Makefile question...

Kurt Granroth kurt+plug-discuss at granroth.com
Tue Oct 27 22:29:29 MST 2009


Not so much more automated than make, than more automated than 
Makefiles.  See, make is a very primitive tool by itself and requires 
quite complex Makefiles to really see any true power.  Building 
Makefiles by hand is tedious, error prone, and unlikely to ever do as 
much as you want or need them to do.

To really get the to next level, you need to move up to something that 
will either build your Makefiles for you OR replace the entire system.

automake/autoconf is the granddaddy of the automated Makefile building, 
but in my experience, you just replaced one complex set of rules to 
remember with another set.

CMake is the logical extension of that.  It's nearly trivial to setup 
but generates very full featured Makefiles.

Of course, in the end, you still have Makefiles which will always be a 
kludge when dealing with things like proper dependency tree calculations 
and detection of file changes.  To fix that, you need to move to 
something *else*.

We use SCons at work and have been overall very pleased with yet.  It's 
not without its flaws... but even with the flaws, it's still light years 
beyond Makefiles.

For instance, it does completely automated dependency tree checking to 
determine what needs to be recompiled if you change a file.  It's all 
internal and it's very accurate.  It also uses md5 sums (I believe) to 
determine if a file has actually changed -- no more relying solely on 
timestamps.

But the real power is the Includes and Provides statements.  That *may* 
be a local extension that a co-worker created... but I don't remember. 
It's very easy to create SCons extensions since it's all Python. 
Anyway, we can setup an interconnected series of base libraries with 
each have a "Provides(thislib, [depend,other-depend])".  That tells the 
system that this module can serve us the 'thislib' dependency but it 
needs to first pull in whatever module is serving up the 'depend' and 
'other-depend' dependencies.  These can nest up quite a bit. 
Eventually, you'll have some front-end module that will have a 
"Includes(thislib)' which will automatically pull in ALL libraries 
needed, all the way down the tree.  The modules can be laid out in any 
order you want without having to a change a single line in the 
SConscript files since scons will track down where all the dependencies 
are.  This makes creating the SConscript files (analogous to Makefiles) 
almost trivially simple.

Anyway, I'm already babbling so that's enough for now.  But you did ask ;-)

On 10/27/09 7:05 PM, Bob Elzer wrote:
> what's more automated than make ???
>
>
> -----Original Message-----
> From: plug-discuss-bounces at lists.plug.phoenix.az.us
> [mailto:plug-discuss-bounces at lists.plug.phoenix.az.us] On Behalf Of Kurt
> Granroth
> Sent: Tuesday, October 27, 2009 5:59 PM
> To: plug-discuss at lists.plug.phoenix.az.us
> Subject: Re: Makefile question...
>
> On 10/27/09 9:23 AM, kitepilot at kitepilot.com wrote:
>> Hello virtual inhabitants:
>>
>> I have a C++ application scattered over several directories.
>> Each leaf directory has its own Makefile.
>> I want to write a top-level Makefile that traverses the tree and
>> builds the application.
>> Makefile(s) are not one of my talents, and I cant' remember how to
>> traverse the tree and fire up the nested Makefile(s).
>>
>> Any "make Guru" in the population?
>
> Hmm... I'm tempted to recommend that you move away from Makefiles entirely
> into something a little more automated.  Still, that's not what your
> question was.
>
> ---------------------------
> DIRS = one two three
>
> all:
> 	for dir in ${DIRS}; do make -C $$dir $@; done
> ---------------------------
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss



More information about the PLUG-discuss mailing list