Introduce - Makefiles
Up until now, the code that we've written has all been inside of one main program. Compiling just the one main program is pretty straight-forward, and we haven't really needed any help in compiling them beyond typing in the compile command at the command line prompt with a couple of options.
However, it's very rare that anything beyond 'toy' or 'practice' programs are small enough to put into one main programs. As the tasks we want the computer to perform become more complex, it makes sense to have the main program call subprograms, which may in turn call other sub-programs. In addition, there exist libraries of existing programs that we can refer to instead of writing them again and re-inventing the wheel. Compiling sophisticated programs that refer to each other (And may in fact be written in separate files) becomes incredibly messy without a tool to help in the compilation process.
Makefiles are an extremely useful as a tool to help programmers compiling their code, especially when programs are written in more than one file. Makefiles also help speed up the infamous edit-compile-debug loop by speeding up the compile process tremendously.
However, just like programs, makefiles come with their own special, equally rigorous syntax that must be adhered to precisely in order to correctly compile our code. The Connect portion of this Module on Makefiles discusses how to construct makefiles and obey the rigorous syntax.
The Apply section will give us a chance to explore what we've learned about developing sophisticated programs that require complex compilation rules, and the Reflect and Extend sections will give us a chance to think about other ways of applying Makefile rules and where we can take these constructs from here.
|