-
Notifications
You must be signed in to change notification settings - Fork 226
/
makefile
175 lines (154 loc) · 5.63 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#! /bin/make
# Makefile for dtrace. Everything is put into the build/ dir
# (well, nearly). Kernel litters the source directory, but dtrace
# the userland binary is in build/
# Allow me to create tmp releases.
rel=`if [ -z $$REL ] ; then date +%Y%m%d ; else echo $$REL ; fi`
RELDIR=dtrace
######################################################################
# Avoid UTF quoted strings from gcc. #
######################################################################
LANG=C
UNAME_M=`uname -m`
NOPWD = --no-print-directory
MAKEFLAGS += --no-print-directory
ifdef BUILD_KERNEL
BUILD_DIR=build-$(BUILD_KERNEL)
else
BUILD_DIR=build-$(shell uname -r)
endif
# Use sudo if you want ...
SUDO=if [ -x $$HOME/bin/setuid ]; then setuid root ; else sudo fi
######################################################################
# List of drivers we have: #
# #
# ctf - compact type framework. #
# #
# dtrace: The grand daddy which marshalls the other components. #
# #
# fasttrap - trace user land applications. #
# #
# fbt - function boundary tracing - provider to intercept any #
# function #
# #
# systrace - system call tracing. #
######################################################################
DRIVERS = dtrace
notice: .first-time
echo rel=$(rel)
@echo "make all - build everything - auto-detect (32 or 64 bit)"
@echo "make clean - clean out *.o/*.a and binaries"
@echo "make install - install files into target locations"
@echo "make release - create a new tarball for distribution"
@echo "make load - install the driver"
@echo "make unload - remove the driver"
@echo "make test - run cmd/dtrace regression tests."
.first-time:
cat doc/README.first
touch .first-time
release:
tools/mkrelease.pl $$REL
######################################################################
# Non-real releases, for my benefit. #
######################################################################
beta:
tools/mkrelease.pl -nocopy $$REL
all:
BUILD_DIR=$(BUILD_DIR) \
tools/mkdriver.pl driver-kmem ; \
tools/build.pl $(BUILD_DIR) $(UNAME_M)
cmds:
BUILD_DIR=$(BUILD_DIR) tools/build.pl -make do_cmds $(BUILD_DIR) $(UNAME_M)
all0: do_cmds kernel
do_cmds:
cd tests ; $(MAKE) $(NOPWD)
cd libctf ; $(MAKE) $(NOPWD)
cd libdtrace ; $(MAKE) $(NOPWD)
cd liblinux ; $(MAKE) $(NOPWD)
cd libproc/common ; $(MAKE) $(NOPWD)
cd librtld ; $(MAKE) $(NOPWD)
cd cmd/dtrace ; $(MAKE) $(NOPWD)
cd cmd/ctfconvert ; $(MAKE) $(NOPWD)
cd cmd/instr ; $(MAKE) $(NOPWD)
cd usdt/c ; $(MAKE) $(NOPWD)
######################################################################
# We need the driver-kmem (/proc/dtrace_kmem) loaded before we #
# can build the real driver - because very old kernels wont #
# expose old_rsp value. #
######################################################################
kernel:
tools/mkdriver.pl driver-kmem all
tools/mkdriver.pl all
tools/mkdriver.pl driver-2 all
tools/mkctf.sh
clean:
rm -rf build?*
rm -f usdt/*/*.o
rm -f usdt/*/*.so
cd libctf ; $(MAKE) clean
cd libdtrace ; $(MAKE) clean
cd liblinux ; $(MAKE) clean
cd libproc/common ; $(MAKE) clean
cd cmd/dtrace ; $(MAKE) clean
tools/mkdriver.pl clean
install: build/dtrace build/config.sh
. build/config.sh ; \
mkdir -p "$(DESTDIR)"/usr/lib/dtrace/$$CPU_BITS ; \
rm -f "$(DESTDIR)"/usr/lib/dtrace/types.d ; \
mkdir -p "$(DESTDIR)"/usr/sbin/ ; \
install -m 4755 -o root build/dtrace "$(DESTDIR)"/usr/sbin/dtrace ; \
install -m 644 -o root build/drti.o "$(DESTDIR)"/usr/lib/dtrace/$$CPU_BITS/drti.o
mkdir -p "$(DESTDIR)"/etc/ ; \
if [ ! -f "$(DESTDIR)"/etc/dtrace.conf ] ; then \
install -m 644 -o root etc/dtrace.conf "$(DESTDIR)"/etc/dtrace.conf ; \
fi
if [ -f "build/linux-`uname -r`.ctf" ]; then \
install -m 644 -o root build/linux-`uname -r`.ctf "$(DESTDIR)"/usr/lib/dtrace ; \
fi
install -m 644 -o root etc/io.d "$(DESTDIR)"/usr/lib/dtrace
install -m 644 -o root etc/sched.d "$(DESTDIR)"/usr/lib/dtrace
install -m 644 -o root etc/unistd.d "$(DESTDIR)"/usr/lib/dtrace
scripts/mkinstall.pl -o="$(DESTDIR)"/usr/lib/dtrace
newf:
tar cvf /tmp/new.tar `find . -newer TIMESTAMP -type f | \
grep -v /build/ | \
grep -v /build- | grep -v ./tags | \
grep -v ./cmd/dtrace/dtrace$$ | \
grep -v dt_grammar.h | \
grep -v '\*.so' | \
grep -v '\.o$$'`
tar:
tar cvf /tmp/dtrace.tar `find . -type f -o -type l | \
grep -v /build/ | \
grep -v /build- | grep -v ./tags | \
grep -v ./cmd/dtrace/dtrace$$ | \
grep -v dt_grammar.h | \
grep -v '\*.so' | \
grep -v '\.o$$'`
test:
tools/tests.pl
# tools/runtests.pl
testloop:
while true ; do tools/tests.pl run </dev/null ; done
######################################################################
# Load the driver -- we chmod 666 til i work out how to make the #
# driver do it. Otherwise dtrace needs to be setuid-root. #
######################################################################
load:
tools/load.pl
unl unload:
tools/sudo /sbin/rmmod dtracedrv
######################################################################
# Validate compilation on the kernels on my system(s) #
# 'warn' is a simple tool to color code errors/warnings and give #
# grand totals. If anyone wants a copy, let me know and I will #
# put out the source, but I need to de-crispify it, before it #
# will run. Its a single C program. #
######################################################################
kernels:
tools/make_kernels.pl
x:
rdate delly ; \
mkupdate -m delly ; \
make all
tools/load.pl