Why I still write a build script before a Makefile
A Makefile is a dependency graph with a build tool bolted to it. That is a great deal of machinery, and it earns its keep on projects with hundreds of artifacts. On a project with four artifacts it is a liability, mostly because nobody wants to be the person who refactors it.
My habit: start with ./build.sh, twenty lines, no dependencies beyond a
shell and the compiler. When the script starts sprouting functions that look
like a parser, that is the signal to graduate.
Signals that you have outgrown the script
- You are implementing incremental rebuilds by hand, badly.
- Two targets need the same output and you have started copy-pasting rules.
- Someone asks for parallel builds and you reach for
xargs. - New contributors modify the script to build one component.
The script also has a second life. Once the real build system exists, the shell script becomes the thing CI calls, which keeps the build definition in one place instead of spread across a YAML file that only the CI provider understands.
I have deleted more Makefiles than I have written, and I do not regret any of the deletions.