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


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