-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
82 lines (71 loc) · 2.02 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
BINARY_NAME=harpoon
BINARY_DIR=./bin
OUTPUT_DIR=./output
build-static-libbpfgo:
git clone https://github.com/aquasecurity/libbpfgo.git && \
cd libbpfgo/ && \
make libbpfgo-static
vmlinux.h:
bpftool btf dump file /sys/kernel/btf/vmlinux format c > ebpf/vmlinux.h
build-bpf: create-output-dir
clang -g -O2 -c -target bpf -D__TARGET_ARCH_x86 -o ${OUTPUT_DIR}/ebpf.o ebpf/ebpf.c
cp ${OUTPUT_DIR}/ebpf.o ./internal/embeddable/output/
build-go: create-bin-dir
go mod download
export CURRENT_DIR=$(shell pwd); \
CC=gcc \
CGO_CFLAGS="-I $$CURRENT_DIR/libbpfgo/output" \
CGO_LDFLAGS="-lelf -lz $$CURRENT_DIR/libbpfgo/output/libbpf/libbpf.a" \
go build \
-tags core,ebpf \
-v \
-o ${BINARY_DIR}/${BINARY_NAME} \
.
build-go-cover: create-bin-dir
go mod download
export CURRENT_DIR=$(shell pwd); \
CC=gcc \
CGO_CFLAGS="-I $$CURRENT_DIR/libbpfgo/output" \
CGO_LDFLAGS="-lelf -lz $$CURRENT_DIR/libbpfgo/output/libbpf/libbpf.a" \
go build \
-tags core,ebpf \
-v \
-cover \
-o ${BINARY_DIR}/${BINARY_NAME} \
.
build: create-bin-dir vmlinux.h build-static-libbpfgo build-bpf
go mod download
export CURRENT_DIR=$(shell pwd); \
CC=gcc \
CGO_CFLAGS="-I $$CURRENT_DIR/libbpfgo/output" \
CGO_LDFLAGS="-lelf -lz $$CURRENT_DIR/libbpfgo/output/libbpf/libbpf.a" \
go build \
-tags core,ebpf \
-v \
-o ${BINARY_DIR}/${BINARY_NAME} \
.
build-gh: create-bin-dir vmlinux.h build-static-libbpfgo build-bpf
ifndef GITHUB_REF_NAME
$(error GITHUB_REF_NAME is undefined)
endif
go mod download
export CURRENT_DIR=$(shell pwd); \
CC=gcc \
CGO_CFLAGS="-I $$CURRENT_DIR/libbpfgo/output" \
CGO_LDFLAGS="-lelf -lz $$CURRENT_DIR/libbpfgo/output/libbpf/libbpf.a" \
go build \
-tags core,ebpf \
-v \
-ldflags="-s -w -X 'github.com/alegrey91/harpoon/cmd.Version=${GITHUB_REF_NAME}'" \
-o ${BINARY_DIR}/${BINARY_NAME} \
.
create-bin-dir:
mkdir -p ${BINARY_DIR}
create-output-dir:
mkdir -p ${OUTPUT_DIR}
install:
cp ${BINARY_DIR}/${BINARY_NAME} /usr/local/bin/
clean:
rm -rf ${OUTPUT_DIR}
rm -rf ${BINARY_DIR}
rm -rf ./libbpfgo