[makefile] rule with spaces

whired123

Member
Joined
Nov 15, 2021
Messages
151
Reaction score
10
Credits
1,097
Code:
$ cat makefile
default: "a b"

$ touch "a b"

$ make
make: *** No rule to make target '"a', needed by 'default'.  Stop.

Why?
 


Make sees a and b and two separate targets. Double quotes work a little differently in makefiles.

try this...

Code:
default: a\ b

a\ b:
    touch "a b"

Or this...

Code:
FILE = a\ b
default: $(FILE)
$(FILE):
    touch "a b"
 
Make sees a and b and two separate targets. Double quotes work a little differently in makefiles.

try this...

Code:
default: a\ b

a\ b:
    touch "a b"

Or this...

Code:
FILE = a\ b
default: $(FILE)
$(FILE):
    touch "a b"
OK, but
Code:
$ tree
├── a b
└── makefile

$ cat makefile
spaces := $(shell echo "a b")
default: $(spaces)

$ make
make: *** No rule to make target 'a', needed by 'default'.  Stop.
 


Follow Linux.org

Members online


Top