Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000763 [1003.1(2008)/Issue 7] Shell and Utilities Editorial Clarification Requested 2013-10-10 02:18 2019-06-10 08:55
Reporter dwheeler View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Closed  
Name David A. Wheeler
Organization
User Reference
Section make
Page Number 2911
Line Number 95628-95636
Interp Status ---
Final Accepted Text See Note: 0001949.
Summary 0000763: If rule has no prerequisites or commands, and target is non-existent, imagine it's been updated
Description Many people want to have "make" dependencies automatically generated. However, many tools and approaches (such as automake) that do this depend on a poorly-documented interpretation of make's specification. I'd like to see this interpretation clarified and clearly stated.

As explained in "Advanced Auto-Dependency Generation" (http://mad-scientist.net/make/autodep.html), [^] it's common to create a "dependency" file for each source file that contains the dependency statement for the target. This normally works, but it creates a serious problem when done the obvious way: "if you remove or rename a prerequisite file (say a C .h file), make will stop with a fatal error, complaining that the target doesn't exist".

Tom Tromey found a solution, which appears to be the approach used by automake. IF you mention the file as a target in the makefile with no commands and no prerequisites, then if the file doesn't exist, make is supposed to silently pretend it was recreated. The same approach is recommended here: http://scottmcpeak.com/autodepend/autodepend.html [^] (and probably many other places).

This solution works in GNU make, and I suspect it works in many makes. However, this solution assumes a particular interpretation of the rules in make's "EXTENDED DESCRIPTION" that is not immediately obvious from the POSIX text (at best).

I'd like to see this stated clearly, so that it can be relied on by systems that automatically generate dependencies.
Desired Action After "If there are no commands listed for the target, the target shall be treated as up-to-date." append the following:

"If a target has no prerequisites or commands, and the target of the rule is a nonexistent file, then `make' imagines this target to have been updated whenever its rule is run. This implies that all targets depending on this one will always have their commands run."

(Note that this text is similar to the GNU make section 4.7 text:
http://www.gnu.org/software/make/manual/html_node/Force-Targets.html). [^]

Tags tc2-2008
Attached Files

- Relationships
related to 0000857Closed 1003.1(2013)/Issue7+TC1 Make rules which do not create the target file or do unexpected things with its timestamp 

-  Notes
(0001949)
Don Cragun (manager)
2013-10-31 16:22
edited on: 2013-11-07 16:27

This issue was reopened and discussed during the November 7, 2013 conference call. This note has been updated to address the changed resolution. The standard was already clear on the requirements, but a note is being added to the application usage to serve as a hint for people who might have missed the normative requirement:

Add to the end of the APPLICATION USAGE (p2922 L96124, or in the 2013 edition P2948 L97603):
As a consequence of the general rules for target updating, a useful special case is that if a target has no prerequisites and no commands, and the target of the rule is a nonexistent file, then make acts as if this target has been updated whenever its rule is run. (Note: This implies that all targets depending on this one will always have their commands run.)


(0001964)
geoffclare (manager)
2013-11-07 09:35

I'm reopening the bug, based on this input from Konrad Schwarz ...

The proposed addition is:
        If a target has no prerequisites or commands, and the target of
        the rule is a nonexistent file, then make shall act as if this target
        has been updated whenever its rule is run. (Note: This implies that
        all targets depending on this one will always have their commands
        run.)

However, make always acts if the target has been updated whenever its rule is run,
irrespective of whether it has prerequisites, commands, or does or does not exist.
This immediately follows from the first two paragraphs of the Extended Description:

        The make utility attempts to perform the actions required to ensure that the
        specified targets are up-to-date. A target is considered out-of-date if it is
        older than any of its prerequisites or if it does not exist. The make
        shall treat all prerequisites as targets themselves and recursively ensure that
        they are up-to-date, processing them in the order in which they appear in the
        rule. The make utility shall use the modification times of files to determine
        whether the corresponding targets are out-of-date.

        After make has ensured that all of the prerequisites of a target are up-to-date
        and if the target is out-of-date, the commands associated with the target entry
        shall be executed. If there are no commands listed for the target, the target shall
        be treated as up-to-date.

Target does not exist -> it is out-of-date.
Target has no prerequisites -> no further targets need to be examined.
Target has no commands -> the target is treated as up to date.
(Target is up to date -> targets depending on this one need to be updated.)

The proposed addition makes it sound like non-existent targets without prerequisites or
commands receive special treatment, whereas in fact they don't.
(0001965)
shware_systems (reporter)
2013-11-07 11:45

I dunno... maybe some makes were treating "not exist" as out-of-date, and since no prerequisites weren't bothering to check if any commands or not to override the out-of-date. The language should probably be:

Change:
        The make utility attempts to perform the actions required to ensure that the
        specified targets are up-to-date. A target is considered out-of-date if it is
        older than any of its prerequisites or if it does not exist.
To:
        The make utility attempts to perform the actions required to ensure that the
        specified targets are up-to-date. An existing target file is considered out-of-date if it is
        older than any of its prerequisites. If it exists but does not have any prerequisites
        it shall be considered as up-to-date. If it does not exist, and it has no prerequisites or
        commands it shall also be considered up-to-date. If it does not exist and has no
        prerequisites but does have commands, these shall be executed and the
        target considered up-to-date, whether the commands create the target or not.
        Otherwise a file that does not exist shall also be considered out-of-date.

followed by the rest of paragraph. I think that covers the intent that checking both prerequisites and commands shall be done when the file doesn't exist, and makes the Desired Action explicit. It also adds the missing case of exists but no prerequisites. Treating it as up-to-date allows create-once rules if not exist, recreate if deleted sort of thing.

- Issue History
Date Modified Username Field Change
2013-10-10 02:18 dwheeler New Issue
2013-10-10 02:18 dwheeler Status New => Under Review
2013-10-10 02:18 dwheeler Assigned To => ajosey
2013-10-10 02:18 dwheeler Name => David A. Wheeler
2013-10-10 02:18 dwheeler Section => make
2013-10-10 02:18 dwheeler Page Number => 2911
2013-10-10 02:18 dwheeler Line Number => 95628-95636
2013-10-31 16:22 Don Cragun Interp Status => ---
2013-10-31 16:22 Don Cragun Note Added: 0001949
2013-10-31 16:22 Don Cragun Status Under Review => Resolved
2013-10-31 16:22 Don Cragun Resolution Open => Accepted As Marked
2013-10-31 16:23 Don Cragun Note Edited: 0001949
2013-10-31 16:23 Don Cragun Note Edited: 0001949
2013-10-31 16:24 Don Cragun Final Accepted Text => See Note: 0001949.
2013-10-31 16:24 Don Cragun Tag Attached: tc2-2008
2013-11-07 09:35 geoffclare Note Added: 0001964
2013-11-07 09:35 geoffclare Status Resolved => Under Review
2013-11-07 09:35 geoffclare Resolution Accepted As Marked => Reopened
2013-11-07 11:45 shware_systems Note Added: 0001965
2013-11-07 16:27 Don Cragun Note Edited: 0001949
2013-11-07 16:29 Don Cragun Status Under Review => Resolved
2013-11-07 16:29 Don Cragun Resolution Reopened => Accepted As Marked
2014-08-08 12:22 eblake Relationship added related to 0000857
2019-06-10 08:55 agadmin Status Resolved => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker