help-gnu-utils
[Top][All Lists]
Advanced

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

Re: make question (target dependent variable)


From: Paul D. Smith
Subject: Re: make question (target dependent variable)
Date: 13 Jan 2006 17:46:45 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

%% "James" <hslee@ind.alcatel.com> writes:

  j> Thanks. This seesm to work as well.

  j> CFLAGS = -c
  j> CFLAGS += $(shell [ $(foreach f,$(P),$(filter $(f),$@)) ] && echo -g)

Well... yeah.  But... ugh! :-|

You're invoking that shell EVERY TIME you evaluate CFLAGS; and I mean
_in addition to_ the shell that's actually doing the echo.

If you're going to do this you might as well use make's builtin $(if
...)  function instead of calling out to the shell:

    CFLAGS += $(if $(filter $@,$(P)),-g)

Note that (a) you don't need the foreach even the way you wrote it
originally because filter tests _each_ of its arguments against each of
the possibilities; there can be more than one, and (b) if you swap them
(since $@ is only one item) you'll get better performance.


If it were me, I'd still probably use target-specific variables rather
than something like the above.  Seems cleaner to me.

But, either of these is better than using $(shell ...), IMO.

Cheers!

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@gnu.org>          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]