Switch to xgo for cross-compilation

Ref T529
pull/45/head
Matt Baer 6 years ago
parent 20c77989ba
commit 9fb7777c33
  1. 21
      Makefile

@ -16,13 +16,22 @@ build: deps
cd cmd/writefreely; $(GOBUILD) -v cd cmd/writefreely; $(GOBUILD) -v
build-linux: deps 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 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 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 : build-docker :
$(DOCKERCMD) build -t $(IMAGE_NAME):latest -t $(IMAGE_NAME):$(GITREV) . $(DOCKERCMD) build -t $(IMAGE_NAME):latest -t $(IMAGE_NAME):$(GITREV) .
@ -50,15 +59,15 @@ release : clean ui
cp schema.sql build cp schema.sql build
cp sqlite.sql build cp sqlite.sql build
$(MAKE) build-linux $(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 * cd build; tar -cvzf ../$(BINARY_NAME)_$(GITREV)_linux_amd64.tar.gz *
rm build/$(BINARY_NAME) rm build/$(BINARY_NAME)
$(MAKE) build-darwin $(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 * cd build; tar -cvzf ../$(BINARY_NAME)_$(GITREV)_darwin_amd64.tar.gz *
rm build/$(BINARY_NAME) rm build/$(BINARY_NAME)
$(MAKE) build-windows $(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 ./* cd build; zip -r ../$(BINARY_NAME)_$(GITREV)_windows_amd64.zip ./*
$(MAKE) build-docker $(MAKE) build-docker
$(MAKE) release-docker $(MAKE) release-docker

Loading…
Cancel
Save