help-make
[Top][All Lists]
Advanced

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

Re: Help needed on writing rules


From: Fergus Henderson
Subject: Re: Help needed on writing rules
Date: Tue, 13 Feb 2001 18:42:14 +1100

On 12-Feb-2001, Thomas Chen <address@hidden> wrote:
> I don't know how to write a single rule for all of them. What I can do
> is:
> 
> LIST = a b c
> 
> ${LIST} : %_1 : %
>       echo "$* 1"
> ${LIST} : %_2 : %
>       echo "$* 2"
> 
> Is there any way to put them together?  There are also "d,e,f .." and
> "3, 4, 5 ..." in my real situation.

You can generate the Makefile rules automatically:

        LIST1 = a b c d
        LIST2 = 1 2 3 4

        Rules : Makefile
                for x in $(LIST2); do \
                        echo "$(LIST1:%=%_$$x) : %_$$x : %"; \
                        echo '  echo $$* "'"$$x"'"'; \
                done > Rules

        include Rules

You might also want a target for creating everything:

        ALL := $(shell for x in $(LIST1); do for y in $(LIST2); do \
                echo $${x}_$${y}; done; done)

        all : $(ALL)

And your original Makefile didn't specify how to create `a', `b', etc.,
so you may want to fill in some rules for them:
 
        $(LIST1) : ...
                ...

-- 
Fergus Henderson <address@hidden>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.



reply via email to

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