Skip to content

Commit 5887d3b

Browse files
committed
fix: Update makefile for build target
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 090da7c commit 5887d3b

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

Makefile

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

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

16-
.PHONY: build
17-
build:
18-
$(eval PACKAGE := github.com/runfinch/finch-daemon)
19-
$(eval VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags))
20-
$(eval GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi))
21-
ifneq ($(STATIC),)
22-
$(eval GO_BUILDTAGS := osusergo netgo)
23-
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) -extldflags '-static'")
24-
@echo "Building Static Binary"
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)
2526
else
26-
@echo "Building Dynamic Binary"
27-
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)")
27+
$(info Building Dynamic Binary)
2828
endif
29-
GOOS=linux go build $(if $(GO_BUILDTAGS), -tags "$(GO_BUILDTAGS)") -ldflags $(LDFLAGS) $(if $(STATIC), ) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon
29+
30+
.PHONY: build
31+
build:
32+
GOOS=linux go build $(if $(GO_BUILDTAGS), -tags "$(GO_BUILDTAGS)") -ldflags "$(LDFLAGS)" -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon
3033

3134
.PHONY: linux
3235
linux:

0 commit comments

Comments
 (0)