Home Segments Index Top Previous Next

694: Mainline

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

# makefile for analyze_trades program 
  
analyze_trades: main.o trades.o mode.o 
        cc -o analyze_trades main.o trades.o mode.o 
  
main.o: main.c trades.h mode.h 
        cc -c main.c 
  
trades.o: trades.c trades.h 
        cc -c trades.c 
  
mode.o: mode.c mode.h 
        cc -c mode.c 

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