help-make
[Top][All Lists]
Advanced

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

Re: only run submake if that submake needs to be run?


From: Boris Kolpackov
Subject: Re: only run submake if that submake needs to be run?
Date: Fri, 20 Aug 2004 18:24:18 +0000 (UTC)
User-agent: nn/6.6.5+RFC1522

David Wuertele <address@hidden> writes:

> The reason I chose recursive in the first place was for a couple of
> reasons:
> 
> 1.  I want to be able to run make in the sub-directory and have it
>     work

That shouldn't be a problem (see link below).

> 
> 2.  I want to use the same variable namespace for all the makefiles.
>     For example, I don't want one of my users to have to create
>     variable names like:
> 
>       my_program_OBJ := this.o that.o
> 
>     I want them to be able to write:
> 
>       OBJ := this.o that.o
> 
>     This is an oversimplified example for the purposes of making the
>     point.  I want them to be able to copy their neighbor's Makefile
>     and not have to change all the variable names.

This one is a bit trickier but there is a way to achieve this. Here is
the idea. There is a special make variable called `.VARIABLES' which 
contains names of all variables defined up to the point. With this
variable you can write two functions that will save and restore values
of all variables; I called them `frame-enter' and `frame-leave'. Now
having those two functions you can write function `import-rules' like
this:

define import-rules-body
$(call frame-enter)
include $1
$(call frame-leave)
endef

define import-rules
$(eval $(call import-rules-body,$1))
endef

With this function you can import rules from makefiles without 
overriding variables.


All this stuff (and much more) is implemented in `build'

http://kolpackov.net/projects/build/

Even though `build' won't work with mainline GNU make both of your
problems are addressed in a way that it should work with mainline 
GNU make.


hth,
-boris





reply via email to

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