Skip to content

Commit 4cae7e7

Browse files
committed
helloworld-go: add Makefile
1 parent 54aade0 commit 4cae7e7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

ebpf-examples/helloworld-go/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CLANG ?= clang-10
2+
CFLAGS ?= -O2 -g -Wall -Werror
3+
4+
LIBEBPF_TOP = /home/tonybai/go/src/github.com/cilium/ebpf
5+
EXAMPLES_HEADERS = $(LIBEBPF_TOP)/examples/headers
6+
7+
all: generate
8+
9+
generate: export BPF_CLANG=$(CLANG)
10+
generate: export BPF_CFLAGS=$(CFLAGS)
11+
generate: export BPF_HEADERS=$(EXAMPLES_HEADERS)
12+
generate:
13+
go generate ./...

ebpf-examples/helloworld-go/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"github.com/cilium/ebpf/rlimit"
1414
)
1515

16+
// $BPF_CLANG, $BPF_CFLAGS and $BPF_HEADERS are set by the Makefile.
17+
//go:generate bpf2go -cc $BPF_CLANG -cflags $BPF_CFLAGS -target bpfel,bpfeb bpf helloworld.bpf.c -- -I $BPF_HEADERS
1618
func main() {
1719
stopper := make(chan os.Signal, 1)
1820
signal.Notify(stopper, os.Interrupt, syscall.SIGTERM)

0 commit comments

Comments
 (0)