This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
61 lines (49 loc) · 1.6 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
DOCKER_FILE?=Dockerfile
DOCKER_IMAGE?=akroh/go-ebpf-builder
UID=$(shell id -u)
GID=$(shell id -g)
SUDO=$(shell docker info >/dev/null 2>&1 || echo "sudo -E")
all: execsnoop socketsnoop
check:
@go get golang.org/x/tools/cmd/goimports
@goimports -l -local github.com/andrewkroh . | (! grep .) || (echo "Code differs from goimports' style ^" && false)
@go get github.com/elastic/go-licenser
@go-licenser -d
@go-licenser -d -ext '.c'
fmt:
@goimports -l -w -local github.com/andrewkroh .
@go-licenser
@go-licenser -ext '.c'
clean:
@rm -rf build cmd/execsnoop/execsnoop cmd/socketsnoop/socketsnoop
@find . -name '*.o' -exec rm {} \;
build_dir:
@mkdir -p build/bin
@mkdir -p build/test
execsnoop: build_dir
$(MAKE) -C exec/bpf
go build -o build/bin/execsnoop ./cmd/execsnoop
execsnoop-test: build_dir
go test -c ./exec/ -o build/test/exec.test
sudo build/test/exec.test -test.v
socketsnoop: build_dir
$(MAKE) -C socket/bpf
go build -o build/bin/socketsnoop ./cmd/socketsnoop
# For building inside of a Docker environment.
docker-all: build-docker-image
$(SUDO) docker run --rm \
-v $(PWD):/go/src/github.com/andrewkroh/go-ebpf \
--workdir=/go/src/github.com/andrewkroh/go-ebpf \
$(DOCKER_IMAGE) \
make all
# Fixing permissions on files generated in Docker.
sudo chown -R $(UID):$(GID) .
docker-run:
$(SUDO) docker run -it --rm \
-v $(PWD):/go/src/github.com/andrewkroh/go-ebpf \
--workdir=/go/src/github.com/andrewkroh/go-ebpf \
$(DOCKER_IMAGE) /bin/bash
build-docker-image:
$(SUDO) docker build -t $(DOCKER_IMAGE) -f $(DOCKER_FILE) .
delete-docker-image:
$(SUDO) docker rmi -f $(DOCKER_IMAGE)