Makefile for SDL testbed
After playing with Makefiles to make this site, one thing I realized is that make would be more useful for a testbed project than my goto cmake, as it is way easier to create and manage a big number of targets. I started with the Makefile tutorial’s cookbook, I wanted to do the following:
- ✅ Configure SDL and its satellite libraries to be included and used;
- ✅ Create a target for demos (i.e small programs) for each
demo_*.cpp
undersrc/
subdirectory; - 🔍 Create a target for each subdirectory under
src
withdemo_
prefix; - ✅ Manage configuration for compilation and properly handle recompile when they change;
- ✅ Add some utility to list demos and to get/set a default demo.
This is the resulting Makefile:
Using it
With this I can create a foo.cpp file under src/
subdirectory with demo_
prefix and the following will just work:
$ make build/demo_foo
$ build/demo_foo