[PLUG] gnu make exported variable expansion

Larry Brigman larry.brigman at gmail.com
Thu Oct 25 05:07:01 UTC 2007


On 10/24/07, Galen Seitz <galens at seitzassoc.com> wrote:
>
> I have a Makefile that is set up to create listing files when gcc is
> run.  This is done with the following switch in CFLAGS.
>
> CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
>
> This works fine at the top level, however I'm trying to get it to work
> with a recursive make.  CFLAGS is exported to pass it to the recursive
> make.  I believe my problem is that $< gets expanded to an empty
> string when CFLAGS is exported, leaving the listing filename set to
> .lst instead of sourcefile.lst.  What is the correct way to do
> something like this?
>

Make does some strange stuff which is sometimes hard to understand
unless you have a
guide.

The problem is that what you have is a variable that does not get expanded until
the variable is referenced in the context that it is referenced.

I find that these following reference have helped me figure out how to
fix my makefiles
and make them better.

http://www.electric-cloud.com/resources/mrmake.php
http://www.cmcrossroads.com/articles/ask-mr.-make.html



More information about the PLUG mailing list