[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: variables-as-targets driving me insane
From: |
Matt.Vandewerken |
Subject: |
RE: variables-as-targets driving me insane |
Date: |
Fri, 1 Oct 2010 14:35:28 +1000 |
I guess as with most things of this nature, "it's a feature, not a bug". I have
worked around the problem by assigning the PLATFORM variable in the make
invokation, ie:
# make PLATFORM=avr avrlib
It works fine now, and is a small price to pay as against the cost of
reengineering my Makefile.
Thanks to all who responded,
Cheers,
--
Matt van de Werken
Electronics Engineer
Mining Geoscience, CSIRO Earth Science and Resource Engineering
1 Technology Ct Pullenvale QLD 4069
P: 07 3327 4142 F: 07 3327 4455 M: 0400 538 608
E: address@hidden
"Those that do not understand UNIX are condemned to reinvent it, poorly"
- Henry Spencer
-----Original Message-----
From: Paul Smith [mailto:address@hidden
Sent: Friday, 1 October 2010 2:32 PM
To: Iwan Aucamp
Cc: Van De Werken, Matt (CESRE, Pullenvale); address@hidden
Subject: Re: variables-as-targets driving me insane
On Fri, 2010-10-01 at 04:41 +0200, Iwan Aucamp wrote:
> On 10/01/2010 02:46 AM, address@hidden wrote:
> > Hi All:
> >
> > I have a problem with my Makefile, where I'm trying to change the
> > destination directory of the objects/output depending on the target
> > selected.
> >
> > Here's the snippet that is giving me grief:
> ...
> > # AVR Static library:
> > avrlib avrtest: PLATFORM=avr
> ...
> > dylib : PLATFORM=osx
> >
> > #Let's make a default PLATFORM:
> > PLATFORM ?= osx
> ...
> > So it seems that the PLATFORM variable is picked up incorrectly
> > early on, but later it is correct.
> Quoted from make manual:
>
> 3.9 How make Reads a Makefile
> GNU make does its work in two distinct phases. During the first
> phase it reads all the make-
> files, included makefiles, etc. and internalizes all the variables
> and their values, implicit and
> explicit rules, and constructs a dependency graph of all the targets
> and their prerequisites.
> During the second phase, make uses these internal structures to
> determine what targets will
> need to be rebuilt and to invoke the rules necessary to do so.
And more directly, from the second paragraph of the section on target-specific
variables:
The other exception is "target-specific variable values". This
feature allows you to define different values for the same variable,
based on the target that `make' is currently building. As with
automatic variables, these values are only available within the context
of a target's recipe (and in other target-specific assignments).
Note the last sentence.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist