The Missing Bit

Using Makefiles

Why do I think of Makefiles now? Simply because I opened a 3 months old project and it took me 10 minutes to figure out how to build it. Yes, I could have written a README, but it was a home project (I know I should have…).

There have been a few discussions about using Makefiles to manage javascript projects. There is especially this post which highlights the different parts of setting up a Makefile with a javascript project.

I remember the time you would just make into a project, or make help to get the build options. This is discoverable and easy. It’s highly likely that a developer will have make available.

Just to be clear, this is not a post against any specialised build tool, I love my webpack (complicated) setup. But I now see webpack more alike gcc than make.


So, I’ve decided to put a Makefile in all my projects. In the end, it’s the simplest, easiest task runner in the wild. And it can invoke anything else if needed (gulp, webpack, mix, ...). Even if it’s only .PHONY targets, it’s fine, it’s an entry point.

You could always wrap rake with something like (written hastly, might end the world):

RAKE_TASKS = $(shell bundle exec rake -T |cut -d ' ' -f 2| sed s/:/\\\\:/g )

.PHONY: ${RAKE_TASKS}

${RAKE_TASKS}:
bundle exec rake $@

Just throw an .editorconfig in your project to ensure your Makefile uses tabs (I love how make is opiniated on this, even if I use spaces everywhere, I love how consistent it is, and I’m looking at Python when I say that).


I will certainly write an update after some time with Makefile in my non C projects.