summaryrefslogtreecommitdiff
path: root/cmd/rescribe/makefile
diff options
context:
space:
mode:
authorNick White <git@njw.name>2022-02-09 16:23:45 +0000
committerNick White <git@njw.name>2022-02-09 16:23:45 +0000
commitb539af4ca52c94db8dfa8a1d7e91a2400ae03f87 (patch)
treebfbf641c18549cfcaebdb035c01752b2597356ff /cmd/rescribe/makefile
parent1045fde0b0e5025ca0c1140949474455418f77f8 (diff)
rescribe: makefile now supports cross-compiling with fyne
This also necessitated a version bump to fyne.
Diffstat (limited to 'cmd/rescribe/makefile')
-rw-r--r--cmd/rescribe/makefile66
1 files changed, 58 insertions, 8 deletions
diff --git a/cmd/rescribe/makefile b/cmd/rescribe/makefile
index aee2114..21a59fb 100644
--- a/cmd/rescribe/makefile
+++ b/cmd/rescribe/makefile
@@ -1,19 +1,69 @@
# See LICENSE file for copyright and license details.
+#
+# This is a set of make(1) rules to cross compile rescribe
+# from Linux to other architectures - as we use Fyne, CGO
+# is required, so we have to do more to cross compile than
+# just rely on the standard go tools. It relies on osxcross
+# being set up for the Mac builds, and mingw-w64 being
+# installed for the Windows build.
+#
+# The standard go tools work perfectly for native builds on
+# all architectures - note that "go generate" needs to be
+# run before building to download the dependencies which are
+# embedded.
-all: dist/linux/rescribe dist/darwin_amd64/rescribe dist/darwin_arm64/rescribe dist/windows/rescribe.exe
+# For osxcross, there are many versions of the MacOS SDK
+# that are too old or too new to build Rescribe correctly.
+# SDK 11.3, as extracted from XCode 12.5.1, seems to work
+# perfectly for us.
+OSXCROSSBIN=$(HOME)/src/osxcross/target/bin
-dist/linux/rescribe:
+EMBEDS=embed_darwin_amd64.go embed_linux.go embed_windows.go gui.go embed_darwin_arm64.go embed_other.go
+GODEPS=gui.go main.go $(EMBEDS)
+
+all: dist/linux/rescribe dist/darwin_universal/Rescribe.app dist/windows/rescribe.exe
+
+dist/linux/rescribe: $(GODEPS)
+ go generate
mkdir -p dist/linux
GOOS=linux GOARCH=amd64 go build -o $@ .
-dist/darwin_amd64/rescribe:
+dist/darwin_amd64/rescribe: $(GODEPS)
+ go generate
mkdir -p dist/darwin_amd64
- GOOS=darwin GOARCH=amd64 go build -o $@ .
+ PATH="$(PATH):$(OSXCROSSBIN)" CC="o64-clang" CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o $@ .
-dist/darwin_arm64/rescribe:
+dist/darwin_arm64/rescribe: $(GODEPS)
+ go generate
mkdir -p dist/darwin_arm64
- GOOS=darwin GOARCH=arm64 go build -o $@ .
+ PATH="$(PATH):$(OSXCROSSBIN)" CC="oa64-clang" CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o $@ .
+
+dist/darwin_universal/rescribe: dist/darwin_amd64/rescribe dist/darwin_arm64/rescribe
+ mkdir -p dist/darwin_universal
+ PATH="$(PATH):$(OSXCROSSBIN)" lipo -create dist/darwin_amd64/rescribe dist/darwin_arm64/rescribe -output $@
+
+# TODO: remove this, once universal is confirmed working
+dist/darwin_amd64/Rescribe.app: dist/darwin_amd64/rescribe
+ go install fyne.io/fyne/v2/cmd/fyne@latest
+ fyne package --name Rescribe --exe dist/darwin_amd64/rescribe --os darwin --icon icon.png
+ mv Rescribe.app $@
-dist/windows/rescribe.exe:
+# TODO: remove this, once universal is confirmed working
+dist/darwin_arm64/Rescribe.app: dist/darwin_arm64/rescribe
+ go install fyne.io/fyne/v2/cmd/fyne@latest
+ fyne package --name Rescribe --exe dist/darwin_arm64/rescribe --os darwin --icon icon.png
+ mv Rescribe.app $@
+
+dist/darwin_universal/Rescribe.app: dist/darwin_universal/rescribe
+ go install fyne.io/fyne/v2/cmd/fyne@latest
+ fyne package --name Rescribe --exe dist/darwin_universal/rescribe --os darwin --icon icon.png
+ mv Rescribe.app $@
+
+dist/windows/rescribe-bin.exe: $(GODEPS)
+ #go generate
mkdir -p dist/windows
- GOOS=windows GOARCH=386 go build -o $@ .
+ CC="x86_64-w64-mingw32-gcc" CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o $@ .
+
+dist/windows/rescribe.exe: dist/windows/rescribe-bin.exe
+ CC="x86_64-w64-mingw32-gcc" fyne package --name Rescribe --exe dist/windows/rescribe-bin.exe --os windows --icon icon.png
+ mv rescribe.exe $@