help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variables-as-targets driving me insane


From: Paul Smith
Subject: Re: variables-as-targets driving me insane
Date: Fri, 01 Oct 2010 00:32:27 -0400

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]