# A Makefile to build sbs # The CFLAGS variable contains a set of compiler flags # -g means include information for a debugger # -Wall means print out all warnings # Your submitted progam should compile cleanly with no warning messages. # -ansi -pedantic are not required for this programs submitted for 209 CFLAGS = -g -Wall # The standard set of variables found in most Makefiles # LIBS and INCLUDES are empty because we do not need any special libraries # or include paths. CC = gcc LIBS = INCLUDES = OBJS = psort.o data.o readn.o writen.o SRCS = psort.c data.c readn.c writen.c HDRS = data.h io.h # The first target is the default target. If you type "make" this is the # rule that will be evaluated. This target depends on sbs which is the # next target. (Note that if you want to compile more than one program # using the same Makefile, list all targets as dependencies in the default # target.) all: psort readurls showurls ssort # The variable $@ has the value of the target. In this case $@ = pusage psort: ${OBJS} ${CC} ${CFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS} readurls: readurls.o ${CC} ${CFLAGS} -o $@ readurls.o -lm showurls: showurls.o ${CC} ${CFLAGS} -o $@ showurls.o ssort: ssort.o ${CC} ${CFLAGS} -o $@ ssort.o data.o # This rule tells make how to create .o files (which are dependencies in # the psort rule). Since readn depends on "readn.o", make looks # for a file called "readn.c" in the current directory and uses this # rule to compile the file. The variable $< has the value of the .c # file that it found. .c.o: ${CC} ${CFLAGS} ${INCLUDES} -c $< # To ensure that when you change a header file the dependencies are properly # accounted for, run make depend when ever you add a new source file or some # #include statements in a file. depend: makedepend ${SRCS} # An easy way to keep your directory clean clean: rm *.o core *~ # A handy rule to package up your code. tar: tar cf psort-code.tar Makefile *.c *.h runtests # A favourite rule of mine. It creates a postscript file and simplifies # printing your code. It saves on paper by combining all the files into one # before printing. print: more Makefile $(HDRS) $(SRCS) | enscript -2r -p listing.ps # DO NOT DELETE