Makefile

# httptap build targets
# see mercemay.top/src/httptap/

CLANG   ?= clang
STRIP   ?= llvm-strip
GO      ?= go

BPF_SRC := internal/tracer/tracer.bpf.c
BPF_OBJ := internal/tracer/tracer.bpf.o

CFLAGS  := -O2 -g -Wall -Werror \
           -target bpf \
           -D__TARGET_ARCH_$(shell uname -m | sed 's/x86_64/x86/;s/aarch64/arm64/')

BIN     := bin/httptap

.PHONY: all build bpf test vet clean

all: build

bpf: $(BPF_OBJ)

$(BPF_OBJ): $(BPF_SRC)
	$(CLANG) $(CFLAGS) -c $< -o $@
	$(STRIP) -g $@

build: bpf
	mkdir -p bin
	$(GO) build -trimpath -ldflags '-s -w' -o $(BIN) ./cmd/httptap

test:
	$(GO) test ./...

vet:
	$(GO) vet ./...

clean:
	rm -f $(BPF_OBJ) $(BIN)
	rm -rf bin