Makefiles For Easy To Use 'Public' Development UI
Recently, I read an article titled Time for Makefiles to Make a Comeback which reminded me of a fantastic UNIX tool that far too many people view as being scary.
Make dates back to 1976 (41 years ago!), where it was used by Stuart Feldman at Bell Labs. Here’s what the creator of Make had to say about it:
Make originated with a visit from Steve Johnson (author of yacc, etc.), storming into my office, cursing the Fates that had caused him to waste a morning debugging a correct program (bug had been fixed, file hadn’t been compiled, cc *.o was therefore unaffected). As I had spent a part of the previous evening coping with the same disaster on a project I was working on, the idea of a tool to solve it came up. It began with an elaborate idea of a dependency analyzer, boiled down to something much simpler, and turned into Make that weekend. Use of tools that were still wet was part of the culture. Makefiles were text files, not magically encoded binaries, because that was the Unix ethos: printable, debuggable, understandable stuff.
— Stuart Feldman, The Art of Unix Programming, Eric S. Raymond 2003
Since reading that I’ve been working on creating Makefiles for all my various projects and codebases.
Here is my template Makefile that I use as a starting point (for Ruby projects)
start: setup
docker-compose up
setup:
docker-compose create
rebuild:
docker-compose run app bundle install
$(MAKE) setup
test: start
docker-compose run app rspec spec/
This simplifies most projects setup and day-to-day use immensely.
Now, instead of having to remember a bunch of different commands for each project I just set every project up to have the same public interface, regardless of if it’s running on the metal or Docker, if it’s Ruby or Golang, webapp or CLI utility.
Resources for Makefiles: