diff --git a/macos/Dependencies/dependencies.make b/macos/Dependencies/dependencies.make index 5ee68510..204e26e8 100644 --- a/macos/Dependencies/dependencies.make +++ b/macos/Dependencies/dependencies.make @@ -87,7 +87,7 @@ sigcxx: init_dirs $(LIBDIR)/libsigc-2.0.a $(LIBDIR)/libsigc-2.0.a: $(DOWNLOADS)/sigcxx/Makefile cd $(DOWNLOADS)/sigcxx; \ - make; make install + $(CONFIGURE_ENV) make; $(CONFIGURE_ENV) make install $(DOWNLOADS)/sigcxx/Makefile: $(DOWNLOADS)/sigcxx/autogen.sh cd $(DOWNLOADS)/sigcxx; \ @@ -262,11 +262,11 @@ $(DOWNLOADS)/openssl/Configure: cd $(DOWNLOADS)/openssl; git checkout OpenSSL_1_1_1i # Standard ruby -ruby: init_dirs $(LIBDIR)/libruby.3.0.dylib openssl +ruby: init_dirs openssl $(LIBDIR)/libruby.3.0.dylib $(LIBDIR)/libruby.3.0.dylib: $(DOWNLOADS)/ruby/Makefile cd $(DOWNLOADS)/ruby; \ - make -j$(NPROC); make install + $(CONFIGURE_ENV) make -j$(NPROC); $(CONFIGURE_ENV) make install # Make the dylib relative install_name_tool -id @rpath/libruby.3.0.dylib $(LIBDIR)/libruby.3.0.dylib diff --git a/macos/Dependencies/make_macuniversal.command b/macos/Dependencies/make_macuniversal similarity index 100% rename from macos/Dependencies/make_macuniversal.command rename to macos/Dependencies/make_macuniversal diff --git a/macos/Dependencies/setup b/macos/Dependencies/setup new file mode 100755 index 00000000..77bb9b9d --- /dev/null +++ b/macos/Dependencies/setup @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +HOST = `clang -dumpmachine`.strip +ARCH = HOST[/x86_64|arm64/] + +def run_build(arch) + case arch + when "x86_64" + return system("make everything -f .Intel") + when "arm64" + code = system("make everything -f .AppleSilicon") + return code if !code + code = (system("arch -x86_64 make everything -f .Intel")) + return code if !code + return system("./make_macuniversal") + else + raise "Unsupported architecture" + end +end + +exit(run_build(ARCH) ? 0 : 1) diff --git a/macos/README.md b/macos/README.md index 8fa2656c..ec5832f8 100644 --- a/macos/README.md +++ b/macos/README.md @@ -1,34 +1,4 @@ -This folder contains an experimental Xcode project that will build mkxp-z and all of its dependencies. +Currently, building the Apple Silicon and Universal schemes requires an ARM Mac on hand. -Currently, building mkxp-z for ARM requires an ARM Mac on hand. -This is primarily because libsigc++ doesn't properly cross-compile when you ask it to. - -To get all dependencies, cd to the `Dependencies` folder and run: - -```sh -# This will download all the required tools -# for building the dependencies -brew bundle - -# Intel Macs -make everything -f .Intel - -# ARM Macs -make everything -f .AppleSilicon - -# Create universal libraries (For the universal build) -make everything -f .AppleSilicon -arch -x86_64 make everything -f .Intel -./make_macuniversal.command - -# Use your own Ruby, and build everything else (for Intel Macs) -make custom-ruby -f .Intel RUBY_PATH="Path to Ruby" RUBY_FLAGS="extra configure arguments" -make deps-core -f .Intel -``` - -Afterwards, simply open the Xcode project, select the scheme you'd like to use -and hit Command+B. - -If you built a version of ruby >= 2, change the MRI_VERSION build setting to match. - -If you built 1.8, select the PlayerLegacy scheme. \ No newline at end of file +To get all dependencies, all you need to do is run `setup.command`. +Then you can open the Xcode project and build it. \ No newline at end of file diff --git a/macos/setup.command b/macos/setup.command new file mode 100755 index 00000000..5e53039b --- /dev/null +++ b/macos/setup.command @@ -0,0 +1,7 @@ +#!/bin/bash + +# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +cd "$DIR/Dependencies" +./setup \ No newline at end of file