Reputation: 21615
I have a makefile and I pass a parameter to it through command line. Say I pass parameter for clock frequency such as this.
make run FREQ=500
In my makefile, I want to include the value of FREQ inside a string, for example, I want to expand it like this.
RUN_FLG = "--frequency = 500"
I know you can use $(FREQ) if you are using that parameter normally (not inside strings), but how do you expand it inside a string?
Upvotes: 1
Views: 161
Reputation: 19805
Just use $(value)
Example:
freq = 500
x = "--frequency = $(freq)"
run:
@$(/bin/echo -e) $(x)
Output of make -n
:
"--frequency = 500"
Upvotes: 1
Reputation: 753705
make
doesn't know what a string is; you embed the macro reference into the string the same as outside a string:
DEFAULT_FREQ = 60
FREQ = $(DEFAULT_FREQ)
RUN_FLG = "--frequency=$(FREQ)"
I've 'corrected' the spacing in the --frequency
; you would not normally have the =
separate from the option text, and the value would also follow without spaces.
I've provided a default value for FREQ inside the makefile
so that if it is invoked without any FREQ=500
override, you still have the default value as part of $(RUN_FLG)
.
Upvotes: 1