[Top][All Lists]

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

Re: possible bug in documentation for make

From: Philip Guenther
Subject: Re: possible bug in documentation for make
Date: Sat, 25 Oct 2008 15:04:25 -0700

On Sat, Oct 25, 2008 at 1:42 PM, Daniela Rütting <address@hidden> wrote:
> 1st problem: In an attempt to reduce tedious typing when defining a variable 
> from
> the command line, I tried:
> ifeq (max,$(O))
> O = -O3 -fomit-frame-pointer -fno-unroll-loops
> endif
> ifeq (,$(O))
> O = -O
> endif
> CXXFLAGS = -W -Wall $(O)
> but this didn t work. After typing  make O=max  the value  max  was passed 
> straight
> to the compiler instead of being changed to  -O3 -fomit-frame-pointer 
> -fno-unroll-loops.
> I had to use the more complex sequence
> ifeq (max,$(O))
> OPTIM = -O3 -fomit-frame-pointer -fno-unroll-loops
> endif
> ifeq (,$(O))
> OPTIM = -O
> endif
> ifndef OPTIM
> OPTIM = $(O)
> endif
> CXXFLAGS = -W -Wall $(OPTIM)
> It seems as if it is not possible to change the value of a variable inside an 
>  ifeq
> conditional that test against that very variable, but I wasn t told in the 
> documentation.

This has nothing to do with the conditionals and everything to do with
mixing command-line and makefile assignments.  To quote section 9.5
"Overriding Variables" of the make 3.81 manual:
An argument that contains `=' specifies the value of a variable: `V=X'
sets the value of the variable V to X.  If you specify a value in this
way, all ordinary assignments of the same variable in the makefile are
ignored; we say they have been "overridden" by the command line
   There is one way that the makefile can change a variable that you
have overridden.  This is to use the `override' directive, which is a
line that looks like this: `override VARIABLE = VALUE' (*note The
`override' Directive: Override Directive.).

Indeed, if you use 'override' in your makefile, then it works as you expect.

> I refer to: Edition 0.55, last updated 04 April 2000, of `The GNU Make 
> Manual', for
> `make', Version 3.79.
> I use: GNU Make version 3.79.1, Built for i386-pc-msdosdjgpp
> (not the newest version, I presume, but maybe no one mentioned the problem 
> yet?)

So you're using a version of make that has been obsolete for *6
years*, but haven't checked the new manual?  (3.80 was released on
2002-10-03; 3.81 on 2006-04-01)

Philip Guenther

reply via email to

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