mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-14 02:17:36 +08:00
Update the build-macos and build-macos-sdl2 scripts to build both arm64 and x86_64
Universal App Bundles require we build the executables twice. Update the build scripts to support building both arm64 and x86_64 architectures. By default the scripts should behave like they always did, despite the major overhaul, and only build for your host's architecture. To build *both* architectures, you *must* run the build on an Apple Silicon Mac *and* run the script with the word `universal` as the first parameter - any parameters thereafter are used as-is for the `configure` script of DosBox-X like the build script did before it supported the extra parameter. Signed-off-by: Dani Llewellyn <dani@bowlhat.net>
This commit is contained in:
174
build-macos
174
build-macos
@@ -12,73 +12,133 @@ if test -z "$top" ; then exit 1; fi
|
||||
# fix
|
||||
chmod +x vs/sdl/build-scripts/strip_fPIC.sh
|
||||
|
||||
# prefer to compile against our own copy of SDL 1.x
|
||||
echo Compiling our internal SDL 1.x
|
||||
(cd vs/sdl && ./build-dosbox.sh) || exit 1
|
||||
new="-I$top/vs/sdl/linux-host/include "
|
||||
nld="-L$top/vs/sdl/linux-host/lib "
|
||||
export CFLAGS="$new$CFLAGS"
|
||||
export LDFLAGS="$nld$LDFLAGS"
|
||||
export CPPFLAGS="$new$CPPFLAGS"
|
||||
export CXXFLAGS="$new$CXXFLAGS"
|
||||
orig_CFLAGS="$CFLAGS"
|
||||
orig_LDFLAGS="$LDFLAGS"
|
||||
orig_CPPFLAGS="$CPPFLAGS"
|
||||
orig_CXXFLAGS="$CXXFLAGS"
|
||||
|
||||
# prefer to compile against our own copy of SDLnet 1.x
|
||||
echo Compiling our internal SDLnet 1.x
|
||||
(cd vs/sdlnet && ./build-dosbox.sh) || exit 1
|
||||
do_cleanup() {
|
||||
rm -rf vs/sdl/linux-host vs/sdl/linux-build
|
||||
rm -rf vs/sdlnet/linux-host vs/sdlnet/linux-build
|
||||
rm -rf vs/zlib/linux-host vs/zlib/linux-build
|
||||
rm -rf vs/libpng/linux-host vs/libpng/linux-build
|
||||
rm -rf vs/freetype/linux-host vs/freetype/linux-build
|
||||
[ -e Makefile ] && make distclean
|
||||
}
|
||||
|
||||
# prefer to compile against our own zlib
|
||||
echo Compiling our internal zlib
|
||||
(cd vs/zlib && ./build-dosbox.sh) || exit 1
|
||||
new="-I$top/vs/zlib/linux-host/include "
|
||||
nld="-L$top/vs/zlib/linux-host/lib "
|
||||
export CFLAGS="$new$CFLAGS"
|
||||
export LDFLAGS="$nld$LDFLAGS"
|
||||
export CPPFLAGS="$new$CPPFLAGS"
|
||||
export CXXFLAGS="$new$CXXFLAGS"
|
||||
universal=0
|
||||
architectures="$(uname -m)"
|
||||
if [ "$1" = "universal" ]; then
|
||||
shift
|
||||
if [ "$architectures" = "arm64" ]; then
|
||||
# We can only build universal binaries on an arm64 host because we
|
||||
# need homebrew functional under both architectures.
|
||||
universal=1
|
||||
architectures="arm64 x86_64"
|
||||
fi
|
||||
fi
|
||||
|
||||
# prefer to compile against our own libpng (comment this out to disable)
|
||||
echo Compiling our internal libpng
|
||||
(cd vs/libpng && ./build-dosbox.sh) || exit 1
|
||||
new="-I$top/vs/libpng/linux-host/include "
|
||||
nld="-L$top/vs/libpng/linux-host/lib "
|
||||
export CFLAGS="$new$CFLAGS"
|
||||
export LDFLAGS="$nld$LDFLAGS"
|
||||
export CPPFLAGS="$new$CPPFLAGS"
|
||||
export CXXFLAGS="$new$CXXFLAGS"
|
||||
arm64_brew_cmd=""
|
||||
x86_64_brew_cmd=""
|
||||
# arm64 native Homebrew
|
||||
if [ -x /opt/homebrew/bin/brew ]; then
|
||||
arm64_brew_cmd="/opt/homebrew/bin/brew"
|
||||
fi
|
||||
|
||||
# prefer to compile against our own freetype
|
||||
echo Compiling our internal freetype
|
||||
(cd vs/freetype && ./build-dosbox.sh) || exit 1
|
||||
new="-I$top/vs/freetype/linux-host/include/freetype2 "
|
||||
nld="-L$top/vs/freetype/linux-host/lib -lfreetype "
|
||||
export CFLAGS="$new$CFLAGS"
|
||||
export LDFLAGS="$nld$LDFLAGS"
|
||||
export CPPFLAGS="$new$CPPFLAGS"
|
||||
export CXXFLAGS="$new$CXXFLAGS"
|
||||
export INTERNAL_FREETYPE=1
|
||||
# x86_64 Homebrew
|
||||
if [ -x /usr/local/bin/brew ]; then
|
||||
# old homebrew
|
||||
x86_64_brew_cmd="/usr/local/bin/brew"
|
||||
elif [ -x /usr/local/Homebrew/bin/brew ]; then
|
||||
# new homebrew
|
||||
x86_64_brew_cmd="/usr/local/Homebrew/bin/brew"
|
||||
fi
|
||||
|
||||
brew list fluid-synth &>/dev/null || brew install fluid-synth
|
||||
brew list libslirp &>/dev/null || brew install libslirp
|
||||
brew list pkg-config &>/dev/null || brew install pkg-config
|
||||
# x86_64 on arm64 for universal builds if x86_64 Homebrew is installed
|
||||
if [ -n "$x86_64_brew_cmd" ] && [ "$universal" -eq 1 ]; then
|
||||
x86_64_brew_cmd="/usr/bin/arch -x86_64 $x86_64_brew_cmd"
|
||||
fi
|
||||
|
||||
opts=
|
||||
for arch in $architectures; do
|
||||
declare brew_cmd="${arch}_brew_cmd"
|
||||
if [ -n "${!brew_cmd}" ]; then
|
||||
${!brew_cmd} list fluid-synth &>/dev/null || ${!brew_cmd} install fluid-synth
|
||||
${!brew_cmd} list libslirp &>/dev/null || ${!brew_cmd} install libslirp
|
||||
${!brew_cmd} list pkg-config &>/dev/null || ${!brew_cmd} install pkg-config
|
||||
fi
|
||||
|
||||
# if Brew has installed packages, try to use those too
|
||||
brew="/opt/homebrew"
|
||||
if [[ -d "$brew" && -d "$brew/include" && -d "$brew/lib" ]]; then
|
||||
echo "Brew is installed, I'm going to use it's libraries too"
|
||||
new=" -I$brew/include"
|
||||
nld=" -L$brew/lib"
|
||||
do_cleanup
|
||||
|
||||
arch_flags="-arch $arch -mmacosx-version-min=10.12 "
|
||||
export CFLAGS="$arch_flags$orig_CFLAGS"
|
||||
export LDFLAGS="$arch_flags$orig_LDFLAGS"
|
||||
export CPPFLAGS="$arch_flags$orig_CPPFLAGS"
|
||||
export CXXFLAGS="$arch_flags$orig_CXXFLAGS"
|
||||
|
||||
# prefer to compile against our own copy of SDL 1.x
|
||||
echo Compiling our internal SDL 1.x
|
||||
(cd vs/sdl && ./build-dosbox.sh) || exit 1
|
||||
new=" -I$top/vs/sdl/linux-host/include"
|
||||
nld=" -L$top/vs/sdl/linux-host/lib"
|
||||
export CFLAGS="$CFLAGS$new"
|
||||
export LDFLAGS="$LDFLAGS$nld"
|
||||
export CPPFLAGS="$CPPFLAGS$new"
|
||||
export CXXFLAGS="$CXXFLAGS$new"
|
||||
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$brew/lib/pkgconfig"
|
||||
fi
|
||||
|
||||
# now compile ourself
|
||||
echo Compiling DOSBox-X
|
||||
chmod +x configure
|
||||
./configure --enable-debug=heavy --prefix=/usr $opts "$@" || exit 1
|
||||
make -j3 || exit 1
|
||||
# prefer to compile against our own copy of SDLnet 1.x
|
||||
echo Compiling our internal SDLnet 1.x
|
||||
(cd vs/sdlnet && ./build-dosbox.sh) || exit 1
|
||||
|
||||
# prefer to compile against our own zlib
|
||||
echo Compiling our internal zlib
|
||||
(cd vs/zlib && ./build-dosbox.sh) || exit 1
|
||||
new=" -I$top/vs/zlib/linux-host/include"
|
||||
nld=" -L$top/vs/zlib/linux-host/lib"
|
||||
export CFLAGS="$CFLAGS$new"
|
||||
export LDFLAGS="$LDFLAGS$nld"
|
||||
export CPPFLAGS="$CPPFLAGS$new"
|
||||
export CXXFLAGS="$CXXFLAGS$new"
|
||||
|
||||
# prefer to compile against our own libpng (comment this out to disable)
|
||||
echo Compiling our internal libpng
|
||||
(cd vs/libpng && ./build-dosbox.sh) || exit 1
|
||||
new=" -I$top/vs/libpng/linux-host/include"
|
||||
nld=" -L$top/vs/libpng/linux-host/lib"
|
||||
export CFLAGS="$CFLAGS$new"
|
||||
export LDFLAGS="$LDFLAGS$nld"
|
||||
export CPPFLAGS="$CPPFLAGS$new"
|
||||
export CXXFLAGS="$CXXFLAGS$new"
|
||||
|
||||
# prefer to compile against our own freetype
|
||||
echo Compiling our internal freetype
|
||||
(cd vs/freetype && ./build-dosbox.sh) || exit 1
|
||||
new=" -I$top/vs/freetype/linux-host/include/freetype2"
|
||||
nld=" -L$top/vs/freetype/linux-host/lib -lfreetype"
|
||||
export CFLAGS="$CFLAGS$new"
|
||||
export LDFLAGS="$LDFLAGS$nld"
|
||||
export CPPFLAGS="$CPPFLAGS$new"
|
||||
export CXXFLAGS="$CXXFLAGS$new"
|
||||
export INTERNAL_FREETYPE=1
|
||||
|
||||
opts=
|
||||
|
||||
# if Brew has installed packages, try to use those too
|
||||
if [ -n "${!brew_cmd}" ]; then
|
||||
echo "Brew is installed, I'm going to use it's libraries too"
|
||||
new=" -I$(${!brew_cmd} --prefix)/include"
|
||||
nld=" -L$(${!brew_cmd} --prefix)/lib"
|
||||
export CFLAGS="$CFLAGS$new"
|
||||
export LDFLAGS="$LDFLAGS$nld"
|
||||
export CPPFLAGS="$CPPFLAGS$new"
|
||||
export CXXFLAGS="$CXXFLAGS$new"
|
||||
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(${!brew_cmd} --prefix)/lib/pkgconfig"
|
||||
fi
|
||||
|
||||
# now compile ourself
|
||||
echo Compiling DOSBox-X
|
||||
chmod +x configure
|
||||
./configure --enable-debug=heavy --prefix=/usr $opts "$@" || exit 1
|
||||
make -j3 || exit 1
|
||||
|
||||
cp src/dosbox-x src/dosbox-x-$arch
|
||||
done
|
Reference in New Issue
Block a user