File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -17,21 +17,27 @@ ifndef GODEBUG
1717 EXTRA_LDFLAGS += -s -w
1818endif
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
2128build :
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')
3236endif
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
3541clean :
3642 @rm -f $(BINARIES )
3743 @rm -rf $(BIN )
You can’t perform that action at this time.
0 commit comments