-
Notifications
You must be signed in to change notification settings - Fork 9
/
build-qemu.sh
executable file
·99 lines (84 loc) · 2.75 KB
/
build-qemu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly ROOT_DIR="$(dirname "${SCRIPT_DIR}")"
readonly HOST_ARCH="$(uname -m)"
readonly HOST_OS="$(uname | tr '[:upper:]' '[:lower:]')"
readonly HOST_TRIPLE="${HOST_ARCH}-${HOST_OS}"
if [[ "x${HOST_OS}" == "xlinux" ]]; then
readonly QEMU_HOST_FLAGS="${QEMU_FLAGS} --disable-gtk --enable-sdl=internal --enable-kvm"
elif [[ "x${HOST_OS}" == "xdarwin" ]]; then
readonly QEMU_HOST_FLAGS="${QEMU_FLAGS} --enable-cocoa"
else
echo "unsupported system: ${HOST_OS}" 1>&2
exit 1
fi
set -eo pipefail; [[ "${TRACE}" ]] && set -x
usage() {
printf >&2 '%s: [-c] [-o outdir] [-d destdir] [-j jobs] [-s srcdir]\n' "$0"
exit 1
}
build() {
local srcdir="$1" outdir="$2" destdir="$3" clean="$4" jobs="$5"
if [[ "${clean}" = "true" ]]; then
rm -rf -- "${outdir}/build-qemu-${HOST_TRIPLE}"
fi
rm -rf "${destdir}/qemu-${HOST_TRIPLE}"
mkdir -p -- "${outdir}/build-qemu-${HOST_TRIPLE}"
pushd "${outdir}/build-qemu-${HOST_TRIPLE}"
${srcdir}/configure \
${QEMU_HOST_FLAGS} \
--prefix= \
--target-list=aarch64-softmmu,x86_64-softmmu \
--without-system-pixman \
--without-system-fdt \
--disable-vte \
--disable-vnc \
--disable-docs \
--disable-curl \
--disable-debug-info \
--disable-qom-cast-debug \
--disable-guest-agent \
--disable-bluez \
--disable-brlapi \
--disable-gnutls \
--disable-gcrypt \
--disable-nettle \
--disable-virtfs \
--disable-vhost-net \
--disable-vhost-scsi \
--disable-vhost-vsock \
--disable-libusb \
--disable-smartcard \
--disable-tools \
--disable-tasn1
make -j "${jobs}"
make DESTDIR="${destdir}/qemu-${HOST_TRIPLE}" install
popd
}
declare CLEAN="${CLEAN:-false}"
declare SRCDIR="${SRCDIR:-}"
declare OUTDIR="${OUTDIR:-${ROOT_DIR}/out}"
declare DESTDIR="${DESTDIR:-${OUTDIR}}"
declare JOBS="${JOBS:-$(getconf _NPROCESSORS_ONLN)}"
while getopts "cd:j:o:s:" opt; do
case "${opt}" in
c) CLEAN="true" ;;
d) DESTDIR="$(cd "${OPTARG}"; pwd -P)" ;;
j) JOBS="${OPTARG}" ;;
o) OUTDIR="$(cd "${OPTARG}"; pwd -P)" ;;
s) SRCDIR="$(cd "${OPTARG}"; pwd -P)" ;;
*) usage;;
esac
done
if [[ ! -d "${SRCDIR}" ]]; then
# Do all our work in a temporary directory, then rm it when we're done.
readonly TEMPDIR="$(mktemp -d ${ROOT_DIR}/qemu.XXXXXXXXXX)"
trap "rm -rf -- ${TEMPDIR}" EXIT
git clone --recursive "https://fuchsia.googlesource.com/third_party/qemu" "${TEMPDIR}"
SRCDIR="${TEMPDIR}"
fi
readonly CLEAN SRCDIR OUTDIR DESTDIR JOBS
build "${SRCDIR}" "${OUTDIR}" "${DESTDIR}" "${CLEAN}" "${JOBS}"