summaryrefslogtreecommitdiff
path: root/Makefile
blob: 666271a928d0f2e319708e0af727e37993918d4b (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
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
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/libbpf.a
export GO ?= go
export TEST_NAME ?= TestEventloop

all: bpfbuild gobuild

.PHONY: bpfbuild
bpfbuild:
	make -C ./internal/c redo
	cp -v ./internal/c/ior.bpf.o .

gen: generate
generate: generate

.PHONY: generate
generate:
	make -C ./internal/c generate
	make -C ./internal/tracepoints generate
	make -C ./internal/types generate

.PHONY: gobuild
gobuild:
	$(GO) build -tags netgo -ldflags '-w -extldflags "-static"' -o ior ./cmd/ior/main.go
gobuild_race:
	$(GO) build -tags netgo -ldflags '-w -extldflags "-static"' -race -o ior ./cmd/ior/main.go

.PHONY: clean
clean:
	find . -type f -name ior -delete
	if [ -e ior.bpf.o ]; then rm ior.bpf.o; fi
	make -C ./internal/c clean

.PHONY: mrproper
mrproper: clean
	find . -type f -name \*.zst -delete		
	find . -type f -name \*.collapsed -delete		
	find . -type f -name \*.svg -delete		
	find . -type f -name \*profile -delete		
	find . -type f -name \*.pdf -delete		
	find . -type f -name \*.tmp -delete		
	find . -type f -name palete.map -delete		

.PHONY: world
world: clean generate test all

.PHONY: prof
prof:
	$(GO) tool pprof -pdf ./ior ior.cpuprofile > cpuprofile.pdf && evince cpuprofile.pdf &
	$(GO) tool pprof -pdf ./ior ior.memprofile > memprofile.pdf && evince memprofile.pdf &

.PHONY: test
test:
	$(GO) clean -testcache
	$(GO) test ./... -v

.PHONY: test_specific
test_specific:
	$(GO) clean -testcache
	$(GO) test ./... -run ^$(TEST_NAME)$$ -v

.PHONY: test_foo
test_foo:
	$(GO) clean -testcache
	$(GO) test ./internal/types -v

.PHONY: bench
bench:
	$(GO) test ./... -v -bench=. -run xxx