xref: /openbmc/qemu/configure (revision 24e804ec146fa491c32a39941dc9f259c8df41e6)
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
94be17dc90SMichael S. Tsirkin# default flags for all hosts
95be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
96be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
97be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
98be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
99be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
100be17dc90SMichael S. TsirkinQEMU_CFLAGS="-U_FORTIFY_SOURCE $QEMU_CFLAGS"
101be17dc90SMichael S. TsirkinQEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
102be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
103be17dc90SMichael S. Tsirkin
104be17dc90SMichael S. Tsirkingcc_flags="-Wold-style-declaration -Wold-style-definition"
105be17dc90SMichael S. Tsirkincat > $TMPC << EOF
106be17dc90SMichael S. Tsirkinint main(void) { }
107be17dc90SMichael S. TsirkinEOF
108be17dc90SMichael S. Tsirkinfor flag in $gcc_flags; do
109be17dc90SMichael S. Tsirkin    if compile_prog "$QEMU_CFLAGS" "$flag" ; then
110be17dc90SMichael S. Tsirkin	QEMU_CFLAGS="$flag $QEMU_CFLAGS"
111be17dc90SMichael S. Tsirkin    fi
112be17dc90SMichael S. Tsirkindone
113be17dc90SMichael S. Tsirkin
114ac0df51dSaliguori# check that the C compiler works.
115ac0df51dSaliguoricat > $TMPC <<EOF
116ac0df51dSaliguoriint main(void) {}
117ac0df51dSaliguoriEOF
118ac0df51dSaliguori
11952166aa0SJuan Quintelaif compile_object ; then
120ac0df51dSaliguori  : C compiler works ok
121ac0df51dSaliguorielse
122ac0df51dSaliguori    echo "ERROR: \"$cc\" either does not exist or does not work"
123ac0df51dSaliguori    exit 1
124ac0df51dSaliguorifi
125ac0df51dSaliguori
126ac0df51dSaliguoricheck_define() {
127ac0df51dSaliguoricat > $TMPC <<EOF
128ac0df51dSaliguori#if !defined($1)
129ac0df51dSaliguori#error Not defined
130ac0df51dSaliguori#endif
131ac0df51dSaliguoriint main(void) { return 0; }
132ac0df51dSaliguoriEOF
13352166aa0SJuan Quintela  compile_object
134ac0df51dSaliguori}
135ac0df51dSaliguori
1362ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
1372ff6b91eSJuan Quintela  # command line argument
1382ff6b91eSJuan Quintela  :
1392ff6b91eSJuan Quintelaelif check_define __i386__ ; then
140ac0df51dSaliguori  cpu="i386"
141ac0df51dSaliguorielif check_define __x86_64__ ; then
142ac0df51dSaliguori  cpu="x86_64"
1433aa9bd6cSblueswir1elif check_define __sparc__ ; then
1443aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
1453aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
1463aa9bd6cSblueswir1  if check_define __arch64__ ; then
1473aa9bd6cSblueswir1    cpu="sparc64"
1483aa9bd6cSblueswir1  else
1493aa9bd6cSblueswir1    cpu="sparc"
1503aa9bd6cSblueswir1  fi
151fdf7ed96Smalcelif check_define _ARCH_PPC ; then
152fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
153fdf7ed96Smalc    cpu="ppc64"
154ac0df51dSaliguori  else
155fdf7ed96Smalc    cpu="ppc"
156fdf7ed96Smalc  fi
157afa05235SAurelien Jarnoelif check_define __mips__ ; then
158afa05235SAurelien Jarno  cpu="mips"
159fdf7ed96Smalcelse
160fdf7ed96Smalc  cpu=`uname -m`
161ac0df51dSaliguorifi
162ac0df51dSaliguori
1635327cf48Sbellardtarget_list=""
1647d13299dSbellardcase "$cpu" in
165afa05235SAurelien Jarno  alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
166ea8f20f8SJuan Quintela    cpu="$cpu"
167ea8f20f8SJuan Quintela  ;;
1687d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
16997a847bcSbellard    cpu="i386"
1707d13299dSbellard  ;;
171aaa5fa14Saurel32  x86_64|amd64)
172aaa5fa14Saurel32    cpu="x86_64"
173aaa5fa14Saurel32  ;;
174ba68055eSbellard  armv*b)
175808c4954Sbellard    cpu="armv4b"
176808c4954Sbellard  ;;
177ba68055eSbellard  armv*l)
1787d13299dSbellard    cpu="armv4l"
1797d13299dSbellard  ;;
180f54b3f92Saurel32  parisc|parisc64)
181f54b3f92Saurel32    cpu="hppa"
182f54b3f92Saurel32  ;;
183afa05235SAurelien Jarno  mips*)
184afa05235SAurelien Jarno    cpu="mips"
185afa05235SAurelien Jarno  ;;
186*24e804ecSAlexander Graf  s390)
187fb3e5849Sbellard    cpu="s390"
188fb3e5849Sbellard  ;;
189*24e804ecSAlexander Graf  s390x)
190*24e804ecSAlexander Graf    cpu="s390x"
191*24e804ecSAlexander Graf  ;;
1923142255cSblueswir1  sparc|sun4[cdmuv])
193ae228531Sbellard    cpu="sparc"
194ae228531Sbellard  ;;
1957d13299dSbellard  *)
1967d13299dSbellard    cpu="unknown"
1977d13299dSbellard  ;;
1987d13299dSbellardesac
199e2d52ad3SJuan Quintela
2003a3fb96dSStefan Weil# Default value for a variable defining feature "foo".
2013a3fb96dSStefan Weil#  * foo="no"  feature will only be used if --enable-foo arg is given
2023a3fb96dSStefan Weil#  * foo=""    feature will be searched for, and if found, will be used
2033a3fb96dSStefan Weil#              unless --disable-foo is given
2043a3fb96dSStefan Weil#  * foo="yes" this value will only be set by --enable-foo flag.
2053a3fb96dSStefan Weil#              feature will searched for,
2063a3fb96dSStefan Weil#              if not found, configure exits with error
207e2d52ad3SJuan Quintela#
2083a3fb96dSStefan Weil# Always add --enable-foo and --disable-foo command line args.
2093a3fb96dSStefan Weil# Distributions want to ensure that several features are compiled in, and it
2103a3fb96dSStefan Weil# is impossible without a --enable-foo that exits if a feature is not found.
211e2d52ad3SJuan Quintela
212a20a6f46SJuan Quintelabluez=""
2134ffcedb6SJuan Quintelabrlapi=""
214788c8196SJuan Quintelacurl=""
215c584a6d0SJuan Quintelacurses=""
216a25dba17SJuan Quinteladocs=""
2172df87df7SJuan Quintelafdt=""
218b31a0277SJuan Quintelakvm=""
219b0a47e79SJuan Quintelanptl=""
220c4198157SJuan Quintelasdl=""
221dfffc653SJuan Quintelasparse="no"
222ee682d27SStefan Weiluuid=""
223dfb278bdSJuan Quintelavde=""
2241be10ad2SJuan Quintelavnc_tls=""
225ea784e3bSJuan Quintelavnc_sasl=""
226fc321b4bSJuan Quintelaxen=""
2275c6c3a6cSChristoph Hellwiglinux_aio=""
228dfb278bdSJuan Quintela
2297d13299dSbellardgprof="no"
230f8393946Saurel32debug_tcg="no"
231f3d08ee6SPaul Brookdebug="no"
2321625af87Saliguoristrip_opt="yes"
2337d13299dSbellardbigendian="no"
23467b915a5Sbellardmingw32="no"
23567b915a5SbellardEXESUF=""
236443f1376Sbellardslirp="yes"
237102a52e4Sbellardfmod_lib=""
238102a52e4Sbellardfmod_inc=""
2392f6a1ab0Sblueswir1oss_lib=""
240b1a550a0Spbrookbsd="no"
2415327cf48Sbellardlinux="no"
242d2c7c9b8Sblueswir1solaris="no"
24305c2a3e7Sbellardprofiler="no"
2445b0753e0Sbellardcocoa="no"
2450a8e90f4Spbrooksoftmmu="yes"
246831b7825Sthslinux_user="no"
247831b7825Sthsdarwin_user="no"
24884778508Sblueswir1bsd_user="no"
249379f6698SPaul Brookguest_base=""
250c5937220Spbrookuname_release=""
251e5d355d1Saliguoriio_thread="no"
2528ff9cbf7Smalcmixemu="no"
253eac30262Saliguorikerneldir=""
254b29fe3edSmalcaix="no"
25577755340Sthsblobs="yes"
2564a19f1ecSpbrookpkgversion=""
2575495ed11SLuiz Capitulinocheck_utests="no"
25834005a00SKirill A. Shutemovuser_pie="no"
2597d13299dSbellard
2607d13299dSbellard# OS specific
261ac0df51dSaliguoriif check_define __linux__ ; then
262ac0df51dSaliguori  targetos="Linux"
263ac0df51dSaliguorielif check_define _WIN32 ; then
264ac0df51dSaliguori  targetos='MINGW32'
265169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
266169dc5d3Sblueswir1  targetos='OpenBSD'
267169dc5d3Sblueswir1elif check_define __sun__ ; then
268169dc5d3Sblueswir1  targetos='SunOS'
269ac0df51dSaliguorielse
2707d13299dSbellard  targetos=`uname -s`
271ac0df51dSaliguorifi
2720dbfc675SJuan Quintela
2737d13299dSbellardcase $targetos in
274c326e0afSbellardCYGWIN*)
275c326e0afSbellard  mingw32="yes"
276a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
277d5631638Smalc  audio_possible_drivers="winwave sdl"
278d5631638Smalc  audio_drv_list="winwave"
279c326e0afSbellard;;
28067b915a5SbellardMINGW32*)
28167b915a5Sbellard  mingw32="yes"
282d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
283d5631638Smalc  audio_drv_list="winwave"
28467b915a5Sbellard;;
2855c40d2bdSthsGNU/kFreeBSD)
286a167ba50SAurelien Jarno  bsd="yes"
2870c58ac1cSmalc  audio_drv_list="oss"
288f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
2895c40d2bdSths;;
2907d3505c5SbellardFreeBSD)
2917d3505c5Sbellard  bsd="yes"
292a167ba50SAurelien Jarno  make="gmake"
2930c58ac1cSmalc  audio_drv_list="oss"
294f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
2957d3505c5Sbellard;;
296c5e97233Sblueswir1DragonFly)
297c5e97233Sblueswir1  bsd="yes"
298a167ba50SAurelien Jarno  make="gmake"
299c5e97233Sblueswir1  audio_drv_list="oss"
300c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
301c5e97233Sblueswir1;;
3027d3505c5SbellardNetBSD)
3037d3505c5Sbellard  bsd="yes"
304a167ba50SAurelien Jarno  make="gmake"
3050c58ac1cSmalc  audio_drv_list="oss"
306c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3078ef92a88Sblueswir1  oss_lib="-lossaudio"
3087d3505c5Sbellard;;
3097d3505c5SbellardOpenBSD)
3107d3505c5Sbellard  bsd="yes"
311a167ba50SAurelien Jarno  make="gmake"
3120c58ac1cSmalc  audio_drv_list="oss"
313c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3142f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3157d3505c5Sbellard;;
31683fb7adfSbellardDarwin)
31783fb7adfSbellard  bsd="yes"
31883fb7adfSbellard  darwin="yes"
3190dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3200dbfc675SJuan Quintela  # run 64-bit userspace code
321aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3221b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
323aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3241b0f9cc2Saliguori  fi
3251b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
326a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3270c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3281b0f9cc2Saliguori  else
329a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3301b0f9cc2Saliguori  fi
331831b7825Sths  darwin_user="yes"
332fd677642Sths  cocoa="yes"
3330c58ac1cSmalc  audio_drv_list="coreaudio"
334c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
3350c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
3367973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
33783fb7adfSbellard;;
338ec530c81SbellardSunOS)
339ec530c81Sbellard  solaris="yes"
340c2b84fabSths  make="gmake"
341c2b84fabSths  install="ginstall"
342fa58948dSBlue Swirl  ld="gld"
3430475a5caSths  needs_libsunmath="no"
344c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
345ef18c883Sths  # have to select again, because `uname -m` returns i86pc
346ef18c883Sths  # even on an x86_64 box.
347ef18c883Sths  solariscpu=`isainfo -k`
348ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
349ef18c883Sths    cpu="x86_64"
350ef18c883Sths  fi
351c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
3520475a5caSths    if test "$solarisrev" -le 9 ; then
3530475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
3540475a5caSths        needs_libsunmath="yes"
355f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
356f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
357f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
3580475a5caSths      else
3590475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
3600475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
3610475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
3620475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
3630475a5caSths        exit 1
3640475a5caSths      fi
3650475a5caSths    fi
36686b2bd93Sths  fi
3676b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
3680c58ac1cSmalc    audio_drv_list="oss"
3696b4d2ba1Sths  fi
370c2de5c91Smalc  audio_possible_drivers="oss sdl"
371d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
372d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
373d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
374d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
375a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
376e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
377ec530c81Sbellard;;
378b29fe3edSmalcAIX)
379b29fe3edSmalc  aix="yes"
380b29fe3edSmalc  make="gmake"
381b29fe3edSmalc;;
382fb065187Sbellard*)
3830c58ac1cSmalc  audio_drv_list="oss"
384b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
3855327cf48Sbellard  linux="yes"
386831b7825Sths  linux_user="yes"
38768063649Sblueswir1  usb="linux"
38807f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
389c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
390c9ec1fe4Sbellard  fi
391fb065187Sbellard;;
3927d13299dSbellardesac
3937d13299dSbellard
3947d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
395b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
39668063649Sblueswir1    usb="bsd"
39783fb7adfSbellard  fi
39884778508Sblueswir1  bsd_user="yes"
3997d3505c5Sbellardfi
4007d3505c5Sbellard
4013457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4023457a3f8SJuan Quintela  EXESUF=".exe"
403a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
404884044aaSJuan Quintela  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
4053457a3f8SJuan Quintelafi
4063457a3f8SJuan Quintela
4077d13299dSbellard# find source path
408ad064840Spbrooksource_path=`dirname "$0"`
40959faef3aSbalrogsource_path_used="no"
41059faef3aSbalrogworkdir=`pwd`
411ad064840Spbrookif [ -z "$source_path" ]; then
41259faef3aSbalrog    source_path=$workdir
413ad064840Spbrookelse
414ad064840Spbrook    source_path=`cd "$source_path"; pwd`
4157d13299dSbellardfi
416724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
4177d13299dSbellard
418487fefdbSAnthony Liguoriwerror=""
41985aa5189Sbellard
4207d13299dSbellardfor opt do
421a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4227d13299dSbellard  case "$opt" in
4232efc3265Sbellard  --help|-h) show_help=yes
4242efc3265Sbellard  ;;
425b1a550a0Spbrook  --prefix=*) prefix="$optarg"
4267d13299dSbellard  ;;
427b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
42832ce6337Sbellard  ;;
429b1a550a0Spbrook  --source-path=*) source_path="$optarg"
430ad064840Spbrook  source_path_used="yes"
4317d13299dSbellard  ;;
432ac0df51dSaliguori  --cross-prefix=*)
4337d13299dSbellard  ;;
434ac0df51dSaliguori  --cc=*)
4357d13299dSbellard  ;;
436b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
43783469015Sbellard  ;;
438b1a550a0Spbrook  --make=*) make="$optarg"
4397d13299dSbellard  ;;
4406a882643Spbrook  --install=*) install="$optarg"
4416a882643Spbrook  ;;
442e2a2ed06SJuan Quintela  --extra-cflags=*)
4437d13299dSbellard  ;;
444e2a2ed06SJuan Quintela  --extra-ldflags=*)
4457d13299dSbellard  ;;
4462ff6b91eSJuan Quintela  --cpu=*)
4477d13299dSbellard  ;;
448b1a550a0Spbrook  --target-list=*) target_list="$optarg"
449de83cd02Sbellard  ;;
4507d13299dSbellard  --enable-gprof) gprof="yes"
4517d13299dSbellard  ;;
45243ce4dfeSbellard  --static) static="yes"
45343ce4dfeSbellard  ;;
45497a847bcSbellard  --disable-sdl) sdl="no"
45597a847bcSbellard  ;;
456c4198157SJuan Quintela  --enable-sdl) sdl="yes"
457c4198157SJuan Quintela  ;;
458b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
459102a52e4Sbellard  ;;
460c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
461c2de5c91Smalc  ;;
4622f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
4632f6a1ab0Sblueswir1  ;;
4642fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
4650c58ac1cSmalc  ;;
4660c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
4670c58ac1cSmalc  ;;
468eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
469eb852011SMarkus Armbruster  ;;
470f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
471f8393946Saurel32  ;;
472f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
473f8393946Saurel32  ;;
474f3d08ee6SPaul Brook  --enable-debug)
475f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
476f3d08ee6SPaul Brook      debug_tcg="yes"
477f3d08ee6SPaul Brook      debug="yes"
478f3d08ee6SPaul Brook      strip_opt="no"
479f3d08ee6SPaul Brook  ;;
48003b4fe7dSaliguori  --enable-sparse) sparse="yes"
48103b4fe7dSaliguori  ;;
48203b4fe7dSaliguori  --disable-sparse) sparse="no"
48303b4fe7dSaliguori  ;;
4841625af87Saliguori  --disable-strip) strip_opt="no"
4851625af87Saliguori  ;;
4868d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
4878d5d2d4cSths  ;;
4881be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
4891be10ad2SJuan Quintela  ;;
4902f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
4912f9606b3Saliguori  ;;
492ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
493ea784e3bSJuan Quintela  ;;
494443f1376Sbellard  --disable-slirp) slirp="no"
495c20709aaSbellard  ;;
496ee682d27SStefan Weil  --disable-uuid) uuid="no"
497ee682d27SStefan Weil  ;;
498ee682d27SStefan Weil  --enable-uuid) uuid="yes"
499ee682d27SStefan Weil  ;;
500e0e6c8c0Saliguori  --disable-vde) vde="no"
5018a16d273Sths  ;;
502dfb278bdSJuan Quintela  --enable-vde) vde="yes"
503dfb278bdSJuan Quintela  ;;
504e37630caSaliguori  --disable-xen) xen="no"
505e37630caSaliguori  ;;
506fc321b4bSJuan Quintela  --enable-xen) xen="yes"
507fc321b4bSJuan Quintela  ;;
5082e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
5092e4d9fb1Saurel32  ;;
5104ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
5114ffcedb6SJuan Quintela  ;;
512fb599c9aSbalrog  --disable-bluez) bluez="no"
513fb599c9aSbalrog  ;;
514a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
515a20a6f46SJuan Quintela  ;;
5167ba1e619Saliguori  --disable-kvm) kvm="no"
5177ba1e619Saliguori  ;;
518b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
519b31a0277SJuan Quintela  ;;
52005c2a3e7Sbellard  --enable-profiler) profiler="yes"
52105c2a3e7Sbellard  ;;
522c2de5c91Smalc  --enable-cocoa)
523c2de5c91Smalc      cocoa="yes" ;
524c2de5c91Smalc      sdl="no" ;
525c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
5265b0753e0Sbellard  ;;
527cad25d69Spbrook  --disable-system) softmmu="no"
5280a8e90f4Spbrook  ;;
529cad25d69Spbrook  --enable-system) softmmu="yes"
5300a8e90f4Spbrook  ;;
5310953a80fSZachary Amsden  --disable-user)
5320953a80fSZachary Amsden      linux_user="no" ;
5330953a80fSZachary Amsden      bsd_user="no" ;
5340953a80fSZachary Amsden      darwin_user="no"
5350953a80fSZachary Amsden  ;;
5360953a80fSZachary Amsden  --enable-user) ;;
537831b7825Sths  --disable-linux-user) linux_user="no"
5380a8e90f4Spbrook  ;;
539831b7825Sths  --enable-linux-user) linux_user="yes"
540831b7825Sths  ;;
541831b7825Sths  --disable-darwin-user) darwin_user="no"
542831b7825Sths  ;;
543831b7825Sths  --enable-darwin-user) darwin_user="yes"
5440a8e90f4Spbrook  ;;
54584778508Sblueswir1  --disable-bsd-user) bsd_user="no"
54684778508Sblueswir1  ;;
54784778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
54884778508Sblueswir1  ;;
549379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
550379f6698SPaul Brook  ;;
551379f6698SPaul Brook  --disable-guest-base) guest_base="no"
552379f6698SPaul Brook  ;;
55334005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
55434005a00SKirill A. Shutemov  ;;
55534005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
55634005a00SKirill A. Shutemov  ;;
557c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
558c5937220Spbrook  ;;
5593142255cSblueswir1  --sparc_cpu=*)
5603142255cSblueswir1  ;;
56185aa5189Sbellard  --enable-werror) werror="yes"
56285aa5189Sbellard  ;;
56385aa5189Sbellard  --disable-werror) werror="no"
56485aa5189Sbellard  ;;
5654d3b6f6eSbalrog  --disable-curses) curses="no"
5664d3b6f6eSbalrog  ;;
567c584a6d0SJuan Quintela  --enable-curses) curses="yes"
568c584a6d0SJuan Quintela  ;;
569769ce76dSAlexander Graf  --disable-curl) curl="no"
570769ce76dSAlexander Graf  ;;
571788c8196SJuan Quintela  --enable-curl) curl="yes"
572788c8196SJuan Quintela  ;;
5732df87df7SJuan Quintela  --disable-fdt) fdt="no"
5742df87df7SJuan Quintela  ;;
5752df87df7SJuan Quintela  --enable-fdt) fdt="yes"
5762df87df7SJuan Quintela  ;;
5775495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
5785495ed11SLuiz Capitulino  ;;
5795495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
5805495ed11SLuiz Capitulino  ;;
581bd0c5661Spbrook  --disable-nptl) nptl="no"
582bd0c5661Spbrook  ;;
583b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
584b0a47e79SJuan Quintela  ;;
5858ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
5868ff9cbf7Smalc  ;;
5875c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
5885c6c3a6cSChristoph Hellwig  ;;
5895c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
5905c6c3a6cSChristoph Hellwig  ;;
591e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
592e5d355d1Saliguori  ;;
59377755340Sths  --disable-blobs) blobs="no"
59477755340Sths  ;;
595eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
596eac30262Saliguori  ;;
5974a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
5984a19f1ecSpbrook  ;;
599a25dba17SJuan Quintela  --disable-docs) docs="no"
60070ec5dc0SAnthony Liguori  ;;
601a25dba17SJuan Quintela  --enable-docs) docs="yes"
60283a3ab8bSJuan Quintela  ;;
6037f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
6047f1559c6Sbalrog  ;;
6057d13299dSbellard  esac
6067d13299dSbellarddone
6077d13299dSbellard
6083142255cSblueswir1#
6093142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
610a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
6113142255cSblueswir1#
612379f6698SPaul Brookhost_guest_base="no"
61340293e58Sbellardcase "$cpu" in
614ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
615ed968ff1SJuan Quintela           v7|v8)
616a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
617ed968ff1SJuan Quintela           ;;
618ed968ff1SJuan Quintela           v8plus|v8plusa)
619a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
620ed968ff1SJuan Quintela           ;;
621ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
622a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
623ed968ff1SJuan Quintela           esac
6240c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
625a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
626762e8230Sblueswir1           if test "$solaris" = "no" ; then
627a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
628c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
629762e8230Sblueswir1           fi
6303142255cSblueswir1           ;;
631ed968ff1SJuan Quintela    sparc64)
632a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
6330c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
634a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
635ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
636a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
637762e8230Sblueswir1           fi
6383142255cSblueswir1           ;;
63976d83bdeSths    s390)
640a558ee17SJuan Quintela           QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
64176d83bdeSths           ;;
64240293e58Sbellard    i386)
643a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
6440c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
645c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
646379f6698SPaul Brook           host_guest_base="yes"
64740293e58Sbellard           ;;
64840293e58Sbellard    x86_64)
649a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
6500c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
651379f6698SPaul Brook           host_guest_base="yes"
652379f6698SPaul Brook           ;;
653379f6698SPaul Brook    arm*)
654379f6698SPaul Brook           host_guest_base="yes"
65540293e58Sbellard           ;;
656f6548c0aSmalc    ppc*)
657f6548c0aSmalc           host_guest_base="yes"
658f6548c0aSmalc           ;;
6593142255cSblueswir1esac
6603142255cSblueswir1
661379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
662379f6698SPaul Brook
663af5db58eSpbrookif test x"$show_help" = x"yes" ; then
664af5db58eSpbrookcat << EOF
665af5db58eSpbrook
666af5db58eSpbrookUsage: configure [options]
667af5db58eSpbrookOptions: [defaults in brackets after descriptions]
668af5db58eSpbrook
669af5db58eSpbrookEOF
670af5db58eSpbrookecho "Standard options:"
671af5db58eSpbrookecho "  --help                   print this message"
672af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
673af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
674af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
675af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
676af5db58eSpbrookecho ""
677af5db58eSpbrookecho "Advanced options (experts only):"
678af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
679af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
680af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
681af5db58eSpbrookecho "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
682a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
683e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
684af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
6856a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
686af5db58eSpbrookecho "  --static                 enable static build [$static]"
687f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
688f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
68909695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
690890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
691890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
6921625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
69385aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
694fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
695c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
696af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
697c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
698c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
6994c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
7004c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
701eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
702eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
7038ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
704e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
705fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
7062e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
7074ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
7088d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
7091be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
7102f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
711ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
712af896aaaSpbrookecho "  --disable-curses         disable curses output"
713c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
714769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
715788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
7162df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
7172df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
7185495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
7195495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
720fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
721a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
7227ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
723b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
724bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
725e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
726af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
727af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
7280953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
7290953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
730831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
731831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
732831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
733831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
73484778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
73584778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
736379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
737379f6698SPaul Brookecho "                           emulation targets"
738379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
73934005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
74034005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
741af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
742af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
7432f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
744c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
7453142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
746ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
747ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
748e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
749dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
7505c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
7515c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
752e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
75377755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
754eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
755af5db58eSpbrookecho ""
7565bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
757af5db58eSpbrookexit 1
758af5db58eSpbrookfi
759af5db58eSpbrook
760ec530c81Sbellard#
761ec530c81Sbellard# Solaris specific configure tool chain decisions
762ec530c81Sbellard#
763ec530c81Sbellardif test "$solaris" = "yes" ; then
764ec530c81Sbellard  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
765ec530c81Sbellard  if test -z "$solinst" ; then
766ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
767ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
768ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
769ec530c81Sbellard    exit 1
770ec530c81Sbellard  fi
771ec530c81Sbellard  if test "$solinst" = "/usr/sbin/install" ; then
772ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
773ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
774ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
775ec530c81Sbellard    exit 1
776ec530c81Sbellard  fi
777ec530c81Sbellard  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
778ec530c81Sbellard  if test -z "$sol_ar" ; then
779ec530c81Sbellard    echo "Error: No path includes ar"
780ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
781ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
782ec530c81Sbellard    fi
783ec530c81Sbellard    exit 1
784ec530c81Sbellard  fi
785ec530c81Sbellardfi
786ec530c81Sbellard
787ec530c81Sbellard
7885327cf48Sbellardif test -z "$target_list" ; then
7895327cf48Sbellard# these targets are portable
7900a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
7912408a527Saurel32        target_list="\
7922408a527Saurel32i386-softmmu \
7932408a527Saurel32x86_64-softmmu \
7942408a527Saurel32arm-softmmu \
7952408a527Saurel32cris-softmmu \
7962408a527Saurel32m68k-softmmu \
79772b675caSEdgar E. Iglesiasmicroblaze-softmmu \
7982408a527Saurel32mips-softmmu \
7992408a527Saurel32mipsel-softmmu \
8002408a527Saurel32mips64-softmmu \
8012408a527Saurel32mips64el-softmmu \
8022408a527Saurel32ppc-softmmu \
8032408a527Saurel32ppcemb-softmmu \
8042408a527Saurel32ppc64-softmmu \
8052408a527Saurel32sh4-softmmu \
8062408a527Saurel32sh4eb-softmmu \
8072408a527Saurel32sparc-softmmu \
8081b64fcaeSIgor V. Kovalenkosparc64-softmmu \
8092408a527Saurel32"
8100a8e90f4Spbrook    fi
8115327cf48Sbellard# the following are Linux specific
812831b7825Sths    if [ "$linux_user" = "yes" ] ; then
8132408a527Saurel32        target_list="${target_list}\
8142408a527Saurel32i386-linux-user \
8152408a527Saurel32x86_64-linux-user \
8162408a527Saurel32alpha-linux-user \
8172408a527Saurel32arm-linux-user \
8182408a527Saurel32armeb-linux-user \
8192408a527Saurel32cris-linux-user \
8202408a527Saurel32m68k-linux-user \
82172b675caSEdgar E. Iglesiasmicroblaze-linux-user \
8222408a527Saurel32mips-linux-user \
8232408a527Saurel32mipsel-linux-user \
8242408a527Saurel32ppc-linux-user \
8252408a527Saurel32ppc64-linux-user \
8262408a527Saurel32ppc64abi32-linux-user \
8272408a527Saurel32sh4-linux-user \
8282408a527Saurel32sh4eb-linux-user \
8292408a527Saurel32sparc-linux-user \
8302408a527Saurel32sparc64-linux-user \
8312408a527Saurel32sparc32plus-linux-user \
8322408a527Saurel32"
833831b7825Sths    fi
834831b7825Sths# the following are Darwin specific
835831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
8362408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
8375327cf48Sbellard    fi
83884778508Sblueswir1# the following are BSD specific
83984778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
84084778508Sblueswir1        target_list="${target_list}\
84131fc12dfSblueswir1i386-bsd-user \
84231fc12dfSblueswir1x86_64-bsd-user \
84331fc12dfSblueswir1sparc-bsd-user \
84484778508Sblueswir1sparc64-bsd-user \
84584778508Sblueswir1"
84684778508Sblueswir1    fi
8476e20a45fSbellardelse
848b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
8495327cf48Sbellardfi
8500a8e90f4Spbrookif test -z "$target_list" ; then
8510a8e90f4Spbrook    echo "No targets enabled"
8520a8e90f4Spbrook    exit 1
8530a8e90f4Spbrookfi
8545327cf48Sbellard
855249247c9SJuan Quintelafeature_not_found() {
856249247c9SJuan Quintela  feature=$1
857249247c9SJuan Quintela
858249247c9SJuan Quintela  echo "ERROR"
859249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
8609332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
861249247c9SJuan Quintela  echo "ERROR"
862249247c9SJuan Quintela  exit 1;
863249247c9SJuan Quintela}
864249247c9SJuan Quintela
8657d13299dSbellardif test -z "$cross_prefix" ; then
8667d13299dSbellard
8677d13299dSbellard# ---
8687d13299dSbellard# big/little endian test
8697d13299dSbellardcat > $TMPC << EOF
8707d13299dSbellard#include <inttypes.h>
8717d13299dSbellardint main(int argc, char ** argv){
8727d13299dSbellard        volatile uint32_t i=0x01234567;
8737d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
8747d13299dSbellard}
8757d13299dSbellardEOF
8767d13299dSbellard
87752166aa0SJuan Quintelaif compile_prog "" "" ; then
8787d13299dSbellard$TMPE && bigendian="yes"
8797d13299dSbellardelse
8807d13299dSbellardecho big/little test failed
8817d13299dSbellardfi
8827d13299dSbellard
8837d13299dSbellardelse
8847d13299dSbellard
8857d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
886ea8f20f8SJuan Quintelacase "$cpu" in
887*24e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
888ea8f20f8SJuan Quintela    bigendian=yes
889ea8f20f8SJuan Quintela  ;;
890ea8f20f8SJuan Quintelaesac
8917d13299dSbellard
8927d13299dSbellardfi
8937d13299dSbellard
894b6853697Sbellard# host long bits test
895b6853697Sbellardhostlongbits="32"
896ea8f20f8SJuan Quintelacase "$cpu" in
897*24e804ecSAlexander Graf  x86_64|alpha|ia64|sparc64|ppc64|s390x)
898ea8f20f8SJuan Quintela    hostlongbits=64
899ea8f20f8SJuan Quintela  ;;
900ea8f20f8SJuan Quintelaesac
901b6853697Sbellard
902b0a47e79SJuan Quintela
903b0a47e79SJuan Quintela##########################################
904b0a47e79SJuan Quintela# NPTL probe
905b0a47e79SJuan Quintela
906b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
907bd0c5661Spbrook  cat > $TMPC <<EOF
908bd0c5661Spbrook#include <sched.h>
90930813ceaSpbrook#include <linux/futex.h>
910bd0c5661Spbrookvoid foo()
911bd0c5661Spbrook{
912bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
913bd0c5661Spbrook#error bork
914bd0c5661Spbrook#endif
915bd0c5661Spbrook}
916bd0c5661SpbrookEOF
917bd0c5661Spbrook
91852166aa0SJuan Quintela  if compile_object ; then
919b0a47e79SJuan Quintela    nptl=yes
920bd0c5661Spbrook  else
921b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
922b0a47e79SJuan Quintela      feature_not_found "nptl"
923b0a47e79SJuan Quintela    fi
924b0a47e79SJuan Quintela    nptl=no
925b0a47e79SJuan Quintela  fi
926bd0c5661Spbrookfi
927bd0c5661Spbrook
92811d9f695Sbellard##########################################
929ac62922eSbalrog# zlib check
930ac62922eSbalrog
931ac62922eSbalrogcat > $TMPC << EOF
932ac62922eSbalrog#include <zlib.h>
933ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
934ac62922eSbalrogEOF
93552166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
936ac62922eSbalrog    :
937ac62922eSbalrogelse
938ac62922eSbalrog    echo
939ac62922eSbalrog    echo "Error: zlib check failed"
940ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
941ac62922eSbalrog    echo
942ac62922eSbalrog    exit 1
943ac62922eSbalrogfi
944ac62922eSbalrog
945ac62922eSbalrog##########################################
946e37630caSaliguori# xen probe
947e37630caSaliguori
948fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
949b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
950e37630caSaliguori  cat > $TMPC <<EOF
951e37630caSaliguori#include <xenctrl.h>
952e37630caSaliguori#include <xs.h>
953df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
954e37630caSaliguoriEOF
95552166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
956fc321b4bSJuan Quintela    xen=yes
9573efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
958e37630caSaliguori  else
959fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
960fc321b4bSJuan Quintela      feature_not_found "xen"
961fc321b4bSJuan Quintela    fi
962fc321b4bSJuan Quintela    xen=no
963e37630caSaliguori  fi
964e37630caSaliguorifi
965e37630caSaliguori
966e37630caSaliguori##########################################
967dfffc653SJuan Quintela# Sparse probe
968dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
969dfffc653SJuan Quintela  if test -x "$(which cgcc 2>/dev/null)"; then
970dfffc653SJuan Quintela    sparse=yes
971dfffc653SJuan Quintela  else
972dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
973dfffc653SJuan Quintela      feature_not_found "sparse"
974dfffc653SJuan Quintela    fi
975dfffc653SJuan Quintela    sparse=no
976dfffc653SJuan Quintela  fi
977dfffc653SJuan Quintelafi
978dfffc653SJuan Quintela
979dfffc653SJuan Quintela##########################################
98011d9f695Sbellard# SDL probe
98111d9f695Sbellard
98211d9f695Sbellardsdl_too_old=no
98311d9f695Sbellard
984c4198157SJuan Quintelaif test "$sdl" != "no" ; then
98511d9f695Sbellard  cat > $TMPC << EOF
98611d9f695Sbellard#include <SDL.h>
98711d9f695Sbellard#undef main /* We don't want SDL to override our main() */
98811d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
98911d9f695SbellardEOF
9908ad3a7ddSJuan Quintela  sdl_cflags=`sdl-config --cflags 2> /dev/null`
9918ad3a7ddSJuan Quintela  sdl_libs=`sdl-config --libs 2> /dev/null`
99252166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
993d3d9738fSJuan Quintela    _sdlversion=`sdl-config --version | sed 's/[^0-9]//g'`
99411d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
99511d9f695Sbellard      sdl_too_old=yes
99611d9f695Sbellard    else
997fd677642Sths      if test "$cocoa" = "no" ; then
99811d9f695Sbellard        sdl=yes
99911d9f695Sbellard      fi
1000fd677642Sths    fi
10017c1f25b4Sbellard
10027c1f25b4Sbellard    # static link with sdl ?
10031ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
10041ac88f28SJuan Quintela      sdl_libs=`sdl-config --static-libs 2>/dev/null`
10051ac88f28SJuan Quintela      if test `sdl-config --static-libs 2>/dev/null | grep \\\-laa > /dev/null` ; then
10061ac88f28SJuan Quintela         sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
10071ac88f28SJuan Quintela         sdl_cflags="$sd_cflags `aalib-config --cflags >2 /dev/null`"
100811d9f695Sbellard      fi
100952166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
10101ac88f28SJuan Quintela	:
10111ac88f28SJuan Quintela      else
10121ac88f28SJuan Quintela        sdl=no
10137c1f25b4Sbellard      fi
10147c1f25b4Sbellard    fi # static link
1015c4198157SJuan Quintela  else # sdl not found
1016c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1017c4198157SJuan Quintela      feature_not_found "sdl"
1018c4198157SJuan Quintela    fi
1019c4198157SJuan Quintela    sdl=no
10207c1f25b4Sbellard  fi # sdl compile test
1021fd677642Sthsfi
102211d9f695Sbellard
10235368a422Saliguoriif test "$sdl" = "yes" ; then
10245368a422Saliguori  cat > $TMPC <<EOF
10255368a422Saliguori#include <SDL.h>
10265368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
10275368a422Saliguori#include <X11/XKBlib.h>
10285368a422Saliguori#else
10295368a422Saliguori#error No x11 support
10305368a422Saliguori#endif
10315368a422Saliguoriint main(void) { return 0; }
10325368a422SaliguoriEOF
103352166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1034681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
10355368a422Saliguori  fi
103607d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
103707d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
103807d9ac44SJuan Quintela  fi
10390705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
10405368a422Saliguorifi
10415368a422Saliguori
10428f28f3fbSths##########################################
10438d5d2d4cSths# VNC TLS detection
10441be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1045ae6b5e5aSaliguori  cat > $TMPC <<EOF
1046ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1047ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1048ae6b5e5aSaliguoriEOF
1049ae6b5e5aSaliguori  vnc_tls_cflags=`pkg-config --cflags gnutls 2> /dev/null`
1050ae6b5e5aSaliguori  vnc_tls_libs=`pkg-config --libs gnutls 2> /dev/null`
105152166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
10521be10ad2SJuan Quintela    vnc_tls=yes
1053a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1054ae6b5e5aSaliguori  else
10551be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
10561be10ad2SJuan Quintela      feature_not_found "vnc-tls"
10571be10ad2SJuan Quintela    fi
10581be10ad2SJuan Quintela    vnc_tls=no
10598d5d2d4cSths  fi
10608d5d2d4cSthsfi
10618d5d2d4cSths
10628d5d2d4cSths##########################################
10632f9606b3Saliguori# VNC SASL detection
10643aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
10652f9606b3Saliguori  cat > $TMPC <<EOF
10662f9606b3Saliguori#include <sasl/sasl.h>
10672f9606b3Saliguori#include <stdio.h>
10682f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
10692f9606b3SaliguoriEOF
10702f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
10712f9606b3Saliguori  vnc_sasl_cflags=""
10722f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
107352166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1074ea784e3bSJuan Quintela    vnc_sasl=yes
1075fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
10762f9606b3Saliguori  else
1077ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1078ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1079ea784e3bSJuan Quintela    fi
1080ea784e3bSJuan Quintela    vnc_sasl=no
10812f9606b3Saliguori  fi
10822f9606b3Saliguorifi
10832f9606b3Saliguori
10842f9606b3Saliguori##########################################
108576655d6dSaliguori# fnmatch() probe, used for ACL routines
108676655d6dSaliguorifnmatch="no"
108776655d6dSaliguoricat > $TMPC << EOF
108876655d6dSaliguori#include <fnmatch.h>
108976655d6dSaliguoriint main(void)
109076655d6dSaliguori{
109176655d6dSaliguori    fnmatch("foo", "foo", 0);
109276655d6dSaliguori    return 0;
109376655d6dSaliguori}
109476655d6dSaliguoriEOF
109552166aa0SJuan Quintelaif compile_prog "" "" ; then
109676655d6dSaliguori   fnmatch="yes"
109776655d6dSaliguorifi
109876655d6dSaliguori
109976655d6dSaliguori##########################################
1100ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1101ee682d27SStefan Weilif test "$uuid" != "no" ; then
1102ee682d27SStefan Weil  uuid_libs="-luuid"
1103ee682d27SStefan Weil  cat > $TMPC << EOF
1104ee682d27SStefan Weil#include <uuid/uuid.h>
1105ee682d27SStefan Weilint main(void)
1106ee682d27SStefan Weil{
1107ee682d27SStefan Weil    uuid_t my_uuid;
1108ee682d27SStefan Weil    uuid_generate(my_uuid);
1109ee682d27SStefan Weil    return 0;
1110ee682d27SStefan Weil}
1111ee682d27SStefan WeilEOF
1112ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1113ee682d27SStefan Weil    uuid="yes"
1114ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1115ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1116ee682d27SStefan Weil  else
1117ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1118ee682d27SStefan Weil      feature_not_found "uuid"
1119ee682d27SStefan Weil    fi
1120ee682d27SStefan Weil    uuid=no
1121ee682d27SStefan Weil  fi
1122ee682d27SStefan Weilfi
1123ee682d27SStefan Weil
1124ee682d27SStefan Weil##########################################
11258a16d273Sths# vde libraries probe
1126dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
11274baae0acSJuan Quintela  vde_libs="-lvdeplug"
11288a16d273Sths  cat > $TMPC << EOF
11298a16d273Sths#include <libvdeplug.h>
11304a7f0e06Spbrookint main(void)
11314a7f0e06Spbrook{
11324a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
11334a7f0e06Spbrook    vde_open("", "", &a);
11344a7f0e06Spbrook    return 0;
11354a7f0e06Spbrook}
11368a16d273SthsEOF
113752166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
11384baae0acSJuan Quintela    vde=yes
11398e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
11408e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1141dfb278bdSJuan Quintela  else
1142dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1143dfb278bdSJuan Quintela      feature_not_found "vde"
1144dfb278bdSJuan Quintela    fi
1145dfb278bdSJuan Quintela    vde=no
11468a16d273Sths  fi
11478a16d273Sthsfi
11488a16d273Sths
11498a16d273Sths##########################################
1150c2de5c91Smalc# Sound support libraries probe
11518f28f3fbSths
1152c2de5c91Smalcaudio_drv_probe()
1153c2de5c91Smalc{
1154c2de5c91Smalc    drv=$1
1155c2de5c91Smalc    hdr=$2
1156c2de5c91Smalc    lib=$3
1157c2de5c91Smalc    exp=$4
1158c2de5c91Smalc    cfl=$5
11598f28f3fbSths        cat > $TMPC << EOF
1160c2de5c91Smalc#include <$hdr>
1161c2de5c91Smalcint main(void) { $exp }
11628f28f3fbSthsEOF
116352166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
11648f28f3fbSths        :
11658f28f3fbSths    else
11668f28f3fbSths        echo
1167c2de5c91Smalc        echo "Error: $drv check failed"
1168c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
11698f28f3fbSths        echo
11708f28f3fbSths        exit 1
11718f28f3fbSths    fi
1172c2de5c91Smalc}
1173c2de5c91Smalc
11742fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1175c2de5c91Smalcfor drv in $audio_drv_list; do
1176c2de5c91Smalc    case $drv in
1177c2de5c91Smalc    alsa)
1178c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1179c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1180a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1181c2de5c91Smalc    ;;
1182c2de5c91Smalc
1183c2de5c91Smalc    fmod)
1184c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1185c2de5c91Smalc        echo
1186c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1187c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1188c2de5c91Smalc        echo
1189c2de5c91Smalc        exit 1
11908f28f3fbSths    fi
1191c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1192a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1193c2de5c91Smalc    ;;
1194c2de5c91Smalc
1195c2de5c91Smalc    esd)
1196c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1197a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
119867f86e8eSJuan Quintela    audio_pt_int="yes"
1199c2de5c91Smalc    ;;
1200b8e59f18Smalc
1201b8e59f18Smalc    pa)
1202493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1203b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1204493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
120567f86e8eSJuan Quintela    audio_pt_int="yes"
1206b8e59f18Smalc    ;;
1207b8e59f18Smalc
1208997e690aSJuan Quintela    coreaudio)
1209997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1210997e690aSJuan Quintela    ;;
1211997e690aSJuan Quintela
1212a4bf6780SJuan Quintela    dsound)
1213a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1214d5631638Smalc      audio_win_int="yes"
1215a4bf6780SJuan Quintela    ;;
1216a4bf6780SJuan Quintela
1217a4bf6780SJuan Quintela    oss)
1218a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1219a4bf6780SJuan Quintela    ;;
1220a4bf6780SJuan Quintela
1221a4bf6780SJuan Quintela    sdl|wav)
12222f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
12232f6a1ab0Sblueswir1    ;;
12242f6a1ab0Sblueswir1
1225d5631638Smalc    winwave)
1226d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1227d5631638Smalc      audio_win_int="yes"
1228d5631638Smalc    ;;
1229d5631638Smalc
1230e4c63a6aSmalc    *)
12311c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1232e4c63a6aSmalc        echo
1233e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1234e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1235e4c63a6aSmalc        echo
1236e4c63a6aSmalc        exit 1
1237e4c63a6aSmalc    }
1238e4c63a6aSmalc    ;;
1239c2de5c91Smalc    esac
1240c2de5c91Smalcdone
12418f28f3fbSths
12424d3b6f6eSbalrog##########################################
12432e4d9fb1Saurel32# BrlAPI probe
12442e4d9fb1Saurel32
12454ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1246eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
12472e4d9fb1Saurel32  cat > $TMPC << EOF
12482e4d9fb1Saurel32#include <brlapi.h>
12492e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
12502e4d9fb1Saurel32EOF
125152166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
12522e4d9fb1Saurel32    brlapi=yes
1253264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
12544ffcedb6SJuan Quintela  else
12554ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
12564ffcedb6SJuan Quintela      feature_not_found "brlapi"
12574ffcedb6SJuan Quintela    fi
12584ffcedb6SJuan Quintela    brlapi=no
1259eb82284fSJuan Quintela  fi
1260eb82284fSJuan Quintelafi
12612e4d9fb1Saurel32
12622e4d9fb1Saurel32##########################################
12634d3b6f6eSbalrog# curses probe
12644f78ef9aSJuan Quintelacurses_list="-lncurses -lcurses"
12654d3b6f6eSbalrog
1266c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1267c584a6d0SJuan Quintela  curses_found=no
12684d3b6f6eSbalrog  cat > $TMPC << EOF
12694d3b6f6eSbalrog#include <curses.h>
12705a8ff3aaSblueswir1#ifdef __OpenBSD__
12715a8ff3aaSblueswir1#define resize_term resizeterm
12725a8ff3aaSblueswir1#endif
12735a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
12744d3b6f6eSbalrogEOF
12754f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
12764f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1277c584a6d0SJuan Quintela      curses_found=yes
12784f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
12794f78ef9aSJuan Quintela      break
12804d3b6f6eSbalrog    fi
12814f78ef9aSJuan Quintela  done
1282c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1283c584a6d0SJuan Quintela    curses=yes
1284c584a6d0SJuan Quintela  else
1285c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1286c584a6d0SJuan Quintela      feature_not_found "curses"
1287c584a6d0SJuan Quintela    fi
1288c584a6d0SJuan Quintela    curses=no
1289c584a6d0SJuan Quintela  fi
12904f78ef9aSJuan Quintelafi
12914d3b6f6eSbalrog
1292414f0dabSblueswir1##########################################
1293769ce76dSAlexander Graf# curl probe
1294769ce76dSAlexander Graf
1295788c8196SJuan Quintelaif test "$curl" != "no" ; then
1296769ce76dSAlexander Graf  cat > $TMPC << EOF
1297769ce76dSAlexander Graf#include <curl/curl.h>
1298769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1299769ce76dSAlexander GrafEOF
1300b1d5a277SJuan Quintela  curl_cflags=`curl-config --cflags 2>/dev/null`
130152368552SPaul Brook  curl_libs=`curl-config --libs 2>/dev/null`
1302b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1303769ce76dSAlexander Graf    curl=yes
1304f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1305f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1306788c8196SJuan Quintela  else
1307788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1308788c8196SJuan Quintela      feature_not_found "curl"
1309788c8196SJuan Quintela    fi
1310788c8196SJuan Quintela    curl=no
1311769ce76dSAlexander Graf  fi
1312769ce76dSAlexander Graffi # test "$curl"
1313769ce76dSAlexander Graf
1314769ce76dSAlexander Graf##########################################
13155495ed11SLuiz Capitulino# check framework probe
13165495ed11SLuiz Capitulino
13175495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
13185495ed11SLuiz Capitulino  cat > $TMPC << EOF
13195495ed11SLuiz Capitulino#include <check.h>
13205495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
13215495ed11SLuiz CapitulinoEOF
13225495ed11SLuiz Capitulino  check_libs=`pkg-config --libs check`
13235495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
13245495ed11SLuiz Capitulino    check_utests=yes
13255495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
13265495ed11SLuiz Capitulino  else
13275495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
13285495ed11SLuiz Capitulino      feature_not_found "check"
13295495ed11SLuiz Capitulino    fi
13305495ed11SLuiz Capitulino    check_utests=no
13315495ed11SLuiz Capitulino  fi
13325495ed11SLuiz Capitulinofi # test "$check_utests"
13335495ed11SLuiz Capitulino
13345495ed11SLuiz Capitulino##########################################
1335fb599c9aSbalrog# bluez support probe
1336a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1337e820e3f4Sbalrog  cat > $TMPC << EOF
1338e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1339e820e3f4Sbalrogint main(void) { return bt_error(0); }
1340e820e3f4SbalrogEOF
1341efcfd0c5SBlue Swirl  bluez_cflags=`pkg-config --cflags bluez 2> /dev/null`
1342efcfd0c5SBlue Swirl  bluez_libs=`pkg-config --libs bluez 2> /dev/null`
134352166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1344a20a6f46SJuan Quintela    bluez=yes
1345e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1346e820e3f4Sbalrog  else
1347a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1348a20a6f46SJuan Quintela      feature_not_found "bluez"
1349a20a6f46SJuan Quintela    fi
1350e820e3f4Sbalrog    bluez="no"
1351e820e3f4Sbalrog  fi
1352fb599c9aSbalrogfi
1353fb599c9aSbalrog
1354fb599c9aSbalrog##########################################
13557ba1e619Saliguori# kvm probe
1356b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
13577ba1e619Saliguori    cat > $TMPC <<EOF
13587ba1e619Saliguori#include <linux/kvm.h>
13599fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
13607ba1e619Saliguori#error Invalid KVM version
13617ba1e619Saliguori#endif
13629fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
13639fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
13649fd8d8d7Saliguori#endif
13659fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
13669fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
13679fd8d8d7Saliguori#endif
13689fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
13699fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
13709fd8d8d7Saliguori#endif
13717ba1e619Saliguoriint main(void) { return 0; }
13727ba1e619SaliguoriEOF
1373eac30262Saliguori  if test "$kerneldir" != "" ; then
1374eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
13758444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
13768444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
13778444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1378406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1379406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
13808444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
13818444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
13828444eb6eSaliguori      fi
1383eac30262Saliguori  else
1384eac30262Saliguori      kvm_cflags=""
1385eac30262Saliguori  fi
138652166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1387b31a0277SJuan Quintela    kvm=yes
13887ba1e619Saliguori  else
1389b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
13909fd8d8d7Saliguori      if [ -x "`which awk 2>/dev/null`" ] && \
13919fd8d8d7Saliguori         [ -x "`which grep 2>/dev/null`" ]; then
1392a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
13939fd8d8d7Saliguori	| grep "error: " \
13949fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
13959fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1396b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1397168ccc11SJan Kiszka      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1398168ccc11SJan Kiszka  recent kvm-kmod from http://sourceforge.net/projects/kvm."
13999fd8d8d7Saliguori        fi
14009fd8d8d7Saliguori      fi
1401b31a0277SJuan Quintela      feature_not_found "kvm"
1402b31a0277SJuan Quintela    fi
1403b31a0277SJuan Quintela    kvm=no
14047ba1e619Saliguori  fi
14057ba1e619Saliguorifi
14067ba1e619Saliguori
14077ba1e619Saliguori##########################################
1408e5d355d1Saliguori# pthread probe
1409de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
14103c529d93Saliguori
1411e5d355d1Saliguoripthread=no
1412414f0dabSblueswir1cat > $TMPC << EOF
14133c529d93Saliguori#include <pthread.h>
1414de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1415414f0dabSblueswir1EOF
1416de65fe0fSSebastian Herbsztfor pthread_lib in $PTHREADLIBS_LIST; do
141752166aa0SJuan Quintela  if compile_prog "" "$pthread_lib" ; then
1418e5d355d1Saliguori    pthread=yes
14195572b539SJuan Quintela    LIBS="$pthread_lib $LIBS"
1420de65fe0fSSebastian Herbszt    break
1421414f0dabSblueswir1  fi
1422de65fe0fSSebastian Herbsztdone
1423414f0dabSblueswir1
14244617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
14254dd75c70SChristoph Hellwig  echo
14264dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
14274dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
14284dd75c70SChristoph Hellwig  echo
14294dd75c70SChristoph Hellwig  exit 1
1430e5d355d1Saliguorifi
1431e5d355d1Saliguori
1432bf9298b9Saliguori##########################################
14335c6c3a6cSChristoph Hellwig# linux-aio probe
14345c6c3a6cSChristoph Hellwig
14355c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
14365c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
14375c6c3a6cSChristoph Hellwig#include <libaio.h>
14385c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
14395c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
14405c6c3a6cSChristoph HellwigEOF
14415c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
14425c6c3a6cSChristoph Hellwig    linux_aio=yes
14435c6c3a6cSChristoph Hellwig    LIBS="$LIBS -laio"
14445c6c3a6cSChristoph Hellwig  else
14455c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
14465c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
14475c6c3a6cSChristoph Hellwig    fi
14483cfcae3cSLuiz Capitulino    linux_aio=no
14495c6c3a6cSChristoph Hellwig  fi
14505c6c3a6cSChristoph Hellwigfi
14515c6c3a6cSChristoph Hellwig
14525c6c3a6cSChristoph Hellwig##########################################
1453bf9298b9Saliguori# iovec probe
1454bf9298b9Saliguoricat > $TMPC <<EOF
1455db34f0b3Sblueswir1#include <sys/types.h>
1456bf9298b9Saliguori#include <sys/uio.h>
1457db34f0b3Sblueswir1#include <unistd.h>
1458bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1459bf9298b9SaliguoriEOF
1460bf9298b9Saliguoriiovec=no
146152166aa0SJuan Quintelaif compile_prog "" "" ; then
1462bf9298b9Saliguori  iovec=yes
1463bf9298b9Saliguorifi
1464bf9298b9Saliguori
1465f652e6afSaurel32##########################################
1466ceb42de8Saliguori# preadv probe
1467ceb42de8Saliguoricat > $TMPC <<EOF
1468ceb42de8Saliguori#include <sys/types.h>
1469ceb42de8Saliguori#include <sys/uio.h>
1470ceb42de8Saliguori#include <unistd.h>
1471ceb42de8Saliguoriint main(void) { preadv; }
1472ceb42de8SaliguoriEOF
1473ceb42de8Saliguoripreadv=no
147452166aa0SJuan Quintelaif compile_prog "" "" ; then
1475ceb42de8Saliguori  preadv=yes
1476ceb42de8Saliguorifi
1477ceb42de8Saliguori
1478ceb42de8Saliguori##########################################
1479f652e6afSaurel32# fdt probe
14802df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1481b41af4baSJuan Quintela  fdt_libs="-lfdt"
1482f652e6afSaurel32  cat > $TMPC << EOF
1483f652e6afSaurel32int main(void) { return 0; }
1484f652e6afSaurel32EOF
148552166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1486f652e6afSaurel32    fdt=yes
1487e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
14882df87df7SJuan Quintela  else
14892df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
14902df87df7SJuan Quintela      feature_not_found "fdt"
14912df87df7SJuan Quintela    fi
14922df87df7SJuan Quintela    fdt=no
1493f652e6afSaurel32  fi
1494f652e6afSaurel32fi
1495f652e6afSaurel32
14963b3f24adSaurel32#
14973b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
14983b3f24adSaurel32# emulator.  This is done because older glibc versions don't
14993b3f24adSaurel32# have syscall stubs for these implemented.
15003b3f24adSaurel32#
15013b3f24adSaurel32atfile=no
15023b3f24adSaurel32cat > $TMPC << EOF
15033b3f24adSaurel32#define _ATFILE_SOURCE
15043b3f24adSaurel32#include <sys/types.h>
15053b3f24adSaurel32#include <fcntl.h>
15063b3f24adSaurel32#include <unistd.h>
15073b3f24adSaurel32
15083b3f24adSaurel32int
15093b3f24adSaurel32main(void)
15103b3f24adSaurel32{
15113b3f24adSaurel32	/* try to unlink nonexisting file */
15123b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
15133b3f24adSaurel32}
15143b3f24adSaurel32EOF
151552166aa0SJuan Quintelaif compile_prog "" "" ; then
15163b3f24adSaurel32  atfile=yes
15173b3f24adSaurel32fi
15183b3f24adSaurel32
151939386ac7Saurel32# Check for inotify functions when we are building linux-user
15203b3f24adSaurel32# emulator.  This is done because older glibc versions don't
15213b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
15223b3f24adSaurel32# don't provide them even if kernel supports them.
15233b3f24adSaurel32#
15243b3f24adSaurel32inotify=no
15253b3f24adSaurel32cat > $TMPC << EOF
15263b3f24adSaurel32#include <sys/inotify.h>
15273b3f24adSaurel32
15283b3f24adSaurel32int
15293b3f24adSaurel32main(void)
15303b3f24adSaurel32{
15313b3f24adSaurel32	/* try to start inotify */
15328690e420Saurel32	return inotify_init();
15333b3f24adSaurel32}
15343b3f24adSaurel32EOF
153552166aa0SJuan Quintelaif compile_prog "" "" ; then
15363b3f24adSaurel32  inotify=yes
15373b3f24adSaurel32fi
15383b3f24adSaurel32
1539ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1540ebc996f3SRiku Voipioutimens=no
1541ebc996f3SRiku Voipiocat > $TMPC << EOF
1542ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1543ebc996f3SRiku Voipio#define _GNU_SOURCE
1544ebc996f3SRiku Voipio#include <stddef.h>
1545ebc996f3SRiku Voipio#include <fcntl.h>
1546ebc996f3SRiku Voipio
1547ebc996f3SRiku Voipioint main(void)
1548ebc996f3SRiku Voipio{
1549ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1550ebc996f3SRiku Voipio    futimens(0, NULL);
1551ebc996f3SRiku Voipio    return 0;
1552ebc996f3SRiku Voipio}
1553ebc996f3SRiku VoipioEOF
155452166aa0SJuan Quintelaif compile_prog "" "" ; then
1555ebc996f3SRiku Voipio  utimens=yes
1556ebc996f3SRiku Voipiofi
1557ebc996f3SRiku Voipio
1558099d6b0fSRiku Voipio# check if pipe2 is there
1559099d6b0fSRiku Voipiopipe2=no
1560099d6b0fSRiku Voipiocat > $TMPC << EOF
1561099d6b0fSRiku Voipio#define _GNU_SOURCE
1562099d6b0fSRiku Voipio#include <unistd.h>
1563099d6b0fSRiku Voipio#include <fcntl.h>
1564099d6b0fSRiku Voipio
1565099d6b0fSRiku Voipioint main(void)
1566099d6b0fSRiku Voipio{
1567099d6b0fSRiku Voipio    int pipefd[2];
1568099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1569099d6b0fSRiku Voipio    return 0;
1570099d6b0fSRiku Voipio}
1571099d6b0fSRiku VoipioEOF
157252166aa0SJuan Quintelaif compile_prog "" "" ; then
1573099d6b0fSRiku Voipio  pipe2=yes
1574099d6b0fSRiku Voipiofi
1575099d6b0fSRiku Voipio
157640ff6d7eSKevin Wolf# check if accept4 is there
157740ff6d7eSKevin Wolfaccept4=no
157840ff6d7eSKevin Wolfcat > $TMPC << EOF
157940ff6d7eSKevin Wolf#define _GNU_SOURCE
158040ff6d7eSKevin Wolf#include <sys/socket.h>
158140ff6d7eSKevin Wolf#include <stddef.h>
158240ff6d7eSKevin Wolf
158340ff6d7eSKevin Wolfint main(void)
158440ff6d7eSKevin Wolf{
158540ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
158640ff6d7eSKevin Wolf    return 0;
158740ff6d7eSKevin Wolf}
158840ff6d7eSKevin WolfEOF
158940ff6d7eSKevin Wolfif compile_prog "" "" ; then
159040ff6d7eSKevin Wolf  accept4=yes
159140ff6d7eSKevin Wolffi
159240ff6d7eSKevin Wolf
15933ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
15943ce34dfbSvibisreenivasansplice=no
15953ce34dfbSvibisreenivasancat > $TMPC << EOF
15963ce34dfbSvibisreenivasan#define _GNU_SOURCE
15973ce34dfbSvibisreenivasan#include <unistd.h>
15983ce34dfbSvibisreenivasan#include <fcntl.h>
15993ce34dfbSvibisreenivasan#include <limits.h>
16003ce34dfbSvibisreenivasan
16013ce34dfbSvibisreenivasanint main(void)
16023ce34dfbSvibisreenivasan{
16033ce34dfbSvibisreenivasan    int len, fd;
16043ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
16053ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
16063ce34dfbSvibisreenivasan    return 0;
16073ce34dfbSvibisreenivasan}
16083ce34dfbSvibisreenivasanEOF
160952166aa0SJuan Quintelaif compile_prog "" "" ; then
16103ce34dfbSvibisreenivasan  splice=yes
16113ce34dfbSvibisreenivasanfi
16123ce34dfbSvibisreenivasan
1613c2882b96SRiku Voipio# check if eventfd is supported
1614c2882b96SRiku Voipioeventfd=no
1615c2882b96SRiku Voipiocat > $TMPC << EOF
1616c2882b96SRiku Voipio#include <sys/eventfd.h>
1617c2882b96SRiku Voipio
1618c2882b96SRiku Voipioint main(void)
1619c2882b96SRiku Voipio{
1620c2882b96SRiku Voipio    int efd = eventfd(0, 0);
1621c2882b96SRiku Voipio    return 0;
1622c2882b96SRiku Voipio}
1623c2882b96SRiku VoipioEOF
1624c2882b96SRiku Voipioif compile_prog "" "" ; then
1625c2882b96SRiku Voipio  eventfd=yes
1626c2882b96SRiku Voipiofi
1627c2882b96SRiku Voipio
1628d0927938SUlrich Hecht# check for fallocate
1629d0927938SUlrich Hechtfallocate=no
1630d0927938SUlrich Hechtcat > $TMPC << EOF
1631d0927938SUlrich Hecht#include <fcntl.h>
1632d0927938SUlrich Hecht
1633d0927938SUlrich Hechtint main(void)
1634d0927938SUlrich Hecht{
1635d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
1636d0927938SUlrich Hecht    return 0;
1637d0927938SUlrich Hecht}
1638d0927938SUlrich HechtEOF
1639be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
1640d0927938SUlrich Hecht  fallocate=yes
1641d0927938SUlrich Hechtfi
1642d0927938SUlrich Hecht
1643d0927938SUlrich Hecht# check for dup3
1644d0927938SUlrich Hechtdup3=no
1645d0927938SUlrich Hechtcat > $TMPC << EOF
1646d0927938SUlrich Hecht#include <unistd.h>
1647d0927938SUlrich Hecht
1648d0927938SUlrich Hechtint main(void)
1649d0927938SUlrich Hecht{
1650d0927938SUlrich Hecht    dup3(0, 0, 0);
1651d0927938SUlrich Hecht    return 0;
1652d0927938SUlrich Hecht}
1653d0927938SUlrich HechtEOF
165478f5d726SJan Kiszkaif compile_prog "" "" ; then
1655d0927938SUlrich Hecht  dup3=yes
1656d0927938SUlrich Hechtfi
1657d0927938SUlrich Hecht
1658cc8ae6deSpbrook# Check if tools are available to build documentation.
1659a25dba17SJuan Quintelaif test "$docs" != "no" ; then
166083a3ab8bSJuan Quintela  if test -x "`which texi2html 2>/dev/null`" -a \
166183a3ab8bSJuan Quintela          -x "`which pod2man 2>/dev/null`" ; then
1662a25dba17SJuan Quintela    docs=yes
166383a3ab8bSJuan Quintela  else
1664a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
1665a25dba17SJuan Quintela      feature_not_found "docs"
166683a3ab8bSJuan Quintela    fi
1667a25dba17SJuan Quintela    docs=no
166883a3ab8bSJuan Quintela  fi
1669cc8ae6deSpbrookfi
1670cc8ae6deSpbrook
1671f514f41cSStefan Weil# Search for bswap_32 function
16726ae9a1f4SJuan Quintelabyteswap_h=no
16736ae9a1f4SJuan Quintelacat > $TMPC << EOF
16746ae9a1f4SJuan Quintela#include <byteswap.h>
16756ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
16766ae9a1f4SJuan QuintelaEOF
167752166aa0SJuan Quintelaif compile_prog "" "" ; then
16786ae9a1f4SJuan Quintela  byteswap_h=yes
16796ae9a1f4SJuan Quintelafi
16806ae9a1f4SJuan Quintela
1681f514f41cSStefan Weil# Search for bswap_32 function
16826ae9a1f4SJuan Quintelabswap_h=no
16836ae9a1f4SJuan Quintelacat > $TMPC << EOF
16846ae9a1f4SJuan Quintela#include <sys/endian.h>
16856ae9a1f4SJuan Quintela#include <sys/types.h>
16866ae9a1f4SJuan Quintela#include <machine/bswap.h>
16876ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
16886ae9a1f4SJuan QuintelaEOF
168952166aa0SJuan Quintelaif compile_prog "" "" ; then
16906ae9a1f4SJuan Quintela  bswap_h=yes
16916ae9a1f4SJuan Quintelafi
16926ae9a1f4SJuan Quintela
1693da93a1fdSaliguori##########################################
1694da93a1fdSaliguori# Do we need librt
1695da93a1fdSaliguoricat > $TMPC <<EOF
1696da93a1fdSaliguori#include <signal.h>
1697da93a1fdSaliguori#include <time.h>
1698da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
1699da93a1fdSaliguoriEOF
1700da93a1fdSaliguori
170152166aa0SJuan Quintelaif compile_prog "" "" ; then
170207ffa4bdSJuan Quintela  :
170352166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
170407ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
1705da93a1fdSaliguorifi
1706da93a1fdSaliguori
1707a36abbbbSJuan Quintela# Determine what linker flags to use to force archive inclusion
1708a36abbbbSJuan Quintelacheck_linker_flags()
1709a36abbbbSJuan Quintela{
1710a36abbbbSJuan Quintela    w2=
1711a36abbbbSJuan Quintela    if test "$2" ; then
1712a36abbbbSJuan Quintela	w2=-Wl,$2
1713a36abbbbSJuan Quintela    fi
171452166aa0SJuan Quintela    compile_prog "" "-Wl,$1 ${w2}"
1715a36abbbbSJuan Quintela}
1716a36abbbbSJuan Quintela
1717a36abbbbSJuan Quintelacat > $TMPC << EOF
1718a36abbbbSJuan Quintelaint main(void) { }
1719a36abbbbSJuan QuintelaEOF
1720a36abbbbSJuan Quintelaif check_linker_flags --whole-archive --no-whole-archive ; then
1721a36abbbbSJuan Quintela    # GNU ld
1722a36abbbbSJuan Quintela    arlibs_begin="-Wl,--whole-archive"
1723a36abbbbSJuan Quintela    arlibs_end="-Wl,--no-whole-archive"
1724a36abbbbSJuan Quintelaelif check_linker_flags -z,allextract -z,defaultextract ; then
1725a36abbbbSJuan Quintela    # Solaris ld
172631ff504dSBlue Swirl    arlibs_begin="-Wl,-z,allextract"
1727a36abbbbSJuan Quintela    arlibs_end="-Wl,-z,defaultextract"
1728a36abbbbSJuan Quintelaelif check_linker_flags -all_load ; then
1729a36abbbbSJuan Quintela    # Mac OS X
1730a36abbbbSJuan Quintela    arlibs_begin="-all_load"
1731a36abbbbSJuan Quintela    arlibs_end=""
1732a36abbbbSJuan Quintelaelse
1733a36abbbbSJuan Quintela    echo "Error: your linker does not support --whole-archive or -z."
1734a36abbbbSJuan Quintela    echo "Please report to qemu-devel@nongnu.org"
1735a36abbbbSJuan Quintela    exit 1
1736a36abbbbSJuan Quintelafi
1737a36abbbbSJuan Quintela
173831ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
17396362a53fSJuan Quintela        "$aix" != "yes" ; then
17406362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
17416362a53fSJuan Quintelafi
17426362a53fSJuan Quintela
1743de5071c5SBlue Swirl##########################################
1744de5071c5SBlue Swirl# check if the compiler defines offsetof
1745de5071c5SBlue Swirl
1746de5071c5SBlue Swirlneed_offsetof=yes
1747de5071c5SBlue Swirlcat > $TMPC << EOF
1748de5071c5SBlue Swirl#include <stddef.h>
1749de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
1750de5071c5SBlue SwirlEOF
1751de5071c5SBlue Swirlif compile_prog "" "" ; then
1752de5071c5SBlue Swirl    need_offsetof=no
1753de5071c5SBlue Swirlfi
1754de5071c5SBlue Swirl
17555f6b9e8fSBlue Swirl##########################################
1756747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
1757747bbdf7SBlue Swirl#
1758747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
1759747bbdf7SBlue Swirl# about attribute warn_unused_result
1760747bbdf7SBlue Swirl
1761747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
1762747bbdf7SBlue Swirlcat > $TMPC << EOF
1763747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
1764747bbdf7SBlue Swirl#error gcc 3.3 or older
1765747bbdf7SBlue Swirl#endif
1766747bbdf7SBlue Swirlint main(void) { return 0;}
1767747bbdf7SBlue SwirlEOF
1768747bbdf7SBlue Swirlif compile_prog "" ""; then
1769747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
1770747bbdf7SBlue Swirlfi
1771747bbdf7SBlue Swirl
1772747bbdf7SBlue Swirl##########################################
17735f6b9e8fSBlue Swirl# check if we have fdatasync
17745f6b9e8fSBlue Swirl
17755f6b9e8fSBlue Swirlfdatasync=no
17765f6b9e8fSBlue Swirlcat > $TMPC << EOF
17775f6b9e8fSBlue Swirl#include <unistd.h>
17785f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
17795f6b9e8fSBlue SwirlEOF
17805f6b9e8fSBlue Swirlif compile_prog "" "" ; then
17815f6b9e8fSBlue Swirl    fdatasync=yes
17825f6b9e8fSBlue Swirlfi
17835f6b9e8fSBlue Swirl
1784e86ecd4bSJuan Quintela# End of CC checks
1785e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
1786e86ecd4bSJuan Quintela
1787e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
17881156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
1789e86ecd4bSJuan Quintelafi
1790a316e378SJuan Quintela
1791e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
1792e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
1793e86ecd4bSJuan Quintelaif test -z "$werror" ; then
1794e86ecd4bSJuan Quintela    z_version=`cut -f3 -d. $source_path/VERSION`
1795e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
1796e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
1797e86ecd4bSJuan Quintela        werror="yes"
1798e86ecd4bSJuan Quintela    else
1799e86ecd4bSJuan Quintela        werror="no"
1800e86ecd4bSJuan Quintela    fi
1801e86ecd4bSJuan Quintelafi
1802e86ecd4bSJuan Quintela
1803e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
1804a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1805e86ecd4bSJuan Quintelafi
1806e86ecd4bSJuan Quintela
1807e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
1808e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
18091156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
1810e86ecd4bSJuan Quintela    fi
1811e86ecd4bSJuan Quintelafi
1812e86ecd4bSJuan Quintela
181311d9f695Sbellardif test "$mingw32" = "yes" ; then
181411d9f695Sbellard  if test -z "$prefix" ; then
181555418b96SStefan Weil      prefix="c:/Program Files/Qemu"
181611d9f695Sbellard  fi
1817308c3593Spbrook  mansuffix=""
1818308c3593Spbrook  datasuffix=""
1819308c3593Spbrook  docsuffix=""
1820308c3593Spbrook  binsuffix=""
182111d9f695Sbellardelse
182211d9f695Sbellard  if test -z "$prefix" ; then
182311d9f695Sbellard      prefix="/usr/local"
182411d9f695Sbellard  fi
1825308c3593Spbrook  mansuffix="/share/man"
1826308c3593Spbrook  datasuffix="/share/qemu"
1827308c3593Spbrook  docsuffix="/share/doc/qemu"
1828308c3593Spbrook  binsuffix="/bin"
182911d9f695Sbellardfi
18305a67135aSbellard
18317d13299dSbellardecho "Install prefix    $prefix"
1832308c3593Spbrookecho "BIOS directory    $prefix$datasuffix"
1833308c3593Spbrookecho "binary directory  $prefix$binsuffix"
183411d9f695Sbellardif test "$mingw32" = "no" ; then
1835308c3593Spbrookecho "Manual directory  $prefix$mansuffix"
183643ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
183711d9f695Sbellardfi
18385a67135aSbellardecho "Source path       $source_path"
18397d13299dSbellardecho "C compiler        $cc"
184083469015Sbellardecho "Host C compiler   $host_cc"
18410c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
1842a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
18430c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
18447d13299dSbellardecho "make              $make"
18456a882643Spbrookecho "install           $install"
1846a98fd896Sbellardecho "host CPU          $cpu"
1847de83cd02Sbellardecho "host big endian   $bigendian"
184897a847bcSbellardecho "target list       $target_list"
1849ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
18507d13299dSbellardecho "gprof enabled     $gprof"
185103b4fe7dSaliguoriecho "sparse enabled    $sparse"
18521625af87Saliguoriecho "strip binaries    $strip_opt"
185305c2a3e7Sbellardecho "profiler          $profiler"
185443ce4dfeSbellardecho "static build      $static"
185585aa5189Sbellardecho "-Werror enabled   $werror"
18565b0753e0Sbellardif test "$darwin" = "yes" ; then
18575b0753e0Sbellard    echo "Cocoa support     $cocoa"
18585b0753e0Sbellardfi
185997a847bcSbellardecho "SDL support       $sdl"
18604d3b6f6eSbalrogecho "curses support    $curses"
1861769ce76dSAlexander Grafecho "curl support      $curl"
18625495ed11SLuiz Capitulinoecho "check support     $check_utests"
186367b915a5Sbellardecho "mingw32 support   $mingw32"
18640c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
18650c58ac1cSmalcecho "Extra audio cards $audio_card_list"
1866eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
18678ff9cbf7Smalcecho "Mixer emulation   $mixemu"
18688d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
18692f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
18703142255cSblueswir1if test -n "$sparc_cpu"; then
18713142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
18723142255cSblueswir1fi
1873e37630caSaliguoriecho "xen support       $xen"
18742e4d9fb1Saurel32echo "brlapi support    $brlapi"
1875a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
1876a25dba17SJuan Quintelaecho "Documentation     $docs"
1877c5937220Spbrook[ ! -z "$uname_release" ] && \
1878c5937220Spbrookecho "uname -r          $uname_release"
1879bd0c5661Spbrookecho "NPTL support      $nptl"
1880379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
188134005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
18828a16d273Sthsecho "vde support       $vde"
1883e5d355d1Saliguoriecho "IO thread         $io_thread"
18845c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
188577755340Sthsecho "Install blobs     $blobs"
1886b31a0277SJuan Quintelaecho "KVM support       $kvm"
1887f652e6afSaurel32echo "fdt support       $fdt"
1888ceb42de8Saliguoriecho "preadv support    $preadv"
18895f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
1890ee682d27SStefan Weilecho "uuid support      $uuid"
189167b915a5Sbellard
189297a847bcSbellardif test $sdl_too_old = "yes"; then
189324b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
1894e8cd23deSbellardfi
189597a847bcSbellard
189698ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
18974bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
189897a847bcSbellard
189998ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
190098ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
190198ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
190298ec69acSJuan Quintelaecho >> $config_host_mak
190398ec69acSJuan Quintela
19042358a494SJuan Quintelaecho "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1905804edf29SJuan Quintela
19062408a527Saurel32case "$cpu" in
1907*24e804ecSAlexander Graf  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1908e0da9dd3SJuan Quintela    ARCH=$cpu
19092408a527Saurel32  ;;
1910a302c32dSLaurent Desnogues  armv4b|armv4l)
191116dbd14fSJuan Quintela    ARCH=arm
19122408a527Saurel32  ;;
19132408a527Saurel32  *)
19143142255cSblueswir1    echo "Unsupported CPU = $cpu"
19157d13299dSbellard    exit 1
19162408a527Saurel32  ;;
19172408a527Saurel32esac
191898ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
1919f8393946Saurel32if test "$debug_tcg" = "yes" ; then
19202358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1921f8393946Saurel32fi
1922f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
19232358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1924f3d08ee6SPaul Brookfi
19251625af87Saliguoriif test "$strip_opt" = "yes" ; then
192698ec69acSJuan Quintela  echo "STRIP_OPT=-s" >> $config_host_mak
19271625af87Saliguorifi
19287d13299dSbellardif test "$bigendian" = "yes" ; then
1929e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
193097a847bcSbellardfi
19312358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
193267b915a5Sbellardif test "$mingw32" = "yes" ; then
193398ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
1934210fa556Spbrookelse
193535f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
1936210fa556Spbrookfi
1937128ab2ffSblueswir1
1938dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
1939dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
1940dffcb71cSMark McLoughlinfi
1941dffcb71cSMark McLoughlin
194283fb7adfSbellardif test "$darwin" = "yes" ; then
194398ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
194483fb7adfSbellardfi
1945b29fe3edSmalc
1946b29fe3edSmalcif test "$aix" = "yes" ; then
194798ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
1948b29fe3edSmalcfi
1949b29fe3edSmalc
1950ec530c81Sbellardif test "$solaris" = "yes" ; then
195198ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
19522358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
19530475a5caSths  if test "$needs_libsunmath" = "yes" ; then
195475b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
19550475a5caSths  fi
1956ec530c81Sbellardfi
195797a847bcSbellardif test "$static" = "yes" ; then
195898ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
19591156c669SJuan Quintela  LDFLAGS="-static $LDFLAGS"
196097a847bcSbellardfi
196105c2a3e7Sbellardif test $profiler = "yes" ; then
19622358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
196305c2a3e7Sbellardfi
1964c20709aaSbellardif test "$slirp" = "yes" ; then
196598ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
1966b6e31c12SJuan Quintela  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
1967c20709aaSbellardfi
19688a16d273Sthsif test "$vde" = "yes" ; then
196998ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
19708a16d273Sthsfi
19710c58ac1cSmalcfor card in $audio_card_list; do
1972f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
197398ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
19740c58ac1cSmalcdone
19752358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
19760c58ac1cSmalcfor drv in $audio_drv_list; do
1977f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
197898ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
1979923e4521Smalc    if test "$drv" = "fmod"; then
19807aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1981fb065187Sbellard    fi
19820c58ac1cSmalcdone
198367f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
198467f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
198567f86e8eSJuan Quintelafi
1986d5631638Smalcif test "$audio_win_int" = "yes" ; then
1987d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
1988d5631638Smalcfi
1989eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
19908ff9cbf7Smalcif test "$mixemu" = "yes" ; then
199198ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
19928ff9cbf7Smalcfi
19938d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
199498ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
1995525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
19968d5d2d4cSthsfi
19972f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
199898ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
199960ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
20002f9606b3Saliguorifi
200176655d6dSaliguoriif test "$fnmatch" = "yes" ; then
20022358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
200376655d6dSaliguorifi
2004ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2005ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2006ee682d27SStefan Weilfi
2007b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
200898ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
20092358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
201098ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
2011ad064840Spbrookif [ "$source_path_used" = "yes" ]; then
201298ec69acSJuan Quintela  echo "VPATH=$source_path" >> $config_host_mak
2013ad064840Spbrookfi
201498ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2015a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
201698ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2017cc8ae6deSpbrookfi
20181ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
201998ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
20208ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
202149ecc3faSbellardfi
202249ecc3faSbellardif test "$cocoa" = "yes" ; then
202398ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
202449ecc3faSbellardfi
20254d3b6f6eSbalrogif test "$curses" = "yes" ; then
202698ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2027ab4e5602SJan Kiszkafi
20283b3f24adSaurel32if test "$atfile" = "yes" ; then
20292358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
20303b3f24adSaurel32fi
2031ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
20322358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2033ebc996f3SRiku Voipiofi
2034099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
20352358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2036099d6b0fSRiku Voipiofi
203740ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
203840ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
203940ff6d7eSKevin Wolffi
20403ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
20412358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
20423ce34dfbSvibisreenivasanfi
2043c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2044c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2045c2882b96SRiku Voipiofi
2046d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2047d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2048d0927938SUlrich Hechtfi
2049d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2050d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2051d0927938SUlrich Hechtfi
20523b3f24adSaurel32if test "$inotify" = "yes" ; then
20532358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
20543b3f24adSaurel32fi
20556ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
20566ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
20576ae9a1f4SJuan Quintelafi
20586ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
20596ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
20606ae9a1f4SJuan Quintelafi
2061769ce76dSAlexander Grafif test "$curl" = "yes" ; then
206298ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2063b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2064769ce76dSAlexander Graffi
20652e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
206698ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
20672e4d9fb1Saurel32fi
2068fb599c9aSbalrogif test "$bluez" = "yes" ; then
206998ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2070ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2071fb599c9aSbalrogfi
2072e37630caSaliguoriif test "$xen" = "yes" ; then
20735647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2074e37630caSaliguorifi
2075e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
207698ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2077e5d355d1Saliguorifi
20785c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
20795c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
20805c6c3a6cSChristoph Hellwigfi
208177755340Sthsif test "$blobs" = "yes" ; then
208298ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
208377755340Sthsfi
2084bf9298b9Saliguoriif test "$iovec" = "yes" ; then
20852358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2086bf9298b9Saliguorifi
2087ceb42de8Saliguoriif test "$preadv" = "yes" ; then
20882358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2089ceb42de8Saliguorifi
2090f652e6afSaurel32if test "$fdt" = "yes" ; then
20913f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2092f652e6afSaurel32fi
2093de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2094de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2095de5071c5SBlue Swirlfi
2096747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2097747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2098747bbdf7SBlue Swirlfi
20995f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
21005f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
21015f6b9e8fSBlue Swirlfi
210297a847bcSbellard
210383fb7adfSbellard# XXX: suppress that
21047d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
21052358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
21067d3505c5Sbellardfi
21077d3505c5Sbellard
21082358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2109c5937220Spbrook
211068063649Sblueswir1# USB host support
211168063649Sblueswir1case "$usb" in
211268063649Sblueswir1linux)
211398ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
211468063649Sblueswir1;;
211568063649Sblueswir1bsd)
211698ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
211768063649Sblueswir1;;
211868063649Sblueswir1*)
211998ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
212068063649Sblueswir1;;
212168063649Sblueswir1esac
212268063649Sblueswir1
2123c39e3338Spbrooktools=
2124c39e3338Spbrookif test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
212586355e07SAurelien Jarno  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
21267a5ca864Sbellard  if [ "$linux" = "yes" ] ; then
212786355e07SAurelien Jarno      tools="qemu-nbd\$(EXESUF) $tools"
21285495ed11SLuiz Capitulino    if [ "$check_utests" = "yes" ]; then
21293aa3dcffSLuiz Capitulino      tools="check-qint check-qstring check-qdict check-qlist $tools"
2130422c46a8SAnthony Liguori      tools="check-qfloat check-qjson $tools"
21315495ed11SLuiz Capitulino    fi
21327a5ca864Sbellard  fi
2133c39e3338Spbrookfi
213498ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
2135c39e3338Spbrook
2136161294d8SJuan Quintela# Mac OS X ships with a broken assembler
2137253d0942SAlexander Grafroms=
2138161294d8SJuan Quintelaif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2139ea5ad306SAndreas Faerber        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2140b461cdc9SBlue Swirl        `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2141c05ac895SPaul Brook  roms="optionrom"
2142253d0942SAlexander Graffi
214398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2144253d0942SAlexander Graf
2145804edf29SJuan Quintelaecho "prefix=$prefix" >> $config_host_mak
2146804edf29SJuan Quintelaecho "bindir=\${prefix}$binsuffix" >> $config_host_mak
2147804edf29SJuan Quintelaecho "mandir=\${prefix}$mansuffix" >> $config_host_mak
2148804edf29SJuan Quintelaecho "datadir=\${prefix}$datasuffix" >> $config_host_mak
2149804edf29SJuan Quintelaecho "docdir=\${prefix}$docsuffix" >> $config_host_mak
2150804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2151804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2152804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2153804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2154804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2155804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
2156804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2157804edf29SJuan Quintelaif test "$sparse" = "yes" ; then
2158804edf29SJuan Quintela  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2159804edf29SJuan Quintela  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2160a558ee17SJuan Quintela  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2161804edf29SJuan Quintelafi
2162804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2163804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2164804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
2165e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2166a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2167c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2168e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2169a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2170a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
217173da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
21723e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2173804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2174804edf29SJuan Quintela
21754bf6b55bSJuan Quintela# generate list of library paths for linker script
21764bf6b55bSJuan Quintela
21774bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
21784bf6b55bSJuan Quintela
21794bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
21804bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
21814bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
21824bf6b55bSJuan Quintela  else
21834bf6b55bSJuan Quintela    rm ${config_host_ld}~
21844bf6b55bSJuan Quintela  fi
21854bf6b55bSJuan Quintelafi
21864bf6b55bSJuan Quintela
218797a847bcSbellardfor target in $target_list; do
218897a847bcSbellardtarget_dir="$target"
218925be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2190600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
219197a847bcSbellardtarget_bigendian="no"
21921f3d3c8fSJuan Quintela
2193ea2d6a39SJuan Quintelacase "$target_arch2" in
2194*24e804ecSAlexander Graf  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2195ea2d6a39SJuan Quintela  target_bigendian=yes
2196ea2d6a39SJuan Quintela  ;;
2197ea2d6a39SJuan Quintelaesac
219897a847bcSbellardtarget_softmmu="no"
2199997344f3Sbellardtarget_user_only="no"
2200831b7825Sthstarget_linux_user="no"
2201831b7825Sthstarget_darwin_user="no"
220284778508Sblueswir1target_bsd_user="no"
22039e407a85Spbrookcase "$target" in
2204600309b6SBlue Swirl  ${target_arch2}-softmmu)
22059e407a85Spbrook    target_softmmu="yes"
22069e407a85Spbrook    ;;
2207600309b6SBlue Swirl  ${target_arch2}-linux-user)
22089c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
22099c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
22109c7a4202SBlue Swirl      exit 1
22119c7a4202SBlue Swirl    fi
22129e407a85Spbrook    target_user_only="yes"
22139e407a85Spbrook    target_linux_user="yes"
22149e407a85Spbrook    ;;
2215600309b6SBlue Swirl  ${target_arch2}-darwin-user)
22169c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
22179c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
22189c7a4202SBlue Swirl      exit 1
22199c7a4202SBlue Swirl    fi
22209e407a85Spbrook    target_user_only="yes"
2221831b7825Sths    target_darwin_user="yes"
22229e407a85Spbrook    ;;
2223600309b6SBlue Swirl  ${target_arch2}-bsd-user)
22249cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
22259c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
22269c7a4202SBlue Swirl      exit 1
22279c7a4202SBlue Swirl    fi
222884778508Sblueswir1    target_user_only="yes"
222984778508Sblueswir1    target_bsd_user="yes"
223084778508Sblueswir1    ;;
22319e407a85Spbrook  *)
22329e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
22339e407a85Spbrook    exit 1
22349e407a85Spbrook    ;;
22359e407a85Spbrookesac
2236831b7825Sths
223797a847bcSbellardmkdir -p $target_dir
2238158142c2Sbellardmkdir -p $target_dir/fpu
223957fec1feSbellardmkdir -p $target_dir/tcg
224059f2a787SGerd Hoffmannmkdir -p $target_dir/ide
224184778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
224269de927cSbellard  mkdir -p $target_dir/nwfpe
224369de927cSbellardfi
224469de927cSbellard
2245ec530c81Sbellard#
2246ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
2247ec530c81Sbellard#
2248ec530c81Sbellardrm -f $target_dir/Makefile
2249ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
2250ec530c81Sbellard
225197a847bcSbellard
225225be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
225397a847bcSbellard
2254e5fe0c52Spbrookbflt="no"
2255cb33da57Sblueswir1elfload32="no"
2256bd0c5661Spbrooktarget_nptl="no"
2257600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
225825be210fSJuan Quintelaecho "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
225956aebc89Spbrookgdb_xml_files=""
22607ba1e619Saliguori
2261938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
22626acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2263e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2264e73aae67SJuan Quintela
2265600309b6SBlue Swirlcase "$target_arch2" in
22662408a527Saurel32  i386)
22671ad2134fSPaul Brook    target_phys_bits=32
22682408a527Saurel32  ;;
22692408a527Saurel32  x86_64)
22706acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
22711ad2134fSPaul Brook    target_phys_bits=64
22722408a527Saurel32  ;;
22732408a527Saurel32  alpha)
22741ad2134fSPaul Brook    target_phys_bits=64
22752408a527Saurel32  ;;
22762408a527Saurel32  arm|armeb)
2277b498c8a0SJuan Quintela    TARGET_ARCH=arm
2278e5fe0c52Spbrook    bflt="yes"
2279bd0c5661Spbrook    target_nptl="yes"
228056aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
22811ad2134fSPaul Brook    target_phys_bits=32
22822408a527Saurel32  ;;
22832408a527Saurel32  cris)
2284253bd7f8Sedgar_igl    target_nptl="yes"
22851ad2134fSPaul Brook    target_phys_bits=32
22862408a527Saurel32  ;;
22872408a527Saurel32  m68k)
22880938cda5Saurel32    bflt="yes"
228956aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
22901ad2134fSPaul Brook    target_phys_bits=32
22912408a527Saurel32  ;;
229272b675caSEdgar E. Iglesias  microblaze)
229372b675caSEdgar E. Iglesias    bflt="yes"
229472b675caSEdgar E. Iglesias    target_nptl="yes"
229572b675caSEdgar E. Iglesias    target_phys_bits=32
229672b675caSEdgar E. Iglesias  ;;
22972408a527Saurel32  mips|mipsel)
2298b498c8a0SJuan Quintela    TARGET_ARCH=mips
229925be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2300f04dc72fSPaul Brook    target_nptl="yes"
23011ad2134fSPaul Brook    target_phys_bits=64
23022408a527Saurel32  ;;
23032408a527Saurel32  mipsn32|mipsn32el)
2304b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
23056acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
230625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
23071ad2134fSPaul Brook    target_phys_bits=64
23082408a527Saurel32  ;;
23092408a527Saurel32  mips64|mips64el)
2310b498c8a0SJuan Quintela    TARGET_ARCH=mips64
23116acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
231225be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
23131ad2134fSPaul Brook    target_phys_bits=64
23142408a527Saurel32  ;;
23152408a527Saurel32  ppc)
2316c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23171ad2134fSPaul Brook    target_phys_bits=32
2318d6630708SNathan Froyd    target_nptl="yes"
23192408a527Saurel32  ;;
23202408a527Saurel32  ppcemb)
23216acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2322e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2323c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23241ad2134fSPaul Brook    target_phys_bits=64
2325d6630708SNathan Froyd    target_nptl="yes"
23262408a527Saurel32  ;;
23272408a527Saurel32  ppc64)
23286acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2329e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2330c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23311ad2134fSPaul Brook    target_phys_bits=64
23322408a527Saurel32  ;;
23332408a527Saurel32  ppc64abi32)
2334b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
23356acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2336e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
233725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
2338c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23391ad2134fSPaul Brook    target_phys_bits=64
23402408a527Saurel32  ;;
23412408a527Saurel32  sh4|sh4eb)
2342b498c8a0SJuan Quintela    TARGET_ARCH=sh4
23434dbed897Spbrook    bflt="yes"
23440b6d3ae0Saurel32    target_nptl="yes"
23451ad2134fSPaul Brook    target_phys_bits=32
23462408a527Saurel32  ;;
23472408a527Saurel32  sparc)
23481ad2134fSPaul Brook    target_phys_bits=64
23492408a527Saurel32  ;;
23502408a527Saurel32  sparc64)
23516acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
23520938cda5Saurel32    elfload32="yes"
23531ad2134fSPaul Brook    target_phys_bits=64
23542408a527Saurel32  ;;
23552408a527Saurel32  sparc32plus)
2356b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
23576acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
2358e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
235925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
23601ad2134fSPaul Brook    target_phys_bits=64
23612408a527Saurel32  ;;
2362*24e804ecSAlexander Graf  s390x)
2363*24e804ecSAlexander Graf    target_phys_bits=64
2364*24e804ecSAlexander Graf  ;;
23652408a527Saurel32  *)
2366de83cd02Sbellard    echo "Unsupported target CPU"
2367de83cd02Sbellard    exit 1
23682408a527Saurel32  ;;
23692408a527Saurel32esac
237025be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2371053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
237225be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
237325be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
237442bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
23756acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
23766acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
23776acff7daSJuan Quintelafi
237825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2379e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
2380e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
2381e6e91b9cSJuan Quintelafi
238225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
23831ad2134fSPaul Brookif [ $target_phys_bits -lt $hostlongbits ] ; then
23841ad2134fSPaul Brook  target_phys_bits=$hostlongbits
23851ad2134fSPaul Brookfi
23861b0c87fcSJuan Quintelacase "$target_arch2" in
23871b0c87fcSJuan Quintela  i386|x86_64)
23881b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
238925be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
23901b0c87fcSJuan Quintela    fi
23911b0c87fcSJuan Quintelaesac
2392c59249f9SJuan Quintelacase "$target_arch2" in
23935f114bc6SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64)
2394c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
2395c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2396c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
2397c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
23985f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2399c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2400c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
240125be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
240225be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2403c59249f9SJuan Quintela    fi
2404c59249f9SJuan Quintelaesac
240525be210fSJuan Quintelaecho "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
2406de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
240725be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
240897a847bcSbellardfi
240997a847bcSbellardif test "$target_softmmu" = "yes" ; then
241025be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
241125be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
241225be210fSJuan Quintela  echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_target_mak
24135791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2414de83cd02Sbellardfi
2415997344f3Sbellardif test "$target_user_only" = "yes" ; then
241625be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2417997344f3Sbellardfi
2418831b7825Sthsif test "$target_linux_user" = "yes" ; then
241925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2420831b7825Sthsfi
2421831b7825Sthsif test "$target_darwin_user" = "yes" ; then
242225be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2423831b7825Sthsfi
242456aebc89Spbrooklist=""
242556aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
242656aebc89Spbrook  for x in $gdb_xml_files; do
242756aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
242856aebc89Spbrook  done
242925be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
24303d0f1517SJuan Quintelafi
2431de83cd02Sbellard
2432f57975fbSJuan Quintelacase "$target_arch2" in
2433*24e804ecSAlexander Graf  arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
243425be210fSJuan Quintela    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2435f57975fbSJuan Quintela    ;;
2436d6b38939SJuan Quintela  *)
243725be210fSJuan Quintela    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2438d6b38939SJuan Quintela    ;;
2439f57975fbSJuan Quintelaesac
2440f57975fbSJuan Quintela
2441e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
244225be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2443e5fe0c52Spbrookfi
2444bd0c5661Spbrookif test "$target_user_only" = "yes" \
2445bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
244625be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2447bd0c5661Spbrookfi
2448cb33da57Sblueswir1# 32 bit ELF loader in addition to native 64 bit loader?
2449cb33da57Sblueswir1if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
245025be210fSJuan Quintela  echo "TARGET_HAS_ELFLOAD32=y" >> $config_target_mak
2451cb33da57Sblueswir1fi
2452379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
245325be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2454379f6698SPaul Brookfi
245584778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
245625be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
245784778508Sblueswir1fi
24585b0753e0Sbellard
24594afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
2460fa282484SJuan Quintela
24614afddb55SJuan Quintelacflags=""
2462fa282484SJuan Quintelaldflags=""
24639b8e111fSJuan Quintela
246457ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
246557ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
2466*24e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
2467*24e804ecSAlexander Graf  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
246857ddfbf7SJuan Quintelaelse
246957ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
247057ddfbf7SJuan Quintelafi
247157ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/tcg $cflags"
247257ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/fpu $cflags"
247357ddfbf7SJuan Quintela
247464656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
247564656024SJuan Quintela  case "$i" in
247664656024SJuan Quintela  alpha)
247725be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
247864656024SJuan Quintela  ;;
247964656024SJuan Quintela  arm)
248025be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
248164656024SJuan Quintela  ;;
248264656024SJuan Quintela  cris)
248325be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
248464656024SJuan Quintela  ;;
248564656024SJuan Quintela  hppa)
248625be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
248764656024SJuan Quintela  ;;
248864656024SJuan Quintela  i386|x86_64)
248925be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
249064656024SJuan Quintela  ;;
249164656024SJuan Quintela  m68k)
249225be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
249364656024SJuan Quintela  ;;
249464656024SJuan Quintela  microblaze)
249525be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
249664656024SJuan Quintela  ;;
249764656024SJuan Quintela  mips*)
249825be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
249964656024SJuan Quintela  ;;
250064656024SJuan Quintela  ppc*)
250125be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
250264656024SJuan Quintela  ;;
2503*24e804ecSAlexander Graf  s390*)
250425be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
250564656024SJuan Quintela  ;;
250664656024SJuan Quintela  sh4)
250725be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
250864656024SJuan Quintela  ;;
250964656024SJuan Quintela  sparc*)
251025be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
251164656024SJuan Quintela  ;;
251264656024SJuan Quintela  esac
251364656024SJuan Quinteladone
251464656024SJuan Quintela
25156ee7126fSJuan Quintelacase "$ARCH" in
25166ee7126fSJuan Quintelaalpha)
25176ee7126fSJuan Quintela  # Ensure there's only a single GP
25186ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
25196ee7126fSJuan Quintela;;
2520c60d0afaSJuan Quintelaia64)
2521c60d0afaSJuan Quintela  cflags="-mno-sdata $cflags"
2522c60d0afaSJuan Quintela;;
25236ee7126fSJuan Quintelaesac
25246ee7126fSJuan Quintela
252555d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
252655d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
252755d9c04bSJuan Quintela  arm)
252855d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
252955d9c04bSJuan Quintela  ;;
253055d9c04bSJuan Quintela  i386|mips|ppc)
253155d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
253255d9c04bSJuan Quintela  ;;
253355d9c04bSJuan Quintela  esac
253455d9c04bSJuan Quintelafi
253555d9c04bSJuan Quintela
253634005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
253734005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
253834005a00SKirill A. Shutemov  cflags="-fpie $cflags"
253934005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
254034005a00SKirill A. Shutemovfi
254134005a00SKirill A. Shutemov
2542471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
2543471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
2544471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
254525be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
2546471857ddSJuan Quintelafi
2547471857ddSJuan Quintela
2548d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
254925be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
2550d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
2551d02c1db3SJuan Quintela    cflags="-p $cflags"
2552d02c1db3SJuan Quintela    ldflags="-p $ldflags"
2553d02c1db3SJuan Quintela  fi
2554d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
2555d02c1db3SJuan Quintela    ldflags="-p $ldflags"
255625be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
2557d02c1db3SJuan Quintela  fi
2558d02c1db3SJuan Quintelafi
2559d02c1db3SJuan Quintela
25606ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
25619b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2562fa282484SJuan Quintela  case "$ARCH" in
2563fa282484SJuan Quintela  sparc)
2564fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
2565322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
2566fa282484SJuan Quintela    ;;
2567fa282484SJuan Quintela  ia64)
2568322e5878SJuan Quintela    ldflags="-Wl,-G0 $linker_script -static $ldflags"
2569fa282484SJuan Quintela    ;;
2570df70204dSKirill A. Shutemov  i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2571322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
2572fa282484SJuan Quintela    ;;
2573fa282484SJuan Quintela  esac
2574fa282484SJuan Quintelafi
2575fa282484SJuan Quintelaif test "$target_softmmu" = "yes" ; then
2576fa282484SJuan Quintela  case "$ARCH" in
2577fa282484SJuan Quintela  ia64)
2578322e5878SJuan Quintela    ldflags="-Wl,-G0 $linker_script -static $ldflags"
2579fa282484SJuan Quintela    ;;
2580fa282484SJuan Quintela  esac
2581fa282484SJuan Quintelafi
2582fa282484SJuan Quintela
258325be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
258425be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
2585fa282484SJuan Quintela
258697a847bcSbellarddone # for target in $targets
25877d13299dSbellard
25887d13299dSbellard# build tree in object directory if source path is different from current one
25897d13299dSbellardif test "$source_path_used" = "yes" ; then
2590e1144d00SMark McLoughlin    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
25912d9f27d2SAnthony Liguori    DIRS="$DIRS roms/seabios roms/vgabios"
25927d13299dSbellard    FILES="Makefile tests/Makefile"
2593e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2594e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
25957ea78b74SJan Kiszka    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
25962d9f27d2SAnthony Liguori    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
25977ea78b74SJan Kiszka    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
25987ea78b74SJan Kiszka        FILES="$FILES pc-bios/`basename $bios_file`"
25997ea78b74SJan Kiszka    done
26007d13299dSbellard    for dir in $DIRS ; do
26017d13299dSbellard            mkdir -p $dir
26027d13299dSbellard    done
2603ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
26047d13299dSbellard    for f in $FILES ; do
2605ec530c81Sbellard        rm -f $f
2606ec530c81Sbellard        ln -s $source_path/$f $f
26077d13299dSbellard    done
26087d13299dSbellardfi
26091ad2134fSPaul Brook
2610c34ebfdcSAnthony Liguori# temporary config to build submodules
26112d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
2612c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
2613c34ebfdcSAnthony Liguori    echo "# Automatically generated by configure - do not modify" >> $config_mak
2614c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2615c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
2616c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
2617c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
2618c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
2619c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
2620c34ebfdcSAnthony Liguori    echo "HOST_CC=$host_cc" >> $config_mak
2621c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
2622c34ebfdcSAnthony Liguoridone
2623c34ebfdcSAnthony Liguori
26241ad2134fSPaul Brookfor hwlib in 32 64; do
26251ad2134fSPaul Brook  d=libhw$hwlib
26261ad2134fSPaul Brook  mkdir -p $d
26271ad2134fSPaul Brook  rm -f $d/Makefile
26281ad2134fSPaul Brook  ln -s $source_path/Makefile.hw $d/Makefile
26291ad2134fSPaul Brook  echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
2630a558ee17SJuan Quintela  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
26311ad2134fSPaul Brookdone
2632add16157SBlue Swirl
2633add16157SBlue Swirld=libuser
2634add16157SBlue Swirlmkdir -p $d
2635add16157SBlue Swirlrm -f $d/Makefile
2636add16157SBlue Swirlln -s $source_path/Makefile.user $d/Makefile
2637