summaryrefslogtreecommitdiff
path: root/Toolchain/BuildQemu.sh
blob: d43dea9ec7db806a2f5efe56e01db22cec040b4e (plain)
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
#!/bin/bash
set -e

# This file will need to be run in bash, for now.

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "$DIR"

TARGET=i686-pc-serenity
PREFIX="$DIR/Local"
SYSROOT="$DIR/../Root"

QEMU300_MD5SUM="6a5c8df583406ea24ef25b239c3243e0"
QEMU410_MD5SUM="cdf2b5ca52b9abac9bacb5842fa420f8"

QEMU_VERSION="qemu-4.1.0"
QEMU_MD5SUM="${QEMU410_MD5SUM}"

echo PREFIX is "$PREFIX"
echo SYSROOT is "$SYSROOT"

mkdir -p "$DIR/Tarballs"

source "$DIR/UseIt.sh"

pushd "$DIR/Tarballs"

    md5="$(md5sum $QEMU_VERSION.tar.xz | cut -f1 -d' ')"
    echo "qemu md5='$md5'"
    if [ ! -e "$QEMU_VERSION.tar.xz" ] || [ "$md5" != "$QEMU_MD5SUM" ] ; then
        rm -f qemu-3.0.0.tar.xz
        curl -O "https://download.qemu.org/$QEMU_VERSION.tar.xz"

        if  [ "$md5" != "$QEMU_MD5SUM" ] ; then
            echo "qemu md5 sum mismatching, please run script again."
            exit 1
        fi
    else
        echo "Skipped downloading $QEMU_VERSION"
    fi

    if [ ! -d "$QEMU_VERSION" ]; then
        echo "Extracting qemu..."
        tar -xf "$QEMU_VERSION.tar.xz"
    else
        echo "Skipped extracting qemu"
    fi
popd

mkdir -p "$PREFIX"
mkdir -p "$DIR/Build/qemu"

if [ -z "$MAKEJOBS" ]; then
    MAKEJOBS=$(nproc)
fi

pushd "$DIR/Build/"
    pushd qemu
        "$DIR"/Tarballs/$QEMU_VERSION/configure --prefix="$PREFIX" \
                                                --target-list=i386-softmmu \
                                                --enable-gtk || exit 1
        make -j "$MAKEJOBS" || exit 1
        make install || exit 1
    popd
popd