help-make
[Top][All Lists]
Advanced

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

Re: Echoing a list of variables


From: Paul Smith
Subject: Re: Echoing a list of variables
Date: Mon, 07 Jul 2008 17:25:22 -0400

On Mon, 2008-07-07 at 12:36 -0700, EricDeb wrote:
> Makefile1 (for project A):
> VERSIONNAMES = VERSIONA VERSIONB
> VERSIONA = foo
> VERSIONB = bar
> make Makefile2
> 
> Makefile1 (for project B):
> VERSIONNAMES = VERSIONA
> VERSIONA = ugh
> make Makefile2
> 
> Makefile2:
> reportversions :
>         ???? Help!
> 
> The goal would be for the user to type:
>    make reportversions

It's always better to include actual examples and snippets rather than
"psuedo-code"; most of the time many of the important bits are in the
parts of the psuedo-code not included.

First, I don't know what "make Makefile2" is supposed to be but it
doesn't make any sense.  Maybe you meant "make -f Makefile2"?  If you're
really invoking a sub-make you should always use the variable form
$(MAKE), not "make".

Second, although you don't show it I'm assuming that you're "export"ing
VERSIONNAMES and VERSIONA/VERSIONB etc.  If you don't do that, then when
you run "$(MAKE) -f Makefile2" the sub-make won't be able to see any of
the values of any of the variables.  Maybe you wanted to use "include
Makefile2" instead?

Third, you could write "reportversions" like this:

        reportversions:
                @$(foreach V,$(VERSIONNAMES),echo '$V = $($V)';)

But, there are still many other things that could be causing problems
which we can't detect from your example above.





reply via email to

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