Add vhost and memif MRR suite
[csit.git] / resources / libraries / bash / qemu_build.sh
index ad6d27b..57520a9 100755 (executable)
@@ -18,6 +18,7 @@ QEMU_DOWNLOAD_PACKAGE="${QEMU_VERSION}.tar.xz"
 QEMU_PACKAGE_URL="${QEMU_DOWNLOAD_REPO}${QEMU_DOWNLOAD_PACKAGE}"
 QEMU_INSTALL_DIR="/opt/${QEMU_VERSION}"
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+TARGET_LIST="x86_64-softmmu"
 
 for i in "$@"; do
     case $i in
@@ -33,6 +34,9 @@ for i in "$@"; do
         --force)
             FORCE=1
             shift ;;
+        --target-list)
+            TARGET_LIST="${i#*=}"
+            shift ;;
         *)
             ;;
     esac
@@ -56,12 +60,14 @@ else
         { echo "Qemu already installed: ${QEMU_INSTALL_DIR}"; exit 0; }
 fi
 
-# Download QEMU source code
-wget -P ${WORKING_DIR} -q ${QEMU_PACKAGE_URL} || \
-    { echo "Failed to download ${QEMU_VERSION}"; exit 1; }
+# Download QEMU source code if no local copy exists
+if [ ! -f /opt/${QEMU_DOWNLOAD_PACKAGE} ]; then
+    wget -P /opt -q ${QEMU_PACKAGE_URL} || \
+        { echo "Failed to download ${QEMU_VERSION}"; exit 1; }
+fi
 
 # Extract archive into temp directory
-tar --strip-components 1 -xf ${WORKING_DIR}/${QEMU_DOWNLOAD_PACKAGE} -C ${WORKING_DIR} || \
+tar --strip-components 1 -xf /opt/${QEMU_DOWNLOAD_PACKAGE} -C ${WORKING_DIR} || \
     { echo "Failed to extract ${QEMU_VERSION}.tar.xz"; exit 1; }
 
 cd ${WORKING_DIR}
@@ -76,7 +82,7 @@ then
 fi
 
 # Build
-./configure --target-list=x86_64-softmmu --prefix=${QEMU_INSTALL_DIR} || \
+./configure --target-list=${TARGET_LIST} --prefix=${QEMU_INSTALL_DIR} || \
     { echo "Failed to configure ${QEMU_VERSION}"; exit 1; }
 make -j`nproc` || \
     { echo "Failed to compile ${QEMU_VERSION}"; exit 1; }