# # makefile for sorted int list (recursive and iterative versions) # # 'make all' makes two executables # 'make OPT= all' makes the executable # with a non-default optimization level # (possible values are -g, -O0, etc.) # 'make clean' deletes object files # 'make xclean' deletes object files and executables # # to use valgrind to check for memory leaks and other malloc/free errors: # 'make OPT="-g -O0" all' # 'valgrind test-sorted-int-list-recur' and # 'valgrind test-sorted-int-list-iter' # CC = gcc OPT = -O CFLAGS = -Wall -pedantic -std=c99 $(OPT) EXES = test-sorted-int-list-recur test-sorted-int-list-iter OBJS = test-sorted-int-list.o sorted-int-list-recur.o sorted-int-list-iter.o all: $(EXES) test-sorted-int-list-recur: test-sorted-int-list.o sorted-int-list-recur.o $(CC) $^ -o $@ test-sorted-int-list-iter: test-sorted-int-list.o sorted-int-list-iter.o $(CC) $^ -o $@ sorted-int-list-recur.o: sorted-int-list-recur.c sorted-int-list.h sorted-int-list-iter.o: sorted-int-list-iter.c sorted-int-list.h .PHONY: clean clean: -rm $(OBJS) .PHONY: xclean xclean: -rm $(OBJS) $(EXES)