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 build/xds: vendor scripts
46 @echo "### Build XDS server (version $(VERSION))";
47 @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-server -ldflags "-X main.AppVersionGitTag=$(VERSION)" .
50 go test --race $(shell ./tools/glide novendor)
53 go vet $(shell ./tools/glide novendor)
56 go fmt $(shell ./tools/glide novendor)
58 run: build/xds tools/syncthing
59 $(LOCAL_BINDIR)/xds-server --log info -c config.json.in
61 debug: build/xds webapp/debug tools/syncthing
62 $(LOCAL_BINDIR)/xds-server --log debug -c config.json.in
66 rm -rf $(LOCAL_BINDIR)/* debug cmd/*/debug $(ROOT_GOPRJ)/pkg/*/$(REPOPATH)
70 rm -rf $(LOCAL_BINDIR) tools glide.lock vendor cmd/*/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 " build (default)"
118 @echo "Influential make variables:"
119 @echo " V - Build verbosity {0,1,2}."
120 @echo " BUILD_ENV_FLAGS - Environment added to 'go build'."