[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: a function that calls a function eval'ing an immediate variable

From: Sandy Currier
Subject: re: a function that calls a function eval'ing an immediate variable
Date: Tue, 2 Mar 2004 10:22:03 -0500

First, thanks so much for the answer to my previous question.

We are continuing to prototype a potential gmake application.
It is rather large (+1000 leaf makefiles) and over 8G of
derived objects.  The project currently is using a non-
recursive design and leverages a bunch of 3.81 features.

To simplify the leaf makefiles, we are trying to use some
templates that are eval-call'ed by the leaf makefiles.  The
leaf makefiles will hopefully be fully generated.  The
problem is that we want to embed eval-call constructs inside
the initial 'function' definition called by the leaf
makefile.  When we try this, I for one cannot get the macros
defined by the outer (first) function to be correctly eval'ed by
the second (inner) function.  I have read the secton on macro
expansion several times, and the code looks right, but
non-the-less, it does not appear to work.  

What fails is that an immediate variable, defined in the first (outer)
function, does not appear to be accessable by the second
(inner) macro/function call.  I have attached a make snippet 
below that reproduces the error.  The error is that the
"_TEST2_glnx86" printout should be printing "../do_glnx86/ZZZ", 
but is being evaled as "../do_glnx86/" instead.  This looks like the 
$(_THIS_DIR) variable is not being properly eval'ed by the inner
(second) function call.

Any thoughts or reviews or comments would be much appreciated.


# make snippet to reproduce the above issue

# define some platforms
PLATFORMS               := glnx86 sol2 hpux mac windows
DO_COMMON               := ../do_common
DO_FLAVOR_glnx86        := ../do_glnx86
DO_FLAVOR_hpux          := ../do_hpux
DO_FLAVOR_mac           := ../do_mac
DO_FLAVOR_sol2          := ../do_sol2
DO_FLAVOR_windows       := ../do_windows

# define a function
TEST2_TEMPLATE = _TEST2_$(1) := $$(DO_FLAVOR_$(1))/$$(_THIS_DIR)

# define a function that calls the above
# $(1) = 
# $(2) = 
_THIS_DIR               := $(1)
_DO_THIS_DIR            := $(DO_COMMON)/$$(_THIS_DIR)
_TEST1                  := $$(_DO_THIS_DIR)/EXPORTS/$(2).exports
# call DO_THIS_DIR_TEMPLATE function
$(foreach platform, $(PLATFORMS),$(eval $(call TEST2_TEMPLATE,$(platform))))

# now call the macro

# now print some diagnostics
.PHONY: print2
        @echo "PLATFORMS             = $(PLATFORMS)"
        @echo "_THIS_DIR             = $(_THIS_DIR)"
        @echo "_DO_THIS_DIR          = $(_DO_THIS_DIR)"
        @echo "_TEST2_glnx86         = $(_TEST2_glnx86)"
        @echo "_TEST1                = $(_TEST1)"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]