xref: /openbmc/qemu/configure (revision 508634723981e5cf269efb1c353afd1ec8b7a45a)
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"
211e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
2243ce4dfeSbellardstatic="no"
237d13299dSbellardcross_prefix=""
247d13299dSbellardcc="gcc"
257d13299dSbellardhost_cc="gcc"
267d13299dSbellardar="ar"
277d13299dSbellardmake="make"
287d13299dSbellardstrip="strip"
297d13299dSbellardcpu=`uname -m`
30997344f3Sbellardtarget_list="i386-user i386 i386-softmmu arm-user sparc-user"
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  ;;
5938e584a0Sbellard  m68k)
6038e584a0Sbellard    cpu="m68k"
6138e584a0Sbellard  ;;
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
16938e584a0Sbellardif 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]"
1961e43adfcSbellardecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
1971e43adfcSbellardecho "                           use %M for cpu name [$interp_prefix]"
19897a847bcSbellardecho "  --target-list=LIST       set target list [$target_list]"
1997d13299dSbellardecho ""
2007d13299dSbellardecho "Advanced options (experts only):"
2017d13299dSbellardecho "  --source-path=PATH       path of source code [$source_path]"
2027d13299dSbellardecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
2037d13299dSbellardecho "  --cc=CC                  use C compiler CC [$cc]"
2047d13299dSbellardecho "  --make=MAKE              use specified make [$make]"
20543ce4dfeSbellardecho "  --static                 enable static build [$static]"
2067d13299dSbellardecho ""
2077d13299dSbellardecho "NOTE: The object files are build at the place where configure is launched"
2087d13299dSbellardexit 1
2097d13299dSbellardfi
2107d13299dSbellard
2115a67135aSbellardmandir="$prefix/share/man"
2125a67135aSbellardsharedir="$prefix/share/qemu"
2135a67135aSbellard
2147d13299dSbellardecho "Install prefix    $prefix"
2155a67135aSbellardecho "Manual directory  $mandir"
2165a67135aSbellardecho "BIOS directory    $sharedir"
21743ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
2185a67135aSbellardecho "Source path       $source_path"
2197d13299dSbellardecho "C compiler        $cc"
2207d13299dSbellardecho "make              $make"
221a98fd896Sbellardecho "host CPU          $cpu"
222de83cd02Sbellardecho "host big endian   $bigendian"
22397a847bcSbellardecho "target list       $target_list"
2247d13299dSbellardecho "gprof enabled     $gprof"
22543ce4dfeSbellardecho "static build      $static"
22697a847bcSbellardecho "SDL support       $sdl"
22797a847bcSbellardif test $sdl_too_old = "yes"; then
22897a847bcSbellardecho "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
229e8cd23deSbellardfi
23097a847bcSbellard
23197a847bcSbellardconfig_mak="config-host.mak"
23297a847bcSbellardconfig_h="config-host.h"
23397a847bcSbellard
23497a847bcSbellardecho "Creating $config_mak and $config_h"
23597a847bcSbellard
23697a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
23797a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
23897a847bcSbellard
23997a847bcSbellardecho "prefix=$prefix" >> $config_mak
2405a67135aSbellardecho "mandir=$mandir" >> $config_mak
2415a67135aSbellardecho "sharedir=$sharedir" >> $config_mak
2425a67135aSbellardecho "#define CONFIG_QEMU_SHAREDIR \"$sharedir\"" >> $config_h
24397a847bcSbellardecho "MAKE=$make" >> $config_mak
24497a847bcSbellardecho "CC=$cc" >> $config_mak
24597a847bcSbellardif test "$have_gcc3_options" = "yes" ; then
24697a847bcSbellard  echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak
24797a847bcSbellardfi
24897a847bcSbellardecho "HOST_CC=$host_cc" >> $config_mak
24997a847bcSbellardecho "AR=$ar" >> $config_mak
25097a847bcSbellardecho "STRIP=$strip -s -R .comment -R .note" >> $config_mak
25197a847bcSbellardecho "CFLAGS=$CFLAGS" >> $config_mak
25297a847bcSbellardecho "LDFLAGS=$LDFLAGS" >> $config_mak
25397a847bcSbellardif test "$cpu" = "i386" ; then
25497a847bcSbellard  echo "ARCH=i386" >> $config_mak
25597a847bcSbellard  echo "#define HOST_I386 1" >> $config_h
2567d13299dSbellardelif test "$cpu" = "armv4l" ; then
25797a847bcSbellard  echo "ARCH=arm" >> $config_mak
25897a847bcSbellard  echo "#define HOST_ARM 1" >> $config_h
2597d13299dSbellardelif test "$cpu" = "powerpc" ; then
26097a847bcSbellard  echo "ARCH=ppc" >> $config_mak
26197a847bcSbellard  echo "#define HOST_PPC 1" >> $config_h
2627d13299dSbellardelif test "$cpu" = "mips" ; then
26397a847bcSbellard  echo "ARCH=mips" >> $config_mak
26497a847bcSbellard  echo "#define HOST_MIPS 1" >> $config_h
265fb3e5849Sbellardelif test "$cpu" = "s390" ; then
26697a847bcSbellard  echo "ARCH=s390" >> $config_mak
26797a847bcSbellard  echo "#define HOST_S390 1" >> $config_h
268295defa5Sbellardelif test "$cpu" = "alpha" ; then
26997a847bcSbellard  echo "ARCH=alpha" >> $config_mak
27097a847bcSbellard  echo "#define HOST_ALPHA 1" >> $config_h
271ae228531Sbellardelif test "$cpu" = "sparc" ; then
27297a847bcSbellard  echo "ARCH=sparc" >> $config_mak
27397a847bcSbellard  echo "#define HOST_SPARC 1" >> $config_h
274ae228531Sbellardelif test "$cpu" = "sparc64" ; then
27597a847bcSbellard  echo "ARCH=sparc64" >> $config_mak
27697a847bcSbellard  echo "#define HOST_SPARC64 1" >> $config_h
277a8baa8c5Sbellardelif test "$cpu" = "ia64" ; then
27897a847bcSbellard  echo "ARCH=ia64" >> $config_mak
27997a847bcSbellard  echo "#define HOST_IA64 1" >> $config_h
28038e584a0Sbellardelif test "$cpu" = "m68k" ; then
28138e584a0Sbellard  echo "ARCH=m68k" >> config.mak
28238e584a0Sbellard  echo "#define HOST_M68K 1" >> $TMPH
2837d13299dSbellardelse
2847d13299dSbellard  echo "Unsupported CPU"
2857d13299dSbellard  exit 1
2867d13299dSbellardfi
2877d13299dSbellardif test "$bigendian" = "yes" ; then
28897a847bcSbellard  echo "WORDS_BIGENDIAN=yes" >> $config_mak
28997a847bcSbellard  echo "#define WORDS_BIGENDIAN 1" >> $config_h
29097a847bcSbellardfi
29197a847bcSbellardecho "#define HAVE_BYTESWAP_H 1" >> $config_h
29297a847bcSbellardif test "$gprof" = "yes" ; then
29397a847bcSbellard  echo "TARGET_GPROF=yes" >> $config_mak
29497a847bcSbellard  echo "#define HAVE_GPROF 1" >> $config_h
29597a847bcSbellardfi
29697a847bcSbellardif test "$static" = "yes" ; then
29797a847bcSbellard  echo "CONFIG_STATIC=yes" >> $config_mak
298*50863472Sbellard  echo "#define CONFIG_STATIC 1" >> $config_h
29997a847bcSbellardfi
30097a847bcSbellardif test "$sdl" = "yes" ; then
30197a847bcSbellard  echo "CONFIG_SDL=yes" >> $config_mak
30297a847bcSbellard  echo "#define CONFIG_SDL 1" >> $config_h
30397a847bcSbellard  echo "SDL_LIBS=`sdl-config --libs`" >> $config_mak
30497a847bcSbellard  echo "SDL_CFLAGS=`sdl-config --cflags`" >> $config_mak
30597a847bcSbellardfi
30697a847bcSbellardecho -n "VERSION=" >>$config_mak
30797a847bcSbellardhead $source_path/VERSION >>$config_mak
30897a847bcSbellardecho "" >>$config_mak
30997a847bcSbellardecho -n "#define QEMU_VERSION \"" >> $config_h
31097a847bcSbellardhead $source_path/VERSION >> $config_h
31197a847bcSbellardecho "\"" >> $config_h
31297a847bcSbellard
31397a847bcSbellardecho "SRC_PATH=$source_path" >> $config_mak
31497a847bcSbellardecho "TARGET_DIRS=$target_list" >> $config_mak
31597a847bcSbellard
31697a847bcSbellardfor target in $target_list; do
31797a847bcSbellard
31897a847bcSbellardtarget_dir="$target"
31997a847bcSbellardconfig_mak=$target_dir/config.mak
32097a847bcSbellardconfig_h=$target_dir/config.h
32197a847bcSbellardtarget_cpu=`echo $target | cut -d '-' -f 1`
32297a847bcSbellardtarget_bigendian="no"
3231e43adfcSbellard[ "$target_cpu" = "sparc" ] && target_bigendian=yes
32497a847bcSbellardtarget_softmmu="no"
32597a847bcSbellardif expr $target : '.*-softmmu' > /dev/null ; then
32697a847bcSbellard  target_softmmu="yes"
3277d13299dSbellardfi
328997344f3Sbellardtarget_user_only="no"
329997344f3Sbellardif expr $target : '.*-user' > /dev/null ; then
330997344f3Sbellard  target_user_only="yes"
331997344f3Sbellardfi
332de83cd02Sbellard
33397a847bcSbellardecho "Creating $config_mak, $config_h and $target_dir/Makefile"
33497a847bcSbellard
33597a847bcSbellardmkdir -p $target_dir
33697a847bcSbellardln -sf $source_path/Makefile.target $target_dir/Makefile
33797a847bcSbellard
33897a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
33997a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
34097a847bcSbellard
34197a847bcSbellard
34297a847bcSbellardecho "include ../config-host.mak" >> $config_mak
34397a847bcSbellardecho "#include \"../config-host.h\"" >> $config_h
3441e43adfcSbellard
3451e43adfcSbellardinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
3461e43adfcSbellardecho "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
34797a847bcSbellard
34897a847bcSbellardif test "$target_cpu" = "i386" ; then
34997a847bcSbellard  echo "TARGET_ARCH=i386" >> $config_mak
35097a847bcSbellard  echo "#define TARGET_ARCH \"i386\"" >> $config_h
35197a847bcSbellard  echo "#define TARGET_I386 1" >> $config_h
352de83cd02Sbellardelif test "$target_cpu" = "arm" ; then
35397a847bcSbellard  echo "TARGET_ARCH=arm" >> $config_mak
35497a847bcSbellard  echo "#define TARGET_ARCH \"arm\"" >> $config_h
35597a847bcSbellard  echo "#define TARGET_ARM 1" >> $config_h
3561e43adfcSbellardelif test "$target_cpu" = "sparc" ; then
3571e43adfcSbellard  echo "TARGET_ARCH=sparc" >> $config_mak
3581e43adfcSbellard  echo "#define TARGET_ARCH \"sparc\"" >> $config_h
3591e43adfcSbellard  echo "#define TARGET_SPARC 1" >> $config_h
360de83cd02Sbellardelse
361de83cd02Sbellard  echo "Unsupported target CPU"
362de83cd02Sbellard  exit 1
363de83cd02Sbellardfi
364de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
36597a847bcSbellard  echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
36697a847bcSbellard  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
36797a847bcSbellardfi
36897a847bcSbellardif test "$target_softmmu" = "yes" ; then
36997a847bcSbellard  echo "CONFIG_SOFTMMU=yes" >> $config_mak
37097a847bcSbellard  echo "#define CONFIG_SOFTMMU 1" >> $config_h
371de83cd02Sbellardfi
372997344f3Sbellardif test "$target_user_only" = "yes" ; then
373997344f3Sbellard  echo "CONFIG_USER_ONLY=yes" >> $config_mak
374997344f3Sbellard  echo "#define CONFIG_USER_ONLY 1" >> $config_h
375997344f3Sbellardfi
376de83cd02Sbellard
37797a847bcSbellarddone # for target in $targets
3787d13299dSbellard
3797d13299dSbellard# build tree in object directory if source path is different from current one
3807d13299dSbellardif test "$source_path_used" = "yes" ; then
3817d13299dSbellard    DIRS="tests"
3827d13299dSbellard    FILES="Makefile tests/Makefile"
3837d13299dSbellard    for dir in $DIRS ; do
3847d13299dSbellard            mkdir -p $dir
3857d13299dSbellard    done
3867d13299dSbellard    for f in $FILES ; do
3877d13299dSbellard        ln -sf $source_path/$f $f
3887d13299dSbellard    done
3897d13299dSbellardfi
3907d13299dSbellard
39197a847bcSbellardrm -f $TMPO $TMPC $TMPE $TMPS
392