|
From: | John Graham-Cumming |
Subject: | Re: Setting Variables depending on target being made |
Date: | Wed, 04 Jun 2008 15:13:59 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208 Thunderbird/0.5 Mnenhy/0.6.0.104 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gary Hall wrote: | 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}"; \ That's not going to work for two reasons: 1. You are setting MY_OPTS in the commands for cmp which does nothing to change the value of MY_OPTS inside GNU Make: here you are just setting a shell variable 2. Even if it did set MY_OPTS in the Makefile this still wouldn't work because the commands for cmp would be run after all the other commands in the Makefile (since cmp is the goal). You have the same problem with the commands for cmp and cmpDbg which get run after the rest of the build but attempt to output "Starting Compile...". The right solution is to set MY_OPTS as a target-specific variable based on the goal: MY_OPT1 := +1 MY_OPT2 := -I/include -I/home/include MY_OPTS := $(MY_OPT1) cmp : compile cmpDbg : MY_OPTS += $(MY_OPT2) cmpDbg : compile John. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIRpUXLphrp73n/hARAtmMAKCF7x8dVAw0hDGOxHc4DXQl3JVyTACfRcO+ pKJlTmFaRVamLHYWX0qLaIc= =aOdX -----END PGP SIGNATURE-----
[Prev in Thread] | Current Thread | [Next in Thread] |