Home Segments Index Top Previous Next

719: Mainline

The following is a complete makefile for the analyze_train program; note that the make utility interprets as comments lines beginning with # characters:

# makefile for analyze_train program 
  
analyze_train: trains.o containers.o cars.o 
        CC -o analyze_train trains.o containers.o cars.o 
  
trains.o: trains.cxx containers.h cars.h 
        CC -c trains.cxx 
  
containers.o: containers.cxx containers.h 
        CC -c containers.cxx 
  
cars.o: cars.cxx cars.h containers.h 
        CC -c cars.cxx 

The make utility is smart enough to propagate changes properly through the dependencies. For example, noting a change to the cars.cxx file, make produces a new cars.o object-code file. Then, noting a change to the cars.o file, make produces a new analyze_train executable file.