xref: /openbmc/qemu/configure (revision d66ed0eae9c82b657bf7f3ea969490ad72155734)
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"
196*d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
197*d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
198*d66ed0eaSAurelien Jarno    cpu="s390x"
199*d66ed0eaSAurelien Jarno  else
200*d66ed0eaSAurelien Jarno    cpu="s390"
201*d66ed0eaSAurelien 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=""
273d5970055SMichael S. Tsirkinvhost_net=""
274dfb278bdSJuan Quintela
2757d13299dSbellardgprof="no"
276f8393946Saurel32debug_tcg="no"
277b4475aa2SLuiz Capitulinodebug_mon="no"
278f3d08ee6SPaul Brookdebug="no"
2791625af87Saliguoristrip_opt="yes"
2807d13299dSbellardbigendian="no"
28167b915a5Sbellardmingw32="no"
28267b915a5SbellardEXESUF=""
283683035deSPaolo Bonziniprefix="/usr/local"
284683035deSPaolo Bonzinimandir="\${prefix}/share/man"
285683035deSPaolo Bonzinidatadir="\${prefix}/share/qemu"
286683035deSPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
287683035deSPaolo Bonzinibindir="\${prefix}/bin"
288683035deSPaolo Bonzinisysconfdir="\${prefix}/etc"
289683035deSPaolo Bonziniconfsuffix="/qemu"
290443f1376Sbellardslirp="yes"
291102a52e4Sbellardfmod_lib=""
292102a52e4Sbellardfmod_inc=""
2932f6a1ab0Sblueswir1oss_lib=""
294b1a550a0Spbrookbsd="no"
2955327cf48Sbellardlinux="no"
296d2c7c9b8Sblueswir1solaris="no"
29705c2a3e7Sbellardprofiler="no"
2985b0753e0Sbellardcocoa="no"
2990a8e90f4Spbrooksoftmmu="yes"
300831b7825Sthslinux_user="no"
301831b7825Sthsdarwin_user="no"
30284778508Sblueswir1bsd_user="no"
303379f6698SPaul Brookguest_base=""
304c5937220Spbrookuname_release=""
305e5d355d1Saliguoriio_thread="no"
3068ff9cbf7Smalcmixemu="no"
307eac30262Saliguorikerneldir=""
308b29fe3edSmalcaix="no"
30977755340Sthsblobs="yes"
3104a19f1ecSpbrookpkgversion=""
3115495ed11SLuiz Capitulinocheck_utests="no"
31234005a00SKirill A. Shutemovuser_pie="no"
31320ff6c80SAnthony Liguorizero_malloc=""
3147d13299dSbellard
3157d13299dSbellard# OS specific
316ac0df51dSaliguoriif check_define __linux__ ; then
317ac0df51dSaliguori  targetos="Linux"
318ac0df51dSaliguorielif check_define _WIN32 ; then
319ac0df51dSaliguori  targetos='MINGW32'
320169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
321169dc5d3Sblueswir1  targetos='OpenBSD'
322169dc5d3Sblueswir1elif check_define __sun__ ; then
323169dc5d3Sblueswir1  targetos='SunOS'
324ac0df51dSaliguorielse
3257d13299dSbellard  targetos=`uname -s`
326ac0df51dSaliguorifi
3270dbfc675SJuan Quintela
3287d13299dSbellardcase $targetos in
329c326e0afSbellardCYGWIN*)
330c326e0afSbellard  mingw32="yes"
331a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
332d5631638Smalc  audio_possible_drivers="winwave sdl"
333d5631638Smalc  audio_drv_list="winwave"
334c326e0afSbellard;;
33567b915a5SbellardMINGW32*)
33667b915a5Sbellard  mingw32="yes"
337d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
338d5631638Smalc  audio_drv_list="winwave"
33967b915a5Sbellard;;
3405c40d2bdSthsGNU/kFreeBSD)
341a167ba50SAurelien Jarno  bsd="yes"
3420c58ac1cSmalc  audio_drv_list="oss"
343f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3445c40d2bdSths;;
3457d3505c5SbellardFreeBSD)
3467d3505c5Sbellard  bsd="yes"
347a167ba50SAurelien Jarno  make="gmake"
3480c58ac1cSmalc  audio_drv_list="oss"
349f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
350f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
351f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3527d3505c5Sbellard;;
353c5e97233Sblueswir1DragonFly)
354c5e97233Sblueswir1  bsd="yes"
355a167ba50SAurelien Jarno  make="gmake"
356c5e97233Sblueswir1  audio_drv_list="oss"
357c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
358c5e97233Sblueswir1;;
3597d3505c5SbellardNetBSD)
3607d3505c5Sbellard  bsd="yes"
361a167ba50SAurelien Jarno  make="gmake"
3620c58ac1cSmalc  audio_drv_list="oss"
363c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3648ef92a88Sblueswir1  oss_lib="-lossaudio"
3657d3505c5Sbellard;;
3667d3505c5SbellardOpenBSD)
3677d3505c5Sbellard  bsd="yes"
368a167ba50SAurelien Jarno  make="gmake"
3690c58ac1cSmalc  audio_drv_list="oss"
370c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3712f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3727d3505c5Sbellard;;
37383fb7adfSbellardDarwin)
37483fb7adfSbellard  bsd="yes"
37583fb7adfSbellard  darwin="yes"
3760dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3770dbfc675SJuan Quintela  # run 64-bit userspace code
378aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3791b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
380aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3811b0f9cc2Saliguori  fi
3821b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
383a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3840c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3851b0f9cc2Saliguori  else
386a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3871b0f9cc2Saliguori  fi
388831b7825Sths  darwin_user="yes"
389fd677642Sths  cocoa="yes"
3900c58ac1cSmalc  audio_drv_list="coreaudio"
391c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
3920c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
3937973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
39483fb7adfSbellard;;
395ec530c81SbellardSunOS)
396ec530c81Sbellard  solaris="yes"
397c2b84fabSths  make="gmake"
398c2b84fabSths  install="ginstall"
399fa58948dSBlue Swirl  ld="gld"
4000475a5caSths  needs_libsunmath="no"
401c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
402ef18c883Sths  # have to select again, because `uname -m` returns i86pc
403ef18c883Sths  # even on an x86_64 box.
404ef18c883Sths  solariscpu=`isainfo -k`
405ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
406ef18c883Sths    cpu="x86_64"
407ef18c883Sths  fi
408c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4090475a5caSths    if test "$solarisrev" -le 9 ; then
4100475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4110475a5caSths        needs_libsunmath="yes"
412f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
413f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
414f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4150475a5caSths      else
4160475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4170475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4180475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4190475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4200475a5caSths        exit 1
4210475a5caSths      fi
4220475a5caSths    fi
42386b2bd93Sths  fi
4246b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4250c58ac1cSmalc    audio_drv_list="oss"
4266b4d2ba1Sths  fi
427c2de5c91Smalc  audio_possible_drivers="oss sdl"
428d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
429d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
430d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
431d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
432a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
433e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
434ec530c81Sbellard;;
435b29fe3edSmalcAIX)
436b29fe3edSmalc  aix="yes"
437b29fe3edSmalc  make="gmake"
438b29fe3edSmalc;;
439fb065187Sbellard*)
4400c58ac1cSmalc  audio_drv_list="oss"
441b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4425327cf48Sbellard  linux="yes"
443831b7825Sths  linux_user="yes"
44468063649Sblueswir1  usb="linux"
44507f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
446c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
447c9ec1fe4Sbellard  fi
448fb065187Sbellard;;
4497d13299dSbellardesac
4507d13299dSbellard
4517d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
452b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
45368063649Sblueswir1    usb="bsd"
45483fb7adfSbellard  fi
45584778508Sblueswir1  bsd_user="yes"
4567d3505c5Sbellardfi
4577d3505c5Sbellard
4583457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4593457a3f8SJuan Quintela  EXESUF=".exe"
460a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
461e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
462e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
463884044aaSJuan Quintela  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
464683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
465683035deSPaolo Bonzini  mandir="\${prefix}"
466683035deSPaolo Bonzini  datadir="\${prefix}"
467683035deSPaolo Bonzini  docdir="\${prefix}"
468683035deSPaolo Bonzini  bindir="\${prefix}"
469683035deSPaolo Bonzini  sysconfdir="\${prefix}"
470683035deSPaolo Bonzini  confsuffix=""
4713457a3f8SJuan Quintelafi
4723457a3f8SJuan Quintela
4737d13299dSbellard# find source path
474ad064840Spbrooksource_path=`dirname "$0"`
47559faef3aSbalrogsource_path_used="no"
47659faef3aSbalrogworkdir=`pwd`
477ad064840Spbrookif [ -z "$source_path" ]; then
47859faef3aSbalrog    source_path=$workdir
479ad064840Spbrookelse
480ad064840Spbrook    source_path=`cd "$source_path"; pwd`
4817d13299dSbellardfi
482724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
4837d13299dSbellard
484487fefdbSAnthony Liguoriwerror=""
48585aa5189Sbellard
4867d13299dSbellardfor opt do
487a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4887d13299dSbellard  case "$opt" in
4892efc3265Sbellard  --help|-h) show_help=yes
4902efc3265Sbellard  ;;
491b1a550a0Spbrook  --prefix=*) prefix="$optarg"
4927d13299dSbellard  ;;
493b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
49432ce6337Sbellard  ;;
495b1a550a0Spbrook  --source-path=*) source_path="$optarg"
496ad064840Spbrook  source_path_used="yes"
4977d13299dSbellard  ;;
498ac0df51dSaliguori  --cross-prefix=*)
4997d13299dSbellard  ;;
500ac0df51dSaliguori  --cc=*)
5017d13299dSbellard  ;;
502b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
50383469015Sbellard  ;;
504b1a550a0Spbrook  --make=*) make="$optarg"
5057d13299dSbellard  ;;
5066a882643Spbrook  --install=*) install="$optarg"
5076a882643Spbrook  ;;
508e2a2ed06SJuan Quintela  --extra-cflags=*)
5097d13299dSbellard  ;;
510e2a2ed06SJuan Quintela  --extra-ldflags=*)
5117d13299dSbellard  ;;
5122ff6b91eSJuan Quintela  --cpu=*)
5137d13299dSbellard  ;;
514b1a550a0Spbrook  --target-list=*) target_list="$optarg"
515de83cd02Sbellard  ;;
5167d13299dSbellard  --enable-gprof) gprof="yes"
5177d13299dSbellard  ;;
51879427693SLoïc Minier  --static)
51979427693SLoïc Minier    static="yes"
52079427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
52143ce4dfeSbellard  ;;
5220b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5230b24e75fSPaolo Bonzini  ;;
5240b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5250b24e75fSPaolo Bonzini  ;;
5260b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5270b24e75fSPaolo Bonzini  ;;
5280b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5290b24e75fSPaolo Bonzini  ;;
530ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
53107381cc1SAnthony Liguori  ;;
53297a847bcSbellard  --disable-sdl) sdl="no"
53397a847bcSbellard  ;;
534c4198157SJuan Quintela  --enable-sdl) sdl="yes"
535c4198157SJuan Quintela  ;;
536b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
537102a52e4Sbellard  ;;
538c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
539c2de5c91Smalc  ;;
5402f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5412f6a1ab0Sblueswir1  ;;
5422fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5430c58ac1cSmalc  ;;
5440c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5450c58ac1cSmalc  ;;
546eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
547eb852011SMarkus Armbruster  ;;
548f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
549f8393946Saurel32  ;;
550f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
551f8393946Saurel32  ;;
552b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
553b4475aa2SLuiz Capitulino  ;;
554b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
555b4475aa2SLuiz Capitulino  ;;
556f3d08ee6SPaul Brook  --enable-debug)
557f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
558f3d08ee6SPaul Brook      debug_tcg="yes"
559b4475aa2SLuiz Capitulino      debug_mon="yes"
560f3d08ee6SPaul Brook      debug="yes"
561f3d08ee6SPaul Brook      strip_opt="no"
562f3d08ee6SPaul Brook  ;;
56303b4fe7dSaliguori  --enable-sparse) sparse="yes"
56403b4fe7dSaliguori  ;;
56503b4fe7dSaliguori  --disable-sparse) sparse="no"
56603b4fe7dSaliguori  ;;
5671625af87Saliguori  --disable-strip) strip_opt="no"
5681625af87Saliguori  ;;
5698d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5708d5d2d4cSths  ;;
5711be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5721be10ad2SJuan Quintela  ;;
5732f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5742f9606b3Saliguori  ;;
575ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
576ea784e3bSJuan Quintela  ;;
577443f1376Sbellard  --disable-slirp) slirp="no"
578c20709aaSbellard  ;;
579ee682d27SStefan Weil  --disable-uuid) uuid="no"
580ee682d27SStefan Weil  ;;
581ee682d27SStefan Weil  --enable-uuid) uuid="yes"
582ee682d27SStefan Weil  ;;
583e0e6c8c0Saliguori  --disable-vde) vde="no"
5848a16d273Sths  ;;
585dfb278bdSJuan Quintela  --enable-vde) vde="yes"
586dfb278bdSJuan Quintela  ;;
587e37630caSaliguori  --disable-xen) xen="no"
588e37630caSaliguori  ;;
589fc321b4bSJuan Quintela  --enable-xen) xen="yes"
590fc321b4bSJuan Quintela  ;;
5912e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
5922e4d9fb1Saurel32  ;;
5934ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
5944ffcedb6SJuan Quintela  ;;
595fb599c9aSbalrog  --disable-bluez) bluez="no"
596fb599c9aSbalrog  ;;
597a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
598a20a6f46SJuan Quintela  ;;
5997ba1e619Saliguori  --disable-kvm) kvm="no"
6007ba1e619Saliguori  ;;
601b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
602b31a0277SJuan Quintela  ;;
60305c2a3e7Sbellard  --enable-profiler) profiler="yes"
60405c2a3e7Sbellard  ;;
605c2de5c91Smalc  --enable-cocoa)
606c2de5c91Smalc      cocoa="yes" ;
607c2de5c91Smalc      sdl="no" ;
608c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6095b0753e0Sbellard  ;;
610cad25d69Spbrook  --disable-system) softmmu="no"
6110a8e90f4Spbrook  ;;
612cad25d69Spbrook  --enable-system) softmmu="yes"
6130a8e90f4Spbrook  ;;
6140953a80fSZachary Amsden  --disable-user)
6150953a80fSZachary Amsden      linux_user="no" ;
6160953a80fSZachary Amsden      bsd_user="no" ;
6170953a80fSZachary Amsden      darwin_user="no"
6180953a80fSZachary Amsden  ;;
6190953a80fSZachary Amsden  --enable-user) ;;
620831b7825Sths  --disable-linux-user) linux_user="no"
6210a8e90f4Spbrook  ;;
622831b7825Sths  --enable-linux-user) linux_user="yes"
623831b7825Sths  ;;
624831b7825Sths  --disable-darwin-user) darwin_user="no"
625831b7825Sths  ;;
626831b7825Sths  --enable-darwin-user) darwin_user="yes"
6270a8e90f4Spbrook  ;;
62884778508Sblueswir1  --disable-bsd-user) bsd_user="no"
62984778508Sblueswir1  ;;
63084778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
63184778508Sblueswir1  ;;
632379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
633379f6698SPaul Brook  ;;
634379f6698SPaul Brook  --disable-guest-base) guest_base="no"
635379f6698SPaul Brook  ;;
63634005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
63734005a00SKirill A. Shutemov  ;;
63834005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
63934005a00SKirill A. Shutemov  ;;
640c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
641c5937220Spbrook  ;;
6423142255cSblueswir1  --sparc_cpu=*)
6433142255cSblueswir1  ;;
64485aa5189Sbellard  --enable-werror) werror="yes"
64585aa5189Sbellard  ;;
64685aa5189Sbellard  --disable-werror) werror="no"
64785aa5189Sbellard  ;;
6484d3b6f6eSbalrog  --disable-curses) curses="no"
6494d3b6f6eSbalrog  ;;
650c584a6d0SJuan Quintela  --enable-curses) curses="yes"
651c584a6d0SJuan Quintela  ;;
652769ce76dSAlexander Graf  --disable-curl) curl="no"
653769ce76dSAlexander Graf  ;;
654788c8196SJuan Quintela  --enable-curl) curl="yes"
655788c8196SJuan Quintela  ;;
6562df87df7SJuan Quintela  --disable-fdt) fdt="no"
6572df87df7SJuan Quintela  ;;
6582df87df7SJuan Quintela  --enable-fdt) fdt="yes"
6592df87df7SJuan Quintela  ;;
6605495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
6615495ed11SLuiz Capitulino  ;;
6625495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
6635495ed11SLuiz Capitulino  ;;
664bd0c5661Spbrook  --disable-nptl) nptl="no"
665bd0c5661Spbrook  ;;
666b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
667b0a47e79SJuan Quintela  ;;
6688ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
6698ff9cbf7Smalc  ;;
6705c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
6715c6c3a6cSChristoph Hellwig  ;;
6725c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
6735c6c3a6cSChristoph Hellwig  ;;
674e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
675e5d355d1Saliguori  ;;
67677755340Sths  --disable-blobs) blobs="no"
67777755340Sths  ;;
678eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
679eac30262Saliguori  ;;
6804a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
6814a19f1ecSpbrook  ;;
682a25dba17SJuan Quintela  --disable-docs) docs="no"
68370ec5dc0SAnthony Liguori  ;;
684a25dba17SJuan Quintela  --enable-docs) docs="yes"
68583a3ab8bSJuan Quintela  ;;
686d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
687d5970055SMichael S. Tsirkin  ;;
688d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
689d5970055SMichael S. Tsirkin  ;;
6906bde81cbSPaolo Bonzini  --*dir)
6916bde81cbSPaolo Bonzini  ;;
6927f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
6937f1559c6Sbalrog  ;;
6947d13299dSbellard  esac
6957d13299dSbellarddone
6967d13299dSbellard
6973142255cSblueswir1#
6983142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
699a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7003142255cSblueswir1#
701379f6698SPaul Brookhost_guest_base="no"
70240293e58Sbellardcase "$cpu" in
703ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
704ed968ff1SJuan Quintela           v7|v8)
705a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
706ed968ff1SJuan Quintela           ;;
707ed968ff1SJuan Quintela           v8plus|v8plusa)
708a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
709ed968ff1SJuan Quintela           ;;
710ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
711a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
712ed968ff1SJuan Quintela           esac
7130c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
714a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
715762e8230Sblueswir1           if test "$solaris" = "no" ; then
716a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
717c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
718762e8230Sblueswir1           fi
7193142255cSblueswir1           ;;
720ed968ff1SJuan Quintela    sparc64)
721a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7220c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
723a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
724ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
725a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
726762e8230Sblueswir1           fi
7273142255cSblueswir1           ;;
72876d83bdeSths    s390)
72928d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
73028d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
73128d7cc49SRichard Henderson           ;;
73228d7cc49SRichard Henderson    s390x)
73328d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
73428d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
73576d83bdeSths           ;;
73640293e58Sbellard    i386)
737a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7380c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
739c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
740379f6698SPaul Brook           host_guest_base="yes"
74140293e58Sbellard           ;;
74240293e58Sbellard    x86_64)
743a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
7440c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
745379f6698SPaul Brook           host_guest_base="yes"
746379f6698SPaul Brook           ;;
747379f6698SPaul Brook    arm*)
748379f6698SPaul Brook           host_guest_base="yes"
74940293e58Sbellard           ;;
750f6548c0aSmalc    ppc*)
751f6548c0aSmalc           host_guest_base="yes"
752f6548c0aSmalc           ;;
753cc01cc8eSAurelien Jarno    mips*)
754cc01cc8eSAurelien Jarno           host_guest_base="yes"
755cc01cc8eSAurelien Jarno           ;;
756477ba620SAurelien Jarno    ia64*)
757477ba620SAurelien Jarno           host_guest_base="yes"
758477ba620SAurelien Jarno           ;;
759fd76e73aSRichard Henderson    hppa*)
760fd76e73aSRichard Henderson           host_guest_base="yes"
761fd76e73aSRichard Henderson           ;;
7623142255cSblueswir1esac
7633142255cSblueswir1
764379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
765379f6698SPaul Brook
766af5db58eSpbrookif test x"$show_help" = x"yes" ; then
767af5db58eSpbrookcat << EOF
768af5db58eSpbrook
769af5db58eSpbrookUsage: configure [options]
770af5db58eSpbrookOptions: [defaults in brackets after descriptions]
771af5db58eSpbrook
772af5db58eSpbrookEOF
773af5db58eSpbrookecho "Standard options:"
774af5db58eSpbrookecho "  --help                   print this message"
775af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
776af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
777af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
778af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
779af5db58eSpbrookecho ""
780af5db58eSpbrookecho "Advanced options (experts only):"
781af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
782af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
783af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
7840bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
7850bfe8cc0SPaolo Bonziniecho "                           build time"
786a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
787e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
788af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
7896a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
790af5db58eSpbrookecho "  --static                 enable static build [$static]"
7910b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
7920b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
7930b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
7940b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
7950b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
796f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
797f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
79809695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
799890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
800890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
8011625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
80285aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
803fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
804c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
805af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
806c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
807c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
8084c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
8094c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
810eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
811eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
8128ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
813e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
814fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
8152e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
8164ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
8178d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
8181be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
8192f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
820ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
821af896aaaSpbrookecho "  --disable-curses         disable curses output"
822c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
823769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
824788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
8252df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
8262df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
8275495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
8285495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
829fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
830a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
8317ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
832b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
833bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
834e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
835af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
836af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
8370953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
8380953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
839831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
840831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
841831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
842831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
84384778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
84484778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
845379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
846379f6698SPaul Brookecho "                           emulation targets"
847379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
84834005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
84934005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
850af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
851af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
8522f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
853c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
8543142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
855ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
856ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
857e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
858dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
8595c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
8605c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
861e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
86277755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
863eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
864d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
865d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
866d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
867d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
868af5db58eSpbrookecho ""
8695bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
870af5db58eSpbrookexit 1
871af5db58eSpbrookfi
872af5db58eSpbrook
873ec530c81Sbellard#
874ec530c81Sbellard# Solaris specific configure tool chain decisions
875ec530c81Sbellard#
876ec530c81Sbellardif test "$solaris" = "yes" ; then
8776792aa11SLoïc Minier  if has $install; then
8786792aa11SLoïc Minier    :
8796792aa11SLoïc Minier  else
880ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
881ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
882ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
883ec530c81Sbellard    exit 1
884ec530c81Sbellard  fi
8856792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
886ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
887ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
888ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
889ec530c81Sbellard    exit 1
890ec530c81Sbellard  fi
8916792aa11SLoïc Minier  if has ar; then
8926792aa11SLoïc Minier    :
8936792aa11SLoïc Minier  else
894ec530c81Sbellard    echo "Error: No path includes ar"
895ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
896ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
897ec530c81Sbellard    fi
898ec530c81Sbellard    exit 1
899ec530c81Sbellard  fi
900ec530c81Sbellardfi
901ec530c81Sbellard
902ec530c81Sbellard
9035327cf48Sbellardif test -z "$target_list" ; then
9045327cf48Sbellard# these targets are portable
9050a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
9062408a527Saurel32        target_list="\
9072408a527Saurel32i386-softmmu \
9082408a527Saurel32x86_64-softmmu \
9092408a527Saurel32arm-softmmu \
9102408a527Saurel32cris-softmmu \
9112408a527Saurel32m68k-softmmu \
91272b675caSEdgar E. Iglesiasmicroblaze-softmmu \
9132408a527Saurel32mips-softmmu \
9142408a527Saurel32mipsel-softmmu \
9152408a527Saurel32mips64-softmmu \
9162408a527Saurel32mips64el-softmmu \
9172408a527Saurel32ppc-softmmu \
9182408a527Saurel32ppcemb-softmmu \
9192408a527Saurel32ppc64-softmmu \
9202408a527Saurel32sh4-softmmu \
9212408a527Saurel32sh4eb-softmmu \
9222408a527Saurel32sparc-softmmu \
9231b64fcaeSIgor V. Kovalenkosparc64-softmmu \
9242408a527Saurel32"
9250a8e90f4Spbrook    fi
9265327cf48Sbellard# the following are Linux specific
927831b7825Sths    if [ "$linux_user" = "yes" ] ; then
9282408a527Saurel32        target_list="${target_list}\
9292408a527Saurel32i386-linux-user \
9302408a527Saurel32x86_64-linux-user \
9312408a527Saurel32alpha-linux-user \
9322408a527Saurel32arm-linux-user \
9332408a527Saurel32armeb-linux-user \
9342408a527Saurel32cris-linux-user \
9352408a527Saurel32m68k-linux-user \
93672b675caSEdgar E. Iglesiasmicroblaze-linux-user \
9372408a527Saurel32mips-linux-user \
9382408a527Saurel32mipsel-linux-user \
9392408a527Saurel32ppc-linux-user \
9402408a527Saurel32ppc64-linux-user \
9412408a527Saurel32ppc64abi32-linux-user \
9422408a527Saurel32sh4-linux-user \
9432408a527Saurel32sh4eb-linux-user \
9442408a527Saurel32sparc-linux-user \
9452408a527Saurel32sparc64-linux-user \
9462408a527Saurel32sparc32plus-linux-user \
9472408a527Saurel32"
948831b7825Sths    fi
949831b7825Sths# the following are Darwin specific
950831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
9512408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
9525327cf48Sbellard    fi
95384778508Sblueswir1# the following are BSD specific
95484778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
95584778508Sblueswir1        target_list="${target_list}\
95631fc12dfSblueswir1i386-bsd-user \
95731fc12dfSblueswir1x86_64-bsd-user \
95831fc12dfSblueswir1sparc-bsd-user \
95984778508Sblueswir1sparc64-bsd-user \
96084778508Sblueswir1"
96184778508Sblueswir1    fi
9626e20a45fSbellardelse
963b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
9645327cf48Sbellardfi
9650a8e90f4Spbrookif test -z "$target_list" ; then
9660a8e90f4Spbrook    echo "No targets enabled"
9670a8e90f4Spbrook    exit 1
9680a8e90f4Spbrookfi
969f55fe278SPaolo Bonzini# see if system emulation was really requested
970f55fe278SPaolo Bonzinicase " $target_list " in
971f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
972f55fe278SPaolo Bonzini  ;;
973f55fe278SPaolo Bonzini  *) softmmu=no
974f55fe278SPaolo Bonzini  ;;
975f55fe278SPaolo Bonziniesac
9765327cf48Sbellard
977249247c9SJuan Quintelafeature_not_found() {
978249247c9SJuan Quintela  feature=$1
979249247c9SJuan Quintela
980249247c9SJuan Quintela  echo "ERROR"
981249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
9829332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
983249247c9SJuan Quintela  echo "ERROR"
984249247c9SJuan Quintela  exit 1;
985249247c9SJuan Quintela}
986249247c9SJuan Quintela
9877d13299dSbellardif test -z "$cross_prefix" ; then
9887d13299dSbellard
9897d13299dSbellard# ---
9907d13299dSbellard# big/little endian test
9917d13299dSbellardcat > $TMPC << EOF
9927d13299dSbellard#include <inttypes.h>
9937d13299dSbellardint main(int argc, char ** argv){
9947d13299dSbellard        volatile uint32_t i=0x01234567;
9957d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
9967d13299dSbellard}
9977d13299dSbellardEOF
9987d13299dSbellard
99952166aa0SJuan Quintelaif compile_prog "" "" ; then
10007d13299dSbellard$TMPE && bigendian="yes"
10017d13299dSbellardelse
10027d13299dSbellardecho big/little test failed
10037d13299dSbellardfi
10047d13299dSbellard
10057d13299dSbellardelse
10067d13299dSbellard
10077d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1008ea8f20f8SJuan Quintelacase "$cpu" in
100924e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1010ea8f20f8SJuan Quintela    bigendian=yes
1011ea8f20f8SJuan Quintela  ;;
1012ea8f20f8SJuan Quintelaesac
10137d13299dSbellard
10147d13299dSbellardfi
10157d13299dSbellard
1016b6853697Sbellard# host long bits test
1017b6853697Sbellardhostlongbits="32"
1018ea8f20f8SJuan Quintelacase "$cpu" in
101924e804ecSAlexander Graf  x86_64|alpha|ia64|sparc64|ppc64|s390x)
1020ea8f20f8SJuan Quintela    hostlongbits=64
1021ea8f20f8SJuan Quintela  ;;
1022ea8f20f8SJuan Quintelaesac
1023b6853697Sbellard
1024b0a47e79SJuan Quintela
1025b0a47e79SJuan Quintela##########################################
1026b0a47e79SJuan Quintela# NPTL probe
1027b0a47e79SJuan Quintela
1028b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1029bd0c5661Spbrook  cat > $TMPC <<EOF
1030bd0c5661Spbrook#include <sched.h>
103130813ceaSpbrook#include <linux/futex.h>
1032bd0c5661Spbrookvoid foo()
1033bd0c5661Spbrook{
1034bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1035bd0c5661Spbrook#error bork
1036bd0c5661Spbrook#endif
1037bd0c5661Spbrook}
1038bd0c5661SpbrookEOF
1039bd0c5661Spbrook
104052166aa0SJuan Quintela  if compile_object ; then
1041b0a47e79SJuan Quintela    nptl=yes
1042bd0c5661Spbrook  else
1043b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1044b0a47e79SJuan Quintela      feature_not_found "nptl"
1045b0a47e79SJuan Quintela    fi
1046b0a47e79SJuan Quintela    nptl=no
1047b0a47e79SJuan Quintela  fi
1048bd0c5661Spbrookfi
1049bd0c5661Spbrook
105011d9f695Sbellard##########################################
1051ac62922eSbalrog# zlib check
1052ac62922eSbalrog
1053ac62922eSbalrogcat > $TMPC << EOF
1054ac62922eSbalrog#include <zlib.h>
1055ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1056ac62922eSbalrogEOF
105752166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1058ac62922eSbalrog    :
1059ac62922eSbalrogelse
1060ac62922eSbalrog    echo
1061ac62922eSbalrog    echo "Error: zlib check failed"
1062ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1063ac62922eSbalrog    echo
1064ac62922eSbalrog    exit 1
1065ac62922eSbalrogfi
1066ac62922eSbalrog
1067ac62922eSbalrog##########################################
1068e37630caSaliguori# xen probe
1069e37630caSaliguori
1070fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1071b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1072e37630caSaliguori  cat > $TMPC <<EOF
1073e37630caSaliguori#include <xenctrl.h>
1074e37630caSaliguori#include <xs.h>
1075df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1076e37630caSaliguoriEOF
107752166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1078fc321b4bSJuan Quintela    xen=yes
10793efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
1080e37630caSaliguori  else
1081fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1082fc321b4bSJuan Quintela      feature_not_found "xen"
1083fc321b4bSJuan Quintela    fi
1084fc321b4bSJuan Quintela    xen=no
1085e37630caSaliguori  fi
1086e37630caSaliguorifi
1087e37630caSaliguori
1088e37630caSaliguori##########################################
1089f91672e5SPaolo Bonzini# pkgconfig probe
1090f91672e5SPaolo Bonzini
1091f91672e5SPaolo Bonzinipkgconfig="${cross_prefix}pkg-config"
10920dba6195SLoïc Minierif ! has $pkgconfig; then
1093f91672e5SPaolo Bonzini  # likely not cross compiling, or hope for the best
1094f91672e5SPaolo Bonzini  pkgconfig=pkg-config
1095f91672e5SPaolo Bonzinifi
1096f91672e5SPaolo Bonzini
1097f91672e5SPaolo Bonzini##########################################
1098dfffc653SJuan Quintela# Sparse probe
1099dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
11000dba6195SLoïc Minier  if has cgcc; then
1101dfffc653SJuan Quintela    sparse=yes
1102dfffc653SJuan Quintela  else
1103dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1104dfffc653SJuan Quintela      feature_not_found "sparse"
1105dfffc653SJuan Quintela    fi
1106dfffc653SJuan Quintela    sparse=no
1107dfffc653SJuan Quintela  fi
1108dfffc653SJuan Quintelafi
1109dfffc653SJuan Quintela
1110dfffc653SJuan Quintela##########################################
111111d9f695Sbellard# SDL probe
111211d9f695Sbellard
1113fec0e3e8SStefan Weil# Look for sdl configuration program (pkg-config or sdl-config).
1114fec0e3e8SStefan Weil# Prefer variant with cross prefix if cross compiling,
1115fec0e3e8SStefan Weil# and favour pkg-config with sdl over sdl-config.
1116fec0e3e8SStefan Weilif test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
1117fec0e3e8SStefan Weil     $pkgconfig sdl --modversion >/dev/null 2>&1; then
1118fec0e3e8SStefan Weil  sdlconfig="$pkgconfig sdl"
1119fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1120fec0e3e8SStefan Weilelif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
1121fec0e3e8SStefan Weil  sdlconfig="${cross_prefix}sdl-config"
1122fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1123fec0e3e8SStefan Weilelif $pkgconfig sdl --modversion >/dev/null 2>&1; then
11249316f803SPaolo Bonzini  sdlconfig="$pkgconfig sdl"
11259316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
11260dba6195SLoïc Minierelif has sdl-config; then
11279316f803SPaolo Bonzini  sdlconfig='sdl-config'
11289316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1129a0dfd8a4SLoïc Minierelse
1130a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1131a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1132a0dfd8a4SLoïc Minier  fi
1133a0dfd8a4SLoïc Minier  sdl=no
11349316f803SPaolo Bonzinifi
113511d9f695Sbellard
11369316f803SPaolo Bonzinisdl_too_old=no
1137c4198157SJuan Quintelaif test "$sdl" != "no" ; then
113811d9f695Sbellard  cat > $TMPC << EOF
113911d9f695Sbellard#include <SDL.h>
114011d9f695Sbellard#undef main /* We don't want SDL to override our main() */
114111d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
114211d9f695SbellardEOF
11439316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
114474f42e18STeLeMan  if test "$static" = "yes" ; then
114574f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
114674f42e18STeLeMan  else
11479316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
114874f42e18STeLeMan  fi
114952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
115011d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
115111d9f695Sbellard      sdl_too_old=yes
115211d9f695Sbellard    else
1153fd677642Sths      if test "$cocoa" = "no" ; then
115411d9f695Sbellard        sdl=yes
115511d9f695Sbellard      fi
1156fd677642Sths    fi
11577c1f25b4Sbellard
115867c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
11591ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
116067c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1161f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1162f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
116311d9f695Sbellard      fi
116452166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
11651ac88f28SJuan Quintela	:
11661ac88f28SJuan Quintela      else
11671ac88f28SJuan Quintela        sdl=no
11687c1f25b4Sbellard      fi
11697c1f25b4Sbellard    fi # static link
1170c4198157SJuan Quintela  else # sdl not found
1171c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1172c4198157SJuan Quintela      feature_not_found "sdl"
1173c4198157SJuan Quintela    fi
1174c4198157SJuan Quintela    sdl=no
11757c1f25b4Sbellard  fi # sdl compile test
1176fd677642Sthsfi
117711d9f695Sbellard
11785368a422Saliguoriif test "$sdl" = "yes" ; then
11795368a422Saliguori  cat > $TMPC <<EOF
11805368a422Saliguori#include <SDL.h>
11815368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
11825368a422Saliguori#include <X11/XKBlib.h>
11835368a422Saliguori#else
11845368a422Saliguori#error No x11 support
11855368a422Saliguori#endif
11865368a422Saliguoriint main(void) { return 0; }
11875368a422SaliguoriEOF
118852166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1189681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
11905368a422Saliguori  fi
119107d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
119207d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
119307d9ac44SJuan Quintela  fi
11940705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
11955368a422Saliguorifi
11965368a422Saliguori
11978f28f3fbSths##########################################
11988d5d2d4cSths# VNC TLS detection
11991be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1200ae6b5e5aSaliguori  cat > $TMPC <<EOF
1201ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1202ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1203ae6b5e5aSaliguoriEOF
1204f91672e5SPaolo Bonzini  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1205f91672e5SPaolo Bonzini  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
120652166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
12071be10ad2SJuan Quintela    vnc_tls=yes
1208a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1209ae6b5e5aSaliguori  else
12101be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
12111be10ad2SJuan Quintela      feature_not_found "vnc-tls"
12121be10ad2SJuan Quintela    fi
12131be10ad2SJuan Quintela    vnc_tls=no
12148d5d2d4cSths  fi
12158d5d2d4cSthsfi
12168d5d2d4cSths
12178d5d2d4cSths##########################################
12182f9606b3Saliguori# VNC SASL detection
12193aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
12202f9606b3Saliguori  cat > $TMPC <<EOF
12212f9606b3Saliguori#include <sasl/sasl.h>
12222f9606b3Saliguori#include <stdio.h>
12232f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
12242f9606b3SaliguoriEOF
12252f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
12262f9606b3Saliguori  vnc_sasl_cflags=""
12272f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
122852166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1229ea784e3bSJuan Quintela    vnc_sasl=yes
1230fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
12312f9606b3Saliguori  else
1232ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1233ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1234ea784e3bSJuan Quintela    fi
1235ea784e3bSJuan Quintela    vnc_sasl=no
12362f9606b3Saliguori  fi
12372f9606b3Saliguorifi
12382f9606b3Saliguori
12392f9606b3Saliguori##########################################
124076655d6dSaliguori# fnmatch() probe, used for ACL routines
124176655d6dSaliguorifnmatch="no"
124276655d6dSaliguoricat > $TMPC << EOF
124376655d6dSaliguori#include <fnmatch.h>
124476655d6dSaliguoriint main(void)
124576655d6dSaliguori{
124676655d6dSaliguori    fnmatch("foo", "foo", 0);
124776655d6dSaliguori    return 0;
124876655d6dSaliguori}
124976655d6dSaliguoriEOF
125052166aa0SJuan Quintelaif compile_prog "" "" ; then
125176655d6dSaliguori   fnmatch="yes"
125276655d6dSaliguorifi
125376655d6dSaliguori
125476655d6dSaliguori##########################################
1255ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1256ee682d27SStefan Weilif test "$uuid" != "no" ; then
1257ee682d27SStefan Weil  uuid_libs="-luuid"
1258ee682d27SStefan Weil  cat > $TMPC << EOF
1259ee682d27SStefan Weil#include <uuid/uuid.h>
1260ee682d27SStefan Weilint main(void)
1261ee682d27SStefan Weil{
1262ee682d27SStefan Weil    uuid_t my_uuid;
1263ee682d27SStefan Weil    uuid_generate(my_uuid);
1264ee682d27SStefan Weil    return 0;
1265ee682d27SStefan Weil}
1266ee682d27SStefan WeilEOF
1267ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1268ee682d27SStefan Weil    uuid="yes"
1269ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1270ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1271ee682d27SStefan Weil  else
1272ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1273ee682d27SStefan Weil      feature_not_found "uuid"
1274ee682d27SStefan Weil    fi
1275ee682d27SStefan Weil    uuid=no
1276ee682d27SStefan Weil  fi
1277ee682d27SStefan Weilfi
1278ee682d27SStefan Weil
1279ee682d27SStefan Weil##########################################
12808a16d273Sths# vde libraries probe
1281dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
12824baae0acSJuan Quintela  vde_libs="-lvdeplug"
12838a16d273Sths  cat > $TMPC << EOF
12848a16d273Sths#include <libvdeplug.h>
12854a7f0e06Spbrookint main(void)
12864a7f0e06Spbrook{
12874a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
12884a7f0e06Spbrook    vde_open("", "", &a);
12894a7f0e06Spbrook    return 0;
12904a7f0e06Spbrook}
12918a16d273SthsEOF
129252166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
12934baae0acSJuan Quintela    vde=yes
12948e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
12958e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1296dfb278bdSJuan Quintela  else
1297dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1298dfb278bdSJuan Quintela      feature_not_found "vde"
1299dfb278bdSJuan Quintela    fi
1300dfb278bdSJuan Quintela    vde=no
13018a16d273Sths  fi
13028a16d273Sthsfi
13038a16d273Sths
13048a16d273Sths##########################################
1305c2de5c91Smalc# Sound support libraries probe
13068f28f3fbSths
1307c2de5c91Smalcaudio_drv_probe()
1308c2de5c91Smalc{
1309c2de5c91Smalc    drv=$1
1310c2de5c91Smalc    hdr=$2
1311c2de5c91Smalc    lib=$3
1312c2de5c91Smalc    exp=$4
1313c2de5c91Smalc    cfl=$5
13148f28f3fbSths        cat > $TMPC << EOF
1315c2de5c91Smalc#include <$hdr>
1316c2de5c91Smalcint main(void) { $exp }
13178f28f3fbSthsEOF
131852166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
13198f28f3fbSths        :
13208f28f3fbSths    else
13218f28f3fbSths        echo
1322c2de5c91Smalc        echo "Error: $drv check failed"
1323c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
13248f28f3fbSths        echo
13258f28f3fbSths        exit 1
13268f28f3fbSths    fi
1327c2de5c91Smalc}
1328c2de5c91Smalc
13292fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1330c2de5c91Smalcfor drv in $audio_drv_list; do
1331c2de5c91Smalc    case $drv in
1332c2de5c91Smalc    alsa)
1333c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1334c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1335a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1336c2de5c91Smalc    ;;
1337c2de5c91Smalc
1338c2de5c91Smalc    fmod)
1339c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1340c2de5c91Smalc        echo
1341c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1342c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1343c2de5c91Smalc        echo
1344c2de5c91Smalc        exit 1
13458f28f3fbSths    fi
1346c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1347a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1348c2de5c91Smalc    ;;
1349c2de5c91Smalc
1350c2de5c91Smalc    esd)
1351c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1352a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
135367f86e8eSJuan Quintela    audio_pt_int="yes"
1354c2de5c91Smalc    ;;
1355b8e59f18Smalc
1356b8e59f18Smalc    pa)
1357493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1358b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1359493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
136067f86e8eSJuan Quintela    audio_pt_int="yes"
1361b8e59f18Smalc    ;;
1362b8e59f18Smalc
1363997e690aSJuan Quintela    coreaudio)
1364997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1365997e690aSJuan Quintela    ;;
1366997e690aSJuan Quintela
1367a4bf6780SJuan Quintela    dsound)
1368a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1369d5631638Smalc      audio_win_int="yes"
1370a4bf6780SJuan Quintela    ;;
1371a4bf6780SJuan Quintela
1372a4bf6780SJuan Quintela    oss)
1373a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1374a4bf6780SJuan Quintela    ;;
1375a4bf6780SJuan Quintela
1376a4bf6780SJuan Quintela    sdl|wav)
13772f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
13782f6a1ab0Sblueswir1    ;;
13792f6a1ab0Sblueswir1
1380d5631638Smalc    winwave)
1381d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1382d5631638Smalc      audio_win_int="yes"
1383d5631638Smalc    ;;
1384d5631638Smalc
1385e4c63a6aSmalc    *)
13861c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1387e4c63a6aSmalc        echo
1388e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1389e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1390e4c63a6aSmalc        echo
1391e4c63a6aSmalc        exit 1
1392e4c63a6aSmalc    }
1393e4c63a6aSmalc    ;;
1394c2de5c91Smalc    esac
1395c2de5c91Smalcdone
13968f28f3fbSths
13974d3b6f6eSbalrog##########################################
13982e4d9fb1Saurel32# BrlAPI probe
13992e4d9fb1Saurel32
14004ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1401eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
14022e4d9fb1Saurel32  cat > $TMPC << EOF
14032e4d9fb1Saurel32#include <brlapi.h>
14042e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
14052e4d9fb1Saurel32EOF
140652166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
14072e4d9fb1Saurel32    brlapi=yes
1408264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
14094ffcedb6SJuan Quintela  else
14104ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
14114ffcedb6SJuan Quintela      feature_not_found "brlapi"
14124ffcedb6SJuan Quintela    fi
14134ffcedb6SJuan Quintela    brlapi=no
1414eb82284fSJuan Quintela  fi
1415eb82284fSJuan Quintelafi
14162e4d9fb1Saurel32
14172e4d9fb1Saurel32##########################################
14184d3b6f6eSbalrog# curses probe
14194f78ef9aSJuan Quintelacurses_list="-lncurses -lcurses"
14204d3b6f6eSbalrog
1421c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1422c584a6d0SJuan Quintela  curses_found=no
14234d3b6f6eSbalrog  cat > $TMPC << EOF
14244d3b6f6eSbalrog#include <curses.h>
14255a8ff3aaSblueswir1#ifdef __OpenBSD__
14265a8ff3aaSblueswir1#define resize_term resizeterm
14275a8ff3aaSblueswir1#endif
14285a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
14294d3b6f6eSbalrogEOF
14304f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
14314f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1432c584a6d0SJuan Quintela      curses_found=yes
14334f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
14344f78ef9aSJuan Quintela      break
14354d3b6f6eSbalrog    fi
14364f78ef9aSJuan Quintela  done
1437c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1438c584a6d0SJuan Quintela    curses=yes
1439c584a6d0SJuan Quintela  else
1440c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1441c584a6d0SJuan Quintela      feature_not_found "curses"
1442c584a6d0SJuan Quintela    fi
1443c584a6d0SJuan Quintela    curses=no
1444c584a6d0SJuan Quintela  fi
14454f78ef9aSJuan Quintelafi
14464d3b6f6eSbalrog
1447414f0dabSblueswir1##########################################
1448769ce76dSAlexander Graf# curl probe
1449769ce76dSAlexander Graf
14504e2b0658SPaolo Bonziniif $pkgconfig libcurl --modversion >/dev/null 2>&1; then
14514e2b0658SPaolo Bonzini  curlconfig="$pkgconfig libcurl"
14524e2b0658SPaolo Bonzinielse
14534e2b0658SPaolo Bonzini  curlconfig=curl-config
14544e2b0658SPaolo Bonzinifi
14554e2b0658SPaolo Bonzini
1456788c8196SJuan Quintelaif test "$curl" != "no" ; then
1457769ce76dSAlexander Graf  cat > $TMPC << EOF
1458769ce76dSAlexander Graf#include <curl/curl.h>
1459769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1460769ce76dSAlexander GrafEOF
14614e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
14624e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1463b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1464769ce76dSAlexander Graf    curl=yes
1465f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1466f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1467788c8196SJuan Quintela  else
1468788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1469788c8196SJuan Quintela      feature_not_found "curl"
1470788c8196SJuan Quintela    fi
1471788c8196SJuan Quintela    curl=no
1472769ce76dSAlexander Graf  fi
1473769ce76dSAlexander Graffi # test "$curl"
1474769ce76dSAlexander Graf
1475769ce76dSAlexander Graf##########################################
14765495ed11SLuiz Capitulino# check framework probe
14775495ed11SLuiz Capitulino
14785495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
14795495ed11SLuiz Capitulino  cat > $TMPC << EOF
14805495ed11SLuiz Capitulino#include <check.h>
14815495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
14825495ed11SLuiz CapitulinoEOF
1483f91672e5SPaolo Bonzini  check_libs=`$pkgconfig --libs check`
14845495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
14855495ed11SLuiz Capitulino    check_utests=yes
14865495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
14875495ed11SLuiz Capitulino  else
14885495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
14895495ed11SLuiz Capitulino      feature_not_found "check"
14905495ed11SLuiz Capitulino    fi
14915495ed11SLuiz Capitulino    check_utests=no
14925495ed11SLuiz Capitulino  fi
14935495ed11SLuiz Capitulinofi # test "$check_utests"
14945495ed11SLuiz Capitulino
14955495ed11SLuiz Capitulino##########################################
1496fb599c9aSbalrog# bluez support probe
1497a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1498e820e3f4Sbalrog  cat > $TMPC << EOF
1499e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1500e820e3f4Sbalrogint main(void) { return bt_error(0); }
1501e820e3f4SbalrogEOF
1502f91672e5SPaolo Bonzini  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1503f91672e5SPaolo Bonzini  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
150452166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1505a20a6f46SJuan Quintela    bluez=yes
1506e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1507e820e3f4Sbalrog  else
1508a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1509a20a6f46SJuan Quintela      feature_not_found "bluez"
1510a20a6f46SJuan Quintela    fi
1511e820e3f4Sbalrog    bluez="no"
1512e820e3f4Sbalrog  fi
1513fb599c9aSbalrogfi
1514fb599c9aSbalrog
1515fb599c9aSbalrog##########################################
15167ba1e619Saliguori# kvm probe
1517b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
15187ba1e619Saliguori    cat > $TMPC <<EOF
15197ba1e619Saliguori#include <linux/kvm.h>
15209fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
15217ba1e619Saliguori#error Invalid KVM version
15227ba1e619Saliguori#endif
15239fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
15249fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
15259fd8d8d7Saliguori#endif
15269fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
15279fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
15289fd8d8d7Saliguori#endif
15299fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
15309fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
15319fd8d8d7Saliguori#endif
15327ba1e619Saliguoriint main(void) { return 0; }
15337ba1e619SaliguoriEOF
1534eac30262Saliguori  if test "$kerneldir" != "" ; then
1535eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
15368444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
15378444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
15388444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1539406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1540406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
15410e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
15420e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
15438444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
15448444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
15458444eb6eSaliguori      fi
1546eac30262Saliguori  else
1547f038e8f7SStefan Weil    kvm_cflags=`$pkgconfig --cflags kvm-kmod 2>/dev/null`
1548eac30262Saliguori  fi
154952166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1550b31a0277SJuan Quintela    kvm=yes
1551dae5079aSJan Kiszka    cat > $TMPC <<EOF
1552dae5079aSJan Kiszka#include <linux/kvm_para.h>
1553dae5079aSJan Kiszkaint main(void) { return 0; }
1554dae5079aSJan KiszkaEOF
1555dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1556dae5079aSJan Kiszka      kvm_para=yes
1557dae5079aSJan Kiszka    fi
15587ba1e619Saliguori  else
1559b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
15600dba6195SLoïc Minier      if has awk && has grep; then
1561a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
15629fd8d8d7Saliguori	| grep "error: " \
15639fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
15649fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1565b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1566168ccc11SJan Kiszka      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1567168ccc11SJan Kiszka  recent kvm-kmod from http://sourceforge.net/projects/kvm."
15689fd8d8d7Saliguori        fi
15699fd8d8d7Saliguori      fi
1570b31a0277SJuan Quintela      feature_not_found "kvm"
1571b31a0277SJuan Quintela    fi
1572b31a0277SJuan Quintela    kvm=no
15737ba1e619Saliguori  fi
15747ba1e619Saliguorifi
15757ba1e619Saliguori
15767ba1e619Saliguori##########################################
1577d5970055SMichael S. Tsirkin# test for vhost net
1578d5970055SMichael S. Tsirkin
1579d5970055SMichael S. Tsirkinif test "$vhost_net" != "no"; then
1580d5970055SMichael S. Tsirkin    if test "$kvm" != "no"; then
1581d5970055SMichael S. Tsirkin            cat > $TMPC <<EOF
1582d5970055SMichael S. Tsirkin    #include <linux/vhost.h>
1583d5970055SMichael S. Tsirkin    int main(void) { return 0; }
1584d5970055SMichael S. TsirkinEOF
1585d5970055SMichael S. Tsirkin            if compile_prog "$kvm_cflags" "" ; then
1586d5970055SMichael S. Tsirkin                vhost_net=yes
1587d5970055SMichael S. Tsirkin            else
1588d5970055SMichael S. Tsirkin                if test "$vhost_net" = "yes" ; then
1589d5970055SMichael S. Tsirkin                    feature_not_found "vhost-net"
1590d5970055SMichael S. Tsirkin                fi
1591d5970055SMichael S. Tsirkin                vhost_net=no
1592d5970055SMichael S. Tsirkin            fi
1593d5970055SMichael S. Tsirkin    else
1594d5970055SMichael S. Tsirkin            if test "$vhost_net" = "yes" ; then
15954021d247SAurelien Jarno                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1596d5970055SMichael S. Tsirkin                feature_not_found "vhost-net"
1597d5970055SMichael S. Tsirkin            fi
1598d5970055SMichael S. Tsirkin            vhost_net=no
1599d5970055SMichael S. Tsirkin    fi
1600d5970055SMichael S. Tsirkinfi
1601d5970055SMichael S. Tsirkin
1602d5970055SMichael S. Tsirkin##########################################
1603e5d355d1Saliguori# pthread probe
1604de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
16053c529d93Saliguori
1606e5d355d1Saliguoripthread=no
1607414f0dabSblueswir1cat > $TMPC << EOF
16083c529d93Saliguori#include <pthread.h>
1609de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1610414f0dabSblueswir1EOF
1611de65fe0fSSebastian Herbsztfor pthread_lib in $PTHREADLIBS_LIST; do
161252166aa0SJuan Quintela  if compile_prog "" "$pthread_lib" ; then
1613e5d355d1Saliguori    pthread=yes
16145572b539SJuan Quintela    LIBS="$pthread_lib $LIBS"
1615de65fe0fSSebastian Herbszt    break
1616414f0dabSblueswir1  fi
1617de65fe0fSSebastian Herbsztdone
1618414f0dabSblueswir1
16194617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
16204dd75c70SChristoph Hellwig  echo
16214dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
16224dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
16234dd75c70SChristoph Hellwig  echo
16244dd75c70SChristoph Hellwig  exit 1
1625e5d355d1Saliguorifi
1626e5d355d1Saliguori
1627bf9298b9Saliguori##########################################
16285c6c3a6cSChristoph Hellwig# linux-aio probe
16295c6c3a6cSChristoph Hellwig
16305c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
16315c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
16325c6c3a6cSChristoph Hellwig#include <libaio.h>
16335c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
16345c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
16355c6c3a6cSChristoph HellwigEOF
16365c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
16375c6c3a6cSChristoph Hellwig    linux_aio=yes
1638048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1639048d179fSPaul Brook    libs_tools="$libs_tools -laio"
16405c6c3a6cSChristoph Hellwig  else
16415c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
16425c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
16435c6c3a6cSChristoph Hellwig    fi
16443cfcae3cSLuiz Capitulino    linux_aio=no
16455c6c3a6cSChristoph Hellwig  fi
16465c6c3a6cSChristoph Hellwigfi
16475c6c3a6cSChristoph Hellwig
16485c6c3a6cSChristoph Hellwig##########################################
1649bf9298b9Saliguori# iovec probe
1650bf9298b9Saliguoricat > $TMPC <<EOF
1651db34f0b3Sblueswir1#include <sys/types.h>
1652bf9298b9Saliguori#include <sys/uio.h>
1653db34f0b3Sblueswir1#include <unistd.h>
1654bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1655bf9298b9SaliguoriEOF
1656bf9298b9Saliguoriiovec=no
165752166aa0SJuan Quintelaif compile_prog "" "" ; then
1658bf9298b9Saliguori  iovec=yes
1659bf9298b9Saliguorifi
1660bf9298b9Saliguori
1661f652e6afSaurel32##########################################
1662ceb42de8Saliguori# preadv probe
1663ceb42de8Saliguoricat > $TMPC <<EOF
1664ceb42de8Saliguori#include <sys/types.h>
1665ceb42de8Saliguori#include <sys/uio.h>
1666ceb42de8Saliguori#include <unistd.h>
1667ceb42de8Saliguoriint main(void) { preadv; }
1668ceb42de8SaliguoriEOF
1669ceb42de8Saliguoripreadv=no
167052166aa0SJuan Quintelaif compile_prog "" "" ; then
1671ceb42de8Saliguori  preadv=yes
1672ceb42de8Saliguorifi
1673ceb42de8Saliguori
1674ceb42de8Saliguori##########################################
1675f652e6afSaurel32# fdt probe
16762df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1677b41af4baSJuan Quintela  fdt_libs="-lfdt"
1678f652e6afSaurel32  cat > $TMPC << EOF
1679f652e6afSaurel32int main(void) { return 0; }
1680f652e6afSaurel32EOF
168152166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1682f652e6afSaurel32    fdt=yes
1683e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
16842df87df7SJuan Quintela  else
16852df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
16862df87df7SJuan Quintela      feature_not_found "fdt"
16872df87df7SJuan Quintela    fi
16882df87df7SJuan Quintela    fdt=no
1689f652e6afSaurel32  fi
1690f652e6afSaurel32fi
1691f652e6afSaurel32
16923b3f24adSaurel32#
16933b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
16943b3f24adSaurel32# emulator.  This is done because older glibc versions don't
16953b3f24adSaurel32# have syscall stubs for these implemented.
16963b3f24adSaurel32#
16973b3f24adSaurel32atfile=no
16983b3f24adSaurel32cat > $TMPC << EOF
16993b3f24adSaurel32#define _ATFILE_SOURCE
17003b3f24adSaurel32#include <sys/types.h>
17013b3f24adSaurel32#include <fcntl.h>
17023b3f24adSaurel32#include <unistd.h>
17033b3f24adSaurel32
17043b3f24adSaurel32int
17053b3f24adSaurel32main(void)
17063b3f24adSaurel32{
17073b3f24adSaurel32	/* try to unlink nonexisting file */
17083b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
17093b3f24adSaurel32}
17103b3f24adSaurel32EOF
171152166aa0SJuan Quintelaif compile_prog "" "" ; then
17123b3f24adSaurel32  atfile=yes
17133b3f24adSaurel32fi
17143b3f24adSaurel32
171539386ac7Saurel32# Check for inotify functions when we are building linux-user
17163b3f24adSaurel32# emulator.  This is done because older glibc versions don't
17173b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
17183b3f24adSaurel32# don't provide them even if kernel supports them.
17193b3f24adSaurel32#
17203b3f24adSaurel32inotify=no
17213b3f24adSaurel32cat > $TMPC << EOF
17223b3f24adSaurel32#include <sys/inotify.h>
17233b3f24adSaurel32
17243b3f24adSaurel32int
17253b3f24adSaurel32main(void)
17263b3f24adSaurel32{
17273b3f24adSaurel32	/* try to start inotify */
17288690e420Saurel32	return inotify_init();
17293b3f24adSaurel32}
17303b3f24adSaurel32EOF
173152166aa0SJuan Quintelaif compile_prog "" "" ; then
17323b3f24adSaurel32  inotify=yes
17333b3f24adSaurel32fi
17343b3f24adSaurel32
1735c05c7a73SRiku Voipioinotify1=no
1736c05c7a73SRiku Voipiocat > $TMPC << EOF
1737c05c7a73SRiku Voipio#include <sys/inotify.h>
1738c05c7a73SRiku Voipio
1739c05c7a73SRiku Voipioint
1740c05c7a73SRiku Voipiomain(void)
1741c05c7a73SRiku Voipio{
1742c05c7a73SRiku Voipio    /* try to start inotify */
1743c05c7a73SRiku Voipio    return inotify_init1(0);
1744c05c7a73SRiku Voipio}
1745c05c7a73SRiku VoipioEOF
1746c05c7a73SRiku Voipioif compile_prog "" "" ; then
1747c05c7a73SRiku Voipio  inotify1=yes
1748c05c7a73SRiku Voipiofi
1749c05c7a73SRiku Voipio
1750ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1751ebc996f3SRiku Voipioutimens=no
1752ebc996f3SRiku Voipiocat > $TMPC << EOF
1753ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1754ebc996f3SRiku Voipio#define _GNU_SOURCE
1755ebc996f3SRiku Voipio#include <stddef.h>
1756ebc996f3SRiku Voipio#include <fcntl.h>
1757ebc996f3SRiku Voipio
1758ebc996f3SRiku Voipioint main(void)
1759ebc996f3SRiku Voipio{
1760ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1761ebc996f3SRiku Voipio    futimens(0, NULL);
1762ebc996f3SRiku Voipio    return 0;
1763ebc996f3SRiku Voipio}
1764ebc996f3SRiku VoipioEOF
176552166aa0SJuan Quintelaif compile_prog "" "" ; then
1766ebc996f3SRiku Voipio  utimens=yes
1767ebc996f3SRiku Voipiofi
1768ebc996f3SRiku Voipio
1769099d6b0fSRiku Voipio# check if pipe2 is there
1770099d6b0fSRiku Voipiopipe2=no
1771099d6b0fSRiku Voipiocat > $TMPC << EOF
1772099d6b0fSRiku Voipio#define _GNU_SOURCE
1773099d6b0fSRiku Voipio#include <unistd.h>
1774099d6b0fSRiku Voipio#include <fcntl.h>
1775099d6b0fSRiku Voipio
1776099d6b0fSRiku Voipioint main(void)
1777099d6b0fSRiku Voipio{
1778099d6b0fSRiku Voipio    int pipefd[2];
1779099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1780099d6b0fSRiku Voipio    return 0;
1781099d6b0fSRiku Voipio}
1782099d6b0fSRiku VoipioEOF
178352166aa0SJuan Quintelaif compile_prog "" "" ; then
1784099d6b0fSRiku Voipio  pipe2=yes
1785099d6b0fSRiku Voipiofi
1786099d6b0fSRiku Voipio
178740ff6d7eSKevin Wolf# check if accept4 is there
178840ff6d7eSKevin Wolfaccept4=no
178940ff6d7eSKevin Wolfcat > $TMPC << EOF
179040ff6d7eSKevin Wolf#define _GNU_SOURCE
179140ff6d7eSKevin Wolf#include <sys/socket.h>
179240ff6d7eSKevin Wolf#include <stddef.h>
179340ff6d7eSKevin Wolf
179440ff6d7eSKevin Wolfint main(void)
179540ff6d7eSKevin Wolf{
179640ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
179740ff6d7eSKevin Wolf    return 0;
179840ff6d7eSKevin Wolf}
179940ff6d7eSKevin WolfEOF
180040ff6d7eSKevin Wolfif compile_prog "" "" ; then
180140ff6d7eSKevin Wolf  accept4=yes
180240ff6d7eSKevin Wolffi
180340ff6d7eSKevin Wolf
18043ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
18053ce34dfbSvibisreenivasansplice=no
18063ce34dfbSvibisreenivasancat > $TMPC << EOF
18073ce34dfbSvibisreenivasan#define _GNU_SOURCE
18083ce34dfbSvibisreenivasan#include <unistd.h>
18093ce34dfbSvibisreenivasan#include <fcntl.h>
18103ce34dfbSvibisreenivasan#include <limits.h>
18113ce34dfbSvibisreenivasan
18123ce34dfbSvibisreenivasanint main(void)
18133ce34dfbSvibisreenivasan{
18143ce34dfbSvibisreenivasan    int len, fd;
18153ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
18163ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
18173ce34dfbSvibisreenivasan    return 0;
18183ce34dfbSvibisreenivasan}
18193ce34dfbSvibisreenivasanEOF
182052166aa0SJuan Quintelaif compile_prog "" "" ; then
18213ce34dfbSvibisreenivasan  splice=yes
18223ce34dfbSvibisreenivasanfi
18233ce34dfbSvibisreenivasan
1824c2882b96SRiku Voipio# check if eventfd is supported
1825c2882b96SRiku Voipioeventfd=no
1826c2882b96SRiku Voipiocat > $TMPC << EOF
1827c2882b96SRiku Voipio#include <sys/eventfd.h>
1828c2882b96SRiku Voipio
1829c2882b96SRiku Voipioint main(void)
1830c2882b96SRiku Voipio{
1831c2882b96SRiku Voipio    int efd = eventfd(0, 0);
1832c2882b96SRiku Voipio    return 0;
1833c2882b96SRiku Voipio}
1834c2882b96SRiku VoipioEOF
1835c2882b96SRiku Voipioif compile_prog "" "" ; then
1836c2882b96SRiku Voipio  eventfd=yes
1837c2882b96SRiku Voipiofi
1838c2882b96SRiku Voipio
1839d0927938SUlrich Hecht# check for fallocate
1840d0927938SUlrich Hechtfallocate=no
1841d0927938SUlrich Hechtcat > $TMPC << EOF
1842d0927938SUlrich Hecht#include <fcntl.h>
1843d0927938SUlrich Hecht
1844d0927938SUlrich Hechtint main(void)
1845d0927938SUlrich Hecht{
1846d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
1847d0927938SUlrich Hecht    return 0;
1848d0927938SUlrich Hecht}
1849d0927938SUlrich HechtEOF
1850be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
1851d0927938SUlrich Hecht  fallocate=yes
1852d0927938SUlrich Hechtfi
1853d0927938SUlrich Hecht
1854d0927938SUlrich Hecht# check for dup3
1855d0927938SUlrich Hechtdup3=no
1856d0927938SUlrich Hechtcat > $TMPC << EOF
1857d0927938SUlrich Hecht#include <unistd.h>
1858d0927938SUlrich Hecht
1859d0927938SUlrich Hechtint main(void)
1860d0927938SUlrich Hecht{
1861d0927938SUlrich Hecht    dup3(0, 0, 0);
1862d0927938SUlrich Hecht    return 0;
1863d0927938SUlrich Hecht}
1864d0927938SUlrich HechtEOF
186578f5d726SJan Kiszkaif compile_prog "" "" ; then
1866d0927938SUlrich Hecht  dup3=yes
1867d0927938SUlrich Hechtfi
1868d0927938SUlrich Hecht
1869cc8ae6deSpbrook# Check if tools are available to build documentation.
1870a25dba17SJuan Quintelaif test "$docs" != "no" ; then
187101668d98SStefan Weil  if has makeinfo && has pod2man; then
1872a25dba17SJuan Quintela    docs=yes
187383a3ab8bSJuan Quintela  else
1874a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
1875a25dba17SJuan Quintela      feature_not_found "docs"
187683a3ab8bSJuan Quintela    fi
1877a25dba17SJuan Quintela    docs=no
187883a3ab8bSJuan Quintela  fi
1879cc8ae6deSpbrookfi
1880cc8ae6deSpbrook
1881f514f41cSStefan Weil# Search for bswap_32 function
18826ae9a1f4SJuan Quintelabyteswap_h=no
18836ae9a1f4SJuan Quintelacat > $TMPC << EOF
18846ae9a1f4SJuan Quintela#include <byteswap.h>
18856ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
18866ae9a1f4SJuan QuintelaEOF
188752166aa0SJuan Quintelaif compile_prog "" "" ; then
18886ae9a1f4SJuan Quintela  byteswap_h=yes
18896ae9a1f4SJuan Quintelafi
18906ae9a1f4SJuan Quintela
1891f514f41cSStefan Weil# Search for bswap_32 function
18926ae9a1f4SJuan Quintelabswap_h=no
18936ae9a1f4SJuan Quintelacat > $TMPC << EOF
18946ae9a1f4SJuan Quintela#include <sys/endian.h>
18956ae9a1f4SJuan Quintela#include <sys/types.h>
18966ae9a1f4SJuan Quintela#include <machine/bswap.h>
18976ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
18986ae9a1f4SJuan QuintelaEOF
189952166aa0SJuan Quintelaif compile_prog "" "" ; then
19006ae9a1f4SJuan Quintela  bswap_h=yes
19016ae9a1f4SJuan Quintelafi
19026ae9a1f4SJuan Quintela
1903da93a1fdSaliguori##########################################
1904da93a1fdSaliguori# Do we need librt
1905da93a1fdSaliguoricat > $TMPC <<EOF
1906da93a1fdSaliguori#include <signal.h>
1907da93a1fdSaliguori#include <time.h>
1908da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
1909da93a1fdSaliguoriEOF
1910da93a1fdSaliguori
191152166aa0SJuan Quintelaif compile_prog "" "" ; then
191207ffa4bdSJuan Quintela  :
191352166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
191407ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
1915da93a1fdSaliguorifi
1916da93a1fdSaliguori
191731ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
19186362a53fSJuan Quintela        "$aix" != "yes" ; then
19196362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
19206362a53fSJuan Quintelafi
19216362a53fSJuan Quintela
1922de5071c5SBlue Swirl##########################################
1923de5071c5SBlue Swirl# check if the compiler defines offsetof
1924de5071c5SBlue Swirl
1925de5071c5SBlue Swirlneed_offsetof=yes
1926de5071c5SBlue Swirlcat > $TMPC << EOF
1927de5071c5SBlue Swirl#include <stddef.h>
1928de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
1929de5071c5SBlue SwirlEOF
1930de5071c5SBlue Swirlif compile_prog "" "" ; then
1931de5071c5SBlue Swirl    need_offsetof=no
1932de5071c5SBlue Swirlfi
1933de5071c5SBlue Swirl
19345f6b9e8fSBlue Swirl##########################################
1935747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
1936747bbdf7SBlue Swirl#
1937747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
1938747bbdf7SBlue Swirl# about attribute warn_unused_result
1939747bbdf7SBlue Swirl
1940747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
1941747bbdf7SBlue Swirlcat > $TMPC << EOF
1942747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
1943747bbdf7SBlue Swirl#error gcc 3.3 or older
1944747bbdf7SBlue Swirl#endif
1945747bbdf7SBlue Swirlint main(void) { return 0;}
1946747bbdf7SBlue SwirlEOF
1947747bbdf7SBlue Swirlif compile_prog "" ""; then
1948747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
1949747bbdf7SBlue Swirlfi
1950747bbdf7SBlue Swirl
1951747bbdf7SBlue Swirl##########################################
19525f6b9e8fSBlue Swirl# check if we have fdatasync
19535f6b9e8fSBlue Swirl
19545f6b9e8fSBlue Swirlfdatasync=no
19555f6b9e8fSBlue Swirlcat > $TMPC << EOF
19565f6b9e8fSBlue Swirl#include <unistd.h>
19575f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
19585f6b9e8fSBlue SwirlEOF
19595f6b9e8fSBlue Swirlif compile_prog "" "" ; then
19605f6b9e8fSBlue Swirl    fdatasync=yes
19615f6b9e8fSBlue Swirlfi
19625f6b9e8fSBlue Swirl
1963e86ecd4bSJuan Quintela# End of CC checks
1964e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
1965e86ecd4bSJuan Quintela
1966e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
19671156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
1968e86ecd4bSJuan Quintelafi
1969a316e378SJuan Quintela
1970e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
1971e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
1972e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
197320ff6c80SAnthony Liguori
197420ff6c80SAnthony Liguoriif test -z "$werror" ; then
1975e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
1976e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
1977e86ecd4bSJuan Quintela        werror="yes"
1978e86ecd4bSJuan Quintela    else
1979e86ecd4bSJuan Quintela        werror="no"
1980e86ecd4bSJuan Quintela    fi
1981e86ecd4bSJuan Quintelafi
1982e86ecd4bSJuan Quintela
198320ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
198420ff6c80SAnthony Liguori# enable/disable
198520ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
198620ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
198720ff6c80SAnthony Liguori	zero_malloc="no"
198820ff6c80SAnthony Liguori    else
198920ff6c80SAnthony Liguori	zero_malloc="yes"
199020ff6c80SAnthony Liguori    fi
199120ff6c80SAnthony Liguorifi
199220ff6c80SAnthony Liguori
1993e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
1994a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
1995e86ecd4bSJuan Quintelafi
1996e86ecd4bSJuan Quintela
1997e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
1998e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
19991156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2000e86ecd4bSJuan Quintela    fi
2001e86ecd4bSJuan Quintelafi
2002e86ecd4bSJuan Quintela
2003190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
20045a67135aSbellard
2005ca35f780SPaolo Bonzinitools=
2006ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2007ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2008ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2009ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2010ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2011ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2012ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2013ca35f780SPaolo Bonzini    fi
2014ca35f780SPaolo Bonzini  fi
2015ca35f780SPaolo Bonzinifi
2016ca35f780SPaolo Bonzini
2017ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2018ca35f780SPaolo Bonziniroms=
2019ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2020ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2021ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2022ca35f780SPaolo Bonzini  roms="optionrom"
2023ca35f780SPaolo Bonzinifi
2024ca35f780SPaolo Bonzini
2025ca35f780SPaolo Bonzini
20267d13299dSbellardecho "Install prefix    $prefix"
2027f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2028f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
20291c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
203011d9f695Sbellardif test "$mingw32" = "no" ; then
2031f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
203243ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
203311d9f695Sbellardfi
20345a67135aSbellardecho "Source path       $source_path"
20357d13299dSbellardecho "C compiler        $cc"
203683469015Sbellardecho "Host C compiler   $host_cc"
20370c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2038a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
20390c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
20407d13299dSbellardecho "make              $make"
20416a882643Spbrookecho "install           $install"
2042a98fd896Sbellardecho "host CPU          $cpu"
2043de83cd02Sbellardecho "host big endian   $bigendian"
204497a847bcSbellardecho "target list       $target_list"
2045ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2046b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
20477d13299dSbellardecho "gprof enabled     $gprof"
204803b4fe7dSaliguoriecho "sparse enabled    $sparse"
20491625af87Saliguoriecho "strip binaries    $strip_opt"
205005c2a3e7Sbellardecho "profiler          $profiler"
205143ce4dfeSbellardecho "static build      $static"
205285aa5189Sbellardecho "-Werror enabled   $werror"
20535b0753e0Sbellardif test "$darwin" = "yes" ; then
20545b0753e0Sbellard    echo "Cocoa support     $cocoa"
20555b0753e0Sbellardfi
205697a847bcSbellardecho "SDL support       $sdl"
20574d3b6f6eSbalrogecho "curses support    $curses"
2058769ce76dSAlexander Grafecho "curl support      $curl"
20595495ed11SLuiz Capitulinoecho "check support     $check_utests"
206067b915a5Sbellardecho "mingw32 support   $mingw32"
20610c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
20620c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2063eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
20648ff9cbf7Smalcecho "Mixer emulation   $mixemu"
20658d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
20662f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
20673142255cSblueswir1if test -n "$sparc_cpu"; then
20683142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
20693142255cSblueswir1fi
2070e37630caSaliguoriecho "xen support       $xen"
20712e4d9fb1Saurel32echo "brlapi support    $brlapi"
2072a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2073a25dba17SJuan Quintelaecho "Documentation     $docs"
2074c5937220Spbrook[ ! -z "$uname_release" ] && \
2075c5937220Spbrookecho "uname -r          $uname_release"
2076bd0c5661Spbrookecho "NPTL support      $nptl"
2077379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
207834005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
20798a16d273Sthsecho "vde support       $vde"
2080e5d355d1Saliguoriecho "IO thread         $io_thread"
20815c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
208277755340Sthsecho "Install blobs     $blobs"
2083b31a0277SJuan Quintelaecho "KVM support       $kvm"
2084f652e6afSaurel32echo "fdt support       $fdt"
2085ceb42de8Saliguoriecho "preadv support    $preadv"
20865f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2087ee682d27SStefan Weilecho "uuid support      $uuid"
2088d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
208967b915a5Sbellard
209097a847bcSbellardif test $sdl_too_old = "yes"; then
209124b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2092e8cd23deSbellardfi
209397a847bcSbellard
209498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
20954bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
209697a847bcSbellard
209798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
209898ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
209998ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
210098ec69acSJuan Quintelaecho >> $config_host_mak
210198ec69acSJuan Quintela
210299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
210399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
210499d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
210599d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
210699d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
210799d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
21081dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2109804edf29SJuan Quintela
21102408a527Saurel32case "$cpu" in
211124e804ecSAlexander Graf  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2112e0da9dd3SJuan Quintela    ARCH=$cpu
21132408a527Saurel32  ;;
2114a302c32dSLaurent Desnogues  armv4b|armv4l)
211516dbd14fSJuan Quintela    ARCH=arm
21162408a527Saurel32  ;;
21172408a527Saurel32esac
211898ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2119f8393946Saurel32if test "$debug_tcg" = "yes" ; then
21202358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2121f8393946Saurel32fi
2122b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2123b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2124b4475aa2SLuiz Capitulinofi
2125f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
21262358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2127f3d08ee6SPaul Brookfi
21281625af87Saliguoriif test "$strip_opt" = "yes" ; then
212998ec69acSJuan Quintela  echo "STRIP_OPT=-s" >> $config_host_mak
21301625af87Saliguorifi
21317d13299dSbellardif test "$bigendian" = "yes" ; then
2132e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
213397a847bcSbellardfi
21342358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
213567b915a5Sbellardif test "$mingw32" = "yes" ; then
213698ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
2137210fa556Spbrookelse
213835f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2139210fa556Spbrookfi
2140128ab2ffSblueswir1
2141dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2142dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2143dffcb71cSMark McLoughlinfi
2144dffcb71cSMark McLoughlin
214583fb7adfSbellardif test "$darwin" = "yes" ; then
214698ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
214783fb7adfSbellardfi
2148b29fe3edSmalc
2149b29fe3edSmalcif test "$aix" = "yes" ; then
215098ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2151b29fe3edSmalcfi
2152b29fe3edSmalc
2153ec530c81Sbellardif test "$solaris" = "yes" ; then
215498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
21552358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
21560475a5caSths  if test "$needs_libsunmath" = "yes" ; then
215775b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
21580475a5caSths  fi
2159ec530c81Sbellardfi
216097a847bcSbellardif test "$static" = "yes" ; then
216198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
216297a847bcSbellardfi
216305c2a3e7Sbellardif test $profiler = "yes" ; then
21642358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
216505c2a3e7Sbellardfi
2166c20709aaSbellardif test "$slirp" = "yes" ; then
216798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2168b6e31c12SJuan Quintela  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
2169c20709aaSbellardfi
21708a16d273Sthsif test "$vde" = "yes" ; then
217198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
21728a16d273Sthsfi
21730c58ac1cSmalcfor card in $audio_card_list; do
2174f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
217598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
21760c58ac1cSmalcdone
21772358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
21780c58ac1cSmalcfor drv in $audio_drv_list; do
2179f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
218098ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2181923e4521Smalc    if test "$drv" = "fmod"; then
21827aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2183fb065187Sbellard    fi
21840c58ac1cSmalcdone
218567f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
218667f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
218767f86e8eSJuan Quintelafi
2188d5631638Smalcif test "$audio_win_int" = "yes" ; then
2189d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2190d5631638Smalcfi
2191eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
21928ff9cbf7Smalcif test "$mixemu" = "yes" ; then
219398ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
21948ff9cbf7Smalcfi
21958d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
219698ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2197525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
21988d5d2d4cSthsfi
21992f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
220098ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
220160ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
22022f9606b3Saliguorifi
220376655d6dSaliguoriif test "$fnmatch" = "yes" ; then
22042358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
220576655d6dSaliguorifi
2206ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2207ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2208ee682d27SStefan Weilfi
2209b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
221098ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
22112358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
221298ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
221398ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2214a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
221598ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2216cc8ae6deSpbrookfi
22171ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
221898ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
22198ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
222049ecc3faSbellardfi
222149ecc3faSbellardif test "$cocoa" = "yes" ; then
222298ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
222349ecc3faSbellardfi
22244d3b6f6eSbalrogif test "$curses" = "yes" ; then
222598ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2226ab4e5602SJan Kiszkafi
22273b3f24adSaurel32if test "$atfile" = "yes" ; then
22282358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
22293b3f24adSaurel32fi
2230ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
22312358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2232ebc996f3SRiku Voipiofi
2233099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
22342358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2235099d6b0fSRiku Voipiofi
223640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
223740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
223840ff6d7eSKevin Wolffi
22393ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
22402358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
22413ce34dfbSvibisreenivasanfi
2242c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2243c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2244c2882b96SRiku Voipiofi
2245d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2246d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2247d0927938SUlrich Hechtfi
2248d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2249d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2250d0927938SUlrich Hechtfi
22513b3f24adSaurel32if test "$inotify" = "yes" ; then
22522358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
22533b3f24adSaurel32fi
2254c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2255c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2256c05c7a73SRiku Voipiofi
22576ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
22586ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
22596ae9a1f4SJuan Quintelafi
22606ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
22616ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
22626ae9a1f4SJuan Quintelafi
2263769ce76dSAlexander Grafif test "$curl" = "yes" ; then
226498ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2265b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2266769ce76dSAlexander Graffi
22672e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
226898ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
22692e4d9fb1Saurel32fi
2270fb599c9aSbalrogif test "$bluez" = "yes" ; then
227198ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2272ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2273fb599c9aSbalrogfi
2274e37630caSaliguoriif test "$xen" = "yes" ; then
22755647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2276e37630caSaliguorifi
2277e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
227898ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2279e5d355d1Saliguorifi
22805c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
22815c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
22825c6c3a6cSChristoph Hellwigfi
228377755340Sthsif test "$blobs" = "yes" ; then
228498ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
228577755340Sthsfi
2286bf9298b9Saliguoriif test "$iovec" = "yes" ; then
22872358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2288bf9298b9Saliguorifi
2289ceb42de8Saliguoriif test "$preadv" = "yes" ; then
22902358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2291ceb42de8Saliguorifi
2292f652e6afSaurel32if test "$fdt" = "yes" ; then
22933f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2294f652e6afSaurel32fi
2295de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2296de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2297de5071c5SBlue Swirlfi
2298747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2299747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2300747bbdf7SBlue Swirlfi
23015f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
23025f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
23035f6b9e8fSBlue Swirlfi
230497a847bcSbellard
230583fb7adfSbellard# XXX: suppress that
23067d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
23072358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
23087d3505c5Sbellardfi
23097d3505c5Sbellard
23102358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2311c5937220Spbrook
231220ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
231320ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
231420ff6c80SAnthony Liguorifi
231520ff6c80SAnthony Liguori
231668063649Sblueswir1# USB host support
231768063649Sblueswir1case "$usb" in
231868063649Sblueswir1linux)
231998ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
232068063649Sblueswir1;;
232168063649Sblueswir1bsd)
232298ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
232368063649Sblueswir1;;
232468063649Sblueswir1*)
232598ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
232668063649Sblueswir1;;
232768063649Sblueswir1esac
232868063649Sblueswir1
232998ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
233098ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2331804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2332804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2333804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2334804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2335804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2336804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
2337804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2338804edf29SJuan Quintelaif test "$sparse" = "yes" ; then
2339804edf29SJuan Quintela  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2340804edf29SJuan Quintela  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2341a558ee17SJuan Quintela  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2342804edf29SJuan Quintelafi
2343804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2344804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2345804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
2346e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2347a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2348c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2349e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2350a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2351a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
235273da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
23533e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2354804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2355804edf29SJuan Quintela
23564bf6b55bSJuan Quintela# generate list of library paths for linker script
23574bf6b55bSJuan Quintela
23584bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
23594bf6b55bSJuan Quintela
23604bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
23614bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
23624bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
23634bf6b55bSJuan Quintela  else
23644bf6b55bSJuan Quintela    rm ${config_host_ld}~
23654bf6b55bSJuan Quintela  fi
23664bf6b55bSJuan Quintelafi
23674bf6b55bSJuan Quintela
23684d904533SBlue Swirlfor d in libdis libdis-user; do
23694d904533SBlue Swirl    mkdir -p $d
23704d904533SBlue Swirl    rm -f $d/Makefile
23714d904533SBlue Swirl    ln -s $source_path/Makefile.dis $d/Makefile
23724d904533SBlue Swirl    echo > $d/config.mak
23734d904533SBlue Swirldone
2374d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
2375d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2376d44cff22SRichard Hendersonfi
23774d904533SBlue Swirl
237897a847bcSbellardfor target in $target_list; do
237997a847bcSbellardtarget_dir="$target"
238025be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2381600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
238297a847bcSbellardtarget_bigendian="no"
23831f3d3c8fSJuan Quintela
2384ea2d6a39SJuan Quintelacase "$target_arch2" in
238524e804ecSAlexander Graf  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2386ea2d6a39SJuan Quintela  target_bigendian=yes
2387ea2d6a39SJuan Quintela  ;;
2388ea2d6a39SJuan Quintelaesac
238997a847bcSbellardtarget_softmmu="no"
2390997344f3Sbellardtarget_user_only="no"
2391831b7825Sthstarget_linux_user="no"
2392831b7825Sthstarget_darwin_user="no"
239384778508Sblueswir1target_bsd_user="no"
23949e407a85Spbrookcase "$target" in
2395600309b6SBlue Swirl  ${target_arch2}-softmmu)
23969e407a85Spbrook    target_softmmu="yes"
23979e407a85Spbrook    ;;
2398600309b6SBlue Swirl  ${target_arch2}-linux-user)
23999c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
24009c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
24019c7a4202SBlue Swirl      exit 1
24029c7a4202SBlue Swirl    fi
24039e407a85Spbrook    target_user_only="yes"
24049e407a85Spbrook    target_linux_user="yes"
24059e407a85Spbrook    ;;
2406600309b6SBlue Swirl  ${target_arch2}-darwin-user)
24079c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
24089c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
24099c7a4202SBlue Swirl      exit 1
24109c7a4202SBlue Swirl    fi
24119e407a85Spbrook    target_user_only="yes"
2412831b7825Sths    target_darwin_user="yes"
24139e407a85Spbrook    ;;
2414600309b6SBlue Swirl  ${target_arch2}-bsd-user)
24159cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
24169c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
24179c7a4202SBlue Swirl      exit 1
24189c7a4202SBlue Swirl    fi
241984778508Sblueswir1    target_user_only="yes"
242084778508Sblueswir1    target_bsd_user="yes"
242184778508Sblueswir1    ;;
24229e407a85Spbrook  *)
24239e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
24249e407a85Spbrook    exit 1
24259e407a85Spbrook    ;;
24269e407a85Spbrookesac
2427831b7825Sths
242897a847bcSbellardmkdir -p $target_dir
2429158142c2Sbellardmkdir -p $target_dir/fpu
243057fec1feSbellardmkdir -p $target_dir/tcg
243159f2a787SGerd Hoffmannmkdir -p $target_dir/ide
243284778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
243369de927cSbellard  mkdir -p $target_dir/nwfpe
243469de927cSbellardfi
243569de927cSbellard
2436ec530c81Sbellard#
2437ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
2438ec530c81Sbellard#
2439ec530c81Sbellardrm -f $target_dir/Makefile
2440ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
2441ec530c81Sbellard
244297a847bcSbellard
244325be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
244497a847bcSbellard
2445e5fe0c52Spbrookbflt="no"
2446bd0c5661Spbrooktarget_nptl="no"
2447600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
24487ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
244956aebc89Spbrookgdb_xml_files=""
24507ba1e619Saliguori
2451938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
24526acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2453e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2454e73aae67SJuan Quintela
2455600309b6SBlue Swirlcase "$target_arch2" in
24562408a527Saurel32  i386)
24571ad2134fSPaul Brook    target_phys_bits=32
24582408a527Saurel32  ;;
24592408a527Saurel32  x86_64)
24606acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
24611ad2134fSPaul Brook    target_phys_bits=64
24622408a527Saurel32  ;;
24632408a527Saurel32  alpha)
24641ad2134fSPaul Brook    target_phys_bits=64
2465a4b388ffSRichard Henderson    target_nptl="yes"
24662408a527Saurel32  ;;
24672408a527Saurel32  arm|armeb)
2468b498c8a0SJuan Quintela    TARGET_ARCH=arm
2469e5fe0c52Spbrook    bflt="yes"
2470bd0c5661Spbrook    target_nptl="yes"
247156aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
24721ad2134fSPaul Brook    target_phys_bits=32
24732408a527Saurel32  ;;
24742408a527Saurel32  cris)
2475253bd7f8Sedgar_igl    target_nptl="yes"
24761ad2134fSPaul Brook    target_phys_bits=32
24772408a527Saurel32  ;;
24782408a527Saurel32  m68k)
24790938cda5Saurel32    bflt="yes"
248056aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
24811ad2134fSPaul Brook    target_phys_bits=32
24822408a527Saurel32  ;;
248372b675caSEdgar E. Iglesias  microblaze)
248472b675caSEdgar E. Iglesias    bflt="yes"
248572b675caSEdgar E. Iglesias    target_nptl="yes"
248672b675caSEdgar E. Iglesias    target_phys_bits=32
248772b675caSEdgar E. Iglesias  ;;
24882408a527Saurel32  mips|mipsel)
2489b498c8a0SJuan Quintela    TARGET_ARCH=mips
249025be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2491f04dc72fSPaul Brook    target_nptl="yes"
24921ad2134fSPaul Brook    target_phys_bits=64
24932408a527Saurel32  ;;
24942408a527Saurel32  mipsn32|mipsn32el)
2495b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
24966acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
249725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
24981ad2134fSPaul Brook    target_phys_bits=64
24992408a527Saurel32  ;;
25002408a527Saurel32  mips64|mips64el)
2501b498c8a0SJuan Quintela    TARGET_ARCH=mips64
25026acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
250325be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
25041ad2134fSPaul Brook    target_phys_bits=64
25052408a527Saurel32  ;;
25062408a527Saurel32  ppc)
2507c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25081ad2134fSPaul Brook    target_phys_bits=32
2509d6630708SNathan Froyd    target_nptl="yes"
25102408a527Saurel32  ;;
25112408a527Saurel32  ppcemb)
25126acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2513e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2514c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25151ad2134fSPaul Brook    target_phys_bits=64
2516d6630708SNathan Froyd    target_nptl="yes"
25172408a527Saurel32  ;;
25182408a527Saurel32  ppc64)
25196acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2520e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2521c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25221ad2134fSPaul Brook    target_phys_bits=64
25232408a527Saurel32  ;;
25242408a527Saurel32  ppc64abi32)
2525b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
25266acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2527e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
252825be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
2529c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25301ad2134fSPaul Brook    target_phys_bits=64
25312408a527Saurel32  ;;
25322408a527Saurel32  sh4|sh4eb)
2533b498c8a0SJuan Quintela    TARGET_ARCH=sh4
25344dbed897Spbrook    bflt="yes"
25350b6d3ae0Saurel32    target_nptl="yes"
25361ad2134fSPaul Brook    target_phys_bits=32
25372408a527Saurel32  ;;
25382408a527Saurel32  sparc)
25391ad2134fSPaul Brook    target_phys_bits=64
25402408a527Saurel32  ;;
25412408a527Saurel32  sparc64)
25426acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
25431ad2134fSPaul Brook    target_phys_bits=64
25442408a527Saurel32  ;;
25452408a527Saurel32  sparc32plus)
2546b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
25476acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
2548e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
254925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
25501ad2134fSPaul Brook    target_phys_bits=64
25512408a527Saurel32  ;;
255224e804ecSAlexander Graf  s390x)
255324e804ecSAlexander Graf    target_phys_bits=64
255424e804ecSAlexander Graf  ;;
25552408a527Saurel32  *)
2556de83cd02Sbellard    echo "Unsupported target CPU"
2557de83cd02Sbellard    exit 1
25582408a527Saurel32  ;;
25592408a527Saurel32esac
256025be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2561053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
256225be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
256325be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
256442bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
25656acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
25666acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
25676acff7daSJuan Quintelafi
256825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2569e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
2570e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
2571e6e91b9cSJuan Quintelafi
257225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
25731b0c87fcSJuan Quintelacase "$target_arch2" in
25741b0c87fcSJuan Quintela  i386|x86_64)
25751b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
257625be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
25771b0c87fcSJuan Quintela    fi
25781b0c87fcSJuan Quintelaesac
2579c59249f9SJuan Quintelacase "$target_arch2" in
25800e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
2581c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
2582c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2583c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
2584c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
25855f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2586c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2587c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
258825be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
258925be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2590dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
2591dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
2592dae5079aSJan Kiszka      fi
2593d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
2594d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
2595d5970055SMichael S. Tsirkin      fi
2596c59249f9SJuan Quintela    fi
2597c59249f9SJuan Quintelaesac
2598de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
259925be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
260097a847bcSbellardfi
260197a847bcSbellardif test "$target_softmmu" = "yes" ; then
2602b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
260325be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
260425be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
26050e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
26065791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2607de83cd02Sbellardfi
2608997344f3Sbellardif test "$target_user_only" = "yes" ; then
260925be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2610997344f3Sbellardfi
2611831b7825Sthsif test "$target_linux_user" = "yes" ; then
261225be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2613831b7825Sthsfi
2614831b7825Sthsif test "$target_darwin_user" = "yes" ; then
261525be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2616831b7825Sthsfi
261756aebc89Spbrooklist=""
261856aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
261956aebc89Spbrook  for x in $gdb_xml_files; do
262056aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
262156aebc89Spbrook  done
262225be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
26233d0f1517SJuan Quintelafi
2624de83cd02Sbellard
2625f57975fbSJuan Quintelacase "$target_arch2" in
2626990b3e19SRichard Henderson  alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
262725be210fSJuan Quintela    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2628f57975fbSJuan Quintela    ;;
2629d6b38939SJuan Quintela  *)
263025be210fSJuan Quintela    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2631d6b38939SJuan Quintela    ;;
2632f57975fbSJuan Quintelaesac
2633f57975fbSJuan Quintela
2634e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
263525be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2636e5fe0c52Spbrookfi
2637bd0c5661Spbrookif test "$target_user_only" = "yes" \
2638bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
263925be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2640bd0c5661Spbrookfi
2641379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
264225be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2643379f6698SPaul Brookfi
264484778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
264525be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
264684778508Sblueswir1fi
26475b0753e0Sbellard
26484afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
2649fa282484SJuan Quintela
26504afddb55SJuan Quintelacflags=""
2651fa282484SJuan Quintelaldflags=""
26529b8e111fSJuan Quintela
265357ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
265457ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
265524e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
265624e804ecSAlexander Graf  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
26575d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
26585d8a4f8fSRichard Henderson  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
265957ddfbf7SJuan Quintelaelse
266057ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
266157ddfbf7SJuan Quintelafi
266257ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/tcg $cflags"
266357ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/fpu $cflags"
266457ddfbf7SJuan Quintela
26654d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
26664d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
26674d904533SBlue Swirlelse
26684d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
26694d904533SBlue Swirlfi
26704d904533SBlue Swirl
267164656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
267264656024SJuan Quintela  case "$i" in
267364656024SJuan Quintela  alpha)
267425be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
26754d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
267664656024SJuan Quintela  ;;
267764656024SJuan Quintela  arm)
267825be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
26794d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
268064656024SJuan Quintela  ;;
268164656024SJuan Quintela  cris)
268225be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
26834d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
268464656024SJuan Quintela  ;;
268564656024SJuan Quintela  hppa)
268625be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
26874d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
268864656024SJuan Quintela  ;;
268964656024SJuan Quintela  i386|x86_64)
269025be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
26914d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
269264656024SJuan Quintela  ;;
2693903ec55cSAurelien Jarno  ia64*)
2694903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
2695903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
2696903ec55cSAurelien Jarno  ;;
269764656024SJuan Quintela  m68k)
269825be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
26994d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
270064656024SJuan Quintela  ;;
270164656024SJuan Quintela  microblaze)
270225be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
27034d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
270464656024SJuan Quintela  ;;
270564656024SJuan Quintela  mips*)
270625be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
27074d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
270864656024SJuan Quintela  ;;
270964656024SJuan Quintela  ppc*)
271025be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
27114d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
271264656024SJuan Quintela  ;;
271324e804ecSAlexander Graf  s390*)
271425be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
27154d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
271664656024SJuan Quintela  ;;
271764656024SJuan Quintela  sh4)
271825be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
27194d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
272064656024SJuan Quintela  ;;
272164656024SJuan Quintela  sparc*)
272225be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
27234d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
272464656024SJuan Quintela  ;;
272564656024SJuan Quintela  esac
272664656024SJuan Quinteladone
272764656024SJuan Quintela
27286ee7126fSJuan Quintelacase "$ARCH" in
27296ee7126fSJuan Quintelaalpha)
27306ee7126fSJuan Quintela  # Ensure there's only a single GP
27316ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
27326ee7126fSJuan Quintela;;
27336ee7126fSJuan Quintelaesac
27346ee7126fSJuan Quintela
273555d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
273655d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
273755d9c04bSJuan Quintela  arm)
273855d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
273955d9c04bSJuan Quintela  ;;
274055d9c04bSJuan Quintela  i386|mips|ppc)
274155d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
274255d9c04bSJuan Quintela  ;;
274355d9c04bSJuan Quintela  esac
274455d9c04bSJuan Quintelafi
274555d9c04bSJuan Quintela
274634005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
274734005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
274834005a00SKirill A. Shutemov  cflags="-fpie $cflags"
274934005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
275034005a00SKirill A. Shutemovfi
275134005a00SKirill A. Shutemov
2752471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
2753471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
2754471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
275525be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
2756471857ddSJuan Quintelafi
2757471857ddSJuan Quintela
2758d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
275925be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
2760d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
2761d02c1db3SJuan Quintela    cflags="-p $cflags"
2762d02c1db3SJuan Quintela    ldflags="-p $ldflags"
2763d02c1db3SJuan Quintela  fi
2764d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
2765d02c1db3SJuan Quintela    ldflags="-p $ldflags"
276625be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
2767d02c1db3SJuan Quintela  fi
2768d02c1db3SJuan Quintelafi
2769d02c1db3SJuan Quintela
27706ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
27719b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2772fa282484SJuan Quintela  case "$ARCH" in
2773fa282484SJuan Quintela  sparc)
2774fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
2775322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
2776fa282484SJuan Quintela    ;;
27774d58be06SRichard Henderson  alpha | s390x)
27784d58be06SRichard Henderson    # The default placement of the application is fine.
27794d58be06SRichard Henderson    ;;
2780fd76e73aSRichard Henderson  *)
2781322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
2782fa282484SJuan Quintela    ;;
2783fa282484SJuan Quintela  esac
2784fa282484SJuan Quintelafi
2785fa282484SJuan Quintela
278625be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
278725be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
2788fa282484SJuan Quintela
278997a847bcSbellarddone # for target in $targets
27907d13299dSbellard
27917d13299dSbellard# build tree in object directory if source path is different from current one
27927d13299dSbellardif test "$source_path_used" = "yes" ; then
2793e1144d00SMark McLoughlin    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
27942d9f27d2SAnthony Liguori    DIRS="$DIRS roms/seabios roms/vgabios"
279574db920cSGautham R Shenoy    DIRS="$DIRS fsdev"
27967d13299dSbellard    FILES="Makefile tests/Makefile"
2797e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2798e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
27997ea78b74SJan Kiszka    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
28002d9f27d2SAnthony Liguori    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
28017ea78b74SJan Kiszka    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
28027ea78b74SJan Kiszka        FILES="$FILES pc-bios/`basename $bios_file`"
28037ea78b74SJan Kiszka    done
28047d13299dSbellard    for dir in $DIRS ; do
28057d13299dSbellard            mkdir -p $dir
28067d13299dSbellard    done
2807ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
28087d13299dSbellard    for f in $FILES ; do
2809ec530c81Sbellard        rm -f $f
2810ec530c81Sbellard        ln -s $source_path/$f $f
28117d13299dSbellard    done
28127d13299dSbellardfi
28131ad2134fSPaul Brook
2814c34ebfdcSAnthony Liguori# temporary config to build submodules
28152d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
2816c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
281737116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
2818c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2819c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
2820c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
2821c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
2822c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
2823c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
2824c34ebfdcSAnthony Liguori    echo "HOST_CC=$host_cc" >> $config_mak
2825c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
2826c34ebfdcSAnthony Liguoridone
2827c34ebfdcSAnthony Liguori
28281ad2134fSPaul Brookfor hwlib in 32 64; do
28291ad2134fSPaul Brook  d=libhw$hwlib
28301ad2134fSPaul Brook  mkdir -p $d
28319953b2fcSBlue Swirl  mkdir -p $d/ide
28321ad2134fSPaul Brook  rm -f $d/Makefile
28331ad2134fSPaul Brook  ln -s $source_path/Makefile.hw $d/Makefile
283437116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
28351ad2134fSPaul Brookdone
2836add16157SBlue Swirl
2837add16157SBlue Swirld=libuser
2838add16157SBlue Swirlmkdir -p $d
2839add16157SBlue Swirlrm -f $d/Makefile
2840add16157SBlue Swirlln -s $source_path/Makefile.user $d/Makefile
2841299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
2842299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
2843299060a0SKirill A. Shutemovfi
2844b40292e7SJan Kiszka
2845b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
2846b40292e7SJan Kiszka  mkdir -p QMP
2847b40292e7SJan Kiszkafi
2848