3. Build Diversity Management¶
Let’s list some diversities that the Makefiles need to handle.
3.1. Platform / Host¶
Platform/Host used for compilation - Windows - Linux - Mac
e.g. On linux like systems, you will get access to command rm
to remove a file, or cp
to copy a file. On windows, these files are not available by default. So, how do you handle such differences?
If you are little more versed with Makefiles, then you must also know that there is a concept of shell
in Makefiles. Which one would you choose? sh
?, bash
? cmd
?
3.2. Compiler¶
Which compiler are you using for this compilation?
Assuming you are compiling on Windows, the build system may have many choices of the compilers.
Visual Studio and it’s various versions
GCC / GCC GNU C / GNUC G++
GCC based cross compilers
Clang
CL-Clang
If your software product is compiled using different compilers, then you will have to handle such complexities.
You may have to invoke cl.exe
in some case, gcc
in some other. (And the list goes on)
If you are using IDEs, then when ever you add or remove one file from one IDE, you will have to do same thing manually for other IDEs. Sometimes for different versions of the same IDE.
If you are using Makefiles for compilation, the Makefiles have to provide same information to visual studio compiler CL
and GCC Compilers gcc
(e.g. Include paths and defiles) with different syntax. e.g. using -I
and -D
for gcc based systems to provide include paths and defines and /I
and /D
for Visual Studio based systems. The Makefiles have to handle such complexity.
This is just tip of the iceberg…. There are many compiler and linker flags as well.
3.3. Choice of different libraries.¶
Your product may be dependent on other Vendors.
Assuming you are developing in C++ and you use the standard template library there are many options for the choice of implementation of the standard template library. See https://en.wikipedia.org/wiki/Standard_Template_Library#Implementations
So, how easily do you select swith across these STL Implementations?
3.4. Makefiles just keep getting complex (and slow)¶
There are small decisions that the Makefiles have to take for all above diversities/variants. All such decisions in make files pile up and generally slows down the build. Ir-respective of platform, such decisions have to be evaluated inside Makefiles and it becomes very complex to maintain such decisions as well.
Makefile generators take a pragmatic approach for this problem. The generators first detect what is the scope and parameters of build and then generate an optimized Makefiles. The generated makefiles are many times faster than the Manually written makefiles. We also get one more advantage, the build system generates does not only generate Makefile, but also generates IDE Files.