xref: /openbmc/qemu/configure (revision 2f6f5c7a)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
57d13299dSbellard# set temporary file name
67d13299dSbellardif test ! -z "$TMPDIR" ; then
77d13299dSbellard    TMPDIR1="${TMPDIR}"
87d13299dSbellardelif test ! -z "$TEMPDIR" ; then
97d13299dSbellard    TMPDIR1="${TEMPDIR}"
107d13299dSbellardelse
117d13299dSbellard    TMPDIR1="/tmp"
127d13299dSbellardfi
137d13299dSbellard
143ef693a0SbellardTMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
153ef693a0SbellardTMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o"
16a91b857cSmalcTMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
177d13299dSbellard
184021d247SAurelien Jarnotrap "rm -f $TMPC $TMPO $TMPE ; exit" EXIT INT QUIT TERM
199ac81bbbSmalc
2052166aa0SJuan Quintelacompile_object() {
21a558ee17SJuan Quintela  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
2252166aa0SJuan Quintela}
2352166aa0SJuan Quintela
2452166aa0SJuan Quintelacompile_prog() {
2552166aa0SJuan Quintela  local_cflags="$1"
2652166aa0SJuan Quintela  local_ldflags="$2"
27a558ee17SJuan Quintela  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
2852166aa0SJuan Quintela}
2952166aa0SJuan Quintela
300dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
310dba6195SLoïc Minier# executable or a builtin)
320dba6195SLoïc Minierhas() {
330dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
340dba6195SLoïc Minier}
350dba6195SLoïc Minier
360dba6195SLoïc Minier# search for an executable in PATH
370dba6195SLoïc Minierpath_of() {
380dba6195SLoïc Minier    local_command="$1"
390dba6195SLoïc Minier    local_ifs="$IFS"
400dba6195SLoïc Minier    local_dir=""
410dba6195SLoïc Minier
420dba6195SLoïc Minier    # pathname has a dir component?
430dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
440dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
450dba6195SLoïc Minier            echo "$local_command"
460dba6195SLoïc Minier            return 0
470dba6195SLoïc Minier        fi
480dba6195SLoïc Minier    fi
490dba6195SLoïc Minier    if [ -z "$local_command" ]; then
500dba6195SLoïc Minier        return 1
510dba6195SLoïc Minier    fi
520dba6195SLoïc Minier
530dba6195SLoïc Minier    IFS=:
540dba6195SLoïc Minier    for local_dir in $PATH; do
550dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
560dba6195SLoïc Minier            echo "$local_dir/$local_command"
570dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
580dba6195SLoïc Minier            return 0
590dba6195SLoïc Minier        fi
600dba6195SLoïc Minier    done
610dba6195SLoïc Minier    # not found
620dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
630dba6195SLoïc Minier    return 1
640dba6195SLoïc Minier}
650dba6195SLoïc Minier
667d13299dSbellard# default parameters
672ff6b91eSJuan Quintelacpu=""
681e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
6943ce4dfeSbellardstatic="no"
70ed968ff1SJuan Quintelasparc_cpu=""
717d13299dSbellardcross_prefix=""
727d13299dSbellardcc="gcc"
730c58ac1cSmalcaudio_drv_list=""
744c9b53e3Smalcaudio_card_list="ac97 es1370 sb16"
754c9b53e3Smalcaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus"
76eb852011SMarkus Armbrusterblock_drv_whitelist=""
777d13299dSbellardhost_cc="gcc"
787d13299dSbellardar="ar"
797d13299dSbellardmake="make"
806a882643Spbrookinstall="install"
817aa486feSAnthony Liguoriobjcopy="objcopy"
827aa486feSAnthony Liguorild="ld"
83c81da56eSJuan Quintelahelper_cflags=""
8473da375eSJuan Quintelalibs_softmmu=""
853e2e0e6bSJuan Quintelalibs_tools=""
8667f86e8eSJuan Quintelaaudio_pt_int=""
87d5631638Smalcaudio_win_int=""
88ac0df51dSaliguori
89ac0df51dSaliguori# parse CC options first
90ac0df51dSaliguorifor opt do
91ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
92ac0df51dSaliguori  case "$opt" in
93ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
94ac0df51dSaliguori  ;;
95ac0df51dSaliguori  --cc=*) cc="$optarg"
96ac0df51dSaliguori  ;;
972ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
982ff6b91eSJuan Quintela  ;;
99a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
100e2a2ed06SJuan Quintela  ;;
101e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
102e2a2ed06SJuan Quintela  ;;
10350e7b1a0SJuan Quintela  --sparc_cpu=*)
10450e7b1a0SJuan Quintela    sparc_cpu="$optarg"
10550e7b1a0SJuan Quintela    case $sparc_cpu in
106ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
10750e7b1a0SJuan Quintela      cpu="sparc"
10850e7b1a0SJuan Quintela    ;;
10950e7b1a0SJuan Quintela    v9)
11050e7b1a0SJuan Quintela      cpu="sparc64"
11150e7b1a0SJuan Quintela    ;;
11250e7b1a0SJuan Quintela    *)
11350e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
11450e7b1a0SJuan Quintela      exit 1
11550e7b1a0SJuan Quintela    ;;
11650e7b1a0SJuan Quintela    esac
11750e7b1a0SJuan Quintela  ;;
118ac0df51dSaliguori  esac
119ac0df51dSaliguoridone
120ac0df51dSaliguori# OS specific
121ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
122ac0df51dSaliguori# we can eliminate it's usage altogether
123ac0df51dSaliguori
124ac0df51dSaliguoricc="${cross_prefix}${cc}"
125ac0df51dSaliguoriar="${cross_prefix}${ar}"
1267aa486feSAnthony Liguoriobjcopy="${cross_prefix}${objcopy}"
1277aa486feSAnthony Liguorild="${cross_prefix}${ld}"
128ac0df51dSaliguori
129be17dc90SMichael S. Tsirkin# default flags for all hosts
130be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
131be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
132be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
133be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
134be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
13584958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
136be17dc90SMichael S. TsirkinQEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
137be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
138be17dc90SMichael S. Tsirkin
139a0f291fcSJuan Quintelagcc_flags="-Wold-style-declaration -Wold-style-definition -fstack-protector-all"
140be17dc90SMichael S. Tsirkincat > $TMPC << EOF
141aa527b65SAurelien Jarnoint main(void) { return 0; }
142be17dc90SMichael S. TsirkinEOF
143be17dc90SMichael S. Tsirkinfor flag in $gcc_flags; do
144aa527b65SAurelien Jarno    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
145be17dc90SMichael S. Tsirkin	QEMU_CFLAGS="$flag $QEMU_CFLAGS"
146be17dc90SMichael S. Tsirkin    fi
147be17dc90SMichael S. Tsirkindone
148be17dc90SMichael S. Tsirkin
149ac0df51dSaliguori# check that the C compiler works.
150ac0df51dSaliguoricat > $TMPC <<EOF
151ac0df51dSaliguoriint main(void) {}
152ac0df51dSaliguoriEOF
153ac0df51dSaliguori
15452166aa0SJuan Quintelaif compile_object ; then
155ac0df51dSaliguori  : C compiler works ok
156ac0df51dSaliguorielse
157ac0df51dSaliguori    echo "ERROR: \"$cc\" either does not exist or does not work"
158ac0df51dSaliguori    exit 1
159ac0df51dSaliguorifi
160ac0df51dSaliguori
161ac0df51dSaliguoricheck_define() {
162ac0df51dSaliguoricat > $TMPC <<EOF
163ac0df51dSaliguori#if !defined($1)
164ac0df51dSaliguori#error Not defined
165ac0df51dSaliguori#endif
166ac0df51dSaliguoriint main(void) { return 0; }
167ac0df51dSaliguoriEOF
16852166aa0SJuan Quintela  compile_object
169ac0df51dSaliguori}
170ac0df51dSaliguori
1712ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
1722ff6b91eSJuan Quintela  # command line argument
1732ff6b91eSJuan Quintela  :
1742ff6b91eSJuan Quintelaelif check_define __i386__ ; then
175ac0df51dSaliguori  cpu="i386"
176ac0df51dSaliguorielif check_define __x86_64__ ; then
177ac0df51dSaliguori  cpu="x86_64"
1783aa9bd6cSblueswir1elif check_define __sparc__ ; then
1793aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
1803aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
1813aa9bd6cSblueswir1  if check_define __arch64__ ; then
1823aa9bd6cSblueswir1    cpu="sparc64"
1833aa9bd6cSblueswir1  else
1843aa9bd6cSblueswir1    cpu="sparc"
1853aa9bd6cSblueswir1  fi
186fdf7ed96Smalcelif check_define _ARCH_PPC ; then
187fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
188fdf7ed96Smalc    cpu="ppc64"
189ac0df51dSaliguori  else
190fdf7ed96Smalc    cpu="ppc"
191fdf7ed96Smalc  fi
192afa05235SAurelien Jarnoelif check_define __mips__ ; then
193afa05235SAurelien Jarno  cpu="mips"
194477ba620SAurelien Jarnoelif check_define __ia64__ ; then
195477ba620SAurelien Jarno  cpu="ia64"
196d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
197d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
198d66ed0eaSAurelien Jarno    cpu="s390x"
199d66ed0eaSAurelien Jarno  else
200d66ed0eaSAurelien Jarno    cpu="s390"
201d66ed0eaSAurelien Jarno  fi
202fdf7ed96Smalcelse
203fdf7ed96Smalc  cpu=`uname -m`
204ac0df51dSaliguorifi
205ac0df51dSaliguori
2065327cf48Sbellardtarget_list=""
2077d13299dSbellardcase "$cpu" in
208afa05235SAurelien Jarno  alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
209ea8f20f8SJuan Quintela    cpu="$cpu"
210ea8f20f8SJuan Quintela  ;;
2117d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
21297a847bcSbellard    cpu="i386"
2137d13299dSbellard  ;;
214aaa5fa14Saurel32  x86_64|amd64)
215aaa5fa14Saurel32    cpu="x86_64"
216aaa5fa14Saurel32  ;;
217ba68055eSbellard  armv*b)
218808c4954Sbellard    cpu="armv4b"
219808c4954Sbellard  ;;
220ba68055eSbellard  armv*l)
2217d13299dSbellard    cpu="armv4l"
2227d13299dSbellard  ;;
223f54b3f92Saurel32  parisc|parisc64)
224f54b3f92Saurel32    cpu="hppa"
225f54b3f92Saurel32  ;;
226afa05235SAurelien Jarno  mips*)
227afa05235SAurelien Jarno    cpu="mips"
228afa05235SAurelien Jarno  ;;
22924e804ecSAlexander Graf  s390)
230fb3e5849Sbellard    cpu="s390"
231fb3e5849Sbellard  ;;
23224e804ecSAlexander Graf  s390x)
23324e804ecSAlexander Graf    cpu="s390x"
23424e804ecSAlexander Graf  ;;
2353142255cSblueswir1  sparc|sun4[cdmuv])
236ae228531Sbellard    cpu="sparc"
237ae228531Sbellard  ;;
2387d13299dSbellard  *)
239a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
240a447d4dcSPaolo Bonzini    exit 1
2417d13299dSbellard  ;;
2427d13299dSbellardesac
243e2d52ad3SJuan Quintela
2443a3fb96dSStefan Weil# Default value for a variable defining feature "foo".
2453a3fb96dSStefan Weil#  * foo="no"  feature will only be used if --enable-foo arg is given
2463a3fb96dSStefan Weil#  * foo=""    feature will be searched for, and if found, will be used
2473a3fb96dSStefan Weil#              unless --disable-foo is given
2483a3fb96dSStefan Weil#  * foo="yes" this value will only be set by --enable-foo flag.
2493a3fb96dSStefan Weil#              feature will searched for,
2503a3fb96dSStefan Weil#              if not found, configure exits with error
251e2d52ad3SJuan Quintela#
2523a3fb96dSStefan Weil# Always add --enable-foo and --disable-foo command line args.
2533a3fb96dSStefan Weil# Distributions want to ensure that several features are compiled in, and it
2543a3fb96dSStefan Weil# is impossible without a --enable-foo that exits if a feature is not found.
255e2d52ad3SJuan Quintela
256a20a6f46SJuan Quintelabluez=""
2574ffcedb6SJuan Quintelabrlapi=""
258788c8196SJuan Quintelacurl=""
259c584a6d0SJuan Quintelacurses=""
260a25dba17SJuan Quinteladocs=""
2612df87df7SJuan Quintelafdt=""
262b31a0277SJuan Quintelakvm=""
263dae5079aSJan Kiszkakvm_para=""
264b0a47e79SJuan Quintelanptl=""
265c4198157SJuan Quintelasdl=""
266dfffc653SJuan Quintelasparse="no"
267ee682d27SStefan Weiluuid=""
268dfb278bdSJuan Quintelavde=""
2691be10ad2SJuan Quintelavnc_tls=""
270ea784e3bSJuan Quintelavnc_sasl=""
271*2f6f5c7aSCorentin Charyvnc_jpeg=""
272fc321b4bSJuan Quintelaxen=""
2735c6c3a6cSChristoph Hellwiglinux_aio=""
274758e8e38SVenkateswararao Jujjuri (JV)attr=""
275d5970055SMichael S. Tsirkinvhost_net=""
276dfb278bdSJuan Quintela
2777d13299dSbellardgprof="no"
278f8393946Saurel32debug_tcg="no"
279b4475aa2SLuiz Capitulinodebug_mon="no"
280f3d08ee6SPaul Brookdebug="no"
2811625af87Saliguoristrip_opt="yes"
2827d13299dSbellardbigendian="no"
28367b915a5Sbellardmingw32="no"
28467b915a5SbellardEXESUF=""
285683035deSPaolo Bonziniprefix="/usr/local"
286683035deSPaolo Bonzinimandir="\${prefix}/share/man"
287683035deSPaolo Bonzinidatadir="\${prefix}/share/qemu"
288683035deSPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
289683035deSPaolo Bonzinibindir="\${prefix}/bin"
290683035deSPaolo Bonzinisysconfdir="\${prefix}/etc"
291683035deSPaolo Bonziniconfsuffix="/qemu"
292443f1376Sbellardslirp="yes"
293102a52e4Sbellardfmod_lib=""
294102a52e4Sbellardfmod_inc=""
2952f6a1ab0Sblueswir1oss_lib=""
296b1a550a0Spbrookbsd="no"
2975327cf48Sbellardlinux="no"
298d2c7c9b8Sblueswir1solaris="no"
29905c2a3e7Sbellardprofiler="no"
3005b0753e0Sbellardcocoa="no"
3010a8e90f4Spbrooksoftmmu="yes"
302831b7825Sthslinux_user="no"
303831b7825Sthsdarwin_user="no"
30484778508Sblueswir1bsd_user="no"
305379f6698SPaul Brookguest_base=""
306c5937220Spbrookuname_release=""
307e5d355d1Saliguoriio_thread="no"
3088ff9cbf7Smalcmixemu="no"
309eac30262Saliguorikerneldir=""
310b29fe3edSmalcaix="no"
31177755340Sthsblobs="yes"
3124a19f1ecSpbrookpkgversion=""
3135495ed11SLuiz Capitulinocheck_utests="no"
31434005a00SKirill A. Shutemovuser_pie="no"
31520ff6c80SAnthony Liguorizero_malloc=""
3167d13299dSbellard
3177d13299dSbellard# OS specific
318ac0df51dSaliguoriif check_define __linux__ ; then
319ac0df51dSaliguori  targetos="Linux"
320ac0df51dSaliguorielif check_define _WIN32 ; then
321ac0df51dSaliguori  targetos='MINGW32'
322169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
323169dc5d3Sblueswir1  targetos='OpenBSD'
324169dc5d3Sblueswir1elif check_define __sun__ ; then
325169dc5d3Sblueswir1  targetos='SunOS'
326ac0df51dSaliguorielse
3277d13299dSbellard  targetos=`uname -s`
328ac0df51dSaliguorifi
3290dbfc675SJuan Quintela
3307d13299dSbellardcase $targetos in
331c326e0afSbellardCYGWIN*)
332c326e0afSbellard  mingw32="yes"
333a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
334d5631638Smalc  audio_possible_drivers="winwave sdl"
335d5631638Smalc  audio_drv_list="winwave"
336c326e0afSbellard;;
33767b915a5SbellardMINGW32*)
33867b915a5Sbellard  mingw32="yes"
339d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
340d5631638Smalc  audio_drv_list="winwave"
34167b915a5Sbellard;;
3425c40d2bdSthsGNU/kFreeBSD)
343a167ba50SAurelien Jarno  bsd="yes"
3440c58ac1cSmalc  audio_drv_list="oss"
345f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3465c40d2bdSths;;
3477d3505c5SbellardFreeBSD)
3487d3505c5Sbellard  bsd="yes"
349a167ba50SAurelien Jarno  make="gmake"
3500c58ac1cSmalc  audio_drv_list="oss"
351f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
352f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
353f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3547d3505c5Sbellard;;
355c5e97233Sblueswir1DragonFly)
356c5e97233Sblueswir1  bsd="yes"
357a167ba50SAurelien Jarno  make="gmake"
358c5e97233Sblueswir1  audio_drv_list="oss"
359c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
360c5e97233Sblueswir1;;
3617d3505c5SbellardNetBSD)
3627d3505c5Sbellard  bsd="yes"
363a167ba50SAurelien Jarno  make="gmake"
3640c58ac1cSmalc  audio_drv_list="oss"
365c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3668ef92a88Sblueswir1  oss_lib="-lossaudio"
3677d3505c5Sbellard;;
3687d3505c5SbellardOpenBSD)
3697d3505c5Sbellard  bsd="yes"
370a167ba50SAurelien Jarno  make="gmake"
3710c58ac1cSmalc  audio_drv_list="oss"
372c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3732f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3747d3505c5Sbellard;;
37583fb7adfSbellardDarwin)
37683fb7adfSbellard  bsd="yes"
37783fb7adfSbellard  darwin="yes"
3780dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3790dbfc675SJuan Quintela  # run 64-bit userspace code
380aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3811b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
382aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3831b0f9cc2Saliguori  fi
3841b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
385a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3860c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3871b0f9cc2Saliguori  else
388a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3891b0f9cc2Saliguori  fi
390831b7825Sths  darwin_user="yes"
391fd677642Sths  cocoa="yes"
3920c58ac1cSmalc  audio_drv_list="coreaudio"
393c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
3940c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
3957973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
39683fb7adfSbellard;;
397ec530c81SbellardSunOS)
398ec530c81Sbellard  solaris="yes"
399c2b84fabSths  make="gmake"
400c2b84fabSths  install="ginstall"
401fa58948dSBlue Swirl  ld="gld"
4020475a5caSths  needs_libsunmath="no"
403c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
404ef18c883Sths  # have to select again, because `uname -m` returns i86pc
405ef18c883Sths  # even on an x86_64 box.
406ef18c883Sths  solariscpu=`isainfo -k`
407ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
408ef18c883Sths    cpu="x86_64"
409ef18c883Sths  fi
410c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4110475a5caSths    if test "$solarisrev" -le 9 ; then
4120475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4130475a5caSths        needs_libsunmath="yes"
414f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
415f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
416f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4170475a5caSths      else
4180475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4190475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4200475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4210475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4220475a5caSths        exit 1
4230475a5caSths      fi
4240475a5caSths    fi
42586b2bd93Sths  fi
4266b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4270c58ac1cSmalc    audio_drv_list="oss"
4286b4d2ba1Sths  fi
429c2de5c91Smalc  audio_possible_drivers="oss sdl"
430d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
431d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
432d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
433d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
434a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
435e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
436ec530c81Sbellard;;
437b29fe3edSmalcAIX)
438b29fe3edSmalc  aix="yes"
439b29fe3edSmalc  make="gmake"
440b29fe3edSmalc;;
441fb065187Sbellard*)
4420c58ac1cSmalc  audio_drv_list="oss"
443b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4445327cf48Sbellard  linux="yes"
445831b7825Sths  linux_user="yes"
44668063649Sblueswir1  usb="linux"
44707f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
448c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
449c9ec1fe4Sbellard  fi
450fb065187Sbellard;;
4517d13299dSbellardesac
4527d13299dSbellard
4537d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
454b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
45568063649Sblueswir1    usb="bsd"
45683fb7adfSbellard  fi
45784778508Sblueswir1  bsd_user="yes"
4587d3505c5Sbellardfi
4597d3505c5Sbellard
4603457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4613457a3f8SJuan Quintela  EXESUF=".exe"
462a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
463e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
464e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
465884044aaSJuan Quintela  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
466683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
467683035deSPaolo Bonzini  mandir="\${prefix}"
468683035deSPaolo Bonzini  datadir="\${prefix}"
469683035deSPaolo Bonzini  docdir="\${prefix}"
470683035deSPaolo Bonzini  bindir="\${prefix}"
471683035deSPaolo Bonzini  sysconfdir="\${prefix}"
472683035deSPaolo Bonzini  confsuffix=""
4733457a3f8SJuan Quintelafi
4743457a3f8SJuan Quintela
4757d13299dSbellard# find source path
476ad064840Spbrooksource_path=`dirname "$0"`
47759faef3aSbalrogsource_path_used="no"
47859faef3aSbalrogworkdir=`pwd`
479ad064840Spbrookif [ -z "$source_path" ]; then
48059faef3aSbalrog    source_path=$workdir
481ad064840Spbrookelse
482ad064840Spbrook    source_path=`cd "$source_path"; pwd`
4837d13299dSbellardfi
484724db118Spbrook[ -f "$workdir/vl.c" ] || source_path_used="yes"
4857d13299dSbellard
486487fefdbSAnthony Liguoriwerror=""
48785aa5189Sbellard
4887d13299dSbellardfor opt do
489a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4907d13299dSbellard  case "$opt" in
4912efc3265Sbellard  --help|-h) show_help=yes
4922efc3265Sbellard  ;;
493b1a550a0Spbrook  --prefix=*) prefix="$optarg"
4947d13299dSbellard  ;;
495b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
49632ce6337Sbellard  ;;
497b1a550a0Spbrook  --source-path=*) source_path="$optarg"
498ad064840Spbrook  source_path_used="yes"
4997d13299dSbellard  ;;
500ac0df51dSaliguori  --cross-prefix=*)
5017d13299dSbellard  ;;
502ac0df51dSaliguori  --cc=*)
5037d13299dSbellard  ;;
504b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
50583469015Sbellard  ;;
506b1a550a0Spbrook  --make=*) make="$optarg"
5077d13299dSbellard  ;;
5086a882643Spbrook  --install=*) install="$optarg"
5096a882643Spbrook  ;;
510e2a2ed06SJuan Quintela  --extra-cflags=*)
5117d13299dSbellard  ;;
512e2a2ed06SJuan Quintela  --extra-ldflags=*)
5137d13299dSbellard  ;;
5142ff6b91eSJuan Quintela  --cpu=*)
5157d13299dSbellard  ;;
516b1a550a0Spbrook  --target-list=*) target_list="$optarg"
517de83cd02Sbellard  ;;
5187d13299dSbellard  --enable-gprof) gprof="yes"
5197d13299dSbellard  ;;
52079427693SLoïc Minier  --static)
52179427693SLoïc Minier    static="yes"
52279427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
52343ce4dfeSbellard  ;;
5240b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5250b24e75fSPaolo Bonzini  ;;
5260b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5270b24e75fSPaolo Bonzini  ;;
5280b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5290b24e75fSPaolo Bonzini  ;;
5300b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5310b24e75fSPaolo Bonzini  ;;
532ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
53307381cc1SAnthony Liguori  ;;
53497a847bcSbellard  --disable-sdl) sdl="no"
53597a847bcSbellard  ;;
536c4198157SJuan Quintela  --enable-sdl) sdl="yes"
537c4198157SJuan Quintela  ;;
538b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
539102a52e4Sbellard  ;;
540c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
541c2de5c91Smalc  ;;
5422f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5432f6a1ab0Sblueswir1  ;;
5442fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5450c58ac1cSmalc  ;;
5460c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5470c58ac1cSmalc  ;;
548eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
549eb852011SMarkus Armbruster  ;;
550f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
551f8393946Saurel32  ;;
552f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
553f8393946Saurel32  ;;
554b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
555b4475aa2SLuiz Capitulino  ;;
556b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
557b4475aa2SLuiz Capitulino  ;;
558f3d08ee6SPaul Brook  --enable-debug)
559f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
560f3d08ee6SPaul Brook      debug_tcg="yes"
561b4475aa2SLuiz Capitulino      debug_mon="yes"
562f3d08ee6SPaul Brook      debug="yes"
563f3d08ee6SPaul Brook      strip_opt="no"
564f3d08ee6SPaul Brook  ;;
56503b4fe7dSaliguori  --enable-sparse) sparse="yes"
56603b4fe7dSaliguori  ;;
56703b4fe7dSaliguori  --disable-sparse) sparse="no"
56803b4fe7dSaliguori  ;;
5691625af87Saliguori  --disable-strip) strip_opt="no"
5701625af87Saliguori  ;;
5718d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5728d5d2d4cSths  ;;
5731be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5741be10ad2SJuan Quintela  ;;
5752f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5762f9606b3Saliguori  ;;
577ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
578ea784e3bSJuan Quintela  ;;
579*2f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
580*2f6f5c7aSCorentin Chary  ;;
581*2f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
582*2f6f5c7aSCorentin Chary  ;;
583443f1376Sbellard  --disable-slirp) slirp="no"
584c20709aaSbellard  ;;
585ee682d27SStefan Weil  --disable-uuid) uuid="no"
586ee682d27SStefan Weil  ;;
587ee682d27SStefan Weil  --enable-uuid) uuid="yes"
588ee682d27SStefan Weil  ;;
589e0e6c8c0Saliguori  --disable-vde) vde="no"
5908a16d273Sths  ;;
591dfb278bdSJuan Quintela  --enable-vde) vde="yes"
592dfb278bdSJuan Quintela  ;;
593e37630caSaliguori  --disable-xen) xen="no"
594e37630caSaliguori  ;;
595fc321b4bSJuan Quintela  --enable-xen) xen="yes"
596fc321b4bSJuan Quintela  ;;
5972e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
5982e4d9fb1Saurel32  ;;
5994ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6004ffcedb6SJuan Quintela  ;;
601fb599c9aSbalrog  --disable-bluez) bluez="no"
602fb599c9aSbalrog  ;;
603a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
604a20a6f46SJuan Quintela  ;;
6057ba1e619Saliguori  --disable-kvm) kvm="no"
6067ba1e619Saliguori  ;;
607b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
608b31a0277SJuan Quintela  ;;
60905c2a3e7Sbellard  --enable-profiler) profiler="yes"
61005c2a3e7Sbellard  ;;
611c2de5c91Smalc  --enable-cocoa)
612c2de5c91Smalc      cocoa="yes" ;
613c2de5c91Smalc      sdl="no" ;
614c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6155b0753e0Sbellard  ;;
616cad25d69Spbrook  --disable-system) softmmu="no"
6170a8e90f4Spbrook  ;;
618cad25d69Spbrook  --enable-system) softmmu="yes"
6190a8e90f4Spbrook  ;;
6200953a80fSZachary Amsden  --disable-user)
6210953a80fSZachary Amsden      linux_user="no" ;
6220953a80fSZachary Amsden      bsd_user="no" ;
6230953a80fSZachary Amsden      darwin_user="no"
6240953a80fSZachary Amsden  ;;
6250953a80fSZachary Amsden  --enable-user) ;;
626831b7825Sths  --disable-linux-user) linux_user="no"
6270a8e90f4Spbrook  ;;
628831b7825Sths  --enable-linux-user) linux_user="yes"
629831b7825Sths  ;;
630831b7825Sths  --disable-darwin-user) darwin_user="no"
631831b7825Sths  ;;
632831b7825Sths  --enable-darwin-user) darwin_user="yes"
6330a8e90f4Spbrook  ;;
63484778508Sblueswir1  --disable-bsd-user) bsd_user="no"
63584778508Sblueswir1  ;;
63684778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
63784778508Sblueswir1  ;;
638379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
639379f6698SPaul Brook  ;;
640379f6698SPaul Brook  --disable-guest-base) guest_base="no"
641379f6698SPaul Brook  ;;
64234005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
64334005a00SKirill A. Shutemov  ;;
64434005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
64534005a00SKirill A. Shutemov  ;;
646c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
647c5937220Spbrook  ;;
6483142255cSblueswir1  --sparc_cpu=*)
6493142255cSblueswir1  ;;
65085aa5189Sbellard  --enable-werror) werror="yes"
65185aa5189Sbellard  ;;
65285aa5189Sbellard  --disable-werror) werror="no"
65385aa5189Sbellard  ;;
6544d3b6f6eSbalrog  --disable-curses) curses="no"
6554d3b6f6eSbalrog  ;;
656c584a6d0SJuan Quintela  --enable-curses) curses="yes"
657c584a6d0SJuan Quintela  ;;
658769ce76dSAlexander Graf  --disable-curl) curl="no"
659769ce76dSAlexander Graf  ;;
660788c8196SJuan Quintela  --enable-curl) curl="yes"
661788c8196SJuan Quintela  ;;
6622df87df7SJuan Quintela  --disable-fdt) fdt="no"
6632df87df7SJuan Quintela  ;;
6642df87df7SJuan Quintela  --enable-fdt) fdt="yes"
6652df87df7SJuan Quintela  ;;
6665495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
6675495ed11SLuiz Capitulino  ;;
6685495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
6695495ed11SLuiz Capitulino  ;;
670bd0c5661Spbrook  --disable-nptl) nptl="no"
671bd0c5661Spbrook  ;;
672b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
673b0a47e79SJuan Quintela  ;;
6748ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
6758ff9cbf7Smalc  ;;
6765c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
6775c6c3a6cSChristoph Hellwig  ;;
6785c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
6795c6c3a6cSChristoph Hellwig  ;;
680758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
681758e8e38SVenkateswararao Jujjuri (JV)  ;;
682758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
683758e8e38SVenkateswararao Jujjuri (JV)  ;;
684e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
685e5d355d1Saliguori  ;;
68677755340Sths  --disable-blobs) blobs="no"
68777755340Sths  ;;
688eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
689eac30262Saliguori  ;;
6904a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
6914a19f1ecSpbrook  ;;
692a25dba17SJuan Quintela  --disable-docs) docs="no"
69370ec5dc0SAnthony Liguori  ;;
694a25dba17SJuan Quintela  --enable-docs) docs="yes"
69583a3ab8bSJuan Quintela  ;;
696d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
697d5970055SMichael S. Tsirkin  ;;
698d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
699d5970055SMichael S. Tsirkin  ;;
7006bde81cbSPaolo Bonzini  --*dir)
7016bde81cbSPaolo Bonzini  ;;
7027f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7037f1559c6Sbalrog  ;;
7047d13299dSbellard  esac
7057d13299dSbellarddone
7067d13299dSbellard
7073142255cSblueswir1#
7083142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
709a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7103142255cSblueswir1#
711379f6698SPaul Brookhost_guest_base="no"
71240293e58Sbellardcase "$cpu" in
713ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
714ed968ff1SJuan Quintela           v7|v8)
715a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
716ed968ff1SJuan Quintela           ;;
717ed968ff1SJuan Quintela           v8plus|v8plusa)
718a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
719ed968ff1SJuan Quintela           ;;
720ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
721a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
722ed968ff1SJuan Quintela           esac
7230c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
724a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
725762e8230Sblueswir1           if test "$solaris" = "no" ; then
726a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
727c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
728762e8230Sblueswir1           fi
7293142255cSblueswir1           ;;
730ed968ff1SJuan Quintela    sparc64)
731a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7320c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
733a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
734ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
735a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
736762e8230Sblueswir1           fi
7373142255cSblueswir1           ;;
73876d83bdeSths    s390)
73928d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
74028d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
74148bb3750SRichard Henderson           host_guest_base="yes"
74228d7cc49SRichard Henderson           ;;
74328d7cc49SRichard Henderson    s390x)
74428d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
74528d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
74648bb3750SRichard Henderson           host_guest_base="yes"
74776d83bdeSths           ;;
74840293e58Sbellard    i386)
749a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7500c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
751c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
752379f6698SPaul Brook           host_guest_base="yes"
75340293e58Sbellard           ;;
75440293e58Sbellard    x86_64)
755a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
7560c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
757379f6698SPaul Brook           host_guest_base="yes"
758379f6698SPaul Brook           ;;
759379f6698SPaul Brook    arm*)
760379f6698SPaul Brook           host_guest_base="yes"
76140293e58Sbellard           ;;
762f6548c0aSmalc    ppc*)
763f6548c0aSmalc           host_guest_base="yes"
764f6548c0aSmalc           ;;
765cc01cc8eSAurelien Jarno    mips*)
766cc01cc8eSAurelien Jarno           host_guest_base="yes"
767cc01cc8eSAurelien Jarno           ;;
768477ba620SAurelien Jarno    ia64*)
769477ba620SAurelien Jarno           host_guest_base="yes"
770477ba620SAurelien Jarno           ;;
771fd76e73aSRichard Henderson    hppa*)
772fd76e73aSRichard Henderson           host_guest_base="yes"
773fd76e73aSRichard Henderson           ;;
7743142255cSblueswir1esac
7753142255cSblueswir1
776379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
777379f6698SPaul Brook
778af5db58eSpbrookif test x"$show_help" = x"yes" ; then
779af5db58eSpbrookcat << EOF
780af5db58eSpbrook
781af5db58eSpbrookUsage: configure [options]
782af5db58eSpbrookOptions: [defaults in brackets after descriptions]
783af5db58eSpbrook
784af5db58eSpbrookEOF
785af5db58eSpbrookecho "Standard options:"
786af5db58eSpbrookecho "  --help                   print this message"
787af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
788af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
789af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
790af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
791af5db58eSpbrookecho ""
792af5db58eSpbrookecho "Advanced options (experts only):"
793af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
794af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
795af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
7960bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
7970bfe8cc0SPaolo Bonziniecho "                           build time"
798a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
799e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
800af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
8016a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
802af5db58eSpbrookecho "  --static                 enable static build [$static]"
8030b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
8040b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
8050b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
8060b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
8070b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
808f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
809f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
81009695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
811890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
812890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
8131625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
81485aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
815fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
816c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
817af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
818c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
819c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
8204c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
8214c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
822eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
823eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
8248ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
825e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
826fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
8272e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
8284ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
8298d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
8301be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
8312f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
832ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
833*2f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
834*2f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
835af896aaaSpbrookecho "  --disable-curses         disable curses output"
836c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
837769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
838788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
8392df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
8402df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
8415495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
8425495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
843fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
844a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
8457ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
846b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
847bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
848e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
849af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
850af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
8510953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
8520953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
853831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
854831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
855831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
856831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
85784778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
85884778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
859379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
860379f6698SPaul Brookecho "                           emulation targets"
861379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
86234005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
86334005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
864af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
865af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
8662f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
867c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
8683142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
869ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
870ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
871e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
872dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
8735c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
8745c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
875758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
876758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
877e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
87877755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
879eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
880d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
881d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
882d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
883d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
884af5db58eSpbrookecho ""
8855bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
886af5db58eSpbrookexit 1
887af5db58eSpbrookfi
888af5db58eSpbrook
889ec530c81Sbellard#
890ec530c81Sbellard# Solaris specific configure tool chain decisions
891ec530c81Sbellard#
892ec530c81Sbellardif test "$solaris" = "yes" ; then
8936792aa11SLoïc Minier  if has $install; then
8946792aa11SLoïc Minier    :
8956792aa11SLoïc Minier  else
896ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
897ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
898ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
899ec530c81Sbellard    exit 1
900ec530c81Sbellard  fi
9016792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
902ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
903ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
904ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
905ec530c81Sbellard    exit 1
906ec530c81Sbellard  fi
9076792aa11SLoïc Minier  if has ar; then
9086792aa11SLoïc Minier    :
9096792aa11SLoïc Minier  else
910ec530c81Sbellard    echo "Error: No path includes ar"
911ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
912ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
913ec530c81Sbellard    fi
914ec530c81Sbellard    exit 1
915ec530c81Sbellard  fi
916ec530c81Sbellardfi
917ec530c81Sbellard
918ec530c81Sbellard
9195327cf48Sbellardif test -z "$target_list" ; then
9205327cf48Sbellard# these targets are portable
9210a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
9222408a527Saurel32        target_list="\
9232408a527Saurel32i386-softmmu \
9242408a527Saurel32x86_64-softmmu \
9252408a527Saurel32arm-softmmu \
9262408a527Saurel32cris-softmmu \
9272408a527Saurel32m68k-softmmu \
92872b675caSEdgar E. Iglesiasmicroblaze-softmmu \
9292408a527Saurel32mips-softmmu \
9302408a527Saurel32mipsel-softmmu \
9312408a527Saurel32mips64-softmmu \
9322408a527Saurel32mips64el-softmmu \
9332408a527Saurel32ppc-softmmu \
9342408a527Saurel32ppcemb-softmmu \
9352408a527Saurel32ppc64-softmmu \
9362408a527Saurel32sh4-softmmu \
9372408a527Saurel32sh4eb-softmmu \
9382408a527Saurel32sparc-softmmu \
9391b64fcaeSIgor V. Kovalenkosparc64-softmmu \
9402408a527Saurel32"
9410a8e90f4Spbrook    fi
9425327cf48Sbellard# the following are Linux specific
943831b7825Sths    if [ "$linux_user" = "yes" ] ; then
9442408a527Saurel32        target_list="${target_list}\
9452408a527Saurel32i386-linux-user \
9462408a527Saurel32x86_64-linux-user \
9472408a527Saurel32alpha-linux-user \
9482408a527Saurel32arm-linux-user \
9492408a527Saurel32armeb-linux-user \
9502408a527Saurel32cris-linux-user \
9512408a527Saurel32m68k-linux-user \
95272b675caSEdgar E. Iglesiasmicroblaze-linux-user \
9532408a527Saurel32mips-linux-user \
9542408a527Saurel32mipsel-linux-user \
9552408a527Saurel32ppc-linux-user \
9562408a527Saurel32ppc64-linux-user \
9572408a527Saurel32ppc64abi32-linux-user \
9582408a527Saurel32sh4-linux-user \
9592408a527Saurel32sh4eb-linux-user \
9602408a527Saurel32sparc-linux-user \
9612408a527Saurel32sparc64-linux-user \
9622408a527Saurel32sparc32plus-linux-user \
9632408a527Saurel32"
964831b7825Sths    fi
965831b7825Sths# the following are Darwin specific
966831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
9672408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
9685327cf48Sbellard    fi
96984778508Sblueswir1# the following are BSD specific
97084778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
97184778508Sblueswir1        target_list="${target_list}\
97231fc12dfSblueswir1i386-bsd-user \
97331fc12dfSblueswir1x86_64-bsd-user \
97431fc12dfSblueswir1sparc-bsd-user \
97584778508Sblueswir1sparc64-bsd-user \
97684778508Sblueswir1"
97784778508Sblueswir1    fi
9786e20a45fSbellardelse
979b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
9805327cf48Sbellardfi
9810a8e90f4Spbrookif test -z "$target_list" ; then
9820a8e90f4Spbrook    echo "No targets enabled"
9830a8e90f4Spbrook    exit 1
9840a8e90f4Spbrookfi
985f55fe278SPaolo Bonzini# see if system emulation was really requested
986f55fe278SPaolo Bonzinicase " $target_list " in
987f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
988f55fe278SPaolo Bonzini  ;;
989f55fe278SPaolo Bonzini  *) softmmu=no
990f55fe278SPaolo Bonzini  ;;
991f55fe278SPaolo Bonziniesac
9925327cf48Sbellard
993249247c9SJuan Quintelafeature_not_found() {
994249247c9SJuan Quintela  feature=$1
995249247c9SJuan Quintela
996249247c9SJuan Quintela  echo "ERROR"
997249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
9989332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
999249247c9SJuan Quintela  echo "ERROR"
1000249247c9SJuan Quintela  exit 1;
1001249247c9SJuan Quintela}
1002249247c9SJuan Quintela
10037d13299dSbellardif test -z "$cross_prefix" ; then
10047d13299dSbellard
10057d13299dSbellard# ---
10067d13299dSbellard# big/little endian test
10077d13299dSbellardcat > $TMPC << EOF
10087d13299dSbellard#include <inttypes.h>
10097d13299dSbellardint main(int argc, char ** argv){
10107d13299dSbellard        volatile uint32_t i=0x01234567;
10117d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
10127d13299dSbellard}
10137d13299dSbellardEOF
10147d13299dSbellard
101552166aa0SJuan Quintelaif compile_prog "" "" ; then
10167d13299dSbellard$TMPE && bigendian="yes"
10177d13299dSbellardelse
10187d13299dSbellardecho big/little test failed
10197d13299dSbellardfi
10207d13299dSbellard
10217d13299dSbellardelse
10227d13299dSbellard
10237d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1024ea8f20f8SJuan Quintelacase "$cpu" in
102524e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1026ea8f20f8SJuan Quintela    bigendian=yes
1027ea8f20f8SJuan Quintela  ;;
1028ea8f20f8SJuan Quintelaesac
10297d13299dSbellard
10307d13299dSbellardfi
10317d13299dSbellard
1032b6853697Sbellard# host long bits test
1033b6853697Sbellardhostlongbits="32"
1034ea8f20f8SJuan Quintelacase "$cpu" in
103524e804ecSAlexander Graf  x86_64|alpha|ia64|sparc64|ppc64|s390x)
1036ea8f20f8SJuan Quintela    hostlongbits=64
1037ea8f20f8SJuan Quintela  ;;
1038ea8f20f8SJuan Quintelaesac
1039b6853697Sbellard
1040b0a47e79SJuan Quintela
1041b0a47e79SJuan Quintela##########################################
1042b0a47e79SJuan Quintela# NPTL probe
1043b0a47e79SJuan Quintela
1044b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1045bd0c5661Spbrook  cat > $TMPC <<EOF
1046bd0c5661Spbrook#include <sched.h>
104730813ceaSpbrook#include <linux/futex.h>
1048bd0c5661Spbrookvoid foo()
1049bd0c5661Spbrook{
1050bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1051bd0c5661Spbrook#error bork
1052bd0c5661Spbrook#endif
1053bd0c5661Spbrook}
1054bd0c5661SpbrookEOF
1055bd0c5661Spbrook
105652166aa0SJuan Quintela  if compile_object ; then
1057b0a47e79SJuan Quintela    nptl=yes
1058bd0c5661Spbrook  else
1059b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1060b0a47e79SJuan Quintela      feature_not_found "nptl"
1061b0a47e79SJuan Quintela    fi
1062b0a47e79SJuan Quintela    nptl=no
1063b0a47e79SJuan Quintela  fi
1064bd0c5661Spbrookfi
1065bd0c5661Spbrook
106611d9f695Sbellard##########################################
1067ac62922eSbalrog# zlib check
1068ac62922eSbalrog
1069ac62922eSbalrogcat > $TMPC << EOF
1070ac62922eSbalrog#include <zlib.h>
1071ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1072ac62922eSbalrogEOF
107352166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1074ac62922eSbalrog    :
1075ac62922eSbalrogelse
1076ac62922eSbalrog    echo
1077ac62922eSbalrog    echo "Error: zlib check failed"
1078ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1079ac62922eSbalrog    echo
1080ac62922eSbalrog    exit 1
1081ac62922eSbalrogfi
1082ac62922eSbalrog
1083ac62922eSbalrog##########################################
1084e37630caSaliguori# xen probe
1085e37630caSaliguori
1086fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1087b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1088e37630caSaliguori  cat > $TMPC <<EOF
1089e37630caSaliguori#include <xenctrl.h>
1090e37630caSaliguori#include <xs.h>
1091df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1092e37630caSaliguoriEOF
109352166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1094fc321b4bSJuan Quintela    xen=yes
10953efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
1096e37630caSaliguori  else
1097fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1098fc321b4bSJuan Quintela      feature_not_found "xen"
1099fc321b4bSJuan Quintela    fi
1100fc321b4bSJuan Quintela    xen=no
1101e37630caSaliguori  fi
1102e37630caSaliguorifi
1103e37630caSaliguori
1104e37630caSaliguori##########################################
1105f91672e5SPaolo Bonzini# pkgconfig probe
1106f91672e5SPaolo Bonzini
1107f91672e5SPaolo Bonzinipkgconfig="${cross_prefix}pkg-config"
11080dba6195SLoïc Minierif ! has $pkgconfig; then
1109f91672e5SPaolo Bonzini  # likely not cross compiling, or hope for the best
1110f91672e5SPaolo Bonzini  pkgconfig=pkg-config
1111f91672e5SPaolo Bonzinifi
1112f91672e5SPaolo Bonzini
1113f91672e5SPaolo Bonzini##########################################
1114dfffc653SJuan Quintela# Sparse probe
1115dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
11160dba6195SLoïc Minier  if has cgcc; then
1117dfffc653SJuan Quintela    sparse=yes
1118dfffc653SJuan Quintela  else
1119dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1120dfffc653SJuan Quintela      feature_not_found "sparse"
1121dfffc653SJuan Quintela    fi
1122dfffc653SJuan Quintela    sparse=no
1123dfffc653SJuan Quintela  fi
1124dfffc653SJuan Quintelafi
1125dfffc653SJuan Quintela
1126dfffc653SJuan Quintela##########################################
112711d9f695Sbellard# SDL probe
112811d9f695Sbellard
1129fec0e3e8SStefan Weil# Look for sdl configuration program (pkg-config or sdl-config).
1130fec0e3e8SStefan Weil# Prefer variant with cross prefix if cross compiling,
1131fec0e3e8SStefan Weil# and favour pkg-config with sdl over sdl-config.
1132fec0e3e8SStefan Weilif test -n "$cross_prefix" -a $pkgconfig != pkg-config && \
1133fec0e3e8SStefan Weil     $pkgconfig sdl --modversion >/dev/null 2>&1; then
1134fec0e3e8SStefan Weil  sdlconfig="$pkgconfig sdl"
1135fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1136fec0e3e8SStefan Weilelif test -n "$cross_prefix" && has ${cross_prefix}sdl-config; then
1137fec0e3e8SStefan Weil  sdlconfig="${cross_prefix}sdl-config"
1138fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1139fec0e3e8SStefan Weilelif $pkgconfig sdl --modversion >/dev/null 2>&1; then
11409316f803SPaolo Bonzini  sdlconfig="$pkgconfig sdl"
11419316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
11420dba6195SLoïc Minierelif has sdl-config; then
11439316f803SPaolo Bonzini  sdlconfig='sdl-config'
11449316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1145a0dfd8a4SLoïc Minierelse
1146a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1147a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1148a0dfd8a4SLoïc Minier  fi
1149a0dfd8a4SLoïc Minier  sdl=no
11509316f803SPaolo Bonzinifi
115111d9f695Sbellard
11529316f803SPaolo Bonzinisdl_too_old=no
1153c4198157SJuan Quintelaif test "$sdl" != "no" ; then
115411d9f695Sbellard  cat > $TMPC << EOF
115511d9f695Sbellard#include <SDL.h>
115611d9f695Sbellard#undef main /* We don't want SDL to override our main() */
115711d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
115811d9f695SbellardEOF
11599316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
116074f42e18STeLeMan  if test "$static" = "yes" ; then
116174f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
116274f42e18STeLeMan  else
11639316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
116474f42e18STeLeMan  fi
116552166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
116611d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
116711d9f695Sbellard      sdl_too_old=yes
116811d9f695Sbellard    else
1169fd677642Sths      if test "$cocoa" = "no" ; then
117011d9f695Sbellard        sdl=yes
117111d9f695Sbellard      fi
1172fd677642Sths    fi
11737c1f25b4Sbellard
117467c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
11751ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
117667c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1177f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1178f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
117911d9f695Sbellard      fi
118052166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
11811ac88f28SJuan Quintela	:
11821ac88f28SJuan Quintela      else
11831ac88f28SJuan Quintela        sdl=no
11847c1f25b4Sbellard      fi
11857c1f25b4Sbellard    fi # static link
1186c4198157SJuan Quintela  else # sdl not found
1187c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1188c4198157SJuan Quintela      feature_not_found "sdl"
1189c4198157SJuan Quintela    fi
1190c4198157SJuan Quintela    sdl=no
11917c1f25b4Sbellard  fi # sdl compile test
1192fd677642Sthsfi
119311d9f695Sbellard
11945368a422Saliguoriif test "$sdl" = "yes" ; then
11955368a422Saliguori  cat > $TMPC <<EOF
11965368a422Saliguori#include <SDL.h>
11975368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
11985368a422Saliguori#include <X11/XKBlib.h>
11995368a422Saliguori#else
12005368a422Saliguori#error No x11 support
12015368a422Saliguori#endif
12025368a422Saliguoriint main(void) { return 0; }
12035368a422SaliguoriEOF
120452166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1205681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
12065368a422Saliguori  fi
120707d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
120807d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
120907d9ac44SJuan Quintela  fi
12100705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
12115368a422Saliguorifi
12125368a422Saliguori
12138f28f3fbSths##########################################
12148d5d2d4cSths# VNC TLS detection
12151be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1216ae6b5e5aSaliguori  cat > $TMPC <<EOF
1217ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1218ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1219ae6b5e5aSaliguoriEOF
1220f91672e5SPaolo Bonzini  vnc_tls_cflags=`$pkgconfig --cflags gnutls 2> /dev/null`
1221f91672e5SPaolo Bonzini  vnc_tls_libs=`$pkgconfig --libs gnutls 2> /dev/null`
122252166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
12231be10ad2SJuan Quintela    vnc_tls=yes
1224a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1225ae6b5e5aSaliguori  else
12261be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
12271be10ad2SJuan Quintela      feature_not_found "vnc-tls"
12281be10ad2SJuan Quintela    fi
12291be10ad2SJuan Quintela    vnc_tls=no
12308d5d2d4cSths  fi
12318d5d2d4cSthsfi
12328d5d2d4cSths
12338d5d2d4cSths##########################################
12342f9606b3Saliguori# VNC SASL detection
12353aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
12362f9606b3Saliguori  cat > $TMPC <<EOF
12372f9606b3Saliguori#include <sasl/sasl.h>
12382f9606b3Saliguori#include <stdio.h>
12392f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
12402f9606b3SaliguoriEOF
12412f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
12422f9606b3Saliguori  vnc_sasl_cflags=""
12432f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
124452166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1245ea784e3bSJuan Quintela    vnc_sasl=yes
1246fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
12472f9606b3Saliguori  else
1248ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1249ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1250ea784e3bSJuan Quintela    fi
1251ea784e3bSJuan Quintela    vnc_sasl=no
12522f9606b3Saliguori  fi
12532f9606b3Saliguorifi
12542f9606b3Saliguori
12552f9606b3Saliguori##########################################
1256*2f6f5c7aSCorentin Chary# VNC JPEG detection
1257*2f6f5c7aSCorentin Charyif test "$vnc_jpeg" = "yes" ; then
1258*2f6f5c7aSCorentin Charycat > $TMPC <<EOF
1259*2f6f5c7aSCorentin Chary#include <stdio.h>
1260*2f6f5c7aSCorentin Chary#include <jpeglib.h>
1261*2f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
1262*2f6f5c7aSCorentin CharyEOF
1263*2f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
1264*2f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
1265*2f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
1266*2f6f5c7aSCorentin Chary    vnc_jpeg=yes
1267*2f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
1268*2f6f5c7aSCorentin Chary  else
1269*2f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
1270*2f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
1271*2f6f5c7aSCorentin Chary    fi
1272*2f6f5c7aSCorentin Chary    vnc_jpeg=no
1273*2f6f5c7aSCorentin Chary  fi
1274*2f6f5c7aSCorentin Charyfi
1275*2f6f5c7aSCorentin Chary
1276*2f6f5c7aSCorentin Chary##########################################
127776655d6dSaliguori# fnmatch() probe, used for ACL routines
127876655d6dSaliguorifnmatch="no"
127976655d6dSaliguoricat > $TMPC << EOF
128076655d6dSaliguori#include <fnmatch.h>
128176655d6dSaliguoriint main(void)
128276655d6dSaliguori{
128376655d6dSaliguori    fnmatch("foo", "foo", 0);
128476655d6dSaliguori    return 0;
128576655d6dSaliguori}
128676655d6dSaliguoriEOF
128752166aa0SJuan Quintelaif compile_prog "" "" ; then
128876655d6dSaliguori   fnmatch="yes"
128976655d6dSaliguorifi
129076655d6dSaliguori
129176655d6dSaliguori##########################################
1292ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1293ee682d27SStefan Weilif test "$uuid" != "no" ; then
1294ee682d27SStefan Weil  uuid_libs="-luuid"
1295ee682d27SStefan Weil  cat > $TMPC << EOF
1296ee682d27SStefan Weil#include <uuid/uuid.h>
1297ee682d27SStefan Weilint main(void)
1298ee682d27SStefan Weil{
1299ee682d27SStefan Weil    uuid_t my_uuid;
1300ee682d27SStefan Weil    uuid_generate(my_uuid);
1301ee682d27SStefan Weil    return 0;
1302ee682d27SStefan Weil}
1303ee682d27SStefan WeilEOF
1304ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1305ee682d27SStefan Weil    uuid="yes"
1306ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1307ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1308ee682d27SStefan Weil  else
1309ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1310ee682d27SStefan Weil      feature_not_found "uuid"
1311ee682d27SStefan Weil    fi
1312ee682d27SStefan Weil    uuid=no
1313ee682d27SStefan Weil  fi
1314ee682d27SStefan Weilfi
1315ee682d27SStefan Weil
1316ee682d27SStefan Weil##########################################
13178a16d273Sths# vde libraries probe
1318dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
13194baae0acSJuan Quintela  vde_libs="-lvdeplug"
13208a16d273Sths  cat > $TMPC << EOF
13218a16d273Sths#include <libvdeplug.h>
13224a7f0e06Spbrookint main(void)
13234a7f0e06Spbrook{
13244a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
13254a7f0e06Spbrook    vde_open("", "", &a);
13264a7f0e06Spbrook    return 0;
13274a7f0e06Spbrook}
13288a16d273SthsEOF
132952166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
13304baae0acSJuan Quintela    vde=yes
13318e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
13328e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1333dfb278bdSJuan Quintela  else
1334dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1335dfb278bdSJuan Quintela      feature_not_found "vde"
1336dfb278bdSJuan Quintela    fi
1337dfb278bdSJuan Quintela    vde=no
13388a16d273Sths  fi
13398a16d273Sthsfi
13408a16d273Sths
13418a16d273Sths##########################################
1342c2de5c91Smalc# Sound support libraries probe
13438f28f3fbSths
1344c2de5c91Smalcaudio_drv_probe()
1345c2de5c91Smalc{
1346c2de5c91Smalc    drv=$1
1347c2de5c91Smalc    hdr=$2
1348c2de5c91Smalc    lib=$3
1349c2de5c91Smalc    exp=$4
1350c2de5c91Smalc    cfl=$5
13518f28f3fbSths        cat > $TMPC << EOF
1352c2de5c91Smalc#include <$hdr>
1353c2de5c91Smalcint main(void) { $exp }
13548f28f3fbSthsEOF
135552166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
13568f28f3fbSths        :
13578f28f3fbSths    else
13588f28f3fbSths        echo
1359c2de5c91Smalc        echo "Error: $drv check failed"
1360c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
13618f28f3fbSths        echo
13628f28f3fbSths        exit 1
13638f28f3fbSths    fi
1364c2de5c91Smalc}
1365c2de5c91Smalc
13662fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1367c2de5c91Smalcfor drv in $audio_drv_list; do
1368c2de5c91Smalc    case $drv in
1369c2de5c91Smalc    alsa)
1370c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1371c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1372a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1373c2de5c91Smalc    ;;
1374c2de5c91Smalc
1375c2de5c91Smalc    fmod)
1376c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1377c2de5c91Smalc        echo
1378c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1379c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1380c2de5c91Smalc        echo
1381c2de5c91Smalc        exit 1
13828f28f3fbSths    fi
1383c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1384a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1385c2de5c91Smalc    ;;
1386c2de5c91Smalc
1387c2de5c91Smalc    esd)
1388c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1389a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
139067f86e8eSJuan Quintela    audio_pt_int="yes"
1391c2de5c91Smalc    ;;
1392b8e59f18Smalc
1393b8e59f18Smalc    pa)
1394493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1395b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1396493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
139767f86e8eSJuan Quintela    audio_pt_int="yes"
1398b8e59f18Smalc    ;;
1399b8e59f18Smalc
1400997e690aSJuan Quintela    coreaudio)
1401997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1402997e690aSJuan Quintela    ;;
1403997e690aSJuan Quintela
1404a4bf6780SJuan Quintela    dsound)
1405a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1406d5631638Smalc      audio_win_int="yes"
1407a4bf6780SJuan Quintela    ;;
1408a4bf6780SJuan Quintela
1409a4bf6780SJuan Quintela    oss)
1410a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1411a4bf6780SJuan Quintela    ;;
1412a4bf6780SJuan Quintela
1413a4bf6780SJuan Quintela    sdl|wav)
14142f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
14152f6a1ab0Sblueswir1    ;;
14162f6a1ab0Sblueswir1
1417d5631638Smalc    winwave)
1418d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1419d5631638Smalc      audio_win_int="yes"
1420d5631638Smalc    ;;
1421d5631638Smalc
1422e4c63a6aSmalc    *)
14231c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1424e4c63a6aSmalc        echo
1425e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1426e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1427e4c63a6aSmalc        echo
1428e4c63a6aSmalc        exit 1
1429e4c63a6aSmalc    }
1430e4c63a6aSmalc    ;;
1431c2de5c91Smalc    esac
1432c2de5c91Smalcdone
14338f28f3fbSths
14344d3b6f6eSbalrog##########################################
14352e4d9fb1Saurel32# BrlAPI probe
14362e4d9fb1Saurel32
14374ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1438eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
14392e4d9fb1Saurel32  cat > $TMPC << EOF
14402e4d9fb1Saurel32#include <brlapi.h>
14412e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
14422e4d9fb1Saurel32EOF
144352166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
14442e4d9fb1Saurel32    brlapi=yes
1445264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
14464ffcedb6SJuan Quintela  else
14474ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
14484ffcedb6SJuan Quintela      feature_not_found "brlapi"
14494ffcedb6SJuan Quintela    fi
14504ffcedb6SJuan Quintela    brlapi=no
1451eb82284fSJuan Quintela  fi
1452eb82284fSJuan Quintelafi
14532e4d9fb1Saurel32
14542e4d9fb1Saurel32##########################################
14554d3b6f6eSbalrog# curses probe
14564f78ef9aSJuan Quintelacurses_list="-lncurses -lcurses"
14574d3b6f6eSbalrog
1458c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1459c584a6d0SJuan Quintela  curses_found=no
14604d3b6f6eSbalrog  cat > $TMPC << EOF
14614d3b6f6eSbalrog#include <curses.h>
14625a8ff3aaSblueswir1#ifdef __OpenBSD__
14635a8ff3aaSblueswir1#define resize_term resizeterm
14645a8ff3aaSblueswir1#endif
14655a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
14664d3b6f6eSbalrogEOF
14674f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
14684f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1469c584a6d0SJuan Quintela      curses_found=yes
14704f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
14714f78ef9aSJuan Quintela      break
14724d3b6f6eSbalrog    fi
14734f78ef9aSJuan Quintela  done
1474c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1475c584a6d0SJuan Quintela    curses=yes
1476c584a6d0SJuan Quintela  else
1477c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1478c584a6d0SJuan Quintela      feature_not_found "curses"
1479c584a6d0SJuan Quintela    fi
1480c584a6d0SJuan Quintela    curses=no
1481c584a6d0SJuan Quintela  fi
14824f78ef9aSJuan Quintelafi
14834d3b6f6eSbalrog
1484414f0dabSblueswir1##########################################
1485769ce76dSAlexander Graf# curl probe
1486769ce76dSAlexander Graf
14874e2b0658SPaolo Bonziniif $pkgconfig libcurl --modversion >/dev/null 2>&1; then
14884e2b0658SPaolo Bonzini  curlconfig="$pkgconfig libcurl"
14894e2b0658SPaolo Bonzinielse
14904e2b0658SPaolo Bonzini  curlconfig=curl-config
14914e2b0658SPaolo Bonzinifi
14924e2b0658SPaolo Bonzini
1493788c8196SJuan Quintelaif test "$curl" != "no" ; then
1494769ce76dSAlexander Graf  cat > $TMPC << EOF
1495769ce76dSAlexander Graf#include <curl/curl.h>
1496769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1497769ce76dSAlexander GrafEOF
14984e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
14994e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1500b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1501769ce76dSAlexander Graf    curl=yes
1502f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1503f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1504788c8196SJuan Quintela  else
1505788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1506788c8196SJuan Quintela      feature_not_found "curl"
1507788c8196SJuan Quintela    fi
1508788c8196SJuan Quintela    curl=no
1509769ce76dSAlexander Graf  fi
1510769ce76dSAlexander Graffi # test "$curl"
1511769ce76dSAlexander Graf
1512769ce76dSAlexander Graf##########################################
15135495ed11SLuiz Capitulino# check framework probe
15145495ed11SLuiz Capitulino
15155495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
15165495ed11SLuiz Capitulino  cat > $TMPC << EOF
15175495ed11SLuiz Capitulino#include <check.h>
15185495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
15195495ed11SLuiz CapitulinoEOF
1520f91672e5SPaolo Bonzini  check_libs=`$pkgconfig --libs check`
15215495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
15225495ed11SLuiz Capitulino    check_utests=yes
15235495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
15245495ed11SLuiz Capitulino  else
15255495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
15265495ed11SLuiz Capitulino      feature_not_found "check"
15275495ed11SLuiz Capitulino    fi
15285495ed11SLuiz Capitulino    check_utests=no
15295495ed11SLuiz Capitulino  fi
15305495ed11SLuiz Capitulinofi # test "$check_utests"
15315495ed11SLuiz Capitulino
15325495ed11SLuiz Capitulino##########################################
1533fb599c9aSbalrog# bluez support probe
1534a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1535e820e3f4Sbalrog  cat > $TMPC << EOF
1536e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1537e820e3f4Sbalrogint main(void) { return bt_error(0); }
1538e820e3f4SbalrogEOF
1539f91672e5SPaolo Bonzini  bluez_cflags=`$pkgconfig --cflags bluez 2> /dev/null`
1540f91672e5SPaolo Bonzini  bluez_libs=`$pkgconfig --libs bluez 2> /dev/null`
154152166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1542a20a6f46SJuan Quintela    bluez=yes
1543e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1544e820e3f4Sbalrog  else
1545a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1546a20a6f46SJuan Quintela      feature_not_found "bluez"
1547a20a6f46SJuan Quintela    fi
1548e820e3f4Sbalrog    bluez="no"
1549e820e3f4Sbalrog  fi
1550fb599c9aSbalrogfi
1551fb599c9aSbalrog
1552fb599c9aSbalrog##########################################
15537ba1e619Saliguori# kvm probe
1554b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
15557ba1e619Saliguori    cat > $TMPC <<EOF
15567ba1e619Saliguori#include <linux/kvm.h>
15579fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
15587ba1e619Saliguori#error Invalid KVM version
15597ba1e619Saliguori#endif
15609fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
15619fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
15629fd8d8d7Saliguori#endif
15639fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
15649fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
15659fd8d8d7Saliguori#endif
15669fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
15679fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
15689fd8d8d7Saliguori#endif
15697ba1e619Saliguoriint main(void) { return 0; }
15707ba1e619SaliguoriEOF
1571eac30262Saliguori  if test "$kerneldir" != "" ; then
1572eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
15738444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
15748444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
15758444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1576406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1577406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
15780e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
15790e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
15808444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
15818444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
15828444eb6eSaliguori      fi
1583eac30262Saliguori  else
1584f038e8f7SStefan Weil    kvm_cflags=`$pkgconfig --cflags kvm-kmod 2>/dev/null`
1585eac30262Saliguori  fi
158652166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1587b31a0277SJuan Quintela    kvm=yes
1588dae5079aSJan Kiszka    cat > $TMPC <<EOF
1589dae5079aSJan Kiszka#include <linux/kvm_para.h>
1590dae5079aSJan Kiszkaint main(void) { return 0; }
1591dae5079aSJan KiszkaEOF
1592dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1593dae5079aSJan Kiszka      kvm_para=yes
1594dae5079aSJan Kiszka    fi
15957ba1e619Saliguori  else
1596b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
15970dba6195SLoïc Minier      if has awk && has grep; then
1598a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
15999fd8d8d7Saliguori	| grep "error: " \
16009fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
16019fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1602b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1603168ccc11SJan Kiszka      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1604168ccc11SJan Kiszka  recent kvm-kmod from http://sourceforge.net/projects/kvm."
16059fd8d8d7Saliguori        fi
16069fd8d8d7Saliguori      fi
1607b31a0277SJuan Quintela      feature_not_found "kvm"
1608b31a0277SJuan Quintela    fi
1609b31a0277SJuan Quintela    kvm=no
16107ba1e619Saliguori  fi
16117ba1e619Saliguorifi
16127ba1e619Saliguori
16137ba1e619Saliguori##########################################
1614d5970055SMichael S. Tsirkin# test for vhost net
1615d5970055SMichael S. Tsirkin
1616d5970055SMichael S. Tsirkinif test "$vhost_net" != "no"; then
1617d5970055SMichael S. Tsirkin    if test "$kvm" != "no"; then
1618d5970055SMichael S. Tsirkin            cat > $TMPC <<EOF
1619d5970055SMichael S. Tsirkin    #include <linux/vhost.h>
1620d5970055SMichael S. Tsirkin    int main(void) { return 0; }
1621d5970055SMichael S. TsirkinEOF
1622d5970055SMichael S. Tsirkin            if compile_prog "$kvm_cflags" "" ; then
1623d5970055SMichael S. Tsirkin                vhost_net=yes
1624d5970055SMichael S. Tsirkin            else
1625d5970055SMichael S. Tsirkin                if test "$vhost_net" = "yes" ; then
1626d5970055SMichael S. Tsirkin                    feature_not_found "vhost-net"
1627d5970055SMichael S. Tsirkin                fi
1628d5970055SMichael S. Tsirkin                vhost_net=no
1629d5970055SMichael S. Tsirkin            fi
1630d5970055SMichael S. Tsirkin    else
1631d5970055SMichael S. Tsirkin            if test "$vhost_net" = "yes" ; then
16324021d247SAurelien Jarno                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1633d5970055SMichael S. Tsirkin                feature_not_found "vhost-net"
1634d5970055SMichael S. Tsirkin            fi
1635d5970055SMichael S. Tsirkin            vhost_net=no
1636d5970055SMichael S. Tsirkin    fi
1637d5970055SMichael S. Tsirkinfi
1638d5970055SMichael S. Tsirkin
1639d5970055SMichael S. Tsirkin##########################################
1640e5d355d1Saliguori# pthread probe
1641de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
16423c529d93Saliguori
1643e5d355d1Saliguoripthread=no
1644414f0dabSblueswir1cat > $TMPC << EOF
16453c529d93Saliguori#include <pthread.h>
1646de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1647414f0dabSblueswir1EOF
1648de65fe0fSSebastian Herbsztfor pthread_lib in $PTHREADLIBS_LIST; do
164952166aa0SJuan Quintela  if compile_prog "" "$pthread_lib" ; then
1650e5d355d1Saliguori    pthread=yes
16515572b539SJuan Quintela    LIBS="$pthread_lib $LIBS"
1652de65fe0fSSebastian Herbszt    break
1653414f0dabSblueswir1  fi
1654de65fe0fSSebastian Herbsztdone
1655414f0dabSblueswir1
16564617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
16574dd75c70SChristoph Hellwig  echo
16584dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
16594dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
16604dd75c70SChristoph Hellwig  echo
16614dd75c70SChristoph Hellwig  exit 1
1662e5d355d1Saliguorifi
1663e5d355d1Saliguori
1664bf9298b9Saliguori##########################################
16655c6c3a6cSChristoph Hellwig# linux-aio probe
16665c6c3a6cSChristoph Hellwig
16675c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
16685c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
16695c6c3a6cSChristoph Hellwig#include <libaio.h>
16705c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
16715c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
16725c6c3a6cSChristoph HellwigEOF
16735c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
16745c6c3a6cSChristoph Hellwig    linux_aio=yes
1675048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1676048d179fSPaul Brook    libs_tools="$libs_tools -laio"
16775c6c3a6cSChristoph Hellwig  else
16785c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
16795c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
16805c6c3a6cSChristoph Hellwig    fi
16813cfcae3cSLuiz Capitulino    linux_aio=no
16825c6c3a6cSChristoph Hellwig  fi
16835c6c3a6cSChristoph Hellwigfi
16845c6c3a6cSChristoph Hellwig
16855c6c3a6cSChristoph Hellwig##########################################
1686758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1687758e8e38SVenkateswararao Jujjuri (JV)
1688758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1689758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1690758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1691758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
1692758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
1693758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1694758e8e38SVenkateswararao Jujjuri (JV)EOF
1695758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
1696758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1697758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
1698758e8e38SVenkateswararao Jujjuri (JV)  else
1699758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1700758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1701758e8e38SVenkateswararao Jujjuri (JV)    fi
1702758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1703758e8e38SVenkateswararao Jujjuri (JV)  fi
1704758e8e38SVenkateswararao Jujjuri (JV)fi
1705758e8e38SVenkateswararao Jujjuri (JV)
1706758e8e38SVenkateswararao Jujjuri (JV)##########################################
1707bf9298b9Saliguori# iovec probe
1708bf9298b9Saliguoricat > $TMPC <<EOF
1709db34f0b3Sblueswir1#include <sys/types.h>
1710bf9298b9Saliguori#include <sys/uio.h>
1711db34f0b3Sblueswir1#include <unistd.h>
1712bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1713bf9298b9SaliguoriEOF
1714bf9298b9Saliguoriiovec=no
171552166aa0SJuan Quintelaif compile_prog "" "" ; then
1716bf9298b9Saliguori  iovec=yes
1717bf9298b9Saliguorifi
1718bf9298b9Saliguori
1719f652e6afSaurel32##########################################
1720ceb42de8Saliguori# preadv probe
1721ceb42de8Saliguoricat > $TMPC <<EOF
1722ceb42de8Saliguori#include <sys/types.h>
1723ceb42de8Saliguori#include <sys/uio.h>
1724ceb42de8Saliguori#include <unistd.h>
1725ceb42de8Saliguoriint main(void) { preadv; }
1726ceb42de8SaliguoriEOF
1727ceb42de8Saliguoripreadv=no
172852166aa0SJuan Quintelaif compile_prog "" "" ; then
1729ceb42de8Saliguori  preadv=yes
1730ceb42de8Saliguorifi
1731ceb42de8Saliguori
1732ceb42de8Saliguori##########################################
1733f652e6afSaurel32# fdt probe
17342df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1735b41af4baSJuan Quintela  fdt_libs="-lfdt"
1736f652e6afSaurel32  cat > $TMPC << EOF
1737f652e6afSaurel32int main(void) { return 0; }
1738f652e6afSaurel32EOF
173952166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1740f652e6afSaurel32    fdt=yes
1741e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
17422df87df7SJuan Quintela  else
17432df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
17442df87df7SJuan Quintela      feature_not_found "fdt"
17452df87df7SJuan Quintela    fi
17462df87df7SJuan Quintela    fdt=no
1747f652e6afSaurel32  fi
1748f652e6afSaurel32fi
1749f652e6afSaurel32
17503b3f24adSaurel32#
17513b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
17523b3f24adSaurel32# emulator.  This is done because older glibc versions don't
17533b3f24adSaurel32# have syscall stubs for these implemented.
17543b3f24adSaurel32#
17553b3f24adSaurel32atfile=no
17563b3f24adSaurel32cat > $TMPC << EOF
17573b3f24adSaurel32#define _ATFILE_SOURCE
17583b3f24adSaurel32#include <sys/types.h>
17593b3f24adSaurel32#include <fcntl.h>
17603b3f24adSaurel32#include <unistd.h>
17613b3f24adSaurel32
17623b3f24adSaurel32int
17633b3f24adSaurel32main(void)
17643b3f24adSaurel32{
17653b3f24adSaurel32	/* try to unlink nonexisting file */
17663b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
17673b3f24adSaurel32}
17683b3f24adSaurel32EOF
176952166aa0SJuan Quintelaif compile_prog "" "" ; then
17703b3f24adSaurel32  atfile=yes
17713b3f24adSaurel32fi
17723b3f24adSaurel32
177339386ac7Saurel32# Check for inotify functions when we are building linux-user
17743b3f24adSaurel32# emulator.  This is done because older glibc versions don't
17753b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
17763b3f24adSaurel32# don't provide them even if kernel supports them.
17773b3f24adSaurel32#
17783b3f24adSaurel32inotify=no
17793b3f24adSaurel32cat > $TMPC << EOF
17803b3f24adSaurel32#include <sys/inotify.h>
17813b3f24adSaurel32
17823b3f24adSaurel32int
17833b3f24adSaurel32main(void)
17843b3f24adSaurel32{
17853b3f24adSaurel32	/* try to start inotify */
17868690e420Saurel32	return inotify_init();
17873b3f24adSaurel32}
17883b3f24adSaurel32EOF
178952166aa0SJuan Quintelaif compile_prog "" "" ; then
17903b3f24adSaurel32  inotify=yes
17913b3f24adSaurel32fi
17923b3f24adSaurel32
1793c05c7a73SRiku Voipioinotify1=no
1794c05c7a73SRiku Voipiocat > $TMPC << EOF
1795c05c7a73SRiku Voipio#include <sys/inotify.h>
1796c05c7a73SRiku Voipio
1797c05c7a73SRiku Voipioint
1798c05c7a73SRiku Voipiomain(void)
1799c05c7a73SRiku Voipio{
1800c05c7a73SRiku Voipio    /* try to start inotify */
1801c05c7a73SRiku Voipio    return inotify_init1(0);
1802c05c7a73SRiku Voipio}
1803c05c7a73SRiku VoipioEOF
1804c05c7a73SRiku Voipioif compile_prog "" "" ; then
1805c05c7a73SRiku Voipio  inotify1=yes
1806c05c7a73SRiku Voipiofi
1807c05c7a73SRiku Voipio
1808ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1809ebc996f3SRiku Voipioutimens=no
1810ebc996f3SRiku Voipiocat > $TMPC << EOF
1811ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1812ebc996f3SRiku Voipio#define _GNU_SOURCE
1813ebc996f3SRiku Voipio#include <stddef.h>
1814ebc996f3SRiku Voipio#include <fcntl.h>
1815ebc996f3SRiku Voipio
1816ebc996f3SRiku Voipioint main(void)
1817ebc996f3SRiku Voipio{
1818ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1819ebc996f3SRiku Voipio    futimens(0, NULL);
1820ebc996f3SRiku Voipio    return 0;
1821ebc996f3SRiku Voipio}
1822ebc996f3SRiku VoipioEOF
182352166aa0SJuan Quintelaif compile_prog "" "" ; then
1824ebc996f3SRiku Voipio  utimens=yes
1825ebc996f3SRiku Voipiofi
1826ebc996f3SRiku Voipio
1827099d6b0fSRiku Voipio# check if pipe2 is there
1828099d6b0fSRiku Voipiopipe2=no
1829099d6b0fSRiku Voipiocat > $TMPC << EOF
1830099d6b0fSRiku Voipio#define _GNU_SOURCE
1831099d6b0fSRiku Voipio#include <unistd.h>
1832099d6b0fSRiku Voipio#include <fcntl.h>
1833099d6b0fSRiku Voipio
1834099d6b0fSRiku Voipioint main(void)
1835099d6b0fSRiku Voipio{
1836099d6b0fSRiku Voipio    int pipefd[2];
1837099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1838099d6b0fSRiku Voipio    return 0;
1839099d6b0fSRiku Voipio}
1840099d6b0fSRiku VoipioEOF
184152166aa0SJuan Quintelaif compile_prog "" "" ; then
1842099d6b0fSRiku Voipio  pipe2=yes
1843099d6b0fSRiku Voipiofi
1844099d6b0fSRiku Voipio
184540ff6d7eSKevin Wolf# check if accept4 is there
184640ff6d7eSKevin Wolfaccept4=no
184740ff6d7eSKevin Wolfcat > $TMPC << EOF
184840ff6d7eSKevin Wolf#define _GNU_SOURCE
184940ff6d7eSKevin Wolf#include <sys/socket.h>
185040ff6d7eSKevin Wolf#include <stddef.h>
185140ff6d7eSKevin Wolf
185240ff6d7eSKevin Wolfint main(void)
185340ff6d7eSKevin Wolf{
185440ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
185540ff6d7eSKevin Wolf    return 0;
185640ff6d7eSKevin Wolf}
185740ff6d7eSKevin WolfEOF
185840ff6d7eSKevin Wolfif compile_prog "" "" ; then
185940ff6d7eSKevin Wolf  accept4=yes
186040ff6d7eSKevin Wolffi
186140ff6d7eSKevin Wolf
18623ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
18633ce34dfbSvibisreenivasansplice=no
18643ce34dfbSvibisreenivasancat > $TMPC << EOF
18653ce34dfbSvibisreenivasan#define _GNU_SOURCE
18663ce34dfbSvibisreenivasan#include <unistd.h>
18673ce34dfbSvibisreenivasan#include <fcntl.h>
18683ce34dfbSvibisreenivasan#include <limits.h>
18693ce34dfbSvibisreenivasan
18703ce34dfbSvibisreenivasanint main(void)
18713ce34dfbSvibisreenivasan{
18723ce34dfbSvibisreenivasan    int len, fd;
18733ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
18743ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
18753ce34dfbSvibisreenivasan    return 0;
18763ce34dfbSvibisreenivasan}
18773ce34dfbSvibisreenivasanEOF
187852166aa0SJuan Quintelaif compile_prog "" "" ; then
18793ce34dfbSvibisreenivasan  splice=yes
18803ce34dfbSvibisreenivasanfi
18813ce34dfbSvibisreenivasan
1882c2882b96SRiku Voipio# check if eventfd is supported
1883c2882b96SRiku Voipioeventfd=no
1884c2882b96SRiku Voipiocat > $TMPC << EOF
1885c2882b96SRiku Voipio#include <sys/eventfd.h>
1886c2882b96SRiku Voipio
1887c2882b96SRiku Voipioint main(void)
1888c2882b96SRiku Voipio{
1889c2882b96SRiku Voipio    int efd = eventfd(0, 0);
1890c2882b96SRiku Voipio    return 0;
1891c2882b96SRiku Voipio}
1892c2882b96SRiku VoipioEOF
1893c2882b96SRiku Voipioif compile_prog "" "" ; then
1894c2882b96SRiku Voipio  eventfd=yes
1895c2882b96SRiku Voipiofi
1896c2882b96SRiku Voipio
1897d0927938SUlrich Hecht# check for fallocate
1898d0927938SUlrich Hechtfallocate=no
1899d0927938SUlrich Hechtcat > $TMPC << EOF
1900d0927938SUlrich Hecht#include <fcntl.h>
1901d0927938SUlrich Hecht
1902d0927938SUlrich Hechtint main(void)
1903d0927938SUlrich Hecht{
1904d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
1905d0927938SUlrich Hecht    return 0;
1906d0927938SUlrich Hecht}
1907d0927938SUlrich HechtEOF
1908be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
1909d0927938SUlrich Hecht  fallocate=yes
1910d0927938SUlrich Hechtfi
1911d0927938SUlrich Hecht
1912d0927938SUlrich Hecht# check for dup3
1913d0927938SUlrich Hechtdup3=no
1914d0927938SUlrich Hechtcat > $TMPC << EOF
1915d0927938SUlrich Hecht#include <unistd.h>
1916d0927938SUlrich Hecht
1917d0927938SUlrich Hechtint main(void)
1918d0927938SUlrich Hecht{
1919d0927938SUlrich Hecht    dup3(0, 0, 0);
1920d0927938SUlrich Hecht    return 0;
1921d0927938SUlrich Hecht}
1922d0927938SUlrich HechtEOF
192378f5d726SJan Kiszkaif compile_prog "" "" ; then
1924d0927938SUlrich Hecht  dup3=yes
1925d0927938SUlrich Hechtfi
1926d0927938SUlrich Hecht
1927cc8ae6deSpbrook# Check if tools are available to build documentation.
1928a25dba17SJuan Quintelaif test "$docs" != "no" ; then
192901668d98SStefan Weil  if has makeinfo && has pod2man; then
1930a25dba17SJuan Quintela    docs=yes
193183a3ab8bSJuan Quintela  else
1932a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
1933a25dba17SJuan Quintela      feature_not_found "docs"
193483a3ab8bSJuan Quintela    fi
1935a25dba17SJuan Quintela    docs=no
193683a3ab8bSJuan Quintela  fi
1937cc8ae6deSpbrookfi
1938cc8ae6deSpbrook
1939f514f41cSStefan Weil# Search for bswap_32 function
19406ae9a1f4SJuan Quintelabyteswap_h=no
19416ae9a1f4SJuan Quintelacat > $TMPC << EOF
19426ae9a1f4SJuan Quintela#include <byteswap.h>
19436ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
19446ae9a1f4SJuan QuintelaEOF
194552166aa0SJuan Quintelaif compile_prog "" "" ; then
19466ae9a1f4SJuan Quintela  byteswap_h=yes
19476ae9a1f4SJuan Quintelafi
19486ae9a1f4SJuan Quintela
1949f514f41cSStefan Weil# Search for bswap_32 function
19506ae9a1f4SJuan Quintelabswap_h=no
19516ae9a1f4SJuan Quintelacat > $TMPC << EOF
19526ae9a1f4SJuan Quintela#include <sys/endian.h>
19536ae9a1f4SJuan Quintela#include <sys/types.h>
19546ae9a1f4SJuan Quintela#include <machine/bswap.h>
19556ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
19566ae9a1f4SJuan QuintelaEOF
195752166aa0SJuan Quintelaif compile_prog "" "" ; then
19586ae9a1f4SJuan Quintela  bswap_h=yes
19596ae9a1f4SJuan Quintelafi
19606ae9a1f4SJuan Quintela
1961da93a1fdSaliguori##########################################
1962da93a1fdSaliguori# Do we need librt
1963da93a1fdSaliguoricat > $TMPC <<EOF
1964da93a1fdSaliguori#include <signal.h>
1965da93a1fdSaliguori#include <time.h>
1966da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
1967da93a1fdSaliguoriEOF
1968da93a1fdSaliguori
196952166aa0SJuan Quintelaif compile_prog "" "" ; then
197007ffa4bdSJuan Quintela  :
197152166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
197207ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
1973da93a1fdSaliguorifi
1974da93a1fdSaliguori
197531ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
19766362a53fSJuan Quintela        "$aix" != "yes" ; then
19776362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
19786362a53fSJuan Quintelafi
19796362a53fSJuan Quintela
1980de5071c5SBlue Swirl##########################################
1981de5071c5SBlue Swirl# check if the compiler defines offsetof
1982de5071c5SBlue Swirl
1983de5071c5SBlue Swirlneed_offsetof=yes
1984de5071c5SBlue Swirlcat > $TMPC << EOF
1985de5071c5SBlue Swirl#include <stddef.h>
1986de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
1987de5071c5SBlue SwirlEOF
1988de5071c5SBlue Swirlif compile_prog "" "" ; then
1989de5071c5SBlue Swirl    need_offsetof=no
1990de5071c5SBlue Swirlfi
1991de5071c5SBlue Swirl
19925f6b9e8fSBlue Swirl##########################################
1993747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
1994747bbdf7SBlue Swirl#
1995747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
1996747bbdf7SBlue Swirl# about attribute warn_unused_result
1997747bbdf7SBlue Swirl
1998747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
1999747bbdf7SBlue Swirlcat > $TMPC << EOF
2000747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2001747bbdf7SBlue Swirl#error gcc 3.3 or older
2002747bbdf7SBlue Swirl#endif
2003747bbdf7SBlue Swirlint main(void) { return 0;}
2004747bbdf7SBlue SwirlEOF
2005747bbdf7SBlue Swirlif compile_prog "" ""; then
2006747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
2007747bbdf7SBlue Swirlfi
2008747bbdf7SBlue Swirl
2009747bbdf7SBlue Swirl##########################################
20105f6b9e8fSBlue Swirl# check if we have fdatasync
20115f6b9e8fSBlue Swirl
20125f6b9e8fSBlue Swirlfdatasync=no
20135f6b9e8fSBlue Swirlcat > $TMPC << EOF
20145f6b9e8fSBlue Swirl#include <unistd.h>
20155f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
20165f6b9e8fSBlue SwirlEOF
20175f6b9e8fSBlue Swirlif compile_prog "" "" ; then
20185f6b9e8fSBlue Swirl    fdatasync=yes
20195f6b9e8fSBlue Swirlfi
20205f6b9e8fSBlue Swirl
2021e86ecd4bSJuan Quintela# End of CC checks
2022e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2023e86ecd4bSJuan Quintela
2024e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
20251156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2026e86ecd4bSJuan Quintelafi
2027a316e378SJuan Quintela
2028e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2029e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2030e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
203120ff6c80SAnthony Liguori
203220ff6c80SAnthony Liguoriif test -z "$werror" ; then
2033e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2034e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2035e86ecd4bSJuan Quintela        werror="yes"
2036e86ecd4bSJuan Quintela    else
2037e86ecd4bSJuan Quintela        werror="no"
2038e86ecd4bSJuan Quintela    fi
2039e86ecd4bSJuan Quintelafi
2040e86ecd4bSJuan Quintela
204120ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
204220ff6c80SAnthony Liguori# enable/disable
204320ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
204420ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
204520ff6c80SAnthony Liguori	zero_malloc="no"
204620ff6c80SAnthony Liguori    else
204720ff6c80SAnthony Liguori	zero_malloc="yes"
204820ff6c80SAnthony Liguori    fi
204920ff6c80SAnthony Liguorifi
205020ff6c80SAnthony Liguori
2051e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2052a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2053e86ecd4bSJuan Quintelafi
2054e86ecd4bSJuan Quintela
2055e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2056e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
20571156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2058e86ecd4bSJuan Quintela    fi
2059e86ecd4bSJuan Quintelafi
2060e86ecd4bSJuan Quintela
2061190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
20625a67135aSbellard
2063ca35f780SPaolo Bonzinitools=
2064ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2065ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2066ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2067ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2068ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2069ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2070ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2071ca35f780SPaolo Bonzini    fi
2072ca35f780SPaolo Bonzini  fi
2073ca35f780SPaolo Bonzinifi
2074ca35f780SPaolo Bonzini
2075ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2076ca35f780SPaolo Bonziniroms=
2077ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2078ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2079ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2080ca35f780SPaolo Bonzini  roms="optionrom"
2081ca35f780SPaolo Bonzinifi
2082ca35f780SPaolo Bonzini
2083ca35f780SPaolo Bonzini
20847d13299dSbellardecho "Install prefix    $prefix"
2085f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2086f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
20871c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
208811d9f695Sbellardif test "$mingw32" = "no" ; then
2089f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
209043ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
209111d9f695Sbellardfi
20925a67135aSbellardecho "Source path       $source_path"
20937d13299dSbellardecho "C compiler        $cc"
209483469015Sbellardecho "Host C compiler   $host_cc"
20950c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2096a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
20970c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
20987d13299dSbellardecho "make              $make"
20996a882643Spbrookecho "install           $install"
2100a98fd896Sbellardecho "host CPU          $cpu"
2101de83cd02Sbellardecho "host big endian   $bigendian"
210297a847bcSbellardecho "target list       $target_list"
2103ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2104b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
21057d13299dSbellardecho "gprof enabled     $gprof"
210603b4fe7dSaliguoriecho "sparse enabled    $sparse"
21071625af87Saliguoriecho "strip binaries    $strip_opt"
210805c2a3e7Sbellardecho "profiler          $profiler"
210943ce4dfeSbellardecho "static build      $static"
211085aa5189Sbellardecho "-Werror enabled   $werror"
21115b0753e0Sbellardif test "$darwin" = "yes" ; then
21125b0753e0Sbellard    echo "Cocoa support     $cocoa"
21135b0753e0Sbellardfi
211497a847bcSbellardecho "SDL support       $sdl"
21154d3b6f6eSbalrogecho "curses support    $curses"
2116769ce76dSAlexander Grafecho "curl support      $curl"
21175495ed11SLuiz Capitulinoecho "check support     $check_utests"
211867b915a5Sbellardecho "mingw32 support   $mingw32"
21190c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
21200c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2121eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
21228ff9cbf7Smalcecho "Mixer emulation   $mixemu"
21238d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
21242f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
2125*2f6f5c7aSCorentin Charyecho "VNC JPEG support  $vnc_jpeg"
21263142255cSblueswir1if test -n "$sparc_cpu"; then
21273142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
21283142255cSblueswir1fi
2129e37630caSaliguoriecho "xen support       $xen"
21302e4d9fb1Saurel32echo "brlapi support    $brlapi"
2131a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2132a25dba17SJuan Quintelaecho "Documentation     $docs"
2133c5937220Spbrook[ ! -z "$uname_release" ] && \
2134c5937220Spbrookecho "uname -r          $uname_release"
2135bd0c5661Spbrookecho "NPTL support      $nptl"
2136379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
213734005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
21388a16d273Sthsecho "vde support       $vde"
2139e5d355d1Saliguoriecho "IO thread         $io_thread"
21405c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2141758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
214277755340Sthsecho "Install blobs     $blobs"
2143b31a0277SJuan Quintelaecho "KVM support       $kvm"
2144f652e6afSaurel32echo "fdt support       $fdt"
2145ceb42de8Saliguoriecho "preadv support    $preadv"
21465f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2147ee682d27SStefan Weilecho "uuid support      $uuid"
2148d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
214967b915a5Sbellard
215097a847bcSbellardif test $sdl_too_old = "yes"; then
215124b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2152e8cd23deSbellardfi
215397a847bcSbellard
215498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
21554bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
215697a847bcSbellard
215798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
215898ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
215998ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
216098ec69acSJuan Quintelaecho >> $config_host_mak
216198ec69acSJuan Quintela
216299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
216399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
216499d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
216599d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
216699d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
216799d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
21681dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2169804edf29SJuan Quintela
21702408a527Saurel32case "$cpu" in
217124e804ecSAlexander Graf  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2172e0da9dd3SJuan Quintela    ARCH=$cpu
21732408a527Saurel32  ;;
2174a302c32dSLaurent Desnogues  armv4b|armv4l)
217516dbd14fSJuan Quintela    ARCH=arm
21762408a527Saurel32  ;;
21772408a527Saurel32esac
217898ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2179f8393946Saurel32if test "$debug_tcg" = "yes" ; then
21802358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2181f8393946Saurel32fi
2182b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2183b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2184b4475aa2SLuiz Capitulinofi
2185f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
21862358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2187f3d08ee6SPaul Brookfi
21881625af87Saliguoriif test "$strip_opt" = "yes" ; then
218998ec69acSJuan Quintela  echo "STRIP_OPT=-s" >> $config_host_mak
21901625af87Saliguorifi
21917d13299dSbellardif test "$bigendian" = "yes" ; then
2192e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
219397a847bcSbellardfi
21942358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
219567b915a5Sbellardif test "$mingw32" = "yes" ; then
219698ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
2197210fa556Spbrookelse
219835f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2199210fa556Spbrookfi
2200128ab2ffSblueswir1
2201dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2202dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2203dffcb71cSMark McLoughlinfi
2204dffcb71cSMark McLoughlin
220583fb7adfSbellardif test "$darwin" = "yes" ; then
220698ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
220783fb7adfSbellardfi
2208b29fe3edSmalc
2209b29fe3edSmalcif test "$aix" = "yes" ; then
221098ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2211b29fe3edSmalcfi
2212b29fe3edSmalc
2213ec530c81Sbellardif test "$solaris" = "yes" ; then
221498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
22152358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
22160475a5caSths  if test "$needs_libsunmath" = "yes" ; then
221775b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
22180475a5caSths  fi
2219ec530c81Sbellardfi
222097a847bcSbellardif test "$static" = "yes" ; then
222198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
222297a847bcSbellardfi
222305c2a3e7Sbellardif test $profiler = "yes" ; then
22242358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
222505c2a3e7Sbellardfi
2226c20709aaSbellardif test "$slirp" = "yes" ; then
222798ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2228b6e31c12SJuan Quintela  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
2229c20709aaSbellardfi
22308a16d273Sthsif test "$vde" = "yes" ; then
223198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
22328a16d273Sthsfi
22330c58ac1cSmalcfor card in $audio_card_list; do
2234f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
223598ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
22360c58ac1cSmalcdone
22372358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
22380c58ac1cSmalcfor drv in $audio_drv_list; do
2239f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
224098ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2241923e4521Smalc    if test "$drv" = "fmod"; then
22427aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2243fb065187Sbellard    fi
22440c58ac1cSmalcdone
224567f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
224667f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
224767f86e8eSJuan Quintelafi
2248d5631638Smalcif test "$audio_win_int" = "yes" ; then
2249d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2250d5631638Smalcfi
2251eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
22528ff9cbf7Smalcif test "$mixemu" = "yes" ; then
225398ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
22548ff9cbf7Smalcfi
22558d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
225698ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2257525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
22588d5d2d4cSthsfi
22592f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
226098ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
226160ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
22622f9606b3Saliguorifi
2263*2f6f5c7aSCorentin Charyif test "$vnc_jpeg" = "yes" ; then
2264*2f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2265*2f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
2266*2f6f5c7aSCorentin Charyfi
226776655d6dSaliguoriif test "$fnmatch" = "yes" ; then
22682358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
226976655d6dSaliguorifi
2270ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2271ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2272ee682d27SStefan Weilfi
2273b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
227498ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
22752358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
227698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
227798ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2278a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
227998ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2280cc8ae6deSpbrookfi
22811ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
228298ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
22838ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
228449ecc3faSbellardfi
228549ecc3faSbellardif test "$cocoa" = "yes" ; then
228698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
228749ecc3faSbellardfi
22884d3b6f6eSbalrogif test "$curses" = "yes" ; then
228998ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2290ab4e5602SJan Kiszkafi
22913b3f24adSaurel32if test "$atfile" = "yes" ; then
22922358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
22933b3f24adSaurel32fi
2294ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
22952358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2296ebc996f3SRiku Voipiofi
2297099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
22982358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2299099d6b0fSRiku Voipiofi
230040ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
230140ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
230240ff6d7eSKevin Wolffi
23033ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
23042358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
23053ce34dfbSvibisreenivasanfi
2306c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2307c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2308c2882b96SRiku Voipiofi
2309d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2310d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2311d0927938SUlrich Hechtfi
2312d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2313d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2314d0927938SUlrich Hechtfi
23153b3f24adSaurel32if test "$inotify" = "yes" ; then
23162358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
23173b3f24adSaurel32fi
2318c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2319c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2320c05c7a73SRiku Voipiofi
23216ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
23226ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
23236ae9a1f4SJuan Quintelafi
23246ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
23256ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
23266ae9a1f4SJuan Quintelafi
2327769ce76dSAlexander Grafif test "$curl" = "yes" ; then
232898ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2329b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2330769ce76dSAlexander Graffi
23312e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
233298ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
23332e4d9fb1Saurel32fi
2334fb599c9aSbalrogif test "$bluez" = "yes" ; then
233598ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2336ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2337fb599c9aSbalrogfi
2338e37630caSaliguoriif test "$xen" = "yes" ; then
23395647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2340e37630caSaliguorifi
2341e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
234298ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2343e5d355d1Saliguorifi
23445c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
23455c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
23465c6c3a6cSChristoph Hellwigfi
2347758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2348758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2349758e8e38SVenkateswararao Jujjuri (JV)fi
2350758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2351758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2352758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2353758e8e38SVenkateswararao Jujjuri (JV)  fi
2354758e8e38SVenkateswararao Jujjuri (JV)fi
235577755340Sthsif test "$blobs" = "yes" ; then
235698ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
235777755340Sthsfi
2358bf9298b9Saliguoriif test "$iovec" = "yes" ; then
23592358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2360bf9298b9Saliguorifi
2361ceb42de8Saliguoriif test "$preadv" = "yes" ; then
23622358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2363ceb42de8Saliguorifi
2364f652e6afSaurel32if test "$fdt" = "yes" ; then
23653f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2366f652e6afSaurel32fi
2367de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2368de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2369de5071c5SBlue Swirlfi
2370747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2371747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2372747bbdf7SBlue Swirlfi
23735f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
23745f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
23755f6b9e8fSBlue Swirlfi
237697a847bcSbellard
237783fb7adfSbellard# XXX: suppress that
23787d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
23792358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
23807d3505c5Sbellardfi
23817d3505c5Sbellard
23822358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2383c5937220Spbrook
238420ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
238520ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
238620ff6c80SAnthony Liguorifi
238720ff6c80SAnthony Liguori
238868063649Sblueswir1# USB host support
238968063649Sblueswir1case "$usb" in
239068063649Sblueswir1linux)
239198ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
239268063649Sblueswir1;;
239368063649Sblueswir1bsd)
239498ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
239568063649Sblueswir1;;
239668063649Sblueswir1*)
239798ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
239868063649Sblueswir1;;
239968063649Sblueswir1esac
240068063649Sblueswir1
240198ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
240298ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2403804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2404804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2405804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2406804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2407804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2408804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
2409804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2410804edf29SJuan Quintelaif test "$sparse" = "yes" ; then
2411804edf29SJuan Quintela  echo "CC      := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2412804edf29SJuan Quintela  echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2413a558ee17SJuan Quintela  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2414804edf29SJuan Quintelafi
2415804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2416804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2417804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
2418e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2419a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2420c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2421e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2422a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2423a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
242473da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
24253e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2426804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2427804edf29SJuan Quintela
24284bf6b55bSJuan Quintela# generate list of library paths for linker script
24294bf6b55bSJuan Quintela
24304bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
24314bf6b55bSJuan Quintela
24324bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
24334bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
24344bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
24354bf6b55bSJuan Quintela  else
24364bf6b55bSJuan Quintela    rm ${config_host_ld}~
24374bf6b55bSJuan Quintela  fi
24384bf6b55bSJuan Quintelafi
24394bf6b55bSJuan Quintela
24404d904533SBlue Swirlfor d in libdis libdis-user; do
24414d904533SBlue Swirl    mkdir -p $d
24424d904533SBlue Swirl    rm -f $d/Makefile
24434d904533SBlue Swirl    ln -s $source_path/Makefile.dis $d/Makefile
24444d904533SBlue Swirl    echo > $d/config.mak
24454d904533SBlue Swirldone
2446d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
2447d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2448d44cff22SRichard Hendersonfi
24494d904533SBlue Swirl
245097a847bcSbellardfor target in $target_list; do
245197a847bcSbellardtarget_dir="$target"
245225be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2453600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
245497a847bcSbellardtarget_bigendian="no"
24551f3d3c8fSJuan Quintela
2456ea2d6a39SJuan Quintelacase "$target_arch2" in
245724e804ecSAlexander Graf  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2458ea2d6a39SJuan Quintela  target_bigendian=yes
2459ea2d6a39SJuan Quintela  ;;
2460ea2d6a39SJuan Quintelaesac
246197a847bcSbellardtarget_softmmu="no"
2462997344f3Sbellardtarget_user_only="no"
2463831b7825Sthstarget_linux_user="no"
2464831b7825Sthstarget_darwin_user="no"
246584778508Sblueswir1target_bsd_user="no"
24669e407a85Spbrookcase "$target" in
2467600309b6SBlue Swirl  ${target_arch2}-softmmu)
24689e407a85Spbrook    target_softmmu="yes"
24699e407a85Spbrook    ;;
2470600309b6SBlue Swirl  ${target_arch2}-linux-user)
24719c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
24729c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
24739c7a4202SBlue Swirl      exit 1
24749c7a4202SBlue Swirl    fi
24759e407a85Spbrook    target_user_only="yes"
24769e407a85Spbrook    target_linux_user="yes"
24779e407a85Spbrook    ;;
2478600309b6SBlue Swirl  ${target_arch2}-darwin-user)
24799c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
24809c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
24819c7a4202SBlue Swirl      exit 1
24829c7a4202SBlue Swirl    fi
24839e407a85Spbrook    target_user_only="yes"
2484831b7825Sths    target_darwin_user="yes"
24859e407a85Spbrook    ;;
2486600309b6SBlue Swirl  ${target_arch2}-bsd-user)
24879cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
24889c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
24899c7a4202SBlue Swirl      exit 1
24909c7a4202SBlue Swirl    fi
249184778508Sblueswir1    target_user_only="yes"
249284778508Sblueswir1    target_bsd_user="yes"
249384778508Sblueswir1    ;;
24949e407a85Spbrook  *)
24959e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
24969e407a85Spbrook    exit 1
24979e407a85Spbrook    ;;
24989e407a85Spbrookesac
2499831b7825Sths
250097a847bcSbellardmkdir -p $target_dir
2501158142c2Sbellardmkdir -p $target_dir/fpu
250257fec1feSbellardmkdir -p $target_dir/tcg
250359f2a787SGerd Hoffmannmkdir -p $target_dir/ide
250484778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
250569de927cSbellard  mkdir -p $target_dir/nwfpe
250669de927cSbellardfi
250769de927cSbellard
2508ec530c81Sbellard#
2509ec530c81Sbellard# don't use ln -sf as not all "ln -sf" over write the file/link
2510ec530c81Sbellard#
2511ec530c81Sbellardrm -f $target_dir/Makefile
2512ec530c81Sbellardln -s $source_path/Makefile.target $target_dir/Makefile
2513ec530c81Sbellard
251497a847bcSbellard
251525be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
251697a847bcSbellard
2517e5fe0c52Spbrookbflt="no"
2518bd0c5661Spbrooktarget_nptl="no"
2519600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
25207ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
252156aebc89Spbrookgdb_xml_files=""
25227ba1e619Saliguori
2523938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
25246acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2525e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2526e73aae67SJuan Quintela
2527600309b6SBlue Swirlcase "$target_arch2" in
25282408a527Saurel32  i386)
25291ad2134fSPaul Brook    target_phys_bits=32
25302408a527Saurel32  ;;
25312408a527Saurel32  x86_64)
25326acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
25331ad2134fSPaul Brook    target_phys_bits=64
25342408a527Saurel32  ;;
25352408a527Saurel32  alpha)
25361ad2134fSPaul Brook    target_phys_bits=64
2537a4b388ffSRichard Henderson    target_nptl="yes"
25382408a527Saurel32  ;;
25392408a527Saurel32  arm|armeb)
2540b498c8a0SJuan Quintela    TARGET_ARCH=arm
2541e5fe0c52Spbrook    bflt="yes"
2542bd0c5661Spbrook    target_nptl="yes"
254356aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
25441ad2134fSPaul Brook    target_phys_bits=32
25452408a527Saurel32  ;;
25462408a527Saurel32  cris)
2547253bd7f8Sedgar_igl    target_nptl="yes"
25481ad2134fSPaul Brook    target_phys_bits=32
25492408a527Saurel32  ;;
25502408a527Saurel32  m68k)
25510938cda5Saurel32    bflt="yes"
255256aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
25531ad2134fSPaul Brook    target_phys_bits=32
25542408a527Saurel32  ;;
255572b675caSEdgar E. Iglesias  microblaze)
255672b675caSEdgar E. Iglesias    bflt="yes"
255772b675caSEdgar E. Iglesias    target_nptl="yes"
255872b675caSEdgar E. Iglesias    target_phys_bits=32
255972b675caSEdgar E. Iglesias  ;;
25602408a527Saurel32  mips|mipsel)
2561b498c8a0SJuan Quintela    TARGET_ARCH=mips
256225be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2563f04dc72fSPaul Brook    target_nptl="yes"
25641ad2134fSPaul Brook    target_phys_bits=64
25652408a527Saurel32  ;;
25662408a527Saurel32  mipsn32|mipsn32el)
2567b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
25686acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
256925be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
25701ad2134fSPaul Brook    target_phys_bits=64
25712408a527Saurel32  ;;
25722408a527Saurel32  mips64|mips64el)
2573b498c8a0SJuan Quintela    TARGET_ARCH=mips64
25746acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
257525be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
25761ad2134fSPaul Brook    target_phys_bits=64
25772408a527Saurel32  ;;
25782408a527Saurel32  ppc)
2579c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25801ad2134fSPaul Brook    target_phys_bits=32
2581d6630708SNathan Froyd    target_nptl="yes"
25822408a527Saurel32  ;;
25832408a527Saurel32  ppcemb)
25846acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2585e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2586c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25871ad2134fSPaul Brook    target_phys_bits=64
2588d6630708SNathan Froyd    target_nptl="yes"
25892408a527Saurel32  ;;
25902408a527Saurel32  ppc64)
25916acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2592e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2593c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
25941ad2134fSPaul Brook    target_phys_bits=64
25952408a527Saurel32  ;;
25962408a527Saurel32  ppc64abi32)
2597b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
25986acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2599e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
260025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
2601c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
26021ad2134fSPaul Brook    target_phys_bits=64
26032408a527Saurel32  ;;
26042408a527Saurel32  sh4|sh4eb)
2605b498c8a0SJuan Quintela    TARGET_ARCH=sh4
26064dbed897Spbrook    bflt="yes"
26070b6d3ae0Saurel32    target_nptl="yes"
26081ad2134fSPaul Brook    target_phys_bits=32
26092408a527Saurel32  ;;
26102408a527Saurel32  sparc)
26111ad2134fSPaul Brook    target_phys_bits=64
26122408a527Saurel32  ;;
26132408a527Saurel32  sparc64)
26146acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
26151ad2134fSPaul Brook    target_phys_bits=64
26162408a527Saurel32  ;;
26172408a527Saurel32  sparc32plus)
2618b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
26196acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
2620e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
262125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
26221ad2134fSPaul Brook    target_phys_bits=64
26232408a527Saurel32  ;;
262424e804ecSAlexander Graf  s390x)
262524e804ecSAlexander Graf    target_phys_bits=64
262624e804ecSAlexander Graf  ;;
26272408a527Saurel32  *)
2628de83cd02Sbellard    echo "Unsupported target CPU"
2629de83cd02Sbellard    exit 1
26302408a527Saurel32  ;;
26312408a527Saurel32esac
263225be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2633053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
263425be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
263525be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
263642bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
26376acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
26386acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
26396acff7daSJuan Quintelafi
264025be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
2641e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
2642e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
2643e6e91b9cSJuan Quintelafi
264425be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
26451b0c87fcSJuan Quintelacase "$target_arch2" in
26461b0c87fcSJuan Quintela  i386|x86_64)
26471b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
264825be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
26491b0c87fcSJuan Quintela    fi
26501b0c87fcSJuan Quintelaesac
2651c59249f9SJuan Quintelacase "$target_arch2" in
26520e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
2653c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
2654c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
2655c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
2656c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
26575f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
2658c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
2659c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
266025be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
266125be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
2662dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
2663dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
2664dae5079aSJan Kiszka      fi
2665d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
2666d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
2667d5970055SMichael S. Tsirkin      fi
2668c59249f9SJuan Quintela    fi
2669c59249f9SJuan Quintelaesac
2670de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
267125be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
267297a847bcSbellardfi
267397a847bcSbellardif test "$target_softmmu" = "yes" ; then
2674b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
267525be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
267625be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
26770e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
26785791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
2679de83cd02Sbellardfi
2680997344f3Sbellardif test "$target_user_only" = "yes" ; then
268125be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
2682997344f3Sbellardfi
2683831b7825Sthsif test "$target_linux_user" = "yes" ; then
268425be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
2685831b7825Sthsfi
2686831b7825Sthsif test "$target_darwin_user" = "yes" ; then
268725be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
2688831b7825Sthsfi
268956aebc89Spbrooklist=""
269056aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
269156aebc89Spbrook  for x in $gdb_xml_files; do
269256aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
269356aebc89Spbrook  done
269425be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
26953d0f1517SJuan Quintelafi
2696de83cd02Sbellard
2697f57975fbSJuan Quintelacase "$target_arch2" in
2698990b3e19SRichard Henderson  alpha|arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
269925be210fSJuan Quintela    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
2700f57975fbSJuan Quintela    ;;
2701d6b38939SJuan Quintela  *)
270225be210fSJuan Quintela    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
2703d6b38939SJuan Quintela    ;;
2704f57975fbSJuan Quintelaesac
2705f57975fbSJuan Quintela
2706e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
270725be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
2708e5fe0c52Spbrookfi
2709bd0c5661Spbrookif test "$target_user_only" = "yes" \
2710bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
271125be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
2712bd0c5661Spbrookfi
2713379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
271425be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
2715379f6698SPaul Brookfi
271684778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
271725be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
271884778508Sblueswir1fi
27195b0753e0Sbellard
27204afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
2721fa282484SJuan Quintela
27224afddb55SJuan Quintelacflags=""
2723fa282484SJuan Quintelaldflags=""
27249b8e111fSJuan Quintela
272557ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
272657ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
272724e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
272824e804ecSAlexander Graf  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
27295d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
27305d8a4f8fSRichard Henderson  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
273157ddfbf7SJuan Quintelaelse
273257ddfbf7SJuan Quintela  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
273357ddfbf7SJuan Quintelafi
273457ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/tcg $cflags"
273557ddfbf7SJuan Quintelacflags="-I\$(SRC_PATH)/fpu $cflags"
273657ddfbf7SJuan Quintela
27374d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
27384d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
27394d904533SBlue Swirlelse
27404d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
27414d904533SBlue Swirlfi
27424d904533SBlue Swirl
274364656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
274464656024SJuan Quintela  case "$i" in
274564656024SJuan Quintela  alpha)
274625be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
27474d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
274864656024SJuan Quintela  ;;
274964656024SJuan Quintela  arm)
275025be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
27514d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
275264656024SJuan Quintela  ;;
275364656024SJuan Quintela  cris)
275425be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
27554d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
275664656024SJuan Quintela  ;;
275764656024SJuan Quintela  hppa)
275825be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
27594d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
276064656024SJuan Quintela  ;;
276164656024SJuan Quintela  i386|x86_64)
276225be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
27634d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
276464656024SJuan Quintela  ;;
2765903ec55cSAurelien Jarno  ia64*)
2766903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
2767903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
2768903ec55cSAurelien Jarno  ;;
276964656024SJuan Quintela  m68k)
277025be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
27714d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
277264656024SJuan Quintela  ;;
277364656024SJuan Quintela  microblaze)
277425be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
27754d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
277664656024SJuan Quintela  ;;
277764656024SJuan Quintela  mips*)
277825be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
27794d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
278064656024SJuan Quintela  ;;
278164656024SJuan Quintela  ppc*)
278225be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
27834d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
278464656024SJuan Quintela  ;;
278524e804ecSAlexander Graf  s390*)
278625be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
27874d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
278864656024SJuan Quintela  ;;
278964656024SJuan Quintela  sh4)
279025be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
27914d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
279264656024SJuan Quintela  ;;
279364656024SJuan Quintela  sparc*)
279425be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
27954d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
279664656024SJuan Quintela  ;;
279764656024SJuan Quintela  esac
279864656024SJuan Quinteladone
279964656024SJuan Quintela
28006ee7126fSJuan Quintelacase "$ARCH" in
28016ee7126fSJuan Quintelaalpha)
28026ee7126fSJuan Quintela  # Ensure there's only a single GP
28036ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
28046ee7126fSJuan Quintela;;
28056ee7126fSJuan Quintelaesac
28066ee7126fSJuan Quintela
280755d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
280855d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
280955d9c04bSJuan Quintela  arm)
281055d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
281155d9c04bSJuan Quintela  ;;
281255d9c04bSJuan Quintela  i386|mips|ppc)
281355d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
281455d9c04bSJuan Quintela  ;;
281555d9c04bSJuan Quintela  esac
281655d9c04bSJuan Quintelafi
281755d9c04bSJuan Quintela
281834005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
281934005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
282034005a00SKirill A. Shutemov  cflags="-fpie $cflags"
282134005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
282234005a00SKirill A. Shutemovfi
282334005a00SKirill A. Shutemov
2824471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
2825471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
2826471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
282725be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
2828471857ddSJuan Quintelafi
2829471857ddSJuan Quintela
2830d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
283125be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
2832d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
2833d02c1db3SJuan Quintela    cflags="-p $cflags"
2834d02c1db3SJuan Quintela    ldflags="-p $ldflags"
2835d02c1db3SJuan Quintela  fi
2836d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
2837d02c1db3SJuan Quintela    ldflags="-p $ldflags"
283825be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
2839d02c1db3SJuan Quintela  fi
2840d02c1db3SJuan Quintelafi
2841d02c1db3SJuan Quintela
28426ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
28439b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
2844fa282484SJuan Quintela  case "$ARCH" in
2845fa282484SJuan Quintela  sparc)
2846fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
2847322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
2848fa282484SJuan Quintela    ;;
28494d58be06SRichard Henderson  alpha | s390x)
28504d58be06SRichard Henderson    # The default placement of the application is fine.
28514d58be06SRichard Henderson    ;;
2852fd76e73aSRichard Henderson  *)
2853322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
2854fa282484SJuan Quintela    ;;
2855fa282484SJuan Quintela  esac
2856fa282484SJuan Quintelafi
2857fa282484SJuan Quintela
285825be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
285925be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
2860fa282484SJuan Quintela
286197a847bcSbellarddone # for target in $targets
28627d13299dSbellard
28637d13299dSbellard# build tree in object directory if source path is different from current one
28647d13299dSbellardif test "$source_path_used" = "yes" ; then
2865e1144d00SMark McLoughlin    DIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
28662d9f27d2SAnthony Liguori    DIRS="$DIRS roms/seabios roms/vgabios"
286774db920cSGautham R Shenoy    DIRS="$DIRS fsdev"
28687d13299dSbellard    FILES="Makefile tests/Makefile"
2869e7daa605Sths    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2870e1ffb0f1Sedgar_igl    FILES="$FILES tests/test-mmap.c"
28717ea78b74SJan Kiszka    FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps pc-bios/video.x"
28722d9f27d2SAnthony Liguori    FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
28737ea78b74SJan Kiszka    for bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
28747ea78b74SJan Kiszka        FILES="$FILES pc-bios/`basename $bios_file`"
28757ea78b74SJan Kiszka    done
28767d13299dSbellard    for dir in $DIRS ; do
28777d13299dSbellard            mkdir -p $dir
28787d13299dSbellard    done
2879ec530c81Sbellard    # remove the link and recreate it, as not all "ln -sf" overwrite the link
28807d13299dSbellard    for f in $FILES ; do
2881ec530c81Sbellard        rm -f $f
2882ec530c81Sbellard        ln -s $source_path/$f $f
28837d13299dSbellard    done
28847d13299dSbellardfi
28851ad2134fSPaul Brook
2886c34ebfdcSAnthony Liguori# temporary config to build submodules
28872d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
2888c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
288937116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
2890c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
2891c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
2892c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
2893c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
2894c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
2895c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
2896c34ebfdcSAnthony Liguori    echo "HOST_CC=$host_cc" >> $config_mak
2897c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
2898c34ebfdcSAnthony Liguoridone
2899c34ebfdcSAnthony Liguori
29001ad2134fSPaul Brookfor hwlib in 32 64; do
29011ad2134fSPaul Brook  d=libhw$hwlib
29021ad2134fSPaul Brook  mkdir -p $d
29039953b2fcSBlue Swirl  mkdir -p $d/ide
29041ad2134fSPaul Brook  rm -f $d/Makefile
29051ad2134fSPaul Brook  ln -s $source_path/Makefile.hw $d/Makefile
290637116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
29071ad2134fSPaul Brookdone
2908add16157SBlue Swirl
2909add16157SBlue Swirld=libuser
2910add16157SBlue Swirlmkdir -p $d
2911add16157SBlue Swirlrm -f $d/Makefile
2912add16157SBlue Swirlln -s $source_path/Makefile.user $d/Makefile
2913299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
2914299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
2915299060a0SKirill A. Shutemovfi
2916b40292e7SJan Kiszka
2917b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
2918b40292e7SJan Kiszka  mkdir -p QMP
2919b40292e7SJan Kiszkafi
2920