bug-make
[Top][All Lists]
Advanced

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

Multiple rules for one target (wildcard related)


From: Håkan Kvist
Subject: Multiple rules for one target (wildcard related)
Date: Mon, 3 May 2010 09:13:04 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

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 does not seem to work properly (atleast when wildcards are
involved).


The makefile below describes the problem:

---------------------------------------------
# Prerequisites: Create a couple of in-files
# using touch before running this makefile.
#
# The prerequisite executable is not built
# before the %.out rule is executed.

all: $(patsubst %.in,%.out,$(wildcard *.in))

%.out: executable
%.out: %.in
       @echo prerequisite: $^
       test -f executable || exit 1

executable:
        sleep 20
        touch $@
---------------------------------------------

The output from this makefile will be:

prerequisite: 01.in
test -f executable || exit 1
make: *** [01.out] Error 1


However, if I change the lines:
%.out: executable
%.out: %.in

to:
%.out: %.in executable

The output will look like this:
sleep 20
touch executable
prerequisite: 01.in executable
test -f executable || exit 1
prerequisite: 02.in executable
test -f executable || exit 1
prerequisite: 03.in executable
test -f executable || exit 1
prerequisite: 04.in executable
test -f executable || exit 1
prerequisite: 05.in executable
test -f executable || exit 1
prerequisite: 06.in executable
test -f executable || exit 1
prerequisite: 07.in executable



br
Håkan





reply via email to

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