-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
64 lines (48 loc) · 1.19 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
.PHONY: all test
all: ldso
TESTS := got_finder_test \
plt_caller_test
test: $(TESTS)
MAIN_OBJS := log.o \
got_finder.o \
ptracer.o \
main.o
MAIN_TEST_OBJS := \
got_finder_test.o \
test.o \
X64_MAIN_OBJS := \
x64/plt_caller.o \
X64_TEST_OBJS := \
x64/plt_caller_test.o \
OBJS := $(MAIN_OBJS) \
\
$(MAIN_TEST_OBJS) \
\
$(X64_MAIN_OBJS) \
\
$(X64_TEST_OBJS)
CFLAGS := -O0 -g -Wall -I. -fPIC -fvisibility=hidden
LDFLAGS := -pie
LDLIBS := -lpthread -lrt
-include $(OBJS:.o=.d)
%.o: %.c
gcc $(CFLAGS) -c $*.c -o $*.o
gcc -MM $(CFLAGS) $*.c > $*.d
%.o: %.cpp
g++ $(CFLAGS) -c $*.cpp -o $*.o
g++ -MM $(CFLAGS) $*.cpp > $*.d
%.o: %.S
g++ $(CFLAGS) -c $*.S -o $*.o
g++ -MM $(CFLAGS) $*.S > $*.d
got_finder_test: got_finder.o log.o got_finder_test.o ptracer.o
g++ $(LDFLAGS) -o $@ $^ $(LDLIBS) -ldl
plt_caller_test: got_finder.o log.o ptracer.o x64/plt_caller_test.o x64/plt_caller.o libtest.so
g++ $(LDFLAGS) -o $@ $^ $(LDLIBS) -ldl
libtest.so: test.o
g++ $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
ldso: $(MAIN_OBJS) $(X64_MAIN_OBJS)
g++ $(LDFLAGS) -o $@ $^ $(LDLIBS)
clean:
rm *.o *.d **/*.o **/*.d
test_all: $(TESTS)
$(foreach test, $^, $(info ./$(test)))