help-gnu-utils
[Top][All Lists]
Advanced

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

Re: gmake - how to generate variable assignments?


From: John Graham-Cumming
Subject: Re: gmake - how to generate variable assignments?
Date: Mon, 27 Dec 2004 17:26:40 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040208 Thunderbird/0.5 Mnenhy/0.6.0.104

Ernest wrote:
Say I have a variable with n words...

FILES = foo1 foo2 foo3 ...

And I want to be able to generate *global* variable assignments (which may need to be used later in multiple targets) of the form:

foo1_VAR = ${VALUES}
foo2_VAR = ${VALUES}
...

Is there a way to do this? I've looked into $(eval) and "define", but they appear to be limited to doing stuff inside a target's command list only...not for generating willy-nilly makefile lines.

You can do this in GNU Make 3.80 using the $(eval) function.

    $(foreach V,$(FILES),$(eval $V_VAR = ${VALUES}))

This will set V to be the name of each variables in FILES in turn and then do $(eval $V_VAR = ${VALUES}) for each V.

John.


reply via email to

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