CPPFLAGS+= in Makefile.target
PATCH 1/1 CPPFLAGS+= in Makefile.target
Saying CPPFLAGS+= is much more convenient if for any reason the external build environment would like to pass unusual CPPFLAGS.
Regards,
Ian.
Index: Makefile.target
===================================================================
RCS file: /sources/qemu/qemu/Makefile.target,v
retrieving revision 1.240
Makefile.target +1 -1
@@ -24,7 +24,7 @@ endif TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH) VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw -CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MP -DNEED_CPU_H +CPPFLAGS+=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MP -DNEED_CPU_H ifdef CONFIG_DARWIN_USER VPATH+=:$(SRC_PATH)/darwin-user CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
Quoted 2 lines
Saying CPPFLAGS+= is much more convenient if for any reason the external build environment would like to pass unusual CPPFLAGS.
No. This doesn't do what you thing it does.
The most common way of overriding these variables is to pass them on the commandline, i.e. "make CPPFLAGS=-blah". This overrides all assignments to that variable including +=.
Paul
Paul Brook writes ("Re: [Qemu-devel] [PATCH] CPPFLAGS+= in Makefile.target"):
Quoted 4 lines
No. This doesn't do what you thing it does.
The most common way of overriding these variables is to pass them on the commandline, i.e. "make CPPFLAGS=-blah". This overrides all assignments to that variable including +=.
Err, yes (and this is annoying behaviour in make), but if Makefile.target sets CPPFLAGS=-I... then even config.mak cannot override it.
Ian.
iwj writes ("Re: [Qemu-devel] [PATCH] CPPFLAGS+= in Makefile.target"):
Quoted 9 lines
Paul Brook writes ("Re: [Qemu-devel] [PATCH] CPPFLAGS+= in Makefile.target"):
Quoted 4 lines
No. This doesn't do what you thing it does.
The most common way of overriding these variables is to pass them on the commandline, i.e. "make CPPFLAGS=-blah". This overrides all assignments to that variable including +=.Err, yes (and this is annoying behaviour in make), but if Makefile.target sets CPPFLAGS=-I... then even config.mak cannot override it.
Sorry, perhaps that was less than clear. What I mean is: if you want for any reason to build qemu in a weird way then you're going to have to edit config-host.mak (or somewhere similar) in any case. You probably want to set some CPPFLAGS as well as various other things. If you do this at the moment then you have to reproduce all of the CPPFLAGS -I settings and so on from Makefile.target in your own setting that you add to config-host.mak.
With my change this is no longer needed: if you set CPPFLAGS in config-host.mak or some target's config.mak then the right -I's are automatically added later.
Ian.
Quoted 7 lines
What I mean is: if you want
for any reason to build qemu in a weird way then you're going to have to edit config-host.mak (or somewhere similar) in any case. You probably want to set some CPPFLAGS as well as various other things. If you do this at the moment then you have to reproduce all of the CPPFLAGS -I settings and so on from Makefile.target in your own setting that you add to config-host.mak.
In that case you should always provide a definition in config-host.mak. Under some circumstances make may inherit initial values from elsewhere. The rules for make variables are sufficiently twisty that it's best to be explicit, rather than allowing a subset of the ways of defining that variable.
Paul
Paul Brook writes ("Re: [Qemu-devel] [PATCH] CPPFLAGS+= in Makefile.target"):
Quoted 2 lines
In that case you should always provide a definition in config-host.mak. Under some circumstances make may inherit initial values from elsewhere.
What circumstances ? CPPFLAGS+= overrides (discards) values in the environment as well as ones from the command line.
Providing a definition in config-host.mak involves duplicating the value, which can't be right. If there's no other way to do it then there should be a reference to USER_CPPFLAGS or some such but frankly that's a pain and overkill.
Ian.
Quoted 1 line · Ian Jackson
Paul Brook writes ("Re: [Qemu-devel] [PATCH] CPPFLAGS+= in
Makefile.target"):
Quoted 5 lines
Quoted 2 lines
In that case you should always provide a definition in config-host.mak. Under some circumstances make may inherit initial values from elsewhere.
What circumstances ? CPPFLAGS+= overrides (discards) values in the environment as well as ones from the command line.
$ cat Makefile
FOO += World
all:
@echo "$(FOO)"
$ FOO=Hello make
Hello WorldPaul Brook writes ("Re: [Qemu-devel] [PATCH] CPPFLAGS+= in Makefile.target"):
Quoted 5 lines · Ian Jackson
Quoted 2 lines
What circumstances ? CPPFLAGS+= overrides (discards) values in the environment as well as ones from the command line.
[ demonstration ]
Oh, err, looks like I messed up in my own test. I see what you mean. We don't want the top-level's CPPFLAGS turning up there.
Still, there ought to be a way to introduce extra compiler options that doesn't involve duplicating the ones which are essential to find qemu's own includes etc.
Ian.
Quoted 2 lines
Providing a definition in config-host.mak involves duplicating the value, which can't be right.
Huh? No it doesn't. config-host.mak contains
CPPFLAGS=
then Makefile.target contains
CPPFLAGS+=whatever
Quoted 3 lines
If there's no other way to do it then
there should be a reference toUSER_CPPFLAGSor some such but frankly that's a pain and overkill.
Why don't you just put your custom flags in CFLAGS, not CPPFLAGS? The former is deliberately left for the user to override.
Paul
Paul Brook writes ("Re: [Qemu-devel] [PATCH] CPPFLAGS+= in Makefile.target"):
Quoted 4 lines
Huh? No it doesn't. config-host.mak contains
CPPFLAGS=
then Makefile.target contains
CPPFLAGS+=whatever
It doesn't seem to on my build.
Quoted 2 lines
Why don't you just put your custom flags in CFLAGS, not CPPFLAGS? The former is deliberately left for the user to override.
Several (but not all AFAICT) of the target subdirectory Makefiles set CFLAGS.
Anyway, I think you're right that I should go away and think about this some more. Sorry for the inconvenience.
Ian.
Quoted 5 lines
Quoted 2 lines
Why don't you just put your custom flags in CFLAGS, not CPPFLAGS? The former is deliberately left for the user to override.
Several (but not all AFAICT) of the target subdirectory Makefiles set CFLAGS.
Really? Which ones?
Paul
Paul Brook writes ("Re: [Qemu-devel] [PATCH] CPPFLAGS+= in Makefile.target"):
Quoted 1 line
Really? Which ones?
tests/Makefile and tests/cris/Makefile do. Not that they're particularly important. I also saw Makefile.target's if'd out change to CFLAGS near at the bottom by the audio .o's, but of course that's not really relevant.
Ian.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Paul Brook
Saying CPPFLAGS+= is much more convenient if for any reason the external build environment would like to pass unusual CPPFLAGS.
Paul> No. This doesn't do what you thing it does. The most common way Paul> of overriding these variables is to pass them on the Paul> commandline, i.e. "make CPPFLAGS=-blah". This overrides all Paul> assignments to that variable including +=.
By the way, it is possible to improve the GNU make weirdness :-) by playing with stuff like:
override CFLAGS += -g
Cf section 6.7 of the documentation.
Hmmm... GNU make evolves more rapidly than my brain... :-)
Signature · 5 lines
Ronan KERYELL |\/ Tel: (+33|0) 2.29.00.14.15 Département Informatique |/) Fax: (+33|0) 2.29.00.12.82 TÉLÉCOM Bretagne, CS 83818 K GSM: (+33|0) 6.13.14.37.66 F-29238 PLOUZANÉ CEDEX 3 |\ E-mail: [email protected] FRANCE | \ http://enstb.org/~keryell
Quoted 10 lines · Ronan Keryell
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line · Paul Brook
Saying CPPFLAGS+= is much more convenient if for any reason the external build environment would like to pass unusual CPPFLAGS.
Paul> No. This doesn't do what you thing it does. The most common way Paul> of overriding these variables is to pass them on the Paul> commandline, i.e. "make CPPFLAGS=-blah". This overrides all Paul> assignments to that variable including +=.
Quoted 6 lines
By the way, it is possible to improve the GNU make weirdness :-) by playing with stuff like:
override CFLAGS += -g
Cf section 6.7 of the documentation.
IIRC the documentation warns against careless use of overrides.
Quoted 1 line
Hmmm... GNU make evolves more rapidly than my brain... :-)
It's only a decade old or so. :-)
Thiemo