| #!/bin/sh |
| # |
| # Small script to rebuild the QEMU sources from scratch with the AOSP |
| # SDK toolchain. |
| |
| # Sanitize environment |
| set -e |
| export LANG=C |
| export LC_ALL=C |
| |
| panic () { |
| echo "ERROR: $@" >&2 |
| exit 1 |
| } |
| |
| NUM_JOBS=$(grep -c -e "processor" /proc/cpuinfo) |
| |
| if [ -z "$1" ]; then |
| panic "Please specify the path to the QEMU source directory!" |
| fi |
| |
| QEMU_SRC_DIR=$1 |
| if [ ! -f $QEMU_SRC_DIR/include/qemu-common.h ]; then |
| panic "Not a QEMU source directory: $QEMU_SRC_DIR" |
| fi |
| if [ ! -f $QEMU_SRC_DIR/configure ]; then |
| # This happens is you mistakenly point to the Android emulator |
| # source tree. |
| panic "Missing configure script at: $QEMU_SRC_DIR" |
| fi |
| |
| QEMU_SRC_DIR=$(cd "$QEMU_SRC_DIR" && pwd -P) |
| GIT_SHA1=$(cd $QEMU_SRC_DIR && git log --oneline --no-merges -n1) |
| |
| echo "Cloning source directory to temporary workspace." |
| TMPDIR=/tmp/$USER-qemu-android-build-$$ |
| mkdir $TMPDIR |
| ( |
| cd $TMPDIR |
| git clone $QEMU_SRC_DIR qemu-android |
| cd qemu-android |
| git submodule update --init dtc |
| ) |
| |
| BUILD_DIR=$TMPDIR/build |
| ( |
| mkdir -p $BUILD_DIR |
| cd $BUILD_DIR |
| |
| echo "Configuring QEMU build system." |
| $TMPDIR/qemu-android/configure \ |
| --target-list=aarch64-softmmu \ |
| --disable-gtk \ |
| --enable-sdl \ |
| --disable-guest-agent \ |
| --disable-werror \ |
| |
| echo "Building QEMU from sources." |
| make -j$NUM_JOBS |
| |
| echo "Cleaning up." |
| cd .. |
| ) |
| cp $BUILD_DIR/aarch64-softmmu/qemu-system-aarch64 . |
| strip qemu-system-aarch64 |
| |
| rm -rf $TMPDIR |
| |
| DATE=$(date +%Y-%m-%d) |
| |
| cat > README <<EOF |
| This directory contains Linux binaries from the following sources: |
| |
| Git URL : https://qemu-android.googlesource.com/qemu-android |
| Git SHA1: $GIT_SHA1 |
| Date : $DATE |
| Command : $(basename "$0") /path/to/qemu-android |
| |
| EOF |