17d13299dSbellard#!/bin/sh 27d13299dSbellard# 33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard 47d13299dSbellard# 57d13299dSbellard# set temporary file name 67d13299dSbellardif test ! -z "$TMPDIR" ; then 77d13299dSbellard TMPDIR1="${TMPDIR}" 87d13299dSbellardelif test ! -z "$TEMPDIR" ; then 97d13299dSbellard TMPDIR1="${TEMPDIR}" 107d13299dSbellardelse 117d13299dSbellard TMPDIR1="/tmp" 127d13299dSbellardfi 137d13299dSbellard 143ef693a0SbellardTMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c" 153ef693a0SbellardTMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o" 163ef693a0SbellardTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}" 173ef693a0SbellardTMPS="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.S" 187d13299dSbellard 197d13299dSbellard# default parameters 207d13299dSbellardprefix="/usr/local" 2132ce6337Sbellardinterp_prefix="/usr/gnemul/qemu-i386" 2243ce4dfeSbellardstatic="no" 237d13299dSbellardcross_prefix="" 247d13299dSbellardcc="gcc" 257d13299dSbellardhost_cc="gcc" 267d13299dSbellardar="ar" 277d13299dSbellardmake="make" 287d13299dSbellardstrip="strip" 297d13299dSbellardcpu=`uname -m` 3097a847bcSbellardtarget_list="i386 i386-softmmu arm" 317d13299dSbellardcase "$cpu" in 327d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 3397a847bcSbellard cpu="i386" 347d13299dSbellard ;; 357d13299dSbellard armv4l) 367d13299dSbellard cpu="armv4l" 377d13299dSbellard ;; 387d13299dSbellard alpha) 397d13299dSbellard cpu="alpha" 407d13299dSbellard ;; 41295defa5Sbellard "Power Macintosh"|ppc|ppc64) 427d13299dSbellard cpu="powerpc" 437d13299dSbellard ;; 447d13299dSbellard mips) 457d13299dSbellard cpu="mips" 467d13299dSbellard ;; 47fb3e5849Sbellard s390) 48fb3e5849Sbellard cpu="s390" 49fb3e5849Sbellard ;; 50ae228531Sbellard sparc) 51ae228531Sbellard cpu="sparc" 52ae228531Sbellard ;; 53ae228531Sbellard sparc64) 54ae228531Sbellard cpu="sparc64" 55ae228531Sbellard ;; 56a8baa8c5Sbellard ia64) 57a8baa8c5Sbellard cpu="ia64" 58a8baa8c5Sbellard ;; 59*38e584a0Sbellard m68k) 60*38e584a0Sbellard cpu="m68k" 61*38e584a0Sbellard ;; 627d13299dSbellard *) 637d13299dSbellard cpu="unknown" 647d13299dSbellard ;; 657d13299dSbellardesac 667d13299dSbellardgprof="no" 677d13299dSbellardbigendian="no" 687d13299dSbellard 697d13299dSbellard# OS specific 707d13299dSbellardtargetos=`uname -s` 717d13299dSbellardcase $targetos in 727d13299dSbellard*) ;; 737d13299dSbellardesac 747d13299dSbellard 7597a847bcSbellard########################################## 7697a847bcSbellard# SDL probe 7797a847bcSbellard 7897a847bcSbellardcat > $TMPC << EOF 7997a847bcSbellard#include <SDL.h> 8097a847bcSbellard#undef main /* We don't want SDL to override our main() */ 8197a847bcSbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); } 8297a847bcSbellardEOF 8397a847bcSbellard 8497a847bcSbellardsdl_too_old=no 8597a847bcSbellardsdl=no 8697a847bcSbellardif $cc -o $TMPE `sdl-config --cflags` $TMPC `sdl-config --libs` 2> /dev/null ; then 8797a847bcSbellard_sdlversion=`sdl-config --version | sed 's/[^0-9]//g'` 8897a847bcSbellardif test "$_sdlversion" -lt 121 ; then 8997a847bcSbellardsdl_too_old=yes 9097a847bcSbellardelse 9197a847bcSbellardsdl=yes 9297a847bcSbellardfi 9397a847bcSbellardfi 9497a847bcSbellard 957d13299dSbellard# find source path 967d13299dSbellard# XXX: we assume an absolute path is given when launching configure, 977d13299dSbellard# except in './configure' case. 987d13299dSbellardsource_path=${0%configure} 997d13299dSbellardsource_path=${source_path%/} 1007d13299dSbellardsource_path_used="yes" 1017d13299dSbellardif test -z "$source_path" -o "$source_path" = "." ; then 1027d13299dSbellard source_path=`pwd` 1037d13299dSbellard source_path_used="no" 1047d13299dSbellardfi 1057d13299dSbellard 1067d13299dSbellardfor opt do 1077d13299dSbellard case "$opt" in 1087d13299dSbellard --prefix=*) prefix=`echo $opt | cut -d '=' -f 2` 1097d13299dSbellard ;; 11032ce6337Sbellard --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2` 11132ce6337Sbellard ;; 1127d13299dSbellard --source-path=*) source_path=`echo $opt | cut -d '=' -f 2` 1137d13299dSbellard ;; 1147d13299dSbellard --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2` 1157d13299dSbellard ;; 1167d13299dSbellard --cc=*) cc=`echo $opt | cut -d '=' -f 2` 1177d13299dSbellard ;; 1187d13299dSbellard --make=*) make=`echo $opt | cut -d '=' -f 2` 1197d13299dSbellard ;; 1207d13299dSbellard --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}" 1217d13299dSbellard ;; 1227d13299dSbellard --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}" 1237d13299dSbellard ;; 1247d13299dSbellard --extra-libs=*) extralibs=${opt#--extra-libs=} 1257d13299dSbellard ;; 1267d13299dSbellard --cpu=*) cpu=`echo $opt | cut -d '=' -f 2` 1277d13299dSbellard ;; 12897a847bcSbellard --target-list=*) target_list=${opt#--target-list=} 129de83cd02Sbellard ;; 1307d13299dSbellard --enable-gprof) gprof="yes" 1317d13299dSbellard ;; 13243ce4dfeSbellard --static) static="yes" 13343ce4dfeSbellard ;; 13497a847bcSbellard --disable-sdl) sdl="no" 13597a847bcSbellard ;; 1367d13299dSbellard esac 1377d13299dSbellarddone 1387d13299dSbellard 1397d13299dSbellard# Checking for CFLAGS 1407d13299dSbellardif test -z "$CFLAGS"; then 1417d13299dSbellard CFLAGS="-O2" 1427d13299dSbellardfi 1437d13299dSbellard 1447d13299dSbellardcc="${cross_prefix}${cc}" 1457d13299dSbellardar="${cross_prefix}${ar}" 1467d13299dSbellardstrip="${cross_prefix}${strip}" 1477d13299dSbellard 1487d13299dSbellardif test -z "$cross_prefix" ; then 1497d13299dSbellard 1507d13299dSbellard# --- 1517d13299dSbellard# big/little endian test 1527d13299dSbellardcat > $TMPC << EOF 1537d13299dSbellard#include <inttypes.h> 1547d13299dSbellardint main(int argc, char ** argv){ 1557d13299dSbellard volatile uint32_t i=0x01234567; 1567d13299dSbellard return (*((uint8_t*)(&i))) == 0x67; 1577d13299dSbellard} 1587d13299dSbellardEOF 1597d13299dSbellard 1607d13299dSbellardif $cc -o $TMPE $TMPC 2>/dev/null ; then 1617d13299dSbellard$TMPE && bigendian="yes" 1627d13299dSbellardelse 1637d13299dSbellardecho big/little test failed 1647d13299dSbellardfi 1657d13299dSbellard 1667d13299dSbellardelse 1677d13299dSbellard 1687d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess 169*38e584a0Sbellardif test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k"; then 1707d13299dSbellard bigendian="yes" 1717d13299dSbellardfi 1727d13299dSbellard 1737d13299dSbellardfi 1747d13299dSbellard 175e8cd23deSbellard# check gcc options support 17604369ff2Sbellardcat > $TMPC <<EOF 17704369ff2Sbellardint main(void) { 17804369ff2Sbellard} 17904369ff2SbellardEOF 18004369ff2Sbellard 181e8cd23deSbellardhave_gcc3_options="no" 182e8cd23deSbellardif $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then 183e8cd23deSbellard have_gcc3_options="yes" 18404369ff2Sbellardfi 185ca735206Sbellard 1867d13299dSbellardif test x"$1" = x"-h" -o x"$1" = x"--help" ; then 1877d13299dSbellardcat << EOF 1887d13299dSbellard 1897d13299dSbellardUsage: configure [options] 1907d13299dSbellardOptions: [defaults in brackets after descriptions] 1917d13299dSbellard 1927d13299dSbellardEOF 1937d13299dSbellardecho "Standard options:" 1947d13299dSbellardecho " --help print this message" 1957d13299dSbellardecho " --prefix=PREFIX install in PREFIX [$prefix]" 19632ce6337Sbellardecho " --interp-prefix=PREFIX where to find shared libraries, etc. [$interp_prefix]" 19797a847bcSbellardecho " --target-list=LIST set target list [$target_list]" 1987d13299dSbellardecho "" 1997d13299dSbellardecho "Advanced options (experts only):" 2007d13299dSbellardecho " --source-path=PATH path of source code [$source_path]" 2017d13299dSbellardecho " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]" 2027d13299dSbellardecho " --cc=CC use C compiler CC [$cc]" 2037d13299dSbellardecho " --make=MAKE use specified make [$make]" 20443ce4dfeSbellardecho " --static enable static build [$static]" 2057d13299dSbellardecho "" 2067d13299dSbellardecho "NOTE: The object files are build at the place where configure is launched" 2077d13299dSbellardexit 1 2087d13299dSbellardfi 2097d13299dSbellard 2107d13299dSbellardecho "Install prefix $prefix" 2117d13299dSbellardecho "Source path $source_path" 21243ce4dfeSbellardecho "ELF interp prefix $interp_prefix" 2137d13299dSbellardecho "C compiler $cc" 2147d13299dSbellardecho "make $make" 215a98fd896Sbellardecho "host CPU $cpu" 216de83cd02Sbellardecho "host big endian $bigendian" 21797a847bcSbellardecho "target list $target_list" 2187d13299dSbellardecho "gprof enabled $gprof" 21943ce4dfeSbellardecho "static build $static" 22097a847bcSbellardecho "SDL support $sdl" 22197a847bcSbellardif test $sdl_too_old = "yes"; then 22297a847bcSbellardecho "-> Your SDL version is too old - please upgrade to have FFplay/SDL support" 223e8cd23deSbellardfi 22497a847bcSbellard 22597a847bcSbellardconfig_mak="config-host.mak" 22697a847bcSbellardconfig_h="config-host.h" 22797a847bcSbellard 22897a847bcSbellardecho "Creating $config_mak and $config_h" 22997a847bcSbellard 23097a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak 23197a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h 23297a847bcSbellard 23397a847bcSbellardecho "prefix=$prefix" >> $config_mak 23497a847bcSbellardecho "MAKE=$make" >> $config_mak 23597a847bcSbellardecho "CC=$cc" >> $config_mak 23697a847bcSbellardif test "$have_gcc3_options" = "yes" ; then 23797a847bcSbellard echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak 23897a847bcSbellardfi 23997a847bcSbellardecho "HOST_CC=$host_cc" >> $config_mak 24097a847bcSbellardecho "AR=$ar" >> $config_mak 24197a847bcSbellardecho "STRIP=$strip -s -R .comment -R .note" >> $config_mak 24297a847bcSbellardecho "CFLAGS=$CFLAGS" >> $config_mak 24397a847bcSbellardecho "LDFLAGS=$LDFLAGS" >> $config_mak 24497a847bcSbellardif test "$cpu" = "i386" ; then 24597a847bcSbellard echo "ARCH=i386" >> $config_mak 24697a847bcSbellard echo "#define HOST_I386 1" >> $config_h 2477d13299dSbellardelif test "$cpu" = "armv4l" ; then 24897a847bcSbellard echo "ARCH=arm" >> $config_mak 24997a847bcSbellard echo "#define HOST_ARM 1" >> $config_h 2507d13299dSbellardelif test "$cpu" = "powerpc" ; then 25197a847bcSbellard echo "ARCH=ppc" >> $config_mak 25297a847bcSbellard echo "#define HOST_PPC 1" >> $config_h 2537d13299dSbellardelif test "$cpu" = "mips" ; then 25497a847bcSbellard echo "ARCH=mips" >> $config_mak 25597a847bcSbellard echo "#define HOST_MIPS 1" >> $config_h 256fb3e5849Sbellardelif test "$cpu" = "s390" ; then 25797a847bcSbellard echo "ARCH=s390" >> $config_mak 25897a847bcSbellard echo "#define HOST_S390 1" >> $config_h 259295defa5Sbellardelif test "$cpu" = "alpha" ; then 26097a847bcSbellard echo "ARCH=alpha" >> $config_mak 26197a847bcSbellard echo "#define HOST_ALPHA 1" >> $config_h 262ae228531Sbellardelif test "$cpu" = "sparc" ; then 26397a847bcSbellard echo "ARCH=sparc" >> $config_mak 26497a847bcSbellard echo "#define HOST_SPARC 1" >> $config_h 265ae228531Sbellardelif test "$cpu" = "sparc64" ; then 26697a847bcSbellard echo "ARCH=sparc64" >> $config_mak 26797a847bcSbellard echo "#define HOST_SPARC64 1" >> $config_h 268a8baa8c5Sbellardelif test "$cpu" = "ia64" ; then 26997a847bcSbellard echo "ARCH=ia64" >> $config_mak 27097a847bcSbellard echo "#define HOST_IA64 1" >> $config_h 271*38e584a0Sbellardelif test "$cpu" = "m68k" ; then 272*38e584a0Sbellard echo "ARCH=m68k" >> config.mak 273*38e584a0Sbellard echo "#define HOST_M68K 1" >> $TMPH 2747d13299dSbellardelse 2757d13299dSbellard echo "Unsupported CPU" 2767d13299dSbellard exit 1 2777d13299dSbellardfi 2787d13299dSbellardif test "$bigendian" = "yes" ; then 27997a847bcSbellard echo "WORDS_BIGENDIAN=yes" >> $config_mak 28097a847bcSbellard echo "#define WORDS_BIGENDIAN 1" >> $config_h 28197a847bcSbellardfi 28297a847bcSbellardecho "#define HAVE_BYTESWAP_H 1" >> $config_h 28397a847bcSbellardif test "$gprof" = "yes" ; then 28497a847bcSbellard echo "TARGET_GPROF=yes" >> $config_mak 28597a847bcSbellard echo "#define HAVE_GPROF 1" >> $config_h 28697a847bcSbellardfi 28797a847bcSbellardif test "$static" = "yes" ; then 28897a847bcSbellard echo "CONFIG_STATIC=yes" >> $config_mak 28997a847bcSbellardfi 29097a847bcSbellardif test "$sdl" = "yes" ; then 29197a847bcSbellard echo "CONFIG_SDL=yes" >> $config_mak 29297a847bcSbellard echo "#define CONFIG_SDL 1" >> $config_h 29397a847bcSbellard echo "SDL_LIBS=`sdl-config --libs`" >> $config_mak 29497a847bcSbellard echo "SDL_CFLAGS=`sdl-config --cflags`" >> $config_mak 29597a847bcSbellardfi 29697a847bcSbellardecho -n "VERSION=" >>$config_mak 29797a847bcSbellardhead $source_path/VERSION >>$config_mak 29897a847bcSbellardecho "" >>$config_mak 29997a847bcSbellardecho -n "#define QEMU_VERSION \"" >> $config_h 30097a847bcSbellardhead $source_path/VERSION >> $config_h 30197a847bcSbellardecho "\"" >> $config_h 30297a847bcSbellard 30397a847bcSbellardecho "SRC_PATH=$source_path" >> $config_mak 30497a847bcSbellardecho "TARGET_DIRS=$target_list" >> $config_mak 30597a847bcSbellard 30697a847bcSbellardfor target in $target_list; do 30797a847bcSbellard 30897a847bcSbellardtarget_dir="$target" 30997a847bcSbellardconfig_mak=$target_dir/config.mak 31097a847bcSbellardconfig_h=$target_dir/config.h 31197a847bcSbellardtarget_cpu=`echo $target | cut -d '-' -f 1` 31297a847bcSbellardtarget_bigendian="no" 31397a847bcSbellardtarget_softmmu="no" 31497a847bcSbellardif expr $target : '.*-softmmu' > /dev/null ; then 31597a847bcSbellard target_softmmu="yes" 3167d13299dSbellardfi 317de83cd02Sbellard 31897a847bcSbellardecho "Creating $config_mak, $config_h and $target_dir/Makefile" 31997a847bcSbellard 32097a847bcSbellardmkdir -p $target_dir 32197a847bcSbellardln -sf $source_path/Makefile.target $target_dir/Makefile 32297a847bcSbellard 32397a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak 32497a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h 32597a847bcSbellard 32697a847bcSbellard 32797a847bcSbellardecho "include ../config-host.mak" >> $config_mak 32897a847bcSbellardecho "#include \"../config-host.h\"" >> $config_h 32997a847bcSbellardecho "#define CONFIG_QEMU_PREFIX \"$interp_prefix\"" >> $config_h 33097a847bcSbellard 33197a847bcSbellardif test "$target_cpu" = "i386" ; then 33297a847bcSbellard echo "TARGET_ARCH=i386" >> $config_mak 33397a847bcSbellard echo "#define TARGET_ARCH \"i386\"" >> $config_h 33497a847bcSbellard echo "#define TARGET_I386 1" >> $config_h 335de83cd02Sbellardelif test "$target_cpu" = "arm" ; then 33697a847bcSbellard echo "TARGET_ARCH=arm" >> $config_mak 33797a847bcSbellard echo "#define TARGET_ARCH \"arm\"" >> $config_h 33897a847bcSbellard echo "#define TARGET_ARM 1" >> $config_h 339de83cd02Sbellardelse 340de83cd02Sbellard echo "Unsupported target CPU" 341de83cd02Sbellard exit 1 342de83cd02Sbellardfi 343de83cd02Sbellardif test "$target_bigendian" = "yes" ; then 34497a847bcSbellard echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak 34597a847bcSbellard echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h 34697a847bcSbellardfi 34797a847bcSbellardif test "$target_softmmu" = "yes" ; then 34897a847bcSbellard echo "CONFIG_SOFTMMU=yes" >> $config_mak 34997a847bcSbellard echo "#define CONFIG_SOFTMMU 1" >> $config_h 350de83cd02Sbellardfi 351de83cd02Sbellard 35297a847bcSbellarddone # for target in $targets 3537d13299dSbellard 3547d13299dSbellard# build tree in object directory if source path is different from current one 3557d13299dSbellardif test "$source_path_used" = "yes" ; then 3567d13299dSbellard DIRS="tests" 3577d13299dSbellard FILES="Makefile tests/Makefile" 3587d13299dSbellard for dir in $DIRS ; do 3597d13299dSbellard mkdir -p $dir 3607d13299dSbellard done 3617d13299dSbellard for f in $FILES ; do 3627d13299dSbellard ln -sf $source_path/$f $f 3637d13299dSbellard done 3647d13299dSbellardfi 3657d13299dSbellard 36697a847bcSbellardrm -f $TMPO $TMPC $TMPE $TMPS 367