Anatomy of a Makefile



next up previous contents index
Next: Source Code Control Up: The Make Utility Previous: The Make Utility

Anatomy of a Makefile


# Makefile for kp archive Define a lists of object files. LIBOBJ = albmom.o energy.o prntio.o OBJ = kp.o bimom.o handle.o graf.o FC = f77 Define the Fortran Compiler. FFLAGS = -O $(DEBUG) Define flags for Fortran compiler all: kplib.a kp kabs Define dummy target all. kp: $(OBJ) kplib.a kp depends on all files defined inOBJ and kp library. $(FC) $(FFLAGS) -o kp $(OBJ) kplib.a kplib.a: $(LIBOBJ) To make the kp library, ar r kplib.a $(LIBOBJ) use the ar command. kabs: To make kabs, cd kabs; make kabs change directory & issue make. clean: Dummy target for /bin/rm *.o cleaning up the directory.

Notice that make with no options uses the first target in the makefile. Traditionally, there is a dummy target called all and we have defined an all above. After that, we change to the directory kabs, which contains a makefile, and issue make.



next up previous contents index
Next: Source Code Control Up: The Make Utility Previous: The Make Utility