2

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.