summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile23
1 files changed, 19 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 7138f8f36..e3ed6e1a5 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,9 @@ GO_LINKER_FLAGS ?= -ldflags \
-X github.com/mattermost/platform/model.BuildHashEnterprise=$(BUILD_HASH_ENTERPRISE)\
-X github.com/mattermost/platform/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)"
+# GOOS/GOARCH of the build host, used to determine whether we're cross-compiling or not
+BUILDER_GOOS_GOARCH="$(shell $(GO) env GOOS)_$(shell $(GO) env GOARCH)"
+
# Output paths
DIST_ROOT=dist
DIST_PATH=$(DIST_ROOT)/mattermost
@@ -310,7 +313,11 @@ endif
@# Make osx package
@# Copy binary
- cp $(GOPATH)/bin/darwin_amd64/platform $(DIST_PATH)/bin
+ifeq ($(BUILDER_GOOS_GOARCH),"darwin_amd64")
+ cp $(GOPATH)/bin/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled
+else
+ cp $(GOPATH)/bin/darwin_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
+endif
@# Package
tar -C dist -czf $(DIST_PATH)-$(BUILD_TYPE_NAME)-osx-amd64.tar.gz mattermost
@# Cleanup
@@ -318,7 +325,11 @@ endif
@# Make windows package
@# Copy binary
- cp $(GOPATH)/bin/windows_amd64/platform.exe $(DIST_PATH)/bin
+ifeq ($(BUILDER_GOOS_GOARCH),"windows_amd64")
+ cp $(GOPATH)/bin/platform.exe $(DIST_PATH)/bin # from native bin dir, not cross-compiled
+else
+ cp $(GOPATH)/bin/windows_amd64/platform.exe $(DIST_PATH)/bin # from cross-compiled bin dir
+endif
@# Package
tar -C dist -czf $(DIST_PATH)-$(BUILD_TYPE_NAME)-windows-amd64.tar.gz mattermost
@# Cleanup
@@ -326,10 +337,14 @@ endif
@# Make linux package
@# Copy binary
- cp $(GOPATH)/bin/platform $(DIST_PATH)/bin
+ifeq ($(BUILDER_GOOS_GOARCH),"linux_amd64")
+ cp $(GOPATH)/bin/platform $(DIST_PATH)/bin # from native bin dir, not cross-compiled
+else
+ cp $(GOPATH)/bin/linux_amd64/platform $(DIST_PATH)/bin # from cross-compiled bin dir
+endif
@# Package
tar -C dist -czf $(DIST_PATH)-$(BUILD_TYPE_NAME)-linux-amd64.tar.gz mattermost
- @# Don't cleanup linux package so dev machines will have an unziped linux package avalilable
+ @# Don't clean up native package so dev machines will have an unzipped package available
@#rm -f $(DIST_PATH)/bin/platform