Makefile (2131B)
1CFLAGS = -I lib/libdvec/include -I lib/libhmap/include 2CFLAGS += -I lib/libmaxint/include -I lib/liballoc/include 3CFLAGS += -I lib/liblist/include 4 5CFLAGS += -Wunused-variable -Wunused-function -Wformat 6CFLAGS += -Wconversion -Wsign-compare 7CFLAGS += -I common -g -Werror -std=c99 8 9ifeq "$(DEBUG)" "1" 10CFLAGS += -DLIBDVEC_ASSERT_ARGS -DLIBDVEC_ASSERT_ALLOC 11LIBDVEC_ENV = DEBUG=1 ASSERT_ALLOC=1 ASSERT_ARGS=1 12CFLAGS += -DLIBHMAP_ASSERT_ARGS -DLIBHMAP_ASSERT_ALLOC 13LIBHMAP_ENV = DEBUG=1 ASSERT_ALLOC=1 ASSERT_ARGS=1 14LIBMAXINT_ENV = DEBUG=1 15LIBALLOC_ENV = DEBUG=1 16CFLAGS += -DLIBLIST_ASSERT_ARGS 17LIBLIST_ENV = DEBUG=1 18LIBPQ_ENV = DEBUG=1 19endif 20 21DAYS = $(shell seq 1 25 | xargs printf "%02i\n") 22 23all:: build run 24 25include */info.mk 26 27lib/libdvec/build/libdvec.a: 28 make -C lib/libdvec build/libdvec.a $(LIBDVEC_ENV) 29 30lib/libhmap/build/libhmap.a: 31 make -C lib/libhmap build/libhmap.a $(LIBHMAP_ENV) 32 33lib/libmaxint/build/libmaxint.a: 34 make -C lib/libmaxint build/libmaxint.a $(LIBMAXINT_ENV) 35 36lib/liballoc/build/liballoc.a: 37 make -C lib/liballoc build/liballoc.a $(LIBALLOC_ENV) 38 39lib/liblist/build/liblist.a: 40 make -C lib/liblist build/liblist.a $(LIBLIST_ENV) 41 42lib/libpq/build/libpq.a: 43 make -C lib/libpq build/libpq.a $(LIBPQ_ENV) 44 45define make-day 46 47build:: $1/main 48$1/main: $($(1)_SRC) $($(1)_HDR) 49 $(CC) -o $1/main $($(1)_SRC) $(CFLAGS) $($(1)_CFLAGS) \ 50 $(LDFLAGS) $($(1)_LDFLAGS) $(LDLIBS) $($(1)_LDLIBS) 51 52.PHONY: $1/run 53run:: $1/run 54$1/run: $1/main 55 @echo "== day $1 ==" 56 @echo -en "\npart 1: " && cd $1 && time ./main 1 57 @echo -en "\npart 2: " && cd $1 && time ./main 2 58 @echo "" 59 60.PHONY: $1/debug 61debug:: $1/debug 62$1/debug: $1/main 63 @echo "== day $1 part 1 ==" 64 @cd $1 && valgrind --error-exitcode=1 --leak-check=full \ 65 --show-leak-kinds=all ./main 1 66 @echo "== day $1 part 2 ==" 67 @cd $1 && valgrind --error-exitcode=1 --leak-check=full \ 68 --show-leak-kinds=all ./main 2 69 70endef 71 72$(foreach day,$(DAYS),$(eval $(call make-day,$(day)))) 73 74clean: 75 rm -f */main 76 77cleanall: clean 78 make -C lib/libdvec clean 79 make -C lib/libhmap clean 80 make -C lib/libmaxint clean 81 make -C lib/liballoc clean 82 83.PHONY: all build run debug clean cleanall