Don’t write your own build system

The title might be a bit controversial but at least it is catchy one. Recently I’ve seen a few posts about Shake, a make replacement with several improvements (such as more flexible dependency specification). There are also examples how to use it with say Vala.

The problem is that the Make and Shake are both rather quite low-level tools and while improvement in them is beneficial shake, at least currently, is not a replacement for autotools or CMake.

There are number of things user might want to do with build system, which would need to be manually added to make or shake script:

  • CC, CXX, VALAC, CFLAGS… environment variables to allow fine-tuning the compilation by user (or developer who wants to for example test with clang instead of gcc).
  • Personalizing the prefix to put program in right place (usually /usr/local is used for program compiled by source but it is often not accessible by users)
  • Installing in different root hierarchy steered by DESTDIR. This is different from prefix as latter denotes where program is run from while this variable locates a root (/) location during install time. This is used mostly for creating packages.
  • distcheck which allows to create tarballs, build from them, run tests etc.
  • Cross-compilation
  • Compile dynamic libraries on whatever platform I’m on, handling all complexity (correct flags – say -fPIC, tools, …)
  • Build in separate build directory (useful for cross-compilation)

Those features are not explicitly supported by Make or Shake as they are more low-level tools – which is fine if we treat them as such and use other libraries or tools automating the compiling and linking (I haven’t seen anyone claiming Shake is anything more, but it is good to keep in mind that build systems can grow quite complex while using it). However for a tool to be usable for wide range of users there should be provided – preferably with consistent interface with existing tools as it makes the integration easier with other tools (say portage) and does not require user to relearn the specifics. Unfortunately most make tutorials (and shake) omit those problems. It can be fine if we made some assumptions – say we have closed environment (so the need is to integrate with internal tools and only them, specific installation etc.) or we know that we need to provide those features. However it can cause problems if they do appear in published repository.

The own build system therefore is not the Make or Shake but rather systems built on top of them. My guess is that when someone knows the full requirements of a build system than writing more highier-level library on top of Shake should be relativly simple (as it’s EDSL) – however it is harder then it looks like.

PS. While looking for links to the post I’ve (re)read similar post.

PPS. The draft version of this post was accidentally published. Sorry for confusion.

This entry was posted in Programming and tagged , , , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your 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 )

Google+ photo

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

Connecting to %s