Clemson University -- CPSC 231 -- Fall 2009 Example of a four-module program where separate assembly is managed by the Unix make utility m4 as ld (gcc -c) (gcc) main.m --------> main.s --------> main.o ------. \ memzero.m -----> memzero.s -----> memzero.o ----.\ >--> popf popcount.m ----> popcount.s ----> popcount.o ---'// // prttable.m ----> prttable.s ----> prttable.o --'/ / printf stub ' ---- % cat makefile OBJS = main.o memzero.o popcount.o prttable.o ASMS = main.s memzero.s popcount.s prttable.s popf: $(OBJS) gcc -gstabs $(OBJS) -o popf main.o: main.m m4 main.m >main.s gcc -gstabs -c main.s memzero.o: memzero.m m4 memzero.m >memzero.s gcc -gstabs -c memzero.s popcount.o: popcount.m m4 popcount.m >popcount.s gcc -gstabs -c popcount.s prttable.o: prttable.m m4 prttable.m >prttable.s gcc -gstabs -c prttable.s cleanup: /usr/bin/rm $(OBJS) $(ASMS) ---- "make" is name of the command; it expects a file named "makefile" to be present in the current directory a makefile is composed of a set of "rules" (must start in column 1) (must start with a tab) ... ... a rule begins with a dependency line, which lists file dependencies