aoc-2019-c

Advent of Code 2019 Solutions in C
git clone https://git.sinitax.com/sinitax/aoc-2019-c
Log | Files | Refs | README | sfeed.txt

Makefile (1521B)


      1PREFIX ?= /usr/local
      2INCLDIR ?= /include
      3LIBDIR ?= /lib
      4
      5CFLAGS += -I include -I lib/liballoc/include
      6CFLAGS += -Wunused-function -Wunused-variable -Wno-prototype 
      7CFLAGS += -Wconversion -Wsign-compare -Werror
      8
      9ifeq "$(DEBUG)" "1"
     10CFLAGS += -Og -g
     11else
     12CFLAGS += -O2
     13endif
     14
     15ifeq "$(ASSERT_ARGS)" "1"
     16CFLAGS += -DLIBHMAP_ASSERT_ARGS=1
     17endif
     18
     19ifeq "$(ASSERT_ALLOC)" "1"
     20CFLAGS += -DLIBHMAP_ASSERT_ALLLOC=1
     21endif
     22
     23all: build/libhmap.so build/libhmap.a build/test
     24
     25clean:
     26	rm -rf build
     27
     28cleanall: clean
     29	make -C lib/liballoc cleanall
     30
     31build:
     32	mkdir build
     33
     34lib/liballoc/build/liballoc.a:
     35	make -C lib/liballoc build/liballoc.a
     36
     37build/libhmap.a: src/hmap.c include/hmap.h libhmap.api | build
     38	$(CC) -o build/tmp.o src/hmap.c $(CFLAGS) -r
     39	objcopy --keep-global-symbols=libhmap.api build/tmp.o build/fixed.o
     40	$(AR) rcs $@ build/fixed.o
     41
     42build/libhmap.so: src/hmap.c include/hmap.h libhmap.lds | build
     43	$(CC) -o $@ src/hmap.c -fPIC $(CFLAGS) -shared \
     44		-Wl,-version-script libhmap.lds
     45
     46build/test: src/test.c build/libhmap.a lib/liballoc/build/liballoc.a  | build
     47	$(CC) -o $@ $^ -I include -I lib/liballoc/include -g
     48
     49install:
     50	install -m 644 include/hmap.h -t "$(DESTDIR)$(PREFIX)$(INCLDIR)"
     51	install -m 755 build/libhmap.a -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
     52	install -m 755 build/libhmap.so -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
     53
     54uninstall:
     55	rm -f "$(DESTDIR)$(PREFIX)$(INCLDIR)/hmap.h"
     56	rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libhmap.a"
     57	rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libhmap.so"
     58
     59.PHONY: all clean cleanall install uninstall