summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-24 17:20:48 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-24 17:21:21 +0200
commit0f52586a6208a66a8d5e4dd4c4e3a58cdff6b46f (patch)
treebff0c6481821eb2105b3af2f683f00dae8776d86 /Makefile
parent32bf4cb0c949f44343849607d0439a61d1e6ea49 (diff)
Support Windows cross-build.
Use following command cross build for Windows on a Linux machine: GOOS=windows GOARCH=amd64 make Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile13
1 files changed, 9 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 4246133..619c514 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,11 @@ HOST_GOARCH=$(shell go env GOARCH)
ARCH=$(HOST_GOOS)-$(HOST_GOARCH)
REPOPATH=github.com/iotbzh/xds-agent
+EXT=
+ifeq ($(HOST_GOOS), windows)
+ EXT=.exe
+endif
+
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_SRCDIR := $(patsubst %/,%,$(dir $(mkfile_path)))
ROOT_GOPRJ := $(abspath $(ROOT_SRCDIR)/../../../..)
@@ -46,7 +51,7 @@ all: tools/syncthing build
build: vendor tools/syncthing/copytobin
@echo "### Build XDS agent (version $(VERSION), subversion $(SUB_VERSION))";
- @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-agent -ldflags "-X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" .
+ @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(LOCAL_BINDIR)/xds-agent$(EXT) -ldflags "-X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" .
package: clean build
@mkdir -p $(PACKAGE_DIR)/xds-agent
@@ -64,10 +69,10 @@ fmt: tools/glide
go fmt $(shell ./tools/glide novendor)
run: build/xds tools/syncthing/copytobin
- $(LOCAL_BINDIR)/xds-agent --log info -c agent-config.json.in
+ $(LOCAL_BINDIR)/xds-agent$(EXT) --log info -c agent-config.json.in
debug: build/xds tools/syncthing/copytobin
- $(LOCAL_BINDIR)/xds-agent --log debug -c agent-config.json.in
+ $(LOCAL_BINDIR)/xds-agent$(EXT) --log debug -c agent-config.json.in
.PHONY: clean
clean:
@@ -102,7 +107,7 @@ tools/syncthing:
tools/syncthing/copytobin:
@test -e $(LOCAL_TOOLSDIR)/syncthing -a -e $(LOCAL_TOOLSDIR)/syncthing-inotify || { echo "Please execute first: make tools/syncthing\n"; exit 1; }
@mkdir -p $(LOCAL_BINDIR)
- @cp -f $(LOCAL_TOOLSDIR)/syncthing* $(LOCAL_BINDIR)
+ @cp -f $(LOCAL_TOOLSDIR)/syncthing$(EXT) $(LOCAL_TOOLSDIR)/syncthing-inotify$(EXT) $(LOCAL_BINDIR)
.PHONY: help
help: