[Top][All Lists]

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

RE: Question Regarding Emile van Bergen's Non-Recursive Make

From: Davidson, Josh
Subject: RE: Question Regarding Emile van Bergen's Non-Recursive Make
Date: Tue, 02 Dec 2008 13:26:13 -0700

First of all, Mike thanks for that incredibly detailed post.  I'm
surprised how thorough your solution was and how worked out of the box.
I did confirm that it requires 3.80.

Garrett, what part of that process do you find confusing?  I hid all of
the macros in another include file with related macros, so end users
don't have to worry about it.  I will admit that it took me a few passes
over the code to figure out how everything was working, but end users
shouldn't have to care.  By doing this, I was able to considerably
shrink my main makefiles.

I haven't hit a case where a define block is required...yet.


-----Original Message-----
From: Garrett Cooper [mailto:address@hidden 
Sent: Monday, December 01, 2008 7:44 PM
To: Mike Shal
Cc: Davidson, Josh; address@hidden
Subject: Re: Question Regarding Emile van Bergen's Non-Recursive Make

On Mon, Dec 1, 2008 at 2:09 PM, Mike Shal <address@hidden> wrote:
> On 12/1/08, Davidson, Josh <address@hidden> wrote:
>> Ok, I'm close to getting this working.  I'm trying to find an
>>  alternative to doing:
>>  dir := moduleA
>>  include $(dir)/
>>  dir := moduleB
>>  include $(dir)/
>>  dir := moduleC
>>  include $(dir)/
>>  #etc
>>  Normally, I would do something like
>>  MODULES = moduleA moduleB moduleC #etc
>>  include $(addsuffix /, $(MODULES))
>>  However, I need to set dir before adding the include.  Is there a
>>  to doing that?
> You can try to pull the directory name from the MAKEFILE_LIST
> variable, which will have the Makefiles included up to that point (I
> think that was added in make 3.80, though). For example (using % as
> the prompt):
> % cat Makefile
> # macro to pull out the last entry in a list
> last = $(if $1,$(word $(words $1),$1))
> # macro to find the most recent file
> makefile = $(call last,$(filter %/,$(MAKEFILE_LIST)))
> dir = $(patsubst %/,%,$(makefile))
> MODULES = ant bee
> include $(MODULES:%=%/
> % cat ant/
> $(warning in ant, dir=$(dir))
> % cat bee/
> $(warning in bee, dir=$(dir))
> MODULES = test
> include $(MODULES:%=$(dir)/%/
> % cat bee/test/
> $(warning in bee/test, dir=$(dir))
> % make
> ant/ in ant, dir=ant
> bee/ in bee, dir=bee
> bee/test/ in bee/test, dir=bee/test
> make: *** No targets.  Stop.
> You could also try to derive the MODULES from doing a $(wildcard
> $(dir)/*/ or something instead of setting it in each
> file. I use a similar setup for the Makefiles in marfitude, and it
> seems to work reasonably well. Most of the per-directory Makefile
> stubs end up fairly empty.
> Hope that helps,
> -Mike

You'll need to probably put the dereferencing items in define blocks
to avoid dereferencing variables too early.

Word to the wise -- don't use this methodology because it's confusing
as shit to follow once the make system gets sufficiently large. My
group at Cisco is currently trying to scrap this type of poorly
executed methodology we inherited from another group in favor of flat
makefiles, which is much easier to follow.

Then again the whole damn make system we got sucks.


reply via email to

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