-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
100 lines (83 loc) · 2.12 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
LIBUNWIND_PREFIX:=/usr
LIBBFD_PREFIX:=/usr
MAIN_BINS=ptrace-sampler ptrace-singlestep extract-vdso linux-gate.dso.1
TEST_BINS=app1 app2 app4 app7-libc app9-gl app11-sigchld
DIST_FILES= \
ptrace-sampler \
sample_reader.py samples2calltree.py resolve_addr.py \
syscalls.py cacher.py lib_finder.py \
start_sampling.sh \
README
PTRACE_SAMPLER_CXX_SRCS:= \
ptrace-sampler.C \
Common.C \
MemoryMappings.C \
DebugInterpreter.C \
Vdso.C \
PltList.C
HAVE_LIBUNWIND:=$(shell ls $(LIBUNWIND_PREFIX)/lib/libunwind-ptrace.a 2>/dev/null)
ifeq ($(HAVE_LIBUNWIND),)
LIBUNWIND_OPTIONS:=
else
LIBUNWIND_OPTIONS:= \
-DHAVE_LIBUNWIND=1 \
-I$(LIBUNWIND_PREFIX)/include/ \
-L$(LIBUNWIND_PREFIX)/lib/ \
-lunwind-ptrace -lunwind-generic
endif
HAVE_LIBBFD:=$(shell ls $(LIBBFD_PREFIX)/lib/libbfd.a 2>/dev/null)
ifeq ($(HAVE_LIBBFD),)
LIBBFD_OPTIONS:=
else
LIBBFD_OPTIONS:= \
-DHAVE_LIBBFD=1 \
-I$(LIBBFD_PREFIX)/include/ \
-L$(LIBBFD_PREFIX)/lib/ \
-lbfd -lopcodes -liberty
PTRACE_SAMPLER_CXX_SRCS+=Disassembler.C DebugCreator.C
endif
main: $(MAIN_BINS)
tests: $(TEST_BINS)
all: $(MAIN_BINS) $(TEST_BINS)
clean:
rm -f $(MAIN_BINS) $(TEST_BINS)
app%-gl: app%-gl.C
g++ -W -Wall -Wextra \
-g3 -O0 -rdynamic \
$+ \
-pthread \
-lGLU -lglut \
-o $@
app%: app%.C
g++ -W -Wall -Wextra \
-g3 -O0 -rdynamic \
-pthread \
-o $@ \
$+
ptrace-%: ptrace-%.C
g++ -W -Wall -Wextra \
-g3 -O0 \
-o $@ \
$+
ptrace-sampler: $(PTRACE_SAMPLER_CXX_SRCS)
g++ -W -Wall -Wextra \
-g3 -O2 \
-I. \
-o $@ \
$+ \
$(LIBBFD_OPTIONS) \
$(LIBUNWIND_OPTIONS)
extract-vdso: extract-vdso.C Common.C MemoryMappings.C Vdso.C
g++ -W -Wall -Wextra \
-g3 -O0 \
-o $@ \
$+
# extract VDSO (kernel-provided shared library) as file, for display in kcachegrind:
linux-gate.dso.1: extract-vdso
./extract-vdso linux-gate.dso.1
RELEASE_VERSION=$(shell date '+%Y%m%d-%H%M%S')
release: $(DIST_FILES)
mkdir ptrace-sampler-$(RELEASE_VERSION)
cp $(DIST_FILES) ptrace-sampler-$(RELEASE_VERSION)/
tar cvzf ptrace-sampler-release-$(RELEASE_VERSION).tgz ptrace-sampler-$(RELEASE_VERSION)/
rm -rf ptrace-sampler-$(RELEASE_VERSION)/