help-make
[Top][All Lists]
Advanced

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

Why rules depends on the same target behave differently if the commands


From: Peng Yu
Subject: Why rules depends on the same target behave differently if the commands are different?
Date: Sun, 25 Apr 2010 15:13:16 -0500

Hi,

I have the following two Makefiles. The difference between them are
that the commands are not the same. I don't understand why both rules
are executed in /tmp/double_targets_different_command and why only one
rule (always a, no matter what the order between a and b) is executed
in /tmp/double_targets_same_command. Would you please help me
understand it?

/tmp/double_targets_different_command$ make
a
touch a
b
touch b
/tmp/double_targets_different_command$ cat Makefile
.PHONY: all

all: a b

b: command.sh
        @echo b
        touch b

a: command.sh
        @echo a
        touch a

clean:
        $(RM) a b

/tmp/double_targets_same_command$ make
a
echo 'a' > a; sleep 1; echo 'b' > b
/tmp/double_targets_same_command$ cat Makefile
.PHONY: all

all: a b

b: command.sh
        @echo b
        echo 'a' > a; sleep 1; echo 'b' > b

a: command.sh
        @echo a
        echo 'a' > a; sleep 1; echo 'b' > b

clean:
        $(RM) a b

-- 
Regards,
Peng




reply via email to

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