Equal sign in Makefile target

Viewed 102

Is there a good way to have equal signs in the target name of a Makefile?

If I write a Makefile like

test=file:
    touch test=file

I get

Makefile:2: *** recipe commences before first target.  Stop.

The only way I've found to get around that is to do

NAME = test=file

$(NAME):
    touch test=file

which works, but it would be a bit cumbersome to define a variable for every filename. Is there a better way to do this, by quoting/escaping the = directly?

1 Answers

There is no other way than using a variable to hide the =. Of course you don't have to put the entire filename in the variable you can just use:

EQ = =
test$(EQ)file: ; touch $@

Or, if you put it into a single-letter variable you don't need the ():

E = =
test$Efile: ; touch $@

if you prefer.

Related