Bobbing for Kernels

See Bob. See Bob bob. Bob, Bob, bob!

Better Makefiles

Posted by kernelbob on October 25, 2008

Today I’ve released a new open source package: better-makefiles.

Makefiles are a black art.  The vast majority of people who use ’em and write ’em don’t really understand what’s happening.  I’ve spent a few hundred hours banging my head against them over the years.  I decided yesterday morning to write a better makefile, one that would carry from project to project.  I released it under a BSD license, in case someone else can benefit.

Update 15:30: I wrote a little more about it over here.

Peter Miller (no relation) wrote a paper back in 1997 titled Recursive Make Considered Harmful (RMCH).  His big idea was that when you put a separate makefile in every directory of the project, you deprive make of the global knowledge it needs to get dependencies right.  Instead, you should invoke make once at the top of the project tree, and use include files to tell it what’s in the subdirectories.  Then, given true information, make can build the right files all the time.

So I’m adopting RMCH’s ideas.

I’m also using some of the juicy extensions the GNU project has been writing over the last decade.  GCC can write part of your makefile for you — the C preprocessor can output a list of include files each C file depends on.  GNU Make has evolved into a full programming language.  A really yucky, difficult language, but you can do stuff in it if you’re determined.

Anyway, I published the makefile project on Gitorious.  Go take a look.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: