Hi Paul, Thank you very much for your quick reply! I will try out both of these methods first thing tomorrow at work.
-Phil Paul Smith-20 wrote: > > On Thu, 2009-02-19 at 19:42 -0800, pip9ball wrote: > >> I'm looking for a way to export/set an environment variable while I'm >> inside >> a target. >> >> test1: >> export CURRENT_TARGET = $@ >> @printenv | grep CURRENT_TARGET >> >> Is this possible? > > Each line of a recipe is invoked inside a different shell. If you want > to set an environment variable inside the recipe, you have to put the > command on the same line. For example: > > test1: > CURRENT_TARGET='$@' env | grep CURRENT_TARGET > > Note that your syntax above is wrong in two ways: first, shell variable > assignments cannot have whitespace around the "=", and second the > "export VAR=VAL" form is not portable; since make always runs recipes > using /bin/sh you should use only portable shell constructs. > > Another alternative for GNU make is to use its export keyword, like > this: > > CURRENT_TARGET = $@ > export CURRENT_TARGET > test1: > env | grep CURRENT_TARGET > > Because you are using "=" and not ":=", the variable won't be expanded > until the recipe is about to be run, by which time "$@" will be set > properly. > > -- > ------------------------------------------------------------------------------- > Paul D. Smith <[email protected]> Find some GNU make tips at: > http://www.gnu.org http://make.mad-scientist.us > "Please remain calm...I may be mad, but I am a professional." --Mad > Scientist > > > _______________________________________________ > Help-make mailing list > [email protected] > http://lists.gnu.org/mailman/listinfo/help-make > > -- View this message in context: http://www.nabble.com/Setting-an-environment-variable-while-inside-a-target-tp22114339p22115042.html Sent from the Gnu - Make - Help mailing list archive at Nabble.com. _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
