diff --git a/Makefile b/Makefile index 62120c150..1d2eeab9b 100644 --- a/Makefile +++ b/Makefile @@ -1,33 +1,52 @@ -TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64 -DIST_DIRS = find * -type d -exec -APP = helm +BINDIR := $(CURDIR)/bin +DIST_DIRS := find * -type d -exec +TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64 # go option -GO ?= go -PKG := $(shell glide novendor) -TAGS := -TESTS := . -TESTFLAGS := -LDFLAGS := -w -s -GOFLAGS := -BINDIR := $(CURDIR)/bin -BINARIES := helm +GO ?= go +PKG := ./... +TAGS := +TESTS := . +TESTFLAGS := +LDFLAGS := -w -s +GOFLAGS := # Required for globs to work correctly -SHELL=/bin/bash +SHELL = /bin/bash + +GIT_COMMIT = $(shell git rev-parse HEAD) +GIT_SHA = $(shell git rev-parse --short HEAD) +GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) +GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean") + +ifdef VERSION + BINARY_VERSION = $(VERSION) +endif +BINARY_VERSION ?= ${GIT_TAG} + +# Only set Version if building a tag or VERSION is set +ifneq ($(BINARY_VERSION),) + LDFLAGS += -X k8s.io/helm/pkg/version.Version=${BINARY_VERSION} +endif + +# Clear the "unreleased" string in BuildMetadata +ifneq ($(GIT_TAG),) + LDFLAGS += -X k8s.io/helm/pkg/version.BuildMetadata= +endif +LDFLAGS += -X k8s.io/helm/pkg/version.GitCommit=${GIT_COMMIT} +LDFLAGS += -X k8s.io/helm/pkg/version.GitTreeState=${GIT_DIRTY} .PHONY: all all: build .PHONY: build build: - GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' k8s.io/helm/cmd/... + $(GO) build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(BINDIR)/helm k8s.io/helm/cmd/helm -# usage: make clean build-cross dist APP=helm|tiller VERSION=v2.0.0-alpha.3 .PHONY: build-cross build-cross: LDFLAGS += -extldflags "-static" build-cross: - CGO_ENABLED=0 gox -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' k8s.io/helm/cmd/$(APP) + CGO_ENABLED=0 gox -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' k8s.io/helm/cmd/helm .PHONY: dist dist: @@ -84,16 +103,20 @@ HAS_GIT := $(shell command -v git;) .PHONY: bootstrap bootstrap: +ifndef HAS_GIT + $(error You must install Git) +endif ifndef HAS_GLIDE go get -u github.com/Masterminds/glide endif ifndef HAS_GOX go get -u github.com/mitchellh/gox endif - -ifndef HAS_GIT - $(error You must install Git) -endif glide install --strip-vendor -include versioning.mk +.PHONY: info +info: + @echo "Version: ${VERSION}" + @echo "Git Tag: ${GIT_TAG}" + @echo "Git Commit: ${GIT_COMMIT}" + @echo "Git Tree State: ${GIT_DIRTY}" diff --git a/versioning.mk b/versioning.mk deleted file mode 100644 index b8350ea63..000000000 --- a/versioning.mk +++ /dev/null @@ -1,28 +0,0 @@ -GIT_COMMIT = $(shell git rev-parse HEAD) -GIT_SHA = $(shell git rev-parse --short HEAD) -GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) -GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean") - -ifdef VERSION - BINARY_VERSION = $(VERSION) -endif - -BINARY_VERSION ?= ${GIT_TAG} - -# Only set Version if building a tag or VERSION is set -ifneq ($(BINARY_VERSION),) - LDFLAGS += -X k8s.io/helm/pkg/version.Version=${BINARY_VERSION} -endif - -# Clear the "unreleased" string in BuildMetadata -ifneq ($(GIT_TAG),) - LDFLAGS += -X k8s.io/helm/pkg/version.BuildMetadata= -endif -LDFLAGS += -X k8s.io/helm/pkg/version.GitCommit=${GIT_COMMIT} -LDFLAGS += -X k8s.io/helm/pkg/version.GitTreeState=${GIT_DIRTY} - -info: - @echo "Version: ${VERSION}" - @echo "Git Tag: ${GIT_TAG}" - @echo "Git Commit: ${GIT_COMMIT}" - @echo "Git Tree State: ${GIT_DIRTY}"