Add script to get xds-agent tarballs.
[src/xds/xds-server.git] / Makefile
index e3cc99b..8b2df13 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,10 @@
 VERSION := 0.0.1
 
 # Syncthing version to install
-SYNCTHING_VERSION = 0.14.27
-# FIXME: use patched version while waiting integration of #165
+SYNCTHING_VERSION = 0.14.28
+# FIXME: use master while waiting a release that include #164
 #SYNCTHING_INOTIFY_VERSION = 0.8.5
+SYNCTHING_INOTIFY_VERSION=master
 
 
 # Retrieve git tag/commit to set sub-version string
@@ -22,7 +23,7 @@ ifeq ($(origin INSTALL_DIR), undefined)
        INSTALL_DIR := /usr/local/bin
 endif
 ifeq ($(origin INSTALL_WEBAPP_DIR), undefined)
-       INSTALL_WEBAPP_DIR := $(INSTALL_DIR)/xds-server-www
+       INSTALL_WEBAPP_DIR := $(INSTALL_DIR)/www-xds-server
 endif
 
 HOST_GOOS=$(shell go env GOOS)
@@ -43,12 +44,12 @@ VERBOSE_1 := -v
 VERBOSE_2 := -v -x
 
 
-all: build webapp
+all: tools/syncthing build
 
 .PHONY: build
-build: xds
+build: xds webapp
 
-xds:vendor scripts
+xds:vendor scripts tools/syncthing/copytobin
        @echo "### Build XDS server (version $(VERSION), subversion $(SUB_VERSION))";
        @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-server -ldflags "-X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" .
 
@@ -61,10 +62,10 @@ vet: tools/glide
 fmt: tools/glide
        go fmt $(shell $(LOCAL_TOOLSDIR)/glide novendor)
 
-run: build/xds tools/syncthing
+run: build/xds tools/syncthing/copytobin
        $(LOCAL_BINDIR)/xds-server --log info -c config.json.in
 
-debug: build/xds webapp/debug tools/syncthing
+debug: build/xds webapp/debug tools/syncthing/copytobin
        $(LOCAL_BINDIR)/xds-server --log debug -c config.json.in
 
 .PHONY: clean
@@ -86,13 +87,15 @@ webapp/install:
 
 .PHONY: scripts
 scripts:
-       @mkdir -p $(LOCAL_BINDIR) && cp -f scripts/xds-start-server.sh $(LOCAL_BINDIR)
+       @mkdir -p $(LOCAL_BINDIR) && cp -rf scripts/xds-server-st*.sh scripts/xds-utils $(LOCAL_BINDIR)
 
 .PHONY: install
-install: all scripts tools/syncthing
+install:
+       @test -e $(LOCAL_BINDIR)/xds-server -a -d webapp/dist || { echo "Please execute first: make all\n"; exit 1; }
+       @test -e $(LOCAL_BINDIR)/xds-server-start.sh -a -d $(LOCAL_BINDIR)/xds-utils || { echo "Please execute first: make all\n"; exit 1; }
+       @test -e $(LOCAL_BINDIR)/syncthing -a -e $(LOCAL_BINDIR)/syncthing-inotify || { echo "Please execute first: make all\n"; exit 1; }
        mkdir -p $(INSTALL_DIR) \
-               && cp $(LOCAL_BINDIR)/* $(INSTALL_DIR) \
-               && cp $(LOCAL_TOOLSDIR)/syncthing* $(INSTALL_DIR)
+               && cp -a $(LOCAL_BINDIR)/* $(INSTALL_DIR)
        mkdir -p $(INSTALL_WEBAPP_DIR) \
                && cp -a webapp/dist/* $(INSTALL_WEBAPP_DIR)
 
@@ -106,11 +109,17 @@ tools/glide:
 
 .PHONY: tools/syncthing
 tools/syncthing:
-       @(test -s $(LOCAL_TOOLSDIR)/syncthing || \
+       @test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify  || { \
+       mkdir -p $(LOCAL_TOOLSDIR); \
        DESTDIR=$(LOCAL_TOOLSDIR) \
        SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
        SYNCTHING_INOTIFY_VERSION=$(SYNCTHING_INOTIFY_VERSION) \
-       ./scripts/get-syncthing.sh)
+       ./scripts/xds-utils/get-syncthing.sh; }
+
+.PHONY:
+tools/syncthing/copytobin:
+       @test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify || { echo "Please execute first: make tools/syncthing\n"; exit 1; }
+       @cp -f $(LOCAL_TOOLSDIR)/syncthing* $(LOCAL_BINDIR)
 
 .PHONY: help
 help: