Generic Makefile

Update: Now also supports C++, see the Github repository[1] for the updated file.

In every single project, or even just test, I write the same simple Makefile over and over, by now I can write it without looking up anything. And if I forgot something, I would go through my old projects, to dig up the definition I need.
Today I got fed up with that, and decided to write one completely generic Makefile I can just reuse in all my projects. It only requires a reasonably new make, nothing else.

It features:

  • Automatic detection of changes in dependencies (eg header files)
  • Detection of system compiler / linker (via environment variables CC and LD)
  • Ability to amend CFLAGS, CPPFLAGS, LDFLAGS, or LDLIBS via cli
  • install and clean targets, the former also respects PREFIX
  • Generetion of gdb debug files
  • Sane compiler defaults

You can find the repository containing the file on GitHub[1:1]. Currently it only supports C, but I might add C++ support in the feature, be sure to keep an eye on my blog to be notified about any news.

  1. ↩︎ ↩︎