--- title The BK build system description A minimal, non-configurable build system for C ---
Motivation
I realized that all my Makefiles looked the same. And that it was pretty wasteful to both 1) not really make use of Make proper, in all its thousands of lines of code, and 2) waste time writing a Makefile for each trivial build I used.
I also had some problems with Make, namely that the most basic builds required makefiles that were either hardcoded, to the point of being annoying to maintain, or abstracted to the point of being illegible by anyone who hasn't read the GNU Make manual (of 200+ pages) front-to-back at least two or three times.
Process
So I went about making my own build system, with the goal of fixing these issues. The most common builds should work out-of-the-box with no configuration whatsoever. Configuring less-common builds should be hard in proportion to how weird the build is exactly. And, where there is complexity, that complexity should either be reflected in the projects' file structure, or in the implementation of the build tools. NOT in configuration files, which should be kept as small and simple as absolutely possible.
It took about a week. The result is BK! You can explore the source code on your local system. The basic idea though, is that a directory is a basic unit that either describes a library or a program.
BK provides first, a trivial way to compile the code in a
directory: just run bk and the program that lives
in the current working directory will get compiled into a binary
named after that directory (as is by far the most common case). If
that program requires code from another directory, you can create a
file called "bkfile", containing only the text "dir DIR" (where the
capitalized DIR is replaced with a relative path to the directory
with the other code. If you want to use a .a or .so library, simply
soft- or hard-link it into one of the source code directories to be
compiled.
Outcomes
As soon as I had written the basic "build" command, I was able to start dogfooding this and pretty much entirely stopped using make. I also noticed that not futzing with Make and its endless, useless generalizations freed me up to think more about how I was structuring my source code. Ultimately it made my projects much easier to build, which ironically reduces the amount that I actually end up needing bk.
Work is ongoing and I will continue to improve this tool, there are many things that it doesn't do, however this is by design in some cases. As I feel an actual need to do things that don't fit nicely into bk's existing channels, I'll add them. So far though, I've been able to build even non-bk-native projects more easily with bk than in those projects' native Make build.