#!/bin/sh # File names look like this: # # qemu-2.11.0.tar.xz DESTINATION_DIRECTORY="/Users/Shared" COMPONENT_LIST="qemu:QEMU" COMPONENT_LIST="$COMPONENT_LIST libffi:LIBFFI" COMPONENT_LIST="$COMPONENT_LIST gettext:GETTEXT" COMPONENT_LIST="$COMPONENT_LIST glib:GLIB" COMPONENT_LIST="$COMPONENT_LIST pixman:PIXMAN" COMPONENT_LIST="$COMPONENT_LIST pkg-config:PKGCONFIG" #export CC="/Users/Shared/gcc/bin/gcc" #export CPP="/Users/Shared/gcc/bin/cpp" #export CXX="/Users/Shared/gcc/bin/g++" #export PATH="/Users/Shared/gcc/bin:$PATH" # --------------------------------------------- # Make the script directory our build directory # --------------------------------------------- cd "`dirname "$0"`" || exit 1 # ------------------------------------------- # Create a temporary directory for work files # ------------------------------------------- TEMPDIR="`mktemp -d`" || exit 1 trap "rm -fr $TEMPDIR" exit # $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ # Loop through each of the component source tar files, # extract the actual version and compression type from # the file in the present directory, and store the # details in environment variables # $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ for c in $COMPONENT_LIST; do # -------------------------------------- # Isolate the package base name and the # prefix which we'll use for environment # variables # -------------------------------------- echo "1: $c" PKGNAME=`echo "$c" | cut -f1 -d:` PKGPREFIX=`echo "$c" | cut -f2 -d:` echo "2: $PKGNAME -> $PKGPREFIX" # ------------------------------------------ # Find the file for this package and extract # the wanted details from the file name # ------------------------------------------ ls -1 $PKGNAME-[0-9]*.tar.*z > $TEMPDIR/pkglist || exit 1 pkgcount=`wc -l $TEMPDIR/pkglist` || exit 1 pkgcount=`echo $pkgcount | sed -e 's/^ *//' -e 's/ .*$//'` if [ $pkgcount -ne 1 ]; then echo "Need ONE (only) $PKGNAME source tar file" >&2 exit 1 fi pkgfile=`head -n1 $TEMPDIR/pkglist` compression=`echo $pkgfile | sed -e 's/^.*\.//'` version=`echo $pkgfile | sed -e "s/^$PKGNAME-//" -e 's/.tar.*$//'` echo "3: /$compression/ <$version>" if [ "a$compression" = "a" -o "a$version" = "a" ]; then echo "Problem parsing file name: $pkgfile" >&2 exit 1 fi # ------------------------------------ # Store the details in the environment # ------------------------------------ declare -x ${PKGPREFIX}_COMPRESSION="$compression" declare -x ${PKGPREFIX}_FILE="$pkgfile" declare -x ${PKGPREFIX}_VERSION="$version" done # -------------------------------------------- # Determine where everything will be installed # -------------------------------------------- installdir="$DESTINATION_DIRECTORY/qemu-$QEMU_VERSION" # ========================= # Build and assemble it all # ========================= rm -fr libffi-$LIBFFI_VERSION tar --$LIBFFI_COMPRESSION -xf $LIBFFI_FILE || exit 1 pushd libffi-$LIBFFI_VERSION || exit 1 ./configure --prefix="$installdir" || exit 1 make || exit 1 make install || exit 1 popd || exit 1 rm -fr gettext-$GETTEXT_VERSION tar --$GETTEXT_COMPRESSION -xf $GETTEXT_FILE || exit 1 pushd gettext-$GETTEXT_VERSION || exit 1 ./configure --prefix="$installdir" || exit 1 make || exit 1 make install || exit 1 popd || exit 1 rm -fr glib-$GLIB_VERSION tar --$GLIB_COMPRESSION -xf $GLIB_FILE || exit 1 pushd glib-$GLIB_VERSION || exit 1 LIBFFI_CFLAGS="-I$installdir/lib/libffi-$LIBFFI_VERSION/include" \ LIBFFI_LIBS="-L$installdir/lib" \ CFLAGS="-I$installdir/include" \ CPPFLAGS="-I$installdir/include" \ LIBS="-L$installdir/lib" \ PATH="$PATH:$installdir/bin" \ ./configure --prefix="$installdir" --with-pcre=internal || exit 1 make || exit 1 make install || exit 1 popd rm -fr pkg-config-$PKGCONFIG_VERSION tar --$PKGCONFIG_COMPRESSION -xf $PKGCONFIG_FILE || exit 1 pushd pkg-config-$PKGCONFIG_VERSION || exit 1 ./configure --prefix="$installdir" --with-internal-glib || exit 1 make || exit 1 make install || exit 1 popd || exit 1 rm -fr pixman-$PIXMAN_VERSION tar --$PIXMAN_COMPRESSION -xf $PIXMAN_FILE || exit 1 pushd pixman-$PIXMAN_VERSION || exit 1 # clang doesn't have the full set of GCC vector ops/functions so we need to break the vector-support test in "configure" CPPFLAGS="-Dvector_size=broken_vector" ./configure --prefix="$installdir" || exit 1 make || exit 1 make install || exit 1 popd || exit 1 rm -fr qemu-$QEMU_VERSION tar --$QEMU_COMPRESSION -xf $QEMU_FILE || exit 1 pushd qemu-$QEMU_VERSION || exit 1 PATH=$PATH:"$installdir/bin" \ ./configure \ --prefix="$installdir" \ --audio-drv-list="" \ --target-list="i386-softmmu,x86_64-softmmu,arm-softmmu,aarch64-softmmu" make || exit 1 make install || exit 1 make install-doc || exit 1 popd || exit 1