bugmake - Bugs: bug #48970, unclear which prerequisites...

 
 

bug #48970: unclear which prerequisites included in $? for intermediate targets

Submitted by:  Sam Fok <fragapanagos>
Submitted on:  Thu Sep 1 19:22:48 2016  
 
Severity: 3 - NormalItem Group: Documentation
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: 3.81Operating System: POSIX-Based
Fixed Release: NoneTriage Status: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu Sep 1 19:22:48 2016, original submission:

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}

foo%.in:
touch foo$*.in

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

.PHONY: all clean
.INTERMEDIATE: ${LIST}

------------------------------

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.
Makefile
$ 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.

Sam Fok <fragapanagos>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by fragapanagos (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1