blob: c47a37122eeaba197f48e787fb53d0f1887fa4ed (
plain)
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
|
export LIBBPFGO = $(CURDIR)/../libbpfgo
export CC = clang
export GOOS = linux
export GOARCH = amd64
export CGO_CFLAGS = -I$(LIBBPFGO)/output -I$(LIBBPFGO)/selftest/common
export CGO_LDFLAGS = -lelf -lzstd $(LIBBPFGO)/output/libbpf.a
all: build run
build: bpfbuild gobuild
.PHONY: bpfbuild
bpfbuild:
bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
$(CC) -g -O2 -Wall -fpie -target bpf -D__TARGET_ARCH_amd64 -I$(LIBBPFGO)/output -c ioriotng.bpf.c -o ioriotng.bpf.o
.PHONY: gobuild
gobuild:
echo 'package internal' > internal/opids.go
echo >> internal/opids.go
sed -E 's/#define (.*) ([0-9]+)/const \1 = \2/' opids.h >> internal/opids.go
go build -tags netgo -ldflags '-w -extldflags "-static"' -o ioriotng ./cmd/ioriotng/main.go
.PHONY: clean
clean:
find . -type f -name ioriotng -delete
find . -name \*.o -delete
find . -name vmlinux.h -delete
.PHONY: run
run:
sudo ./ioriotng -uid $$(id -u)
|