From 1b7e12caa5ecf231c8b56b513e0a502414936746 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Wed, 21 Sep 2016 04:59:11 -0700 Subject: Fixing make file so you can build linx on mac easily (#4058) --- Makefile | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3-1-g7c22