From af52579189f48c3f2c83d3a115f5873c7328291f Mon Sep 17 00:00:00 2001 From: Chad Metcalf Date: Sun, 14 Jun 2015 13:03:07 -0700 Subject: [PATCH] Handle building without git. Resolves #609 by removing two dependencies on git. - Use the Makefile to find the current directory. - In the case of building from an archive fall back to fixed REV and BRANCH values. --- Makefile.INCLUDE | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile.INCLUDE b/Makefile.INCLUDE index 9812f1d0b..5f903ecb8 100644 --- a/Makefile.INCLUDE +++ b/Makefile.INCLUDE @@ -15,7 +15,9 @@ .SUFFIXES: -VERSION?=$(shell cat `git rev-parse --show-toplevel`/VERSION) +current_dir := $(patsubst %/,%, $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) + +VERSION=$(shell cat $(current_dir)/VERSION) OS=$(shell uname) ARCH=$(shell uname -m) @@ -62,8 +64,8 @@ export GO_TEST_FLAGS ?= -short GO_GET := $(GO) get -u -v -x -REV := $(shell git rev-parse --short HEAD) -BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +REV := $(shell git rev-parse --short HEAD 2> /dev/null || echo 'unknown') +BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown') HOSTNAME := $(shell hostname -f) BUILD_DATE := $(shell date +%Y%m%d-%H:%M:%S) BUILDFLAGS := -ldflags \