xref: /openbmc/qemu/configure (revision 9316f803)
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  ;;
18624e804ecSAlexander Graf  s390)
187fb3e5849Sbellard    cpu="s390"
188fb3e5849Sbellard  ;;
18924e804ecSAlexander Graf  s390x)
19024e804ecSAlexander Graf    cpu="s390x"
19124e804ecSAlexander 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=""
219dae5079aSJan Kiszkakvm_para=""
220b0a47e79SJuan Quintelanptl=""
221c4198157SJuan Quintelasdl=""
222dfffc653SJuan Quintelasparse="no"
223ee682d27SStefan Weiluuid=""
224dfb278bdSJuan Quintelavde=""
2251be10ad2SJuan Quintelavnc_tls=""
226ea784e3bSJuan Quintelavnc_sasl=""
227fc321b4bSJuan Quintelaxen=""
2285c6c3a6cSChristoph Hellwiglinux_aio=""
229dfb278bdSJuan Quintela
2307d13299dSbellardgprof="no"
231f8393946Saurel32debug_tcg="no"
232f3d08ee6SPaul Brookdebug="no"
2331625af87Saliguoristrip_opt="yes"
2347d13299dSbellardbigendian="no"
23567b915a5Sbellardmingw32="no"
23667b915a5SbellardEXESUF=""
237443f1376Sbellardslirp="yes"
238102a52e4Sbellardfmod_lib=""
239102a52e4Sbellardfmod_inc=""
2402f6a1ab0Sblueswir1oss_lib=""
241b1a550a0Spbrookbsd="no"
2425327cf48Sbellardlinux="no"
243d2c7c9b8Sblueswir1solaris="no"
24405c2a3e7Sbellardprofiler="no"
2455b0753e0Sbellardcocoa="no"
2460a8e90f4Spbrooksoftmmu="yes"
247831b7825Sthslinux_user="no"
248831b7825Sthsdarwin_user="no"
24984778508Sblueswir1bsd_user="no"
250379f6698SPaul Brookguest_base=""
251c5937220Spbrookuname_release=""
252e5d355d1Saliguoriio_thread="no"
2538ff9cbf7Smalcmixemu="no"
254eac30262Saliguorikerneldir=""
255b29fe3edSmalcaix="no"
25677755340Sthsblobs="yes"
2574a19f1ecSpbrookpkgversion=""
2585495ed11SLuiz Capitulinocheck_utests="no"
25934005a00SKirill A. Shutemovuser_pie="no"
26020ff6c80SAnthony Liguorizero_malloc=""
2617d13299dSbellard
2627d13299dSbellard# OS specific
263ac0df51dSaliguoriif check_define __linux__ ; then
264ac0df51dSaliguori  targetos="Linux"
265ac0df51dSaliguorielif check_define _WIN32 ; then
266ac0df51dSaliguori  targetos='MINGW32'
267169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
268169dc5d3Sblueswir1  targetos='OpenBSD'
269169dc5d3Sblueswir1elif check_define __sun__ ; then
270169dc5d3Sblueswir1  targetos='SunOS'
271ac0df51dSaliguorielse
2727d13299dSbellard  targetos=`uname -s`
273ac0df51dSaliguorifi
2740dbfc675SJuan Quintela
2757d13299dSbellardcase $targetos in
276c326e0afSbellardCYGWIN*)
277c326e0afSbellard  mingw32="yes"
278a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
279d5631638Smalc  audio_possible_drivers="winwave sdl"
280d5631638Smalc  audio_drv_list="winwave"
281c326e0afSbellard;;
28267b915a5SbellardMINGW32*)
28367b915a5Sbellard  mingw32="yes"
284d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
285d5631638Smalc  audio_drv_list="winwave"
28667b915a5Sbellard;;
2875c40d2bdSthsGNU/kFreeBSD)
288a167ba50SAurelien Jarno  bsd="yes"
2890c58ac1cSmalc  audio_drv_list="oss"
290f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
2915c40d2bdSths;;
2927d3505c5SbellardFreeBSD)
2937d3505c5Sbellard  bsd="yes"
294a167ba50SAurelien Jarno  make="gmake"
2950c58ac1cSmalc  audio_drv_list="oss"
296f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
2977d3505c5Sbellard;;
298c5e97233Sblueswir1DragonFly)
299c5e97233Sblueswir1  bsd="yes"
300a167ba50SAurelien Jarno  make="gmake"
301c5e97233Sblueswir1  audio_drv_list="oss"
302c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
303c5e97233Sblueswir1;;
3047d3505c5SbellardNetBSD)
3057d3505c5Sbellard  bsd="yes"
306a167ba50SAurelien Jarno  make="gmake"
3070c58ac1cSmalc  audio_drv_list="oss"
308c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3098ef92a88Sblueswir1  oss_lib="-lossaudio"
3107d3505c5Sbellard;;
3117d3505c5SbellardOpenBSD)
3127d3505c5Sbellard  bsd="yes"
313a167ba50SAurelien Jarno  make="gmake"
3140c58ac1cSmalc  audio_drv_list="oss"
315c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3162f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3177d3505c5Sbellard;;
31883fb7adfSbellardDarwin)
31983fb7adfSbellard  bsd="yes"
32083fb7adfSbellard  darwin="yes"
3210dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3220dbfc675SJuan Quintela  # run 64-bit userspace code
323aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3241b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
325aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3261b0f9cc2Saliguori  fi
3271b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
328a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3290c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3301b0f9cc2Saliguori  else
331a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3321b0f9cc2Saliguori  fi
333831b7825Sths  darwin_user="yes"
334fd677642Sths  cocoa="yes"
3350c58ac1cSmalc  audio_drv_list="coreaudio"
336c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
3370c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
3387973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
33983fb7adfSbellard;;
340ec530c81SbellardSunOS)
341ec530c81Sbellard  solaris="yes"
342c2b84fabSths  make="gmake"
343c2b84fabSths  install="ginstall"
344fa58948dSBlue Swirl  ld="gld"
3450475a5caSths  needs_libsunmath="no"
346c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
347ef18c883Sths  # have to select again, because `uname -m` returns i86pc
348ef18c883Sths  # even on an x86_64 box.
349ef18c883Sths  solariscpu=`isainfo -k`
350ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
351ef18c883Sths    cpu="x86_64"
352ef18c883Sths  fi
353c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
3540475a5caSths    if test "$solarisrev" -le 9 ; then
3550475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
3560475a5caSths        needs_libsunmath="yes"
357f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
358f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
359f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
3600475a5caSths      else
3610475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
3620475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
3630475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
3640475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
3650475a5caSths        exit 1
3660475a5caSths      fi
3670475a5caSths    fi
36886b2bd93Sths  fi
3696b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
3700c58ac1cSmalc    audio_drv_list="oss"
3716b4d2ba1Sths  fi
372c2de5c91Smalc  audio_possible_drivers="oss sdl"
373d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
374d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
375d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
376d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
377a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
378e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
379ec530c81Sbellard;;
380b29fe3edSmalcAIX)
381b29fe3edSmalc  aix="yes"
382b29fe3edSmalc  make="gmake"
383b29fe3edSmalc;;
384fb065187Sbellard*)
3850c58ac1cSmalc  audio_drv_list="oss"
386b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
3875327cf48Sbellard  linux="yes"
388831b7825Sths  linux_user="yes"
38968063649Sblueswir1  usb="linux"
39007f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
391c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
392c9ec1fe4Sbellard  fi
393fb065187Sbellard;;
3947d13299dSbellardesac
3957d13299dSbellard
3967d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
397b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
39868063649Sblueswir1    usb="bsd"
39983fb7adfSbellard  fi
40084778508Sblueswir1  bsd_user="yes"
4017d3505c5Sbellardfi
4027d3505c5Sbellard
4033457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4043457a3f8SJuan Quintela  EXESUF=".exe"
405a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
406884044aaSJuan Quintela  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
4073457a3f8SJuan Quintelafi
4083457a3f8SJuan Quintela
4097d13299dSbellard# find source path
410ad064840Spbrooksource_path=`dirname "$0"`
41159faef3aSbalrogsource_path_used="no"
41259faef3aSbalrogworkdir=`pwd`
413ad064840Spbrookif [ -z "$source_path" ]; then
41459faef3aSbalrog    source_path=$workdir
415ad064840Spbrookelse
416ad064840Spbrook    source_path=`cd "$source_path"; pwd`
4177d13299dSbellardfi
418724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
4197d13299dSbellard
420487fefdbSAnthony Liguoriwerror=""
42185aa5189Sbellard
4227d13299dSbellardfor opt do
423a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4247d13299dSbellard  case "$opt" in
4252efc3265Sbellard  --help|-h) show_help=yes
4262efc3265Sbellard  ;;
427b1a550a0Spbrook  --prefix=*) prefix="$optarg"
4287d13299dSbellard  ;;
429b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
43032ce6337Sbellard  ;;
431b1a550a0Spbrook  --source-path=*) source_path="$optarg"
432ad064840Spbrook  source_path_used="yes"
4337d13299dSbellard  ;;
434ac0df51dSaliguori  --cross-prefix=*)
4357d13299dSbellard  ;;
436ac0df51dSaliguori  --cc=*)
4377d13299dSbellard  ;;
438b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
43983469015Sbellard  ;;
440b1a550a0Spbrook  --make=*) make="$optarg"
4417d13299dSbellard  ;;
4426a882643Spbrook  --install=*) install="$optarg"
4436a882643Spbrook  ;;
444e2a2ed06SJuan Quintela  --extra-cflags=*)
4457d13299dSbellard  ;;
446e2a2ed06SJuan Quintela  --extra-ldflags=*)
4477d13299dSbellard  ;;
4482ff6b91eSJuan Quintela  --cpu=*)
4497d13299dSbellard  ;;
450b1a550a0Spbrook  --target-list=*) target_list="$optarg"
451de83cd02Sbellard  ;;
4527d13299dSbellard  --enable-gprof) gprof="yes"
4537d13299dSbellard  ;;
45443ce4dfeSbellard  --static) static="yes"
45543ce4dfeSbellard  ;;
45697a847bcSbellard  --disable-sdl) sdl="no"
45797a847bcSbellard  ;;
458c4198157SJuan Quintela  --enable-sdl) sdl="yes"
459c4198157SJuan Quintela  ;;
460b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
461102a52e4Sbellard  ;;
462c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
463c2de5c91Smalc  ;;
4642f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
4652f6a1ab0Sblueswir1  ;;
4662fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
4670c58ac1cSmalc  ;;
4680c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
4690c58ac1cSmalc  ;;
470eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
471eb852011SMarkus Armbruster  ;;
472f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
473f8393946Saurel32  ;;
474f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
475f8393946Saurel32  ;;
476f3d08ee6SPaul Brook  --enable-debug)
477f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
478f3d08ee6SPaul Brook      debug_tcg="yes"
479f3d08ee6SPaul Brook      debug="yes"
480f3d08ee6SPaul Brook      strip_opt="no"
481f3d08ee6SPaul Brook  ;;
48203b4fe7dSaliguori  --enable-sparse) sparse="yes"
48303b4fe7dSaliguori  ;;
48403b4fe7dSaliguori  --disable-sparse) sparse="no"
48503b4fe7dSaliguori  ;;
4861625af87Saliguori  --disable-strip) strip_opt="no"
4871625af87Saliguori  ;;
4888d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
4898d5d2d4cSths  ;;
4901be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
4911be10ad2SJuan Quintela  ;;
4922f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
4932f9606b3Saliguori  ;;
494ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
495ea784e3bSJuan Quintela  ;;
496443f1376Sbellard  --disable-slirp) slirp="no"
497c20709aaSbellard  ;;
498ee682d27SStefan Weil  --disable-uuid) uuid="no"
499ee682d27SStefan Weil  ;;
500ee682d27SStefan Weil  --enable-uuid) uuid="yes"
501ee682d27SStefan Weil  ;;
502e0e6c8c0Saliguori  --disable-vde) vde="no"
5038a16d273Sths  ;;
504dfb278bdSJuan Quintela  --enable-vde) vde="yes"
505dfb278bdSJuan Quintela  ;;
506e37630caSaliguori  --disable-xen) xen="no"
507e37630caSaliguori  ;;
508fc321b4bSJuan Quintela  --enable-xen) xen="yes"
509fc321b4bSJuan Quintela  ;;
5102e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
5112e4d9fb1Saurel32  ;;
5124ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
5134ffcedb6SJuan Quintela  ;;
514fb599c9aSbalrog  --disable-bluez) bluez="no"
515fb599c9aSbalrog  ;;
516a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
517a20a6f46SJuan Quintela  ;;
5187ba1e619Saliguori  --disable-kvm) kvm="no"
5197ba1e619Saliguori  ;;
520b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
521b31a0277SJuan Quintela  ;;
52205c2a3e7Sbellard  --enable-profiler) profiler="yes"
52305c2a3e7Sbellard  ;;
524c2de5c91Smalc  --enable-cocoa)
525c2de5c91Smalc      cocoa="yes" ;
526c2de5c91Smalc      sdl="no" ;
527c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
5285b0753e0Sbellard  ;;
529cad25d69Spbrook  --disable-system) softmmu="no"
5300a8e90f4Spbrook  ;;
531cad25d69Spbrook  --enable-system) softmmu="yes"
5320a8e90f4Spbrook  ;;
5330953a80fSZachary Amsden  --disable-user)
5340953a80fSZachary Amsden      linux_user="no" ;
5350953a80fSZachary Amsden      bsd_user="no" ;
5360953a80fSZachary Amsden      darwin_user="no"
5370953a80fSZachary Amsden  ;;
5380953a80fSZachary Amsden  --enable-user) ;;
539831b7825Sths  --disable-linux-user) linux_user="no"
5400a8e90f4Spbrook  ;;
541831b7825Sths  --enable-linux-user) linux_user="yes"
542831b7825Sths  ;;
543831b7825Sths  --disable-darwin-user) darwin_user="no"
544831b7825Sths  ;;
545831b7825Sths  --enable-darwin-user) darwin_user="yes"
5460a8e90f4Spbrook  ;;
54784778508Sblueswir1  --disable-bsd-user) bsd_user="no"
54884778508Sblueswir1  ;;
54984778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
55084778508Sblueswir1  ;;
551379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
552379f6698SPaul Brook  ;;
553379f6698SPaul Brook  --disable-guest-base) guest_base="no"
554379f6698SPaul Brook  ;;
55534005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
55634005a00SKirill A. Shutemov  ;;
55734005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
55834005a00SKirill A. Shutemov  ;;
559c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
560c5937220Spbrook  ;;
5613142255cSblueswir1  --sparc_cpu=*)
5623142255cSblueswir1  ;;
56385aa5189Sbellard  --enable-werror) werror="yes"
56485aa5189Sbellard  ;;
56585aa5189Sbellard  --disable-werror) werror="no"
56685aa5189Sbellard  ;;
5674d3b6f6eSbalrog  --disable-curses) curses="no"
5684d3b6f6eSbalrog  ;;
569c584a6d0SJuan Quintela  --enable-curses) curses="yes"
570c584a6d0SJuan Quintela  ;;
571769ce76dSAlexander Graf  --disable-curl) curl="no"
572769ce76dSAlexander Graf  ;;
573788c8196SJuan Quintela  --enable-curl) curl="yes"
574788c8196SJuan Quintela  ;;
5752df87df7SJuan Quintela  --disable-fdt) fdt="no"
5762df87df7SJuan Quintela  ;;
5772df87df7SJuan Quintela  --enable-fdt) fdt="yes"
5782df87df7SJuan Quintela  ;;
5795495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
5805495ed11SLuiz Capitulino  ;;
5815495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
5825495ed11SLuiz Capitulino  ;;
583bd0c5661Spbrook  --disable-nptl) nptl="no"
584bd0c5661Spbrook  ;;
585b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
586b0a47e79SJuan Quintela  ;;
5878ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
5888ff9cbf7Smalc  ;;
5895c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
5905c6c3a6cSChristoph Hellwig  ;;
5915c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
5925c6c3a6cSChristoph Hellwig  ;;
593e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
594e5d355d1Saliguori  ;;
59577755340Sths  --disable-blobs) blobs="no"
59677755340Sths  ;;
597eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
598eac30262Saliguori  ;;
5994a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
6004a19f1ecSpbrook  ;;
601a25dba17SJuan Quintela  --disable-docs) docs="no"
60270ec5dc0SAnthony Liguori  ;;
603a25dba17SJuan Quintela  --enable-docs) docs="yes"
60483a3ab8bSJuan Quintela  ;;
6057f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
6067f1559c6Sbalrog  ;;
6077d13299dSbellard  esac
6087d13299dSbellarddone
6097d13299dSbellard
6103142255cSblueswir1#
6113142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
612a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
6133142255cSblueswir1#
614379f6698SPaul Brookhost_guest_base="no"
61540293e58Sbellardcase "$cpu" in
616ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
617ed968ff1SJuan Quintela           v7|v8)
618a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
619ed968ff1SJuan Quintela           ;;
620ed968ff1SJuan Quintela           v8plus|v8plusa)
621a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
622ed968ff1SJuan Quintela           ;;
623ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
624a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
625ed968ff1SJuan Quintela           esac
6260c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
627a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
628762e8230Sblueswir1           if test "$solaris" = "no" ; then
629a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
630c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
631762e8230Sblueswir1           fi
6323142255cSblueswir1           ;;
633ed968ff1SJuan Quintela    sparc64)
634a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
6350c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
636a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
637ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
638a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
639762e8230Sblueswir1           fi
6403142255cSblueswir1           ;;
64176d83bdeSths    s390)
642a558ee17SJuan Quintela           QEMU_CFLAGS="-march=z900 $QEMU_CFLAGS"
64376d83bdeSths           ;;
64440293e58Sbellard    i386)
645a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
6460c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
647c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
648379f6698SPaul Brook           host_guest_base="yes"
64940293e58Sbellard           ;;
65040293e58Sbellard    x86_64)
651a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
6520c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
653379f6698SPaul Brook           host_guest_base="yes"
654379f6698SPaul Brook           ;;
655379f6698SPaul Brook    arm*)
656379f6698SPaul Brook           host_guest_base="yes"
65740293e58Sbellard           ;;
658f6548c0aSmalc    ppc*)
659f6548c0aSmalc           host_guest_base="yes"
660f6548c0aSmalc           ;;
6613142255cSblueswir1esac
6623142255cSblueswir1
663379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
664379f6698SPaul Brook
665af5db58eSpbrookif test x"$show_help" = x"yes" ; then
666af5db58eSpbrookcat << EOF
667af5db58eSpbrook
668af5db58eSpbrookUsage: configure [options]
669af5db58eSpbrookOptions: [defaults in brackets after descriptions]
670af5db58eSpbrook
671af5db58eSpbrookEOF
672af5db58eSpbrookecho "Standard options:"
673af5db58eSpbrookecho "  --help                   print this message"
674af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
675af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
676af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
677af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
678af5db58eSpbrookecho ""
679af5db58eSpbrookecho "Advanced options (experts only):"
680af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
681af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
682af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
683af5db58eSpbrookecho "  --host-cc=CC             use C compiler CC [$host_cc] for dyngen etc."
684a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
685e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
686af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
6876a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
688af5db58eSpbrookecho "  --static                 enable static build [$static]"
689f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
690f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
69109695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
692890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
693890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
6941625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
69585aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
696fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
697c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
698af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
699c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
700c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
7014c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
7024c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
703eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
704eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
7058ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
706e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
707fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
7082e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
7094ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
7108d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
7111be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
7122f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
713ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
714af896aaaSpbrookecho "  --disable-curses         disable curses output"
715c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
716769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
717788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
7182df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
7192df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
7205495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
7215495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
722fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
723a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
7247ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
725b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
726bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
727e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
728af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
729af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
7300953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
7310953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
732831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
733831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
734831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
735831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
73684778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
73784778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
738379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
739379f6698SPaul Brookecho "                           emulation targets"
740379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
74134005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
74234005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
743af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
744af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
7452f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
746c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
7473142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
748ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
749ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
750e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
751dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
7525c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
7535c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
754e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
75577755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
756eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
757af5db58eSpbrookecho ""
7585bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
759af5db58eSpbrookexit 1
760af5db58eSpbrookfi
761af5db58eSpbrook
762ec530c81Sbellard#
763ec530c81Sbellard# Solaris specific configure tool chain decisions
764ec530c81Sbellard#
765ec530c81Sbellardif test "$solaris" = "yes" ; then
766ec530c81Sbellard  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
767ec530c81Sbellard  if test -z "$solinst" ; then
768ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
769ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
770ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
771ec530c81Sbellard    exit 1
772ec530c81Sbellard  fi
773ec530c81Sbellard  if test "$solinst" = "/usr/sbin/install" ; then
774ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
775ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
776ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
777ec530c81Sbellard    exit 1
778ec530c81Sbellard  fi
779ec530c81Sbellard  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
780ec530c81Sbellard  if test -z "$sol_ar" ; then
781ec530c81Sbellard    echo "Error: No path includes ar"
782ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
783ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
784ec530c81Sbellard    fi
785ec530c81Sbellard    exit 1
786ec530c81Sbellard  fi
787ec530c81Sbellardfi
788ec530c81Sbellard
789ec530c81Sbellard
7905327cf48Sbellardif test -z "$target_list" ; then
7915327cf48Sbellard# these targets are portable
7920a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
7932408a527Saurel32        target_list="\
7942408a527Saurel32i386-softmmu \
7952408a527Saurel32x86_64-softmmu \
7962408a527Saurel32arm-softmmu \
7972408a527Saurel32cris-softmmu \
7982408a527Saurel32m68k-softmmu \
79972b675caSEdgar E. Iglesiasmicroblaze-softmmu \
8002408a527Saurel32mips-softmmu \
8012408a527Saurel32mipsel-softmmu \
8022408a527Saurel32mips64-softmmu \
8032408a527Saurel32mips64el-softmmu \
8042408a527Saurel32ppc-softmmu \
8052408a527Saurel32ppcemb-softmmu \
8062408a527Saurel32ppc64-softmmu \
8072408a527Saurel32sh4-softmmu \
8082408a527Saurel32sh4eb-softmmu \
8092408a527Saurel32sparc-softmmu \
8101b64fcaeSIgor V. Kovalenkosparc64-softmmu \
8112408a527Saurel32"
8120a8e90f4Spbrook    fi
8135327cf48Sbellard# the following are Linux specific
814831b7825Sths    if [ "$linux_user" = "yes" ] ; then
8152408a527Saurel32        target_list="${target_list}\
8162408a527Saurel32i386-linux-user \
8172408a527Saurel32x86_64-linux-user \
8182408a527Saurel32alpha-linux-user \
8192408a527Saurel32arm-linux-user \
8202408a527Saurel32armeb-linux-user \
8212408a527Saurel32cris-linux-user \
8222408a527Saurel32m68k-linux-user \
82372b675caSEdgar E. Iglesiasmicroblaze-linux-user \
8242408a527Saurel32mips-linux-user \
8252408a527Saurel32mipsel-linux-user \
8262408a527Saurel32ppc-linux-user \
8272408a527Saurel32ppc64-linux-user \
8282408a527Saurel32ppc64abi32-linux-user \
8292408a527Saurel32sh4-linux-user \
8302408a527Saurel32sh4eb-linux-user \
8312408a527Saurel32sparc-linux-user \
8322408a527Saurel32sparc64-linux-user \
8332408a527Saurel32sparc32plus-linux-user \
8342408a527Saurel32"
835831b7825Sths    fi
836831b7825Sths# the following are Darwin specific
837831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
8382408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
8395327cf48Sbellard    fi
84084778508Sblueswir1# the following are BSD specific
84184778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
84284778508Sblueswir1        target_list="${target_list}\
84331fc12dfSblueswir1i386-bsd-user \
84431fc12dfSblueswir1x86_64-bsd-user \
84531fc12dfSblueswir1sparc-bsd-user \
84684778508Sblueswir1sparc64-bsd-user \
84784778508Sblueswir1"
84884778508Sblueswir1    fi
8496e20a45fSbellardelse
850b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
8515327cf48Sbellardfi
8520a8e90f4Spbrookif test -z "$target_list" ; then
8530a8e90f4Spbrook    echo "No targets enabled"
8540a8e90f4Spbrook    exit 1
8550a8e90f4Spbrookfi
8565327cf48Sbellard
857249247c9SJuan Quintelafeature_not_found() {
858249247c9SJuan Quintela  feature=$1
859249247c9SJuan Quintela
860249247c9SJuan Quintela  echo "ERROR"
861249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
8629332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
863249247c9SJuan Quintela  echo "ERROR"
864249247c9SJuan Quintela  exit 1;
865249247c9SJuan Quintela}
866249247c9SJuan Quintela
8677d13299dSbellardif test -z "$cross_prefix" ; then
8687d13299dSbellard
8697d13299dSbellard# ---
8707d13299dSbellard# big/little endian test
8717d13299dSbellardcat > $TMPC << EOF
8727d13299dSbellard#include <inttypes.h>
8737d13299dSbellardint main(int argc, char ** argv){
8747d13299dSbellard        volatile uint32_t i=0x01234567;
8757d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
8767d13299dSbellard}
8777d13299dSbellardEOF
8787d13299dSbellard
87952166aa0SJuan Quintelaif compile_prog "" "" ; then
8807d13299dSbellard$TMPE && bigendian="yes"
8817d13299dSbellardelse
8827d13299dSbellardecho big/little test failed
8837d13299dSbellardfi
8847d13299dSbellard
8857d13299dSbellardelse
8867d13299dSbellard
8877d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
888ea8f20f8SJuan Quintelacase "$cpu" in
88924e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
890ea8f20f8SJuan Quintela    bigendian=yes
891ea8f20f8SJuan Quintela  ;;
892ea8f20f8SJuan Quintelaesac
8937d13299dSbellard
8947d13299dSbellardfi
8957d13299dSbellard
896b6853697Sbellard# host long bits test
897b6853697Sbellardhostlongbits="32"
898ea8f20f8SJuan Quintelacase "$cpu" in
89924e804ecSAlexander Graf  x86_64|alpha|ia64|sparc64|ppc64|s390x)
900ea8f20f8SJuan Quintela    hostlongbits=64
901ea8f20f8SJuan Quintela  ;;
902ea8f20f8SJuan Quintelaesac
903b6853697Sbellard
904b0a47e79SJuan Quintela
905b0a47e79SJuan Quintela##########################################
906b0a47e79SJuan Quintela# NPTL probe
907b0a47e79SJuan Quintela
908b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
909bd0c5661Spbrook  cat > $TMPC <<EOF
910bd0c5661Spbrook#include <sched.h>
91130813ceaSpbrook#include <linux/futex.h>
912bd0c5661Spbrookvoid foo()
913bd0c5661Spbrook{
914bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
915bd0c5661Spbrook#error bork
916bd0c5661Spbrook#endif
917bd0c5661Spbrook}
918bd0c5661SpbrookEOF
919bd0c5661Spbrook
92052166aa0SJuan Quintela  if compile_object ; then
921b0a47e79SJuan Quintela    nptl=yes
922bd0c5661Spbrook  else
923b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
924b0a47e79SJuan Quintela      feature_not_found "nptl"
925b0a47e79SJuan Quintela    fi
926b0a47e79SJuan Quintela    nptl=no
927b0a47e79SJuan Quintela  fi
928bd0c5661Spbrookfi
929bd0c5661Spbrook
93011d9f695Sbellard##########################################
931ac62922eSbalrog# zlib check
932ac62922eSbalrog
933ac62922eSbalrogcat > $TMPC << EOF
934ac62922eSbalrog#include <zlib.h>
935ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
936ac62922eSbalrogEOF
93752166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
938ac62922eSbalrog    :
939ac62922eSbalrogelse
940ac62922eSbalrog    echo
941ac62922eSbalrog    echo "Error: zlib check failed"
942ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
943ac62922eSbalrog    echo
944ac62922eSbalrog    exit 1
945ac62922eSbalrogfi
946ac62922eSbalrog
947ac62922eSbalrog##########################################
948e37630caSaliguori# xen probe
949e37630caSaliguori
950fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
951b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
952e37630caSaliguori  cat > $TMPC <<EOF
953e37630caSaliguori#include <xenctrl.h>
954e37630caSaliguori#include <xs.h>
955df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
956e37630caSaliguoriEOF
95752166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
958fc321b4bSJuan Quintela    xen=yes
9593efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
960e37630caSaliguori  else
961fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
962fc321b4bSJuan Quintela      feature_not_found "xen"
963fc321b4bSJuan Quintela    fi
964fc321b4bSJuan Quintela    xen=no
965e37630caSaliguori  fi
966e37630caSaliguorifi
967e37630caSaliguori
968e37630caSaliguori##########################################
969f91672e5SPaolo Bonzini# pkgconfig probe
970f91672e5SPaolo Bonzini
971f91672e5SPaolo Bonzinipkgconfig="${cross_prefix}pkg-config"
972f91672e5SPaolo Bonziniif ! test -x "$(which $pkgconfig 2>/dev/null)"; then
973f91672e5SPaolo Bonzini  # likely not cross compiling, or hope for the best
974f91672e5SPaolo Bonzini  pkgconfig=pkg-config
975f91672e5SPaolo Bonzinifi
976f91672e5SPaolo Bonzini
977f91672e5SPaolo Bonzini##########################################
978dfffc653SJuan Quintela# Sparse probe
979dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
980dfffc653SJuan Quintela  if test -x "$(which cgcc 2>/dev/null)"; then
981dfffc653SJuan Quintela    sparse=yes
982dfffc653SJuan Quintela  else
983dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
984dfffc653SJuan Quintela      feature_not_found "sparse"
985dfffc653SJuan Quintela    fi
986dfffc653SJuan Quintela    sparse=no
987dfffc653SJuan Quintela  fi
988dfffc653SJuan Quintelafi
989dfffc653SJuan Quintela
990dfffc653SJuan Quintela##########################################
99111d9f695Sbellard# SDL probe
99211d9f695Sbellard
993*9316f803SPaolo Bonziniif $pkgconfig sdl --modversion >/dev/null 2>&1; then
994*9316f803SPaolo Bonzini  sdlconfig="$pkgconfig sdl"
995*9316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
996*9316f803SPaolo Bonzinielse
997*9316f803SPaolo Bonzini  sdlconfig='sdl-config'
998*9316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
999*9316f803SPaolo Bonzinifi
100011d9f695Sbellard
1001*9316f803SPaolo Bonzinisdl_too_old=no
1002c4198157SJuan Quintelaif test "$sdl" != "no" ; then
100311d9f695Sbellard  cat > $TMPC << EOF
100411d9f695Sbellard#include <SDL.h>
100511d9f695Sbellard#undef main /* We don't want SDL to override our main() */
100611d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
100711d9f695SbellardEOF
1008*9316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
1009*9316f803SPaolo Bonzini  sdl_libs=`$sdlconfig --libs 2> /dev/null`
101052166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
101111d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
101211d9f695Sbellard      sdl_too_old=yes
101311d9f695Sbellard    else
1014fd677642Sths      if test "$cocoa" = "no" ; then
101511d9f695Sbellard        sdl=yes
101611d9f695Sbellard      fi
1017fd677642Sths    fi
10187c1f25b4Sbellard
101967c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
10201ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
10211ac88f28SJuan Quintela      sdl_libs=`sdl-config --static-libs 2>/dev/null`
102267c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
10231ac88f28SJuan Quintela         sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`"
102467c274d3SPaolo Bonzini         sdl_cflags="$sdl_cflags `aalib-config --cflags >2 /dev/null`"
102511d9f695Sbellard      fi
102652166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
10271ac88f28SJuan Quintela	:
10281ac88f28SJuan Quintela      else
10291ac88f28SJuan Quintela        sdl=no
10307c1f25b4Sbellard      fi
10317c1f25b4Sbellard    fi # static link
1032c4198157SJuan Quintela  else # sdl not found
1033c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1034c4198157SJuan Quintela      feature_not_found "sdl"
1035c4198157SJuan Quintela    fi
1036c4198157SJuan Quintela    sdl=no
10377c1f25b4Sbellard  fi # sdl compile test
1038fd677642Sthsfi
103911d9f695Sbellard
10405368a422Saliguoriif test "$sdl" = "yes" ; then
10415368a422Saliguori  cat > $TMPC <<EOF
10425368a422Saliguori#include <SDL.h>
10435368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
10445368a422Saliguori#include <X11/XKBlib.h>
10455368a422Saliguori#else
10465368a422Saliguori#error No x11 support
10475368a422Saliguori#endif
10485368a422Saliguoriint main(void) { return 0; }
10495368a422SaliguoriEOF
105052166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1051681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
10525368a422Saliguori  fi
105307d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
105407d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
105507d9ac44SJuan Quintela  fi
10560705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
10575368a422Saliguorifi
10585368a422Saliguori
10598f28f3fbSths##########################################
10608d5d2d4cSths# VNC TLS detection
10611be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1062ae6b5e5aSaliguori  cat > $TMPC <<EOF
1063ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1064ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1065ae6b5e5aSaliguoriEOF
1066f91672e5SPaolo Bonzini  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1067f91672e5SPaolo Bonzini  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
106852166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
10691be10ad2SJuan Quintela    vnc_tls=yes
1070a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1071ae6b5e5aSaliguori  else
10721be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
10731be10ad2SJuan Quintela      feature_not_found "vnc-tls"
10741be10ad2SJuan Quintela    fi
10751be10ad2SJuan Quintela    vnc_tls=no
10768d5d2d4cSths  fi
10778d5d2d4cSthsfi
10788d5d2d4cSths
10798d5d2d4cSths##########################################
10802f9606b3Saliguori# VNC SASL detection
10813aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
10822f9606b3Saliguori  cat > $TMPC <<EOF
10832f9606b3Saliguori#include <sasl/sasl.h>
10842f9606b3Saliguori#include <stdio.h>
10852f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
10862f9606b3SaliguoriEOF
10872f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
10882f9606b3Saliguori  vnc_sasl_cflags=""
10892f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
109052166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1091ea784e3bSJuan Quintela    vnc_sasl=yes
1092fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
10932f9606b3Saliguori  else
1094ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1095ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1096ea784e3bSJuan Quintela    fi
1097ea784e3bSJuan Quintela    vnc_sasl=no
10982f9606b3Saliguori  fi
10992f9606b3Saliguorifi
11002f9606b3Saliguori
11012f9606b3Saliguori##########################################
110276655d6dSaliguori# fnmatch() probe, used for ACL routines
110376655d6dSaliguorifnmatch="no"
110476655d6dSaliguoricat > $TMPC << EOF
110576655d6dSaliguori#include <fnmatch.h>
110676655d6dSaliguoriint main(void)
110776655d6dSaliguori{
110876655d6dSaliguori    fnmatch("foo", "foo", 0);
110976655d6dSaliguori    return 0;
111076655d6dSaliguori}
111176655d6dSaliguoriEOF
111252166aa0SJuan Quintelaif compile_prog "" "" ; then
111376655d6dSaliguori   fnmatch="yes"
111476655d6dSaliguorifi
111576655d6dSaliguori
111676655d6dSaliguori##########################################
1117ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1118ee682d27SStefan Weilif test "$uuid" != "no" ; then
1119ee682d27SStefan Weil  uuid_libs="-luuid"
1120ee682d27SStefan Weil  cat > $TMPC << EOF
1121ee682d27SStefan Weil#include <uuid/uuid.h>
1122ee682d27SStefan Weilint main(void)
1123ee682d27SStefan Weil{
1124ee682d27SStefan Weil    uuid_t my_uuid;
1125ee682d27SStefan Weil    uuid_generate(my_uuid);
1126ee682d27SStefan Weil    return 0;
1127ee682d27SStefan Weil}
1128ee682d27SStefan WeilEOF
1129ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1130ee682d27SStefan Weil    uuid="yes"
1131ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1132ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1133ee682d27SStefan Weil  else
1134ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1135ee682d27SStefan Weil      feature_not_found "uuid"
1136ee682d27SStefan Weil    fi
1137ee682d27SStefan Weil    uuid=no
1138ee682d27SStefan Weil  fi
1139ee682d27SStefan Weilfi
1140ee682d27SStefan Weil
1141ee682d27SStefan Weil##########################################
11428a16d273Sths# vde libraries probe
1143dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
11444baae0acSJuan Quintela  vde_libs="-lvdeplug"
11458a16d273Sths  cat > $TMPC << EOF
11468a16d273Sths#include <libvdeplug.h>
11474a7f0e06Spbrookint main(void)
11484a7f0e06Spbrook{
11494a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
11504a7f0e06Spbrook    vde_open("", "", &a);
11514a7f0e06Spbrook    return 0;
11524a7f0e06Spbrook}
11538a16d273SthsEOF
115452166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
11554baae0acSJuan Quintela    vde=yes
11568e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
11578e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1158dfb278bdSJuan Quintela  else
1159dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1160dfb278bdSJuan Quintela      feature_not_found "vde"
1161dfb278bdSJuan Quintela    fi
1162dfb278bdSJuan Quintela    vde=no
11638a16d273Sths  fi
11648a16d273Sthsfi
11658a16d273Sths
11668a16d273Sths##########################################
1167c2de5c91Smalc# Sound support libraries probe
11688f28f3fbSths
1169c2de5c91Smalcaudio_drv_probe()
1170c2de5c91Smalc{
1171c2de5c91Smalc    drv=$1
1172c2de5c91Smalc    hdr=$2
1173c2de5c91Smalc    lib=$3
1174c2de5c91Smalc    exp=$4
1175c2de5c91Smalc    cfl=$5
11768f28f3fbSths        cat > $TMPC << EOF
1177c2de5c91Smalc#include <$hdr>
1178c2de5c91Smalcint main(void) { $exp }
11798f28f3fbSthsEOF
118052166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
11818f28f3fbSths        :
11828f28f3fbSths    else
11838f28f3fbSths        echo
1184c2de5c91Smalc        echo "Error: $drv check failed"
1185c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
11868f28f3fbSths        echo
11878f28f3fbSths        exit 1
11888f28f3fbSths    fi
1189c2de5c91Smalc}
1190c2de5c91Smalc
11912fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1192c2de5c91Smalcfor drv in $audio_drv_list; do
1193c2de5c91Smalc    case $drv in
1194c2de5c91Smalc    alsa)
1195c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1196c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1197a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1198c2de5c91Smalc    ;;
1199c2de5c91Smalc
1200c2de5c91Smalc    fmod)
1201c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1202c2de5c91Smalc        echo
1203c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1204c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1205c2de5c91Smalc        echo
1206c2de5c91Smalc        exit 1
12078f28f3fbSths    fi
1208c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1209a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1210c2de5c91Smalc    ;;
1211c2de5c91Smalc
1212c2de5c91Smalc    esd)
1213c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1214a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
121567f86e8eSJuan Quintela    audio_pt_int="yes"
1216c2de5c91Smalc    ;;
1217b8e59f18Smalc
1218b8e59f18Smalc    pa)
1219493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1220b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1221493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
122267f86e8eSJuan Quintela    audio_pt_int="yes"
1223b8e59f18Smalc    ;;
1224b8e59f18Smalc
1225997e690aSJuan Quintela    coreaudio)
1226997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1227997e690aSJuan Quintela    ;;
1228997e690aSJuan Quintela
1229a4bf6780SJuan Quintela    dsound)
1230a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1231d5631638Smalc      audio_win_int="yes"
1232a4bf6780SJuan Quintela    ;;
1233a4bf6780SJuan Quintela
1234a4bf6780SJuan Quintela    oss)
1235a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1236a4bf6780SJuan Quintela    ;;
1237a4bf6780SJuan Quintela
1238a4bf6780SJuan Quintela    sdl|wav)
12392f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
12402f6a1ab0Sblueswir1    ;;
12412f6a1ab0Sblueswir1
1242d5631638Smalc    winwave)
1243d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1244d5631638Smalc      audio_win_int="yes"
1245d5631638Smalc    ;;
1246d5631638Smalc
1247e4c63a6aSmalc    *)
12481c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1249e4c63a6aSmalc        echo
1250e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1251e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1252e4c63a6aSmalc        echo
1253e4c63a6aSmalc        exit 1
1254e4c63a6aSmalc    }
1255e4c63a6aSmalc    ;;
1256c2de5c91Smalc    esac
1257c2de5c91Smalcdone
12588f28f3fbSths
12594d3b6f6eSbalrog##########################################
12602e4d9fb1Saurel32# BrlAPI probe
12612e4d9fb1Saurel32
12624ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1263eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
12642e4d9fb1Saurel32  cat > $TMPC << EOF
12652e4d9fb1Saurel32#include <brlapi.h>
12662e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
12672e4d9fb1Saurel32EOF
126852166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
12692e4d9fb1Saurel32    brlapi=yes
1270264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
12714ffcedb6SJuan Quintela  else
12724ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
12734ffcedb6SJuan Quintela      feature_not_found "brlapi"
12744ffcedb6SJuan Quintela    fi
12754ffcedb6SJuan Quintela    brlapi=no
1276eb82284fSJuan Quintela  fi
1277eb82284fSJuan Quintelafi
12782e4d9fb1Saurel32
12792e4d9fb1Saurel32##########################################
12804d3b6f6eSbalrog# curses probe
12814f78ef9aSJuan Quintelacurses_list="-lncurses -lcurses"
12824d3b6f6eSbalrog
1283c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1284c584a6d0SJuan Quintela  curses_found=no
12854d3b6f6eSbalrog  cat > $TMPC << EOF
12864d3b6f6eSbalrog#include <curses.h>
12875a8ff3aaSblueswir1#ifdef __OpenBSD__
12885a8ff3aaSblueswir1#define resize_term resizeterm
12895a8ff3aaSblueswir1#endif
12905a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
12914d3b6f6eSbalrogEOF
12924f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
12934f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1294c584a6d0SJuan Quintela      curses_found=yes
12954f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
12964f78ef9aSJuan Quintela      break
12974d3b6f6eSbalrog    fi
12984f78ef9aSJuan Quintela  done
1299c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1300c584a6d0SJuan Quintela    curses=yes
1301c584a6d0SJuan Quintela  else
1302c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1303c584a6d0SJuan Quintela      feature_not_found "curses"
1304c584a6d0SJuan Quintela    fi
1305c584a6d0SJuan Quintela    curses=no
1306c584a6d0SJuan Quintela  fi
13074f78ef9aSJuan Quintelafi
13084d3b6f6eSbalrog
1309414f0dabSblueswir1##########################################
1310769ce76dSAlexander Graf# curl probe
1311769ce76dSAlexander Graf
1312788c8196SJuan Quintelaif test "$curl" != "no" ; then
1313769ce76dSAlexander Graf  cat > $TMPC << EOF
1314769ce76dSAlexander Graf#include <curl/curl.h>
1315769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1316769ce76dSAlexander GrafEOF
1317b1d5a277SJuan Quintela  curl_cflags=`curl-config --cflags 2>/dev/null`
131852368552SPaul Brook  curl_libs=`curl-config --libs 2>/dev/null`
1319b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1320769ce76dSAlexander Graf    curl=yes
1321f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1322f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1323788c8196SJuan Quintela  else
1324788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1325788c8196SJuan Quintela      feature_not_found "curl"
1326788c8196SJuan Quintela    fi
1327788c8196SJuan Quintela    curl=no
1328769ce76dSAlexander Graf  fi
1329769ce76dSAlexander Graffi # test "$curl"
1330769ce76dSAlexander Graf
1331769ce76dSAlexander Graf##########################################
13325495ed11SLuiz Capitulino# check framework probe
13335495ed11SLuiz Capitulino
13345495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
13355495ed11SLuiz Capitulino  cat > $TMPC << EOF
13365495ed11SLuiz Capitulino#include <check.h>
13375495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
13385495ed11SLuiz CapitulinoEOF
1339f91672e5SPaolo Bonzini  check_libs=`$pkgconfig --libs check`
13405495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
13415495ed11SLuiz Capitulino    check_utests=yes
13425495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
13435495ed11SLuiz Capitulino  else
13445495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
13455495ed11SLuiz Capitulino      feature_not_found "check"
13465495ed11SLuiz Capitulino    fi
13475495ed11SLuiz Capitulino    check_utests=no
13485495ed11SLuiz Capitulino  fi
13495495ed11SLuiz Capitulinofi # test "$check_utests"
13505495ed11SLuiz Capitulino
13515495ed11SLuiz Capitulino##########################################
1352fb599c9aSbalrog# bluez support probe
1353a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1354e820e3f4Sbalrog  cat > $TMPC << EOF
1355e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1356e820e3f4Sbalrogint main(void) { return bt_error(0); }
1357e820e3f4SbalrogEOF
1358f91672e5SPaolo Bonzini  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1359f91672e5SPaolo Bonzini  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
136052166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1361a20a6f46SJuan Quintela    bluez=yes
1362e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1363e820e3f4Sbalrog  else
1364a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1365a20a6f46SJuan Quintela      feature_not_found "bluez"
1366a20a6f46SJuan Quintela    fi
1367e820e3f4Sbalrog    bluez="no"
1368e820e3f4Sbalrog  fi
1369fb599c9aSbalrogfi
1370fb599c9aSbalrog
1371fb599c9aSbalrog##########################################
13727ba1e619Saliguori# kvm probe
1373b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
13747ba1e619Saliguori    cat > $TMPC <<EOF
13757ba1e619Saliguori#include <linux/kvm.h>
13769fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
13777ba1e619Saliguori#error Invalid KVM version
13787ba1e619Saliguori#endif
13799fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
13809fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
13819fd8d8d7Saliguori#endif
13829fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
13839fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
13849fd8d8d7Saliguori#endif
13859fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
13869fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
13879fd8d8d7Saliguori#endif
13887ba1e619Saliguoriint main(void) { return 0; }
13897ba1e619SaliguoriEOF
1390eac30262Saliguori  if test "$kerneldir" != "" ; then
1391eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
13928444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
13938444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
13948444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1395406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1396406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
13970e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
13980e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
13998444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
14008444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
14018444eb6eSaliguori      fi
1402eac30262Saliguori  else
1403ffd8b67fSJan Kiszka    kvm_cflags=`pkg-config --cflags kvm-kmod 2> /dev/null`
1404eac30262Saliguori  fi
140552166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1406b31a0277SJuan Quintela    kvm=yes
1407dae5079aSJan Kiszka    cat > $TMPC <<EOF
1408dae5079aSJan Kiszka#include <linux/kvm_para.h>
1409dae5079aSJan Kiszkaint main(void) { return 0; }
1410dae5079aSJan KiszkaEOF
1411dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1412dae5079aSJan Kiszka      kvm_para=yes
1413dae5079aSJan Kiszka    fi
14147ba1e619Saliguori  else
1415b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
14169fd8d8d7Saliguori      if [ -x "`which awk 2>/dev/null`" ] && \
14179fd8d8d7Saliguori         [ -x "`which grep 2>/dev/null`" ]; then
1418a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
14199fd8d8d7Saliguori	| grep "error: " \
14209fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
14219fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1422b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1423168ccc11SJan Kiszka      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1424168ccc11SJan Kiszka  recent kvm-kmod from http://sourceforge.net/projects/kvm."
14259fd8d8d7Saliguori        fi
14269fd8d8d7Saliguori      fi
1427b31a0277SJuan Quintela      feature_not_found "kvm"
1428b31a0277SJuan Quintela    fi
1429b31a0277SJuan Quintela    kvm=no
14307ba1e619Saliguori  fi
14317ba1e619Saliguorifi
14327ba1e619Saliguori
14337ba1e619Saliguori##########################################
1434e5d355d1Saliguori# pthread probe
1435de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
14363c529d93Saliguori
1437e5d355d1Saliguoripthread=no
1438414f0dabSblueswir1cat > $TMPC << EOF
14393c529d93Saliguori#include <pthread.h>
1440de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1441414f0dabSblueswir1EOF
1442de65fe0fSSebastian Herbsztfor pthread_lib in $PTHREADLIBS_LIST; do
144352166aa0SJuan Quintela  if compile_prog "" "$pthread_lib" ; then
1444e5d355d1Saliguori    pthread=yes
14455572b539SJuan Quintela    LIBS="$pthread_lib $LIBS"
1446de65fe0fSSebastian Herbszt    break
1447414f0dabSblueswir1  fi
1448de65fe0fSSebastian Herbsztdone
1449414f0dabSblueswir1
14504617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
14514dd75c70SChristoph Hellwig  echo
14524dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
14534dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
14544dd75c70SChristoph Hellwig  echo
14554dd75c70SChristoph Hellwig  exit 1
1456e5d355d1Saliguorifi
1457e5d355d1Saliguori
1458bf9298b9Saliguori##########################################
14595c6c3a6cSChristoph Hellwig# linux-aio probe
14605c6c3a6cSChristoph Hellwig
14615c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
14625c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
14635c6c3a6cSChristoph Hellwig#include <libaio.h>
14645c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
14655c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
14665c6c3a6cSChristoph HellwigEOF
14675c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
14685c6c3a6cSChristoph Hellwig    linux_aio=yes
14695c6c3a6cSChristoph Hellwig    LIBS="$LIBS -laio"
14705c6c3a6cSChristoph Hellwig  else
14715c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
14725c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
14735c6c3a6cSChristoph Hellwig    fi
14743cfcae3cSLuiz Capitulino    linux_aio=no
14755c6c3a6cSChristoph Hellwig  fi
14765c6c3a6cSChristoph Hellwigfi
14775c6c3a6cSChristoph Hellwig
14785c6c3a6cSChristoph Hellwig##########################################
1479bf9298b9Saliguori# iovec probe
1480bf9298b9Saliguoricat > $TMPC <<EOF
1481db34f0b3Sblueswir1#include <sys/types.h>
1482bf9298b9Saliguori#include <sys/uio.h>
1483db34f0b3Sblueswir1#include <unistd.h>
1484bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1485bf9298b9SaliguoriEOF
1486bf9298b9Saliguoriiovec=no
148752166aa0SJuan Quintelaif compile_prog "" "" ; then
1488bf9298b9Saliguori  iovec=yes
1489bf9298b9Saliguorifi
1490bf9298b9Saliguori
1491f652e6afSaurel32##########################################
1492ceb42de8Saliguori# preadv probe
1493ceb42de8Saliguoricat > $TMPC <<EOF
1494ceb42de8Saliguori#include <sys/types.h>
1495ceb42de8Saliguori#include <sys/uio.h>
1496ceb42de8Saliguori#include <unistd.h>
1497ceb42de8Saliguoriint main(void) { preadv; }
1498ceb42de8SaliguoriEOF
1499ceb42de8Saliguoripreadv=no
150052166aa0SJuan Quintelaif compile_prog "" "" ; then
1501ceb42de8Saliguori  preadv=yes
1502ceb42de8Saliguorifi
1503ceb42de8Saliguori
1504ceb42de8Saliguori##########################################
1505f652e6afSaurel32# fdt probe
15062df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1507b41af4baSJuan Quintela  fdt_libs="-lfdt"
1508f652e6afSaurel32  cat > $TMPC << EOF
1509f652e6afSaurel32int main(void) { return 0; }
1510f652e6afSaurel32EOF
151152166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1512f652e6afSaurel32    fdt=yes
1513e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
15142df87df7SJuan Quintela  else
15152df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
15162df87df7SJuan Quintela      feature_not_found "fdt"
15172df87df7SJuan Quintela    fi
15182df87df7SJuan Quintela    fdt=no
1519f652e6afSaurel32  fi
1520f652e6afSaurel32fi
1521f652e6afSaurel32
15223b3f24adSaurel32#
15233b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
15243b3f24adSaurel32# emulator.  This is done because older glibc versions don't
15253b3f24adSaurel32# have syscall stubs for these implemented.
15263b3f24adSaurel32#
15273b3f24adSaurel32atfile=no
15283b3f24adSaurel32cat > $TMPC << EOF
15293b3f24adSaurel32#define _ATFILE_SOURCE
15303b3f24adSaurel32#include <sys/types.h>
15313b3f24adSaurel32#include <fcntl.h>
15323b3f24adSaurel32#include <unistd.h>
15333b3f24adSaurel32
15343b3f24adSaurel32int
15353b3f24adSaurel32main(void)
15363b3f24adSaurel32{
15373b3f24adSaurel32	/* try to unlink nonexisting file */
15383b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
15393b3f24adSaurel32}
15403b3f24adSaurel32EOF
154152166aa0SJuan Quintelaif compile_prog "" "" ; then
15423b3f24adSaurel32  atfile=yes
15433b3f24adSaurel32fi
15443b3f24adSaurel32
154539386ac7Saurel32# Check for inotify functions when we are building linux-user
15463b3f24adSaurel32# emulator.  This is done because older glibc versions don't
15473b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
15483b3f24adSaurel32# don't provide them even if kernel supports them.
15493b3f24adSaurel32#
15503b3f24adSaurel32inotify=no
15513b3f24adSaurel32cat > $TMPC << EOF
15523b3f24adSaurel32#include <sys/inotify.h>
15533b3f24adSaurel32
15543b3f24adSaurel32int
15553b3f24adSaurel32main(void)
15563b3f24adSaurel32{
15573b3f24adSaurel32	/* try to start inotify */
15588690e420Saurel32	return inotify_init();
15593b3f24adSaurel32}
15603b3f24adSaurel32EOF
156152166aa0SJuan Quintelaif compile_prog "" "" ; then
15623b3f24adSaurel32  inotify=yes
15633b3f24adSaurel32fi
15643b3f24adSaurel32
1565ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1566ebc996f3SRiku Voipioutimens=no
1567ebc996f3SRiku Voipiocat > $TMPC << EOF
1568ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1569ebc996f3SRiku Voipio#define _GNU_SOURCE
1570ebc996f3SRiku Voipio#include <stddef.h>
1571ebc996f3SRiku Voipio#include <fcntl.h>
1572ebc996f3SRiku Voipio
1573ebc996f3SRiku Voipioint main(void)
1574ebc996f3SRiku Voipio{
1575ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1576ebc996f3SRiku Voipio    futimens(0, NULL);
1577ebc996f3SRiku Voipio    return 0;
1578ebc996f3SRiku Voipio}
1579ebc996f3SRiku VoipioEOF
158052166aa0SJuan Quintelaif compile_prog "" "" ; then
1581ebc996f3SRiku Voipio  utimens=yes
1582ebc996f3SRiku Voipiofi
1583ebc996f3SRiku Voipio
1584099d6b0fSRiku Voipio# check if pipe2 is there
1585099d6b0fSRiku Voipiopipe2=no
1586099d6b0fSRiku Voipiocat > $TMPC << EOF
1587099d6b0fSRiku Voipio#define _GNU_SOURCE
1588099d6b0fSRiku Voipio#include <unistd.h>
1589099d6b0fSRiku Voipio#include <fcntl.h>
1590099d6b0fSRiku Voipio
1591099d6b0fSRiku Voipioint main(void)
1592099d6b0fSRiku Voipio{
1593099d6b0fSRiku Voipio    int pipefd[2];
1594099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1595099d6b0fSRiku Voipio    return 0;
1596099d6b0fSRiku Voipio}
1597099d6b0fSRiku VoipioEOF
159852166aa0SJuan Quintelaif compile_prog "" "" ; then
1599099d6b0fSRiku Voipio  pipe2=yes
1600099d6b0fSRiku Voipiofi
1601099d6b0fSRiku Voipio
160240ff6d7eSKevin Wolf# check if accept4 is there
160340ff6d7eSKevin Wolfaccept4=no
160440ff6d7eSKevin Wolfcat > $TMPC << EOF
160540ff6d7eSKevin Wolf#define _GNU_SOURCE
160640ff6d7eSKevin Wolf#include <sys/socket.h>
160740ff6d7eSKevin Wolf#include <stddef.h>
160840ff6d7eSKevin Wolf
160940ff6d7eSKevin Wolfint main(void)
161040ff6d7eSKevin Wolf{
161140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
161240ff6d7eSKevin Wolf    return 0;
161340ff6d7eSKevin Wolf}
161440ff6d7eSKevin WolfEOF
161540ff6d7eSKevin Wolfif compile_prog "" "" ; then
161640ff6d7eSKevin Wolf  accept4=yes
161740ff6d7eSKevin Wolffi
161840ff6d7eSKevin Wolf
16193ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
16203ce34dfbSvibisreenivasansplice=no
16213ce34dfbSvibisreenivasancat > $TMPC << EOF
16223ce34dfbSvibisreenivasan#define _GNU_SOURCE
16233ce34dfbSvibisreenivasan#include <unistd.h>
16243ce34dfbSvibisreenivasan#include <fcntl.h>
16253ce34dfbSvibisreenivasan#include <limits.h>
16263ce34dfbSvibisreenivasan
16273ce34dfbSvibisreenivasanint main(void)
16283ce34dfbSvibisreenivasan{
16293ce34dfbSvibisreenivasan    int len, fd;
16303ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
16313ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
16323ce34dfbSvibisreenivasan    return 0;
16333ce34dfbSvibisreenivasan}
16343ce34dfbSvibisreenivasanEOF
163552166aa0SJuan Quintelaif compile_prog "" "" ; then
16363ce34dfbSvibisreenivasan  splice=yes
16373ce34dfbSvibisreenivasanfi
16383ce34dfbSvibisreenivasan
1639c2882b96SRiku Voipio# check if eventfd is supported
1640c2882b96SRiku Voipioeventfd=no
1641c2882b96SRiku Voipiocat > $TMPC << EOF
1642c2882b96SRiku Voipio#include <sys/eventfd.h>
1643c2882b96SRiku Voipio
1644c2882b96SRiku Voipioint main(void)
1645c2882b96SRiku Voipio{
1646c2882b96SRiku Voipio    int efd = eventfd(0, 0);
1647c2882b96SRiku Voipio    return 0;
1648c2882b96SRiku Voipio}
1649c2882b96SRiku VoipioEOF
1650c2882b96SRiku Voipioif compile_prog "" "" ; then
1651c2882b96SRiku Voipio  eventfd=yes
1652c2882b96SRiku Voipiofi
1653c2882b96SRiku Voipio
1654d0927938SUlrich Hecht# check for fallocate
1655d0927938SUlrich Hechtfallocate=no
1656d0927938SUlrich Hechtcat > $TMPC << EOF
1657d0927938SUlrich Hecht#include <fcntl.h>
1658d0927938SUlrich Hecht
1659d0927938SUlrich Hechtint main(void)
1660d0927938SUlrich Hecht{
1661d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
1662d0927938SUlrich Hecht    return 0;
1663d0927938SUlrich Hecht}
1664d0927938SUlrich HechtEOF
1665be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
1666d0927938SUlrich Hecht  fallocate=yes
1667d0927938SUlrich Hechtfi
1668d0927938SUlrich Hecht
1669d0927938SUlrich Hecht# check for dup3
1670d0927938SUlrich Hechtdup3=no
1671d0927938SUlrich Hechtcat > $TMPC << EOF
1672d0927938SUlrich Hecht#include <unistd.h>
1673d0927938SUlrich Hecht
1674d0927938SUlrich Hechtint main(void)
1675d0927938SUlrich Hecht{
1676d0927938SUlrich Hecht    dup3(0, 0, 0);
1677d0927938SUlrich Hecht    return 0;
1678d0927938SUlrich Hecht}
1679d0927938SUlrich HechtEOF
168078f5d726SJan Kiszkaif compile_prog "" "" ; then
1681d0927938SUlrich Hecht  dup3=yes
1682d0927938SUlrich Hechtfi
1683d0927938SUlrich Hecht
1684cc8ae6deSpbrook# Check if tools are available to build documentation.
1685a25dba17SJuan Quintelaif test "$docs" != "no" ; then
168683a3ab8bSJuan Quintela  if test -x "`which texi2html 2>/dev/null`" -a \
168783a3ab8bSJuan Quintela          -x "`which pod2man 2>/dev/null`" ; then
1688a25dba17SJuan Quintela    docs=yes
168983a3ab8bSJuan Quintela  else
1690a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
1691a25dba17SJuan Quintela      feature_not_found "docs"
169283a3ab8bSJuan Quintela    fi
1693a25dba17SJuan Quintela    docs=no
169483a3ab8bSJuan Quintela  fi
1695cc8ae6deSpbrookfi
1696cc8ae6deSpbrook
1697f514f41cSStefan Weil# Search for bswap_32 function
16986ae9a1f4SJuan Quintelabyteswap_h=no
16996ae9a1f4SJuan Quintelacat > $TMPC << EOF
17006ae9a1f4SJuan Quintela#include <byteswap.h>
17016ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
17026ae9a1f4SJuan QuintelaEOF
170352166aa0SJuan Quintelaif compile_prog "" "" ; then
17046ae9a1f4SJuan Quintela  byteswap_h=yes
17056ae9a1f4SJuan Quintelafi
17066ae9a1f4SJuan Quintela
1707f514f41cSStefan Weil# Search for bswap_32 function
17086ae9a1f4SJuan Quintelabswap_h=no
17096ae9a1f4SJuan Quintelacat > $TMPC << EOF
17106ae9a1f4SJuan Quintela#include <sys/endian.h>
17116ae9a1f4SJuan Quintela#include <sys/types.h>
17126ae9a1f4SJuan Quintela#include <machine/bswap.h>
17136ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
17146ae9a1f4SJuan QuintelaEOF
171552166aa0SJuan Quintelaif compile_prog "" "" ; then
17166ae9a1f4SJuan Quintela  bswap_h=yes
17176ae9a1f4SJuan Quintelafi
17186ae9a1f4SJuan Quintela
1719da93a1fdSaliguori##########################################
1720da93a1fdSaliguori# Do we need librt
1721da93a1fdSaliguoricat > $TMPC <<EOF
1722da93a1fdSaliguori#include <signal.h>
1723da93a1fdSaliguori#include <time.h>
1724da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
1725da93a1fdSaliguoriEOF
1726da93a1fdSaliguori
172752166aa0SJuan Quintelaif compile_prog "" "" ; then
172807ffa4bdSJuan Quintela  :
172952166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
173007ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
1731da93a1fdSaliguorifi
1732da93a1fdSaliguori
173331ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
17346362a53fSJuan Quintela        "$aix" != "yes" ; then
17356362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
17366362a53fSJuan Quintelafi
17376362a53fSJuan Quintela
1738de5071c5SBlue Swirl##########################################
1739de5071c5SBlue Swirl# check if the compiler defines offsetof
1740de5071c5SBlue Swirl
1741de5071c5SBlue Swirlneed_offsetof=yes
1742de5071c5SBlue Swirlcat > $TMPC << EOF
1743de5071c5SBlue Swirl#include <stddef.h>
1744de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
1745de5071c5SBlue SwirlEOF
1746de5071c5SBlue Swirlif compile_prog "" "" ; then
1747de5071c5SBlue Swirl    need_offsetof=no
1748de5071c5SBlue Swirlfi
1749de5071c5SBlue Swirl
17505f6b9e8fSBlue Swirl##########################################
1751747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
1752747bbdf7SBlue Swirl#
1753747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
1754747bbdf7SBlue Swirl# about attribute warn_unused_result
1755747bbdf7SBlue Swirl
1756747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
1757747bbdf7SBlue Swirlcat > $TMPC << EOF
1758747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
1759747bbdf7SBlue Swirl#error gcc 3.3 or older
1760747bbdf7SBlue Swirl#endif
1761747bbdf7SBlue Swirlint main(void) { return 0;}
1762747bbdf7SBlue SwirlEOF
1763747bbdf7SBlue Swirlif compile_prog "" ""; then
1764747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
1765747bbdf7SBlue Swirlfi
1766747bbdf7SBlue Swirl
1767747bbdf7SBlue Swirl##########################################
17685f6b9e8fSBlue Swirl# check if we have fdatasync
17695f6b9e8fSBlue Swirl
17705f6b9e8fSBlue Swirlfdatasync=no
17715f6b9e8fSBlue Swirlcat > $TMPC << EOF
17725f6b9e8fSBlue Swirl#include <unistd.h>
17735f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
17745f6b9e8fSBlue SwirlEOF
17755f6b9e8fSBlue Swirlif compile_prog "" "" ; then
17765f6b9e8fSBlue Swirl    fdatasync=yes
17775f6b9e8fSBlue Swirlfi
17785f6b9e8fSBlue Swirl
1779e86ecd4bSJuan Quintela# End of CC checks
1780e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
1781e86ecd4bSJuan Quintela
1782e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
17831156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
1784e86ecd4bSJuan Quintelafi
1785a316e378SJuan Quintela
1786e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
1787e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
1788e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
178920ff6c80SAnthony Liguori
179020ff6c80SAnthony Liguoriif test -z "$werror" ; then
1791e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
1792e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
1793e86ecd4bSJuan Quintela        werror="yes"
1794e86ecd4bSJuan Quintela    else
1795e86ecd4bSJuan Quintela        werror="no"
1796e86ecd4bSJuan Quintela    fi
1797e86ecd4bSJuan Quintelafi
1798e86ecd4bSJuan Quintela
179920ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
180020ff6c80SAnthony Liguori# enable/disable
180120ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
180220ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
180320ff6c80SAnthony Liguori	zero_malloc="no"
180420ff6c80SAnthony Liguori    else
180520ff6c80SAnthony Liguori	zero_malloc="yes"
180620ff6c80SAnthony Liguori    fi
180720ff6c80SAnthony Liguorifi
180820ff6c80SAnthony Liguori
1809e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
1810a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1811e86ecd4bSJuan Quintelafi
1812e86ecd4bSJuan Quintela
1813e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
1814e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
18151156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
1816e86ecd4bSJuan Quintela    fi
1817e86ecd4bSJuan Quintelafi
1818e86ecd4bSJuan Quintela
181911d9f695Sbellardif test "$mingw32" = "yes" ; then
182011d9f695Sbellard  if test -z "$prefix" ; then
182155418b96SStefan Weil      prefix="c:/Program Files/Qemu"
182211d9f695Sbellard  fi
1823308c3593Spbrook  mansuffix=""
1824308c3593Spbrook  datasuffix=""
1825308c3593Spbrook  docsuffix=""
1826308c3593Spbrook  binsuffix=""
182711d9f695Sbellardelse
182811d9f695Sbellard  if test -z "$prefix" ; then
182911d9f695Sbellard      prefix="/usr/local"
183011d9f695Sbellard  fi
1831308c3593Spbrook  mansuffix="/share/man"
1832308c3593Spbrook  datasuffix="/share/qemu"
1833308c3593Spbrook  docsuffix="/share/doc/qemu"
1834308c3593Spbrook  binsuffix="/bin"
183511d9f695Sbellardfi
18365a67135aSbellard
18377d13299dSbellardecho "Install prefix    $prefix"
1838308c3593Spbrookecho "BIOS directory    $prefix$datasuffix"
1839308c3593Spbrookecho "binary directory  $prefix$binsuffix"
184011d9f695Sbellardif test "$mingw32" = "no" ; then
1841308c3593Spbrookecho "Manual directory  $prefix$mansuffix"
184243ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
184311d9f695Sbellardfi
18445a67135aSbellardecho "Source path       $source_path"
18457d13299dSbellardecho "C compiler        $cc"
184683469015Sbellardecho "Host C compiler   $host_cc"
18470c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
1848a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
18490c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
18507d13299dSbellardecho "make              $make"
18516a882643Spbrookecho "install           $install"
1852a98fd896Sbellardecho "host CPU          $cpu"
1853de83cd02Sbellardecho "host big endian   $bigendian"
185497a847bcSbellardecho "target list       $target_list"
1855ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
18567d13299dSbellardecho "gprof enabled     $gprof"
185703b4fe7dSaliguoriecho "sparse enabled    $sparse"
18581625af87Saliguoriecho "strip binaries    $strip_opt"
185905c2a3e7Sbellardecho "profiler          $profiler"
186043ce4dfeSbellardecho "static build      $static"
186185aa5189Sbellardecho "-Werror enabled   $werror"
18625b0753e0Sbellardif test "$darwin" = "yes" ; then
18635b0753e0Sbellard    echo "Cocoa support     $cocoa"
18645b0753e0Sbellardfi
186597a847bcSbellardecho "SDL support       $sdl"
18664d3b6f6eSbalrogecho "curses support    $curses"
1867769ce76dSAlexander Grafecho "curl support      $curl"
18685495ed11SLuiz Capitulinoecho "check support     $check_utests"
186967b915a5Sbellardecho "mingw32 support   $mingw32"
18700c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
18710c58ac1cSmalcecho "Extra audio cards $audio_card_list"
1872eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
18738ff9cbf7Smalcecho "Mixer emulation   $mixemu"
18748d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
18752f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
18763142255cSblueswir1if test -n "$sparc_cpu"; then
18773142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
18783142255cSblueswir1fi
1879e37630caSaliguoriecho "xen support       $xen"
18802e4d9fb1Saurel32echo "brlapi support    $brlapi"
1881a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
1882a25dba17SJuan Quintelaecho "Documentation     $docs"
1883c5937220Spbrook[ ! -z "$uname_release" ] && \
1884c5937220Spbrookecho "uname -r          $uname_release"
1885bd0c5661Spbrookecho "NPTL support      $nptl"
1886379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
188734005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
18888a16d273Sthsecho "vde support       $vde"
1889e5d355d1Saliguoriecho "IO thread         $io_thread"
18905c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
189177755340Sthsecho "Install blobs     $blobs"
1892b31a0277SJuan Quintelaecho "KVM support       $kvm"
1893f652e6afSaurel32echo "fdt support       $fdt"
1894ceb42de8Saliguoriecho "preadv support    $preadv"
18955f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
1896ee682d27SStefan Weilecho "uuid support      $uuid"
189767b915a5Sbellard
189897a847bcSbellardif test $sdl_too_old = "yes"; then
189924b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
1900e8cd23deSbellardfi
190197a847bcSbellard
190298ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
19034bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
190497a847bcSbellard
190598ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
190698ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
190798ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
190898ec69acSJuan Quintelaecho >> $config_host_mak
190998ec69acSJuan Quintela
19102358a494SJuan Quintelaecho "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
1911804edf29SJuan Quintela
19122408a527Saurel32case "$cpu" in
191324e804ecSAlexander Graf  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1914e0da9dd3SJuan Quintela    ARCH=$cpu
19152408a527Saurel32  ;;
1916a302c32dSLaurent Desnogues  armv4b|armv4l)
191716dbd14fSJuan Quintela    ARCH=arm
19182408a527Saurel32  ;;
19192408a527Saurel32  *)
19203142255cSblueswir1    echo "Unsupported CPU = $cpu"
19217d13299dSbellard    exit 1
19222408a527Saurel32  ;;
19232408a527Saurel32esac
192498ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
1925f8393946Saurel32if test "$debug_tcg" = "yes" ; then
19262358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1927f8393946Saurel32fi
1928f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
19292358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
1930f3d08ee6SPaul Brookfi
19311625af87Saliguoriif test "$strip_opt" = "yes" ; then
193298ec69acSJuan Quintela  echo "STRIP_OPT=-s" >> $config_host_mak
19331625af87Saliguorifi
19347d13299dSbellardif test "$bigendian" = "yes" ; then
1935e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
193697a847bcSbellardfi
19372358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
193867b915a5Sbellardif test "$mingw32" = "yes" ; then
193998ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
1940210fa556Spbrookelse
194135f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
1942210fa556Spbrookfi
1943128ab2ffSblueswir1
1944dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
1945dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
1946dffcb71cSMark McLoughlinfi
1947dffcb71cSMark McLoughlin
194883fb7adfSbellardif test "$darwin" = "yes" ; then
194998ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
195083fb7adfSbellardfi
1951b29fe3edSmalc
1952b29fe3edSmalcif test "$aix" = "yes" ; then
195398ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
1954b29fe3edSmalcfi
1955b29fe3edSmalc
1956ec530c81Sbellardif test "$solaris" = "yes" ; then
195798ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
19582358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
19590475a5caSths  if test "$needs_libsunmath" = "yes" ; then
196075b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
19610475a5caSths  fi
1962ec530c81Sbellardfi
196397a847bcSbellardif test "$static" = "yes" ; then
196498ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
19651156c669SJuan Quintela  LDFLAGS="-static $LDFLAGS"
196697a847bcSbellardfi
196705c2a3e7Sbellardif test $profiler = "yes" ; then
19682358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
196905c2a3e7Sbellardfi
1970c20709aaSbellardif test "$slirp" = "yes" ; then
197198ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
1972b6e31c12SJuan Quintela  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
1973c20709aaSbellardfi
19748a16d273Sthsif test "$vde" = "yes" ; then
197598ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
19768a16d273Sthsfi
19770c58ac1cSmalcfor card in $audio_card_list; do
1978f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
197998ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
19800c58ac1cSmalcdone
19812358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
19820c58ac1cSmalcfor drv in $audio_drv_list; do
1983f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
198498ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
1985923e4521Smalc    if test "$drv" = "fmod"; then
19867aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
1987fb065187Sbellard    fi
19880c58ac1cSmalcdone
198967f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
199067f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
199167f86e8eSJuan Quintelafi
1992d5631638Smalcif test "$audio_win_int" = "yes" ; then
1993d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
1994d5631638Smalcfi
1995eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
19968ff9cbf7Smalcif test "$mixemu" = "yes" ; then
199798ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
19988ff9cbf7Smalcfi
19998d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
200098ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2001525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
20028d5d2d4cSthsfi
20032f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
200498ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
200560ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
20062f9606b3Saliguorifi
200776655d6dSaliguoriif test "$fnmatch" = "yes" ; then
20082358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
200976655d6dSaliguorifi
2010ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2011ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2012ee682d27SStefan Weilfi
2013b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
201498ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
20152358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
201698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
201798ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2018a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
201998ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2020cc8ae6deSpbrookfi
20211ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
202298ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
20238ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
202449ecc3faSbellardfi
202549ecc3faSbellardif test "$cocoa" = "yes" ; then
202698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
202749ecc3faSbellardfi
20284d3b6f6eSbalrogif test "$curses" = "yes" ; then
202998ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2030ab4e5602SJan Kiszkafi
20313b3f24adSaurel32if test "$atfile" = "yes" ; then
20322358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
20333b3f24adSaurel32fi
2034ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
20352358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2036ebc996f3SRiku Voipiofi
2037099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
20382358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2039099d6b0fSRiku Voipiofi
204040ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
204140ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
204240ff6d7eSKevin Wolffi
20433ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
20442358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
20453ce34dfbSvibisreenivasanfi
2046c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2047c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2048c2882b96SRiku Voipiofi
2049d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2050d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2051d0927938SUlrich Hechtfi
2052d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2053d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2054d0927938SUlrich Hechtfi
20553b3f24adSaurel32if test "$inotify" = "yes" ; then
20562358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
20573b3f24adSaurel32fi
20586ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
20596ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
20606ae9a1f4SJuan Quintelafi
20616ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
20626ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
20636ae9a1f4SJuan Quintelafi
2064769ce76dSAlexander Grafif test "$curl" = "yes" ; then
206598ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2066b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2067769ce76dSAlexander Graffi
20682e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
206998ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
20702e4d9fb1Saurel32fi
2071fb599c9aSbalrogif test "$bluez" = "yes" ; then
207298ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2073ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2074fb599c9aSbalrogfi
2075e37630caSaliguoriif test "$xen" = "yes" ; then
20765647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2077e37630caSaliguorifi
2078e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
207998ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2080e5d355d1Saliguorifi
20815c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
20825c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
20835c6c3a6cSChristoph Hellwigfi
208477755340Sthsif test "$blobs" = "yes" ; then
208598ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
208677755340Sthsfi
2087bf9298b9Saliguoriif test "$iovec" = "yes" ; then
20882358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2089bf9298b9Saliguorifi
2090ceb42de8Saliguoriif test "$preadv" = "yes" ; then
20912358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2092ceb42de8Saliguorifi
2093f652e6afSaurel32if test "$fdt" = "yes" ; then
20943f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2095f652e6afSaurel32fi
2096de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2097de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2098de5071c5SBlue Swirlfi
2099747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2100747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2101747bbdf7SBlue Swirlfi
21025f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
21035f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
21045f6b9e8fSBlue Swirlfi
210597a847bcSbellard
210683fb7adfSbellard# XXX: suppress that
21077d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
21082358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
21097d3505c5Sbellardfi
21107d3505c5Sbellard
21112358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2112c5937220Spbrook
211320ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
211420ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
211520ff6c80SAnthony Liguorifi
211620ff6c80SAnthony Liguori
211768063649Sblueswir1# USB host support
211868063649Sblueswir1case "$usb" in
211968063649Sblueswir1linux)
212098ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
212168063649Sblueswir1;;
212268063649Sblueswir1bsd)
212398ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
212468063649Sblueswir1;;
212568063649Sblueswir1*)
212698ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
212768063649Sblueswir1;;
212868063649Sblueswir1esac
212968063649Sblueswir1
2130c39e3338Spbrooktools=
2131c39e3338Spbrookif test `expr "$target_list" : ".*softmmu.*"` != 0 ; then
213286355e07SAurelien Jarno  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
21332bff4b6fSBlue Swirl  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
213486355e07SAurelien Jarno      tools="qemu-nbd\$(EXESUF) $tools"
21355495ed11SLuiz Capitulino    if [ "$check_utests" = "yes" ]; then
21363aa3dcffSLuiz Capitulino      tools="check-qint check-qstring check-qdict check-qlist $tools"
2137422c46a8SAnthony Liguori      tools="check-qfloat check-qjson $tools"
21385495ed11SLuiz Capitulino    fi
21397a5ca864Sbellard  fi
2140c39e3338Spbrookfi
214198ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
2142c39e3338Spbrook
2143161294d8SJuan Quintela# Mac OS X ships with a broken assembler
2144253d0942SAlexander Grafroms=
2145161294d8SJuan Quintelaif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2146ea5ad306SAndreas Faerber        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2147b461cdc9SBlue Swirl        `expr "$target_list" : ".*softmmu.*"` != 0 ; then
2148c05ac895SPaul Brook  roms="optionrom"
2149253d0942SAlexander Graffi
215098ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2151253d0942SAlexander Graf
2152804edf29SJuan Quintelaecho "prefix=$prefix" >> $config_host_mak
2153804edf29SJuan Quintelaecho "bindir=\${prefix}$binsuffix" >> $config_host_mak
2154804edf29SJuan Quintelaecho "mandir=\${prefix}$mansuffix" >> $config_host_mak
2155804edf29SJuan Quintelaecho "datadir=\${prefix}$datasuffix" >> $config_host_mak
2156804edf29SJuan Quintelaecho "docdir=\${prefix}$docsuffix" >> $config_host_mak
2157804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2158804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2159804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2160804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2161804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2162804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
2163804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2164804edf29SJuan Quintelaif test "$sparse" = "yes" ; then
2165804edf29SJuan Quintela  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2166804edf29SJuan Quintela  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2167a558ee17SJuan Quintela  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2168804edf29SJuan Quintelafi
2169804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2170804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2171804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
2172e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2173a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2174c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2175e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2176a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2177a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
217873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
21793e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2180804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2181804edf29SJuan Quintela
21824bf6b55bSJuan Quintela# generate list of library paths for linker script
21834bf6b55bSJuan Quintela
21844bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
21854bf6b55bSJuan Quintela
21864bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
21874bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
21884bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
21894bf6b55bSJuan Quintela  else
21904bf6b55bSJuan Quintela    rm ${config_host_ld}~
21914bf6b55bSJuan Quintela  fi
21924bf6b55bSJuan Quintelafi
21934bf6b55bSJuan Quintela
219497a847bcSbellardfor target in $target_list; do
219597a847bcSbellardtarget_dir="$target"
219625be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2197600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
219897a847bcSbellardtarget_bigendian="no"
21991f3d3c8fSJuan Quintela
2200ea2d6a39SJuan Quintelacase "$target_arch2" in
220124e804ecSAlexander Graf  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2202ea2d6a39SJuan Quintela  target_bigendian=yes
2203ea2d6a39SJuan Quintela  ;;
2204ea2d6a39SJuan Quintelaesac
220597a847bcSbellardtarget_softmmu="no"
2206997344f3Sbellardtarget_user_only="no"
2207831b7825Sthstarget_linux_user="no"
2208831b7825Sthstarget_darwin_user="no"
220984778508Sblueswir1target_bsd_user="no"
22109e407a85Spbrookcase "$target" in
2211600309b6SBlue Swirl  ${target_arch2}-softmmu)
22129e407a85Spbrook    target_softmmu="yes"
22139e407a85Spbrook    ;;
2214600309b6SBlue Swirl  ${target_arch2}-linux-user)
22159c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
22169c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
22179c7a4202SBlue Swirl      exit 1
22189c7a4202SBlue Swirl    fi
22199e407a85Spbrook    target_user_only="yes"
22209e407a85Spbrook    target_linux_user="yes"
22219e407a85Spbrook    ;;
2222600309b6SBlue Swirl  ${target_arch2}-darwin-user)
22239c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
22249c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
22259c7a4202SBlue Swirl      exit 1
22269c7a4202SBlue Swirl    fi
22279e407a85Spbrook    target_user_only="yes"
2228831b7825Sths    target_darwin_user="yes"
22299e407a85Spbrook    ;;
2230600309b6SBlue Swirl  ${target_arch2}-bsd-user)
22319cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
22329c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
22339c7a4202SBlue Swirl      exit 1
22349c7a4202SBlue Swirl    fi
223584778508Sblueswir1    target_user_only="yes"
223684778508Sblueswir1    target_bsd_user="yes"
223784778508Sblueswir1    ;;
22389e407a85Spbrook  *)
22399e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
22409e407a85Spbrook    exit 1
22419e407a85Spbrook    ;;
22429e407a85Spbrookesac
2243831b7825Sths
224497a847bcSbellardmkdir -p $target_dir
2245158142c2Sbellardmkdir -p $target_dir/fpu
224657fec1feSbellardmkdir -p $target_dir/tcg
224759f2a787SGerd Hoffmannmkdir -p $target_dir/ide
224884778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
224969de927cSbellard  mkdir -p $target_dir/nwfpe
225069de927cSbellardfi
225169de927cSbellard
2252ec530c81Sbellard#
2253ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
2254ec530c81Sbellard#
2255ec530c81Sbellardrm -f $target_dir/Makefile
2256ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
2257ec530c81Sbellard
225897a847bcSbellard
225925be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
226097a847bcSbellard
2261e5fe0c52Spbrookbflt="no"
2262cb33da57Sblueswir1elfload32="no"
2263bd0c5661Spbrooktarget_nptl="no"
2264600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
226525be210fSJuan Quintelaecho "CONFIG_QEMU_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
226656aebc89Spbrookgdb_xml_files=""
22677ba1e619Saliguori
2268938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
22696acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2270e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2271e73aae67SJuan Quintela
2272600309b6SBlue Swirlcase "$target_arch2" in
22732408a527Saurel32  i386)
22741ad2134fSPaul Brook    target_phys_bits=32
22752408a527Saurel32  ;;
22762408a527Saurel32  x86_64)
22776acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
22781ad2134fSPaul Brook    target_phys_bits=64
22792408a527Saurel32  ;;
22802408a527Saurel32  alpha)
22811ad2134fSPaul Brook    target_phys_bits=64
22822408a527Saurel32  ;;
22832408a527Saurel32  arm|armeb)
2284b498c8a0SJuan Quintela    TARGET_ARCH=arm
2285e5fe0c52Spbrook    bflt="yes"
2286bd0c5661Spbrook    target_nptl="yes"
228756aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
22881ad2134fSPaul Brook    target_phys_bits=32
22892408a527Saurel32  ;;
22902408a527Saurel32  cris)
2291253bd7f8Sedgar_igl    target_nptl="yes"
22921ad2134fSPaul Brook    target_phys_bits=32
22932408a527Saurel32  ;;
22942408a527Saurel32  m68k)
22950938cda5Saurel32    bflt="yes"
229656aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
22971ad2134fSPaul Brook    target_phys_bits=32
22982408a527Saurel32  ;;
229972b675caSEdgar E. Iglesias  microblaze)
230072b675caSEdgar E. Iglesias    bflt="yes"
230172b675caSEdgar E. Iglesias    target_nptl="yes"
230272b675caSEdgar E. Iglesias    target_phys_bits=32
230372b675caSEdgar E. Iglesias  ;;
23042408a527Saurel32  mips|mipsel)
2305b498c8a0SJuan Quintela    TARGET_ARCH=mips
230625be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2307f04dc72fSPaul Brook    target_nptl="yes"
23081ad2134fSPaul Brook    target_phys_bits=64
23092408a527Saurel32  ;;
23102408a527Saurel32  mipsn32|mipsn32el)
2311b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
23126acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
231325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
23141ad2134fSPaul Brook    target_phys_bits=64
23152408a527Saurel32  ;;
23162408a527Saurel32  mips64|mips64el)
2317b498c8a0SJuan Quintela    TARGET_ARCH=mips64
23186acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
231925be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
23201ad2134fSPaul Brook    target_phys_bits=64
23212408a527Saurel32  ;;
23222408a527Saurel32  ppc)
2323c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23241ad2134fSPaul Brook    target_phys_bits=32
2325d6630708SNathan Froyd    target_nptl="yes"
23262408a527Saurel32  ;;
23272408a527Saurel32  ppcemb)
23286acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2329e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2330c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23311ad2134fSPaul Brook    target_phys_bits=64
2332d6630708SNathan Froyd    target_nptl="yes"
23332408a527Saurel32  ;;
23342408a527Saurel32  ppc64)
23356acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2336e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2337c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23381ad2134fSPaul Brook    target_phys_bits=64
23392408a527Saurel32  ;;
23402408a527Saurel32  ppc64abi32)
2341b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
23426acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2343e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
234425be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
2345c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
23461ad2134fSPaul Brook    target_phys_bits=64
23472408a527Saurel32  ;;
23482408a527Saurel32  sh4|sh4eb)
2349b498c8a0SJuan Quintela    TARGET_ARCH=sh4
23504dbed897Spbrook    bflt="yes"
23510b6d3ae0Saurel32    target_nptl="yes"
23521ad2134fSPaul Brook    target_phys_bits=32
23532408a527Saurel32  ;;
23542408a527Saurel32  sparc)
23551ad2134fSPaul Brook    target_phys_bits=64
23562408a527Saurel32  ;;
23572408a527Saurel32  sparc64)
23586acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
23590938cda5Saurel32    elfload32="yes"
23601ad2134fSPaul Brook    target_phys_bits=64
23612408a527Saurel32  ;;
23622408a527Saurel32  sparc32plus)
2363b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
23646acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
2365e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
236625be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
23671ad2134fSPaul Brook    target_phys_bits=64
23682408a527Saurel32  ;;
236924e804ecSAlexander Graf  s390x)
237024e804ecSAlexander Graf    target_phys_bits=64
237124e804ecSAlexander Graf  ;;
23722408a527Saurel32  *)
2373de83cd02Sbellard    echo "Unsupported target CPU"
2374de83cd02Sbellard    exit 1
23752408a527Saurel32  ;;
23762408a527Saurel32esac
237725be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2378053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
237925be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
238025be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
238142bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
23826acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
23836acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
23846acff7daSJuan Quintelafi
238525be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2386e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
2387e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
2388e6e91b9cSJuan Quintelafi
238925be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
23901ad2134fSPaul Brookif [ $target_phys_bits -lt $hostlongbits ] ; then
23911ad2134fSPaul Brook  target_phys_bits=$hostlongbits
23921ad2134fSPaul Brookfi
23931b0c87fcSJuan Quintelacase "$target_arch2" in
23941b0c87fcSJuan Quintela  i386|x86_64)
23951b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
239625be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
23971b0c87fcSJuan Quintela    fi
23981b0c87fcSJuan Quintelaesac
2399c59249f9SJuan Quintelacase "$target_arch2" in
24000e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
2401c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
2402c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2403c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
2404c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
24055f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2406c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2407c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
240825be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
240925be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2410dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
2411dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
2412dae5079aSJan Kiszka      fi
2413c59249f9SJuan Quintela    fi
2414c59249f9SJuan Quintelaesac
241525be210fSJuan Quintelaecho "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
2416de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
241725be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
241897a847bcSbellardfi
241997a847bcSbellardif test "$target_softmmu" = "yes" ; then
242025be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
242125be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
24220e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
24235791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2424de83cd02Sbellardfi
2425997344f3Sbellardif test "$target_user_only" = "yes" ; then
242625be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2427997344f3Sbellardfi
2428831b7825Sthsif test "$target_linux_user" = "yes" ; then
242925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2430831b7825Sthsfi
2431831b7825Sthsif test "$target_darwin_user" = "yes" ; then
243225be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2433831b7825Sthsfi
243456aebc89Spbrooklist=""
243556aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
243656aebc89Spbrook  for x in $gdb_xml_files; do
243756aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
243856aebc89Spbrook  done
243925be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
24403d0f1517SJuan Quintelafi
2441de83cd02Sbellard
2442f57975fbSJuan Quintelacase "$target_arch2" in
2443990b3e19SRichard Henderson  alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
244425be210fSJuan Quintela    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2445f57975fbSJuan Quintela    ;;
2446d6b38939SJuan Quintela  *)
244725be210fSJuan Quintela    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2448d6b38939SJuan Quintela    ;;
2449f57975fbSJuan Quintelaesac
2450f57975fbSJuan Quintela
2451e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
245225be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2453e5fe0c52Spbrookfi
2454bd0c5661Spbrookif test "$target_user_only" = "yes" \
2455bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
245625be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2457bd0c5661Spbrookfi
2458cb33da57Sblueswir1# 32 bit ELF loader in addition to native 64 bit loader?
2459cb33da57Sblueswir1if test "$target_user_only" = "yes" -a "$elfload32" = "yes"; then
246025be210fSJuan Quintela  echo "TARGET_HAS_ELFLOAD32=y" >> $config_target_mak
2461cb33da57Sblueswir1fi
2462379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
246325be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2464379f6698SPaul Brookfi
246584778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
246625be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
246784778508Sblueswir1fi
24685b0753e0Sbellard
24694afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
2470fa282484SJuan Quintela
24714afddb55SJuan Quintelacflags=""
2472fa282484SJuan Quintelaldflags=""
24739b8e111fSJuan Quintela
247457ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
247557ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
247624e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
247724e804ecSAlexander Graf  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
247857ddfbf7SJuan Quintelaelse
247957ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
248057ddfbf7SJuan Quintelafi
248157ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/tcg $cflags"
248257ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/fpu $cflags"
248357ddfbf7SJuan Quintela
248464656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
248564656024SJuan Quintela  case "$i" in
248664656024SJuan Quintela  alpha)
248725be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
248864656024SJuan Quintela  ;;
248964656024SJuan Quintela  arm)
249025be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
249164656024SJuan Quintela  ;;
249264656024SJuan Quintela  cris)
249325be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
249464656024SJuan Quintela  ;;
249564656024SJuan Quintela  hppa)
249625be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
249764656024SJuan Quintela  ;;
249864656024SJuan Quintela  i386|x86_64)
249925be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
250064656024SJuan Quintela  ;;
250164656024SJuan Quintela  m68k)
250225be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
250364656024SJuan Quintela  ;;
250464656024SJuan Quintela  microblaze)
250525be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
250664656024SJuan Quintela  ;;
250764656024SJuan Quintela  mips*)
250825be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
250964656024SJuan Quintela  ;;
251064656024SJuan Quintela  ppc*)
251125be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
251264656024SJuan Quintela  ;;
251324e804ecSAlexander Graf  s390*)
251425be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
251564656024SJuan Quintela  ;;
251664656024SJuan Quintela  sh4)
251725be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
251864656024SJuan Quintela  ;;
251964656024SJuan Quintela  sparc*)
252025be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
252164656024SJuan Quintela  ;;
252264656024SJuan Quintela  esac
252364656024SJuan Quinteladone
252464656024SJuan Quintela
25256ee7126fSJuan Quintelacase "$ARCH" in
25266ee7126fSJuan Quintelaalpha)
25276ee7126fSJuan Quintela  # Ensure there's only a single GP
25286ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
25296ee7126fSJuan Quintela;;
2530c60d0afaSJuan Quintelaia64)
2531c60d0afaSJuan Quintela  cflags="-mno-sdata $cflags"
2532c60d0afaSJuan Quintela;;
25336ee7126fSJuan Quintelaesac
25346ee7126fSJuan Quintela
253555d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
253655d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
253755d9c04bSJuan Quintela  arm)
253855d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
253955d9c04bSJuan Quintela  ;;
254055d9c04bSJuan Quintela  i386|mips|ppc)
254155d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
254255d9c04bSJuan Quintela  ;;
254355d9c04bSJuan Quintela  esac
254455d9c04bSJuan Quintelafi
254555d9c04bSJuan Quintela
254634005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
254734005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
254834005a00SKirill A. Shutemov  cflags="-fpie $cflags"
254934005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
255034005a00SKirill A. Shutemovfi
255134005a00SKirill A. Shutemov
2552471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
2553471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
2554471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
255525be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
2556471857ddSJuan Quintelafi
2557471857ddSJuan Quintela
2558d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
255925be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
2560d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
2561d02c1db3SJuan Quintela    cflags="-p $cflags"
2562d02c1db3SJuan Quintela    ldflags="-p $ldflags"
2563d02c1db3SJuan Quintela  fi
2564d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
2565d02c1db3SJuan Quintela    ldflags="-p $ldflags"
256625be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
2567d02c1db3SJuan Quintela  fi
2568d02c1db3SJuan Quintelafi
2569d02c1db3SJuan Quintela
25706ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
25719b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2572fa282484SJuan Quintela  case "$ARCH" in
2573fa282484SJuan Quintela  sparc)
2574fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
2575322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
2576fa282484SJuan Quintela    ;;
2577fa282484SJuan Quintela  ia64)
2578322e5878SJuan Quintela    ldflags="-Wl,-G0 $linker_script -static $ldflags"
2579fa282484SJuan Quintela    ;;
2580df70204dSKirill A. Shutemov  i386|x86_64|ppc|ppc64|s390|sparc64|alpha|arm|m68k|mips|mips64)
2581322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
2582fa282484SJuan Quintela    ;;
2583fa282484SJuan Quintela  esac
2584fa282484SJuan Quintelafi
2585fa282484SJuan Quintelaif test "$target_softmmu" = "yes" ; then
2586fa282484SJuan Quintela  case "$ARCH" in
2587fa282484SJuan Quintela  ia64)
2588322e5878SJuan Quintela    ldflags="-Wl,-G0 $linker_script -static $ldflags"
2589fa282484SJuan Quintela    ;;
2590fa282484SJuan Quintela  esac
2591fa282484SJuan Quintelafi
2592fa282484SJuan Quintela
259325be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
259425be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
2595fa282484SJuan Quintela
259697a847bcSbellarddone # for target in $targets
25977d13299dSbellard
25987d13299dSbellard# build tree in object directory if source path is different from current one
25997d13299dSbellardif test "$source_path_used" = "yes" ; then
2600e1144d00SMark McLoughlin    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
26012d9f27d2SAnthony Liguori    DIRS="$DIRS roms/seabios roms/vgabios"
26027d13299dSbellard    FILES="Makefile tests/Makefile"
2603e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2604e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
26057ea78b74SJan Kiszka    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
26062d9f27d2SAnthony Liguori    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
26077ea78b74SJan Kiszka    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
26087ea78b74SJan Kiszka        FILES="$FILES pc-bios/`basename $bios_file`"
26097ea78b74SJan Kiszka    done
26107d13299dSbellard    for dir in $DIRS ; do
26117d13299dSbellard            mkdir -p $dir
26127d13299dSbellard    done
2613ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
26147d13299dSbellard    for f in $FILES ; do
2615ec530c81Sbellard        rm -f $f
2616ec530c81Sbellard        ln -s $source_path/$f $f
26177d13299dSbellard    done
26187d13299dSbellardfi
26191ad2134fSPaul Brook
2620c34ebfdcSAnthony Liguori# temporary config to build submodules
26212d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
2622c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
2623c34ebfdcSAnthony Liguori    echo "# Automatically generated by configure - do not modify" >> $config_mak
2624c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2625c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
2626c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
2627c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
2628c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
2629c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
2630c34ebfdcSAnthony Liguori    echo "HOST_CC=$host_cc" >> $config_mak
2631c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
2632c34ebfdcSAnthony Liguoridone
2633c34ebfdcSAnthony Liguori
26341ad2134fSPaul Brookfor hwlib in 32 64; do
26351ad2134fSPaul Brook  d=libhw$hwlib
26361ad2134fSPaul Brook  mkdir -p $d
26371ad2134fSPaul Brook  rm -f $d/Makefile
26381ad2134fSPaul Brook  ln -s $source_path/Makefile.hw $d/Makefile
2639a558ee17SJuan Quintela  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
26401ad2134fSPaul Brookdone
2641add16157SBlue Swirl
2642add16157SBlue Swirld=libuser
2643add16157SBlue Swirlmkdir -p $d
2644add16157SBlue Swirlrm -f $d/Makefile
2645add16157SBlue Swirlln -s $source_path/Makefile.user $d/Makefile
2646299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
2647299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
2648299060a0SKirill A. Shutemovfi
2649