xref: /qemu/configure (revision ac0df51d7b3e0a76923a03efa2cfdec4b9f65ef5)
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"
189d56d2dcSmalcTMPI="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.i"
19d4742de8SmalcTMPSDLLOG="${TMPDIR1}/qemu-conf-sdl-$$-${RANDOM}.log"
207d13299dSbellard
21d4742de8Smalctrap "rm -f $TMPC $TMPO $TMPE $TMPS $TMPI $TMPSDLLOG; exit" 0 2 3 15
229ac81bbbSmalc
237d13299dSbellard# default parameters
2411d9f695Sbellardprefix=""
251e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
2643ce4dfeSbellardstatic="no"
277d13299dSbellardcross_prefix=""
287d13299dSbellardcc="gcc"
290c58ac1cSmalcaudio_drv_list=""
300c58ac1cSmalcaudio_card_list=""
317d13299dSbellardhost_cc="gcc"
327d13299dSbellardar="ar"
337d13299dSbellardmake="make"
346a882643Spbrookinstall="install"
357d13299dSbellardstrip="strip"
36*ac0df51dSaliguori
37*ac0df51dSaliguori# parse CC options first
38*ac0df51dSaliguorifor opt do
39*ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
40*ac0df51dSaliguori  case "$opt" in
41*ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
42*ac0df51dSaliguori  ;;
43*ac0df51dSaliguori  --cc=*) cc="$optarg"
44*ac0df51dSaliguori  ;;
45*ac0df51dSaliguori  esac
46*ac0df51dSaliguoridone
47*ac0df51dSaliguori
48*ac0df51dSaliguori# OS specific
49*ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
50*ac0df51dSaliguori# we can eliminate it's usage altogether
51*ac0df51dSaliguori
52*ac0df51dSaliguoricc="${cross_prefix}${cc}"
53*ac0df51dSaliguoriar="${cross_prefix}${ar}"
54*ac0df51dSaliguoristrip="${cross_prefix}${strip}"
55*ac0df51dSaliguori
56*ac0df51dSaliguori# check that the C compiler works.
57*ac0df51dSaliguoricat > $TMPC <<EOF
58*ac0df51dSaliguoriint main(void) {}
59*ac0df51dSaliguoriEOF
60*ac0df51dSaliguori
61*ac0df51dSaliguoriif $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
62*ac0df51dSaliguori  : C compiler works ok
63*ac0df51dSaliguorielse
64*ac0df51dSaliguori    echo "ERROR: \"$cc\" either does not exist or does not work"
65*ac0df51dSaliguori    exit 1
66*ac0df51dSaliguorifi
67*ac0df51dSaliguori
68*ac0df51dSaliguoricheck_define() {
69*ac0df51dSaliguoricat > $TMPC <<EOF
70*ac0df51dSaliguori#if !defined($1)
71*ac0df51dSaliguori#error Not defined
72*ac0df51dSaliguori#endif
73*ac0df51dSaliguoriint main(void) { return 0; }
74*ac0df51dSaliguoriEOF
75*ac0df51dSaliguori  $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
76*ac0df51dSaliguori}
77*ac0df51dSaliguori
78*ac0df51dSaliguoriif check_define __i386__ ; then
79*ac0df51dSaliguori  cpu="i386"
80*ac0df51dSaliguorielif check_define __x86_64__ ; then
81*ac0df51dSaliguori  cpu="x86_64"
82*ac0df51dSaliguorielse
83b29fe3edSmalc  cpu=`test $(uname -s) = AIX && uname -p || uname -m`
84*ac0df51dSaliguorifi
85*ac0df51dSaliguori
865327cf48Sbellardtarget_list=""
877d13299dSbellardcase "$cpu" in
887d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
8997a847bcSbellard    cpu="i386"
907d13299dSbellard  ;;
91aaa5fa14Saurel32  x86_64|amd64)
92aaa5fa14Saurel32    cpu="x86_64"
93aaa5fa14Saurel32  ;;
94aaa5fa14Saurel32  alpha)
95aaa5fa14Saurel32    cpu="alpha"
96aaa5fa14Saurel32  ;;
97ba68055eSbellard  armv*b)
98808c4954Sbellard    cpu="armv4b"
99808c4954Sbellard  ;;
100ba68055eSbellard  armv*l)
1017d13299dSbellard    cpu="armv4l"
1027d13299dSbellard  ;;
103aaa5fa14Saurel32  cris)
104aaa5fa14Saurel32    cpu="cris"
1057d13299dSbellard  ;;
106f54b3f92Saurel32  parisc|parisc64)
107f54b3f92Saurel32    cpu="hppa"
108f54b3f92Saurel32  ;;
109aaa5fa14Saurel32  ia64)
110aaa5fa14Saurel32    cpu="ia64"
111aaa5fa14Saurel32  ;;
112aaa5fa14Saurel32  m68k)
113aaa5fa14Saurel32    cpu="m68k"
1147d13299dSbellard  ;;
1157d13299dSbellard  mips)
1167d13299dSbellard    cpu="mips"
1177d13299dSbellard  ;;
118fbe4f65bSths  mips64)
119fbe4f65bSths    cpu="mips64"
120fbe4f65bSths  ;;
121b29fe3edSmalc  "Power Macintosh"|ppc|ppc64|powerpc)
122aaa5fa14Saurel32    cpu="powerpc"
123e7daa605Sths  ;;
1240e7b8a9fSths  s390*)
125fb3e5849Sbellard    cpu="s390"
126fb3e5849Sbellard  ;;
1273142255cSblueswir1  sparc|sun4[cdmuv])
128ae228531Sbellard    cpu="sparc"
129ae228531Sbellard  ;;
130ae228531Sbellard  sparc64)
131ae228531Sbellard    cpu="sparc64"
132ae228531Sbellard  ;;
1337d13299dSbellard  *)
1347d13299dSbellard    cpu="unknown"
1357d13299dSbellard  ;;
1367d13299dSbellardesac
1377d13299dSbellardgprof="no"
13803b4fe7dSaliguorisparse="no"
1397d13299dSbellardbigendian="no"
14067b915a5Sbellardmingw32="no"
14167b915a5SbellardEXESUF=""
14267b915a5Sbellardgdbstub="yes"
143443f1376Sbellardslirp="yes"
144e0e6c8c0Saliguorivde="yes"
145102a52e4Sbellardfmod_lib=""
146102a52e4Sbellardfmod_inc=""
1472f6a1ab0Sblueswir1oss_lib=""
1488d5d2d4cSthsvnc_tls="yes"
149b1a550a0Spbrookbsd="no"
1505327cf48Sbellardlinux="no"
151d2c7c9b8Sblueswir1solaris="no"
152c9ec1fe4Sbellardkqemu="no"
15305c2a3e7Sbellardprofiler="no"
1545b0753e0Sbellardcocoa="no"
15597ccc689Sbellardcheck_gfx="yes"
1560a8e90f4Spbrooksoftmmu="yes"
157831b7825Sthslinux_user="no"
158831b7825Sthsdarwin_user="no"
15984778508Sblueswir1bsd_user="no"
160cc8ae6deSpbrookbuild_docs="no"
161c5937220Spbrookuname_release=""
1624d3b6f6eSbalrogcurses="yes"
163414f0dabSblueswir1aio="yes"
164bd0c5661Spbrooknptl="yes"
1658ff9cbf7Smalcmixemu="no"
166fb599c9aSbalrogbluez="yes"
1677ba1e619Saliguorikvm="yes"
168eac30262Saliguorikerneldir=""
169b29fe3edSmalcaix="no"
17077755340Sthsblobs="yes"
171f652e6afSaurel32fdt="yes"
1727d13299dSbellard
1737d13299dSbellard# OS specific
174*ac0df51dSaliguoriif check_define __linux__ ; then
175*ac0df51dSaliguori  targetos="Linux"
176*ac0df51dSaliguorielif check_define _WIN32 ; then
177*ac0df51dSaliguori  targetos='MINGW32'
178*ac0df51dSaliguorielse
1797d13299dSbellard  targetos=`uname -s`
180*ac0df51dSaliguorifi
1817d13299dSbellardcase $targetos in
182c326e0afSbellardCYGWIN*)
183c326e0afSbellardmingw32="yes"
1846f30fa85SthsOS_CFLAGS="-mno-cygwin"
185db8d7dd1Sthsif [ "$cpu" = "i386" ] ; then
186db8d7dd1Sths    kqemu="yes"
187db8d7dd1Sthsfi
188c2de5c91Smalcaudio_possible_drivers="sdl"
189c326e0afSbellard;;
19067b915a5SbellardMINGW32*)
19167b915a5Sbellardmingw32="yes"
192db8d7dd1Sthsif [ "$cpu" = "i386" ] ; then
193db8d7dd1Sths    kqemu="yes"
194db8d7dd1Sthsfi
195c2de5c91Smalcaudio_possible_drivers="dsound sdl fmod"
19667b915a5Sbellard;;
1975c40d2bdSthsGNU/kFreeBSD)
1980c58ac1cSmalcaudio_drv_list="oss"
199f34af52cSaurel32audio_possible_drivers="oss sdl esd pa"
2005c40d2bdSthsif [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
2015c40d2bdSths    kqemu="yes"
2025c40d2bdSthsfi
2035c40d2bdSths;;
2047d3505c5SbellardFreeBSD)
2057d3505c5Sbellardbsd="yes"
2060c58ac1cSmalcaudio_drv_list="oss"
207f34af52cSaurel32audio_possible_drivers="oss sdl esd pa"
208e99f9060Sbellardif [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
20907f4ddbfSbellard    kqemu="yes"
21007f4ddbfSbellardfi
2117d3505c5Sbellard;;
2127d3505c5SbellardNetBSD)
2137d3505c5Sbellardbsd="yes"
2140c58ac1cSmalcaudio_drv_list="oss"
215c2de5c91Smalcaudio_possible_drivers="oss sdl esd"
2168ef92a88Sblueswir1oss_lib="-lossaudio"
2177d3505c5Sbellard;;
2187d3505c5SbellardOpenBSD)
2197d3505c5Sbellardbsd="yes"
220128ab2ffSblueswir1openbsd="yes"
2210c58ac1cSmalcaudio_drv_list="oss"
222c2de5c91Smalcaudio_possible_drivers="oss sdl esd"
2232f6a1ab0Sblueswir1oss_lib="-lossaudio"
2247d3505c5Sbellard;;
22583fb7adfSbellardDarwin)
22683fb7adfSbellardbsd="yes"
22783fb7adfSbellarddarwin="yes"
228831b7825Sthsdarwin_user="yes"
229fd677642Sthscocoa="yes"
2300c58ac1cSmalcaudio_drv_list="coreaudio"
231c2de5c91Smalcaudio_possible_drivers="coreaudio sdl fmod"
2326f30fa85SthsOS_CFLAGS="-mdynamic-no-pic"
233c2c59c3eSthsOS_LDFLAGS="-framework CoreFoundation -framework IOKit"
23483fb7adfSbellard;;
235ec530c81SbellardSunOS)
236ec530c81Sbellard    solaris="yes"
237c2b84fabSths    make="gmake"
238c2b84fabSths    install="ginstall"
2390475a5caSths    needs_libsunmath="no"
240c2b84fabSths    solarisrev=`uname -r | cut -f2 -d.`
241ef18c883Sths    # have to select again, because `uname -m` returns i86pc
242ef18c883Sths    # even on an x86_64 box.
243ef18c883Sths    solariscpu=`isainfo -k`
244ef18c883Sths    if test "${solariscpu}" = "amd64" ; then
245ef18c883Sths        cpu="x86_64"
246ef18c883Sths    fi
247c2b84fabSths    if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
2480475a5caSths        if test "$solarisrev" -le 9 ; then
2490475a5caSths            if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
2500475a5caSths                needs_libsunmath="yes"
2510475a5caSths            else
2520475a5caSths                echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
2530475a5caSths                echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
2540475a5caSths                echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
2550475a5caSths                echo "Studio 11 can be downloaded from www.sun.com."
2560475a5caSths                exit 1
2570475a5caSths            fi
2580475a5caSths        fi
2590475a5caSths        if test "$solarisrev" -ge 9 ; then
260c2b84fabSths            kqemu="yes"
261c2b84fabSths        fi
26286b2bd93Sths    fi
2636b4d2ba1Sths    if test -f /usr/include/sys/soundcard.h ; then
2640c58ac1cSmalc        audio_drv_list="oss"
2656b4d2ba1Sths    fi
266c2de5c91Smalc    audio_possible_drivers="oss sdl"
267ec530c81Sbellard;;
268b29fe3edSmalcAIX)
269b29fe3edSmalcaix="yes"
270b29fe3edSmalcmake="gmake"
271b29fe3edSmalc;;
272fb065187Sbellard*)
2730c58ac1cSmalcaudio_drv_list="oss"
274b8e59f18Smalcaudio_possible_drivers="oss alsa sdl esd pa"
2755327cf48Sbellardlinux="yes"
276831b7825Sthslinux_user="yes"
27768063649Sblueswir1usb="linux"
27807f4ddbfSbellardif [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
279c9ec1fe4Sbellard    kqemu="yes"
280c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
281c9ec1fe4Sbellardfi
282fb065187Sbellard;;
2837d13299dSbellardesac
2847d13299dSbellard
2857d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
286b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
2877d3505c5Sbellard    make="gmake"
28868063649Sblueswir1    usb="bsd"
28983fb7adfSbellard  fi
29084778508Sblueswir1  bsd_user="yes"
2917d3505c5Sbellardfi
2927d3505c5Sbellard
2937d13299dSbellard# find source path
294ad064840Spbrooksource_path=`dirname "$0"`
29559faef3aSbalrogsource_path_used="no"
29659faef3aSbalrogworkdir=`pwd`
297ad064840Spbrookif [ -z "$source_path" ]; then
29859faef3aSbalrog    source_path=$workdir
299ad064840Spbrookelse
300ad064840Spbrook    source_path=`cd "$source_path"; pwd`
3017d13299dSbellardfi
302724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
3037d13299dSbellard
30485aa5189Sbellardwerror="no"
3050d1e2394Sbellard# generate compile errors on warnings for development builds
3060d1e2394Sbellard#if grep cvs $source_path/VERSION > /dev/null 2>&1 ; then
3070d1e2394Sbellard#werror="yes";
3080d1e2394Sbellard#fi
30985aa5189Sbellard
3107d13299dSbellardfor opt do
311a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
3127d13299dSbellard  case "$opt" in
3132efc3265Sbellard  --help|-h) show_help=yes
3142efc3265Sbellard  ;;
315b1a550a0Spbrook  --prefix=*) prefix="$optarg"
3167d13299dSbellard  ;;
317b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
31832ce6337Sbellard  ;;
319b1a550a0Spbrook  --source-path=*) source_path="$optarg"
320ad064840Spbrook  source_path_used="yes"
3217d13299dSbellard  ;;
322*ac0df51dSaliguori  --cross-prefix=*)
3237d13299dSbellard  ;;
324*ac0df51dSaliguori  --cc=*)
3257d13299dSbellard  ;;
326b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
32783469015Sbellard  ;;
328b1a550a0Spbrook  --make=*) make="$optarg"
3297d13299dSbellard  ;;
3306a882643Spbrook  --install=*) install="$optarg"
3316a882643Spbrook  ;;
332b1a550a0Spbrook  --extra-cflags=*) CFLAGS="$optarg"
3337d13299dSbellard  ;;
334b1a550a0Spbrook  --extra-ldflags=*) LDFLAGS="$optarg"
3357d13299dSbellard  ;;
336b1a550a0Spbrook  --cpu=*) cpu="$optarg"
3377d13299dSbellard  ;;
338b1a550a0Spbrook  --target-list=*) target_list="$optarg"
339de83cd02Sbellard  ;;
3407d13299dSbellard  --enable-gprof) gprof="yes"
3417d13299dSbellard  ;;
34243ce4dfeSbellard  --static) static="yes"
34343ce4dfeSbellard  ;;
34497a847bcSbellard  --disable-sdl) sdl="no"
34597a847bcSbellard  ;;
346b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
347102a52e4Sbellard  ;;
348c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
349c2de5c91Smalc  ;;
3502f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
3512f6a1ab0Sblueswir1  ;;
3522fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
3530c58ac1cSmalc  ;;
3540c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
3550c58ac1cSmalc  ;;
35603b4fe7dSaliguori  --enable-sparse) sparse="yes"
35703b4fe7dSaliguori  ;;
35803b4fe7dSaliguori  --disable-sparse) sparse="no"
35903b4fe7dSaliguori  ;;
3608d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
3618d5d2d4cSths  ;;
362443f1376Sbellard  --disable-slirp) slirp="no"
363c20709aaSbellard  ;;
364e0e6c8c0Saliguori  --disable-vde) vde="no"
3658a16d273Sths  ;;
366c9ec1fe4Sbellard  --disable-kqemu) kqemu="no"
367c9ec1fe4Sbellard  ;;
3682e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
3692e4d9fb1Saurel32  ;;
370fb599c9aSbalrog  --disable-bluez) bluez="no"
371fb599c9aSbalrog  ;;
3727ba1e619Saliguori  --disable-kvm) kvm="no"
3737ba1e619Saliguori  ;;
37405c2a3e7Sbellard  --enable-profiler) profiler="yes"
37505c2a3e7Sbellard  ;;
376c2de5c91Smalc  --enable-cocoa)
377c2de5c91Smalc      cocoa="yes" ;
378c2de5c91Smalc      sdl="no" ;
379c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
3805b0753e0Sbellard  ;;
38197ccc689Sbellard  --disable-gfx-check) check_gfx="no"
38297ccc689Sbellard  ;;
383cad25d69Spbrook  --disable-system) softmmu="no"
3840a8e90f4Spbrook  ;;
385cad25d69Spbrook  --enable-system) softmmu="yes"
3860a8e90f4Spbrook  ;;
387831b7825Sths  --disable-linux-user) linux_user="no"
3880a8e90f4Spbrook  ;;
389831b7825Sths  --enable-linux-user) linux_user="yes"
390831b7825Sths  ;;
391831b7825Sths  --disable-darwin-user) darwin_user="no"
392831b7825Sths  ;;
393831b7825Sths  --enable-darwin-user) darwin_user="yes"
3940a8e90f4Spbrook  ;;
39584778508Sblueswir1  --disable-bsd-user) bsd_user="no"
39684778508Sblueswir1  ;;
39784778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
39884778508Sblueswir1  ;;
399c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
400c5937220Spbrook  ;;
4013142255cSblueswir1  --sparc_cpu=*)
4023142255cSblueswir1      sparc_cpu="$optarg"
4033142255cSblueswir1      case $sparc_cpu in
4043142255cSblueswir1        v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
4053142255cSblueswir1                 target_cpu="sparc"; cpu="sparc" ;;
4063142255cSblueswir1        v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
4073142255cSblueswir1                 target_cpu="sparc"; cpu="sparc" ;;
4083142255cSblueswir1        v9)    SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
4093142255cSblueswir1                 target_cpu="sparc64"; cpu="sparc64" ;;
4103142255cSblueswir1        *)     echo "undefined SPARC architecture. Exiting";exit 1;;
4113142255cSblueswir1      esac
4123142255cSblueswir1  ;;
41385aa5189Sbellard  --enable-werror) werror="yes"
41485aa5189Sbellard  ;;
41585aa5189Sbellard  --disable-werror) werror="no"
41685aa5189Sbellard  ;;
4174d3b6f6eSbalrog  --disable-curses) curses="no"
4184d3b6f6eSbalrog  ;;
419bd0c5661Spbrook  --disable-nptl) nptl="no"
420bd0c5661Spbrook  ;;
4218ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
4228ff9cbf7Smalc  ;;
423414f0dabSblueswir1  --disable-aio) aio="no"
424414f0dabSblueswir1  ;;
42577755340Sths  --disable-blobs) blobs="no"
42677755340Sths  ;;
427eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
428eac30262Saliguori  ;;
4297f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
4307f1559c6Sbalrog  ;;
4317d13299dSbellard  esac
4327d13299dSbellarddone
4337d13299dSbellard
4346f30fa85Sths# default flags for all hosts
435ac41a620Sblueswir1CFLAGS="$CFLAGS -O2 -g -fno-strict-aliasing"
436e0e36fe9Sblueswir1CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
4376f30fa85SthsLDFLAGS="$LDFLAGS -g"
43885aa5189Sbellardif test "$werror" = "yes" ; then
43985aa5189SbellardCFLAGS="$CFLAGS -Werror"
44085aa5189Sbellardfi
4416f30fa85Sths
442d2c7c9b8Sblueswir1if test "$solaris" = "no" ; then
443d2c7c9b8Sblueswir1    if ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
44449237acdSblueswir1        LDFLAGS="$LDFLAGS -Wl,--warn-common"
44549237acdSblueswir1    fi
446d2c7c9b8Sblueswir1fi
44749237acdSblueswir1
4483142255cSblueswir1#
4493142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
4503142255cSblueswir1# ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
4513142255cSblueswir1#
45240293e58Sbellardcase "$cpu" in
4533142255cSblueswir1    sparc) if test -z "$sparc_cpu" ; then
4543142255cSblueswir1               ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
4553142255cSblueswir1               ARCH_LDFLAGS="-m32"
4563142255cSblueswir1           else
4573142255cSblueswir1               ARCH_CFLAGS="${SP_CFLAGS}"
4583142255cSblueswir1               ARCH_LDFLAGS="${SP_LDFLAGS}"
4593142255cSblueswir1           fi
4603142255cSblueswir1           ;;
4613142255cSblueswir1    sparc64) if test -z "$sparc_cpu" ; then
4623142255cSblueswir1               ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
4633142255cSblueswir1               ARCH_LDFLAGS="-m64"
4643142255cSblueswir1           else
4653142255cSblueswir1               ARCH_CFLAGS="${SP_CFLAGS}"
4663142255cSblueswir1               ARCH_LDFLAGS="${SP_LDFLAGS}"
4673142255cSblueswir1           fi
4683142255cSblueswir1           ;;
46976d83bdeSths    s390)
47076d83bdeSths           ARCH_CFLAGS="-march=z900"
47176d83bdeSths           ;;
47240293e58Sbellard    i386)
47340293e58Sbellard           ARCH_CFLAGS="-m32"
47440293e58Sbellard           ARCH_LDFLAGS="-m32"
47540293e58Sbellard           ;;
47640293e58Sbellard    x86_64)
47740293e58Sbellard           ARCH_CFLAGS="-m64"
47840293e58Sbellard           ARCH_LDFLAGS="-m64"
47940293e58Sbellard           ;;
4803142255cSblueswir1esac
4813142255cSblueswir1
482af5db58eSpbrookif test x"$show_help" = x"yes" ; then
483af5db58eSpbrookcat << EOF
484af5db58eSpbrook
485af5db58eSpbrookUsage: configure [options]
486af5db58eSpbrookOptions: [defaults in brackets after descriptions]
487af5db58eSpbrook
488af5db58eSpbrookEOF
489af5db58eSpbrookecho "Standard options:"
490af5db58eSpbrookecho "  --help                   print this message"
491af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
492af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
493af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
494af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
495af5db58eSpbrookecho ""
496af5db58eSpbrookecho "kqemu kernel acceleration support:"
497af5db58eSpbrookecho "  --disable-kqemu          disable kqemu support"
498af5db58eSpbrookecho ""
499af5db58eSpbrookecho "Advanced options (experts only):"
500af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
501af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
502af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
503af5db58eSpbrookecho "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
504af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
5056a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
506af5db58eSpbrookecho "  --static                 enable static build [$static]"
507890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
508890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
50985aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
510fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
511af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
512c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
513c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
514c2de5c91Smalcecho "  --audio-card-list=LIST   set list of additional emulated audio cards"
515c2de5c91Smalcecho "                           Available cards: ac97 adlib cs4231a gus"
5168ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
5172e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
5188d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
519af896aaaSpbrookecho "  --disable-curses         disable curses output"
520fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
5217ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
522bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
523af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
524af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
525831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
526831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
527831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
528831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
52984778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
53084778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
531af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
532af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
5332f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
534c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
5353142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
536e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
537414f0dabSblueswir1echo "  --disable-aio            disable AIO support"
53877755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
539eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
540af5db58eSpbrookecho ""
5415bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
542af5db58eSpbrookexit 1
543af5db58eSpbrookfi
544af5db58eSpbrook
54567b915a5Sbellardif test "$mingw32" = "yes" ; then
5465327cf48Sbellard    linux="no"
54767b915a5Sbellard    EXESUF=".exe"
5489f059ecaSbellard    oss="no"
549cd01b4a3Saliguori    linux_user="no"
55084778508Sblueswir1    bsd_user="no"
551cd01b4a3Saliguorifi
552cd01b4a3Saliguori
55303b4fe7dSaliguoriif test ! -x "$(which cgcc 2>/dev/null)"; then
55403b4fe7dSaliguori    sparse="no"
55503b4fe7dSaliguorifi
55603b4fe7dSaliguori
557ec530c81Sbellard#
558ec530c81Sbellard# Solaris specific configure tool chain decisions
559ec530c81Sbellard#
560ec530c81Sbellardif test "$solaris" = "yes" ; then
561ec530c81Sbellard  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
562ec530c81Sbellard  if test -z "$solinst" ; then
563ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
564ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
565ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
566ec530c81Sbellard    exit 1
567ec530c81Sbellard  fi
568ec530c81Sbellard  if test "$solinst" = "/usr/sbin/install" ; then
569ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
570ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
571ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
572ec530c81Sbellard    exit 1
573ec530c81Sbellard  fi
574ec530c81Sbellard  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
575ec530c81Sbellard  if test -z "$sol_ar" ; then
576ec530c81Sbellard    echo "Error: No path includes ar"
577ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
578ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
579ec530c81Sbellard    fi
580ec530c81Sbellard    exit 1
581ec530c81Sbellard  fi
582ec530c81Sbellardfi
583ec530c81Sbellard
584ec530c81Sbellard
5855327cf48Sbellardif test -z "$target_list" ; then
5865327cf48Sbellard# these targets are portable
5870a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
5882408a527Saurel32        target_list="\
5892408a527Saurel32i386-softmmu \
5902408a527Saurel32x86_64-softmmu \
5912408a527Saurel32arm-softmmu \
5922408a527Saurel32cris-softmmu \
5932408a527Saurel32m68k-softmmu \
5942408a527Saurel32mips-softmmu \
5952408a527Saurel32mipsel-softmmu \
5962408a527Saurel32mips64-softmmu \
5972408a527Saurel32mips64el-softmmu \
5982408a527Saurel32ppc-softmmu \
5992408a527Saurel32ppcemb-softmmu \
6002408a527Saurel32ppc64-softmmu \
6012408a527Saurel32sh4-softmmu \
6022408a527Saurel32sh4eb-softmmu \
6032408a527Saurel32sparc-softmmu \
6042408a527Saurel32"
6050a8e90f4Spbrook    fi
6065327cf48Sbellard# the following are Linux specific
607831b7825Sths    if [ "$linux_user" = "yes" ] ; then
6082408a527Saurel32        target_list="${target_list}\
6092408a527Saurel32i386-linux-user \
6102408a527Saurel32x86_64-linux-user \
6112408a527Saurel32alpha-linux-user \
6122408a527Saurel32arm-linux-user \
6132408a527Saurel32armeb-linux-user \
6142408a527Saurel32cris-linux-user \
6152408a527Saurel32m68k-linux-user \
6162408a527Saurel32mips-linux-user \
6172408a527Saurel32mipsel-linux-user \
6182408a527Saurel32ppc-linux-user \
6192408a527Saurel32ppc64-linux-user \
6202408a527Saurel32ppc64abi32-linux-user \
6212408a527Saurel32sh4-linux-user \
6222408a527Saurel32sh4eb-linux-user \
6232408a527Saurel32sparc-linux-user \
6242408a527Saurel32sparc64-linux-user \
6252408a527Saurel32sparc32plus-linux-user \
6262408a527Saurel32"
627831b7825Sths    fi
628831b7825Sths# the following are Darwin specific
629831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
6302408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user"
6315327cf48Sbellard    fi
63284778508Sblueswir1# the following are BSD specific
63384778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
63484778508Sblueswir1        target_list="${target_list}\
63584778508Sblueswir1sparc64-bsd-user \
63684778508Sblueswir1"
63784778508Sblueswir1    fi
6386e20a45fSbellardelse
639b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
6405327cf48Sbellardfi
6410a8e90f4Spbrookif test -z "$target_list" ; then
6420a8e90f4Spbrook    echo "No targets enabled"
6430a8e90f4Spbrook    exit 1
6440a8e90f4Spbrookfi
6455327cf48Sbellard
6467d13299dSbellardif test -z "$cross_prefix" ; then
6477d13299dSbellard
6487d13299dSbellard# ---
6497d13299dSbellard# big/little endian test
6507d13299dSbellardcat > $TMPC << EOF
6517d13299dSbellard#include <inttypes.h>
6527d13299dSbellardint main(int argc, char ** argv){
6537d13299dSbellard        volatile uint32_t i=0x01234567;
6547d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
6557d13299dSbellard}
6567d13299dSbellardEOF
6577d13299dSbellard
658178baee6Saurel32if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
6597d13299dSbellard$TMPE && bigendian="yes"
6607d13299dSbellardelse
6617d13299dSbellardecho big/little test failed
6627d13299dSbellardfi
6637d13299dSbellard
6647d13299dSbellardelse
6657d13299dSbellard
6667d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
6670938cda5Saurel32if test "$cpu" = "armv4b" \
668f54b3f92Saurel32     -o "$cpu" = "hppa" \
6690938cda5Saurel32     -o "$cpu" = "m68k" \
6700938cda5Saurel32     -o "$cpu" = "mips" \
6710938cda5Saurel32     -o "$cpu" = "mips64" \
6720938cda5Saurel32     -o "$cpu" = "powerpc" \
6730938cda5Saurel32     -o "$cpu" = "s390" \
6740938cda5Saurel32     -o "$cpu" = "sparc" \
6750938cda5Saurel32     -o "$cpu" = "sparc64"; then
6767d13299dSbellard    bigendian="yes"
6777d13299dSbellardfi
6787d13299dSbellard
6797d13299dSbellardfi
6807d13299dSbellard
681b6853697Sbellard# host long bits test
682b6853697Sbellardhostlongbits="32"
6830938cda5Saurel32if test "$cpu" = "x86_64" \
6840938cda5Saurel32     -o "$cpu" = "alpha" \
6850938cda5Saurel32     -o "$cpu" = "ia64" \
6860938cda5Saurel32     -o "$cpu" = "sparc64"; then
687b6853697Sbellard    hostlongbits="64"
688b6853697Sbellardfi
689b6853697Sbellard
690810260a8Smalc# ppc specific hostlongbits selection
691810260a8Smalcif test "$cpu" = "powerpc" ; then
6929d56d2dcSmalc    if $cc $ARCH_CFLAGS -dM -E - -o $TMPI 2>/dev/null </dev/null; then
6939d56d2dcSmalc        grep -q __powerpc64__ $TMPI && hostlongbits=64
694810260a8Smalc    else
695810260a8Smalc        echo hostlongbits test failed
696ba69a08aSmalc        exit 1
697810260a8Smalc    fi
698810260a8Smalcfi
699810260a8Smalc
700e8cd23deSbellard# check gcc options support
70104369ff2Sbellardcat > $TMPC <<EOF
70204369ff2Sbellardint main(void) {
70304369ff2Sbellard}
70404369ff2SbellardEOF
70504369ff2Sbellard
706bd0c5661Spbrook# Check host NPTL support
707bd0c5661Spbrookcat > $TMPC <<EOF
708bd0c5661Spbrook#include <sched.h>
70930813ceaSpbrook#include <linux/futex.h>
710bd0c5661Spbrookvoid foo()
711bd0c5661Spbrook{
712bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
713bd0c5661Spbrook#error bork
714bd0c5661Spbrook#endif
715bd0c5661Spbrook}
716bd0c5661SpbrookEOF
717bd0c5661Spbrook
7188c7f7574Sbalrogif $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
719bd0c5661Spbrook  :
720bd0c5661Spbrookelse
721bd0c5661Spbrook   nptl="no"
722bd0c5661Spbrookfi
723bd0c5661Spbrook
72411d9f695Sbellard##########################################
725ac62922eSbalrog# zlib check
726ac62922eSbalrog
727ac62922eSbalrogcat > $TMPC << EOF
728ac62922eSbalrog#include <zlib.h>
729ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
730ac62922eSbalrogEOF
7318c7f7574Sbalrogif $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz > /dev/null 2> /dev/null ; then
732ac62922eSbalrog    :
733ac62922eSbalrogelse
734ac62922eSbalrog    echo
735ac62922eSbalrog    echo "Error: zlib check failed"
736ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
737ac62922eSbalrog    echo
738ac62922eSbalrog    exit 1
739ac62922eSbalrogfi
740ac62922eSbalrog
741ac62922eSbalrog##########################################
74211d9f695Sbellard# SDL probe
74311d9f695Sbellard
74411d9f695Sbellardsdl_too_old=no
74511d9f695Sbellard
74611d9f695Sbellardif test -z "$sdl" ; then
747a6e022adSbellard    sdl_config="sdl-config"
748a6e022adSbellard    sdl=no
7497c1f25b4Sbellard    sdl_static=no
750a6e022adSbellard
75111d9f695Sbellardcat > $TMPC << EOF
75211d9f695Sbellard#include <SDL.h>
75311d9f695Sbellard#undef main /* We don't want SDL to override our main() */
75411d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
75511d9f695SbellardEOF
7568c7f7574Sbalrog    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > $TMPSDLLOG 2>&1 ; then
757a6e022adSbellard        _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
75811d9f695Sbellard        if test "$_sdlversion" -lt 121 ; then
75911d9f695Sbellard            sdl_too_old=yes
76011d9f695Sbellard        else
761fd677642Sths            if test "$cocoa" = "no" ; then
76211d9f695Sbellard                sdl=yes
76311d9f695Sbellard            fi
764fd677642Sths        fi
7657c1f25b4Sbellard
7667c1f25b4Sbellard        # static link with sdl ?
7677c1f25b4Sbellard        if test "$sdl" = "yes" ; then
7687c1f25b4Sbellard            aa="no"
769e14a693dSths            `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
770e14a693dSths            sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
7717c1f25b4Sbellard            if [ "$aa" = "yes" ] ; then
772d8d8aa4eSbellard                sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
77311d9f695Sbellard            fi
77411d9f695Sbellard
7758c7f7574Sbalrog            if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs > /dev/null 2> /dev/null; then
7767c1f25b4Sbellard                sdl_static=yes
7777c1f25b4Sbellard            fi
7787c1f25b4Sbellard        fi # static link
7797c1f25b4Sbellard    fi # sdl compile test
780fd677642Sthselse
781fd677642Sths    # Make sure to disable cocoa if sdl was set
782fd677642Sths    if test "$sdl" = "yes" ; then
783fd677642Sths       cocoa="no"
784c2de5c91Smalc       audio_drv_list="`echo $audio_drv_list | sed s,coreaudio,,g`"
785fd677642Sths    fi
786a6e022adSbellardfi # -z $sdl
78711d9f695Sbellard
7888f28f3fbSths##########################################
7898d5d2d4cSths# VNC TLS detection
7908d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
791ae6b5e5aSaliguoricat > $TMPC <<EOF
792ae6b5e5aSaliguori#include <gnutls/gnutls.h>
793ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
794ae6b5e5aSaliguoriEOF
795ae6b5e5aSaliguori    vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
796ae6b5e5aSaliguori    vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
797ae6b5e5aSaliguori    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
7988c7f7574Sbalrog           $vnc_tls_libs > /dev/null 2> /dev/null ; then
799ae6b5e5aSaliguori	:
800ae6b5e5aSaliguori    else
801ae6b5e5aSaliguori	vnc_tls="no"
8028d5d2d4cSths    fi
8038d5d2d4cSthsfi
8048d5d2d4cSths
8058d5d2d4cSths##########################################
8068a16d273Sths# vde libraries probe
8078a16d273Sthsif test "$vde" = "yes" ; then
8088a16d273Sths  cat > $TMPC << EOF
8098a16d273Sths#include <libvdeplug.h>
8104a7f0e06Spbrookint main(void)
8114a7f0e06Spbrook{
8124a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
8134a7f0e06Spbrook    vde_open("", "", &a);
8144a7f0e06Spbrook    return 0;
8154a7f0e06Spbrook}
8168a16d273SthsEOF
8178c7f7574Sbalrog    if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lvdeplug > /dev/null 2> /dev/null ; then
8188a16d273Sths        :
8198a16d273Sths    else
820e0e6c8c0Saliguori        vde="no"
8218a16d273Sths    fi
8228a16d273Sthsfi
8238a16d273Sths
8248a16d273Sths##########################################
825c2de5c91Smalc# Sound support libraries probe
8268f28f3fbSths
827c2de5c91Smalcaudio_drv_probe()
828c2de5c91Smalc{
829c2de5c91Smalc    drv=$1
830c2de5c91Smalc    hdr=$2
831c2de5c91Smalc    lib=$3
832c2de5c91Smalc    exp=$4
833c2de5c91Smalc    cfl=$5
8348f28f3fbSths        cat > $TMPC << EOF
835c2de5c91Smalc#include <$hdr>
836c2de5c91Smalcint main(void) { $exp }
8378f28f3fbSthsEOF
8388c7f7574Sbalrog    if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
8398f28f3fbSths        :
8408f28f3fbSths    else
8418f28f3fbSths        echo
842c2de5c91Smalc        echo "Error: $drv check failed"
843c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
8448f28f3fbSths        echo
8458f28f3fbSths        exit 1
8468f28f3fbSths    fi
847c2de5c91Smalc}
848c2de5c91Smalc
8492fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
850c2de5c91Smalcfor drv in $audio_drv_list; do
851c2de5c91Smalc    case $drv in
852c2de5c91Smalc    alsa)
853c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
854c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
855c2de5c91Smalc    ;;
856c2de5c91Smalc
857c2de5c91Smalc    fmod)
858c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
859c2de5c91Smalc        echo
860c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
861c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
862c2de5c91Smalc        echo
863c2de5c91Smalc        exit 1
8648f28f3fbSths    fi
865c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
866c2de5c91Smalc    ;;
867c2de5c91Smalc
868c2de5c91Smalc    esd)
869c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
870c2de5c91Smalc    ;;
871b8e59f18Smalc
872b8e59f18Smalc    pa)
873b8e59f18Smalc    audio_drv_probe $drv pulse/simple.h -lpulse-simple \
874b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
875b8e59f18Smalc    ;;
876b8e59f18Smalc
8772f6a1ab0Sblueswir1    oss|sdl|core|wav|dsound)
8782f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
8792f6a1ab0Sblueswir1    ;;
8802f6a1ab0Sblueswir1
881e4c63a6aSmalc    *)
8821c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
883e4c63a6aSmalc        echo
884e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
885e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
886e4c63a6aSmalc        echo
887e4c63a6aSmalc        exit 1
888e4c63a6aSmalc    }
889e4c63a6aSmalc    ;;
890c2de5c91Smalc    esac
891c2de5c91Smalcdone
8928f28f3fbSths
8934d3b6f6eSbalrog##########################################
8942e4d9fb1Saurel32# BrlAPI probe
8952e4d9fb1Saurel32
8962e4d9fb1Saurel32if test -z "$brlapi" ; then
8972e4d9fb1Saurel32    brlapi=no
8982e4d9fb1Saurel32cat > $TMPC << EOF
8992e4d9fb1Saurel32#include <brlapi.h>
9002e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
9012e4d9fb1Saurel32EOF
902178baee6Saurel32    if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi > /dev/null 2> /dev/null ; then
9032e4d9fb1Saurel32	    brlapi=yes
9042e4d9fb1Saurel32    fi # brlapi compile test
9052e4d9fb1Saurel32fi # -z $brlapi
9062e4d9fb1Saurel32
9072e4d9fb1Saurel32##########################################
9084d3b6f6eSbalrog# curses probe
9094d3b6f6eSbalrog
9104d3b6f6eSbalrogif test "$curses" = "yes" ; then
9114d3b6f6eSbalrog  curses=no
9124d3b6f6eSbalrog  cat > $TMPC << EOF
9134d3b6f6eSbalrog#include <curses.h>
9144d3b6f6eSbalrogint main(void) { return curses_version(); }
9154d3b6f6eSbalrogEOF
916178baee6Saurel32  if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
9174d3b6f6eSbalrog    curses=yes
9184d3b6f6eSbalrog  fi
9194d3b6f6eSbalrogfi # test "$curses"
9204d3b6f6eSbalrog
921414f0dabSblueswir1##########################################
922fb599c9aSbalrog# bluez support probe
923fb599c9aSbalrogif test "$bluez" = "yes" ; then
924fb599c9aSbalrog  `pkg-config bluez` || bluez="no"
925fb599c9aSbalrogfi
926fb599c9aSbalrogif test "$bluez" = "yes" ; then
927e820e3f4Sbalrog  cat > $TMPC << EOF
928e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
929e820e3f4Sbalrogint main(void) { return bt_error(0); }
930e820e3f4SbalrogEOF
931fb599c9aSbalrog  bluez_cflags=`pkg-config --cflags bluez`
932fb599c9aSbalrog  bluez_libs=`pkg-config --libs bluez`
93317e1592dSbalrog  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
9348c7f7574Sbalrog      $bluez_libs > /dev/null 2> /dev/null ; then
935e820e3f4Sbalrog    :
936e820e3f4Sbalrog  else
937e820e3f4Sbalrog    bluez="no"
938e820e3f4Sbalrog  fi
939fb599c9aSbalrogfi
940fb599c9aSbalrog
941fb599c9aSbalrog##########################################
9427ba1e619Saliguori# kvm probe
9437ba1e619Saliguoriif test "$kvm" = "yes" ; then
9447ba1e619Saliguori    cat > $TMPC <<EOF
9457ba1e619Saliguori#include <linux/kvm.h>
9467ba1e619Saliguori#if !defined(KVM_API_VERSION) || \
9477ba1e619Saliguori    KVM_API_VERSION < 12 || \
9487ba1e619Saliguori    KVM_API_VERSION > 12 || \
9497ba1e619Saliguori    !defined(KVM_CAP_USER_MEMORY) || \
950d85dc283Saliguori    !defined(KVM_CAP_SET_TSS_ADDR) || \
951d85dc283Saliguori    !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
9527ba1e619Saliguori#error Invalid KVM version
9537ba1e619Saliguori#endif
9547ba1e619Saliguoriint main(void) { return 0; }
9557ba1e619SaliguoriEOF
956eac30262Saliguori  if test "$kerneldir" != "" ; then
957eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
958eac30262Saliguori  else
959eac30262Saliguori      kvm_cflags=""
960eac30262Saliguori  fi
9617ba1e619Saliguori  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
9628c7f7574Sbalrog      > /dev/null 2>/dev/null ; then
9637ba1e619Saliguori    :
9647ba1e619Saliguori  else
9657ba1e619Saliguori    kvm="no"
9667ba1e619Saliguori  fi
9677ba1e619Saliguorifi
9687ba1e619Saliguori
9697ba1e619Saliguori##########################################
970414f0dabSblueswir1# AIO probe
9713c529d93SaliguoriAIOLIBS=""
9723c529d93Saliguori
973414f0dabSblueswir1if test "$aio" = "yes" ; then
974414f0dabSblueswir1  aio=no
975414f0dabSblueswir1  cat > $TMPC << EOF
9763c529d93Saliguori#include <pthread.h>
9773c529d93Saliguoriint main(void) { pthread_mutex_t lock; return 0; }
978414f0dabSblueswir1EOF
979414f0dabSblueswir1  if $cc $ARCH_CFLAGS -o $TMPE $AIOLIBS $TMPC 2> /dev/null ; then
980414f0dabSblueswir1    aio=yes
9813c529d93Saliguori    AIOLIBS="-lpthread"
982414f0dabSblueswir1  fi
983414f0dabSblueswir1fi
984414f0dabSblueswir1
985bf9298b9Saliguori##########################################
986bf9298b9Saliguori# iovec probe
987bf9298b9Saliguoricat > $TMPC <<EOF
988bf9298b9Saliguori#include <sys/uio.h>
989bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
990bf9298b9SaliguoriEOF
991bf9298b9Saliguoriiovec=no
9928c7f7574Sbalrogif $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
993bf9298b9Saliguori  iovec=yes
994bf9298b9Saliguorifi
995bf9298b9Saliguori
996f652e6afSaurel32##########################################
997f652e6afSaurel32# fdt probe
998f652e6afSaurel32if test "$fdt" = "yes" ; then
999f652e6afSaurel32    fdt=no
1000f652e6afSaurel32    cat > $TMPC << EOF
1001f652e6afSaurel32int main(void) { return 0; }
1002f652e6afSaurel32EOF
1003f652e6afSaurel32  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null ; then
1004f652e6afSaurel32    fdt=yes
1005f652e6afSaurel32  fi
1006f652e6afSaurel32fi
1007f652e6afSaurel32
1008cc8ae6deSpbrook# Check if tools are available to build documentation.
10096c591867Sthsif [ -x "`which texi2html 2>/dev/null`" ] && \
10106c591867Sths   [ -x "`which pod2man 2>/dev/null`" ]; then
1011cc8ae6deSpbrook  build_docs="yes"
1012cc8ae6deSpbrookfi
1013cc8ae6deSpbrook
1014da93a1fdSaliguori##########################################
1015da93a1fdSaliguori# Do we need librt
1016da93a1fdSaliguoricat > $TMPC <<EOF
1017da93a1fdSaliguori#include <signal.h>
1018da93a1fdSaliguori#include <time.h>
1019da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
1020da93a1fdSaliguoriEOF
1021da93a1fdSaliguori
1022da93a1fdSaliguorirt=no
10238c7f7574Sbalrogif $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1024da93a1fdSaliguori  :
10258c7f7574Sbalrogelif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1026da93a1fdSaliguori  rt=yes
1027da93a1fdSaliguorifi
1028da93a1fdSaliguori
1029da93a1fdSaliguoriif test "$rt" = "yes" ; then
1030da93a1fdSaliguori  # Hack, we should have a general purpose LIBS for this sort of thing
1031da93a1fdSaliguori  AIOLIBS="$AIOLIBS -lrt"
1032da93a1fdSaliguorifi
1033da93a1fdSaliguori
103411d9f695Sbellardif test "$mingw32" = "yes" ; then
103511d9f695Sbellard  if test -z "$prefix" ; then
103617e90973Saliguori      prefix="c:\\\\Program Files\\\\Qemu"
103711d9f695Sbellard  fi
1038308c3593Spbrook  mansuffix=""
1039308c3593Spbrook  datasuffix=""
1040308c3593Spbrook  docsuffix=""
1041308c3593Spbrook  binsuffix=""
104211d9f695Sbellardelse
104311d9f695Sbellard  if test -z "$prefix" ; then
104411d9f695Sbellard      prefix="/usr/local"
104511d9f695Sbellard  fi
1046308c3593Spbrook  mansuffix="/share/man"
1047308c3593Spbrook  datasuffix="/share/qemu"
1048308c3593Spbrook  docsuffix="/share/doc/qemu"
1049308c3593Spbrook  binsuffix="/bin"
105011d9f695Sbellardfi
10515a67135aSbellard
10527d13299dSbellardecho "Install prefix    $prefix"
1053308c3593Spbrookecho "BIOS directory    $prefix$datasuffix"
1054308c3593Spbrookecho "binary directory  $prefix$binsuffix"
105511d9f695Sbellardif test "$mingw32" = "no" ; then
1056308c3593Spbrookecho "Manual directory  $prefix$mansuffix"
105743ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
105811d9f695Sbellardfi
10595a67135aSbellardecho "Source path       $source_path"
10607d13299dSbellardecho "C compiler        $cc"
106183469015Sbellardecho "Host C compiler   $host_cc"
1062db7287edSpbrookecho "ARCH_CFLAGS       $ARCH_CFLAGS"
10637d13299dSbellardecho "make              $make"
10646a882643Spbrookecho "install           $install"
1065a98fd896Sbellardecho "host CPU          $cpu"
1066de83cd02Sbellardecho "host big endian   $bigendian"
106797a847bcSbellardecho "target list       $target_list"
10687d13299dSbellardecho "gprof enabled     $gprof"
106903b4fe7dSaliguoriecho "sparse enabled    $sparse"
107005c2a3e7Sbellardecho "profiler          $profiler"
107143ce4dfeSbellardecho "static build      $static"
107285aa5189Sbellardecho "-Werror enabled   $werror"
10735b0753e0Sbellardif test "$darwin" = "yes" ; then
10745b0753e0Sbellard    echo "Cocoa support     $cocoa"
10755b0753e0Sbellardfi
107697a847bcSbellardecho "SDL support       $sdl"
1077e4afee97Sbellardif test "$sdl" != "no" ; then
10787c1f25b4Sbellard    echo "SDL static link   $sdl_static"
1079e4afee97Sbellardfi
10804d3b6f6eSbalrogecho "curses support    $curses"
108167b915a5Sbellardecho "mingw32 support   $mingw32"
10820c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
10830c58ac1cSmalcecho "Extra audio cards $audio_card_list"
10848ff9cbf7Smalcecho "Mixer emulation   $mixemu"
10858d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
10868d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
10878d5d2d4cSths    echo "    TLS CFLAGS    $vnc_tls_cflags"
10888d5d2d4cSths    echo "    TLS LIBS      $vnc_tls_libs"
10898d5d2d4cSthsfi
10903142255cSblueswir1if test -n "$sparc_cpu"; then
10913142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
10923142255cSblueswir1fi
109307f4ddbfSbellardecho "kqemu support     $kqemu"
10942e4d9fb1Saurel32echo "brlapi support    $brlapi"
1095cc8ae6deSpbrookecho "Documentation     $build_docs"
1096c5937220Spbrook[ ! -z "$uname_release" ] && \
1097c5937220Spbrookecho "uname -r          $uname_release"
1098bd0c5661Spbrookecho "NPTL support      $nptl"
10998a16d273Sthsecho "vde support       $vde"
1100414f0dabSblueswir1echo "AIO support       $aio"
110177755340Sthsecho "Install blobs     $blobs"
11027ba1e619Saliguoriecho "KVM support       $kvm"
1103f652e6afSaurel32echo "fdt support       $fdt"
110467b915a5Sbellard
110597a847bcSbellardif test $sdl_too_old = "yes"; then
110624b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
1107e8cd23deSbellardfi
1108d4742de8Smalcif [ -s $TMPSDLLOG ]; then
110920b40c6aSths  echo "The error log from compiling the libSDL test is: "
1110d4742de8Smalc  cat $TMPSDLLOG
111120b40c6aSthsfi
111224b55b96Sbellard#if test "$sdl_static" = "no"; then
111324b55b96Sbellard#  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
111424b55b96Sbellard#fi
111597a847bcSbellardconfig_mak="config-host.mak"
111697a847bcSbellardconfig_h="config-host.h"
111797a847bcSbellard
11187c1f25b4Sbellard#echo "Creating $config_mak and $config_h"
111997a847bcSbellard
112015d9ca0fSthstest -f $config_h && mv $config_h ${config_h}~
112115d9ca0fSths
112297a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
1123fc9902d9Smalcprintf "# Configured with:" >> $config_mak
1124fd69fe2bSmalcprintf " '%s'" "$0" "$@" >> $config_mak
1125fd69fe2bSmalcecho >> $config_mak
112697a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
112797a847bcSbellard
112897a847bcSbellardecho "prefix=$prefix" >> $config_mak
1129308c3593Spbrookecho "bindir=\${prefix}$binsuffix" >> $config_mak
1130308c3593Spbrookecho "mandir=\${prefix}$mansuffix" >> $config_mak
1131308c3593Spbrookecho "datadir=\${prefix}$datasuffix" >> $config_mak
11324ad5b06dSthsecho "docdir=\${prefix}$docsuffix" >> $config_mak
1133308c3593Spbrookecho "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
113497a847bcSbellardecho "MAKE=$make" >> $config_mak
11356a882643Spbrookecho "INSTALL=$install" >> $config_mak
113697a847bcSbellardecho "CC=$cc" >> $config_mak
113797a847bcSbellardecho "HOST_CC=$host_cc" >> $config_mak
113897a847bcSbellardecho "AR=$ar" >> $config_mak
113997a847bcSbellardecho "STRIP=$strip -s -R .comment -R .note" >> $config_mak
114040293e58Sbellard# XXX: only use CFLAGS and LDFLAGS ?
114140293e58Sbellard# XXX: should export HOST_CFLAGS and HOST_LDFLAGS for cross
114240293e58Sbellard# compilation of dyngen tool (useful for win32 build on Linux host)
11436f30fa85Sthsecho "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
11443142255cSblueswir1echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
11453142255cSblueswir1echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
11463142255cSblueswir1echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
114797a847bcSbellardecho "CFLAGS=$CFLAGS" >> $config_mak
114897a847bcSbellardecho "LDFLAGS=$LDFLAGS" >> $config_mak
114967b915a5Sbellardecho "EXESUF=$EXESUF" >> $config_mak
115070956b77Sthsecho "AIOLIBS=$AIOLIBS" >> $config_mak
11512408a527Saurel32case "$cpu" in
11522408a527Saurel32  i386)
115397a847bcSbellard    echo "ARCH=i386" >> $config_mak
115497a847bcSbellard    echo "#define HOST_I386 1" >> $config_h
11552408a527Saurel32  ;;
11562408a527Saurel32  x86_64)
11570b0babc6Sbellard    echo "ARCH=x86_64" >> $config_mak
11580b0babc6Sbellard    echo "#define HOST_X86_64 1" >> $config_h
11592408a527Saurel32  ;;
11602408a527Saurel32  alpha)
11610938cda5Saurel32    echo "ARCH=alpha" >> $config_mak
11620938cda5Saurel32    echo "#define HOST_ALPHA 1" >> $config_h
11632408a527Saurel32  ;;
11642408a527Saurel32  armv4b)
1165808c4954Sbellard    echo "ARCH=arm" >> $config_mak
1166808c4954Sbellard    echo "#define HOST_ARM 1" >> $config_h
11672408a527Saurel32  ;;
11682408a527Saurel32  armv4l)
116997a847bcSbellard    echo "ARCH=arm" >> $config_mak
117097a847bcSbellard    echo "#define HOST_ARM 1" >> $config_h
11712408a527Saurel32  ;;
11722408a527Saurel32  cris)
1173e7daa605Sths    echo "ARCH=cris" >> $config_mak
1174e7daa605Sths    echo "#define HOST_CRIS 1" >> $config_h
11752408a527Saurel32  ;;
11762408a527Saurel32  hppa)
1177f54b3f92Saurel32    echo "ARCH=hppa" >> $config_mak
1178f54b3f92Saurel32    echo "#define HOST_HPPA 1" >> $config_h
11792408a527Saurel32  ;;
11802408a527Saurel32  ia64)
118197a847bcSbellard    echo "ARCH=ia64" >> $config_mak
118297a847bcSbellard    echo "#define HOST_IA64 1" >> $config_h
11832408a527Saurel32  ;;
11842408a527Saurel32  m68k)
118538ca2abcSbellard    echo "ARCH=m68k" >> $config_mak
118638ca2abcSbellard    echo "#define HOST_M68K 1" >> $config_h
11872408a527Saurel32  ;;
11882408a527Saurel32  mips)
11890938cda5Saurel32    echo "ARCH=mips" >> $config_mak
11900938cda5Saurel32    echo "#define HOST_MIPS 1" >> $config_h
11912408a527Saurel32  ;;
11922408a527Saurel32  mips64)
11930938cda5Saurel32    echo "ARCH=mips64" >> $config_mak
11940938cda5Saurel32    echo "#define HOST_MIPS64 1" >> $config_h
11952408a527Saurel32  ;;
11962408a527Saurel32  powerpc)
1197810260a8Smalc  if test "$hostlongbits" = "32"; then
11980938cda5Saurel32      echo "ARCH=ppc" >> $config_mak
11990938cda5Saurel32      echo "#define HOST_PPC 1" >> $config_h
1200810260a8Smalc  else
1201810260a8Smalc      echo "ARCH=ppc64" >> $config_mak
1202810260a8Smalc      echo "#define HOST_PPC64 1" >> $config_h
1203810260a8Smalc  fi
12042408a527Saurel32  ;;
12052408a527Saurel32  s390)
12060938cda5Saurel32    echo "ARCH=s390" >> $config_mak
12070938cda5Saurel32    echo "#define HOST_S390 1" >> $config_h
12082408a527Saurel32  ;;
12092408a527Saurel32  sparc)
12100938cda5Saurel32    echo "ARCH=sparc" >> $config_mak
12110938cda5Saurel32    echo "#define HOST_SPARC 1" >> $config_h
12122408a527Saurel32  ;;
12132408a527Saurel32  sparc64)
12140938cda5Saurel32    echo "ARCH=sparc64" >> $config_mak
12150938cda5Saurel32    echo "#define HOST_SPARC64 1" >> $config_h
12162408a527Saurel32  ;;
12172408a527Saurel32  *)
12183142255cSblueswir1    echo "Unsupported CPU = $cpu"
12197d13299dSbellard    exit 1
12202408a527Saurel32  ;;
12212408a527Saurel32esac
122203b4fe7dSaliguoriif test "$sparse" = "yes" ; then
122303b4fe7dSaliguori  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_mak
122403b4fe7dSaliguori  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_mak
122503b4fe7dSaliguori  echo "CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_mak
122603b4fe7dSaliguorifi
12277d13299dSbellardif test "$bigendian" = "yes" ; then
122897a847bcSbellard  echo "WORDS_BIGENDIAN=yes" >> $config_mak
122997a847bcSbellard  echo "#define WORDS_BIGENDIAN 1" >> $config_h
123097a847bcSbellardfi
1231b6853697Sbellardecho "#define HOST_LONG_BITS $hostlongbits" >> $config_h
123267b915a5Sbellardif test "$mingw32" = "yes" ; then
123367b915a5Sbellard  echo "CONFIG_WIN32=yes" >> $config_mak
123411d9f695Sbellard  echo "#define CONFIG_WIN32 1" >> $config_h
1235210fa556Spbrookelse
1236210fa556Spbrook  cat > $TMPC << EOF
1237210fa556Spbrook#include <byteswap.h>
1238210fa556Spbrookint main(void) { return bswap_32(0); }
1239210fa556SpbrookEOF
1240178baee6Saurel32  if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
124197a847bcSbellard    echo "#define HAVE_BYTESWAP_H 1" >> $config_h
124267b915a5Sbellard  fi
12431360677cSblueswir1  cat > $TMPC << EOF
12441360677cSblueswir1#include <sys/endian.h>
12451360677cSblueswir1#include <sys/types.h>
12461360677cSblueswir1#include <machine/bswap.h>
12471360677cSblueswir1int main(void) { return bswap32(0); }
12481360677cSblueswir1EOF
1249178baee6Saurel32  if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
12501360677cSblueswir1    echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
12511360677cSblueswir1  fi
1252210fa556Spbrookfi
1253128ab2ffSblueswir1
1254128ab2ffSblueswir1if [ "$openbsd" = "yes" ] ; then
1255128ab2ffSblueswir1  echo "#define ENOTSUP 4096" >> $config_h
1256128ab2ffSblueswir1fi
1257128ab2ffSblueswir1
125883fb7adfSbellardif test "$darwin" = "yes" ; then
125983fb7adfSbellard  echo "CONFIG_DARWIN=yes" >> $config_mak
126083fb7adfSbellard  echo "#define CONFIG_DARWIN 1" >> $config_h
126183fb7adfSbellardfi
1262b29fe3edSmalc
1263b29fe3edSmalcif test "$aix" = "yes" ; then
1264b29fe3edSmalc  echo "CONFIG_AIX=yes" >> $config_mak
1265b29fe3edSmalc  echo "#define CONFIG_AIX 1" >> $config_h
1266b29fe3edSmalcfi
1267b29fe3edSmalc
1268ec530c81Sbellardif test "$solaris" = "yes" ; then
1269ec530c81Sbellard  echo "CONFIG_SOLARIS=yes" >> $config_mak
127038cfa06cSbellard  echo "#define HOST_SOLARIS $solarisrev" >> $config_h
12710475a5caSths  if test "$needs_libsunmath" = "yes" ; then
12720475a5caSths    echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
12730475a5caSths    echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
12740475a5caSths  fi
1275ec530c81Sbellardfi
12763142255cSblueswir1if test -n "$sparc_cpu"; then
12773142255cSblueswir1  echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
12783142255cSblueswir1  echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
12793142255cSblueswir1fi
128067b915a5Sbellardif test "$gdbstub" = "yes" ; then
128167b915a5Sbellard  echo "CONFIG_GDBSTUB=yes" >> $config_mak
128267b915a5Sbellard  echo "#define CONFIG_GDBSTUB 1" >> $config_h
128367b915a5Sbellardfi
128497a847bcSbellardif test "$gprof" = "yes" ; then
128597a847bcSbellard  echo "TARGET_GPROF=yes" >> $config_mak
128697a847bcSbellard  echo "#define HAVE_GPROF 1" >> $config_h
128797a847bcSbellardfi
128897a847bcSbellardif test "$static" = "yes" ; then
128997a847bcSbellard  echo "CONFIG_STATIC=yes" >> $config_mak
129050863472Sbellard  echo "#define CONFIG_STATIC 1" >> $config_h
129197a847bcSbellardfi
129205c2a3e7Sbellardif test $profiler = "yes" ; then
129305c2a3e7Sbellard  echo "#define CONFIG_PROFILER 1" >> $config_h
129405c2a3e7Sbellardfi
1295c20709aaSbellardif test "$slirp" = "yes" ; then
1296c20709aaSbellard  echo "CONFIG_SLIRP=yes" >> $config_mak
1297c20709aaSbellard  echo "#define CONFIG_SLIRP 1" >> $config_h
1298c20709aaSbellardfi
12998a16d273Sthsif test "$vde" = "yes" ; then
13008a16d273Sths  echo "CONFIG_VDE=yes" >> $config_mak
13018a16d273Sths  echo "#define CONFIG_VDE 1" >> $config_h
13028a16d273Sths  echo "VDE_LIBS=-lvdeplug" >> $config_mak
13038a16d273Sthsfi
13040c58ac1cSmalcfor card in $audio_card_list; do
1305f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
13060c58ac1cSmalc    echo "$def=yes" >> $config_mak
13070c58ac1cSmalc    echo "#define $def 1" >> $config_h
13080c58ac1cSmalcdone
13090c58ac1cSmalcecho "#define AUDIO_DRIVERS \\" >> $config_h
13100c58ac1cSmalcfor drv in $audio_drv_list; do
13110c58ac1cSmalc    echo "    &${drv}_audio_driver, \\" >>$config_h
1312f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
13130c58ac1cSmalc    echo "$def=yes" >> $config_mak
1314923e4521Smalc    if test "$drv" = "fmod"; then
13150c58ac1cSmalc        echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
13160c58ac1cSmalc        echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
13172f6a1ab0Sblueswir1    elif test "$drv" = "oss"; then
13182f6a1ab0Sblueswir1        echo "CONFIG_OSS_LIB=$oss_lib" >> $config_mak
1319fb065187Sbellard    fi
13200c58ac1cSmalcdone
13210c58ac1cSmalcecho "" >>$config_h
13228ff9cbf7Smalcif test "$mixemu" = "yes" ; then
13238ff9cbf7Smalc  echo "CONFIG_MIXEMU=yes" >> $config_mak
13248ff9cbf7Smalc  echo "#define CONFIG_MIXEMU 1" >> $config_h
13258ff9cbf7Smalcfi
13268d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
13278d5d2d4cSths  echo "CONFIG_VNC_TLS=yes" >> $config_mak
13288d5d2d4cSths  echo "CONFIG_VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_mak
13298d5d2d4cSths  echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
13308d5d2d4cSths  echo "#define CONFIG_VNC_TLS 1" >> $config_h
13318d5d2d4cSthsfi
1332b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
1333b1a550a0Spbrookecho "VERSION=$qemu_version" >>$config_mak
1334d4b8f039Spbrookecho "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
133597a847bcSbellard
133697a847bcSbellardecho "SRC_PATH=$source_path" >> $config_mak
1337ad064840Spbrookif [ "$source_path_used" = "yes" ]; then
1338ad064840Spbrook  echo "VPATH=$source_path" >> $config_mak
1339ad064840Spbrookfi
134097a847bcSbellardecho "TARGET_DIRS=$target_list" >> $config_mak
1341cc8ae6deSpbrookif [ "$build_docs" = "yes" ] ; then
1342cc8ae6deSpbrook  echo "BUILD_DOCS=yes" >> $config_mak
1343cc8ae6deSpbrookfi
134449ecc3faSbellardif test "$static" = "yes"; then
134549ecc3faSbellard  sdl1=$sdl_static
134649ecc3faSbellardelse
134749ecc3faSbellard  sdl1=$sdl
134849ecc3faSbellardfi
134949ecc3faSbellardif test "$sdl1" = "yes" ; then
135049ecc3faSbellard  echo "#define CONFIG_SDL 1" >> $config_h
135149ecc3faSbellard  echo "CONFIG_SDL=yes" >> $config_mak
135249ecc3faSbellard  if test "$target_softmmu" = "no" -o "$static" = "yes"; then
135349ecc3faSbellard    echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
135449ecc3faSbellard  else
135549ecc3faSbellard    echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
135649ecc3faSbellard  fi
135749ecc3faSbellard  if [ "${aa}" = "yes" ] ; then
135849ecc3faSbellard    echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
135949ecc3faSbellard  else
136049ecc3faSbellard    echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
136149ecc3faSbellard  fi
136249ecc3faSbellardfi
136349ecc3faSbellardif test "$cocoa" = "yes" ; then
136449ecc3faSbellard  echo "#define CONFIG_COCOA 1" >> $config_h
136549ecc3faSbellard  echo "CONFIG_COCOA=yes" >> $config_mak
136649ecc3faSbellardfi
13674d3b6f6eSbalrogif test "$curses" = "yes" ; then
13684d3b6f6eSbalrog  echo "#define CONFIG_CURSES 1" >> $config_h
13694d3b6f6eSbalrog  echo "CONFIG_CURSES=yes" >> $config_mak
13704d3b6f6eSbalrog  echo "CURSES_LIBS=-lcurses" >> $config_mak
13714d3b6f6eSbalrogfi
13722e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
13732e4d9fb1Saurel32  echo "CONFIG_BRLAPI=yes" >> $config_mak
13742e4d9fb1Saurel32  echo "#define CONFIG_BRLAPI 1" >> $config_h
13752e4d9fb1Saurel32  echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
13762e4d9fb1Saurel32fi
1377fb599c9aSbalrogif test "$bluez" = "yes" ; then
1378fb599c9aSbalrog  echo "CONFIG_BLUEZ=yes" >> $config_mak
1379fb599c9aSbalrog  echo "CONFIG_BLUEZ_CFLAGS=$bluez_cflags" >> $config_mak
1380fb599c9aSbalrog  echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
1381fb599c9aSbalrog  echo "#define CONFIG_BLUEZ 1" >> $config_h
1382fb599c9aSbalrogfi
1383414f0dabSblueswir1if test "$aio" = "yes" ; then
1384414f0dabSblueswir1  echo "#define CONFIG_AIO 1" >> $config_h
1385a3392f9bSaliguori  echo "CONFIG_AIO=yes" >> $config_mak
1386414f0dabSblueswir1fi
138777755340Sthsif test "$blobs" = "yes" ; then
138877755340Sths  echo "INSTALL_BLOBS=yes" >> $config_mak
138977755340Sthsfi
1390bf9298b9Saliguoriif test "$iovec" = "yes" ; then
1391bf9298b9Saliguori  echo "#define HAVE_IOVEC 1" >> $config_h
1392bf9298b9Saliguorifi
1393f652e6afSaurel32if test "$fdt" = "yes" ; then
1394f652e6afSaurel32  echo "#define HAVE_FDT 1" >> $config_h
1395f652e6afSaurel32  echo "FDT_LIBS=-lfdt" >> $config_mak
1396f652e6afSaurel32fi
139797a847bcSbellard
139883fb7adfSbellard# XXX: suppress that
13997d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
140043003046Sbellard  echo "#define O_LARGEFILE 0" >> $config_h
140143003046Sbellard  echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
14027d3505c5Sbellard  echo "#define _BSD 1" >> $config_h
14037d3505c5Sbellardfi
14047d3505c5Sbellard
1405c5937220Spbrookecho "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
1406c5937220Spbrook
140768063649Sblueswir1# USB host support
140868063649Sblueswir1case "$usb" in
140968063649Sblueswir1linux)
141068063649Sblueswir1  echo "HOST_USB=linux" >> $config_mak
141168063649Sblueswir1;;
141268063649Sblueswir1bsd)
141368063649Sblueswir1  echo "HOST_USB=bsd" >> $config_mak
141468063649Sblueswir1;;
141568063649Sblueswir1*)
141668063649Sblueswir1  echo "HOST_USB=stub" >> $config_mak
141768063649Sblueswir1;;
141868063649Sblueswir1esac
141968063649Sblueswir1
1420c39e3338Spbrooktools=
1421c39e3338Spbrookif test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
1422c39e3338Spbrook  tools="qemu-img\$(EXESUF) $tools"
14237a5ca864Sbellard  if [ "$linux" = "yes" ] ; then
14247a5ca864Sbellard      tools="qemu-nbd\$(EXESUF) $tools"
14257a5ca864Sbellard  fi
1426c39e3338Spbrookfi
1427c39e3338Spbrookecho "TOOLS=$tools" >> $config_mak
1428c39e3338Spbrook
142915d9ca0fSthstest -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
143015d9ca0fSths
143197a847bcSbellardfor target in $target_list; do
143297a847bcSbellardtarget_dir="$target"
143397a847bcSbellardconfig_mak=$target_dir/config.mak
143497a847bcSbellardconfig_h=$target_dir/config.h
143597a847bcSbellardtarget_cpu=`echo $target | cut -d '-' -f 1`
143697a847bcSbellardtarget_bigendian="no"
1437808c4954Sbellard[ "$target_cpu" = "armeb" ] && target_bigendian=yes
14380938cda5Saurel32[ "$target_cpu" = "m68k" ] && target_bigendian=yes
14390938cda5Saurel32[ "$target_cpu" = "mips" ] && target_bigendian=yes
14400938cda5Saurel32[ "$target_cpu" = "mipsn32" ] && target_bigendian=yes
14410938cda5Saurel32[ "$target_cpu" = "mips64" ] && target_bigendian=yes
144267867308Sbellard[ "$target_cpu" = "ppc" ] && target_bigendian=yes
1443d4082e95Sj_mayer[ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
144422f8a8b3Sj_mayer[ "$target_cpu" = "ppc64" ] && target_bigendian=yes
1445e85e7c6eSj_mayer[ "$target_cpu" = "ppc64abi32" ] && target_bigendian=yes
1446908f52b0Spbrook[ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
14470938cda5Saurel32[ "$target_cpu" = "sparc" ] && target_bigendian=yes
14480938cda5Saurel32[ "$target_cpu" = "sparc64" ] && target_bigendian=yes
14490938cda5Saurel32[ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
145097a847bcSbellardtarget_softmmu="no"
1451997344f3Sbellardtarget_user_only="no"
1452831b7825Sthstarget_linux_user="no"
1453831b7825Sthstarget_darwin_user="no"
145484778508Sblueswir1target_bsd_user="no"
14559e407a85Spbrookcase "$target" in
14569e407a85Spbrook  ${target_cpu}-softmmu)
14579e407a85Spbrook    target_softmmu="yes"
14589e407a85Spbrook    ;;
14599e407a85Spbrook  ${target_cpu}-linux-user)
14609e407a85Spbrook    target_user_only="yes"
14619e407a85Spbrook    target_linux_user="yes"
14629e407a85Spbrook    ;;
14639e407a85Spbrook  ${target_cpu}-darwin-user)
14649e407a85Spbrook    target_user_only="yes"
1465831b7825Sths    target_darwin_user="yes"
14669e407a85Spbrook    ;;
146784778508Sblueswir1  ${target_cpu}-bsd-user)
146884778508Sblueswir1    target_user_only="yes"
146984778508Sblueswir1    target_bsd_user="yes"
147084778508Sblueswir1    ;;
14719e407a85Spbrook  *)
14729e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
14739e407a85Spbrook    exit 1
14749e407a85Spbrook    ;;
14759e407a85Spbrookesac
1476831b7825Sths
147797ccc689Sbellardif test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
147897ccc689Sbellard        -a "$sdl" = "no" -a "$cocoa" = "no" ; then
147997ccc689Sbellard    echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
14809c038506Spbrook    echo "To build QEMU without graphical output configure with --disable-gfx-check"
14814d3b6f6eSbalrog    echo "Note that this will disable all output from the virtual graphics card"
14824d3b6f6eSbalrog    echo "except through VNC or curses."
148397ccc689Sbellard    exit 1;
148497ccc689Sbellardfi
148597ccc689Sbellard
14867c1f25b4Sbellard#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
148797a847bcSbellard
148815d9ca0fSthstest -f $config_h && mv $config_h ${config_h}~
148915d9ca0fSths
149097a847bcSbellardmkdir -p $target_dir
1491158142c2Sbellardmkdir -p $target_dir/fpu
149257fec1feSbellardmkdir -p $target_dir/tcg
149384778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
149469de927cSbellard  mkdir -p $target_dir/nwfpe
149569de927cSbellardfi
149669de927cSbellard
1497ec530c81Sbellard#
1498ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
1499ec530c81Sbellard#
1500ec530c81Sbellardrm -f $target_dir/Makefile
1501ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
1502ec530c81Sbellard
150397a847bcSbellard
150497a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
150597a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
150697a847bcSbellard
150797a847bcSbellard
150897a847bcSbellardecho "include ../config-host.mak" >> $config_mak
150997a847bcSbellardecho "#include \"../config-host.h\"" >> $config_h
15101e43adfcSbellard
1511e5fe0c52Spbrookbflt="no"
1512cb33da57Sblueswir1elfload32="no"
1513bd0c5661Spbrooktarget_nptl="no"
15141e43adfcSbellardinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
15151e43adfcSbellardecho "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
151656aebc89Spbrookgdb_xml_files=""
151797a847bcSbellard
15185985eceeSaliguori# Make sure the target and host cpus are compatible
15195985eceeSaliguoriif test "$kvm" = "yes" -a ! \( "$target_cpu" = "$cpu" -o \
1520d76d1650Saurel32  \( "$target_cpu" = "ppcemb" -a "$cpu" = "powerpc" \) -o \
15215985eceeSaliguori  \( "$target_cpu" = "x86_64" -a "$cpu" = "i386"   \) -o \
15225985eceeSaliguori  \( "$target_cpu" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
15237ba1e619Saliguori  kvm="no"
15247ba1e619Saliguorifi
15257ba1e619Saliguori# Disable KVM for linux-user
15267ba1e619Saliguoriif test "$kvm" = "yes" -a "$target_softmmu" = "no" ; then
15277ba1e619Saliguori  kvm="no"
15287ba1e619Saliguorifi
15297ba1e619Saliguori
15302408a527Saurel32case "$target_cpu" in
15312408a527Saurel32  i386)
153297a847bcSbellard    echo "TARGET_ARCH=i386" >> $config_mak
153397a847bcSbellard    echo "#define TARGET_ARCH \"i386\"" >> $config_h
153497a847bcSbellard    echo "#define TARGET_I386 1" >> $config_h
1535da260249Sbellard    if test $kqemu = "yes" -a "$target_softmmu" = "yes"
15362408a527Saurel32    then
1537824d560fSbellard      echo "#define USE_KQEMU 1" >> $config_h
1538824d560fSbellard    fi
15397ba1e619Saliguori    if test "$kvm" = "yes" ; then
15407ba1e619Saliguori      echo "CONFIG_KVM=yes" >> $config_mak
15417ba1e619Saliguori      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
15425985eceeSaliguori      echo "#define CONFIG_KVM 1" >> $config_h
15437ba1e619Saliguori    fi
15442408a527Saurel32  ;;
15452408a527Saurel32  x86_64)
15460938cda5Saurel32    echo "TARGET_ARCH=x86_64" >> $config_mak
15470938cda5Saurel32    echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
15480938cda5Saurel32    echo "#define TARGET_I386 1" >> $config_h
15490938cda5Saurel32    echo "#define TARGET_X86_64 1" >> $config_h
15502408a527Saurel32    if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"
15512408a527Saurel32    then
15520938cda5Saurel32      echo "#define USE_KQEMU 1" >> $config_h
15530938cda5Saurel32    fi
15547ba1e619Saliguori    if test "$kvm" = "yes" ; then
15557ba1e619Saliguori      echo "CONFIG_KVM=yes" >> $config_mak
15567ba1e619Saliguori      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
15577ba1e619Saliguori      echo "#define CONFIG_KVM 1" >> $config_h
15587ba1e619Saliguori    fi
15592408a527Saurel32  ;;
15602408a527Saurel32  alpha)
15610938cda5Saurel32    echo "TARGET_ARCH=alpha" >> $config_mak
15620938cda5Saurel32    echo "#define TARGET_ARCH \"alpha\"" >> $config_h
15630938cda5Saurel32    echo "#define TARGET_ALPHA 1" >> $config_h
15642408a527Saurel32  ;;
15652408a527Saurel32  arm|armeb)
156697a847bcSbellard    echo "TARGET_ARCH=arm" >> $config_mak
156797a847bcSbellard    echo "#define TARGET_ARCH \"arm\"" >> $config_h
156897a847bcSbellard    echo "#define TARGET_ARM 1" >> $config_h
1569e5fe0c52Spbrook    bflt="yes"
1570bd0c5661Spbrook    target_nptl="yes"
157156aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
15722408a527Saurel32  ;;
15732408a527Saurel32  cris)
15740938cda5Saurel32    echo "TARGET_ARCH=cris" >> $config_mak
15750938cda5Saurel32    echo "#define TARGET_ARCH \"cris\"" >> $config_h
15760938cda5Saurel32    echo "#define TARGET_CRIS 1" >> $config_h
15772408a527Saurel32  ;;
15782408a527Saurel32  m68k)
15790938cda5Saurel32    echo "TARGET_ARCH=m68k" >> $config_mak
15800938cda5Saurel32    echo "#define TARGET_ARCH \"m68k\"" >> $config_h
15810938cda5Saurel32    echo "#define TARGET_M68K 1" >> $config_h
15820938cda5Saurel32    bflt="yes"
158356aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
15842408a527Saurel32  ;;
15852408a527Saurel32  mips|mipsel)
15860938cda5Saurel32    echo "TARGET_ARCH=mips" >> $config_mak
15870938cda5Saurel32    echo "#define TARGET_ARCH \"mips\"" >> $config_h
15880938cda5Saurel32    echo "#define TARGET_MIPS 1" >> $config_h
15890938cda5Saurel32    echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
15902408a527Saurel32  ;;
15912408a527Saurel32  mipsn32|mipsn32el)
15920938cda5Saurel32    echo "TARGET_ARCH=mipsn32" >> $config_mak
15930938cda5Saurel32    echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
15940938cda5Saurel32    echo "#define TARGET_MIPS 1" >> $config_h
15950938cda5Saurel32    echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
15962408a527Saurel32  ;;
15972408a527Saurel32  mips64|mips64el)
15980938cda5Saurel32    echo "TARGET_ARCH=mips64" >> $config_mak
15990938cda5Saurel32    echo "#define TARGET_ARCH \"mips64\"" >> $config_h
16000938cda5Saurel32    echo "#define TARGET_MIPS 1" >> $config_h
16010938cda5Saurel32    echo "#define TARGET_MIPS64 1" >> $config_h
16020938cda5Saurel32    echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
16032408a527Saurel32  ;;
16042408a527Saurel32  ppc)
160567867308Sbellard    echo "TARGET_ARCH=ppc" >> $config_mak
160667867308Sbellard    echo "#define TARGET_ARCH \"ppc\"" >> $config_h
160767867308Sbellard    echo "#define TARGET_PPC 1" >> $config_h
16082408a527Saurel32  ;;
16092408a527Saurel32  ppcemb)
1610d4082e95Sj_mayer    echo "TARGET_ARCH=ppcemb" >> $config_mak
1611e85e7c6eSj_mayer    echo "TARGET_ABI_DIR=ppc" >> $config_mak
1612d4082e95Sj_mayer    echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
1613d4082e95Sj_mayer    echo "#define TARGET_PPC 1" >> $config_h
1614d4082e95Sj_mayer    echo "#define TARGET_PPCEMB 1" >> $config_h
1615d76d1650Saurel32    if test "$kvm" = "yes" ; then
1616d76d1650Saurel32      echo "CONFIG_KVM=yes" >> $config_mak
1617d76d1650Saurel32      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
1618d76d1650Saurel32      echo "#define CONFIG_KVM 1" >> $config_h
1619d76d1650Saurel32    fi
16202408a527Saurel32  ;;
16212408a527Saurel32  ppc64)
162222f8a8b3Sj_mayer    echo "TARGET_ARCH=ppc64" >> $config_mak
1623f85e9a68Sj_mayer    echo "TARGET_ABI_DIR=ppc" >> $config_mak
16245e692ecdSj_mayer    echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
162522f8a8b3Sj_mayer    echo "#define TARGET_PPC 1" >> $config_h
162622f8a8b3Sj_mayer    echo "#define TARGET_PPC64 1" >> $config_h
16272408a527Saurel32  ;;
16282408a527Saurel32  ppc64abi32)
1629e85e7c6eSj_mayer    echo "TARGET_ARCH=ppc64" >> $config_mak
1630e85e7c6eSj_mayer    echo "TARGET_ABI_DIR=ppc" >> $config_mak
16310c64b9cdSbellard    echo "TARGET_ARCH2=ppc64abi32" >> $config_mak
16325e692ecdSj_mayer    echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
1633e85e7c6eSj_mayer    echo "#define TARGET_PPC 1" >> $config_h
1634e85e7c6eSj_mayer    echo "#define TARGET_PPC64 1" >> $config_h
1635e85e7c6eSj_mayer    echo "#define TARGET_ABI32 1" >> $config_h
16362408a527Saurel32  ;;
16372408a527Saurel32  sh4|sh4eb)
1638fdf9b3e8Sbellard    echo "TARGET_ARCH=sh4" >> $config_mak
1639fdf9b3e8Sbellard    echo "#define TARGET_ARCH \"sh4\"" >> $config_h
1640fdf9b3e8Sbellard    echo "#define TARGET_SH4 1" >> $config_h
16414dbed897Spbrook    bflt="yes"
16420b6d3ae0Saurel32    target_nptl="yes"
16432408a527Saurel32  ;;
16442408a527Saurel32  sparc)
16450938cda5Saurel32    echo "TARGET_ARCH=sparc" >> $config_mak
16460938cda5Saurel32    echo "#define TARGET_ARCH \"sparc\"" >> $config_h
16470938cda5Saurel32    echo "#define TARGET_SPARC 1" >> $config_h
16482408a527Saurel32  ;;
16492408a527Saurel32  sparc64)
16500938cda5Saurel32    echo "TARGET_ARCH=sparc64" >> $config_mak
16510938cda5Saurel32    echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
16520938cda5Saurel32    echo "#define TARGET_SPARC 1" >> $config_h
16530938cda5Saurel32    echo "#define TARGET_SPARC64 1" >> $config_h
16540938cda5Saurel32    elfload32="yes"
16552408a527Saurel32  ;;
16562408a527Saurel32  sparc32plus)
16570938cda5Saurel32    echo "TARGET_ARCH=sparc64" >> $config_mak
16580938cda5Saurel32    echo "TARGET_ABI_DIR=sparc" >> $config_mak
16590938cda5Saurel32    echo "TARGET_ARCH2=sparc32plus" >> $config_mak
16600938cda5Saurel32    echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
16610938cda5Saurel32    echo "#define TARGET_SPARC 1" >> $config_h
16620938cda5Saurel32    echo "#define TARGET_SPARC64 1" >> $config_h
16630938cda5Saurel32    echo "#define TARGET_ABI32 1" >> $config_h
16642408a527Saurel32  ;;
16652408a527Saurel32  *)
1666de83cd02Sbellard    echo "Unsupported target CPU"
1667de83cd02Sbellard    exit 1
16682408a527Saurel32  ;;
16692408a527Saurel32esac
1670de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
167197a847bcSbellard  echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
167297a847bcSbellard  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
167397a847bcSbellardfi
167497a847bcSbellardif test "$target_softmmu" = "yes" ; then
167597a847bcSbellard  echo "CONFIG_SOFTMMU=yes" >> $config_mak
167697a847bcSbellard  echo "#define CONFIG_SOFTMMU 1" >> $config_h
1677de83cd02Sbellardfi
1678997344f3Sbellardif test "$target_user_only" = "yes" ; then
1679997344f3Sbellard  echo "CONFIG_USER_ONLY=yes" >> $config_mak
1680997344f3Sbellard  echo "#define CONFIG_USER_ONLY 1" >> $config_h
1681997344f3Sbellardfi
1682831b7825Sthsif test "$target_linux_user" = "yes" ; then
1683831b7825Sths  echo "CONFIG_LINUX_USER=yes" >> $config_mak
1684831b7825Sths  echo "#define CONFIG_LINUX_USER 1" >> $config_h
1685831b7825Sthsfi
1686831b7825Sthsif test "$target_darwin_user" = "yes" ; then
1687831b7825Sths  echo "CONFIG_DARWIN_USER=yes" >> $config_mak
1688831b7825Sths  echo "#define CONFIG_DARWIN_USER 1" >> $config_h
1689831b7825Sthsfi
169056aebc89Spbrooklist=""
169156aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
169256aebc89Spbrook  for x in $gdb_xml_files; do
169356aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
169456aebc89Spbrook  done
169556aebc89Spbrookfi
169656aebc89Spbrookecho "TARGET_XML_FILES=$list" >> $config_mak
1697de83cd02Sbellard
16980938cda5Saurel32if test "$target_cpu" = "arm" \
16990938cda5Saurel32     -o "$target_cpu" = "armeb" \
17000938cda5Saurel32     -o "$target_cpu" = "m68k" \
17010938cda5Saurel32     -o "$target_cpu" = "mips" \
17020938cda5Saurel32     -o "$target_cpu" = "mipsel" \
17030938cda5Saurel32     -o "$target_cpu" = "mipsn32" \
17040938cda5Saurel32     -o "$target_cpu" = "mipsn32el" \
17050938cda5Saurel32     -o "$target_cpu" = "mips64" \
17060938cda5Saurel32     -o "$target_cpu" = "mips64el" \
17073147d1e8Saurel32     -o "$target_cpu" = "ppc" \
17083147d1e8Saurel32     -o "$target_cpu" = "ppc64" \
170971e991fdSaurel32     -o "$target_cpu" = "ppc64abi32" \
171071e991fdSaurel32     -o "$target_cpu" = "ppcemb" \
17110938cda5Saurel32     -o "$target_cpu" = "sparc" \
17120938cda5Saurel32     -o "$target_cpu" = "sparc64" \
17130938cda5Saurel32     -o "$target_cpu" = "sparc32plus"; then
1714158142c2Sbellard  echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
1715158142c2Sbellard  echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
1716158142c2Sbellardfi
1717e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
1718e5fe0c52Spbrook  echo "TARGET_HAS_BFLT=yes" >> $config_mak
1719e5fe0c52Spbrook  echo "#define TARGET_HAS_BFLT 1" >> $config_h
1720e5fe0c52Spbrookfi
1721bd0c5661Spbrookif test "$target_user_only" = "yes" \
1722bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
1723bd0c5661Spbrook  echo "#define USE_NPTL 1" >> $config_h
1724bd0c5661Spbrookfi
1725cb33da57Sblueswir1# 32 bit ELF loader in addition to native 64 bit loader?
1726cb33da57Sblueswir1if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
1727cb33da57Sblueswir1  echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
1728cb33da57Sblueswir1  echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
1729cb33da57Sblueswir1fi
173084778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
173184778508Sblueswir1  echo "CONFIG_BSD_USER=yes" >> $config_mak
173284778508Sblueswir1  echo "#define CONFIG_BSD_USER 1" >> $config_h
173384778508Sblueswir1fi
17345b0753e0Sbellard
173515d9ca0fSthstest -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
173615d9ca0fSths
173797a847bcSbellarddone # for target in $targets
17387d13299dSbellard
17397d13299dSbellard# build tree in object directory if source path is different from current one
17407d13299dSbellardif test "$source_path_used" = "yes" ; then
174149ecc3faSbellard    DIRS="tests tests/cris slirp audio"
17427d13299dSbellard    FILES="Makefile tests/Makefile"
1743e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
1744e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
17457d13299dSbellard    for dir in $DIRS ; do
17467d13299dSbellard            mkdir -p $dir
17477d13299dSbellard    done
1748ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
17497d13299dSbellard    for f in $FILES ; do
1750ec530c81Sbellard        rm -f $f
1751ec530c81Sbellard        ln -s $source_path/$f $f
17527d13299dSbellard    done
17537d13299dSbellardfi
1754