I'm trying to create a makefile that has rule something like:
~/$ cat >开发者_开发技巧; Makefile << EOF
FILES=a b c
$(FILES): % : src/%/%
@echo "$@ $<"
EOF
Running the command gives:
~/$ make a
make: *** No rule to make target `src/a/%', needed by `a'. Stop.
And what I'd like to see is:
~/$ make a
a src/a/a
How do a create rule to expand the second %
?
In this case,
secondary expansion
might help.
For example:
FILES=a b c
.SECONDEXPANSION:
$(FILES): % : src/$$*/$$*
@echo "$@ $<"
If your GNU make's version is 3.80 or lower, $*
might not work.
In that case, $@
and some text manipulation might be needed instead.
精彩评论