-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
42 lines (31 loc) · 1.24 KB
/
Makefile
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
dir = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
EXAMPLES = $(patsubst %, %test, $(dir $(wildcard examples/*/target.c)))
CFLAGS = -O2 -Wall -fpic -I/usr/include/json-c $(EXTRA_CFLAGS)
# TODO: use CMake or something, because this is not correct on every computer
CFLAGS += -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include
LDLIBS = -ltracefs -ltraceevent -ldl -ljson-c -lglib-2.0
LDLIBS += -lgsl -lgslcblas -lm
obj = config.o main.o trace.o stats.o
.PHONY: clean examples install
libk-race.so: $(obj)
$(CC) -shared -o libk-race.so $(obj) $(LDLIBS)
prefix ?= /usr/local
install: libk-race.so
if [ ! -d $(prefix)/include/k-race ]; then \
install -m 0755 -d $(prefix)/include/k-race; \
fi; \
if [ ! -d $(prefix)/lib ]; then \
install -m 0755 -d $(prefix)/lib; \
fi; \
install -m 0755 libk-race.so $(prefix)/lib; \
install -m 0644 k-race.h $(prefix)/include/k-race;
.SECONDEXPANSION:
$(EXAMPLES): $$(dir $$@)target.c
$(CC) -I $(dir) -L $(dir) -Wall $(EXTRA_CFLAGS) -o $@ $(dir $@)target.c -lk-race
examples: $(EXAMPLES)
config.o: config.h
trace.o: config.h trace.h
main.o: config.h k-race.h stats.h trace.h
stats.o: stats.h
clean:
rm *.o libk-race.so examples/*/test