Check go version and print error if not >1.8.1
[src/xds/xds-server.git] / Makefile
index f895166..cf2de0f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,26 +1,19 @@
-# Makefile used to build XDS daemon Web Server
-
-# Application Version
-VERSION := 0.3.0
+# Makefile used to build XDS Server
 
 # Syncthing version to install
-SYNCTHING_VERSION = 0.14.28
-SYNCTHING_INOTIFY_VERSION = 0.8.6
-
-
-# Retrieve git tag/commit to set sub-version string
-ifeq ($(origin SUB_VERSION), undefined)
-       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)))
-       endif
-       ifeq ($(SUB_VERSION), )
-               SUB_VERSION := $(shell git rev-parse --short HEAD)
-               ifeq ($(SUB_VERSION), )
-                       SUB_VERSION := unknown-dev
-               endif
-       endif
+SYNCTHING_VERSION = 0.14.38
+SYNCTHING_INOTIFY_VERSION = 0.8.7
+
+
+# Retrieve git tag/commit to set version & sub-version strings
+GIT_DESC := $(shell git describe --always --tags)
+VERSION := $(firstword $(subst -, ,$(GIT_DESC)))
+SUB_VERSION := $(subst $(VERSION)-,,$(GIT_DESC))
+ifeq ($(VERSION), )
+       VERSION := unknown-dev
+endif
+ifeq ($(SUB_VERSION), )
+       SUB_VERSION := $(shell date +'%Y-%m-%d_%H%M%S')
 endif
 
 # for backward compatibility
@@ -59,6 +52,14 @@ PACKAGE_DIR := $(ROOT_SRCDIR)/package
 export GOPATH := $(shell go env GOPATH):$(ROOT_GOPRJ)
 export PATH := $(PATH):$(LOCAL_TOOLSDIR)
 
+# Check Go version
+GOVERSION := $(shell go version |grep -o '[0-9\.]*'|head -n 1)
+GOVERMAJ := $(shell echo $(GOVERSION) |cut -f1 -d.)
+GOVERMIN := $(shell echo $(GOVERSION) |cut -f2 -d.)
+CHECKGOVER := $(shell [ $(GOVERMAJ) -gt 1 -o \( $(GOVERMAJ) -eq 1 -a $(GOVERMIN) -ge 8 \) ] && echo true)
+CHECKERRMSG := "ERROR: Go version 1.8.1 or higher is requested (current detected version: $(GOVERSION))."
+
+
 VERBOSE_1 := -v
 VERBOSE_2 := -v -x
 
@@ -85,7 +86,7 @@ endif
 all: tools/syncthing build
 
 .PHONY: build
-build: vendor xds webapp
+build: checkgover vendor xds webapp
 
 xds: scripts tools/syncthing/copytobin
        @echo "### Build XDS server (version $(VERSION), subversion $(SUB_VERSION), $(BUILD_MODE))";
@@ -103,7 +104,7 @@ fmt: tools/glide
 run: build/xds tools/syncthing/copytobin
        $(LOCAL_BINDIR)/xds-server$(EXT) --log info -c config.json.in
 
-debug: build/xds webapp/debug tools/syncthing/copytobin
+debug: build/xds tools/syncthing/copytobin
        $(LOCAL_BINDIR)/xds-server$(EXT) --log debug -c config.json.in
 
 .PHONY: clean
@@ -112,17 +113,15 @@ clean:
 
 .PHONY: distclean
 distclean: clean
-       rm -rf $(LOCAL_BINDIR) $(ROOT_SRCDIR)/tools glide.lock vendor webapp/node_modules webapp/dist webapp/assets/xds-agent-tarballs/*.zip
+       rm -rf $(LOCAL_BINDIR) $(ROOT_SRCDIR)/tools glide.lock vendor $(ROOT_SRCDIR)/webapp/dist $(ROOT_SRCDIR)/webapp/node_modules
 
 webapp: webapp/install
-       (cd webapp && gulp build)
-
-webapp/debug:
-       (cd webapp && gulp watch &)
+       mkdir -p $(ROOT_SRCDIR)/webapp/dist $(ROOT_SRCDIR)/webapp/dist/fonts
+       (cd $(ROOT_SRCDIR)/webapp && cp -a ./assets ./src/index.html ./node_modules/font-awesome/css/font-awesome.min.css ./dist/)
+       (cd $(ROOT_SRCDIR)/webapp && cp -a ./node_modules/font-awesome/fonts/* ./dist/fonts/)
 
 webapp/install:
        (cd webapp && npm install)
-       @if [ -d ${DESTDIR}/usr/local/etc ]; then rm -rf ${DESTDIR}/usr; fi
 
 .PHONY: scripts
 scripts:
@@ -193,6 +192,11 @@ tools/syncthing/copytobin:
        @mkdir -p $(LOCAL_BINDIR)
        @cp -f $(LOCAL_TOOLSDIR)/syncthing$(EXT) $(LOCAL_TOOLSDIR)/syncthing-inotify$(EXT) $(LOCAL_BINDIR)
 
+.PHONY:
+checkgover:
+       @test "$(CHECKGOVER)" = "true" || { echo $(CHECKERRMSG); exit 1; }
+
+
 .PHONY: help
 help:
        @echo "Main supported rules:"