Why ‘make’ must die…

One of my tasks at work is maintaining a make-based build system.  It is required to build our software properly on Linux and Windows (cross-compilation, our target CPU is Hitachi SH4). Anytime I have to dive into makefiles, I’m wondering why a tool like that is still in widespread use. Please note, that I’m quite familiar with make, I’ve done some reading and feel more or less comfortable with what I’m doing. However, I can probably name a few obvious problems of make. The problems I list here are of different caliber, but those are the most annoying ones from my (and my team) perspective.

  • The first issue is makefile syntax. It requires some time to get used to (yes, it is possible). However, if the type of whitespace used in a file matters, there’s something wrong.
  • The next (little) flaw is the way make handles shell commands.  If you write a multi-line script inside a makefile rule, make spawns a new shell for each line. It is a common mistake, to write a rule like that:
    foo: bar
           cd some_dir

    In this example cd command has just no effect, as do_something is executed in a brand new shell process. Sure, it is very easy to workaround this issue, still you need to be aware. Surprisingly high amount of questions I get form other team members deal with this particular issue.

  • In my opinion the biggest issue is the way make supports recursive builds. Virtually every serious project contains some hierarchy of directories with source code. On the other hand, make gives little support for recursive compilation. Either you need to literally spawn make recursively for each subdirectory, which is just silly, or you have to use various tricks in your Makefile to collect all the sources form subdirectories (it is well described in a book). Why should I really care?
  • Finally, make gives little support for cross-platform builds, beyond the fact that make itself is available on many platforms. Unfortunately, even the things like path separator slashes need to be handled manually in many cases. I don’t even want to mention autotools here, that’s another painful story.

Fortunately, there are alternatives. At the moment I’m evaluating SCons, and I’m quite satisfied. I’ll share my experience soon.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: