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: [email protected] "Those that do not understand UNIX are condemned to reinvent it, poorly" - Henry Spencer -----Original Message----- From: Paul Smith [mailto:[email protected]] Sent: Friday, 1 October 2010 2:32 PM To: Iwan Aucamp Cc: Van De Werken, Matt (CESRE, Pullenvale); [email protected] 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, [email protected] 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 <[email protected]> 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 _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
