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 (1086B)


      1PREFIX ?= /usr/local
      2LIBDIR ?= /lib
      3INCLDIR ?= /include
      4
      5CFLAGS = -I include
      6
      7ifeq "$(DEBUG)" "1"
      8CFLAGS += -Og -g
      9else
     10CFLAGS += -O2
     11endif
     12
     13all: build/liballoc.so build/liballoc.a build/test
     14
     15clean:
     16	rm -rf build
     17
     18cleanall: clean
     19
     20build:
     21	mkdir build
     22
     23build/liballoc.a: src/allocator.c | build
     24	$(CC) -o build/tmp.o src/allocator.c $(CFLAGS) -r
     25	objcopy --keep-global-symbols=liballoc.api build/tmp.o build/fixed.o
     26	ar rcs $@ build/fixed.o
     27
     28build/liballoc.so: src/allocator.c include/allocator.h | build
     29	$(CC) -o $@ src/allocator.c $(CFLAGS) \
     30		-shared -Wl,-version-script liballoc.lds
     31
     32build/test: src/test.c build/liballoc.a | build
     33	$(CC) -o $@ $^ -I include
     34
     35install:
     36	install -m755 include/allocator.h -t "$(DESTDIR)$(PREFIX)$(INCLDIR)"
     37	install -m755 build/liballoc.a -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
     38	install -m755 build/liballoc.so -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
     39
     40uninstall:
     41	rm -f "$(DESTDIR)$(PREFIX)$(INCLDIR)/allocator.h"
     42	rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/liballoc.a"
     43	rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/liballoc.so"
     44
     45.PHONY: all clean cleanall install uninstall