xref: /openbmc/qemu/configure (revision 710fc4f5f1cbb6d2cebdc575def9f9dba4b0263f)
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
180ba8681eSLoïc Minier# NB: do not call "exit" in the trap handler; this is buggy with some shells;
190ba8681eSLoïc Minier# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
200ba8681eSLoïc Miniertrap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
21da1d85e3SGerd Hoffmannrm -f config.log
229ac81bbbSmalc
2352166aa0SJuan Quintelacompile_object() {
24da1d85e3SGerd Hoffmann  echo $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log
25da1d85e3SGerd Hoffmann  $cc $QEMU_CFLAGS -c -o $TMPO $TMPC >> config.log 2>&1
2652166aa0SJuan Quintela}
2752166aa0SJuan Quintela
2852166aa0SJuan Quintelacompile_prog() {
2952166aa0SJuan Quintela  local_cflags="$1"
3052166aa0SJuan Quintela  local_ldflags="$2"
31da1d85e3SGerd Hoffmann  echo $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log
32da1d85e3SGerd Hoffmann  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags >> config.log 2>&1
3352166aa0SJuan Quintela}
3452166aa0SJuan Quintela
3511568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
3611568d6dSPaolo Bonzinisymlink() {
3711568d6dSPaolo Bonzini  rm -f $2
3811568d6dSPaolo Bonzini  ln -s $1 $2
3911568d6dSPaolo Bonzini}
4011568d6dSPaolo Bonzini
410dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
420dba6195SLoïc Minier# executable or a builtin)
430dba6195SLoïc Minierhas() {
440dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
450dba6195SLoïc Minier}
460dba6195SLoïc Minier
470dba6195SLoïc Minier# search for an executable in PATH
480dba6195SLoïc Minierpath_of() {
490dba6195SLoïc Minier    local_command="$1"
500dba6195SLoïc Minier    local_ifs="$IFS"
510dba6195SLoïc Minier    local_dir=""
520dba6195SLoïc Minier
530dba6195SLoïc Minier    # pathname has a dir component?
540dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
550dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
560dba6195SLoïc Minier            echo "$local_command"
570dba6195SLoïc Minier            return 0
580dba6195SLoïc Minier        fi
590dba6195SLoïc Minier    fi
600dba6195SLoïc Minier    if [ -z "$local_command" ]; then
610dba6195SLoïc Minier        return 1
620dba6195SLoïc Minier    fi
630dba6195SLoïc Minier
640dba6195SLoïc Minier    IFS=:
650dba6195SLoïc Minier    for local_dir in $PATH; do
660dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
670dba6195SLoïc Minier            echo "$local_dir/$local_command"
680dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
690dba6195SLoïc Minier            return 0
700dba6195SLoïc Minier        fi
710dba6195SLoïc Minier    done
720dba6195SLoïc Minier    # not found
730dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
740dba6195SLoïc Minier    return 1
750dba6195SLoïc Minier}
760dba6195SLoïc Minier
777d13299dSbellard# default parameters
78ca4deeb1SPaolo Bonzinisource_path=`dirname "$0"`
792ff6b91eSJuan Quintelacpu=""
801e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
8143ce4dfeSbellardstatic="no"
82ed968ff1SJuan Quintelasparc_cpu=""
837d13299dSbellardcross_prefix=""
840c58ac1cSmalcaudio_drv_list=""
85d61a4ce8SGerd Hoffmannaudio_card_list="ac97 es1370 sb16 hda"
86d61a4ce8SGerd Hoffmannaudio_possible_cards="ac97 es1370 sb16 cs4231a adlib gus hda"
87eb852011SMarkus Armbrusterblock_drv_whitelist=""
887d13299dSbellardhost_cc="gcc"
89c81da56eSJuan Quintelahelper_cflags=""
9073da375eSJuan Quintelalibs_softmmu=""
913e2e0e6bSJuan Quintelalibs_tools=""
9267f86e8eSJuan Quintelaaudio_pt_int=""
93d5631638Smalcaudio_win_int=""
942b2e59e6SPaolo Bonzinicc_i386=i386-pc-linux-gnu-gcc
95ac0df51dSaliguori
96377529c0SPaolo Bonzinitarget_list=""
97377529c0SPaolo Bonzini
98377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
99377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
100377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
101377529c0SPaolo Bonzini#              unless --disable-foo is given
102377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
103377529c0SPaolo Bonzini#              feature will searched for,
104377529c0SPaolo Bonzini#              if not found, configure exits with error
105377529c0SPaolo Bonzini#
106377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
107377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
108377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
109377529c0SPaolo Bonzini
110377529c0SPaolo Bonzinibluez=""
111377529c0SPaolo Bonzinibrlapi=""
112377529c0SPaolo Bonzinicurl=""
113377529c0SPaolo Bonzinicurses=""
114377529c0SPaolo Bonzinidocs=""
115377529c0SPaolo Bonzinifdt=""
116377529c0SPaolo Bonzinikvm=""
117377529c0SPaolo Bonzinikvm_para=""
118377529c0SPaolo Bonzininptl=""
119377529c0SPaolo Bonzinisdl=""
120377529c0SPaolo Bonzinisparse="no"
121377529c0SPaolo Bonziniuuid=""
122377529c0SPaolo Bonzinivde=""
123377529c0SPaolo Bonzinivnc_tls=""
124377529c0SPaolo Bonzinivnc_sasl=""
125377529c0SPaolo Bonzinivnc_jpeg=""
126377529c0SPaolo Bonzinivnc_png=""
127377529c0SPaolo Bonzinivnc_thread="no"
128377529c0SPaolo Bonzinixen=""
129377529c0SPaolo Bonzinilinux_aio=""
130377529c0SPaolo Bonziniattr=""
131377529c0SPaolo Bonzinivhost_net=""
132377529c0SPaolo Bonzinixfs=""
133377529c0SPaolo Bonzini
134377529c0SPaolo Bonzinigprof="no"
135377529c0SPaolo Bonzinidebug_tcg="no"
136377529c0SPaolo Bonzinidebug_mon="no"
137377529c0SPaolo Bonzinidebug="no"
138377529c0SPaolo Bonzinistrip_opt="yes"
139377529c0SPaolo Bonzinibigendian="no"
140377529c0SPaolo Bonzinimingw32="no"
141377529c0SPaolo BonziniEXESUF=""
142377529c0SPaolo Bonziniprefix="/usr/local"
143377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
144377529c0SPaolo Bonzinidatadir="\${prefix}/share/qemu"
145377529c0SPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
146377529c0SPaolo Bonzinibindir="\${prefix}/bin"
147377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
148377529c0SPaolo Bonziniconfsuffix="/qemu"
149377529c0SPaolo Bonzinislirp="yes"
150377529c0SPaolo Bonzinifmod_lib=""
151377529c0SPaolo Bonzinifmod_inc=""
152377529c0SPaolo Bonzinioss_lib=""
153377529c0SPaolo Bonzinibsd="no"
154377529c0SPaolo Bonzinilinux="no"
155377529c0SPaolo Bonzinisolaris="no"
156377529c0SPaolo Bonziniprofiler="no"
157377529c0SPaolo Bonzinicocoa="no"
158377529c0SPaolo Bonzinisoftmmu="yes"
159377529c0SPaolo Bonzinilinux_user="no"
160377529c0SPaolo Bonzinidarwin_user="no"
161377529c0SPaolo Bonzinibsd_user="no"
162377529c0SPaolo Bonziniguest_base=""
163377529c0SPaolo Bonziniuname_release=""
164377529c0SPaolo Bonziniio_thread="no"
165377529c0SPaolo Bonzinimixemu="no"
166377529c0SPaolo Bonzinikerneldir=""
167377529c0SPaolo Bonziniaix="no"
168377529c0SPaolo Bonziniblobs="yes"
169377529c0SPaolo Bonzinipkgversion=""
170377529c0SPaolo Bonzinicheck_utests="no"
171377529c0SPaolo Bonziniuser_pie="no"
172377529c0SPaolo Bonzinizero_malloc=""
173377529c0SPaolo Bonzinitrace_backend="nop"
174377529c0SPaolo Bonzinitrace_file="trace"
175377529c0SPaolo Bonzinispice=""
176377529c0SPaolo Bonzinirbd=""
177377529c0SPaolo Bonzini
178ac0df51dSaliguori# parse CC options first
179ac0df51dSaliguorifor opt do
180ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
181ac0df51dSaliguori  case "$opt" in
182ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
183ac0df51dSaliguori  ;;
1843d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
185ac0df51dSaliguori  ;;
186ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
187ca4deeb1SPaolo Bonzini  ;;
1882ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
1892ff6b91eSJuan Quintela  ;;
190a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
191e2a2ed06SJuan Quintela  ;;
192e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
193e2a2ed06SJuan Quintela  ;;
19450e7b1a0SJuan Quintela  --sparc_cpu=*)
19550e7b1a0SJuan Quintela    sparc_cpu="$optarg"
19650e7b1a0SJuan Quintela    case $sparc_cpu in
197ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
19850e7b1a0SJuan Quintela      cpu="sparc"
19950e7b1a0SJuan Quintela    ;;
20050e7b1a0SJuan Quintela    v9)
20150e7b1a0SJuan Quintela      cpu="sparc64"
20250e7b1a0SJuan Quintela    ;;
20350e7b1a0SJuan Quintela    *)
20450e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
20550e7b1a0SJuan Quintela      exit 1
20650e7b1a0SJuan Quintela    ;;
20750e7b1a0SJuan Quintela    esac
20850e7b1a0SJuan Quintela  ;;
209ac0df51dSaliguori  esac
210ac0df51dSaliguoridone
211ac0df51dSaliguori# OS specific
212ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
213ac0df51dSaliguori# we can eliminate it's usage altogether
214ac0df51dSaliguori
2153d8df640SPaolo Bonzinicc="${cross_prefix}${CC-gcc}"
2163d8df640SPaolo Bonziniar="${cross_prefix}${AR-ar}"
2173d8df640SPaolo Bonziniobjcopy="${cross_prefix}${OBJCOPY-objcopy}"
2183d8df640SPaolo Bonzinild="${cross_prefix}${LD-ld}"
2193d8df640SPaolo Bonzinistrip="${cross_prefix}${STRIP-strip}"
2203d8df640SPaolo Bonziniwindres="${cross_prefix}${WINDRES-windres}"
221a8bd70adSPaolo Bonzinipkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
2223ec87ffeSPaolo Bonzinisdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
223ac0df51dSaliguori
224be17dc90SMichael S. Tsirkin# default flags for all hosts
225be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
226be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
227be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
228be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
229be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
23084958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
231f9728943SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH)"
232be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
233be17dc90SMichael S. Tsirkin
234ca4deeb1SPaolo Bonzini# make source path absolute
235ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
236ca4deeb1SPaolo Bonzini
237ac0df51dSaliguoricheck_define() {
238ac0df51dSaliguoricat > $TMPC <<EOF
239ac0df51dSaliguori#if !defined($1)
240ac0df51dSaliguori#error Not defined
241ac0df51dSaliguori#endif
242ac0df51dSaliguoriint main(void) { return 0; }
243ac0df51dSaliguoriEOF
24452166aa0SJuan Quintela  compile_object
245ac0df51dSaliguori}
246ac0df51dSaliguori
2472ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
2482ff6b91eSJuan Quintela  # command line argument
2492ff6b91eSJuan Quintela  :
2502ff6b91eSJuan Quintelaelif check_define __i386__ ; then
251ac0df51dSaliguori  cpu="i386"
252ac0df51dSaliguorielif check_define __x86_64__ ; then
253ac0df51dSaliguori  cpu="x86_64"
2543aa9bd6cSblueswir1elif check_define __sparc__ ; then
2553aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
2563aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
2573aa9bd6cSblueswir1  if check_define __arch64__ ; then
2583aa9bd6cSblueswir1    cpu="sparc64"
2593aa9bd6cSblueswir1  else
2603aa9bd6cSblueswir1    cpu="sparc"
2613aa9bd6cSblueswir1  fi
262fdf7ed96Smalcelif check_define _ARCH_PPC ; then
263fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
264fdf7ed96Smalc    cpu="ppc64"
265ac0df51dSaliguori  else
266fdf7ed96Smalc    cpu="ppc"
267fdf7ed96Smalc  fi
268afa05235SAurelien Jarnoelif check_define __mips__ ; then
269afa05235SAurelien Jarno  cpu="mips"
270477ba620SAurelien Jarnoelif check_define __ia64__ ; then
271477ba620SAurelien Jarno  cpu="ia64"
272d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
273d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
274d66ed0eaSAurelien Jarno    cpu="s390x"
275d66ed0eaSAurelien Jarno  else
276d66ed0eaSAurelien Jarno    cpu="s390"
277d66ed0eaSAurelien Jarno  fi
278fdf7ed96Smalcelse
279fdf7ed96Smalc  cpu=`uname -m`
280ac0df51dSaliguorifi
281ac0df51dSaliguori
2827d13299dSbellardcase "$cpu" in
283afa05235SAurelien Jarno  alpha|cris|ia64|m68k|microblaze|ppc|ppc64|sparc64)
284ea8f20f8SJuan Quintela    cpu="$cpu"
285ea8f20f8SJuan Quintela  ;;
2867d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
28797a847bcSbellard    cpu="i386"
2887d13299dSbellard  ;;
289aaa5fa14Saurel32  x86_64|amd64)
290aaa5fa14Saurel32    cpu="x86_64"
291aaa5fa14Saurel32  ;;
292ba68055eSbellard  armv*b)
293808c4954Sbellard    cpu="armv4b"
294808c4954Sbellard  ;;
295ba68055eSbellard  armv*l)
2967d13299dSbellard    cpu="armv4l"
2977d13299dSbellard  ;;
298f54b3f92Saurel32  parisc|parisc64)
299f54b3f92Saurel32    cpu="hppa"
300f54b3f92Saurel32  ;;
301afa05235SAurelien Jarno  mips*)
302afa05235SAurelien Jarno    cpu="mips"
303afa05235SAurelien Jarno  ;;
30424e804ecSAlexander Graf  s390)
305fb3e5849Sbellard    cpu="s390"
306fb3e5849Sbellard  ;;
30724e804ecSAlexander Graf  s390x)
30824e804ecSAlexander Graf    cpu="s390x"
30924e804ecSAlexander Graf  ;;
3103142255cSblueswir1  sparc|sun4[cdmuv])
311ae228531Sbellard    cpu="sparc"
312ae228531Sbellard  ;;
3137d13299dSbellard  *)
314a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
315a447d4dcSPaolo Bonzini    exit 1
3167d13299dSbellard  ;;
3177d13299dSbellardesac
318e2d52ad3SJuan Quintela
3197d13299dSbellard# OS specific
320ac0df51dSaliguoriif check_define __linux__ ; then
321ac0df51dSaliguori  targetos="Linux"
322ac0df51dSaliguorielif check_define _WIN32 ; then
323ac0df51dSaliguori  targetos='MINGW32'
324169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
325169dc5d3Sblueswir1  targetos='OpenBSD'
326169dc5d3Sblueswir1elif check_define __sun__ ; then
327169dc5d3Sblueswir1  targetos='SunOS'
328179cf400SAndreas Färberelif check_define __HAIKU__ ; then
329179cf400SAndreas Färber  targetos='Haiku'
330ac0df51dSaliguorielse
3317d13299dSbellard  targetos=`uname -s`
332ac0df51dSaliguorifi
3330dbfc675SJuan Quintela
3347d13299dSbellardcase $targetos in
335c326e0afSbellardCYGWIN*)
336c326e0afSbellard  mingw32="yes"
337a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
338d5631638Smalc  audio_possible_drivers="winwave sdl"
339d5631638Smalc  audio_drv_list="winwave"
340c326e0afSbellard;;
34167b915a5SbellardMINGW32*)
34267b915a5Sbellard  mingw32="yes"
343d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
344d5631638Smalc  audio_drv_list="winwave"
34567b915a5Sbellard;;
3465c40d2bdSthsGNU/kFreeBSD)
347a167ba50SAurelien Jarno  bsd="yes"
3480c58ac1cSmalc  audio_drv_list="oss"
349f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3505c40d2bdSths;;
3517d3505c5SbellardFreeBSD)
3527d3505c5Sbellard  bsd="yes"
3530db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3540c58ac1cSmalc  audio_drv_list="oss"
355f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
356f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
357f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3587d3505c5Sbellard;;
359c5e97233Sblueswir1DragonFly)
360c5e97233Sblueswir1  bsd="yes"
3610db4a067SPaolo Bonzini  make="${MAKE-gmake}"
362c5e97233Sblueswir1  audio_drv_list="oss"
363c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
364c5e97233Sblueswir1;;
3657d3505c5SbellardNetBSD)
3667d3505c5Sbellard  bsd="yes"
3670db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3680c58ac1cSmalc  audio_drv_list="oss"
369c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3708ef92a88Sblueswir1  oss_lib="-lossaudio"
3717d3505c5Sbellard;;
3727d3505c5SbellardOpenBSD)
3737d3505c5Sbellard  bsd="yes"
3740db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3750c58ac1cSmalc  audio_drv_list="oss"
376c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3772f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3787d3505c5Sbellard;;
37983fb7adfSbellardDarwin)
38083fb7adfSbellard  bsd="yes"
38183fb7adfSbellard  darwin="yes"
3820dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3830dbfc675SJuan Quintela  # run 64-bit userspace code
384aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3851b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
386aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3871b0f9cc2Saliguori  fi
3881b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
389a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3900c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3911b0f9cc2Saliguori  else
392a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3931b0f9cc2Saliguori  fi
394831b7825Sths  darwin_user="yes"
395fd677642Sths  cocoa="yes"
3960c58ac1cSmalc  audio_drv_list="coreaudio"
397c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
3980c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
3997973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
40083fb7adfSbellard;;
401ec530c81SbellardSunOS)
402ec530c81Sbellard  solaris="yes"
4030db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4040db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
405fa58948dSBlue Swirl  ld="gld"
4060475a5caSths  needs_libsunmath="no"
407c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
408ef18c883Sths  # have to select again, because `uname -m` returns i86pc
409ef18c883Sths  # even on an x86_64 box.
410ef18c883Sths  solariscpu=`isainfo -k`
411ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
412ef18c883Sths    cpu="x86_64"
413ef18c883Sths  fi
414c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4150475a5caSths    if test "$solarisrev" -le 9 ; then
4160475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4170475a5caSths        needs_libsunmath="yes"
418f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
419f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
420f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4210475a5caSths      else
4220475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4230475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4240475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4250475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4260475a5caSths        exit 1
4270475a5caSths      fi
4280475a5caSths    fi
42986b2bd93Sths  fi
4306b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4310c58ac1cSmalc    audio_drv_list="oss"
4326b4d2ba1Sths  fi
433c2de5c91Smalc  audio_possible_drivers="oss sdl"
434d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
435d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
436d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
437d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
438a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
439e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
440ec530c81Sbellard;;
441b29fe3edSmalcAIX)
442b29fe3edSmalc  aix="yes"
4430db4a067SPaolo Bonzini  make="${MAKE-gmake}"
444b29fe3edSmalc;;
445179cf400SAndreas FärberHaiku)
446179cf400SAndreas Färber  haiku="yes"
447179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
448179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
449179cf400SAndreas Färber;;
450fb065187Sbellard*)
4510c58ac1cSmalc  audio_drv_list="oss"
452b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4535327cf48Sbellard  linux="yes"
454831b7825Sths  linux_user="yes"
45568063649Sblueswir1  usb="linux"
45607f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
457c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
458c9ec1fe4Sbellard  fi
459fb065187Sbellard;;
4607d13299dSbellardesac
4617d13299dSbellard
4627d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
463b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
46468063649Sblueswir1    usb="bsd"
46583fb7adfSbellard  fi
46684778508Sblueswir1  bsd_user="yes"
4677d3505c5Sbellardfi
4687d3505c5Sbellard
4690db4a067SPaolo Bonzini: ${make=${MAKE-make}}
4700db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
4710db4a067SPaolo Bonzini
4723457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4733457a3f8SJuan Quintela  EXESUF=".exe"
474a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
475e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
476e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
477884044aaSJuan Quintela  LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
478683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
479683035deSPaolo Bonzini  mandir="\${prefix}"
480683035deSPaolo Bonzini  datadir="\${prefix}"
481683035deSPaolo Bonzini  docdir="\${prefix}"
482683035deSPaolo Bonzini  bindir="\${prefix}"
483683035deSPaolo Bonzini  sysconfdir="\${prefix}"
484683035deSPaolo Bonzini  confsuffix=""
4853457a3f8SJuan Quintelafi
4863457a3f8SJuan Quintela
487487fefdbSAnthony Liguoriwerror=""
48885aa5189Sbellard
4897d13299dSbellardfor opt do
490a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4917d13299dSbellard  case "$opt" in
4922efc3265Sbellard  --help|-h) show_help=yes
4932efc3265Sbellard  ;;
494b1a550a0Spbrook  --prefix=*) prefix="$optarg"
4957d13299dSbellard  ;;
496b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
49732ce6337Sbellard  ;;
498ca4deeb1SPaolo Bonzini  --source-path=*)
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  ;;
51874242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
51994a420b1SStefan Hajnoczi  ;;
52074242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
5219410b56cSPrerna Saxena  ;;
5227d13299dSbellard  --enable-gprof) gprof="yes"
5237d13299dSbellard  ;;
52479427693SLoïc Minier  --static)
52579427693SLoïc Minier    static="yes"
52679427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
52743ce4dfeSbellard  ;;
5280b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5290b24e75fSPaolo Bonzini  ;;
5300b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5310b24e75fSPaolo Bonzini  ;;
5320b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5330b24e75fSPaolo Bonzini  ;;
5340b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5350b24e75fSPaolo Bonzini  ;;
536ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
53707381cc1SAnthony Liguori  ;;
53897a847bcSbellard  --disable-sdl) sdl="no"
53997a847bcSbellard  ;;
540c4198157SJuan Quintela  --enable-sdl) sdl="yes"
541c4198157SJuan Quintela  ;;
542b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
543102a52e4Sbellard  ;;
544c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
545c2de5c91Smalc  ;;
5462f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5472f6a1ab0Sblueswir1  ;;
5482fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5490c58ac1cSmalc  ;;
5500c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5510c58ac1cSmalc  ;;
552eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
553eb852011SMarkus Armbruster  ;;
554f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
555f8393946Saurel32  ;;
556f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
557f8393946Saurel32  ;;
558b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
559b4475aa2SLuiz Capitulino  ;;
560b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
561b4475aa2SLuiz Capitulino  ;;
562f3d08ee6SPaul Brook  --enable-debug)
563f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
564f3d08ee6SPaul Brook      debug_tcg="yes"
565b4475aa2SLuiz Capitulino      debug_mon="yes"
566f3d08ee6SPaul Brook      debug="yes"
567f3d08ee6SPaul Brook      strip_opt="no"
568f3d08ee6SPaul Brook  ;;
56903b4fe7dSaliguori  --enable-sparse) sparse="yes"
57003b4fe7dSaliguori  ;;
57103b4fe7dSaliguori  --disable-sparse) sparse="no"
57203b4fe7dSaliguori  ;;
5731625af87Saliguori  --disable-strip) strip_opt="no"
5741625af87Saliguori  ;;
5758d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5768d5d2d4cSths  ;;
5771be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5781be10ad2SJuan Quintela  ;;
5792f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5802f9606b3Saliguori  ;;
581ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
582ea784e3bSJuan Quintela  ;;
5832f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
5842f6f5c7aSCorentin Chary  ;;
5852f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
5862f6f5c7aSCorentin Chary  ;;
587efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
588efe556adSCorentin Chary  ;;
589efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
590efe556adSCorentin Chary  ;;
591bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
592bd023f95SCorentin Chary  ;;
593bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
594bd023f95SCorentin Chary  ;;
595443f1376Sbellard  --disable-slirp) slirp="no"
596c20709aaSbellard  ;;
597ee682d27SStefan Weil  --disable-uuid) uuid="no"
598ee682d27SStefan Weil  ;;
599ee682d27SStefan Weil  --enable-uuid) uuid="yes"
600ee682d27SStefan Weil  ;;
601e0e6c8c0Saliguori  --disable-vde) vde="no"
6028a16d273Sths  ;;
603dfb278bdSJuan Quintela  --enable-vde) vde="yes"
604dfb278bdSJuan Quintela  ;;
605e37630caSaliguori  --disable-xen) xen="no"
606e37630caSaliguori  ;;
607fc321b4bSJuan Quintela  --enable-xen) xen="yes"
608fc321b4bSJuan Quintela  ;;
6092e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6102e4d9fb1Saurel32  ;;
6114ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6124ffcedb6SJuan Quintela  ;;
613fb599c9aSbalrog  --disable-bluez) bluez="no"
614fb599c9aSbalrog  ;;
615a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
616a20a6f46SJuan Quintela  ;;
6177ba1e619Saliguori  --disable-kvm) kvm="no"
6187ba1e619Saliguori  ;;
619b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
620b31a0277SJuan Quintela  ;;
621cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
622cd4ec0b4SGerd Hoffmann  ;;
623cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
624cd4ec0b4SGerd Hoffmann  ;;
62505c2a3e7Sbellard  --enable-profiler) profiler="yes"
62605c2a3e7Sbellard  ;;
627c2de5c91Smalc  --enable-cocoa)
628c2de5c91Smalc      cocoa="yes" ;
629c2de5c91Smalc      sdl="no" ;
630c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6315b0753e0Sbellard  ;;
632cad25d69Spbrook  --disable-system) softmmu="no"
6330a8e90f4Spbrook  ;;
634cad25d69Spbrook  --enable-system) softmmu="yes"
6350a8e90f4Spbrook  ;;
6360953a80fSZachary Amsden  --disable-user)
6370953a80fSZachary Amsden      linux_user="no" ;
6380953a80fSZachary Amsden      bsd_user="no" ;
6390953a80fSZachary Amsden      darwin_user="no"
6400953a80fSZachary Amsden  ;;
6410953a80fSZachary Amsden  --enable-user) ;;
642831b7825Sths  --disable-linux-user) linux_user="no"
6430a8e90f4Spbrook  ;;
644831b7825Sths  --enable-linux-user) linux_user="yes"
645831b7825Sths  ;;
646831b7825Sths  --disable-darwin-user) darwin_user="no"
647831b7825Sths  ;;
648831b7825Sths  --enable-darwin-user) darwin_user="yes"
6490a8e90f4Spbrook  ;;
65084778508Sblueswir1  --disable-bsd-user) bsd_user="no"
65184778508Sblueswir1  ;;
65284778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
65384778508Sblueswir1  ;;
654379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
655379f6698SPaul Brook  ;;
656379f6698SPaul Brook  --disable-guest-base) guest_base="no"
657379f6698SPaul Brook  ;;
65834005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
65934005a00SKirill A. Shutemov  ;;
66034005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
66134005a00SKirill A. Shutemov  ;;
662c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
663c5937220Spbrook  ;;
6643142255cSblueswir1  --sparc_cpu=*)
6653142255cSblueswir1  ;;
66685aa5189Sbellard  --enable-werror) werror="yes"
66785aa5189Sbellard  ;;
66885aa5189Sbellard  --disable-werror) werror="no"
66985aa5189Sbellard  ;;
6704d3b6f6eSbalrog  --disable-curses) curses="no"
6714d3b6f6eSbalrog  ;;
672c584a6d0SJuan Quintela  --enable-curses) curses="yes"
673c584a6d0SJuan Quintela  ;;
674769ce76dSAlexander Graf  --disable-curl) curl="no"
675769ce76dSAlexander Graf  ;;
676788c8196SJuan Quintela  --enable-curl) curl="yes"
677788c8196SJuan Quintela  ;;
6782df87df7SJuan Quintela  --disable-fdt) fdt="no"
6792df87df7SJuan Quintela  ;;
6802df87df7SJuan Quintela  --enable-fdt) fdt="yes"
6812df87df7SJuan Quintela  ;;
6825495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
6835495ed11SLuiz Capitulino  ;;
6845495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
6855495ed11SLuiz Capitulino  ;;
686bd0c5661Spbrook  --disable-nptl) nptl="no"
687bd0c5661Spbrook  ;;
688b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
689b0a47e79SJuan Quintela  ;;
6908ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
6918ff9cbf7Smalc  ;;
6925c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
6935c6c3a6cSChristoph Hellwig  ;;
6945c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
6955c6c3a6cSChristoph Hellwig  ;;
696758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
697758e8e38SVenkateswararao Jujjuri (JV)  ;;
698758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
699758e8e38SVenkateswararao Jujjuri (JV)  ;;
700e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
701e5d355d1Saliguori  ;;
70277755340Sths  --disable-blobs) blobs="no"
70377755340Sths  ;;
704eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
705eac30262Saliguori  ;;
7064a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7074a19f1ecSpbrook  ;;
708a25dba17SJuan Quintela  --disable-docs) docs="no"
70970ec5dc0SAnthony Liguori  ;;
710a25dba17SJuan Quintela  --enable-docs) docs="yes"
71183a3ab8bSJuan Quintela  ;;
712d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
713d5970055SMichael S. Tsirkin  ;;
714d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
715d5970055SMichael S. Tsirkin  ;;
7166bde81cbSPaolo Bonzini  --*dir)
7176bde81cbSPaolo Bonzini  ;;
718f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
719f27aaf4bSChristian Brunner  ;;
720f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
721f27aaf4bSChristian Brunner  ;;
7227f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7237f1559c6Sbalrog  ;;
7247d13299dSbellard  esac
7257d13299dSbellarddone
7267d13299dSbellard
7273142255cSblueswir1#
7283142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
729a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7303142255cSblueswir1#
731379f6698SPaul Brookhost_guest_base="no"
73240293e58Sbellardcase "$cpu" in
733ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
734ed968ff1SJuan Quintela           v7|v8)
735a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
736ed968ff1SJuan Quintela           ;;
737ed968ff1SJuan Quintela           v8plus|v8plusa)
738a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
739ed968ff1SJuan Quintela           ;;
740ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
741a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
742ed968ff1SJuan Quintela           esac
7430c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
744a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
745762e8230Sblueswir1           if test "$solaris" = "no" ; then
746a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
747c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
748762e8230Sblueswir1           fi
7493142255cSblueswir1           ;;
750ed968ff1SJuan Quintela    sparc64)
751a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7520c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
753a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
754ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
755a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
756762e8230Sblueswir1           fi
7573142255cSblueswir1           ;;
75876d83bdeSths    s390)
75928d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
76028d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
76148bb3750SRichard Henderson           host_guest_base="yes"
76228d7cc49SRichard Henderson           ;;
76328d7cc49SRichard Henderson    s390x)
76428d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
76528d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
76648bb3750SRichard Henderson           host_guest_base="yes"
76776d83bdeSths           ;;
76840293e58Sbellard    i386)
769a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7700c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
7712b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
772c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
773379f6698SPaul Brook           host_guest_base="yes"
77440293e58Sbellard           ;;
77540293e58Sbellard    x86_64)
776a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
7770c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
7782b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
779379f6698SPaul Brook           host_guest_base="yes"
780379f6698SPaul Brook           ;;
781379f6698SPaul Brook    arm*)
782379f6698SPaul Brook           host_guest_base="yes"
78340293e58Sbellard           ;;
784f6548c0aSmalc    ppc*)
785f6548c0aSmalc           host_guest_base="yes"
786f6548c0aSmalc           ;;
787cc01cc8eSAurelien Jarno    mips*)
788cc01cc8eSAurelien Jarno           host_guest_base="yes"
789cc01cc8eSAurelien Jarno           ;;
790477ba620SAurelien Jarno    ia64*)
791477ba620SAurelien Jarno           host_guest_base="yes"
792477ba620SAurelien Jarno           ;;
793fd76e73aSRichard Henderson    hppa*)
794fd76e73aSRichard Henderson           host_guest_base="yes"
795fd76e73aSRichard Henderson           ;;
7963142255cSblueswir1esac
7973142255cSblueswir1
798379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
799379f6698SPaul Brook
800af5db58eSpbrookif test x"$show_help" = x"yes" ; then
801af5db58eSpbrookcat << EOF
802af5db58eSpbrook
803af5db58eSpbrookUsage: configure [options]
804af5db58eSpbrookOptions: [defaults in brackets after descriptions]
805af5db58eSpbrook
806af5db58eSpbrookEOF
807af5db58eSpbrookecho "Standard options:"
808af5db58eSpbrookecho "  --help                   print this message"
809af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
810af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
811af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
812af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
813af5db58eSpbrookecho ""
814af5db58eSpbrookecho "Advanced options (experts only):"
815af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
816af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
817af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
8180bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
8190bfe8cc0SPaolo Bonziniecho "                           build time"
820a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
821e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
822af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
8236a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
824af5db58eSpbrookecho "  --static                 enable static build [$static]"
8250b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
8260b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
8270b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
8280b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
8290b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
830f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
831f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
83209695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
833890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
834890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
8351625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
83685aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
837fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
838c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
839af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
840c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
841c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
8424c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
8434c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
844eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
845eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
8468ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
847e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
848fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
8492e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
8504ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
8518d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
8521be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
8532f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
854ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
8552f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
8562f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
85796763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
858efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
859bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
860bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
861af896aaaSpbrookecho "  --disable-curses         disable curses output"
862c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
863769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
864788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
8652df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
8662df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
8675495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
8685495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
869fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
870a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
8717ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
872b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
873bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
874e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
875af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
876af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
8770953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
8780953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
879831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
880831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
881831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
882831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
88384778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
88484778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
885379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
886379f6698SPaul Brookecho "                           emulation targets"
887379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
88834005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
88934005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
890af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
891af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
8922f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
893c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
8943142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
895ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
896ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
897e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
898dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
8995c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
9005c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
901758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
902758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
903e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
90477755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
905eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
906d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
907d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
908d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
909d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
91074242e0fSPaolo Bonziniecho "  --enable-trace-backend=B Trace backend nop simple ust dtrace"
91174242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
9129410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
913cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
914cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
915f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
916af5db58eSpbrookecho ""
9175bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
918af5db58eSpbrookexit 1
919af5db58eSpbrookfi
920af5db58eSpbrook
9218d05095cSPaolo Bonzini# check that the C compiler works.
9228d05095cSPaolo Bonzinicat > $TMPC <<EOF
9238d05095cSPaolo Bonziniint main(void) {}
9248d05095cSPaolo BonziniEOF
9258d05095cSPaolo Bonzini
9268d05095cSPaolo Bonziniif compile_object ; then
9278d05095cSPaolo Bonzini  : C compiler works ok
9288d05095cSPaolo Bonzinielse
9298d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
9308d05095cSPaolo Bonzini    exit 1
9318d05095cSPaolo Bonzinifi
9328d05095cSPaolo Bonzini
9338d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
9348d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
9358d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
9368d05095cSPaolo Bonzinigcc_flags="-fstack-protector-all $gcc_flags"
9378d05095cSPaolo Bonzinicat > $TMPC << EOF
9388d05095cSPaolo Bonziniint main(void) { return 0; }
9398d05095cSPaolo BonziniEOF
9408d05095cSPaolo Bonzinifor flag in $gcc_flags; do
9418d05095cSPaolo Bonzini    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
9428d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
9438d05095cSPaolo Bonzini    fi
9448d05095cSPaolo Bonzinidone
9458d05095cSPaolo Bonzini
946ec530c81Sbellard#
947ec530c81Sbellard# Solaris specific configure tool chain decisions
948ec530c81Sbellard#
949ec530c81Sbellardif test "$solaris" = "yes" ; then
9506792aa11SLoïc Minier  if has $install; then
9516792aa11SLoïc Minier    :
9526792aa11SLoïc Minier  else
953ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
954ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
955ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
956ec530c81Sbellard    exit 1
957ec530c81Sbellard  fi
9586792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
959ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
960ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
961ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
962ec530c81Sbellard    exit 1
963ec530c81Sbellard  fi
9646792aa11SLoïc Minier  if has ar; then
9656792aa11SLoïc Minier    :
9666792aa11SLoïc Minier  else
967ec530c81Sbellard    echo "Error: No path includes ar"
968ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
969ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
970ec530c81Sbellard    fi
971ec530c81Sbellard    exit 1
972ec530c81Sbellard  fi
973ec530c81Sbellardfi
974ec530c81Sbellard
975ec530c81Sbellard
9765327cf48Sbellardif test -z "$target_list" ; then
9775327cf48Sbellard# these targets are portable
9780a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
9792408a527Saurel32        target_list="\
9802408a527Saurel32i386-softmmu \
9812408a527Saurel32x86_64-softmmu \
9822408a527Saurel32arm-softmmu \
9832408a527Saurel32cris-softmmu \
9842408a527Saurel32m68k-softmmu \
98572b675caSEdgar E. Iglesiasmicroblaze-softmmu \
9862408a527Saurel32mips-softmmu \
9872408a527Saurel32mipsel-softmmu \
9882408a527Saurel32mips64-softmmu \
9892408a527Saurel32mips64el-softmmu \
9902408a527Saurel32ppc-softmmu \
9912408a527Saurel32ppcemb-softmmu \
9922408a527Saurel32ppc64-softmmu \
9932408a527Saurel32sh4-softmmu \
9942408a527Saurel32sh4eb-softmmu \
9952408a527Saurel32sparc-softmmu \
9961b64fcaeSIgor V. Kovalenkosparc64-softmmu \
9972408a527Saurel32"
9980a8e90f4Spbrook    fi
9995327cf48Sbellard# the following are Linux specific
1000831b7825Sths    if [ "$linux_user" = "yes" ] ; then
10012408a527Saurel32        target_list="${target_list}\
10022408a527Saurel32i386-linux-user \
10032408a527Saurel32x86_64-linux-user \
10042408a527Saurel32alpha-linux-user \
10052408a527Saurel32arm-linux-user \
10062408a527Saurel32armeb-linux-user \
10072408a527Saurel32cris-linux-user \
10082408a527Saurel32m68k-linux-user \
100972b675caSEdgar E. Iglesiasmicroblaze-linux-user \
10102408a527Saurel32mips-linux-user \
10112408a527Saurel32mipsel-linux-user \
10122408a527Saurel32ppc-linux-user \
10132408a527Saurel32ppc64-linux-user \
10142408a527Saurel32ppc64abi32-linux-user \
10152408a527Saurel32sh4-linux-user \
10162408a527Saurel32sh4eb-linux-user \
10172408a527Saurel32sparc-linux-user \
10182408a527Saurel32sparc64-linux-user \
10192408a527Saurel32sparc32plus-linux-user \
10202408a527Saurel32"
1021831b7825Sths    fi
1022831b7825Sths# the following are Darwin specific
1023831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
10242408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
10255327cf48Sbellard    fi
102684778508Sblueswir1# the following are BSD specific
102784778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
102884778508Sblueswir1        target_list="${target_list}\
102931fc12dfSblueswir1i386-bsd-user \
103031fc12dfSblueswir1x86_64-bsd-user \
103131fc12dfSblueswir1sparc-bsd-user \
103284778508Sblueswir1sparc64-bsd-user \
103384778508Sblueswir1"
103484778508Sblueswir1    fi
10356e20a45fSbellardelse
1036b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
10375327cf48Sbellardfi
10380a8e90f4Spbrookif test -z "$target_list" ; then
10390a8e90f4Spbrook    echo "No targets enabled"
10400a8e90f4Spbrook    exit 1
10410a8e90f4Spbrookfi
1042f55fe278SPaolo Bonzini# see if system emulation was really requested
1043f55fe278SPaolo Bonzinicase " $target_list " in
1044f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1045f55fe278SPaolo Bonzini  ;;
1046f55fe278SPaolo Bonzini  *) softmmu=no
1047f55fe278SPaolo Bonzini  ;;
1048f55fe278SPaolo Bonziniesac
10495327cf48Sbellard
1050249247c9SJuan Quintelafeature_not_found() {
1051249247c9SJuan Quintela  feature=$1
1052249247c9SJuan Quintela
1053249247c9SJuan Quintela  echo "ERROR"
1054249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
10559332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1056249247c9SJuan Quintela  echo "ERROR"
1057249247c9SJuan Quintela  exit 1;
1058249247c9SJuan Quintela}
1059249247c9SJuan Quintela
10607d13299dSbellardif test -z "$cross_prefix" ; then
10617d13299dSbellard
10627d13299dSbellard# ---
10637d13299dSbellard# big/little endian test
10647d13299dSbellardcat > $TMPC << EOF
10657d13299dSbellard#include <inttypes.h>
10667d13299dSbellardint main(int argc, char ** argv){
10677d13299dSbellard        volatile uint32_t i=0x01234567;
10687d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
10697d13299dSbellard}
10707d13299dSbellardEOF
10717d13299dSbellard
107252166aa0SJuan Quintelaif compile_prog "" "" ; then
10737d13299dSbellard$TMPE && bigendian="yes"
10747d13299dSbellardelse
10757d13299dSbellardecho big/little test failed
10767d13299dSbellardfi
10777d13299dSbellard
10787d13299dSbellardelse
10797d13299dSbellard
10807d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1081ea8f20f8SJuan Quintelacase "$cpu" in
108224e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1083ea8f20f8SJuan Quintela    bigendian=yes
1084ea8f20f8SJuan Quintela  ;;
1085ea8f20f8SJuan Quintelaesac
10867d13299dSbellard
10877d13299dSbellardfi
10887d13299dSbellard
108970be1a2eSPaolo Bonzini# host long bits test, actually a pointer size test
109070be1a2eSPaolo Bonzinicat > $TMPC << EOF
109170be1a2eSPaolo Bonziniint sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
109270be1a2eSPaolo BonziniEOF
109370be1a2eSPaolo Bonziniif compile_object; then
1094ea8f20f8SJuan Quintelahostlongbits=64
109570be1a2eSPaolo Bonzinielse
109670be1a2eSPaolo Bonzinihostlongbits=32
109770be1a2eSPaolo Bonzinifi
1098b6853697Sbellard
1099b0a47e79SJuan Quintela
1100b0a47e79SJuan Quintela##########################################
1101b0a47e79SJuan Quintela# NPTL probe
1102b0a47e79SJuan Quintela
1103b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1104bd0c5661Spbrook  cat > $TMPC <<EOF
1105bd0c5661Spbrook#include <sched.h>
110630813ceaSpbrook#include <linux/futex.h>
1107bd0c5661Spbrookvoid foo()
1108bd0c5661Spbrook{
1109bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1110bd0c5661Spbrook#error bork
1111bd0c5661Spbrook#endif
1112bd0c5661Spbrook}
1113bd0c5661SpbrookEOF
1114bd0c5661Spbrook
111552166aa0SJuan Quintela  if compile_object ; then
1116b0a47e79SJuan Quintela    nptl=yes
1117bd0c5661Spbrook  else
1118b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1119b0a47e79SJuan Quintela      feature_not_found "nptl"
1120b0a47e79SJuan Quintela    fi
1121b0a47e79SJuan Quintela    nptl=no
1122b0a47e79SJuan Quintela  fi
1123bd0c5661Spbrookfi
1124bd0c5661Spbrook
112511d9f695Sbellard##########################################
1126ac62922eSbalrog# zlib check
1127ac62922eSbalrog
1128ac62922eSbalrogcat > $TMPC << EOF
1129ac62922eSbalrog#include <zlib.h>
1130ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1131ac62922eSbalrogEOF
113252166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1133ac62922eSbalrog    :
1134ac62922eSbalrogelse
1135ac62922eSbalrog    echo
1136ac62922eSbalrog    echo "Error: zlib check failed"
1137ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1138ac62922eSbalrog    echo
1139ac62922eSbalrog    exit 1
1140ac62922eSbalrogfi
1141ac62922eSbalrog
1142ac62922eSbalrog##########################################
1143e37630caSaliguori# xen probe
1144e37630caSaliguori
1145fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1146b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1147e37630caSaliguori  cat > $TMPC <<EOF
1148e37630caSaliguori#include <xenctrl.h>
1149e37630caSaliguori#include <xs.h>
1150df7a607bSChristoph Eggerint main(void) { xs_daemon_open(); xc_interface_open(); return 0; }
1151e37630caSaliguoriEOF
115252166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1153fc321b4bSJuan Quintela    xen=yes
11543efd632bSJuan Quintela    libs_softmmu="$xen_libs $libs_softmmu"
1155e37630caSaliguori  else
1156fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1157fc321b4bSJuan Quintela      feature_not_found "xen"
1158fc321b4bSJuan Quintela    fi
1159fc321b4bSJuan Quintela    xen=no
1160e37630caSaliguori  fi
1161e37630caSaliguorifi
1162e37630caSaliguori
1163e37630caSaliguori##########################################
1164a8bd70adSPaolo Bonzini# pkg-config probe
1165f91672e5SPaolo Bonzini
1166a8bd70adSPaolo Bonziniif ! has $pkg_config; then
116708421541SPaolo Bonzini  echo warning: proceeding without "$pkg_config" >&2
116808421541SPaolo Bonzini  pkg_config=/bin/false
1169f91672e5SPaolo Bonzinifi
1170f91672e5SPaolo Bonzini
1171f91672e5SPaolo Bonzini##########################################
1172dfffc653SJuan Quintela# Sparse probe
1173dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
11740dba6195SLoïc Minier  if has cgcc; then
1175dfffc653SJuan Quintela    sparse=yes
1176dfffc653SJuan Quintela  else
1177dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1178dfffc653SJuan Quintela      feature_not_found "sparse"
1179dfffc653SJuan Quintela    fi
1180dfffc653SJuan Quintela    sparse=no
1181dfffc653SJuan Quintela  fi
1182dfffc653SJuan Quintelafi
1183dfffc653SJuan Quintela
1184dfffc653SJuan Quintela##########################################
118511d9f695Sbellard# SDL probe
118611d9f695Sbellard
11873ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
11883ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
11893ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
11903ec87ffeSPaolo Bonzini  sdl_config=sdl-config
11913ec87ffeSPaolo Bonzinifi
11923ec87ffeSPaolo Bonzini
11933ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1194a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1195fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
11963ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
11973ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
11989316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1199a0dfd8a4SLoïc Minierelse
1200a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1201a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1202a0dfd8a4SLoïc Minier  fi
1203a0dfd8a4SLoïc Minier  sdl=no
12049316f803SPaolo Bonzinifi
12053ec87ffeSPaolo Bonziniif test -n "$cross_prefix" && test "`basename $sdlconfig`" = sdl-config; then
12063ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
12073ec87ffeSPaolo Bonzinifi
120811d9f695Sbellard
12099316f803SPaolo Bonzinisdl_too_old=no
1210c4198157SJuan Quintelaif test "$sdl" != "no" ; then
121111d9f695Sbellard  cat > $TMPC << EOF
121211d9f695Sbellard#include <SDL.h>
121311d9f695Sbellard#undef main /* We don't want SDL to override our main() */
121411d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
121511d9f695SbellardEOF
12169316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
121774f42e18STeLeMan  if test "$static" = "yes" ; then
121874f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
121974f42e18STeLeMan  else
12209316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
122174f42e18STeLeMan  fi
122252166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
122311d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
122411d9f695Sbellard      sdl_too_old=yes
122511d9f695Sbellard    else
1226fd677642Sths      if test "$cocoa" = "no" ; then
122711d9f695Sbellard        sdl=yes
122811d9f695Sbellard      fi
1229fd677642Sths    fi
12307c1f25b4Sbellard
123167c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
12321ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
123367c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1234f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1235f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
123611d9f695Sbellard      fi
123752166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
12381ac88f28SJuan Quintela	:
12391ac88f28SJuan Quintela      else
12401ac88f28SJuan Quintela        sdl=no
12417c1f25b4Sbellard      fi
12427c1f25b4Sbellard    fi # static link
1243c4198157SJuan Quintela  else # sdl not found
1244c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1245c4198157SJuan Quintela      feature_not_found "sdl"
1246c4198157SJuan Quintela    fi
1247c4198157SJuan Quintela    sdl=no
12487c1f25b4Sbellard  fi # sdl compile test
1249fd677642Sthsfi
125011d9f695Sbellard
12515368a422Saliguoriif test "$sdl" = "yes" ; then
12525368a422Saliguori  cat > $TMPC <<EOF
12535368a422Saliguori#include <SDL.h>
12545368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
12555368a422Saliguori#include <X11/XKBlib.h>
12565368a422Saliguori#else
12575368a422Saliguori#error No x11 support
12585368a422Saliguori#endif
12595368a422Saliguoriint main(void) { return 0; }
12605368a422SaliguoriEOF
126152166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1262681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
12635368a422Saliguori  fi
126407d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
126507d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
126607d9ac44SJuan Quintela  fi
12670705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
12685368a422Saliguorifi
12695368a422Saliguori
12708f28f3fbSths##########################################
12718d5d2d4cSths# VNC TLS detection
12721be10ad2SJuan Quintelaif test "$vnc_tls" != "no" ; then
1273ae6b5e5aSaliguori  cat > $TMPC <<EOF
1274ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1275ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1276ae6b5e5aSaliguoriEOF
1277a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1278a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
127952166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
12801be10ad2SJuan Quintela    vnc_tls=yes
1281a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1282ae6b5e5aSaliguori  else
12831be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
12841be10ad2SJuan Quintela      feature_not_found "vnc-tls"
12851be10ad2SJuan Quintela    fi
12861be10ad2SJuan Quintela    vnc_tls=no
12878d5d2d4cSths  fi
12888d5d2d4cSthsfi
12898d5d2d4cSths
12908d5d2d4cSths##########################################
12912f9606b3Saliguori# VNC SASL detection
12923aefa744SJuan Quintelaif test "$vnc_sasl" != "no" ; then
12932f9606b3Saliguori  cat > $TMPC <<EOF
12942f9606b3Saliguori#include <sasl/sasl.h>
12952f9606b3Saliguori#include <stdio.h>
12962f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
12972f9606b3SaliguoriEOF
12982f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
12992f9606b3Saliguori  vnc_sasl_cflags=""
13002f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
130152166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1302ea784e3bSJuan Quintela    vnc_sasl=yes
1303fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
13042f9606b3Saliguori  else
1305ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1306ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1307ea784e3bSJuan Quintela    fi
1308ea784e3bSJuan Quintela    vnc_sasl=no
13092f9606b3Saliguori  fi
13102f9606b3Saliguorifi
13112f9606b3Saliguori
13122f9606b3Saliguori##########################################
13132f6f5c7aSCorentin Chary# VNC JPEG detection
131496763cf9SCorentin Charyif test "$vnc_jpeg" != "no" ; then
13152f6f5c7aSCorentin Charycat > $TMPC <<EOF
13162f6f5c7aSCorentin Chary#include <stdio.h>
13172f6f5c7aSCorentin Chary#include <jpeglib.h>
13182f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
13192f6f5c7aSCorentin CharyEOF
13202f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
13212f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
13222f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
13232f6f5c7aSCorentin Chary    vnc_jpeg=yes
13242f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
13252f6f5c7aSCorentin Chary  else
13262f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
13272f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
13282f6f5c7aSCorentin Chary    fi
13292f6f5c7aSCorentin Chary    vnc_jpeg=no
13302f6f5c7aSCorentin Chary  fi
13312f6f5c7aSCorentin Charyfi
13322f6f5c7aSCorentin Chary
13332f6f5c7aSCorentin Chary##########################################
1334efe556adSCorentin Chary# VNC PNG detection
133596763cf9SCorentin Charyif test "$vnc_png" != "no" ; then
1336efe556adSCorentin Charycat > $TMPC <<EOF
1337efe556adSCorentin Chary//#include <stdio.h>
1338efe556adSCorentin Chary#include <png.h>
1339832ce9c2SScott Wood#include <stddef.h>
1340efe556adSCorentin Charyint main(void) {
1341efe556adSCorentin Chary    png_structp png_ptr;
1342efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1343efe556adSCorentin Chary    return 0;
1344efe556adSCorentin Chary}
1345efe556adSCorentin CharyEOF
1346efe556adSCorentin Chary    vnc_png_cflags=""
1347efe556adSCorentin Chary    vnc_png_libs="-lpng"
1348efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1349efe556adSCorentin Chary    vnc_png=yes
1350efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
1351efe556adSCorentin Chary  else
1352efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1353efe556adSCorentin Chary      feature_not_found "vnc-png"
1354efe556adSCorentin Chary    fi
1355efe556adSCorentin Chary    vnc_png=no
1356efe556adSCorentin Chary  fi
1357efe556adSCorentin Charyfi
1358efe556adSCorentin Chary
1359efe556adSCorentin Chary##########################################
136076655d6dSaliguori# fnmatch() probe, used for ACL routines
136176655d6dSaliguorifnmatch="no"
136276655d6dSaliguoricat > $TMPC << EOF
136376655d6dSaliguori#include <fnmatch.h>
136476655d6dSaliguoriint main(void)
136576655d6dSaliguori{
136676655d6dSaliguori    fnmatch("foo", "foo", 0);
136776655d6dSaliguori    return 0;
136876655d6dSaliguori}
136976655d6dSaliguoriEOF
137052166aa0SJuan Quintelaif compile_prog "" "" ; then
137176655d6dSaliguori   fnmatch="yes"
137276655d6dSaliguorifi
137376655d6dSaliguori
137476655d6dSaliguori##########################################
1375ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1376ee682d27SStefan Weilif test "$uuid" != "no" ; then
1377ee682d27SStefan Weil  uuid_libs="-luuid"
1378ee682d27SStefan Weil  cat > $TMPC << EOF
1379ee682d27SStefan Weil#include <uuid/uuid.h>
1380ee682d27SStefan Weilint main(void)
1381ee682d27SStefan Weil{
1382ee682d27SStefan Weil    uuid_t my_uuid;
1383ee682d27SStefan Weil    uuid_generate(my_uuid);
1384ee682d27SStefan Weil    return 0;
1385ee682d27SStefan Weil}
1386ee682d27SStefan WeilEOF
1387ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1388ee682d27SStefan Weil    uuid="yes"
1389ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1390ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1391ee682d27SStefan Weil  else
1392ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1393ee682d27SStefan Weil      feature_not_found "uuid"
1394ee682d27SStefan Weil    fi
1395ee682d27SStefan Weil    uuid=no
1396ee682d27SStefan Weil  fi
1397ee682d27SStefan Weilfi
1398ee682d27SStefan Weil
1399ee682d27SStefan Weil##########################################
1400dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1401dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1402dce512deSChristoph Hellwig  cat > $TMPC << EOF
1403dce512deSChristoph Hellwig#include <xfs/xfs.h>
1404dce512deSChristoph Hellwigint main(void)
1405dce512deSChristoph Hellwig{
1406dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1407dce512deSChristoph Hellwig    return 0;
1408dce512deSChristoph Hellwig}
1409dce512deSChristoph HellwigEOF
1410dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1411dce512deSChristoph Hellwig    xfs="yes"
1412dce512deSChristoph Hellwig  else
1413dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1414dce512deSChristoph Hellwig      feature_not_found "xfs"
1415dce512deSChristoph Hellwig    fi
1416dce512deSChristoph Hellwig    xfs=no
1417dce512deSChristoph Hellwig  fi
1418dce512deSChristoph Hellwigfi
1419dce512deSChristoph Hellwig
1420dce512deSChristoph Hellwig##########################################
14218a16d273Sths# vde libraries probe
1422dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
14234baae0acSJuan Quintela  vde_libs="-lvdeplug"
14248a16d273Sths  cat > $TMPC << EOF
14258a16d273Sths#include <libvdeplug.h>
14264a7f0e06Spbrookint main(void)
14274a7f0e06Spbrook{
14284a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
14294a7f0e06Spbrook    vde_open("", "", &a);
14304a7f0e06Spbrook    return 0;
14314a7f0e06Spbrook}
14328a16d273SthsEOF
143352166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
14344baae0acSJuan Quintela    vde=yes
14358e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
14368e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1437dfb278bdSJuan Quintela  else
1438dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1439dfb278bdSJuan Quintela      feature_not_found "vde"
1440dfb278bdSJuan Quintela    fi
1441dfb278bdSJuan Quintela    vde=no
14428a16d273Sths  fi
14438a16d273Sthsfi
14448a16d273Sths
14458a16d273Sths##########################################
1446c2de5c91Smalc# Sound support libraries probe
14478f28f3fbSths
1448c2de5c91Smalcaudio_drv_probe()
1449c2de5c91Smalc{
1450c2de5c91Smalc    drv=$1
1451c2de5c91Smalc    hdr=$2
1452c2de5c91Smalc    lib=$3
1453c2de5c91Smalc    exp=$4
1454c2de5c91Smalc    cfl=$5
14558f28f3fbSths        cat > $TMPC << EOF
1456c2de5c91Smalc#include <$hdr>
1457c2de5c91Smalcint main(void) { $exp }
14588f28f3fbSthsEOF
145952166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
14608f28f3fbSths        :
14618f28f3fbSths    else
14628f28f3fbSths        echo
1463c2de5c91Smalc        echo "Error: $drv check failed"
1464c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
14658f28f3fbSths        echo
14668f28f3fbSths        exit 1
14678f28f3fbSths    fi
1468c2de5c91Smalc}
1469c2de5c91Smalc
14702fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1471c2de5c91Smalcfor drv in $audio_drv_list; do
1472c2de5c91Smalc    case $drv in
1473c2de5c91Smalc    alsa)
1474c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1475c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1476a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1477c2de5c91Smalc    ;;
1478c2de5c91Smalc
1479c2de5c91Smalc    fmod)
1480c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1481c2de5c91Smalc        echo
1482c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1483c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1484c2de5c91Smalc        echo
1485c2de5c91Smalc        exit 1
14868f28f3fbSths    fi
1487c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1488a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1489c2de5c91Smalc    ;;
1490c2de5c91Smalc
1491c2de5c91Smalc    esd)
1492c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1493a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
149467f86e8eSJuan Quintela    audio_pt_int="yes"
1495c2de5c91Smalc    ;;
1496b8e59f18Smalc
1497b8e59f18Smalc    pa)
1498493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1499b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1500493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
150167f86e8eSJuan Quintela    audio_pt_int="yes"
1502b8e59f18Smalc    ;;
1503b8e59f18Smalc
1504997e690aSJuan Quintela    coreaudio)
1505997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1506997e690aSJuan Quintela    ;;
1507997e690aSJuan Quintela
1508a4bf6780SJuan Quintela    dsound)
1509a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1510d5631638Smalc      audio_win_int="yes"
1511a4bf6780SJuan Quintela    ;;
1512a4bf6780SJuan Quintela
1513a4bf6780SJuan Quintela    oss)
1514a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1515a4bf6780SJuan Quintela    ;;
1516a4bf6780SJuan Quintela
1517a4bf6780SJuan Quintela    sdl|wav)
15182f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
15192f6a1ab0Sblueswir1    ;;
15202f6a1ab0Sblueswir1
1521d5631638Smalc    winwave)
1522d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1523d5631638Smalc      audio_win_int="yes"
1524d5631638Smalc    ;;
1525d5631638Smalc
1526e4c63a6aSmalc    *)
15271c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1528e4c63a6aSmalc        echo
1529e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1530e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1531e4c63a6aSmalc        echo
1532e4c63a6aSmalc        exit 1
1533e4c63a6aSmalc    }
1534e4c63a6aSmalc    ;;
1535c2de5c91Smalc    esac
1536c2de5c91Smalcdone
15378f28f3fbSths
15384d3b6f6eSbalrog##########################################
15392e4d9fb1Saurel32# BrlAPI probe
15402e4d9fb1Saurel32
15414ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1542eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
15432e4d9fb1Saurel32  cat > $TMPC << EOF
15442e4d9fb1Saurel32#include <brlapi.h>
1545832ce9c2SScott Wood#include <stddef.h>
15462e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
15472e4d9fb1Saurel32EOF
154852166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
15492e4d9fb1Saurel32    brlapi=yes
1550264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
15514ffcedb6SJuan Quintela  else
15524ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
15534ffcedb6SJuan Quintela      feature_not_found "brlapi"
15544ffcedb6SJuan Quintela    fi
15554ffcedb6SJuan Quintela    brlapi=no
1556eb82284fSJuan Quintela  fi
1557eb82284fSJuan Quintelafi
15582e4d9fb1Saurel32
15592e4d9fb1Saurel32##########################################
15604d3b6f6eSbalrog# curses probe
15614f78ef9aSJuan Quintelacurses_list="-lncurses -lcurses"
15624d3b6f6eSbalrog
1563c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1564c584a6d0SJuan Quintela  curses_found=no
15654d3b6f6eSbalrog  cat > $TMPC << EOF
15664d3b6f6eSbalrog#include <curses.h>
15675a8ff3aaSblueswir1#ifdef __OpenBSD__
15685a8ff3aaSblueswir1#define resize_term resizeterm
15695a8ff3aaSblueswir1#endif
15705a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
15714d3b6f6eSbalrogEOF
15724f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
15734f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1574c584a6d0SJuan Quintela      curses_found=yes
15754f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
15764f78ef9aSJuan Quintela      break
15774d3b6f6eSbalrog    fi
15784f78ef9aSJuan Quintela  done
1579c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1580c584a6d0SJuan Quintela    curses=yes
1581c584a6d0SJuan Quintela  else
1582c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1583c584a6d0SJuan Quintela      feature_not_found "curses"
1584c584a6d0SJuan Quintela    fi
1585c584a6d0SJuan Quintela    curses=no
1586c584a6d0SJuan Quintela  fi
15874f78ef9aSJuan Quintelafi
15884d3b6f6eSbalrog
1589414f0dabSblueswir1##########################################
1590769ce76dSAlexander Graf# curl probe
1591769ce76dSAlexander Graf
1592a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
1593a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
15944e2b0658SPaolo Bonzinielse
15954e2b0658SPaolo Bonzini  curlconfig=curl-config
15964e2b0658SPaolo Bonzinifi
15974e2b0658SPaolo Bonzini
1598788c8196SJuan Quintelaif test "$curl" != "no" ; then
1599769ce76dSAlexander Graf  cat > $TMPC << EOF
1600769ce76dSAlexander Graf#include <curl/curl.h>
1601769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1602769ce76dSAlexander GrafEOF
16034e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
16044e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1605b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1606769ce76dSAlexander Graf    curl=yes
1607f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1608f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1609788c8196SJuan Quintela  else
1610788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1611788c8196SJuan Quintela      feature_not_found "curl"
1612788c8196SJuan Quintela    fi
1613788c8196SJuan Quintela    curl=no
1614769ce76dSAlexander Graf  fi
1615769ce76dSAlexander Graffi # test "$curl"
1616769ce76dSAlexander Graf
1617769ce76dSAlexander Graf##########################################
16185495ed11SLuiz Capitulino# check framework probe
16195495ed11SLuiz Capitulino
16205495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
16215495ed11SLuiz Capitulino  cat > $TMPC << EOF
16225495ed11SLuiz Capitulino#include <check.h>
16235495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
16245495ed11SLuiz CapitulinoEOF
1625a8bd70adSPaolo Bonzini  check_libs=`$pkg_config --libs check`
16265495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
16275495ed11SLuiz Capitulino    check_utests=yes
16285495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
16295495ed11SLuiz Capitulino  else
16305495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
16315495ed11SLuiz Capitulino      feature_not_found "check"
16325495ed11SLuiz Capitulino    fi
16335495ed11SLuiz Capitulino    check_utests=no
16345495ed11SLuiz Capitulino  fi
16355495ed11SLuiz Capitulinofi # test "$check_utests"
16365495ed11SLuiz Capitulino
16375495ed11SLuiz Capitulino##########################################
1638fb599c9aSbalrog# bluez support probe
1639a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1640e820e3f4Sbalrog  cat > $TMPC << EOF
1641e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1642e820e3f4Sbalrogint main(void) { return bt_error(0); }
1643e820e3f4SbalrogEOF
1644a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1645a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
164652166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1647a20a6f46SJuan Quintela    bluez=yes
1648e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1649e820e3f4Sbalrog  else
1650a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1651a20a6f46SJuan Quintela      feature_not_found "bluez"
1652a20a6f46SJuan Quintela    fi
1653e820e3f4Sbalrog    bluez="no"
1654e820e3f4Sbalrog  fi
1655fb599c9aSbalrogfi
1656fb599c9aSbalrog
1657fb599c9aSbalrog##########################################
16587ba1e619Saliguori# kvm probe
1659b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
16607ba1e619Saliguori    cat > $TMPC <<EOF
16617ba1e619Saliguori#include <linux/kvm.h>
16629fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
16637ba1e619Saliguori#error Invalid KVM version
16647ba1e619Saliguori#endif
16659fd8d8d7Saliguori#if !defined(KVM_CAP_USER_MEMORY)
16669fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_USER_MEMORY
16679fd8d8d7Saliguori#endif
16689fd8d8d7Saliguori#if !defined(KVM_CAP_SET_TSS_ADDR)
16699fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_SET_TSS_ADDR
16709fd8d8d7Saliguori#endif
16719fd8d8d7Saliguori#if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS)
16729fd8d8d7Saliguori#error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS
16739fd8d8d7Saliguori#endif
16747ba1e619Saliguoriint main(void) { return 0; }
16757ba1e619SaliguoriEOF
1676eac30262Saliguori  if test "$kerneldir" != "" ; then
1677eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
16788444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
16798444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
16808444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1681406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1682406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
16830e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
16840e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
16858444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
16868444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
16878444eb6eSaliguori      fi
1688eac30262Saliguori  else
1689a8bd70adSPaolo Bonzini    kvm_cflags=`$pkg_config --cflags kvm-kmod 2>/dev/null`
1690eac30262Saliguori  fi
169152166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1692b31a0277SJuan Quintela    kvm=yes
1693dae5079aSJan Kiszka    cat > $TMPC <<EOF
1694dae5079aSJan Kiszka#include <linux/kvm_para.h>
1695dae5079aSJan Kiszkaint main(void) { return 0; }
1696dae5079aSJan KiszkaEOF
1697dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1698dae5079aSJan Kiszka      kvm_para=yes
1699dae5079aSJan Kiszka    fi
17007ba1e619Saliguori  else
1701b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
17020dba6195SLoïc Minier      if has awk && has grep; then
1703a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
17049fd8d8d7Saliguori	| grep "error: " \
17059fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
17069fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1707b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1708168ccc11SJan Kiszka      NOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1709168ccc11SJan Kiszka  recent kvm-kmod from http://sourceforge.net/projects/kvm."
17109fd8d8d7Saliguori        fi
17119fd8d8d7Saliguori      fi
1712b31a0277SJuan Quintela      feature_not_found "kvm"
1713b31a0277SJuan Quintela    fi
1714b31a0277SJuan Quintela    kvm=no
17157ba1e619Saliguori  fi
17167ba1e619Saliguorifi
17177ba1e619Saliguori
17187ba1e619Saliguori##########################################
1719d5970055SMichael S. Tsirkin# test for vhost net
1720d5970055SMichael S. Tsirkin
1721d5970055SMichael S. Tsirkinif test "$vhost_net" != "no"; then
1722d5970055SMichael S. Tsirkin    if test "$kvm" != "no"; then
1723d5970055SMichael S. Tsirkin            cat > $TMPC <<EOF
1724d5970055SMichael S. Tsirkin    #include <linux/vhost.h>
1725d5970055SMichael S. Tsirkin    int main(void) { return 0; }
1726d5970055SMichael S. TsirkinEOF
1727d5970055SMichael S. Tsirkin            if compile_prog "$kvm_cflags" "" ; then
1728d5970055SMichael S. Tsirkin                vhost_net=yes
1729d5970055SMichael S. Tsirkin            else
1730d5970055SMichael S. Tsirkin                if test "$vhost_net" = "yes" ; then
1731d5970055SMichael S. Tsirkin                    feature_not_found "vhost-net"
1732d5970055SMichael S. Tsirkin                fi
1733d5970055SMichael S. Tsirkin                vhost_net=no
1734d5970055SMichael S. Tsirkin            fi
1735d5970055SMichael S. Tsirkin    else
1736d5970055SMichael S. Tsirkin            if test "$vhost_net" = "yes" ; then
17374021d247SAurelien Jarno                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1738d5970055SMichael S. Tsirkin                feature_not_found "vhost-net"
1739d5970055SMichael S. Tsirkin            fi
1740d5970055SMichael S. Tsirkin            vhost_net=no
1741d5970055SMichael S. Tsirkin    fi
1742d5970055SMichael S. Tsirkinfi
1743d5970055SMichael S. Tsirkin
1744d5970055SMichael S. Tsirkin##########################################
1745e5d355d1Saliguori# pthread probe
1746de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
17473c529d93Saliguori
1748e5d355d1Saliguoripthread=no
1749414f0dabSblueswir1cat > $TMPC << EOF
17503c529d93Saliguori#include <pthread.h>
1751de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1752414f0dabSblueswir1EOF
1753bd00d539SAndreas Färberif compile_prog "" "" ; then
1754bd00d539SAndreas Färber  pthread=yes
1755bd00d539SAndreas Färberelse
1756de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
175752166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1758e5d355d1Saliguori      pthread=yes
17595572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1760de65fe0fSSebastian Herbszt      break
1761414f0dabSblueswir1    fi
1762de65fe0fSSebastian Herbszt  done
1763bd00d539SAndreas Färberfi
1764414f0dabSblueswir1
17654617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
17664dd75c70SChristoph Hellwig  echo
17674dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
17684dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
17694dd75c70SChristoph Hellwig  echo
17704dd75c70SChristoph Hellwig  exit 1
1771e5d355d1Saliguorifi
1772e5d355d1Saliguori
1773bf9298b9Saliguori##########################################
1774f27aaf4bSChristian Brunner# rbd probe
1775f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1776f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1777f27aaf4bSChristian Brunner#include <stdio.h>
1778f27aaf4bSChristian Brunner#include <rados/librados.h>
1779f27aaf4bSChristian Brunnerint main(void) { rados_initialize(0, NULL); return 0; }
1780f27aaf4bSChristian BrunnerEOF
1781f27aaf4bSChristian Brunner  rbd_libs="-lrados -lcrypto"
1782f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1783f27aaf4bSChristian Brunner    librados_too_old=no
1784f27aaf4bSChristian Brunner    cat > $TMPC <<EOF
1785f27aaf4bSChristian Brunner#include <stdio.h>
1786f27aaf4bSChristian Brunner#include <rados/librados.h>
1787f27aaf4bSChristian Brunner#ifndef CEPH_OSD_TMAP_SET
1788f27aaf4bSChristian Brunner#error missing CEPH_OSD_TMAP_SET
1789f27aaf4bSChristian Brunner#endif
1790f27aaf4bSChristian Brunnerint main(void) {
1791f27aaf4bSChristian Brunner    int (*func)(const rados_pool_t pool, uint64_t *snapid) = rados_selfmanaged_snap_create;
1792f27aaf4bSChristian Brunner    rados_initialize(0, NULL);
1793f27aaf4bSChristian Brunner    return 0;
1794f27aaf4bSChristian Brunner}
1795f27aaf4bSChristian BrunnerEOF
1796f27aaf4bSChristian Brunner    if compile_prog "" "$rbd_libs" ; then
1797f27aaf4bSChristian Brunner      rbd=yes
1798f27aaf4bSChristian Brunner      libs_tools="$rbd_libs $libs_tools"
1799f27aaf4bSChristian Brunner      libs_softmmu="$rbd_libs $libs_softmmu"
1800f27aaf4bSChristian Brunner    else
1801f27aaf4bSChristian Brunner      rbd=no
1802f27aaf4bSChristian Brunner      librados_too_old=yes
1803f27aaf4bSChristian Brunner    fi
1804f27aaf4bSChristian Brunner  else
1805f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1806f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1807f27aaf4bSChristian Brunner    fi
1808f27aaf4bSChristian Brunner    rbd=no
1809f27aaf4bSChristian Brunner  fi
1810f27aaf4bSChristian Brunner  if test "$librados_too_old" = "yes" ; then
1811f27aaf4bSChristian Brunner    echo "-> Your librados version is too old - upgrade needed to have rbd support"
1812f27aaf4bSChristian Brunner  fi
1813f27aaf4bSChristian Brunnerfi
1814f27aaf4bSChristian Brunner
1815f27aaf4bSChristian Brunner##########################################
18165c6c3a6cSChristoph Hellwig# linux-aio probe
18175c6c3a6cSChristoph Hellwig
18185c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
18195c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
18205c6c3a6cSChristoph Hellwig#include <libaio.h>
18215c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
1822832ce9c2SScott Wood#include <stddef.h>
18235c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
18245c6c3a6cSChristoph HellwigEOF
18255c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
18265c6c3a6cSChristoph Hellwig    linux_aio=yes
1827048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1828048d179fSPaul Brook    libs_tools="$libs_tools -laio"
18295c6c3a6cSChristoph Hellwig  else
18305c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
18315c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
18325c6c3a6cSChristoph Hellwig    fi
18333cfcae3cSLuiz Capitulino    linux_aio=no
18345c6c3a6cSChristoph Hellwig  fi
18355c6c3a6cSChristoph Hellwigfi
18365c6c3a6cSChristoph Hellwig
18375c6c3a6cSChristoph Hellwig##########################################
1838758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1839758e8e38SVenkateswararao Jujjuri (JV)
1840758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1841758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1842758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1843758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
1844758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
1845758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1846758e8e38SVenkateswararao Jujjuri (JV)EOF
1847758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
1848758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1849758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
1850758e8e38SVenkateswararao Jujjuri (JV)  else
1851758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1852758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1853758e8e38SVenkateswararao Jujjuri (JV)    fi
1854758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1855758e8e38SVenkateswararao Jujjuri (JV)  fi
1856758e8e38SVenkateswararao Jujjuri (JV)fi
1857758e8e38SVenkateswararao Jujjuri (JV)
1858758e8e38SVenkateswararao Jujjuri (JV)##########################################
1859bf9298b9Saliguori# iovec probe
1860bf9298b9Saliguoricat > $TMPC <<EOF
1861db34f0b3Sblueswir1#include <sys/types.h>
1862bf9298b9Saliguori#include <sys/uio.h>
1863db34f0b3Sblueswir1#include <unistd.h>
1864bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1865bf9298b9SaliguoriEOF
1866bf9298b9Saliguoriiovec=no
186752166aa0SJuan Quintelaif compile_prog "" "" ; then
1868bf9298b9Saliguori  iovec=yes
1869bf9298b9Saliguorifi
1870bf9298b9Saliguori
1871f652e6afSaurel32##########################################
1872ceb42de8Saliguori# preadv probe
1873ceb42de8Saliguoricat > $TMPC <<EOF
1874ceb42de8Saliguori#include <sys/types.h>
1875ceb42de8Saliguori#include <sys/uio.h>
1876ceb42de8Saliguori#include <unistd.h>
1877ceb42de8Saliguoriint main(void) { preadv; }
1878ceb42de8SaliguoriEOF
1879ceb42de8Saliguoripreadv=no
188052166aa0SJuan Quintelaif compile_prog "" "" ; then
1881ceb42de8Saliguori  preadv=yes
1882ceb42de8Saliguorifi
1883ceb42de8Saliguori
1884ceb42de8Saliguori##########################################
1885f652e6afSaurel32# fdt probe
18862df87df7SJuan Quintelaif test "$fdt" != "no" ; then
1887b41af4baSJuan Quintela  fdt_libs="-lfdt"
1888f652e6afSaurel32  cat > $TMPC << EOF
1889f652e6afSaurel32int main(void) { return 0; }
1890f652e6afSaurel32EOF
189152166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
1892f652e6afSaurel32    fdt=yes
1893e4782985SJuan Quintela    libs_softmmu="$fdt_libs $libs_softmmu"
18942df87df7SJuan Quintela  else
18952df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
18962df87df7SJuan Quintela      feature_not_found "fdt"
18972df87df7SJuan Quintela    fi
18982df87df7SJuan Quintela    fdt=no
1899f652e6afSaurel32  fi
1900f652e6afSaurel32fi
1901f652e6afSaurel32
19023b3f24adSaurel32#
19033b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
19043b3f24adSaurel32# emulator.  This is done because older glibc versions don't
19053b3f24adSaurel32# have syscall stubs for these implemented.
19063b3f24adSaurel32#
19073b3f24adSaurel32atfile=no
19083b3f24adSaurel32cat > $TMPC << EOF
19093b3f24adSaurel32#define _ATFILE_SOURCE
19103b3f24adSaurel32#include <sys/types.h>
19113b3f24adSaurel32#include <fcntl.h>
19123b3f24adSaurel32#include <unistd.h>
19133b3f24adSaurel32
19143b3f24adSaurel32int
19153b3f24adSaurel32main(void)
19163b3f24adSaurel32{
19173b3f24adSaurel32	/* try to unlink nonexisting file */
19183b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
19193b3f24adSaurel32}
19203b3f24adSaurel32EOF
192152166aa0SJuan Quintelaif compile_prog "" "" ; then
19223b3f24adSaurel32  atfile=yes
19233b3f24adSaurel32fi
19243b3f24adSaurel32
192539386ac7Saurel32# Check for inotify functions when we are building linux-user
19263b3f24adSaurel32# emulator.  This is done because older glibc versions don't
19273b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
19283b3f24adSaurel32# don't provide them even if kernel supports them.
19293b3f24adSaurel32#
19303b3f24adSaurel32inotify=no
19313b3f24adSaurel32cat > $TMPC << EOF
19323b3f24adSaurel32#include <sys/inotify.h>
19333b3f24adSaurel32
19343b3f24adSaurel32int
19353b3f24adSaurel32main(void)
19363b3f24adSaurel32{
19373b3f24adSaurel32	/* try to start inotify */
19388690e420Saurel32	return inotify_init();
19393b3f24adSaurel32}
19403b3f24adSaurel32EOF
194152166aa0SJuan Quintelaif compile_prog "" "" ; then
19423b3f24adSaurel32  inotify=yes
19433b3f24adSaurel32fi
19443b3f24adSaurel32
1945c05c7a73SRiku Voipioinotify1=no
1946c05c7a73SRiku Voipiocat > $TMPC << EOF
1947c05c7a73SRiku Voipio#include <sys/inotify.h>
1948c05c7a73SRiku Voipio
1949c05c7a73SRiku Voipioint
1950c05c7a73SRiku Voipiomain(void)
1951c05c7a73SRiku Voipio{
1952c05c7a73SRiku Voipio    /* try to start inotify */
1953c05c7a73SRiku Voipio    return inotify_init1(0);
1954c05c7a73SRiku Voipio}
1955c05c7a73SRiku VoipioEOF
1956c05c7a73SRiku Voipioif compile_prog "" "" ; then
1957c05c7a73SRiku Voipio  inotify1=yes
1958c05c7a73SRiku Voipiofi
1959c05c7a73SRiku Voipio
1960ebc996f3SRiku Voipio# check if utimensat and futimens are supported
1961ebc996f3SRiku Voipioutimens=no
1962ebc996f3SRiku Voipiocat > $TMPC << EOF
1963ebc996f3SRiku Voipio#define _ATFILE_SOURCE
1964ebc996f3SRiku Voipio#include <stddef.h>
1965ebc996f3SRiku Voipio#include <fcntl.h>
1966ebc996f3SRiku Voipio
1967ebc996f3SRiku Voipioint main(void)
1968ebc996f3SRiku Voipio{
1969ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
1970ebc996f3SRiku Voipio    futimens(0, NULL);
1971ebc996f3SRiku Voipio    return 0;
1972ebc996f3SRiku Voipio}
1973ebc996f3SRiku VoipioEOF
197452166aa0SJuan Quintelaif compile_prog "" "" ; then
1975ebc996f3SRiku Voipio  utimens=yes
1976ebc996f3SRiku Voipiofi
1977ebc996f3SRiku Voipio
1978099d6b0fSRiku Voipio# check if pipe2 is there
1979099d6b0fSRiku Voipiopipe2=no
1980099d6b0fSRiku Voipiocat > $TMPC << EOF
1981099d6b0fSRiku Voipio#include <unistd.h>
1982099d6b0fSRiku Voipio#include <fcntl.h>
1983099d6b0fSRiku Voipio
1984099d6b0fSRiku Voipioint main(void)
1985099d6b0fSRiku Voipio{
1986099d6b0fSRiku Voipio    int pipefd[2];
1987099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
1988099d6b0fSRiku Voipio    return 0;
1989099d6b0fSRiku Voipio}
1990099d6b0fSRiku VoipioEOF
199152166aa0SJuan Quintelaif compile_prog "" "" ; then
1992099d6b0fSRiku Voipio  pipe2=yes
1993099d6b0fSRiku Voipiofi
1994099d6b0fSRiku Voipio
199540ff6d7eSKevin Wolf# check if accept4 is there
199640ff6d7eSKevin Wolfaccept4=no
199740ff6d7eSKevin Wolfcat > $TMPC << EOF
199840ff6d7eSKevin Wolf#include <sys/socket.h>
199940ff6d7eSKevin Wolf#include <stddef.h>
200040ff6d7eSKevin Wolf
200140ff6d7eSKevin Wolfint main(void)
200240ff6d7eSKevin Wolf{
200340ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
200440ff6d7eSKevin Wolf    return 0;
200540ff6d7eSKevin Wolf}
200640ff6d7eSKevin WolfEOF
200740ff6d7eSKevin Wolfif compile_prog "" "" ; then
200840ff6d7eSKevin Wolf  accept4=yes
200940ff6d7eSKevin Wolffi
201040ff6d7eSKevin Wolf
20113ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
20123ce34dfbSvibisreenivasansplice=no
20133ce34dfbSvibisreenivasancat > $TMPC << EOF
20143ce34dfbSvibisreenivasan#include <unistd.h>
20153ce34dfbSvibisreenivasan#include <fcntl.h>
20163ce34dfbSvibisreenivasan#include <limits.h>
20173ce34dfbSvibisreenivasan
20183ce34dfbSvibisreenivasanint main(void)
20193ce34dfbSvibisreenivasan{
20203ce34dfbSvibisreenivasan    int len, fd;
20213ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
20223ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
20233ce34dfbSvibisreenivasan    return 0;
20243ce34dfbSvibisreenivasan}
20253ce34dfbSvibisreenivasanEOF
202652166aa0SJuan Quintelaif compile_prog "" "" ; then
20273ce34dfbSvibisreenivasan  splice=yes
20283ce34dfbSvibisreenivasanfi
20293ce34dfbSvibisreenivasan
2030dcc38d1cSMarcelo Tosatti##########################################
2031dcc38d1cSMarcelo Tosatti# signalfd probe
2032dcc38d1cSMarcelo Tosattisignalfd="no"
2033dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2034dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2035dcc38d1cSMarcelo Tosatti#include <unistd.h>
2036dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2037dcc38d1cSMarcelo Tosatti#include <signal.h>
2038dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2039dcc38d1cSMarcelo TosattiEOF
2040dcc38d1cSMarcelo Tosatti
2041dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2042dcc38d1cSMarcelo Tosatti  signalfd=yes
2043dcc38d1cSMarcelo Tosattifi
2044dcc38d1cSMarcelo Tosatti
2045c2882b96SRiku Voipio# check if eventfd is supported
2046c2882b96SRiku Voipioeventfd=no
2047c2882b96SRiku Voipiocat > $TMPC << EOF
2048c2882b96SRiku Voipio#include <sys/eventfd.h>
2049c2882b96SRiku Voipio
2050c2882b96SRiku Voipioint main(void)
2051c2882b96SRiku Voipio{
2052c2882b96SRiku Voipio    int efd = eventfd(0, 0);
2053c2882b96SRiku Voipio    return 0;
2054c2882b96SRiku Voipio}
2055c2882b96SRiku VoipioEOF
2056c2882b96SRiku Voipioif compile_prog "" "" ; then
2057c2882b96SRiku Voipio  eventfd=yes
2058c2882b96SRiku Voipiofi
2059c2882b96SRiku Voipio
2060d0927938SUlrich Hecht# check for fallocate
2061d0927938SUlrich Hechtfallocate=no
2062d0927938SUlrich Hechtcat > $TMPC << EOF
2063d0927938SUlrich Hecht#include <fcntl.h>
2064d0927938SUlrich Hecht
2065d0927938SUlrich Hechtint main(void)
2066d0927938SUlrich Hecht{
2067d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2068d0927938SUlrich Hecht    return 0;
2069d0927938SUlrich Hecht}
2070d0927938SUlrich HechtEOF
2071be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2072d0927938SUlrich Hecht  fallocate=yes
2073d0927938SUlrich Hechtfi
2074d0927938SUlrich Hecht
2075c727f47dSPeter Maydell# check for sync_file_range
2076c727f47dSPeter Maydellsync_file_range=no
2077c727f47dSPeter Maydellcat > $TMPC << EOF
2078c727f47dSPeter Maydell#include <fcntl.h>
2079c727f47dSPeter Maydell
2080c727f47dSPeter Maydellint main(void)
2081c727f47dSPeter Maydell{
2082c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2083c727f47dSPeter Maydell    return 0;
2084c727f47dSPeter Maydell}
2085c727f47dSPeter MaydellEOF
2086c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2087c727f47dSPeter Maydell  sync_file_range=yes
2088c727f47dSPeter Maydellfi
2089c727f47dSPeter Maydell
2090dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2091dace20dcSPeter Maydellfiemap=no
2092dace20dcSPeter Maydellcat > $TMPC << EOF
2093dace20dcSPeter Maydell#include <sys/ioctl.h>
2094dace20dcSPeter Maydell#include <linux/fs.h>
2095dace20dcSPeter Maydell#include <linux/fiemap.h>
2096dace20dcSPeter Maydell
2097dace20dcSPeter Maydellint main(void)
2098dace20dcSPeter Maydell{
2099dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2100dace20dcSPeter Maydell    return 0;
2101dace20dcSPeter Maydell}
2102dace20dcSPeter MaydellEOF
2103dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2104dace20dcSPeter Maydell  fiemap=yes
2105dace20dcSPeter Maydellfi
2106dace20dcSPeter Maydell
2107d0927938SUlrich Hecht# check for dup3
2108d0927938SUlrich Hechtdup3=no
2109d0927938SUlrich Hechtcat > $TMPC << EOF
2110d0927938SUlrich Hecht#include <unistd.h>
2111d0927938SUlrich Hecht
2112d0927938SUlrich Hechtint main(void)
2113d0927938SUlrich Hecht{
2114d0927938SUlrich Hecht    dup3(0, 0, 0);
2115d0927938SUlrich Hecht    return 0;
2116d0927938SUlrich Hecht}
2117d0927938SUlrich HechtEOF
211878f5d726SJan Kiszkaif compile_prog "" "" ; then
2119d0927938SUlrich Hecht  dup3=yes
2120d0927938SUlrich Hechtfi
2121d0927938SUlrich Hecht
2122cc8ae6deSpbrook# Check if tools are available to build documentation.
2123a25dba17SJuan Quintelaif test "$docs" != "no" ; then
212401668d98SStefan Weil  if has makeinfo && has pod2man; then
2125a25dba17SJuan Quintela    docs=yes
212683a3ab8bSJuan Quintela  else
2127a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2128a25dba17SJuan Quintela      feature_not_found "docs"
212983a3ab8bSJuan Quintela    fi
2130a25dba17SJuan Quintela    docs=no
213183a3ab8bSJuan Quintela  fi
2132cc8ae6deSpbrookfi
2133cc8ae6deSpbrook
2134f514f41cSStefan Weil# Search for bswap_32 function
21356ae9a1f4SJuan Quintelabyteswap_h=no
21366ae9a1f4SJuan Quintelacat > $TMPC << EOF
21376ae9a1f4SJuan Quintela#include <byteswap.h>
21386ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
21396ae9a1f4SJuan QuintelaEOF
214052166aa0SJuan Quintelaif compile_prog "" "" ; then
21416ae9a1f4SJuan Quintela  byteswap_h=yes
21426ae9a1f4SJuan Quintelafi
21436ae9a1f4SJuan Quintela
2144f514f41cSStefan Weil# Search for bswap_32 function
21456ae9a1f4SJuan Quintelabswap_h=no
21466ae9a1f4SJuan Quintelacat > $TMPC << EOF
21476ae9a1f4SJuan Quintela#include <sys/endian.h>
21486ae9a1f4SJuan Quintela#include <sys/types.h>
21496ae9a1f4SJuan Quintela#include <machine/bswap.h>
21506ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
21516ae9a1f4SJuan QuintelaEOF
215252166aa0SJuan Quintelaif compile_prog "" "" ; then
21536ae9a1f4SJuan Quintela  bswap_h=yes
21546ae9a1f4SJuan Quintelafi
21556ae9a1f4SJuan Quintela
2156da93a1fdSaliguori##########################################
2157da93a1fdSaliguori# Do we need librt
2158da93a1fdSaliguoricat > $TMPC <<EOF
2159da93a1fdSaliguori#include <signal.h>
2160da93a1fdSaliguori#include <time.h>
2161da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2162da93a1fdSaliguoriEOF
2163da93a1fdSaliguori
216452166aa0SJuan Quintelaif compile_prog "" "" ; then
216507ffa4bdSJuan Quintela  :
216652166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
216707ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2168da93a1fdSaliguorifi
2169da93a1fdSaliguori
217031ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2171179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
21726362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
21736362a53fSJuan Quintelafi
21746362a53fSJuan Quintela
2175de5071c5SBlue Swirl##########################################
2176de5071c5SBlue Swirl# check if the compiler defines offsetof
2177de5071c5SBlue Swirl
2178de5071c5SBlue Swirlneed_offsetof=yes
2179de5071c5SBlue Swirlcat > $TMPC << EOF
2180de5071c5SBlue Swirl#include <stddef.h>
2181de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2182de5071c5SBlue SwirlEOF
2183de5071c5SBlue Swirlif compile_prog "" "" ; then
2184de5071c5SBlue Swirl    need_offsetof=no
2185de5071c5SBlue Swirlfi
2186de5071c5SBlue Swirl
21875f6b9e8fSBlue Swirl##########################################
2188747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
2189747bbdf7SBlue Swirl#
2190747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
2191747bbdf7SBlue Swirl# about attribute warn_unused_result
2192747bbdf7SBlue Swirl
2193747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
2194747bbdf7SBlue Swirlcat > $TMPC << EOF
2195747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2196747bbdf7SBlue Swirl#error gcc 3.3 or older
2197747bbdf7SBlue Swirl#endif
2198747bbdf7SBlue Swirlint main(void) { return 0;}
2199747bbdf7SBlue SwirlEOF
2200747bbdf7SBlue Swirlif compile_prog "" ""; then
2201747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
2202747bbdf7SBlue Swirlfi
2203747bbdf7SBlue Swirl
2204cd4ec0b4SGerd Hoffmann# spice probe
2205cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2206cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2207cd4ec0b4SGerd Hoffmann#include <spice.h>
2208cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2209cd4ec0b4SGerd HoffmannEOF
2210*710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2211*710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2212*710fc4f5SJiri Denemark  if $pkg_config --atleast-version=0.5.3 spice-server >/dev/null 2>&1 && \
2213cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2214cd4ec0b4SGerd Hoffmann    spice="yes"
2215cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2216cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2217cd4ec0b4SGerd Hoffmann  else
2218cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2219cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2220cd4ec0b4SGerd Hoffmann    fi
2221cd4ec0b4SGerd Hoffmann    spice="no"
2222cd4ec0b4SGerd Hoffmann  fi
2223cd4ec0b4SGerd Hoffmannfi
2224cd4ec0b4SGerd Hoffmann
2225cd4ec0b4SGerd Hoffmann##########################################
2226cd4ec0b4SGerd Hoffmann
2227747bbdf7SBlue Swirl##########################################
22285f6b9e8fSBlue Swirl# check if we have fdatasync
22295f6b9e8fSBlue Swirl
22305f6b9e8fSBlue Swirlfdatasync=no
22315f6b9e8fSBlue Swirlcat > $TMPC << EOF
22325f6b9e8fSBlue Swirl#include <unistd.h>
22335f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
22345f6b9e8fSBlue SwirlEOF
22355f6b9e8fSBlue Swirlif compile_prog "" "" ; then
22365f6b9e8fSBlue Swirl    fdatasync=yes
22375f6b9e8fSBlue Swirlfi
22385f6b9e8fSBlue Swirl
223994a420b1SStefan Hajnoczi##########################################
2240e78815a5SAndreas Färber# check if we have madvise
2241e78815a5SAndreas Färber
2242e78815a5SAndreas Färbermadvise=no
2243e78815a5SAndreas Färbercat > $TMPC << EOF
2244e78815a5SAndreas Färber#include <sys/types.h>
2245e78815a5SAndreas Färber#include <sys/mman.h>
2246832ce9c2SScott Wood#include <stddef.h>
2247e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2248e78815a5SAndreas FärberEOF
2249e78815a5SAndreas Färberif compile_prog "" "" ; then
2250e78815a5SAndreas Färber    madvise=yes
2251e78815a5SAndreas Färberfi
2252e78815a5SAndreas Färber
2253e78815a5SAndreas Färber##########################################
2254e78815a5SAndreas Färber# check if we have posix_madvise
2255e78815a5SAndreas Färber
2256e78815a5SAndreas Färberposix_madvise=no
2257e78815a5SAndreas Färbercat > $TMPC << EOF
2258e78815a5SAndreas Färber#include <sys/mman.h>
2259832ce9c2SScott Wood#include <stddef.h>
2260e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2261e78815a5SAndreas FärberEOF
2262e78815a5SAndreas Färberif compile_prog "" "" ; then
2263e78815a5SAndreas Färber    posix_madvise=yes
2264e78815a5SAndreas Färberfi
2265e78815a5SAndreas Färber
2266e78815a5SAndreas Färber##########################################
226794a420b1SStefan Hajnoczi# check if trace backend exists
226894a420b1SStefan Hajnoczi
22694c3b5a48SBlue Swirlsh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
227094a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
227194a420b1SStefan Hajnoczi  echo
227294a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
227394a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
227494a420b1SStefan Hajnoczi  echo
227594a420b1SStefan Hajnoczi  exit 1
227694a420b1SStefan Hajnoczifi
227794a420b1SStefan Hajnoczi
22787e24e92aSStefan Hajnoczi##########################################
22797e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
22807e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
22817e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
22827e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
22837e24e92aSStefan Hajnoczi#include <ust/marker.h>
22847e24e92aSStefan Hajnocziint main(void) { return 0; }
22857e24e92aSStefan HajnocziEOF
22867e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
22877e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
22887e24e92aSStefan Hajnoczi  else
22897e24e92aSStefan Hajnoczi    echo
22907e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
22917e24e92aSStefan Hajnoczi    echo
22927e24e92aSStefan Hajnoczi    exit 1
22937e24e92aSStefan Hajnoczi  fi
22947e24e92aSStefan Hajnoczifi
2295b3d08c02SDaniel P. Berrange
2296b3d08c02SDaniel P. Berrange##########################################
2297b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2298b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2299b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2300b3d08c02SDaniel P. Berrange    echo
2301b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2302b3d08c02SDaniel P. Berrange    echo
2303b3d08c02SDaniel P. Berrange    exit 1
2304b3d08c02SDaniel P. Berrange  fi
2305c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2306c276b17dSDaniel P. Berrange  if has 'stap' ; then
2307c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2308c276b17dSDaniel P. Berrange  fi
2309b3d08c02SDaniel P. Berrangefi
2310b3d08c02SDaniel P. Berrange
23117e24e92aSStefan Hajnoczi##########################################
2312e86ecd4bSJuan Quintela# End of CC checks
2313e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2314e86ecd4bSJuan Quintela
2315e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
23161156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2317e86ecd4bSJuan Quintelafi
2318a316e378SJuan Quintela
2319e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2320e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2321e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
232220ff6c80SAnthony Liguori
232320ff6c80SAnthony Liguoriif test -z "$werror" ; then
2324e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2325e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2326e86ecd4bSJuan Quintela        werror="yes"
2327e86ecd4bSJuan Quintela    else
2328e86ecd4bSJuan Quintela        werror="no"
2329e86ecd4bSJuan Quintela    fi
2330e86ecd4bSJuan Quintelafi
2331e86ecd4bSJuan Quintela
233220ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
233320ff6c80SAnthony Liguori# enable/disable
233420ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
233520ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
233620ff6c80SAnthony Liguori	zero_malloc="no"
233720ff6c80SAnthony Liguori    else
233820ff6c80SAnthony Liguori	zero_malloc="yes"
233920ff6c80SAnthony Liguori    fi
234020ff6c80SAnthony Liguorifi
234120ff6c80SAnthony Liguori
2342e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2343a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2344e86ecd4bSJuan Quintelafi
2345e86ecd4bSJuan Quintela
2346e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2347e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
23481156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2349e86ecd4bSJuan Quintela    fi
2350e86ecd4bSJuan Quintelafi
2351e86ecd4bSJuan Quintela
2352952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2353952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2354952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2355952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2356952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2357952afb71SBlue Swirl        fi
2358952afb71SBlue Swirl    done
2359952afb71SBlue Swirlfi
2360952afb71SBlue Swirl
2361190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
23625a67135aSbellard
2363ca35f780SPaolo Bonzinitools=
2364ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2365ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2366ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2367ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2368ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2369ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2370ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2371ca35f780SPaolo Bonzini    fi
2372ca35f780SPaolo Bonzini  fi
2373ca35f780SPaolo Bonzinifi
2374ca35f780SPaolo Bonzini
2375ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2376ca35f780SPaolo Bonziniroms=
2377ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2378ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2379ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2380ca35f780SPaolo Bonzini  roms="optionrom"
2381ca35f780SPaolo Bonzinifi
2382ca35f780SPaolo Bonzini
2383ca35f780SPaolo Bonzini
23847d13299dSbellardecho "Install prefix    $prefix"
2385f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2386f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
23871c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
238811d9f695Sbellardif test "$mingw32" = "no" ; then
2389f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
239043ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
239111d9f695Sbellardfi
23925a67135aSbellardecho "Source path       $source_path"
23937d13299dSbellardecho "C compiler        $cc"
239483469015Sbellardecho "Host C compiler   $host_cc"
23950c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2396a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
23970c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
23987d13299dSbellardecho "make              $make"
23996a882643Spbrookecho "install           $install"
2400a98fd896Sbellardecho "host CPU          $cpu"
2401de83cd02Sbellardecho "host big endian   $bigendian"
240297a847bcSbellardecho "target list       $target_list"
2403ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2404b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
24057d13299dSbellardecho "gprof enabled     $gprof"
240603b4fe7dSaliguoriecho "sparse enabled    $sparse"
24071625af87Saliguoriecho "strip binaries    $strip_opt"
240805c2a3e7Sbellardecho "profiler          $profiler"
240943ce4dfeSbellardecho "static build      $static"
241085aa5189Sbellardecho "-Werror enabled   $werror"
24115b0753e0Sbellardif test "$darwin" = "yes" ; then
24125b0753e0Sbellard    echo "Cocoa support     $cocoa"
24135b0753e0Sbellardfi
241497a847bcSbellardecho "SDL support       $sdl"
24154d3b6f6eSbalrogecho "curses support    $curses"
2416769ce76dSAlexander Grafecho "curl support      $curl"
24175495ed11SLuiz Capitulinoecho "check support     $check_utests"
241867b915a5Sbellardecho "mingw32 support   $mingw32"
24190c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
24200c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2421eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
24228ff9cbf7Smalcecho "Mixer emulation   $mixemu"
24238d5d2d4cSthsecho "VNC TLS support   $vnc_tls"
24242f9606b3Saliguoriecho "VNC SASL support  $vnc_sasl"
24252f6f5c7aSCorentin Charyecho "VNC JPEG support  $vnc_jpeg"
2426efe556adSCorentin Charyecho "VNC PNG support   $vnc_png"
2427bd023f95SCorentin Charyecho "VNC thread        $vnc_thread"
24283142255cSblueswir1if test -n "$sparc_cpu"; then
24293142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
24303142255cSblueswir1fi
2431e37630caSaliguoriecho "xen support       $xen"
24322e4d9fb1Saurel32echo "brlapi support    $brlapi"
2433a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2434a25dba17SJuan Quintelaecho "Documentation     $docs"
2435c5937220Spbrook[ ! -z "$uname_release" ] && \
2436c5937220Spbrookecho "uname -r          $uname_release"
2437bd0c5661Spbrookecho "NPTL support      $nptl"
2438379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
243934005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
24408a16d273Sthsecho "vde support       $vde"
2441e5d355d1Saliguoriecho "IO thread         $io_thread"
24425c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2443758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
244477755340Sthsecho "Install blobs     $blobs"
2445b31a0277SJuan Quintelaecho "KVM support       $kvm"
2446f652e6afSaurel32echo "fdt support       $fdt"
2447ceb42de8Saliguoriecho "preadv support    $preadv"
24485f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2449e78815a5SAndreas Färberecho "madvise           $madvise"
2450e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2451ee682d27SStefan Weilecho "uuid support      $uuid"
2452d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
245394a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
24549410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2455cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2456f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2457dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
245867b915a5Sbellard
245997a847bcSbellardif test $sdl_too_old = "yes"; then
246024b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2461e8cd23deSbellardfi
246297a847bcSbellard
246398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
24644bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
246597a847bcSbellard
246698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
246798ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
246898ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
246998ec69acSJuan Quintelaecho >> $config_host_mak
247098ec69acSJuan Quintela
2471e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
247299d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
247399d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
247499d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
247599d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
247699d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
247799d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
24781dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2479804edf29SJuan Quintela
24802408a527Saurel32case "$cpu" in
248124e804ecSAlexander Graf  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
2482e0da9dd3SJuan Quintela    ARCH=$cpu
24832408a527Saurel32  ;;
2484a302c32dSLaurent Desnogues  armv4b|armv4l)
248516dbd14fSJuan Quintela    ARCH=arm
24862408a527Saurel32  ;;
24872408a527Saurel32esac
248898ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2489f8393946Saurel32if test "$debug_tcg" = "yes" ; then
24902358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2491f8393946Saurel32fi
2492b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2493b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2494b4475aa2SLuiz Capitulinofi
2495f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
24962358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2497f3d08ee6SPaul Brookfi
24981625af87Saliguoriif test "$strip_opt" = "yes" ; then
249952ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
25001625af87Saliguorifi
25017d13299dSbellardif test "$bigendian" = "yes" ; then
2502e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
250397a847bcSbellardfi
25042358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
250567b915a5Sbellardif test "$mingw32" = "yes" ; then
250698ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
25079fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
25089fe6de94SBlue Swirl  version_major=${rc_version%%.*}
25099fe6de94SBlue Swirl  rc_version=${rc_version#*.}
25109fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
25119fe6de94SBlue Swirl  rc_version=${rc_version#*.}
25129fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
25139fe6de94SBlue Swirl  version_micro=0
25149fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
25159fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2516210fa556Spbrookelse
251735f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2518210fa556Spbrookfi
2519128ab2ffSblueswir1
2520dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2521dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2522dffcb71cSMark McLoughlinfi
2523dffcb71cSMark McLoughlin
252483fb7adfSbellardif test "$darwin" = "yes" ; then
252598ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
252683fb7adfSbellardfi
2527b29fe3edSmalc
2528b29fe3edSmalcif test "$aix" = "yes" ; then
252998ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2530b29fe3edSmalcfi
2531b29fe3edSmalc
2532ec530c81Sbellardif test "$solaris" = "yes" ; then
253398ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
25342358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
25350475a5caSths  if test "$needs_libsunmath" = "yes" ; then
253675b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
25370475a5caSths  fi
2538ec530c81Sbellardfi
2539179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2540179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2541179cf400SAndreas Färberfi
254297a847bcSbellardif test "$static" = "yes" ; then
254398ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
254497a847bcSbellardfi
254505c2a3e7Sbellardif test $profiler = "yes" ; then
25462358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
254705c2a3e7Sbellardfi
2548c20709aaSbellardif test "$slirp" = "yes" ; then
254998ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2550f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2551c20709aaSbellardfi
25528a16d273Sthsif test "$vde" = "yes" ; then
255398ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
25548a16d273Sthsfi
25550c58ac1cSmalcfor card in $audio_card_list; do
2556f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
255798ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
25580c58ac1cSmalcdone
25592358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
25600c58ac1cSmalcfor drv in $audio_drv_list; do
2561f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
256298ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2563923e4521Smalc    if test "$drv" = "fmod"; then
25647aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2565fb065187Sbellard    fi
25660c58ac1cSmalcdone
256767f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
256867f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
256967f86e8eSJuan Quintelafi
2570d5631638Smalcif test "$audio_win_int" = "yes" ; then
2571d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2572d5631638Smalcfi
2573eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
25748ff9cbf7Smalcif test "$mixemu" = "yes" ; then
257598ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
25768ff9cbf7Smalcfi
25778d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
257898ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2579525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
25808d5d2d4cSthsfi
25812f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
258298ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
258360ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
25842f9606b3Saliguorifi
258596763cf9SCorentin Charyif test "$vnc_jpeg" != "no" ; then
25862f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
25872f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
25882f6f5c7aSCorentin Charyfi
258996763cf9SCorentin Charyif test "$vnc_png" != "no" ; then
2590efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2591efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2592efe556adSCorentin Charyfi
259396763cf9SCorentin Charyif test "$vnc_thread" != "no" ; then
2594bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2595bd023f95SCorentin Chary  echo "CONFIG_THREAD=y" >> $config_host_mak
2596bd023f95SCorentin Charyfi
259776655d6dSaliguoriif test "$fnmatch" = "yes" ; then
25982358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
259976655d6dSaliguorifi
2600ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2601ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2602ee682d27SStefan Weilfi
2603dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
2604dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
2605dce512deSChristoph Hellwigfi
2606b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
260798ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
26082358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
260998ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
261098ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2611a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
261298ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2613cc8ae6deSpbrookfi
26141ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
261598ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
26168ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
261749ecc3faSbellardfi
261849ecc3faSbellardif test "$cocoa" = "yes" ; then
261998ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
262049ecc3faSbellardfi
26214d3b6f6eSbalrogif test "$curses" = "yes" ; then
262298ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2623ab4e5602SJan Kiszkafi
26243b3f24adSaurel32if test "$atfile" = "yes" ; then
26252358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
26263b3f24adSaurel32fi
2627ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
26282358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2629ebc996f3SRiku Voipiofi
2630099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
26312358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2632099d6b0fSRiku Voipiofi
263340ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
263440ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
263540ff6d7eSKevin Wolffi
26363ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
26372358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
26383ce34dfbSvibisreenivasanfi
2639c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2640c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2641c2882b96SRiku Voipiofi
2642d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2643d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2644d0927938SUlrich Hechtfi
2645c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
2646c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2647c727f47dSPeter Maydellfi
2648dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
2649dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
2650dace20dcSPeter Maydellfi
2651d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2652d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2653d0927938SUlrich Hechtfi
26543b3f24adSaurel32if test "$inotify" = "yes" ; then
26552358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
26563b3f24adSaurel32fi
2657c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2658c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2659c05c7a73SRiku Voipiofi
26606ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
26616ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
26626ae9a1f4SJuan Quintelafi
26636ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
26646ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
26656ae9a1f4SJuan Quintelafi
2666769ce76dSAlexander Grafif test "$curl" = "yes" ; then
266798ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2668b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2669769ce76dSAlexander Graffi
26702e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
267198ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
26722e4d9fb1Saurel32fi
2673fb599c9aSbalrogif test "$bluez" = "yes" ; then
267498ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2675ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2676fb599c9aSbalrogfi
2677e37630caSaliguoriif test "$xen" = "yes" ; then
26785647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2679e37630caSaliguorifi
2680e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
268198ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2682bd023f95SCorentin Chary  echo "CONFIG_THREAD=y" >> $config_host_mak
2683e5d355d1Saliguorifi
26845c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
26855c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
26865c6c3a6cSChristoph Hellwigfi
2687758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2688758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2689758e8e38SVenkateswararao Jujjuri (JV)fi
2690758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2691758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2692758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2693758e8e38SVenkateswararao Jujjuri (JV)  fi
2694758e8e38SVenkateswararao Jujjuri (JV)fi
269577755340Sthsif test "$blobs" = "yes" ; then
269698ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
269777755340Sthsfi
2698bf9298b9Saliguoriif test "$iovec" = "yes" ; then
26992358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2700bf9298b9Saliguorifi
2701ceb42de8Saliguoriif test "$preadv" = "yes" ; then
27022358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2703ceb42de8Saliguorifi
2704f652e6afSaurel32if test "$fdt" = "yes" ; then
27053f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2706f652e6afSaurel32fi
2707dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
2708dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2709dcc38d1cSMarcelo Tosattifi
2710de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2711de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2712de5071c5SBlue Swirlfi
2713747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2714747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2715747bbdf7SBlue Swirlfi
27165f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
27175f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
27185f6b9e8fSBlue Swirlfi
2719e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
2720e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
2721e78815a5SAndreas Färberfi
2722e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
2723e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2724e78815a5SAndreas Färberfi
272597a847bcSbellard
2726cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
2727cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
2728cd4ec0b4SGerd Hoffmannfi
2729cd4ec0b4SGerd Hoffmann
273083fb7adfSbellard# XXX: suppress that
27317d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
27322358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
27337d3505c5Sbellardfi
27347d3505c5Sbellard
27352358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
2736c5937220Spbrook
273720ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
273820ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
273920ff6c80SAnthony Liguorifi
2740f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
2741f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
2742f27aaf4bSChristian Brunnerfi
274320ff6c80SAnthony Liguori
274468063649Sblueswir1# USB host support
274568063649Sblueswir1case "$usb" in
274668063649Sblueswir1linux)
274798ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
274868063649Sblueswir1;;
274968063649Sblueswir1bsd)
275098ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
275168063649Sblueswir1;;
275268063649Sblueswir1*)
275398ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
275468063649Sblueswir1;;
275568063649Sblueswir1esac
275668063649Sblueswir1
275794a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
275822890ab5SPrerna Saxenaif test "$trace_backend" = "simple"; then
275922890ab5SPrerna Saxena  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
276022890ab5SPrerna Saxenafi
27619410b56cSPrerna Saxena# Set the appropriate trace file.
27629410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
27639410b56cSPrerna Saxena  trace_file="\"$trace_file-%u\""
27649410b56cSPrerna Saxenafi
2765c276b17dSDaniel P. Berrangeif test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
2766c276b17dSDaniel P. Berrange  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
2767c276b17dSDaniel P. Berrangefi
27689410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
27699410b56cSPrerna Saxena
277098ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
277198ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
2772804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
2773804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
2774804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
2775804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
2776804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
2777804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
27782b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
2779804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
2780804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
2781804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
2782804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
27839fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
2784e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
2785a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2786f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
2787e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
2788e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
2789e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
2790e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
2791e39f0062SPaolo Bonzinifi
2792c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
2793e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
2794a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
2795a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
279673da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
27973e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
2798804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
2799804edf29SJuan Quintela
28004bf6b55bSJuan Quintela# generate list of library paths for linker script
28014bf6b55bSJuan Quintela
28024bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
28034bf6b55bSJuan Quintela
28044bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
28054bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
28064bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
28074bf6b55bSJuan Quintela  else
28084bf6b55bSJuan Quintela    rm ${config_host_ld}~
28094bf6b55bSJuan Quintela  fi
28104bf6b55bSJuan Quintelafi
28114bf6b55bSJuan Quintela
28124d904533SBlue Swirlfor d in libdis libdis-user; do
28134d904533SBlue Swirl    mkdir -p $d
281411568d6dSPaolo Bonzini    symlink $source_path/Makefile.dis $d/Makefile
28154d904533SBlue Swirl    echo > $d/config.mak
28164d904533SBlue Swirldone
2817d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
2818d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
2819d44cff22SRichard Hendersonfi
28204d904533SBlue Swirl
282197a847bcSbellardfor target in $target_list; do
282297a847bcSbellardtarget_dir="$target"
282325be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
2824600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
282597a847bcSbellardtarget_bigendian="no"
28261f3d3c8fSJuan Quintela
2827ea2d6a39SJuan Quintelacase "$target_arch2" in
282824e804ecSAlexander Graf  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
2829ea2d6a39SJuan Quintela  target_bigendian=yes
2830ea2d6a39SJuan Quintela  ;;
2831ea2d6a39SJuan Quintelaesac
283297a847bcSbellardtarget_softmmu="no"
2833997344f3Sbellardtarget_user_only="no"
2834831b7825Sthstarget_linux_user="no"
2835831b7825Sthstarget_darwin_user="no"
283684778508Sblueswir1target_bsd_user="no"
28379e407a85Spbrookcase "$target" in
2838600309b6SBlue Swirl  ${target_arch2}-softmmu)
28399e407a85Spbrook    target_softmmu="yes"
28409e407a85Spbrook    ;;
2841600309b6SBlue Swirl  ${target_arch2}-linux-user)
28429c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
28439c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
28449c7a4202SBlue Swirl      exit 1
28459c7a4202SBlue Swirl    fi
28469e407a85Spbrook    target_user_only="yes"
28479e407a85Spbrook    target_linux_user="yes"
28489e407a85Spbrook    ;;
2849600309b6SBlue Swirl  ${target_arch2}-darwin-user)
28509c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
28519c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
28529c7a4202SBlue Swirl      exit 1
28539c7a4202SBlue Swirl    fi
28549e407a85Spbrook    target_user_only="yes"
2855831b7825Sths    target_darwin_user="yes"
28569e407a85Spbrook    ;;
2857600309b6SBlue Swirl  ${target_arch2}-bsd-user)
28589cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
28599c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
28609c7a4202SBlue Swirl      exit 1
28619c7a4202SBlue Swirl    fi
286284778508Sblueswir1    target_user_only="yes"
286384778508Sblueswir1    target_bsd_user="yes"
286484778508Sblueswir1    ;;
28659e407a85Spbrook  *)
28669e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
28679e407a85Spbrook    exit 1
28689e407a85Spbrook    ;;
28699e407a85Spbrookesac
2870831b7825Sths
287197a847bcSbellardmkdir -p $target_dir
2872158142c2Sbellardmkdir -p $target_dir/fpu
287357fec1feSbellardmkdir -p $target_dir/tcg
287459f2a787SGerd Hoffmannmkdir -p $target_dir/ide
287584778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
287669de927cSbellard  mkdir -p $target_dir/nwfpe
287769de927cSbellardfi
287811568d6dSPaolo Bonzinisymlink $source_path/Makefile.target $target_dir/Makefile
2879ec530c81Sbellard
288097a847bcSbellard
288125be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
288297a847bcSbellard
2883e5fe0c52Spbrookbflt="no"
2884bd0c5661Spbrooktarget_nptl="no"
2885600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
28867ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
288756aebc89Spbrookgdb_xml_files=""
28887ba1e619Saliguori
2889938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
28906acff7daSJuan QuintelaTARGET_BASE_ARCH=""
2891e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
2892e73aae67SJuan Quintela
2893600309b6SBlue Swirlcase "$target_arch2" in
28942408a527Saurel32  i386)
28951ad2134fSPaul Brook    target_phys_bits=32
28962408a527Saurel32  ;;
28972408a527Saurel32  x86_64)
28986acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
28991ad2134fSPaul Brook    target_phys_bits=64
29002408a527Saurel32  ;;
29012408a527Saurel32  alpha)
29021ad2134fSPaul Brook    target_phys_bits=64
2903a4b388ffSRichard Henderson    target_nptl="yes"
29042408a527Saurel32  ;;
29052408a527Saurel32  arm|armeb)
2906b498c8a0SJuan Quintela    TARGET_ARCH=arm
2907e5fe0c52Spbrook    bflt="yes"
2908bd0c5661Spbrook    target_nptl="yes"
290956aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
29101ad2134fSPaul Brook    target_phys_bits=32
29112408a527Saurel32  ;;
29122408a527Saurel32  cris)
2913253bd7f8Sedgar_igl    target_nptl="yes"
29141ad2134fSPaul Brook    target_phys_bits=32
29152408a527Saurel32  ;;
29162408a527Saurel32  m68k)
29170938cda5Saurel32    bflt="yes"
291856aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
29191ad2134fSPaul Brook    target_phys_bits=32
29202408a527Saurel32  ;;
292172b675caSEdgar E. Iglesias  microblaze)
292272b675caSEdgar E. Iglesias    bflt="yes"
292372b675caSEdgar E. Iglesias    target_nptl="yes"
292472b675caSEdgar E. Iglesias    target_phys_bits=32
292572b675caSEdgar E. Iglesias  ;;
29262408a527Saurel32  mips|mipsel)
2927b498c8a0SJuan Quintela    TARGET_ARCH=mips
292825be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2929f04dc72fSPaul Brook    target_nptl="yes"
29301ad2134fSPaul Brook    target_phys_bits=64
29312408a527Saurel32  ;;
29322408a527Saurel32  mipsn32|mipsn32el)
2933b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
29346acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
293525be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
29361ad2134fSPaul Brook    target_phys_bits=64
29372408a527Saurel32  ;;
29382408a527Saurel32  mips64|mips64el)
2939b498c8a0SJuan Quintela    TARGET_ARCH=mips64
29406acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
294125be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
29421ad2134fSPaul Brook    target_phys_bits=64
29432408a527Saurel32  ;;
29442408a527Saurel32  ppc)
2945c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
29461ad2134fSPaul Brook    target_phys_bits=32
2947d6630708SNathan Froyd    target_nptl="yes"
29482408a527Saurel32  ;;
29492408a527Saurel32  ppcemb)
29506acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2951e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2952c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
29531ad2134fSPaul Brook    target_phys_bits=64
2954d6630708SNathan Froyd    target_nptl="yes"
29552408a527Saurel32  ;;
29562408a527Saurel32  ppc64)
29576acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2958e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
2959c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
29601ad2134fSPaul Brook    target_phys_bits=64
29612408a527Saurel32  ;;
29622408a527Saurel32  ppc64abi32)
2963b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
29646acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
2965e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
296625be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
2967c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
29681ad2134fSPaul Brook    target_phys_bits=64
29692408a527Saurel32  ;;
29702408a527Saurel32  sh4|sh4eb)
2971b498c8a0SJuan Quintela    TARGET_ARCH=sh4
29724dbed897Spbrook    bflt="yes"
29730b6d3ae0Saurel32    target_nptl="yes"
29741ad2134fSPaul Brook    target_phys_bits=32
29752408a527Saurel32  ;;
29762408a527Saurel32  sparc)
29771ad2134fSPaul Brook    target_phys_bits=64
29782408a527Saurel32  ;;
29792408a527Saurel32  sparc64)
29806acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
29811ad2134fSPaul Brook    target_phys_bits=64
29822408a527Saurel32  ;;
29832408a527Saurel32  sparc32plus)
2984b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
29856acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
2986e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
298725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
29881ad2134fSPaul Brook    target_phys_bits=64
29892408a527Saurel32  ;;
299024e804ecSAlexander Graf  s390x)
299124e804ecSAlexander Graf    target_phys_bits=64
299224e804ecSAlexander Graf  ;;
29932408a527Saurel32  *)
2994de83cd02Sbellard    echo "Unsupported target CPU"
2995de83cd02Sbellard    exit 1
29962408a527Saurel32  ;;
29972408a527Saurel32esac
299825be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
2999053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
300025be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
300125be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
300242bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
30036acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
30046acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
30056acff7daSJuan Quintelafi
300625be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3007e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3008e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3009e6e91b9cSJuan Quintelafi
301025be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
30111b0c87fcSJuan Quintelacase "$target_arch2" in
30121b0c87fcSJuan Quintela  i386|x86_64)
30131b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
301425be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
30151b0c87fcSJuan Quintela    fi
30161b0c87fcSJuan Quintelaesac
3017c59249f9SJuan Quintelacase "$target_arch2" in
30180e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3019c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3020c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3021c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3022c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
30235f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3024c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3025c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
302625be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
302725be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
3028dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
3029dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
3030dae5079aSJan Kiszka      fi
3031d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
3032d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3033d5970055SMichael S. Tsirkin      fi
3034c59249f9SJuan Quintela    fi
3035c59249f9SJuan Quintelaesac
3036de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
303725be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
303897a847bcSbellardfi
303997a847bcSbellardif test "$target_softmmu" = "yes" ; then
3040b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
304125be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
304225be210fSJuan Quintela  echo "LIBS+=$libs_softmmu" >> $config_target_mak
30430e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
30445791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3045de83cd02Sbellardfi
3046997344f3Sbellardif test "$target_user_only" = "yes" ; then
304725be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3048997344f3Sbellardfi
3049831b7825Sthsif test "$target_linux_user" = "yes" ; then
305025be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3051831b7825Sthsfi
3052831b7825Sthsif test "$target_darwin_user" = "yes" ; then
305325be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3054831b7825Sthsfi
305556aebc89Spbrooklist=""
305656aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
305756aebc89Spbrook  for x in $gdb_xml_files; do
305856aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
305956aebc89Spbrook  done
306025be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
30613d0f1517SJuan Quintelafi
3062de83cd02Sbellard
3063f57975fbSJuan Quintelacase "$target_arch2" in
3064eb8f7776SAurelien Jarno  i386|x86_64)
3065eb8f7776SAurelien Jarno    echo "CONFIG_NOSOFTFLOAT=y" >> $config_target_mak
3066f57975fbSJuan Quintela    ;;
3067d6b38939SJuan Quintela  *)
3068eb8f7776SAurelien Jarno    echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
3069d6b38939SJuan Quintela    ;;
3070f57975fbSJuan Quintelaesac
3071f57975fbSJuan Quintela
3072e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
307325be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3074e5fe0c52Spbrookfi
3075bd0c5661Spbrookif test "$target_user_only" = "yes" \
3076bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
307725be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3078bd0c5661Spbrookfi
3079379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
308025be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3081379f6698SPaul Brookfi
308284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
308325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
308484778508Sblueswir1fi
30855b0753e0Sbellard
30864afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3087fa282484SJuan Quintela
30884afddb55SJuan Quintelacflags=""
3089f9728943SPaolo Bonziniincludes=""
3090fa282484SJuan Quintelaldflags=""
30919b8e111fSJuan Quintela
309257ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
3093f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
309424e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3095f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
30965d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3097f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
309857ddfbf7SJuan Quintelaelse
3099f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
310057ddfbf7SJuan Quintelafi
3101f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
3102f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/fpu $includes"
310357ddfbf7SJuan Quintela
31044d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
31054d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
31064d904533SBlue Swirlelse
31074d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
31084d904533SBlue Swirlfi
31094d904533SBlue Swirl
311064656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
311164656024SJuan Quintela  case "$i" in
311264656024SJuan Quintela  alpha)
311325be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
31144d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
311564656024SJuan Quintela  ;;
311664656024SJuan Quintela  arm)
311725be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
31184d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
311964656024SJuan Quintela  ;;
312064656024SJuan Quintela  cris)
312125be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
31224d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
312364656024SJuan Quintela  ;;
312464656024SJuan Quintela  hppa)
312525be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
31264d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
312764656024SJuan Quintela  ;;
312864656024SJuan Quintela  i386|x86_64)
312925be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
31304d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
313164656024SJuan Quintela  ;;
3132903ec55cSAurelien Jarno  ia64*)
3133903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3134903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3135903ec55cSAurelien Jarno  ;;
313664656024SJuan Quintela  m68k)
313725be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
31384d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
313964656024SJuan Quintela  ;;
314064656024SJuan Quintela  microblaze)
314125be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
31424d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
314364656024SJuan Quintela  ;;
314464656024SJuan Quintela  mips*)
314525be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
31464d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
314764656024SJuan Quintela  ;;
314864656024SJuan Quintela  ppc*)
314925be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
31504d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
315164656024SJuan Quintela  ;;
315224e804ecSAlexander Graf  s390*)
315325be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
31544d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
315564656024SJuan Quintela  ;;
315664656024SJuan Quintela  sh4)
315725be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
31584d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
315964656024SJuan Quintela  ;;
316064656024SJuan Quintela  sparc*)
316125be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
31624d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
316364656024SJuan Quintela  ;;
316464656024SJuan Quintela  esac
316564656024SJuan Quinteladone
316664656024SJuan Quintela
31676ee7126fSJuan Quintelacase "$ARCH" in
31686ee7126fSJuan Quintelaalpha)
31696ee7126fSJuan Quintela  # Ensure there's only a single GP
31706ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
31716ee7126fSJuan Quintela;;
31726ee7126fSJuan Quintelaesac
31736ee7126fSJuan Quintela
317455d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
317555d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
317655d9c04bSJuan Quintela  arm)
317755d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
317855d9c04bSJuan Quintela  ;;
317955d9c04bSJuan Quintela  i386|mips|ppc)
318055d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
318155d9c04bSJuan Quintela  ;;
318255d9c04bSJuan Quintela  esac
318355d9c04bSJuan Quintelafi
318455d9c04bSJuan Quintela
318534005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
318634005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
318734005a00SKirill A. Shutemov  cflags="-fpie $cflags"
318834005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
318934005a00SKirill A. Shutemovfi
319034005a00SKirill A. Shutemov
3191471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3192471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3193471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
319425be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3195471857ddSJuan Quintelafi
3196471857ddSJuan Quintela
3197d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
319825be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3199d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3200d02c1db3SJuan Quintela    cflags="-p $cflags"
3201d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3202d02c1db3SJuan Quintela  fi
3203d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3204d02c1db3SJuan Quintela    ldflags="-p $ldflags"
320525be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3206d02c1db3SJuan Quintela  fi
3207d02c1db3SJuan Quintelafi
3208d02c1db3SJuan Quintela
32096ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
32109b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3211fa282484SJuan Quintela  case "$ARCH" in
3212fa282484SJuan Quintela  sparc)
3213fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3214322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3215fa282484SJuan Quintela    ;;
32164d58be06SRichard Henderson  alpha | s390x)
32174d58be06SRichard Henderson    # The default placement of the application is fine.
32184d58be06SRichard Henderson    ;;
3219fd76e73aSRichard Henderson  *)
3220322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3221fa282484SJuan Quintela    ;;
3222fa282484SJuan Quintela  esac
3223fa282484SJuan Quintelafi
3224fa282484SJuan Quintela
322525be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
322625be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3227f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
3228fa282484SJuan Quintela
322997a847bcSbellarddone # for target in $targets
32307d13299dSbellard
3231d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
3232e1144d00SMark McLoughlinDIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
32332d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
32343e230dd2SCorentin CharyDIRS="$DIRS fsdev ui"
32357d13299dSbellardFILES="Makefile tests/Makefile"
3236e7daa605SthsFILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3237ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
32382d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
32397ea78b74SJan Kiszkafor bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
32407ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
32417ea78b74SJan Kiszkadone
3242d1807a4fSPaolo Bonzinimkdir -p $DIRS
32437d13299dSbellardfor f in $FILES ; do
3244eae30c8fSAurelien Jarno    test -e $f || symlink $source_path/$f $f
32457d13299dSbellarddone
32461ad2134fSPaul Brook
3247c34ebfdcSAnthony Liguori# temporary config to build submodules
32482d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3249c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
325037116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3251c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3252c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3253c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3254c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3255c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3256c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3257c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3258c34ebfdcSAnthony Liguoridone
3259c34ebfdcSAnthony Liguori
32601ad2134fSPaul Brookfor hwlib in 32 64; do
32611ad2134fSPaul Brook  d=libhw$hwlib
32621ad2134fSPaul Brook  mkdir -p $d
32639953b2fcSBlue Swirl  mkdir -p $d/ide
326411568d6dSPaolo Bonzini  symlink $source_path/Makefile.hw $d/Makefile
326537116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
32661ad2134fSPaul Brookdone
3267add16157SBlue Swirl
3268add16157SBlue Swirld=libuser
3269add16157SBlue Swirlmkdir -p $d
327011568d6dSPaolo Bonzinisymlink $source_path/Makefile.user $d/Makefile
3271299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
3272299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3273299060a0SKirill A. Shutemovfi
3274b40292e7SJan Kiszka
3275b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3276b40292e7SJan Kiszka  mkdir -p QMP
3277b40292e7SJan Kiszkafi
3278