1 # Makefile used to build XDS daemon Web Server
3 # Retrieve git tag/commit to set sub-version string
4 ifeq ($(origin VERSION), undefined)
5 VERSION := $(shell git describe --tags --always | sed 's/^v//')
11 # Configurable variables for installation (default /usr/local/...)
12 ifeq ($(origin INSTALL_DIR), undefined)
13 INSTALL_DIR := /usr/local/bin
15 ifeq ($(origin INSTALL_WEBAPP_DIR), undefined)
16 INSTALL_WEBAPP_DIR := ${INSTALL_DIR}/xds-server-www
19 HOST_GOOS=$(shell go env GOOS)
20 HOST_GOARCH=$(shell go env GOARCH)
21 REPOPATH=github.com/iotbzh/xds-server
23 mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
24 ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
25 ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
27 export GOPATH := $(shell go env GOPATH):$(ROOT_GOPRJ)
28 export PATH := $(PATH):$(ROOT_SRCDIR)/tools
37 #build: build/xds build/cmds
43 @echo "### Build XDS server (version $(VERSION))";
44 @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o bin/xds-server -ldflags "-X main.AppVersionGitTag=$(VERSION)" .
47 # @for target in $(WHAT); do \
48 # echo "### Build $$target"; \
49 # $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o bin/$$target -ldflags "-X main.AppVersionGitTag=$(VERSION)" ./cmd/$$target; \
53 go test --race $(shell ./tools/glide novendor)
56 go vet $(shell ./tools/glide novendor)
59 go fmt $(shell ./tools/glide novendor)
62 ./bin/xds-server --log info -c config.json.in
64 debug: build/xds webapp/debug
65 ./bin/xds-server --log debug -c config.json.in
68 rm -rf ./bin/* debug cmd/*/debug $(ROOT_GOPRJ)/pkg/*/$(REPOPATH)
71 rm -rf bin tools glide.lock vendor cmd/*/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 ${INSTALL_DIR} && cp bin/xds-server ${INSTALL_DIR}
88 mkdir -p ${INSTALL_WEBAPP_DIR} && cp -a webapp/dist/* ${INSTALL_WEBAPP_DIR}
90 vendor: tools/glide glide.yaml
91 ./tools/glide install --strip-vendor
94 @echo "Downloading glide"
96 curl --silent -L https://glide.sh/get | GOBIN=./tools sh
102 @echo "Main supported rules:"
103 @echo " build (default)"
110 @echo "Influential make variables:"
111 @echo " V - Build verbosity {0,1,2}."
112 @echo " BUILD_ENV_FLAGS - Environment added to 'go build'."
113 # @echo " WHAT - Command to build. (e.g. WHAT=xds-make)"