@@ -20,11 +20,13 @@ $(TARGET): libpcap/libpcap.a
2020 -ldflags " -w -s \
2121 -X ' github.com/cilium/pwru/internal/pwru.Version=${VERSION}' "
2222
23+ # # Build libpcap for static linking
2324libpcap/libpcap.a :
2425 cd libpcap && \
2526 CC=$(LIBPCAP_CC ) ./configure --disable-rdma --disable-shared --disable-usb --disable-netmap --disable-bluetooth --disable-dbus --without-libnl --host=$(LIBPCAP_ARCH ) && \
2627 make
2728
29+ # # Spin up a docker container to build a new release
2830release :
2931 docker run \
3032 --rm \
@@ -35,16 +37,19 @@ release:
3537 git config --global --add safe.directory /pwru && \
3638 make local-release"
3739
40+ # # Build a new release
3841local-release : clean
3942 # TODO(brb) remove once https://github.com/cilium/pwru/issues/246 is resolved
4043 clang --version
4144 gcc --version
4245 ARCHS=' amd64 arm64' ./local-release.sh
4346
47+ # # Install the binary locally
4448install : $(TARGET )
4549 $(INSTALL ) -m 0755 -d $(DESTDIR )$(BINDIR )
4650 $(INSTALL ) -m 0755 $(TARGET ) $(DESTDIR )$(BINDIR )
4751
52+ # # Clean up build artifacts
4853clean :
4954 rm -f $(TARGET )
5055 rm -f kprobepwru_bpf*
@@ -53,7 +58,32 @@ clean:
5358 rm -f kprobemultipwruwithoutoutputskb_bpf*
5459 cd libpcap/ && make clean || true
5560
61+ # # Run GO tests
5662test :
5763 $(GO ) test -timeout=$(TEST_TIMEOUT ) -race -cover $$($(GO ) list ./...)
5864
65+ # COLORS
66+ GREEN := $(shell tput -Txterm setaf 2)
67+ YELLOW := $(shell tput -Txterm setaf 3)
68+ WHITE := $(shell tput -Txterm setaf 7)
69+ RESET := $(shell tput -Txterm sgr0)
70+
71+ TARGET_MAX_CHAR_NUM =20
72+ # # Show this help
73+ help :
74+ @echo ' '
75+ @echo ' Usage:'
76+ @echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
77+ @echo ' '
78+ @echo ' Targets:'
79+ @awk ' /^[a-zA-Z\-\_0-9]+:/ { \
80+ helpMessage = match(lastLine, /^# # (.*)/); \
81+ if (helpMessage) { \
82+ helpCommand = substr($$ 1, 0, index($$ 1, " :" )-1); \
83+ helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
84+ printf " ${YELLOW} %-$( TARGET_MAX_CHAR_NUM) s${RESET} ${GREEN} %s${RESET} \n" , helpCommand, helpMessage; \
85+ } \
86+ } \
87+ { lastLine = $$ 0 }' $(MAKEFILE_LIST)
88+
5989.PHONY : $(TARGET ) release local-release install clean test
0 commit comments