Fix SM compilation on M1, fix cross-compilation.

Fixes 08e7efc76a.
The SM build script worked on its own, but the mac OS libraries script
passes it an unexpected value.
This also fixes cross-compilation arm -> x86.
Harfbuzz is explicitly not used when compiling freetype to avoid
pkgconfig using it.

Reorganize the logic a little bit around architecture handling.

Differential Revision: https://code.wildfiregames.com/D4647
This was SVN commit r26882.
This commit is contained in:
wraitii 2022-05-15 21:22:49 +00:00
parent 08e7efc76a
commit f82fc6431b
2 changed files with 26 additions and 20 deletions

View file

@ -62,19 +62,28 @@ elseif not os.istarget("windows") then
end
-- detect CPU architecture (simplistic)
-- The user can target an architecture with HOSTTYPE, but the game still selects some know value.
arch = "x86"
macos_arch = "x86_64"
if _OPTIONS["android"] then
arch = "arm"
elseif os.istarget("windows") then
if os.getenv("PROCESSOR_ARCHITECTURE") == "amd64" or os.getenv("PROCESSOR_ARCHITEW6432") == "amd64" then
if os.getenv("HOSTTYPE") then
arch = os.getenv("HOSTTYPE")
elseif os.getenv("PROCESSOR_ARCHITECTURE") == "amd64" or os.getenv("PROCESSOR_ARCHITEW6432") == "amd64" then
arch = "amd64"
end
else
os.execute(cc .. " -dumpmachine > .gccmachine.tmp")
local f = io.open(".gccmachine.tmp", "r")
local machine = f:read("*line")
f:close()
local machine = "x86_64"
if os.getenv("HOSTTYPE") and os.getenv("HOSTTYPE") ~= '' then
machine = os.getenv("HOSTTYPE")
else
os.execute(cc .. " -dumpmachine > .gccmachine.tmp")
local f = io.open(".gccmachine.tmp", "r")
machine = f:read("*line")
f:close()
end
-- Special handling on mac os where xcode needs special flags.
if os.istarget("macosx") then
if string.find(machine, "arm64") then

View file

@ -97,21 +97,16 @@ ARCHLESS_LDFLAGS="$LDFLAGS -stdlib=libc++"
# If ARCH isn't set, select either x86_64 or arm64
if [ -z "${ARCH}" ]; then
if [ "`uname -m`" == "arm64" ]; then
ARCH="arm64"
# Some libs want this passed to configure for cross compilation.
HOST_PLATFORM="--host=aarch64-apple-darwin"
else
CXXFLAGS="$CXXFLAGS -msse4.1"
ARCH="x86_64"
# Some libs want this passed to configure for cross compilation.
HOST_PLATFORM="--host=x86_64-apple-darwin"
fi
ARCH=`uname -m`
fi
if [ $ARCH == "arm64" ]; then
# Some libs want this passed to configure for cross compilation.
HOST_PLATFORM="--host=aarch64-apple-darwin"
else
CXXFLAGS="$CXXFLAGS -msse4.1"
# Some libs want this passed to configure for cross compilation.
HOST_PLATFORM="--host=x86_64-apple-darwin"
fi
echo "ARCHITECTURE BREAKDOWN"
echo $ARCH
echo $HOST_PLATFORM
CFLAGS="$CFLAGS -arch $ARCH"
CXXFLAGS="$CXXFLAGS -arch $ARCH"
@ -463,10 +458,10 @@ then
CONF_OPTS="--prefix=$INSTALL_DIR
--disable-shared
--enable-unicode
--enable-universal_binary=x86_64
--with-cocoa
--with-opengl
--with-libiconv-prefix=${ICONV_DIR}
--enable-universal-binary=${ARCH}
--with-expat=builtin
--with-libpng=builtin
--without-libtiff
@ -557,7 +552,9 @@ then
(./configure CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
--prefix=$INSTALL_DIR \
"$HOST_PLATFORM" \
--enable-shared=no \
--with-harfbuzz=no \
--with-bzip2=no \
--with-brotli=no \
&& make ${JOBS} && make install) || die "freetype build failed"