From 7ce6f03860483bd44e094e4b559920ae3b83efb7 Mon Sep 17 00:00:00 2001 From: RUNZHEN WANG Date: Tue, 9 Jun 2026 21:59:08 +0000 Subject: [PATCH] add a clean target in Makefile --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 599018fe5..e88857945 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) CHECK_TARGETS := golangci-lint check-generate -MAKE_TARGETS := binaries build build-image check fmt lint-internal test examples cmds coverage generate vendor check-modules helm-lint helm-package $(CHECK_TARGETS) +MAKE_TARGETS := binaries build build-image check clean fmt lint-internal test examples cmds coverage generate vendor check-modules helm-lint helm-package $(CHECK_TARGETS) TARGETS := $(MAKE_TARGETS) $(CMD_TARGETS) @@ -61,6 +61,12 @@ $(CMD_TARGETS): cmd-%: build: CC=$(CC) GOOS=$(GOOS) GOARCH=$(GOARCH) go build ./... +clean: + @for cmd in $(CMDS); do \ + rm -f $(CURDIR)/$$cmd; \ + [ -n "$(PREFIX)" ] && rm -f $(PREFIX)/$$cmd || true; \ + done + examples: $(EXAMPLE_TARGETS) $(EXAMPLE_TARGETS): example-%: CC=$(CC) GOOS=$(GOOS) GOARCH=$(GOARCH) go build ./examples/$(*)