xref: /openbmc/qemu/configure (revision 758e8e38)
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
184021d247SAurelien Jarnotrap "rm -f $TMPC $TMPO $TMPE ; exit" EXIT INT QUIT TERM
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
300dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
310dba6195SLoïc Minier# executable or a builtin)
320dba6195SLoïc Minierhas() {
330dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
340dba6195SLoïc Minier}
350dba6195SLoïc Minier
360dba6195SLoïc Minier# search for an executable in PATH
370dba6195SLoïc Minierpath_of() {
380dba6195SLoïc Minier    local_command="$1"
390dba6195SLoïc Minier    local_ifs="$IFS"
400dba6195SLoïc Minier    local_dir=""
410dba6195SLoïc Minier
420dba6195SLoïc Minier    # pathname has a dir component?
430dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
440dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
450dba6195SLoïc Minier            echo "$local_command"
460dba6195SLoïc Minier            return 0
470dba6195SLoïc Minier        fi
480dba6195SLoïc Minier    fi
490dba6195SLoïc Minier    if [ -z "$local_command" ]; then
500dba6195SLoïc Minier        return 1
510dba6195SLoïc Minier    fi
520dba6195SLoïc Minier
530dba6195SLoïc Minier    IFS=:
540dba6195SLoïc Minier    for local_dir in $PATH; do
550dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
560dba6195SLoïc Minier            echo "$local_dir/$local_command"
570dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
580dba6195SLoïc Minier            return 0
590dba6195SLoïc Minier        fi
600dba6195SLoïc Minier    done
610dba6195SLoïc Minier    # not found
620dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
630dba6195SLoïc Minier    return 1
640dba6195SLoïc Minier}
650dba6195SLoïc Minier
667d13299dSbellard# default parameters
672ff6b91eSJuan Quintelacpu=""
681e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
6943ce4dfeSbellardstatic="no"
70ed968ff1SJuan Quintelasparc_cpu=""
717d13299dSbellardcross_prefix=""
727d13299dSbellardcc="gcc"
730c58ac1cSmalcaudio_drv_list=""
744c9b53e3Smalcaudio_card_list="ac97 es1370 sb16"
754c9b53e3Smalcaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
76eb852011SMarkus Armbrusterblock_drv_whitelist=""
777d13299dSbellardhost_cc="gcc"
787d13299dSbellardar="ar"
797d13299dSbellardmake="make"
806a882643Spbrookinstall="install"
817aa486feSAnthony Liguoriobjcopy="objcopy"
827aa486feSAnthony Liguorild="ld"
83c81da56eSJuan Quintelahelper_cflags=""
8473da375eSJuan Quintelalibs_softmmu=""
853e2e0e6bSJuan Quintelalibs_tools=""
8667f86e8eSJuan Quintelaaudio_pt_int=""
87d5631638Smalcaudio_win_int=""
88ac0df51dSaliguori
89ac0df51dSaliguori# parse CC options first
90ac0df51dSaliguorifor opt do
91ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
92ac0df51dSaliguori  case "$opt" in
93ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
94ac0df51dSaliguori  ;;
95ac0df51dSaliguori  --cc=*) cc="$optarg"
96ac0df51dSaliguori  ;;
972ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
982ff6b91eSJuan Quintela  ;;
99a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
100e2a2ed06SJuan Quintela  ;;
101e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
102e2a2ed06SJuan Quintela  ;;
10350e7b1a0SJuan Quintela  --sparc_cpu=*)
10450e7b1a0SJuan Quintela    sparc_cpu="$optarg"
10550e7b1a0SJuan Quintela    case $sparc_cpu in
106ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
10750e7b1a0SJuan Quintela      cpu="sparc"
10850e7b1a0SJuan Quintela    ;;
10950e7b1a0SJuan Quintela    v9)
11050e7b1a0SJuan Quintela      cpu="sparc64"
11150e7b1a0SJuan Quintela    ;;
11250e7b1a0SJuan Quintela    *)
11350e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
11450e7b1a0SJuan Quintela      exit 1
11550e7b1a0SJuan Quintela    ;;
11650e7b1a0SJuan Quintela    esac
11750e7b1a0SJuan Quintela  ;;
118ac0df51dSaliguori  esac
119ac0df51dSaliguoridone
120ac0df51dSaliguori# OS specific
121ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
122ac0df51dSaliguori# we can eliminate it's usage altogether
123ac0df51dSaliguori
124ac0df51dSaliguoricc="${cross_prefix}${cc}"
125ac0df51dSaliguoriar="${cross_prefix}${ar}"
1267aa486feSAnthony Liguoriobjcopy="${cross_prefix}${objcopy}"
1277aa486feSAnthony Liguorild="${cross_prefix}${ld}"
128ac0df51dSaliguori
129be17dc90SMichael S. Tsirkin# default flags for all hosts
130be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
131be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
132be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
133be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
134be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
13584958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
136be17dc90SMichael S. TsirkinQEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
137be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
138be17dc90SMichael S. Tsirkin
139a0f291fcSJuan Quintelagcc_flags="-Wold-style-declaration -Wold-style-definition -fstack-protector-all"
140be17dc90SMichael S. Tsirkincat > $TMPC << EOF
141aa527b65SAurelien Jarnoint main(void) { return 0; }
142be17dc90SMichael S. TsirkinEOF
143be17dc90SMichael S. Tsirkinfor flag in $gcc_flags; do
144aa527b65SAurelien Jarno    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
145be17dc90SMichael S. Tsirkin	QEMU_CFLAGS="$flag $QEMU_CFLAGS"
146be17dc90SMichael S. Tsirkin    fi
147be17dc90SMichael S. Tsirkindone
148be17dc90SMichael S. Tsirkin
149ac0df51dSaliguori# check that the C compiler works.
150ac0df51dSaliguoricat > $TMPC <<EOF
151ac0df51dSaliguoriint main(void) {}
152ac0df51dSaliguoriEOF
153ac0df51dSaliguori
15452166aa0SJuan Quintelaif compile_object ; then
155ac0df51dSaliguori  : C compiler works ok
156ac0df51dSaliguorielse
157ac0df51dSaliguori    echo "ERROR: \"$cc\" either does not exist or does not work"
158ac0df51dSaliguori    exit 1
159ac0df51dSaliguorifi
160ac0df51dSaliguori
161ac0df51dSaliguoricheck_define() {
162ac0df51dSaliguoricat > $TMPC <<EOF
163ac0df51dSaliguori#if !defined($1)
164ac0df51dSaliguori#error Not defined
165ac0df51dSaliguori#endif
166ac0df51dSaliguoriint main(void) { return 0; }
167ac0df51dSaliguoriEOF
16852166aa0SJuan Quintela  compile_object
169ac0df51dSaliguori}
170ac0df51dSaliguori
1712ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
1722ff6b91eSJuan Quintela  # command line argument
1732ff6b91eSJuan Quintela  :
1742ff6b91eSJuan Quintelaelif check_define __i386__ ; then
175ac0df51dSaliguori  cpu="i386"
176ac0df51dSaliguorielif check_define __x86_64__ ; then
177ac0df51dSaliguori  cpu="x86_64"
1783aa9bd6cSblueswir1elif check_define __sparc__ ; then
1793aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
1803aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
1813aa9bd6cSblueswir1  if check_define __arch64__ ; then
1823aa9bd6cSblueswir1    cpu="sparc64"
1833aa9bd6cSblueswir1  else
1843aa9bd6cSblueswir1    cpu="sparc"
1853aa9bd6cSblueswir1  fi
186fdf7ed96Smalcelif check_define _ARCH_PPC ; then
187fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
188fdf7ed96Smalc    cpu="ppc64"
189ac0df51dSaliguori  else
190fdf7ed96Smalc    cpu="ppc"
191fdf7ed96Smalc  fi
192afa05235SAurelien Jarnoelif check_define __mips__ ; then
193afa05235SAurelien Jarno  cpu="mips"
194477ba620SAurelien Jarnoelif check_define __ia64__ ; then
195477ba620SAurelien Jarno  cpu="ia64"
196d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
197d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
198d66ed0eaSAurelien Jarno    cpu="s390x"
199d66ed0eaSAurelien Jarno  else
200d66ed0eaSAurelien Jarno    cpu="s390"
201d66ed0eaSAurelien Jarno  fi
202fdf7ed96Smalcelse
203fdf7ed96Smalc  cpu=`uname -m`
204ac0df51dSaliguorifi
205ac0df51dSaliguori
2065327cf48Sbellardtarget_list=""
2077d13299dSbellardcase "$cpu" in
208afa05235SAurelien Jarno  alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
209ea8f20f8SJuan Quintela    cpu="$cpu"
210ea8f20f8SJuan Quintela  ;;
2117d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
21297a847bcSbellard    cpu="i386"
2137d13299dSbellard  ;;
214aaa5fa14Saurel32  x86_64|amd64)
215aaa5fa14Saurel32    cpu="x86_64"
216aaa5fa14Saurel32  ;;
217ba68055eSbellard  armv*b)
218808c4954Sbellard    cpu="armv4b"
219808c4954Sbellard  ;;
220ba68055eSbellard  armv*l)
2217d13299dSbellard    cpu="armv4l"
2227d13299dSbellard  ;;
223f54b3f92Saurel32  parisc|parisc64)
224f54b3f92Saurel32    cpu="hppa"
225f54b3f92Saurel32  ;;
226afa05235SAurelien Jarno  mips*)
227afa05235SAurelien Jarno    cpu="mips"
228afa05235SAurelien Jarno  ;;
22924e804ecSAlexander Graf  s390)
230fb3e5849Sbellard    cpu="s390"
231fb3e5849Sbellard  ;;
23224e804ecSAlexander Graf  s390x)
23324e804ecSAlexander Graf    cpu="s390x"
23424e804ecSAlexander Graf  ;;
2353142255cSblueswir1  sparc|sun4[cdmuv])
236ae228531Sbellard    cpu="sparc"
237ae228531Sbellard  ;;
2387d13299dSbellard  *)
239a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
240a447d4dcSPaolo Bonzini    exit 1
2417d13299dSbellard  ;;
2427d13299dSbellardesac
243e2d52ad3SJuan Quintela
2443a3fb96dSStefan Weil# Default value for a variable defining feature "foo".
2453a3fb96dSStefan Weil#  * foo="no"  feature will only be used if --enable-foo arg is given
2463a3fb96dSStefan Weil#  * foo=""    feature will be searched for, and if found, will be used
2473a3fb96dSStefan Weil#              unless --disable-foo is given
2483a3fb96dSStefan Weil#  * foo="yes" this value will only be set by --enable-foo flag.
2493a3fb96dSStefan Weil#              feature will searched for,
2503a3fb96dSStefan Weil#              if not found, configure exits with error
251e2d52ad3SJuan Quintela#
2523a3fb96dSStefan Weil# Always add --enable-foo and --disable-foo command line args.
2533a3fb96dSStefan Weil# Distributions want to ensure that several features are compiled in, and it
2543a3fb96dSStefan Weil# is impossible without a --enable-foo that exits if a feature is not found.
255e2d52ad3SJuan Quintela
256a20a6f46SJuan Quintelabluez=""
2574ffcedb6SJuan Quintelabrlapi=""
258788c8196SJuan Quintelacurl=""
259c584a6d0SJuan Quintelacurses=""
260a25dba17SJuan Quinteladocs=""
2612df87df7SJuan Quintelafdt=""
262b31a0277SJuan Quintelakvm=""
263dae5079aSJan Kiszkakvm_para=""
264b0a47e79SJuan Quintelanptl=""
265c4198157SJuan Quintelasdl=""
266dfffc653SJuan Quintelasparse="no"
267ee682d27SStefan Weiluuid=""
268dfb278bdSJuan Quintelavde=""
2691be10ad2SJuan Quintelavnc_tls=""
270ea784e3bSJuan Quintelavnc_sasl=""
271fc321b4bSJuan Quintelaxen=""
2725c6c3a6cSChristoph Hellwiglinux_aio=""
273*758e8e38SVenkateswararao Jujjuri (JV)attr=""
274d5970055SMichael S. Tsirkinvhost_net=""
275dfb278bdSJuan Quintela
2767d13299dSbellardgprof="no"
277f8393946Saurel32debug_tcg="no"
278b4475aa2SLuiz Capitulinodebug_mon="no"
279f3d08ee6SPaul Brookdebug="no"
2801625af87Saliguoristrip_opt="yes"
2817d13299dSbellardbigendian="no"
28267b915a5Sbellardmingw32="no"
28367b915a5SbellardEXESUF=""
284683035deSPaolo Bonziniprefix="/usr/local"
285683035deSPaolo Bonzinimandir="\${prefix}/share/man"
286683035deSPaolo Bonzinidatadir="\${prefix}/share/qemu"
287683035deSPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
288683035deSPaolo Bonzinibindir="\${prefix}/bin"
289683035deSPaolo Bonzinisysconfdir="\${prefix}/etc"
290683035deSPaolo Bonziniconfsuffix="/qemu"
291443f1376Sbellardslirp="yes"
292102a52e4Sbellardfmod_lib=""
293102a52e4Sbellardfmod_inc=""
2942f6a1ab0Sblueswir1oss_lib=""
295b1a550a0Spbrookbsd="no"
2965327cf48Sbellardlinux="no"
297d2c7c9b8Sblueswir1solaris="no"
29805c2a3e7Sbellardprofiler="no"
2995b0753e0Sbellardcocoa="no"
3000a8e90f4Spbrooksoftmmu="yes"
301831b7825Sthslinux_user="no"
302831b7825Sthsdarwin_user="no"
30384778508Sblueswir1bsd_user="no"
304379f6698SPaul Brookguest_base=""
305c5937220Spbrookuname_release=""
306e5d355d1Saliguoriio_thread="no"
3078ff9cbf7Smalcmixemu="no"
308eac30262Saliguorikerneldir=""
309b29fe3edSmalcaix="no"
31077755340Sthsblobs="yes"
3114a19f1ecSpbrookpkgversion=""
3125495ed11SLuiz Capitulinocheck_utests="no"
31334005a00SKirill A. Shutemovuser_pie="no"
31420ff6c80SAnthony Liguorizero_malloc=""
3157d13299dSbellard
3167d13299dSbellard# OS specific
317ac0df51dSaliguoriif check_define __linux__ ; then
318ac0df51dSaliguori  targetos="Linux"
319ac0df51dSaliguorielif check_define _WIN32 ; then
320ac0df51dSaliguori  targetos='MINGW32'
321169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
322169dc5d3Sblueswir1  targetos='OpenBSD'
323169dc5d3Sblueswir1elif check_define __sun__ ; then
324169dc5d3Sblueswir1  targetos='SunOS'
325ac0df51dSaliguorielse
3267d13299dSbellard  targetos=`uname -s`
327ac0df51dSaliguorifi
3280dbfc675SJuan Quintela
3297d13299dSbellardcase $targetos in
330c326e0afSbellardCYGWIN*)
331c326e0afSbellard  mingw32="yes"
332a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
333d5631638Smalc  audio_possible_drivers="winwave sdl"
334d5631638Smalc  audio_drv_list="winwave"
335c326e0afSbellard;;
33667b915a5SbellardMINGW32*)
33767b915a5Sbellard  mingw32="yes"
338d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
339d5631638Smalc  audio_drv_list="winwave"
34067b915a5Sbellard;;
3415c40d2bdSthsGNU/kFreeBSD)
342a167ba50SAurelien Jarno  bsd="yes"
3430c58ac1cSmalc  audio_drv_list="oss"
344f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3455c40d2bdSths;;
3467d3505c5SbellardFreeBSD)
3477d3505c5Sbellard  bsd="yes"
348a167ba50SAurelien Jarno  make="gmake"
3490c58ac1cSmalc  audio_drv_list="oss"
350f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
351f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
352f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3537d3505c5Sbellard;;
354c5e97233Sblueswir1DragonFly)
355c5e97233Sblueswir1  bsd="yes"
356a167ba50SAurelien Jarno  make="gmake"
357c5e97233Sblueswir1  audio_drv_list="oss"
358c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
359c5e97233Sblueswir1;;
3607d3505c5SbellardNetBSD)
3617d3505c5Sbellard  bsd="yes"
362a167ba50SAurelien Jarno  make="gmake"
3630c58ac1cSmalc  audio_drv_list="oss"
364c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3658ef92a88Sblueswir1  oss_lib="-lossaudio"
3667d3505c5Sbellard;;
3677d3505c5SbellardOpenBSD)
3687d3505c5Sbellard  bsd="yes"
369a167ba50SAurelien Jarno  make="gmake"
3700c58ac1cSmalc  audio_drv_list="oss"
371c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3722f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3737d3505c5Sbellard;;
37483fb7adfSbellardDarwin)
37583fb7adfSbellard  bsd="yes"
37683fb7adfSbellard  darwin="yes"
3770dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3780dbfc675SJuan Quintela  # run 64-bit userspace code
379aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3801b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
381aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3821b0f9cc2Saliguori  fi
3831b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
384a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3850c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3861b0f9cc2Saliguori  else
387a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3881b0f9cc2Saliguori  fi
389831b7825Sths  darwin_user="yes"
390fd677642Sths  cocoa="yes"
3910c58ac1cSmalc  audio_drv_list="coreaudio"
392c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
3930c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
3947973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
39583fb7adfSbellard;;
396ec530c81SbellardSunOS)
397ec530c81Sbellard  solaris="yes"
398c2b84fabSths  make="gmake"
399c2b84fabSths  install="ginstall"
400fa58948dSBlue Swirl  ld="gld"
4010475a5caSths  needs_libsunmath="no"
402c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
403ef18c883Sths  # have to select again, because `uname -m` returns i86pc
404ef18c883Sths  # even on an x86_64 box.
405ef18c883Sths  solariscpu=`isainfo -k`
406ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
407ef18c883Sths    cpu="x86_64"
408ef18c883Sths  fi
409c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4100475a5caSths    if test "$solarisrev" -le 9 ; then
4110475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4120475a5caSths        needs_libsunmath="yes"
413f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
414f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
415f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4160475a5caSths      else
4170475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4180475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4190475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4200475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4210475a5caSths        exit 1
4220475a5caSths      fi
4230475a5caSths    fi
42486b2bd93Sths  fi
4256b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4260c58ac1cSmalc    audio_drv_list="oss"
4276b4d2ba1Sths  fi
428c2de5c91Smalc  audio_possible_drivers="oss sdl"
429d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
430d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
431d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
432d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
433a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
434e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
435ec530c81Sbellard;;
436b29fe3edSmalcAIX)
437b29fe3edSmalc  aix="yes"
438b29fe3edSmalc  make="gmake"
439b29fe3edSmalc;;
440fb065187Sbellard*)
4410c58ac1cSmalc  audio_drv_list="oss"
442b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4435327cf48Sbellard  linux="yes"
444831b7825Sths  linux_user="yes"
44568063649Sblueswir1  usb="linux"
44607f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
447c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
448c9ec1fe4Sbellard  fi
449fb065187Sbellard;;
4507d13299dSbellardesac
4517d13299dSbellard
4527d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
453b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
45468063649Sblueswir1    usb="bsd"
45583fb7adfSbellard  fi
45684778508Sblueswir1  bsd_user="yes"
4577d3505c5Sbellardfi
4587d3505c5Sbellard
4593457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4603457a3f8SJuan Quintela  EXESUF=".exe"
461a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
462e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
463e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
464884044aaSJuan Quintela  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
465683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
466683035deSPaolo Bonzini  mandir="\${prefix}"
467683035deSPaolo Bonzini  datadir="\${prefix}"
468683035deSPaolo Bonzini  docdir="\${prefix}"
469683035deSPaolo Bonzini  bindir="\${prefix}"
470683035deSPaolo Bonzini  sysconfdir="\${prefix}"
471683035deSPaolo Bonzini  confsuffix=""
4723457a3f8SJuan Quintelafi
4733457a3f8SJuan Quintela
4747d13299dSbellard# find source path
475ad064840Spbrooksource_path=`dirname "$0"`
47659faef3aSbalrogsource_path_used="no"
47759faef3aSbalrogworkdir=`pwd`
478ad064840Spbrookif [ -z "$source_path" ]; then
47959faef3aSbalrog    source_path=$workdir
480ad064840Spbrookelse
481ad064840Spbrook    source_path=`cd "$source_path"; pwd`
4827d13299dSbellardfi
483724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
4847d13299dSbellard
485487fefdbSAnthony Liguoriwerror=""
48685aa5189Sbellard
4877d13299dSbellardfor opt do
488a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4897d13299dSbellard  case "$opt" in
4902efc3265Sbellard  --help|-h) show_help=yes
4912efc3265Sbellard  ;;
492b1a550a0Spbrook  --prefix=*) prefix="$optarg"
4937d13299dSbellard  ;;
494b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
49532ce6337Sbellard  ;;
496b1a550a0Spbrook  --source-path=*) source_path="$optarg"
497ad064840Spbrook  source_path_used="yes"
4987d13299dSbellard  ;;
499ac0df51dSaliguori  --cross-prefix=*)
5007d13299dSbellard  ;;
501ac0df51dSaliguori  --cc=*)
5027d13299dSbellard  ;;
503b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
50483469015Sbellard  ;;
505b1a550a0Spbrook  --make=*) make="$optarg"
5067d13299dSbellard  ;;
5076a882643Spbrook  --install=*) install="$optarg"
5086a882643Spbrook  ;;
509e2a2ed06SJuan Quintela  --extra-cflags=*)
5107d13299dSbellard  ;;
511e2a2ed06SJuan Quintela  --extra-ldflags=*)
5127d13299dSbellard  ;;
5132ff6b91eSJuan Quintela  --cpu=*)
5147d13299dSbellard  ;;
515b1a550a0Spbrook  --target-list=*) target_list="$optarg"
516de83cd02Sbellard  ;;
5177d13299dSbellard  --enable-gprof) gprof="yes"
5187d13299dSbellard  ;;
51979427693SLoïc Minier  --static)
52079427693SLoïc Minier    static="yes"
52179427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
52243ce4dfeSbellard  ;;
5230b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5240b24e75fSPaolo Bonzini  ;;
5250b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5260b24e75fSPaolo Bonzini  ;;
5270b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5280b24e75fSPaolo Bonzini  ;;
5290b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5300b24e75fSPaolo Bonzini  ;;
531ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
53207381cc1SAnthony Liguori  ;;
53397a847bcSbellard  --disable-sdl) sdl="no"
53497a847bcSbellard  ;;
535c4198157SJuan Quintela  --enable-sdl) sdl="yes"
536c4198157SJuan Quintela  ;;
537b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
538102a52e4Sbellard  ;;
539c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
540c2de5c91Smalc  ;;
5412f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5422f6a1ab0Sblueswir1  ;;
5432fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5440c58ac1cSmalc  ;;
5450c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5460c58ac1cSmalc  ;;
547eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
548eb852011SMarkus Armbruster  ;;
549f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
550f8393946Saurel32  ;;
551f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
552f8393946Saurel32  ;;
553b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
554b4475aa2SLuiz Capitulino  ;;
555b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
556b4475aa2SLuiz Capitulino  ;;
557f3d08ee6SPaul Brook  --enable-debug)
558f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
559f3d08ee6SPaul Brook      debug_tcg="yes"
560b4475aa2SLuiz Capitulino      debug_mon="yes"
561f3d08ee6SPaul Brook      debug="yes"
562f3d08ee6SPaul Brook      strip_opt="no"
563f3d08ee6SPaul Brook  ;;
56403b4fe7dSaliguori  --enable-sparse) sparse="yes"
56503b4fe7dSaliguori  ;;
56603b4fe7dSaliguori  --disable-sparse) sparse="no"
56703b4fe7dSaliguori  ;;
5681625af87Saliguori  --disable-strip) strip_opt="no"
5691625af87Saliguori  ;;
5708d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5718d5d2d4cSths  ;;
5721be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5731be10ad2SJuan Quintela  ;;
5742f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5752f9606b3Saliguori  ;;
576ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
577ea784e3bSJuan Quintela  ;;
578443f1376Sbellard  --disable-slirp) slirp="no"
579c20709aaSbellard  ;;
580ee682d27SStefan Weil  --disable-uuid) uuid="no"
581ee682d27SStefan Weil  ;;
582ee682d27SStefan Weil  --enable-uuid) uuid="yes"
583ee682d27SStefan Weil  ;;
584e0e6c8c0Saliguori  --disable-vde) vde="no"
5858a16d273Sths  ;;
586dfb278bdSJuan Quintela  --enable-vde) vde="yes"
587dfb278bdSJuan Quintela  ;;
588e37630caSaliguori  --disable-xen) xen="no"
589e37630caSaliguori  ;;
590fc321b4bSJuan Quintela  --enable-xen) xen="yes"
591fc321b4bSJuan Quintela  ;;
5922e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
5932e4d9fb1Saurel32  ;;
5944ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
5954ffcedb6SJuan Quintela  ;;
596fb599c9aSbalrog  --disable-bluez) bluez="no"
597fb599c9aSbalrog  ;;
598a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
599a20a6f46SJuan Quintela  ;;
6007ba1e619Saliguori  --disable-kvm) kvm="no"
6017ba1e619Saliguori  ;;
602b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
603b31a0277SJuan Quintela  ;;
60405c2a3e7Sbellard  --enable-profiler) profiler="yes"
60505c2a3e7Sbellard  ;;
606c2de5c91Smalc  --enable-cocoa)
607c2de5c91Smalc      cocoa="yes" ;
608c2de5c91Smalc      sdl="no" ;
609c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6105b0753e0Sbellard  ;;
611cad25d69Spbrook  --disable-system) softmmu="no"
6120a8e90f4Spbrook  ;;
613cad25d69Spbrook  --enable-system) softmmu="yes"
6140a8e90f4Spbrook  ;;
6150953a80fSZachary Amsden  --disable-user)
6160953a80fSZachary Amsden      linux_user="no" ;
6170953a80fSZachary Amsden      bsd_user="no" ;
6180953a80fSZachary Amsden      darwin_user="no"
6190953a80fSZachary Amsden  ;;
6200953a80fSZachary Amsden  --enable-user) ;;
621831b7825Sths  --disable-linux-user) linux_user="no"
6220a8e90f4Spbrook  ;;
623831b7825Sths  --enable-linux-user) linux_user="yes"
624831b7825Sths  ;;
625831b7825Sths  --disable-darwin-user) darwin_user="no"
626831b7825Sths  ;;
627831b7825Sths  --enable-darwin-user) darwin_user="yes"
6280a8e90f4Spbrook  ;;
62984778508Sblueswir1  --disable-bsd-user) bsd_user="no"
63084778508Sblueswir1  ;;
63184778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
63284778508Sblueswir1  ;;
633379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
634379f6698SPaul Brook  ;;
635379f6698SPaul Brook  --disable-guest-base) guest_base="no"
636379f6698SPaul Brook  ;;
63734005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
63834005a00SKirill A. Shutemov  ;;
63934005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
64034005a00SKirill A. Shutemov  ;;
641c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
642c5937220Spbrook  ;;
6433142255cSblueswir1  --sparc_cpu=*)
6443142255cSblueswir1  ;;
64585aa5189Sbellard  --enable-werror) werror="yes"
64685aa5189Sbellard  ;;
64785aa5189Sbellard  --disable-werror) werror="no"
64885aa5189Sbellard  ;;
6494d3b6f6eSbalrog  --disable-curses) curses="no"
6504d3b6f6eSbalrog  ;;
651c584a6d0SJuan Quintela  --enable-curses) curses="yes"
652c584a6d0SJuan Quintela  ;;
653769ce76dSAlexander Graf  --disable-curl) curl="no"
654769ce76dSAlexander Graf  ;;
655788c8196SJuan Quintela  --enable-curl) curl="yes"
656788c8196SJuan Quintela  ;;
6572df87df7SJuan Quintela  --disable-fdt) fdt="no"
6582df87df7SJuan Quintela  ;;
6592df87df7SJuan Quintela  --enable-fdt) fdt="yes"
6602df87df7SJuan Quintela  ;;
6615495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
6625495ed11SLuiz Capitulino  ;;
6635495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
6645495ed11SLuiz Capitulino  ;;
665bd0c5661Spbrook  --disable-nptl) nptl="no"
666bd0c5661Spbrook  ;;
667b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
668b0a47e79SJuan Quintela  ;;
6698ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
6708ff9cbf7Smalc  ;;
6715c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
6725c6c3a6cSChristoph Hellwig  ;;
6735c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
6745c6c3a6cSChristoph Hellwig  ;;
675*758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
676*758e8e38SVenkateswararao Jujjuri (JV)  ;;
677*758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
678*758e8e38SVenkateswararao Jujjuri (JV)  ;;
679e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
680e5d355d1Saliguori  ;;
68177755340Sths  --disable-blobs) blobs="no"
68277755340Sths  ;;
683eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
684eac30262Saliguori  ;;
6854a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
6864a19f1ecSpbrook  ;;
687a25dba17SJuan Quintela  --disable-docs) docs="no"
68870ec5dc0SAnthony Liguori  ;;
689a25dba17SJuan Quintela  --enable-docs) docs="yes"
69083a3ab8bSJuan Quintela  ;;
691d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
692d5970055SMichael S. Tsirkin  ;;
693d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
694d5970055SMichael S. Tsirkin  ;;
6956bde81cbSPaolo Bonzini  --*dir)
6966bde81cbSPaolo Bonzini  ;;
6977f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
6987f1559c6Sbalrog  ;;
6997d13299dSbellard  esac
7007d13299dSbellarddone
7017d13299dSbellard
7023142255cSblueswir1#
7033142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
704a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7053142255cSblueswir1#
706379f6698SPaul Brookhost_guest_base="no"
70740293e58Sbellardcase "$cpu" in
708ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
709ed968ff1SJuan Quintela           v7|v8)
710a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
711ed968ff1SJuan Quintela           ;;
712ed968ff1SJuan Quintela           v8plus|v8plusa)
713a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
714ed968ff1SJuan Quintela           ;;
715ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
716a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
717ed968ff1SJuan Quintela           esac
7180c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
719a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
720762e8230Sblueswir1           if test "$solaris" = "no" ; then
721a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
722c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
723762e8230Sblueswir1           fi
7243142255cSblueswir1           ;;
725ed968ff1SJuan Quintela    sparc64)
726a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7270c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
728a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
729ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
730a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
731762e8230Sblueswir1           fi
7323142255cSblueswir1           ;;
73376d83bdeSths    s390)
73428d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
73528d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
73628d7cc49SRichard Henderson           ;;
73728d7cc49SRichard Henderson    s390x)
73828d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
73928d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
74076d83bdeSths           ;;
74140293e58Sbellard    i386)
742a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7430c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
744c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
745379f6698SPaul Brook           host_guest_base="yes"
74640293e58Sbellard           ;;
74740293e58Sbellard    x86_64)
748a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
7490c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
750379f6698SPaul Brook           host_guest_base="yes"
751379f6698SPaul Brook           ;;
752379f6698SPaul Brook    arm*)
753379f6698SPaul Brook           host_guest_base="yes"
75440293e58Sbellard           ;;
755f6548c0aSmalc    ppc*)
756f6548c0aSmalc           host_guest_base="yes"
757f6548c0aSmalc           ;;
758cc01cc8eSAurelien Jarno    mips*)
759cc01cc8eSAurelien Jarno           host_guest_base="yes"
760cc01cc8eSAurelien Jarno           ;;
761477ba620SAurelien Jarno    ia64*)
762477ba620SAurelien Jarno           host_guest_base="yes"
763477ba620SAurelien Jarno           ;;
764fd76e73aSRichard Henderson    hppa*)
765fd76e73aSRichard Henderson           host_guest_base="yes"
766fd76e73aSRichard Henderson           ;;
7673142255cSblueswir1esac
7683142255cSblueswir1
769379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
770379f6698SPaul Brook
771af5db58eSpbrookif test x"$show_help" = x"yes" ; then
772af5db58eSpbrookcat << EOF
773af5db58eSpbrook
774af5db58eSpbrookUsage: configure [options]
775af5db58eSpbrookOptions: [defaults in brackets after descriptions]
776af5db58eSpbrook
777af5db58eSpbrookEOF
778af5db58eSpbrookecho "Standard options:"
779af5db58eSpbrookecho "  --help                   print this message"
780af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
781af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
782af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
783af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
784af5db58eSpbrookecho ""
785af5db58eSpbrookecho "Advanced options (experts only):"
786af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
787af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
788af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
7890bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
7900bfe8cc0SPaolo Bonziniecho "                           build time"
791a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
792e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
793af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
7946a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
795af5db58eSpbrookecho "  --static                 enable static build [$static]"
7960b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
7970b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
7980b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
7990b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
8000b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
801f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
802f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
80309695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
804890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
805890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
8061625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
80785aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
808fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
809c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
810af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
811c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
812c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
8134c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
8144c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
815eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
816eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
8178ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
818e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
819fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
8202e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
8214ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
8228d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
8231be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
8242f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
825ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
826af896aaaSpbrookecho "  --disable-curses         disable curses output"
827c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
828769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
829788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
8302df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
8312df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
8325495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
8335495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
834fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
835a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
8367ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
837b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
838bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
839e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
840af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
841af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
8420953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
8430953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
844831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
845831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
846831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
847831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
84884778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
84984778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
850379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
851379f6698SPaul Brookecho "                           emulation targets"
852379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
85334005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
85434005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
855af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
856af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
8572f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
858c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
8593142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
860ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
861ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
862e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
863dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
8645c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
8655c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
866*758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
867*758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
868e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
86977755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
870eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
871d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
872d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
873d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
874d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
875af5db58eSpbrookecho ""
8765bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
877af5db58eSpbrookexit 1
878af5db58eSpbrookfi
879af5db58eSpbrook
880ec530c81Sbellard#
881ec530c81Sbellard# Solaris specific configure tool chain decisions
882ec530c81Sbellard#
883ec530c81Sbellardif test "$solaris" = "yes" ; then
8846792aa11SLoïc Minier  if has $install; then
8856792aa11SLoïc Minier    :
8866792aa11SLoïc Minier  else
887ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
888ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
889ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
890ec530c81Sbellard    exit 1
891ec530c81Sbellard  fi
8926792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
893ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
894ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
895ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
896ec530c81Sbellard    exit 1
897ec530c81Sbellard  fi
8986792aa11SLoïc Minier  if has ar; then
8996792aa11SLoïc Minier    :
9006792aa11SLoïc Minier  else
901ec530c81Sbellard    echo "Error: No path includes ar"
902ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
903ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
904ec530c81Sbellard    fi
905ec530c81Sbellard    exit 1
906ec530c81Sbellard  fi
907ec530c81Sbellardfi
908ec530c81Sbellard
909ec530c81Sbellard
9105327cf48Sbellardif test -z "$target_list" ; then
9115327cf48Sbellard# these targets are portable
9120a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
9132408a527Saurel32        target_list="\
9142408a527Saurel32i386-softmmu \
9152408a527Saurel32x86_64-softmmu \
9162408a527Saurel32arm-softmmu \
9172408a527Saurel32cris-softmmu \
9182408a527Saurel32m68k-softmmu \
91972b675caSEdgar E. Iglesiasmicroblaze-softmmu \
9202408a527Saurel32mips-softmmu \
9212408a527Saurel32mipsel-softmmu \
9222408a527Saurel32mips64-softmmu \
9232408a527Saurel32mips64el-softmmu \
9242408a527Saurel32ppc-softmmu \
9252408a527Saurel32ppcemb-softmmu \
9262408a527Saurel32ppc64-softmmu \
9272408a527Saurel32sh4-softmmu \
9282408a527Saurel32sh4eb-softmmu \
9292408a527Saurel32sparc-softmmu \
9301b64fcaeSIgor V. Kovalenkosparc64-softmmu \
9312408a527Saurel32"
9320a8e90f4Spbrook    fi
9335327cf48Sbellard# the following are Linux specific
934831b7825Sths    if [ "$linux_user" = "yes" ] ; then
9352408a527Saurel32        target_list="${target_list}\
9362408a527Saurel32i386-linux-user \
9372408a527Saurel32x86_64-linux-user \
9382408a527Saurel32alpha-linux-user \
9392408a527Saurel32arm-linux-user \
9402408a527Saurel32armeb-linux-user \
9412408a527Saurel32cris-linux-user \
9422408a527Saurel32m68k-linux-user \
94372b675caSEdgar E. Iglesiasmicroblaze-linux-user \
9442408a527Saurel32mips-linux-user \
9452408a527Saurel32mipsel-linux-user \
9462408a527Saurel32ppc-linux-user \
9472408a527Saurel32ppc64-linux-user \
9482408a527Saurel32ppc64abi32-linux-user \
9492408a527Saurel32sh4-linux-user \
9502408a527Saurel32sh4eb-linux-user \
9512408a527Saurel32sparc-linux-user \
9522408a527Saurel32sparc64-linux-user \
9532408a527Saurel32sparc32plus-linux-user \
9542408a527Saurel32"
955831b7825Sths    fi
956831b7825Sths# the following are Darwin specific
957831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
9582408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
9595327cf48Sbellard    fi
96084778508Sblueswir1# the following are BSD specific
96184778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
96284778508Sblueswir1        target_list="${target_list}\
96331fc12dfSblueswir1i386-bsd-user \
96431fc12dfSblueswir1x86_64-bsd-user \
96531fc12dfSblueswir1sparc-bsd-user \
96684778508Sblueswir1sparc64-bsd-user \
96784778508Sblueswir1"
96884778508Sblueswir1    fi
9696e20a45fSbellardelse
970b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
9715327cf48Sbellardfi
9720a8e90f4Spbrookif test -z "$target_list" ; then
9730a8e90f4Spbrook    echo "No targets enabled"
9740a8e90f4Spbrook    exit 1
9750a8e90f4Spbrookfi
976f55fe278SPaolo Bonzini# see if system emulation was really requested
977f55fe278SPaolo Bonzinicase " $target_list " in
978f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
979f55fe278SPaolo Bonzini  ;;
980f55fe278SPaolo Bonzini  *) softmmu=no
981f55fe278SPaolo Bonzini  ;;
982f55fe278SPaolo Bonziniesac
9835327cf48Sbellard
984249247c9SJuan Quintelafeature_not_found() {
985249247c9SJuan Quintela  feature=$1
986249247c9SJuan Quintela
987249247c9SJuan Quintela  echo "ERROR"
988249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
9899332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
990249247c9SJuan Quintela  echo "ERROR"
991249247c9SJuan Quintela  exit 1;
992249247c9SJuan Quintela}
993249247c9SJuan Quintela
9947d13299dSbellardif test -z "$cross_prefix" ; then
9957d13299dSbellard
9967d13299dSbellard# ---
9977d13299dSbellard# big/little endian test
9987d13299dSbellardcat > $TMPC << EOF
9997d13299dSbellard#include <inttypes.h>
10007d13299dSbellardint main(int argc, char ** argv){
10017d13299dSbellard        volatile uint32_t i=0x01234567;
10027d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
10037d13299dSbellard}
10047d13299dSbellardEOF
10057d13299dSbellard
100652166aa0SJuan Quintelaif compile_prog "" "" ; then
10077d13299dSbellard$TMPE && bigendian="yes"
10087d13299dSbellardelse
10097d13299dSbellardecho big/little test failed
10107d13299dSbellardfi
10117d13299dSbellard
10127d13299dSbellardelse
10137d13299dSbellard
10147d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1015ea8f20f8SJuan Quintelacase "$cpu" in
101624e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1017ea8f20f8SJuan Quintela    bigendian=yes
1018ea8f20f8SJuan Quintela  ;;
1019ea8f20f8SJuan Quintelaesac
10207d13299dSbellard
10217d13299dSbellardfi
10227d13299dSbellard
1023b6853697Sbellard# host long bits test
1024b6853697Sbellardhostlongbits="32"
1025ea8f20f8SJuan Quintelacase "$cpu" in
102624e804ecSAlexander Graf  x86_64|alpha|ia64|sparc64|ppc64|s390x)
1027ea8f20f8SJuan Quintela    hostlongbits=64
1028ea8f20f8SJuan Quintela  ;;
1029ea8f20f8SJuan Quintelaesac
1030b6853697Sbellard
1031b0a47e79SJuan Quintela
1032b0a47e79SJuan Quintela##########################################
1033b0a47e79SJuan Quintela# NPTL probe
1034b0a47e79SJuan Quintela
1035b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1036bd0c5661Spbrook  cat > $TMPC <<EOF
1037bd0c5661Spbrook#include <sched.h>
103830813ceaSpbrook#include <linux/futex.h>
1039bd0c5661Spbrookvoid foo()
1040bd0c5661Spbrook{
1041bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1042bd0c5661Spbrook#error bork
1043bd0c5661Spbrook#endif
1044bd0c5661Spbrook}
1045bd0c5661SpbrookEOF
1046bd0c5661Spbrook
104752166aa0SJuan Quintela  if compile_object ; then
1048b0a47e79SJuan Quintela    nptl=yes
1049bd0c5661Spbrook  else
1050b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1051b0a47e79SJuan Quintela      feature_not_found "nptl"
1052b0a47e79SJuan Quintela    fi
1053b0a47e79SJuan Quintela    nptl=no
1054b0a47e79SJuan Quintela  fi
1055bd0c5661Spbrookfi
1056bd0c5661Spbrook
105711d9f695Sbellard##########################################
1058ac62922eSbalrog# zlib check
1059ac62922eSbalrog
1060ac62922eSbalrogcat > $TMPC << EOF
1061ac62922eSbalrog#include <zlib.h>
1062ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1063ac62922eSbalrogEOF
106452166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1065ac62922eSbalrog    :
1066ac62922eSbalrogelse
1067ac62922eSbalrog    echo
1068ac62922eSbalrog    echo "Error: zlib check failed"
1069ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1070ac62922eSbalrog    echo
1071ac62922eSbalrog    exit 1
1072ac62922eSbalrogfi
1073ac62922eSbalrog
1074ac62922eSbalrog##########################################
1075e37630caSaliguori# xen probe
1076e37630caSaliguori
1077fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1078b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1079e37630caSaliguori  cat > $TMPC <<EOF
1080e37630caSaliguori#include <xenctrl.h>
1081e37630caSaliguori#include <xs.h>
1082df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1083e37630caSaliguoriEOF
108452166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1085fc321b4bSJuan Quintela    xen=yes
10863efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
1087e37630caSaliguori  else
1088fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1089fc321b4bSJuan Quintela      feature_not_found "xen"
1090fc321b4bSJuan Quintela    fi
1091fc321b4bSJuan Quintela    xen=no
1092e37630caSaliguori  fi
1093e37630caSaliguorifi
1094e37630caSaliguori
1095e37630caSaliguori##########################################
1096f91672e5SPaolo Bonzini# pkgconfig probe
1097f91672e5SPaolo Bonzini
1098f91672e5SPaolo Bonzinipkgconfig="${cross_prefix}pkg-config"
10990dba6195SLoïc Minierif ! has $pkgconfig; then
1100f91672e5SPaolo Bonzini  # likely not cross compiling, or hope for the best
1101f91672e5SPaolo Bonzini  pkgconfig=pkg-config
1102f91672e5SPaolo Bonzinifi
1103f91672e5SPaolo Bonzini
1104f91672e5SPaolo Bonzini##########################################
1105dfffc653SJuan Quintela# Sparse probe
1106dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
11070dba6195SLoïc Minier  if has cgcc; then
1108dfffc653SJuan Quintela    sparse=yes
1109dfffc653SJuan Quintela  else
1110dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1111dfffc653SJuan Quintela      feature_not_found "sparse"
1112dfffc653SJuan Quintela    fi
1113dfffc653SJuan Quintela    sparse=no
1114dfffc653SJuan Quintela  fi
1115dfffc653SJuan Quintelafi
1116dfffc653SJuan Quintela
1117dfffc653SJuan Quintela##########################################
111811d9f695Sbellard# SDL probe
111911d9f695Sbellard
1120fec0e3e8SStefan Weil# Look for sdl configuration program (pkg-config or sdl-config).
1121fec0e3e8SStefan Weil# Prefer variant with cross prefix if cross compiling,
1122fec0e3e8SStefan Weil# and favour pkg-config with sdl over sdl-config.
1123fec0e3e8SStefan Weilif test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
1124fec0e3e8SStefan Weil     $pkgconfig sdl --modversion >/dev/null 2>&1; then
1125fec0e3e8SStefan Weil  sdlconfig="$pkgconfig sdl"
1126fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1127fec0e3e8SStefan Weilelif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
1128fec0e3e8SStefan Weil  sdlconfig="${cross_prefix}sdl-config"
1129fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1130fec0e3e8SStefan Weilelif $pkgconfig sdl --modversion >/dev/null 2>&1; then
11319316f803SPaolo Bonzini  sdlconfig="$pkgconfig sdl"
11329316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
11330dba6195SLoïc Minierelif has sdl-config; then
11349316f803SPaolo Bonzini  sdlconfig='sdl-config'
11359316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1136a0dfd8a4SLoïc Minierelse
1137a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1138a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1139a0dfd8a4SLoïc Minier  fi
1140a0dfd8a4SLoïc Minier  sdl=no
11419316f803SPaolo Bonzinifi
114211d9f695Sbellard
11439316f803SPaolo Bonzinisdl_too_old=no
1144c4198157SJuan Quintelaif test "$sdl" != "no" ; then
114511d9f695Sbellard  cat > $TMPC << EOF
114611d9f695Sbellard#include <SDL.h>
114711d9f695Sbellard#undef main /* We don't want SDL to override our main() */
114811d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
114911d9f695SbellardEOF
11509316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
115174f42e18STeLeMan  if test "$static" = "yes" ; then
115274f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
115374f42e18STeLeMan  else
11549316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
115574f42e18STeLeMan  fi
115652166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
115711d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
115811d9f695Sbellard      sdl_too_old=yes
115911d9f695Sbellard    else
1160fd677642Sths      if test "$cocoa" = "no" ; then
116111d9f695Sbellard        sdl=yes
116211d9f695Sbellard      fi
1163fd677642Sths    fi
11647c1f25b4Sbellard
116567c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
11661ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
116767c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1168f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1169f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
117011d9f695Sbellard      fi
117152166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
11721ac88f28SJuan Quintela	:
11731ac88f28SJuan Quintela      else
11741ac88f28SJuan Quintela        sdl=no
11757c1f25b4Sbellard      fi
11767c1f25b4Sbellard    fi # static link
1177c4198157SJuan Quintela  else # sdl not found
1178c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1179c4198157SJuan Quintela      feature_not_found "sdl"
1180c4198157SJuan Quintela    fi
1181c4198157SJuan Quintela    sdl=no
11827c1f25b4Sbellard  fi # sdl compile test
1183fd677642Sthsfi
118411d9f695Sbellard
11855368a422Saliguoriif test "$sdl" = "yes" ; then
11865368a422Saliguori  cat > $TMPC <<EOF
11875368a422Saliguori#include <SDL.h>
11885368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
11895368a422Saliguori#include <X11/XKBlib.h>
11905368a422Saliguori#else
11915368a422Saliguori#error No x11 support
11925368a422Saliguori#endif
11935368a422Saliguoriint main(void) { return 0; }
11945368a422SaliguoriEOF
119552166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1196681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
11975368a422Saliguori  fi
119807d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
119907d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
120007d9ac44SJuan Quintela  fi
12010705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
12025368a422Saliguorifi
12035368a422Saliguori
12048f28f3fbSths##########################################
12058d5d2d4cSths# VNC TLS detection
12061be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1207ae6b5e5aSaliguori  cat > $TMPC <<EOF
1208ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1209ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1210ae6b5e5aSaliguoriEOF
1211f91672e5SPaolo Bonzini  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1212f91672e5SPaolo Bonzini  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
121352166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
12141be10ad2SJuan Quintela    vnc_tls=yes
1215a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1216ae6b5e5aSaliguori  else
12171be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
12181be10ad2SJuan Quintela      feature_not_found "vnc-tls"
12191be10ad2SJuan Quintela    fi
12201be10ad2SJuan Quintela    vnc_tls=no
12218d5d2d4cSths  fi
12228d5d2d4cSthsfi
12238d5d2d4cSths
12248d5d2d4cSths##########################################
12252f9606b3Saliguori# VNC SASL detection
12263aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
12272f9606b3Saliguori  cat > $TMPC <<EOF
12282f9606b3Saliguori#include <sasl/sasl.h>
12292f9606b3Saliguori#include <stdio.h>
12302f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
12312f9606b3SaliguoriEOF
12322f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
12332f9606b3Saliguori  vnc_sasl_cflags=""
12342f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
123552166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1236ea784e3bSJuan Quintela    vnc_sasl=yes
1237fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
12382f9606b3Saliguori  else
1239ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1240ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1241ea784e3bSJuan Quintela    fi
1242ea784e3bSJuan Quintela    vnc_sasl=no
12432f9606b3Saliguori  fi
12442f9606b3Saliguorifi
12452f9606b3Saliguori
12462f9606b3Saliguori##########################################
124776655d6dSaliguori# fnmatch() probe, used for ACL routines
124876655d6dSaliguorifnmatch="no"
124976655d6dSaliguoricat > $TMPC << EOF
125076655d6dSaliguori#include <fnmatch.h>
125176655d6dSaliguoriint main(void)
125276655d6dSaliguori{
125376655d6dSaliguori    fnmatch("foo", "foo", 0);
125476655d6dSaliguori    return 0;
125576655d6dSaliguori}
125676655d6dSaliguoriEOF
125752166aa0SJuan Quintelaif compile_prog "" "" ; then
125876655d6dSaliguori   fnmatch="yes"
125976655d6dSaliguorifi
126076655d6dSaliguori
126176655d6dSaliguori##########################################
1262ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1263ee682d27SStefan Weilif test "$uuid" != "no" ; then
1264ee682d27SStefan Weil  uuid_libs="-luuid"
1265ee682d27SStefan Weil  cat > $TMPC << EOF
1266ee682d27SStefan Weil#include <uuid/uuid.h>
1267ee682d27SStefan Weilint main(void)
1268ee682d27SStefan Weil{
1269ee682d27SStefan Weil    uuid_t my_uuid;
1270ee682d27SStefan Weil    uuid_generate(my_uuid);
1271ee682d27SStefan Weil    return 0;
1272ee682d27SStefan Weil}
1273ee682d27SStefan WeilEOF
1274ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1275ee682d27SStefan Weil    uuid="yes"
1276ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1277ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1278ee682d27SStefan Weil  else
1279ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1280ee682d27SStefan Weil      feature_not_found "uuid"
1281ee682d27SStefan Weil    fi
1282ee682d27SStefan Weil    uuid=no
1283ee682d27SStefan Weil  fi
1284ee682d27SStefan Weilfi
1285ee682d27SStefan Weil
1286ee682d27SStefan Weil##########################################
12878a16d273Sths# vde libraries probe
1288dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
12894baae0acSJuan Quintela  vde_libs="-lvdeplug"
12908a16d273Sths  cat > $TMPC << EOF
12918a16d273Sths#include <libvdeplug.h>
12924a7f0e06Spbrookint main(void)
12934a7f0e06Spbrook{
12944a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
12954a7f0e06Spbrook    vde_open("", "", &a);
12964a7f0e06Spbrook    return 0;
12974a7f0e06Spbrook}
12988a16d273SthsEOF
129952166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
13004baae0acSJuan Quintela    vde=yes
13018e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
13028e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1303dfb278bdSJuan Quintela  else
1304dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1305dfb278bdSJuan Quintela      feature_not_found "vde"
1306dfb278bdSJuan Quintela    fi
1307dfb278bdSJuan Quintela    vde=no
13088a16d273Sths  fi
13098a16d273Sthsfi
13108a16d273Sths
13118a16d273Sths##########################################
1312c2de5c91Smalc# Sound support libraries probe
13138f28f3fbSths
1314c2de5c91Smalcaudio_drv_probe()
1315c2de5c91Smalc{
1316c2de5c91Smalc    drv=$1
1317c2de5c91Smalc    hdr=$2
1318c2de5c91Smalc    lib=$3
1319c2de5c91Smalc    exp=$4
1320c2de5c91Smalc    cfl=$5
13218f28f3fbSths        cat > $TMPC << EOF
1322c2de5c91Smalc#include <$hdr>
1323c2de5c91Smalcint main(void) { $exp }
13248f28f3fbSthsEOF
132552166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
13268f28f3fbSths        :
13278f28f3fbSths    else
13288f28f3fbSths        echo
1329c2de5c91Smalc        echo "Error: $drv check failed"
1330c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
13318f28f3fbSths        echo
13328f28f3fbSths        exit 1
13338f28f3fbSths    fi
1334c2de5c91Smalc}
1335c2de5c91Smalc
13362fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1337c2de5c91Smalcfor drv in $audio_drv_list; do
1338c2de5c91Smalc    case $drv in
1339c2de5c91Smalc    alsa)
1340c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1341c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1342a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1343c2de5c91Smalc    ;;
1344c2de5c91Smalc
1345c2de5c91Smalc    fmod)
1346c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1347c2de5c91Smalc        echo
1348c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1349c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1350c2de5c91Smalc        echo
1351c2de5c91Smalc        exit 1
13528f28f3fbSths    fi
1353c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1354a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1355c2de5c91Smalc    ;;
1356c2de5c91Smalc
1357c2de5c91Smalc    esd)
1358c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1359a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
136067f86e8eSJuan Quintela    audio_pt_int="yes"
1361c2de5c91Smalc    ;;
1362b8e59f18Smalc
1363b8e59f18Smalc    pa)
1364493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1365b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1366493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
136767f86e8eSJuan Quintela    audio_pt_int="yes"
1368b8e59f18Smalc    ;;
1369b8e59f18Smalc
1370997e690aSJuan Quintela    coreaudio)
1371997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1372997e690aSJuan Quintela    ;;
1373997e690aSJuan Quintela
1374a4bf6780SJuan Quintela    dsound)
1375a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1376d5631638Smalc      audio_win_int="yes"
1377a4bf6780SJuan Quintela    ;;
1378a4bf6780SJuan Quintela
1379a4bf6780SJuan Quintela    oss)
1380a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1381a4bf6780SJuan Quintela    ;;
1382a4bf6780SJuan Quintela
1383a4bf6780SJuan Quintela    sdl|wav)
13842f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
13852f6a1ab0Sblueswir1    ;;
13862f6a1ab0Sblueswir1
1387d5631638Smalc    winwave)
1388d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1389d5631638Smalc      audio_win_int="yes"
1390d5631638Smalc    ;;
1391d5631638Smalc
1392e4c63a6aSmalc    *)
13931c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1394e4c63a6aSmalc        echo
1395e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1396e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1397e4c63a6aSmalc        echo
1398e4c63a6aSmalc        exit 1
1399e4c63a6aSmalc    }
1400e4c63a6aSmalc    ;;
1401c2de5c91Smalc    esac
1402c2de5c91Smalcdone
14038f28f3fbSths
14044d3b6f6eSbalrog##########################################
14052e4d9fb1Saurel32# BrlAPI probe
14062e4d9fb1Saurel32
14074ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1408eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
14092e4d9fb1Saurel32  cat > $TMPC << EOF
14102e4d9fb1Saurel32#include <brlapi.h>
14112e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
14122e4d9fb1Saurel32EOF
141352166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
14142e4d9fb1Saurel32    brlapi=yes
1415264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
14164ffcedb6SJuan Quintela  else
14174ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
14184ffcedb6SJuan Quintela      feature_not_found "brlapi"
14194ffcedb6SJuan Quintela    fi
14204ffcedb6SJuan Quintela    brlapi=no
1421eb82284fSJuan Quintela  fi
1422eb82284fSJuan Quintelafi
14232e4d9fb1Saurel32
14242e4d9fb1Saurel32##########################################
14254d3b6f6eSbalrog# curses probe
14264f78ef9aSJuan Quintelacurses_list="-lncurses -lcurses"
14274d3b6f6eSbalrog
1428c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1429c584a6d0SJuan Quintela  curses_found=no
14304d3b6f6eSbalrog  cat > $TMPC << EOF
14314d3b6f6eSbalrog#include <curses.h>
14325a8ff3aaSblueswir1#ifdef __OpenBSD__
14335a8ff3aaSblueswir1#define resize_term resizeterm
14345a8ff3aaSblueswir1#endif
14355a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
14364d3b6f6eSbalrogEOF
14374f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
14384f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1439c584a6d0SJuan Quintela      curses_found=yes
14404f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
14414f78ef9aSJuan Quintela      break
14424d3b6f6eSbalrog    fi
14434f78ef9aSJuan Quintela  done
1444c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1445c584a6d0SJuan Quintela    curses=yes
1446c584a6d0SJuan Quintela  else
1447c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1448c584a6d0SJuan Quintela      feature_not_found "curses"
1449c584a6d0SJuan Quintela    fi
1450c584a6d0SJuan Quintela    curses=no
1451c584a6d0SJuan Quintela  fi
14524f78ef9aSJuan Quintelafi
14534d3b6f6eSbalrog
1454414f0dabSblueswir1##########################################
1455769ce76dSAlexander Graf# curl probe
1456769ce76dSAlexander Graf
14574e2b0658SPaolo Bonziniif $pkgconfig libcurl --modversion >/dev/null 2>&1; then
14584e2b0658SPaolo Bonzini  curlconfig="$pkgconfig libcurl"
14594e2b0658SPaolo Bonzinielse
14604e2b0658SPaolo Bonzini  curlconfig=curl-config
14614e2b0658SPaolo Bonzinifi
14624e2b0658SPaolo Bonzini
1463788c8196SJuan Quintelaif test "$curl" != "no" ; then
1464769ce76dSAlexander Graf  cat > $TMPC << EOF
1465769ce76dSAlexander Graf#include <curl/curl.h>
1466769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1467769ce76dSAlexander GrafEOF
14684e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
14694e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1470b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1471769ce76dSAlexander Graf    curl=yes
1472f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1473f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1474788c8196SJuan Quintela  else
1475788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1476788c8196SJuan Quintela      feature_not_found "curl"
1477788c8196SJuan Quintela    fi
1478788c8196SJuan Quintela    curl=no
1479769ce76dSAlexander Graf  fi
1480769ce76dSAlexander Graffi # test "$curl"
1481769ce76dSAlexander Graf
1482769ce76dSAlexander Graf##########################################
14835495ed11SLuiz Capitulino# check framework probe
14845495ed11SLuiz Capitulino
14855495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
14865495ed11SLuiz Capitulino  cat > $TMPC << EOF
14875495ed11SLuiz Capitulino#include <check.h>
14885495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
14895495ed11SLuiz CapitulinoEOF
1490f91672e5SPaolo Bonzini  check_libs=`$pkgconfig --libs check`
14915495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
14925495ed11SLuiz Capitulino    check_utests=yes
14935495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
14945495ed11SLuiz Capitulino  else
14955495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
14965495ed11SLuiz Capitulino      feature_not_found "check"
14975495ed11SLuiz Capitulino    fi
14985495ed11SLuiz Capitulino    check_utests=no
14995495ed11SLuiz Capitulino  fi
15005495ed11SLuiz Capitulinofi # test "$check_utests"
15015495ed11SLuiz Capitulino
15025495ed11SLuiz Capitulino##########################################
1503fb599c9aSbalrog# bluez support probe
1504a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1505e820e3f4Sbalrog  cat > $TMPC << EOF
1506e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1507e820e3f4Sbalrogint main(void) { return bt_error(0); }
1508e820e3f4SbalrogEOF
1509f91672e5SPaolo Bonzini  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1510f91672e5SPaolo Bonzini  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
151152166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1512a20a6f46SJuan Quintela    bluez=yes
1513e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1514e820e3f4Sbalrog  else
1515a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1516a20a6f46SJuan Quintela      feature_not_found "bluez"
1517a20a6f46SJuan Quintela    fi
1518e820e3f4Sbalrog    bluez="no"
1519e820e3f4Sbalrog  fi
1520fb599c9aSbalrogfi
1521fb599c9aSbalrog
1522fb599c9aSbalrog##########################################
15237ba1e619Saliguori# kvm probe
1524b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
15257ba1e619Saliguori    cat > $TMPC <<EOF
15267ba1e619Saliguori#include <linux/kvm.h>
15279fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
15287ba1e619Saliguori#error Invalid KVM version
15297ba1e619Saliguori#endif
15309fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
15319fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
15329fd8d8d7Saliguori#endif
15339fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
15349fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
15359fd8d8d7Saliguori#endif
15369fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
15379fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
15389fd8d8d7Saliguori#endif
15397ba1e619Saliguoriint main(void) { return 0; }
15407ba1e619SaliguoriEOF
1541eac30262Saliguori  if test "$kerneldir" != "" ; then
1542eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
15438444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
15448444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
15458444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1546406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1547406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
15480e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
15490e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
15508444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
15518444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
15528444eb6eSaliguori      fi
1553eac30262Saliguori  else
1554f038e8f7SStefan Weil    kvm_cflags=`$pkgconfig --cflags kvm-kmod 2>/dev/null`
1555eac30262Saliguori  fi
155652166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1557b31a0277SJuan Quintela    kvm=yes
1558dae5079aSJan Kiszka    cat > $TMPC <<EOF
1559dae5079aSJan Kiszka#include <linux/kvm_para.h>
1560dae5079aSJan Kiszkaint main(void) { return 0; }
1561dae5079aSJan KiszkaEOF
1562dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1563dae5079aSJan Kiszka      kvm_para=yes
1564dae5079aSJan Kiszka    fi
15657ba1e619Saliguori  else
1566b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
15670dba6195SLoïc Minier      if has awk && has grep; then
1568a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
15699fd8d8d7Saliguori	| grep "error: " \
15709fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
15719fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1572b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1573168ccc11SJan Kiszka      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1574168ccc11SJan Kiszka  recent kvm-kmod from http://sourceforge.net/projects/kvm."
15759fd8d8d7Saliguori        fi
15769fd8d8d7Saliguori      fi
1577b31a0277SJuan Quintela      feature_not_found "kvm"
1578b31a0277SJuan Quintela    fi
1579b31a0277SJuan Quintela    kvm=no
15807ba1e619Saliguori  fi
15817ba1e619Saliguorifi
15827ba1e619Saliguori
15837ba1e619Saliguori##########################################
1584d5970055SMichael S. Tsirkin# test for vhost net
1585d5970055SMichael S. Tsirkin
1586d5970055SMichael S. Tsirkinif test "$vhost_net" != "no"; then
1587d5970055SMichael S. Tsirkin    if test "$kvm" != "no"; then
1588d5970055SMichael S. Tsirkin            cat > $TMPC <<EOF
1589d5970055SMichael S. Tsirkin    #include <linux/vhost.h>
1590d5970055SMichael S. Tsirkin    int main(void) { return 0; }
1591d5970055SMichael S. TsirkinEOF
1592d5970055SMichael S. Tsirkin            if compile_prog "$kvm_cflags" "" ; then
1593d5970055SMichael S. Tsirkin                vhost_net=yes
1594d5970055SMichael S. Tsirkin            else
1595d5970055SMichael S. Tsirkin                if test "$vhost_net" = "yes" ; then
1596d5970055SMichael S. Tsirkin                    feature_not_found "vhost-net"
1597d5970055SMichael S. Tsirkin                fi
1598d5970055SMichael S. Tsirkin                vhost_net=no
1599d5970055SMichael S. Tsirkin            fi
1600d5970055SMichael S. Tsirkin    else
1601d5970055SMichael S. Tsirkin            if test "$vhost_net" = "yes" ; then
16024021d247SAurelien Jarno                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1603d5970055SMichael S. Tsirkin                feature_not_found "vhost-net"
1604d5970055SMichael S. Tsirkin            fi
1605d5970055SMichael S. Tsirkin            vhost_net=no
1606d5970055SMichael S. Tsirkin    fi
1607d5970055SMichael S. Tsirkinfi
1608d5970055SMichael S. Tsirkin
1609d5970055SMichael S. Tsirkin##########################################
1610e5d355d1Saliguori# pthread probe
1611de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
16123c529d93Saliguori
1613e5d355d1Saliguoripthread=no
1614414f0dabSblueswir1cat > $TMPC << EOF
16153c529d93Saliguori#include <pthread.h>
1616de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1617414f0dabSblueswir1EOF
1618de65fe0fSSebastian Herbsztfor pthread_lib in $PTHREADLIBS_LIST; do
161952166aa0SJuan Quintela  if compile_prog "" "$pthread_lib" ; then
1620e5d355d1Saliguori    pthread=yes
16215572b539SJuan Quintela    LIBS="$pthread_lib $LIBS"
1622de65fe0fSSebastian Herbszt    break
1623414f0dabSblueswir1  fi
1624de65fe0fSSebastian Herbsztdone
1625414f0dabSblueswir1
16264617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
16274dd75c70SChristoph Hellwig  echo
16284dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
16294dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
16304dd75c70SChristoph Hellwig  echo
16314dd75c70SChristoph Hellwig  exit 1
1632e5d355d1Saliguorifi
1633e5d355d1Saliguori
1634bf9298b9Saliguori##########################################
16355c6c3a6cSChristoph Hellwig# linux-aio probe
16365c6c3a6cSChristoph Hellwig
16375c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
16385c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
16395c6c3a6cSChristoph Hellwig#include <libaio.h>
16405c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
16415c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
16425c6c3a6cSChristoph HellwigEOF
16435c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
16445c6c3a6cSChristoph Hellwig    linux_aio=yes
1645048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1646048d179fSPaul Brook    libs_tools="$libs_tools -laio"
16475c6c3a6cSChristoph Hellwig  else
16485c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
16495c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
16505c6c3a6cSChristoph Hellwig    fi
16513cfcae3cSLuiz Capitulino    linux_aio=no
16525c6c3a6cSChristoph Hellwig  fi
16535c6c3a6cSChristoph Hellwigfi
16545c6c3a6cSChristoph Hellwig
16555c6c3a6cSChristoph Hellwig##########################################
1656*758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1657*758e8e38SVenkateswararao Jujjuri (JV)
1658*758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1659*758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1660*758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1661*758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
1662*758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
1663*758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1664*758e8e38SVenkateswararao Jujjuri (JV)EOF
1665*758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
1666*758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1667*758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
1668*758e8e38SVenkateswararao Jujjuri (JV)  else
1669*758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1670*758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1671*758e8e38SVenkateswararao Jujjuri (JV)    fi
1672*758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1673*758e8e38SVenkateswararao Jujjuri (JV)  fi
1674*758e8e38SVenkateswararao Jujjuri (JV)fi
1675*758e8e38SVenkateswararao Jujjuri (JV)
1676*758e8e38SVenkateswararao Jujjuri (JV)##########################################
1677bf9298b9Saliguori# iovec probe
1678bf9298b9Saliguoricat > $TMPC <<EOF
1679db34f0b3Sblueswir1#include <sys/types.h>
1680bf9298b9Saliguori#include <sys/uio.h>
1681db34f0b3Sblueswir1#include <unistd.h>
1682bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1683bf9298b9SaliguoriEOF
1684bf9298b9Saliguoriiovec=no
168552166aa0SJuan Quintelaif compile_prog "" "" ; then
1686bf9298b9Saliguori  iovec=yes
1687bf9298b9Saliguorifi
1688bf9298b9Saliguori
1689f652e6afSaurel32##########################################
1690ceb42de8Saliguori# preadv probe
1691ceb42de8Saliguoricat > $TMPC <<EOF
1692ceb42de8Saliguori#include <sys/types.h>
1693ceb42de8Saliguori#include <sys/uio.h>
1694ceb42de8Saliguori#include <unistd.h>
1695ceb42de8Saliguoriint main(void) { preadv; }
1696ceb42de8SaliguoriEOF
1697ceb42de8Saliguoripreadv=no
169852166aa0SJuan Quintelaif compile_prog "" "" ; then
1699ceb42de8Saliguori  preadv=yes
1700ceb42de8Saliguorifi
1701ceb42de8Saliguori
1702ceb42de8Saliguori##########################################
1703f652e6afSaurel32# fdt probe
17042df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1705b41af4baSJuan Quintela  fdt_libs="-lfdt"
1706f652e6afSaurel32  cat > $TMPC << EOF
1707f652e6afSaurel32int main(void) { return 0; }
1708f652e6afSaurel32EOF
170952166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1710f652e6afSaurel32    fdt=yes
1711e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
17122df87df7SJuan Quintela  else
17132df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
17142df87df7SJuan Quintela      feature_not_found "fdt"
17152df87df7SJuan Quintela    fi
17162df87df7SJuan Quintela    fdt=no
1717f652e6afSaurel32  fi
1718f652e6afSaurel32fi
1719f652e6afSaurel32
17203b3f24adSaurel32#
17213b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
17223b3f24adSaurel32# emulator.  This is done because older glibc versions don't
17233b3f24adSaurel32# have syscall stubs for these implemented.
17243b3f24adSaurel32#
17253b3f24adSaurel32atfile=no
17263b3f24adSaurel32cat > $TMPC << EOF
17273b3f24adSaurel32#define _ATFILE_SOURCE
17283b3f24adSaurel32#include <sys/types.h>
17293b3f24adSaurel32#include <fcntl.h>
17303b3f24adSaurel32#include <unistd.h>
17313b3f24adSaurel32
17323b3f24adSaurel32int
17333b3f24adSaurel32main(void)
17343b3f24adSaurel32{
17353b3f24adSaurel32	/* try to unlink nonexisting file */
17363b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
17373b3f24adSaurel32}
17383b3f24adSaurel32EOF
173952166aa0SJuan Quintelaif compile_prog "" "" ; then
17403b3f24adSaurel32  atfile=yes
17413b3f24adSaurel32fi
17423b3f24adSaurel32
174339386ac7Saurel32# Check for inotify functions when we are building linux-user
17443b3f24adSaurel32# emulator.  This is done because older glibc versions don't
17453b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
17463b3f24adSaurel32# don't provide them even if kernel supports them.
17473b3f24adSaurel32#
17483b3f24adSaurel32inotify=no
17493b3f24adSaurel32cat > $TMPC << EOF
17503b3f24adSaurel32#include <sys/inotify.h>
17513b3f24adSaurel32
17523b3f24adSaurel32int
17533b3f24adSaurel32main(void)
17543b3f24adSaurel32{
17553b3f24adSaurel32	/* try to start inotify */
17568690e420Saurel32	return inotify_init();
17573b3f24adSaurel32}
17583b3f24adSaurel32EOF
175952166aa0SJuan Quintelaif compile_prog "" "" ; then
17603b3f24adSaurel32  inotify=yes
17613b3f24adSaurel32fi
17623b3f24adSaurel32
1763c05c7a73SRiku Voipioinotify1=no
1764c05c7a73SRiku Voipiocat > $TMPC << EOF
1765c05c7a73SRiku Voipio#include <sys/inotify.h>
1766c05c7a73SRiku Voipio
1767c05c7a73SRiku Voipioint
1768c05c7a73SRiku Voipiomain(void)
1769c05c7a73SRiku Voipio{
1770c05c7a73SRiku Voipio    /* try to start inotify */
1771c05c7a73SRiku Voipio    return inotify_init1(0);
1772c05c7a73SRiku Voipio}
1773c05c7a73SRiku VoipioEOF
1774c05c7a73SRiku Voipioif compile_prog "" "" ; then
1775c05c7a73SRiku Voipio  inotify1=yes
1776c05c7a73SRiku Voipiofi
1777c05c7a73SRiku Voipio
1778ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1779ebc996f3SRiku Voipioutimens=no
1780ebc996f3SRiku Voipiocat > $TMPC << EOF
1781ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1782ebc996f3SRiku Voipio#define _GNU_SOURCE
1783ebc996f3SRiku Voipio#include <stddef.h>
1784ebc996f3SRiku Voipio#include <fcntl.h>
1785ebc996f3SRiku Voipio
1786ebc996f3SRiku Voipioint main(void)
1787ebc996f3SRiku Voipio{
1788ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1789ebc996f3SRiku Voipio    futimens(0, NULL);
1790ebc996f3SRiku Voipio    return 0;
1791ebc996f3SRiku Voipio}
1792ebc996f3SRiku VoipioEOF
179352166aa0SJuan Quintelaif compile_prog "" "" ; then
1794ebc996f3SRiku Voipio  utimens=yes
1795ebc996f3SRiku Voipiofi
1796ebc996f3SRiku Voipio
1797099d6b0fSRiku Voipio# check if pipe2 is there
1798099d6b0fSRiku Voipiopipe2=no
1799099d6b0fSRiku Voipiocat > $TMPC << EOF
1800099d6b0fSRiku Voipio#define _GNU_SOURCE
1801099d6b0fSRiku Voipio#include <unistd.h>
1802099d6b0fSRiku Voipio#include <fcntl.h>
1803099d6b0fSRiku Voipio
1804099d6b0fSRiku Voipioint main(void)
1805099d6b0fSRiku Voipio{
1806099d6b0fSRiku Voipio    int pipefd[2];
1807099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1808099d6b0fSRiku Voipio    return 0;
1809099d6b0fSRiku Voipio}
1810099d6b0fSRiku VoipioEOF
181152166aa0SJuan Quintelaif compile_prog "" "" ; then
1812099d6b0fSRiku Voipio  pipe2=yes
1813099d6b0fSRiku Voipiofi
1814099d6b0fSRiku Voipio
181540ff6d7eSKevin Wolf# check if accept4 is there
181640ff6d7eSKevin Wolfaccept4=no
181740ff6d7eSKevin Wolfcat > $TMPC << EOF
181840ff6d7eSKevin Wolf#define _GNU_SOURCE
181940ff6d7eSKevin Wolf#include <sys/socket.h>
182040ff6d7eSKevin Wolf#include <stddef.h>
182140ff6d7eSKevin Wolf
182240ff6d7eSKevin Wolfint main(void)
182340ff6d7eSKevin Wolf{
182440ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
182540ff6d7eSKevin Wolf    return 0;
182640ff6d7eSKevin Wolf}
182740ff6d7eSKevin WolfEOF
182840ff6d7eSKevin Wolfif compile_prog "" "" ; then
182940ff6d7eSKevin Wolf  accept4=yes
183040ff6d7eSKevin Wolffi
183140ff6d7eSKevin Wolf
18323ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
18333ce34dfbSvibisreenivasansplice=no
18343ce34dfbSvibisreenivasancat > $TMPC << EOF
18353ce34dfbSvibisreenivasan#define _GNU_SOURCE
18363ce34dfbSvibisreenivasan#include <unistd.h>
18373ce34dfbSvibisreenivasan#include <fcntl.h>
18383ce34dfbSvibisreenivasan#include <limits.h>
18393ce34dfbSvibisreenivasan
18403ce34dfbSvibisreenivasanint main(void)
18413ce34dfbSvibisreenivasan{
18423ce34dfbSvibisreenivasan    int len, fd;
18433ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
18443ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
18453ce34dfbSvibisreenivasan    return 0;
18463ce34dfbSvibisreenivasan}
18473ce34dfbSvibisreenivasanEOF
184852166aa0SJuan Quintelaif compile_prog "" "" ; then
18493ce34dfbSvibisreenivasan  splice=yes
18503ce34dfbSvibisreenivasanfi
18513ce34dfbSvibisreenivasan
1852c2882b96SRiku Voipio# check if eventfd is supported
1853c2882b96SRiku Voipioeventfd=no
1854c2882b96SRiku Voipiocat > $TMPC << EOF
1855c2882b96SRiku Voipio#include <sys/eventfd.h>
1856c2882b96SRiku Voipio
1857c2882b96SRiku Voipioint main(void)
1858c2882b96SRiku Voipio{
1859c2882b96SRiku Voipio    int efd = eventfd(0, 0);
1860c2882b96SRiku Voipio    return 0;
1861c2882b96SRiku Voipio}
1862c2882b96SRiku VoipioEOF
1863c2882b96SRiku Voipioif compile_prog "" "" ; then
1864c2882b96SRiku Voipio  eventfd=yes
1865c2882b96SRiku Voipiofi
1866c2882b96SRiku Voipio
1867d0927938SUlrich Hecht# check for fallocate
1868d0927938SUlrich Hechtfallocate=no
1869d0927938SUlrich Hechtcat > $TMPC << EOF
1870d0927938SUlrich Hecht#include <fcntl.h>
1871d0927938SUlrich Hecht
1872d0927938SUlrich Hechtint main(void)
1873d0927938SUlrich Hecht{
1874d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
1875d0927938SUlrich Hecht    return 0;
1876d0927938SUlrich Hecht}
1877d0927938SUlrich HechtEOF
1878be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
1879d0927938SUlrich Hecht  fallocate=yes
1880d0927938SUlrich Hechtfi
1881d0927938SUlrich Hecht
1882d0927938SUlrich Hecht# check for dup3
1883d0927938SUlrich Hechtdup3=no
1884d0927938SUlrich Hechtcat > $TMPC << EOF
1885d0927938SUlrich Hecht#include <unistd.h>
1886d0927938SUlrich Hecht
1887d0927938SUlrich Hechtint main(void)
1888d0927938SUlrich Hecht{
1889d0927938SUlrich Hecht    dup3(0, 0, 0);
1890d0927938SUlrich Hecht    return 0;
1891d0927938SUlrich Hecht}
1892d0927938SUlrich HechtEOF
189378f5d726SJan Kiszkaif compile_prog "" "" ; then
1894d0927938SUlrich Hecht  dup3=yes
1895d0927938SUlrich Hechtfi
1896d0927938SUlrich Hecht
1897cc8ae6deSpbrook# Check if tools are available to build documentation.
1898a25dba17SJuan Quintelaif test "$docs" != "no" ; then
189901668d98SStefan Weil  if has makeinfo && has pod2man; then
1900a25dba17SJuan Quintela    docs=yes
190183a3ab8bSJuan Quintela  else
1902a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
1903a25dba17SJuan Quintela      feature_not_found "docs"
190483a3ab8bSJuan Quintela    fi
1905a25dba17SJuan Quintela    docs=no
190683a3ab8bSJuan Quintela  fi
1907cc8ae6deSpbrookfi
1908cc8ae6deSpbrook
1909f514f41cSStefan Weil# Search for bswap_32 function
19106ae9a1f4SJuan Quintelabyteswap_h=no
19116ae9a1f4SJuan Quintelacat > $TMPC << EOF
19126ae9a1f4SJuan Quintela#include <byteswap.h>
19136ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
19146ae9a1f4SJuan QuintelaEOF
191552166aa0SJuan Quintelaif compile_prog "" "" ; then
19166ae9a1f4SJuan Quintela  byteswap_h=yes
19176ae9a1f4SJuan Quintelafi
19186ae9a1f4SJuan Quintela
1919f514f41cSStefan Weil# Search for bswap_32 function
19206ae9a1f4SJuan Quintelabswap_h=no
19216ae9a1f4SJuan Quintelacat > $TMPC << EOF
19226ae9a1f4SJuan Quintela#include <sys/endian.h>
19236ae9a1f4SJuan Quintela#include <sys/types.h>
19246ae9a1f4SJuan Quintela#include <machine/bswap.h>
19256ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
19266ae9a1f4SJuan QuintelaEOF
192752166aa0SJuan Quintelaif compile_prog "" "" ; then
19286ae9a1f4SJuan Quintela  bswap_h=yes
19296ae9a1f4SJuan Quintelafi
19306ae9a1f4SJuan Quintela
1931da93a1fdSaliguori##########################################
1932da93a1fdSaliguori# Do we need librt
1933da93a1fdSaliguoricat > $TMPC <<EOF
1934da93a1fdSaliguori#include <signal.h>
1935da93a1fdSaliguori#include <time.h>
1936da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
1937da93a1fdSaliguoriEOF
1938da93a1fdSaliguori
193952166aa0SJuan Quintelaif compile_prog "" "" ; then
194007ffa4bdSJuan Quintela  :
194152166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
194207ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
1943da93a1fdSaliguorifi
1944da93a1fdSaliguori
194531ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
19466362a53fSJuan Quintela        "$aix" != "yes" ; then
19476362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
19486362a53fSJuan Quintelafi
19496362a53fSJuan Quintela
1950de5071c5SBlue Swirl##########################################
1951de5071c5SBlue Swirl# check if the compiler defines offsetof
1952de5071c5SBlue Swirl
1953de5071c5SBlue Swirlneed_offsetof=yes
1954de5071c5SBlue Swirlcat > $TMPC << EOF
1955de5071c5SBlue Swirl#include <stddef.h>
1956de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
1957de5071c5SBlue SwirlEOF
1958de5071c5SBlue Swirlif compile_prog "" "" ; then
1959de5071c5SBlue Swirl    need_offsetof=no
1960de5071c5SBlue Swirlfi
1961de5071c5SBlue Swirl
19625f6b9e8fSBlue Swirl##########################################
1963747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
1964747bbdf7SBlue Swirl#
1965747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
1966747bbdf7SBlue Swirl# about attribute warn_unused_result
1967747bbdf7SBlue Swirl
1968747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
1969747bbdf7SBlue Swirlcat > $TMPC << EOF
1970747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
1971747bbdf7SBlue Swirl#error gcc 3.3 or older
1972747bbdf7SBlue Swirl#endif
1973747bbdf7SBlue Swirlint main(void) { return 0;}
1974747bbdf7SBlue SwirlEOF
1975747bbdf7SBlue Swirlif compile_prog "" ""; then
1976747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
1977747bbdf7SBlue Swirlfi
1978747bbdf7SBlue Swirl
1979747bbdf7SBlue Swirl##########################################
19805f6b9e8fSBlue Swirl# check if we have fdatasync
19815f6b9e8fSBlue Swirl
19825f6b9e8fSBlue Swirlfdatasync=no
19835f6b9e8fSBlue Swirlcat > $TMPC << EOF
19845f6b9e8fSBlue Swirl#include <unistd.h>
19855f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
19865f6b9e8fSBlue SwirlEOF
19875f6b9e8fSBlue Swirlif compile_prog "" "" ; then
19885f6b9e8fSBlue Swirl    fdatasync=yes
19895f6b9e8fSBlue Swirlfi
19905f6b9e8fSBlue Swirl
1991e86ecd4bSJuan Quintela# End of CC checks
1992e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
1993e86ecd4bSJuan Quintela
1994e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
19951156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
1996e86ecd4bSJuan Quintelafi
1997a316e378SJuan Quintela
1998e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
1999e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2000e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
200120ff6c80SAnthony Liguori
200220ff6c80SAnthony Liguoriif test -z "$werror" ; then
2003e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2004e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2005e86ecd4bSJuan Quintela        werror="yes"
2006e86ecd4bSJuan Quintela    else
2007e86ecd4bSJuan Quintela        werror="no"
2008e86ecd4bSJuan Quintela    fi
2009e86ecd4bSJuan Quintelafi
2010e86ecd4bSJuan Quintela
201120ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
201220ff6c80SAnthony Liguori# enable/disable
201320ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
201420ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
201520ff6c80SAnthony Liguori	zero_malloc="no"
201620ff6c80SAnthony Liguori    else
201720ff6c80SAnthony Liguori	zero_malloc="yes"
201820ff6c80SAnthony Liguori    fi
201920ff6c80SAnthony Liguorifi
202020ff6c80SAnthony Liguori
2021e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2022a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2023e86ecd4bSJuan Quintelafi
2024e86ecd4bSJuan Quintela
2025e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2026e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
20271156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2028e86ecd4bSJuan Quintela    fi
2029e86ecd4bSJuan Quintelafi
2030e86ecd4bSJuan Quintela
2031190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
20325a67135aSbellard
2033ca35f780SPaolo Bonzinitools=
2034ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2035ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2036ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2037ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2038ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2039ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2040ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2041ca35f780SPaolo Bonzini    fi
2042ca35f780SPaolo Bonzini  fi
2043ca35f780SPaolo Bonzinifi
2044ca35f780SPaolo Bonzini
2045ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2046ca35f780SPaolo Bonziniroms=
2047ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2048ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2049ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2050ca35f780SPaolo Bonzini  roms="optionrom"
2051ca35f780SPaolo Bonzinifi
2052ca35f780SPaolo Bonzini
2053ca35f780SPaolo Bonzini
20547d13299dSbellardecho "Install prefix    $prefix"
2055f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2056f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
20571c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
205811d9f695Sbellardif test "$mingw32" = "no" ; then
2059f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
206043ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
206111d9f695Sbellardfi
20625a67135aSbellardecho "Source path       $source_path"
20637d13299dSbellardecho "C compiler        $cc"
206483469015Sbellardecho "Host C compiler   $host_cc"
20650c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2066a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
20670c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
20687d13299dSbellardecho "make              $make"
20696a882643Spbrookecho "install           $install"
2070a98fd896Sbellardecho "host CPU          $cpu"
2071de83cd02Sbellardecho "host big endian   $bigendian"
207297a847bcSbellardecho "target list       $target_list"
2073ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2074b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
20757d13299dSbellardecho "gprof enabled     $gprof"
207603b4fe7dSaliguoriecho "sparse enabled    $sparse"
20771625af87Saliguoriecho "strip binaries    $strip_opt"
207805c2a3e7Sbellardecho "profiler          $profiler"
207943ce4dfeSbellardecho "static build      $static"
208085aa5189Sbellardecho "-Werror enabled   $werror"
20815b0753e0Sbellardif test "$darwin" = "yes" ; then
20825b0753e0Sbellard    echo "Cocoa support     $cocoa"
20835b0753e0Sbellardfi
208497a847bcSbellardecho "SDL support       $sdl"
20854d3b6f6eSbalrogecho "curses support    $curses"
2086769ce76dSAlexander Grafecho "curl support      $curl"
20875495ed11SLuiz Capitulinoecho "check support     $check_utests"
208867b915a5Sbellardecho "mingw32 support   $mingw32"
20890c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
20900c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2091eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
20928ff9cbf7Smalcecho "Mixer emulation   $mixemu"
20938d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
20942f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
20953142255cSblueswir1if test -n "$sparc_cpu"; then
20963142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
20973142255cSblueswir1fi
2098e37630caSaliguoriecho "xen support       $xen"
20992e4d9fb1Saurel32echo "brlapi support    $brlapi"
2100a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2101a25dba17SJuan Quintelaecho "Documentation     $docs"
2102c5937220Spbrook[ ! -z "$uname_release" ] && \
2103c5937220Spbrookecho "uname -r          $uname_release"
2104bd0c5661Spbrookecho "NPTL support      $nptl"
2105379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
210634005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
21078a16d273Sthsecho "vde support       $vde"
2108e5d355d1Saliguoriecho "IO thread         $io_thread"
21095c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2110*758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
211177755340Sthsecho "Install blobs     $blobs"
2112b31a0277SJuan Quintelaecho "KVM support       $kvm"
2113f652e6afSaurel32echo "fdt support       $fdt"
2114ceb42de8Saliguoriecho "preadv support    $preadv"
21155f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2116ee682d27SStefan Weilecho "uuid support      $uuid"
2117d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
211867b915a5Sbellard
211997a847bcSbellardif test $sdl_too_old = "yes"; then
212024b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2121e8cd23deSbellardfi
212297a847bcSbellard
212398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
21244bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
212597a847bcSbellard
212698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
212798ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
212898ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
212998ec69acSJuan Quintelaecho >> $config_host_mak
213098ec69acSJuan Quintela
213199d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
213299d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
213399d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
213499d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
213599d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
213699d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
21371dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2138804edf29SJuan Quintela
21392408a527Saurel32case "$cpu" in
214024e804ecSAlexander Graf  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2141e0da9dd3SJuan Quintela    ARCH=$cpu
21422408a527Saurel32  ;;
2143a302c32dSLaurent Desnogues  armv4b|armv4l)
214416dbd14fSJuan Quintela    ARCH=arm
21452408a527Saurel32  ;;
21462408a527Saurel32esac
214798ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2148f8393946Saurel32if test "$debug_tcg" = "yes" ; then
21492358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2150f8393946Saurel32fi
2151b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2152b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2153b4475aa2SLuiz Capitulinofi
2154f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
21552358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2156f3d08ee6SPaul Brookfi
21571625af87Saliguoriif test "$strip_opt" = "yes" ; then
215898ec69acSJuan Quintela  echo "STRIP_OPT=-s" >> $config_host_mak
21591625af87Saliguorifi
21607d13299dSbellardif test "$bigendian" = "yes" ; then
2161e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
216297a847bcSbellardfi
21632358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
216467b915a5Sbellardif test "$mingw32" = "yes" ; then
216598ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
2166210fa556Spbrookelse
216735f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2168210fa556Spbrookfi
2169128ab2ffSblueswir1
2170dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2171dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2172dffcb71cSMark McLoughlinfi
2173dffcb71cSMark McLoughlin
217483fb7adfSbellardif test "$darwin" = "yes" ; then
217598ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
217683fb7adfSbellardfi
2177b29fe3edSmalc
2178b29fe3edSmalcif test "$aix" = "yes" ; then
217998ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2180b29fe3edSmalcfi
2181b29fe3edSmalc
2182ec530c81Sbellardif test "$solaris" = "yes" ; then
218398ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
21842358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
21850475a5caSths  if test "$needs_libsunmath" = "yes" ; then
218675b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
21870475a5caSths  fi
2188ec530c81Sbellardfi
218997a847bcSbellardif test "$static" = "yes" ; then
219098ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
219197a847bcSbellardfi
219205c2a3e7Sbellardif test $profiler = "yes" ; then
21932358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
219405c2a3e7Sbellardfi
2195c20709aaSbellardif test "$slirp" = "yes" ; then
219698ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2197b6e31c12SJuan Quintela  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
2198c20709aaSbellardfi
21998a16d273Sthsif test "$vde" = "yes" ; then
220098ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
22018a16d273Sthsfi
22020c58ac1cSmalcfor card in $audio_card_list; do
2203f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
220498ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
22050c58ac1cSmalcdone
22062358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
22070c58ac1cSmalcfor drv in $audio_drv_list; do
2208f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
220998ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2210923e4521Smalc    if test "$drv" = "fmod"; then
22117aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2212fb065187Sbellard    fi
22130c58ac1cSmalcdone
221467f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
221567f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
221667f86e8eSJuan Quintelafi
2217d5631638Smalcif test "$audio_win_int" = "yes" ; then
2218d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2219d5631638Smalcfi
2220eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
22218ff9cbf7Smalcif test "$mixemu" = "yes" ; then
222298ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
22238ff9cbf7Smalcfi
22248d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
222598ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2226525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
22278d5d2d4cSthsfi
22282f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
222998ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
223060ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
22312f9606b3Saliguorifi
223276655d6dSaliguoriif test "$fnmatch" = "yes" ; then
22332358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
223476655d6dSaliguorifi
2235ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2236ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2237ee682d27SStefan Weilfi
2238b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
223998ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
22402358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
224198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
224298ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2243a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
224498ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2245cc8ae6deSpbrookfi
22461ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
224798ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
22488ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
224949ecc3faSbellardfi
225049ecc3faSbellardif test "$cocoa" = "yes" ; then
225198ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
225249ecc3faSbellardfi
22534d3b6f6eSbalrogif test "$curses" = "yes" ; then
225498ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2255ab4e5602SJan Kiszkafi
22563b3f24adSaurel32if test "$atfile" = "yes" ; then
22572358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
22583b3f24adSaurel32fi
2259ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
22602358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2261ebc996f3SRiku Voipiofi
2262099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
22632358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2264099d6b0fSRiku Voipiofi
226540ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
226640ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
226740ff6d7eSKevin Wolffi
22683ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
22692358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
22703ce34dfbSvibisreenivasanfi
2271c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2272c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2273c2882b96SRiku Voipiofi
2274d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2275d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2276d0927938SUlrich Hechtfi
2277d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2278d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2279d0927938SUlrich Hechtfi
22803b3f24adSaurel32if test "$inotify" = "yes" ; then
22812358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
22823b3f24adSaurel32fi
2283c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2284c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2285c05c7a73SRiku Voipiofi
22866ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
22876ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
22886ae9a1f4SJuan Quintelafi
22896ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
22906ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
22916ae9a1f4SJuan Quintelafi
2292769ce76dSAlexander Grafif test "$curl" = "yes" ; then
229398ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2294b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2295769ce76dSAlexander Graffi
22962e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
229798ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
22982e4d9fb1Saurel32fi
2299fb599c9aSbalrogif test "$bluez" = "yes" ; then
230098ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2301ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2302fb599c9aSbalrogfi
2303e37630caSaliguoriif test "$xen" = "yes" ; then
23045647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2305e37630caSaliguorifi
2306e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
230798ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2308e5d355d1Saliguorifi
23095c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
23105c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
23115c6c3a6cSChristoph Hellwigfi
2312*758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2313*758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2314*758e8e38SVenkateswararao Jujjuri (JV)fi
2315*758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2316*758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2317*758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2318*758e8e38SVenkateswararao Jujjuri (JV)  fi
2319*758e8e38SVenkateswararao Jujjuri (JV)fi
232077755340Sthsif test "$blobs" = "yes" ; then
232198ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
232277755340Sthsfi
2323bf9298b9Saliguoriif test "$iovec" = "yes" ; then
23242358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2325bf9298b9Saliguorifi
2326ceb42de8Saliguoriif test "$preadv" = "yes" ; then
23272358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2328ceb42de8Saliguorifi
2329f652e6afSaurel32if test "$fdt" = "yes" ; then
23303f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2331f652e6afSaurel32fi
2332de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2333de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2334de5071c5SBlue Swirlfi
2335747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2336747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2337747bbdf7SBlue Swirlfi
23385f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
23395f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
23405f6b9e8fSBlue Swirlfi
234197a847bcSbellard
234283fb7adfSbellard# XXX: suppress that
23437d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
23442358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
23457d3505c5Sbellardfi
23467d3505c5Sbellard
23472358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2348c5937220Spbrook
234920ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
235020ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
235120ff6c80SAnthony Liguorifi
235220ff6c80SAnthony Liguori
235368063649Sblueswir1# USB host support
235468063649Sblueswir1case "$usb" in
235568063649Sblueswir1linux)
235698ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
235768063649Sblueswir1;;
235868063649Sblueswir1bsd)
235998ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
236068063649Sblueswir1;;
236168063649Sblueswir1*)
236298ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
236368063649Sblueswir1;;
236468063649Sblueswir1esac
236568063649Sblueswir1
236698ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
236798ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2368804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2369804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2370804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2371804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2372804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2373804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
2374804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2375804edf29SJuan Quintelaif test "$sparse" = "yes" ; then
2376804edf29SJuan Quintela  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2377804edf29SJuan Quintela  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2378a558ee17SJuan Quintela  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2379804edf29SJuan Quintelafi
2380804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2381804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2382804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
2383e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2384a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2385c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2386e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2387a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2388a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
238973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
23903e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2391804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2392804edf29SJuan Quintela
23934bf6b55bSJuan Quintela# generate list of library paths for linker script
23944bf6b55bSJuan Quintela
23954bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
23964bf6b55bSJuan Quintela
23974bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
23984bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
23994bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
24004bf6b55bSJuan Quintela  else
24014bf6b55bSJuan Quintela    rm ${config_host_ld}~
24024bf6b55bSJuan Quintela  fi
24034bf6b55bSJuan Quintelafi
24044bf6b55bSJuan Quintela
24054d904533SBlue Swirlfor d in libdis libdis-user; do
24064d904533SBlue Swirl    mkdir -p $d
24074d904533SBlue Swirl    rm -f $d/Makefile
24084d904533SBlue Swirl    ln -s $source_path/Makefile.dis $d/Makefile
24094d904533SBlue Swirl    echo > $d/config.mak
24104d904533SBlue Swirldone
2411d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
2412d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2413d44cff22SRichard Hendersonfi
24144d904533SBlue Swirl
241597a847bcSbellardfor target in $target_list; do
241697a847bcSbellardtarget_dir="$target"
241725be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2418600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
241997a847bcSbellardtarget_bigendian="no"
24201f3d3c8fSJuan Quintela
2421ea2d6a39SJuan Quintelacase "$target_arch2" in
242224e804ecSAlexander Graf  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2423ea2d6a39SJuan Quintela  target_bigendian=yes
2424ea2d6a39SJuan Quintela  ;;
2425ea2d6a39SJuan Quintelaesac
242697a847bcSbellardtarget_softmmu="no"
2427997344f3Sbellardtarget_user_only="no"
2428831b7825Sthstarget_linux_user="no"
2429831b7825Sthstarget_darwin_user="no"
243084778508Sblueswir1target_bsd_user="no"
24319e407a85Spbrookcase "$target" in
2432600309b6SBlue Swirl  ${target_arch2}-softmmu)
24339e407a85Spbrook    target_softmmu="yes"
24349e407a85Spbrook    ;;
2435600309b6SBlue Swirl  ${target_arch2}-linux-user)
24369c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
24379c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
24389c7a4202SBlue Swirl      exit 1
24399c7a4202SBlue Swirl    fi
24409e407a85Spbrook    target_user_only="yes"
24419e407a85Spbrook    target_linux_user="yes"
24429e407a85Spbrook    ;;
2443600309b6SBlue Swirl  ${target_arch2}-darwin-user)
24449c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
24459c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
24469c7a4202SBlue Swirl      exit 1
24479c7a4202SBlue Swirl    fi
24489e407a85Spbrook    target_user_only="yes"
2449831b7825Sths    target_darwin_user="yes"
24509e407a85Spbrook    ;;
2451600309b6SBlue Swirl  ${target_arch2}-bsd-user)
24529cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
24539c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
24549c7a4202SBlue Swirl      exit 1
24559c7a4202SBlue Swirl    fi
245684778508Sblueswir1    target_user_only="yes"
245784778508Sblueswir1    target_bsd_user="yes"
245884778508Sblueswir1    ;;
24599e407a85Spbrook  *)
24609e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
24619e407a85Spbrook    exit 1
24629e407a85Spbrook    ;;
24639e407a85Spbrookesac
2464831b7825Sths
246597a847bcSbellardmkdir -p $target_dir
2466158142c2Sbellardmkdir -p $target_dir/fpu
246757fec1feSbellardmkdir -p $target_dir/tcg
246859f2a787SGerd Hoffmannmkdir -p $target_dir/ide
246984778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
247069de927cSbellard  mkdir -p $target_dir/nwfpe
247169de927cSbellardfi
247269de927cSbellard
2473ec530c81Sbellard#
2474ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
2475ec530c81Sbellard#
2476ec530c81Sbellardrm -f $target_dir/Makefile
2477ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
2478ec530c81Sbellard
247997a847bcSbellard
248025be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
248197a847bcSbellard
2482e5fe0c52Spbrookbflt="no"
2483bd0c5661Spbrooktarget_nptl="no"
2484600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
24857ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
248656aebc89Spbrookgdb_xml_files=""
24877ba1e619Saliguori
2488938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
24896acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2490e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2491e73aae67SJuan Quintela
2492600309b6SBlue Swirlcase "$target_arch2" in
24932408a527Saurel32  i386)
24941ad2134fSPaul Brook    target_phys_bits=32
24952408a527Saurel32  ;;
24962408a527Saurel32  x86_64)
24976acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
24981ad2134fSPaul Brook    target_phys_bits=64
24992408a527Saurel32  ;;
25002408a527Saurel32  alpha)
25011ad2134fSPaul Brook    target_phys_bits=64
2502a4b388ffSRichard Henderson    target_nptl="yes"
25032408a527Saurel32  ;;
25042408a527Saurel32  arm|armeb)
2505b498c8a0SJuan Quintela    TARGET_ARCH=arm
2506e5fe0c52Spbrook    bflt="yes"
2507bd0c5661Spbrook    target_nptl="yes"
250856aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
25091ad2134fSPaul Brook    target_phys_bits=32
25102408a527Saurel32  ;;
25112408a527Saurel32  cris)
2512253bd7f8Sedgar_igl    target_nptl="yes"
25131ad2134fSPaul Brook    target_phys_bits=32
25142408a527Saurel32  ;;
25152408a527Saurel32  m68k)
25160938cda5Saurel32    bflt="yes"
251756aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
25181ad2134fSPaul Brook    target_phys_bits=32
25192408a527Saurel32  ;;
252072b675caSEdgar E. Iglesias  microblaze)
252172b675caSEdgar E. Iglesias    bflt="yes"
252272b675caSEdgar E. Iglesias    target_nptl="yes"
252372b675caSEdgar E. Iglesias    target_phys_bits=32
252472b675caSEdgar E. Iglesias  ;;
25252408a527Saurel32  mips|mipsel)
2526b498c8a0SJuan Quintela    TARGET_ARCH=mips
252725be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2528f04dc72fSPaul Brook    target_nptl="yes"
25291ad2134fSPaul Brook    target_phys_bits=64
25302408a527Saurel32  ;;
25312408a527Saurel32  mipsn32|mipsn32el)
2532b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
25336acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
253425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
25351ad2134fSPaul Brook    target_phys_bits=64
25362408a527Saurel32  ;;
25372408a527Saurel32  mips64|mips64el)
2538b498c8a0SJuan Quintela    TARGET_ARCH=mips64
25396acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
254025be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
25411ad2134fSPaul Brook    target_phys_bits=64
25422408a527Saurel32  ;;
25432408a527Saurel32  ppc)
2544c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25451ad2134fSPaul Brook    target_phys_bits=32
2546d6630708SNathan Froyd    target_nptl="yes"
25472408a527Saurel32  ;;
25482408a527Saurel32  ppcemb)
25496acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2550e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2551c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25521ad2134fSPaul Brook    target_phys_bits=64
2553d6630708SNathan Froyd    target_nptl="yes"
25542408a527Saurel32  ;;
25552408a527Saurel32  ppc64)
25566acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2557e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2558c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25591ad2134fSPaul Brook    target_phys_bits=64
25602408a527Saurel32  ;;
25612408a527Saurel32  ppc64abi32)
2562b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
25636acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2564e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
256525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
2566c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25671ad2134fSPaul Brook    target_phys_bits=64
25682408a527Saurel32  ;;
25692408a527Saurel32  sh4|sh4eb)
2570b498c8a0SJuan Quintela    TARGET_ARCH=sh4
25714dbed897Spbrook    bflt="yes"
25720b6d3ae0Saurel32    target_nptl="yes"
25731ad2134fSPaul Brook    target_phys_bits=32
25742408a527Saurel32  ;;
25752408a527Saurel32  sparc)
25761ad2134fSPaul Brook    target_phys_bits=64
25772408a527Saurel32  ;;
25782408a527Saurel32  sparc64)
25796acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
25801ad2134fSPaul Brook    target_phys_bits=64
25812408a527Saurel32  ;;
25822408a527Saurel32  sparc32plus)
2583b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
25846acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
2585e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
258625be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
25871ad2134fSPaul Brook    target_phys_bits=64
25882408a527Saurel32  ;;
258924e804ecSAlexander Graf  s390x)
259024e804ecSAlexander Graf    target_phys_bits=64
259124e804ecSAlexander Graf  ;;
25922408a527Saurel32  *)
2593de83cd02Sbellard    echo "Unsupported target CPU"
2594de83cd02Sbellard    exit 1
25952408a527Saurel32  ;;
25962408a527Saurel32esac
259725be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2598053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
259925be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
260025be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
260142bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
26026acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
26036acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
26046acff7daSJuan Quintelafi
260525be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2606e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
2607e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
2608e6e91b9cSJuan Quintelafi
260925be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
26101b0c87fcSJuan Quintelacase "$target_arch2" in
26111b0c87fcSJuan Quintela  i386|x86_64)
26121b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
261325be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
26141b0c87fcSJuan Quintela    fi
26151b0c87fcSJuan Quintelaesac
2616c59249f9SJuan Quintelacase "$target_arch2" in
26170e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
2618c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
2619c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2620c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
2621c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
26225f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2623c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2624c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
262525be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
262625be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2627dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
2628dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
2629dae5079aSJan Kiszka      fi
2630d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
2631d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
2632d5970055SMichael S. Tsirkin      fi
2633c59249f9SJuan Quintela    fi
2634c59249f9SJuan Quintelaesac
2635de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
263625be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
263797a847bcSbellardfi
263897a847bcSbellardif test "$target_softmmu" = "yes" ; then
2639b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
264025be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
264125be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
26420e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
26435791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2644de83cd02Sbellardfi
2645997344f3Sbellardif test "$target_user_only" = "yes" ; then
264625be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2647997344f3Sbellardfi
2648831b7825Sthsif test "$target_linux_user" = "yes" ; then
264925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2650831b7825Sthsfi
2651831b7825Sthsif test "$target_darwin_user" = "yes" ; then
265225be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2653831b7825Sthsfi
265456aebc89Spbrooklist=""
265556aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
265656aebc89Spbrook  for x in $gdb_xml_files; do
265756aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
265856aebc89Spbrook  done
265925be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
26603d0f1517SJuan Quintelafi
2661de83cd02Sbellard
2662f57975fbSJuan Quintelacase "$target_arch2" in
2663990b3e19SRichard Henderson  alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
266425be210fSJuan Quintela    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2665f57975fbSJuan Quintela    ;;
2666d6b38939SJuan Quintela  *)
266725be210fSJuan Quintela    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2668d6b38939SJuan Quintela    ;;
2669f57975fbSJuan Quintelaesac
2670f57975fbSJuan Quintela
2671e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
267225be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2673e5fe0c52Spbrookfi
2674bd0c5661Spbrookif test "$target_user_only" = "yes" \
2675bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
267625be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2677bd0c5661Spbrookfi
2678379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
267925be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2680379f6698SPaul Brookfi
268184778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
268225be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
268384778508Sblueswir1fi
26845b0753e0Sbellard
26854afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
2686fa282484SJuan Quintela
26874afddb55SJuan Quintelacflags=""
2688fa282484SJuan Quintelaldflags=""
26899b8e111fSJuan Quintela
269057ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
269157ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
269224e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
269324e804ecSAlexander Graf  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
26945d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
26955d8a4f8fSRichard Henderson  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
269657ddfbf7SJuan Quintelaelse
269757ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
269857ddfbf7SJuan Quintelafi
269957ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/tcg $cflags"
270057ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/fpu $cflags"
270157ddfbf7SJuan Quintela
27024d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
27034d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
27044d904533SBlue Swirlelse
27054d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
27064d904533SBlue Swirlfi
27074d904533SBlue Swirl
270864656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
270964656024SJuan Quintela  case "$i" in
271064656024SJuan Quintela  alpha)
271125be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
27124d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
271364656024SJuan Quintela  ;;
271464656024SJuan Quintela  arm)
271525be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
27164d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
271764656024SJuan Quintela  ;;
271864656024SJuan Quintela  cris)
271925be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
27204d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
272164656024SJuan Quintela  ;;
272264656024SJuan Quintela  hppa)
272325be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
27244d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
272564656024SJuan Quintela  ;;
272664656024SJuan Quintela  i386|x86_64)
272725be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
27284d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
272964656024SJuan Quintela  ;;
2730903ec55cSAurelien Jarno  ia64*)
2731903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
2732903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
2733903ec55cSAurelien Jarno  ;;
273464656024SJuan Quintela  m68k)
273525be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
27364d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
273764656024SJuan Quintela  ;;
273864656024SJuan Quintela  microblaze)
273925be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
27404d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
274164656024SJuan Quintela  ;;
274264656024SJuan Quintela  mips*)
274325be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
27444d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
274564656024SJuan Quintela  ;;
274664656024SJuan Quintela  ppc*)
274725be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
27484d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
274964656024SJuan Quintela  ;;
275024e804ecSAlexander Graf  s390*)
275125be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
27524d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
275364656024SJuan Quintela  ;;
275464656024SJuan Quintela  sh4)
275525be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
27564d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
275764656024SJuan Quintela  ;;
275864656024SJuan Quintela  sparc*)
275925be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
27604d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
276164656024SJuan Quintela  ;;
276264656024SJuan Quintela  esac
276364656024SJuan Quinteladone
276464656024SJuan Quintela
27656ee7126fSJuan Quintelacase "$ARCH" in
27666ee7126fSJuan Quintelaalpha)
27676ee7126fSJuan Quintela  # Ensure there's only a single GP
27686ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
27696ee7126fSJuan Quintela;;
27706ee7126fSJuan Quintelaesac
27716ee7126fSJuan Quintela
277255d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
277355d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
277455d9c04bSJuan Quintela  arm)
277555d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
277655d9c04bSJuan Quintela  ;;
277755d9c04bSJuan Quintela  i386|mips|ppc)
277855d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
277955d9c04bSJuan Quintela  ;;
278055d9c04bSJuan Quintela  esac
278155d9c04bSJuan Quintelafi
278255d9c04bSJuan Quintela
278334005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
278434005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
278534005a00SKirill A. Shutemov  cflags="-fpie $cflags"
278634005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
278734005a00SKirill A. Shutemovfi
278834005a00SKirill A. Shutemov
2789471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
2790471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
2791471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
279225be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
2793471857ddSJuan Quintelafi
2794471857ddSJuan Quintela
2795d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
279625be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
2797d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
2798d02c1db3SJuan Quintela    cflags="-p $cflags"
2799d02c1db3SJuan Quintela    ldflags="-p $ldflags"
2800d02c1db3SJuan Quintela  fi
2801d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
2802d02c1db3SJuan Quintela    ldflags="-p $ldflags"
280325be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
2804d02c1db3SJuan Quintela  fi
2805d02c1db3SJuan Quintelafi
2806d02c1db3SJuan Quintela
28076ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
28089b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2809fa282484SJuan Quintela  case "$ARCH" in
2810fa282484SJuan Quintela  sparc)
2811fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
2812322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
2813fa282484SJuan Quintela    ;;
28144d58be06SRichard Henderson  alpha | s390x)
28154d58be06SRichard Henderson    # The default placement of the application is fine.
28164d58be06SRichard Henderson    ;;
2817fd76e73aSRichard Henderson  *)
2818322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
2819fa282484SJuan Quintela    ;;
2820fa282484SJuan Quintela  esac
2821fa282484SJuan Quintelafi
2822fa282484SJuan Quintela
282325be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
282425be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
2825fa282484SJuan Quintela
282697a847bcSbellarddone # for target in $targets
28277d13299dSbellard
28287d13299dSbellard# build tree in object directory if source path is different from current one
28297d13299dSbellardif test "$source_path_used" = "yes" ; then
2830e1144d00SMark McLoughlin    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
28312d9f27d2SAnthony Liguori    DIRS="$DIRS roms/seabios roms/vgabios"
283274db920cSGautham R Shenoy    DIRS="$DIRS fsdev"
28337d13299dSbellard    FILES="Makefile tests/Makefile"
2834e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2835e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
28367ea78b74SJan Kiszka    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
28372d9f27d2SAnthony Liguori    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
28387ea78b74SJan Kiszka    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
28397ea78b74SJan Kiszka        FILES="$FILES pc-bios/`basename $bios_file`"
28407ea78b74SJan Kiszka    done
28417d13299dSbellard    for dir in $DIRS ; do
28427d13299dSbellard            mkdir -p $dir
28437d13299dSbellard    done
2844ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
28457d13299dSbellard    for f in $FILES ; do
2846ec530c81Sbellard        rm -f $f
2847ec530c81Sbellard        ln -s $source_path/$f $f
28487d13299dSbellard    done
28497d13299dSbellardfi
28501ad2134fSPaul Brook
2851c34ebfdcSAnthony Liguori# temporary config to build submodules
28522d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
2853c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
285437116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
2855c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2856c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
2857c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
2858c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
2859c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
2860c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
2861c34ebfdcSAnthony Liguori    echo "HOST_CC=$host_cc" >> $config_mak
2862c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
2863c34ebfdcSAnthony Liguoridone
2864c34ebfdcSAnthony Liguori
28651ad2134fSPaul Brookfor hwlib in 32 64; do
28661ad2134fSPaul Brook  d=libhw$hwlib
28671ad2134fSPaul Brook  mkdir -p $d
28689953b2fcSBlue Swirl  mkdir -p $d/ide
28691ad2134fSPaul Brook  rm -f $d/Makefile
28701ad2134fSPaul Brook  ln -s $source_path/Makefile.hw $d/Makefile
287137116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
28721ad2134fSPaul Brookdone
2873add16157SBlue Swirl
2874add16157SBlue Swirld=libuser
2875add16157SBlue Swirlmkdir -p $d
2876add16157SBlue Swirlrm -f $d/Makefile
2877add16157SBlue Swirlln -s $source_path/Makefile.user $d/Makefile
2878299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
2879299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
2880299060a0SKirill A. Shutemovfi
2881b40292e7SJan Kiszka
2882b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
2883b40292e7SJan Kiszka  mkdir -p QMP
2884b40292e7SJan Kiszkafi
2885