help-make
[Top][All Lists]
Advanced

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

Re: Automatically generate rules from a list variable


From: Paul Smith
Subject: Re: Automatically generate rules from a list variable
Date: Fri, 24 Oct 2008 11:51:41 -0400

On Fri, 2008-10-24 at 18:45 +0300, Andrei Deftu wrote:
> I have the following scenario
> 
> LIST := file1.cpp file2.cpp file3.cpp
> 
> and I want to generate these rules
> 
> file1.cpp_o: file1.cpp
>        # bla bla
> file2.cpp_o: file1.cpp
>        # bla bla
> file2.cpp_o: file1.cpp
>        # bla bla
> 
> but I want to write only a single rule for this, like:
> $(LIST:%=%_o): $(@:%_o=%)
>        # bla bla
> 
> The problem is that this is not valid

Yes.  See the GNU make manual chapter "how make reads a makefile" to
understand this.  It's a fundamental, critical aspect of make and
makefiles that you MUST understand, or you will never "get" makefiles.

> and I don't know how to write a rule for a list that expands to a rule
> for every element of the list and each of this rule must have as a
> target and as a dependency the current element of the list. Thanks.

Why can't youjust use a normal pattern rule?  Something like:

        %.cpp_o : %.cpp
                # bla bla

?






reply via email to

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