1 # Makefile used to build XDS daemon Web Server
6 # Syncthing version to install
7 SYNCTHING_VERSION = 0.14.28
8 # FIXME: use master while waiting a release that include #164
9 #SYNCTHING_INOTIFY_VERSION = 0.8.5
10 SYNCTHING_INOTIFY_VERSION=master
13 # Retrieve git tag/commit to set sub-version string
14 ifeq ($(origin SUB_VERSION), undefined)
15 SUB_VERSION := $(shell git describe --tags --always | sed 's/^v//')
16 ifeq ($(SUB_VERSION), )
17 SUB_VERSION=unknown-dev
21 # Configurable variables for installation (default /usr/local/...)
22 ifeq ($(origin INSTALL_DIR), undefined)
23 INSTALL_DIR := /usr/local/bin
25 ifeq ($(origin INSTALL_WEBAPP_DIR), undefined)
26 INSTALL_WEBAPP_DIR := $(INSTALL_DIR)/www-xds-server
29 HOST_GOOS=$(shell go env GOOS)
30 HOST_GOARCH=$(shell go env GOARCH)
31 REPOPATH=github.com/iotbzh/xds-server
33 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
34 ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
35 ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
36 LOCAL_BINDIR := $(ROOT_SRCDIR)/bin
37 LOCAL_TOOLSDIR := $(ROOT_SRCDIR)/tools
40 export GOPATH := $(shell go env GOPATH):$(ROOT_GOPRJ)
41 export PATH := $(PATH):$(LOCAL_TOOLSDIR)
47 all: tools/syncthing build
52 xds:vendor scripts tools/syncthing/copytobin
53 @echo "### Build XDS server (version $(VERSION), subversion $(SUB_VERSION))";
54 @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)" .
57 go test --race $(shell $(LOCAL_TOOLSDIR)/glide novendor)
60 go vet $(shell $(LOCAL_TOOLSDIR)/glide novendor)
63 go fmt $(shell $(LOCAL_TOOLSDIR)/glide novendor)
65 run: build/xds tools/syncthing/copytobin
66 $(LOCAL_BINDIR)/xds-server --log info -c config.json.in
68 debug: build/xds webapp/debug tools/syncthing/copytobin
69 $(LOCAL_BINDIR)/xds-server --log debug -c config.json.in
73 rm -rf $(LOCAL_BINDIR)/* debug $(ROOT_GOPRJ)/pkg/*/$(REPOPATH)
77 rm -rf $(LOCAL_BINDIR) $(LOCAL_TOOLSDIR) glide.lock vendor webapp/node_modules webapp/dist
79 webapp: webapp/install
80 (cd webapp && gulp build)
83 (cd webapp && gulp watch &)
86 (cd webapp && npm install)
90 @mkdir -p $(LOCAL_BINDIR) && cp -rf scripts/xds-server-st*.sh scripts/xds-utils $(LOCAL_BINDIR)
94 @test -e $(LOCAL_BINDIR)/xds-server -a -d webapp/dist || { echo "Please execute first: make all\n"; exit 1; }
95 @test -e $(LOCAL_BINDIR)/xds-server-start.sh -a -d $(LOCAL_BINDIR)/xds-utils || { echo "Please execute first: make all\n"; exit 1; }
96 @test -e $(LOCAL_BINDIR)/syncthing -a -e $(LOCAL_BINDIR)/syncthing-inotify || { echo "Please execute first: make all\n"; exit 1; }
97 mkdir -p $(INSTALL_DIR) \
98 && cp -a $(LOCAL_BINDIR)/* $(INSTALL_DIR)
99 mkdir -p $(INSTALL_WEBAPP_DIR) \
100 && cp -a webapp/dist/* $(INSTALL_WEBAPP_DIR)
102 vendor: tools/glide glide.yaml
103 $(LOCAL_TOOLSDIR)/glide install --strip-vendor
106 @echo "Downloading glide"
107 mkdir -p $(LOCAL_TOOLSDIR)
108 curl --silent -L https://glide.sh/get | GOBIN=$(LOCAL_TOOLSDIR) sh
110 .PHONY: tools/syncthing
112 @test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify || { \
113 mkdir -p $(LOCAL_TOOLSDIR); \
114 DESTDIR=$(LOCAL_TOOLSDIR) \
115 SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
116 SYNCTHING_INOTIFY_VERSION=$(SYNCTHING_INOTIFY_VERSION) \
117 ./scripts/xds-utils/get-syncthing.sh; }
120 tools/syncthing/copytobin:
121 @test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify || { echo "Please execute first: make tools/syncthing\n"; exit 1; }
122 @cp -f $(LOCAL_TOOLSDIR)/syncthing* $(LOCAL_BINDIR)
126 @echo "Main supported rules:"
127 @echo " all (default)"
133 @echo "Influential make variables:"
134 @echo " V - Build verbosity {0,1,2}."
135 @echo " BUILD_ENV_FLAGS - Environment added to 'go build'."