diff options
| author | Paul Buetow <paul@buetow.org> | 2024-02-11 23:18:26 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-02-11 23:18:26 +0200 |
| commit | 3e988cebf28b1c03d8be4aac0cad7fd2a59701ff (patch) | |
| tree | 7135d7d703cd953dd988fb33eedff6a41c0a80d3 | |
| parent | 38a1666d39d834a2d2bd69662291afd9a63b2fd6 (diff) | |
move all to makefiles
| -rw-r--r-- | Makefile | 22 | ||||
| -rwxr-xr-x | build.sh | 20 |
2 files changed, 20 insertions, 22 deletions
@@ -1,9 +1,27 @@ +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: - ./build.sh + +build: bpfbuild gobuild + +bpfbuild: + bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h + $(CC) -g -O2 -Wall -fpie -I$(LIBBPFGO)/selftest/common -target bpf -D__TARGET_ARCH_amd64 -I$(LIBBPFGO)/output -I$(LIBBPFGO)/selftest/common -c ioriotng.bpf.c -o ioriotng.bpf.o + +gobuild: + echo 'package main' > internal/opids.go + echo >> internal/opids.go + sed -E 's/#define (.*) ([0-9]+)/const \1 = \2/' opids.h >> internal/opids.go + go build -race -tags netgo -ldflags '-w -extldflags "-static"' -o ioriotng ./cmd/ioriotng/main.go clean: find . -type f -name ioriotng -delete find . -name \*.o -delete find . -name vmlinux.h -delete + run: sudo ./ioriotng diff --git a/build.sh b/build.sh deleted file mode 100755 index cb26319..0000000 --- a/build.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -xeuf -o pipefail - -declare -r LIBBPFGO="$(pwd)/../libbpfgo" - -bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h -echo 'package main' > internal/opids.go -echo >> internal/opids.go -sed -E 's/#define (.*) ([0-9]+)/const \1 = \2/' opids.h >> internal/opids.go - -clang -g -O2 -Wall -fpie -I../libbpfgo/selftest/common -target bpf -D__TARGET_ARCH_amd64 -I../libbpfgo/output -I../libbpfgo/selftest/common -c ioriotng.bpf.c -o ioriotng.bpf.o - -export CC=clang -export CGO_CFLAGS="-I$LIBBPFGO/output -I$LIBBPFGO/selftest/common" -export CGO_LDFLAGS="-lelf -lzstd $LIBBPFGO/output/libbpf.a" -export GOOS=linux -export GOARCH=amd64 - -go build -race -tags netgo -ldflags '-w -extldflags "-static"' -o ioriotng ./cmd/ioriotng/main.go |
