The purpose of this lab is to understand how the make program works. It is a useful program for maintaining large programs that have been broken into many software modules. The program uses a file, usually named Makefile, that resides in the same directory as the source code. You should have such a file with the following contents in your directory. This file describes how to ``make'' a number of targets specified. There are two useful targets in the sample Makefile--lab3_rr and clean. Typing make lab3_rr causes the executable file lab3_rr to be created. Typing make clean causes all .o and the executable file lab3_rr to be removed.
The Makefile you will be using is shown below. As a matter of explanation the first line simply defines and gives a value to a make variable. The CFLAGS variable specifies the compile flags to use. The ``-g'' flag causes additional symbolic information to be saved for debugging.
The remaining text describes how to make the targets lab3_rr, lab3_stack.o, lab3_rr.o and clean. For each target is a list of dependencies (lab3_rr depends on lab3_rr.o and lab3_stack.o being up-to-date) followed by an operation line on how to make the target given the dependencies are up-to-date. WARNING: The operation line(s) for a target MUST begin with a TAB (do not use spaces). Make has other features, but this example shows the basics.
CFLAGS = -g lab3_rr: lab3_rr.o lab3_stack.o g++ $(CFLAGS) -o lab3_rr lab3_rr.o lab3_stack.o lab3_stack.o: lab3_stack.C lab3_stack.h g++ -c $(CFLAGS) lab3_stack.C lab3_rr.o: lab3_rr.C lab3_stack.h g++ -c $(CFLAGS) lab3_rr.C clean: rm *.o lab3_rr
Here is an outline of what you are to do for this lab:
> cp /cs/cs2005/pub/labs/lab3/* .You will now have a Makefile in your directory (will overwrite if one previously existed) and files beginning with lab3_.
You should turnin your revised versions of the files stack.C and stack.h. You do not need to turn in a script file for this lab.
/cs/cs2005/pub/bin/turnin lab3 lab3_stack.C lab3_stack.h