Let's look at the C program. I mentioned that to rebuild the C program, you might issue the following commands: cc -c sum.c cc -c main.c cc sum.o main.o -o my_sum There are a few things one could improve on:
The make program addresses these needs. You can put your source files (sum.h, main.c and sum.c), along with a special makefile (which we'll discuss in the next page) in a directory, then simply type make each time you make changes to any of your source files. Anyone else who wants to build your program can just copy those four files, and type make — they don't have to know the (potentially gory) details of what it takes to build the program. If you've already built your program; then you edit, say, sum.c; and then you type make, main.c won't be re-compiled — because it doesn't need to be. This is called build avoidance — rebuilding only what needs to be built. This becomes important for programs with hundreds or thousands of source files. |