From 9b8c45924da5e0d9b0ecf9b02e963f7599cc5c22 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Thu, 11 Dec 2025 14:09:50 +0000 Subject: [PATCH] Makefile: Make CGO_ENABLED configurable Although disabling it can have some benefits, it is sometimes needed for compliance reasons. Signed-off-by: James Le Cuirot --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8d86e633..0ee6af8c 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ BINARIES=$(addprefix bin/,$(COMMANDS)) # go packages GO_PACKAGES=$(shell go list ${GO_TAGS} ./... | grep -v /vendor/) +CGO_ENABLED ?= 0 + all: binaries binaries: $(BINARIES) ## build binaries into bin @@ -19,7 +21,7 @@ force: # build a binary from cmd bin/%: cmd/% force @echo "$@" - @GOOS=linux CGO_ENABLED=0 go build -ldflags "-X 'main.commitID=$$COMMIT_ID'" -o $@ ./$< + @GOOS=linux CGO_ENABLED="$(CGO_ENABLED)" go build -ldflags "-X 'main.commitID=$$COMMIT_ID'" -o $@ ./$< install: ## install binaries from bin @mkdir -p $(SN_DESTDIR)