[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Setting variables for an included file only
From: |
Paul D. Smith |
Subject: |
Re: Setting variables for an included file only |
Date: |
Wed, 4 Jun 2003 01:50:20 -0400 |
%% Peter Simons <address@hidden> writes:
ps> I want to include several sub-makefiles from my top-level
ps> makefile, but I need to overwrite some of the variables they
ps> define. Unfortunately, I need to overwrite these variables with
ps> different values for each sub-makefile! Since recursive make is
ps> not an option in my case, I wonder whether GNU Make supports a
ps> construct like this:
ps> | foo/GNUmakefile: CPPFLAGS=-I/somewhere
ps> | bar/GNUmakefile: CPPFLAGS=-I/elsewhere
ps> |
ps> | include foo/GNUmakefile bar/GNUmakefile
No, nothing like that is supported. Why not just do:
CPPFLAGS = -I/somewhere
include foo/GNUmakefile
CPPFLAGS = -I/elsewhere
include bar/GNUmakefile
Of course, if what you really meant was for all targets defined in the
given makefiles to somehow magically have those values set, then of
course the above won't do that. You'd have to do something like:
include foo/GNUmakefile
$(TARGETS) : CPPFLAGS = -I/somewhere
include bar/GNUmakefile
$(TARGETS) : CPPFLAGS = -I/somewhere
Then in foo/GNUmakefile:
TARGETS = foo foobiz foobaz
and in bar/GNUmakefile:
TARGETS = bar barbiz barbaz
ps> I know I can specify per-target variables in newer makes, but can
ps> I somehow specify an per-include variable as well?
No, definitely not.
ps> If not, would it be very difficult to add this feature?
Yes.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist