#!/bin/sh # # qemu configure script (c) 2003 Fabrice Bellard # # set temporary file name if test ! -z "$TMPDIR" ; then TMPDIR1="${TMPDIR}" elif test ! -z "$TEMPDIR" ; then TMPDIR1="${TEMPDIR}" else TMPDIR1="/tmp" fi TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c" TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o" TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}" TMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S" # default parameters prefix="" static="no" libdir="lib" cross_prefix="" cc="gcc" host_cc="gcc" ar="ar" make="make" install="install" strip="strip" cpu=`uname -m` target_list="" case "$cpu" in i386|i486|i586|i686|i86pc|BePC) cpu="i386" ;; armv*b) cpu="armv4b" ;; armv*l) cpu="armv4l" ;; alpha) cpu="alpha" ;; "Power Macintosh"|ppc|ppc64) cpu="powerpc" ;; mips) cpu="mips" ;; s390) cpu="s390" ;; sparc|sun4[muv]) cpu="sparc" ;; sparc64) cpu="sparc64" ;; ia64) cpu="ia64" ;; m68k) cpu="m68k" ;; x86_64|amd64) cpu="x86_64" libdir="lib64" ;; *) cpu="unknown" ;; esac gprof="no" bigendian="no" mingw32="no" EXESUF="" gdbstub="no" slirp="no" adlib="no" oss="no" dsound="no" coreaudio="no" alsa="no" fmod="no" fmod_lib="" fmod_inc="" bsd="no" linux="no" kqemu="no" profiler="no" kernel_path="" cocoa="no" check_gfx="yes" check_gcc="no" softmmu="yes" user="no" build_docs="no" build_acpi_tables="no" uname_release="" # OS specific targetos=`uname -s` case $targetos in CYGWIN*) mingw32="yes" CFLAGS="-O2 -mno-cygwin" ;; MINGW32*) mingw32="yes" ;; FreeBSD) bsd="yes" oss="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then kqemu="yes" fi ;; NetBSD) bsd="yes" oss="yes" ;; OpenBSD) bsd="yes" oss="yes" ;; Darwin) bsd="yes" darwin="yes" ;; SunOS) solaris="yes" ;; *) oss="yes" linux="yes" user="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then kqemu="yes" fi ;; esac if [ "$bsd" = "yes" ] ; then if [ "$darwin" != "yes" ] ; then make="gmake" fi fi if [ "$solaris" = "yes" ] ; then make="gmake" install="ginstall" solarisrev=`uname -r | cut -f2 -d.` fi # find source path source_path=`dirname "$0"` if [ -z "$source_path" ]; then source_path=`pwd` else source_path=`cd "$source_path"; pwd` fi if test "$source_path" = `pwd` ; then source_path_used="no" else source_path_used="yes" fi for opt do optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'` case "$opt" in --help|-h) show_help=yes ;; --prefix=*) prefix="$optarg" ;; --interp-prefix=*) interp_prefix="$optarg" ;; --source-path=*) source_path="$optarg" source_path_used="yes" ;; --cross-prefix=*) cross_prefix="$optarg" ;; --cc=*) cc="$optarg" ;; --host-cc=*) host_cc="$optarg" ;; --make=*) make="$optarg" ;; --install=*) install="$optarg" ;; --extra-cflags=*) CFLAGS="$optarg" ;; --extra-ldflags=*) LDFLAGS="$optarg" ;; --cpu=*) cpu="$optarg" ;; --target-list=*) target_list="$optarg" ;; --enable-gprof) gprof="yes" ;; --static) static="yes" ;; --disable-sdl) sdl="no" ;; --enable-coreaudio) coreaudio="yes" ;; --enable-alsa) alsa="yes" ;; --enable-dsound) dsound="yes" ;; --enable-fmod) fmod="yes" ;; --fmod-lib=*) fmod_lib="$optarg" ;; --fmod-inc=*) fmod_inc="$optarg" ;; --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" ; user="no" ;; --disable-slirp) slirp="no" ;; --enable-adlib) adlib="yes" ;; --disable-kqemu) kqemu="no" ;; --enable-profiler) profiler="yes" ;; --kernel-path=*) kernel_path="$optarg" ;; --enable-cocoa) cocoa="yes" ; coreaudio="yes" ; sdl="no" ;; --disable-gcc-check) check_gcc="no" ;; --disable-system) softmmu="no" ;; --enable-system) softmmu="yes" ;; --disable-user) user="no" ;; --enable-user) user="yes" ;; --enable-uname-release=*) uname_release="$optarg" ;; --enable-iasl) build_acpi_tables="yes" ;; esac done # Checking for CFLAGS if test -z "$CFLAGS"; then CFLAGS="-O2" fi if test x"$show_help" = x"yes" ; then cat << EOF Usage: configure [options] Options: [defaults in brackets after descriptions] EOF echo "Standard options:" echo " --help print this message" echo " --prefix=PREFIX install in PREFIX [$prefix]" echo " --interp-prefix=PREFIX where to find shared libraries, etc." echo " use %M for cpu name [$interp_prefix]" echo " --target-list=LIST set target list [$target_list]" echo "" echo "kqemu kernel acceleration support:" echo " --disable-kqemu disable kqemu support" echo " --kernel-path=PATH set the kernel path (configure probes it)" echo "" echo "Advanced options (experts only):" echo " --source-path=PATH path of source code [$source_path]" echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" echo " --cc=CC use C compiler CC [$cc]" echo " --host-cc=CC use C compiler CC [$host_cc] for dyngen etc." echo " --make=MAKE use specified make [$make]" echo " --install=INSTALL use specified install [$install]" echo " --static enable static build [$static]" echo " --enable-cocoa enable COCO
#! /bin/sh
# A little script I whipped up to make it easy to
# patch source trees and have sane error handling
# -Erik
#
# (c) 2002 Erik Andersen <andersen@codepoet.org>

