xref: /openbmc/qemu/configure (revision 1026f1336b1121ff3215fcef703cbcfe63a488fd)
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  ;;
35ba68055eSbellard  armv*b)
36808c4954Sbellard    cpu="armv4b"
37808c4954Sbellard  ;;
38ba68055eSbellard  armv*l)
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=""
865b0753e0Sbellardcocoa="no"
877d13299dSbellard
887d13299dSbellard# OS specific
897d13299dSbellardtargetos=`uname -s`
907d13299dSbellardcase $targetos in
91c326e0afSbellardCYGWIN*)
92c326e0afSbellardmingw32="yes"
93c326e0afSbellardCFLAGS="-O2 -mno-cygwin"
94c326e0afSbellard;;
9567b915a5SbellardMINGW32*)
9667b915a5Sbellardmingw32="yes"
9767b915a5Sbellard;;
987d3505c5SbellardFreeBSD)
997d3505c5Sbellardbsd="yes"
100fb065187Sbellardoss="yes"
10107f4ddbfSbellardif [ "$cpu" = "i386" ] ; then
10207f4ddbfSbellard    kqemu="yes"
10307f4ddbfSbellardfi
1047d3505c5Sbellard;;
1057d3505c5SbellardNetBSD)
1067d3505c5Sbellardbsd="yes"
107fb065187Sbellardoss="yes"
1087d3505c5Sbellard;;
1097d3505c5SbellardOpenBSD)
1107d3505c5Sbellardbsd="yes"
111fb065187Sbellardoss="yes"
1127d3505c5Sbellard;;
11383fb7adfSbellardDarwin)
11483fb7adfSbellardbsd="yes"
11583fb7adfSbellarddarwin="yes"
11683fb7adfSbellard;;
117fb065187Sbellard*)
118fb065187Sbellardoss="yes"
1195327cf48Sbellardlinux="yes"
12007f4ddbfSbellardif [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
121c9ec1fe4Sbellard    kqemu="yes"
122c9ec1fe4Sbellardfi
123fb065187Sbellard;;
1247d13299dSbellardesac
1257d13299dSbellard
1267d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
12783fb7adfSbellard  if [ ! "$darwin" = "yes" ] ; then
1287d3505c5Sbellard    make="gmake"
12983fb7adfSbellard  fi
1307d3505c5Sbellardfi
1317d3505c5Sbellard
1327d13299dSbellard# find source path
1337d13299dSbellard# XXX: we assume an absolute path is given when launching configure,
1347d13299dSbellard# except in './configure' case.
1357d13299dSbellardsource_path=${0%configure}
1367d13299dSbellardsource_path=${source_path%/}
1377d13299dSbellardsource_path_used="yes"
1387d13299dSbellardif test -z "$source_path" -o "$source_path" = "." ; then
1397d13299dSbellard    source_path=`pwd`
1407d13299dSbellard    source_path_used="no"
1417d13299dSbellardfi
1427d13299dSbellard
1437d13299dSbellardfor opt do
1447d13299dSbellard  case "$opt" in
1457d13299dSbellard  --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
1467d13299dSbellard  ;;
14732ce6337Sbellard  --interp-prefix=*) interp_prefix=`echo $opt | cut -d '=' -f 2`
14832ce6337Sbellard  ;;
1497d13299dSbellard  --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
1507d13299dSbellard  ;;
1517d13299dSbellard  --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
1527d13299dSbellard  ;;
1537d13299dSbellard  --cc=*) cc=`echo $opt | cut -d '=' -f 2`
1547d13299dSbellard  ;;
1557d13299dSbellard  --make=*) make=`echo $opt | cut -d '=' -f 2`
1567d13299dSbellard  ;;
1577d13299dSbellard  --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
1587d13299dSbellard  ;;
1597d13299dSbellard  --extra-ldflags=*) LDFLAGS="${opt#--extra-ldflags=}"
1607d13299dSbellard  ;;
1617d13299dSbellard  --extra-libs=*) extralibs=${opt#--extra-libs=}
1627d13299dSbellard  ;;
1637d13299dSbellard  --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
1647d13299dSbellard  ;;
16597a847bcSbellard  --target-list=*) target_list=${opt#--target-list=}
166de83cd02Sbellard  ;;
1677d13299dSbellard  --enable-gprof) gprof="yes"
1687d13299dSbellard  ;;
16943ce4dfeSbellard  --static) static="yes"
17043ce4dfeSbellard  ;;
17197a847bcSbellard  --disable-sdl) sdl="no"
17297a847bcSbellard  ;;
173102a52e4Sbellard  --enable-fmod) fmod="yes"
174102a52e4Sbellard  ;;
175102a52e4Sbellard  --fmod-lib=*) fmod_lib=${opt#--fmod-lib=}
176102a52e4Sbellard  ;;
177102a52e4Sbellard  --fmod-inc=*) fmod_inc=${opt#--fmod-inc=}
178102a52e4Sbellard  ;;
17967b915a5Sbellard  --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
18067b915a5Sbellard  ;;
181443f1376Sbellard  --disable-slirp) slirp="no"
182c20709aaSbellard  ;;
183fb065187Sbellard  --enable-adlib) adlib="yes"
184fb065187Sbellard  ;;
185c9ec1fe4Sbellard  --disable-kqemu) kqemu="no"
186c9ec1fe4Sbellard  ;;
187c9ec1fe4Sbellard  --kernel-path=*) kernel_path=${opt#--kernel-path=}
188c9ec1fe4Sbellard  ;;
1895b0753e0Sbellard  --enable-cocoa) cocoa="yes" ; sdl="no"
1905b0753e0Sbellard  ;;
1917d13299dSbellard  esac
1927d13299dSbellarddone
1937d13299dSbellard
1947d13299dSbellard# Checking for CFLAGS
1957d13299dSbellardif test -z "$CFLAGS"; then
1967d13299dSbellard    CFLAGS="-O2"
1977d13299dSbellardfi
1987d13299dSbellard
1997d13299dSbellardcc="${cross_prefix}${cc}"
2007d13299dSbellardar="${cross_prefix}${ar}"
2017d13299dSbellardstrip="${cross_prefix}${strip}"
2027d13299dSbellard
20367b915a5Sbellardif test "$mingw32" = "yes" ; then
2045327cf48Sbellard    linux="no"
20567b915a5Sbellard    EXESUF=".exe"
20667b915a5Sbellard    gdbstub="no"
2079f059ecaSbellard    oss="no"
20807f4ddbfSbellard    if [ "$cpu" = "i386" ] ; then
20907f4ddbfSbellard        kqemu="yes"
21007f4ddbfSbellard    fi
21167b915a5Sbellardfi
21267b915a5Sbellard
2135327cf48Sbellardif test -z "$target_list" ; then
2145327cf48Sbellard# these targets are portable
215a20b5524Sbellard    target_list="i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu"
2165327cf48Sbellard# the following are Linux specific
2175327cf48Sbellard    if [ "$linux" = "yes" ] ; then
218a20b5524Sbellard        target_list="i386-user arm-user armeb-user sparc-user ppc-user $target_list"
2195327cf48Sbellard    fi
2205327cf48Sbellardfi
2215327cf48Sbellard
2227d13299dSbellardif test -z "$cross_prefix" ; then
2237d13299dSbellard
2247d13299dSbellard# ---
2257d13299dSbellard# big/little endian test
2267d13299dSbellardcat > $TMPC << EOF
2277d13299dSbellard#include <inttypes.h>
2287d13299dSbellardint main(int argc, char ** argv){
2297d13299dSbellard	volatile uint32_t i=0x01234567;
2307d13299dSbellard	return (*((uint8_t*)(&i))) == 0x67;
2317d13299dSbellard}
2327d13299dSbellardEOF
2337d13299dSbellard
2347d13299dSbellardif $cc -o $TMPE $TMPC 2>/dev/null ; then
2357d13299dSbellard$TMPE && bigendian="yes"
2367d13299dSbellardelse
2377d13299dSbellardecho big/little test failed
2387d13299dSbellardfi
2397d13299dSbellard
2407d13299dSbellardelse
2417d13299dSbellard
2427d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
243808c4954Sbellardif test "$cpu" = "powerpc" -o "$cpu" = "mips" -o "$cpu" = "s390" -o "$cpu" = "sparc" -o "$cpu" = "sparc64" -o "$cpu" = "m68k" -o "$cpu" = "armv4b"; then
2447d13299dSbellard    bigendian="yes"
2457d13299dSbellardfi
2467d13299dSbellard
2477d13299dSbellardfi
2487d13299dSbellard
249e8cd23deSbellard# check gcc options support
25004369ff2Sbellardcat > $TMPC <<EOF
25104369ff2Sbellardint main(void) {
25204369ff2Sbellard}
25304369ff2SbellardEOF
25404369ff2Sbellard
255e8cd23deSbellardhave_gcc3_options="no"
256e8cd23deSbellardif $cc -fno-reorder-blocks -fno-optimize-sibling-calls -o $TMPO $TMPC 2> /dev/null ; then
257e8cd23deSbellard   have_gcc3_options="yes"
25804369ff2Sbellardfi
259ca735206Sbellard
26011d9f695Sbellard##########################################
26111d9f695Sbellard# SDL probe
26211d9f695Sbellard
26311d9f695Sbellardsdl_too_old=no
26411d9f695Sbellard
26511d9f695Sbellardif test -z "$sdl" ; then
26611d9f695Sbellard
267a6e022adSbellardsdl_config="sdl-config"
268a6e022adSbellardsdl=no
2697c1f25b4Sbellardsdl_static=no
270a6e022adSbellard
271a6e022adSbellardif test "$mingw32" = "yes" -a ! -z "$cross_prefix" ; then
272a6e022adSbellard# win32 cross compilation case
273a6e022adSbellard    sdl_config="i386-mingw32msvc-sdl-config"
274a6e022adSbellard    sdl=yes
275a6e022adSbellardelse
276a6e022adSbellard# normal SDL probe
27711d9f695Sbellardcat > $TMPC << EOF
27811d9f695Sbellard#include <SDL.h>
27911d9f695Sbellard#undef main /* We don't want SDL to override our main() */
28011d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
28111d9f695SbellardEOF
28211d9f695Sbellard
283a6e022adSbellardif $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then
284a6e022adSbellard_sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
28511d9f695Sbellardif test "$_sdlversion" -lt 121 ; then
28611d9f695Sbellardsdl_too_old=yes
28711d9f695Sbellardelse
28811d9f695Sbellardsdl=yes
28911d9f695Sbellardfi
2907c1f25b4Sbellard
2917c1f25b4Sbellard# static link with sdl ?
2927c1f25b4Sbellardif test "$sdl" = "yes" ; then
2937c1f25b4Sbellardaa="no"
2947c1f25b4Sbellard`$sdl_config --static-libs | grep \\\-laa > /dev/null` && aa="yes"
2957c1f25b4Sbellardsdl_static_libs=`$sdl_config --static-libs`
2967c1f25b4Sbellardif [ "$aa" = "yes" ] ; then
297d8d8aa4eSbellard  sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
29811d9f695Sbellardfi
29911d9f695Sbellard
3007c1f25b4Sbellardif $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs 2> /dev/null; then
3017c1f25b4Sbellard  sdl_static=yes
3027c1f25b4Sbellardfi
3037c1f25b4Sbellard
3047c1f25b4Sbellardfi # static link
3057c1f25b4Sbellard
3067c1f25b4Sbellardfi # sdl compile test
3077c1f25b4Sbellard
308a6e022adSbellardfi # cross compilation
309a6e022adSbellardfi # -z $sdl
31011d9f695Sbellard
3117d13299dSbellardif test x"$1" = x"-h" -o x"$1" = x"--help" ; then
3127d13299dSbellardcat << EOF
3137d13299dSbellard
3147d13299dSbellardUsage: configure [options]
3157d13299dSbellardOptions: [defaults in brackets after descriptions]
3167d13299dSbellard
3177d13299dSbellardEOF
3187d13299dSbellardecho "Standard options:"
3197d13299dSbellardecho "  --help                   print this message"
3207d13299dSbellardecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
3211e43adfcSbellardecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
3221e43adfcSbellardecho "                           use %M for cpu name [$interp_prefix]"
32397a847bcSbellardecho "  --target-list=LIST       set target list [$target_list]"
3247d13299dSbellardecho ""
325c9ec1fe4Sbellardecho "kqemu kernel acceleration support:"
326c9ec1fe4Sbellardecho "  --disable-kqemu          disable kqemu build"
327c9ec1fe4Sbellardecho "  --kernel-path=PATH       set the kernel path (configure probes it)"
328c9ec1fe4Sbellardecho ""
3297d13299dSbellardecho "Advanced options (experts only):"
3307d13299dSbellardecho "  --source-path=PATH       path of source code [$source_path]"
3317d13299dSbellardecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
3327d13299dSbellardecho "  --cc=CC                  use C compiler CC [$cc]"
3337d13299dSbellardecho "  --make=MAKE              use specified make [$make]"
33443ce4dfeSbellardecho "  --static                 enable static build [$static]"
33567b915a5Sbellardecho "  --enable-mingw32         enable Win32 cross compilation with mingw32"
336102a52e4Sbellardecho "  --enable-fmod            enable FMOD audio output driver"
337102a52e4Sbellardecho "  --fmod-lib               path to FMOD library"
338102a52e4Sbellardecho "  --fmod-inc               path to FMOD includes"
3397d13299dSbellardecho ""
3407d13299dSbellardecho "NOTE: The object files are build at the place where configure is launched"
3417d13299dSbellardexit 1
3427d13299dSbellardfi
3437d13299dSbellard
34411d9f695Sbellardif test "$mingw32" = "yes" ; then
34511d9f695Sbellardif test -z "$prefix" ; then
34611d9f695Sbellard    prefix="/c/Program Files/Qemu"
34711d9f695Sbellardfi
34811d9f695Sbellardmandir="$prefix"
3497efa4387Sbellarddatadir="$prefix"
3501f50f8d1Sbellarddocdir="$prefix"
35111d9f695Sbellardbindir="$prefix"
35211d9f695Sbellardelse
35311d9f695Sbellardif test -z "$prefix" ; then
35411d9f695Sbellard    prefix="/usr/local"
35511d9f695Sbellardfi
3565a67135aSbellardmandir="$prefix/share/man"
3577efa4387Sbellarddatadir="$prefix/share/qemu"
3581f50f8d1Sbellarddocdir="$prefix/share/doc/qemu"
35911d9f695Sbellardbindir="$prefix/bin"
36011d9f695Sbellardfi
3615a67135aSbellard
36207f4ddbfSbellard# kqemu support
363c9ec1fe4Sbellardif test $kqemu = "yes" ; then
364441c72baSbellard    # test if the source code is installed
365441c72baSbellard    if test '!' -f "kqemu/Makefile" ; then
366441c72baSbellard        kqemu="no"
367441c72baSbellard    fi
368441c72baSbellardfi
369441c72baSbellard
37007f4ddbfSbellard# Linux specific kqemu configuration
37107f4ddbfSbellardif test $kqemu = "yes" -a $linux = "yes" ; then
372c9ec1fe4Sbellard# find the kernel path
373c9ec1fe4Sbellardif test -z "$kernel_path" ; then
374c9ec1fe4Sbellardkernel_version=`uname -r`
375c9ec1fe4Sbellardkernel_path="/lib/modules/$kernel_version/build"
376c9ec1fe4Sbellardif test '!' -d "$kernel_path/include" ; then
377c9ec1fe4Sbellard    kernel_path="/usr/src/linux"
378c9ec1fe4Sbellard    if test '!' -d "$kernel_path/include" ; then
379c9ec1fe4Sbellard        echo "Could not find kernel includes in /lib/modules or /usr/src/linux - cannot build the kqemu module"
380c9ec1fe4Sbellard        kqemu="no"
381c9ec1fe4Sbellard    fi
382c9ec1fe4Sbellardfi
383c9ec1fe4Sbellardfi
384c9ec1fe4Sbellard
385c9ec1fe4Sbellardif test $kqemu = "yes" ; then
386c9ec1fe4Sbellard
387c9ec1fe4Sbellard# test that the kernel config is present
388c9ec1fe4Sbellardif test '!' -f "$kernel_path/Makefile" ; then
389f94daeddSbellard    echo "No Makefile file present in $kernel_path - kqemu cannot be built"
390c9ec1fe4Sbellard    kqemu="no"
391c9ec1fe4Sbellardfi
392c9ec1fe4Sbellard
393c9ec1fe4Sbellard# find build system (2.6 or legacy)
394c9ec1fe4Sbellardkbuild26="yes"
395c9ec1fe4Sbellardif grep -q "PATCHLEVEL = 4" $kernel_path/Makefile ; then
396c9ec1fe4Sbellardkbuild26="no"
397c9ec1fe4Sbellardfi
398c9ec1fe4Sbellard
399c9ec1fe4Sbellardfi # kqemu
400c9ec1fe4Sbellard
40107f4ddbfSbellardfi # kqemu and linux
402c9ec1fe4Sbellard
403c9ec1fe4Sbellard
4047d13299dSbellardecho "Install prefix    $prefix"
4057efa4387Sbellardecho "BIOS directory    $datadir"
40611d9f695Sbellardecho "binary directory  $bindir"
40711d9f695Sbellardif test "$mingw32" = "no" ; then
40811d9f695Sbellardecho "Manual directory  $mandir"
40943ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
41011d9f695Sbellardfi
4115a67135aSbellardecho "Source path       $source_path"
4127d13299dSbellardecho "C compiler        $cc"
4137d13299dSbellardecho "make              $make"
414a98fd896Sbellardecho "host CPU          $cpu"
415de83cd02Sbellardecho "host big endian   $bigendian"
41697a847bcSbellardecho "target list       $target_list"
4177d13299dSbellardecho "gprof enabled     $gprof"
41843ce4dfeSbellardecho "static build      $static"
4195b0753e0Sbellardif test "$darwin" = "yes" ; then
4205b0753e0Sbellard    echo "Cocoa support     $cocoa"
4215b0753e0Sbellardfi
42297a847bcSbellardecho "SDL support       $sdl"
4237c1f25b4Sbellardecho "SDL static link   $sdl_static"
42467b915a5Sbellardecho "mingw32 support   $mingw32"
425fb065187Sbellardecho "Adlib support     $adlib"
426102a52e4Sbellardecho -n "FMOD support      $fmod"
427102a52e4Sbellardif test $fmod = "yes"; then
428102a52e4Sbellard    echo -n " (lib='$fmod_lib' include='$fmod_inc')"
429102a52e4Sbellardfi
430102a52e4Sbellardecho ""
43107f4ddbfSbellardecho "kqemu support     $kqemu"
43207f4ddbfSbellardif test $kqemu = "yes" -a $linux = "yes" ; then
433c9ec1fe4Sbellardecho ""
43407f4ddbfSbellardecho "KQEMU Linux module configuration:"
435c9ec1fe4Sbellardecho "kernel sources    $kernel_path"
436c9ec1fe4Sbellardecho -n "kbuild type       "
437c9ec1fe4Sbellardif test $kbuild26 = "yes"; then
438c9ec1fe4Sbellardecho "2.6"
439c9ec1fe4Sbellardelse
440c9ec1fe4Sbellardecho "2.4"
441c9ec1fe4Sbellardfi
442c9ec1fe4Sbellardfi
44367b915a5Sbellard
44497a847bcSbellardif test $sdl_too_old = "yes"; then
44524b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
446e8cd23deSbellardfi
44724b55b96Sbellard#if test "$sdl_static" = "no"; then
44824b55b96Sbellard#  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
44924b55b96Sbellard#fi
45097a847bcSbellard
45197a847bcSbellardconfig_mak="config-host.mak"
45297a847bcSbellardconfig_h="config-host.h"
45397a847bcSbellard
4547c1f25b4Sbellard#echo "Creating $config_mak and $config_h"
45597a847bcSbellard
45697a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
45797a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
45897a847bcSbellard
45997a847bcSbellardecho "prefix=$prefix" >> $config_mak
46011d9f695Sbellardecho "bindir=$bindir" >> $config_mak
4615a67135aSbellardecho "mandir=$mandir" >> $config_mak
4627efa4387Sbellardecho "datadir=$datadir" >> $config_mak
4631f50f8d1Sbellardecho "docdir=$docdir" >> $config_mak
4647efa4387Sbellardecho "#define CONFIG_QEMU_SHAREDIR \"$datadir\"" >> $config_h
46597a847bcSbellardecho "MAKE=$make" >> $config_mak
46697a847bcSbellardecho "CC=$cc" >> $config_mak
46797a847bcSbellardif test "$have_gcc3_options" = "yes" ; then
46897a847bcSbellard  echo "HAVE_GCC3_OPTIONS=yes" >> $config_mak
46997a847bcSbellardfi
47097a847bcSbellardecho "HOST_CC=$host_cc" >> $config_mak
47197a847bcSbellardecho "AR=$ar" >> $config_mak
47297a847bcSbellardecho "STRIP=$strip -s -R .comment -R .note" >> $config_mak
47397a847bcSbellardecho "CFLAGS=$CFLAGS" >> $config_mak
47497a847bcSbellardecho "LDFLAGS=$LDFLAGS" >> $config_mak
47567b915a5Sbellardecho "EXESUF=$EXESUF" >> $config_mak
47697a847bcSbellardif test "$cpu" = "i386" ; then
47797a847bcSbellard  echo "ARCH=i386" >> $config_mak
47897a847bcSbellard  echo "#define HOST_I386 1" >> $config_h
4790b0babc6Sbellardelif test "$cpu" = "x86_64" ; then
4800b0babc6Sbellard  echo "ARCH=x86_64" >> $config_mak
4810b0babc6Sbellard  echo "#define HOST_X86_64 1" >> $config_h
482808c4954Sbellardelif test "$cpu" = "armv4b" ; then
483808c4954Sbellard  echo "ARCH=arm" >> $config_mak
484808c4954Sbellard  echo "#define HOST_ARM 1" >> $config_h
4857d13299dSbellardelif test "$cpu" = "armv4l" ; then
48697a847bcSbellard  echo "ARCH=arm" >> $config_mak
48797a847bcSbellard  echo "#define HOST_ARM 1" >> $config_h
4887d13299dSbellardelif test "$cpu" = "powerpc" ; then
48997a847bcSbellard  echo "ARCH=ppc" >> $config_mak
49097a847bcSbellard  echo "#define HOST_PPC 1" >> $config_h
4917d13299dSbellardelif test "$cpu" = "mips" ; then
49297a847bcSbellard  echo "ARCH=mips" >> $config_mak
49397a847bcSbellard  echo "#define HOST_MIPS 1" >> $config_h
494fb3e5849Sbellardelif test "$cpu" = "s390" ; then
49597a847bcSbellard  echo "ARCH=s390" >> $config_mak
49697a847bcSbellard  echo "#define HOST_S390 1" >> $config_h
497295defa5Sbellardelif test "$cpu" = "alpha" ; then
49897a847bcSbellard  echo "ARCH=alpha" >> $config_mak
49997a847bcSbellard  echo "#define HOST_ALPHA 1" >> $config_h
500ae228531Sbellardelif test "$cpu" = "sparc" ; then
50197a847bcSbellard  echo "ARCH=sparc" >> $config_mak
50297a847bcSbellard  echo "#define HOST_SPARC 1" >> $config_h
503ae228531Sbellardelif test "$cpu" = "sparc64" ; then
50497a847bcSbellard  echo "ARCH=sparc64" >> $config_mak
50597a847bcSbellard  echo "#define HOST_SPARC64 1" >> $config_h
506a8baa8c5Sbellardelif test "$cpu" = "ia64" ; then
50797a847bcSbellard  echo "ARCH=ia64" >> $config_mak
50897a847bcSbellard  echo "#define HOST_IA64 1" >> $config_h
50938e584a0Sbellardelif test "$cpu" = "m68k" ; then
51038ca2abcSbellard  echo "ARCH=m68k" >> $config_mak
51138ca2abcSbellard  echo "#define HOST_M68K 1" >> $config_h
5127d13299dSbellardelse
5137d13299dSbellard  echo "Unsupported CPU"
5147d13299dSbellard  exit 1
5157d13299dSbellardfi
5167d13299dSbellardif test "$bigendian" = "yes" ; then
51797a847bcSbellard  echo "WORDS_BIGENDIAN=yes" >> $config_mak
51897a847bcSbellard  echo "#define WORDS_BIGENDIAN 1" >> $config_h
51997a847bcSbellardfi
52067b915a5Sbellardif test "$mingw32" = "yes" ; then
52167b915a5Sbellard  echo "CONFIG_WIN32=yes" >> $config_mak
52211d9f695Sbellard  echo "#define CONFIG_WIN32 1" >> $config_h
5237d3505c5Sbellardelif test -f "/usr/include/byteswap.h" ; then
52497a847bcSbellard  echo "#define HAVE_BYTESWAP_H 1" >> $config_h
52567b915a5Sbellardfi
52683fb7adfSbellardif test "$darwin" = "yes" ; then
52783fb7adfSbellard  echo "CONFIG_DARWIN=yes" >> $config_mak
52883fb7adfSbellard  echo "#define CONFIG_DARWIN 1" >> $config_h
52983fb7adfSbellardfi
53067b915a5Sbellardif test "$gdbstub" = "yes" ; then
53167b915a5Sbellard  echo "CONFIG_GDBSTUB=yes" >> $config_mak
53267b915a5Sbellard  echo "#define CONFIG_GDBSTUB 1" >> $config_h
53367b915a5Sbellardfi
53497a847bcSbellardif test "$gprof" = "yes" ; then
53597a847bcSbellard  echo "TARGET_GPROF=yes" >> $config_mak
53697a847bcSbellard  echo "#define HAVE_GPROF 1" >> $config_h
53797a847bcSbellardfi
53897a847bcSbellardif test "$static" = "yes" ; then
53997a847bcSbellard  echo "CONFIG_STATIC=yes" >> $config_mak
54050863472Sbellard  echo "#define CONFIG_STATIC 1" >> $config_h
54197a847bcSbellardfi
542c20709aaSbellardif test "$slirp" = "yes" ; then
543c20709aaSbellard  echo "CONFIG_SLIRP=yes" >> $config_mak
544c20709aaSbellard  echo "#define CONFIG_SLIRP 1" >> $config_h
545c20709aaSbellardfi
546fb065187Sbellardif test "$adlib" = "yes" ; then
547fb065187Sbellard  echo "CONFIG_ADLIB=yes" >> $config_mak
548fb065187Sbellard  echo "#define CONFIG_ADLIB 1" >> $config_h
549fb065187Sbellardfi
550fb065187Sbellardif test "$oss" = "yes" ; then
551fb065187Sbellard  echo "CONFIG_OSS=yes" >> $config_mak
552fb065187Sbellard  echo "#define CONFIG_OSS 1" >> $config_h
553fb065187Sbellardfi
554102a52e4Sbellardif test "$fmod" = "yes" ; then
555102a52e4Sbellard  echo "CONFIG_FMOD=yes" >> $config_mak
556102a52e4Sbellard  echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
557102a52e4Sbellard  echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
558102a52e4Sbellard  echo "#define CONFIG_FMOD 1" >> $config_h
559102a52e4Sbellardfi
56097a847bcSbellardecho -n "VERSION=" >>$config_mak
56197a847bcSbellardhead $source_path/VERSION >>$config_mak
56297a847bcSbellardecho "" >>$config_mak
56397a847bcSbellardecho -n "#define QEMU_VERSION \"" >> $config_h
56497a847bcSbellardhead $source_path/VERSION >> $config_h
56597a847bcSbellardecho "\"" >> $config_h
56697a847bcSbellard
567c9ec1fe4Sbellardif test $kqemu = "yes" ; then
568c9ec1fe4Sbellard  echo "CONFIG_KQEMU=yes" >> $config_mak
569*1026f133Sbellard  if test $linux = "yes" ; then
570c9ec1fe4Sbellard    echo "KERNEL_PATH=$kernel_path" >> $config_mak
571c9ec1fe4Sbellard    if test $kbuild26 = "yes" ; then
572c9ec1fe4Sbellard      echo "CONFIG_KBUILD26=yes" >> $config_mak
573c9ec1fe4Sbellard    fi
574c9ec1fe4Sbellard  fi
575*1026f133Sbellardfi
57697a847bcSbellardecho "SRC_PATH=$source_path" >> $config_mak
57797a847bcSbellardecho "TARGET_DIRS=$target_list" >> $config_mak
57897a847bcSbellard
57983fb7adfSbellard# XXX: suppress that
5807d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
58143003046Sbellard  echo "#define O_LARGEFILE 0" >> $config_h
58243003046Sbellard  echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
5837d3505c5Sbellard  echo "#define _BSD 1" >> $config_h
5847d3505c5Sbellardfi
5857d3505c5Sbellard
58697a847bcSbellardfor target in $target_list; do
58797a847bcSbellard
58897a847bcSbellardtarget_dir="$target"
58997a847bcSbellardconfig_mak=$target_dir/config.mak
59097a847bcSbellardconfig_h=$target_dir/config.h
59197a847bcSbellardtarget_cpu=`echo $target | cut -d '-' -f 1`
59297a847bcSbellardtarget_bigendian="no"
593808c4954Sbellard[ "$target_cpu" = "armeb" ] && target_bigendian=yes
5941e43adfcSbellard[ "$target_cpu" = "sparc" ] && target_bigendian=yes
59564b3ab24Sbellard[ "$target_cpu" = "sparc64" ] && target_bigendian=yes
59667867308Sbellard[ "$target_cpu" = "ppc" ] && target_bigendian=yes
59797a847bcSbellardtarget_softmmu="no"
59897a847bcSbellardif expr $target : '.*-softmmu' > /dev/null ; then
59997a847bcSbellard  target_softmmu="yes"
6007d13299dSbellardfi
601997344f3Sbellardtarget_user_only="no"
602997344f3Sbellardif expr $target : '.*-user' > /dev/null ; then
603997344f3Sbellard  target_user_only="yes"
604997344f3Sbellardfi
605de83cd02Sbellard
6067c1f25b4Sbellard#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
60797a847bcSbellard
60897a847bcSbellardmkdir -p $target_dir
609158142c2Sbellardmkdir -p $target_dir/fpu
610808c4954Sbellardif test "$target" = "arm-user" -o "$target" = "armeb-user" ; then
61169de927cSbellard  mkdir -p $target_dir/nwfpe
61269de927cSbellardfi
613a7e61ed4Sbellardif test "$target_user_only" = "no" ; then
614a7e61ed4Sbellard  mkdir -p $target_dir/slirp
615a7e61ed4Sbellardfi
61669de927cSbellard
61797a847bcSbellardln -sf $source_path/Makefile.target $target_dir/Makefile
61897a847bcSbellard
61997a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
62097a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
62197a847bcSbellard
62297a847bcSbellard
62397a847bcSbellardecho "include ../config-host.mak" >> $config_mak
62497a847bcSbellardecho "#include \"../config-host.h\"" >> $config_h
6251e43adfcSbellard
6261e43adfcSbellardinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
6271e43adfcSbellardecho "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
62897a847bcSbellard
62997a847bcSbellardif test "$target_cpu" = "i386" ; then
63097a847bcSbellard  echo "TARGET_ARCH=i386" >> $config_mak
63197a847bcSbellard  echo "#define TARGET_ARCH \"i386\"" >> $config_h
63297a847bcSbellard  echo "#define TARGET_I386 1" >> $config_h
63307f4ddbfSbellard  if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "i386" ; then
634824d560fSbellard    echo "#define USE_KQEMU 1" >> $config_h
635824d560fSbellard  fi
636808c4954Sbellardelif test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
63797a847bcSbellard  echo "TARGET_ARCH=arm" >> $config_mak
63897a847bcSbellard  echo "#define TARGET_ARCH \"arm\"" >> $config_h
63997a847bcSbellard  echo "#define TARGET_ARM 1" >> $config_h
6401e43adfcSbellardelif test "$target_cpu" = "sparc" ; then
6411e43adfcSbellard  echo "TARGET_ARCH=sparc" >> $config_mak
6421e43adfcSbellard  echo "#define TARGET_ARCH \"sparc\"" >> $config_h
6431e43adfcSbellard  echo "#define TARGET_SPARC 1" >> $config_h
64464b3ab24Sbellardelif test "$target_cpu" = "sparc64" ; then
64564b3ab24Sbellard  echo "TARGET_ARCH=sparc64" >> $config_mak
64664b3ab24Sbellard  echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
64764b3ab24Sbellard  echo "#define TARGET_SPARC 1" >> $config_h
64864b3ab24Sbellard  echo "#define TARGET_SPARC64 1" >> $config_h
64967867308Sbellardelif test "$target_cpu" = "ppc" ; then
65067867308Sbellard  echo "TARGET_ARCH=ppc" >> $config_mak
65167867308Sbellard  echo "#define TARGET_ARCH \"ppc\"" >> $config_h
65267867308Sbellard  echo "#define TARGET_PPC 1" >> $config_h
6530b0babc6Sbellardelif test "$target_cpu" = "x86_64" ; then
6540b0babc6Sbellard  echo "TARGET_ARCH=x86_64" >> $config_mak
6550b0babc6Sbellard  echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
6560b0babc6Sbellard  echo "#define TARGET_I386 1" >> $config_h
6570b0babc6Sbellard  echo "#define TARGET_X86_64 1" >> $config_h
65807f4ddbfSbellard  if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"  ; then
65907f4ddbfSbellard    echo "#define USE_KQEMU 1" >> $config_h
66007f4ddbfSbellard  fi
661de83cd02Sbellardelse
662de83cd02Sbellard  echo "Unsupported target CPU"
663de83cd02Sbellard  exit 1
664de83cd02Sbellardfi
665de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
66697a847bcSbellard  echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
66797a847bcSbellard  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
66897a847bcSbellardfi
66997a847bcSbellardif test "$target_softmmu" = "yes" ; then
67097a847bcSbellard  echo "CONFIG_SOFTMMU=yes" >> $config_mak
67197a847bcSbellard  echo "#define CONFIG_SOFTMMU 1" >> $config_h
672de83cd02Sbellardfi
673997344f3Sbellardif test "$target_user_only" = "yes" ; then
674997344f3Sbellard  echo "CONFIG_USER_ONLY=yes" >> $config_mak
675997344f3Sbellard  echo "#define CONFIG_USER_ONLY 1" >> $config_h
676997344f3Sbellardfi
677de83cd02Sbellard
678158142c2Sbellardif test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
679158142c2Sbellard  echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
680158142c2Sbellard  echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
681158142c2Sbellardfi
6827c1f25b4Sbellard# sdl defines
6837c1f25b4Sbellard
6847c1f25b4Sbellardif test "$target_user_only" = "no"; then
6857c1f25b4Sbellard    if test "$target_softmmu" = "no" -o "$static" = "yes"; then
686dbb2c921Sbellard        sdl1=$sdl_static
6877c1f25b4Sbellard    else
688dbb2c921Sbellard        sdl1=$sdl
689dbb2c921Sbellard    fi
690dbb2c921Sbellard    if test "$sdl1" = "yes" ; then
6917c1f25b4Sbellard        echo "#define CONFIG_SDL 1" >> $config_h
6927c1f25b4Sbellard        echo "CONFIG_SDL=yes" >> $config_mak
693dbb2c921Sbellard        if test "$target_softmmu" = "no" -o "$static" = "yes"; then
694dbb2c921Sbellard            echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
695dbb2c921Sbellard        else
6967c1f25b4Sbellard            echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
6977c1f25b4Sbellard        fi
6987c1f25b4Sbellard        echo -n "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
6997c1f25b4Sbellard        if [ "${aa}" = "yes" ] ; then
7007c1f25b4Sbellard            echo -n " `aalib-config --cflags`" >> $config_mak ;
7017c1f25b4Sbellard        fi
7027c1f25b4Sbellard        echo "" >> $config_mak
7037c1f25b4Sbellard    fi
704dbb2c921Sbellardfi
7057c1f25b4Sbellard
7065b0753e0Sbellardif test "$cocoa" = "yes" ; then
7075b0753e0Sbellard    echo "#define CONFIG_COCOA 1" >> $config_h
7085b0753e0Sbellard    echo "CONFIG_COCOA=yes" >> $config_mak
7095b0753e0Sbellardfi
7105b0753e0Sbellard
71197a847bcSbellarddone # for target in $targets
7127d13299dSbellard
7137d13299dSbellard# build tree in object directory if source path is different from current one
7147d13299dSbellardif test "$source_path_used" = "yes" ; then
7157d13299dSbellard    DIRS="tests"
7167d13299dSbellard    FILES="Makefile tests/Makefile"
7177d13299dSbellard    for dir in $DIRS ; do
7187d13299dSbellard            mkdir -p $dir
7197d13299dSbellard    done
7207d13299dSbellard    for f in $FILES ; do
7217d13299dSbellard        ln -sf $source_path/$f $f
7227d13299dSbellard    done
7237d13299dSbellardfi
7247d13299dSbellard
72597a847bcSbellardrm -f $TMPO $TMPC $TMPE $TMPS
726