From 6133df65fc3fc20b67faf57a0cdde3baf0b77fc7 Mon Sep 17 00:00:00 2001 From: Tom Kidd Date: Sat, 26 Jun 2021 21:42:36 -0500 Subject: [PATCH] Added shell script to compile Universal 2 binary (x86_64+arm64) --- Makefile | 2 +- make-macosx-app.sh | 6 +++++- make-macosx-ub2.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++ make-macosx.sh | 2 +- 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100755 make-macosx-ub2.sh diff --git a/Makefile b/Makefile index 7ec4fa32..dd708b8a 100644 --- a/Makefile +++ b/Makefile @@ -480,7 +480,7 @@ ifeq ($(PLATFORM),darwin) BASE_CFLAGS += -arch x86_64 endif ifeq ($(ARCH),arm64) - HAVE_VM_COMPILED=false # TODO: implement compiled vm + # HAVE_VM_COMPILED=false # TODO: implement compiled vm BASE_CFLAGS += -arch arm64 endif diff --git a/make-macosx-app.sh b/make-macosx-app.sh index d077c2f5..21248bc8 100755 --- a/make-macosx-app.sh +++ b/make-macosx-app.sh @@ -263,7 +263,11 @@ fi # set the final application bundle output directory if [ "${2}" == "" ]; then - BUILT_PRODUCTS_DIR="${OBJROOT}/${TARGET_NAME}-darwin-universal" + if [ -n "${MACOSX_DEPLOYMENT_TARGET_ARM64}" ]; then + BUILT_PRODUCTS_DIR="${OBJROOT}/${TARGET_NAME}-darwin-universal2" + else + BUILT_PRODUCTS_DIR="${OBJROOT}/${TARGET_NAME}-darwin-universal" + fi if [ ! -d ${BUILT_PRODUCTS_DIR} ]; then mkdir -p ${BUILT_PRODUCTS_DIR} || exit 1; fi diff --git a/make-macosx-ub2.sh b/make-macosx-ub2.sh new file mode 100755 index 00000000..b7cbd2f2 --- /dev/null +++ b/make-macosx-ub2.sh @@ -0,0 +1,50 @@ +#!/bin/bash +CC=gcc-4.0 + +cd `dirname $0` +if [ ! -f Makefile ]; then + echo "This script must be run from the ioquake3 build directory" + exit 1 +fi + +# This script is to build a Universal 2 binary +# (Apple's term for an x86_64 and arm64 binary) + +unset X86_64_SDK +unset X86_64_CFLAGS +unset X86_64_MACOSX_VERSION_MIN +unset ARM64_SDK +unset ARM64_CFLAGS +unset ARM64_MACOSX_VERSION_MIN + +X86_64_MACOSX_VERSION_MIN="10.7" +ARM64_MACOSX_VERSION_MIN="11.0" + +echo "Building X86_64 Client/Dedicated Server" +echo "Building ARM64 Client/Dedicated Server" +echo + +# For parallel make on multicore boxes... +NCPU=`sysctl -n hw.ncpu` + +# x86_64 client and server +#if [ -d build/release-release-x86_64 ]; then +# rm -r build/release-darwin-x86_64 +#fi +(ARCH=x86_64 CFLAGS=$X86_64_CFLAGS MACOSX_VERSION_MIN=$X86_64_MACOSX_VERSION_MIN make -j$NCPU) || exit 1; + +echo;echo + +# arm64 client and server +#if [ -d build/release-release-arm64 ]; then +# rm -r build/release-darwin-arm64 +#fi +(ARCH=arm64 CFLAGS=$ARM64_CFLAGS MACOSX_VERSION_MIN=$ARM64_MACOSX_VERSION_MIN make -j$NCPU) || exit 1; + +echo + +# use the following shell script to build a universal 2 application bundle +export MACOSX_DEPLOYMENT_TARGET="10.7" +export MACOSX_DEPLOYMENT_TARGET_X86_64="$X86_64_MACOSX_VERSION_MIN" +export MACOSX_DEPLOYMENT_TARGET_ARM64="$ARM64_MACOSX_VERSION_MIN" +"./make-macosx-app.sh" release diff --git a/make-macosx.sh b/make-macosx.sh index 4d68f673..81df929c 100755 --- a/make-macosx.sh +++ b/make-macosx.sh @@ -6,7 +6,7 @@ if [ $# -ne 1 ]; then echo "Usage: $0 target_architecture" echo "Example: $0 x86" - echo "other valid options are x86_64 or ppc" + echo "other valid options are arm64, x86_64 or ppc" echo echo "If you don't know or care about architectures please consider using make-macosx-ub.sh instead of this script." exit 1