bug-make
[Top][All Lists]
Advanced

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

Override... but not really


From: Philip Prindeville
Subject: Override... but not really
Date: Mon, 09 Aug 2010 10:00:36 -0700
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.7) Gecko/20100713 Thunderbird/3.1.1

 Is this expected behavior?

$ cat makefile1
override CFLAGS+=-DB

$(info makefile1: CFLAGS=$(CFLAGS))

all:
        make -f makefile2
$ cat makefile2

$(info makefile2: CFLAGS=$(CFLAGS))

override CFLAGS+=-DC

$(info makefile2: CFLAGS=$(CFLAGS))

all:
        @echo foo
$ make -f makefile1 CFLAGS=-DA
makefile1: CFLAGS=-DA -DB
make -f makefile2
makefile2: CFLAGS=-DA
makefile2: CFLAGS=-DA -DC
foo
$


So why isn't the CFLAGS that gets passed to the submake set to "-DA -DB"?

This is less than intuitive: it's not *really* overriding if it's only 
semi-persistent.

What's even more confusing is that make apparently keeps two copies...  the one 
that's in-scope for the current make, and the one that gets re-exported into 
sub-makes.

I couldn't find in the documentation where this behavior gets called out.

-Philip





reply via email to

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