Generic Makefile
Update: Now also supports C++, see the Github repository) 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
andLD
) - Ability to amend
CFLAGS
,CPPFLAGS
,LDFLAGS
, orLDLIBS
via cli install
andclean
targets, the former also respectsPREFIX
- Generetion of gdb debug files
- Sane compiler defaults
You can find the repository containing the file on GitHub. 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.