1 # Makefile used to build XDS daemon Web Server
3 # Syncthing version to install
4 SYNCTHING_VERSION = 0.14.25
5 SYNCTHING_INOTIFY_VERSION = 0.8.5
7 # Retrieve git tag/commit to set sub-version string
8 ifeq ($(origin VERSION), undefined)
9 VERSION := $(shell git describe --tags --always | sed 's/^v//')
15 # Configurable variables for installation (default /usr/local/...)
16 ifeq ($(origin INSTALL_DIR), undefined)
17 INSTALL_DIR := /usr/local/bin
19 ifeq ($(origin INSTALL_WEBAPP_DIR), undefined)
20 INSTALL_WEBAPP_DIR := $(INSTALL_DIR)/xds-server-www
23 HOST_GOOS=$(shell go env GOOS)
24 HOST_GOARCH=$(shell go env GOARCH)
25 REPOPATH=github.com/iotbzh/xds-server
27 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
28 ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
29 ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
30 LOCAL_BINDIR := $(ROOT_SRCDIR)/bin
32 export GOPATH := $(shell go env GOPATH):$(ROOT_GOPRJ)
33 export PATH := $(PATH):$(ROOT_SRCDIR)/tools
45 @echo "### Build XDS server (version $(VERSION))";
46 @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-server -ldflags "-X main.AppVersionGitTag=$(VERSION)" .
49 go test --race $(shell ./tools/glide novendor)
52 go vet $(shell ./tools/glide novendor)
55 go fmt $(shell ./tools/glide novendor)
57 run: build/xds tools/syncthing
58 $(LOCAL_BINDIR)/xds-server --log info -c config.json.in
60 debug: build/xds webapp/debug tools/syncthing
61 $(LOCAL_BINDIR)/xds-server --log debug -c config.json.in
65 rm -rf $(LOCAL_BINDIR)/* debug $(ROOT_GOPRJ)/pkg/*/$(REPOPATH)
69 rm -rf $(LOCAL_BINDIR) tools glide.lock vendor webapp/node_modules webapp/dist
71 webapp: webapp/install
72 (cd webapp && gulp build)
75 (cd webapp && gulp watch &)
78 (cd webapp && npm install)
82 @mkdir -p $(LOCAL_BINDIR) && cp -f scripts/xds-start-server.sh $(LOCAL_BINDIR)
85 install: all scripts tools/syncthing
86 mkdir -p $(INSTALL_DIR) && cp $(LOCAL_BINDIR)/* $(INSTALL_DIR)
87 mkdir -p $(INSTALL_WEBAPP_DIR) && cp -a webapp/dist/* $(INSTALL_WEBAPP_DIR)
89 vendor: tools/glide glide.yaml
90 ./tools/glide install --strip-vendor
93 @echo "Downloading glide"
95 curl --silent -L https://glide.sh/get | GOBIN=./tools sh
97 .PHONY: tools/syncthing
99 @(test -s $(LOCAL_BINDIR)/syncthing || \
100 DESTDIR=$(LOCAL_BINDIR) \
101 SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
102 SYNCTHING_INOTIFY_VERSION=$(SYNCTHING_INOTIFY_VERSION) \
103 ./scripts/get-syncthing.sh)
107 @echo "Main supported rules:"
108 @echo " build (default)"
113 @echo "Influential make variables:"
114 @echo " V - Build verbosity {0,1,2}."
115 @echo " BUILD_ENV_FLAGS - Environment added to 'go build'."