Skip to content

Commit 85e8eeb

Browse files
committed
fix: update makefile
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent a6da2c0 commit 85e8eeb

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

Makefile

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,27 @@ ifndef GODEBUG
1717
EXTRA_LDFLAGS += -s -w
1818
endif
1919

20+
PACKAGE := github.com/runfinch/finch-daemon
21+
VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags)
22+
GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)
23+
BINARY ?= finch-daemon
24+
25+
LDFLAGS_BASE := -X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) $(EXTRA_LDFLAGS)
26+
2027
.PHONY: build
2128
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) $(EXTRA_LDFLAGS) -extldflags '-static'")
28-
@echo "Building Static Binary"
29-
else
29+
ifeq ($(STATIC),)
3030
@echo "Building Dynamic Binary"
31-
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) $(EXTRA_LDFLAGS)")
31+
$(eval LDFLAGS := $(LDFLAGS_BASE))
32+
else
33+
@echo "Building Static Binary"
34+
$(eval GO_BUILDTAGS := osusergo netgo)
35+
$(eval LDFLAGS := $(LDFLAGS_BASE) -extldflags '-static')
3236
endif
33-
GOOS=linux go build $(if $(GO_BUILDTAGS), -tags "$(GO_BUILDTAGS)") -ldflags $(LDFLAGS) $(if $(STATIC), ) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon
34-
37+
GOOS=linux go build \
38+
$(if $(GO_BUILDTAGS),-tags "$(GO_BUILDTAGS)") \
39+
-ldflags "$(LDFLAGS)" \
40+
-v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon
3541
clean:
3642
@rm -f $(BINARIES)
3743
@rm -rf $(BIN)

0 commit comments

Comments
 (0)