Target specific variables can be complex. Use indirection instead. Make has a lot of syntax for cutting template text. .SECONDEXPANSIONoften good. Sketch:
.SECONDEXPANSION:
${DEBUG_OBJ} ${RELEASE_OBJ}: $$(patsubst %.o,%.c,$${@F})
gcc ${copts-${@D}} -c $< -o $@
Here we say that ./release/a.odepends on a.c. When make decides to build ./release/a.o, it expands the shell line. How it does this is ${@D}natural release, therefore make continues and expands ${copts-release}, which you define with benefit.
Similarly, when created, ./debug/a.omake expands ${copts-debug}.
Rapid deployment $(warning [blah]), $(error [blah blah])and mandatory --warn-undefined-variableswill help you get it right.
source
share