[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Variable definition in eval'd function
From: |
John Graham-Cumming |
Subject: |
Re: Variable definition in eval'd function |
Date: |
Wed, 10 Oct 2007 20:40:34 +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
Bryan Ischo wrote:
> The amazing thing is this DOES seem to work as I expected; I end up with
> the following two additional rules:
>
> .PHONY: foo_variable
> foo_variable:
> @echo foo_variable
>
> .PHONY: bar_variable
> bar_variable:
> @echo bar_variable
>
> So it seems that for some reason, variables that are the part of a rule's
> commands are not expanded in the same way as variables that are not part
> of a rule's commands. Is there a reason for this? And, is there a way to
> 'workaround' this behavior, so that I can have the commands of a rule be
> the result of a variable evaluation, as well as the target name and
> dependencies?
That's because $(VARIABLE) is going to be expanded after you've read in
all the Makefiles (because it's inside a rule) and hence it takes the
last value that VARIABLE was set to (which is bar_variable). The best
way to do with will be with a target-specific variable where you do
foo: VARIABLE := foo_variable
and
bar: VARIABLE := bar_variable
John.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHDRyiLphrp73n/hARAgg2AJ9qTU0QEJJJdOLFrvbVYM7166SK1QCguA5F
RfBCh/xtAF/a0SOooqApBss=
=thvD
-----END PGP SIGNATURE-----