-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (108 loc) · 3.31 KB
/
Copy pathMakefile
File metadata and controls
126 lines (108 loc) · 3.31 KB
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
KVER = $(shell uname -r)
KMAJ = $(shell echo $(KVER) | sed -e 's/^\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*.*/\1/')
KMIN = $(shell echo $(KVER) | sed -e 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*.*/\1/')
KREV = $(shell echo $(KVER) | sed -e 's/^[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/')
PKGMGR = apt
UPDATE = update
INSTALL = install -y
ADDREPO = apt-key adv --keyserver
KEYSERVER = keyserver.ubuntu.com
GOPATH = ${HOME}/go/
kver_ge = $(shell \
echo test | awk '{if($(KMAJ) < $(1)) {print 0} else { \
if($(KMAJ) > $(1)) {print 1} else { \
if($(KMIN) < $(2)) {print 0} else { \
if($(KMIN) > $(2)) {print 1} else { \
if($(KREV) < $(3)) {print 0} else { print 1 } \
} } } }}' \
)
.PHONY: all
all: generate build
.PHONY: get-deps
get-deps:
ifneq ($(call kver_ge,4,9,0),1)
echo "pprof-ebpf requires kernel features found in 4.9.X and newer" && exit 1
endif
ifeq (,$(wildcard /lib/modules/$(KVER)))
sudo ${PKGMGR} ${INSTALL} linux-headers-${KVER}
endif
ifeq (,$(wildcard /usr/share/bcc/))
sudo ${ADDREPO} ${KEYSERVER} --recv-keys D4284CDD
sudo ${PKGMGR} ${UPDATE}
if ! [ -x `which git` -eq ""]; then sudo ${PKGMGR} ${INSTALL} git; fi
if ! [ `which go` -eq "" ]; then sudo ${PKGMGR} ${INSTALL} golang; fi
if ! [ `which clang` -eq "" ]; then sudo ${PKGMGR} ${INSTALL} \
llvm-3.8 libclang-3.8-dev bison \
libelf-dev flex libedit-dev zlib1g-dev \
automake libtool;\
fi
if ! [ `which cmake` -eq "" ]; then sudo ${PKGMGR} ${INSTALL} cmake; fi
if ! [ `which python` -eq "" ]; then sudo ${PKGMGR} ${INSTALL} python; fi
git clone https://github.com/iovisor/bcc.git \
/usr/share/bcc/ && \
cd /usr/share/bcc && git checkout v0.5.0 && \
mkdir ./build && cd ./build/ && \
cmake .. -DCMAKE_INSTALL_PREFIX=/usr && \
make && \
sudo make install;
endif
ifeq (,$(wildcard $(GOPATH)/bin/dep))
go get github.com/golang/dep
endif
ifeq (,$(wildcard /usr/local/bin/protoc))
cd /tmp/ && \
git clone https://github.com/google/protobuf.git && \
cd protobuf && \
./autogen.sh && \
./configure && make && make install
endif
.PHONY: build
build:
ifneq ($(call kver_ge,4,9,0),1)
echo "pprof-ebpf requires kernel features found in 4.9.X and newer" && exit 1
endif
ifeq (,$(wildcard ./vendor/github.com/))
dep ensure
endif
ifeq (,$(wildcard ./vendor/github.com/google/pprof/proto/profile.pb.go))
cd ./vendor/github.com/google/pprof/proto/ && \
protoc ./profile.proto
endif
mkdir -p ./build/
sudo -E go build -o ./build/pprof-ebpf ./main.go
docker-build:
ifneq ($(call kver_ge,4,9,0),1)
echo "pprof-ebpf requires kernel features found in 4.9.X and newer" && exit 1
endif
GOPATH=/go/ go env
ifeq (,$(wildcard ./vendor/github.com/))
GOPATH=/go/ dep ensure
endif
ifeq (,$(wildcard ./vendor/github.com/google/pprof/proto/profile.pb.go))
cd ./vendor/github.com/google/pprof/proto/ && \
protoc ./profile.proto
endif
mkdir -p ./build/
GOPATH=/go/ go build -o ./build/pprof-ebpf ./main.go
.PHONY: test
test:
ifneq ($(call kver_ge,4,9,0),1)
echo "pprof-ebpf requires kernel features found in 4.9.X and newer" && exit 1
endif
go test -v ./...
.PHONY: clean
clean:
rm pprof-ebpf
.PHONY: install
install:
ifneq ($(call kver_ge,4,9,0),1)
echo "pprof-ebpf requires kernel features found in 4.9.X and newer" && exit 1
endif
go install .
.PHONY: uninstall
uninstall:
rm `which pprof-ebpf`
.PHONY: generate
generate:
rm pkg/cpu/bpf.go pkg/heap/bpf.go
go generate ./...