Skip to content

Commit ad26173

Browse files
authored
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 <[email protected]>
1 parent 5d6878c commit ad26173

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,22 @@ BINDIR ?= $(PREFIX)/bin
1313

1414
BINARY = $(addprefix bin/,finch-daemon)
1515

16+
ifndef GODEBUG
17+
EXTRA_LDFLAGS += -s -w
18+
endif
19+
1620
.PHONY: build
1721
build:
1822
$(eval PACKAGE := github.com/runfinch/finch-daemon)
1923
$(eval VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags))
2024
$(eval GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi))
21-
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)")
25+
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) $(EXTRA_LDFLAGS)")
2226
GOOS=linux go build -ldflags $(LDFLAGS) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon
2327

28+
clean:
29+
@rm -f $(BINARIES)
30+
@rm -rf $(BIN)
31+
2432
.PHONY: linux
2533
linux:
2634
ifneq ($(shell uname), Linux)

0 commit comments

Comments
 (0)