[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gmake: implicit rule help
From: |
Paul D. Smith |
Subject: |
Re: gmake: implicit rule help |
Date: |
22 Mar 2005 14:05:35 -0500 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
%% Ernest <ecrvichNOSPAM@NOSPAMfootbag.org> writes:
e> One of the custom rules I'm writing involves the .c -> .o kind of
e> transformation, but the command script (semi-complex,
e> multi-platform, etc.) needs to be the same for all source suffix
e> types. How do I write the equivalent of this...
e> ${WORKDIR}/%${OBJ_SUFF} : <all possible C/C++ source types>
e> cmd1
e> cmd2
e> ...
The only way to do it is by writing the rule multiple times, once for
each prerequisite. You can make this slightly more palatable by using a
define variable:
define BUILDOBJ
cmd1
cmd2
...
endef
${WORKDIR}/%${OBJ_SUFF} : %.c
$(BUILDOBJ)
${WORKDIR}/%${OBJ_SUFF} : %.cc
$(BUILDOBJ)
${WORKDIR}/%${OBJ_SUFF} : %.cpp
$(BUILDOBJ)
${WORKDIR}/%${OBJ_SUFF} : %.C
$(BUILDOBJ)
If you REALLY don't want to do that and you are willing to restrict
yourself to GNU make 3.80 or better, you can use eval to do it.
--
-------------------------------------------------------------------------------
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