Getting started with Makefiles: Overview
The subject of these pages is to provide a brief hands-on introduction
to Makefiles.
1. What are Makefiles?
-
As your programs are growing bigger and bigger you will sooner or later
reach a point where you have to split your code simply to avoid having
to recompile the whole source code after having applied (minor) changes
to one routine.
-
Having split the program into many files you now face the problem of how
to cope with all these files. You always have to recompile all the
files that are affected by your changes (if you forget some that may cause
strange behavior of your program).
-
Now you will be seeking for a program to decide on its own which files
have to be recompiled and then to compile them. That program is called
make and the files containig information about how make shall generate
the program are called Makefiles (where 'are called' means both
the filename - Makefile - and the terminus technicus - a Makefile)
2. Do I need extra software?
There is no extra software needed to use Makefiles. On Unix systems 'make'
comes with the very operating system (Unix has been mostly written in C).
On machines running other operating systems 'make' is either also
part of the OS distribution or comes with the compiler
3. Where to find an introduction?
Simply click HERE.
4. How to write more advanced Makefiles?
Thus far all Makefiles described how to make a certain object file from
a certain C++ file and how to do that in a certain computing environment.
The next step will consist in writing general rules how to make an object
file from a C++ file and to make your makefiles portable. HERE
I describe how to do that.
5. What about literature?
There is one very good book available entitled 'Mastering Make'. Not only
does it explain in detail the general usage of Makefiles - it also treats
in depth different make utilities available under different operating systems,
gives a comparison of these programs, brief summaries of the major features
(much like Unix man pages) and real-life examples of how to use make:
The authors are C. Tondo, A.Nathanson, and E. Yount, the complete title
is "Mastering Make, a guide to building programs on DOS, OS/2 and UNIX
systems". The Book was published 1994 by Prentice Hall, Englewood Cliffs,
New Jersey in second edition. The international book number (ISBN) is 0-13-121906-5.
Last changed tuesday, 6/2/1998