Skip to content

Instantly share code, notes, and snippets.

@ahobson
Created August 12, 2021 20:53
Show Gist options
  • Save ahobson/c86ba422a2ab008b9cdda54d3f5a7f18 to your computer and use it in GitHub Desktop.
Save ahobson/c86ba422a2ab008b9cdda54d3f5a7f18 to your computer and use it in GitHub Desktop.
Makefiles are not for me

I'm not a big fan of Makefiles as entrypoints for a project.

  1. There's no way to pass command line arguments other than environment variables and there's no way to report per subcommand options
  2. There's no code reuse. If you have common functionality that you want to share (e.g. starting a dev db vs a test db) but with some parameters slightly different, there's no good way to do that in a Makefile
  3. The syntax is inscrutable. How do you run a shell command sending it a multi line command (for readability)? I tried for about an hour before giving up and writing an external shell script. MilMove has an entire directory of scripts for this reason. Even better, on MilMove those scripts call back out the the Makefile.
  4. Makefiles were needed for C/C++ because you recompiled individual files. There's even a command $(CC) $(CFLAGS) -MM that generates Makefile compatible syntax so that only necessary files are rebuilt. Modern languages don't work that way: they provide a single command that recompiles all necessary files (go build, javac) and you have to provide all source files, not just the ones that have changed. And so all targets need to be .PHONY except folks don't realize that. So we have targets and scripts that explicitly remove files.
  5. Because we don't use languages that need per file recompilation, any dependencies for .PHONY targets can be expressed as a very simple DAG.
  6. There's no testing framework for Makefiles, so we end up writing literally thousands of lines of untested code that underpins one of the most critical part of our deliverable: building and testing the software.

All of this "makes" it clear to me that a Makefile provides no benefits over a shell script and all the downsides. Makefiles are just crappy shell scripts with syntax that no one understands.

So if you have to use the lowest common denoninator, just use bash. If you have the choice, write your build tooling in a real language that supports all the development tooling you would want when delivering critical business features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment