From 4ca98b5f177929e20d729acdc28a505fcb2c41ab Mon Sep 17 00:00:00 2001 From: Joe Julian Date: Tue, 30 Aug 2016 13:58:40 -0700 Subject: [PATCH] Allow make overrides of version if git fails If the $(shell ...) command fails, the ':=' operator fails as well preventing variable overrides from functioning. Wrap the assignment in an $(or ...) to prevent the shell script from running if the variable is set from the command line or the environment. Fixes issue #58 --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8fa48c20..e7749218 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,8 @@ SHELL = /bin/bash .PHONY: all version program path deps run race generate build clean test gofmt yamlfmt format docs rpmbuild mkdirs rpm srpm spec tar upload upload-sources upload-srpms upload-rpms copr .SILENT: clean -SVERSION := $(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --dirty --always) -VERSION := $(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --abbrev=0) +SVERSION := $(or $(SVERSION),$(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --dirty --always)) +VERSION := $(or $(VERSION),$(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --abbrev=0)) PROGRAM := $(shell echo $(notdir $(CURDIR)) | cut -f1 -d"-") OLDGOLANG := $(shell go version | grep -E 'go1.3|go1.4') ifeq ($(VERSION),$(SVERSION))