From ad261736724ba4e600d3952dc40ce5d281512c3c Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Mon, 21 Oct 2024 16:01:31 -0700 Subject: [PATCH] chore: strip debug info and add the clean build target (#67) chore: strip debug info by default to reduce binary size and add the clean target Signed-off-by: Henry Wang --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c0bc628..e81e414 100644 --- a/Makefile +++ b/Makefile @@ -13,14 +13,22 @@ BINDIR ?= $(PREFIX)/bin BINARY = $(addprefix bin/,finch-daemon) +ifndef GODEBUG + EXTRA_LDFLAGS += -s -w +endif + .PHONY: build build: $(eval PACKAGE := github.com/runfinch/finch-daemon) $(eval VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags)) $(eval GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)) - $(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)") + $(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) $(EXTRA_LDFLAGS)") GOOS=linux go build -ldflags $(LDFLAGS) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon +clean: + @rm -f $(BINARIES) + @rm -rf $(BIN) + .PHONY: linux linux: ifneq ($(shell uname), Linux)