# Set directories from arguments, or use defaults.
targetdir=${1-.}
patchdir=${2-../kernel-patches}
patchpattern=${3-*}

if [ ! -d "${targetdir}" ] ; then
    echo "Aborting.  '${targetdir}' is not a directory."
    exit 1
fi
if [ ! -d "${patchdir}" ] ; then
    echo "Aborting.  '${patchdir}' is not a directory."
    exit 1
fi
    
for i in ${patchdir}/${patchpattern} ; do 
    case "$i" in
	*.gz)
	type="gzip"; uncomp="gunzip -dc"; ;; 
	*.bz)
	type="bzip"; uncomp="bunzip -dc"; ;; 
	*.bz2)
	type="bzip2"; uncomp="bunzip2 -dc"; ;; 
	*.zip)
	type="zip"; uncomp="unzip -d"; ;; 
	*.Z)
	type="compress"; uncomp="uncompress -c"; ;; 
	*)
	type="plaintext"; uncomp="cat"; ;; 
    esac
    [ -d "${i}" ] && echo "Ignoring subdirectory ${i}" && continue	
    echo ""
    echo "Applying ${i} using ${type}: " 
    ${uncomp} ${i} | ${PATCH:-patch} -f -p1 -E -d ${targetdir} 
    if [ $? != 0 ] ; then
        echo "Patch failed!  Please fix $i!"
	exit 1
    fi
done

# Check for rejects...
if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
    echo "Aborting.  Reject files found."
    exit 1
fi

