1 # Makefile used to build XDS daemon Web Server
6 # Syncthing version to install
7 SYNCTHING_VERSION = 0.14.27
8 # FIXME: use patched version while waiting integration of #165
9 #SYNCTHING_INOTIFY_VERSION = 0.8.5
12 # Retrieve git tag/commit to set sub-version string
13 ifeq ($(origin SUB_VERSION), undefined)
14 SUB_VERSION := $(shell git describe --tags --always | sed 's/^v//')
15 ifeq ($(SUB_VERSION), )
16 SUB_VERSION=unknown-dev
20 # Configurable variables for installation (default /usr/local/...)
21 ifeq ($(origin INSTALL_DIR), undefined)
22 INSTALL_DIR := /usr/local/bin
24 ifeq ($(origin INSTALL_WEBAPP_DIR), undefined)
25 INSTALL_WEBAPP_DIR := $(INSTALL_DIR)/xds-server-www
28 HOST_GOOS=$(shell go env GOOS)
29 HOST_GOARCH=$(shell go env GOARCH)
30 REPOPATH=github.com/iotbzh/xds-server
32 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
33 ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
34 ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
35 LOCAL_BINDIR := $(ROOT_SRCDIR)/bin
37 export GOPATH := $(shell go env GOPATH):$(ROOT_GOPRJ)
38 export PATH := $(PATH):$(ROOT_SRCDIR)/tools
50 @echo "### Build XDS server (version $(VERSION), subversion $(SUB_VERSION))";
51 @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)" .
54 go test --race $(shell ./tools/glide novendor)
57 go vet $(shell ./tools/glide novendor)
60 go fmt $(shell ./tools/glide novendor)
62 run: build/xds tools/syncthing
63 $(LOCAL_BINDIR)/xds-server --log info -c config.json.in
65 debug: build/xds webapp/debug tools/syncthing
66 $(LOCAL_BINDIR)/xds-server --log debug -c config.json.in
70 rm -rf $(LOCAL_BINDIR)/* debug $(ROOT_GOPRJ)/pkg/*/$(REPOPATH)
74 rm -rf $(LOCAL_BINDIR) tools glide.lock vendor webapp/node_modules webapp/dist
76 webapp: webapp/install
77 (cd webapp && gulp build)
80 (cd webapp && gulp watch &)
83 (cd webapp && npm install)
87 @mkdir -p $(LOCAL_BINDIR) && cp -f scripts/xds-start-server.sh $(LOCAL_BINDIR)
90 install: all scripts tools/syncthing
91 mkdir -p $(INSTALL_DIR) && cp $(LOCAL_BINDIR)/* $(INSTALL_DIR)
92 mkdir -p $(INSTALL_WEBAPP_DIR) && cp -a webapp/dist/* $(INSTALL_WEBAPP_DIR)
94 vendor: tools/glide glide.yaml
95 ./tools/glide install --strip-vendor
98 @echo "Downloading glide"
100 curl --silent -L https://glide.sh/get | GOBIN=./tools sh
102 .PHONY: tools/syncthing
104 @(test -s $(LOCAL_BINDIR)/syncthing || \
105 DESTDIR=$(LOCAL_BINDIR) \
106 SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
107 SYNCTHING_INOTIFY_VERSION=$(SYNCTHING_INOTIFY_VERSION) \
108 ./scripts/get-syncthing.sh)
112 @echo "Main supported rules:"
113 @echo " all (default)"
119 @echo "Influential make variables:"
120 @echo " V - Build verbosity {0,1,2}."
121 @echo " BUILD_ENV_FLAGS - Environment added to 'go build'."