help-make
[Top][All Lists]
Advanced

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

Re: Target-specific CPPFLAGS for autodependencies


From: Paul D. Smith
Subject: Re: Target-specific CPPFLAGS for autodependencies
Date: Wed, 10 May 2006 18:32:49 -0400

%% David Greene <address@hidden> writes:

  dg> I use target-specific variable definitions for things like CFLAGS
  dg> and CPPFLAGS.

  dg> Unfortunately, GNU make's ability to automatically make makefiles
  dg> can't take advantage of this:

  dg> prog: CPPFLAGS = -I/my/include/dir
  dg> prog: file1.o file2.o

  dg> %.d: %.c
  dg>   $(CC) -MM $(CPPFLAGS) $< > $@

  dg> include file1.d file2.d

  dg> Since the rule that makes file.d and file2.d is not invoked
  dg> as a dependency of prog, CPPFLAGS is not set to the correct
  dg> value.

  dg> What's the right way to do this?  I have a number of dependency
  dg> includes which need to use different CPPFLAGS to search different
  dg> header directories.  I'd rather not have to define prog_CPPFLAGS,
  dg> prog2_CPPFLAGS and then do some command magic to use the right
  dg> variable in the $(CC) -MM invocation depending on the value of 
address@hidden

Maybe I can suggest reinterpreting the entire problem?

If you move away from the "traditional" dependency generation method
you're using here (and the one described in the GNU make manual) and
start using the "advanced" dependency generation method described on my
web site below (first created by the automake folks), you will get all
the CPPFLAGS stuff handled for free and won't have to worry about this.

It's good stuff!

-- 
-------------------------------------------------------------------------------
 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




reply via email to

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