2021-01-22 16:44:05 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-11-11 12:58:18 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# This file will need to be run in bash, for now.
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2023-04-24 18:24:22 +00: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 12:58:18 +00:00
|
|
|
echo "$DIR"
|
|
|
|
|
2021-07-03 08:43:13 +00:00
|
|
|
PREFIX="$DIR/Local/qemu"
|
2020-12-29 03:38:52 +00:00
|
|
|
BUILD=$(realpath "$DIR/../Build")
|
|
|
|
SYSROOT="$BUILD/Root"
|
2019-11-11 12:58:18 +00:00
|
|
|
|
2023-04-15 21:14:11 +00:00
|
|
|
# shellcheck source=/dev/null
|
|
|
|
source "${DIR}/../Ports/qemu/version.sh"
|
2019-11-11 12:58:18 +00:00
|
|
|
|
|
|
|
echo PREFIX is "$PREFIX"
|
|
|
|
echo SYSROOT is "$SYSROOT"
|
|
|
|
|
|
|
|
mkdir -p "$DIR/Tarballs"
|
|
|
|
|
|
|
|
pushd "$DIR/Tarballs"
|
2023-04-15 21:14:11 +00:00
|
|
|
if [ ! -e "${QEMU_ARCHIVE}" ]; then
|
|
|
|
curl -C - -O "${QEMU_ARCHIVE_URL}"
|
2019-11-11 12:58:18 +00:00
|
|
|
else
|
2023-04-15 21:14:11 +00:00
|
|
|
echo "Skipped downloading ${QEMU_ARCHIVE}"
|
2019-11-11 12:58:18 +00:00
|
|
|
fi
|
|
|
|
|
2023-04-15 21:14:11 +00: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 18:59:45 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-04-28 14:57:36 +00:00
|
|
|
if [ -d "qemu-$QEMU_VERSION" ]; then
|
|
|
|
rm -rf "qemu-$QEMU_VERSION"
|
2019-11-11 12:58:18 +00:00
|
|
|
fi
|
2022-02-12 15:07:31 +00:00
|
|
|
|
2023-04-28 14:57:36 +00:00
|
|
|
echo "Extracting qemu..."
|
|
|
|
tar -xf "${QEMU_ARCHIVE}"
|
2019-11-11 12:58:18 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
mkdir -p "$PREFIX"
|
2021-07-03 08:43:13 +00:00
|
|
|
mkdir -p "$DIR/Build/qemu"
|
2019-11-11 12:58:18 +00:00
|
|
|
|
2023-05-02 19:05:04 +00:00
|
|
|
NPROC=$(get_number_of_processing_units)
|
|
|
|
[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
|
2019-11-11 12:58:18 +00:00
|
|
|
|
2023-04-28 14:14:06 +00:00
|
|
|
EXTRA_ARGS=""
|
2020-04-06 23:55:25 +00:00
|
|
|
if [[ $(uname) == "Darwin" ]]
|
|
|
|
then
|
|
|
|
UI_LIB=cocoa
|
2023-04-28 14:14:06 +00: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 23:55:25 +00:00
|
|
|
else
|
|
|
|
UI_LIB=gtk
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo Using $UI_LIB based UI
|
|
|
|
|
2021-07-03 08:43:13 +00:00
|
|
|
pushd "$DIR/Build/qemu"
|
2023-04-15 21:14:11 +00:00
|
|
|
"$DIR"/Tarballs/qemu-"${QEMU_VERSION}"/configure --prefix="$PREFIX" \
|
2023-08-10 17:56:49 +00:00
|
|
|
--target-list=aarch64-softmmu,x86_64-softmmu,riscv64-softmmu \
|
2023-04-15 21:14:11 +00:00
|
|
|
--enable-$UI_LIB \
|
2023-04-28 14:14:06 +00:00
|
|
|
--enable-slirp \
|
|
|
|
$EXTRA_ARGS || exit 1
|
2021-07-03 08:43:13 +00:00
|
|
|
make -j "$MAKEJOBS" || exit 1
|
|
|
|
make install || exit 1
|
2019-11-11 12:58:18 +00:00
|
|
|
popd
|