bugmake - Bugs: bug #2260, Cannot create variables for use...

 
 

bug #2260: Cannot create variables for use with the $(call varaiable,param,param,...) function

Submitted by:  Jon-Paul Sullivan <j3p0uk>
Submitted on:  Mon 20 Jan 2003 04:53:10 PM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: 3.79.1Operating System: Any
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.

 

Tue 21 Jan 2003 03:12:01 PM UTC, comment #3:

This will not work. Exporting variables is NOT an appropriate method for sharing makefile code between different make processes: you should use a common include file for that and include it in both makefiles. If you don't want to explicitly include it, see also the MAKEFILES variable. Since you don't say why you want to do this, that's all the advice I can offer.

Exporting variables is intended to allow the make process to communicate values (not make code) to programs it invokes, like the shell or a compiler, etc.

All values that are exported are expanded before the subshell is invoked: this is required by POSIX and is a feature, not a bug.

If you really, really want to do this you'll have to escape the value that's exported like this:

MYFUNC = $$(2) $$(1)
export MYFUNC

then you'll have to "un-escape" it before you use it, like this:

_MYFUNC := $(MYFUNC)

all: ; @echo $(call _MYFUNC,one,two)

(note I just wrote this off the top of my head; I didn't test it).

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Tue 21 Jan 2003 10:30:23 AM UTC, comment #2:

Full problem description is:

Using an include I define a variable to be a function, then export it.

A sub-make cannot then use the variable as a function.

Makefile:
include variables

all:
$(MAKE) -C subdir all

==========
variables:
MYFUNC=$(2) $(1)
export MYFUNC

==========
subdir/Makefile

all:
echo $(call MYFUNC,one,two)
==========

This will 'echo ""'.

Jon-Paul Sullivan <j3p0uk>
Mon 20 Jan 2003 11:13:05 PM UTC, comment #1:

In the duplicate bug you reported that variables that are exported are evaluated first, as a comment on this bug.

That is perfectly correct and is not a bug. First, make has no idea which variables are meant to be "functions" (used with $(call ...)) and which aren't, and second all variables have to be expanded before they are passed to the child: it would make exporting of variables quite useless if this were not the case. Not to mention that POSIX requires this.

Is this the root cause of your bug report? Or is there more to it? I can't reproduce your problem based on the information provided: it works fine for me. If you still see a problem other than the exported variable issue then please provide a simple test case with the results you got, and describe the results you expected (or why you think what you got was wrong).

Thanks.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Mon 20 Jan 2003 04:53:10 PM UTC, original submission:

Version is 3.79.1 from Red Hat Linux 7.2 on i386. No re-compilation of make, using as is from RH 7.2

Can't see any problems in Makefile. Usin --warn-undefined-variables can see that '1' is an undefined variable.

Can't get call function to work in even the simplest example from the documentation.

Jon-Paul Sullivan <j3p0uk>

 

(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

 

CC list is empty

 

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 3 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue 21 Jan 2003 03:12:01 PM UTCpsmithStatusNone=>(Error - Not Found)
  Open/ClosedOpen=>(Error - Not Found)
Mon 20 Jan 2003 11:13:05 PM UTCpsmithAssigned toNone=>NA

Back to the top


Powered by Savane 3.1-cleanup1