Skip to content

Commit 3d62114

Browse files
committed
fix: Update makefile for build target
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent d1590fc commit 3d62114

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

Makefile

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,23 @@ BINDIR ?= $(PREFIX)/bin
1313

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

16-
ifndef GODEBUG
17-
EXTRA_LDFLAGS += -s -w
16+
PACKAGE := github.com/runfinch/finch-daemon
17+
VERSION := $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags)
18+
GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)
19+
20+
LDFLAGS := -X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)
21+
22+
ifeq ($(STATIC),)
23+
GO_BUILDTAGS := osusergo netgo
24+
LDFLAGS += -extldflags '-static'
25+
$(info Building Static Binary)
26+
else
27+
$(info Building Dynamic Binary)
1828
endif
1929

2030
.PHONY: build
2131
build:
22-
$(eval PACKAGE := github.com/runfinch/finch-daemon)
23-
$(eval VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags))
24-
$(eval GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi))
25-
ifneq ($(STATIC),)
26-
$(eval GO_BUILDTAGS := osusergo netgo)
27-
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) -extldflags '-static'")
28-
@echo "Building Static Binary"
29-
else
30-
@echo "Building Dynamic Binary"
31-
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)")
32-
endif
33-
GOOS=linux go build $(if $(GO_BUILDTAGS), -tags "$(GO_BUILDTAGS)") -ldflags $(LDFLAGS) $(if $(STATIC), ) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon
32+
GOOS=linux go build $(if $(GO_BUILDTAGS), -tags "$(GO_BUILDTAGS)") -ldflags "$(LDFLAGS)" -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon
3433

3534
clean:
3635
@rm -f $(BINARIES)

0 commit comments

Comments
 (0)