.
Last update: 1997-05-20
9945-2-94 _____________________________________________________________________________ Topic: macro processing in make Relevant Sections: 6.2.7.4 Defect Report: ----------------------- From: [email protected] (Mark Funkenhauser) Date: Fri, 20 Jan 1995 12:30:18 -0500 (EST) Dear Standards Board, I would like to an request official, binding interpretation from the WG15 concerning the following point in ISO/IEC 9945-2:1993 (POSIX.2). It is not clear in POSIX.2-1992 (Section 6.2.7.4) what the proper behaviour is between the evaluation of macros in target lines and macro assignments. POSIX.2 (Section 6.2.7.4, lines 471-472) states: "Macros in target lines shall be evaluated when the target line is read." Lines 482-492 describe the rules for macro assignments. Macro assignments shall be accepted from the sources in the following list, in the order shown. If a macro name already exists at the time it is being processed, the newer definition shall replace the existing definition. (1) Macros defined in the inference rules built into make. (2) The contents of the environment, including the variables with null values, in the order defined in the environment. (3) Macros defined in the makefile(s), processed in the order specified. (4) Macros specified on the command line. It is unspecified whether the internal macros defined in 6.2.7.7 are accepted from the command line. If the -e option is specified, the order of processing sources (2) and (3) shall be reversed. Its unclear what the temporal relationship is between the "processing" of Macro assignments and "when the target line is read". Are target lines read (and thus macros evaluated) at the same time that the processing of macro assignments are being performed in (3)? I am assuming the answer is yes. If so, then the way I interpret 6.2.7.4 is that macros in target lines shall be evaluated to the current value of the macro at the time the makefile is read, which means that specifying a value on the command line will not be in effect at this time and the target line will expand to an empty value. The following 2 examples show that historical behaviour does not follow my interpretation. Example 1: ---------- What is supposed to happen when the following command line is excuted: $ make MY_MACRO=command_line where the makefile contains: MY_MACRO=in_makefile $(MY_MACRO): echo $$@ = $@, $$MY_MACRO = $(MY_MACRO) My interpretation of 6.2.7.4 should yield the following result: $@ = in_makefile, $MY_MACRO = command_line But, historically the answer is $@ = command_line, $MY_MACRO = command_line Example 2: ---------- Using the same makefile as above, what is supposed to happen when the following command line is excuted: $ export MY_MACRO=in_environ $ make -e A I interpret Section 6.2.7.4, I expect the following result: $@ = in_makefile, $MY_MACRO = in_environ But, historically the result is: $@ = in_environ, $MY_MACRO = in_environ To rationalize the historical behaviour using the description in Section 6.2.7.4, this would imply that there is a two-pass process whereby macro assignments are accepted from all of the sources listed in steps (1)-(4) *before* the target lines are read. Thank you for your attention to this matter. Mark Funkenhauser Interpretation response: ------------------------- The standard is unclear on this issue, and no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor. Rationale: None Forwarded to Interpretations group: 22 Jan 95 Proposed resolution circulated: May 16th Comments due: June 15th Finalised: June 16th 1995