summaryrefslogtreecommitdiffstats
path: root/lib/liballoc/Makefile
blob: dab8818740ca9499a06cdabdae20b984cce1668c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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