Simple make system - putting it all together
So putting all the build principles together I built a makefile system which is very simple to use. Read the C++ Compiler Concepts and Make - Concepts to understand it.
You can see it in action in a tutorial video I use for my team.
To build an executable called test it involves:
Place the c and cpp files for the application in a directory.
Add a makefile. The makefile should list the directories with other library code you want to compile and link. Here is an example:
DIRS=\
TEST\
BAS\
include ../make/makefile.core
It links all the files together into a single statically linked binary which is either test or test.exe under windows.
It’s fast and simple.
It works natively on windows and it’s fast since it doesn’t invoke submake processes.
It doesn’t require any other tools other than GNU make and the Microsoft compiler for that platform.
It implements support for dependency files under Mac and Linux so if you change a header and do a build you’ll get a minimal rebuild.
It makes use of ccache under Mac and Linux so that if you do a second compile it’s much faster
Because it uses wildcard matching to build up the list of target files there is no need to manually maintain lists of source or object files.
It doesn’t bother with creating intermediate library files since when I ship applications I generally think it is easier to support statically linked binaries.
You can get an up to date copy of makefile.core from my public repository:
https://github.com/eliotmuirgrid/core/blob/main/make/makefile.core
To try out the makefile system you can follow the instructions for the C++ tracing sandbox.
One problem we ran into with windows with this system was the length of the command line got exceeded. @Vismay Shah needs to update the concepts site to show the solution to this problem.
Â