1 # Makefile used to build XDS daemon Web Server
6 # Syncthing version to install
7 SYNCTHING_VERSION = 0.14.27
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)/xds-server-www
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: build tools/syncthing
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
66 $(LOCAL_BINDIR)/xds-server --log info -c config.json.in
68 debug: build/xds webapp/debug tools/syncthing
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-start-server.sh scripts/agl $(LOCAL_BINDIR)
94 @test -e $(LOCAL_BINDIR)/xds-server -a -d webapp/dist || { echo "Please execute first: make build\n"; exit 1; }
95 @test -e $(LOCAL_BINDIR)/xds-start-server.sh -a -d $(LOCAL_BINDIR)/agl || { echo "Please execute first: scripts\n"; exit 1; }
96 @test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify || { echo "Please execute first: make tools/syncthing\n"; exit 1; }
97 mkdir -p $(INSTALL_DIR) \
98 && cp $(LOCAL_BINDIR)/* $(INSTALL_DIR) \
99 && cp $(LOCAL_TOOLSDIR)/syncthing* $(INSTALL_DIR)
100 mkdir -p $(INSTALL_WEBAPP_DIR) \
101 && cp -a webapp/dist/* $(INSTALL_WEBAPP_DIR)
103 vendor: tools/glide glide.yaml
104 $(LOCAL_TOOLSDIR)/glide install --strip-vendor
107 @echo "Downloading glide"
108 mkdir -p $(LOCAL_TOOLSDIR)
109 curl --silent -L https://glide.sh/get | GOBIN=$(LOCAL_TOOLSDIR) sh
111 .PHONY: tools/syncthing
113 @test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify || { \
114 DESTDIR=$(LOCAL_TOOLSDIR) \
115 SYNCTHING_VERSION=$(SYNCTHING_VERSION) \
116 SYNCTHING_INOTIFY_VERSION=$(SYNCTHING_INOTIFY_VERSION) \
117 ./scripts/get-syncthing.sh; }
121 @echo "Main supported rules:"
122 @echo " all (default)"
128 @echo "Influential make variables:"
129 @echo " V - Build verbosity {0,1,2}."
130 @echo " BUILD_ENV_FLAGS - Environment added to 'go build'."