On Mon, 2010-02-01 at 22:09 -0600, Peng Yu wrote:
> Suppose that I use the following rule pattern a lot in my makefile,
> where <filename> has to be the same in each block of the three rules.
> <some1> <some2> ... <some_n> can be any files.
> 
> all: <filename>.RData
> 
> clean: <filename>.RData
>       $(RM) $^
> 
> <filename>.RData: <filename>.R <some1> <some2> ... <some_n>
>       Rscript $<

You can use $(eval ...) as long as you can require a new-enough version
of GNU make.


define special-rule
all: $1.RData

clean $1.RData
        $$(RM) $$^

$1.RData: $1.R $2 $3 $4 $5 $6 $7 $8 $9
        Rscript $$<
enddef

$(eval $(call special-rule,xxx,a.txt,b.txt))
$(eval $(call special-rule,uuu,x.txt,y.txt,z.txt))


Note that this has the disadvantage that if you have >8 prerequisites it
will fail.  You can increase this as much as you want but I can't think
of a way, offhand, to make it foolproof.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email protected]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to