diff --git a/Makefile b/Makefile index 1e3d706b..273ff848 100644 --- a/Makefile +++ b/Makefile @@ -13,20 +13,23 @@ BINDIR ?= $(PREFIX)/bin BINARY = $(addprefix bin/,finch-daemon) -.PHONY: build -build: - $(eval PACKAGE := github.com/runfinch/finch-daemon) - $(eval VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags)) - $(eval GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)) -ifneq ($(STATIC),) - $(eval GO_BUILDTAGS := osusergo netgo) - $(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) -extldflags '-static'") - @echo "Building Static Binary" +PACKAGE := github.com/runfinch/finch-daemon +VERSION := $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags) +GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi) + +LDFLAGS := -X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) + +ifeq ($(STATIC),) + GO_BUILDTAGS := osusergo netgo + LDFLAGS += -extldflags '-static' + $(info Building Static Binary) else - @echo "Building Dynamic Binary" - $(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)") + $(info Building Dynamic Binary) endif - GOOS=linux go build $(if $(GO_BUILDTAGS), -tags "$(GO_BUILDTAGS)") -ldflags $(LDFLAGS) $(if $(STATIC), ) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon + +.PHONY: build +build: + GOOS=linux go build $(if $(GO_BUILDTAGS), -tags "$(GO_BUILDTAGS)") -ldflags "$(LDFLAGS)" -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon .PHONY: linux linux: