help-make
[Top][All Lists]
Advanced

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

variable parameter list


From: Warlich, Christof
Subject: variable parameter list
Date: Wed, 10 Nov 2010 14:55:36 +0100

Hi,

consider this makefile:

.PHONY: all
all: sorted.tgt header.tgt reverse.tgt footer.tgt
# The lines below are supposed to do this:
#sorted.tgt: list1.lst list2.lst
# cat $^ | sort >$@
#header.tgt: list1.lst list2.lst list3.lst
# cat $^ | head >$@
#reverse.tgt: list1.lst
# cat $^ | tac >$@
#footer.tgt: list1.lst list2.lst list3.lst list4.lst list5.lst list6.lst 
list7.lst list8.lst
# cat $^ | tac >$@
define FILTER_RULE
${2}: ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10}
 cat $$^ | ${1} >$$@
endef
$(eval $(call FILTER_RULE, sort, sorted.tgt, list1.lst, list2.lst))
$(eval $(call FILTER_RULE, head -n1, header.tgt, list1.lst, list2.lst, 
list3.lst))
$(eval $(call FILTER_RULE, tac, reverse.tgt, list1.lst))
$(eval $(call FILTER_RULE, tail -n1, footer.tgt, list1.lst, list2.lst, 
list3.lst, list4.lst, list5.lst, list6.lst, list7.lst, list8.lst))

Is there a way to pass an arbitrary number of positional parameters to my 
FILTER_RULE function?
I certainly could add ${11} ${12} ... to the dependency list, but that doesn't 
exatly look elegant. Is there
a better, i.e. more general way to do this? I think that foreach could be my 
friend, but I just don't
know how to get hold of the entire list of positional parameters.

Thanks for any help,

Christof




reply via email to

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