xref: /openbmc/qemu/configure (revision ab4e5602)
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=""
304c9b53e3Smalcaudio_card_list="ac97 es1370 sb16"
314c9b53e3Smalcaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
327d13299dSbellardhost_cc="gcc"
337d13299dSbellardar="ar"
347d13299dSbellardmake="make"
356a882643Spbrookinstall="install"
367d13299dSbellardstrip="strip"
37ac0df51dSaliguori
38ac0df51dSaliguori# parse CC options first
39ac0df51dSaliguorifor opt do
40ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
41ac0df51dSaliguori  case "$opt" in
42ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
43ac0df51dSaliguori  ;;
44ac0df51dSaliguori  --cc=*) cc="$optarg"
45ac0df51dSaliguori  ;;
46ac0df51dSaliguori  esac
47ac0df51dSaliguoridone
48ac0df51dSaliguori
49ac0df51dSaliguori# OS specific
50ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
51ac0df51dSaliguori# we can eliminate it's usage altogether
52ac0df51dSaliguori
53ac0df51dSaliguoricc="${cross_prefix}${cc}"
54ac0df51dSaliguoriar="${cross_prefix}${ar}"
55ac0df51dSaliguoristrip="${cross_prefix}${strip}"
56ac0df51dSaliguori
57ac0df51dSaliguori# check that the C compiler works.
58ac0df51dSaliguoricat > $TMPC <<EOF
59ac0df51dSaliguoriint main(void) {}
60ac0df51dSaliguoriEOF
61ac0df51dSaliguori
62ac0df51dSaliguoriif $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
63ac0df51dSaliguori  : C compiler works ok
64ac0df51dSaliguorielse
65ac0df51dSaliguori    echo "ERROR: \"$cc\" either does not exist or does not work"
66ac0df51dSaliguori    exit 1
67ac0df51dSaliguorifi
68ac0df51dSaliguori
69ac0df51dSaliguoricheck_define() {
70ac0df51dSaliguoricat > $TMPC <<EOF
71ac0df51dSaliguori#if !defined($1)
72ac0df51dSaliguori#error Not defined
73ac0df51dSaliguori#endif
74ac0df51dSaliguoriint main(void) { return 0; }
75ac0df51dSaliguoriEOF
76ac0df51dSaliguori  $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
77ac0df51dSaliguori}
78ac0df51dSaliguori
79ac0df51dSaliguoriif check_define __i386__ ; then
80ac0df51dSaliguori  cpu="i386"
81ac0df51dSaliguorielif check_define __x86_64__ ; then
82ac0df51dSaliguori  cpu="x86_64"
833aa9bd6cSblueswir1elif check_define __sparc__ ; then
843aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
853aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
863aa9bd6cSblueswir1  if check_define __arch64__ ; then
873aa9bd6cSblueswir1    cpu="sparc64"
883aa9bd6cSblueswir1  else
893aa9bd6cSblueswir1    cpu="sparc"
903aa9bd6cSblueswir1  fi
91fdf7ed96Smalcelif check_define _ARCH_PPC ; then
92fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
93fdf7ed96Smalc    cpu="ppc64"
94ac0df51dSaliguori  else
95fdf7ed96Smalc    cpu="ppc"
96fdf7ed96Smalc  fi
97fdf7ed96Smalcelse
98fdf7ed96Smalc  cpu=`uname -m`
99ac0df51dSaliguorifi
100ac0df51dSaliguori
1015327cf48Sbellardtarget_list=""
1027d13299dSbellardcase "$cpu" in
1037d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
10497a847bcSbellard    cpu="i386"
1057d13299dSbellard  ;;
106aaa5fa14Saurel32  x86_64|amd64)
107aaa5fa14Saurel32    cpu="x86_64"
108aaa5fa14Saurel32  ;;
109aaa5fa14Saurel32  alpha)
110aaa5fa14Saurel32    cpu="alpha"
111aaa5fa14Saurel32  ;;
112ba68055eSbellard  armv*b)
113808c4954Sbellard    cpu="armv4b"
114808c4954Sbellard  ;;
115ba68055eSbellard  armv*l)
1167d13299dSbellard    cpu="armv4l"
1177d13299dSbellard  ;;
118aaa5fa14Saurel32  cris)
119aaa5fa14Saurel32    cpu="cris"
1207d13299dSbellard  ;;
121f54b3f92Saurel32  parisc|parisc64)
122f54b3f92Saurel32    cpu="hppa"
123f54b3f92Saurel32  ;;
124aaa5fa14Saurel32  ia64)
125aaa5fa14Saurel32    cpu="ia64"
126aaa5fa14Saurel32  ;;
127aaa5fa14Saurel32  m68k)
128aaa5fa14Saurel32    cpu="m68k"
1297d13299dSbellard  ;;
13072b675caSEdgar E. Iglesias  microblaze)
13172b675caSEdgar E. Iglesias    cpu="microblaze"
13272b675caSEdgar E. Iglesias  ;;
1337d13299dSbellard  mips)
1347d13299dSbellard    cpu="mips"
1357d13299dSbellard  ;;
136fbe4f65bSths  mips64)
137fbe4f65bSths    cpu="mips64"
138fbe4f65bSths  ;;
139fdf7ed96Smalc  ppc)
140fdf7ed96Smalc    cpu="ppc"
141fdf7ed96Smalc  ;;
142fdf7ed96Smalc  ppc64)
143fdf7ed96Smalc    cpu="ppc64"
144e7daa605Sths  ;;
1450e7b8a9fSths  s390*)
146fb3e5849Sbellard    cpu="s390"
147fb3e5849Sbellard  ;;
1483142255cSblueswir1  sparc|sun4[cdmuv])
149ae228531Sbellard    cpu="sparc"
150ae228531Sbellard  ;;
151ae228531Sbellard  sparc64)
152ae228531Sbellard    cpu="sparc64"
153ae228531Sbellard  ;;
1547d13299dSbellard  *)
1557d13299dSbellard    cpu="unknown"
1567d13299dSbellard  ;;
1577d13299dSbellardesac
1587d13299dSbellardgprof="no"
159f8393946Saurel32debug_tcg="no"
160f3d08ee6SPaul Brookdebug="no"
16103b4fe7dSaliguorisparse="no"
1621625af87Saliguoristrip_opt="yes"
1637d13299dSbellardbigendian="no"
16467b915a5Sbellardmingw32="no"
16567b915a5SbellardEXESUF=""
166443f1376Sbellardslirp="yes"
167e0e6c8c0Saliguorivde="yes"
168102a52e4Sbellardfmod_lib=""
169102a52e4Sbellardfmod_inc=""
1702f6a1ab0Sblueswir1oss_lib=""
1718d5d2d4cSthsvnc_tls="yes"
1722f9606b3Saliguorivnc_sasl="yes"
173b1a550a0Spbrookbsd="no"
1745327cf48Sbellardlinux="no"
175d2c7c9b8Sblueswir1solaris="no"
176c9ec1fe4Sbellardkqemu="no"
17705c2a3e7Sbellardprofiler="no"
1785b0753e0Sbellardcocoa="no"
1790a8e90f4Spbrooksoftmmu="yes"
180831b7825Sthslinux_user="no"
181831b7825Sthsdarwin_user="no"
18284778508Sblueswir1bsd_user="no"
18370ec5dc0SAnthony Liguoribuild_docs="yes"
184c5937220Spbrookuname_release=""
1854d3b6f6eSbalrogcurses="yes"
186769ce76dSAlexander Grafcurl="yes"
187e5d355d1Saliguoripthread="yes"
188414f0dabSblueswir1aio="yes"
189e5d355d1Saliguoriio_thread="no"
190bd0c5661Spbrooknptl="yes"
1918ff9cbf7Smalcmixemu="no"
192fb599c9aSbalrogbluez="yes"
193dff84034SJan Kiszkakvm="no"
194eac30262Saliguorikerneldir=""
195b29fe3edSmalcaix="no"
19677755340Sthsblobs="yes"
197f652e6afSaurel32fdt="yes"
198f92f8afeSAnthony Liguorisdl="yes"
1995368a422Saliguorisdl_x11="no"
200e37630caSaliguorixen="yes"
2014a19f1ecSpbrookpkgversion=""
2027d13299dSbellard
2037d13299dSbellard# OS specific
204ac0df51dSaliguoriif check_define __linux__ ; then
205ac0df51dSaliguori  targetos="Linux"
206ac0df51dSaliguorielif check_define _WIN32 ; then
207ac0df51dSaliguori  targetos='MINGW32'
208169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
209169dc5d3Sblueswir1  targetos='OpenBSD'
210169dc5d3Sblueswir1elif check_define __sun__ ; then
211169dc5d3Sblueswir1  targetos='SunOS'
212ac0df51dSaliguorielse
2137d13299dSbellard  targetos=`uname -s`
214ac0df51dSaliguorifi
2157d13299dSbellardcase $targetos in
216c326e0afSbellardCYGWIN*)
217c326e0afSbellardmingw32="yes"
2186f30fa85SthsOS_CFLAGS="-mno-cygwin"
219db8d7dd1Sthsif [ "$cpu" = "i386" ] ; then
220db8d7dd1Sths    kqemu="yes"
221db8d7dd1Sthsfi
222c2de5c91Smalcaudio_possible_drivers="sdl"
223c326e0afSbellard;;
22467b915a5SbellardMINGW32*)
22567b915a5Sbellardmingw32="yes"
226db8d7dd1Sthsif [ "$cpu" = "i386" ] ; then
227db8d7dd1Sths    kqemu="yes"
228db8d7dd1Sthsfi
229c2de5c91Smalcaudio_possible_drivers="dsound sdl fmod"
23067b915a5Sbellard;;
2315c40d2bdSthsGNU/kFreeBSD)
2320c58ac1cSmalcaudio_drv_list="oss"
233f34af52cSaurel32audio_possible_drivers="oss sdl esd pa"
2345c40d2bdSthsif [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
2355c40d2bdSths    kqemu="yes"
2365c40d2bdSthsfi
2375c40d2bdSths;;
2387d3505c5SbellardFreeBSD)
2397d3505c5Sbellardbsd="yes"
2400c58ac1cSmalcaudio_drv_list="oss"
241f34af52cSaurel32audio_possible_drivers="oss sdl esd pa"
242e99f9060Sbellardif [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
24307f4ddbfSbellard    kqemu="yes"
24407f4ddbfSbellardfi
2457d3505c5Sbellard;;
246c5e97233Sblueswir1DragonFly)
247c5e97233Sblueswir1bsd="yes"
248c5e97233Sblueswir1audio_drv_list="oss"
249c5e97233Sblueswir1audio_possible_drivers="oss sdl esd pa"
250c5e97233Sblueswir1if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
251c5e97233Sblueswir1    kqemu="yes"
252c5e97233Sblueswir1fi
253c5e97233Sblueswir1aio="no"
254c5e97233Sblueswir1;;
2557d3505c5SbellardNetBSD)
2567d3505c5Sbellardbsd="yes"
2570c58ac1cSmalcaudio_drv_list="oss"
258c2de5c91Smalcaudio_possible_drivers="oss sdl esd"
2598ef92a88Sblueswir1oss_lib="-lossaudio"
2607d3505c5Sbellard;;
2617d3505c5SbellardOpenBSD)
2627d3505c5Sbellardbsd="yes"
263128ab2ffSblueswir1openbsd="yes"
2640c58ac1cSmalcaudio_drv_list="oss"
265c2de5c91Smalcaudio_possible_drivers="oss sdl esd"
2662f6a1ab0Sblueswir1oss_lib="-lossaudio"
2677d3505c5Sbellard;;
26883fb7adfSbellardDarwin)
26983fb7adfSbellardbsd="yes"
27083fb7adfSbellarddarwin="yes"
2711b0f9cc2Saliguori# on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can run 64-bit userspace code
272aab8588aSmalcif [ "$cpu" = "i386" ] ; then
2731b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
274aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
2751b0f9cc2Saliguorifi
2761b0f9cc2Saliguoriif [ "$cpu" = "x86_64" ] ; then
2771b0f9cc2Saliguori    OS_CFLAGS="-arch x86_64"
2781b0f9cc2Saliguori    LDFLAGS="-arch x86_64"
2791b0f9cc2Saliguorielse
2801b0f9cc2Saliguori    OS_CFLAGS="-mdynamic-no-pic"
2811b0f9cc2Saliguorifi
282831b7825Sthsdarwin_user="yes"
283fd677642Sthscocoa="yes"
2840c58ac1cSmalcaudio_drv_list="coreaudio"
285c2de5c91Smalcaudio_possible_drivers="coreaudio sdl fmod"
286c2c59c3eSthsOS_LDFLAGS="-framework CoreFoundation -framework IOKit"
28783fb7adfSbellard;;
288ec530c81SbellardSunOS)
289ec530c81Sbellard    solaris="yes"
290c2b84fabSths    make="gmake"
291c2b84fabSths    install="ginstall"
2920475a5caSths    needs_libsunmath="no"
293c2b84fabSths    solarisrev=`uname -r | cut -f2 -d.`
294ef18c883Sths    # have to select again, because `uname -m` returns i86pc
295ef18c883Sths    # even on an x86_64 box.
296ef18c883Sths    solariscpu=`isainfo -k`
297ef18c883Sths    if test "${solariscpu}" = "amd64" ; then
298ef18c883Sths        cpu="x86_64"
299ef18c883Sths    fi
300c2b84fabSths    if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
3010475a5caSths        if test "$solarisrev" -le 9 ; then
3020475a5caSths            if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
3030475a5caSths                needs_libsunmath="yes"
3040475a5caSths            else
3050475a5caSths                echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
3060475a5caSths                echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
3070475a5caSths                echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
3080475a5caSths                echo "Studio 11 can be downloaded from www.sun.com."
3090475a5caSths                exit 1
3100475a5caSths            fi
3110475a5caSths        fi
3120475a5caSths        if test "$solarisrev" -ge 9 ; then
313c2b84fabSths            kqemu="yes"
314c2b84fabSths        fi
31586b2bd93Sths    fi
3166b4d2ba1Sths    if test -f /usr/include/sys/soundcard.h ; then
3170c58ac1cSmalc        audio_drv_list="oss"
3186b4d2ba1Sths    fi
319c2de5c91Smalc    audio_possible_drivers="oss sdl"
32014d483ecSblueswir1    OS_CFLAGS=-std=gnu99
321ec530c81Sbellard;;
322b29fe3edSmalcAIX)
323b29fe3edSmalcaix="yes"
324b29fe3edSmalcmake="gmake"
325b29fe3edSmalc;;
326fb065187Sbellard*)
3270c58ac1cSmalcaudio_drv_list="oss"
328b8e59f18Smalcaudio_possible_drivers="oss alsa sdl esd pa"
3295327cf48Sbellardlinux="yes"
330831b7825Sthslinux_user="yes"
33168063649Sblueswir1usb="linux"
332dff84034SJan Kiszkakvm="yes"
33307f4ddbfSbellardif [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
334c9ec1fe4Sbellard    kqemu="yes"
335c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
336c9ec1fe4Sbellardfi
337fb065187Sbellard;;
3387d13299dSbellardesac
3397d13299dSbellard
3407d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
341b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
3427d3505c5Sbellard    make="gmake"
34368063649Sblueswir1    usb="bsd"
34483fb7adfSbellard  fi
34584778508Sblueswir1  bsd_user="yes"
3467d3505c5Sbellardfi
3477d3505c5Sbellard
3487d13299dSbellard# find source path
349ad064840Spbrooksource_path=`dirname "$0"`
35059faef3aSbalrogsource_path_used="no"
35159faef3aSbalrogworkdir=`pwd`
352ad064840Spbrookif [ -z "$source_path" ]; then
35359faef3aSbalrog    source_path=$workdir
354ad064840Spbrookelse
355ad064840Spbrook    source_path=`cd "$source_path"; pwd`
3567d13299dSbellardfi
357724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
3587d13299dSbellard
359487fefdbSAnthony Liguoriwerror=""
36085aa5189Sbellard
3617d13299dSbellardfor opt do
362a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
3637d13299dSbellard  case "$opt" in
3642efc3265Sbellard  --help|-h) show_help=yes
3652efc3265Sbellard  ;;
366b1a550a0Spbrook  --prefix=*) prefix="$optarg"
3677d13299dSbellard  ;;
368b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
36932ce6337Sbellard  ;;
370b1a550a0Spbrook  --source-path=*) source_path="$optarg"
371ad064840Spbrook  source_path_used="yes"
3727d13299dSbellard  ;;
373ac0df51dSaliguori  --cross-prefix=*)
3747d13299dSbellard  ;;
375ac0df51dSaliguori  --cc=*)
3767d13299dSbellard  ;;
377b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
37883469015Sbellard  ;;
379b1a550a0Spbrook  --make=*) make="$optarg"
3807d13299dSbellard  ;;
3816a882643Spbrook  --install=*) install="$optarg"
3826a882643Spbrook  ;;
383b1a550a0Spbrook  --extra-cflags=*) CFLAGS="$optarg"
3847d13299dSbellard  ;;
385b1a550a0Spbrook  --extra-ldflags=*) LDFLAGS="$optarg"
3867d13299dSbellard  ;;
387b1a550a0Spbrook  --cpu=*) cpu="$optarg"
3887d13299dSbellard  ;;
389b1a550a0Spbrook  --target-list=*) target_list="$optarg"
390de83cd02Sbellard  ;;
3917d13299dSbellard  --enable-gprof) gprof="yes"
3927d13299dSbellard  ;;
39343ce4dfeSbellard  --static) static="yes"
39443ce4dfeSbellard  ;;
39597a847bcSbellard  --disable-sdl) sdl="no"
39697a847bcSbellard  ;;
397b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
398102a52e4Sbellard  ;;
399c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
400c2de5c91Smalc  ;;
4012f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
4022f6a1ab0Sblueswir1  ;;
4032fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
4040c58ac1cSmalc  ;;
4050c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
4060c58ac1cSmalc  ;;
407f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
408f8393946Saurel32  ;;
409f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
410f8393946Saurel32  ;;
411f3d08ee6SPaul Brook  --enable-debug)
412f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
413f3d08ee6SPaul Brook      debug_tcg="yes"
414f3d08ee6SPaul Brook      debug="yes"
415f3d08ee6SPaul Brook      strip_opt="no"
416f3d08ee6SPaul Brook  ;;
41703b4fe7dSaliguori  --enable-sparse) sparse="yes"
41803b4fe7dSaliguori  ;;
41903b4fe7dSaliguori  --disable-sparse) sparse="no"
42003b4fe7dSaliguori  ;;
4211625af87Saliguori  --disable-strip) strip_opt="no"
4221625af87Saliguori  ;;
4238d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
4248d5d2d4cSths  ;;
4252f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
4262f9606b3Saliguori  ;;
427443f1376Sbellard  --disable-slirp) slirp="no"
428c20709aaSbellard  ;;
429e0e6c8c0Saliguori  --disable-vde) vde="no"
4308a16d273Sths  ;;
431c9ec1fe4Sbellard  --disable-kqemu) kqemu="no"
432c9ec1fe4Sbellard  ;;
433e37630caSaliguori  --disable-xen) xen="no"
434e37630caSaliguori  ;;
4352e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
4362e4d9fb1Saurel32  ;;
437fb599c9aSbalrog  --disable-bluez) bluez="no"
438fb599c9aSbalrog  ;;
4397ba1e619Saliguori  --disable-kvm) kvm="no"
4407ba1e619Saliguori  ;;
44105c2a3e7Sbellard  --enable-profiler) profiler="yes"
44205c2a3e7Sbellard  ;;
443c2de5c91Smalc  --enable-cocoa)
444c2de5c91Smalc      cocoa="yes" ;
445c2de5c91Smalc      sdl="no" ;
446c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
4475b0753e0Sbellard  ;;
448cad25d69Spbrook  --disable-system) softmmu="no"
4490a8e90f4Spbrook  ;;
450cad25d69Spbrook  --enable-system) softmmu="yes"
4510a8e90f4Spbrook  ;;
452831b7825Sths  --disable-linux-user) linux_user="no"
4530a8e90f4Spbrook  ;;
454831b7825Sths  --enable-linux-user) linux_user="yes"
455831b7825Sths  ;;
456831b7825Sths  --disable-darwin-user) darwin_user="no"
457831b7825Sths  ;;
458831b7825Sths  --enable-darwin-user) darwin_user="yes"
4590a8e90f4Spbrook  ;;
46084778508Sblueswir1  --disable-bsd-user) bsd_user="no"
46184778508Sblueswir1  ;;
46284778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
46384778508Sblueswir1  ;;
464c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
465c5937220Spbrook  ;;
4663142255cSblueswir1  --sparc_cpu=*)
4673142255cSblueswir1      sparc_cpu="$optarg"
4683142255cSblueswir1      case $sparc_cpu in
4693142255cSblueswir1        v7|v8) SP_CFLAGS="-m32 -mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
4703142255cSblueswir1                 target_cpu="sparc"; cpu="sparc" ;;
4713142255cSblueswir1        v8plus|v8plusa) SP_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m32"
4723142255cSblueswir1                 target_cpu="sparc"; cpu="sparc" ;;
4733142255cSblueswir1        v9)    SP_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_${sparc_cpu}__"; SP_LDFLAGS="-m64"
4743142255cSblueswir1                 target_cpu="sparc64"; cpu="sparc64" ;;
4753142255cSblueswir1        *)     echo "undefined SPARC architecture. Exiting";exit 1;;
4763142255cSblueswir1      esac
4773142255cSblueswir1  ;;
47885aa5189Sbellard  --enable-werror) werror="yes"
47985aa5189Sbellard  ;;
48085aa5189Sbellard  --disable-werror) werror="no"
48185aa5189Sbellard  ;;
4824d3b6f6eSbalrog  --disable-curses) curses="no"
4834d3b6f6eSbalrog  ;;
484769ce76dSAlexander Graf  --disable-curl) curl="no"
485769ce76dSAlexander Graf  ;;
486bd0c5661Spbrook  --disable-nptl) nptl="no"
487bd0c5661Spbrook  ;;
4888ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
4898ff9cbf7Smalc  ;;
490e5d355d1Saliguori  --disable-pthread) pthread="no"
491e5d355d1Saliguori  ;;
492414f0dabSblueswir1  --disable-aio) aio="no"
493414f0dabSblueswir1  ;;
494e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
495e5d355d1Saliguori  ;;
49677755340Sths  --disable-blobs) blobs="no"
49777755340Sths  ;;
498eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
499eac30262Saliguori  ;;
5004a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
5014a19f1ecSpbrook  ;;
50270ec5dc0SAnthony Liguori  --disable-docs) build_docs="no"
50370ec5dc0SAnthony Liguori  ;;
5047f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
5057f1559c6Sbalrog  ;;
5067d13299dSbellard  esac
5077d13299dSbellarddone
5087d13299dSbellard
5096f30fa85Sths# default flags for all hosts
510f3d08ee6SPaul BrookCFLAGS="$CFLAGS -g -fno-strict-aliasing"
511f3d08ee6SPaul Brookif test "$debug" = "no" ; then
512f3d08ee6SPaul Brook  CFLAGS="$CFLAGS -O2"
513f3d08ee6SPaul Brookfi
514e0e36fe9Sblueswir1CFLAGS="$CFLAGS -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls"
5156f30fa85SthsLDFLAGS="$LDFLAGS -g"
5161172f653SBlue Swirl
5171172f653SBlue Swirl# Consult white-list to determine whether to enable werror
5181172f653SBlue Swirl# by default.  Only enable by default for git builds
5191172f653SBlue Swirlif test -z "$werror" ; then
5201172f653SBlue Swirl    z_version=`cut -f3 -d. $source_path/VERSION`
5211172f653SBlue Swirl    if test "$z_version" = "50" -a \
5221172f653SBlue Swirl        "$linux" = "yes" ; then
5231172f653SBlue Swirl        werror="yes"
5241172f653SBlue Swirl    else
5251172f653SBlue Swirl        werror="no"
5261172f653SBlue Swirl    fi
5271172f653SBlue Swirlfi
5281172f653SBlue Swirl
52985aa5189Sbellardif test "$werror" = "yes" ; then
53085aa5189Sbellard    CFLAGS="$CFLAGS -Werror"
53185aa5189Sbellardfi
5326f30fa85Sths
533d2c7c9b8Sblueswir1if test "$solaris" = "no" ; then
534d2c7c9b8Sblueswir1    if ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
53549237acdSblueswir1        LDFLAGS="$LDFLAGS -Wl,--warn-common"
53649237acdSblueswir1    fi
537d2c7c9b8Sblueswir1fi
53849237acdSblueswir1
5393142255cSblueswir1#
5403142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
5413142255cSblueswir1# ARCH_CFLAGS/ARCH_LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
5423142255cSblueswir1#
54340293e58Sbellardcase "$cpu" in
5443142255cSblueswir1    sparc) if test -z "$sparc_cpu" ; then
5453142255cSblueswir1               ARCH_CFLAGS="-m32 -mcpu=ultrasparc -D__sparc_v8plus__"
5463142255cSblueswir1               ARCH_LDFLAGS="-m32"
5473142255cSblueswir1           else
5483142255cSblueswir1               ARCH_CFLAGS="${SP_CFLAGS}"
5493142255cSblueswir1               ARCH_LDFLAGS="${SP_LDFLAGS}"
5503142255cSblueswir1           fi
551762e8230Sblueswir1           ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g2 -ffixed-g3"
552762e8230Sblueswir1           if test "$solaris" = "no" ; then
553762e8230Sblueswir1               ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g1 -ffixed-g6"
554762e8230Sblueswir1           fi
5553142255cSblueswir1           ;;
5563142255cSblueswir1    sparc64) if test -z "$sparc_cpu" ; then
5573142255cSblueswir1               ARCH_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__"
5583142255cSblueswir1               ARCH_LDFLAGS="-m64"
5593142255cSblueswir1           else
5603142255cSblueswir1               ARCH_CFLAGS="${SP_CFLAGS}"
5613142255cSblueswir1               ARCH_LDFLAGS="${SP_LDFLAGS}"
5623142255cSblueswir1           fi
563762e8230Sblueswir1           if test "$solaris" = "no" ; then
564762e8230Sblueswir1               ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g5 -ffixed-g6 -ffixed-g7"
565762e8230Sblueswir1           else
566762e8230Sblueswir1               ARCH_CFLAGS="$ARCH_CFLAGS -ffixed-g1 -ffixed-g5 -ffixed-g6 -ffixed-g7"
567762e8230Sblueswir1           fi
5683142255cSblueswir1           ;;
56976d83bdeSths    s390)
57076d83bdeSths           ARCH_CFLAGS="-march=z900"
57176d83bdeSths           ;;
57240293e58Sbellard    i386)
57340293e58Sbellard           ARCH_CFLAGS="-m32"
57440293e58Sbellard           ARCH_LDFLAGS="-m32"
57540293e58Sbellard           ;;
57640293e58Sbellard    x86_64)
57740293e58Sbellard           ARCH_CFLAGS="-m64"
57840293e58Sbellard           ARCH_LDFLAGS="-m64"
57940293e58Sbellard           ;;
5803142255cSblueswir1esac
5813142255cSblueswir1
582af5db58eSpbrookif test x"$show_help" = x"yes" ; then
583af5db58eSpbrookcat << EOF
584af5db58eSpbrook
585af5db58eSpbrookUsage: configure [options]
586af5db58eSpbrookOptions: [defaults in brackets after descriptions]
587af5db58eSpbrook
588af5db58eSpbrookEOF
589af5db58eSpbrookecho "Standard options:"
590af5db58eSpbrookecho "  --help                   print this message"
591af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
592af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
593af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
594af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
595af5db58eSpbrookecho ""
596af5db58eSpbrookecho "kqemu kernel acceleration support:"
597af5db58eSpbrookecho "  --disable-kqemu          disable kqemu support"
598af5db58eSpbrookecho ""
599af5db58eSpbrookecho "Advanced options (experts only):"
600af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
601af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
602af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
603af5db58eSpbrookecho "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
6042981fa96Saurel32echo "  --extra-cflags=CFLAGS    add C compiler flags CFLAGS"
6052981fa96Saurel32echo "  --extra-ldflags=LDFLAGS  add linker flags LDFLAGS"
606af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
6076a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
608af5db58eSpbrookecho "  --static                 enable static build [$static]"
609f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
610f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
61109695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
612890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
613890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
6141625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
61585aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
616fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
617af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
618c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
619c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
6204c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
6214c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
6228ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
623e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
6242e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
6258d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
6262f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
627af896aaaSpbrookecho "  --disable-curses         disable curses output"
628769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
629fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
6307ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
631bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
632af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
633af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
634831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
635831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
636831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
637831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
63884778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
63984778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
640af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
641af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
6422f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
643c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
6443142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
645e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
646e5d355d1Saliguoriecho "  --disable-pthread        disable pthread support"
647414f0dabSblueswir1echo "  --disable-aio            disable AIO support"
648e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
64977755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
650eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
651af5db58eSpbrookecho ""
6525bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
653af5db58eSpbrookexit 1
654af5db58eSpbrookfi
655af5db58eSpbrook
65667b915a5Sbellardif test "$mingw32" = "yes" ; then
6575327cf48Sbellard    linux="no"
65867b915a5Sbellard    EXESUF=".exe"
6599f059ecaSbellard    oss="no"
660cd01b4a3Saliguori    linux_user="no"
66184778508Sblueswir1    bsd_user="no"
66249dc768dSaliguori    OS_CFLAGS="$OS_CFLAGS -DWIN32_LEAN_AND_MEAN -DWINVER=0x501"
663cd01b4a3Saliguorifi
664cd01b4a3Saliguori
66503b4fe7dSaliguoriif test ! -x "$(which cgcc 2>/dev/null)"; then
66603b4fe7dSaliguori    sparse="no"
66703b4fe7dSaliguorifi
66803b4fe7dSaliguori
669ec530c81Sbellard#
670ec530c81Sbellard# Solaris specific configure tool chain decisions
671ec530c81Sbellard#
672ec530c81Sbellardif test "$solaris" = "yes" ; then
673ec530c81Sbellard  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
674ec530c81Sbellard  if test -z "$solinst" ; then
675ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
676ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
677ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
678ec530c81Sbellard    exit 1
679ec530c81Sbellard  fi
680ec530c81Sbellard  if test "$solinst" = "/usr/sbin/install" ; then
681ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
682ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
683ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
684ec530c81Sbellard    exit 1
685ec530c81Sbellard  fi
686ec530c81Sbellard  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
687ec530c81Sbellard  if test -z "$sol_ar" ; then
688ec530c81Sbellard    echo "Error: No path includes ar"
689ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
690ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
691ec530c81Sbellard    fi
692ec530c81Sbellard    exit 1
693ec530c81Sbellard  fi
694ec530c81Sbellardfi
695ec530c81Sbellard
696ec530c81Sbellard
6975327cf48Sbellardif test -z "$target_list" ; then
6985327cf48Sbellard# these targets are portable
6990a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
7002408a527Saurel32        target_list="\
7012408a527Saurel32i386-softmmu \
7022408a527Saurel32x86_64-softmmu \
7032408a527Saurel32arm-softmmu \
7042408a527Saurel32cris-softmmu \
7052408a527Saurel32m68k-softmmu \
70672b675caSEdgar E. Iglesiasmicroblaze-softmmu \
7072408a527Saurel32mips-softmmu \
7082408a527Saurel32mipsel-softmmu \
7092408a527Saurel32mips64-softmmu \
7102408a527Saurel32mips64el-softmmu \
7112408a527Saurel32ppc-softmmu \
7122408a527Saurel32ppcemb-softmmu \
7132408a527Saurel32ppc64-softmmu \
7142408a527Saurel32sh4-softmmu \
7152408a527Saurel32sh4eb-softmmu \
7162408a527Saurel32sparc-softmmu \
7171b64fcaeSIgor V. Kovalenkosparc64-softmmu \
7182408a527Saurel32"
7190a8e90f4Spbrook    fi
7205327cf48Sbellard# the following are Linux specific
721831b7825Sths    if [ "$linux_user" = "yes" ] ; then
7222408a527Saurel32        target_list="${target_list}\
7232408a527Saurel32i386-linux-user \
7242408a527Saurel32x86_64-linux-user \
7252408a527Saurel32alpha-linux-user \
7262408a527Saurel32arm-linux-user \
7272408a527Saurel32armeb-linux-user \
7282408a527Saurel32cris-linux-user \
7292408a527Saurel32m68k-linux-user \
73072b675caSEdgar E. Iglesiasmicroblaze-linux-user \
7312408a527Saurel32mips-linux-user \
7322408a527Saurel32mipsel-linux-user \
7332408a527Saurel32ppc-linux-user \
7342408a527Saurel32ppc64-linux-user \
7352408a527Saurel32ppc64abi32-linux-user \
7362408a527Saurel32sh4-linux-user \
7372408a527Saurel32sh4eb-linux-user \
7382408a527Saurel32sparc-linux-user \
7392408a527Saurel32sparc64-linux-user \
7402408a527Saurel32sparc32plus-linux-user \
7412408a527Saurel32"
742831b7825Sths    fi
743831b7825Sths# the following are Darwin specific
744831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
7452408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
7465327cf48Sbellard    fi
74784778508Sblueswir1# the following are BSD specific
74884778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
74984778508Sblueswir1        target_list="${target_list}\
75031fc12dfSblueswir1i386-bsd-user \
75131fc12dfSblueswir1x86_64-bsd-user \
75231fc12dfSblueswir1sparc-bsd-user \
75384778508Sblueswir1sparc64-bsd-user \
75484778508Sblueswir1"
75584778508Sblueswir1    fi
7566e20a45fSbellardelse
757b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
7585327cf48Sbellardfi
7590a8e90f4Spbrookif test -z "$target_list" ; then
7600a8e90f4Spbrook    echo "No targets enabled"
7610a8e90f4Spbrook    exit 1
7620a8e90f4Spbrookfi
7635327cf48Sbellard
7647d13299dSbellardif test -z "$cross_prefix" ; then
7657d13299dSbellard
7667d13299dSbellard# ---
7677d13299dSbellard# big/little endian test
7687d13299dSbellardcat > $TMPC << EOF
7697d13299dSbellard#include <inttypes.h>
7707d13299dSbellardint main(int argc, char ** argv){
7717d13299dSbellard        volatile uint32_t i=0x01234567;
7727d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
7737d13299dSbellard}
7747d13299dSbellardEOF
7757d13299dSbellard
776178baee6Saurel32if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
7777d13299dSbellard$TMPE && bigendian="yes"
7787d13299dSbellardelse
7797d13299dSbellardecho big/little test failed
7807d13299dSbellardfi
7817d13299dSbellard
7827d13299dSbellardelse
7837d13299dSbellard
7847d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
7850938cda5Saurel32if test "$cpu" = "armv4b" \
786f54b3f92Saurel32     -o "$cpu" = "hppa" \
7870938cda5Saurel32     -o "$cpu" = "m68k" \
7880938cda5Saurel32     -o "$cpu" = "mips" \
7890938cda5Saurel32     -o "$cpu" = "mips64" \
790fdf7ed96Smalc     -o "$cpu" = "ppc" \
791fdf7ed96Smalc     -o "$cpu" = "ppc64" \
7920938cda5Saurel32     -o "$cpu" = "s390" \
7930938cda5Saurel32     -o "$cpu" = "sparc" \
7940938cda5Saurel32     -o "$cpu" = "sparc64"; then
7957d13299dSbellard    bigendian="yes"
7967d13299dSbellardfi
7977d13299dSbellard
7987d13299dSbellardfi
7997d13299dSbellard
800b6853697Sbellard# host long bits test
801b6853697Sbellardhostlongbits="32"
8020938cda5Saurel32if test "$cpu" = "x86_64" \
8030938cda5Saurel32     -o "$cpu" = "alpha" \
8040938cda5Saurel32     -o "$cpu" = "ia64" \
805fdf7ed96Smalc     -o "$cpu" = "sparc64" \
806fdf7ed96Smalc     -o "$cpu" = "ppc64"; then
807b6853697Sbellard    hostlongbits="64"
808b6853697Sbellardfi
809b6853697Sbellard
810bd0c5661Spbrook# Check host NPTL support
811bd0c5661Spbrookcat > $TMPC <<EOF
812bd0c5661Spbrook#include <sched.h>
81330813ceaSpbrook#include <linux/futex.h>
814bd0c5661Spbrookvoid foo()
815bd0c5661Spbrook{
816bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
817bd0c5661Spbrook#error bork
818bd0c5661Spbrook#endif
819bd0c5661Spbrook}
820bd0c5661SpbrookEOF
821bd0c5661Spbrook
8228c7f7574Sbalrogif $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
823bd0c5661Spbrook  :
824bd0c5661Spbrookelse
825bd0c5661Spbrook   nptl="no"
826bd0c5661Spbrookfi
827bd0c5661Spbrook
82811d9f695Sbellard##########################################
829ac62922eSbalrog# zlib check
830ac62922eSbalrog
831ac62922eSbalrogcat > $TMPC << EOF
832ac62922eSbalrog#include <zlib.h>
833ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
834ac62922eSbalrogEOF
8358c7f7574Sbalrogif $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lz > /dev/null 2> /dev/null ; then
836ac62922eSbalrog    :
837ac62922eSbalrogelse
838ac62922eSbalrog    echo
839ac62922eSbalrog    echo "Error: zlib check failed"
840ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
841ac62922eSbalrog    echo
842ac62922eSbalrog    exit 1
843ac62922eSbalrogfi
844ac62922eSbalrog
845ac62922eSbalrog##########################################
846e37630caSaliguori# xen probe
847e37630caSaliguori
848e37630caSaliguoriif test "$xen" = "yes" ; then
849e37630caSaliguoricat > $TMPC <<EOF
850e37630caSaliguori#include <xenctrl.h>
851e37630caSaliguori#include <xs.h>
852e37630caSaliguoriint main(void) { xs_daemon_open; xc_interface_open; }
853e37630caSaliguoriEOF
854918a608bSJan Kiszka   if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC -lxenstore -lxenctrl 2> /dev/null > /dev/null ; then
855e37630caSaliguori      :
856e37630caSaliguori   else
857e37630caSaliguori      xen="no"
858e37630caSaliguori   fi
859e37630caSaliguorifi
860e37630caSaliguori
861e37630caSaliguori##########################################
86211d9f695Sbellard# SDL probe
86311d9f695Sbellard
86411d9f695Sbellardsdl_too_old=no
86511d9f695Sbellard
866f92f8afeSAnthony Liguoriif test "$sdl" = "yes" ; then
867a6e022adSbellard    sdl_config="sdl-config"
868a6e022adSbellard    sdl=no
8697c1f25b4Sbellard    sdl_static=no
870a6e022adSbellard
87111d9f695Sbellardcat > $TMPC << EOF
87211d9f695Sbellard#include <SDL.h>
87311d9f695Sbellard#undef main /* We don't want SDL to override our main() */
87411d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
87511d9f695SbellardEOF
8768c7f7574Sbalrog    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
877a6e022adSbellard        _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'`
87811d9f695Sbellard        if test "$_sdlversion" -lt 121 ; then
87911d9f695Sbellard            sdl_too_old=yes
88011d9f695Sbellard        else
881fd677642Sths            if test "$cocoa" = "no" ; then
88211d9f695Sbellard                sdl=yes
88311d9f695Sbellard            fi
884fd677642Sths        fi
8857c1f25b4Sbellard
8867c1f25b4Sbellard        # static link with sdl ?
8877c1f25b4Sbellard        if test "$sdl" = "yes" ; then
8887c1f25b4Sbellard            aa="no"
889e14a693dSths            `$sdl_config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` && aa="yes"
890e14a693dSths            sdl_static_libs=`$sdl_config --static-libs 2>/dev/null`
8917c1f25b4Sbellard            if [ "$aa" = "yes" ] ; then
892d8d8aa4eSbellard                sdl_static_libs="$sdl_static_libs `aalib-config --static-libs`"
89311d9f695Sbellard            fi
89411d9f695Sbellard
8958c7f7574Sbalrog            if $cc -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC $sdl_static_libs > /dev/null 2> /dev/null; then
8967c1f25b4Sbellard                sdl_static=yes
8977c1f25b4Sbellard            fi
8987c1f25b4Sbellard        fi # static link
8997c1f25b4Sbellard    fi # sdl compile test
900fd677642Sthselse
901fd677642Sths    # Make sure to disable cocoa if sdl was set
902fd677642Sths    if test "$sdl" = "yes" ; then
903fd677642Sths       cocoa="no"
904c2de5c91Smalc       audio_drv_list="`echo $audio_drv_list | sed s,coreaudio,,g`"
905fd677642Sths    fi
906a6e022adSbellardfi # -z $sdl
90711d9f695Sbellard
9085368a422Saliguoriif test "$sdl" = "yes" ; then
9095368a422Saliguoricat > $TMPC <<EOF
9105368a422Saliguori#include <SDL.h>
9115368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
9125368a422Saliguori#include <X11/XKBlib.h>
9135368a422Saliguori#else
9145368a422Saliguori#error No x11 support
9155368a422Saliguori#endif
9165368a422Saliguoriint main(void) { return 0; }
9175368a422SaliguoriEOF
9185368a422Saliguori    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > /dev/null 2>&1 ; then
9195368a422Saliguori	sdl_x11="yes"
9205368a422Saliguori    fi
9215368a422Saliguorifi
9225368a422Saliguori
9238f28f3fbSths##########################################
9248d5d2d4cSths# VNC TLS detection
9258d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
926ae6b5e5aSaliguoricat > $TMPC <<EOF
927ae6b5e5aSaliguori#include <gnutls/gnutls.h>
928ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
929ae6b5e5aSaliguoriEOF
930ae6b5e5aSaliguori    vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
931ae6b5e5aSaliguori    vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
932ae6b5e5aSaliguori    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_tls_cflags $TMPC \
9338c7f7574Sbalrog           $vnc_tls_libs > /dev/null 2> /dev/null ; then
934ae6b5e5aSaliguori	:
935ae6b5e5aSaliguori    else
936ae6b5e5aSaliguori	vnc_tls="no"
9378d5d2d4cSths    fi
9388d5d2d4cSthsfi
9398d5d2d4cSths
9408d5d2d4cSths##########################################
9412f9606b3Saliguori# VNC SASL detection
9422f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
9432f9606b3Saliguoricat > $TMPC <<EOF
9442f9606b3Saliguori#include <sasl/sasl.h>
9452f9606b3Saliguori#include <stdio.h>
9462f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
9472f9606b3SaliguoriEOF
9482f9606b3Saliguori    # Assuming Cyrus-SASL installed in /usr prefix
9492f9606b3Saliguori    vnc_sasl_cflags=""
9502f9606b3Saliguori    vnc_sasl_libs="-lsasl2"
9512f9606b3Saliguori    if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $vnc_sasl_cflags $TMPC \
952918a608bSJan Kiszka           $vnc_sasl_libs 2> /dev/null > /dev/null ; then
9532f9606b3Saliguori	:
9542f9606b3Saliguori    else
9552f9606b3Saliguori	vnc_sasl="no"
9562f9606b3Saliguori    fi
9572f9606b3Saliguorifi
9582f9606b3Saliguori
9592f9606b3Saliguori##########################################
96076655d6dSaliguori# fnmatch() probe, used for ACL routines
96176655d6dSaliguorifnmatch="no"
96276655d6dSaliguoricat > $TMPC << EOF
96376655d6dSaliguori#include <fnmatch.h>
96476655d6dSaliguoriint main(void)
96576655d6dSaliguori{
96676655d6dSaliguori    fnmatch("foo", "foo", 0);
96776655d6dSaliguori    return 0;
96876655d6dSaliguori}
96976655d6dSaliguoriEOF
97076655d6dSaliguoriif $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
97176655d6dSaliguori   fnmatch="yes"
97276655d6dSaliguorifi
97376655d6dSaliguori
97476655d6dSaliguori##########################################
9758a16d273Sths# vde libraries probe
9768a16d273Sthsif test "$vde" = "yes" ; then
9778a16d273Sths  cat > $TMPC << EOF
9788a16d273Sths#include <libvdeplug.h>
9794a7f0e06Spbrookint main(void)
9804a7f0e06Spbrook{
9814a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
9824a7f0e06Spbrook    vde_open("", "", &a);
9834a7f0e06Spbrook    return 0;
9844a7f0e06Spbrook}
9858a16d273SthsEOF
9868c7f7574Sbalrog    if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lvdeplug > /dev/null 2> /dev/null ; then
9878a16d273Sths        :
9888a16d273Sths    else
989e0e6c8c0Saliguori        vde="no"
9908a16d273Sths    fi
9918a16d273Sthsfi
9928a16d273Sths
9938a16d273Sths##########################################
994c2de5c91Smalc# Sound support libraries probe
9958f28f3fbSths
996c2de5c91Smalcaudio_drv_probe()
997c2de5c91Smalc{
998c2de5c91Smalc    drv=$1
999c2de5c91Smalc    hdr=$2
1000c2de5c91Smalc    lib=$3
1001c2de5c91Smalc    exp=$4
1002c2de5c91Smalc    cfl=$5
10038f28f3fbSths        cat > $TMPC << EOF
1004c2de5c91Smalc#include <$hdr>
1005c2de5c91Smalcint main(void) { $exp }
10068f28f3fbSthsEOF
10078c7f7574Sbalrog    if $cc $ARCH_CFLAGS $cfl -o $TMPE $TMPC $lib > /dev/null 2> /dev/null ; then
10088f28f3fbSths        :
10098f28f3fbSths    else
10108f28f3fbSths        echo
1011c2de5c91Smalc        echo "Error: $drv check failed"
1012c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
10138f28f3fbSths        echo
10148f28f3fbSths        exit 1
10158f28f3fbSths    fi
1016c2de5c91Smalc}
1017c2de5c91Smalc
10182fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1019c2de5c91Smalcfor drv in $audio_drv_list; do
1020c2de5c91Smalc    case $drv in
1021c2de5c91Smalc    alsa)
1022c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1023c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1024c2de5c91Smalc    ;;
1025c2de5c91Smalc
1026c2de5c91Smalc    fmod)
1027c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1028c2de5c91Smalc        echo
1029c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1030c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1031c2de5c91Smalc        echo
1032c2de5c91Smalc        exit 1
10338f28f3fbSths    fi
1034c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1035c2de5c91Smalc    ;;
1036c2de5c91Smalc
1037c2de5c91Smalc    esd)
1038c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1039c2de5c91Smalc    ;;
1040b8e59f18Smalc
1041b8e59f18Smalc    pa)
1042b8e59f18Smalc    audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1043b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1044b8e59f18Smalc    ;;
1045b8e59f18Smalc
10462f6a1ab0Sblueswir1    oss|sdl|core|wav|dsound)
10472f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
10482f6a1ab0Sblueswir1    ;;
10492f6a1ab0Sblueswir1
1050e4c63a6aSmalc    *)
10511c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1052e4c63a6aSmalc        echo
1053e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1054e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1055e4c63a6aSmalc        echo
1056e4c63a6aSmalc        exit 1
1057e4c63a6aSmalc    }
1058e4c63a6aSmalc    ;;
1059c2de5c91Smalc    esac
1060c2de5c91Smalcdone
10618f28f3fbSths
10624d3b6f6eSbalrog##########################################
10632e4d9fb1Saurel32# BrlAPI probe
10642e4d9fb1Saurel32
10652e4d9fb1Saurel32if test -z "$brlapi" ; then
10662e4d9fb1Saurel32    brlapi=no
10672e4d9fb1Saurel32cat > $TMPC << EOF
10682e4d9fb1Saurel32#include <brlapi.h>
10692e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
10702e4d9fb1Saurel32EOF
1071178baee6Saurel32    if $cc ${ARCH_CFLAGS} -o $TMPE ${OS_CFLAGS} $TMPC -lbrlapi > /dev/null 2> /dev/null ; then
10722e4d9fb1Saurel32	    brlapi=yes
10732e4d9fb1Saurel32    fi # brlapi compile test
10742e4d9fb1Saurel32fi # -z $brlapi
10752e4d9fb1Saurel32
10762e4d9fb1Saurel32##########################################
10774d3b6f6eSbalrog# curses probe
10784d3b6f6eSbalrog
10794d3b6f6eSbalrogif test "$curses" = "yes" ; then
10804d3b6f6eSbalrog  curses=no
1081*ab4e5602SJan Kiszka  ncurses=no
10824d3b6f6eSbalrog  cat > $TMPC << EOF
10834d3b6f6eSbalrog#include <curses.h>
10845a8ff3aaSblueswir1#ifdef __OpenBSD__
10855a8ff3aaSblueswir1#define resize_term resizeterm
10865a8ff3aaSblueswir1#endif
10875a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
10884d3b6f6eSbalrogEOF
1089*ab4e5602SJan Kiszka  if $cc $ARCH_CFLAGS -o $TMPE $TMPC -lncurses > /dev/null 2> /dev/null ; then
1090*ab4e5602SJan Kiszka    curses=yes
1091*ab4e5602SJan Kiszka    ncurses=yes
1092*ab4e5602SJan Kiszka  elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lcurses > /dev/null 2> /dev/null ; then
10934d3b6f6eSbalrog    curses=yes
10944d3b6f6eSbalrog  fi
10954d3b6f6eSbalrogfi # test "$curses"
10964d3b6f6eSbalrog
1097414f0dabSblueswir1##########################################
1098769ce76dSAlexander Graf# curl probe
1099769ce76dSAlexander Graf
1100769ce76dSAlexander Grafif test "$curl" = "yes" ; then
1101769ce76dSAlexander Graf  curl=no
1102769ce76dSAlexander Graf  cat > $TMPC << EOF
1103769ce76dSAlexander Graf#include <curl/curl.h>
1104769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1105769ce76dSAlexander GrafEOF
110652368552SPaul Brook  curl_libs=`curl-config --libs 2>/dev/null`
1107769ce76dSAlexander Graf if $cc $ARCH_CFLAGS $curl_libs -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1108769ce76dSAlexander Graf    curl=yes
1109769ce76dSAlexander Graf  fi
1110769ce76dSAlexander Graffi # test "$curl"
1111769ce76dSAlexander Graf
1112769ce76dSAlexander Graf##########################################
1113fb599c9aSbalrog# bluez support probe
1114fb599c9aSbalrogif test "$bluez" = "yes" ; then
1115efcfd0c5SBlue Swirl  `pkg-config bluez 2> /dev/null` || bluez="no"
1116fb599c9aSbalrogfi
1117fb599c9aSbalrogif test "$bluez" = "yes" ; then
1118e820e3f4Sbalrog  cat > $TMPC << EOF
1119e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1120e820e3f4Sbalrogint main(void) { return bt_error(0); }
1121e820e3f4SbalrogEOF
1122efcfd0c5SBlue Swirl  bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1123efcfd0c5SBlue Swirl  bluez_libs=`pkg-config --libs bluez 2> /dev/null`
112417e1592dSbalrog  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $bluez_cflags $TMPC \
11258c7f7574Sbalrog      $bluez_libs > /dev/null 2> /dev/null ; then
1126e820e3f4Sbalrog    :
1127e820e3f4Sbalrog  else
1128e820e3f4Sbalrog    bluez="no"
1129e820e3f4Sbalrog  fi
1130fb599c9aSbalrogfi
1131fb599c9aSbalrog
1132fb599c9aSbalrog##########################################
11337ba1e619Saliguori# kvm probe
11347ba1e619Saliguoriif test "$kvm" = "yes" ; then
11357ba1e619Saliguori    cat > $TMPC <<EOF
11367ba1e619Saliguori#include <linux/kvm.h>
11379fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
11387ba1e619Saliguori#error Invalid KVM version
11397ba1e619Saliguori#endif
11409fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
11419fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
11429fd8d8d7Saliguori#endif
11439fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
11449fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
11459fd8d8d7Saliguori#endif
11469fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
11479fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
11489fd8d8d7Saliguori#endif
11497ba1e619Saliguoriint main(void) { return 0; }
11507ba1e619SaliguoriEOF
1151eac30262Saliguori  if test "$kerneldir" != "" ; then
1152eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
11538444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
11548444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
11558444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1156406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1157406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
11588444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
11598444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
11608444eb6eSaliguori      fi
1161eac30262Saliguori  else
1162eac30262Saliguori      kvm_cflags=""
1163eac30262Saliguori  fi
11647ba1e619Saliguori  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC \
11658c7f7574Sbalrog      > /dev/null 2>/dev/null ; then
11667ba1e619Saliguori    :
11677ba1e619Saliguori  else
11689fd8d8d7Saliguori    kvm="no";
11699fd8d8d7Saliguori    if [ -x "`which awk 2>/dev/null`" ] && \
11709fd8d8d7Saliguori       [ -x "`which grep 2>/dev/null`" ]; then
1171e4f5100cSblueswir1      kvmerr=`LANG=C $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $kvm_cflags $TMPC 2>&1 \
11729fd8d8d7Saliguori	| grep "error: " \
11739fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
11749fd8d8d7Saliguori      if test "$kvmerr" != "" ; then
1175168ccc11SJan Kiszka        kvm="no - (${kvmerr})\n\
1176168ccc11SJan Kiszka    NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1177168ccc11SJan Kiszkarecent kvm-kmod from http://sourceforge.net/projects/kvm."
11789fd8d8d7Saliguori      fi
11799fd8d8d7Saliguori    fi
11807ba1e619Saliguori  fi
11817ba1e619Saliguorifi
11827ba1e619Saliguori
11837ba1e619Saliguori##########################################
1184e5d355d1Saliguori# pthread probe
1185de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
1186e5d355d1SaliguoriPTHREADLIBS=""
11873c529d93Saliguori
1188e5d355d1Saliguoriif test "$pthread" = yes; then
1189e5d355d1Saliguori  pthread=no
1190414f0dabSblueswir1cat > $TMPC << EOF
11913c529d93Saliguori#include <pthread.h>
1192de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1193414f0dabSblueswir1EOF
1194de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
1195de65fe0fSSebastian Herbszt    if $cc $ARCH_CFLAGS -o $TMPE $TMPC $pthread_lib 2> /dev/null > /dev/null ; then
1196e5d355d1Saliguori      pthread=yes
1197de65fe0fSSebastian Herbszt      PTHREADLIBS="$pthread_lib"
1198de65fe0fSSebastian Herbszt      break
1199414f0dabSblueswir1    fi
1200de65fe0fSSebastian Herbszt  done
1201414f0dabSblueswir1fi
1202414f0dabSblueswir1
1203e5d355d1Saliguoriif test "$pthread" = no; then
1204e5d355d1Saliguori   aio=no
1205e5d355d1Saliguori   io_thread=no
1206e5d355d1Saliguorifi
1207e5d355d1Saliguori
1208bf9298b9Saliguori##########################################
1209bf9298b9Saliguori# iovec probe
1210bf9298b9Saliguoricat > $TMPC <<EOF
1211db34f0b3Sblueswir1#include <sys/types.h>
1212bf9298b9Saliguori#include <sys/uio.h>
1213db34f0b3Sblueswir1#include <unistd.h>
1214bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1215bf9298b9SaliguoriEOF
1216bf9298b9Saliguoriiovec=no
12178c7f7574Sbalrogif $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1218bf9298b9Saliguori  iovec=yes
1219bf9298b9Saliguorifi
1220bf9298b9Saliguori
1221f652e6afSaurel32##########################################
1222ceb42de8Saliguori# preadv probe
1223ceb42de8Saliguoricat > $TMPC <<EOF
1224ceb42de8Saliguori#include <sys/types.h>
1225ceb42de8Saliguori#include <sys/uio.h>
1226ceb42de8Saliguori#include <unistd.h>
1227ceb42de8Saliguoriint main(void) { preadv; }
1228ceb42de8SaliguoriEOF
1229ceb42de8Saliguoripreadv=no
1230ceb42de8Saliguoriif $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1231ceb42de8Saliguori  preadv=yes
1232ceb42de8Saliguorifi
1233ceb42de8Saliguori
1234ceb42de8Saliguori##########################################
1235f652e6afSaurel32# fdt probe
1236f652e6afSaurel32if test "$fdt" = "yes" ; then
1237f652e6afSaurel32    fdt=no
1238f652e6afSaurel32    cat > $TMPC << EOF
1239f652e6afSaurel32int main(void) { return 0; }
1240f652e6afSaurel32EOF
1241918a608bSJan Kiszka  if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null > /dev/null ; then
1242f652e6afSaurel32    fdt=yes
1243f652e6afSaurel32  fi
1244f652e6afSaurel32fi
1245f652e6afSaurel32
12463b3f24adSaurel32#
12473b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
12483b3f24adSaurel32# emulator.  This is done because older glibc versions don't
12493b3f24adSaurel32# have syscall stubs for these implemented.
12503b3f24adSaurel32#
12513b3f24adSaurel32atfile=no
12523b3f24adSaurel32if [ "$linux_user" = "yes" ] ; then
12533b3f24adSaurel32  cat > $TMPC << EOF
12543b3f24adSaurel32#define _ATFILE_SOURCE
12553b3f24adSaurel32#include <sys/types.h>
12563b3f24adSaurel32#include <fcntl.h>
12573b3f24adSaurel32#include <unistd.h>
12583b3f24adSaurel32
12593b3f24adSaurel32int
12603b3f24adSaurel32main(void)
12613b3f24adSaurel32{
12623b3f24adSaurel32	/* try to unlink nonexisting file */
12633b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
12643b3f24adSaurel32}
12653b3f24adSaurel32EOF
1266918a608bSJan Kiszka  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
12673b3f24adSaurel32    atfile=yes
12683b3f24adSaurel32  fi
12693b3f24adSaurel32fi
12703b3f24adSaurel32
127139386ac7Saurel32# Check for inotify functions when we are building linux-user
12723b3f24adSaurel32# emulator.  This is done because older glibc versions don't
12733b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
12743b3f24adSaurel32# don't provide them even if kernel supports them.
12753b3f24adSaurel32#
12763b3f24adSaurel32inotify=no
12773b3f24adSaurel32if [ "$linux_user" = "yes" ] ; then
12783b3f24adSaurel32  cat > $TMPC << EOF
12793b3f24adSaurel32#include <sys/inotify.h>
12803b3f24adSaurel32
12813b3f24adSaurel32int
12823b3f24adSaurel32main(void)
12833b3f24adSaurel32{
12843b3f24adSaurel32	/* try to start inotify */
12858690e420Saurel32	return inotify_init();
12863b3f24adSaurel32}
12873b3f24adSaurel32EOF
1288918a608bSJan Kiszka  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null > /dev/null ; then
12893b3f24adSaurel32    inotify=yes
12903b3f24adSaurel32  fi
12913b3f24adSaurel32fi
12923b3f24adSaurel32
1293ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1294ebc996f3SRiku Voipioutimens=no
1295ebc996f3SRiku Voipiocat > $TMPC << EOF
1296ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1297ebc996f3SRiku Voipio#define _GNU_SOURCE
1298ebc996f3SRiku Voipio#include <stddef.h>
1299ebc996f3SRiku Voipio#include <fcntl.h>
1300ebc996f3SRiku Voipio
1301ebc996f3SRiku Voipioint main(void)
1302ebc996f3SRiku Voipio{
1303ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1304ebc996f3SRiku Voipio    futimens(0, NULL);
1305ebc996f3SRiku Voipio    return 0;
1306ebc996f3SRiku Voipio}
1307ebc996f3SRiku VoipioEOF
1308ebc996f3SRiku Voipioif $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1309ebc996f3SRiku Voipio  utimens=yes
1310ebc996f3SRiku Voipiofi
1311ebc996f3SRiku Voipio
1312099d6b0fSRiku Voipio# check if pipe2 is there
1313099d6b0fSRiku Voipiopipe2=no
1314099d6b0fSRiku Voipiocat > $TMPC << EOF
1315099d6b0fSRiku Voipio#define _GNU_SOURCE
1316099d6b0fSRiku Voipio#include <unistd.h>
1317099d6b0fSRiku Voipio#include <fcntl.h>
1318099d6b0fSRiku Voipio
1319099d6b0fSRiku Voipioint main(void)
1320099d6b0fSRiku Voipio{
1321099d6b0fSRiku Voipio    int pipefd[2];
1322099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1323099d6b0fSRiku Voipio    return 0;
1324099d6b0fSRiku Voipio}
1325099d6b0fSRiku VoipioEOF
1326099d6b0fSRiku Voipioif $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
1327099d6b0fSRiku Voipio  pipe2=yes
1328099d6b0fSRiku Voipiofi
1329099d6b0fSRiku Voipio
13303ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
13313ce34dfbSvibisreenivasansplice=no
13323ce34dfbSvibisreenivasancat > $TMPC << EOF
13333ce34dfbSvibisreenivasan#define _GNU_SOURCE
13343ce34dfbSvibisreenivasan#include <unistd.h>
13353ce34dfbSvibisreenivasan#include <fcntl.h>
13363ce34dfbSvibisreenivasan#include <limits.h>
13373ce34dfbSvibisreenivasan
13383ce34dfbSvibisreenivasanint main(void)
13393ce34dfbSvibisreenivasan{
13403ce34dfbSvibisreenivasan    int len, fd;
13413ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
13423ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
13433ce34dfbSvibisreenivasan    return 0;
13443ce34dfbSvibisreenivasan}
13453ce34dfbSvibisreenivasanEOF
13463ce34dfbSvibisreenivasanif $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
13473ce34dfbSvibisreenivasan  splice=yes
13483ce34dfbSvibisreenivasanfi
13493ce34dfbSvibisreenivasan
1350cc8ae6deSpbrook# Check if tools are available to build documentation.
135170ec5dc0SAnthony Liguoriif test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then
135270ec5dc0SAnthony Liguori  build_docs="no"
1353cc8ae6deSpbrookfi
1354cc8ae6deSpbrook
1355da93a1fdSaliguori##########################################
1356da93a1fdSaliguori# Do we need librt
1357e5d355d1SaliguoriCLOCKLIBS=""
1358da93a1fdSaliguoricat > $TMPC <<EOF
1359da93a1fdSaliguori#include <signal.h>
1360da93a1fdSaliguori#include <time.h>
1361da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
1362da93a1fdSaliguoriEOF
1363da93a1fdSaliguori
1364da93a1fdSaliguorirt=no
13658c7f7574Sbalrogif $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then
1366da93a1fdSaliguori  :
13678c7f7574Sbalrogelif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt > /dev/null 2> /dev/null ; then
1368da93a1fdSaliguori  rt=yes
1369da93a1fdSaliguorifi
1370da93a1fdSaliguori
1371da93a1fdSaliguoriif test "$rt" = "yes" ; then
1372e5d355d1Saliguori  CLOCKLIBS="-lrt"
1373da93a1fdSaliguorifi
1374da93a1fdSaliguori
137511d9f695Sbellardif test "$mingw32" = "yes" ; then
137611d9f695Sbellard  if test -z "$prefix" ; then
137717e90973Saliguori      prefix="c:\\\\Program Files\\\\Qemu"
137811d9f695Sbellard  fi
1379308c3593Spbrook  mansuffix=""
1380308c3593Spbrook  datasuffix=""
1381308c3593Spbrook  docsuffix=""
1382308c3593Spbrook  binsuffix=""
138311d9f695Sbellardelse
138411d9f695Sbellard  if test -z "$prefix" ; then
138511d9f695Sbellard      prefix="/usr/local"
138611d9f695Sbellard  fi
1387308c3593Spbrook  mansuffix="/share/man"
1388308c3593Spbrook  datasuffix="/share/qemu"
1389308c3593Spbrook  docsuffix="/share/doc/qemu"
1390308c3593Spbrook  binsuffix="/bin"
139111d9f695Sbellardfi
13925a67135aSbellard
13937d13299dSbellardecho "Install prefix    $prefix"
1394308c3593Spbrookecho "BIOS directory    $prefix$datasuffix"
1395308c3593Spbrookecho "binary directory  $prefix$binsuffix"
139611d9f695Sbellardif test "$mingw32" = "no" ; then
1397308c3593Spbrookecho "Manual directory  $prefix$mansuffix"
139843ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
139911d9f695Sbellardfi
14005a67135aSbellardecho "Source path       $source_path"
14017d13299dSbellardecho "C compiler        $cc"
140283469015Sbellardecho "Host C compiler   $host_cc"
1403db7287edSpbrookecho "ARCH_CFLAGS       $ARCH_CFLAGS"
14047d13299dSbellardecho "make              $make"
14056a882643Spbrookecho "install           $install"
1406a98fd896Sbellardecho "host CPU          $cpu"
1407de83cd02Sbellardecho "host big endian   $bigendian"
140897a847bcSbellardecho "target list       $target_list"
1409ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
14107d13299dSbellardecho "gprof enabled     $gprof"
141103b4fe7dSaliguoriecho "sparse enabled    $sparse"
14121625af87Saliguoriecho "strip binaries    $strip_opt"
141305c2a3e7Sbellardecho "profiler          $profiler"
141443ce4dfeSbellardecho "static build      $static"
141585aa5189Sbellardecho "-Werror enabled   $werror"
14165b0753e0Sbellardif test "$darwin" = "yes" ; then
14175b0753e0Sbellard    echo "Cocoa support     $cocoa"
14185b0753e0Sbellardfi
141997a847bcSbellardecho "SDL support       $sdl"
1420e4afee97Sbellardif test "$sdl" != "no" ; then
14217c1f25b4Sbellard    echo "SDL static link   $sdl_static"
1422e4afee97Sbellardfi
14234d3b6f6eSbalrogecho "curses support    $curses"
1424769ce76dSAlexander Grafecho "curl support      $curl"
142567b915a5Sbellardecho "mingw32 support   $mingw32"
14260c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
14270c58ac1cSmalcecho "Extra audio cards $audio_card_list"
14288ff9cbf7Smalcecho "Mixer emulation   $mixemu"
14298d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
14308d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
14318d5d2d4cSths    echo "    TLS CFLAGS    $vnc_tls_cflags"
14328d5d2d4cSths    echo "    TLS LIBS      $vnc_tls_libs"
14338d5d2d4cSthsfi
14342f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
14352f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
14362f9606b3Saliguori    echo "    SASL CFLAGS    $vnc_sasl_cflags"
14372f9606b3Saliguori    echo "    SASL LIBS      $vnc_sasl_libs"
14382f9606b3Saliguorifi
14393142255cSblueswir1if test -n "$sparc_cpu"; then
14403142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
14413142255cSblueswir1fi
144207f4ddbfSbellardecho "kqemu support     $kqemu"
1443e37630caSaliguoriecho "xen support       $xen"
14442e4d9fb1Saurel32echo "brlapi support    $brlapi"
1445cc8ae6deSpbrookecho "Documentation     $build_docs"
1446c5937220Spbrook[ ! -z "$uname_release" ] && \
1447c5937220Spbrookecho "uname -r          $uname_release"
1448bd0c5661Spbrookecho "NPTL support      $nptl"
14498a16d273Sthsecho "vde support       $vde"
1450414f0dabSblueswir1echo "AIO support       $aio"
1451e5d355d1Saliguoriecho "IO thread         $io_thread"
145277755340Sthsecho "Install blobs     $blobs"
1453168ccc11SJan Kiszkaecho -e "KVM support       $kvm"
1454f652e6afSaurel32echo "fdt support       $fdt"
1455ceb42de8Saliguoriecho "preadv support    $preadv"
145667b915a5Sbellard
145797a847bcSbellardif test $sdl_too_old = "yes"; then
145824b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
1459e8cd23deSbellardfi
146024b55b96Sbellard#if test "$sdl_static" = "no"; then
146124b55b96Sbellard#  echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output"
146224b55b96Sbellard#fi
146397a847bcSbellardconfig_mak="config-host.mak"
146497a847bcSbellardconfig_h="config-host.h"
146597a847bcSbellard
14667c1f25b4Sbellard#echo "Creating $config_mak and $config_h"
146797a847bcSbellard
146815d9ca0fSthstest -f $config_h && mv $config_h ${config_h}~
146915d9ca0fSths
147097a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
1471fc9902d9Smalcprintf "# Configured with:" >> $config_mak
1472fd69fe2bSmalcprintf " '%s'" "$0" "$@" >> $config_mak
1473fd69fe2bSmalcecho >> $config_mak
147497a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
147597a847bcSbellard
147697a847bcSbellardecho "prefix=$prefix" >> $config_mak
1477308c3593Spbrookecho "bindir=\${prefix}$binsuffix" >> $config_mak
1478308c3593Spbrookecho "mandir=\${prefix}$mansuffix" >> $config_mak
1479308c3593Spbrookecho "datadir=\${prefix}$datasuffix" >> $config_mak
14804ad5b06dSthsecho "docdir=\${prefix}$docsuffix" >> $config_mak
1481308c3593Spbrookecho "#define CONFIG_QEMU_SHAREDIR \"$prefix$datasuffix\"" >> $config_h
148297a847bcSbellardecho "MAKE=$make" >> $config_mak
14836a882643Spbrookecho "INSTALL=$install" >> $config_mak
148458f8aeadSaliguoriecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_mak
148558f8aeadSaliguoriecho "INSTALL_DATA=$install -m0644 -p" >> $config_mak
148658f8aeadSaliguoriecho "INSTALL_PROG=$install -m0755 -p" >> $config_mak
148797a847bcSbellardecho "CC=$cc" >> $config_mak
148897a847bcSbellardecho "HOST_CC=$host_cc" >> $config_mak
148997a847bcSbellardecho "AR=$ar" >> $config_mak
149040293e58Sbellard# XXX: only use CFLAGS and LDFLAGS ?
149140293e58Sbellard# XXX: should export HOST_CFLAGS and HOST_LDFLAGS for cross
149240293e58Sbellard# compilation of dyngen tool (useful for win32 build on Linux host)
14936f30fa85Sthsecho "OS_CFLAGS=$OS_CFLAGS" >> $config_mak
14943142255cSblueswir1echo "OS_LDFLAGS=$OS_LDFLAGS" >> $config_mak
14953142255cSblueswir1echo "ARCH_CFLAGS=$ARCH_CFLAGS" >> $config_mak
14963142255cSblueswir1echo "ARCH_LDFLAGS=$ARCH_LDFLAGS" >> $config_mak
149797a847bcSbellardecho "CFLAGS=$CFLAGS" >> $config_mak
149897a847bcSbellardecho "LDFLAGS=$LDFLAGS" >> $config_mak
149967b915a5Sbellardecho "EXESUF=$EXESUF" >> $config_mak
1500e5d355d1Saliguoriecho "PTHREADLIBS=$PTHREADLIBS" >> $config_mak
1501e5d355d1Saliguoriecho "CLOCKLIBS=$CLOCKLIBS" >> $config_mak
15022408a527Saurel32case "$cpu" in
15032408a527Saurel32  i386)
150497a847bcSbellard    echo "ARCH=i386" >> $config_mak
150597a847bcSbellard    echo "#define HOST_I386 1" >> $config_h
15062408a527Saurel32  ;;
15072408a527Saurel32  x86_64)
15080b0babc6Sbellard    echo "ARCH=x86_64" >> $config_mak
15090b0babc6Sbellard    echo "#define HOST_X86_64 1" >> $config_h
15102408a527Saurel32  ;;
15112408a527Saurel32  alpha)
15120938cda5Saurel32    echo "ARCH=alpha" >> $config_mak
15130938cda5Saurel32    echo "#define HOST_ALPHA 1" >> $config_h
15142408a527Saurel32  ;;
15152408a527Saurel32  armv4b)
1516808c4954Sbellard    echo "ARCH=arm" >> $config_mak
1517808c4954Sbellard    echo "#define HOST_ARM 1" >> $config_h
15182408a527Saurel32  ;;
15192408a527Saurel32  armv4l)
152097a847bcSbellard    echo "ARCH=arm" >> $config_mak
152197a847bcSbellard    echo "#define HOST_ARM 1" >> $config_h
15222408a527Saurel32  ;;
15232408a527Saurel32  cris)
1524e7daa605Sths    echo "ARCH=cris" >> $config_mak
1525e7daa605Sths    echo "#define HOST_CRIS 1" >> $config_h
15262408a527Saurel32  ;;
15272408a527Saurel32  hppa)
1528f54b3f92Saurel32    echo "ARCH=hppa" >> $config_mak
1529f54b3f92Saurel32    echo "#define HOST_HPPA 1" >> $config_h
15302408a527Saurel32  ;;
15312408a527Saurel32  ia64)
153297a847bcSbellard    echo "ARCH=ia64" >> $config_mak
153397a847bcSbellard    echo "#define HOST_IA64 1" >> $config_h
15342408a527Saurel32  ;;
15352408a527Saurel32  m68k)
153638ca2abcSbellard    echo "ARCH=m68k" >> $config_mak
153738ca2abcSbellard    echo "#define HOST_M68K 1" >> $config_h
15382408a527Saurel32  ;;
153972b675caSEdgar E. Iglesias  microblaze)
154072b675caSEdgar E. Iglesias    echo "ARCH=microblaze" >> $config_mak
154172b675caSEdgar E. Iglesias    echo "#define HOST_MICROBLAZE 1" >> $config_h
154272b675caSEdgar E. Iglesias  ;;
15432408a527Saurel32  mips)
15440938cda5Saurel32    echo "ARCH=mips" >> $config_mak
15450938cda5Saurel32    echo "#define HOST_MIPS 1" >> $config_h
15462408a527Saurel32  ;;
15472408a527Saurel32  mips64)
15480938cda5Saurel32    echo "ARCH=mips64" >> $config_mak
15490938cda5Saurel32    echo "#define HOST_MIPS64 1" >> $config_h
15502408a527Saurel32  ;;
1551fdf7ed96Smalc  ppc)
15520938cda5Saurel32    echo "ARCH=ppc" >> $config_mak
15530938cda5Saurel32    echo "#define HOST_PPC 1" >> $config_h
1554fdf7ed96Smalc  ;;
1555fdf7ed96Smalc  ppc64)
1556810260a8Smalc    echo "ARCH=ppc64" >> $config_mak
1557810260a8Smalc    echo "#define HOST_PPC64 1" >> $config_h
15582408a527Saurel32  ;;
15592408a527Saurel32  s390)
15600938cda5Saurel32    echo "ARCH=s390" >> $config_mak
15610938cda5Saurel32    echo "#define HOST_S390 1" >> $config_h
15622408a527Saurel32  ;;
15632408a527Saurel32  sparc)
15640938cda5Saurel32    echo "ARCH=sparc" >> $config_mak
15650938cda5Saurel32    echo "#define HOST_SPARC 1" >> $config_h
15662408a527Saurel32  ;;
15672408a527Saurel32  sparc64)
15680938cda5Saurel32    echo "ARCH=sparc64" >> $config_mak
15690938cda5Saurel32    echo "#define HOST_SPARC64 1" >> $config_h
15702408a527Saurel32  ;;
15712408a527Saurel32  *)
15723142255cSblueswir1    echo "Unsupported CPU = $cpu"
15737d13299dSbellard    exit 1
15742408a527Saurel32  ;;
15752408a527Saurel32esac
1576f8393946Saurel32if test "$debug_tcg" = "yes" ; then
1577f8393946Saurel32  echo "#define DEBUG_TCG 1" >> $config_h
1578f8393946Saurel32fi
1579f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
1580f3d08ee6SPaul Brook  echo "#define DEBUG_EXEC 1" >> $config_h
1581f3d08ee6SPaul Brookfi
158203b4fe7dSaliguoriif test "$sparse" = "yes" ; then
158303b4fe7dSaliguori  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_mak
158403b4fe7dSaliguori  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_mak
158503b4fe7dSaliguori  echo "CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_mak
158603b4fe7dSaliguorifi
15871625af87Saliguoriif test "$strip_opt" = "yes" ; then
15881625af87Saliguori  echo "STRIP_OPT=-s" >> $config_mak
15891625af87Saliguorifi
15907d13299dSbellardif test "$bigendian" = "yes" ; then
159197a847bcSbellard  echo "WORDS_BIGENDIAN=yes" >> $config_mak
159297a847bcSbellard  echo "#define WORDS_BIGENDIAN 1" >> $config_h
159397a847bcSbellardfi
1594b6853697Sbellardecho "#define HOST_LONG_BITS $hostlongbits" >> $config_h
159567b915a5Sbellardif test "$mingw32" = "yes" ; then
159667b915a5Sbellard  echo "CONFIG_WIN32=yes" >> $config_mak
159711d9f695Sbellard  echo "#define CONFIG_WIN32 1" >> $config_h
1598210fa556Spbrookelse
1599210fa556Spbrook  cat > $TMPC << EOF
1600210fa556Spbrook#include <byteswap.h>
1601210fa556Spbrookint main(void) { return bswap_32(0); }
1602210fa556SpbrookEOF
1603178baee6Saurel32  if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
160497a847bcSbellard    echo "#define HAVE_BYTESWAP_H 1" >> $config_h
160567b915a5Sbellard  fi
16061360677cSblueswir1  cat > $TMPC << EOF
16071360677cSblueswir1#include <sys/endian.h>
16081360677cSblueswir1#include <sys/types.h>
16091360677cSblueswir1#include <machine/bswap.h>
16101360677cSblueswir1int main(void) { return bswap32(0); }
16111360677cSblueswir1EOF
1612178baee6Saurel32  if $cc $ARCH_CFLAGS -o $TMPE $TMPC >/dev/null 2> /dev/null ; then
16131360677cSblueswir1    echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
16141360677cSblueswir1  fi
1615210fa556Spbrookfi
1616128ab2ffSblueswir1
1617128ab2ffSblueswir1if [ "$openbsd" = "yes" ] ; then
1618128ab2ffSblueswir1  echo "#define ENOTSUP 4096" >> $config_h
1619128ab2ffSblueswir1fi
1620128ab2ffSblueswir1
162183fb7adfSbellardif test "$darwin" = "yes" ; then
162283fb7adfSbellard  echo "CONFIG_DARWIN=yes" >> $config_mak
162383fb7adfSbellard  echo "#define CONFIG_DARWIN 1" >> $config_h
162483fb7adfSbellardfi
1625b29fe3edSmalc
1626b29fe3edSmalcif test "$aix" = "yes" ; then
1627b29fe3edSmalc  echo "CONFIG_AIX=yes" >> $config_mak
1628b29fe3edSmalc  echo "#define CONFIG_AIX 1" >> $config_h
1629b29fe3edSmalcfi
1630b29fe3edSmalc
1631ec530c81Sbellardif test "$solaris" = "yes" ; then
1632ec530c81Sbellard  echo "CONFIG_SOLARIS=yes" >> $config_mak
163338cfa06cSbellard  echo "#define HOST_SOLARIS $solarisrev" >> $config_h
16340475a5caSths  if test "$needs_libsunmath" = "yes" ; then
16350475a5caSths    echo "NEEDS_LIBSUNMATH=yes" >> $config_mak
16360475a5caSths    echo "#define NEEDS_LIBSUNMATH 1" >> $config_h
16370475a5caSths  fi
1638ec530c81Sbellardfi
16393142255cSblueswir1if test -n "$sparc_cpu"; then
16403142255cSblueswir1  echo "CONFIG__sparc_${sparc_cpu}__=yes" >> $config_mak
16413142255cSblueswir1  echo "#define __sparc_${sparc_cpu}__ 1" >> $config_h
16423142255cSblueswir1fi
164397a847bcSbellardif test "$gprof" = "yes" ; then
164497a847bcSbellard  echo "TARGET_GPROF=yes" >> $config_mak
164597a847bcSbellard  echo "#define HAVE_GPROF 1" >> $config_h
164697a847bcSbellardfi
164797a847bcSbellardif test "$static" = "yes" ; then
164897a847bcSbellard  echo "CONFIG_STATIC=yes" >> $config_mak
164950863472Sbellard  echo "#define CONFIG_STATIC 1" >> $config_h
165097a847bcSbellardfi
165105c2a3e7Sbellardif test $profiler = "yes" ; then
165205c2a3e7Sbellard  echo "#define CONFIG_PROFILER 1" >> $config_h
165305c2a3e7Sbellardfi
1654c20709aaSbellardif test "$slirp" = "yes" ; then
1655c20709aaSbellard  echo "CONFIG_SLIRP=yes" >> $config_mak
1656c20709aaSbellard  echo "#define CONFIG_SLIRP 1" >> $config_h
1657c20709aaSbellardfi
16588a16d273Sthsif test "$vde" = "yes" ; then
16598a16d273Sths  echo "CONFIG_VDE=yes" >> $config_mak
16608a16d273Sths  echo "#define CONFIG_VDE 1" >> $config_h
16618a16d273Sths  echo "VDE_LIBS=-lvdeplug" >> $config_mak
16628a16d273Sthsfi
16630c58ac1cSmalcfor card in $audio_card_list; do
1664f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
16650c58ac1cSmalc    echo "$def=yes" >> $config_mak
16660c58ac1cSmalc    echo "#define $def 1" >> $config_h
16670c58ac1cSmalcdone
16680c58ac1cSmalcecho "#define AUDIO_DRIVERS \\" >> $config_h
16690c58ac1cSmalcfor drv in $audio_drv_list; do
16700c58ac1cSmalc    echo "    &${drv}_audio_driver, \\" >>$config_h
1671f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
16720c58ac1cSmalc    echo "$def=yes" >> $config_mak
1673923e4521Smalc    if test "$drv" = "fmod"; then
16740c58ac1cSmalc        echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
16750c58ac1cSmalc        echo "CONFIG_FMOD_INC=$fmod_inc" >> $config_mak
16762f6a1ab0Sblueswir1    elif test "$drv" = "oss"; then
16772f6a1ab0Sblueswir1        echo "CONFIG_OSS_LIB=$oss_lib" >> $config_mak
1678fb065187Sbellard    fi
16790c58ac1cSmalcdone
16800c58ac1cSmalcecho "" >>$config_h
16818ff9cbf7Smalcif test "$mixemu" = "yes" ; then
16828ff9cbf7Smalc  echo "CONFIG_MIXEMU=yes" >> $config_mak
16838ff9cbf7Smalc  echo "#define CONFIG_MIXEMU 1" >> $config_h
16848ff9cbf7Smalcfi
16858d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
16868d5d2d4cSths  echo "CONFIG_VNC_TLS=yes" >> $config_mak
16878d5d2d4cSths  echo "CONFIG_VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_mak
16888d5d2d4cSths  echo "CONFIG_VNC_TLS_LIBS=$vnc_tls_libs" >> $config_mak
16898d5d2d4cSths  echo "#define CONFIG_VNC_TLS 1" >> $config_h
16908d5d2d4cSthsfi
16912f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
16922f9606b3Saliguori  echo "CONFIG_VNC_SASL=yes" >> $config_mak
16932f9606b3Saliguori  echo "CONFIG_VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_mak
16942f9606b3Saliguori  echo "CONFIG_VNC_SASL_LIBS=$vnc_sasl_libs" >> $config_mak
16952f9606b3Saliguori  echo "#define CONFIG_VNC_SASL 1" >> $config_h
16962f9606b3Saliguorifi
169776655d6dSaliguoriif test "$fnmatch" = "yes" ; then
169876655d6dSaliguori  echo "#define HAVE_FNMATCH_H 1" >> $config_h
169976655d6dSaliguorifi
1700b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
1701b1a550a0Spbrookecho "VERSION=$qemu_version" >>$config_mak
1702d4b8f039Spbrookecho "#define QEMU_VERSION \"$qemu_version\"" >> $config_h
170397a847bcSbellard
17044a19f1ecSpbrookecho "#define QEMU_PKGVERSION \"$pkgversion\"" >> $config_h
17054a19f1ecSpbrook
170697a847bcSbellardecho "SRC_PATH=$source_path" >> $config_mak
1707ad064840Spbrookif [ "$source_path_used" = "yes" ]; then
1708ad064840Spbrook  echo "VPATH=$source_path" >> $config_mak
1709ad064840Spbrookfi
171097a847bcSbellardecho "TARGET_DIRS=$target_list" >> $config_mak
1711cc8ae6deSpbrookif [ "$build_docs" = "yes" ] ; then
1712cc8ae6deSpbrook  echo "BUILD_DOCS=yes" >> $config_mak
1713cc8ae6deSpbrookfi
171449ecc3faSbellardif test "$static" = "yes"; then
171549ecc3faSbellard  sdl1=$sdl_static
171649ecc3faSbellardelse
171749ecc3faSbellard  sdl1=$sdl
171849ecc3faSbellardfi
171949ecc3faSbellardif test "$sdl1" = "yes" ; then
172049ecc3faSbellard  echo "#define CONFIG_SDL 1" >> $config_h
172149ecc3faSbellard  echo "CONFIG_SDL=yes" >> $config_mak
172249ecc3faSbellard  if test "$target_softmmu" = "no" -o "$static" = "yes"; then
172349ecc3faSbellard    echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
17245368a422Saliguori  elif test "$sdl_x11" = "yes" ; then
17255368a422Saliguori    echo "SDL_LIBS=`$sdl_config --libs` -lX11" >> $config_mak
172649ecc3faSbellard  else
172749ecc3faSbellard    echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
172849ecc3faSbellard  fi
172949ecc3faSbellard  if [ "${aa}" = "yes" ] ; then
173049ecc3faSbellard    echo "SDL_CFLAGS=`$sdl_config --cflags` `aalib-config --cflags`" >> $config_mak
173149ecc3faSbellard  else
173249ecc3faSbellard    echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
173349ecc3faSbellard  fi
173449ecc3faSbellardfi
173549ecc3faSbellardif test "$cocoa" = "yes" ; then
173649ecc3faSbellard  echo "#define CONFIG_COCOA 1" >> $config_h
173749ecc3faSbellard  echo "CONFIG_COCOA=yes" >> $config_mak
173849ecc3faSbellardfi
17394d3b6f6eSbalrogif test "$curses" = "yes" ; then
17404d3b6f6eSbalrog  echo "#define CONFIG_CURSES 1" >> $config_h
17414d3b6f6eSbalrog  echo "CONFIG_CURSES=yes" >> $config_mak
1742*ab4e5602SJan Kiszka  if test "$ncurses" = "yes" ; then
1743*ab4e5602SJan Kiszka    echo "CURSES_LIBS=-lncurses" >> $config_mak
1744*ab4e5602SJan Kiszka  else
17454d3b6f6eSbalrog    echo "CURSES_LIBS=-lcurses" >> $config_mak
17464d3b6f6eSbalrog  fi
1747*ab4e5602SJan Kiszkafi
17483b3f24adSaurel32if test "$atfile" = "yes" ; then
17493b3f24adSaurel32  echo "#define CONFIG_ATFILE 1" >> $config_h
17503b3f24adSaurel32fi
1751ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
1752ebc996f3SRiku Voipio  echo "#define CONFIG_UTIMENSAT 1" >> $config_h
1753ebc996f3SRiku Voipiofi
1754099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
1755099d6b0fSRiku Voipio  echo "#define CONFIG_PIPE2 1" >> $config_h
1756099d6b0fSRiku Voipiofi
17573ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
17583ce34dfbSvibisreenivasan  echo "#define CONFIG_SPLICE 1" >> $config_h
17593ce34dfbSvibisreenivasanfi
17603b3f24adSaurel32if test "$inotify" = "yes" ; then
17613b3f24adSaurel32  echo "#define CONFIG_INOTIFY 1" >> $config_h
17623b3f24adSaurel32fi
1763769ce76dSAlexander Grafif test "$curl" = "yes" ; then
1764769ce76dSAlexander Graf  echo "CONFIG_CURL=yes" >> $config_mak
1765769ce76dSAlexander Graf  echo "CURL_LIBS=$curl_libs" >> $config_mak
1766769ce76dSAlexander Graf  echo "#define CONFIG_CURL 1" >> $config_h
1767769ce76dSAlexander Graffi
17682e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
17692e4d9fb1Saurel32  echo "CONFIG_BRLAPI=yes" >> $config_mak
17702e4d9fb1Saurel32  echo "#define CONFIG_BRLAPI 1" >> $config_h
17712e4d9fb1Saurel32  echo "BRLAPI_LIBS=-lbrlapi" >> $config_mak
17722e4d9fb1Saurel32fi
1773fb599c9aSbalrogif test "$bluez" = "yes" ; then
1774fb599c9aSbalrog  echo "CONFIG_BLUEZ=yes" >> $config_mak
1775fb599c9aSbalrog  echo "CONFIG_BLUEZ_CFLAGS=$bluez_cflags" >> $config_mak
1776fb599c9aSbalrog  echo "CONFIG_BLUEZ_LIBS=$bluez_libs" >> $config_mak
1777fb599c9aSbalrog  echo "#define CONFIG_BLUEZ 1" >> $config_h
1778fb599c9aSbalrogfi
1779e37630caSaliguoriif test "$xen" = "yes" ; then
17809306acb5Saliguori  echo "XEN_LIBS=-lxenstore -lxenctrl -lxenguest" >> $config_mak
1781e37630caSaliguorifi
1782414f0dabSblueswir1if test "$aio" = "yes" ; then
1783414f0dabSblueswir1  echo "#define CONFIG_AIO 1" >> $config_h
1784a3392f9bSaliguori  echo "CONFIG_AIO=yes" >> $config_mak
1785414f0dabSblueswir1fi
1786e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
1787e5d355d1Saliguori  echo "CONFIG_IOTHREAD=yes" >> $config_mak
1788e5d355d1Saliguori  echo "#define CONFIG_IOTHREAD 1" >> $config_h
1789e5d355d1Saliguorifi
179077755340Sthsif test "$blobs" = "yes" ; then
179177755340Sths  echo "INSTALL_BLOBS=yes" >> $config_mak
179277755340Sthsfi
1793bf9298b9Saliguoriif test "$iovec" = "yes" ; then
1794bf9298b9Saliguori  echo "#define HAVE_IOVEC 1" >> $config_h
1795bf9298b9Saliguorifi
1796ceb42de8Saliguoriif test "$preadv" = "yes" ; then
1797ceb42de8Saliguori  echo "#define HAVE_PREADV 1" >> $config_h
1798ceb42de8Saliguorifi
1799f652e6afSaurel32if test "$fdt" = "yes" ; then
1800f652e6afSaurel32  echo "#define HAVE_FDT 1" >> $config_h
1801f652e6afSaurel32  echo "FDT_LIBS=-lfdt" >> $config_mak
1802f652e6afSaurel32fi
180397a847bcSbellard
180483fb7adfSbellard# XXX: suppress that
18057d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
180643003046Sbellard  echo "#define O_LARGEFILE 0" >> $config_h
180743003046Sbellard  echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
1808179a2c19Sblueswir1  echo "#define HOST_BSD 1" >> $config_h
18097d3505c5Sbellardfi
18107d3505c5Sbellard
1811c5937220Spbrookecho "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
1812c5937220Spbrook
181368063649Sblueswir1# USB host support
181468063649Sblueswir1case "$usb" in
181568063649Sblueswir1linux)
181668063649Sblueswir1  echo "HOST_USB=linux" >> $config_mak
181768063649Sblueswir1;;
181868063649Sblueswir1bsd)
181968063649Sblueswir1  echo "HOST_USB=bsd" >> $config_mak
182068063649Sblueswir1;;
182168063649Sblueswir1*)
182268063649Sblueswir1  echo "HOST_USB=stub" >> $config_mak
182368063649Sblueswir1;;
182468063649Sblueswir1esac
182568063649Sblueswir1
18269abbdbfeSAnthony Liguori# Determine what linker flags to use to force archive inclusion
18279abbdbfeSAnthony Liguoricheck_linker_flags()
18289abbdbfeSAnthony Liguori{
182908b9d66bSAnthony Liguori    w2=
183008b9d66bSAnthony Liguori    if test "$2" ; then
183108b9d66bSAnthony Liguori	w2=-Wl,$2
183208b9d66bSAnthony Liguori    fi
183308b9d66bSAnthony Liguori    $cc $ARCH_CFLAGS -o $TMPE $OS_CFLAGS $TMPC -Wl,$1 ${w2} >/dev/null 2>/dev/null
18349abbdbfeSAnthony Liguori}
18359abbdbfeSAnthony Liguori
18369abbdbfeSAnthony Liguoricat > $TMPC << EOF
18379abbdbfeSAnthony Liguoriint main(void) { }
18389abbdbfeSAnthony LiguoriEOF
18399abbdbfeSAnthony Liguoriif check_linker_flags --whole-archive --no-whole-archive ; then
18409abbdbfeSAnthony Liguori    # GNU ld
18419abbdbfeSAnthony Liguori    echo "ARLIBS_BEGIN=-Wl,--whole-archive" >> $config_mak
18429abbdbfeSAnthony Liguori    echo "ARLIBS_END=-Wl,--no-whole-archive" >> $config_mak
18439abbdbfeSAnthony Liguorielif check_linker_flags -z,allextract -z,defaultextract ; then
18449abbdbfeSAnthony Liguori    # Solaris ld
18459abbdbfeSAnthony Liguori    echo "ARLIBS_BEGIN=-Wl,-z,allextract" >> $config_mak
18469abbdbfeSAnthony Liguori    echo "ARLIBS_END=-Wl,-z,defaultextract" >> $config_mak
184708b9d66bSAnthony Liguorielif check_linker_flags -all_load ; then
184808b9d66bSAnthony Liguori    # Mac OS X
184908b9d66bSAnthony Liguori    echo "ARLIBS_BEGIN=-all_load" >> $config_mak
185008b9d66bSAnthony Liguori    echo "ARLIBS_END=" >> $config_mak
18519abbdbfeSAnthony Liguorielse
18529abbdbfeSAnthony Liguori    echo "Error: your linker does not support --whole-archive or -z."
18539abbdbfeSAnthony Liguori    echo "Please report to qemu-devel@nongnu.org"
18549abbdbfeSAnthony Liguori    exit 1
18559abbdbfeSAnthony Liguorifi
18569abbdbfeSAnthony Liguori
18572567f579SBlue Swirlif test "$xen" = "yes" ;
18582567f579SBlue Swirl    then
18592567f579SBlue Swirl    echo "CONFIG_XEN=yes" >> $config_mak
18602567f579SBlue Swirlfi
18612567f579SBlue Swirl
1862c39e3338Spbrooktools=
1863c39e3338Spbrookif test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
18643dd1f8efSaliguori  tools="qemu-img\$(EXESUF) $tools"
18657a5ca864Sbellard  if [ "$linux" = "yes" ] ; then
18663dd1f8efSaliguori      tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
18677a5ca864Sbellard  fi
1868c39e3338Spbrookfi
1869c39e3338Spbrookecho "TOOLS=$tools" >> $config_mak
1870c39e3338Spbrook
1871370ab986SPaul Brookif test -f ${config_h}~ ; then
1872370ab986SPaul Brook  if cmp -s $config_h ${config_h}~ ; then
1873370ab986SPaul Brook    mv ${config_h}~ $config_h
1874370ab986SPaul Brook  else
1875370ab986SPaul Brook    rm ${config_h}~
1876370ab986SPaul Brook  fi
1877370ab986SPaul Brookfi
1878370ab986SPaul Brook
18791ad2134fSPaul Brookconfig_host_mak=${config_mak}
188015d9ca0fSths
188197a847bcSbellardfor target in $target_list; do
188297a847bcSbellardtarget_dir="$target"
188397a847bcSbellardconfig_mak=$target_dir/config.mak
188497a847bcSbellardconfig_h=$target_dir/config.h
188597a847bcSbellardtarget_cpu=`echo $target | cut -d '-' -f 1`
188697a847bcSbellardtarget_bigendian="no"
1887808c4954Sbellard[ "$target_cpu" = "armeb" ] && target_bigendian=yes
18880938cda5Saurel32[ "$target_cpu" = "m68k" ] && target_bigendian=yes
188972b675caSEdgar E. Iglesias[ "$target_cpu" = "microblaze" ] && target_bigendian=yes
18900938cda5Saurel32[ "$target_cpu" = "mips" ] && target_bigendian=yes
18910938cda5Saurel32[ "$target_cpu" = "mipsn32" ] && target_bigendian=yes
18920938cda5Saurel32[ "$target_cpu" = "mips64" ] && target_bigendian=yes
189367867308Sbellard[ "$target_cpu" = "ppc" ] && target_bigendian=yes
1894d4082e95Sj_mayer[ "$target_cpu" = "ppcemb" ] && target_bigendian=yes
189522f8a8b3Sj_mayer[ "$target_cpu" = "ppc64" ] && target_bigendian=yes
1896e85e7c6eSj_mayer[ "$target_cpu" = "ppc64abi32" ] && target_bigendian=yes
1897908f52b0Spbrook[ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
18980938cda5Saurel32[ "$target_cpu" = "sparc" ] && target_bigendian=yes
18990938cda5Saurel32[ "$target_cpu" = "sparc64" ] && target_bigendian=yes
19000938cda5Saurel32[ "$target_cpu" = "sparc32plus" ] && target_bigendian=yes
190197a847bcSbellardtarget_softmmu="no"
1902997344f3Sbellardtarget_user_only="no"
1903831b7825Sthstarget_linux_user="no"
1904831b7825Sthstarget_darwin_user="no"
190584778508Sblueswir1target_bsd_user="no"
19069e407a85Spbrookcase "$target" in
19079e407a85Spbrook  ${target_cpu}-softmmu)
19089e407a85Spbrook    target_softmmu="yes"
19099e407a85Spbrook    ;;
19109e407a85Spbrook  ${target_cpu}-linux-user)
19119e407a85Spbrook    target_user_only="yes"
19129e407a85Spbrook    target_linux_user="yes"
19139e407a85Spbrook    ;;
19149e407a85Spbrook  ${target_cpu}-darwin-user)
19159e407a85Spbrook    target_user_only="yes"
1916831b7825Sths    target_darwin_user="yes"
19179e407a85Spbrook    ;;
191884778508Sblueswir1  ${target_cpu}-bsd-user)
191984778508Sblueswir1    target_user_only="yes"
192084778508Sblueswir1    target_bsd_user="yes"
192184778508Sblueswir1    ;;
19229e407a85Spbrook  *)
19239e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
19249e407a85Spbrook    exit 1
19259e407a85Spbrook    ;;
19269e407a85Spbrookesac
1927831b7825Sths
19287c1f25b4Sbellard#echo "Creating $config_mak, $config_h and $target_dir/Makefile"
192997a847bcSbellard
193015d9ca0fSthstest -f $config_h && mv $config_h ${config_h}~
193115d9ca0fSths
193297a847bcSbellardmkdir -p $target_dir
1933158142c2Sbellardmkdir -p $target_dir/fpu
193457fec1feSbellardmkdir -p $target_dir/tcg
193584778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
193669de927cSbellard  mkdir -p $target_dir/nwfpe
193769de927cSbellardfi
193869de927cSbellard
1939ec530c81Sbellard#
1940ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
1941ec530c81Sbellard#
1942ec530c81Sbellardrm -f $target_dir/Makefile
1943ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
1944ec530c81Sbellard
194597a847bcSbellard
194697a847bcSbellardecho "# Automatically generated by configure - do not modify" > $config_mak
194797a847bcSbellardecho "/* Automatically generated by configure - do not modify */" > $config_h
194897a847bcSbellard
194997a847bcSbellard
195097a847bcSbellardecho "include ../config-host.mak" >> $config_mak
195197a847bcSbellardecho "#include \"../config-host.h\"" >> $config_h
19521e43adfcSbellard
1953e5fe0c52Spbrookbflt="no"
1954cb33da57Sblueswir1elfload32="no"
1955bd0c5661Spbrooktarget_nptl="no"
19561e43adfcSbellardinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
19571e43adfcSbellardecho "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
195856aebc89Spbrookgdb_xml_files=""
19594ca1a9c6SBlue Swirltarget_kvm="$kvm"
196097a847bcSbellard
19615985eceeSaliguori# Make sure the target and host cpus are compatible
19624ca1a9c6SBlue Swirlif test ! \( "$target_cpu" = "$cpu" -o \
1963fdf7ed96Smalc  \( "$target_cpu" = "ppcemb" -a "$cpu" = "ppc" \) -o \
19645985eceeSaliguori  \( "$target_cpu" = "x86_64" -a "$cpu" = "i386"   \) -o \
19655985eceeSaliguori  \( "$target_cpu" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
19664ca1a9c6SBlue Swirl  target_kvm="no"
19677ba1e619Saliguorifi
19687ba1e619Saliguori# Disable KVM for linux-user
19694ca1a9c6SBlue Swirlif test "$target_softmmu" = "no" ; then
19704ca1a9c6SBlue Swirl  target_kvm="no"
19717ba1e619Saliguorifi
19727ba1e619Saliguori
19732408a527Saurel32case "$target_cpu" in
19742408a527Saurel32  i386)
197597a847bcSbellard    echo "TARGET_ARCH=i386" >> $config_mak
197697a847bcSbellard    echo "#define TARGET_ARCH \"i386\"" >> $config_h
197797a847bcSbellard    echo "#define TARGET_I386 1" >> $config_h
1978da260249Sbellard    if test $kqemu = "yes" -a "$target_softmmu" = "yes"
19792408a527Saurel32    then
19802d6ebb0cSblueswir1      echo "CONFIG_KQEMU=yes" >> $config_mak
1981640f42e4Sblueswir1      echo "#define CONFIG_KQEMU 1" >> $config_h
1982824d560fSbellard    fi
19834ca1a9c6SBlue Swirl    if test "$target_kvm" = "yes" ; then
19847ba1e619Saliguori      echo "CONFIG_KVM=yes" >> $config_mak
19857ba1e619Saliguori      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
19865985eceeSaliguori      echo "#define CONFIG_KVM 1" >> $config_h
19877ba1e619Saliguori    fi
1988e37630caSaliguori    if test "$xen" = "yes" -a "$target_softmmu" = "yes";
1989e37630caSaliguori    then
1990e37630caSaliguori      echo "CONFIG_XEN=yes" >> $config_mak
1991e37630caSaliguori      echo "#define CONFIG_XEN 1" >> $config_h
1992e37630caSaliguori    fi
19931ad2134fSPaul Brook    target_phys_bits=32
19942408a527Saurel32  ;;
19952408a527Saurel32  x86_64)
19960938cda5Saurel32    echo "TARGET_ARCH=x86_64" >> $config_mak
19970938cda5Saurel32    echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
19980938cda5Saurel32    echo "#define TARGET_I386 1" >> $config_h
19990938cda5Saurel32    echo "#define TARGET_X86_64 1" >> $config_h
20002408a527Saurel32    if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64"
20012408a527Saurel32    then
20022d6ebb0cSblueswir1      echo "CONFIG_KQEMU=yes" >> $config_mak
2003640f42e4Sblueswir1      echo "#define CONFIG_KQEMU 1" >> $config_h
20040938cda5Saurel32    fi
20054ca1a9c6SBlue Swirl    if test "$target_kvm" = "yes" ; then
20067ba1e619Saliguori      echo "CONFIG_KVM=yes" >> $config_mak
20077ba1e619Saliguori      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
20087ba1e619Saliguori      echo "#define CONFIG_KVM 1" >> $config_h
20097ba1e619Saliguori    fi
2010e37630caSaliguori    if test "$xen" = "yes" -a "$target_softmmu" = "yes"
2011e37630caSaliguori    then
2012e37630caSaliguori      echo "CONFIG_XEN=yes" >> $config_mak
2013e37630caSaliguori      echo "#define CONFIG_XEN 1" >> $config_h
2014e37630caSaliguori    fi
20151ad2134fSPaul Brook    target_phys_bits=64
20162408a527Saurel32  ;;
20172408a527Saurel32  alpha)
20180938cda5Saurel32    echo "TARGET_ARCH=alpha" >> $config_mak
20190938cda5Saurel32    echo "#define TARGET_ARCH \"alpha\"" >> $config_h
20200938cda5Saurel32    echo "#define TARGET_ALPHA 1" >> $config_h
20211ad2134fSPaul Brook    target_phys_bits=64
20222408a527Saurel32  ;;
20232408a527Saurel32  arm|armeb)
202497a847bcSbellard    echo "TARGET_ARCH=arm" >> $config_mak
202597a847bcSbellard    echo "#define TARGET_ARCH \"arm\"" >> $config_h
202697a847bcSbellard    echo "#define TARGET_ARM 1" >> $config_h
2027e5fe0c52Spbrook    bflt="yes"
2028bd0c5661Spbrook    target_nptl="yes"
202956aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
20301ad2134fSPaul Brook    target_phys_bits=32
20312408a527Saurel32  ;;
20322408a527Saurel32  cris)
20330938cda5Saurel32    echo "TARGET_ARCH=cris" >> $config_mak
20340938cda5Saurel32    echo "#define TARGET_ARCH \"cris\"" >> $config_h
20350938cda5Saurel32    echo "#define TARGET_CRIS 1" >> $config_h
2036253bd7f8Sedgar_igl    target_nptl="yes"
20371ad2134fSPaul Brook    target_phys_bits=32
20382408a527Saurel32  ;;
20392408a527Saurel32  m68k)
20400938cda5Saurel32    echo "TARGET_ARCH=m68k" >> $config_mak
20410938cda5Saurel32    echo "#define TARGET_ARCH \"m68k\"" >> $config_h
20420938cda5Saurel32    echo "#define TARGET_M68K 1" >> $config_h
20430938cda5Saurel32    bflt="yes"
204456aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
20451ad2134fSPaul Brook    target_phys_bits=32
20462408a527Saurel32  ;;
204772b675caSEdgar E. Iglesias  microblaze)
204872b675caSEdgar E. Iglesias    echo "TARGET_ARCH=microblaze" >> $config_mak
204972b675caSEdgar E. Iglesias    echo "#define TARGET_ARCH \"microblaze\"" >> $config_h
205072b675caSEdgar E. Iglesias    echo "#define TARGET_MICROBLAZE 1" >> $config_h
205172b675caSEdgar E. Iglesias    bflt="yes"
205272b675caSEdgar E. Iglesias    target_nptl="yes"
205372b675caSEdgar E. Iglesias    target_phys_bits=32
205472b675caSEdgar E. Iglesias  ;;
20552408a527Saurel32 mips|mipsel)
20560938cda5Saurel32    echo "TARGET_ARCH=mips" >> $config_mak
20570938cda5Saurel32    echo "#define TARGET_ARCH \"mips\"" >> $config_h
20580938cda5Saurel32    echo "#define TARGET_MIPS 1" >> $config_h
20590938cda5Saurel32    echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
20601ad2134fSPaul Brook    target_phys_bits=64
20612408a527Saurel32  ;;
20622408a527Saurel32  mipsn32|mipsn32el)
20630938cda5Saurel32    echo "TARGET_ARCH=mipsn32" >> $config_mak
20640938cda5Saurel32    echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
20650938cda5Saurel32    echo "#define TARGET_MIPS 1" >> $config_h
20660938cda5Saurel32    echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
20671ad2134fSPaul Brook    target_phys_bits=64
20682408a527Saurel32  ;;
20692408a527Saurel32  mips64|mips64el)
20700938cda5Saurel32    echo "TARGET_ARCH=mips64" >> $config_mak
20710938cda5Saurel32    echo "#define TARGET_ARCH \"mips64\"" >> $config_h
20720938cda5Saurel32    echo "#define TARGET_MIPS 1" >> $config_h
20730938cda5Saurel32    echo "#define TARGET_MIPS64 1" >> $config_h
20740938cda5Saurel32    echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
20751ad2134fSPaul Brook    target_phys_bits=64
20762408a527Saurel32  ;;
20772408a527Saurel32  ppc)
207867867308Sbellard    echo "TARGET_ARCH=ppc" >> $config_mak
207967867308Sbellard    echo "#define TARGET_ARCH \"ppc\"" >> $config_h
208067867308Sbellard    echo "#define TARGET_PPC 1" >> $config_h
2081c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
20821ad2134fSPaul Brook    target_phys_bits=32
20832408a527Saurel32  ;;
20842408a527Saurel32  ppcemb)
2085d4082e95Sj_mayer    echo "TARGET_ARCH=ppcemb" >> $config_mak
2086e85e7c6eSj_mayer    echo "TARGET_ABI_DIR=ppc" >> $config_mak
2087d4082e95Sj_mayer    echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
2088d4082e95Sj_mayer    echo "#define TARGET_PPC 1" >> $config_h
2089d4082e95Sj_mayer    echo "#define TARGET_PPCEMB 1" >> $config_h
20904ca1a9c6SBlue Swirl    if test "$target_kvm" = "yes" ; then
2091d76d1650Saurel32      echo "CONFIG_KVM=yes" >> $config_mak
2092d76d1650Saurel32      echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak
2093d76d1650Saurel32      echo "#define CONFIG_KVM 1" >> $config_h
2094d76d1650Saurel32    fi
2095c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
20961ad2134fSPaul Brook    target_phys_bits=64
20972408a527Saurel32  ;;
20982408a527Saurel32  ppc64)
209922f8a8b3Sj_mayer    echo "TARGET_ARCH=ppc64" >> $config_mak
2100f85e9a68Sj_mayer    echo "TARGET_ABI_DIR=ppc" >> $config_mak
21015e692ecdSj_mayer    echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
210222f8a8b3Sj_mayer    echo "#define TARGET_PPC 1" >> $config_h
210322f8a8b3Sj_mayer    echo "#define TARGET_PPC64 1" >> $config_h
2104c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
21051ad2134fSPaul Brook    target_phys_bits=64
21062408a527Saurel32  ;;
21072408a527Saurel32  ppc64abi32)
2108e85e7c6eSj_mayer    echo "TARGET_ARCH=ppc64" >> $config_mak
2109e85e7c6eSj_mayer    echo "TARGET_ABI_DIR=ppc" >> $config_mak
21100c64b9cdSbellard    echo "TARGET_ARCH2=ppc64abi32" >> $config_mak
21115e692ecdSj_mayer    echo "#define TARGET_ARCH \"ppc64\"" >> $config_h
2112e85e7c6eSj_mayer    echo "#define TARGET_PPC 1" >> $config_h
2113e85e7c6eSj_mayer    echo "#define TARGET_PPC64 1" >> $config_h
2114e85e7c6eSj_mayer    echo "#define TARGET_ABI32 1" >> $config_h
2115c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
21161ad2134fSPaul Brook    target_phys_bits=64
21172408a527Saurel32  ;;
21182408a527Saurel32  sh4|sh4eb)
2119fdf9b3e8Sbellard    echo "TARGET_ARCH=sh4" >> $config_mak
2120fdf9b3e8Sbellard    echo "#define TARGET_ARCH \"sh4\"" >> $config_h
2121fdf9b3e8Sbellard    echo "#define TARGET_SH4 1" >> $config_h
21224dbed897Spbrook    bflt="yes"
21230b6d3ae0Saurel32    target_nptl="yes"
21241ad2134fSPaul Brook    target_phys_bits=32
21252408a527Saurel32  ;;
21262408a527Saurel32  sparc)
21270938cda5Saurel32    echo "TARGET_ARCH=sparc" >> $config_mak
21280938cda5Saurel32    echo "#define TARGET_ARCH \"sparc\"" >> $config_h
21290938cda5Saurel32    echo "#define TARGET_SPARC 1" >> $config_h
21301ad2134fSPaul Brook    target_phys_bits=64
21312408a527Saurel32  ;;
21322408a527Saurel32  sparc64)
21330938cda5Saurel32    echo "TARGET_ARCH=sparc64" >> $config_mak
21340938cda5Saurel32    echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
21350938cda5Saurel32    echo "#define TARGET_SPARC 1" >> $config_h
21360938cda5Saurel32    echo "#define TARGET_SPARC64 1" >> $config_h
21370938cda5Saurel32    elfload32="yes"
21381ad2134fSPaul Brook    target_phys_bits=64
21392408a527Saurel32  ;;
21402408a527Saurel32  sparc32plus)
21410938cda5Saurel32    echo "TARGET_ARCH=sparc64" >> $config_mak
21420938cda5Saurel32    echo "TARGET_ABI_DIR=sparc" >> $config_mak
21430938cda5Saurel32    echo "TARGET_ARCH2=sparc32plus" >> $config_mak
21440938cda5Saurel32    echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
21450938cda5Saurel32    echo "#define TARGET_SPARC 1" >> $config_h
21460938cda5Saurel32    echo "#define TARGET_SPARC64 1" >> $config_h
21470938cda5Saurel32    echo "#define TARGET_ABI32 1" >> $config_h
21481ad2134fSPaul Brook    target_phys_bits=64
21492408a527Saurel32  ;;
21502408a527Saurel32  *)
2151de83cd02Sbellard    echo "Unsupported target CPU"
2152de83cd02Sbellard    exit 1
21532408a527Saurel32  ;;
21542408a527Saurel32esac
21551ad2134fSPaul Brookif [ $target_phys_bits -lt $hostlongbits ] ; then
21561ad2134fSPaul Brook  target_phys_bits=$hostlongbits
21571ad2134fSPaul Brookfi
21581ad2134fSPaul Brookecho "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
21591ad2134fSPaul Brookecho "#define TARGET_PHYS_ADDR_BITS $target_phys_bits" >> $config_h
21601ad2134fSPaul Brookecho "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2161de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
216297a847bcSbellard  echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
216397a847bcSbellard  echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
216497a847bcSbellardfi
216597a847bcSbellardif test "$target_softmmu" = "yes" ; then
216697a847bcSbellard  echo "CONFIG_SOFTMMU=yes" >> $config_mak
216797a847bcSbellard  echo "#define CONFIG_SOFTMMU 1" >> $config_h
2168de83cd02Sbellardfi
2169997344f3Sbellardif test "$target_user_only" = "yes" ; then
2170997344f3Sbellard  echo "CONFIG_USER_ONLY=yes" >> $config_mak
2171997344f3Sbellard  echo "#define CONFIG_USER_ONLY 1" >> $config_h
2172997344f3Sbellardfi
2173831b7825Sthsif test "$target_linux_user" = "yes" ; then
2174831b7825Sths  echo "CONFIG_LINUX_USER=yes" >> $config_mak
2175831b7825Sths  echo "#define CONFIG_LINUX_USER 1" >> $config_h
2176831b7825Sthsfi
2177831b7825Sthsif test "$target_darwin_user" = "yes" ; then
2178831b7825Sths  echo "CONFIG_DARWIN_USER=yes" >> $config_mak
2179831b7825Sths  echo "#define CONFIG_DARWIN_USER 1" >> $config_h
2180831b7825Sthsfi
218156aebc89Spbrooklist=""
218256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
218356aebc89Spbrook  for x in $gdb_xml_files; do
218456aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
218556aebc89Spbrook  done
218656aebc89Spbrookfi
218756aebc89Spbrookecho "TARGET_XML_FILES=$list" >> $config_mak
2188de83cd02Sbellard
21890938cda5Saurel32if test "$target_cpu" = "arm" \
21900938cda5Saurel32     -o "$target_cpu" = "armeb" \
21910938cda5Saurel32     -o "$target_cpu" = "m68k" \
219272b675caSEdgar E. Iglesias     -o "$target_cpu" = "microblaze" \
21930938cda5Saurel32     -o "$target_cpu" = "mips" \
21940938cda5Saurel32     -o "$target_cpu" = "mipsel" \
21950938cda5Saurel32     -o "$target_cpu" = "mipsn32" \
21960938cda5Saurel32     -o "$target_cpu" = "mipsn32el" \
21970938cda5Saurel32     -o "$target_cpu" = "mips64" \
21980938cda5Saurel32     -o "$target_cpu" = "mips64el" \
21993147d1e8Saurel32     -o "$target_cpu" = "ppc" \
22003147d1e8Saurel32     -o "$target_cpu" = "ppc64" \
220171e991fdSaurel32     -o "$target_cpu" = "ppc64abi32" \
220271e991fdSaurel32     -o "$target_cpu" = "ppcemb" \
22030938cda5Saurel32     -o "$target_cpu" = "sparc" \
22040938cda5Saurel32     -o "$target_cpu" = "sparc64" \
22050938cda5Saurel32     -o "$target_cpu" = "sparc32plus"; then
2206158142c2Sbellard  echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
2207158142c2Sbellard  echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
2208158142c2Sbellardfi
2209e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
2210e5fe0c52Spbrook  echo "TARGET_HAS_BFLT=yes" >> $config_mak
2211e5fe0c52Spbrook  echo "#define TARGET_HAS_BFLT 1" >> $config_h
2212e5fe0c52Spbrookfi
2213bd0c5661Spbrookif test "$target_user_only" = "yes" \
2214bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
2215bd0c5661Spbrook  echo "#define USE_NPTL 1" >> $config_h
2216bd0c5661Spbrookfi
2217cb33da57Sblueswir1# 32 bit ELF loader in addition to native 64 bit loader?
2218cb33da57Sblueswir1if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
2219cb33da57Sblueswir1  echo "TARGET_HAS_ELFLOAD32=yes" >> $config_mak
2220cb33da57Sblueswir1  echo "#define TARGET_HAS_ELFLOAD32 1" >> $config_h
2221cb33da57Sblueswir1fi
222284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
222384778508Sblueswir1  echo "CONFIG_BSD_USER=yes" >> $config_mak
222484778508Sblueswir1  echo "#define CONFIG_BSD_USER 1" >> $config_h
222584778508Sblueswir1fi
22265b0753e0Sbellard
222715d9ca0fSthstest -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
222815d9ca0fSths
222997a847bcSbellarddone # for target in $targets
22307d13299dSbellard
22317d13299dSbellard# build tree in object directory if source path is different from current one
22327d13299dSbellardif test "$source_path_used" = "yes" ; then
2233019d6b8fSAnthony Liguori    DIRS="tests tests/cris slirp audio block"
22347d13299dSbellard    FILES="Makefile tests/Makefile"
2235e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2236e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
22377d13299dSbellard    for dir in $DIRS ; do
22387d13299dSbellard            mkdir -p $dir
22397d13299dSbellard    done
2240ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
22417d13299dSbellard    for f in $FILES ; do
2242ec530c81Sbellard        rm -f $f
2243ec530c81Sbellard        ln -s $source_path/$f $f
22447d13299dSbellard    done
22457d13299dSbellardfi
22461ad2134fSPaul Brook
22471ad2134fSPaul Brookfor hwlib in 32 64; do
22481ad2134fSPaul Brook  d=libhw$hwlib
22491ad2134fSPaul Brook  mkdir -p $d
22501ad2134fSPaul Brook  rm -f $d/Makefile
22511ad2134fSPaul Brook  ln -s $source_path/Makefile.hw $d/Makefile
22521ad2134fSPaul Brook  echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
22531ad2134fSPaul Brook  echo "CPPFLAGS=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
22541ad2134fSPaul Brookdone
2255