bug-make
[Top][All Lists]
Advanced

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

Why is $? affected by .SECONDARY ?


From: Masahiro Yamada
Subject: Why is $? affected by .SECONDARY ?
Date: Sun, 13 Jan 2019 11:19:16 +0900

Hi.

I have a question about $? behavior.
The manual says:

  $?
      The names of all the prerequisites that are newer than the target,
      with spaces between them.


It does not explicitly explain about non-existing prerequisites,
but Paul explained the change in GNU Make 3.81 as follows:

http://lists.gnu.org/archive/html/bug-make/2006-03/msg00003.html


So, non-existing prerequisites are included in $?
and I agree this is the right thing to do.


However, I noticed the behavior is changed
when prerequisites are marked as .SECONDARY.




[Test Code 1]
------------------>8---------------
foo: bar FORCE
        @echo newer prerequisites are: $?

bar:

.PHONY: FORCE
------------------>8---------------

 Result:

$ touch foo; make
newer prerequisites are: bar FORCE


Good.
$? correctly contains 'bar' and 'FORCE'.

This is what we expect
because 'bar' and 'FORCE' do not exist.


If you add .SECONDARY:,
the behavior is different.



[Test Code 2]
------------------>8---------------
foo: bar FORCE
        @echo newer prerequisites are: $?

bar:

.PHONY: FORCE

.SECONDARY:
------------------>8---------------

 Result:

$ touch foo; make
newer prerequisites are:



Oh.
$? does not include 'bar' and 'FORCE' any more
despite they do not exist.


Why is $? affected by the .SECONDARY special target?

Is this intentional?



-- 
Best Regards
Masahiro Yamada



reply via email to

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