2021-01-23 05:44:05 +13:00
|
|
|
#!/usr/bin/env bash
|
2019-11-11 13:58:18 +01:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# This file will need to be run in bash, for now.
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2023-04-24 20:24:22 +02:00
|
|
|
# shellcheck source=/dev/null
|
|
|
|
. "${DIR}/../Meta/shell_include.sh"
|
|
|
|
|
|
|
|
exit_if_running_as_root "Do not run BuildQemu.sh as root, parts of your Toolchain directory will become root-owned"
|
|
|
|
|
2019-11-11 13:58:18 +01:00
|
|
|
echo "$DIR"
|
|
|
|
|
2021-07-03 10:43:13 +02:00
|
|
|
PREFIX="$DIR/Local/qemu"
|
2020-12-28 22:38:52 -05:00
|
|
|
BUILD=$(realpath "$DIR/../Build")
|
|
|
|
SYSROOT="$BUILD/Root"
|
2019-11-11 13:58:18 +01:00
|
|
|
|
2023-04-15 23:14:11 +02:00
|
|
|
# shellcheck source=/dev/null
|
|
|
|
source "${DIR}/../Ports/qemu/version.sh"
|
2019-11-11 13:58:18 +01:00
|
|
|
|
|
|
|
echo PREFIX is "$PREFIX"
|
|
|
|
echo SYSROOT is "$SYSROOT"
|
|
|
|
|
|
|
|
mkdir -p "$DIR/Tarballs"
|
|
|
|
|
|
|
|
pushd "$DIR/Tarballs"
|
2023-04-15 23:14:11 +02:00
|
|
|
if [ ! -e "${QEMU_ARCHIVE}" ]; then
|
|
|
|
curl -C - -O "${QEMU_ARCHIVE_URL}"
|
2019-11-11 13:58:18 +01:00
|
|
|
else
|
2023-04-15 23:14:11 +02:00
|
|
|
echo "Skipped downloading ${QEMU_ARCHIVE}"
|
2019-11-11 13:58:18 +01:00
|
|
|
fi
|
|
|
|
|
2023-04-15 23:14:11 +02:00
|
|
|
if ! sha256sum --status -c <(echo "${QEMU_ARCHIVE_SHA256SUM}" "${QEMU_ARCHIVE}"); then
|
|
|
|
echo "qemu sha256 sum mismatching, please run script again."
|
|
|
|
rm -f "${QEMU_ARCHIVE}"
|
2020-01-24 19:59:45 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-04-28 16:57:36 +02:00
|
|
|
if [ -d "qemu-$QEMU_VERSION" ]; then
|
|
|
|
rm -rf "qemu-$QEMU_VERSION"
|
2019-11-11 13:58:18 +01:00
|
|
|
fi
|
2022-02-12 07:07:31 -08:00
|
|
|
|
2023-04-28 16:57:36 +02:00
|
|
|
echo "Extracting qemu..."
|
|
|
|
tar -xf "${QEMU_ARCHIVE}"
|
2019-11-11 13:58:18 +01:00
|
|
|
popd
|
|
|
|
|
|
|
|
mkdir -p "$PREFIX"
|
2021-07-03 10:43:13 +02:00
|
|
|
mkdir -p "$DIR/Build/qemu"
|
2019-11-11 13:58:18 +01:00
|
|
|
|
2023-05-02 21:05:04 +02:00
|
|
|
NPROC=$(get_number_of_processing_units)
|
|
|
|
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
2019-11-11 13:58:18 +01:00
|
|
|
|
2023-04-28 16:14:06 +02:00
|
|
|
EXTRA_ARGS=""
|
2020-04-06 16:55:25 -07:00
|
|
|
if [[ $(uname) == "Darwin" ]]
|
|
|
|
then
|
|
|
|
UI_LIB=cocoa
|
2023-04-28 16:14:06 +02:00
|
|
|
|
|
|
|
# SDL causes a crash on startup: "NSWindow drag regions should only be invalidated on the Main Thread!"
|
|
|
|
EXTRA_ARGS="--disable-sdl"
|
2020-04-06 16:55:25 -07:00
|
|
|
else
|
|
|
|
UI_LIB=gtk
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo Using $UI_LIB based UI
|
|
|
|
|
2021-07-03 10:43:13 +02:00
|
|
|
pushd "$DIR/Build/qemu"
|
2023-04-15 23:14:11 +02:00
|
|
|
"$DIR"/Tarballs/qemu-"${QEMU_VERSION}"/configure --prefix="$PREFIX" \
|
2023-08-10 19:56:49 +02:00
|
|
|
--target-list=aarch64-softmmu,x86_64-softmmu,riscv64-softmmu \
|
2023-04-15 23:14:11 +02:00
|
|
|
--enable-$UI_LIB \
|
2023-04-28 16:14:06 +02:00
|
|
|
--enable-slirp \
|
|
|
|
$EXTRA_ARGS || exit 1
|
2021-07-03 10:43:13 +02:00
|
|
|
make -j "$MAKEJOBS" || exit 1
|
|
|
|
make install || exit 1
|
2019-11-11 13:58:18 +01:00
|
|
|
popd
|