On Thu, 2005-06-30 at 12:06 +0530, Bhaskar G wrote:
> I would like to know if there is macro that stores list of all the
> existing variables.
Yes there is, it's called .VARIABLES.
> My requirement is as follows. I have a set of variables defined
> currently which starts with _BG%.
> I need to change these variables to begin with _SP% and also need to
> support _BG% for sometime.
>
> I know that I can individually look for variables and conditionally
> assign it as follows
> _SPTMP ?= _BGTMP
>
> Can I handle this using a foreach command in make easily? without
> individual assignments.
Yes, you can with GNU Make 3.80 or above like this:
FOO1 = foo1
FOO2 = foo2
$(foreach a,$(.VARIABLES),$(if $(patsubst FOO%,,$a),,$(eval BAR
$(patsubst FOO%,%,$a) = $$($a))))
all:
@echo $(BAR1) $(BAR2)
Which is the same as doing:
FOO1 = bg1
FOO2 = bg2
BAR1 = $(FOO1)
BAR2 = $(FOO2)
all:
@echo $(BAR1) $(BAR2)
John.
--
John Graham-Cumming
Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make