[Top][All Lists]

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

RE: recusrive make or include make files

From: sharan basappa
Subject: RE: recusrive make or include make files
Date: Mon, 15 Jan 2007 11:44:00 +0000

Phil, Dave, John,

Really appreciate your comments .. As a matter of fact, I would try out
both the options (since I have luxury) of small pilot design and based on the
outcome, can decide to stick to one of these two ..

Thanks once again ..

Problem : In the process I have gone through both the options of doing this
using recursive make option or including these submakes into main make file.
The issue that I forsee in case of including submake file is that individuals who
create these submakes have to be aware from where their make files will be
called, whereas in case of resursive make, once the make works in their
directory it will always work if top level make executes these make files.

The solution I used when I moved a non-trivial project (~50
directories containing source) over to a set of non-recursive
makefiles ran something like this:
1) the variable 'TOP' is defined to be the path of the top of the source tree
2) the variable 'THIS' is defined to be the path of the current
directory relative
 to ${TOP}
3) the above are accomplished by the following:
   - the toplevel GNUmakefile conditionally (?=) sets TOP to '.' and
THIS to the
     empty string
- each subdirectory contains a GNUmakefile that sets TOP and THIS and then
     includes ${TOP}/GNUmakefile
4) all other files included by make perform all their actions relative to ${TOP}
5) ${THIS} is used to control the dependencies of the default target,
so that simply
 type 'gmake'  in a directory will end up compiling all objects and
programs in
 all the directories below the current directory
6) the 'real' actions for a given directory are not in the GNUmakefile for that
  directory but rather in a file "", which is included
by its parent
  directory's, up to the toplevel where the is included
 by the GNUmakefile.

The key item is #4.  If you can drill in that *everything* is done
relative to ${TOP} (or particular variables derived from ${TOP}) then
things Just Work.  I was on a small enough team that that my teammates
would just ask for help when they had doubts.  Having an extended
discussion ahead of the changeover to make sure they all were
comfortable that the new setup would express the dependencies properly
and otherwise support them during development was important too.

It also helped that the actions for a given directory were almost
completely factored out into a single file, so that the
for almost all directories containing source simply sets six variables
and then includes that common file.  You need to add a source file?
Just add the resulting object to the list of objects for the directory
and let the pattern rules do the rest.  Need another compiler flag?
Add it to another variable.  Only a few directories are different
enough to need more than that.

Philip Guenther

From: "Dave Korn" <address@hidden>
To: <address@hidden>,"'sharan basappa'" <address@hidden>
CC: <address@hidden>
Subject: RE: recusrive make or include make files
Date: Mon, 15 Jan 2007 10:15:37 -0000

On 15 January 2007 10:08, John Graham-Cumming wrote:

> something new.   Sometime ago I wrote an article for Dr Dobbs called
> 'Cross-Platform Builds' ( which
> outlines a complete non-recursive build system.

  404 (although strangely the file download is still there).  Try


Can't think of a witty .sigline today....

MSN cricket features 'Cricketer of the Month'

reply via email to

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