xref: /openbmc/qemu/configure (revision a20b5524)
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`
305327cf48Sbellardtarget_list=""
317d13299dSbellardcase "$cpu" in
327d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
3397a847bcSbellard    cpu="i386"
347d13299dSbellard  ;;
35808c4954Sbellard  armv4b)
36808c4954Sbellard    cpu="armv4b"
37808c4954Sbellard  ;;
387d13299dSbellard  armv4l)
397d13299dSbellard    cpu="armv4l"
407d13299dSbellard  ;;
417d13299dSbellard  alpha)
427d13299dSbellard    cpu="alpha"
437d13299dSbellard  ;;
44295defa5Sbellard  "Power Macintosh"|ppc|ppc64)
457d13299dSbellard    cpu="powerpc"
467d13299dSbellard  ;;
477d13299dSbellard  mips)
487d13299dSbellard    cpu="mips"
497d13299dSbellard  ;;
50fb3e5849Sbellard  s390)
51fb3e5849Sbellard    cpu="s390"
52fb3e5849Sbellard  ;;
53ae228531Sbellard  sparc)
54ae228531Sbellard    cpu="sparc"
55ae228531Sbellard  ;;
56ae228531Sbellard  sparc64)
57ae228531Sbellard    cpu="sparc64"
58ae228531Sbellard  ;;
59a8baa8c5Sbellard  ia64)
60a8baa8c5Sbellard    cpu="ia64"
61a8baa8c5Sbellard  ;;
6238e584a0Sbellard  m68k)
6338e584a0Sbellard    cpu="m68k"
6438e584a0Sbellard  ;;
65bc51c5c9Sbellard  x86_64|amd64)
660b0babc6Sbellard    cpu="x86_64"
67bc51c5c9Sbellard  ;;
687d13299dSbellard  *)
697d13299dSbellard    cpu="unknown"
707d13299dSbellard  ;;
717d13299dSbellardesac
727d13299dSbellardgprof="no"
737d13299dSbellardbigendian="no"
7467b915a5Sbellardmingw32="no"
7567b915a5SbellardEXESUF=""
7667b915a5Sbellardgdbstub="yes"
77443f1376Sbellardslirp="yes"
78fb065187Sbellardadlib="no"
79fb065187Sbellardoss="no"
80102a52e4Sbellardfmod="no"
81102a52e4Sbellardfmod_lib=""
82102a52e4Sbellardfmod_inc=""
835327cf48Sbellardlinux="no"
84c9ec1fe4Sbellardkqemu="no"
85c9ec1fe4Sbellardkernel_path=""
867d13299dSbellard
877d13299dSbellard# OS specific
887d13299dSbellardtargetos=`uname -s`
897d13299dSbellardcase $targetos in
9067b915a5SbellardMINGW32*)
9167b915a5Sbellardmingw32="yes"
9267b915a5Sbellard;;
937d3505c5SbellardFreeBSD)
947d3505c5Sbellardbsd="yes"
95fb065187Sbellardoss="yes"
967d3505c5Sbellard;;
977d3505c5SbellardNetBSD)
987d3505c5Sbellardbsd="yes"
99fb065187Sbellardoss="yes"
1007d3505c5Sbellard;;
1017d3505c5SbellardOpenBSD)
1027d3505c5Sbellardbsd="yes"
103fb065187Sbellardoss="yes"
1047d3505c5Sbellard;;
10583fb7adfSbellardDarwin)
10683fb7adfSbellardbsd="yes"
10783fb7adfSbellarddarwin="yes"
10883fb7adfSbellard;;
109fb065187Sbellard*)
110fb065187Sbellardoss="yes"
1115327cf48Sbellardlinux="yes"
112c9ec1fe4Sbellardif [ "$cpu" = "i386" ] ; then
113c9ec1fe4Sbellard    kqemu="yes"
114c9ec1fe4Sbellardfi
115fb065187Sbellard;;
1167d13299dSbellardesac
1177d13299dSbellard
1187d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
11983fb7adfSbellard  if [ ! "$darwin" = "yes" ] ; then
1207d3505c5Sbellard    make="gmake"
12183fb7adfSbellard  fi
1227d3505c5Sbellardfi
1237d3505c5Sbellard
1247d13299dSbellard# find source path
1257d13299dSbellard# XXX: we assume an absolute path is given when launching configure,
1267d13299dSbellard# except in './configure' case.
1277d13299dSbellardsource_path=${0%configure}
1287d13299dSbellardsource_path=${source_path%/}
1297d13299dSbellardsource_path_used="yes"
1307d13299dSbellardif test -z "$source_path" -o "$source_path" = "." ; then
1317d13299dSbellard    source_path=`pwd`
1327d13299dSbellard    source_path_used="no"
1337d13299dSbellardfi
1347d13299dSbellard
1357d13299dSbellardfor opt do
1367d13299dSbellard  case "$opt" in
1377d13299dSbellard  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
1387d13299dSbellard  ;;
13932ce6337Sbellard  --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2`
14032ce6337Sbellard  ;;
1417d13299dSbellard  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
1427d13299dSbellard  ;;
1437d13299dSbellard  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
1447d13299dSbellard  ;;
1457d13299dSbellard  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
1467d13299dSbellard  ;;
1477d13299dSbellard  --make=*) make=`echo $opt | cut -d '=' -f 2`
1487d13299dSbellard  ;;
1497d13299dSbellard  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
1507d13299dSbellard  ;;
1517d13299dSbellard  --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
1527d13299dSbellard  ;;
1537d13299dSbellard  --extra-libs=*) extralibs=${opt#--extra-libs=}
1547d13299dSbellard  ;;
1557d13299dSbellard  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
1567d13299dSbellard  ;;
15797a847bcSbellard  --target-list=*) target_list=${opt#--target-list=}
158de83cd02Sbellard  ;;
1597d13299dSbellard  --enable-gprof) gprof="yes"
1607d13299dSbellard  ;;
16143ce4dfeSbellard  --static) static="yes"
16243ce4dfeSbellard  ;;
16397a847bcSbellard  --disable-sdl) sdl="no"
16497a847bcSbellard  ;;
165102a52e4Sbellard  --enable-fmod) fmod="yes"
166102a52e4Sbellard  ;;
167102a52e4Sbellard  --fmod-lib=*) fmod_lib=${opt#--fmod-lib=}
168102a52e4Sbellard  ;;
169102a52e4Sbellard  --fmod-inc=*) fmod_inc=${opt#--fmod-inc=}
170102a52e4Sbellard  ;;
17167b915a5Sbellard  --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
17267b915a5Sbellard  ;;
173443f1376Sbellard  --disable-slirp) slirp="no"
174c20709aaSbellard  ;;
175fb065187Sbellard  --enable-adlib) adlib="yes"
176fb065187Sbellard  ;;
177c9ec1fe4Sbellard  --disable-kqemu) kqemu="no"
178c9ec1fe4Sbellard  ;;
179c9ec1fe4Sbellard  --kernel-path=*) kernel_path=${opt#--kernel-path=}
180c9ec1fe4Sbellard  ;;
1817d13299dSbellard  esac
1827d13299dSbellarddone
1837d13299dSbellard
1847d13299dSbellard# Checking for CFLAGS
1857d13299dSbellardif test -z "$CFLAGS"; then
1867d13299dSbellard    CFLAGS="-O2"
1877d13299dSbellardfi
1887d13299dSbellard
1897d13299dSbellardcc="${cross_prefix}${cc}"
1907d13299dSbellardar="${cross_prefix}${ar}"
1917d13299dSbellardstrip="${cross_prefix}${strip}"
1927d13299dSbellard
19367b915a5Sbellardif test "$mingw32" = "yes" ; then
1945327cf48Sbellard    linux="no"
19567b915a5Sbellard    EXESUF=".exe"
19667b915a5Sbellard    gdbstub="no"
1979f059ecaSbellard    oss="no"
198824d560fSbellard    kqemu="no"
19967b915a5Sbellardfi
20067b915a5Sbellard
2015327cf48Sbellardif test -z "$target_list" ; then
2025327cf48Sbellard# these targets are portable
203*a20b5524Sbellard    target_list="i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu"
2045327cf48Sbellard# the following are Linux specific
2055327cf48Sbellard    if [ "$linux" = "yes" ] ; then
206*a20b5524Sbellard        target_list="i386-user arm-user armeb-user sparc-user ppc-user $target_list"
2075327cf48Sbellard    fi
2085327cf48Sbellardfi
2095327cf48Sbellard
2107d13299dSbellardif test -z "$cross_prefix" ; then
2117d13299dSbellard
2127d13299dSbellard# ---
2137d13299dSbellard# big/little endian test
2147d13299dSbellardcat > $TMPC << EOF
2157d13299dSbellard#include <inttypes.h>
2167d13299dSbellardint main(int argc, char ** argv){
2177d13299dSbellard	volatile uint32_t i=0x01234567;
2187d13299dSbellard	return (*((uint8_t*)(&i))) == 0x67;
2197d13299dSbellard}
2207d13299dSbellardEOF
2217d13299dSbellard
2227d13299dSbellardif $cc -o $TMPE $TMPC 2>/dev/null ; then
2237d13299dSbellard$TMPE && bigendian="yes"
2247d13299dSbellardelse
2257d13299dSbellardecho big/little test failed
2267d13299dSbellardfi
2277d13299dSbellard
2287d13299dSbellardelse
2297d13299dSbellard
2307d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
231808c4954Sbellardif test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k" -o "$cpu" = "armv4b"; then
2327d13299dSbellard    bigendian="yes"
2337d13299dSbellardfi
2347d13299dSbellard
2357d13299dSbellardfi
2367d13299dSbellard
237e8cd23deSbellard# check gcc options support
23804369ff2Sbellardcat > $TMPC <<EOF
23904369ff2Sbellardint main(void) {
24004369ff2Sbellard}
24104369ff2SbellardEOF
24204369ff2Sbellard
243e8cd23deSbellardhave_gcc3_options="no"
244e8cd23deSbellardif $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then
245e8cd23deSbellard   have_gcc3_options="yes"
24604369ff2Sbellardfi
247ca735206Sbellard
24811d9f695Sbellard##########################################
24911d9f695Sbellard# SDL probe
25011d9f695Sbellard
25111d9f695Sbellardsdl_too_old=no
25211d9f695Sbellard
25311d9f695Sbellardif test -z "$sdl" ; then
25411d9f695Sbellard
255a6e022adSbellardsdl_config="sdl-config"
256a6e022adSbellardsdl=no
2577c1f25b4Sbellardsdl_static=no
258a6e022adSbellard
259a6e022adSbellardif test "$mingw32" = "yes" -a ! -z "$cross_prefix" ; then
260a6e022adSbellard# win32 cross compilation case
261a6e022adSbellard    sdl_config="i386-mingw32msvc-sdl-config"
262a6e022adSbellard    sdl=yes
263a6e022adSbellardelse
264a6e022adSbellard# normal SDL probe
26511d9f695Sbellardcat > $TMPC << EOF
26611d9f695Sbellard#include <SDL.h>
26711d9f695Sbellard#undef main /* We don't want SDL to override our main() */
26811d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
26911d9f695SbellardEOF
27011d9f695Sbellard
271a6e022adSbellardif $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then
272a6e022adSbellard_sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
27311d9f695Sbellardif test "$_sdlversion" -lt 121 ; then
27411d9f695Sbellardsdl_too_old=yes
27511d9f695Sbellardelse
27611d9f695Sbellardsdl=yes
27711d9f695Sbellardfi
2787c1f25b4Sbellard
2797c1f25b4Sbellard# static link with sdl ?
2807c1f25b4Sbellardif test "$sdl" = "yes" ; then
2817c1f25b4Sbellardaa="no"
2827c1f25b4Sbellard`$sdl_config --static-libs | grep \\\-laa > /dev/null` && aa="yes"
2837c1f25b4Sbellardsdl_static_libs=`$sdl_config --static-libs`
2847c1f25b4Sbellardif [ "$aa" = "yes" ] ; then
285d8d8aa4eSbellard  sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
28611d9f695Sbellardfi
28711d9f695Sbellard
2887c1f25b4Sbellardif $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs 2> /dev/null; then
2897c1f25b4Sbellard  sdl_static=yes
2907c1f25b4Sbellardfi
2917c1f25b4Sbellard
2927c1f25b4Sbellardfi # static link
2937c1f25b4Sbellard
2947c1f25b4Sbellardfi # sdl compile test
2957c1f25b4Sbellard
296a6e022adSbellardfi # cross compilation
297a6e022adSbellardfi # -z $sdl
29811d9f695Sbellard
2997d13299dSbellardif test x"$1" = x"-h" -o x"$1" = x"--help" ; then
3007d13299dSbellardcat << EOF
3017d13299dSbellard
3027d13299dSbellardUsage: configure [options]
3037d13299dSbellardOptions: [defaults in brackets after descriptions]
3047d13299dSbellard
3057d13299dSbellardEOF
3067d13299dSbellardecho "Standard options:"
3077d13299dSbellardecho "  --help                   print this message"
3087d13299dSbellardecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
3091e43adfcSbellardecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
3101e43adfcSbellardecho "                           use %M for cpu name [$interp_prefix]"
31197a847bcSbellardecho "  --target-list=LIST       set target list [$target_list]"
3127d13299dSbellardecho ""
313c9ec1fe4Sbellardecho "kqemu kernel acceleration support:"
314c9ec1fe4Sbellardecho "  --disable-kqemu          disable kqemu build"
315c9ec1fe4Sbellardecho "  --kernel-path=PATH       set the kernel path (configure probes it)"
316c9ec1fe4Sbellardecho ""
3177d13299dSbellardecho "Advanced options (experts only):"
3187d13299dSbellardecho "  --source-path=PATH       path of source code [$source_path]"
3197d13299dSbellardecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
3207d13299dSbellardecho "  --cc=CC                  use C compiler CC [$cc]"
3217d13299dSbellardecho "  --make=MAKE              use specified make [$make]"
32243ce4dfeSbellardecho "  --static                 enable static build [$static]"
32367b915a5Sbellardecho "  --enable-mingw32         enable Win32 cross compilation with mingw32"
324102a52e4Sbellardecho "  --enable-fmod            enable FMOD audio output driver"
325102a52e4Sbellardecho "  --fmod-lib               path to FMOD library"
326102a52e4Sbellardecho "  --fmod-inc               path to FMOD includes"
3277d13299dSbellardecho ""
3287d13299dSbellardecho "NOTE: The object files are build at the place where configure is launched"
3297d13299dSbellardexit 1
3307d13299dSbellardfi
3317d13299dSbellard
33211d9f695Sbellardif test "$mingw32" = "yes" ; then
33311d9f695Sbellardif test -z "$prefix" ; then
33411d9f695Sbellard    prefix="/c/Program Files/Qemu"
33511d9f695Sbellardfi
33611d9f695Sbellardmandir="$prefix"
3377efa4387Sbellarddatadir="$prefix"
3381f50f8d1Sbellarddocdir="$prefix"
33911d9f695Sbellardbindir="$prefix"
34011d9f695Sbellardelse
34111d9f695Sbellardif test -z "$prefix" ; then
34211d9f695Sbellard    prefix="/usr/local"
34311d9f695Sbellardfi
3445a67135aSbellardmandir="$prefix/share/man"
3457efa4387Sbellarddatadir="$prefix/share/qemu"
3461f50f8d1Sbellarddocdir="$prefix/share/doc/qemu"
34711d9f695Sbellardbindir="$prefix/bin"
34811d9f695Sbellardfi
3495a67135aSbellard
350c9ec1fe4Sbellard# kernel module support
351c9ec1fe4Sbellardif test $kqemu = "yes" ; then
352441c72baSbellard    # test if the source code is installed
353441c72baSbellard    if test '!' -f "kqemu/Makefile" ; then
354441c72baSbellard        kqemu="no"
355441c72baSbellard    fi
356441c72baSbellardfi
357441c72baSbellard
358441c72baSbellardif test $kqemu = "yes" ; then
359c9ec1fe4Sbellard# find the kernel path
360c9ec1fe4Sbellardif test -z "$kernel_path" ; then
361c9ec1fe4Sbellardkernel_version=`uname -r`
362c9ec1fe4Sbellardkernel_path="/lib/modules/$kernel_version/build"
363c9ec1fe4Sbellardif test '!' -d "$kernel_path/include" ; then
364c9ec1fe4Sbellard    kernel_path="/usr/src/linux"
365c9ec1fe4Sbellard    if test '!' -d "$kernel_path/include" ; then
366c9ec1fe4Sbellard        echo "Could not find kernel includes in /lib/modules or /usr/src/linux - cannot build the kqemu module"
367c9ec1fe4Sbellard        kqemu="no"
368c9ec1fe4Sbellard    fi
369c9ec1fe4Sbellardfi
370c9ec1fe4Sbellardfi
371c9ec1fe4Sbellard
372c9ec1fe4Sbellardif test $kqemu = "yes" ; then
373c9ec1fe4Sbellard
374c9ec1fe4Sbellard# test that the kernel config is present
375c9ec1fe4Sbellardif test '!' -f "$kernel_path/Makefile" ; then
376c9ec1fe4Sbellard    echo "No .config file present in $kernel_path - kqemu cannot be built"
377c9ec1fe4Sbellard    kqemu="no"
378c9ec1fe4Sbellardfi
379c9ec1fe4Sbellard
380c9ec1fe4Sbellard# find build system (2.6 or legacy)
381c9ec1fe4Sbellardkbuild26="yes"
382c9ec1fe4Sbellardif grep -q "PATCHLEVEL = 4" $kernel_path/Makefile ; then
383c9ec1fe4Sbellardkbuild26="no"
384c9ec1fe4Sbellardfi
385c9ec1fe4Sbellard
386c9ec1fe4Sbellardfi # kqemu
387c9ec1fe4Sbellard
388c9ec1fe4Sbellardfi # kqemu
389c9ec1fe4Sbellard
390c9ec1fe4Sbellard
3917d13299dSbellardecho "Install prefix    $prefix"
3927efa4387Sbellardecho "BIOS directory    $datadir"
39311d9f695Sbellardecho "binary directory  $bindir"
39411d9f695Sbellardif test "$mingw32" = "no" ; then
39511d9f695Sbellardecho "Manual directory  $mandir"
39643ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
39711d9f695Sbellardfi
3985a67135aSbellardecho "Source path       $source_path"
3997d13299dSbellardecho "C compiler        $cc"
4007d13299dSbellardecho "make              $make"
401a98fd896Sbellardecho "host CPU          $cpu"
402de83cd02Sbellardecho "host big endian   $bigendian"
40397a847bcSbellardecho "target list       $target_list"
4047d13299dSbellardecho "gprof enabled     $gprof"
40543ce4dfeSbellardecho "static build      $static"
40697a847bcSbellardecho "SDL support       $sdl"
4077c1f25b4Sbellardecho "SDL static link   $sdl_static"
40867b915a5Sbellardecho "mingw32 support   $mingw32"
409fb065187Sbellardecho "Adlib support     $adlib"
410102a52e4Sbellardecho -n "FMOD support      $fmod"
411102a52e4Sbellardif test $fmod = "yes"; then
412102a52e4Sbellard    echo -n " (lib='$fmod_lib' include='$fmod_inc')"
413102a52e4Sbellardfi
414102a52e4Sbellardecho ""
415c9ec1fe4Sbellardif test $kqemu = "yes" ; then
416c9ec1fe4Sbellardecho ""
417c9ec1fe4Sbellardecho "KQEMU module configuration:"
418c9ec1fe4Sbellardecho "kernel sources    $kernel_path"
419c9ec1fe4Sbellardecho -n "kbuild type       "
420c9ec1fe4Sbellardif test $kbuild26 = "yes"; then
421c9ec1fe4Sbellardecho "2.6"
422c9ec1fe4Sbellardelse
423c9ec1fe4Sbellardecho "2.4"
424c9ec1fe4Sbellardfi
425c9ec1fe4Sbellardfi
42667b915a5Sbellard
42797a847bcSbellardif test $sdl_too_old = "yes"; then
42897a847bcSbellardecho "-> Your SDL version is too old - please upgrade to have FFplay/SDL support"
429e8cd23deSbellardfi
4307c1f25b4Sbellardif test "$sdl_static" = "no"; then
4317c1f25b4Sbellard  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
4327c1f25b4Sbellardfi
43397a847bcSbellard
43497a847bcSbellardconfig_mak="config-host.mak"
43597a847bcSbellardconfig_h="config-host.h"
43697a847bcSbellard
4377c1f25b4Sbellard#echo "Creating $config_mak and $config_h"
43897a847bcSbellard
43997a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
44097a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
44197a847bcSbellard
44297a847bcSbellardecho "prefix=$prefix" >> $config_mak
44311d9f695Sbellardecho "bindir=$bindir" >> $config_mak
4445a67135aSbellardecho "mandir=$mandir" >> $config_mak
4457efa4387Sbellardecho "datadir=$datadir" >> $config_mak
4461f50f8d1Sbellardecho "docdir=$docdir" >> $config_mak
4477efa4387Sbellardecho "#define CONFIG_QEMU_SHAREDIR \"$datadir\"" >> $config_h
44897a847bcSbellardecho "MAKE=$make" >> $config_mak
44997a847bcSbellardecho "CC=$cc" >> $config_mak
45097a847bcSbellardif test "$have_gcc3_options" = "yes" ; then
45197a847bcSbellard  echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak
45297a847bcSbellardfi
45397a847bcSbellardecho "HOST_CC=$host_cc" >> $config_mak
45497a847bcSbellardecho "AR=$ar" >> $config_mak
45597a847bcSbellardecho "STRIP=$strip -s -R .comment -R .note" >> $config_mak
45697a847bcSbellardecho "CFLAGS=$CFLAGS" >> $config_mak
45797a847bcSbellardecho "LDFLAGS=$LDFLAGS" >> $config_mak
45867b915a5Sbellardecho "EXESUF=$EXESUF" >> $config_mak
45997a847bcSbellardif test "$cpu" = "i386" ; then
46097a847bcSbellard  echo "ARCH=i386" >> $config_mak
46197a847bcSbellard  echo "#define HOST_I386 1" >> $config_h
4620b0babc6Sbellardelif test "$cpu" = "x86_64" ; then
4630b0babc6Sbellard  echo "ARCH=x86_64" >> $config_mak
4640b0babc6Sbellard  echo "#define HOST_X86_64 1" >> $config_h
465808c4954Sbellardelif test "$cpu" = "armv4b" ; then
466808c4954Sbellard  echo "ARCH=arm" >> $config_mak
467808c4954Sbellard  echo "#define HOST_ARM 1" >> $config_h
4687d13299dSbellardelif test "$cpu" = "armv4l" ; then
46997a847bcSbellard  echo "ARCH=arm" >> $config_mak
47097a847bcSbellard  echo "#define HOST_ARM 1" >> $config_h
4717d13299dSbellardelif test "$cpu" = "powerpc" ; then
47297a847bcSbellard  echo "ARCH=ppc" >> $config_mak
47397a847bcSbellard  echo "#define HOST_PPC 1" >> $config_h
4747d13299dSbellardelif test "$cpu" = "mips" ; then
47597a847bcSbellard  echo "ARCH=mips" >> $config_mak
47697a847bcSbellard  echo "#define HOST_MIPS 1" >> $config_h
477fb3e5849Sbellardelif test "$cpu" = "s390" ; then
47897a847bcSbellard  echo "ARCH=s390" >> $config_mak
47997a847bcSbellard  echo "#define HOST_S390 1" >> $config_h
480295defa5Sbellardelif test "$cpu" = "alpha" ; then
48197a847bcSbellard  echo "ARCH=alpha" >> $config_mak
48297a847bcSbellard  echo "#define HOST_ALPHA 1" >> $config_h
483ae228531Sbellardelif test "$cpu" = "sparc" ; then
48497a847bcSbellard  echo "ARCH=sparc" >> $config_mak
48597a847bcSbellard  echo "#define HOST_SPARC 1" >> $config_h
486ae228531Sbellardelif test "$cpu" = "sparc64" ; then
48797a847bcSbellard  echo "ARCH=sparc64" >> $config_mak
48897a847bcSbellard  echo "#define HOST_SPARC64 1" >> $config_h
489a8baa8c5Sbellardelif test "$cpu" = "ia64" ; then
49097a847bcSbellard  echo "ARCH=ia64" >> $config_mak
49197a847bcSbellard  echo "#define HOST_IA64 1" >> $config_h
49238e584a0Sbellardelif test "$cpu" = "m68k" ; then
49338ca2abcSbellard  echo "ARCH=m68k" >> $config_mak
49438ca2abcSbellard  echo "#define HOST_M68K 1" >> $config_h
4957d13299dSbellardelse
4967d13299dSbellard  echo "Unsupported CPU"
4977d13299dSbellard  exit 1
4987d13299dSbellardfi
4997d13299dSbellardif test "$bigendian" = "yes" ; then
50097a847bcSbellard  echo "WORDS_BIGENDIAN=yes" >> $config_mak
50197a847bcSbellard  echo "#define WORDS_BIGENDIAN 1" >> $config_h
50297a847bcSbellardfi
50367b915a5Sbellardif test "$mingw32" = "yes" ; then
50467b915a5Sbellard  echo "CONFIG_WIN32=yes" >> $config_mak
50511d9f695Sbellard  echo "#define CONFIG_WIN32 1" >> $config_h
5067d3505c5Sbellardelif test -f "/usr/include/byteswap.h" ; then
50797a847bcSbellard  echo "#define HAVE_BYTESWAP_H 1" >> $config_h
50867b915a5Sbellardfi
50983fb7adfSbellardif test "$darwin" = "yes" ; then
51083fb7adfSbellard  echo "CONFIG_DARWIN=yes" >> $config_mak
51183fb7adfSbellard  echo "#define CONFIG_DARWIN 1" >> $config_h
51283fb7adfSbellardfi
51367b915a5Sbellardif test "$gdbstub" = "yes" ; then
51467b915a5Sbellard  echo "CONFIG_GDBSTUB=yes" >> $config_mak
51567b915a5Sbellard  echo "#define CONFIG_GDBSTUB 1" >> $config_h
51667b915a5Sbellardfi
51797a847bcSbellardif test "$gprof" = "yes" ; then
51897a847bcSbellard  echo "TARGET_GPROF=yes" >> $config_mak
51997a847bcSbellard  echo "#define HAVE_GPROF 1" >> $config_h
52097a847bcSbellardfi
52197a847bcSbellardif test "$static" = "yes" ; then
52297a847bcSbellard  echo "CONFIG_STATIC=yes" >> $config_mak
52350863472Sbellard  echo "#define CONFIG_STATIC 1" >> $config_h
52497a847bcSbellardfi
525c20709aaSbellardif test "$slirp" = "yes" ; then
526c20709aaSbellard  echo "CONFIG_SLIRP=yes" >> $config_mak
527c20709aaSbellard  echo "#define CONFIG_SLIRP 1" >> $config_h
528c20709aaSbellardfi
529fb065187Sbellardif test "$adlib" = "yes" ; then
530fb065187Sbellard  echo "CONFIG_ADLIB=yes" >> $config_mak
531fb065187Sbellard  echo "#define CONFIG_ADLIB 1" >> $config_h
532fb065187Sbellardfi
533fb065187Sbellardif test "$oss" = "yes" ; then
534fb065187Sbellard  echo "CONFIG_OSS=yes" >> $config_mak
535fb065187Sbellard  echo "#define CONFIG_OSS 1" >> $config_h
536fb065187Sbellardfi
537102a52e4Sbellardif test "$fmod" = "yes" ; then
538102a52e4Sbellard  echo "CONFIG_FMOD=yes" >> $config_mak
539102a52e4Sbellard  echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
540102a52e4Sbellard  echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
541102a52e4Sbellard  echo "#define CONFIG_FMOD 1" >> $config_h
542102a52e4Sbellardfi
54397a847bcSbellardecho -n "VERSION=" >>$config_mak
54497a847bcSbellardhead $source_path/VERSION >>$config_mak
54597a847bcSbellardecho "" >>$config_mak
54697a847bcSbellardecho -n "#define QEMU_VERSION \"" >> $config_h
54797a847bcSbellardhead $source_path/VERSION >> $config_h
54897a847bcSbellardecho "\"" >> $config_h
54997a847bcSbellard
550c9ec1fe4Sbellardif test $kqemu = "yes" ; then
551c9ec1fe4Sbellard  echo "CONFIG_KQEMU=yes" >> $config_mak
552c9ec1fe4Sbellard  echo "KERNEL_PATH=$kernel_path" >> $config_mak
553c9ec1fe4Sbellard  if test $kbuild26 = "yes" ; then
554c9ec1fe4Sbellard    echo "CONFIG_KBUILD26=yes" >> $config_mak
555c9ec1fe4Sbellard  fi
556c9ec1fe4Sbellardfi
55797a847bcSbellardecho "SRC_PATH=$source_path" >> $config_mak
55897a847bcSbellardecho "TARGET_DIRS=$target_list" >> $config_mak
55997a847bcSbellard
56083fb7adfSbellard# XXX: suppress that
5617d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
56243003046Sbellard  echo "#define O_LARGEFILE 0" >> $config_h
56343003046Sbellard  echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
5647d3505c5Sbellard  echo "#define _BSD 1" >> $config_h
5657d3505c5Sbellardfi
5667d3505c5Sbellard
56797a847bcSbellardfor target in $target_list; do
56897a847bcSbellard
56997a847bcSbellardtarget_dir="$target"
57097a847bcSbellardconfig_mak=$target_dir/config.mak
57197a847bcSbellardconfig_h=$target_dir/config.h
57297a847bcSbellardtarget_cpu=`echo $target | cut -d '-' -f 1`
57397a847bcSbellardtarget_bigendian="no"
574808c4954Sbellard[ "$target_cpu" = "armeb" ] && target_bigendian=yes
5751e43adfcSbellard[ "$target_cpu" = "sparc" ] && target_bigendian=yes
57664b3ab24Sbellard[ "$target_cpu" = "sparc64" ] && target_bigendian=yes
57767867308Sbellard[ "$target_cpu" = "ppc" ] && target_bigendian=yes
57897a847bcSbellardtarget_softmmu="no"
57997a847bcSbellardif expr $target : '.*-softmmu' > /dev/null ; then
58097a847bcSbellard  target_softmmu="yes"
5817d13299dSbellardfi
582997344f3Sbellardtarget_user_only="no"
583997344f3Sbellardif expr $target : '.*-user' > /dev/null ; then
584997344f3Sbellard  target_user_only="yes"
585997344f3Sbellardfi
586de83cd02Sbellard
5877c1f25b4Sbellard#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
58897a847bcSbellard
58997a847bcSbellardmkdir -p $target_dir
590808c4954Sbellardif test "$target" = "arm-user" -o "$target" = "armeb-user" ; then
59169de927cSbellard  mkdir -p $target_dir/nwfpe
59269de927cSbellardfi
593a7e61ed4Sbellardif test "$target_user_only" = "no" ; then
594a7e61ed4Sbellard  mkdir -p $target_dir/slirp
595a7e61ed4Sbellardfi
59669de927cSbellard
59797a847bcSbellardln -sf $source_path/Makefile.target $target_dir/Makefile
59897a847bcSbellard
59997a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
60097a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
60197a847bcSbellard
60297a847bcSbellard
60397a847bcSbellardecho "include ../config-host.mak" >> $config_mak
60497a847bcSbellardecho "#include \"../config-host.h\"" >> $config_h
6051e43adfcSbellard
6061e43adfcSbellardinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
6071e43adfcSbellardecho "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
60897a847bcSbellard
60997a847bcSbellardif test "$target_cpu" = "i386" ; then
61097a847bcSbellard  echo "TARGET_ARCH=i386" >> $config_mak
61197a847bcSbellard  echo "#define TARGET_ARCH \"i386\"" >> $config_h
61297a847bcSbellard  echo "#define TARGET_I386 1" >> $config_h
613824d560fSbellard  if test $kqemu = "yes" -a "$target_softmmu" = "yes" ; then
614824d560fSbellard    echo "#define USE_KQEMU 1" >> $config_h
615824d560fSbellard  fi
616808c4954Sbellardelif test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
61797a847bcSbellard  echo "TARGET_ARCH=arm" >> $config_mak
61897a847bcSbellard  echo "#define TARGET_ARCH \"arm\"" >> $config_h
61997a847bcSbellard  echo "#define TARGET_ARM 1" >> $config_h
6201e43adfcSbellardelif test "$target_cpu" = "sparc" ; then
6211e43adfcSbellard  echo "TARGET_ARCH=sparc" >> $config_mak
6221e43adfcSbellard  echo "#define TARGET_ARCH \"sparc\"" >> $config_h
6231e43adfcSbellard  echo "#define TARGET_SPARC 1" >> $config_h
62464b3ab24Sbellardelif test "$target_cpu" = "sparc64" ; then
62564b3ab24Sbellard  echo "TARGET_ARCH=sparc64" >> $config_mak
62664b3ab24Sbellard  echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
62764b3ab24Sbellard  echo "#define TARGET_SPARC 1" >> $config_h
62864b3ab24Sbellard  echo "#define TARGET_SPARC64 1" >> $config_h
62967867308Sbellardelif test "$target_cpu" = "ppc" ; then
63067867308Sbellard  echo "TARGET_ARCH=ppc" >> $config_mak
63167867308Sbellard  echo "#define TARGET_ARCH \"ppc\"" >> $config_h
63267867308Sbellard  echo "#define TARGET_PPC 1" >> $config_h
6330b0babc6Sbellardelif test "$target_cpu" = "x86_64" ; then
6340b0babc6Sbellard  echo "TARGET_ARCH=x86_64" >> $config_mak
6350b0babc6Sbellard  echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
6360b0babc6Sbellard  echo "#define TARGET_I386 1" >> $config_h
6370b0babc6Sbellard  echo "#define TARGET_X86_64 1" >> $config_h
638de83cd02Sbellardelse
639de83cd02Sbellard  echo "Unsupported target CPU"
640de83cd02Sbellard  exit 1
641de83cd02Sbellardfi
642de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
64397a847bcSbellard  echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
64497a847bcSbellard  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
64597a847bcSbellardfi
64697a847bcSbellardif test "$target_softmmu" = "yes" ; then
64797a847bcSbellard  echo "CONFIG_SOFTMMU=yes" >> $config_mak
64897a847bcSbellard  echo "#define CONFIG_SOFTMMU 1" >> $config_h
649de83cd02Sbellardfi
650997344f3Sbellardif test "$target_user_only" = "yes" ; then
651997344f3Sbellard  echo "CONFIG_USER_ONLY=yes" >> $config_mak
652997344f3Sbellard  echo "#define CONFIG_USER_ONLY 1" >> $config_h
653997344f3Sbellardfi
654de83cd02Sbellard
6557c1f25b4Sbellard# sdl defines
6567c1f25b4Sbellard
6577c1f25b4Sbellardif test "$target_user_only" = "no"; then
6587c1f25b4Sbellard    if test "$target_softmmu" = "no" -o "$static" = "yes"; then
659dbb2c921Sbellard        sdl1=$sdl_static
6607c1f25b4Sbellard    else
661dbb2c921Sbellard        sdl1=$sdl
662dbb2c921Sbellard    fi
663dbb2c921Sbellard    if test "$sdl1" = "yes" ; then
6647c1f25b4Sbellard        echo "#define CONFIG_SDL 1" >> $config_h
6657c1f25b4Sbellard        echo "CONFIG_SDL=yes" >> $config_mak
666dbb2c921Sbellard        if test "$target_softmmu" = "no" -o "$static" = "yes"; then
667dbb2c921Sbellard            echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
668dbb2c921Sbellard        else
6697c1f25b4Sbellard            echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
6707c1f25b4Sbellard        fi
6717c1f25b4Sbellard        echo -n "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
6727c1f25b4Sbellard        if [ "${aa}" = "yes" ] ; then
6737c1f25b4Sbellard            echo -n " `aalib-config --cflags`" >> $config_mak ;
6747c1f25b4Sbellard        fi
6757c1f25b4Sbellard        echo "" >> $config_mak
6767c1f25b4Sbellard    fi
677dbb2c921Sbellardfi
6787c1f25b4Sbellard
67997a847bcSbellarddone # for target in $targets
6807d13299dSbellard
6817d13299dSbellard# build tree in object directory if source path is different from current one
6827d13299dSbellardif test "$source_path_used" = "yes" ; then
6837d13299dSbellard    DIRS="tests"
6847d13299dSbellard    FILES="Makefile tests/Makefile"
6857d13299dSbellard    for dir in $DIRS ; do
6867d13299dSbellard            mkdir -p $dir
6877d13299dSbellard    done
6887d13299dSbellard    for f in $FILES ; do
6897d13299dSbellard        ln -sf $source_path/$f $f
6907d13299dSbellard    done
6917d13299dSbellardfi
6927d13299dSbellard
69397a847bcSbellardrm -f $TMPO $TMPC $TMPE $TMPS
694