help-make
[Top][All Lists]
Advanced

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

$? behavior difference between grouped targets and a multi-target patter


From: Masahiro Yamada
Subject: $? behavior difference between grouped targets and a multi-target pattern rule
Date: Fri, 9 Aug 2024 21:06:28 +0900

Hi.


I have two similar Makefiles.


[Makefile1]

.PHONY: all
all: foo.p foo.q

foo.p foo.q &: foo.r FORCE
        @echo \$$? = $?
        touch foo.p ; touch foo.q

.PHONY: FORCE



[Makefile2]

.PHONY: all
all: foo.p foo.q

%.p %.q : %.r FORCE
        @echo \$$? = $?
        touch foo.p ; touch foo.q

.PHONY: FORCE





The two Makefiles are the same, except for one line.
Makefile1 uses grouped targets.
Makefile2 uses a pattern rule with multiple targets.

My hope is that those two work in the same way.


[test Makefile1]

$ rm -f foo.*
$ touch foo.r
$ touch foo.p
$ make -f Makefile1
$? = foo.r FORCE
touch foo.p ; touch foo.q



[test Makefile2]

$ rm -f foo.*
$ touch foo.r
$ touch foo.p
$ make -f Makefile2
$? = FORCE
touch foo.p ; touch foo.q





The value of $? is different.

I just thought this was fixed by
commit fabb03eac412b5ea19f1a97be31dc8c6fa7fc047

In my opinion, the behavior of Makefile1 is preferred.
Is the behavior of Makefile2 expected?



--
Best Regards
Masahiro Yamada



reply via email to

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