Fix glide install detection
[src/xds/xds-agent.git] / Makefile
index ca04632..90826c7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ SYNCTHING_INOTIFY_VERSION = master
 
 # Retrieve git tag/commit to set sub-version string
 ifeq ($(origin SUB_VERSION), undefined)
-       SUB_VERSION := $(shell git describe --tags 2>/dev/null | sed 's/^v//')
+       SUB_VERSION := $(shell git describe --exact-match --tags 2>/dev/null | sed 's/^v//')
        ifneq ($(SUB_VERSION), )
                VERSION := $(firstword $(subst -, ,$(SUB_VERSION)))
                SUB_VERSION := $(word 2,$(subst -, ,$(SUB_VERSION)))
@@ -25,10 +25,12 @@ ifeq ($(origin SUB_VERSION), undefined)
        endif
 endif
 
+# for backward compatibility
+DESTDIR := $(INSTALL_DIR)
 
 # Configurable variables for installation (default /usr/local/...)
-ifeq ($(origin INSTALL_DIR), undefined)
-       INSTALL_DIR := /usr/local/bin
+ifeq ($(origin DESTDIR), undefined)
+       DESTDIR := /usr/local/bin
 endif
 
 HOST_GOOS=$(shell go env GOOS)
@@ -117,15 +119,18 @@ distclean: clean
 
 .PHONY: install
 install: all
-       mkdir -p $(INSTALL_DIR) && cp $(LOCAL_BINDIR)/* $(INSTALL_DIR)
+       mkdir -p $(DESTDIR) && cp $(LOCAL_BINDIR)/* $(DESTDIR)
 
 vendor: tools/glide glide.yaml
        ./tools/glide install --strip-vendor
 
+.PHONY: tools/glide
 tools/glide:
-       @echo "Downloading glide"
-       mkdir -p tools
-       curl --silent -L https://glide.sh/get | GOBIN=./tools  sh
+       @test -f $(LOCAL_TOOLSDIR)/glide || { \
+               echo "Downloading glide"; \
+               mkdir -p $(LOCAL_TOOLSDIR); \
+               curl --silent -L https://glide.sh/get | GOBIN=$(LOCAL_TOOLSDIR)  sh; \
+       }
 
 .PHONY: tools/syncthing
 tools/syncthing: