bugmake - Bugs: bug #25190, define expansion seems to lose the...

 
 

bug #25190: define expansion seems to lose the final newline

Submitter:  Norman Abramovitz <nabramovitz>
Submitted:  Sun 28 Dec 2008 05:49:38 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  3.81 Operating System:  Any
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 28 Dec 2008 07:53:28 AM UTC, comment #2: 

This is not a bug.  See the GNU make manual, section "Defining Variables Verbatim", where it says:

The value in an ordinary assignment cannot contain a newline; but the newlines that separate the lines of the value in a `define' become part of the variable's value (except for the final newline which precedes the `endef' and is not considered part of the value).

Note the final parenthetical comment (highlight added).

Paul D. Smith <psmith>
Group administrator
Sun 28 Dec 2008 06:32:23 AM UTC, comment #1: 

The cut and past lost the expected indentation or tabs on lines.  Adding an attachment (unix eol) with the test case code.


(file #17143)

Norman Abramovitz <nabramovitz>
Sun 28 Dec 2008 05:49:38 AM UTC, original submission:  

Environment

Red Hat Enterprise Linux Server release 5.2 (Tikanga)This program built for i686-redhat-linux-gnu

If I do not have the empty line at the end of the pkgify_rule, the next generated program target assignment (yyy) gets combined with the previous generated chmod line (xxx).  The blank line should not be required.

Execution results with the blank line.

$ gmake -f x -n all
echo xxx comes from xxx.sh
chmod +x xxx
echo yyy comes from yyy.sh
chmod 644 yyy
echo all done

Execution results without the blank line.

$ gmake -f x -n all
echo xxx comes from xxx.sh
chmod +x xxx   yyy: PKGIFY_MODE?=+x
echo yyy comes from yyy.sh
chmod 644 yyy
echo all done

It is not a printing error since if I run without the -n flag I get the following errors.  Since I made my sources phoney objects to simplify the test case, I expect two error messages from chmod not three.

$ gmake -f x all
echo xxx comes from xxx.sh
xxx comes from xxx.sh
chmod: cannot access `xxx': No such file or directory
chmod: cannot access `yyy:': No such file or directory
chmod: cannot access `PKGIFY_MODE?=+x': No such file or directory
gmake: * [xxx] Error 1

The test script follows.

SH_PROGRAM=xxx yyy
SHSRC=xxx.sh yyy.sh
.PHONY: xxx.sh yyy.sh

yyy: PKGIFY_MODE=644

PKGIFY=echo $@ comes from $<

all: ${SH_PROGRAM}
        echo all done

indices=$(shell (( i= 0 )); while (( i < $(words ${${1}}) )); do (( i += 1 )); l="$${l} $$i"; done; echo  $${l})

define pkgify_rule
$(1): PKGIFY_MODE?=+x
${1}: ${2}
        $${PKGIFY}
        @chmod $${PKGIFY_MODE} $$@

endef
# if the blank line above the endef is removed the next target assignment becomes
# part of the previous chmod line

define pkgify_template
$(foreach idx,$(call indices,${1}), $(call pkgify_rule,$(word ${idx},${$(1)}),$(word ${idx},${${2}})))
endef

# this ifdef works 3.81 but not in 3.80. if function works 3.80 and 3.81
ifdef SH_PROGRAM
$(eval $(call pkgify_template,SH_PROGRAM,SHSRC))
endif

xyz: xyz.sh
        echo xyz

Norman Abramovitz <nabramovitz>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #17143:  bug25190.ksh added by nabramovitz (795B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by nabramovitz (Submitted the item)
  • -email is unavailable- added by nabramovitz
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-12-28 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed
    2008-12-28 nabramovitz Attached File- Added bug25190.ksh, #17143
    2008-12-28 nabramovitz Carbon-Copy- Added nabramovitz

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code