xref: /openbmc/qemu/configure (revision 9c7a4202)
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"
16a91b857cSmalcTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
177d13299dSbellard
1802d5467eSmalctrap "rm -f $TMPC $TMPO $TMPE ; exit" 0 2 3 15
199ac81bbbSmalc
2052166aa0SJuan Quintelacompile_object() {
21a558ee17SJuan Quintela  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
2252166aa0SJuan Quintela}
2352166aa0SJuan Quintela
2452166aa0SJuan Quintelacompile_prog() {
2552166aa0SJuan Quintela  local_cflags="$1"
2652166aa0SJuan Quintela  local_ldflags="$2"
27a558ee17SJuan Quintela  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
2852166aa0SJuan Quintela}
2952166aa0SJuan Quintela
307d13299dSbellard# default parameters
312ff6b91eSJuan Quintelacpu=""
3211d9f695Sbellardprefix=""
331e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
3443ce4dfeSbellardstatic="no"
35ed968ff1SJuan Quintelasparc_cpu=""
367d13299dSbellardcross_prefix=""
377d13299dSbellardcc="gcc"
380c58ac1cSmalcaudio_drv_list=""
394c9b53e3Smalcaudio_card_list="ac97 es1370 sb16"
404c9b53e3Smalcaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
41eb852011SMarkus Armbrusterblock_drv_whitelist=""
427d13299dSbellardhost_cc="gcc"
437d13299dSbellardar="ar"
447d13299dSbellardmake="make"
456a882643Spbrookinstall="install"
467aa486feSAnthony Liguoriobjcopy="objcopy"
477aa486feSAnthony Liguorild="ld"
48c81da56eSJuan Quintelahelper_cflags=""
4973da375eSJuan Quintelalibs_softmmu=""
503e2e0e6bSJuan Quintelalibs_tools=""
5167f86e8eSJuan Quintelaaudio_pt_int=""
52d5631638Smalcaudio_win_int=""
53ac0df51dSaliguori
54ac0df51dSaliguori# parse CC options first
55ac0df51dSaliguorifor opt do
56ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
57ac0df51dSaliguori  case "$opt" in
58ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
59ac0df51dSaliguori  ;;
60ac0df51dSaliguori  --cc=*) cc="$optarg"
61ac0df51dSaliguori  ;;
622ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
632ff6b91eSJuan Quintela  ;;
64a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
65e2a2ed06SJuan Quintela  ;;
66e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
67e2a2ed06SJuan Quintela  ;;
6850e7b1a0SJuan Quintela  --sparc_cpu=*)
6950e7b1a0SJuan Quintela    sparc_cpu="$optarg"
7050e7b1a0SJuan Quintela    case $sparc_cpu in
71ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
7250e7b1a0SJuan Quintela      cpu="sparc"
7350e7b1a0SJuan Quintela    ;;
7450e7b1a0SJuan Quintela    v9)
7550e7b1a0SJuan Quintela      cpu="sparc64"
7650e7b1a0SJuan Quintela    ;;
7750e7b1a0SJuan Quintela    *)
7850e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
7950e7b1a0SJuan Quintela      exit 1
8050e7b1a0SJuan Quintela    ;;
8150e7b1a0SJuan Quintela    esac
8250e7b1a0SJuan Quintela  ;;
83ac0df51dSaliguori  esac
84ac0df51dSaliguoridone
85ac0df51dSaliguori# OS specific
86ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
87ac0df51dSaliguori# we can eliminate it's usage altogether
88ac0df51dSaliguori
89ac0df51dSaliguoricc="${cross_prefix}${cc}"
90ac0df51dSaliguoriar="${cross_prefix}${ar}"
917aa486feSAnthony Liguoriobjcopy="${cross_prefix}${objcopy}"
927aa486feSAnthony Liguorild="${cross_prefix}${ld}"
93ac0df51dSaliguori
94ac0df51dSaliguori# check that the C compiler works.
95ac0df51dSaliguoricat > $TMPC <<EOF
96ac0df51dSaliguoriint main(void) {}
97ac0df51dSaliguoriEOF
98ac0df51dSaliguori
9952166aa0SJuan Quintelaif compile_object ; then
100ac0df51dSaliguori  : C compiler works ok
101ac0df51dSaliguorielse
102ac0df51dSaliguori    echo "ERROR: \"$cc\" either does not exist or does not work"
103ac0df51dSaliguori    exit 1
104ac0df51dSaliguorifi
105ac0df51dSaliguori
106ac0df51dSaliguoricheck_define() {
107ac0df51dSaliguoricat > $TMPC <<EOF
108ac0df51dSaliguori#if !defined($1)
109ac0df51dSaliguori#error Not defined
110ac0df51dSaliguori#endif
111ac0df51dSaliguoriint main(void) { return 0; }
112ac0df51dSaliguoriEOF
11352166aa0SJuan Quintela  compile_object
114ac0df51dSaliguori}
115ac0df51dSaliguori
1162ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
1172ff6b91eSJuan Quintela  # command line argument
1182ff6b91eSJuan Quintela  :
1192ff6b91eSJuan Quintelaelif check_define __i386__ ; then
120ac0df51dSaliguori  cpu="i386"
121ac0df51dSaliguorielif check_define __x86_64__ ; then
122ac0df51dSaliguori  cpu="x86_64"
1233aa9bd6cSblueswir1elif check_define __sparc__ ; then
1243aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
1253aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
1263aa9bd6cSblueswir1  if check_define __arch64__ ; then
1273aa9bd6cSblueswir1    cpu="sparc64"
1283aa9bd6cSblueswir1  else
1293aa9bd6cSblueswir1    cpu="sparc"
1303aa9bd6cSblueswir1  fi
131fdf7ed96Smalcelif check_define _ARCH_PPC ; then
132fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
133fdf7ed96Smalc    cpu="ppc64"
134ac0df51dSaliguori  else
135fdf7ed96Smalc    cpu="ppc"
136fdf7ed96Smalc  fi
137fdf7ed96Smalcelse
138fdf7ed96Smalc  cpu=`uname -m`
139ac0df51dSaliguorifi
140ac0df51dSaliguori
1415327cf48Sbellardtarget_list=""
1427d13299dSbellardcase "$cpu" in
143ea8f20f8SJuan Quintela  alpha|cris|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|sparc64)
144ea8f20f8SJuan Quintela    cpu="$cpu"
145ea8f20f8SJuan Quintela  ;;
1467d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
14797a847bcSbellard    cpu="i386"
1487d13299dSbellard  ;;
149aaa5fa14Saurel32  x86_64|amd64)
150aaa5fa14Saurel32    cpu="x86_64"
151aaa5fa14Saurel32  ;;
152ba68055eSbellard  armv*b)
153808c4954Sbellard    cpu="armv4b"
154808c4954Sbellard  ;;
155ba68055eSbellard  armv*l)
1567d13299dSbellard    cpu="armv4l"
1577d13299dSbellard  ;;
158f54b3f92Saurel32  parisc|parisc64)
159f54b3f92Saurel32    cpu="hppa"
160f54b3f92Saurel32  ;;
1610e7b8a9fSths  s390*)
162fb3e5849Sbellard    cpu="s390"
163fb3e5849Sbellard  ;;
1643142255cSblueswir1  sparc|sun4[cdmuv])
165ae228531Sbellard    cpu="sparc"
166ae228531Sbellard  ;;
1677d13299dSbellard  *)
1687d13299dSbellard    cpu="unknown"
1697d13299dSbellard  ;;
1707d13299dSbellardesac
171e2d52ad3SJuan Quintela
172e2d52ad3SJuan Quintela# Default value for a variable defining feature "foo"
173e2d52ad3SJuan Quintela#  * foo="no", feature will only be used if --enable-foo arg is given
174e2d52ad3SJuan Quintela#  * foo="", feature will be searched for, and if found, will be used
175e2d52ad3SJuan Quintela#  * foo="yes", this value vill only be set by --enable-foo flag.
176e2d52ad3SJuan Quintela#                   feature will searched for, if not found, configure exits with error
177e2d52ad3SJuan Quintela#
178e2d52ad3SJuan Quintela# Always add --enable-foo and --disable-foo command line args.  Distributions want
179e2d52ad3SJuan Quintela# to ensure that several features are compiled in, and it is impossible without a
180e2d52ad3SJuan Quintela# --enable-foo that exits if feature is not found
181e2d52ad3SJuan Quintela
182a20a6f46SJuan Quintelabluez=""
1834ffcedb6SJuan Quintelabrlapi=""
184788c8196SJuan Quintelacurl=""
185c584a6d0SJuan Quintelacurses=""
186a25dba17SJuan Quinteladocs=""
1872df87df7SJuan Quintelafdt=""
188b31a0277SJuan Quintelakvm=""
189b0a47e79SJuan Quintelanptl=""
190c4198157SJuan Quintelasdl=""
191dfffc653SJuan Quintelasparse="no"
192ee682d27SStefan Weiluuid=""
193dfb278bdSJuan Quintelavde=""
1941be10ad2SJuan Quintelavnc_tls=""
195ea784e3bSJuan Quintelavnc_sasl=""
196fc321b4bSJuan Quintelaxen=""
1975c6c3a6cSChristoph Hellwiglinux_aio=""
198dfb278bdSJuan Quintela
1997d13299dSbellardgprof="no"
200f8393946Saurel32debug_tcg="no"
201f3d08ee6SPaul Brookdebug="no"
2021625af87Saliguoristrip_opt="yes"
2037d13299dSbellardbigendian="no"
20467b915a5Sbellardmingw32="no"
20567b915a5SbellardEXESUF=""
206443f1376Sbellardslirp="yes"
207102a52e4Sbellardfmod_lib=""
208102a52e4Sbellardfmod_inc=""
2092f6a1ab0Sblueswir1oss_lib=""
210b1a550a0Spbrookbsd="no"
2115327cf48Sbellardlinux="no"
212d2c7c9b8Sblueswir1solaris="no"
21305c2a3e7Sbellardprofiler="no"
2145b0753e0Sbellardcocoa="no"
2150a8e90f4Spbrooksoftmmu="yes"
216831b7825Sthslinux_user="no"
217831b7825Sthsdarwin_user="no"
21884778508Sblueswir1bsd_user="no"
219379f6698SPaul Brookguest_base=""
220c5937220Spbrookuname_release=""
221e5d355d1Saliguoriio_thread="no"
2228ff9cbf7Smalcmixemu="no"
223eac30262Saliguorikerneldir=""
224b29fe3edSmalcaix="no"
22577755340Sthsblobs="yes"
2264a19f1ecSpbrookpkgversion=""
2275495ed11SLuiz Capitulinocheck_utests="no"
22834005a00SKirill A. Shutemovuser_pie="no"
2297d13299dSbellard
2307d13299dSbellard# OS specific
231ac0df51dSaliguoriif check_define __linux__ ; then
232ac0df51dSaliguori  targetos="Linux"
233ac0df51dSaliguorielif check_define _WIN32 ; then
234ac0df51dSaliguori  targetos='MINGW32'
235169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
236169dc5d3Sblueswir1  targetos='OpenBSD'
237169dc5d3Sblueswir1elif check_define __sun__ ; then
238169dc5d3Sblueswir1  targetos='SunOS'
239ac0df51dSaliguorielse
2407d13299dSbellard  targetos=`uname -s`
241ac0df51dSaliguorifi
2420dbfc675SJuan Quintela
2437d13299dSbellardcase $targetos in
244c326e0afSbellardCYGWIN*)
245c326e0afSbellard  mingw32="yes"
246a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
247d5631638Smalc  audio_possible_drivers="winwave sdl"
248d5631638Smalc  audio_drv_list="winwave"
249c326e0afSbellard;;
25067b915a5SbellardMINGW32*)
25167b915a5Sbellard  mingw32="yes"
252d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
253d5631638Smalc  audio_drv_list="winwave"
25467b915a5Sbellard;;
2555c40d2bdSthsGNU/kFreeBSD)
2560c58ac1cSmalc  audio_drv_list="oss"
257f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
2585c40d2bdSths;;
2597d3505c5SbellardFreeBSD)
2607d3505c5Sbellard  bsd="yes"
2610c58ac1cSmalc  audio_drv_list="oss"
262f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
2637d3505c5Sbellard;;
264c5e97233Sblueswir1DragonFly)
265c5e97233Sblueswir1  bsd="yes"
266c5e97233Sblueswir1  audio_drv_list="oss"
267c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
268c5e97233Sblueswir1;;
2697d3505c5SbellardNetBSD)
2707d3505c5Sbellard  bsd="yes"
2710c58ac1cSmalc  audio_drv_list="oss"
272c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
2738ef92a88Sblueswir1  oss_lib="-lossaudio"
2747d3505c5Sbellard;;
2757d3505c5SbellardOpenBSD)
2767d3505c5Sbellard  bsd="yes"
2770c58ac1cSmalc  audio_drv_list="oss"
278c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
2792f6a1ab0Sblueswir1  oss_lib="-lossaudio"
2807d3505c5Sbellard;;
28183fb7adfSbellardDarwin)
28283fb7adfSbellard  bsd="yes"
28383fb7adfSbellard  darwin="yes"
2840dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
2850dbfc675SJuan Quintela  # run 64-bit userspace code
286aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
2871b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
288aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
2891b0f9cc2Saliguori  fi
2901b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
291a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
2920c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
2931b0f9cc2Saliguori  else
294a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
2951b0f9cc2Saliguori  fi
296831b7825Sths  darwin_user="yes"
297fd677642Sths  cocoa="yes"
2980c58ac1cSmalc  audio_drv_list="coreaudio"
299c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
3000c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
3017973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
30283fb7adfSbellard;;
303ec530c81SbellardSunOS)
304ec530c81Sbellard  solaris="yes"
305c2b84fabSths  make="gmake"
306c2b84fabSths  install="ginstall"
307fa58948dSBlue Swirl  ld="gld"
3080475a5caSths  needs_libsunmath="no"
309c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
310ef18c883Sths  # have to select again, because `uname -m` returns i86pc
311ef18c883Sths  # even on an x86_64 box.
312ef18c883Sths  solariscpu=`isainfo -k`
313ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
314ef18c883Sths    cpu="x86_64"
315ef18c883Sths  fi
316c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
3170475a5caSths    if test "$solarisrev" -le 9 ; then
3180475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
3190475a5caSths        needs_libsunmath="yes"
320f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
321f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
322f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
3230475a5caSths      else
3240475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
3250475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
3260475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
3270475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
3280475a5caSths        exit 1
3290475a5caSths      fi
3300475a5caSths    fi
33186b2bd93Sths  fi
3326b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
3330c58ac1cSmalc    audio_drv_list="oss"
3346b4d2ba1Sths  fi
335c2de5c91Smalc  audio_possible_drivers="oss sdl"
336d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
337d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
338d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
339d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
340a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
341e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
342ec530c81Sbellard;;
343b29fe3edSmalcAIX)
344b29fe3edSmalc  aix="yes"
345b29fe3edSmalc  make="gmake"
346b29fe3edSmalc;;
347fb065187Sbellard*)
3480c58ac1cSmalc  audio_drv_list="oss"
349b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
3505327cf48Sbellard  linux="yes"
351831b7825Sths  linux_user="yes"
35268063649Sblueswir1  usb="linux"
35307f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
354c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
355c9ec1fe4Sbellard  fi
356fb065187Sbellard;;
3577d13299dSbellardesac
3587d13299dSbellard
3597d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
360b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
3617d3505c5Sbellard    make="gmake"
36268063649Sblueswir1    usb="bsd"
36383fb7adfSbellard  fi
36484778508Sblueswir1  bsd_user="yes"
3657d3505c5Sbellardfi
3667d3505c5Sbellard
3673457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
3683457a3f8SJuan Quintela  EXESUF=".exe"
369a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
370884044aaSJuan Quintela  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
3713457a3f8SJuan Quintelafi
3723457a3f8SJuan Quintela
3737d13299dSbellard# find source path
374ad064840Spbrooksource_path=`dirname "$0"`
37559faef3aSbalrogsource_path_used="no"
37659faef3aSbalrogworkdir=`pwd`
377ad064840Spbrookif [ -z "$source_path" ]; then
37859faef3aSbalrog    source_path=$workdir
379ad064840Spbrookelse
380ad064840Spbrook    source_path=`cd "$source_path"; pwd`
3817d13299dSbellardfi
382724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
3837d13299dSbellard
384487fefdbSAnthony Liguoriwerror=""
38585aa5189Sbellard
3867d13299dSbellardfor opt do
387a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
3887d13299dSbellard  case "$opt" in
3892efc3265Sbellard  --help|-h) show_help=yes
3902efc3265Sbellard  ;;
391b1a550a0Spbrook  --prefix=*) prefix="$optarg"
3927d13299dSbellard  ;;
393b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
39432ce6337Sbellard  ;;
395b1a550a0Spbrook  --source-path=*) source_path="$optarg"
396ad064840Spbrook  source_path_used="yes"
3977d13299dSbellard  ;;
398ac0df51dSaliguori  --cross-prefix=*)
3997d13299dSbellard  ;;
400ac0df51dSaliguori  --cc=*)
4017d13299dSbellard  ;;
402b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
40383469015Sbellard  ;;
404b1a550a0Spbrook  --make=*) make="$optarg"
4057d13299dSbellard  ;;
4066a882643Spbrook  --install=*) install="$optarg"
4076a882643Spbrook  ;;
408e2a2ed06SJuan Quintela  --extra-cflags=*)
4097d13299dSbellard  ;;
410e2a2ed06SJuan Quintela  --extra-ldflags=*)
4117d13299dSbellard  ;;
4122ff6b91eSJuan Quintela  --cpu=*)
4137d13299dSbellard  ;;
414b1a550a0Spbrook  --target-list=*) target_list="$optarg"
415de83cd02Sbellard  ;;
4167d13299dSbellard  --enable-gprof) gprof="yes"
4177d13299dSbellard  ;;
41843ce4dfeSbellard  --static) static="yes"
41943ce4dfeSbellard  ;;
42097a847bcSbellard  --disable-sdl) sdl="no"
42197a847bcSbellard  ;;
422c4198157SJuan Quintela  --enable-sdl) sdl="yes"
423c4198157SJuan Quintela  ;;
424b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
425102a52e4Sbellard  ;;
426c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
427c2de5c91Smalc  ;;
4282f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
4292f6a1ab0Sblueswir1  ;;
4302fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
4310c58ac1cSmalc  ;;
4320c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
4330c58ac1cSmalc  ;;
434eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
435eb852011SMarkus Armbruster  ;;
436f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
437f8393946Saurel32  ;;
438f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
439f8393946Saurel32  ;;
440f3d08ee6SPaul Brook  --enable-debug)
441f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
442f3d08ee6SPaul Brook      debug_tcg="yes"
443f3d08ee6SPaul Brook      debug="yes"
444f3d08ee6SPaul Brook      strip_opt="no"
445f3d08ee6SPaul Brook  ;;
44603b4fe7dSaliguori  --enable-sparse) sparse="yes"
44703b4fe7dSaliguori  ;;
44803b4fe7dSaliguori  --disable-sparse) sparse="no"
44903b4fe7dSaliguori  ;;
4501625af87Saliguori  --disable-strip) strip_opt="no"
4511625af87Saliguori  ;;
4528d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
4538d5d2d4cSths  ;;
4541be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
4551be10ad2SJuan Quintela  ;;
4562f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
4572f9606b3Saliguori  ;;
458ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
459ea784e3bSJuan Quintela  ;;
460443f1376Sbellard  --disable-slirp) slirp="no"
461c20709aaSbellard  ;;
462ee682d27SStefan Weil  --disable-uuid) uuid="no"
463ee682d27SStefan Weil  ;;
464ee682d27SStefan Weil  --enable-uuid) uuid="yes"
465ee682d27SStefan Weil  ;;
466e0e6c8c0Saliguori  --disable-vde) vde="no"
4678a16d273Sths  ;;
468dfb278bdSJuan Quintela  --enable-vde) vde="yes"
469dfb278bdSJuan Quintela  ;;
470e37630caSaliguori  --disable-xen) xen="no"
471e37630caSaliguori  ;;
472fc321b4bSJuan Quintela  --enable-xen) xen="yes"
473fc321b4bSJuan Quintela  ;;
4742e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
4752e4d9fb1Saurel32  ;;
4764ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
4774ffcedb6SJuan Quintela  ;;
478fb599c9aSbalrog  --disable-bluez) bluez="no"
479fb599c9aSbalrog  ;;
480a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
481a20a6f46SJuan Quintela  ;;
4827ba1e619Saliguori  --disable-kvm) kvm="no"
4837ba1e619Saliguori  ;;
484b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
485b31a0277SJuan Quintela  ;;
48605c2a3e7Sbellard  --enable-profiler) profiler="yes"
48705c2a3e7Sbellard  ;;
488c2de5c91Smalc  --enable-cocoa)
489c2de5c91Smalc      cocoa="yes" ;
490c2de5c91Smalc      sdl="no" ;
491c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
4925b0753e0Sbellard  ;;
493cad25d69Spbrook  --disable-system) softmmu="no"
4940a8e90f4Spbrook  ;;
495cad25d69Spbrook  --enable-system) softmmu="yes"
4960a8e90f4Spbrook  ;;
4970953a80fSZachary Amsden  --disable-user)
4980953a80fSZachary Amsden      linux_user="no" ;
4990953a80fSZachary Amsden      bsd_user="no" ;
5000953a80fSZachary Amsden      darwin_user="no"
5010953a80fSZachary Amsden  ;;
5020953a80fSZachary Amsden  --enable-user) ;;
503831b7825Sths  --disable-linux-user) linux_user="no"
5040a8e90f4Spbrook  ;;
505831b7825Sths  --enable-linux-user) linux_user="yes"
506831b7825Sths  ;;
507831b7825Sths  --disable-darwin-user) darwin_user="no"
508831b7825Sths  ;;
509831b7825Sths  --enable-darwin-user) darwin_user="yes"
5100a8e90f4Spbrook  ;;
51184778508Sblueswir1  --disable-bsd-user) bsd_user="no"
51284778508Sblueswir1  ;;
51384778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
51484778508Sblueswir1  ;;
515379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
516379f6698SPaul Brook  ;;
517379f6698SPaul Brook  --disable-guest-base) guest_base="no"
518379f6698SPaul Brook  ;;
51934005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
52034005a00SKirill A. Shutemov  ;;
52134005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
52234005a00SKirill A. Shutemov  ;;
523c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
524c5937220Spbrook  ;;
5253142255cSblueswir1  --sparc_cpu=*)
5263142255cSblueswir1  ;;
52785aa5189Sbellard  --enable-werror) werror="yes"
52885aa5189Sbellard  ;;
52985aa5189Sbellard  --disable-werror) werror="no"
53085aa5189Sbellard  ;;
5314d3b6f6eSbalrog  --disable-curses) curses="no"
5324d3b6f6eSbalrog  ;;
533c584a6d0SJuan Quintela  --enable-curses) curses="yes"
534c584a6d0SJuan Quintela  ;;
535769ce76dSAlexander Graf  --disable-curl) curl="no"
536769ce76dSAlexander Graf  ;;
537788c8196SJuan Quintela  --enable-curl) curl="yes"
538788c8196SJuan Quintela  ;;
5392df87df7SJuan Quintela  --disable-fdt) fdt="no"
5402df87df7SJuan Quintela  ;;
5412df87df7SJuan Quintela  --enable-fdt) fdt="yes"
5422df87df7SJuan Quintela  ;;
5435495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
5445495ed11SLuiz Capitulino  ;;
5455495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
5465495ed11SLuiz Capitulino  ;;
547bd0c5661Spbrook  --disable-nptl) nptl="no"
548bd0c5661Spbrook  ;;
549b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
550b0a47e79SJuan Quintela  ;;
5518ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
5528ff9cbf7Smalc  ;;
5535c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
5545c6c3a6cSChristoph Hellwig  ;;
5555c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
5565c6c3a6cSChristoph Hellwig  ;;
557e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
558e5d355d1Saliguori  ;;
55977755340Sths  --disable-blobs) blobs="no"
56077755340Sths  ;;
561eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
562eac30262Saliguori  ;;
5634a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
5644a19f1ecSpbrook  ;;
565a25dba17SJuan Quintela  --disable-docs) docs="no"
56670ec5dc0SAnthony Liguori  ;;
567a25dba17SJuan Quintela  --enable-docs) docs="yes"
56883a3ab8bSJuan Quintela  ;;
5697f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
5707f1559c6Sbalrog  ;;
5717d13299dSbellard  esac
5727d13299dSbellarddone
5737d13299dSbellard
5743142255cSblueswir1#
5753142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
576a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
5773142255cSblueswir1#
578379f6698SPaul Brookhost_guest_base="no"
57940293e58Sbellardcase "$cpu" in
580ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
581ed968ff1SJuan Quintela           v7|v8)
582a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
583ed968ff1SJuan Quintela           ;;
584ed968ff1SJuan Quintela           v8plus|v8plusa)
585a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
586ed968ff1SJuan Quintela           ;;
587ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
588a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
589ed968ff1SJuan Quintela           esac
5900c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
591a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
592762e8230Sblueswir1           if test "$solaris" = "no" ; then
593a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
594c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
595762e8230Sblueswir1           fi
5963142255cSblueswir1           ;;
597ed968ff1SJuan Quintela    sparc64)
598a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
5990c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
600a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
601ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
602a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
603762e8230Sblueswir1           fi
6043142255cSblueswir1           ;;
60576d83bdeSths    s390)
606a558ee17SJuan Quintela           QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
60776d83bdeSths           ;;
60840293e58Sbellard    i386)
609a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
6100c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
611c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
612379f6698SPaul Brook           host_guest_base="yes"
61340293e58Sbellard           ;;
61440293e58Sbellard    x86_64)
615a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
6160c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
617379f6698SPaul Brook           host_guest_base="yes"
618379f6698SPaul Brook           ;;
619379f6698SPaul Brook    arm*)
620379f6698SPaul Brook           host_guest_base="yes"
62140293e58Sbellard           ;;
622f6548c0aSmalc    ppc*)
623f6548c0aSmalc           host_guest_base="yes"
624f6548c0aSmalc           ;;
6253142255cSblueswir1esac
6263142255cSblueswir1
627379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
628379f6698SPaul Brook
629af5db58eSpbrookif test x"$show_help" = x"yes" ; then
630af5db58eSpbrookcat << EOF
631af5db58eSpbrook
632af5db58eSpbrookUsage: configure [options]
633af5db58eSpbrookOptions: [defaults in brackets after descriptions]
634af5db58eSpbrook
635af5db58eSpbrookEOF
636af5db58eSpbrookecho "Standard options:"
637af5db58eSpbrookecho "  --help                   print this message"
638af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
639af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
640af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
641af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
642af5db58eSpbrookecho ""
643af5db58eSpbrookecho "Advanced options (experts only):"
644af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
645af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
646af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
647af5db58eSpbrookecho "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
648a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
649e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
650af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
6516a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
652af5db58eSpbrookecho "  --static                 enable static build [$static]"
653f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
654f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
65509695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
656890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
657890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
6581625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
65985aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
660fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
661c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
662af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
663c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
664c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
6654c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
6664c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
667eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
668eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
6698ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
670e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
671fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
6722e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
6734ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
6748d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
6751be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
6762f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
677ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
678af896aaaSpbrookecho "  --disable-curses         disable curses output"
679c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
680769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
681788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
6822df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
6832df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
6845495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
6855495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
686fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
687a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
6887ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
689b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
690bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
691e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
692af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
693af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
6940953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
6950953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
696831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
697831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
698831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
699831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
70084778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
70184778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
702379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
703379f6698SPaul Brookecho "                           emulation targets"
704379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
70534005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
70634005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
707af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
708af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
7092f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
710c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
7113142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
712ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
713ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
714e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
715dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
7165c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
7175c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
718e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
71977755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
720eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
721af5db58eSpbrookecho ""
7225bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
723af5db58eSpbrookexit 1
724af5db58eSpbrookfi
725af5db58eSpbrook
726ec530c81Sbellard#
727ec530c81Sbellard# Solaris specific configure tool chain decisions
728ec530c81Sbellard#
729ec530c81Sbellardif test "$solaris" = "yes" ; then
730ec530c81Sbellard  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
731ec530c81Sbellard  if test -z "$solinst" ; then
732ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
733ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
734ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
735ec530c81Sbellard    exit 1
736ec530c81Sbellard  fi
737ec530c81Sbellard  if test "$solinst" = "/usr/sbin/install" ; then
738ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
739ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
740ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
741ec530c81Sbellard    exit 1
742ec530c81Sbellard  fi
743ec530c81Sbellard  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
744ec530c81Sbellard  if test -z "$sol_ar" ; then
745ec530c81Sbellard    echo "Error: No path includes ar"
746ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
747ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
748ec530c81Sbellard    fi
749ec530c81Sbellard    exit 1
750ec530c81Sbellard  fi
751ec530c81Sbellardfi
752ec530c81Sbellard
753ec530c81Sbellard
7545327cf48Sbellardif test -z "$target_list" ; then
7555327cf48Sbellard# these targets are portable
7560a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
7572408a527Saurel32        target_list="\
7582408a527Saurel32i386-softmmu \
7592408a527Saurel32x86_64-softmmu \
7602408a527Saurel32arm-softmmu \
7612408a527Saurel32cris-softmmu \
7622408a527Saurel32m68k-softmmu \
76372b675caSEdgar E. Iglesiasmicroblaze-softmmu \
7642408a527Saurel32mips-softmmu \
7652408a527Saurel32mipsel-softmmu \
7662408a527Saurel32mips64-softmmu \
7672408a527Saurel32mips64el-softmmu \
7682408a527Saurel32ppc-softmmu \
7692408a527Saurel32ppcemb-softmmu \
7702408a527Saurel32ppc64-softmmu \
7712408a527Saurel32sh4-softmmu \
7722408a527Saurel32sh4eb-softmmu \
7732408a527Saurel32sparc-softmmu \
7741b64fcaeSIgor V. Kovalenkosparc64-softmmu \
7752408a527Saurel32"
7760a8e90f4Spbrook    fi
7775327cf48Sbellard# the following are Linux specific
778831b7825Sths    if [ "$linux_user" = "yes" ] ; then
7792408a527Saurel32        target_list="${target_list}\
7802408a527Saurel32i386-linux-user \
7812408a527Saurel32x86_64-linux-user \
7822408a527Saurel32alpha-linux-user \
7832408a527Saurel32arm-linux-user \
7842408a527Saurel32armeb-linux-user \
7852408a527Saurel32cris-linux-user \
7862408a527Saurel32m68k-linux-user \
78772b675caSEdgar E. Iglesiasmicroblaze-linux-user \
7882408a527Saurel32mips-linux-user \
7892408a527Saurel32mipsel-linux-user \
7902408a527Saurel32ppc-linux-user \
7912408a527Saurel32ppc64-linux-user \
7922408a527Saurel32ppc64abi32-linux-user \
7932408a527Saurel32sh4-linux-user \
7942408a527Saurel32sh4eb-linux-user \
7952408a527Saurel32sparc-linux-user \
7962408a527Saurel32sparc64-linux-user \
7972408a527Saurel32sparc32plus-linux-user \
7982408a527Saurel32"
799831b7825Sths    fi
800831b7825Sths# the following are Darwin specific
801831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
8022408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
8035327cf48Sbellard    fi
80484778508Sblueswir1# the following are BSD specific
80584778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
80684778508Sblueswir1        target_list="${target_list}\
80731fc12dfSblueswir1i386-bsd-user \
80831fc12dfSblueswir1x86_64-bsd-user \
80931fc12dfSblueswir1sparc-bsd-user \
81084778508Sblueswir1sparc64-bsd-user \
81184778508Sblueswir1"
81284778508Sblueswir1    fi
8136e20a45fSbellardelse
814b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
8155327cf48Sbellardfi
8160a8e90f4Spbrookif test -z "$target_list" ; then
8170a8e90f4Spbrook    echo "No targets enabled"
8180a8e90f4Spbrook    exit 1
8190a8e90f4Spbrookfi
8205327cf48Sbellard
821249247c9SJuan Quintelafeature_not_found() {
822249247c9SJuan Quintela  feature=$1
823249247c9SJuan Quintela
824249247c9SJuan Quintela  echo "ERROR"
825249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
8269332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
827249247c9SJuan Quintela  echo "ERROR"
828249247c9SJuan Quintela  exit 1;
829249247c9SJuan Quintela}
830249247c9SJuan Quintela
8317d13299dSbellardif test -z "$cross_prefix" ; then
8327d13299dSbellard
8337d13299dSbellard# ---
8347d13299dSbellard# big/little endian test
8357d13299dSbellardcat > $TMPC << EOF
8367d13299dSbellard#include <inttypes.h>
8377d13299dSbellardint main(int argc, char ** argv){
8387d13299dSbellard        volatile uint32_t i=0x01234567;
8397d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
8407d13299dSbellard}
8417d13299dSbellardEOF
8427d13299dSbellard
84352166aa0SJuan Quintelaif compile_prog "" "" ; then
8447d13299dSbellard$TMPE && bigendian="yes"
8457d13299dSbellardelse
8467d13299dSbellardecho big/little test failed
8477d13299dSbellardfi
8487d13299dSbellard
8497d13299dSbellardelse
8507d13299dSbellard
8517d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
852ea8f20f8SJuan Quintelacase "$cpu" in
853ea8f20f8SJuan Quintela  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
854ea8f20f8SJuan Quintela    bigendian=yes
855ea8f20f8SJuan Quintela  ;;
856ea8f20f8SJuan Quintelaesac
8577d13299dSbellard
8587d13299dSbellardfi
8597d13299dSbellard
860b6853697Sbellard# host long bits test
861b6853697Sbellardhostlongbits="32"
862ea8f20f8SJuan Quintelacase "$cpu" in
863ea8f20f8SJuan Quintela  x86_64|alpha|ia64|sparc64|ppc64)
864ea8f20f8SJuan Quintela    hostlongbits=64
865ea8f20f8SJuan Quintela  ;;
866ea8f20f8SJuan Quintelaesac
867b6853697Sbellard
868b0a47e79SJuan Quintela
869b0a47e79SJuan Quintela##########################################
870b0a47e79SJuan Quintela# NPTL probe
871b0a47e79SJuan Quintela
872b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
873bd0c5661Spbrook  cat > $TMPC <<EOF
874bd0c5661Spbrook#include <sched.h>
87530813ceaSpbrook#include <linux/futex.h>
876bd0c5661Spbrookvoid foo()
877bd0c5661Spbrook{
878bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
879bd0c5661Spbrook#error bork
880bd0c5661Spbrook#endif
881bd0c5661Spbrook}
882bd0c5661SpbrookEOF
883bd0c5661Spbrook
88452166aa0SJuan Quintela  if compile_object ; then
885b0a47e79SJuan Quintela    nptl=yes
886bd0c5661Spbrook  else
887b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
888b0a47e79SJuan Quintela      feature_not_found "nptl"
889b0a47e79SJuan Quintela    fi
890b0a47e79SJuan Quintela    nptl=no
891b0a47e79SJuan Quintela  fi
892bd0c5661Spbrookfi
893bd0c5661Spbrook
89411d9f695Sbellard##########################################
895ac62922eSbalrog# zlib check
896ac62922eSbalrog
897ac62922eSbalrogcat > $TMPC << EOF
898ac62922eSbalrog#include <zlib.h>
899ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
900ac62922eSbalrogEOF
90152166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
902ac62922eSbalrog    :
903ac62922eSbalrogelse
904ac62922eSbalrog    echo
905ac62922eSbalrog    echo "Error: zlib check failed"
906ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
907ac62922eSbalrog    echo
908ac62922eSbalrog    exit 1
909ac62922eSbalrogfi
910ac62922eSbalrog
911ac62922eSbalrog##########################################
912e37630caSaliguori# xen probe
913e37630caSaliguori
914fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
915b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
916e37630caSaliguori  cat > $TMPC <<EOF
917e37630caSaliguori#include <xenctrl.h>
918e37630caSaliguori#include <xs.h>
919df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
920e37630caSaliguoriEOF
92152166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
922fc321b4bSJuan Quintela    xen=yes
9233efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
924e37630caSaliguori  else
925fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
926fc321b4bSJuan Quintela      feature_not_found "xen"
927fc321b4bSJuan Quintela    fi
928fc321b4bSJuan Quintela    xen=no
929e37630caSaliguori  fi
930e37630caSaliguorifi
931e37630caSaliguori
932e37630caSaliguori##########################################
933dfffc653SJuan Quintela# Sparse probe
934dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
935dfffc653SJuan Quintela  if test -x "$(which cgcc 2>/dev/null)"; then
936dfffc653SJuan Quintela    sparse=yes
937dfffc653SJuan Quintela  else
938dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
939dfffc653SJuan Quintela      feature_not_found "sparse"
940dfffc653SJuan Quintela    fi
941dfffc653SJuan Quintela    sparse=no
942dfffc653SJuan Quintela  fi
943dfffc653SJuan Quintelafi
944dfffc653SJuan Quintela
945dfffc653SJuan Quintela##########################################
94611d9f695Sbellard# SDL probe
94711d9f695Sbellard
94811d9f695Sbellardsdl_too_old=no
94911d9f695Sbellard
950c4198157SJuan Quintelaif test "$sdl" != "no" ; then
95111d9f695Sbellard  cat > $TMPC << EOF
95211d9f695Sbellard#include <SDL.h>
95311d9f695Sbellard#undef main /* We don't want SDL to override our main() */
95411d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
95511d9f695SbellardEOF
9568ad3a7ddSJuan Quintela  sdl_cflags=`sdl-config --cflags 2> /dev/null`
9578ad3a7ddSJuan Quintela  sdl_libs=`sdl-config --libs 2> /dev/null`
95852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
959d3d9738fSJuan Quintela    _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
96011d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
96111d9f695Sbellard      sdl_too_old=yes
96211d9f695Sbellard    else
963fd677642Sths      if test "$cocoa" = "no" ; then
96411d9f695Sbellard        sdl=yes
96511d9f695Sbellard      fi
966fd677642Sths    fi
9677c1f25b4Sbellard
9687c1f25b4Sbellard    # static link with sdl ?
9691ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
9701ac88f28SJuan Quintela      sdl_libs=`sdl-config --static-libs 2>/dev/null`
9711ac88f28SJuan Quintela      if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
9721ac88f28SJuan Quintela         sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
9731ac88f28SJuan Quintela         sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
97411d9f695Sbellard      fi
97552166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
9761ac88f28SJuan Quintela	:
9771ac88f28SJuan Quintela      else
9781ac88f28SJuan Quintela        sdl=no
9797c1f25b4Sbellard      fi
9807c1f25b4Sbellard    fi # static link
981c4198157SJuan Quintela  else # sdl not found
982c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
983c4198157SJuan Quintela      feature_not_found "sdl"
984c4198157SJuan Quintela    fi
985c4198157SJuan Quintela    sdl=no
9867c1f25b4Sbellard  fi # sdl compile test
987fd677642Sthsfi
98811d9f695Sbellard
9895368a422Saliguoriif test "$sdl" = "yes" ; then
9905368a422Saliguori  cat > $TMPC <<EOF
9915368a422Saliguori#include <SDL.h>
9925368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
9935368a422Saliguori#include <X11/XKBlib.h>
9945368a422Saliguori#else
9955368a422Saliguori#error No x11 support
9965368a422Saliguori#endif
9975368a422Saliguoriint main(void) { return 0; }
9985368a422SaliguoriEOF
99952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1000681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
10015368a422Saliguori  fi
100207d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
100307d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
100407d9ac44SJuan Quintela  fi
10050705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
10065368a422Saliguorifi
10075368a422Saliguori
10088f28f3fbSths##########################################
10098d5d2d4cSths# VNC TLS detection
10101be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1011ae6b5e5aSaliguori  cat > $TMPC <<EOF
1012ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1013ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1014ae6b5e5aSaliguoriEOF
1015ae6b5e5aSaliguori  vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
1016ae6b5e5aSaliguori  vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
101752166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
10181be10ad2SJuan Quintela    vnc_tls=yes
1019a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1020ae6b5e5aSaliguori  else
10211be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
10221be10ad2SJuan Quintela      feature_not_found "vnc-tls"
10231be10ad2SJuan Quintela    fi
10241be10ad2SJuan Quintela    vnc_tls=no
10258d5d2d4cSths  fi
10268d5d2d4cSthsfi
10278d5d2d4cSths
10288d5d2d4cSths##########################################
10292f9606b3Saliguori# VNC SASL detection
10303aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
10312f9606b3Saliguori  cat > $TMPC <<EOF
10322f9606b3Saliguori#include <sasl/sasl.h>
10332f9606b3Saliguori#include <stdio.h>
10342f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
10352f9606b3SaliguoriEOF
10362f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
10372f9606b3Saliguori  vnc_sasl_cflags=""
10382f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
103952166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1040ea784e3bSJuan Quintela    vnc_sasl=yes
1041fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
10422f9606b3Saliguori  else
1043ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1044ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1045ea784e3bSJuan Quintela    fi
1046ea784e3bSJuan Quintela    vnc_sasl=no
10472f9606b3Saliguori  fi
10482f9606b3Saliguorifi
10492f9606b3Saliguori
10502f9606b3Saliguori##########################################
105176655d6dSaliguori# fnmatch() probe, used for ACL routines
105276655d6dSaliguorifnmatch="no"
105376655d6dSaliguoricat > $TMPC << EOF
105476655d6dSaliguori#include <fnmatch.h>
105576655d6dSaliguoriint main(void)
105676655d6dSaliguori{
105776655d6dSaliguori    fnmatch("foo", "foo", 0);
105876655d6dSaliguori    return 0;
105976655d6dSaliguori}
106076655d6dSaliguoriEOF
106152166aa0SJuan Quintelaif compile_prog "" "" ; then
106276655d6dSaliguori   fnmatch="yes"
106376655d6dSaliguorifi
106476655d6dSaliguori
106576655d6dSaliguori##########################################
1066ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1067ee682d27SStefan Weilif test "$uuid" != "no" ; then
1068ee682d27SStefan Weil  uuid_libs="-luuid"
1069ee682d27SStefan Weil  cat > $TMPC << EOF
1070ee682d27SStefan Weil#include <uuid/uuid.h>
1071ee682d27SStefan Weilint main(void)
1072ee682d27SStefan Weil{
1073ee682d27SStefan Weil    uuid_t my_uuid;
1074ee682d27SStefan Weil    uuid_generate(my_uuid);
1075ee682d27SStefan Weil    return 0;
1076ee682d27SStefan Weil}
1077ee682d27SStefan WeilEOF
1078ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1079ee682d27SStefan Weil    uuid="yes"
1080ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1081ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1082ee682d27SStefan Weil  else
1083ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1084ee682d27SStefan Weil      feature_not_found "uuid"
1085ee682d27SStefan Weil    fi
1086ee682d27SStefan Weil    uuid=no
1087ee682d27SStefan Weil  fi
1088ee682d27SStefan Weilfi
1089ee682d27SStefan Weil
1090ee682d27SStefan Weil##########################################
10918a16d273Sths# vde libraries probe
1092dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
10934baae0acSJuan Quintela  vde_libs="-lvdeplug"
10948a16d273Sths  cat > $TMPC << EOF
10958a16d273Sths#include <libvdeplug.h>
10964a7f0e06Spbrookint main(void)
10974a7f0e06Spbrook{
10984a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
10994a7f0e06Spbrook    vde_open("", "", &a);
11004a7f0e06Spbrook    return 0;
11014a7f0e06Spbrook}
11028a16d273SthsEOF
110352166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
11044baae0acSJuan Quintela    vde=yes
11058e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
11068e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1107dfb278bdSJuan Quintela  else
1108dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1109dfb278bdSJuan Quintela      feature_not_found "vde"
1110dfb278bdSJuan Quintela    fi
1111dfb278bdSJuan Quintela    vde=no
11128a16d273Sths  fi
11138a16d273Sthsfi
11148a16d273Sths
11158a16d273Sths##########################################
1116c2de5c91Smalc# Sound support libraries probe
11178f28f3fbSths
1118c2de5c91Smalcaudio_drv_probe()
1119c2de5c91Smalc{
1120c2de5c91Smalc    drv=$1
1121c2de5c91Smalc    hdr=$2
1122c2de5c91Smalc    lib=$3
1123c2de5c91Smalc    exp=$4
1124c2de5c91Smalc    cfl=$5
11258f28f3fbSths        cat > $TMPC << EOF
1126c2de5c91Smalc#include <$hdr>
1127c2de5c91Smalcint main(void) { $exp }
11288f28f3fbSthsEOF
112952166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
11308f28f3fbSths        :
11318f28f3fbSths    else
11328f28f3fbSths        echo
1133c2de5c91Smalc        echo "Error: $drv check failed"
1134c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
11358f28f3fbSths        echo
11368f28f3fbSths        exit 1
11378f28f3fbSths    fi
1138c2de5c91Smalc}
1139c2de5c91Smalc
11402fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1141c2de5c91Smalcfor drv in $audio_drv_list; do
1142c2de5c91Smalc    case $drv in
1143c2de5c91Smalc    alsa)
1144c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1145c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1146a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1147c2de5c91Smalc    ;;
1148c2de5c91Smalc
1149c2de5c91Smalc    fmod)
1150c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1151c2de5c91Smalc        echo
1152c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1153c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1154c2de5c91Smalc        echo
1155c2de5c91Smalc        exit 1
11568f28f3fbSths    fi
1157c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1158a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1159c2de5c91Smalc    ;;
1160c2de5c91Smalc
1161c2de5c91Smalc    esd)
1162c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1163a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
116467f86e8eSJuan Quintela    audio_pt_int="yes"
1165c2de5c91Smalc    ;;
1166b8e59f18Smalc
1167b8e59f18Smalc    pa)
1168b8e59f18Smalc    audio_drv_probe $drv pulse/simple.h -lpulse-simple \
1169b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1170a4bf6780SJuan Quintela    libs_softmmu="-lpulse-simple $libs_softmmu"
117167f86e8eSJuan Quintela    audio_pt_int="yes"
1172b8e59f18Smalc    ;;
1173b8e59f18Smalc
1174997e690aSJuan Quintela    coreaudio)
1175997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1176997e690aSJuan Quintela    ;;
1177997e690aSJuan Quintela
1178a4bf6780SJuan Quintela    dsound)
1179a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1180d5631638Smalc      audio_win_int="yes"
1181a4bf6780SJuan Quintela    ;;
1182a4bf6780SJuan Quintela
1183a4bf6780SJuan Quintela    oss)
1184a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1185a4bf6780SJuan Quintela    ;;
1186a4bf6780SJuan Quintela
1187a4bf6780SJuan Quintela    sdl|wav)
11882f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
11892f6a1ab0Sblueswir1    ;;
11902f6a1ab0Sblueswir1
1191d5631638Smalc    winwave)
1192d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1193d5631638Smalc      audio_win_int="yes"
1194d5631638Smalc    ;;
1195d5631638Smalc
1196e4c63a6aSmalc    *)
11971c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1198e4c63a6aSmalc        echo
1199e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1200e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1201e4c63a6aSmalc        echo
1202e4c63a6aSmalc        exit 1
1203e4c63a6aSmalc    }
1204e4c63a6aSmalc    ;;
1205c2de5c91Smalc    esac
1206c2de5c91Smalcdone
12078f28f3fbSths
12084d3b6f6eSbalrog##########################################
12092e4d9fb1Saurel32# BrlAPI probe
12102e4d9fb1Saurel32
12114ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1212eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
12132e4d9fb1Saurel32  cat > $TMPC << EOF
12142e4d9fb1Saurel32#include <brlapi.h>
12152e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
12162e4d9fb1Saurel32EOF
121752166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
12182e4d9fb1Saurel32    brlapi=yes
1219264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
12204ffcedb6SJuan Quintela  else
12214ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
12224ffcedb6SJuan Quintela      feature_not_found "brlapi"
12234ffcedb6SJuan Quintela    fi
12244ffcedb6SJuan Quintela    brlapi=no
1225eb82284fSJuan Quintela  fi
1226eb82284fSJuan Quintelafi
12272e4d9fb1Saurel32
12282e4d9fb1Saurel32##########################################
12294d3b6f6eSbalrog# curses probe
12304f78ef9aSJuan Quintelacurses_list="-lncurses -lcurses"
12314d3b6f6eSbalrog
1232c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1233c584a6d0SJuan Quintela  curses_found=no
12344d3b6f6eSbalrog  cat > $TMPC << EOF
12354d3b6f6eSbalrog#include <curses.h>
12365a8ff3aaSblueswir1#ifdef __OpenBSD__
12375a8ff3aaSblueswir1#define resize_term resizeterm
12385a8ff3aaSblueswir1#endif
12395a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
12404d3b6f6eSbalrogEOF
12414f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
12424f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1243c584a6d0SJuan Quintela      curses_found=yes
12444f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
12454f78ef9aSJuan Quintela      break
12464d3b6f6eSbalrog    fi
12474f78ef9aSJuan Quintela  done
1248c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1249c584a6d0SJuan Quintela    curses=yes
1250c584a6d0SJuan Quintela  else
1251c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1252c584a6d0SJuan Quintela      feature_not_found "curses"
1253c584a6d0SJuan Quintela    fi
1254c584a6d0SJuan Quintela    curses=no
1255c584a6d0SJuan Quintela  fi
12564f78ef9aSJuan Quintelafi
12574d3b6f6eSbalrog
1258414f0dabSblueswir1##########################################
1259769ce76dSAlexander Graf# curl probe
1260769ce76dSAlexander Graf
1261788c8196SJuan Quintelaif test "$curl" != "no" ; then
1262769ce76dSAlexander Graf  cat > $TMPC << EOF
1263769ce76dSAlexander Graf#include <curl/curl.h>
1264769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1265769ce76dSAlexander GrafEOF
1266b1d5a277SJuan Quintela  curl_cflags=`curl-config --cflags 2>/dev/null`
126752368552SPaul Brook  curl_libs=`curl-config --libs 2>/dev/null`
1268b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1269769ce76dSAlexander Graf    curl=yes
1270f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1271f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1272788c8196SJuan Quintela  else
1273788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1274788c8196SJuan Quintela      feature_not_found "curl"
1275788c8196SJuan Quintela    fi
1276788c8196SJuan Quintela    curl=no
1277769ce76dSAlexander Graf  fi
1278769ce76dSAlexander Graffi # test "$curl"
1279769ce76dSAlexander Graf
1280769ce76dSAlexander Graf##########################################
12815495ed11SLuiz Capitulino# check framework probe
12825495ed11SLuiz Capitulino
12835495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
12845495ed11SLuiz Capitulino  cat > $TMPC << EOF
12855495ed11SLuiz Capitulino#include <check.h>
12865495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
12875495ed11SLuiz CapitulinoEOF
12885495ed11SLuiz Capitulino  check_libs=`pkg-config --libs check`
12895495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
12905495ed11SLuiz Capitulino    check_utests=yes
12915495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
12925495ed11SLuiz Capitulino  else
12935495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
12945495ed11SLuiz Capitulino      feature_not_found "check"
12955495ed11SLuiz Capitulino    fi
12965495ed11SLuiz Capitulino    check_utests=no
12975495ed11SLuiz Capitulino  fi
12985495ed11SLuiz Capitulinofi # test "$check_utests"
12995495ed11SLuiz Capitulino
13005495ed11SLuiz Capitulino##########################################
1301fb599c9aSbalrog# bluez support probe
1302a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1303e820e3f4Sbalrog  cat > $TMPC << EOF
1304e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1305e820e3f4Sbalrogint main(void) { return bt_error(0); }
1306e820e3f4SbalrogEOF
1307efcfd0c5SBlue Swirl  bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1308efcfd0c5SBlue Swirl  bluez_libs=`pkg-config --libs bluez 2> /dev/null`
130952166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1310a20a6f46SJuan Quintela    bluez=yes
1311e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1312e820e3f4Sbalrog  else
1313a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1314a20a6f46SJuan Quintela      feature_not_found "bluez"
1315a20a6f46SJuan Quintela    fi
1316e820e3f4Sbalrog    bluez="no"
1317e820e3f4Sbalrog  fi
1318fb599c9aSbalrogfi
1319fb599c9aSbalrog
1320fb599c9aSbalrog##########################################
13217ba1e619Saliguori# kvm probe
1322b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
13237ba1e619Saliguori    cat > $TMPC <<EOF
13247ba1e619Saliguori#include <linux/kvm.h>
13259fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
13267ba1e619Saliguori#error Invalid KVM version
13277ba1e619Saliguori#endif
13289fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
13299fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
13309fd8d8d7Saliguori#endif
13319fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
13329fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
13339fd8d8d7Saliguori#endif
13349fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
13359fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
13369fd8d8d7Saliguori#endif
13377ba1e619Saliguoriint main(void) { return 0; }
13387ba1e619SaliguoriEOF
1339eac30262Saliguori  if test "$kerneldir" != "" ; then
1340eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
13418444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
13428444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
13438444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1344406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1345406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
13468444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
13478444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
13488444eb6eSaliguori      fi
1349eac30262Saliguori  else
1350eac30262Saliguori      kvm_cflags=""
1351eac30262Saliguori  fi
135252166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1353b31a0277SJuan Quintela    kvm=yes
13547ba1e619Saliguori  else
1355b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
13569fd8d8d7Saliguori      if [ -x "`which awk 2>/dev/null`" ] && \
13579fd8d8d7Saliguori         [ -x "`which grep 2>/dev/null`" ]; then
1358a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
13599fd8d8d7Saliguori	| grep "error: " \
13609fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
13619fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1362b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1363168ccc11SJan Kiszka      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1364168ccc11SJan Kiszka  recent kvm-kmod from http://sourceforge.net/projects/kvm."
13659fd8d8d7Saliguori        fi
13669fd8d8d7Saliguori      fi
1367b31a0277SJuan Quintela      feature_not_found "kvm"
1368b31a0277SJuan Quintela    fi
1369b31a0277SJuan Quintela    kvm=no
13707ba1e619Saliguori  fi
13717ba1e619Saliguorifi
13727ba1e619Saliguori
13737ba1e619Saliguori##########################################
1374e5d355d1Saliguori# pthread probe
1375de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
13763c529d93Saliguori
1377e5d355d1Saliguoripthread=no
1378414f0dabSblueswir1cat > $TMPC << EOF
13793c529d93Saliguori#include <pthread.h>
1380de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1381414f0dabSblueswir1EOF
1382de65fe0fSSebastian Herbsztfor pthread_lib in $PTHREADLIBS_LIST; do
138352166aa0SJuan Quintela  if compile_prog "" "$pthread_lib" ; then
1384e5d355d1Saliguori    pthread=yes
13855572b539SJuan Quintela    LIBS="$pthread_lib $LIBS"
1386de65fe0fSSebastian Herbszt    break
1387414f0dabSblueswir1  fi
1388de65fe0fSSebastian Herbsztdone
1389414f0dabSblueswir1
13904617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
13914dd75c70SChristoph Hellwig  echo
13924dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
13934dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
13944dd75c70SChristoph Hellwig  echo
13954dd75c70SChristoph Hellwig  exit 1
1396e5d355d1Saliguorifi
1397e5d355d1Saliguori
1398bf9298b9Saliguori##########################################
13995c6c3a6cSChristoph Hellwig# linux-aio probe
14005c6c3a6cSChristoph Hellwig
14015c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
14025c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
14035c6c3a6cSChristoph Hellwig#include <libaio.h>
14045c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
14055c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
14065c6c3a6cSChristoph HellwigEOF
14075c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
14085c6c3a6cSChristoph Hellwig    linux_aio=yes
14095c6c3a6cSChristoph Hellwig    LIBS="$LIBS -laio"
14105c6c3a6cSChristoph Hellwig  else
14115c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
14125c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
14135c6c3a6cSChristoph Hellwig    fi
14143cfcae3cSLuiz Capitulino    linux_aio=no
14155c6c3a6cSChristoph Hellwig  fi
14165c6c3a6cSChristoph Hellwigfi
14175c6c3a6cSChristoph Hellwig
14185c6c3a6cSChristoph Hellwig##########################################
1419bf9298b9Saliguori# iovec probe
1420bf9298b9Saliguoricat > $TMPC <<EOF
1421db34f0b3Sblueswir1#include <sys/types.h>
1422bf9298b9Saliguori#include <sys/uio.h>
1423db34f0b3Sblueswir1#include <unistd.h>
1424bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1425bf9298b9SaliguoriEOF
1426bf9298b9Saliguoriiovec=no
142752166aa0SJuan Quintelaif compile_prog "" "" ; then
1428bf9298b9Saliguori  iovec=yes
1429bf9298b9Saliguorifi
1430bf9298b9Saliguori
1431f652e6afSaurel32##########################################
1432ceb42de8Saliguori# preadv probe
1433ceb42de8Saliguoricat > $TMPC <<EOF
1434ceb42de8Saliguori#include <sys/types.h>
1435ceb42de8Saliguori#include <sys/uio.h>
1436ceb42de8Saliguori#include <unistd.h>
1437ceb42de8Saliguoriint main(void) { preadv; }
1438ceb42de8SaliguoriEOF
1439ceb42de8Saliguoripreadv=no
144052166aa0SJuan Quintelaif compile_prog "" "" ; then
1441ceb42de8Saliguori  preadv=yes
1442ceb42de8Saliguorifi
1443ceb42de8Saliguori
1444ceb42de8Saliguori##########################################
1445f652e6afSaurel32# fdt probe
14462df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1447b41af4baSJuan Quintela  fdt_libs="-lfdt"
1448f652e6afSaurel32  cat > $TMPC << EOF
1449f652e6afSaurel32int main(void) { return 0; }
1450f652e6afSaurel32EOF
145152166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1452f652e6afSaurel32    fdt=yes
1453e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
14542df87df7SJuan Quintela  else
14552df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
14562df87df7SJuan Quintela      feature_not_found "fdt"
14572df87df7SJuan Quintela    fi
14582df87df7SJuan Quintela    fdt=no
1459f652e6afSaurel32  fi
1460f652e6afSaurel32fi
1461f652e6afSaurel32
14623b3f24adSaurel32#
14633b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
14643b3f24adSaurel32# emulator.  This is done because older glibc versions don't
14653b3f24adSaurel32# have syscall stubs for these implemented.
14663b3f24adSaurel32#
14673b3f24adSaurel32atfile=no
14683b3f24adSaurel32cat > $TMPC << EOF
14693b3f24adSaurel32#define _ATFILE_SOURCE
14703b3f24adSaurel32#include <sys/types.h>
14713b3f24adSaurel32#include <fcntl.h>
14723b3f24adSaurel32#include <unistd.h>
14733b3f24adSaurel32
14743b3f24adSaurel32int
14753b3f24adSaurel32main(void)
14763b3f24adSaurel32{
14773b3f24adSaurel32	/* try to unlink nonexisting file */
14783b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
14793b3f24adSaurel32}
14803b3f24adSaurel32EOF
148152166aa0SJuan Quintelaif compile_prog "" "" ; then
14823b3f24adSaurel32  atfile=yes
14833b3f24adSaurel32fi
14843b3f24adSaurel32
148539386ac7Saurel32# Check for inotify functions when we are building linux-user
14863b3f24adSaurel32# emulator.  This is done because older glibc versions don't
14873b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
14883b3f24adSaurel32# don't provide them even if kernel supports them.
14893b3f24adSaurel32#
14903b3f24adSaurel32inotify=no
14913b3f24adSaurel32cat > $TMPC << EOF
14923b3f24adSaurel32#include <sys/inotify.h>
14933b3f24adSaurel32
14943b3f24adSaurel32int
14953b3f24adSaurel32main(void)
14963b3f24adSaurel32{
14973b3f24adSaurel32	/* try to start inotify */
14988690e420Saurel32	return inotify_init();
14993b3f24adSaurel32}
15003b3f24adSaurel32EOF
150152166aa0SJuan Quintelaif compile_prog "" "" ; then
15023b3f24adSaurel32  inotify=yes
15033b3f24adSaurel32fi
15043b3f24adSaurel32
1505ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1506ebc996f3SRiku Voipioutimens=no
1507ebc996f3SRiku Voipiocat > $TMPC << EOF
1508ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1509ebc996f3SRiku Voipio#define _GNU_SOURCE
1510ebc996f3SRiku Voipio#include <stddef.h>
1511ebc996f3SRiku Voipio#include <fcntl.h>
1512ebc996f3SRiku Voipio
1513ebc996f3SRiku Voipioint main(void)
1514ebc996f3SRiku Voipio{
1515ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1516ebc996f3SRiku Voipio    futimens(0, NULL);
1517ebc996f3SRiku Voipio    return 0;
1518ebc996f3SRiku Voipio}
1519ebc996f3SRiku VoipioEOF
152052166aa0SJuan Quintelaif compile_prog "" "" ; then
1521ebc996f3SRiku Voipio  utimens=yes
1522ebc996f3SRiku Voipiofi
1523ebc996f3SRiku Voipio
1524099d6b0fSRiku Voipio# check if pipe2 is there
1525099d6b0fSRiku Voipiopipe2=no
1526099d6b0fSRiku Voipiocat > $TMPC << EOF
1527099d6b0fSRiku Voipio#define _GNU_SOURCE
1528099d6b0fSRiku Voipio#include <unistd.h>
1529099d6b0fSRiku Voipio#include <fcntl.h>
1530099d6b0fSRiku Voipio
1531099d6b0fSRiku Voipioint main(void)
1532099d6b0fSRiku Voipio{
1533099d6b0fSRiku Voipio    int pipefd[2];
1534099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1535099d6b0fSRiku Voipio    return 0;
1536099d6b0fSRiku Voipio}
1537099d6b0fSRiku VoipioEOF
153852166aa0SJuan Quintelaif compile_prog "" "" ; then
1539099d6b0fSRiku Voipio  pipe2=yes
1540099d6b0fSRiku Voipiofi
1541099d6b0fSRiku Voipio
15423ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
15433ce34dfbSvibisreenivasansplice=no
15443ce34dfbSvibisreenivasancat > $TMPC << EOF
15453ce34dfbSvibisreenivasan#define _GNU_SOURCE
15463ce34dfbSvibisreenivasan#include <unistd.h>
15473ce34dfbSvibisreenivasan#include <fcntl.h>
15483ce34dfbSvibisreenivasan#include <limits.h>
15493ce34dfbSvibisreenivasan
15503ce34dfbSvibisreenivasanint main(void)
15513ce34dfbSvibisreenivasan{
15523ce34dfbSvibisreenivasan    int len, fd;
15533ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
15543ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
15553ce34dfbSvibisreenivasan    return 0;
15563ce34dfbSvibisreenivasan}
15573ce34dfbSvibisreenivasanEOF
155852166aa0SJuan Quintelaif compile_prog "" "" ; then
15593ce34dfbSvibisreenivasan  splice=yes
15603ce34dfbSvibisreenivasanfi
15613ce34dfbSvibisreenivasan
1562c2882b96SRiku Voipio# check if eventfd is supported
1563c2882b96SRiku Voipioeventfd=no
1564c2882b96SRiku Voipiocat > $TMPC << EOF
1565c2882b96SRiku Voipio#include <sys/eventfd.h>
1566c2882b96SRiku Voipio
1567c2882b96SRiku Voipioint main(void)
1568c2882b96SRiku Voipio{
1569c2882b96SRiku Voipio    int efd = eventfd(0, 0);
1570c2882b96SRiku Voipio    return 0;
1571c2882b96SRiku Voipio}
1572c2882b96SRiku VoipioEOF
1573c2882b96SRiku Voipioif compile_prog "" "" ; then
1574c2882b96SRiku Voipio  eventfd=yes
1575c2882b96SRiku Voipiofi
1576c2882b96SRiku Voipio
1577d0927938SUlrich Hecht# check for fallocate
1578d0927938SUlrich Hechtfallocate=no
1579d0927938SUlrich Hechtcat > $TMPC << EOF
1580d0927938SUlrich Hecht#include <fcntl.h>
1581d0927938SUlrich Hecht
1582d0927938SUlrich Hechtint main(void)
1583d0927938SUlrich Hecht{
1584d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
1585d0927938SUlrich Hecht    return 0;
1586d0927938SUlrich Hecht}
1587d0927938SUlrich HechtEOF
158878f5d726SJan Kiszkaif compile_prog "" "" ; then
1589d0927938SUlrich Hecht  fallocate=yes
1590d0927938SUlrich Hechtfi
1591d0927938SUlrich Hecht
1592d0927938SUlrich Hecht# check for dup3
1593d0927938SUlrich Hechtdup3=no
1594d0927938SUlrich Hechtcat > $TMPC << EOF
1595d0927938SUlrich Hecht#include <unistd.h>
1596d0927938SUlrich Hecht
1597d0927938SUlrich Hechtint main(void)
1598d0927938SUlrich Hecht{
1599d0927938SUlrich Hecht    dup3(0, 0, 0);
1600d0927938SUlrich Hecht    return 0;
1601d0927938SUlrich Hecht}
1602d0927938SUlrich HechtEOF
160378f5d726SJan Kiszkaif compile_prog "" "" ; then
1604d0927938SUlrich Hecht  dup3=yes
1605d0927938SUlrich Hechtfi
1606d0927938SUlrich Hecht
1607cc8ae6deSpbrook# Check if tools are available to build documentation.
1608a25dba17SJuan Quintelaif test "$docs" != "no" ; then
160983a3ab8bSJuan Quintela  if test -x "`which texi2html 2>/dev/null`" -a \
161083a3ab8bSJuan Quintela          -x "`which pod2man 2>/dev/null`" ; then
1611a25dba17SJuan Quintela    docs=yes
161283a3ab8bSJuan Quintela  else
1613a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
1614a25dba17SJuan Quintela      feature_not_found "docs"
161583a3ab8bSJuan Quintela    fi
1616a25dba17SJuan Quintela    docs=no
161783a3ab8bSJuan Quintela  fi
1618cc8ae6deSpbrookfi
1619cc8ae6deSpbrook
1620f514f41cSStefan Weil# Search for bswap_32 function
16216ae9a1f4SJuan Quintelabyteswap_h=no
16226ae9a1f4SJuan Quintelacat > $TMPC << EOF
16236ae9a1f4SJuan Quintela#include <byteswap.h>
16246ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
16256ae9a1f4SJuan QuintelaEOF
162652166aa0SJuan Quintelaif compile_prog "" "" ; then
16276ae9a1f4SJuan Quintela  byteswap_h=yes
16286ae9a1f4SJuan Quintelafi
16296ae9a1f4SJuan Quintela
1630f514f41cSStefan Weil# Search for bswap_32 function
16316ae9a1f4SJuan Quintelabswap_h=no
16326ae9a1f4SJuan Quintelacat > $TMPC << EOF
16336ae9a1f4SJuan Quintela#include <sys/endian.h>
16346ae9a1f4SJuan Quintela#include <sys/types.h>
16356ae9a1f4SJuan Quintela#include <machine/bswap.h>
16366ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
16376ae9a1f4SJuan QuintelaEOF
163852166aa0SJuan Quintelaif compile_prog "" "" ; then
16396ae9a1f4SJuan Quintela  bswap_h=yes
16406ae9a1f4SJuan Quintelafi
16416ae9a1f4SJuan Quintela
1642da93a1fdSaliguori##########################################
1643da93a1fdSaliguori# Do we need librt
1644da93a1fdSaliguoricat > $TMPC <<EOF
1645da93a1fdSaliguori#include <signal.h>
1646da93a1fdSaliguori#include <time.h>
1647da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
1648da93a1fdSaliguoriEOF
1649da93a1fdSaliguori
165052166aa0SJuan Quintelaif compile_prog "" "" ; then
165107ffa4bdSJuan Quintela  :
165252166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
165307ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
1654da93a1fdSaliguorifi
1655da93a1fdSaliguori
1656a36abbbbSJuan Quintela# Determine what linker flags to use to force archive inclusion
1657a36abbbbSJuan Quintelacheck_linker_flags()
1658a36abbbbSJuan Quintela{
1659a36abbbbSJuan Quintela    w2=
1660a36abbbbSJuan Quintela    if test "$2" ; then
1661a36abbbbSJuan Quintela	w2=-Wl,$2
1662a36abbbbSJuan Quintela    fi
166352166aa0SJuan Quintela    compile_prog "" "-Wl,$1 ${w2}"
1664a36abbbbSJuan Quintela}
1665a36abbbbSJuan Quintela
1666a36abbbbSJuan Quintelacat > $TMPC << EOF
1667a36abbbbSJuan Quintelaint main(void) { }
1668a36abbbbSJuan QuintelaEOF
1669a36abbbbSJuan Quintelaif check_linker_flags --whole-archive --no-whole-archive ; then
1670a36abbbbSJuan Quintela    # GNU ld
1671a36abbbbSJuan Quintela    arlibs_begin="-Wl,--whole-archive"
1672a36abbbbSJuan Quintela    arlibs_end="-Wl,--no-whole-archive"
1673a36abbbbSJuan Quintelaelif check_linker_flags -z,allextract -z,defaultextract ; then
1674a36abbbbSJuan Quintela    # Solaris ld
167531ff504dSBlue Swirl    arlibs_begin="-Wl,-z,allextract"
1676a36abbbbSJuan Quintela    arlibs_end="-Wl,-z,defaultextract"
1677a36abbbbSJuan Quintelaelif check_linker_flags -all_load ; then
1678a36abbbbSJuan Quintela    # Mac OS X
1679a36abbbbSJuan Quintela    arlibs_begin="-all_load"
1680a36abbbbSJuan Quintela    arlibs_end=""
1681a36abbbbSJuan Quintelaelse
1682a36abbbbSJuan Quintela    echo "Error: your linker does not support --whole-archive or -z."
1683a36abbbbSJuan Quintela    echo "Please report to qemu-devel@nongnu.org"
1684a36abbbbSJuan Quintela    exit 1
1685a36abbbbSJuan Quintelafi
1686a36abbbbSJuan Quintela
168731ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
16886362a53fSJuan Quintela        "$aix" != "yes" ; then
16896362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
16906362a53fSJuan Quintelafi
16916362a53fSJuan Quintela
1692de5071c5SBlue Swirl##########################################
1693de5071c5SBlue Swirl# check if the compiler defines offsetof
1694de5071c5SBlue Swirl
1695de5071c5SBlue Swirlneed_offsetof=yes
1696de5071c5SBlue Swirlcat > $TMPC << EOF
1697de5071c5SBlue Swirl#include <stddef.h>
1698de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
1699de5071c5SBlue SwirlEOF
1700de5071c5SBlue Swirlif compile_prog "" "" ; then
1701de5071c5SBlue Swirl    need_offsetof=no
1702de5071c5SBlue Swirlfi
1703de5071c5SBlue Swirl
17045f6b9e8fSBlue Swirl##########################################
1705747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
1706747bbdf7SBlue Swirl#
1707747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
1708747bbdf7SBlue Swirl# about attribute warn_unused_result
1709747bbdf7SBlue Swirl
1710747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
1711747bbdf7SBlue Swirlcat > $TMPC << EOF
1712747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
1713747bbdf7SBlue Swirl#error gcc 3.3 or older
1714747bbdf7SBlue Swirl#endif
1715747bbdf7SBlue Swirlint main(void) { return 0;}
1716747bbdf7SBlue SwirlEOF
1717747bbdf7SBlue Swirlif compile_prog "" ""; then
1718747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
1719747bbdf7SBlue Swirlfi
1720747bbdf7SBlue Swirl
1721747bbdf7SBlue Swirl##########################################
17225f6b9e8fSBlue Swirl# check if we have fdatasync
17235f6b9e8fSBlue Swirl
17245f6b9e8fSBlue Swirlfdatasync=no
17255f6b9e8fSBlue Swirlcat > $TMPC << EOF
17265f6b9e8fSBlue Swirl#include <unistd.h>
17275f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
17285f6b9e8fSBlue SwirlEOF
17295f6b9e8fSBlue Swirlif compile_prog "" "" ; then
17305f6b9e8fSBlue Swirl    fdatasync=yes
17315f6b9e8fSBlue Swirlfi
17325f6b9e8fSBlue Swirl
1733e86ecd4bSJuan Quintela# End of CC checks
1734e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
1735e86ecd4bSJuan Quintela
1736e86ecd4bSJuan Quintela# default flags for all hosts
1737a558ee17SJuan QuintelaQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
1738a558ee17SJuan QuintelaCFLAGS="-g $CFLAGS"
1739e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
17401156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
1741e86ecd4bSJuan Quintelafi
1742867c16fdSJuan QuintelaQEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
1743867c16fdSJuan QuintelaQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
17446c90361aSJuan QuintelaQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
17456c90361aSJuan QuintelaQEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
174602d5467eSmalcQEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
17471156c669SJuan QuintelaLDFLAGS="-g $LDFLAGS"
1748e86ecd4bSJuan Quintela
1749a316e378SJuan Quintelagcc_flags="-Wold-style-declaration -Wold-style-definition"
1750a316e378SJuan Quintelacat > $TMPC << EOF
1751a316e378SJuan Quintelaint main(void) { }
1752a316e378SJuan QuintelaEOF
1753a316e378SJuan Quintelafor flag in $gcc_flags; do
1754a316e378SJuan Quintela    if compile_prog "$QEMU_CFLAGS" "$flag" ; then
1755a316e378SJuan Quintela	QEMU_CFLAGS="$flag $QEMU_CFLAGS"
1756a316e378SJuan Quintela    fi
1757a316e378SJuan Quinteladone
1758a316e378SJuan Quintela
1759e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
1760e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
1761e86ecd4bSJuan Quintelaif test -z "$werror" ; then
1762e86ecd4bSJuan Quintela    z_version=`cut -f3 -d. $source_path/VERSION`
1763e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
1764e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
1765e86ecd4bSJuan Quintela        werror="yes"
1766e86ecd4bSJuan Quintela    else
1767e86ecd4bSJuan Quintela        werror="no"
1768e86ecd4bSJuan Quintela    fi
1769e86ecd4bSJuan Quintelafi
1770e86ecd4bSJuan Quintela
1771e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
1772a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1773e86ecd4bSJuan Quintelafi
1774e86ecd4bSJuan Quintela
1775e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
1776e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
17771156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
1778e86ecd4bSJuan Quintela    fi
1779e86ecd4bSJuan Quintelafi
1780e86ecd4bSJuan Quintela
178111d9f695Sbellardif test "$mingw32" = "yes" ; then
178211d9f695Sbellard  if test -z "$prefix" ; then
178355418b96SStefan Weil      prefix="c:/Program Files/Qemu"
178411d9f695Sbellard  fi
1785308c3593Spbrook  mansuffix=""
1786308c3593Spbrook  datasuffix=""
1787308c3593Spbrook  docsuffix=""
1788308c3593Spbrook  binsuffix=""
178911d9f695Sbellardelse
179011d9f695Sbellard  if test -z "$prefix" ; then
179111d9f695Sbellard      prefix="/usr/local"
179211d9f695Sbellard  fi
1793308c3593Spbrook  mansuffix="/share/man"
1794308c3593Spbrook  datasuffix="/share/qemu"
1795308c3593Spbrook  docsuffix="/share/doc/qemu"
1796308c3593Spbrook  binsuffix="/bin"
179711d9f695Sbellardfi
17985a67135aSbellard
17997d13299dSbellardecho "Install prefix    $prefix"
1800308c3593Spbrookecho "BIOS directory    $prefix$datasuffix"
1801308c3593Spbrookecho "binary directory  $prefix$binsuffix"
180211d9f695Sbellardif test "$mingw32" = "no" ; then
1803308c3593Spbrookecho "Manual directory  $prefix$mansuffix"
180443ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
180511d9f695Sbellardfi
18065a67135aSbellardecho "Source path       $source_path"
18077d13299dSbellardecho "C compiler        $cc"
180883469015Sbellardecho "Host C compiler   $host_cc"
18090c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
1810a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
18110c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
18127d13299dSbellardecho "make              $make"
18136a882643Spbrookecho "install           $install"
1814a98fd896Sbellardecho "host CPU          $cpu"
1815de83cd02Sbellardecho "host big endian   $bigendian"
181697a847bcSbellardecho "target list       $target_list"
1817ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
18187d13299dSbellardecho "gprof enabled     $gprof"
181903b4fe7dSaliguoriecho "sparse enabled    $sparse"
18201625af87Saliguoriecho "strip binaries    $strip_opt"
182105c2a3e7Sbellardecho "profiler          $profiler"
182243ce4dfeSbellardecho "static build      $static"
182385aa5189Sbellardecho "-Werror enabled   $werror"
18245b0753e0Sbellardif test "$darwin" = "yes" ; then
18255b0753e0Sbellard    echo "Cocoa support     $cocoa"
18265b0753e0Sbellardfi
182797a847bcSbellardecho "SDL support       $sdl"
18284d3b6f6eSbalrogecho "curses support    $curses"
1829769ce76dSAlexander Grafecho "curl support      $curl"
18305495ed11SLuiz Capitulinoecho "check support     $check_utests"
183167b915a5Sbellardecho "mingw32 support   $mingw32"
18320c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
18330c58ac1cSmalcecho "Extra audio cards $audio_card_list"
1834eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
18358ff9cbf7Smalcecho "Mixer emulation   $mixemu"
18368d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
18372f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
18383142255cSblueswir1if test -n "$sparc_cpu"; then
18393142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
18403142255cSblueswir1fi
1841e37630caSaliguoriecho "xen support       $xen"
18422e4d9fb1Saurel32echo "brlapi support    $brlapi"
1843a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
1844a25dba17SJuan Quintelaecho "Documentation     $docs"
1845c5937220Spbrook[ ! -z "$uname_release" ] && \
1846c5937220Spbrookecho "uname -r          $uname_release"
1847bd0c5661Spbrookecho "NPTL support      $nptl"
1848379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
184934005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
18508a16d273Sthsecho "vde support       $vde"
1851e5d355d1Saliguoriecho "IO thread         $io_thread"
18525c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
185377755340Sthsecho "Install blobs     $blobs"
1854b31a0277SJuan Quintelaecho "KVM support       $kvm"
1855f652e6afSaurel32echo "fdt support       $fdt"
1856ceb42de8Saliguoriecho "preadv support    $preadv"
18575f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
1858ee682d27SStefan Weilecho "uuid support      $uuid"
185967b915a5Sbellard
186097a847bcSbellardif test $sdl_too_old = "yes"; then
186124b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
1862e8cd23deSbellardfi
186397a847bcSbellard
186498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
18654bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
186697a847bcSbellard
186798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
186898ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
186998ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
187098ec69acSJuan Quintelaecho >> $config_host_mak
187198ec69acSJuan Quintela
18722358a494SJuan Quintelaecho "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1873804edf29SJuan Quintela
18742408a527Saurel32case "$cpu" in
1875c62bbcd3SAndrzej Zaborowski  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
1876e0da9dd3SJuan Quintela    ARCH=$cpu
18772408a527Saurel32  ;;
1878a302c32dSLaurent Desnogues  armv4b|armv4l)
187916dbd14fSJuan Quintela    ARCH=arm
18802408a527Saurel32  ;;
18812408a527Saurel32  *)
18823142255cSblueswir1    echo "Unsupported CPU = $cpu"
18837d13299dSbellard    exit 1
18842408a527Saurel32  ;;
18852408a527Saurel32esac
188698ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
1887f8393946Saurel32if test "$debug_tcg" = "yes" ; then
18882358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1889f8393946Saurel32fi
1890f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
18912358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1892f3d08ee6SPaul Brookfi
18931625af87Saliguoriif test "$strip_opt" = "yes" ; then
189498ec69acSJuan Quintela  echo "STRIP_OPT=-s" >> $config_host_mak
18951625af87Saliguorifi
18967d13299dSbellardif test "$bigendian" = "yes" ; then
1897e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
189897a847bcSbellardfi
18992358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
190067b915a5Sbellardif test "$mingw32" = "yes" ; then
190198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
1902210fa556Spbrookelse
190335f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
1904210fa556Spbrookfi
1905128ab2ffSblueswir1
1906dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
1907dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
1908dffcb71cSMark McLoughlinfi
1909dffcb71cSMark McLoughlin
191083fb7adfSbellardif test "$darwin" = "yes" ; then
191198ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
191283fb7adfSbellardfi
1913b29fe3edSmalc
1914b29fe3edSmalcif test "$aix" = "yes" ; then
191598ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
1916b29fe3edSmalcfi
1917b29fe3edSmalc
1918ec530c81Sbellardif test "$solaris" = "yes" ; then
191998ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
19202358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
19210475a5caSths  if test "$needs_libsunmath" = "yes" ; then
192275b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
19230475a5caSths  fi
1924ec530c81Sbellardfi
192597a847bcSbellardif test "$static" = "yes" ; then
192698ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
19271156c669SJuan Quintela  LDFLAGS="-static $LDFLAGS"
192897a847bcSbellardfi
192905c2a3e7Sbellardif test $profiler = "yes" ; then
19302358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
193105c2a3e7Sbellardfi
1932c20709aaSbellardif test "$slirp" = "yes" ; then
193398ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
1934b6e31c12SJuan Quintela  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
1935c20709aaSbellardfi
19368a16d273Sthsif test "$vde" = "yes" ; then
193798ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
19388a16d273Sthsfi
19390c58ac1cSmalcfor card in $audio_card_list; do
1940f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
194198ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
19420c58ac1cSmalcdone
19432358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
19440c58ac1cSmalcfor drv in $audio_drv_list; do
1945f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
194698ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
1947923e4521Smalc    if test "$drv" = "fmod"; then
19487aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1949fb065187Sbellard    fi
19500c58ac1cSmalcdone
195167f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
195267f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
195367f86e8eSJuan Quintelafi
1954d5631638Smalcif test "$audio_win_int" = "yes" ; then
1955d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
1956d5631638Smalcfi
1957eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
19588ff9cbf7Smalcif test "$mixemu" = "yes" ; then
195998ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
19608ff9cbf7Smalcfi
19618d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
196298ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
1963525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
19648d5d2d4cSthsfi
19652f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
196698ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
196760ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
19682f9606b3Saliguorifi
196976655d6dSaliguoriif test "$fnmatch" = "yes" ; then
19702358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
197176655d6dSaliguorifi
1972ee682d27SStefan Weilif test "$uuid" = "yes" ; then
1973ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
1974ee682d27SStefan Weilfi
1975b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
197698ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
19772358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
197898ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
1979ad064840Spbrookif [ "$source_path_used" = "yes" ]; then
198098ec69acSJuan Quintela  echo "VPATH=$source_path" >> $config_host_mak
1981ad064840Spbrookfi
198298ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
1983a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
198498ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
1985cc8ae6deSpbrookfi
19861ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
198798ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
19888ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
198949ecc3faSbellardfi
199049ecc3faSbellardif test "$cocoa" = "yes" ; then
199198ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
199249ecc3faSbellardfi
19934d3b6f6eSbalrogif test "$curses" = "yes" ; then
199498ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
1995ab4e5602SJan Kiszkafi
19963b3f24adSaurel32if test "$atfile" = "yes" ; then
19972358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
19983b3f24adSaurel32fi
1999ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
20002358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2001ebc996f3SRiku Voipiofi
2002099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
20032358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2004099d6b0fSRiku Voipiofi
20053ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
20062358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
20073ce34dfbSvibisreenivasanfi
2008c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2009c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2010c2882b96SRiku Voipiofi
2011d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2012d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2013d0927938SUlrich Hechtfi
2014d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2015d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2016d0927938SUlrich Hechtfi
20173b3f24adSaurel32if test "$inotify" = "yes" ; then
20182358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
20193b3f24adSaurel32fi
20206ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
20216ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
20226ae9a1f4SJuan Quintelafi
20236ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
20246ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
20256ae9a1f4SJuan Quintelafi
2026769ce76dSAlexander Grafif test "$curl" = "yes" ; then
202798ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2028b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2029769ce76dSAlexander Graffi
20302e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
203198ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
20322e4d9fb1Saurel32fi
2033fb599c9aSbalrogif test "$bluez" = "yes" ; then
203498ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2035ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2036fb599c9aSbalrogfi
2037e37630caSaliguoriif test "$xen" = "yes" ; then
20385647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2039e37630caSaliguorifi
2040e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
204198ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2042e5d355d1Saliguorifi
20435c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
20445c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
20455c6c3a6cSChristoph Hellwigfi
204677755340Sthsif test "$blobs" = "yes" ; then
204798ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
204877755340Sthsfi
2049bf9298b9Saliguoriif test "$iovec" = "yes" ; then
20502358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2051bf9298b9Saliguorifi
2052ceb42de8Saliguoriif test "$preadv" = "yes" ; then
20532358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2054ceb42de8Saliguorifi
2055f652e6afSaurel32if test "$fdt" = "yes" ; then
20563f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2057f652e6afSaurel32fi
2058de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2059de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2060de5071c5SBlue Swirlfi
2061747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2062747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2063747bbdf7SBlue Swirlfi
20645f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
20655f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
20665f6b9e8fSBlue Swirlfi
206797a847bcSbellard
206883fb7adfSbellard# XXX: suppress that
20697d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
20702358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
20717d3505c5Sbellardfi
20727d3505c5Sbellard
20732358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2074c5937220Spbrook
207568063649Sblueswir1# USB host support
207668063649Sblueswir1case "$usb" in
207768063649Sblueswir1linux)
207898ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
207968063649Sblueswir1;;
208068063649Sblueswir1bsd)
208198ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
208268063649Sblueswir1;;
208368063649Sblueswir1*)
208498ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
208568063649Sblueswir1;;
208668063649Sblueswir1esac
208768063649Sblueswir1
2088c39e3338Spbrooktools=
2089c39e3338Spbrookif test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
20903dd1f8efSaliguori  tools="qemu-img\$(EXESUF) $tools"
20917a5ca864Sbellard  if [ "$linux" = "yes" ] ; then
20923dd1f8efSaliguori      tools="qemu-nbd\$(EXESUF) qemu-io\$(EXESUF) $tools"
20935495ed11SLuiz Capitulino    if [ "$check_utests" = "yes" ]; then
20943aa3dcffSLuiz Capitulino      tools="check-qint check-qstring check-qdict check-qlist $tools"
2095422c46a8SAnthony Liguori      tools="check-qfloat check-qjson $tools"
20965495ed11SLuiz Capitulino    fi
2097c32d766aSStefan Weil  elif test "$mingw32" = "yes" ; then
2098c32d766aSStefan Weil      tools="qemu-io\$(EXESUF) $tools"
20997a5ca864Sbellard  fi
2100c39e3338Spbrookfi
210198ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
2102c39e3338Spbrook
2103161294d8SJuan Quintela# Mac OS X ships with a broken assembler
2104253d0942SAlexander Grafroms=
2105161294d8SJuan Quintelaif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2106b461cdc9SBlue Swirl        "$targetos" != "Darwin" -a \
2107b461cdc9SBlue Swirl        `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2108c05ac895SPaul Brook  roms="optionrom"
2109253d0942SAlexander Graffi
211098ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2111253d0942SAlexander Graf
2112804edf29SJuan Quintelaecho "prefix=$prefix" >> $config_host_mak
2113804edf29SJuan Quintelaecho "bindir=\${prefix}$binsuffix" >> $config_host_mak
2114804edf29SJuan Quintelaecho "mandir=\${prefix}$mansuffix" >> $config_host_mak
2115804edf29SJuan Quintelaecho "datadir=\${prefix}$datasuffix" >> $config_host_mak
2116804edf29SJuan Quintelaecho "docdir=\${prefix}$docsuffix" >> $config_host_mak
2117804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2118804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2119804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2120804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2121804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2122804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
2123804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2124804edf29SJuan Quintelaif test "$sparse" = "yes" ; then
2125804edf29SJuan Quintela  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2126804edf29SJuan Quintela  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2127a558ee17SJuan Quintela  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2128804edf29SJuan Quintelafi
2129804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2130804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2131804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
2132e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2133a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2134c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2135e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2136a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2137a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
213873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
21393e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2140804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2141804edf29SJuan Quintela
21424bf6b55bSJuan Quintela# generate list of library paths for linker script
21434bf6b55bSJuan Quintela
21444bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
21454bf6b55bSJuan Quintela
21464bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
21474bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
21484bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
21494bf6b55bSJuan Quintela  else
21504bf6b55bSJuan Quintela    rm ${config_host_ld}~
21514bf6b55bSJuan Quintela  fi
21524bf6b55bSJuan Quintelafi
21534bf6b55bSJuan Quintela
215497a847bcSbellardfor target in $target_list; do
215597a847bcSbellardtarget_dir="$target"
215625be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2157600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
215897a847bcSbellardtarget_bigendian="no"
21591f3d3c8fSJuan Quintela
2160ea2d6a39SJuan Quintelacase "$target_arch2" in
2161ea2d6a39SJuan Quintela  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
2162ea2d6a39SJuan Quintela  target_bigendian=yes
2163ea2d6a39SJuan Quintela  ;;
2164ea2d6a39SJuan Quintelaesac
216597a847bcSbellardtarget_softmmu="no"
2166997344f3Sbellardtarget_user_only="no"
2167831b7825Sthstarget_linux_user="no"
2168831b7825Sthstarget_darwin_user="no"
216984778508Sblueswir1target_bsd_user="no"
21709e407a85Spbrookcase "$target" in
2171600309b6SBlue Swirl  ${target_arch2}-softmmu)
21729e407a85Spbrook    target_softmmu="yes"
21739e407a85Spbrook    ;;
2174600309b6SBlue Swirl  ${target_arch2}-linux-user)
2175*9c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
2176*9c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
2177*9c7a4202SBlue Swirl      exit 1
2178*9c7a4202SBlue Swirl    fi
21799e407a85Spbrook    target_user_only="yes"
21809e407a85Spbrook    target_linux_user="yes"
21819e407a85Spbrook    ;;
2182600309b6SBlue Swirl  ${target_arch2}-darwin-user)
2183*9c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
2184*9c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
2185*9c7a4202SBlue Swirl      exit 1
2186*9c7a4202SBlue Swirl    fi
21879e407a85Spbrook    target_user_only="yes"
2188831b7825Sths    target_darwin_user="yes"
21899e407a85Spbrook    ;;
2190600309b6SBlue Swirl  ${target_arch2}-bsd-user)
2191*9c7a4202SBlue Swirl    if test "bsd" != "yes" ; then
2192*9c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
2193*9c7a4202SBlue Swirl      exit 1
2194*9c7a4202SBlue Swirl    fi
219584778508Sblueswir1    target_user_only="yes"
219684778508Sblueswir1    target_bsd_user="yes"
219784778508Sblueswir1    ;;
21989e407a85Spbrook  *)
21999e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
22009e407a85Spbrook    exit 1
22019e407a85Spbrook    ;;
22029e407a85Spbrookesac
2203831b7825Sths
220497a847bcSbellardmkdir -p $target_dir
2205158142c2Sbellardmkdir -p $target_dir/fpu
220657fec1feSbellardmkdir -p $target_dir/tcg
220759f2a787SGerd Hoffmannmkdir -p $target_dir/ide
220884778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
220969de927cSbellard  mkdir -p $target_dir/nwfpe
221069de927cSbellardfi
221169de927cSbellard
22121f3d3c8fSJuan Quintelaif test ! -f $target_dir/config-devices.mak ; then
22131f3d3c8fSJuan Quintela  cp $source_path/default-configs/${target}.mak $target_dir/config-devices.mak
22141f3d3c8fSJuan Quintelafi
22151f3d3c8fSJuan Quintela
2216ec530c81Sbellard#
2217ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
2218ec530c81Sbellard#
2219ec530c81Sbellardrm -f $target_dir/Makefile
2220ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
2221ec530c81Sbellard
222297a847bcSbellard
222325be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
222497a847bcSbellard
2225e5fe0c52Spbrookbflt="no"
2226cb33da57Sblueswir1elfload32="no"
2227bd0c5661Spbrooktarget_nptl="no"
2228600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
222925be210fSJuan Quintelaecho "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
223056aebc89Spbrookgdb_xml_files=""
22317ba1e619Saliguori
2232938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
22336acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2234e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2235e73aae67SJuan Quintela
2236600309b6SBlue Swirlcase "$target_arch2" in
22372408a527Saurel32  i386)
22381ad2134fSPaul Brook    target_phys_bits=32
22392408a527Saurel32  ;;
22402408a527Saurel32  x86_64)
22416acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
22421ad2134fSPaul Brook    target_phys_bits=64
22432408a527Saurel32  ;;
22442408a527Saurel32  alpha)
22451ad2134fSPaul Brook    target_phys_bits=64
22462408a527Saurel32  ;;
22472408a527Saurel32  arm|armeb)
2248b498c8a0SJuan Quintela    TARGET_ARCH=arm
2249e5fe0c52Spbrook    bflt="yes"
2250bd0c5661Spbrook    target_nptl="yes"
225156aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
22521ad2134fSPaul Brook    target_phys_bits=32
22532408a527Saurel32  ;;
22542408a527Saurel32  cris)
2255253bd7f8Sedgar_igl    target_nptl="yes"
22561ad2134fSPaul Brook    target_phys_bits=32
22572408a527Saurel32  ;;
22582408a527Saurel32  m68k)
22590938cda5Saurel32    bflt="yes"
226056aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
22611ad2134fSPaul Brook    target_phys_bits=32
22622408a527Saurel32  ;;
226372b675caSEdgar E. Iglesias  microblaze)
226472b675caSEdgar E. Iglesias    bflt="yes"
226572b675caSEdgar E. Iglesias    target_nptl="yes"
226672b675caSEdgar E. Iglesias    target_phys_bits=32
226772b675caSEdgar E. Iglesias  ;;
22682408a527Saurel32  mips|mipsel)
2269b498c8a0SJuan Quintela    TARGET_ARCH=mips
227025be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2271f04dc72fSPaul Brook    target_nptl="yes"
22721ad2134fSPaul Brook    target_phys_bits=64
22732408a527Saurel32  ;;
22742408a527Saurel32  mipsn32|mipsn32el)
2275b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
22766acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
227725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
22781ad2134fSPaul Brook    target_phys_bits=64
22792408a527Saurel32  ;;
22802408a527Saurel32  mips64|mips64el)
2281b498c8a0SJuan Quintela    TARGET_ARCH=mips64
22826acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
228325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
22841ad2134fSPaul Brook    target_phys_bits=64
22852408a527Saurel32  ;;
22862408a527Saurel32  ppc)
2287c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
22881ad2134fSPaul Brook    target_phys_bits=32
2289d6630708SNathan Froyd    target_nptl="yes"
22902408a527Saurel32  ;;
22912408a527Saurel32  ppcemb)
22926acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2293e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2294c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
22951ad2134fSPaul Brook    target_phys_bits=64
2296d6630708SNathan Froyd    target_nptl="yes"
22972408a527Saurel32  ;;
22982408a527Saurel32  ppc64)
22996acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2300e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2301c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23021ad2134fSPaul Brook    target_phys_bits=64
23032408a527Saurel32  ;;
23042408a527Saurel32  ppc64abi32)
2305b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
23066acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2307e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
230825be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
2309c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23101ad2134fSPaul Brook    target_phys_bits=64
23112408a527Saurel32  ;;
23122408a527Saurel32  sh4|sh4eb)
2313b498c8a0SJuan Quintela    TARGET_ARCH=sh4
23144dbed897Spbrook    bflt="yes"
23150b6d3ae0Saurel32    target_nptl="yes"
23161ad2134fSPaul Brook    target_phys_bits=32
23172408a527Saurel32  ;;
23182408a527Saurel32  sparc)
23191ad2134fSPaul Brook    target_phys_bits=64
23202408a527Saurel32  ;;
23212408a527Saurel32  sparc64)
23226acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
23230938cda5Saurel32    elfload32="yes"
23241ad2134fSPaul Brook    target_phys_bits=64
23252408a527Saurel32  ;;
23262408a527Saurel32  sparc32plus)
2327b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
23286acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
2329e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
233025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
23311ad2134fSPaul Brook    target_phys_bits=64
23322408a527Saurel32  ;;
23332408a527Saurel32  *)
2334de83cd02Sbellard    echo "Unsupported target CPU"
2335de83cd02Sbellard    exit 1
23362408a527Saurel32  ;;
23372408a527Saurel32esac
233825be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2339053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
234025be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
234125be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
234242bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
23436acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
23446acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
23456acff7daSJuan Quintelafi
234625be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2347e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
2348e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
2349e6e91b9cSJuan Quintelafi
235025be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
23511ad2134fSPaul Brookif [ $target_phys_bits -lt $hostlongbits ] ; then
23521ad2134fSPaul Brook  target_phys_bits=$hostlongbits
23531ad2134fSPaul Brookfi
23541b0c87fcSJuan Quintelacase "$target_arch2" in
23551b0c87fcSJuan Quintela  i386|x86_64)
23561b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
235725be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
23581b0c87fcSJuan Quintela    fi
23591b0c87fcSJuan Quintelaesac
2360c59249f9SJuan Quintelacase "$target_arch2" in
23615f114bc6SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64)
2362c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
2363c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2364c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
2365c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
23665f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2367c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2368c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
236925be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
237025be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2371c59249f9SJuan Quintela    fi
2372c59249f9SJuan Quintelaesac
237325be210fSJuan Quintelaecho "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
2374de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
237525be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
237697a847bcSbellardfi
237797a847bcSbellardif test "$target_softmmu" = "yes" ; then
237825be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
237925be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
238025be210fSJuan Quintela  echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_target_mak
23815791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2382de83cd02Sbellardfi
2383997344f3Sbellardif test "$target_user_only" = "yes" ; then
238425be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2385997344f3Sbellardfi
2386831b7825Sthsif test "$target_linux_user" = "yes" ; then
238725be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2388831b7825Sthsfi
2389831b7825Sthsif test "$target_darwin_user" = "yes" ; then
239025be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2391831b7825Sthsfi
239256aebc89Spbrooklist=""
239356aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
239456aebc89Spbrook  for x in $gdb_xml_files; do
239556aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
239656aebc89Spbrook  done
239725be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
23983d0f1517SJuan Quintelafi
2399de83cd02Sbellard
2400f57975fbSJuan Quintelacase "$target_arch2" in
2401f57975fbSJuan Quintela  arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
240225be210fSJuan Quintela    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2403f57975fbSJuan Quintela    ;;
2404d6b38939SJuan Quintela  *)
240525be210fSJuan Quintela    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2406d6b38939SJuan Quintela    ;;
2407f57975fbSJuan Quintelaesac
2408f57975fbSJuan Quintela
2409e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
241025be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2411e5fe0c52Spbrookfi
2412bd0c5661Spbrookif test "$target_user_only" = "yes" \
2413bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
241425be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2415bd0c5661Spbrookfi
2416cb33da57Sblueswir1# 32 bit ELF loader in addition to native 64 bit loader?
2417cb33da57Sblueswir1if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
241825be210fSJuan Quintela  echo "TARGET_HAS_ELFLOAD32=y" >> $config_target_mak
2419cb33da57Sblueswir1fi
2420379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
242125be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2422379f6698SPaul Brookfi
242384778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
242425be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
242584778508Sblueswir1fi
24265b0753e0Sbellard
24274afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
2428fa282484SJuan Quintela
24294afddb55SJuan Quintelacflags=""
2430fa282484SJuan Quintelaldflags=""
24319b8e111fSJuan Quintela
243257ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
243357ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
243457ddfbf7SJuan Quintelaelse
243557ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
243657ddfbf7SJuan Quintelafi
243757ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/tcg $cflags"
243857ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/fpu $cflags"
243957ddfbf7SJuan Quintela
244064656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
244164656024SJuan Quintela  case "$i" in
244264656024SJuan Quintela  alpha)
244325be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
244464656024SJuan Quintela  ;;
244564656024SJuan Quintela  arm)
244625be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
244764656024SJuan Quintela  ;;
244864656024SJuan Quintela  cris)
244925be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
245064656024SJuan Quintela  ;;
245164656024SJuan Quintela  hppa)
245225be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
245364656024SJuan Quintela  ;;
245464656024SJuan Quintela  i386|x86_64)
245525be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
245664656024SJuan Quintela  ;;
245764656024SJuan Quintela  m68k)
245825be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
245964656024SJuan Quintela  ;;
246064656024SJuan Quintela  microblaze)
246125be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
246264656024SJuan Quintela  ;;
246364656024SJuan Quintela  mips*)
246425be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
246564656024SJuan Quintela  ;;
246664656024SJuan Quintela  ppc*)
246725be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
246864656024SJuan Quintela  ;;
246964656024SJuan Quintela  s390)
247025be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
247164656024SJuan Quintela  ;;
247264656024SJuan Quintela  sh4)
247325be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
247464656024SJuan Quintela  ;;
247564656024SJuan Quintela  sparc*)
247625be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
247764656024SJuan Quintela  ;;
247864656024SJuan Quintela  esac
247964656024SJuan Quinteladone
248064656024SJuan Quintela
24816ee7126fSJuan Quintelacase "$ARCH" in
24826ee7126fSJuan Quintelaalpha)
24836ee7126fSJuan Quintela  # Ensure there's only a single GP
24846ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
24856ee7126fSJuan Quintela;;
2486c60d0afaSJuan Quintelaia64)
2487c60d0afaSJuan Quintela  cflags="-mno-sdata $cflags"
2488c60d0afaSJuan Quintela;;
24896ee7126fSJuan Quintelaesac
24906ee7126fSJuan Quintela
249155d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
249255d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
249355d9c04bSJuan Quintela  arm)
249455d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
249555d9c04bSJuan Quintela  ;;
249655d9c04bSJuan Quintela  i386|mips|ppc)
249755d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
249855d9c04bSJuan Quintela  ;;
249955d9c04bSJuan Quintela  esac
250055d9c04bSJuan Quintelafi
250155d9c04bSJuan Quintela
250234005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
250334005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
250434005a00SKirill A. Shutemov  cflags="-fpie $cflags"
250534005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
250634005a00SKirill A. Shutemovfi
250734005a00SKirill A. Shutemov
2508471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
2509471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
2510471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
251125be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
2512471857ddSJuan Quintelafi
2513471857ddSJuan Quintela
2514d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
251525be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
2516d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
2517d02c1db3SJuan Quintela    cflags="-p $cflags"
2518d02c1db3SJuan Quintela    ldflags="-p $ldflags"
2519d02c1db3SJuan Quintela  fi
2520d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
2521d02c1db3SJuan Quintela    ldflags="-p $ldflags"
252225be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
2523d02c1db3SJuan Quintela  fi
2524d02c1db3SJuan Quintelafi
2525d02c1db3SJuan Quintela
25266ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
25279b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2528fa282484SJuan Quintela  case "$ARCH" in
2529fa282484SJuan Quintela  sparc)
2530fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
2531322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
2532fa282484SJuan Quintela    ;;
2533fa282484SJuan Quintela  ia64)
2534322e5878SJuan Quintela    ldflags="-Wl,-G0 $linker_script -static $ldflags"
2535fa282484SJuan Quintela    ;;
2536df70204dSKirill A. Shutemov  i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2537322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
2538fa282484SJuan Quintela    ;;
2539fa282484SJuan Quintela  esac
2540fa282484SJuan Quintelafi
2541fa282484SJuan Quintelaif test "$target_softmmu" = "yes" ; then
2542fa282484SJuan Quintela  case "$ARCH" in
2543fa282484SJuan Quintela  ia64)
2544322e5878SJuan Quintela    ldflags="-Wl,-G0 $linker_script -static $ldflags"
2545fa282484SJuan Quintela    ;;
2546fa282484SJuan Quintela  esac
2547fa282484SJuan Quintelafi
2548fa282484SJuan Quintela
254925be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
255025be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
2551fa282484SJuan Quintela
255297a847bcSbellarddone # for target in $targets
25537d13299dSbellard
25547d13299dSbellard# build tree in object directory if source path is different from current one
25557d13299dSbellardif test "$source_path_used" = "yes" ; then
2556e1144d00SMark McLoughlin    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
25572d9f27d2SAnthony Liguori    DIRS="$DIRS roms/seabios roms/vgabios"
25587d13299dSbellard    FILES="Makefile tests/Makefile"
2559e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2560e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
25617ea78b74SJan Kiszka    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
25622d9f27d2SAnthony Liguori    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
25637ea78b74SJan Kiszka    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
25647ea78b74SJan Kiszka        FILES="$FILES pc-bios/`basename $bios_file`"
25657ea78b74SJan Kiszka    done
25667d13299dSbellard    for dir in $DIRS ; do
25677d13299dSbellard            mkdir -p $dir
25687d13299dSbellard    done
2569ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
25707d13299dSbellard    for f in $FILES ; do
2571ec530c81Sbellard        rm -f $f
2572ec530c81Sbellard        ln -s $source_path/$f $f
25737d13299dSbellard    done
25747d13299dSbellardfi
25751ad2134fSPaul Brook
2576c34ebfdcSAnthony Liguori# temporary config to build submodules
25772d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
2578c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
2579c34ebfdcSAnthony Liguori    echo "# Automatically generated by configure - do not modify" >> $config_mak
2580c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2581c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
2582c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
2583c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
2584c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
2585c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
2586c34ebfdcSAnthony Liguori    echo "HOST_CC=$host_cc" >> $config_mak
2587c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
2588c34ebfdcSAnthony Liguoridone
2589c34ebfdcSAnthony Liguori
25901ad2134fSPaul Brookfor hwlib in 32 64; do
25911ad2134fSPaul Brook  d=libhw$hwlib
25921ad2134fSPaul Brook  mkdir -p $d
25931ad2134fSPaul Brook  rm -f $d/Makefile
25941ad2134fSPaul Brook  ln -s $source_path/Makefile.hw $d/Makefile
25951ad2134fSPaul Brook  echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2596a558ee17SJuan Quintela  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
25971ad2134fSPaul Brookdone
2598add16157SBlue Swirl
2599add16157SBlue Swirld=libuser
2600add16157SBlue Swirlmkdir -p $d
2601add16157SBlue Swirlrm -f $d/Makefile
2602add16157SBlue Swirlln -s $source_path/Makefile.user $d/Makefile
2603