Hi,
I'm trying to create a Makefile which alters its behaviour depending on
which target is initially used. In the example below 'compile' is the
main compilation target whose behaviour I want to change depending on
whether I invoked make with the target 'cmp' or 'cmpDbg'.
MY_OPT1 and MY_OPT2 are arbitrary options I've created for this example.
MY_OPTS is defined from MY_OPT1 and MY_OPT2 depending on which target is
used during invocation. The Makefile is only ever invoked with the
targets 'cmp' or 'cmpDbg'.
===== Start of Makefile =====
MY_OPT1 = +1
MY_OPT2 = -I/include \
-I/home/include
cmp :
@ if [ ${dbg} = 0 ] ; then \
MY_OPTS="${MY_OPT1} ${MY_OPT2}"; export MY_OPTS; \
echo "Debug Off : dbg = ${dbg}"; \
else \
MY_OPTS="${MY_OPT1} ; \
echo "Debug On : dbg = ${dbg}"; \
fi
echo "Options : ${OPTS}"; \
cmp : dbg = 0
cmp : compile
@ echo "Starting Compile - dbg = ${dbg}"
@ echo "done"
cmpDbg : dbg = 1
cmpDbg : compile
@ echo "Starting Compile - dbg = ${dbg}"
@ echo "done"
===== End of Makefile =====
The problem is the value of MY_OPTS never seems to get set. I suspect
that it is being set in a different shell which I can not access? I've
tried a few experiments but can't seem to get this to work, any
suggestions would be gratefully appreciated.
Thanks,
Gary
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make