PREFIX ?= /usr/local LIBDIR ?= /lib INCLDIR ?= /include CFLAGS = -I include ifeq "$(DEBUG)" "1" CFLAGS += -Og -g else CFLAGS += -O2 endif all: build/liballoc.so build/liballoc.a build/test clean: rm -rf build cleanall: clean build: mkdir build build/liballoc.a: src/allocator.c | build $(CC) -o build/tmp.o src/allocator.c $(CFLAGS) -r objcopy --keep-global-symbols=liballoc.api build/tmp.o build/fixed.o ar rcs $@ build/fixed.o build/liballoc.so: src/allocator.c include/allocator.h | build $(CC) -o $@ src/allocator.c $(CFLAGS) \ -shared -Wl,-version-script liballoc.lds build/test: src/test.c build/liballoc.a | build $(CC) -o $@ $^ -I include install: install -m755 include/allocator.h -t "$(DESTDIR)$(PREFIX)$(INCLDIR)" install -m755 build/liballoc.a -t "$(DESTDIR)$(PREFIX)$(LIBDIR)" install -m755 build/liballoc.so -t "$(DESTDIR)$(PREFIX)$(LIBDIR)" uninstall: rm -f "$(DESTDIR)$(PREFIX)$(INCLDIR)/allocator.h" rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/liballoc.a" rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/liballoc.so" .PHONY: all clean cleanall install uninstall