summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 250f6b9db17bc8e1ae21b2fa995e97fbd0705ad8 (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
PREFIX ?= /usr/local
LIBDIR ?= /lib

CFLAGS = -I include

ifeq "$(DEBUG)" "1"
CFLAGS += -g
endif

all: build/libstl.a build/libstl.so build/bench

clean:
	rm -rf build

build:
	mkdir build

build/libstl.a: src/stl.c include/stl.h libstl.api | build
	$(CC) -c -o build/tmp.o $< $(CFLAGS) $(LDLIBS)
	objcopy --keep-global-symbols=libstl.api build/tmp.o build/fixed.o
	ar rcs $@ build/fixed.o

build/libstl.so: src/stl.c include/stl.h libstl.lds | build
	$(CC) -o $@ $< -fPIC $(CFLAGS) \
		-shared -Wl,-version-script libstl.lds

build/bench: src/bench.c build/libstl.a | build
	$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)

install:
	install -m755 build/libstl.a -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
	install -m755 build/libstl.so -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"

uninstall:
	rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libstl.a"
	rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libstl.so"

.PHONY: all clean install uninstall