[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gmake: how to avoid $$@ usage?
From: |
Paul D. Smith |
Subject: |
Re: gmake: how to avoid $$@ usage? |
Date: |
01 Mar 2005 08:31:24 -0500 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
%% Ernest <ecrvichNOSPAM@NOSPAMfootbag.org> writes:
e> The GNU make manual, section 10.5.3, mentions the use of the
e> SysV-style automatic variables $$@, $$(@D), and $$(@F), and that
e> these "bizarre" uses are not necessary ("there are other ways to
e> accomplish the same results"). How?
e> For example, I need to do some stuff like what's shown below, where
e> the prereq names are determined by a semi-complex manipulation of
e> the target name (it's actually much more complex than this
e> example). This doesn't work, though.
Right, because you're trying to wrap $$@ in a function; that won't work
because while the expansion of $$@ is delayed, the expansion of the
FUNCTIONS are still immediate (before $$@ is expanded).
Without seeing a REAL example of what you're trying to do it's difficult
to determine how much power you need. Typically there are three ways
you work around the need for $$@, etc.:
1) Static pattern rules, for straightforward situations:
target_types = build comp clobber foo bar biz baz boz
$(target_types:%=%_all) : %_all : %
2) Auto-re-exec: you can include a makefile, then provide a rule to
generate that makefile where the rule constructs the complex data.
Since this happens in a shell script you have all the power of the
shell here:
include all_targets.mk
all_targets.mk: Makefile
@echo <stuff> >> $@
4) If you have GNU make 3.80, you can use the $(eval ...) function.
--
-------------------------------------------------------------------------------
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