xref: /openbmc/qemu/configure (revision fb065187e4ee9e0d1709b344ec01bb426ff1e43b)
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
2011d9f695Sbellardprefix=""
211e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
2243ce4dfeSbellardstatic="no"
237d13299dSbellardcross_prefix=""
247d13299dSbellardcc="gcc"
257d13299dSbellardhost_cc="gcc"
267d13299dSbellardar="ar"
277d13299dSbellardmake="make"
287d13299dSbellardstrip="strip"
297d13299dSbellardcpu=`uname -m`
30e95c8d51Sbellardtarget_list="i386-user i386 i386-softmmu arm-user sparc-user ppc-user ppc-softmmu sparc-softmmu"
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  ;;
62bc51c5c9Sbellard  x86_64|amd64)
63bc51c5c9Sbellard    cpu="amd64"
64bc51c5c9Sbellard  ;;
657d13299dSbellard  *)
667d13299dSbellard    cpu="unknown"
677d13299dSbellard  ;;
687d13299dSbellardesac
697d13299dSbellardgprof="no"
707d13299dSbellardbigendian="no"
7167b915a5Sbellardmingw32="no"
7267b915a5SbellardEXESUF=""
7367b915a5Sbellardgdbstub="yes"
74443f1376Sbellardslirp="yes"
75*fb065187Sbellardadlib="no"
76*fb065187Sbellardoss="no"
777d13299dSbellard
787d13299dSbellard# OS specific
797d13299dSbellardtargetos=`uname -s`
807d13299dSbellardcase $targetos in
8167b915a5SbellardMINGW32*)
8267b915a5Sbellardmingw32="yes"
8367b915a5Sbellard;;
847d3505c5SbellardFreeBSD)
857d3505c5Sbellardbsd="yes"
86*fb065187Sbellardoss="yes"
877d3505c5Sbellard;;
887d3505c5SbellardNetBSD)
897d3505c5Sbellardbsd="yes"
90*fb065187Sbellardoss="yes"
917d3505c5Sbellard;;
927d3505c5SbellardOpenBSD)
937d3505c5Sbellardbsd="yes"
94*fb065187Sbellardoss="yes"
957d3505c5Sbellard;;
9683fb7adfSbellardDarwin)
9783fb7adfSbellardbsd="yes"
9883fb7adfSbellarddarwin="yes"
9983fb7adfSbellard;;
100*fb065187Sbellard*)
101*fb065187Sbellardoss="yes"
102*fb065187Sbellard;;
1037d13299dSbellardesac
1047d13299dSbellard
1057d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
10683fb7adfSbellard  if [ ! "$darwin" = "yes" ] ; then
1077d3505c5Sbellard    make="gmake"
10883fb7adfSbellard  fi
109e95c8d51Sbellard  target_list="i386-softmmu ppc-softmmu sparc-softmmu"
1107d3505c5Sbellardfi
1117d3505c5Sbellard
1127d13299dSbellard# find source path
1137d13299dSbellard# XXX: we assume an absolute path is given when launching configure,
1147d13299dSbellard# except in './configure' case.
1157d13299dSbellardsource_path=${0%configure}
1167d13299dSbellardsource_path=${source_path%/}
1177d13299dSbellardsource_path_used="yes"
1187d13299dSbellardif test -z "$source_path" -o "$source_path" = "." ; then
1197d13299dSbellard    source_path=`pwd`
1207d13299dSbellard    source_path_used="no"
1217d13299dSbellardfi
1227d13299dSbellard
1237d13299dSbellardfor opt do
1247d13299dSbellard  case "$opt" in
1257d13299dSbellard  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
1267d13299dSbellard  ;;
12732ce6337Sbellard  --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2`
12832ce6337Sbellard  ;;
1297d13299dSbellard  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
1307d13299dSbellard  ;;
1317d13299dSbellard  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
1327d13299dSbellard  ;;
1337d13299dSbellard  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
1347d13299dSbellard  ;;
1357d13299dSbellard  --make=*) make=`echo $opt | cut -d '=' -f 2`
1367d13299dSbellard  ;;
1377d13299dSbellard  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
1387d13299dSbellard  ;;
1397d13299dSbellard  --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
1407d13299dSbellard  ;;
1417d13299dSbellard  --extra-libs=*) extralibs=${opt#--extra-libs=}
1427d13299dSbellard  ;;
1437d13299dSbellard  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
1447d13299dSbellard  ;;
14597a847bcSbellard  --target-list=*) target_list=${opt#--target-list=}
146de83cd02Sbellard  ;;
1477d13299dSbellard  --enable-gprof) gprof="yes"
1487d13299dSbellard  ;;
14943ce4dfeSbellard  --static) static="yes"
15043ce4dfeSbellard  ;;
15197a847bcSbellard  --disable-sdl) sdl="no"
15297a847bcSbellard  ;;
15367b915a5Sbellard  --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
15467b915a5Sbellard  ;;
155443f1376Sbellard  --disable-slirp) slirp="no"
156c20709aaSbellard  ;;
157*fb065187Sbellard  --enable-adlib) adlib="yes"
158*fb065187Sbellard  ;;
1597d13299dSbellard  esac
1607d13299dSbellarddone
1617d13299dSbellard
1627d13299dSbellard# Checking for CFLAGS
1637d13299dSbellardif test -z "$CFLAGS"; then
1647d13299dSbellard    CFLAGS="-O2"
1657d13299dSbellardfi
1667d13299dSbellard
1677d13299dSbellardcc="${cross_prefix}${cc}"
1687d13299dSbellardar="${cross_prefix}${ar}"
1697d13299dSbellardstrip="${cross_prefix}${strip}"
1707d13299dSbellard
17167b915a5Sbellardif test "$mingw32" = "yes" ; then
172e95c8d51Sbellard    target_list="i386-softmmu ppc-softmmu sparc-softmmu"
17367b915a5Sbellard    EXESUF=".exe"
17467b915a5Sbellard    gdbstub="no"
17567b915a5Sbellardfi
17667b915a5Sbellard
1777d13299dSbellardif test -z "$cross_prefix" ; then
1787d13299dSbellard
1797d13299dSbellard# ---
1807d13299dSbellard# big/little endian test
1817d13299dSbellardcat > $TMPC << EOF
1827d13299dSbellard#include <inttypes.h>
1837d13299dSbellardint main(int argc, char ** argv){
1847d13299dSbellard	volatile uint32_t i=0x01234567;
1857d13299dSbellard	return (*((uint8_t*)(&i))) == 0x67;
1867d13299dSbellard}
1877d13299dSbellardEOF
1887d13299dSbellard
1897d13299dSbellardif $cc -o $TMPE $TMPC 2>/dev/null ; then
1907d13299dSbellard$TMPE && bigendian="yes"
1917d13299dSbellardelse
1927d13299dSbellardecho big/little test failed
1937d13299dSbellardfi
1947d13299dSbellard
1957d13299dSbellardelse
1967d13299dSbellard
1977d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
19838e584a0Sbellardif test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k"; then
1997d13299dSbellard    bigendian="yes"
2007d13299dSbellardfi
2017d13299dSbellard
2027d13299dSbellardfi
2037d13299dSbellard
204e8cd23deSbellard# check gcc options support
20504369ff2Sbellardcat > $TMPC <<EOF
20604369ff2Sbellardint main(void) {
20704369ff2Sbellard}
20804369ff2SbellardEOF
20904369ff2Sbellard
210e8cd23deSbellardhave_gcc3_options="no"
211e8cd23deSbellardif $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then
212e8cd23deSbellard   have_gcc3_options="yes"
21304369ff2Sbellardfi
214ca735206Sbellard
21511d9f695Sbellard##########################################
21611d9f695Sbellard# SDL probe
21711d9f695Sbellard
21811d9f695Sbellardsdl_too_old=no
21911d9f695Sbellard
22011d9f695Sbellardif test -z "$sdl" ; then
22111d9f695Sbellard
222a6e022adSbellardsdl_config="sdl-config"
223a6e022adSbellardsdl=no
2247c1f25b4Sbellardsdl_static=no
225a6e022adSbellard
226a6e022adSbellardif test "$mingw32" = "yes" -a ! -z "$cross_prefix" ; then
227a6e022adSbellard# win32 cross compilation case
228a6e022adSbellard    sdl_config="i386-mingw32msvc-sdl-config"
229a6e022adSbellard    sdl=yes
230a6e022adSbellardelse
231a6e022adSbellard# normal SDL probe
23211d9f695Sbellardcat > $TMPC << EOF
23311d9f695Sbellard#include <SDL.h>
23411d9f695Sbellard#undef main /* We don't want SDL to override our main() */
23511d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
23611d9f695SbellardEOF
23711d9f695Sbellard
238a6e022adSbellardif $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then
239a6e022adSbellard_sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
24011d9f695Sbellardif test "$_sdlversion" -lt 121 ; then
24111d9f695Sbellardsdl_too_old=yes
24211d9f695Sbellardelse
24311d9f695Sbellardsdl=yes
24411d9f695Sbellardfi
2457c1f25b4Sbellard
2467c1f25b4Sbellard# static link with sdl ?
2477c1f25b4Sbellardif test "$sdl" = "yes" ; then
2487c1f25b4Sbellardaa="no"
2497c1f25b4Sbellard`$sdl_config --static-libs | grep \\\-laa > /dev/null` && aa="yes"
2507c1f25b4Sbellardsdl_static_libs=`$sdl_config --static-libs`
2517c1f25b4Sbellardif [ "$aa" = "yes" ] ; then
252d8d8aa4eSbellard  sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
25311d9f695Sbellardfi
25411d9f695Sbellard
2557c1f25b4Sbellardif $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs 2> /dev/null; then
2567c1f25b4Sbellard  sdl_static=yes
2577c1f25b4Sbellardfi
2587c1f25b4Sbellard
2597c1f25b4Sbellardfi # static link
2607c1f25b4Sbellard
2617c1f25b4Sbellardfi # sdl compile test
2627c1f25b4Sbellard
263a6e022adSbellardfi # cross compilation
264a6e022adSbellardfi # -z $sdl
26511d9f695Sbellard
2667d13299dSbellardif test x"$1" = x"-h" -o x"$1" = x"--help" ; then
2677d13299dSbellardcat << EOF
2687d13299dSbellard
2697d13299dSbellardUsage: configure [options]
2707d13299dSbellardOptions: [defaults in brackets after descriptions]
2717d13299dSbellard
2727d13299dSbellardEOF
2737d13299dSbellardecho "Standard options:"
2747d13299dSbellardecho "  --help                   print this message"
2757d13299dSbellardecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
2761e43adfcSbellardecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
2771e43adfcSbellardecho "                           use %M for cpu name [$interp_prefix]"
27897a847bcSbellardecho "  --target-list=LIST       set target list [$target_list]"
2797d13299dSbellardecho ""
2807d13299dSbellardecho "Advanced options (experts only):"
2817d13299dSbellardecho "  --source-path=PATH       path of source code [$source_path]"
2827d13299dSbellardecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
2837d13299dSbellardecho "  --cc=CC                  use C compiler CC [$cc]"
2847d13299dSbellardecho "  --make=MAKE              use specified make [$make]"
28543ce4dfeSbellardecho "  --static                 enable static build [$static]"
28667b915a5Sbellardecho "  --enable-mingw32         enable Win32 cross compilation with mingw32"
2877d13299dSbellardecho ""
2887d13299dSbellardecho "NOTE: The object files are build at the place where configure is launched"
2897d13299dSbellardexit 1
2907d13299dSbellardfi
2917d13299dSbellard
29211d9f695Sbellardif test "$mingw32" = "yes" ; then
29311d9f695Sbellardif test -z "$prefix" ; then
29411d9f695Sbellard    prefix="/c/Program Files/Qemu"
29511d9f695Sbellardfi
29611d9f695Sbellardmandir="$prefix"
2977efa4387Sbellarddatadir="$prefix"
2981f50f8d1Sbellarddocdir="$prefix"
29911d9f695Sbellardbindir="$prefix"
30011d9f695Sbellardelse
30111d9f695Sbellardif test -z "$prefix" ; then
30211d9f695Sbellard    prefix="/usr/local"
30311d9f695Sbellardfi
3045a67135aSbellardmandir="$prefix/share/man"
3057efa4387Sbellarddatadir="$prefix/share/qemu"
3061f50f8d1Sbellarddocdir="$prefix/share/doc/qemu"
30711d9f695Sbellardbindir="$prefix/bin"
30811d9f695Sbellardfi
3095a67135aSbellard
3107d13299dSbellardecho "Install prefix    $prefix"
3117efa4387Sbellardecho "BIOS directory    $datadir"
31211d9f695Sbellardecho "binary directory  $bindir"
31311d9f695Sbellardif test "$mingw32" = "no" ; then
31411d9f695Sbellardecho "Manual directory  $mandir"
31543ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
31611d9f695Sbellardfi
3175a67135aSbellardecho "Source path       $source_path"
3187d13299dSbellardecho "C compiler        $cc"
3197d13299dSbellardecho "make              $make"
320a98fd896Sbellardecho "host CPU          $cpu"
321de83cd02Sbellardecho "host big endian   $bigendian"
32297a847bcSbellardecho "target list       $target_list"
3237d13299dSbellardecho "gprof enabled     $gprof"
32443ce4dfeSbellardecho "static build      $static"
32597a847bcSbellardecho "SDL support       $sdl"
3267c1f25b4Sbellardecho "SDL static link   $sdl_static"
32767b915a5Sbellardecho "mingw32 support   $mingw32"
328*fb065187Sbellardecho "Adlib support     $adlib"
32967b915a5Sbellard
33097a847bcSbellardif test $sdl_too_old = "yes"; then
33197a847bcSbellardecho "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
332e8cd23deSbellardfi
3337c1f25b4Sbellardif test "$sdl_static" = "no"; then
3347c1f25b4Sbellard  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
3357c1f25b4Sbellardfi
33697a847bcSbellard
33797a847bcSbellardconfig_mak="config-host.mak"
33897a847bcSbellardconfig_h="config-host.h"
33997a847bcSbellard
3407c1f25b4Sbellard#echo "Creating $config_mak and $config_h"
34197a847bcSbellard
34297a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
34397a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
34497a847bcSbellard
34597a847bcSbellardecho "prefix=$prefix" >> $config_mak
34611d9f695Sbellardecho "bindir=$bindir" >> $config_mak
3475a67135aSbellardecho "mandir=$mandir" >> $config_mak
3487efa4387Sbellardecho "datadir=$datadir" >> $config_mak
3491f50f8d1Sbellardecho "docdir=$docdir" >> $config_mak
3507efa4387Sbellardecho "#define CONFIG_QEMU_SHAREDIR \"$datadir\"" >> $config_h
35197a847bcSbellardecho "MAKE=$make" >> $config_mak
35297a847bcSbellardecho "CC=$cc" >> $config_mak
35397a847bcSbellardif test "$have_gcc3_options" = "yes" ; then
35497a847bcSbellard  echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak
35597a847bcSbellardfi
35697a847bcSbellardecho "HOST_CC=$host_cc" >> $config_mak
35797a847bcSbellardecho "AR=$ar" >> $config_mak
35897a847bcSbellardecho "STRIP=$strip -s -R .comment -R .note" >> $config_mak
35997a847bcSbellardecho "CFLAGS=$CFLAGS" >> $config_mak
36097a847bcSbellardecho "LDFLAGS=$LDFLAGS" >> $config_mak
36167b915a5Sbellardecho "EXESUF=$EXESUF" >> $config_mak
36297a847bcSbellardif test "$cpu" = "i386" ; then
36397a847bcSbellard  echo "ARCH=i386" >> $config_mak
36497a847bcSbellard  echo "#define HOST_I386 1" >> $config_h
365bc51c5c9Sbellardelif test "$cpu" = "amd64" ; then
366bc51c5c9Sbellard  echo "ARCH=amd64" >> $config_mak
367bc51c5c9Sbellard  echo "#define HOST_AMD64 1" >> $config_h
3687d13299dSbellardelif test "$cpu" = "armv4l" ; then
36997a847bcSbellard  echo "ARCH=arm" >> $config_mak
37097a847bcSbellard  echo "#define HOST_ARM 1" >> $config_h
3717d13299dSbellardelif test "$cpu" = "powerpc" ; then
37297a847bcSbellard  echo "ARCH=ppc" >> $config_mak
37397a847bcSbellard  echo "#define HOST_PPC 1" >> $config_h
3747d13299dSbellardelif test "$cpu" = "mips" ; then
37597a847bcSbellard  echo "ARCH=mips" >> $config_mak
37697a847bcSbellard  echo "#define HOST_MIPS 1" >> $config_h
377fb3e5849Sbellardelif test "$cpu" = "s390" ; then
37897a847bcSbellard  echo "ARCH=s390" >> $config_mak
37997a847bcSbellard  echo "#define HOST_S390 1" >> $config_h
380295defa5Sbellardelif test "$cpu" = "alpha" ; then
38197a847bcSbellard  echo "ARCH=alpha" >> $config_mak
38297a847bcSbellard  echo "#define HOST_ALPHA 1" >> $config_h
383ae228531Sbellardelif test "$cpu" = "sparc" ; then
38497a847bcSbellard  echo "ARCH=sparc" >> $config_mak
38597a847bcSbellard  echo "#define HOST_SPARC 1" >> $config_h
386ae228531Sbellardelif test "$cpu" = "sparc64" ; then
38797a847bcSbellard  echo "ARCH=sparc64" >> $config_mak
38897a847bcSbellard  echo "#define HOST_SPARC64 1" >> $config_h
389a8baa8c5Sbellardelif test "$cpu" = "ia64" ; then
39097a847bcSbellard  echo "ARCH=ia64" >> $config_mak
39197a847bcSbellard  echo "#define HOST_IA64 1" >> $config_h
39238e584a0Sbellardelif test "$cpu" = "m68k" ; then
39338ca2abcSbellard  echo "ARCH=m68k" >> $config_mak
39438ca2abcSbellard  echo "#define HOST_M68K 1" >> $config_h
3957d13299dSbellardelse
3967d13299dSbellard  echo "Unsupported CPU"
3977d13299dSbellard  exit 1
3987d13299dSbellardfi
3997d13299dSbellardif test "$bigendian" = "yes" ; then
40097a847bcSbellard  echo "WORDS_BIGENDIAN=yes" >> $config_mak
40197a847bcSbellard  echo "#define WORDS_BIGENDIAN 1" >> $config_h
40297a847bcSbellardfi
40367b915a5Sbellardif test "$mingw32" = "yes" ; then
40467b915a5Sbellard  echo "CONFIG_WIN32=yes" >> $config_mak
40511d9f695Sbellard  echo "#define CONFIG_WIN32 1" >> $config_h
4067d3505c5Sbellardelif test -f "/usr/include/byteswap.h" ; then
40797a847bcSbellard  echo "#define HAVE_BYTESWAP_H 1" >> $config_h
40867b915a5Sbellardfi
40983fb7adfSbellardif test "$darwin" = "yes" ; then
41083fb7adfSbellard  echo "CONFIG_DARWIN=yes" >> $config_mak
41183fb7adfSbellard  echo "#define CONFIG_DARWIN 1" >> $config_h
41283fb7adfSbellardfi
41367b915a5Sbellardif test "$gdbstub" = "yes" ; then
41467b915a5Sbellard  echo "CONFIG_GDBSTUB=yes" >> $config_mak
41567b915a5Sbellard  echo "#define CONFIG_GDBSTUB 1" >> $config_h
41667b915a5Sbellardfi
41797a847bcSbellardif test "$gprof" = "yes" ; then
41897a847bcSbellard  echo "TARGET_GPROF=yes" >> $config_mak
41997a847bcSbellard  echo "#define HAVE_GPROF 1" >> $config_h
42097a847bcSbellardfi
42197a847bcSbellardif test "$static" = "yes" ; then
42297a847bcSbellard  echo "CONFIG_STATIC=yes" >> $config_mak
42350863472Sbellard  echo "#define CONFIG_STATIC 1" >> $config_h
42497a847bcSbellardfi
425c20709aaSbellardif test "$slirp" = "yes" ; then
426c20709aaSbellard  echo "CONFIG_SLIRP=yes" >> $config_mak
427c20709aaSbellard  echo "#define CONFIG_SLIRP 1" >> $config_h
428c20709aaSbellardfi
429*fb065187Sbellardif test "$adlib" = "yes" ; then
430*fb065187Sbellard  echo "CONFIG_ADLIB=yes" >> $config_mak
431*fb065187Sbellard  echo "#define CONFIG_ADLIB 1" >> $config_h
432*fb065187Sbellardfi
433*fb065187Sbellardif test "$oss" = "yes" ; then
434*fb065187Sbellard  echo "CONFIG_OSS=yes" >> $config_mak
435*fb065187Sbellard  echo "#define CONFIG_OSS 1" >> $config_h
436*fb065187Sbellardfi
43797a847bcSbellardecho -n "VERSION=" >>$config_mak
43897a847bcSbellardhead $source_path/VERSION >>$config_mak
43997a847bcSbellardecho "" >>$config_mak
44097a847bcSbellardecho -n "#define QEMU_VERSION \"" >> $config_h
44197a847bcSbellardhead $source_path/VERSION >> $config_h
44297a847bcSbellardecho "\"" >> $config_h
44397a847bcSbellard
44497a847bcSbellardecho "SRC_PATH=$source_path" >> $config_mak
44597a847bcSbellardecho "TARGET_DIRS=$target_list" >> $config_mak
44697a847bcSbellard
44783fb7adfSbellard# XXX: suppress that
4487d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
44943003046Sbellard  echo "#define O_LARGEFILE 0" >> $config_h
45043003046Sbellard  echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
4517d3505c5Sbellard  echo "#define _BSD 1" >> $config_h
4527d3505c5Sbellardfi
4537d3505c5Sbellard
45497a847bcSbellardfor target in $target_list; do
45597a847bcSbellard
45697a847bcSbellardtarget_dir="$target"
45797a847bcSbellardconfig_mak=$target_dir/config.mak
45897a847bcSbellardconfig_h=$target_dir/config.h
45997a847bcSbellardtarget_cpu=`echo $target | cut -d '-' -f 1`
46097a847bcSbellardtarget_bigendian="no"
4611e43adfcSbellard[ "$target_cpu" = "sparc" ] && target_bigendian=yes
46267867308Sbellard[ "$target_cpu" = "ppc" ] && target_bigendian=yes
46397a847bcSbellardtarget_softmmu="no"
46497a847bcSbellardif expr $target : '.*-softmmu' > /dev/null ; then
46597a847bcSbellard  target_softmmu="yes"
4667d13299dSbellardfi
467997344f3Sbellardtarget_user_only="no"
468997344f3Sbellardif expr $target : '.*-user' > /dev/null ; then
469997344f3Sbellard  target_user_only="yes"
470997344f3Sbellardfi
471de83cd02Sbellard
4727c1f25b4Sbellard#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
47397a847bcSbellard
47497a847bcSbellardmkdir -p $target_dir
47569de927cSbellardif test "$target" = "arm-user" ; then
47669de927cSbellard  mkdir -p $target_dir/nwfpe
47769de927cSbellardfi
478a7e61ed4Sbellardif test "$target_user_only" = "no" ; then
479a7e61ed4Sbellard  mkdir -p $target_dir/slirp
480a7e61ed4Sbellardfi
48169de927cSbellard
48297a847bcSbellardln -sf $source_path/Makefile.target $target_dir/Makefile
48397a847bcSbellard
48497a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
48597a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
48697a847bcSbellard
48797a847bcSbellard
48897a847bcSbellardecho "include ../config-host.mak" >> $config_mak
48997a847bcSbellardecho "#include \"../config-host.h\"" >> $config_h
4901e43adfcSbellard
4911e43adfcSbellardinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
4921e43adfcSbellardecho "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
49397a847bcSbellard
49497a847bcSbellardif test "$target_cpu" = "i386" ; then
49597a847bcSbellard  echo "TARGET_ARCH=i386" >> $config_mak
49697a847bcSbellard  echo "#define TARGET_ARCH \"i386\"" >> $config_h
49797a847bcSbellard  echo "#define TARGET_I386 1" >> $config_h
498de83cd02Sbellardelif test "$target_cpu" = "arm" ; then
49997a847bcSbellard  echo "TARGET_ARCH=arm" >> $config_mak
50097a847bcSbellard  echo "#define TARGET_ARCH \"arm\"" >> $config_h
50197a847bcSbellard  echo "#define TARGET_ARM 1" >> $config_h
5021e43adfcSbellardelif test "$target_cpu" = "sparc" ; then
5031e43adfcSbellard  echo "TARGET_ARCH=sparc" >> $config_mak
5041e43adfcSbellard  echo "#define TARGET_ARCH \"sparc\"" >> $config_h
5051e43adfcSbellard  echo "#define TARGET_SPARC 1" >> $config_h
50667867308Sbellardelif test "$target_cpu" = "ppc" ; then
50767867308Sbellard  echo "TARGET_ARCH=ppc" >> $config_mak
50867867308Sbellard  echo "#define TARGET_ARCH \"ppc\"" >> $config_h
50967867308Sbellard  echo "#define TARGET_PPC 1" >> $config_h
510de83cd02Sbellardelse
511de83cd02Sbellard  echo "Unsupported target CPU"
512de83cd02Sbellard  exit 1
513de83cd02Sbellardfi
514de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
51597a847bcSbellard  echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
51697a847bcSbellard  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
51797a847bcSbellardfi
51897a847bcSbellardif test "$target_softmmu" = "yes" ; then
51997a847bcSbellard  echo "CONFIG_SOFTMMU=yes" >> $config_mak
52097a847bcSbellard  echo "#define CONFIG_SOFTMMU 1" >> $config_h
521de83cd02Sbellardfi
522997344f3Sbellardif test "$target_user_only" = "yes" ; then
523997344f3Sbellard  echo "CONFIG_USER_ONLY=yes" >> $config_mak
524997344f3Sbellard  echo "#define CONFIG_USER_ONLY 1" >> $config_h
525997344f3Sbellardfi
526de83cd02Sbellard
5277c1f25b4Sbellard# sdl defines
5287c1f25b4Sbellard
5297c1f25b4Sbellardif test "$target_user_only" = "no"; then
5307c1f25b4Sbellard    if test "$target_softmmu" = "no" -o "$static" = "yes"; then
531dbb2c921Sbellard        sdl1=$sdl_static
5327c1f25b4Sbellard    else
533dbb2c921Sbellard        sdl1=$sdl
534dbb2c921Sbellard    fi
535dbb2c921Sbellard    if test "$sdl1" = "yes" ; then
5367c1f25b4Sbellard        echo "#define CONFIG_SDL 1" >> $config_h
5377c1f25b4Sbellard        echo "CONFIG_SDL=yes" >> $config_mak
538dbb2c921Sbellard        if test "$target_softmmu" = "no" -o "$static" = "yes"; then
539dbb2c921Sbellard            echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
540dbb2c921Sbellard        else
5417c1f25b4Sbellard            echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
5427c1f25b4Sbellard        fi
5437c1f25b4Sbellard        echo -n "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
5447c1f25b4Sbellard        if [ "${aa}" = "yes" ] ; then
5457c1f25b4Sbellard            echo -n " `aalib-config --cflags`" >> $config_mak ;
5467c1f25b4Sbellard        fi
5477c1f25b4Sbellard        echo "" >> $config_mak
5487c1f25b4Sbellard    fi
549dbb2c921Sbellardfi
5507c1f25b4Sbellard
55197a847bcSbellarddone # for target in $targets
5527d13299dSbellard
5537d13299dSbellard# build tree in object directory if source path is different from current one
5547d13299dSbellardif test "$source_path_used" = "yes" ; then
5557d13299dSbellard    DIRS="tests"
5567d13299dSbellard    FILES="Makefile tests/Makefile"
5577d13299dSbellard    for dir in $DIRS ; do
5587d13299dSbellard            mkdir -p $dir
5597d13299dSbellard    done
5607d13299dSbellard    for f in $FILES ; do
5617d13299dSbellard        ln -sf $source_path/$f $f
5627d13299dSbellard    done
5637d13299dSbellardfi
5647d13299dSbellard
56597a847bcSbellardrm -f $TMPO $TMPC $TMPE $TMPS
566