From 9fb7777c336d5e4362c2c235a957ed32b2dca87d Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 8 Dec 2018 18:27:50 -0500 Subject: [PATCH] Switch to xgo for cross-compilation Ref T529 --- Makefile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 73823df..993247b 100644 --- a/Makefile +++ b/Makefile @@ -16,13 +16,22 @@ build: deps cd cmd/writefreely; $(GOBUILD) -v build-linux: deps - cd cmd/writefreely; GOOS=linux GOARCH=amd64 $(GOBUILD) -v + @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GOGET) -u github.com/karalabe/xgo; \ + fi + xgo --targets=linux/amd64, -dest build/ $(LDFLAGS) -out writefreely ./cmd/writefreely build-windows: deps - cd cmd/writefreely; GOOS=windows GOARCH=amd64 $(GOBUILD) -v + @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GOGET) -u github.com/karalabe/xgo; \ + fi + xgo --targets=windows/amd64, -dest build/ $(LDFLAGS) -out writefreely ./cmd/writefreely build-darwin: deps - cd cmd/writefreely; GOOS=darwin GOARCH=amd64 $(GOBUILD) -v + @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + $(GOGET) -u github.com/karalabe/xgo; \ + fi + xgo --targets=darwin/amd64, -dest build/ $(LDFLAGS) -out writefreely ./cmd/writefreely build-docker : $(DOCKERCMD) build -t $(IMAGE_NAME):latest -t $(IMAGE_NAME):$(GITREV) . @@ -50,15 +59,15 @@ release : clean ui cp schema.sql build cp sqlite.sql build $(MAKE) build-linux - cp cmd/writefreely/$(BINARY_NAME) build + mv build/$(BINARY_NAME)-linux-amd64 build/$(BINARY_NAME) cd build; tar -cvzf ../$(BINARY_NAME)_$(GITREV)_linux_amd64.tar.gz * rm build/$(BINARY_NAME) $(MAKE) build-darwin - cp cmd/writefreely/$(BINARY_NAME) build + mv build/$(BINARY_NAME)-darwin-10.6-amd64 build/$(BINARY_NAME) cd build; tar -cvzf ../$(BINARY_NAME)_$(GITREV)_darwin_amd64.tar.gz * rm build/$(BINARY_NAME) $(MAKE) build-windows - cp cmd/writefreely/$(BINARY_NAME).exe build + mv build/$(BINARY_NAME)-windows-4.0-amd64.exe build/$(BINARY_NAME).exe cd build; zip -r ../$(BINARY_NAME)_$(GITREV)_windows_amd64.zip ./* $(MAKE) build-docker $(MAKE) release-docker