bugmake - Bugs: bug #51974, call on multiline (define/endef)...

 
 

bug #51974: call on multiline (define/endef) behavior not well-documented

Submitted by:  J. Hart <oss542>
Submitted on:  Sat 09 Sep 2017 08:45:50 PM UTC  
 
Severity: 3 - NormalItem Group: Documentation
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: 4.2.1Operating System: POSIX-Based
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sun 10 Sep 2017 01:54:06 PM UTC, comment #5:

For J. Hart: I do also recommend that you ask questions first on the -unavailable- or -unavailable- mailing lists to be sure the behavior you're seeing is really incorrect, before filing bugs here.

The make parser doesn't "go backwards": it will first read a line, then expand the line, then interpret the line. It doesn't go back after expanding the line to re-interpret the newline characters, so the entire results of expansion is treated as a single logical line by the make parser. I did try, when first implementing eval, to instead just have things re-interpreted after expansion always but it ended up being a real mess. Requiring an explicit eval is not always intuitive at first but it actually makes things much more coherent in general.

I do agree that the behavior could be better documented so I've modified this to a doc bug.

Paul D. Smith <psmith>
Project Administrator
Sun 10 Sep 2017 12:23:08 AM UTC, comment #4:

I can't dispute Anonymous's advice, which was what I first thought of too, but I don't think it's clearly documented, neither in the GNU make manual nor in this vein of bugs, how makefile fragments like these are being parsed. Perhaps this example will help explain what was going on in the other cases:

mad@shuttle:~/tmp/make-51972$ cat case-6.make
define MACRO
A: B
hello
endef
$(MACRO)
mad@shuttle:~/tmp/make-51972$

(The pointlessness of $(call) with no arguments is documented.)

Look away now if you want to guess the behavior on &quot;make -f case-6.make&quot;.

mad@shuttle:~/tmp/make-51972$ make -f case-6.make
make: *** No rule to make target 'B
hello', needed by 'A'. Stop.
mad@shuttle:~/tmp/make-51972$

The result of the variable expansion clearly is being parsed as makefile syntax, in that it has defined a rule (one without a recipe), but the line breaks aren't being treated how they would be in a makefile fragment. Is that reasonable? I'll buy it. But is it obvious?

Martin Dorey <mdorey>
Sat 09 Sep 2017 11:56:40 PM UTC, comment #3:

As the other poster points out here, $(eval) was required to parse the result of the $(call) reference. This resolves this issue. Many thanks for your patience and advice.

J. Hart <oss542>
Sat 09 Sep 2017 11:14:19 PM UTC, comment #2:

case 4:
Makefile:

define EXELNK1
$(1): OBJ1=xOBJ1
endef
define EXELNK2
$(1): OBJ2=xOBJ2
endef
$(call EXELNK1, utl1)
$(call EXELNK2, utl1)
utl1:;@echo "jfh1:pt1:$(OBJ1):$(OBJ2):"

result of invoking make : works as expected

J. Hart <oss542>
Sat 09 Sep 2017 08:58:14 PM UTC, comment #1:

This is also not a bug but rather an example where you need to use $(eval).

I suggest you email your question about how to do what you want to the help-make mailing list:
https://lists.gnu.org/mailman/listinfo/help-make

instead of filing bugs...which are not bugs but rather make doing exactly what it's documented to do.

Anonymous
Sat 09 Sep 2017 08:45:50 PM UTC, original submission:

case 1:
Makefile :

define EXELNK1
$(1): OBJ1=xOBJ1
$(1): OBJ2=xOBJ2
endef
$(call EXELNK1, utl1)
utl1:;@echo "jfh1:pt1:$(OBJ1):$(OBJ2):"

result of invoking make :
expected: jfh1:pt1:xOBJ1:xOBJ2:
actual:

/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [Makefile:6: utl1] Error 2

case 2:
Makefile:

define EXELNK1
$(1): OBJ1=xOBJ1
endef
$(call EXELNK1, utl1)
utl1:;@echo "jfh1:pt1:$(OBJ1):$(OBJ2):"

result of invoking make : works as expected

case 3:
Makefile:

define EXELNK1
$(1): OBJ2=xOBJ2
endef
$(call EXELNK1, utl1)
utl1:;@echo "jfh1:pt1:$(OBJ1):$(OBJ2):"

result of invoking make : works as expected

J. Hart <oss542>

 

(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 psmith (Posted a comment)
  • -unavailable- added by mdorey (Posted a comment)
  • -unavailable- added by oss542 (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):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 10 Sep 2017 01:54:06 PM UTCpsmithItem GroupBug=>Documentation
      Summarymultiline (define/endef) containing target-specific assignments causes errors in /bin/sh=>call on multiline (define/endef) behavior not well-documented

    Back to the top


    Powered by Savane 3.1-cleanup1