-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.md
More file actions
149 lines (129 loc) · 4.04 KB
/
README.md
File metadata and controls
149 lines (129 loc) · 4.04 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# Exit on any error
set -e
# Set base directory to the script's directory
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
QEMU_VERSION="10.0.0"
QEMU_SRC="qemu-$QEMU_VERSION"
BUILD_DIR="$BASE_DIR/build"
INSTALL_DIR="$BASE_DIR/qemu-static"
STATIC_DEPS="$BASE_DIR/static-install"
VENV_DIR="$BASE_DIR/.venv"
# Colors
GREEN="\033[1;32m"
RED="\033[1;31m"
RESET="\033[0m"
# Print step
step() {
echo -e "${GREEN}▶ $1${RESET}"
}
step "Creating directories..."
mkdir -p "$BUILD_DIR" "$STATIC_DEPS" "$INSTALL_DIR"
cd "$BASE_DIR"
step "Installing minimal system dependencies..."
sudo apt-get update
sudo apt-get install -y build-essential wget curl git pkg-config \
python3 python3-venv cmake autoconf automake libtool bison flex \
gettext libxml2-utils
step "Creating Python virtual environment for meson/ninja..."
python3 -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"
pip install --upgrade pip setuptools
pip install meson ninja
export PKG_CONFIG_PATH="$STATIC_DEPS/lib/pkgconfig:$STATIC_DEPS/lib/x86_64-linux-gnu/pkgconfig"
export CFLAGS="-I$STATIC_DEPS/include"
export LDFLAGS="-L$STATIC_DEPS/lib"
build_zlib() {
step "Building static zlib..."
cd "$BUILD_DIR"
wget -nc https://zlib.net/zlib-1.3.1.tar.gz
tar -xf zlib-1.3.1.tar.gz && cd zlib-1.3.1
./configure --static --prefix="$STATIC_DEPS"
make -j$(nproc) && make install
}
build_pixman() {
step "Building static pixman..."
cd "$BUILD_DIR"
wget -nc https://cairographics.org/releases/pixman-0.43.4.tar.gz
tar -xf pixman-0.43.4.tar.gz
cd pixman-0.43.4
meson setup build --prefix="$STATIC_DEPS" -Ddefault_library=static
ninja -C build && ninja -C build install
}
build_glib() {
step "Building static glib..."
cd "$BUILD_DIR"
wget -nc https://download.gnome.org/sources/glib/2.78/glib-2.78.4.tar.xz
tar -xf glib-2.78.4.tar.xz && cd glib-2.78.4
meson setup build --prefix="$STATIC_DEPS" -Ddefault_library=static -Dlibmount=disabled -Dselinux=disabled
ninja -C build && ninja -C build install
}
build_libfdt() {
step "Building static libfdt with Meson..."
cd "$BUILD_DIR"
rm -rf dtc
git clone https://github.com/dgibson/dtc.git
cd dtc
meson setup builddir --prefix="$STATIC_DEPS" -Ddefault_library=static
meson compile -C builddir
meson install -C builddir
}
build_slirp() {
step "Building static libslirp..."
cd "$BUILD_DIR"
rm -rf libslirp
git clone https://gitlab.freedesktop.org/slirp/libslirp.git
cd libslirp
meson setup build --prefix="$STATIC_DEPS" -Ddefault_library=static
ninja -C build && ninja -C build install
}
build_sdl2() {
step "Building static SDL2..."
cd "$BUILD_DIR"
wget -nc https://github.com/libsdl-org/SDL/releases/download/release-2.30.2/SDL2-2.30.2.tar.gz
tar -xf SDL2-2.30.2.tar.gz
cd SDL2-2.30.2
./configure --disable-shared --enable-static --prefix="$STATIC_DEPS"
make -j$(nproc)
make install
}
build_qemu() {
step "Downloading QEMU $QEMU_VERSION..."
cd "$BASE_DIR"
if [ ! -d "$QEMU_SRC" ]; then
wget https://download.qemu.org/$QEMU_SRC.tar.xz
tar -xf $QEMU_SRC.tar.xz
fi
step "Configuring QEMU..."
cd "$QEMU_SRC"
rm -rf build && mkdir build && cd build
if ! ../configure \
--prefix="$INSTALL_DIR" \
--target-list=x86_64-softmmu,aarch64-softmmu \
--static --enable-tools --disable-docs \
--enable-kvm --enable-slirp --enable-fdt \
--enable-sdl --disable-gtk --disable-opengl \
--disable-vnc \
--disable-spice --disable-virglrenderer --disable-curl \
--disable-gnutls --disable-nettle --disable-gcrypt \
--disable-auth-pam --disable-brlapi --disable-vhost-net \
--disable-xen --disable-libnfs --disable-libssh --disable-libiscsi \
--disable-glusterfs --disable-vte --disable-virtfs \
--disable-slirp-smbd --disable-capstone --disable-alsa \
--disable-pa --disable-sndio --disable-mpath \
--disable-libudev; then
echo "QEMU configure script missing or failed."
exit 1
fi
step "Building QEMU..."
make -j$(nproc)
make install
step "✅ QEMU $QEMU_VERSION built and installed in $INSTALL_DIR"
}
build_zlib
build_pixman
build_glib
build_libfdt
build_slirp
build_sdl2
build_qemu