# Remove backup files
find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
S=yes" >> $config_mak echo "#define CONFIG_OSS 1" >> $config_h fi if test "$coreaudio" = "yes" ; then echo "CONFIG_COREAUDIO=yes" >> $config_mak echo "#define CONFIG_COREAUDIO 1" >> $config_h fi if test "$alsa" = "yes" ; then echo "CONFIG_ALSA=yes" >> $config_mak echo "#define CONFIG_ALSA 1" >> $config_h fi if test "$dsound" = "yes" ; then echo "CONFIG_DSOUND=yes" >> $config_mak echo "#define CONFIG_DSOUND 1" >> $config_h fi if test "$fmod" = "yes" ; then echo "CONFIG_FMOD=yes" >> $config_mak echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak echo "#define CONFIG_FMOD 1" >> $config_h fi qemu_version=`head $source_path/VERSION` echo "VERSION=$qemu_version" >>$config_mak echo "#define QEMU_VERSION \"$qemu_version\"" >> $config_h echo "SRC_PATH=$source_path" >> $config_mak if [ "$source_path_used" = "yes" ]; then echo "VPATH=$source_path" >> $config_mak fi echo "TARGET_DIRS=$target_list" >> $config_mak if [ "$build_docs" = "yes" ] ; then echo "BUILD_DOCS=yes" >> $config_mak fi if [ "$build_acpi_tables" = "yes" ] ; then echo "BUILD_ACPI_TABLES=yes" >> $config_mak fi # XXX: suppress that if [ "$bsd" = "yes" ] ; then echo "#define O_LARGEFILE 0" >> $config_h echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h echo "#define _BSD 1" >> $config_h fi echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h for target in $target_list; do target_dir="$target" config_mak=$target_dir/config.mak config_h=$target_dir/config.h target_cpu=`echo $target | cut -d '-' -f 1` target_bigendian="no" [ "$target_cpu" = "armeb" ] && target_bigendian=yes [ "$target_cpu" = "sparc" ] && target_bigendian=yes [ "$target_cpu" = "sparc64" ] && target_bigendian=yes [ "$target_cpu" = "ppc" ] && target_bigendian=yes [ "$target_cpu" = "ppc64" ] && target_bigendian=yes [ "$target_cpu" = "mips" ] && target_bigendian=yes [ "$target_cpu" = "sh4eb" ] && target_bigendian=yes target_softmmu="no" if expr $target : '.*-softmmu' > /dev/null ; then target_softmmu="yes" fi #for support 256M guest target_softmmu="yes" target_user_only="no" if expr $target : '.*-user' > /dev/null ; then target_user_only="yes" fi #echo "Creating $config_mak, $config_h and $target_dir/Makefile" mkdir -p $target_dir mkdir -p $target_dir/fpu if test "$target" = "arm-user" -o "$target" = "armeb-user" ; then mkdir -p $target_dir/nwfpe fi if test "$target_user_only" = "no" ; then mkdir -p $target_dir/slirp fi # # don't use ln -sf as not all "ln -sf" over write the file/link # rm -f $target_dir/Makefile ln -s ../Makefile.target $target_dir/Makefile echo "# Automatically generated by configure - do not modify" > $config_mak echo "/* Automatically generated by configure - do not modify */" > $config_h echo "include ../config-host.mak" >> $config_mak echo "#include \"../config-host.h\"" >> $config_h bflt="no" interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"` echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h target_sub= if expr $target : '.*-dm' > /dev/null ; then target_sub=-dm fi echo "TARGET_SUB=${target_sub}" >> $config_mak if test "$target_cpu" = "i386" ; then echo "TARGET_ARCH=i386" >> $config_mak echo "#define TARGET_ARCH \"i386\"" >> $config_h echo "#define TARGET_I386 1" >> $config_h if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "i386" ; then echo "#define USE_KQEMU 1" >> $config_h fi elif test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then echo "TARGET_ARCH=arm" >> $config_mak echo "#define TARGET_ARCH \"arm\"" >> $config_h echo "#define TARGET_ARM 1" >> $config_h bflt="yes" elif test "$target_cpu" = "sparc" ; then echo "TARGET_ARCH=sparc" >> $config_mak echo "#define TARGET_ARCH \"sparc\"" >> $config_h echo "#define TARGET_SPARC 1" >> $config_h elif test "$target_cpu" = "sparc64" ; then echo "TARGET_ARCH=sparc64" >> $config_mak echo "#define TARGET_ARCH \"sparc64\"" >> $config_h echo "#define TARGET_SPARC 1" >> $config_h echo "#define TARGET_SPARC64 1" >> $config_h elif test "$target_cpu" = "ppc" ; then echo "TARGET_ARCH=ppc" >> $config_mak echo "#define TARGET_ARCH \"ppc\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h elif test "$target_cpu" = "ppc64" ; then echo "TARGET_ARCH=ppc64" >> $config_mak echo "#define TARGET_ARCH \"ppc64\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPC64 1" >> $config_h elif test "$target_cpu" = "x86_64" ; then echo "TARGET_ARCH=x86_64" >> $config_mak echo "#define TARGET_ARCH \"x86_64\"" >> $config_h echo "#define TARGET_I386 1" >> $config_h echo "#define TARGET_X86_64 1" >> $config_h if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64" ; then echo "#define USE_KQEMU 1" >> $config_h fi elif test "$target_cpu" = "mips" -o "$target_cpu" = "mipsel" ; then echo "TARGET_ARCH=mips" >> $config_mak echo "#define TARGET_ARCH \"mips\"" >> $config_h echo "#define TARGET_MIPS 1" >> $config_h echo "CONFIG_SOFTFLOAT=yes" >> $config_mak echo "#define CONFIG_SOFTFLOAT 1" >> $config_h elif test "$target_cpu" = "sh4" -o "$target_cpu" = "sh4eb" ; then echo "TARGET_ARCH=sh4" >> $config_mak echo "#define TARGET_ARCH \"sh4\"" >> $config_h echo "#define TARGET_SH4 1" >> $config_h bflt="yes" else echo "Unsupported target CPU" exit 1 fi if test "$target_bigendian" = "yes" ; then echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h fi if test "$target_softmmu" = "yes" ; then echo "CONFIG_SOFTMMU=yes" >> $config_mak echo "#define CONFIG_SOFTMMU 1" >> $config_h fi if test "$target_user_only" = "yes" ; then echo "CONFIG_USER_ONLY=yes" >> $config_mak echo "#define CONFIG_USER_ONLY 1" >> $config_h fi if expr $target : '.*-dm' > /dev/null ; then echo "#define CONFIG_DM 1" >> $config_h fi if test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" -o "$target_cpu" = "sparc" -o "$target_cpu" = "sparc64"; then echo "CONFIG_SOFTFLOAT=yes" >> $config_mak echo "#define CONFIG_SOFTFLOAT 1" >> $config_h fi if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then echo "TARGET_HAS_BFLT=yes" >> $config_mak echo "#define TARGET_HAS_BFLT 1" >> $config_h fi # sdl defines if test "$target_user_only" = "no"; then if test "$target_softmmu" = "no" -o "$static" = "yes"; then sdl1=$sdl_static else sdl1=$sdl fi if test "$sdl1" = "yes" ; then echo "#define CONFIG_SDL 1" >> $config_h echo "CONFIG_SDL=yes" >> $config_mak if test "$target_softmmu" = "no" -o "$static" = "yes"; then echo "SDL_LIBS=$sdl_static_libs" >> $config_mak else echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak fi if [ "${aa}" = "yes" ] ; then echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak else echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak fi fi fi if test "$cocoa" = "yes" ; then echo "#define CONFIG_COCOA 1" >> $config_h echo "CONFIG_COCOA=yes" >> $config_mak fi done # for target in $targets # build tree in object directory if source path is different from current one if test "$source_path_used" = "yes" ; then DIRS="tests" FILES="Makefile tests/Makefile" for dir in $DIRS ; do mkdir -p $dir done # remove the link and recreate it, as not all "ln -sf" overwrite the link for f in $FILES ; do rm -f $f ln -s $source_path/$f $f done fi rm -f $TMPO $TMPC $TMPE $TMPS