bug-make
[Top][All Lists]
Advanced

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

Re: Multiple rules for one target (wildcard related)


From: Paul Smith
Subject: Re: Multiple rules for one target (wildcard related)
Date: Mon, 03 May 2010 08:35:15 -0400

On Mon, 2010-05-03 at 09:13 +0200, Håkan Kvist wrote:
> Hi.
> 
> This problem is found with GNU Make 3.81, on Ubuntu GNU/Linux 8.10
> x86.
> 
> 4.11 Multiple Rules for One Target
> One file can be the target of several rules. All the prerequisites
> mentioned in all the rules are merged into one list of prerequisites
> for the target. If the target is older than any prerequisite from any
> rule, the commands are executed.

This only applies to normal rules, not to pattern rules.

Look at the section in the GNU make manual on pattern rules to see what
it means to have a pattern rule with no prerequisites: it's something
very different.

> all: $(patsubst %.in,%.out,$(wildcard *.in))
> 
> %.out: executable
> %.out: %.in
>        @echo prerequisite: $^
>        test -f executable || exit 1
> 
> executable:
>       sleep 20
>       touch $@

You could do this:

        TARGETS := $(patsubst %.in,%.out,$(wildcard *.in))
        
        all: $(TARGETS)
        
        $(TARGETS): executable
        
        %.out: %.in
                ...etc...

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          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





reply via email to

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