Start of M1 support. Currently all MacOS support is broken.

This commit is contained in:
Scott Duensing 2021-08-12 18:37:24 -05:00
parent 1ba9000661
commit 1956472c30

View file

@ -2,7 +2,7 @@
# #
# JoeyLib # JoeyLib
# Copyright (C) 2018-2019 Scott Duensing <scott@kangaroopunch.com> # Copyright (C) 2018-2021 Scott Duensing <scott@kangaroopunch.com>
# #
# This software is provided 'as-is', without any express or implied # This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages # warranty. In no event will the authors be held liable for any damages
@ -36,10 +36,13 @@ G_AUTOMATED=
G_PASSWORD= G_PASSWORD=
G_ORCA_FILE= G_ORCA_FILE=
G_GOLDEN_GATE_FILE= G_GOLDEN_GATE_FILE=
G_XCODE_FILE= G_MAC_INTEL_MIN=10.6
G_OSX_MIN=10.6 G_MAC_INTEL_DARWIN=17
G_OSX_DARWIN=17 G_MAC_INTEL_XIP="$(pwd)/Xcode_9.4.1.xip"
#***TODO*** This list is dumb. It and more should be in an array. G_MAC_APPLE_MIN=10.9
G_MAC_APPLE_DARWIN=20.4
G_MAC_APPLE_XIP="$(pwd)/Xcode_12.5.1.xip"
#***TODO*** This list is dumb. It and more should be in an array. The rest is in the mainMenu code.
G_IIGS=0 G_IIGS=0
#G_AMIGA=1 #G_AMIGA=1
#G_ATARIST=2 #G_ATARIST=2
@ -47,56 +50,79 @@ G_LINUX32=1
G_LINUX64=2 G_LINUX64=2
G_WIN32=3 G_WIN32=3
G_WIN64=4 G_WIN64=4
G_MAC32=5 G_MACX32=5
G_MAC64=6 G_MACX64=6
G_MACA64=7
#G_ANDROID=9 #G_ANDROID=9
#G_IOS=10 #G_IOS=10
function buildMacOSXSDK() { function buildMacOSXSDK() {
local RESULT=$1 local ARCH=$1
local RESULT=$2
local XCODE= local XCODE=
local XIP=
local OSX="${G_PARENT}/sdks/macOS" local OSX="${G_PARENT}/sdks/macOS"
eval $RESULT=0 eval $RESULT=0
if [[ "${ARCH}" == "APPLE" ]]; then
OSX="${OSX}/apple"
XIP="${G_MAC_APPLE_XIP}"
else
OSX="${OSX}/intel"
XIP="${G_MAC_INTEL_XIP}"
fi
mkdir -p "${G_PARENT}/sdks" mkdir -p "${G_PARENT}/sdks"
if [[ -e "${OSX}/SDK" ]]; then
eval $RESULT=1
return 0
fi
if [[ ! -z ${G_AUTOMATED} ]]; then if [[ ! -z ${G_AUTOMATED} ]]; then
XCODE=${G_XCODE_FILE} XCODE=${XIP}
if [[ ! -e "${XCODE}" ]]; then if [[ ! -e "${XCODE}" ]]; then
return 0 return 0
fi fi
else else
if [[ ! -e "${OSX}/SDK" ]]; then tFileBrowser XCODE "Please locate ${XIP}" .xip ..
tFileBrowser XCODE "Please locate your XCode XIP" .xip .. if [[ -z ${XCODE} || "${XCODE}" == "" ]]; then
if [[ -z ${XCODE} || "${XCODE}" == "" ]]; then return 0
return 0
fi
fi fi
fi fi
purple "Building macOS SDK"
if [[ ! -d osxcross ]]; then if [[ ! -d osxcross ]]; then
purple "Building macOS SDK"
git clone https://github.com/tpoechtrager/osxcross.git git clone https://github.com/tpoechtrager/osxcross.git
pushd osxcross &> /dev/null
./tools/gen_sdk_package_pbzx.sh "${XCODE}"
mv -f MacOSX.* tarballs/.
# SDK_VERSION=
OSX_VERSION_MIN=${G_OSX_MIN} UNATTENDED=1 ./build.sh
mv -f target "${OSX}"
popd &> /dev/null
fi fi
pushd osxcross &> /dev/null
G_IS_INSTALLED[$G_MAC32]=1 ./tools/gen_sdk_package_pbzx.sh "${XCODE}"
G_IS_INSTALLED[$G_MAC64]=1 mv -f MacOSX.* tarballs/.
configWrite # SDK_VERSION=
configRead # OSX_VERSION_MIN=${G_MAC_INTEL_MIN}
UNATTENDED=1 ./build.sh
mv -f target "${OSX}"
./cleanup.sh
popd &> /dev/null
eval $RESULT=1 eval $RESULT=1
} }
function buildPCDepsM1Hack() {
mkdir -p build-scripts
pushd build-scripts &> /dev/null
rm -f config.guess config.sub
wget https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
wget https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
popd &> /dev/null
cp -f build-scripts/config.guess .
cp -f build-scripts/config.sub .
}
function buildPCDeps() { function buildPCDeps() {
local TARGET=$1 local TARGET=$1
local FOLDER=$2 local FOLDER=$2
@ -104,11 +130,13 @@ function buildPCDeps() {
local CC_EXPORT=$4 local CC_EXPORT=$4
local CXX_EXPORT=$5 local CXX_EXPORT=$5
local LD_EXPORT=$6 local LD_EXPORT=$6
local ADD_PATH=$7
local DIST="$(pwd)/../dist/${FOLDER}" local DIST="$(pwd)/../dist/${FOLDER}"
local PREFIX="$(pwd)/../sdks/${FOLDER}" local PREFIX="$(pwd)/../sdks/${FOLDER}"
local CC_OLD=$CC local CC_OLD=${CC}
local CXX_OLD=$CXX local CXX_OLD=${CXX}
local LD_OLD=$LD_LIBRARY_PATH local LD_OLD=${LD_LIBRARY_PATH}
local PATH_OLD=${PATH}
local SRC="${G_PARENT}/joeylib/joeylib/src" local SRC="${G_PARENT}/joeylib/joeylib/src"
local G_CFLAGS="-Wall -D_REENTRANT_ -I${SRC} -I${PREFIX}/include -c" local G_CFLAGS="-Wall -D_REENTRANT_ -I${SRC} -I${PREFIX}/include -c"
@ -121,12 +149,17 @@ function buildPCDeps() {
export CXX="${CXX_EXPORT}" export CXX="${CXX_EXPORT}"
export LD_LIBRARY_PATH="${LD_EXPORT}" export LD_LIBRARY_PATH="${LD_EXPORT}"
if [[ ! -z ${ADD_PATH} ]]; then
export PATH="${ADD_PATH}:${PATH}"
fi
# SDL2 # SDL2
purple "Building SDL2 ${TARGET}" purple "Building SDL2 ${TARGET}"
if [[ ! -d SDL ]]; then if [[ ! -d SDL ]]; then
hg clone http://hg.libsdl.org/SDL hg clone http://hg.libsdl.org/SDL
pushd SDL &> /dev/null pushd SDL &> /dev/null
hg up release-2.0.12 hg up release-2.0.14
buildPCDepsM1Hack
popd &> /dev/null popd &> /dev/null
fi fi
if [[ ! -e "${PREFIX}/lib/libSDL2.a" ]]; then if [[ ! -e "${PREFIX}/lib/libSDL2.a" ]]; then
@ -157,6 +190,7 @@ function buildPCDeps() {
autoheader autoheader
automake --force-missing --add-missing automake --force-missing --add-missing
autoconf autoconf
buildPCDepsM1Hack
popd &> /dev/null popd &> /dev/null
fi fi
if [[ ! -e "${PREFIX}/lib/libmodplug.a" ]]; then if [[ ! -e "${PREFIX}/lib/libmodplug.a" ]]; then
@ -180,6 +214,7 @@ function buildPCDeps() {
hg clone http://hg.libsdl.org/SDL_mixer hg clone http://hg.libsdl.org/SDL_mixer
pushd SDL_mixer &> /dev/null pushd SDL_mixer &> /dev/null
hg up release-2.0.4 hg up release-2.0.4
buildPCDepsM1Hack
popd &> /dev/null popd &> /dev/null
fi fi
if [[ ! -e "${PREFIX}/lib/libSDL2_mixer.a" ]]; then if [[ ! -e "${PREFIX}/lib/libSDL2_mixer.a" ]]; then
@ -215,6 +250,8 @@ function buildPCDeps() {
export CXX="${CXX_OLD}" export CXX="${CXX_OLD}"
export LD_LIBRARY_PATH="${LD_OLD}" export LD_LIBRARY_PATH="${LD_OLD}"
export PATH="${PATH_OLD}"
configWrite configWrite
configRead configRead
@ -340,16 +377,22 @@ function configWrite() {
SDKLIST="${SDKLIST} ST" SDKLIST="${SDKLIST} ST"
P=\${JOEY}/sdks/st/bin:${P} P=\${JOEY}/sdks/st/bin:${P}
fi fi
if [[ ${G_IS_INSTALLED[$G_MAC32]} == 1 || ${G_IS_INSTALLED[$G_MAC64]} == 1 ]]; then if [[ ${G_IS_INSTALLED[$G_MACX32]} == 1 || ${G_IS_INSTALLED[$G_MACX64]} == 1 ]]; then
if [[ ${G_IS_INSTALLED[$G_MAC32]} == 1 ]]; then if [[ ${G_IS_INSTALLED[$G_MACX32]} == 1 ]]; then
SDKLIST="${SDKLIST} MACOS32" SDKLIST="${SDKLIST} MACOSX32"
fi fi
if [[ ${G_IS_INSTALLED[$G_MAC64]} == 1 ]]; then if [[ ${G_IS_INSTALLED[$G_MACX64]} == 1 ]]; then
SDKLIST="${SDKLIST} MACOS64" SDKLIST="${SDKLIST} MACOSX64"
fi fi
P=\${JOEY}/sdks/macOS/bin:${P} echo "export MACOSX_INTEL_PATH=\"\${JOEY}/sdks/macOS/intel/bin\"" >> "${O}"
echo "export MACOSX_DEPLOYMENT_TARGET=${G_OSX_MIN}" >> "${O}" echo "export MACOSX_INTEL_DEPLOYMENT_TARGET=${G_MAC_INTEL_MIN}" >> "${O}"
echo "export MACOSX_DARWIN=${G_OSX_DARWIN}" >> "${O}" echo "export MACOSX_INTEL_DARWIN=${G_MAC_INTEL_DARWIN}" >> "${O}"
fi
if [[ ${G_IS_INSTALLED[$G_MACA64]} == 1 ]]; then
SDKLIST="${SDKLIST} MACOSA64"
echo "export MACOSX_APPLE_PATH=\"\${JOEY}/sdks/macOS/apple/bin\"" >> "${O}"
echo "export MACOSX_APPLE_DEPLOYMENT_TARGET=${G_MAC_APPLE_MIN}" >> "${O}"
echo "export MACOSX_APPLE_DARWIN=${G_MAC_APPLE_DARWIN}" >> "${O}"
fi fi
echo "export PATH=\"${P}\"" >> "${O}" echo "export PATH=\"${P}\"" >> "${O}"
if [[ ${G_IS_INSTALLED[$G_WIN32]} == 1 ]]; then if [[ ${G_IS_INSTALLED[$G_WIN32]} == 1 ]]; then
@ -697,6 +740,7 @@ function installLinux32() {
"x86_64-linux-gnu" \ "x86_64-linux-gnu" \
"x86_64-linux-gnu-gcc -m32" \ "x86_64-linux-gnu-gcc -m32" \
"x86_64-linux-gnu-g++ -m32" \ "x86_64-linux-gnu-g++ -m32" \
"" \
"" ""
} }
@ -708,38 +752,66 @@ function installLinux64() {
"x86_64-linux-gnu" \ "x86_64-linux-gnu" \
"x86_64-linux-gnu-gcc" \ "x86_64-linux-gnu-gcc" \
"x86_64-linux-gnu-g++" \ "x86_64-linux-gnu-g++" \
"" \
"" ""
#buildSDL12 "x86_64-linux-gnu" "${JOEY}/sdks/linux/x64" #buildSDL12 "x86_64-linux-gnu" "${JOEY}/sdks/linux/x64"
} }
function installmacOS32() { function installmacOSA64() {
local INSTALLED= local INSTALLED=
buildMacOSXSDK INSTALLED buildMacOSXSDK APPLE INSTALLED
if [[ ${INSTALLED} -eq 1 ]]; then if [[ ${INSTALLED} -eq 1 ]]; then
buildPCDeps \ buildPCDeps \
"macos32" \ "macosa64" \
"macOS/i386" \ "macOS/a64" \
"i386-apple-darwin${G_OSX_DARWIN}" \ "arm64-apple-darwin${G_MAC_APPLE_DARWIN}" \
"o32-clang" \ "oa64-clang" \
"" \ "" \
"${JOEY}/sdks/macOS/lib" "${JOEY}/sdks/macOS/apple/lib" \
fi "${JOEY}/sdks/macOS/apple/bin"
G_IS_INSTALLED[$G_MACA64]=1
configWrite
configRead
fi
} }
function installmacOS64() { function installmacOSX32() {
local INSTALLED= local INSTALLED=
buildMacOSXSDK INSTALLED buildMacOSXSDK INTEL INSTALLED
if [[ ${INSTALLED} -eq 1 ]]; then if [[ ${INSTALLED} -eq 1 ]]; then
buildPCDeps \ buildPCDeps \
"macos64" \ "macosx32" \
"macOS/i386" \
"i386-apple-darwin${G_MAC_INTEL_DARWIN}" \
"o32-clang" \
"" \
"${JOEY}/sdks/macOS/intel/lib" \
"${JOEY}/sdks/macOS/intel/bin"
G_IS_INSTALLED[$G_MACX32]=1
configWrite
configRead
fi
}
function installmacOSX64() {
local INSTALLED=
buildMacOSXSDK INTEL INSTALLED
if [[ ${INSTALLED} -eq 1 ]]; then
buildPCDeps \
"macosx64" \
"macOS/x64" \ "macOS/x64" \
"x86_64-apple-darwin${G_OSX_DARWIN}" \ "x86_64-apple-darwin${G_MAC_INTEL_DARWIN}" \
"o64-clang" \ "o64-clang" \
"" \ "" \
"${JOEY}/sdks/macOS/lib" "${JOEY}/sdks/macOS/intel/lib" \
fi "${JOEY}/sdks/macOS/intel/bin"
G_IS_INSTALLED[$G_MACX64]=1
configWrite
configRead
fi
} }
@ -837,6 +909,7 @@ function installWin32() {
"i686-w64-mingw32" \ "i686-w64-mingw32" \
"i686-w64-mingw32-gcc -static-libgcc" \ "i686-w64-mingw32-gcc -static-libgcc" \
"" \ "" \
"" \
"" ""
} }
@ -848,6 +921,7 @@ function installWin64() {
"x86_64-w64-mingw32" \ "x86_64-w64-mingw32" \
"x86_64-w64-mingw32-gcc -static-libgcc" \ "x86_64-w64-mingw32-gcc -static-libgcc" \
"x86_64-w64-mingw32-g++ -static-libstdc++" \ "x86_64-w64-mingw32-g++ -static-libstdc++" \
"" \
"" ""
} }
@ -861,8 +935,9 @@ function mainMenu() {
"Linux64" "Linux64"
"Win32" "Win32"
"Win64" "Win64"
"macOS32" "macOSX32"
"macOS64" "macOSX64"
"macOSA64"
# "Android" # "Android"
# "iOS" # "iOS"
) )
@ -874,8 +949,9 @@ function mainMenu() {
"Linux 64" "Linux 64"
"Windows 32" "Windows 32"
"Windows 64" "Windows 64"
"macOS 32" "macOS Intel 32"
"macOS 64" "macOS Intel 64"
"macOS Apple 64"
# "Android 32" # "Android 32"
# "iOS 64" # "iOS 64"
) )
@ -889,6 +965,7 @@ function mainMenu() {
"windows/x64/libjoeylib.a" "windows/x64/libjoeylib.a"
"macOS/i386/libjoeylib.a" "macOS/i386/libjoeylib.a"
"macOS/x64/libjoeylib.a" "macOS/x64/libjoeylib.a"
"macOS/a64/libjoeylib.a"
# "Android" # "Android"
# "iOS" # "iOS"
) )
@ -908,6 +985,7 @@ function mainMenu() {
0 0
0 0
0 0
0
# 0 # 0
# 0 # 0
) )
@ -1122,7 +1200,6 @@ if [[ "$1" == "AUTOMATED" ]]; then
G_PASSWORD="$2" G_PASSWORD="$2"
G_ORCA_FILE="$3" G_ORCA_FILE="$3"
G_GOLDEN_GATE_FILE="$4" G_GOLDEN_GATE_FILE="$4"
G_XCODE_FILE="$5"
fi fi
# Don't run as root. # Don't run as root.