1 # Makefile used to build XDS daemon Web Server
6 # Syncthing version to install
7 SYNCTHING_VERSION = 0.14.27
8 SYNCTHING_INOTIFY_VERSION = 0.8.5
11 # Retrieve git tag/commit to set sub-version string
12 ifeq ($(origin SUB_VERSION), undefined)
13 SUB_VERSION := $(shell git describe --tags --always | sed 's/^v//')
14 ifeq ($(SUB_VERSION), )
15 SUB_VERSION=unknown-dev
19 # Configurable variables for installation (default /usr/local/...)
20 ifeq ($(origin INSTALL_DIR), undefined)
21 INSTALL_DIR := /usr/local/bin
23 ifeq ($(origin INSTALL_WEBAPP_DIR), undefined)
24 INSTALL_WEBAPP_DIR := $(INSTALL_DIR)/xds-server-www
27 HOST_GOOS=$(shell go env GOOS)
28 HOST_GOARCH=$(shell go env GOARCH)
29 REPOPATH=github.com/iotbzh/xds-server
31 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
32 ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
33 ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
34 LOCAL_BINDIR := $(ROOT_SRCDIR)/bin
36 export GOPATH := $(shell go env GOPATH):$(ROOT_GOPRJ)
37 export PATH := $(PATH):$(ROOT_SRCDIR)/tools
49 @echo "### Build XDS server (version $(VERSION), subversion $(SUB_VERSION))";
50 @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)" .
53 go test --race $(shell ./tools/glide novendor)
56 go vet $(shell ./tools/glide novendor)
59 go fmt $(shell ./tools/glide novendor)
61 run: build/xds tools/syncthing
62 $(LOCAL_BINDIR)/xds-server --log info -c config.json.in
64 debug: build/xds webapp/debug tools/syncthing
65 $(LOCAL_BINDIR)/xds-server --log debug -c config.json.in
69 rm -rf $(LOCAL_BINDIR)/* debug $(ROOT_GOPRJ)/pkg/*/$(REPOPATH)
73 rm -rf $(LOCAL_BINDIR) tools glide.lock vendor webapp/node_modules webapp/dist
75 webapp: webapp/install
76 (cd webapp && gulp build)
79 (cd webapp && gulp watch &)
82 (cd webapp && npm install)
86 @mkdir -p $(LOCAL_BINDIR) && cp -f scripts/xds-start-server.sh $(LOCAL_BINDIR)
89 install: all scripts tools/syncthing
90 mkdir -p $(INSTALL_DIR) && cp $(LOCAL_BINDIR)/* $(INSTALL_DIR)
91 mkdir -p $(INSTALL_WEBAPP_DIR) && cp -a webapp/dist/* $(INSTALL_WEBAPP_DIR)
93 vendor: tools/glide glide.yaml
94 ./tools/glide install --strip-vendor
97 @echo "Downloading glide"
99 curl --silent -L https://glide.sh/get | GOBIN=./tools sh
101 .PHONY: tools/syncthing
103 @(test -s $(LOCAL_BINDIR)/syncthing || \
104 DESTDIR=$(LOCAL_BINDIR) \
105 SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
106 SYNCTHING_INOTIFY_VERSION=$(SYNCTHING_INOTIFY_VERSION) \
107 ./scripts/get-syncthing.sh)
111 @echo "Main supported rules:"
112 @echo " all (default)"
118 @echo "Influential make variables:"
119 @echo " V - Build verbosity {0,1,2}."
120 @echo " BUILD_ENV_FLAGS - Environment added to 'go build'."