summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-10-28 18:33:22 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-10-28 18:33:22 +0900
commit3ba7b5cf2dc98ebe22291928b38a1e79b79f52e0 (patch)
tree1c7bc7fe8f67be4c5b808654c95fa07b03f469ad /Makefile
parent254e9765fe4285681802f5fe15f575bcf7e1815c (diff)
Make Makefile fail when git information is not available
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile19
1 files changed, 17 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 4308d373..f67bd81e 100644
--- a/Makefile
+++ b/Makefile
@@ -5,10 +5,25 @@ MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(shell dirname $(MAKEFILE))
SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(MAKEFILE)
-VERSION := $(shell git describe --abbrev=0)
+ifdef FZF_VERSION
+VERSION := $(FZF_VERSION)
+else
+VERSION := $(shell git describe --abbrev=0 2> /dev/null)
+endif
+ifeq ($(VERSION),)
+$(error Not on git repository; cannot determine $$FZF_VERSION)
+endif
VERSION_TRIM := $(shell sed "s/-.*//" <<< $(VERSION))
VERSION_REGEX := $(subst .,\.,$(VERSION_TRIM))
-REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES))
+
+ifdef FZF_REVISION
+REVISION := $(FZF_REVISION)
+else
+REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES) 2> /dev/null)
+endif
+ifeq ($(REVISION),)
+$(error Not on git repository; cannot determine $$FZF_REVISION)
+endif
BUILD_FLAGS := -a -ldflags "-X main.version=$(VERSION) -X main.revision=$(REVISION) -w '-extldflags=$(LDFLAGS)'" -tags "$(TAGS)"
BINARY64 := fzf-$(GOOS)_amd64