# # makefile for sorted int list # # 'make test-sorted-int-list' makes the executable # (so does 'make main') # 'make OPT= test-sorted-int-list' 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 executable # # to use valgrind to check for memory leaks and other malloc/free errors: # 'make OPT="-g -O0" test-sorted-int-list' # 'valgrind test-sorted-int-list' # OPT = -O CFLAGS = -Wall -pedantic -std=c99 $(OPT) EXE = test-sorted-int-list OBJS = test-sorted-int-list.o test-helper.o sorted-int-list.o EXE_FM = test-filter-and-map OBJS_FM = test-filter-and-map.o sorted-int-list.o all: $(EXE) $(EXE_FM) $(EXE): $(OBJS) gcc $(CFLAGS) -o $(EXE) $(OBJS) $(EXE_FM): $(OBJS_FM) gcc $(CFLAGS) -o $(EXE_FM) $(OBJS_FM) test-sorted-int-list.o: test-sorted-int-list.c sorted-int-list.h test-filter-and-map.o: test-filter-and-map.c sorted-int-list.h test-helper.o: test-helper.c test-helper.h sorted-int-list.o: sorted-int-list.c sorted-int-list.h .PHONY: clean clean: -rm $(OBJS) $(OBJS_FM) .PHONY: xclean xclean: -rm $(OBJS) $(EXE) $(EXE_FM)