On Mon, Nov 14, 2011 at 4:39 PM, Marc Smith <marc.sm...@mcc.edu> wrote: ... > Gotcha, I'm not trying to be difficult, just wrapping my head around this. =) > So, something like this should yield different values: > > --snip-- > blah := $(shell date) > blah2 = $(shell date) > > all: > @ echo $(blah) > @ sleep 10 > @ echo $(blah2) > --snip-- > > Right?
No. That will expand 'blah' immediately, then expand all the lines in the rules for all (thus expanding 'blah2') then run those commands, including the sleep. So blah2 will *not* be expand after the sleep. What I don't understand is why you're using $(shell) there. What's so hard about just running 'date' in the commands? Capture the time of the start of the reading of the makefile with an immediate shell variable, then run date directly for the final time: start_time := $(shell date) all: @echo ${start_time} @sleep 10 @date > Is there another way to use the same variable and have the shell > function execute each time the variable is used in a makefile? No. The commands in rules are run by the shell; use the shell! Make variables are not the only hammer in your toolbox, or shouldn't be. Philip Guenther _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make