help-make
[Top][All Lists]
Advanced

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

Template for variable creation


From: Martin d'Anjou
Subject: Template for variable creation
Date: Fri, 9 Sep 2005 10:45:45 -0400 (EDT)

Hi,

I try to use a template to generate a set of "other" variables based on a
existing set of "base" variables. The "other" variables do not appear to
be created, and show up as being empty. I use a combination of define,
foreach and eval, as explained in section 8.8 of the manual.

Here is my code:

# The default set of variables, base_first_args and base_second_args
base_first_args=one
base_args+=$(base_first_args)
key_list=first

base_second_args=two
base_args+=$(base_second_args)
key_list+=second

TARGETS=base_target

# Templating starts here
define copy_vars
$(1)_$(2)_args=$$(base_$(2)_args)
$(1)_args+=$$($(1)_$(2)_args)
endef

# From now on, users can copy the "base" variables into their own vars
$(foreach key,$(key_list),$(eval $(call copy_vars,other,$(key))))

TARGETS+=other_target

all: $(TARGETS)

%_target:
        @echo RULE: target=$@ args=$*_args expanded_args=$($*_args)

When I type make, it builds both targets, but the echo shows that
$($*_args) value is empty for the variable generated with the template
(e.g. $(other_args) is empty???). Help!

Thanks,
Martin
Using make v3.79.1.










reply via email to

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