From 9cd84b783b7f84af71244f410deb44dff8ec7d1b Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Tue, 28 Jul 2015 14:32:42 -0700 Subject: [PATCH] add changes for makefile for compile time vars Signed-off-by: Jessica Frazelle --- Makefile | 17 +++++++++++++---- VERSION | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 VERSION diff --git a/Makefile b/Makefile index 8cd3eb882b..951db5b530 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,19 @@ # Set an output prefix, which is the local directory if not specified PREFIX?=$(shell pwd) -# Used to populate version variable in main package. -GO_LDFLAGS=-ldflags "-w -X `go list ./version`.Version `git describe --match 'v[0-9]*' --dirty='.m' --always`" -GO_LDFLAGS_STATIC=-ldflags "-w -extldflags -static -X `go list ./version`.Version `git describe --match 'v[0-9]*' --dirty='.m' --always`" -GOOSES = darwin freebsd linux windows +# Populate version variables +# Add to compile time flags +NOTARY_PKG := github.com/docker/notary +VERSION := $(shell cat VERSION) +GITCOMMIT := $(shell git rev-parse --short HEAD) +GITUNTRACKEDCHANGES := $(shell git status --porcelain --untracked-files=no) +ifneq ($(GITUNTRACKEDCHANGES),) + GITCOMMIT := $(GITCOMMIT)-dirty +endif +CTIMEVAR=-X $(NOTARY_PKG)/version/version.GitCommit '$(GITCOMMIT)' -X $(NOTARY_PKG)/version/version.NotaryVersion '$(VERSION)' +GO_LDFLAGS=-ldflags "-w $(CTIMEVAR)" +GO_LDFLAGS_STATIC=-ldflags "-w $(CTIMEVAR) -extldflags -static" +GOOSES = darwin freebsd linux GOARCHS = amd64 386 # go cover test variables diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..ec9fec4def --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0-rc1