[Top][All Lists]

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

[bug #48970] unclear which prerequisites included in $? for intermediate

From: Sam Fok
Subject: [bug #48970] unclear which prerequisites included in $? for intermediate targets
Date: Thu, 1 Sep 2016 19:22:51 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36


                 Summary: unclear which prerequisites included in $? for
intermediate targets
                 Project: make
            Submitted by: fragapanagos
            Submitted on: Thu 01 Sep 2016 07:22:48 PM GMT
                Severity: 3 - Normal
              Item Group: Documentation
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 3.81
        Operating System: POSIX-Based
           Fixed Release: None
           Triage Status: None



I have the following Makefile with intermediate target ${LIST}.


TGT := tgt
LIST := list

all: ${TGT}

${TGT}: ${LIST}
        touch `cat ${LIST}`
        touch $@

${LIST}: foo1.in foo2.in
        echo $(?:in=out) > ${LIST}

        touch foo$*.in

        rm -f foo*
        rm -f ${LIST}
        rm -f ${TGT}

.PHONY: all clean


When any of ${LIST}'s prerequisite's is newer than ${TGT}, the ${LIST} recipe
is executed. However, if .INTERMEDIATE file ${LIST} does not exist, it is
unclear from the documentation which ${LIST} prerequisite would be included in
${?} in the ${LIST} recipe. Would it be only the prerequisites that were newer
than ${TGT} or all prerequisites because ${LIST} does not exist? The following
shell session illustrates the confusion.

$ ls # to show directory state.
$ make
touch foo1.in
touch foo2.in
echo foo1.out foo2.out > list
touch `cat list`
touch tgt
rm list
$ make # to show that make ran successfully
make: Nothing to be done for `all'.
$ touch foo1.in # update foo1.in to be newer than tgt
$ make
echo foo1.out foo2.out > list
touch `cat list`
touch tgt


Since list's prerequisite foo1.in was newer than tgt, list's recipe was
executed. However, I expected only foo1.in to be included in ${?} because
foo1.in alone was newer than tgt and so foo1.in alone caused list's recipe to
be executed.

On intermediate files, the documentation states that 

The first difference is what happens if the intermediate file does not exist.
If an ordinary file b does not exist, and make considers a target that depends
on b, it invariably creates b and then updates the target from b. But if b is
an intermediate file, then make can leave well enough alone. It won’t bother
updating b, or the ultimate target, unless some prerequisite of b is newer
than that target or there is some other reason to update that target.

There is no mention of which prerequisites of b will be considered to be newer
than b. The documentation for $? also does not mention intermediate targets.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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