xref: /openbmc/qemu/configure (revision 7dd319027c26763ad4d0b65c09d1d20105e5c715)
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=""
120821601eaSJes Sorensenvnc="yes"
121377529c0SPaolo Bonzinisparse="no"
122377529c0SPaolo Bonziniuuid=""
123377529c0SPaolo Bonzinivde=""
124377529c0SPaolo Bonzinivnc_tls=""
125377529c0SPaolo Bonzinivnc_sasl=""
126377529c0SPaolo Bonzinivnc_jpeg=""
127377529c0SPaolo Bonzinivnc_png=""
128377529c0SPaolo Bonzinivnc_thread="no"
129377529c0SPaolo Bonzinixen=""
130d5b93ddfSAnthony PERARDxen_ctrl_version=""
131377529c0SPaolo Bonzinilinux_aio=""
132377529c0SPaolo Bonziniattr=""
133377529c0SPaolo Bonzinivhost_net=""
134377529c0SPaolo Bonzinixfs=""
135377529c0SPaolo Bonzini
136377529c0SPaolo Bonzinigprof="no"
137377529c0SPaolo Bonzinidebug_tcg="no"
138377529c0SPaolo Bonzinidebug_mon="no"
139377529c0SPaolo Bonzinidebug="no"
140377529c0SPaolo Bonzinistrip_opt="yes"
141377529c0SPaolo Bonzinibigendian="no"
142377529c0SPaolo Bonzinimingw32="no"
143377529c0SPaolo BonziniEXESUF=""
144377529c0SPaolo Bonziniprefix="/usr/local"
145377529c0SPaolo Bonzinimandir="\${prefix}/share/man"
146377529c0SPaolo Bonzinidatadir="\${prefix}/share/qemu"
147377529c0SPaolo Bonzinidocdir="\${prefix}/share/doc/qemu"
148377529c0SPaolo Bonzinibindir="\${prefix}/bin"
149377529c0SPaolo Bonzinisysconfdir="\${prefix}/etc"
150377529c0SPaolo Bonziniconfsuffix="/qemu"
151377529c0SPaolo Bonzinislirp="yes"
152377529c0SPaolo Bonzinifmod_lib=""
153377529c0SPaolo Bonzinifmod_inc=""
154377529c0SPaolo Bonzinioss_lib=""
155377529c0SPaolo Bonzinibsd="no"
156377529c0SPaolo Bonzinilinux="no"
157377529c0SPaolo Bonzinisolaris="no"
158377529c0SPaolo Bonziniprofiler="no"
159377529c0SPaolo Bonzinicocoa="no"
160377529c0SPaolo Bonzinisoftmmu="yes"
161377529c0SPaolo Bonzinilinux_user="no"
162377529c0SPaolo Bonzinidarwin_user="no"
163377529c0SPaolo Bonzinibsd_user="no"
164377529c0SPaolo Bonziniguest_base=""
165377529c0SPaolo Bonziniuname_release=""
166377529c0SPaolo Bonziniio_thread="no"
167377529c0SPaolo Bonzinimixemu="no"
168377529c0SPaolo Bonzinikerneldir=""
169377529c0SPaolo Bonziniaix="no"
170377529c0SPaolo Bonziniblobs="yes"
171377529c0SPaolo Bonzinipkgversion=""
172377529c0SPaolo Bonzinicheck_utests="no"
173377529c0SPaolo Bonziniuser_pie="no"
174377529c0SPaolo Bonzinizero_malloc=""
175377529c0SPaolo Bonzinitrace_backend="nop"
176377529c0SPaolo Bonzinitrace_file="trace"
177377529c0SPaolo Bonzinispice=""
178377529c0SPaolo Bonzinirbd=""
17936707144SAlon Levysmartcard=""
180111a38b0SRobert Relyeasmartcard_nss=""
181430a3c18SMichael Walleopengl=""
182377529c0SPaolo Bonzini
183ac0df51dSaliguori# parse CC options first
184ac0df51dSaliguorifor opt do
185ac0df51dSaliguori  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
186ac0df51dSaliguori  case "$opt" in
187ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
188ac0df51dSaliguori  ;;
1893d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
190ac0df51dSaliguori  ;;
191ca4deeb1SPaolo Bonzini  --source-path=*) source_path="$optarg"
192ca4deeb1SPaolo Bonzini  ;;
1932ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
1942ff6b91eSJuan Quintela  ;;
195a558ee17SJuan Quintela  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
196e2a2ed06SJuan Quintela  ;;
197e2a2ed06SJuan Quintela  --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
198e2a2ed06SJuan Quintela  ;;
19950e7b1a0SJuan Quintela  --sparc_cpu=*)
20050e7b1a0SJuan Quintela    sparc_cpu="$optarg"
20150e7b1a0SJuan Quintela    case $sparc_cpu in
202ed968ff1SJuan Quintela    v7|v8|v8plus|v8plusa)
20350e7b1a0SJuan Quintela      cpu="sparc"
20450e7b1a0SJuan Quintela    ;;
20550e7b1a0SJuan Quintela    v9)
20650e7b1a0SJuan Quintela      cpu="sparc64"
20750e7b1a0SJuan Quintela    ;;
20850e7b1a0SJuan Quintela    *)
20950e7b1a0SJuan Quintela      echo "undefined SPARC architecture. Exiting";
21050e7b1a0SJuan Quintela      exit 1
21150e7b1a0SJuan Quintela    ;;
21250e7b1a0SJuan Quintela    esac
21350e7b1a0SJuan Quintela  ;;
214ac0df51dSaliguori  esac
215ac0df51dSaliguoridone
216ac0df51dSaliguori# OS specific
217ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
218ac0df51dSaliguori# we can eliminate it's usage altogether
219ac0df51dSaliguori
2203d8df640SPaolo Bonzinicc="${cross_prefix}${CC-gcc}"
2213d8df640SPaolo Bonziniar="${cross_prefix}${AR-ar}"
2223d8df640SPaolo Bonziniobjcopy="${cross_prefix}${OBJCOPY-objcopy}"
2233d8df640SPaolo Bonzinild="${cross_prefix}${LD-ld}"
2243d8df640SPaolo Bonzinistrip="${cross_prefix}${STRIP-strip}"
2253d8df640SPaolo Bonziniwindres="${cross_prefix}${WINDRES-windres}"
226a8bd70adSPaolo Bonzinipkg_config="${cross_prefix}${PKG_CONFIG-pkg-config}"
2273ec87ffeSPaolo Bonzinisdl_config="${cross_prefix}${SDL_CONFIG-sdl-config}"
228ac0df51dSaliguori
229be17dc90SMichael S. Tsirkin# default flags for all hosts
230be17dc90SMichael S. TsirkinQEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
231be17dc90SMichael S. TsirkinCFLAGS="-g $CFLAGS"
232be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
233be17dc90SMichael S. TsirkinQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
234be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
23584958305SKirill A. ShutemovQEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
236f9728943SPaolo BonziniQEMU_INCLUDES="-I. -I\$(SRC_PATH)"
237be17dc90SMichael S. TsirkinLDFLAGS="-g $LDFLAGS"
238be17dc90SMichael S. Tsirkin
239ca4deeb1SPaolo Bonzini# make source path absolute
240ca4deeb1SPaolo Bonzinisource_path=`cd "$source_path"; pwd`
241ca4deeb1SPaolo Bonzini
242ac0df51dSaliguoricheck_define() {
243ac0df51dSaliguoricat > $TMPC <<EOF
244ac0df51dSaliguori#if !defined($1)
245ac0df51dSaliguori#error Not defined
246ac0df51dSaliguori#endif
247ac0df51dSaliguoriint main(void) { return 0; }
248ac0df51dSaliguoriEOF
24952166aa0SJuan Quintela  compile_object
250ac0df51dSaliguori}
251ac0df51dSaliguori
2522ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
2532ff6b91eSJuan Quintela  # command line argument
2542ff6b91eSJuan Quintela  :
2552ff6b91eSJuan Quintelaelif check_define __i386__ ; then
256ac0df51dSaliguori  cpu="i386"
257ac0df51dSaliguorielif check_define __x86_64__ ; then
258ac0df51dSaliguori  cpu="x86_64"
2593aa9bd6cSblueswir1elif check_define __sparc__ ; then
2603aa9bd6cSblueswir1  # We can't check for 64 bit (when gcc is biarch) or V8PLUSA
2613aa9bd6cSblueswir1  # They must be specified using --sparc_cpu
2623aa9bd6cSblueswir1  if check_define __arch64__ ; then
2633aa9bd6cSblueswir1    cpu="sparc64"
2643aa9bd6cSblueswir1  else
2653aa9bd6cSblueswir1    cpu="sparc"
2663aa9bd6cSblueswir1  fi
267fdf7ed96Smalcelif check_define _ARCH_PPC ; then
268fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
269fdf7ed96Smalc    cpu="ppc64"
270ac0df51dSaliguori  else
271fdf7ed96Smalc    cpu="ppc"
272fdf7ed96Smalc  fi
273afa05235SAurelien Jarnoelif check_define __mips__ ; then
274afa05235SAurelien Jarno  cpu="mips"
275477ba620SAurelien Jarnoelif check_define __ia64__ ; then
276477ba620SAurelien Jarno  cpu="ia64"
277d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
278d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
279d66ed0eaSAurelien Jarno    cpu="s390x"
280d66ed0eaSAurelien Jarno  else
281d66ed0eaSAurelien Jarno    cpu="s390"
282d66ed0eaSAurelien Jarno  fi
283fdf7ed96Smalcelse
284fdf7ed96Smalc  cpu=`uname -m`
285ac0df51dSaliguorifi
286ac0df51dSaliguori
2877d13299dSbellardcase "$cpu" in
288d2fbca94SGuan Xuetao  alpha|cris|ia64|lm32|m68k|microblaze|ppc|ppc64|sparc64|unicore32)
289ea8f20f8SJuan Quintela    cpu="$cpu"
290ea8f20f8SJuan Quintela  ;;
2917d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
29297a847bcSbellard    cpu="i386"
2937d13299dSbellard  ;;
294aaa5fa14Saurel32  x86_64|amd64)
295aaa5fa14Saurel32    cpu="x86_64"
296aaa5fa14Saurel32  ;;
297ba68055eSbellard  armv*b)
298808c4954Sbellard    cpu="armv4b"
299808c4954Sbellard  ;;
300ba68055eSbellard  armv*l)
3017d13299dSbellard    cpu="armv4l"
3027d13299dSbellard  ;;
303f54b3f92Saurel32  parisc|parisc64)
304f54b3f92Saurel32    cpu="hppa"
305f54b3f92Saurel32  ;;
306afa05235SAurelien Jarno  mips*)
307afa05235SAurelien Jarno    cpu="mips"
308afa05235SAurelien Jarno  ;;
30924e804ecSAlexander Graf  s390)
310fb3e5849Sbellard    cpu="s390"
311fb3e5849Sbellard  ;;
31224e804ecSAlexander Graf  s390x)
31324e804ecSAlexander Graf    cpu="s390x"
31424e804ecSAlexander Graf  ;;
3153142255cSblueswir1  sparc|sun4[cdmuv])
316ae228531Sbellard    cpu="sparc"
317ae228531Sbellard  ;;
3187d13299dSbellard  *)
319a447d4dcSPaolo Bonzini    echo "Unsupported CPU = $cpu"
320a447d4dcSPaolo Bonzini    exit 1
3217d13299dSbellard  ;;
3227d13299dSbellardesac
323e2d52ad3SJuan Quintela
3247d13299dSbellard# OS specific
325ac0df51dSaliguoriif check_define __linux__ ; then
326ac0df51dSaliguori  targetos="Linux"
327ac0df51dSaliguorielif check_define _WIN32 ; then
328ac0df51dSaliguori  targetos='MINGW32'
329169dc5d3Sblueswir1elif check_define __OpenBSD__ ; then
330169dc5d3Sblueswir1  targetos='OpenBSD'
331169dc5d3Sblueswir1elif check_define __sun__ ; then
332169dc5d3Sblueswir1  targetos='SunOS'
333179cf400SAndreas Färberelif check_define __HAIKU__ ; then
334179cf400SAndreas Färber  targetos='Haiku'
335ac0df51dSaliguorielse
3367d13299dSbellard  targetos=`uname -s`
337ac0df51dSaliguorifi
3380dbfc675SJuan Quintela
3397d13299dSbellardcase $targetos in
340c326e0afSbellardCYGWIN*)
341c326e0afSbellard  mingw32="yes"
342a558ee17SJuan Quintela  QEMU_CFLAGS="-mno-cygwin $QEMU_CFLAGS"
343d5631638Smalc  audio_possible_drivers="winwave sdl"
344d5631638Smalc  audio_drv_list="winwave"
345c326e0afSbellard;;
34667b915a5SbellardMINGW32*)
34767b915a5Sbellard  mingw32="yes"
348d5631638Smalc  audio_possible_drivers="winwave dsound sdl fmod"
349d5631638Smalc  audio_drv_list="winwave"
35067b915a5Sbellard;;
3515c40d2bdSthsGNU/kFreeBSD)
352a167ba50SAurelien Jarno  bsd="yes"
3530c58ac1cSmalc  audio_drv_list="oss"
354f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
3555c40d2bdSths;;
3567d3505c5SbellardFreeBSD)
3577d3505c5Sbellard  bsd="yes"
3580db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3590c58ac1cSmalc  audio_drv_list="oss"
360f34af52cSaurel32  audio_possible_drivers="oss sdl esd pa"
361f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
362f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
3637d3505c5Sbellard;;
364c5e97233Sblueswir1DragonFly)
365c5e97233Sblueswir1  bsd="yes"
3660db4a067SPaolo Bonzini  make="${MAKE-gmake}"
367c5e97233Sblueswir1  audio_drv_list="oss"
368c5e97233Sblueswir1  audio_possible_drivers="oss sdl esd pa"
369c5e97233Sblueswir1;;
3707d3505c5SbellardNetBSD)
3717d3505c5Sbellard  bsd="yes"
3720db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3730c58ac1cSmalc  audio_drv_list="oss"
374c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3758ef92a88Sblueswir1  oss_lib="-lossaudio"
3767d3505c5Sbellard;;
3777d3505c5SbellardOpenBSD)
3787d3505c5Sbellard  bsd="yes"
3790db4a067SPaolo Bonzini  make="${MAKE-gmake}"
3800c58ac1cSmalc  audio_drv_list="oss"
381c2de5c91Smalc  audio_possible_drivers="oss sdl esd"
3822f6a1ab0Sblueswir1  oss_lib="-lossaudio"
3837d3505c5Sbellard;;
38483fb7adfSbellardDarwin)
38583fb7adfSbellard  bsd="yes"
38683fb7adfSbellard  darwin="yes"
3870dbfc675SJuan Quintela  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can
3880dbfc675SJuan Quintela  # run 64-bit userspace code
389aab8588aSmalc  if [ "$cpu" = "i386" ] ; then
3901b0f9cc2Saliguori    is_x86_64=`sysctl -n hw.optional.x86_64`
391aab8588aSmalc    [ "$is_x86_64" = "1" ] && cpu=x86_64
3921b0f9cc2Saliguori  fi
3931b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
394a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
3950c439cbfSJuan Quintela    LDFLAGS="-arch x86_64 $LDFLAGS"
3961b0f9cc2Saliguori  else
397a558ee17SJuan Quintela    QEMU_CFLAGS="-mdynamic-no-pic $QEMU_CFLAGS"
3981b0f9cc2Saliguori  fi
399831b7825Sths  darwin_user="yes"
400fd677642Sths  cocoa="yes"
4010c58ac1cSmalc  audio_drv_list="coreaudio"
402c2de5c91Smalc  audio_possible_drivers="coreaudio sdl fmod"
4030c439cbfSJuan Quintela  LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
4047973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
40583fb7adfSbellard;;
406ec530c81SbellardSunOS)
407ec530c81Sbellard  solaris="yes"
4080db4a067SPaolo Bonzini  make="${MAKE-gmake}"
4090db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
410fa58948dSBlue Swirl  ld="gld"
4110475a5caSths  needs_libsunmath="no"
412c2b84fabSths  solarisrev=`uname -r | cut -f2 -d.`
413ef18c883Sths  # have to select again, because `uname -m` returns i86pc
414ef18c883Sths  # even on an x86_64 box.
415ef18c883Sths  solariscpu=`isainfo -k`
416ef18c883Sths  if test "${solariscpu}" = "amd64" ; then
417ef18c883Sths    cpu="x86_64"
418ef18c883Sths  fi
419c2b84fabSths  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
4200475a5caSths    if test "$solarisrev" -le 9 ; then
4210475a5caSths      if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
4220475a5caSths        needs_libsunmath="yes"
423f14bfdf9SJuan Quintela        QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
424f14bfdf9SJuan Quintela        LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
425f14bfdf9SJuan Quintela        LIBS="-lsunmath $LIBS"
4260475a5caSths      else
4270475a5caSths        echo "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without"
4280475a5caSths        echo "libsunmath from the Sun Studio compilers tools, due to a lack of"
4290475a5caSths        echo "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86"
4300475a5caSths        echo "Studio 11 can be downloaded from www.sun.com."
4310475a5caSths        exit 1
4320475a5caSths      fi
4330475a5caSths    fi
43486b2bd93Sths  fi
4356b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
4360c58ac1cSmalc    audio_drv_list="oss"
4376b4d2ba1Sths  fi
438c2de5c91Smalc  audio_possible_drivers="oss sdl"
439d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
440d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
441d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
442d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
443a558ee17SJuan Quintela  QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
444e174c0bbSJuan Quintela  LIBS="-lsocket -lnsl -lresolv $LIBS"
445ec530c81Sbellard;;
446b29fe3edSmalcAIX)
447b29fe3edSmalc  aix="yes"
4480db4a067SPaolo Bonzini  make="${MAKE-gmake}"
449b29fe3edSmalc;;
450179cf400SAndreas FärberHaiku)
451179cf400SAndreas Färber  haiku="yes"
452179cf400SAndreas Färber  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
453179cf400SAndreas Färber  LIBS="-lposix_error_mapper -lnetwork $LIBS"
454179cf400SAndreas Färber;;
455fb065187Sbellard*)
4560c58ac1cSmalc  audio_drv_list="oss"
457b8e59f18Smalc  audio_possible_drivers="oss alsa sdl esd pa"
4585327cf48Sbellard  linux="yes"
459831b7825Sths  linux_user="yes"
46068063649Sblueswir1  usb="linux"
46107f4ddbfSbellard  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
462c2de5c91Smalc    audio_possible_drivers="$audio_possible_drivers fmod"
463c9ec1fe4Sbellard  fi
464fb065187Sbellard;;
4657d13299dSbellardesac
4667d13299dSbellard
4677d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
468b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
46968063649Sblueswir1    usb="bsd"
47083fb7adfSbellard  fi
47184778508Sblueswir1  bsd_user="yes"
4727d3505c5Sbellardfi
4737d3505c5Sbellard
4740db4a067SPaolo Bonzini: ${make=${MAKE-make}}
4750db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
4760db4a067SPaolo Bonzini
4773457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
4783457a3f8SJuan Quintela  EXESUF=".exe"
479a558ee17SJuan Quintela  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
480e94a7936SStefan Weil  # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
481e94a7936SStefan Weil  QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
48208f3896aSStefan Weil  LIBS="-lwinmm -lws2_32 -liberty -liphlpapi $LIBS"
483683035deSPaolo Bonzini  prefix="c:/Program Files/Qemu"
484683035deSPaolo Bonzini  mandir="\${prefix}"
485683035deSPaolo Bonzini  datadir="\${prefix}"
486683035deSPaolo Bonzini  docdir="\${prefix}"
487683035deSPaolo Bonzini  bindir="\${prefix}"
488683035deSPaolo Bonzini  sysconfdir="\${prefix}"
489683035deSPaolo Bonzini  confsuffix=""
4903457a3f8SJuan Quintelafi
4913457a3f8SJuan Quintela
492487fefdbSAnthony Liguoriwerror=""
49385aa5189Sbellard
4947d13299dSbellardfor opt do
495a46e4035Spbrook  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
4967d13299dSbellard  case "$opt" in
4972efc3265Sbellard  --help|-h) show_help=yes
4982efc3265Sbellard  ;;
49999123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
50099123e13SMike Frysinger  ;;
501b1a550a0Spbrook  --prefix=*) prefix="$optarg"
5027d13299dSbellard  ;;
503b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
50432ce6337Sbellard  ;;
505ca4deeb1SPaolo Bonzini  --source-path=*)
5067d13299dSbellard  ;;
507ac0df51dSaliguori  --cross-prefix=*)
5087d13299dSbellard  ;;
509ac0df51dSaliguori  --cc=*)
5107d13299dSbellard  ;;
511b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
51283469015Sbellard  ;;
513b1a550a0Spbrook  --make=*) make="$optarg"
5147d13299dSbellard  ;;
5156a882643Spbrook  --install=*) install="$optarg"
5166a882643Spbrook  ;;
517e2a2ed06SJuan Quintela  --extra-cflags=*)
5187d13299dSbellard  ;;
519e2a2ed06SJuan Quintela  --extra-ldflags=*)
5207d13299dSbellard  ;;
5212ff6b91eSJuan Quintela  --cpu=*)
5227d13299dSbellard  ;;
523b1a550a0Spbrook  --target-list=*) target_list="$optarg"
524de83cd02Sbellard  ;;
52574242e0fSPaolo Bonzini  --enable-trace-backend=*) trace_backend="$optarg"
52694a420b1SStefan Hajnoczi  ;;
52774242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
5289410b56cSPrerna Saxena  ;;
5297d13299dSbellard  --enable-gprof) gprof="yes"
5307d13299dSbellard  ;;
53179427693SLoïc Minier  --static)
53279427693SLoïc Minier    static="yes"
53379427693SLoïc Minier    LDFLAGS="-static $LDFLAGS"
53443ce4dfeSbellard  ;;
5350b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
5360b24e75fSPaolo Bonzini  ;;
5370b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
5380b24e75fSPaolo Bonzini  ;;
5390b24e75fSPaolo Bonzini  --datadir=*) datadir="$optarg"
5400b24e75fSPaolo Bonzini  ;;
5410b24e75fSPaolo Bonzini  --docdir=*) docdir="$optarg"
5420b24e75fSPaolo Bonzini  ;;
543ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
54407381cc1SAnthony Liguori  ;;
54597a847bcSbellard  --disable-sdl) sdl="no"
54697a847bcSbellard  ;;
547c4198157SJuan Quintela  --enable-sdl) sdl="yes"
548c4198157SJuan Quintela  ;;
549821601eaSJes Sorensen  --disable-vnc) vnc="no"
550821601eaSJes Sorensen  ;;
551821601eaSJes Sorensen  --enable-vnc) vnc="yes"
552821601eaSJes Sorensen  ;;
553b1a550a0Spbrook  --fmod-lib=*) fmod_lib="$optarg"
554102a52e4Sbellard  ;;
555c2de5c91Smalc  --fmod-inc=*) fmod_inc="$optarg"
556c2de5c91Smalc  ;;
5572f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
5582f6a1ab0Sblueswir1  ;;
5592fa7d3bfSmalc  --audio-card-list=*) audio_card_list=`echo "$optarg" | sed -e 's/,/ /g'`
5600c58ac1cSmalc  ;;
5610c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
5620c58ac1cSmalc  ;;
563eb852011SMarkus Armbruster  --block-drv-whitelist=*) block_drv_whitelist=`echo "$optarg" | sed -e 's/,/ /g'`
564eb852011SMarkus Armbruster  ;;
565f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
566f8393946Saurel32  ;;
567f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
568f8393946Saurel32  ;;
569b4475aa2SLuiz Capitulino  --enable-debug-mon) debug_mon="yes"
570b4475aa2SLuiz Capitulino  ;;
571b4475aa2SLuiz Capitulino  --disable-debug-mon) debug_mon="no"
572b4475aa2SLuiz Capitulino  ;;
573f3d08ee6SPaul Brook  --enable-debug)
574f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
575f3d08ee6SPaul Brook      debug_tcg="yes"
576b4475aa2SLuiz Capitulino      debug_mon="yes"
577f3d08ee6SPaul Brook      debug="yes"
578f3d08ee6SPaul Brook      strip_opt="no"
579f3d08ee6SPaul Brook  ;;
58003b4fe7dSaliguori  --enable-sparse) sparse="yes"
58103b4fe7dSaliguori  ;;
58203b4fe7dSaliguori  --disable-sparse) sparse="no"
58303b4fe7dSaliguori  ;;
5841625af87Saliguori  --disable-strip) strip_opt="no"
5851625af87Saliguori  ;;
5868d5d2d4cSths  --disable-vnc-tls) vnc_tls="no"
5878d5d2d4cSths  ;;
5881be10ad2SJuan Quintela  --enable-vnc-tls) vnc_tls="yes"
5891be10ad2SJuan Quintela  ;;
5902f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
5912f9606b3Saliguori  ;;
592ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
593ea784e3bSJuan Quintela  ;;
5942f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
5952f6f5c7aSCorentin Chary  ;;
5962f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
5972f6f5c7aSCorentin Chary  ;;
598efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
599efe556adSCorentin Chary  ;;
600efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
601efe556adSCorentin Chary  ;;
602bd023f95SCorentin Chary  --disable-vnc-thread) vnc_thread="no"
603bd023f95SCorentin Chary  ;;
604bd023f95SCorentin Chary  --enable-vnc-thread) vnc_thread="yes"
605bd023f95SCorentin Chary  ;;
606443f1376Sbellard  --disable-slirp) slirp="no"
607c20709aaSbellard  ;;
608ee682d27SStefan Weil  --disable-uuid) uuid="no"
609ee682d27SStefan Weil  ;;
610ee682d27SStefan Weil  --enable-uuid) uuid="yes"
611ee682d27SStefan Weil  ;;
612e0e6c8c0Saliguori  --disable-vde) vde="no"
6138a16d273Sths  ;;
614dfb278bdSJuan Quintela  --enable-vde) vde="yes"
615dfb278bdSJuan Quintela  ;;
616e37630caSaliguori  --disable-xen) xen="no"
617e37630caSaliguori  ;;
618fc321b4bSJuan Quintela  --enable-xen) xen="yes"
619fc321b4bSJuan Quintela  ;;
6202e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
6212e4d9fb1Saurel32  ;;
6224ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
6234ffcedb6SJuan Quintela  ;;
624fb599c9aSbalrog  --disable-bluez) bluez="no"
625fb599c9aSbalrog  ;;
626a20a6f46SJuan Quintela  --enable-bluez) bluez="yes"
627a20a6f46SJuan Quintela  ;;
6287ba1e619Saliguori  --disable-kvm) kvm="no"
6297ba1e619Saliguori  ;;
630b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
631b31a0277SJuan Quintela  ;;
632cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
633cd4ec0b4SGerd Hoffmann  ;;
634cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
635cd4ec0b4SGerd Hoffmann  ;;
63605c2a3e7Sbellard  --enable-profiler) profiler="yes"
63705c2a3e7Sbellard  ;;
638c2de5c91Smalc  --enable-cocoa)
639c2de5c91Smalc      cocoa="yes" ;
640c2de5c91Smalc      sdl="no" ;
641c2de5c91Smalc      audio_drv_list="coreaudio `echo $audio_drv_list | sed s,coreaudio,,g`"
6425b0753e0Sbellard  ;;
643cad25d69Spbrook  --disable-system) softmmu="no"
6440a8e90f4Spbrook  ;;
645cad25d69Spbrook  --enable-system) softmmu="yes"
6460a8e90f4Spbrook  ;;
6470953a80fSZachary Amsden  --disable-user)
6480953a80fSZachary Amsden      linux_user="no" ;
6490953a80fSZachary Amsden      bsd_user="no" ;
6500953a80fSZachary Amsden      darwin_user="no"
6510953a80fSZachary Amsden  ;;
6520953a80fSZachary Amsden  --enable-user) ;;
653831b7825Sths  --disable-linux-user) linux_user="no"
6540a8e90f4Spbrook  ;;
655831b7825Sths  --enable-linux-user) linux_user="yes"
656831b7825Sths  ;;
657831b7825Sths  --disable-darwin-user) darwin_user="no"
658831b7825Sths  ;;
659831b7825Sths  --enable-darwin-user) darwin_user="yes"
6600a8e90f4Spbrook  ;;
66184778508Sblueswir1  --disable-bsd-user) bsd_user="no"
66284778508Sblueswir1  ;;
66384778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
66484778508Sblueswir1  ;;
665379f6698SPaul Brook  --enable-guest-base) guest_base="yes"
666379f6698SPaul Brook  ;;
667379f6698SPaul Brook  --disable-guest-base) guest_base="no"
668379f6698SPaul Brook  ;;
66934005a00SKirill A. Shutemov  --enable-user-pie) user_pie="yes"
67034005a00SKirill A. Shutemov  ;;
67134005a00SKirill A. Shutemov  --disable-user-pie) user_pie="no"
67234005a00SKirill A. Shutemov  ;;
673c5937220Spbrook  --enable-uname-release=*) uname_release="$optarg"
674c5937220Spbrook  ;;
6753142255cSblueswir1  --sparc_cpu=*)
6763142255cSblueswir1  ;;
67785aa5189Sbellard  --enable-werror) werror="yes"
67885aa5189Sbellard  ;;
67985aa5189Sbellard  --disable-werror) werror="no"
68085aa5189Sbellard  ;;
6814d3b6f6eSbalrog  --disable-curses) curses="no"
6824d3b6f6eSbalrog  ;;
683c584a6d0SJuan Quintela  --enable-curses) curses="yes"
684c584a6d0SJuan Quintela  ;;
685769ce76dSAlexander Graf  --disable-curl) curl="no"
686769ce76dSAlexander Graf  ;;
687788c8196SJuan Quintela  --enable-curl) curl="yes"
688788c8196SJuan Quintela  ;;
6892df87df7SJuan Quintela  --disable-fdt) fdt="no"
6902df87df7SJuan Quintela  ;;
6912df87df7SJuan Quintela  --enable-fdt) fdt="yes"
6922df87df7SJuan Quintela  ;;
6935495ed11SLuiz Capitulino  --disable-check-utests) check_utests="no"
6945495ed11SLuiz Capitulino  ;;
6955495ed11SLuiz Capitulino  --enable-check-utests) check_utests="yes"
6965495ed11SLuiz Capitulino  ;;
697bd0c5661Spbrook  --disable-nptl) nptl="no"
698bd0c5661Spbrook  ;;
699b0a47e79SJuan Quintela  --enable-nptl) nptl="yes"
700b0a47e79SJuan Quintela  ;;
7018ff9cbf7Smalc  --enable-mixemu) mixemu="yes"
7028ff9cbf7Smalc  ;;
7035c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
7045c6c3a6cSChristoph Hellwig  ;;
7055c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
7065c6c3a6cSChristoph Hellwig  ;;
707758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
708758e8e38SVenkateswararao Jujjuri (JV)  ;;
709758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
710758e8e38SVenkateswararao Jujjuri (JV)  ;;
711e5d355d1Saliguori  --enable-io-thread) io_thread="yes"
712e5d355d1Saliguori  ;;
71377755340Sths  --disable-blobs) blobs="no"
71477755340Sths  ;;
715eac30262Saliguori  --kerneldir=*) kerneldir="$optarg"
716eac30262Saliguori  ;;
7174a19f1ecSpbrook  --with-pkgversion=*) pkgversion=" ($optarg)"
7184a19f1ecSpbrook  ;;
719a25dba17SJuan Quintela  --disable-docs) docs="no"
72070ec5dc0SAnthony Liguori  ;;
721a25dba17SJuan Quintela  --enable-docs) docs="yes"
72283a3ab8bSJuan Quintela  ;;
723d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
724d5970055SMichael S. Tsirkin  ;;
725d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
726d5970055SMichael S. Tsirkin  ;;
72720ff075bSMichael Walle  --disable-opengl) opengl="no"
72820ff075bSMichael Walle  ;;
72920ff075bSMichael Walle  --enable-opengl) opengl="yes"
73020ff075bSMichael Walle  ;;
7316bde81cbSPaolo Bonzini  --*dir)
7326bde81cbSPaolo Bonzini  ;;
733f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
734f27aaf4bSChristian Brunner  ;;
735f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
736f27aaf4bSChristian Brunner  ;;
73736707144SAlon Levy  --disable-smartcard) smartcard="no"
73836707144SAlon Levy  ;;
73936707144SAlon Levy  --enable-smartcard) smartcard="yes"
74036707144SAlon Levy  ;;
741111a38b0SRobert Relyea  --disable-smartcard-nss) smartcard_nss="no"
742111a38b0SRobert Relyea  ;;
743111a38b0SRobert Relyea  --enable-smartcard-nss) smartcard_nss="yes"
744111a38b0SRobert Relyea  ;;
7457f1559c6Sbalrog  *) echo "ERROR: unknown option $opt"; show_help="yes"
7467f1559c6Sbalrog  ;;
7477d13299dSbellard  esac
7487d13299dSbellarddone
7497d13299dSbellard
7503142255cSblueswir1#
7513142255cSblueswir1# If cpu ~= sparc and  sparc_cpu hasn't been defined, plug in the right
752a558ee17SJuan Quintela# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
7533142255cSblueswir1#
754379f6698SPaul Brookhost_guest_base="no"
75540293e58Sbellardcase "$cpu" in
756ed968ff1SJuan Quintela    sparc) case $sparc_cpu in
757ed968ff1SJuan Quintela           v7|v8)
758a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
759ed968ff1SJuan Quintela           ;;
760ed968ff1SJuan Quintela           v8plus|v8plusa)
761a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
762ed968ff1SJuan Quintela           ;;
763ed968ff1SJuan Quintela           *) # sparc_cpu not defined in the command line
764a558ee17SJuan Quintela             QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
765ed968ff1SJuan Quintela           esac
7660c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
767a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
768762e8230Sblueswir1           if test "$solaris" = "no" ; then
769a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
770c81da56eSJuan Quintela             helper_cflags="-ffixed-i0"
771762e8230Sblueswir1           fi
7723142255cSblueswir1           ;;
773ed968ff1SJuan Quintela    sparc64)
774a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
7750c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
776a558ee17SJuan Quintela           QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
777ed968ff1SJuan Quintela           if test "$solaris" != "no" ; then
778a558ee17SJuan Quintela             QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
779762e8230Sblueswir1           fi
7803142255cSblueswir1           ;;
78176d83bdeSths    s390)
78228d7cc49SRichard Henderson           QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
78328d7cc49SRichard Henderson           LDFLAGS="-m31 $LDFLAGS"
78448bb3750SRichard Henderson           host_guest_base="yes"
78528d7cc49SRichard Henderson           ;;
78628d7cc49SRichard Henderson    s390x)
78728d7cc49SRichard Henderson           QEMU_CFLAGS="-m64 -march=z990 $QEMU_CFLAGS"
78828d7cc49SRichard Henderson           LDFLAGS="-m64 $LDFLAGS"
78948bb3750SRichard Henderson           host_guest_base="yes"
79076d83bdeSths           ;;
79140293e58Sbellard    i386)
792a558ee17SJuan Quintela           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
7930c439cbfSJuan Quintela           LDFLAGS="-m32 $LDFLAGS"
7942b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
795c81da56eSJuan Quintela           helper_cflags="-fomit-frame-pointer"
796379f6698SPaul Brook           host_guest_base="yes"
79740293e58Sbellard           ;;
79840293e58Sbellard    x86_64)
799a558ee17SJuan Quintela           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
8000c439cbfSJuan Quintela           LDFLAGS="-m64 $LDFLAGS"
8012b2e59e6SPaolo Bonzini           cc_i386='$(CC) -m32'
802379f6698SPaul Brook           host_guest_base="yes"
803379f6698SPaul Brook           ;;
804379f6698SPaul Brook    arm*)
805379f6698SPaul Brook           host_guest_base="yes"
80640293e58Sbellard           ;;
807f6548c0aSmalc    ppc*)
808f6548c0aSmalc           host_guest_base="yes"
809f6548c0aSmalc           ;;
810cc01cc8eSAurelien Jarno    mips*)
811cc01cc8eSAurelien Jarno           host_guest_base="yes"
812cc01cc8eSAurelien Jarno           ;;
813477ba620SAurelien Jarno    ia64*)
814477ba620SAurelien Jarno           host_guest_base="yes"
815477ba620SAurelien Jarno           ;;
816fd76e73aSRichard Henderson    hppa*)
817fd76e73aSRichard Henderson           host_guest_base="yes"
818fd76e73aSRichard Henderson           ;;
819d2fbca94SGuan Xuetao    unicore32*)
820d2fbca94SGuan Xuetao           host_guest_base="yes"
821d2fbca94SGuan Xuetao           ;;
8223142255cSblueswir1esac
8233142255cSblueswir1
824379f6698SPaul Brook[ -z "$guest_base" ] && guest_base="$host_guest_base"
825379f6698SPaul Brook
826af5db58eSpbrookif test x"$show_help" = x"yes" ; then
827af5db58eSpbrookcat << EOF
828af5db58eSpbrook
829af5db58eSpbrookUsage: configure [options]
830af5db58eSpbrookOptions: [defaults in brackets after descriptions]
831af5db58eSpbrook
832af5db58eSpbrookEOF
833af5db58eSpbrookecho "Standard options:"
834af5db58eSpbrookecho "  --help                   print this message"
835af5db58eSpbrookecho "  --prefix=PREFIX          install in PREFIX [$prefix]"
836af5db58eSpbrookecho "  --interp-prefix=PREFIX   where to find shared libraries, etc."
837af5db58eSpbrookecho "                           use %M for cpu name [$interp_prefix]"
838af5db58eSpbrookecho "  --target-list=LIST       set target list [$target_list]"
839af5db58eSpbrookecho ""
840af5db58eSpbrookecho "Advanced options (experts only):"
841af5db58eSpbrookecho "  --source-path=PATH       path of source code [$source_path]"
842af5db58eSpbrookecho "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
843af5db58eSpbrookecho "  --cc=CC                  use C compiler CC [$cc]"
8440bfe8cc0SPaolo Bonziniecho "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
8450bfe8cc0SPaolo Bonziniecho "                           build time"
846a558ee17SJuan Quintelaecho "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
847e3fc14c3SJan Kiszkaecho "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
848af5db58eSpbrookecho "  --make=MAKE              use specified make [$make]"
8496a882643Spbrookecho "  --install=INSTALL        use specified install [$install]"
850af5db58eSpbrookecho "  --static                 enable static build [$static]"
8510b24e75fSPaolo Bonziniecho "  --mandir=PATH            install man pages in PATH"
8520b24e75fSPaolo Bonziniecho "  --datadir=PATH           install firmware in PATH"
8530b24e75fSPaolo Bonziniecho "  --docdir=PATH            install documentation in PATH"
8540b24e75fSPaolo Bonziniecho "  --bindir=PATH            install binaries in PATH"
8550b24e75fSPaolo Bonziniecho "  --sysconfdir=PATH        install config in PATH/qemu"
856f8393946Saurel32echo "  --enable-debug-tcg       enable TCG debugging"
857f8393946Saurel32echo "  --disable-debug-tcg      disable TCG debugging (default)"
85809695a4aSStefan Weilecho "  --enable-debug           enable common debug build options"
859890b1658Saliguoriecho "  --enable-sparse          enable sparse checker"
860890b1658Saliguoriecho "  --disable-sparse         disable sparse checker (default)"
8611625af87Saliguoriecho "  --disable-strip          disable stripping binaries"
86285aa5189Sbellardecho "  --disable-werror         disable compilation abort on warning"
863fe8f78e4Sbalrogecho "  --disable-sdl            disable SDL"
864c4198157SJuan Quintelaecho "  --enable-sdl             enable SDL"
865821601eaSJes Sorensenecho "  --disable-vnc            disable VNC"
866821601eaSJes Sorensenecho "  --enable-vnc             enable VNC"
867af5db58eSpbrookecho "  --enable-cocoa           enable COCOA (Mac OS X only)"
868c2de5c91Smalcecho "  --audio-drv-list=LIST    set audio drivers list:"
869c2de5c91Smalcecho "                           Available drivers: $audio_possible_drivers"
8704c9b53e3Smalcecho "  --audio-card-list=LIST   set list of emulated audio cards [$audio_card_list]"
8714c9b53e3Smalcecho "                           Available cards: $audio_possible_cards"
872eb852011SMarkus Armbrusterecho "  --block-drv-whitelist=L  set block driver whitelist"
873eb852011SMarkus Armbrusterecho "                           (affects only QEMU, not qemu-img)"
8748ff9cbf7Smalcecho "  --enable-mixemu          enable mixer emulation"
875e37630caSaliguoriecho "  --disable-xen            disable xen backend driver support"
876fc321b4bSJuan Quintelaecho "  --enable-xen             enable xen backend driver support"
8772e4d9fb1Saurel32echo "  --disable-brlapi         disable BrlAPI"
8784ffcedb6SJuan Quintelaecho "  --enable-brlapi          enable BrlAPI"
8798d5d2d4cSthsecho "  --disable-vnc-tls        disable TLS encryption for VNC server"
8801be10ad2SJuan Quintelaecho "  --enable-vnc-tls         enable TLS encryption for VNC server"
8812f9606b3Saliguoriecho "  --disable-vnc-sasl       disable SASL encryption for VNC server"
882ea784e3bSJuan Quintelaecho "  --enable-vnc-sasl        enable SASL encryption for VNC server"
8832f6f5c7aSCorentin Charyecho "  --disable-vnc-jpeg       disable JPEG lossy compression for VNC server"
8842f6f5c7aSCorentin Charyecho "  --enable-vnc-jpeg        enable JPEG lossy compression for VNC server"
88596763cf9SCorentin Charyecho "  --disable-vnc-png        disable PNG compression for VNC server (default)"
886efe556adSCorentin Charyecho "  --enable-vnc-png         enable PNG compression for VNC server"
887bd023f95SCorentin Charyecho "  --disable-vnc-thread     disable threaded VNC server"
888bd023f95SCorentin Charyecho "  --enable-vnc-thread      enable threaded VNC server"
889af896aaaSpbrookecho "  --disable-curses         disable curses output"
890c584a6d0SJuan Quintelaecho "  --enable-curses          enable curses output"
891769ce76dSAlexander Grafecho "  --disable-curl           disable curl connectivity"
892788c8196SJuan Quintelaecho "  --enable-curl            enable curl connectivity"
8932df87df7SJuan Quintelaecho "  --disable-fdt            disable fdt device tree"
8942df87df7SJuan Quintelaecho "  --enable-fdt             enable fdt device tree"
8955495ed11SLuiz Capitulinoecho "  --disable-check-utests   disable check unit-tests"
8965495ed11SLuiz Capitulinoecho "  --enable-check-utests    enable check unit-tests"
897fb599c9aSbalrogecho "  --disable-bluez          disable bluez stack connectivity"
898a20a6f46SJuan Quintelaecho "  --enable-bluez           enable bluez stack connectivity"
8997ba1e619Saliguoriecho "  --disable-kvm            disable KVM acceleration support"
900b31a0277SJuan Quintelaecho "  --enable-kvm             enable KVM acceleration support"
901bd0c5661Spbrookecho "  --disable-nptl           disable usermode NPTL support"
902e5934d33SAndre Przywaraecho "  --enable-nptl            enable usermode NPTL support"
903af5db58eSpbrookecho "  --enable-system          enable all system emulation targets"
904af5db58eSpbrookecho "  --disable-system         disable all system emulation targets"
9050953a80fSZachary Amsdenecho "  --enable-user            enable supported user emulation targets"
9060953a80fSZachary Amsdenecho "  --disable-user           disable all user emulation targets"
907831b7825Sthsecho "  --enable-linux-user      enable all linux usermode emulation targets"
908831b7825Sthsecho "  --disable-linux-user     disable all linux usermode emulation targets"
909831b7825Sthsecho "  --enable-darwin-user     enable all darwin usermode emulation targets"
910831b7825Sthsecho "  --disable-darwin-user    disable all darwin usermode emulation targets"
91184778508Sblueswir1echo "  --enable-bsd-user        enable all BSD usermode emulation targets"
91284778508Sblueswir1echo "  --disable-bsd-user       disable all BSD usermode emulation targets"
913379f6698SPaul Brookecho "  --enable-guest-base      enable GUEST_BASE support for usermode"
914379f6698SPaul Brookecho "                           emulation targets"
915379f6698SPaul Brookecho "  --disable-guest-base     disable GUEST_BASE support"
91634005a00SKirill A. Shutemovecho "  --enable-user-pie        build usermode emulation targets as PIE"
91734005a00SKirill A. Shutemovecho "  --disable-user-pie       do not build usermode emulation targets as PIE"
918af5db58eSpbrookecho "  --fmod-lib               path to FMOD library"
919af5db58eSpbrookecho "  --fmod-inc               path to FMOD includes"
9202f6a1ab0Sblueswir1echo "  --oss-lib                path to OSS library"
921c5937220Spbrookecho "  --enable-uname-release=R Return R for uname -r in usermode emulation"
9223142255cSblueswir1echo "  --sparc_cpu=V            Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9"
923ee682d27SStefan Weilecho "  --disable-uuid           disable uuid support"
924ee682d27SStefan Weilecho "  --enable-uuid            enable uuid support"
925e0e6c8c0Saliguoriecho "  --disable-vde            disable support for vde network"
926dfb278bdSJuan Quintelaecho "  --enable-vde             enable support for vde network"
9275c6c3a6cSChristoph Hellwigecho "  --disable-linux-aio      disable Linux AIO support"
9285c6c3a6cSChristoph Hellwigecho "  --enable-linux-aio       enable Linux AIO support"
929758e8e38SVenkateswararao Jujjuri (JV)echo "  --disable-attr           disables attr and xattr support"
930758e8e38SVenkateswararao Jujjuri (JV)echo "  --enable-attr            enable attr and xattr support"
931e5d355d1Saliguoriecho "  --enable-io-thread       enable IO thread"
93277755340Sthsecho "  --disable-blobs          disable installing provided firmware blobs"
933eac30262Saliguoriecho "  --kerneldir=PATH         look for kernel includes in PATH"
934d2807bc9SDirk Ullrichecho "  --enable-docs            enable documentation build"
935d2807bc9SDirk Ullrichecho "  --disable-docs           disable documentation build"
936d5970055SMichael S. Tsirkinecho "  --disable-vhost-net      disable vhost-net acceleration support"
937d5970055SMichael S. Tsirkinecho "  --enable-vhost-net       enable vhost-net acceleration support"
938320fba2aSFabien Chouteauecho "  --enable-trace-backend=B Set trace backend"
939320fba2aSFabien Chouteauecho "                           Available backends:" $("$source_path"/scripts/tracetool --list-backends)
94074242e0fSPaolo Bonziniecho "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
9419410b56cSPrerna Saxenaecho "                           Default:trace-<pid>"
942cd4ec0b4SGerd Hoffmannecho "  --disable-spice          disable spice"
943cd4ec0b4SGerd Hoffmannecho "  --enable-spice           enable spice"
944f27aaf4bSChristian Brunnerecho "  --enable-rbd             enable building the rados block device (rbd)"
94536707144SAlon Levyecho "  --disable-smartcard      disable smartcard support"
94636707144SAlon Levyecho "  --enable-smartcard       enable smartcard support"
947111a38b0SRobert Relyeaecho "  --disable-smartcard-nss  disable smartcard nss support"
948111a38b0SRobert Relyeaecho "  --enable-smartcard-nss   enable smartcard nss support"
949af5db58eSpbrookecho ""
9505bf08934Sthsecho "NOTE: The object files are built at the place where configure is launched"
951af5db58eSpbrookexit 1
952af5db58eSpbrookfi
953af5db58eSpbrook
9548d05095cSPaolo Bonzini# check that the C compiler works.
9558d05095cSPaolo Bonzinicat > $TMPC <<EOF
9568d05095cSPaolo Bonziniint main(void) {}
9578d05095cSPaolo BonziniEOF
9588d05095cSPaolo Bonzini
9598d05095cSPaolo Bonziniif compile_object ; then
9608d05095cSPaolo Bonzini  : C compiler works ok
9618d05095cSPaolo Bonzinielse
9628d05095cSPaolo Bonzini    echo "ERROR: \"$cc\" either does not exist or does not work"
9638d05095cSPaolo Bonzini    exit 1
9648d05095cSPaolo Bonzinifi
9658d05095cSPaolo Bonzini
9668d05095cSPaolo Bonzinigcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
9678d05095cSPaolo Bonzinigcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
9688d05095cSPaolo Bonzinigcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
9698d05095cSPaolo Bonzinigcc_flags="-fstack-protector-all $gcc_flags"
9708d05095cSPaolo Bonzinicat > $TMPC << EOF
9718d05095cSPaolo Bonziniint main(void) { return 0; }
9728d05095cSPaolo BonziniEOF
9738d05095cSPaolo Bonzinifor flag in $gcc_flags; do
9748d05095cSPaolo Bonzini    if compile_prog "-Werror $QEMU_CFLAGS" "-Werror $flag" ; then
9758d05095cSPaolo Bonzini	QEMU_CFLAGS="$QEMU_CFLAGS $flag"
9768d05095cSPaolo Bonzini    fi
9778d05095cSPaolo Bonzinidone
9788d05095cSPaolo Bonzini
979ec530c81Sbellard#
980ec530c81Sbellard# Solaris specific configure tool chain decisions
981ec530c81Sbellard#
982ec530c81Sbellardif test "$solaris" = "yes" ; then
9836792aa11SLoïc Minier  if has $install; then
9846792aa11SLoïc Minier    :
9856792aa11SLoïc Minier  else
986ec530c81Sbellard    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
987ec530c81Sbellard    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
988ec530c81Sbellard    echo "to get ginstall which is used by default (which lives in /opt/csw/bin)"
989ec530c81Sbellard    exit 1
990ec530c81Sbellard  fi
9916792aa11SLoïc Minier  if test "`path_of $install`" = "/usr/sbin/install" ; then
992ec530c81Sbellard    echo "Error: Solaris /usr/sbin/install is not an appropriate install program."
993ec530c81Sbellard    echo "try ginstall from the GNU fileutils available from www.blastwave.org"
994ec530c81Sbellard    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
995ec530c81Sbellard    exit 1
996ec530c81Sbellard  fi
9976792aa11SLoïc Minier  if has ar; then
9986792aa11SLoïc Minier    :
9996792aa11SLoïc Minier  else
1000ec530c81Sbellard    echo "Error: No path includes ar"
1001ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
1002ec530c81Sbellard      echo "Add /usr/ccs/bin to your path and rerun configure"
1003ec530c81Sbellard    fi
1004ec530c81Sbellard    exit 1
1005ec530c81Sbellard  fi
1006ec530c81Sbellardfi
1007ec530c81Sbellard
1008ec530c81Sbellard
10095327cf48Sbellardif test -z "$target_list" ; then
10105327cf48Sbellard# these targets are portable
10110a8e90f4Spbrook    if [ "$softmmu" = "yes" ] ; then
10122408a527Saurel32        target_list="\
10132408a527Saurel32i386-softmmu \
10142408a527Saurel32x86_64-softmmu \
10152408a527Saurel32arm-softmmu \
10162408a527Saurel32cris-softmmu \
1017613a22c9SMichael Wallelm32-softmmu \
10182408a527Saurel32m68k-softmmu \
101972b675caSEdgar E. Iglesiasmicroblaze-softmmu \
1020877fdc12SEdgar E. Iglesiasmicroblazeel-softmmu \
10212408a527Saurel32mips-softmmu \
10222408a527Saurel32mipsel-softmmu \
10232408a527Saurel32mips64-softmmu \
10242408a527Saurel32mips64el-softmmu \
10252408a527Saurel32ppc-softmmu \
10262408a527Saurel32ppcemb-softmmu \
10272408a527Saurel32ppc64-softmmu \
10282408a527Saurel32sh4-softmmu \
10292408a527Saurel32sh4eb-softmmu \
10302408a527Saurel32sparc-softmmu \
10311b64fcaeSIgor V. Kovalenkosparc64-softmmu \
10322408a527Saurel32"
10330a8e90f4Spbrook    fi
10345327cf48Sbellard# the following are Linux specific
1035831b7825Sths    if [ "$linux_user" = "yes" ] ; then
10362408a527Saurel32        target_list="${target_list}\
10372408a527Saurel32i386-linux-user \
10382408a527Saurel32x86_64-linux-user \
10392408a527Saurel32alpha-linux-user \
10402408a527Saurel32arm-linux-user \
10412408a527Saurel32armeb-linux-user \
10422408a527Saurel32cris-linux-user \
10432408a527Saurel32m68k-linux-user \
104472b675caSEdgar E. Iglesiasmicroblaze-linux-user \
1045877fdc12SEdgar E. Iglesiasmicroblazeel-linux-user \
10462408a527Saurel32mips-linux-user \
10472408a527Saurel32mipsel-linux-user \
10482408a527Saurel32ppc-linux-user \
10492408a527Saurel32ppc64-linux-user \
10502408a527Saurel32ppc64abi32-linux-user \
10512408a527Saurel32sh4-linux-user \
10522408a527Saurel32sh4eb-linux-user \
10532408a527Saurel32sparc-linux-user \
10542408a527Saurel32sparc64-linux-user \
10552408a527Saurel32sparc32plus-linux-user \
1056d2fbca94SGuan Xuetaounicore32-linux-user \
10572408a527Saurel32"
1058831b7825Sths    fi
1059831b7825Sths# the following are Darwin specific
1060831b7825Sths    if [ "$darwin_user" = "yes" ] ; then
10612408a527Saurel32        target_list="$target_list i386-darwin-user ppc-darwin-user "
10625327cf48Sbellard    fi
106384778508Sblueswir1# the following are BSD specific
106484778508Sblueswir1    if [ "$bsd_user" = "yes" ] ; then
106584778508Sblueswir1        target_list="${target_list}\
106631fc12dfSblueswir1i386-bsd-user \
106731fc12dfSblueswir1x86_64-bsd-user \
106831fc12dfSblueswir1sparc-bsd-user \
106984778508Sblueswir1sparc64-bsd-user \
107084778508Sblueswir1"
107184778508Sblueswir1    fi
10726e20a45fSbellardelse
1073b1a550a0Spbrook    target_list=`echo "$target_list" | sed -e 's/,/ /g'`
10745327cf48Sbellardfi
10750a8e90f4Spbrookif test -z "$target_list" ; then
10760a8e90f4Spbrook    echo "No targets enabled"
10770a8e90f4Spbrook    exit 1
10780a8e90f4Spbrookfi
1079f55fe278SPaolo Bonzini# see if system emulation was really requested
1080f55fe278SPaolo Bonzinicase " $target_list " in
1081f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1082f55fe278SPaolo Bonzini  ;;
1083f55fe278SPaolo Bonzini  *) softmmu=no
1084f55fe278SPaolo Bonzini  ;;
1085f55fe278SPaolo Bonziniesac
10865327cf48Sbellard
1087249247c9SJuan Quintelafeature_not_found() {
1088249247c9SJuan Quintela  feature=$1
1089249247c9SJuan Quintela
1090249247c9SJuan Quintela  echo "ERROR"
1091249247c9SJuan Quintela  echo "ERROR: User requested feature $feature"
10929332f6a2SSebastian Herbszt  echo "ERROR: configure was not able to find it"
1093249247c9SJuan Quintela  echo "ERROR"
1094249247c9SJuan Quintela  exit 1;
1095249247c9SJuan Quintela}
1096249247c9SJuan Quintela
10977d13299dSbellardif test -z "$cross_prefix" ; then
10987d13299dSbellard
10997d13299dSbellard# ---
11007d13299dSbellard# big/little endian test
11017d13299dSbellardcat > $TMPC << EOF
11027d13299dSbellard#include <inttypes.h>
11037d13299dSbellardint main(int argc, char ** argv){
11047d13299dSbellard        volatile uint32_t i=0x01234567;
11057d13299dSbellard        return (*((uint8_t*)(&i))) == 0x67;
11067d13299dSbellard}
11077d13299dSbellardEOF
11087d13299dSbellard
110952166aa0SJuan Quintelaif compile_prog "" "" ; then
11107d13299dSbellard$TMPE && bigendian="yes"
11117d13299dSbellardelse
11127d13299dSbellardecho big/little test failed
11137d13299dSbellardfi
11147d13299dSbellard
11157d13299dSbellardelse
11167d13299dSbellard
11177d13299dSbellard# if cross compiling, cannot launch a program, so make a static guess
1118ea8f20f8SJuan Quintelacase "$cpu" in
111924e804ecSAlexander Graf  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
1120ea8f20f8SJuan Quintela    bigendian=yes
1121ea8f20f8SJuan Quintela  ;;
1122ea8f20f8SJuan Quintelaesac
11237d13299dSbellard
11247d13299dSbellardfi
11257d13299dSbellard
112670be1a2eSPaolo Bonzini# host long bits test, actually a pointer size test
112770be1a2eSPaolo Bonzinicat > $TMPC << EOF
112870be1a2eSPaolo Bonziniint sizeof_pointer_is_8[sizeof(void *) == 8 ? 1 : -1];
112970be1a2eSPaolo BonziniEOF
113070be1a2eSPaolo Bonziniif compile_object; then
1131ea8f20f8SJuan Quintelahostlongbits=64
113270be1a2eSPaolo Bonzinielse
113370be1a2eSPaolo Bonzinihostlongbits=32
113470be1a2eSPaolo Bonzinifi
1135b6853697Sbellard
1136b0a47e79SJuan Quintela
1137b0a47e79SJuan Quintela##########################################
1138b0a47e79SJuan Quintela# NPTL probe
1139b0a47e79SJuan Quintela
1140b0a47e79SJuan Quintelaif test "$nptl" != "no" ; then
1141bd0c5661Spbrook  cat > $TMPC <<EOF
1142bd0c5661Spbrook#include <sched.h>
114330813ceaSpbrook#include <linux/futex.h>
1144bd0c5661Spbrookvoid foo()
1145bd0c5661Spbrook{
1146bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1147bd0c5661Spbrook#error bork
1148bd0c5661Spbrook#endif
1149bd0c5661Spbrook}
1150bd0c5661SpbrookEOF
1151bd0c5661Spbrook
115252166aa0SJuan Quintela  if compile_object ; then
1153b0a47e79SJuan Quintela    nptl=yes
1154bd0c5661Spbrook  else
1155b0a47e79SJuan Quintela    if test "$nptl" = "yes" ; then
1156b0a47e79SJuan Quintela      feature_not_found "nptl"
1157b0a47e79SJuan Quintela    fi
1158b0a47e79SJuan Quintela    nptl=no
1159b0a47e79SJuan Quintela  fi
1160bd0c5661Spbrookfi
1161bd0c5661Spbrook
116211d9f695Sbellard##########################################
1163ac62922eSbalrog# zlib check
1164ac62922eSbalrog
1165ac62922eSbalrogcat > $TMPC << EOF
1166ac62922eSbalrog#include <zlib.h>
1167ac62922eSbalrogint main(void) { zlibVersion(); return 0; }
1168ac62922eSbalrogEOF
116952166aa0SJuan Quintelaif compile_prog "" "-lz" ; then
1170ac62922eSbalrog    :
1171ac62922eSbalrogelse
1172ac62922eSbalrog    echo
1173ac62922eSbalrog    echo "Error: zlib check failed"
1174ac62922eSbalrog    echo "Make sure to have the zlib libs and headers installed."
1175ac62922eSbalrog    echo
1176ac62922eSbalrog    exit 1
1177ac62922eSbalrogfi
1178ac62922eSbalrog
1179ac62922eSbalrog##########################################
1180e37630caSaliguori# xen probe
1181e37630caSaliguori
1182fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
1183b2266beeSJuan Quintela  xen_libs="-lxenstore -lxenctrl -lxenguest"
1184d5b93ddfSAnthony PERARD
1185d5b93ddfSAnthony PERARD  # Xen unstable
1186e37630caSaliguori  cat > $TMPC <<EOF
1187e37630caSaliguori#include <xenctrl.h>
1188e37630caSaliguori#include <xs.h>
1189d5b93ddfSAnthony PERARD#include <stdint.h>
1190d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1191d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1192d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1193d5b93ddfSAnthony PERARD#endif
1194d5b93ddfSAnthony PERARDint main(void) {
1195d5b93ddfSAnthony PERARD  xc_interface *xc;
1196d5b93ddfSAnthony PERARD  xs_daemon_open();
1197d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
1198d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1199d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
1200d5b93ddfSAnthony PERARD  return 0;
1201d5b93ddfSAnthony PERARD}
1202e37630caSaliguoriEOF
120352166aa0SJuan Quintela  if compile_prog "" "$xen_libs" ; then
1204d5b93ddfSAnthony PERARD    xen_ctrl_version=410
1205fc321b4bSJuan Quintela    xen=yes
1206d5b93ddfSAnthony PERARD
1207d5b93ddfSAnthony PERARD  # Xen 4.0.0
1208d5b93ddfSAnthony PERARD  elif (
1209d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1210d5b93ddfSAnthony PERARD#include <xenctrl.h>
1211d5b93ddfSAnthony PERARD#include <xs.h>
1212d5b93ddfSAnthony PERARD#include <stdint.h>
1213d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
1214d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
1215d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
1216d5b93ddfSAnthony PERARD#endif
1217d5b93ddfSAnthony PERARDint main(void) {
1218d5b93ddfSAnthony PERARD  xs_daemon_open();
1219d5b93ddfSAnthony PERARD  xc_interface_open();
1220d5b93ddfSAnthony PERARD  xc_gnttab_open();
1221d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1222d5b93ddfSAnthony PERARD  return 0;
1223d5b93ddfSAnthony PERARD}
1224d5b93ddfSAnthony PERARDEOF
1225d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1226d5b93ddfSAnthony PERARD    ) ; then
1227d5b93ddfSAnthony PERARD    xen_ctrl_version=400
1228d5b93ddfSAnthony PERARD    xen=yes
1229d5b93ddfSAnthony PERARD
1230d5b93ddfSAnthony PERARD  # Xen 3.3.0, 3.4.0
1231d5b93ddfSAnthony PERARD  elif (
1232d5b93ddfSAnthony PERARD      cat > $TMPC <<EOF
1233d5b93ddfSAnthony PERARD#include <xenctrl.h>
1234d5b93ddfSAnthony PERARD#include <xs.h>
1235d5b93ddfSAnthony PERARDint main(void) {
1236d5b93ddfSAnthony PERARD  xs_daemon_open();
1237d5b93ddfSAnthony PERARD  xc_interface_open();
1238d5b93ddfSAnthony PERARD  xc_gnttab_open();
1239d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1240d5b93ddfSAnthony PERARD  return 0;
1241d5b93ddfSAnthony PERARD}
1242d5b93ddfSAnthony PERARDEOF
1243d5b93ddfSAnthony PERARD      compile_prog "" "$xen_libs"
1244d5b93ddfSAnthony PERARD    ) ; then
1245d5b93ddfSAnthony PERARD    xen_ctrl_version=330
1246d5b93ddfSAnthony PERARD    xen=yes
1247d5b93ddfSAnthony PERARD
1248d5b93ddfSAnthony PERARD  # Xen not found or unsupported
1249e37630caSaliguori  else
1250fc321b4bSJuan Quintela    if test "$xen" = "yes" ; then
1251fc321b4bSJuan Quintela      feature_not_found "xen"
1252fc321b4bSJuan Quintela    fi
1253fc321b4bSJuan Quintela    xen=no
1254e37630caSaliguori  fi
1255d5b93ddfSAnthony PERARD
1256d5b93ddfSAnthony PERARD  if test "$xen" = yes; then
1257d5b93ddfSAnthony PERARD    libs_softmmu="$xen_libs $libs_softmmu"
1258d5b93ddfSAnthony PERARD  fi
1259e37630caSaliguorifi
1260e37630caSaliguori
1261e37630caSaliguori##########################################
1262a8bd70adSPaolo Bonzini# pkg-config probe
1263f91672e5SPaolo Bonzini
1264a8bd70adSPaolo Bonziniif ! has $pkg_config; then
126508421541SPaolo Bonzini  echo warning: proceeding without "$pkg_config" >&2
126608421541SPaolo Bonzini  pkg_config=/bin/false
1267f91672e5SPaolo Bonzinifi
1268f91672e5SPaolo Bonzini
1269f91672e5SPaolo Bonzini##########################################
1270dfffc653SJuan Quintela# Sparse probe
1271dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
12720dba6195SLoïc Minier  if has cgcc; then
1273dfffc653SJuan Quintela    sparse=yes
1274dfffc653SJuan Quintela  else
1275dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
1276dfffc653SJuan Quintela      feature_not_found "sparse"
1277dfffc653SJuan Quintela    fi
1278dfffc653SJuan Quintela    sparse=no
1279dfffc653SJuan Quintela  fi
1280dfffc653SJuan Quintelafi
1281dfffc653SJuan Quintela
1282dfffc653SJuan Quintela##########################################
128311d9f695Sbellard# SDL probe
128411d9f695Sbellard
12853ec87ffeSPaolo Bonzini# Look for sdl configuration program (pkg-config or sdl-config).  Try
12863ec87ffeSPaolo Bonzini# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
12873ec87ffeSPaolo Bonziniif test "`basename $sdl_config`" != sdl-config && ! has ${sdl_config}; then
12883ec87ffeSPaolo Bonzini  sdl_config=sdl-config
12893ec87ffeSPaolo Bonzinifi
12903ec87ffeSPaolo Bonzini
12913ec87ffeSPaolo Bonziniif $pkg_config sdl --modversion >/dev/null 2>&1; then
1292a8bd70adSPaolo Bonzini  sdlconfig="$pkg_config sdl"
1293fec0e3e8SStefan Weil  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
12943ec87ffeSPaolo Bonzinielif has ${sdl_config}; then
12953ec87ffeSPaolo Bonzini  sdlconfig="$sdl_config"
12969316f803SPaolo Bonzini  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1297a0dfd8a4SLoïc Minierelse
1298a0dfd8a4SLoïc Minier  if test "$sdl" = "yes" ; then
1299a0dfd8a4SLoïc Minier    feature_not_found "sdl"
1300a0dfd8a4SLoïc Minier  fi
1301a0dfd8a4SLoïc Minier  sdl=no
13029316f803SPaolo Bonzinifi
130329e5badaSScott Woodif test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
13043ec87ffeSPaolo Bonzini  echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
13053ec87ffeSPaolo Bonzinifi
130611d9f695Sbellard
13079316f803SPaolo Bonzinisdl_too_old=no
1308c4198157SJuan Quintelaif test "$sdl" != "no" ; then
130911d9f695Sbellard  cat > $TMPC << EOF
131011d9f695Sbellard#include <SDL.h>
131111d9f695Sbellard#undef main /* We don't want SDL to override our main() */
131211d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
131311d9f695SbellardEOF
13149316f803SPaolo Bonzini  sdl_cflags=`$sdlconfig --cflags 2> /dev/null`
131574f42e18STeLeMan  if test "$static" = "yes" ; then
131674f42e18STeLeMan    sdl_libs=`$sdlconfig --static-libs 2>/dev/null`
131774f42e18STeLeMan  else
13189316f803SPaolo Bonzini    sdl_libs=`$sdlconfig --libs 2> /dev/null`
131974f42e18STeLeMan  fi
132052166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
132111d9f695Sbellard    if test "$_sdlversion" -lt 121 ; then
132211d9f695Sbellard      sdl_too_old=yes
132311d9f695Sbellard    else
1324fd677642Sths      if test "$cocoa" = "no" ; then
132511d9f695Sbellard        sdl=yes
132611d9f695Sbellard      fi
1327fd677642Sths    fi
13287c1f25b4Sbellard
132967c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
13301ac88f28SJuan Quintela    if test "$sdl" = "yes" -a "$static" = "yes" ; then
133167c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
1332f8aa6c7bSStefan Weil         sdl_libs="$sdl_libs `aalib-config --static-libs 2>/dev/null`"
1333f8aa6c7bSStefan Weil         sdl_cflags="$sdl_cflags `aalib-config --cflags 2>/dev/null`"
133411d9f695Sbellard      fi
133552166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
13361ac88f28SJuan Quintela	:
13371ac88f28SJuan Quintela      else
13381ac88f28SJuan Quintela        sdl=no
13397c1f25b4Sbellard      fi
13407c1f25b4Sbellard    fi # static link
1341c4198157SJuan Quintela  else # sdl not found
1342c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
1343c4198157SJuan Quintela      feature_not_found "sdl"
1344c4198157SJuan Quintela    fi
1345c4198157SJuan Quintela    sdl=no
13467c1f25b4Sbellard  fi # sdl compile test
1347fd677642Sthsfi
134811d9f695Sbellard
13495368a422Saliguoriif test "$sdl" = "yes" ; then
13505368a422Saliguori  cat > $TMPC <<EOF
13515368a422Saliguori#include <SDL.h>
13525368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
13535368a422Saliguori#include <X11/XKBlib.h>
13545368a422Saliguori#else
13555368a422Saliguori#error No x11 support
13565368a422Saliguori#endif
13575368a422Saliguoriint main(void) { return 0; }
13585368a422SaliguoriEOF
135952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
1360681306dfSJuan Quintela    sdl_libs="$sdl_libs -lX11"
13615368a422Saliguori  fi
136207d9ac44SJuan Quintela  if test "$mingw32" = "yes" ; then
136307d9ac44SJuan Quintela    sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole"
136407d9ac44SJuan Quintela  fi
13650705667eSJuan Quintela  libs_softmmu="$sdl_libs $libs_softmmu"
13665368a422Saliguorifi
13675368a422Saliguori
13688f28f3fbSths##########################################
13698d5d2d4cSths# VNC TLS detection
1370821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then
1371ae6b5e5aSaliguori  cat > $TMPC <<EOF
1372ae6b5e5aSaliguori#include <gnutls/gnutls.h>
1373ae6b5e5aSaliguoriint main(void) { gnutls_session_t s; gnutls_init(&s, GNUTLS_SERVER); return 0; }
1374ae6b5e5aSaliguoriEOF
1375a8bd70adSPaolo Bonzini  vnc_tls_cflags=`$pkg_config --cflags gnutls 2> /dev/null`
1376a8bd70adSPaolo Bonzini  vnc_tls_libs=`$pkg_config --libs gnutls 2> /dev/null`
137752166aa0SJuan Quintela  if compile_prog "$vnc_tls_cflags" "$vnc_tls_libs" ; then
13781be10ad2SJuan Quintela    vnc_tls=yes
1379a5e32cc9SJuan Quintela    libs_softmmu="$vnc_tls_libs $libs_softmmu"
1380ae6b5e5aSaliguori  else
13811be10ad2SJuan Quintela    if test "$vnc_tls" = "yes" ; then
13821be10ad2SJuan Quintela      feature_not_found "vnc-tls"
13831be10ad2SJuan Quintela    fi
13841be10ad2SJuan Quintela    vnc_tls=no
13858d5d2d4cSths  fi
13868d5d2d4cSthsfi
13878d5d2d4cSths
13888d5d2d4cSths##########################################
13892f9606b3Saliguori# VNC SASL detection
1390821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
13912f9606b3Saliguori  cat > $TMPC <<EOF
13922f9606b3Saliguori#include <sasl/sasl.h>
13932f9606b3Saliguori#include <stdio.h>
13942f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
13952f9606b3SaliguoriEOF
13962f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
13972f9606b3Saliguori  vnc_sasl_cflags=""
13982f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
139952166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
1400ea784e3bSJuan Quintela    vnc_sasl=yes
1401fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
14022f9606b3Saliguori  else
1403ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
1404ea784e3bSJuan Quintela      feature_not_found "vnc-sasl"
1405ea784e3bSJuan Quintela    fi
1406ea784e3bSJuan Quintela    vnc_sasl=no
14072f9606b3Saliguori  fi
14082f9606b3Saliguorifi
14092f9606b3Saliguori
14102f9606b3Saliguori##########################################
14112f6f5c7aSCorentin Chary# VNC JPEG detection
1412821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
14132f6f5c7aSCorentin Charycat > $TMPC <<EOF
14142f6f5c7aSCorentin Chary#include <stdio.h>
14152f6f5c7aSCorentin Chary#include <jpeglib.h>
14162f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
14172f6f5c7aSCorentin CharyEOF
14182f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
14192f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
14202f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
14212f6f5c7aSCorentin Chary    vnc_jpeg=yes
14222f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
14232f6f5c7aSCorentin Chary  else
14242f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
14252f6f5c7aSCorentin Chary      feature_not_found "vnc-jpeg"
14262f6f5c7aSCorentin Chary    fi
14272f6f5c7aSCorentin Chary    vnc_jpeg=no
14282f6f5c7aSCorentin Chary  fi
14292f6f5c7aSCorentin Charyfi
14302f6f5c7aSCorentin Chary
14312f6f5c7aSCorentin Chary##########################################
1432efe556adSCorentin Chary# VNC PNG detection
1433821601eaSJes Sorensenif test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
1434efe556adSCorentin Charycat > $TMPC <<EOF
1435efe556adSCorentin Chary//#include <stdio.h>
1436efe556adSCorentin Chary#include <png.h>
1437832ce9c2SScott Wood#include <stddef.h>
1438efe556adSCorentin Charyint main(void) {
1439efe556adSCorentin Chary    png_structp png_ptr;
1440efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1441efe556adSCorentin Chary    return 0;
1442efe556adSCorentin Chary}
1443efe556adSCorentin CharyEOF
1444efe556adSCorentin Chary    vnc_png_cflags=""
1445efe556adSCorentin Chary    vnc_png_libs="-lpng"
1446efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
1447efe556adSCorentin Chary    vnc_png=yes
1448efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
1449efe556adSCorentin Chary  else
1450efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
1451efe556adSCorentin Chary      feature_not_found "vnc-png"
1452efe556adSCorentin Chary    fi
1453efe556adSCorentin Chary    vnc_png=no
1454efe556adSCorentin Chary  fi
1455efe556adSCorentin Charyfi
1456efe556adSCorentin Chary
1457efe556adSCorentin Chary##########################################
145876655d6dSaliguori# fnmatch() probe, used for ACL routines
145976655d6dSaliguorifnmatch="no"
146076655d6dSaliguoricat > $TMPC << EOF
146176655d6dSaliguori#include <fnmatch.h>
146276655d6dSaliguoriint main(void)
146376655d6dSaliguori{
146476655d6dSaliguori    fnmatch("foo", "foo", 0);
146576655d6dSaliguori    return 0;
146676655d6dSaliguori}
146776655d6dSaliguoriEOF
146852166aa0SJuan Quintelaif compile_prog "" "" ; then
146976655d6dSaliguori   fnmatch="yes"
147076655d6dSaliguorifi
147176655d6dSaliguori
147276655d6dSaliguori##########################################
1473ee682d27SStefan Weil# uuid_generate() probe, used for vdi block driver
1474ee682d27SStefan Weilif test "$uuid" != "no" ; then
1475ee682d27SStefan Weil  uuid_libs="-luuid"
1476ee682d27SStefan Weil  cat > $TMPC << EOF
1477ee682d27SStefan Weil#include <uuid/uuid.h>
1478ee682d27SStefan Weilint main(void)
1479ee682d27SStefan Weil{
1480ee682d27SStefan Weil    uuid_t my_uuid;
1481ee682d27SStefan Weil    uuid_generate(my_uuid);
1482ee682d27SStefan Weil    return 0;
1483ee682d27SStefan Weil}
1484ee682d27SStefan WeilEOF
1485ee682d27SStefan Weil  if compile_prog "" "$uuid_libs" ; then
1486ee682d27SStefan Weil    uuid="yes"
1487ee682d27SStefan Weil    libs_softmmu="$uuid_libs $libs_softmmu"
1488ee682d27SStefan Weil    libs_tools="$uuid_libs $libs_tools"
1489ee682d27SStefan Weil  else
1490ee682d27SStefan Weil    if test "$uuid" = "yes" ; then
1491ee682d27SStefan Weil      feature_not_found "uuid"
1492ee682d27SStefan Weil    fi
1493ee682d27SStefan Weil    uuid=no
1494ee682d27SStefan Weil  fi
1495ee682d27SStefan Weilfi
1496ee682d27SStefan Weil
1497ee682d27SStefan Weil##########################################
1498dce512deSChristoph Hellwig# xfsctl() probe, used for raw-posix
1499dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
1500dce512deSChristoph Hellwig  cat > $TMPC << EOF
1501dce512deSChristoph Hellwig#include <xfs/xfs.h>
1502dce512deSChristoph Hellwigint main(void)
1503dce512deSChristoph Hellwig{
1504dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
1505dce512deSChristoph Hellwig    return 0;
1506dce512deSChristoph Hellwig}
1507dce512deSChristoph HellwigEOF
1508dce512deSChristoph Hellwig  if compile_prog "" "" ; then
1509dce512deSChristoph Hellwig    xfs="yes"
1510dce512deSChristoph Hellwig  else
1511dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
1512dce512deSChristoph Hellwig      feature_not_found "xfs"
1513dce512deSChristoph Hellwig    fi
1514dce512deSChristoph Hellwig    xfs=no
1515dce512deSChristoph Hellwig  fi
1516dce512deSChristoph Hellwigfi
1517dce512deSChristoph Hellwig
1518dce512deSChristoph Hellwig##########################################
15198a16d273Sths# vde libraries probe
1520dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
15214baae0acSJuan Quintela  vde_libs="-lvdeplug"
15228a16d273Sths  cat > $TMPC << EOF
15238a16d273Sths#include <libvdeplug.h>
15244a7f0e06Spbrookint main(void)
15254a7f0e06Spbrook{
15264a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
15274a7f0e06Spbrook    vde_open("", "", &a);
15284a7f0e06Spbrook    return 0;
15294a7f0e06Spbrook}
15308a16d273SthsEOF
153152166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
15324baae0acSJuan Quintela    vde=yes
15338e02e54cSJuan Quintela    libs_softmmu="$vde_libs $libs_softmmu"
15348e02e54cSJuan Quintela    libs_tools="$vde_libs $libs_tools"
1535dfb278bdSJuan Quintela  else
1536dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
1537dfb278bdSJuan Quintela      feature_not_found "vde"
1538dfb278bdSJuan Quintela    fi
1539dfb278bdSJuan Quintela    vde=no
15408a16d273Sths  fi
15418a16d273Sthsfi
15428a16d273Sths
15438a16d273Sths##########################################
1544c2de5c91Smalc# Sound support libraries probe
15458f28f3fbSths
1546c2de5c91Smalcaudio_drv_probe()
1547c2de5c91Smalc{
1548c2de5c91Smalc    drv=$1
1549c2de5c91Smalc    hdr=$2
1550c2de5c91Smalc    lib=$3
1551c2de5c91Smalc    exp=$4
1552c2de5c91Smalc    cfl=$5
15538f28f3fbSths        cat > $TMPC << EOF
1554c2de5c91Smalc#include <$hdr>
1555c2de5c91Smalcint main(void) { $exp }
15568f28f3fbSthsEOF
155752166aa0SJuan Quintela    if compile_prog "$cfl" "$lib" ; then
15588f28f3fbSths        :
15598f28f3fbSths    else
15608f28f3fbSths        echo
1561c2de5c91Smalc        echo "Error: $drv check failed"
1562c2de5c91Smalc        echo "Make sure to have the $drv libs and headers installed."
15638f28f3fbSths        echo
15648f28f3fbSths        exit 1
15658f28f3fbSths    fi
1566c2de5c91Smalc}
1567c2de5c91Smalc
15682fa7d3bfSmalcaudio_drv_list=`echo "$audio_drv_list" | sed -e 's/,/ /g'`
1569c2de5c91Smalcfor drv in $audio_drv_list; do
1570c2de5c91Smalc    case $drv in
1571c2de5c91Smalc    alsa)
1572c2de5c91Smalc    audio_drv_probe $drv alsa/asoundlib.h -lasound \
1573c2de5c91Smalc        "snd_pcm_t **handle; return snd_pcm_close(*handle);"
1574a4bf6780SJuan Quintela    libs_softmmu="-lasound $libs_softmmu"
1575c2de5c91Smalc    ;;
1576c2de5c91Smalc
1577c2de5c91Smalc    fmod)
1578c2de5c91Smalc    if test -z $fmod_lib || test -z $fmod_inc; then
1579c2de5c91Smalc        echo
1580c2de5c91Smalc        echo "Error: You must specify path to FMOD library and headers"
1581c2de5c91Smalc        echo "Example: --fmod-inc=/path/include/fmod --fmod-lib=/path/lib/libfmod-3.74.so"
1582c2de5c91Smalc        echo
1583c2de5c91Smalc        exit 1
15848f28f3fbSths    fi
1585c2de5c91Smalc    audio_drv_probe $drv fmod.h $fmod_lib "return FSOUND_GetVersion();" "-I $fmod_inc"
1586a4bf6780SJuan Quintela    libs_softmmu="$fmod_lib $libs_softmmu"
1587c2de5c91Smalc    ;;
1588c2de5c91Smalc
1589c2de5c91Smalc    esd)
1590c2de5c91Smalc    audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0);'
1591a4bf6780SJuan Quintela    libs_softmmu="-lesd $libs_softmmu"
159267f86e8eSJuan Quintela    audio_pt_int="yes"
1593c2de5c91Smalc    ;;
1594b8e59f18Smalc
1595b8e59f18Smalc    pa)
1596493abda6SAurelien Jarno    audio_drv_probe $drv pulse/simple.h "-lpulse-simple -lpulse" \
1597b8e59f18Smalc        "pa_simple *s = NULL; pa_simple_free(s); return 0;"
1598493abda6SAurelien Jarno    libs_softmmu="-lpulse -lpulse-simple $libs_softmmu"
159967f86e8eSJuan Quintela    audio_pt_int="yes"
1600b8e59f18Smalc    ;;
1601b8e59f18Smalc
1602997e690aSJuan Quintela    coreaudio)
1603997e690aSJuan Quintela      libs_softmmu="-framework CoreAudio $libs_softmmu"
1604997e690aSJuan Quintela    ;;
1605997e690aSJuan Quintela
1606a4bf6780SJuan Quintela    dsound)
1607a4bf6780SJuan Quintela      libs_softmmu="-lole32 -ldxguid $libs_softmmu"
1608d5631638Smalc      audio_win_int="yes"
1609a4bf6780SJuan Quintela    ;;
1610a4bf6780SJuan Quintela
1611a4bf6780SJuan Quintela    oss)
1612a4bf6780SJuan Quintela      libs_softmmu="$oss_lib $libs_softmmu"
1613a4bf6780SJuan Quintela    ;;
1614a4bf6780SJuan Quintela
1615a4bf6780SJuan Quintela    sdl|wav)
16162f6a1ab0Sblueswir1    # XXX: Probes for CoreAudio, DirectSound, SDL(?)
16172f6a1ab0Sblueswir1    ;;
16182f6a1ab0Sblueswir1
1619d5631638Smalc    winwave)
1620d5631638Smalc      libs_softmmu="-lwinmm $libs_softmmu"
1621d5631638Smalc      audio_win_int="yes"
1622d5631638Smalc    ;;
1623d5631638Smalc
1624e4c63a6aSmalc    *)
16251c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
1626e4c63a6aSmalc        echo
1627e4c63a6aSmalc        echo "Error: Unknown driver '$drv' selected"
1628e4c63a6aSmalc        echo "Possible drivers are: $audio_possible_drivers"
1629e4c63a6aSmalc        echo
1630e4c63a6aSmalc        exit 1
1631e4c63a6aSmalc    }
1632e4c63a6aSmalc    ;;
1633c2de5c91Smalc    esac
1634c2de5c91Smalcdone
16358f28f3fbSths
16364d3b6f6eSbalrog##########################################
16372e4d9fb1Saurel32# BrlAPI probe
16382e4d9fb1Saurel32
16394ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
1640eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
16412e4d9fb1Saurel32  cat > $TMPC << EOF
16422e4d9fb1Saurel32#include <brlapi.h>
1643832ce9c2SScott Wood#include <stddef.h>
16442e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
16452e4d9fb1Saurel32EOF
164652166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
16472e4d9fb1Saurel32    brlapi=yes
1648264606b3SJuan Quintela    libs_softmmu="$brlapi_libs $libs_softmmu"
16494ffcedb6SJuan Quintela  else
16504ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
16514ffcedb6SJuan Quintela      feature_not_found "brlapi"
16524ffcedb6SJuan Quintela    fi
16534ffcedb6SJuan Quintela    brlapi=no
1654eb82284fSJuan Quintela  fi
1655eb82284fSJuan Quintelafi
16562e4d9fb1Saurel32
16572e4d9fb1Saurel32##########################################
16584d3b6f6eSbalrog# curses probe
1659e095e2f3SStefan Weilif test "$mingw32" = "yes" ; then
1660e095e2f3SStefan Weil    curses_list="-lpdcurses"
1661e095e2f3SStefan Weilelse
16624f78ef9aSJuan Quintela    curses_list="-lncurses -lcurses"
1663e095e2f3SStefan Weilfi
16644d3b6f6eSbalrog
1665c584a6d0SJuan Quintelaif test "$curses" != "no" ; then
1666c584a6d0SJuan Quintela  curses_found=no
16674d3b6f6eSbalrog  cat > $TMPC << EOF
16684d3b6f6eSbalrog#include <curses.h>
16695a8ff3aaSblueswir1#ifdef __OpenBSD__
16705a8ff3aaSblueswir1#define resize_term resizeterm
16715a8ff3aaSblueswir1#endif
16725a8ff3aaSblueswir1int main(void) { resize_term(0, 0); return curses_version(); }
16734d3b6f6eSbalrogEOF
16744f78ef9aSJuan Quintela  for curses_lib in $curses_list; do
16754f78ef9aSJuan Quintela    if compile_prog "" "$curses_lib" ; then
1676c584a6d0SJuan Quintela      curses_found=yes
16774f78ef9aSJuan Quintela      libs_softmmu="$curses_lib $libs_softmmu"
16784f78ef9aSJuan Quintela      break
16794d3b6f6eSbalrog    fi
16804f78ef9aSJuan Quintela  done
1681c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
1682c584a6d0SJuan Quintela    curses=yes
1683c584a6d0SJuan Quintela  else
1684c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
1685c584a6d0SJuan Quintela      feature_not_found "curses"
1686c584a6d0SJuan Quintela    fi
1687c584a6d0SJuan Quintela    curses=no
1688c584a6d0SJuan Quintela  fi
16894f78ef9aSJuan Quintelafi
16904d3b6f6eSbalrog
1691414f0dabSblueswir1##########################################
1692769ce76dSAlexander Graf# curl probe
1693769ce76dSAlexander Graf
1694a8bd70adSPaolo Bonziniif $pkg_config libcurl --modversion >/dev/null 2>&1; then
1695a8bd70adSPaolo Bonzini  curlconfig="$pkg_config libcurl"
16964e2b0658SPaolo Bonzinielse
16974e2b0658SPaolo Bonzini  curlconfig=curl-config
16984e2b0658SPaolo Bonzinifi
16994e2b0658SPaolo Bonzini
1700788c8196SJuan Quintelaif test "$curl" != "no" ; then
1701769ce76dSAlexander Graf  cat > $TMPC << EOF
1702769ce76dSAlexander Graf#include <curl/curl.h>
1703769ce76dSAlexander Grafint main(void) { return curl_easy_init(); }
1704769ce76dSAlexander GrafEOF
17054e2b0658SPaolo Bonzini  curl_cflags=`$curlconfig --cflags 2>/dev/null`
17064e2b0658SPaolo Bonzini  curl_libs=`$curlconfig --libs 2>/dev/null`
1707b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
1708769ce76dSAlexander Graf    curl=yes
1709f0302935SJuan Quintela    libs_tools="$curl_libs $libs_tools"
1710f0302935SJuan Quintela    libs_softmmu="$curl_libs $libs_softmmu"
1711788c8196SJuan Quintela  else
1712788c8196SJuan Quintela    if test "$curl" = "yes" ; then
1713788c8196SJuan Quintela      feature_not_found "curl"
1714788c8196SJuan Quintela    fi
1715788c8196SJuan Quintela    curl=no
1716769ce76dSAlexander Graf  fi
1717769ce76dSAlexander Graffi # test "$curl"
1718769ce76dSAlexander Graf
1719769ce76dSAlexander Graf##########################################
17205495ed11SLuiz Capitulino# check framework probe
17215495ed11SLuiz Capitulino
17225495ed11SLuiz Capitulinoif test "$check_utests" != "no" ; then
17235495ed11SLuiz Capitulino  cat > $TMPC << EOF
17245495ed11SLuiz Capitulino#include <check.h>
17255495ed11SLuiz Capitulinoint main(void) { suite_create("qemu test"); return 0; }
17265495ed11SLuiz CapitulinoEOF
1727a8bd70adSPaolo Bonzini  check_libs=`$pkg_config --libs check`
17285495ed11SLuiz Capitulino  if compile_prog "" $check_libs ; then
17295495ed11SLuiz Capitulino    check_utests=yes
17305495ed11SLuiz Capitulino    libs_tools="$check_libs $libs_tools"
17315495ed11SLuiz Capitulino  else
17325495ed11SLuiz Capitulino    if test "$check_utests" = "yes" ; then
17335495ed11SLuiz Capitulino      feature_not_found "check"
17345495ed11SLuiz Capitulino    fi
17355495ed11SLuiz Capitulino    check_utests=no
17365495ed11SLuiz Capitulino  fi
17375495ed11SLuiz Capitulinofi # test "$check_utests"
17385495ed11SLuiz Capitulino
17395495ed11SLuiz Capitulino##########################################
1740fb599c9aSbalrog# bluez support probe
1741a20a6f46SJuan Quintelaif test "$bluez" != "no" ; then
1742e820e3f4Sbalrog  cat > $TMPC << EOF
1743e820e3f4Sbalrog#include <bluetooth/bluetooth.h>
1744e820e3f4Sbalrogint main(void) { return bt_error(0); }
1745e820e3f4SbalrogEOF
1746a8bd70adSPaolo Bonzini  bluez_cflags=`$pkg_config --cflags bluez 2> /dev/null`
1747a8bd70adSPaolo Bonzini  bluez_libs=`$pkg_config --libs bluez 2> /dev/null`
174852166aa0SJuan Quintela  if compile_prog "$bluez_cflags" "$bluez_libs" ; then
1749a20a6f46SJuan Quintela    bluez=yes
1750e482d56aSJuan Quintela    libs_softmmu="$bluez_libs $libs_softmmu"
1751e820e3f4Sbalrog  else
1752a20a6f46SJuan Quintela    if test "$bluez" = "yes" ; then
1753a20a6f46SJuan Quintela      feature_not_found "bluez"
1754a20a6f46SJuan Quintela    fi
1755e820e3f4Sbalrog    bluez="no"
1756e820e3f4Sbalrog  fi
1757fb599c9aSbalrogfi
1758fb599c9aSbalrog
1759fb599c9aSbalrog##########################################
17607ba1e619Saliguori# kvm probe
1761b31a0277SJuan Quintelaif test "$kvm" != "no" ; then
17627ba1e619Saliguori    cat > $TMPC <<EOF
17637ba1e619Saliguori#include <linux/kvm.h>
17649fd8d8d7Saliguori#if !defined(KVM_API_VERSION) || KVM_API_VERSION < 12 || KVM_API_VERSION > 12
17657ba1e619Saliguori#error Invalid KVM version
17667ba1e619Saliguori#endif
176794a8d39aSJan KiszkaEOF
176894a8d39aSJan Kiszka    must_have_caps="KVM_CAP_USER_MEMORY \
176994a8d39aSJan Kiszka                    KVM_CAP_DESTROY_MEMORY_REGION_WORKS \
177094a8d39aSJan Kiszka                    KVM_CAP_COALESCED_MMIO \
177194a8d39aSJan Kiszka                    KVM_CAP_SYNC_MMU \
177294a8d39aSJan Kiszka                   "
177394a8d39aSJan Kiszka    if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) ; then
177494a8d39aSJan Kiszka      must_have_caps="$caps \
177594a8d39aSJan Kiszka                      KVM_CAP_SET_TSS_ADDR \
177694a8d39aSJan Kiszka                      KVM_CAP_EXT_CPUID \
177794a8d39aSJan Kiszka                      KVM_CAP_CLOCKSOURCE \
177894a8d39aSJan Kiszka                      KVM_CAP_NOP_IO_DELAY \
177994a8d39aSJan Kiszka                      KVM_CAP_PV_MMU \
178094a8d39aSJan Kiszka                      KVM_CAP_MP_STATE \
178194a8d39aSJan Kiszka                      KVM_CAP_USER_NMI \
178294a8d39aSJan Kiszka                     "
178394a8d39aSJan Kiszka    fi
178494a8d39aSJan Kiszka    for c in $must_have_caps ; do
178594a8d39aSJan Kiszka      cat >> $TMPC <<EOF
178694a8d39aSJan Kiszka#if !defined($c)
178794a8d39aSJan Kiszka#error Missing KVM capability $c
17889fd8d8d7Saliguori#endif
178994a8d39aSJan KiszkaEOF
179094a8d39aSJan Kiszka    done
179194a8d39aSJan Kiszka    cat >> $TMPC <<EOF
17927ba1e619Saliguoriint main(void) { return 0; }
17937ba1e619SaliguoriEOF
1794eac30262Saliguori  if test "$kerneldir" != "" ; then
1795eac30262Saliguori      kvm_cflags=-I"$kerneldir"/include
17968444eb6eSaliguori      if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) \
17978444eb6eSaliguori         -a -d "$kerneldir/arch/x86/include" ; then
17988444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
1799406b430dSaliguori	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
1800406b430dSaliguori	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
18010e60a699SAlexander Graf	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
18020e60a699SAlexander Graf	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
18038444eb6eSaliguori        elif test -d "$kerneldir/arch/$cpu/include" ; then
18048444eb6eSaliguori            kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
18058444eb6eSaliguori      fi
1806eac30262Saliguori  else
1807a8bd70adSPaolo Bonzini    kvm_cflags=`$pkg_config --cflags kvm-kmod 2>/dev/null`
1808eac30262Saliguori  fi
180952166aa0SJuan Quintela  if compile_prog "$kvm_cflags" "" ; then
1810b31a0277SJuan Quintela    kvm=yes
1811dae5079aSJan Kiszka    cat > $TMPC <<EOF
1812dae5079aSJan Kiszka#include <linux/kvm_para.h>
1813dae5079aSJan Kiszkaint main(void) { return 0; }
1814dae5079aSJan KiszkaEOF
1815dae5079aSJan Kiszka    if compile_prog "$kvm_cflags" "" ; then
1816dae5079aSJan Kiszka      kvm_para=yes
1817dae5079aSJan Kiszka    fi
18187ba1e619Saliguori  else
1819b31a0277SJuan Quintela    if test "$kvm" = "yes" ; then
18200dba6195SLoïc Minier      if has awk && has grep; then
1821a558ee17SJuan Quintela        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
18229fd8d8d7Saliguori	| grep "error: " \
18239fd8d8d7Saliguori	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
18249fd8d8d7Saliguori        if test "$kvmerr" != "" ; then
1825b31a0277SJuan Quintela          echo -e "${kvmerr}\n\
1826168ccc11SJan KiszkaNOTE: To enable KVM support, update your kernel to 2.6.29+ or install \
1827168ccc11SJan Kiszkarecent kvm-kmod from http://sourceforge.net/projects/kvm."
18289fd8d8d7Saliguori        fi
18299fd8d8d7Saliguori      fi
1830b31a0277SJuan Quintela      feature_not_found "kvm"
1831b31a0277SJuan Quintela    fi
1832b31a0277SJuan Quintela    kvm=no
18337ba1e619Saliguori  fi
18347ba1e619Saliguorifi
18357ba1e619Saliguori
18367ba1e619Saliguori##########################################
183764e07be5SAlexander Graf# test for ppc kvm pvr setting
183864e07be5SAlexander Graf
183964e07be5SAlexander Grafif test "$kvm" = "yes" && test "$cpu" = "ppc" -o "$cpu" = "ppc64"; then
184064e07be5SAlexander Graf            cat > $TMPC <<EOF
184164e07be5SAlexander Graf    #include <asm/kvm.h>
184264e07be5SAlexander Graf    int main(void) { struct kvm_sregs s; s.pvr = 0; return 0; }
184364e07be5SAlexander GrafEOF
184464e07be5SAlexander Graf    if compile_prog "$kvm_cflags" "" ; then
184564e07be5SAlexander Graf        kvm_ppc_pvr=yes
184664e07be5SAlexander Graf    else
184764e07be5SAlexander Graf        kvm_ppc_pvr=no
184864e07be5SAlexander Graf    fi
184964e07be5SAlexander Graffi
185064e07be5SAlexander Graf
185164e07be5SAlexander Graf##########################################
1852d5970055SMichael S. Tsirkin# test for vhost net
1853d5970055SMichael S. Tsirkin
1854d5970055SMichael S. Tsirkinif test "$vhost_net" != "no"; then
1855d5970055SMichael S. Tsirkin    if test "$kvm" != "no"; then
1856d5970055SMichael S. Tsirkin            cat > $TMPC <<EOF
1857d5970055SMichael S. Tsirkin    #include <linux/vhost.h>
1858d5970055SMichael S. Tsirkin    int main(void) { return 0; }
1859d5970055SMichael S. TsirkinEOF
1860d5970055SMichael S. Tsirkin            if compile_prog "$kvm_cflags" "" ; then
1861d5970055SMichael S. Tsirkin                vhost_net=yes
1862d5970055SMichael S. Tsirkin            else
1863d5970055SMichael S. Tsirkin                if test "$vhost_net" = "yes" ; then
1864d5970055SMichael S. Tsirkin                    feature_not_found "vhost-net"
1865d5970055SMichael S. Tsirkin                fi
1866d5970055SMichael S. Tsirkin                vhost_net=no
1867d5970055SMichael S. Tsirkin            fi
1868d5970055SMichael S. Tsirkin    else
1869d5970055SMichael S. Tsirkin            if test "$vhost_net" = "yes" ; then
18704021d247SAurelien Jarno                echo "NOTE: vhost-net feature requires KVM (--enable-kvm)."
1871d5970055SMichael S. Tsirkin                feature_not_found "vhost-net"
1872d5970055SMichael S. Tsirkin            fi
1873d5970055SMichael S. Tsirkin            vhost_net=no
1874d5970055SMichael S. Tsirkin    fi
1875d5970055SMichael S. Tsirkinfi
1876d5970055SMichael S. Tsirkin
1877d5970055SMichael S. Tsirkin##########################################
1878e5d355d1Saliguori# pthread probe
1879de65fe0fSSebastian HerbsztPTHREADLIBS_LIST="-lpthread -lpthreadGC2"
18803c529d93Saliguori
1881e5d355d1Saliguoripthread=no
1882414f0dabSblueswir1cat > $TMPC << EOF
18833c529d93Saliguori#include <pthread.h>
1884de65fe0fSSebastian Herbsztint main(void) { pthread_create(0,0,0,0); return 0; }
1885414f0dabSblueswir1EOF
1886bd00d539SAndreas Färberif compile_prog "" "" ; then
1887bd00d539SAndreas Färber  pthread=yes
1888bd00d539SAndreas Färberelse
1889de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
189052166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
1891e5d355d1Saliguori      pthread=yes
18925572b539SJuan Quintela      LIBS="$pthread_lib $LIBS"
1893de65fe0fSSebastian Herbszt      break
1894414f0dabSblueswir1    fi
1895de65fe0fSSebastian Herbszt  done
1896bd00d539SAndreas Färberfi
1897414f0dabSblueswir1
18984617e593SAnthony Liguoriif test "$mingw32" != yes -a "$pthread" = no; then
18994dd75c70SChristoph Hellwig  echo
19004dd75c70SChristoph Hellwig  echo "Error: pthread check failed"
19014dd75c70SChristoph Hellwig  echo "Make sure to have the pthread libs and headers installed."
19024dd75c70SChristoph Hellwig  echo
19034dd75c70SChristoph Hellwig  exit 1
1904e5d355d1Saliguorifi
1905e5d355d1Saliguori
1906bf9298b9Saliguori##########################################
1907f27aaf4bSChristian Brunner# rbd probe
1908f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
1909f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
1910f27aaf4bSChristian Brunner#include <stdio.h>
1911f27aaf4bSChristian Brunner#include <rados/librados.h>
1912f27aaf4bSChristian Brunnerint main(void) { rados_initialize(0, NULL); return 0; }
1913f27aaf4bSChristian BrunnerEOF
1914cc4e8741SAurelien Jarno  rbd_libs="-lrados"
1915f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
1916f27aaf4bSChristian Brunner    librados_too_old=no
1917f27aaf4bSChristian Brunner    cat > $TMPC <<EOF
1918f27aaf4bSChristian Brunner#include <stdio.h>
1919f27aaf4bSChristian Brunner#include <rados/librados.h>
1920f27aaf4bSChristian Brunner#ifndef CEPH_OSD_TMAP_SET
1921f27aaf4bSChristian Brunner#error missing CEPH_OSD_TMAP_SET
1922f27aaf4bSChristian Brunner#endif
1923f27aaf4bSChristian Brunnerint main(void) {
1924f27aaf4bSChristian Brunner    int (*func)(const rados_pool_t pool, uint64_t *snapid) = rados_selfmanaged_snap_create;
1925f27aaf4bSChristian Brunner    rados_initialize(0, NULL);
1926f27aaf4bSChristian Brunner    return 0;
1927f27aaf4bSChristian Brunner}
1928f27aaf4bSChristian BrunnerEOF
1929f27aaf4bSChristian Brunner    if compile_prog "" "$rbd_libs" ; then
1930f27aaf4bSChristian Brunner      rbd=yes
1931f27aaf4bSChristian Brunner      libs_tools="$rbd_libs $libs_tools"
1932f27aaf4bSChristian Brunner      libs_softmmu="$rbd_libs $libs_softmmu"
1933f27aaf4bSChristian Brunner    else
1934f27aaf4bSChristian Brunner      rbd=no
1935f27aaf4bSChristian Brunner      librados_too_old=yes
1936f27aaf4bSChristian Brunner    fi
1937f27aaf4bSChristian Brunner  else
1938f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
1939f27aaf4bSChristian Brunner      feature_not_found "rados block device"
1940f27aaf4bSChristian Brunner    fi
1941f27aaf4bSChristian Brunner    rbd=no
1942f27aaf4bSChristian Brunner  fi
1943f27aaf4bSChristian Brunner  if test "$librados_too_old" = "yes" ; then
1944f27aaf4bSChristian Brunner    echo "-> Your librados version is too old - upgrade needed to have rbd support"
1945f27aaf4bSChristian Brunner  fi
1946f27aaf4bSChristian Brunnerfi
1947f27aaf4bSChristian Brunner
1948f27aaf4bSChristian Brunner##########################################
19495c6c3a6cSChristoph Hellwig# linux-aio probe
19505c6c3a6cSChristoph Hellwig
19515c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
19525c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
19535c6c3a6cSChristoph Hellwig#include <libaio.h>
19545c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
1955832ce9c2SScott Wood#include <stddef.h>
19565c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
19575c6c3a6cSChristoph HellwigEOF
19585c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
19595c6c3a6cSChristoph Hellwig    linux_aio=yes
1960048d179fSPaul Brook    libs_softmmu="$libs_softmmu -laio"
1961048d179fSPaul Brook    libs_tools="$libs_tools -laio"
19625c6c3a6cSChristoph Hellwig  else
19635c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
19645c6c3a6cSChristoph Hellwig      feature_not_found "linux AIO"
19655c6c3a6cSChristoph Hellwig    fi
19663cfcae3cSLuiz Capitulino    linux_aio=no
19675c6c3a6cSChristoph Hellwig  fi
19685c6c3a6cSChristoph Hellwigfi
19695c6c3a6cSChristoph Hellwig
19705c6c3a6cSChristoph Hellwig##########################################
1971758e8e38SVenkateswararao Jujjuri (JV)# attr probe
1972758e8e38SVenkateswararao Jujjuri (JV)
1973758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
1974758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
1975758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
1976758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
1977758e8e38SVenkateswararao Jujjuri (JV)#include <attr/xattr.h>
1978758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
1979758e8e38SVenkateswararao Jujjuri (JV)EOF
1980758e8e38SVenkateswararao Jujjuri (JV)  if compile_prog "" "-lattr" ; then
1981758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
1982758e8e38SVenkateswararao Jujjuri (JV)    LIBS="-lattr $LIBS"
1983758e8e38SVenkateswararao Jujjuri (JV)  else
1984758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
1985758e8e38SVenkateswararao Jujjuri (JV)      feature_not_found "ATTR"
1986758e8e38SVenkateswararao Jujjuri (JV)    fi
1987758e8e38SVenkateswararao Jujjuri (JV)    attr=no
1988758e8e38SVenkateswararao Jujjuri (JV)  fi
1989758e8e38SVenkateswararao Jujjuri (JV)fi
1990758e8e38SVenkateswararao Jujjuri (JV)
1991758e8e38SVenkateswararao Jujjuri (JV)##########################################
1992bf9298b9Saliguori# iovec probe
1993bf9298b9Saliguoricat > $TMPC <<EOF
1994db34f0b3Sblueswir1#include <sys/types.h>
1995bf9298b9Saliguori#include <sys/uio.h>
1996db34f0b3Sblueswir1#include <unistd.h>
1997bf9298b9Saliguoriint main(void) { struct iovec iov; return 0; }
1998bf9298b9SaliguoriEOF
1999bf9298b9Saliguoriiovec=no
200052166aa0SJuan Quintelaif compile_prog "" "" ; then
2001bf9298b9Saliguori  iovec=yes
2002bf9298b9Saliguorifi
2003bf9298b9Saliguori
2004f652e6afSaurel32##########################################
2005ceb42de8Saliguori# preadv probe
2006ceb42de8Saliguoricat > $TMPC <<EOF
2007ceb42de8Saliguori#include <sys/types.h>
2008ceb42de8Saliguori#include <sys/uio.h>
2009ceb42de8Saliguori#include <unistd.h>
2010ceb42de8Saliguoriint main(void) { preadv; }
2011ceb42de8SaliguoriEOF
2012ceb42de8Saliguoripreadv=no
201352166aa0SJuan Quintelaif compile_prog "" "" ; then
2014ceb42de8Saliguori  preadv=yes
2015ceb42de8Saliguorifi
2016ceb42de8Saliguori
2017ceb42de8Saliguori##########################################
2018f652e6afSaurel32# fdt probe
20192df87df7SJuan Quintelaif test "$fdt" != "no" ; then
2020b41af4baSJuan Quintela  fdt_libs="-lfdt"
2021f652e6afSaurel32  cat > $TMPC << EOF
2022f652e6afSaurel32int main(void) { return 0; }
2023f652e6afSaurel32EOF
202452166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
2025f652e6afSaurel32    fdt=yes
20262df87df7SJuan Quintela  else
20272df87df7SJuan Quintela    if test "$fdt" = "yes" ; then
20282df87df7SJuan Quintela      feature_not_found "fdt"
20292df87df7SJuan Quintela    fi
2030de3a354aSMichael Walle    fdt_libs=
20312df87df7SJuan Quintela    fdt=no
2032f652e6afSaurel32  fi
2033f652e6afSaurel32fi
2034f652e6afSaurel32
203520ff075bSMichael Walle##########################################
203620ff075bSMichael Walle# opengl probe, used by milkymist-tmu2
203720ff075bSMichael Walleif test "$opengl" != "no" ; then
203820ff075bSMichael Walle  opengl_libs="-lGL"
203920ff075bSMichael Walle  cat > $TMPC << EOF
204020ff075bSMichael Walle#include <X11/Xlib.h>
204120ff075bSMichael Walle#include <GL/gl.h>
204220ff075bSMichael Walle#include <GL/glx.h>
204320ff075bSMichael Walleint main(void) { GL_VERSION; return 0; }
204420ff075bSMichael WalleEOF
204520ff075bSMichael Walle  if compile_prog "" "-lGL" ; then
204620ff075bSMichael Walle    opengl=yes
204720ff075bSMichael Walle  else
204820ff075bSMichael Walle    if test "$opengl" = "yes" ; then
204920ff075bSMichael Walle      feature_not_found "opengl"
205020ff075bSMichael Walle    fi
2051de3a354aSMichael Walle    opengl_libs=
205220ff075bSMichael Walle    opengl=no
205320ff075bSMichael Walle  fi
205420ff075bSMichael Wallefi
205520ff075bSMichael Walle
20563b3f24adSaurel32#
20573b3f24adSaurel32# Check for xxxat() functions when we are building linux-user
20583b3f24adSaurel32# emulator.  This is done because older glibc versions don't
20593b3f24adSaurel32# have syscall stubs for these implemented.
20603b3f24adSaurel32#
20613b3f24adSaurel32atfile=no
20623b3f24adSaurel32cat > $TMPC << EOF
20633b3f24adSaurel32#define _ATFILE_SOURCE
20643b3f24adSaurel32#include <sys/types.h>
20653b3f24adSaurel32#include <fcntl.h>
20663b3f24adSaurel32#include <unistd.h>
20673b3f24adSaurel32
20683b3f24adSaurel32int
20693b3f24adSaurel32main(void)
20703b3f24adSaurel32{
20713b3f24adSaurel32	/* try to unlink nonexisting file */
20723b3f24adSaurel32	return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
20733b3f24adSaurel32}
20743b3f24adSaurel32EOF
207552166aa0SJuan Quintelaif compile_prog "" "" ; then
20763b3f24adSaurel32  atfile=yes
20773b3f24adSaurel32fi
20783b3f24adSaurel32
207939386ac7Saurel32# Check for inotify functions when we are building linux-user
20803b3f24adSaurel32# emulator.  This is done because older glibc versions don't
20813b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
20823b3f24adSaurel32# don't provide them even if kernel supports them.
20833b3f24adSaurel32#
20843b3f24adSaurel32inotify=no
20853b3f24adSaurel32cat > $TMPC << EOF
20863b3f24adSaurel32#include <sys/inotify.h>
20873b3f24adSaurel32
20883b3f24adSaurel32int
20893b3f24adSaurel32main(void)
20903b3f24adSaurel32{
20913b3f24adSaurel32	/* try to start inotify */
20928690e420Saurel32	return inotify_init();
20933b3f24adSaurel32}
20943b3f24adSaurel32EOF
209552166aa0SJuan Quintelaif compile_prog "" "" ; then
20963b3f24adSaurel32  inotify=yes
20973b3f24adSaurel32fi
20983b3f24adSaurel32
2099c05c7a73SRiku Voipioinotify1=no
2100c05c7a73SRiku Voipiocat > $TMPC << EOF
2101c05c7a73SRiku Voipio#include <sys/inotify.h>
2102c05c7a73SRiku Voipio
2103c05c7a73SRiku Voipioint
2104c05c7a73SRiku Voipiomain(void)
2105c05c7a73SRiku Voipio{
2106c05c7a73SRiku Voipio    /* try to start inotify */
2107c05c7a73SRiku Voipio    return inotify_init1(0);
2108c05c7a73SRiku Voipio}
2109c05c7a73SRiku VoipioEOF
2110c05c7a73SRiku Voipioif compile_prog "" "" ; then
2111c05c7a73SRiku Voipio  inotify1=yes
2112c05c7a73SRiku Voipiofi
2113c05c7a73SRiku Voipio
2114ebc996f3SRiku Voipio# check if utimensat and futimens are supported
2115ebc996f3SRiku Voipioutimens=no
2116ebc996f3SRiku Voipiocat > $TMPC << EOF
2117ebc996f3SRiku Voipio#define _ATFILE_SOURCE
2118ebc996f3SRiku Voipio#include <stddef.h>
2119ebc996f3SRiku Voipio#include <fcntl.h>
2120ebc996f3SRiku Voipio
2121ebc996f3SRiku Voipioint main(void)
2122ebc996f3SRiku Voipio{
2123ebc996f3SRiku Voipio    utimensat(AT_FDCWD, "foo", NULL, 0);
2124ebc996f3SRiku Voipio    futimens(0, NULL);
2125ebc996f3SRiku Voipio    return 0;
2126ebc996f3SRiku Voipio}
2127ebc996f3SRiku VoipioEOF
212852166aa0SJuan Quintelaif compile_prog "" "" ; then
2129ebc996f3SRiku Voipio  utimens=yes
2130ebc996f3SRiku Voipiofi
2131ebc996f3SRiku Voipio
2132099d6b0fSRiku Voipio# check if pipe2 is there
2133099d6b0fSRiku Voipiopipe2=no
2134099d6b0fSRiku Voipiocat > $TMPC << EOF
2135099d6b0fSRiku Voipio#include <unistd.h>
2136099d6b0fSRiku Voipio#include <fcntl.h>
2137099d6b0fSRiku Voipio
2138099d6b0fSRiku Voipioint main(void)
2139099d6b0fSRiku Voipio{
2140099d6b0fSRiku Voipio    int pipefd[2];
2141099d6b0fSRiku Voipio    pipe2(pipefd, O_CLOEXEC);
2142099d6b0fSRiku Voipio    return 0;
2143099d6b0fSRiku Voipio}
2144099d6b0fSRiku VoipioEOF
214552166aa0SJuan Quintelaif compile_prog "" "" ; then
2146099d6b0fSRiku Voipio  pipe2=yes
2147099d6b0fSRiku Voipiofi
2148099d6b0fSRiku Voipio
214940ff6d7eSKevin Wolf# check if accept4 is there
215040ff6d7eSKevin Wolfaccept4=no
215140ff6d7eSKevin Wolfcat > $TMPC << EOF
215240ff6d7eSKevin Wolf#include <sys/socket.h>
215340ff6d7eSKevin Wolf#include <stddef.h>
215440ff6d7eSKevin Wolf
215540ff6d7eSKevin Wolfint main(void)
215640ff6d7eSKevin Wolf{
215740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
215840ff6d7eSKevin Wolf    return 0;
215940ff6d7eSKevin Wolf}
216040ff6d7eSKevin WolfEOF
216140ff6d7eSKevin Wolfif compile_prog "" "" ; then
216240ff6d7eSKevin Wolf  accept4=yes
216340ff6d7eSKevin Wolffi
216440ff6d7eSKevin Wolf
21653ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
21663ce34dfbSvibisreenivasansplice=no
21673ce34dfbSvibisreenivasancat > $TMPC << EOF
21683ce34dfbSvibisreenivasan#include <unistd.h>
21693ce34dfbSvibisreenivasan#include <fcntl.h>
21703ce34dfbSvibisreenivasan#include <limits.h>
21713ce34dfbSvibisreenivasan
21723ce34dfbSvibisreenivasanint main(void)
21733ce34dfbSvibisreenivasan{
21743ce34dfbSvibisreenivasan    int len, fd;
21753ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
21763ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
21773ce34dfbSvibisreenivasan    return 0;
21783ce34dfbSvibisreenivasan}
21793ce34dfbSvibisreenivasanEOF
218052166aa0SJuan Quintelaif compile_prog "" "" ; then
21813ce34dfbSvibisreenivasan  splice=yes
21823ce34dfbSvibisreenivasanfi
21833ce34dfbSvibisreenivasan
2184dcc38d1cSMarcelo Tosatti##########################################
2185dcc38d1cSMarcelo Tosatti# signalfd probe
2186dcc38d1cSMarcelo Tosattisignalfd="no"
2187dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
2188dcc38d1cSMarcelo Tosatti#define _GNU_SOURCE
2189dcc38d1cSMarcelo Tosatti#include <unistd.h>
2190dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
2191dcc38d1cSMarcelo Tosatti#include <signal.h>
2192dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
2193dcc38d1cSMarcelo TosattiEOF
2194dcc38d1cSMarcelo Tosatti
2195dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
2196dcc38d1cSMarcelo Tosatti  signalfd=yes
2197de758970SJan Kiszkaelif test "$kvm" = "yes" -a "$io_thread" != "yes"; then
2198de758970SJan Kiszka  echo
2199de758970SJan Kiszka  echo "ERROR: Host kernel lacks signalfd() support,"
2200de758970SJan Kiszka  echo "but KVM depends on it when the IO thread is disabled."
2201de758970SJan Kiszka  echo
2202de758970SJan Kiszka  exit 1
2203dcc38d1cSMarcelo Tosattifi
2204dcc38d1cSMarcelo Tosatti
2205c2882b96SRiku Voipio# check if eventfd is supported
2206c2882b96SRiku Voipioeventfd=no
2207c2882b96SRiku Voipiocat > $TMPC << EOF
2208c2882b96SRiku Voipio#include <sys/eventfd.h>
2209c2882b96SRiku Voipio
2210c2882b96SRiku Voipioint main(void)
2211c2882b96SRiku Voipio{
2212c2882b96SRiku Voipio    int efd = eventfd(0, 0);
2213c2882b96SRiku Voipio    return 0;
2214c2882b96SRiku Voipio}
2215c2882b96SRiku VoipioEOF
2216c2882b96SRiku Voipioif compile_prog "" "" ; then
2217c2882b96SRiku Voipio  eventfd=yes
2218c2882b96SRiku Voipiofi
2219c2882b96SRiku Voipio
2220d0927938SUlrich Hecht# check for fallocate
2221d0927938SUlrich Hechtfallocate=no
2222d0927938SUlrich Hechtcat > $TMPC << EOF
2223d0927938SUlrich Hecht#include <fcntl.h>
2224d0927938SUlrich Hecht
2225d0927938SUlrich Hechtint main(void)
2226d0927938SUlrich Hecht{
2227d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
2228d0927938SUlrich Hecht    return 0;
2229d0927938SUlrich Hecht}
2230d0927938SUlrich HechtEOF
2231be17dc90SMichael S. Tsirkinif compile_prog "$ARCH_CFLAGS" "" ; then
2232d0927938SUlrich Hecht  fallocate=yes
2233d0927938SUlrich Hechtfi
2234d0927938SUlrich Hecht
2235c727f47dSPeter Maydell# check for sync_file_range
2236c727f47dSPeter Maydellsync_file_range=no
2237c727f47dSPeter Maydellcat > $TMPC << EOF
2238c727f47dSPeter Maydell#include <fcntl.h>
2239c727f47dSPeter Maydell
2240c727f47dSPeter Maydellint main(void)
2241c727f47dSPeter Maydell{
2242c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
2243c727f47dSPeter Maydell    return 0;
2244c727f47dSPeter Maydell}
2245c727f47dSPeter MaydellEOF
2246c727f47dSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2247c727f47dSPeter Maydell  sync_file_range=yes
2248c727f47dSPeter Maydellfi
2249c727f47dSPeter Maydell
2250dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
2251dace20dcSPeter Maydellfiemap=no
2252dace20dcSPeter Maydellcat > $TMPC << EOF
2253dace20dcSPeter Maydell#include <sys/ioctl.h>
2254dace20dcSPeter Maydell#include <linux/fs.h>
2255dace20dcSPeter Maydell#include <linux/fiemap.h>
2256dace20dcSPeter Maydell
2257dace20dcSPeter Maydellint main(void)
2258dace20dcSPeter Maydell{
2259dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
2260dace20dcSPeter Maydell    return 0;
2261dace20dcSPeter Maydell}
2262dace20dcSPeter MaydellEOF
2263dace20dcSPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
2264dace20dcSPeter Maydell  fiemap=yes
2265dace20dcSPeter Maydellfi
2266dace20dcSPeter Maydell
2267d0927938SUlrich Hecht# check for dup3
2268d0927938SUlrich Hechtdup3=no
2269d0927938SUlrich Hechtcat > $TMPC << EOF
2270d0927938SUlrich Hecht#include <unistd.h>
2271d0927938SUlrich Hecht
2272d0927938SUlrich Hechtint main(void)
2273d0927938SUlrich Hecht{
2274d0927938SUlrich Hecht    dup3(0, 0, 0);
2275d0927938SUlrich Hecht    return 0;
2276d0927938SUlrich Hecht}
2277d0927938SUlrich HechtEOF
227878f5d726SJan Kiszkaif compile_prog "" "" ; then
2279d0927938SUlrich Hecht  dup3=yes
2280d0927938SUlrich Hechtfi
2281d0927938SUlrich Hecht
22823b6edd16SPeter Maydell# check for epoll support
22833b6edd16SPeter Maydellepoll=no
22843b6edd16SPeter Maydellcat > $TMPC << EOF
22853b6edd16SPeter Maydell#include <sys/epoll.h>
22863b6edd16SPeter Maydell
22873b6edd16SPeter Maydellint main(void)
22883b6edd16SPeter Maydell{
22893b6edd16SPeter Maydell    epoll_create(0);
22903b6edd16SPeter Maydell    return 0;
22913b6edd16SPeter Maydell}
22923b6edd16SPeter MaydellEOF
22933b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
22943b6edd16SPeter Maydell  epoll=yes
22953b6edd16SPeter Maydellfi
22963b6edd16SPeter Maydell
22973b6edd16SPeter Maydell# epoll_create1 and epoll_pwait are later additions
22983b6edd16SPeter Maydell# so we must check separately for their presence
22993b6edd16SPeter Maydellepoll_create1=no
23003b6edd16SPeter Maydellcat > $TMPC << EOF
23013b6edd16SPeter Maydell#include <sys/epoll.h>
23023b6edd16SPeter Maydell
23033b6edd16SPeter Maydellint main(void)
23043b6edd16SPeter Maydell{
230519e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
230619e83f6bSPeter Maydell     * a function being called. This is necessary so that on
230719e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
230819e83f6bSPeter Maydell     * the library but not declared in the header file we will
230919e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
231019e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
231119e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
231219e83f6bSPeter Maydell     */
231319e83f6bSPeter Maydell    epoll_create1;
23143b6edd16SPeter Maydell    return 0;
23153b6edd16SPeter Maydell}
23163b6edd16SPeter MaydellEOF
23173b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23183b6edd16SPeter Maydell  epoll_create1=yes
23193b6edd16SPeter Maydellfi
23203b6edd16SPeter Maydell
23213b6edd16SPeter Maydellepoll_pwait=no
23223b6edd16SPeter Maydellcat > $TMPC << EOF
23233b6edd16SPeter Maydell#include <sys/epoll.h>
23243b6edd16SPeter Maydell
23253b6edd16SPeter Maydellint main(void)
23263b6edd16SPeter Maydell{
23273b6edd16SPeter Maydell    epoll_pwait(0, 0, 0, 0, 0);
23283b6edd16SPeter Maydell    return 0;
23293b6edd16SPeter Maydell}
23303b6edd16SPeter MaydellEOF
23313b6edd16SPeter Maydellif compile_prog "$ARCH_CFLAGS" "" ; then
23323b6edd16SPeter Maydell  epoll_pwait=yes
23333b6edd16SPeter Maydellfi
23343b6edd16SPeter Maydell
2335cc8ae6deSpbrook# Check if tools are available to build documentation.
2336a25dba17SJuan Quintelaif test "$docs" != "no" ; then
233701668d98SStefan Weil  if has makeinfo && has pod2man; then
2338a25dba17SJuan Quintela    docs=yes
233983a3ab8bSJuan Quintela  else
2340a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
2341a25dba17SJuan Quintela      feature_not_found "docs"
234283a3ab8bSJuan Quintela    fi
2343a25dba17SJuan Quintela    docs=no
234483a3ab8bSJuan Quintela  fi
2345cc8ae6deSpbrookfi
2346cc8ae6deSpbrook
2347f514f41cSStefan Weil# Search for bswap_32 function
23486ae9a1f4SJuan Quintelabyteswap_h=no
23496ae9a1f4SJuan Quintelacat > $TMPC << EOF
23506ae9a1f4SJuan Quintela#include <byteswap.h>
23516ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
23526ae9a1f4SJuan QuintelaEOF
235352166aa0SJuan Quintelaif compile_prog "" "" ; then
23546ae9a1f4SJuan Quintela  byteswap_h=yes
23556ae9a1f4SJuan Quintelafi
23566ae9a1f4SJuan Quintela
2357f514f41cSStefan Weil# Search for bswap_32 function
23586ae9a1f4SJuan Quintelabswap_h=no
23596ae9a1f4SJuan Quintelacat > $TMPC << EOF
23606ae9a1f4SJuan Quintela#include <sys/endian.h>
23616ae9a1f4SJuan Quintela#include <sys/types.h>
23626ae9a1f4SJuan Quintela#include <machine/bswap.h>
23636ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
23646ae9a1f4SJuan QuintelaEOF
236552166aa0SJuan Quintelaif compile_prog "" "" ; then
23666ae9a1f4SJuan Quintela  bswap_h=yes
23676ae9a1f4SJuan Quintelafi
23686ae9a1f4SJuan Quintela
2369da93a1fdSaliguori##########################################
2370da93a1fdSaliguori# Do we need librt
2371da93a1fdSaliguoricat > $TMPC <<EOF
2372da93a1fdSaliguori#include <signal.h>
2373da93a1fdSaliguori#include <time.h>
2374da93a1fdSaliguoriint main(void) { clockid_t id; return clock_gettime(id, NULL); }
2375da93a1fdSaliguoriEOF
2376da93a1fdSaliguori
237752166aa0SJuan Quintelaif compile_prog "" "" ; then
237807ffa4bdSJuan Quintela  :
237952166aa0SJuan Quintelaelif compile_prog "" "-lrt" ; then
238007ffa4bdSJuan Quintela  LIBS="-lrt $LIBS"
2381da93a1fdSaliguorifi
2382da93a1fdSaliguori
238331ff504dSBlue Swirlif test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
2384179cf400SAndreas Färber        "$aix" != "yes" -a "$haiku" != "yes" ; then
23856362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
23866362a53fSJuan Quintelafi
23876362a53fSJuan Quintela
2388de5071c5SBlue Swirl##########################################
2389de5071c5SBlue Swirl# check if the compiler defines offsetof
2390de5071c5SBlue Swirl
2391de5071c5SBlue Swirlneed_offsetof=yes
2392de5071c5SBlue Swirlcat > $TMPC << EOF
2393de5071c5SBlue Swirl#include <stddef.h>
2394de5071c5SBlue Swirlint main(void) { struct s { int f; }; return offsetof(struct s, f); }
2395de5071c5SBlue SwirlEOF
2396de5071c5SBlue Swirlif compile_prog "" "" ; then
2397de5071c5SBlue Swirl    need_offsetof=no
2398de5071c5SBlue Swirlfi
2399de5071c5SBlue Swirl
24005f6b9e8fSBlue Swirl##########################################
2401747bbdf7SBlue Swirl# check if the compiler understands attribute warn_unused_result
2402747bbdf7SBlue Swirl#
2403747bbdf7SBlue Swirl# This could be smarter, but gcc -Werror does not error out even when warning
2404747bbdf7SBlue Swirl# about attribute warn_unused_result
2405747bbdf7SBlue Swirl
2406747bbdf7SBlue Swirlgcc_attribute_warn_unused_result=no
2407747bbdf7SBlue Swirlcat > $TMPC << EOF
2408747bbdf7SBlue Swirl#if defined(__GNUC__) && (__GNUC__ < 4) && defined(__GNUC_MINOR__) && (__GNUC__ < 4)
2409747bbdf7SBlue Swirl#error gcc 3.3 or older
2410747bbdf7SBlue Swirl#endif
2411747bbdf7SBlue Swirlint main(void) { return 0;}
2412747bbdf7SBlue SwirlEOF
2413747bbdf7SBlue Swirlif compile_prog "" ""; then
2414747bbdf7SBlue Swirl    gcc_attribute_warn_unused_result=yes
2415747bbdf7SBlue Swirlfi
2416747bbdf7SBlue Swirl
2417cd4ec0b4SGerd Hoffmann# spice probe
2418cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
2419cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
2420cd4ec0b4SGerd Hoffmann#include <spice.h>
2421cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
2422cd4ec0b4SGerd HoffmannEOF
2423710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
2424710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
2425710fc4f5SJiri Denemark  if $pkg_config --atleast-version=0.5.3 spice-server >/dev/null 2>&1 && \
2426cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
2427cd4ec0b4SGerd Hoffmann    spice="yes"
2428cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
2429cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2430cd4ec0b4SGerd Hoffmann  else
2431cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
2432cd4ec0b4SGerd Hoffmann      feature_not_found "spice"
2433cd4ec0b4SGerd Hoffmann    fi
2434cd4ec0b4SGerd Hoffmann    spice="no"
2435cd4ec0b4SGerd Hoffmann  fi
2436cd4ec0b4SGerd Hoffmannfi
2437cd4ec0b4SGerd Hoffmann
2438111a38b0SRobert Relyea# check for libcacard for smartcard support
2439111a38b0SRobert Relyeaif test "$smartcard" != "no" ; then
2440111a38b0SRobert Relyea    smartcard="yes"
2441111a38b0SRobert Relyea    smartcard_cflags=""
2442111a38b0SRobert Relyea    # TODO - what's the minimal nss version we support?
2443111a38b0SRobert Relyea    if test "$smartcard_nss" != "no"; then
2444111a38b0SRobert Relyea        if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then
2445111a38b0SRobert Relyea            smartcard_nss="yes"
2446111a38b0SRobert Relyea            smartcard_cflags="-I\$(SRC_PATH)/libcacard"
2447111a38b0SRobert Relyea            libcacard_libs=$($pkg_config --libs nss 2>/dev/null)
2448111a38b0SRobert Relyea            libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null)
2449111a38b0SRobert Relyea            QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags"
2450111a38b0SRobert Relyea            LIBS="$libcacard_libs $LIBS"
2451111a38b0SRobert Relyea        else
2452111a38b0SRobert Relyea            if test "$smartcard_nss" = "yes"; then
2453111a38b0SRobert Relyea                feature_not_found "nss"
2454111a38b0SRobert Relyea            fi
2455111a38b0SRobert Relyea            smartcard_nss="no"
2456111a38b0SRobert Relyea        fi
2457111a38b0SRobert Relyea    fi
2458111a38b0SRobert Relyeafi
2459111a38b0SRobert Relyeaif test "$smartcard" = "no" ; then
2460111a38b0SRobert Relyea    smartcard_nss="no"
2461111a38b0SRobert Relyeafi
2462111a38b0SRobert Relyea
2463cd4ec0b4SGerd Hoffmann##########################################
2464cd4ec0b4SGerd Hoffmann
2465747bbdf7SBlue Swirl##########################################
24665f6b9e8fSBlue Swirl# check if we have fdatasync
24675f6b9e8fSBlue Swirl
24685f6b9e8fSBlue Swirlfdatasync=no
24695f6b9e8fSBlue Swirlcat > $TMPC << EOF
24705f6b9e8fSBlue Swirl#include <unistd.h>
24715f6b9e8fSBlue Swirlint main(void) { return fdatasync(0); }
24725f6b9e8fSBlue SwirlEOF
24735f6b9e8fSBlue Swirlif compile_prog "" "" ; then
24745f6b9e8fSBlue Swirl    fdatasync=yes
24755f6b9e8fSBlue Swirlfi
24765f6b9e8fSBlue Swirl
247794a420b1SStefan Hajnoczi##########################################
2478e78815a5SAndreas Färber# check if we have madvise
2479e78815a5SAndreas Färber
2480e78815a5SAndreas Färbermadvise=no
2481e78815a5SAndreas Färbercat > $TMPC << EOF
2482e78815a5SAndreas Färber#include <sys/types.h>
2483e78815a5SAndreas Färber#include <sys/mman.h>
2484832ce9c2SScott Wood#include <stddef.h>
2485e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
2486e78815a5SAndreas FärberEOF
2487e78815a5SAndreas Färberif compile_prog "" "" ; then
2488e78815a5SAndreas Färber    madvise=yes
2489e78815a5SAndreas Färberfi
2490e78815a5SAndreas Färber
2491e78815a5SAndreas Färber##########################################
2492e78815a5SAndreas Färber# check if we have posix_madvise
2493e78815a5SAndreas Färber
2494e78815a5SAndreas Färberposix_madvise=no
2495e78815a5SAndreas Färbercat > $TMPC << EOF
2496e78815a5SAndreas Färber#include <sys/mman.h>
2497832ce9c2SScott Wood#include <stddef.h>
2498e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
2499e78815a5SAndreas FärberEOF
2500e78815a5SAndreas Färberif compile_prog "" "" ; then
2501e78815a5SAndreas Färber    posix_madvise=yes
2502e78815a5SAndreas Färberfi
2503e78815a5SAndreas Färber
2504e78815a5SAndreas Färber##########################################
250594a420b1SStefan Hajnoczi# check if trace backend exists
250694a420b1SStefan Hajnoczi
25074c3b5a48SBlue Swirlsh "$source_path/scripts/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
250894a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
250994a420b1SStefan Hajnoczi  echo
251094a420b1SStefan Hajnoczi  echo "Error: invalid trace backend"
251194a420b1SStefan Hajnoczi  echo "Please choose a supported trace backend."
251294a420b1SStefan Hajnoczi  echo
251394a420b1SStefan Hajnoczi  exit 1
251494a420b1SStefan Hajnoczifi
251594a420b1SStefan Hajnoczi
25167e24e92aSStefan Hajnoczi##########################################
25177e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
25187e24e92aSStefan Hajnocziif test "$trace_backend" = "ust"; then
25197e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
25207e24e92aSStefan Hajnoczi#include <ust/tracepoint.h>
25217e24e92aSStefan Hajnoczi#include <ust/marker.h>
25227e24e92aSStefan Hajnocziint main(void) { return 0; }
25237e24e92aSStefan HajnocziEOF
25247e24e92aSStefan Hajnoczi  if compile_prog "" "" ; then
25257e24e92aSStefan Hajnoczi    LIBS="-lust $LIBS"
25267e24e92aSStefan Hajnoczi  else
25277e24e92aSStefan Hajnoczi    echo
25287e24e92aSStefan Hajnoczi    echo "Error: Trace backend 'ust' missing libust header files"
25297e24e92aSStefan Hajnoczi    echo
25307e24e92aSStefan Hajnoczi    exit 1
25317e24e92aSStefan Hajnoczi  fi
25327e24e92aSStefan Hajnoczifi
2533b3d08c02SDaniel P. Berrange
2534b3d08c02SDaniel P. Berrange##########################################
2535b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
2536b3d08c02SDaniel P. Berrangeif test "$trace_backend" = "dtrace"; then
2537b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
2538b3d08c02SDaniel P. Berrange    echo
2539b3d08c02SDaniel P. Berrange    echo "Error: dtrace command is not found in PATH $PATH"
2540b3d08c02SDaniel P. Berrange    echo
2541b3d08c02SDaniel P. Berrange    exit 1
2542b3d08c02SDaniel P. Berrange  fi
2543c276b17dSDaniel P. Berrange  trace_backend_stap="no"
2544c276b17dSDaniel P. Berrange  if has 'stap' ; then
2545c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
2546c276b17dSDaniel P. Berrange  fi
2547b3d08c02SDaniel P. Berrangefi
2548b3d08c02SDaniel P. Berrange
25497e24e92aSStefan Hajnoczi##########################################
2550e86ecd4bSJuan Quintela# End of CC checks
2551e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
2552e86ecd4bSJuan Quintela
2553e86ecd4bSJuan Quintelaif test "$debug" = "no" ; then
25541156c669SJuan Quintela  CFLAGS="-O2 $CFLAGS"
2555e86ecd4bSJuan Quintelafi
2556a316e378SJuan Quintela
2557e86ecd4bSJuan Quintela# Consult white-list to determine whether to enable werror
2558e86ecd4bSJuan Quintela# by default.  Only enable by default for git builds
2559e86ecd4bSJuan Quintelaz_version=`cut -f3 -d. $source_path/VERSION`
256020ff6c80SAnthony Liguori
256120ff6c80SAnthony Liguoriif test -z "$werror" ; then
2562e86ecd4bSJuan Quintela    if test "$z_version" = "50" -a \
2563e86ecd4bSJuan Quintela        "$linux" = "yes" ; then
2564e86ecd4bSJuan Quintela        werror="yes"
2565e86ecd4bSJuan Quintela    else
2566e86ecd4bSJuan Quintela        werror="no"
2567e86ecd4bSJuan Quintela    fi
2568e86ecd4bSJuan Quintelafi
2569e86ecd4bSJuan Quintela
257020ff6c80SAnthony Liguori# Disable zero malloc errors for official releases unless explicitly told to
257120ff6c80SAnthony Liguori# enable/disable
257220ff6c80SAnthony Liguoriif test -z "$zero_malloc" ; then
257320ff6c80SAnthony Liguori    if test "$z_version" = "50" ; then
257420ff6c80SAnthony Liguori	zero_malloc="no"
257520ff6c80SAnthony Liguori    else
257620ff6c80SAnthony Liguori	zero_malloc="yes"
257720ff6c80SAnthony Liguori    fi
257820ff6c80SAnthony Liguorifi
257920ff6c80SAnthony Liguori
2580e86ecd4bSJuan Quintelaif test "$werror" = "yes" ; then
2581a558ee17SJuan Quintela    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
2582e86ecd4bSJuan Quintelafi
2583e86ecd4bSJuan Quintela
2584e86ecd4bSJuan Quintelaif test "$solaris" = "no" ; then
2585e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
25861156c669SJuan Quintela        LDFLAGS="-Wl,--warn-common $LDFLAGS"
2587e86ecd4bSJuan Quintela    fi
2588e86ecd4bSJuan Quintelafi
2589e86ecd4bSJuan Quintela
2590952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
2591952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
2592952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
2593952afb71SBlue Swirl        if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
2594952afb71SBlue Swirl            LDFLAGS="-Wl,$flag $LDFLAGS"
2595952afb71SBlue Swirl        fi
2596952afb71SBlue Swirl    done
2597952afb71SBlue Swirlfi
2598952afb71SBlue Swirl
2599190e9c59SPaolo Bonziniconfdir=$sysconfdir$confsuffix
26005a67135aSbellard
2601ca35f780SPaolo Bonzinitools=
2602ca35f780SPaolo Bonziniif test "$softmmu" = yes ; then
2603ca35f780SPaolo Bonzini  tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
2604ca35f780SPaolo Bonzini  if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
2605ca35f780SPaolo Bonzini      tools="qemu-nbd\$(EXESUF) $tools"
2606ca35f780SPaolo Bonzini    if [ "$check_utests" = "yes" ]; then
2607ca35f780SPaolo Bonzini      tools="check-qint check-qstring check-qdict check-qlist $tools"
2608ca35f780SPaolo Bonzini      tools="check-qfloat check-qjson $tools"
2609ca35f780SPaolo Bonzini    fi
2610ca35f780SPaolo Bonzini  fi
2611ca35f780SPaolo Bonzinifi
2612ca35f780SPaolo Bonzini
2613ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
2614ca35f780SPaolo Bonziniroms=
2615ca35f780SPaolo Bonziniif test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
2616ca35f780SPaolo Bonzini        "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
2617ca35f780SPaolo Bonzini        "$softmmu" = yes ; then
2618ca35f780SPaolo Bonzini  roms="optionrom"
2619ca35f780SPaolo Bonzinifi
2620d0384d1dSAndreas Färberif test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
262139ac8455SDavid Gibson  roms="$roms spapr-rtas"
262239ac8455SDavid Gibsonfi
2623ca35f780SPaolo Bonzini
26247d13299dSbellardecho "Install prefix    $prefix"
2625f2b9e1e3SPaolo Bonziniecho "BIOS directory    `eval echo $datadir`"
2626f2b9e1e3SPaolo Bonziniecho "binary directory  `eval echo $bindir`"
26271c0fd160SAurelien Jarnoecho "config directory  `eval echo $sysconfdir`"
262811d9f695Sbellardif test "$mingw32" = "no" ; then
2629f2b9e1e3SPaolo Bonziniecho "Manual directory  `eval echo $mandir`"
263043ce4dfeSbellardecho "ELF interp prefix $interp_prefix"
263111d9f695Sbellardfi
26325a67135aSbellardecho "Source path       $source_path"
26337d13299dSbellardecho "C compiler        $cc"
263483469015Sbellardecho "Host C compiler   $host_cc"
26350c439cbfSJuan Quintelaecho "CFLAGS            $CFLAGS"
2636a558ee17SJuan Quintelaecho "QEMU_CFLAGS       $QEMU_CFLAGS"
26370c439cbfSJuan Quintelaecho "LDFLAGS           $LDFLAGS"
26387d13299dSbellardecho "make              $make"
26396a882643Spbrookecho "install           $install"
2640a98fd896Sbellardecho "host CPU          $cpu"
2641de83cd02Sbellardecho "host big endian   $bigendian"
264297a847bcSbellardecho "target list       $target_list"
2643ade25b0dSaurel32echo "tcg debug enabled $debug_tcg"
2644b4475aa2SLuiz Capitulinoecho "Mon debug enabled $debug_mon"
26457d13299dSbellardecho "gprof enabled     $gprof"
264603b4fe7dSaliguoriecho "sparse enabled    $sparse"
26471625af87Saliguoriecho "strip binaries    $strip_opt"
264805c2a3e7Sbellardecho "profiler          $profiler"
264943ce4dfeSbellardecho "static build      $static"
265085aa5189Sbellardecho "-Werror enabled   $werror"
26515b0753e0Sbellardif test "$darwin" = "yes" ; then
26525b0753e0Sbellard    echo "Cocoa support     $cocoa"
26535b0753e0Sbellardfi
265497a847bcSbellardecho "SDL support       $sdl"
26554d3b6f6eSbalrogecho "curses support    $curses"
2656769ce76dSAlexander Grafecho "curl support      $curl"
26575495ed11SLuiz Capitulinoecho "check support     $check_utests"
265867b915a5Sbellardecho "mingw32 support   $mingw32"
26590c58ac1cSmalcecho "Audio drivers     $audio_drv_list"
26600c58ac1cSmalcecho "Extra audio cards $audio_card_list"
2661eb852011SMarkus Armbrusterecho "Block whitelist   $block_drv_whitelist"
26628ff9cbf7Smalcecho "Mixer emulation   $mixemu"
2663821601eaSJes Sorensenecho "VNC support       $vnc"
2664821601eaSJes Sorensenif test "$vnc" = "yes" ; then
26658d5d2d4cSths    echo "VNC TLS support   $vnc_tls"
26662f9606b3Saliguori    echo "VNC SASL support  $vnc_sasl"
26672f6f5c7aSCorentin Chary    echo "VNC JPEG support  $vnc_jpeg"
2668efe556adSCorentin Chary    echo "VNC PNG support   $vnc_png"
2669bd023f95SCorentin Chary    echo "VNC thread        $vnc_thread"
2670821601eaSJes Sorensenfi
26713142255cSblueswir1if test -n "$sparc_cpu"; then
26723142255cSblueswir1    echo "Target Sparc Arch $sparc_cpu"
26733142255cSblueswir1fi
2674e37630caSaliguoriecho "xen support       $xen"
26752e4d9fb1Saurel32echo "brlapi support    $brlapi"
2676a20a6f46SJuan Quintelaecho "bluez  support    $bluez"
2677a25dba17SJuan Quintelaecho "Documentation     $docs"
2678c5937220Spbrook[ ! -z "$uname_release" ] && \
2679c5937220Spbrookecho "uname -r          $uname_release"
2680bd0c5661Spbrookecho "NPTL support      $nptl"
2681379f6698SPaul Brookecho "GUEST_BASE        $guest_base"
268234005a00SKirill A. Shutemovecho "PIE user targets  $user_pie"
26838a16d273Sthsecho "vde support       $vde"
2684e5d355d1Saliguoriecho "IO thread         $io_thread"
26855c6c3a6cSChristoph Hellwigecho "Linux AIO support $linux_aio"
2686758e8e38SVenkateswararao Jujjuri (JV)echo "ATTR/XATTR support $attr"
268777755340Sthsecho "Install blobs     $blobs"
2688b31a0277SJuan Quintelaecho "KVM support       $kvm"
2689f652e6afSaurel32echo "fdt support       $fdt"
2690ceb42de8Saliguoriecho "preadv support    $preadv"
26915f6b9e8fSBlue Swirlecho "fdatasync         $fdatasync"
2692e78815a5SAndreas Färberecho "madvise           $madvise"
2693e78815a5SAndreas Färberecho "posix_madvise     $posix_madvise"
2694ee682d27SStefan Weilecho "uuid support      $uuid"
2695d5970055SMichael S. Tsirkinecho "vhost-net support $vhost_net"
269694a420b1SStefan Hajnocziecho "Trace backend     $trace_backend"
26979410b56cSPrerna Saxenaecho "Trace output file $trace_file-<pid>"
2698cd4ec0b4SGerd Hoffmannecho "spice support     $spice"
2699f27aaf4bSChristian Brunnerecho "rbd support       $rbd"
2700dce512deSChristoph Hellwigecho "xfsctl support    $xfs"
2701111a38b0SRobert Relyeaecho "nss used          $smartcard_nss"
270220ff075bSMichael Walleecho "OpenGL support    $opengl"
270367b915a5Sbellard
270497a847bcSbellardif test $sdl_too_old = "yes"; then
270524b55b96Sbellardecho "-> Your SDL version is too old - please upgrade to have SDL support"
2706e8cd23deSbellardfi
270797a847bcSbellard
270898ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
27094bf6b55bSJuan Quintelaconfig_host_ld="config-host.ld"
271097a847bcSbellard
271198ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
271298ec69acSJuan Quintelaprintf "# Configured with:" >> $config_host_mak
271398ec69acSJuan Quintelaprintf " '%s'" "$0" "$@" >> $config_host_mak
271498ec69acSJuan Quintelaecho >> $config_host_mak
271598ec69acSJuan Quintela
2716e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
271799d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
271899d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
271999d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
272099d7cc75SPaolo Bonziniecho "datadir=$datadir" >> $config_host_mak
272199d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
272299d7cc75SPaolo Bonziniecho "docdir=$docdir" >> $config_host_mak
27231dabe05cSPaolo Bonziniecho "confdir=$confdir" >> $config_host_mak
2724804edf29SJuan Quintela
27252408a527Saurel32case "$cpu" in
2726d2fbca94SGuan Xuetao  i386|x86_64|alpha|cris|hppa|ia64|lm32|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64|unicore32)
2727e0da9dd3SJuan Quintela    ARCH=$cpu
27282408a527Saurel32  ;;
2729a302c32dSLaurent Desnogues  armv4b|armv4l)
273016dbd14fSJuan Quintela    ARCH=arm
27312408a527Saurel32  ;;
27322408a527Saurel32esac
273398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
2734f8393946Saurel32if test "$debug_tcg" = "yes" ; then
27352358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2736f8393946Saurel32fi
2737b4475aa2SLuiz Capitulinoif test "$debug_mon" = "yes" ; then
2738b4475aa2SLuiz Capitulino  echo "CONFIG_DEBUG_MONITOR=y" >> $config_host_mak
2739b4475aa2SLuiz Capitulinofi
2740f3d08ee6SPaul Brookif test "$debug" = "yes" ; then
27412358a494SJuan Quintela  echo "CONFIG_DEBUG_EXEC=y" >> $config_host_mak
2742f3d08ee6SPaul Brookfi
27431625af87Saliguoriif test "$strip_opt" = "yes" ; then
274452ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
27451625af87Saliguorifi
27467d13299dSbellardif test "$bigendian" = "yes" ; then
2747e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
274897a847bcSbellardfi
27492358a494SJuan Quintelaecho "HOST_LONG_BITS=$hostlongbits" >> $config_host_mak
275067b915a5Sbellardif test "$mingw32" = "yes" ; then
275198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
27529fe6de94SBlue Swirl  rc_version=`cat $source_path/VERSION`
27539fe6de94SBlue Swirl  version_major=${rc_version%%.*}
27549fe6de94SBlue Swirl  rc_version=${rc_version#*.}
27559fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
27569fe6de94SBlue Swirl  rc_version=${rc_version#*.}
27579fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
27589fe6de94SBlue Swirl  version_micro=0
27599fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
27609fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
2761210fa556Spbrookelse
276235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
2763210fa556Spbrookfi
2764128ab2ffSblueswir1
2765dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
2766dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
2767dffcb71cSMark McLoughlinfi
2768dffcb71cSMark McLoughlin
276983fb7adfSbellardif test "$darwin" = "yes" ; then
277098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
277183fb7adfSbellardfi
2772b29fe3edSmalc
2773b29fe3edSmalcif test "$aix" = "yes" ; then
277498ec69acSJuan Quintela  echo "CONFIG_AIX=y" >> $config_host_mak
2775b29fe3edSmalcfi
2776b29fe3edSmalc
2777ec530c81Sbellardif test "$solaris" = "yes" ; then
277898ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
27792358a494SJuan Quintela  echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
27800475a5caSths  if test "$needs_libsunmath" = "yes" ; then
278175b5a697SJuan Quintela    echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
27820475a5caSths  fi
2783ec530c81Sbellardfi
2784179cf400SAndreas Färberif test "$haiku" = "yes" ; then
2785179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
2786179cf400SAndreas Färberfi
278797a847bcSbellardif test "$static" = "yes" ; then
278898ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
278997a847bcSbellardfi
279005c2a3e7Sbellardif test $profiler = "yes" ; then
27912358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
279205c2a3e7Sbellardfi
2793c20709aaSbellardif test "$slirp" = "yes" ; then
279498ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
2795f9728943SPaolo Bonzini  QEMU_INCLUDES="-I\$(SRC_PATH)/slirp $QEMU_INCLUDES"
2796c20709aaSbellardfi
27978a16d273Sthsif test "$vde" = "yes" ; then
279898ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
27998a16d273Sthsfi
28000c58ac1cSmalcfor card in $audio_card_list; do
2801f6e5889eSpbrook    def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'`
280298ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
28030c58ac1cSmalcdone
28042358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
28050c58ac1cSmalcfor drv in $audio_drv_list; do
2806f6e5889eSpbrook    def=CONFIG_`echo $drv | tr '[:lower:]' '[:upper:]'`
280798ec69acSJuan Quintela    echo "$def=y" >> $config_host_mak
2808923e4521Smalc    if test "$drv" = "fmod"; then
28097aac6cb1SJuan Quintela        echo "FMOD_CFLAGS=-I$fmod_inc" >> $config_host_mak
2810fb065187Sbellard    fi
28110c58ac1cSmalcdone
281267f86e8eSJuan Quintelaif test "$audio_pt_int" = "yes" ; then
281367f86e8eSJuan Quintela  echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
281467f86e8eSJuan Quintelafi
2815d5631638Smalcif test "$audio_win_int" = "yes" ; then
2816d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
2817d5631638Smalcfi
2818eb852011SMarkus Armbrusterecho "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
28198ff9cbf7Smalcif test "$mixemu" = "yes" ; then
282098ec69acSJuan Quintela  echo "CONFIG_MIXEMU=y" >> $config_host_mak
28218ff9cbf7Smalcfi
2822821601eaSJes Sorensenif test "$vnc" = "yes" ; then
2823821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
2824821601eaSJes Sorensenfi
28258d5d2d4cSthsif test "$vnc_tls" = "yes" ; then
282698ec69acSJuan Quintela  echo "CONFIG_VNC_TLS=y" >> $config_host_mak
2827525061bfSJuan Quintela  echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
28288d5d2d4cSthsfi
28292f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
283098ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
283160ddf533SJuan Quintela  echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
28322f9606b3Saliguorifi
2833821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
28342f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
28352f6f5c7aSCorentin Chary  echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
28362f6f5c7aSCorentin Charyfi
2837821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
2838efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
2839efe556adSCorentin Chary  echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
2840efe556adSCorentin Charyfi
2841821601eaSJes Sorensenif test "$vnc_thread" = "yes" ; then
2842bd023f95SCorentin Chary  echo "CONFIG_VNC_THREAD=y" >> $config_host_mak
2843bd023f95SCorentin Charyfi
284476655d6dSaliguoriif test "$fnmatch" = "yes" ; then
28452358a494SJuan Quintela  echo "CONFIG_FNMATCH=y" >> $config_host_mak
284676655d6dSaliguorifi
2847ee682d27SStefan Weilif test "$uuid" = "yes" ; then
2848ee682d27SStefan Weil  echo "CONFIG_UUID=y" >> $config_host_mak
2849ee682d27SStefan Weilfi
2850dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
2851dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
2852dce512deSChristoph Hellwigfi
2853b1a550a0Spbrookqemu_version=`head $source_path/VERSION`
285498ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
28552358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
285698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
285798ec69acSJuan Quintelaecho "TARGET_DIRS=$target_list" >> $config_host_mak
2858a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
285998ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
2860cc8ae6deSpbrookfi
28611ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
286298ec69acSJuan Quintela  echo "CONFIG_SDL=y" >> $config_host_mak
28638ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
286449ecc3faSbellardfi
286549ecc3faSbellardif test "$cocoa" = "yes" ; then
286698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
286749ecc3faSbellardfi
28684d3b6f6eSbalrogif test "$curses" = "yes" ; then
286998ec69acSJuan Quintela  echo "CONFIG_CURSES=y" >> $config_host_mak
2870ab4e5602SJan Kiszkafi
28713b3f24adSaurel32if test "$atfile" = "yes" ; then
28722358a494SJuan Quintela  echo "CONFIG_ATFILE=y" >> $config_host_mak
28733b3f24adSaurel32fi
2874ebc996f3SRiku Voipioif test "$utimens" = "yes" ; then
28752358a494SJuan Quintela  echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
2876ebc996f3SRiku Voipiofi
2877099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
28782358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
2879099d6b0fSRiku Voipiofi
288040ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
288140ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
288240ff6d7eSKevin Wolffi
28833ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
28842358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
28853ce34dfbSvibisreenivasanfi
2886c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
2887c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
2888c2882b96SRiku Voipiofi
2889d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
2890d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
2891d0927938SUlrich Hechtfi
2892c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
2893c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
2894c727f47dSPeter Maydellfi
2895dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
2896dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
2897dace20dcSPeter Maydellfi
2898d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
2899d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
2900d0927938SUlrich Hechtfi
29013b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
29023b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
29033b6edd16SPeter Maydellfi
29043b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
29053b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
29063b6edd16SPeter Maydellfi
29073b6edd16SPeter Maydellif test "$epoll_pwait" = "yes" ; then
29083b6edd16SPeter Maydell  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
29093b6edd16SPeter Maydellfi
29103b3f24adSaurel32if test "$inotify" = "yes" ; then
29112358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
29123b3f24adSaurel32fi
2913c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
2914c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
2915c05c7a73SRiku Voipiofi
29166ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
29176ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
29186ae9a1f4SJuan Quintelafi
29196ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
29206ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
29216ae9a1f4SJuan Quintelafi
2922769ce76dSAlexander Grafif test "$curl" = "yes" ; then
292398ec69acSJuan Quintela  echo "CONFIG_CURL=y" >> $config_host_mak
2924b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
2925769ce76dSAlexander Graffi
29262e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
292798ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
29282e4d9fb1Saurel32fi
2929fb599c9aSbalrogif test "$bluez" = "yes" ; then
293098ec69acSJuan Quintela  echo "CONFIG_BLUEZ=y" >> $config_host_mak
2931ef7635ecSJuan Quintela  echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
2932fb599c9aSbalrogfi
2933e37630caSaliguoriif test "$xen" = "yes" ; then
29345647eb74SJuan Quintela  echo "CONFIG_XEN=y" >> $config_host_mak
2935d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
2936e37630caSaliguorifi
2937e5d355d1Saliguoriif test "$io_thread" = "yes" ; then
293898ec69acSJuan Quintela  echo "CONFIG_IOTHREAD=y" >> $config_host_mak
2939e5d355d1Saliguorifi
29405c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
29415c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
29425c6c3a6cSChristoph Hellwigfi
2943758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
2944758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
2945758e8e38SVenkateswararao Jujjuri (JV)fi
2946758e8e38SVenkateswararao Jujjuri (JV)if test "$linux" = "yes" ; then
2947758e8e38SVenkateswararao Jujjuri (JV)  if test "$attr" = "yes" ; then
2948758e8e38SVenkateswararao Jujjuri (JV)    echo "CONFIG_VIRTFS=y" >> $config_host_mak
2949758e8e38SVenkateswararao Jujjuri (JV)  fi
2950758e8e38SVenkateswararao Jujjuri (JV)fi
295177755340Sthsif test "$blobs" = "yes" ; then
295298ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
295377755340Sthsfi
2954bf9298b9Saliguoriif test "$iovec" = "yes" ; then
29552358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
2956bf9298b9Saliguorifi
2957ceb42de8Saliguoriif test "$preadv" = "yes" ; then
29582358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
2959ceb42de8Saliguorifi
2960f652e6afSaurel32if test "$fdt" = "yes" ; then
29613f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
2962f652e6afSaurel32fi
2963dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
2964dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
2965dcc38d1cSMarcelo Tosattifi
2966de5071c5SBlue Swirlif test "$need_offsetof" = "yes" ; then
2967de5071c5SBlue Swirl  echo "CONFIG_NEED_OFFSETOF=y" >> $config_host_mak
2968de5071c5SBlue Swirlfi
2969747bbdf7SBlue Swirlif test "$gcc_attribute_warn_unused_result" = "yes" ; then
2970747bbdf7SBlue Swirl  echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak
2971747bbdf7SBlue Swirlfi
29725f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
29735f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
29745f6b9e8fSBlue Swirlfi
2975e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
2976e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
2977e78815a5SAndreas Färberfi
2978e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
2979e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
2980e78815a5SAndreas Färberfi
298197a847bcSbellard
2982cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
2983cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
2984cd4ec0b4SGerd Hoffmannfi
2985cd4ec0b4SGerd Hoffmann
298636707144SAlon Levyif test "$smartcard" = "yes" ; then
298736707144SAlon Levy  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
298836707144SAlon Levyfi
298936707144SAlon Levy
2990111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
2991111a38b0SRobert Relyea  echo "CONFIG_SMARTCARD_NSS=y" >> $config_host_mak
2992111a38b0SRobert Relyeafi
2993111a38b0SRobert Relyea
299420ff075bSMichael Walleif test "$opengl" = "yes" ; then
299520ff075bSMichael Walle  echo "CONFIG_OPENGL=y" >> $config_host_mak
299620ff075bSMichael Wallefi
299720ff075bSMichael Walle
299883fb7adfSbellard# XXX: suppress that
29997d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
30002358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
30017d3505c5Sbellardfi
30027d3505c5Sbellard
30032358a494SJuan Quintelaecho "CONFIG_UNAME_RELEASE=\"$uname_release\"" >> $config_host_mak
3004c5937220Spbrook
300520ff6c80SAnthony Liguoriif test "$zero_malloc" = "yes" ; then
300620ff6c80SAnthony Liguori  echo "CONFIG_ZERO_MALLOC=y" >> $config_host_mak
300720ff6c80SAnthony Liguorifi
3008f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
3009f27aaf4bSChristian Brunner  echo "CONFIG_RBD=y" >> $config_host_mak
3010f27aaf4bSChristian Brunnerfi
301120ff6c80SAnthony Liguori
301268063649Sblueswir1# USB host support
301368063649Sblueswir1case "$usb" in
301468063649Sblueswir1linux)
301598ec69acSJuan Quintela  echo "HOST_USB=linux" >> $config_host_mak
301668063649Sblueswir1;;
301768063649Sblueswir1bsd)
301898ec69acSJuan Quintela  echo "HOST_USB=bsd" >> $config_host_mak
301968063649Sblueswir1;;
302068063649Sblueswir1*)
302198ec69acSJuan Quintela  echo "HOST_USB=stub" >> $config_host_mak
302268063649Sblueswir1;;
302368063649Sblueswir1esac
302468063649Sblueswir1
302594a420b1SStefan Hajnocziecho "TRACE_BACKEND=$trace_backend" >> $config_host_mak
302622890ab5SPrerna Saxenaif test "$trace_backend" = "simple"; then
302722890ab5SPrerna Saxena  echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
302822890ab5SPrerna Saxenafi
30299410b56cSPrerna Saxena# Set the appropriate trace file.
30309410b56cSPrerna Saxenaif test "$trace_backend" = "simple"; then
30319410b56cSPrerna Saxena  trace_file="\"$trace_file-%u\""
30329410b56cSPrerna Saxenafi
3033c276b17dSDaniel P. Berrangeif test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
3034c276b17dSDaniel P. Berrange  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
3035c276b17dSDaniel P. Berrangefi
30369410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
30379410b56cSPrerna Saxena
303898ec69acSJuan Quintelaecho "TOOLS=$tools" >> $config_host_mak
303998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3040804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3041804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
3042804edf29SJuan Quintelaecho "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
3043804edf29SJuan Quintelaecho "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
3044804edf29SJuan Quintelaecho "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
3045804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
30462b2e59e6SPaolo Bonziniecho "CC_I386=$cc_i386" >> $config_host_mak
3047804edf29SJuan Quintelaecho "HOST_CC=$host_cc" >> $config_host_mak
3048804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3049804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3050804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
30519fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
3052e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
3053a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
3054f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
3055e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
3056e39f0062SPaolo Bonzini  echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
3057e39f0062SPaolo Bonzini  echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
3058e39f0062SPaolo Bonzini  echo "QEMU_CFLAGS  += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
3059e39f0062SPaolo Bonzinifi
3060c81da56eSJuan Quintelaecho "HELPER_CFLAGS=$helper_cflags" >> $config_host_mak
3061e2a2ed06SJuan Quintelaecho "LDFLAGS=$LDFLAGS" >> $config_host_mak
3062a36abbbbSJuan Quintelaecho "ARLIBS_BEGIN=$arlibs_begin" >> $config_host_mak
3063a36abbbbSJuan Quintelaecho "ARLIBS_END=$arlibs_end" >> $config_host_mak
306473da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
30653e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
3066804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3067804edf29SJuan Quintela
30684bf6b55bSJuan Quintela# generate list of library paths for linker script
30694bf6b55bSJuan Quintela
30704bf6b55bSJuan Quintela$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
30714bf6b55bSJuan Quintela
30724bf6b55bSJuan Quintelaif test -f ${config_host_ld}~ ; then
30734bf6b55bSJuan Quintela  if cmp -s $config_host_ld ${config_host_ld}~ ; then
30744bf6b55bSJuan Quintela    mv ${config_host_ld}~ $config_host_ld
30754bf6b55bSJuan Quintela  else
30764bf6b55bSJuan Quintela    rm ${config_host_ld}~
30774bf6b55bSJuan Quintela  fi
30784bf6b55bSJuan Quintelafi
30794bf6b55bSJuan Quintela
30804d904533SBlue Swirlfor d in libdis libdis-user; do
30814d904533SBlue Swirl    mkdir -p $d
308211568d6dSPaolo Bonzini    symlink $source_path/Makefile.dis $d/Makefile
30834d904533SBlue Swirl    echo > $d/config.mak
30844d904533SBlue Swirldone
3085d44cff22SRichard Hendersonif test "$static" = "no" -a "$user_pie" = "yes" ; then
3086d44cff22SRichard Henderson  echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
3087d44cff22SRichard Hendersonfi
30884d904533SBlue Swirl
308997a847bcSbellardfor target in $target_list; do
309097a847bcSbellardtarget_dir="$target"
309125be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
3092600309b6SBlue Swirltarget_arch2=`echo $target | cut -d '-' -f 1`
309397a847bcSbellardtarget_bigendian="no"
30941f3d3c8fSJuan Quintela
3095ea2d6a39SJuan Quintelacase "$target_arch2" in
3096613a22c9SMichael Walle  armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
3097ea2d6a39SJuan Quintela  target_bigendian=yes
3098ea2d6a39SJuan Quintela  ;;
3099ea2d6a39SJuan Quintelaesac
310097a847bcSbellardtarget_softmmu="no"
3101997344f3Sbellardtarget_user_only="no"
3102831b7825Sthstarget_linux_user="no"
3103831b7825Sthstarget_darwin_user="no"
310484778508Sblueswir1target_bsd_user="no"
31059e407a85Spbrookcase "$target" in
3106600309b6SBlue Swirl  ${target_arch2}-softmmu)
31079e407a85Spbrook    target_softmmu="yes"
31089e407a85Spbrook    ;;
3109600309b6SBlue Swirl  ${target_arch2}-linux-user)
31109c7a4202SBlue Swirl    if test "$linux" != "yes" ; then
31119c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Linux host"
31129c7a4202SBlue Swirl      exit 1
31139c7a4202SBlue Swirl    fi
31149e407a85Spbrook    target_user_only="yes"
31159e407a85Spbrook    target_linux_user="yes"
31169e407a85Spbrook    ;;
3117600309b6SBlue Swirl  ${target_arch2}-darwin-user)
31189c7a4202SBlue Swirl    if test "$darwin" != "yes" ; then
31199c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a Darwin host"
31209c7a4202SBlue Swirl      exit 1
31219c7a4202SBlue Swirl    fi
31229e407a85Spbrook    target_user_only="yes"
3123831b7825Sths    target_darwin_user="yes"
31249e407a85Spbrook    ;;
3125600309b6SBlue Swirl  ${target_arch2}-bsd-user)
31269cf55765SBlue Swirl    if test "$bsd" != "yes" ; then
31279c7a4202SBlue Swirl      echo "ERROR: Target '$target' is only available on a BSD host"
31289c7a4202SBlue Swirl      exit 1
31299c7a4202SBlue Swirl    fi
313084778508Sblueswir1    target_user_only="yes"
313184778508Sblueswir1    target_bsd_user="yes"
313284778508Sblueswir1    ;;
31339e407a85Spbrook  *)
31349e407a85Spbrook    echo "ERROR: Target '$target' not recognised"
31359e407a85Spbrook    exit 1
31369e407a85Spbrook    ;;
31379e407a85Spbrookesac
3138831b7825Sths
313997a847bcSbellardmkdir -p $target_dir
3140158142c2Sbellardmkdir -p $target_dir/fpu
314157fec1feSbellardmkdir -p $target_dir/tcg
314259f2a787SGerd Hoffmannmkdir -p $target_dir/ide
3143353ac78dSAneesh Kumar K.Vmkdir -p $target_dir/9pfs
314484778508Sblueswir1if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
314569de927cSbellard  mkdir -p $target_dir/nwfpe
314669de927cSbellardfi
314711568d6dSPaolo Bonzinisymlink $source_path/Makefile.target $target_dir/Makefile
3148ec530c81Sbellard
314997a847bcSbellard
315025be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
315197a847bcSbellard
3152e5fe0c52Spbrookbflt="no"
3153bd0c5661Spbrooktarget_nptl="no"
3154600309b6SBlue Swirlinterp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_arch2/g"`
31557ee2822cSPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
315656aebc89Spbrookgdb_xml_files=""
3157c2e3dee6SLaurent Viviertarget_short_alignment=2
3158c2e3dee6SLaurent Viviertarget_int_alignment=4
3159c2e3dee6SLaurent Viviertarget_long_alignment=4
3160c2e3dee6SLaurent Viviertarget_llong_alignment=8
3161de3a354aSMichael Walletarget_libs_softmmu=
31627ba1e619Saliguori
3163938b1eddSJuan QuintelaTARGET_ARCH="$target_arch2"
31646acff7daSJuan QuintelaTARGET_BASE_ARCH=""
3165e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
3166e73aae67SJuan Quintela
3167600309b6SBlue Swirlcase "$target_arch2" in
31682408a527Saurel32  i386)
316971deff27SAurelien Jarno    target_phys_bits=64
31702408a527Saurel32  ;;
31712408a527Saurel32  x86_64)
31726acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
31731ad2134fSPaul Brook    target_phys_bits=64
3174c2e3dee6SLaurent Vivier    target_long_alignment=8
31752408a527Saurel32  ;;
31762408a527Saurel32  alpha)
31771ad2134fSPaul Brook    target_phys_bits=64
3178c2e3dee6SLaurent Vivier    target_long_alignment=8
3179a4b388ffSRichard Henderson    target_nptl="yes"
31802408a527Saurel32  ;;
31812408a527Saurel32  arm|armeb)
3182b498c8a0SJuan Quintela    TARGET_ARCH=arm
3183e5fe0c52Spbrook    bflt="yes"
3184bd0c5661Spbrook    target_nptl="yes"
318556aebc89Spbrook    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
31861ad2134fSPaul Brook    target_phys_bits=32
3187c2e3dee6SLaurent Vivier    target_llong_alignment=4
31882408a527Saurel32  ;;
31892408a527Saurel32  cris)
3190253bd7f8Sedgar_igl    target_nptl="yes"
31911ad2134fSPaul Brook    target_phys_bits=32
31922408a527Saurel32  ;;
3193613a22c9SMichael Walle  lm32)
3194613a22c9SMichael Walle    target_phys_bits=32
3195de3a354aSMichael Walle    target_libs_softmmu="$opengl_libs"
3196613a22c9SMichael Walle  ;;
31972408a527Saurel32  m68k)
31980938cda5Saurel32    bflt="yes"
319956aebc89Spbrook    gdb_xml_files="cf-core.xml cf-fp.xml"
32001ad2134fSPaul Brook    target_phys_bits=32
3201c2e3dee6SLaurent Vivier    target_int_alignment=2
3202c2e3dee6SLaurent Vivier    target_long_alignment=2
3203c2e3dee6SLaurent Vivier    target_llong_alignment=2
32042408a527Saurel32  ;;
3205877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
3206877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
320772b675caSEdgar E. Iglesias    bflt="yes"
320872b675caSEdgar E. Iglesias    target_nptl="yes"
320972b675caSEdgar E. Iglesias    target_phys_bits=32
3210de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
321172b675caSEdgar E. Iglesias  ;;
32122408a527Saurel32  mips|mipsel)
3213b498c8a0SJuan Quintela    TARGET_ARCH=mips
321425be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
3215f04dc72fSPaul Brook    target_nptl="yes"
32161ad2134fSPaul Brook    target_phys_bits=64
32172408a527Saurel32  ;;
32182408a527Saurel32  mipsn32|mipsn32el)
3219b498c8a0SJuan Quintela    TARGET_ARCH=mipsn32
32206acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
322125be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
32221ad2134fSPaul Brook    target_phys_bits=64
32232408a527Saurel32  ;;
32242408a527Saurel32  mips64|mips64el)
3225b498c8a0SJuan Quintela    TARGET_ARCH=mips64
32266acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
322725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
32281ad2134fSPaul Brook    target_phys_bits=64
3229c2e3dee6SLaurent Vivier    target_long_alignment=8
32302408a527Saurel32  ;;
32312408a527Saurel32  ppc)
3232c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32331ad2134fSPaul Brook    target_phys_bits=32
3234d6630708SNathan Froyd    target_nptl="yes"
3235de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32362408a527Saurel32  ;;
32372408a527Saurel32  ppcemb)
32386acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3239e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3240c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32411ad2134fSPaul Brook    target_phys_bits=64
3242d6630708SNathan Froyd    target_nptl="yes"
3243de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32442408a527Saurel32  ;;
32452408a527Saurel32  ppc64)
32466acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3247e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
3248c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32491ad2134fSPaul Brook    target_phys_bits=64
3250c2e3dee6SLaurent Vivier    target_long_alignment=8
3251de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32522408a527Saurel32  ;;
32532408a527Saurel32  ppc64abi32)
3254b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
32556acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
3256e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
325725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
3258c8b3532dSaurel32    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
32591ad2134fSPaul Brook    target_phys_bits=64
3260de3a354aSMichael Walle    target_libs_softmmu="$fdt_libs"
32612408a527Saurel32  ;;
32622408a527Saurel32  sh4|sh4eb)
3263b498c8a0SJuan Quintela    TARGET_ARCH=sh4
32644dbed897Spbrook    bflt="yes"
32650b6d3ae0Saurel32    target_nptl="yes"
32661ad2134fSPaul Brook    target_phys_bits=32
32672408a527Saurel32  ;;
32682408a527Saurel32  sparc)
32691ad2134fSPaul Brook    target_phys_bits=64
32702408a527Saurel32  ;;
32712408a527Saurel32  sparc64)
32726acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
32731ad2134fSPaul Brook    target_phys_bits=64
3274c2e3dee6SLaurent Vivier    target_long_alignment=8
32752408a527Saurel32  ;;
32762408a527Saurel32  sparc32plus)
3277b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
32786acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
3279e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
328025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
32811ad2134fSPaul Brook    target_phys_bits=64
32822408a527Saurel32  ;;
328324e804ecSAlexander Graf  s390x)
3284bc434676SUlrich Hecht    target_nptl="yes"
328524e804ecSAlexander Graf    target_phys_bits=64
32867b3da903SAlexander Graf    target_long_alignment=8
328724e804ecSAlexander Graf  ;;
3288d2fbca94SGuan Xuetao  unicore32)
3289d2fbca94SGuan Xuetao    target_phys_bits=32
3290d2fbca94SGuan Xuetao  ;;
32912408a527Saurel32  *)
3292de83cd02Sbellard    echo "Unsupported target CPU"
3293de83cd02Sbellard    exit 1
32942408a527Saurel32  ;;
32952408a527Saurel32esac
3296c2e3dee6SLaurent Vivierecho "TARGET_SHORT_ALIGNMENT=$target_short_alignment" >> $config_target_mak
3297c2e3dee6SLaurent Vivierecho "TARGET_INT_ALIGNMENT=$target_int_alignment" >> $config_target_mak
3298c2e3dee6SLaurent Vivierecho "TARGET_LONG_ALIGNMENT=$target_long_alignment" >> $config_target_mak
3299c2e3dee6SLaurent Vivierecho "TARGET_LLONG_ALIGNMENT=$target_llong_alignment" >> $config_target_mak
330025be210fSJuan Quintelaecho "TARGET_ARCH=$TARGET_ARCH" >> $config_target_mak
3301053dd92eSJuan Quintelatarget_arch_name="`echo $TARGET_ARCH | tr '[:lower:]' '[:upper:]'`"
330225be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
330325be210fSJuan Quintelaecho "TARGET_ARCH2=$target_arch2" >> $config_target_mak
330442bc608bSJuan Quintela# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
33056acff7daSJuan Quintelaif [ "$TARGET_BASE_ARCH" = "" ]; then
33066acff7daSJuan Quintela  TARGET_BASE_ARCH=$TARGET_ARCH
33076acff7daSJuan Quintelafi
330825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
3309e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
3310e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
3311e6e91b9cSJuan Quintelafi
331225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
33131b0c87fcSJuan Quintelacase "$target_arch2" in
33141b0c87fcSJuan Quintela  i386|x86_64)
33151b0c87fcSJuan Quintela    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
331664b3cfdbSAnthony PERARD      target_phys_bits=64
331725be210fSJuan Quintela      echo "CONFIG_XEN=y" >> $config_target_mak
3318432d268cSJun Nakajima      if test "$cpu" = "i386" -o "$cpu" = "x86_64"; then
3319432d268cSJun Nakajima          echo "CONFIG_XEN_MAPCACHE=y" >> $config_target_mak
3320432d268cSJun Nakajima      fi
33211b0c87fcSJuan Quintela    fi
33221b0c87fcSJuan Quintelaesac
3323c59249f9SJuan Quintelacase "$target_arch2" in
33240e60a699SAlexander Graf  i386|x86_64|ppcemb|ppc|ppc64|s390x)
3325c59249f9SJuan Quintela    # Make sure the target and host cpus are compatible
3326c59249f9SJuan Quintela    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
3327c59249f9SJuan Quintela      \( "$target_arch2" = "$cpu" -o \
3328c59249f9SJuan Quintela      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc" \) -o \
33295f114bc6SAlexander Graf      \( "$target_arch2" = "ppc64"  -a "$cpu" = "ppc" \) -o \
3330adf82011SRené Rebe      \( "$target_arch2" = "ppc"    -a "$cpu" = "ppc64" \) -o \
3331adf82011SRené Rebe      \( "$target_arch2" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
3332c59249f9SJuan Quintela      \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
3333c59249f9SJuan Quintela      \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
333425be210fSJuan Quintela      echo "CONFIG_KVM=y" >> $config_target_mak
333525be210fSJuan Quintela      echo "KVM_CFLAGS=$kvm_cflags" >> $config_target_mak
3336dae5079aSJan Kiszka      if test "$kvm_para" = "yes"; then
3337dae5079aSJan Kiszka        echo "CONFIG_KVM_PARA=y" >> $config_target_mak
3338dae5079aSJan Kiszka      fi
3339d5970055SMichael S. Tsirkin      if test $vhost_net = "yes" ; then
3340d5970055SMichael S. Tsirkin        echo "CONFIG_VHOST_NET=y" >> $config_target_mak
3341d5970055SMichael S. Tsirkin      fi
3342*7dd31902SAurelien Jarno      if test "$kvm_ppc_pvr" = "yes" ; then
334364e07be5SAlexander Graf        echo "CONFIG_KVM_PPC_PVR=y" >> $config_target_mak
334464e07be5SAlexander Graf      fi
3345c59249f9SJuan Quintela    fi
3346c59249f9SJuan Quintelaesac
3347de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
334825be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
334997a847bcSbellardfi
335097a847bcSbellardif test "$target_softmmu" = "yes" ; then
3351b1aa27c4SPaul Brook  echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak
335225be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
3353de3a354aSMichael Walle  echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak
33540e8c9214SAndreas Färber  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
33555791f45bSKirill A. Shutemov  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
3356de83cd02Sbellardfi
3357997344f3Sbellardif test "$target_user_only" = "yes" ; then
335825be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
3359997344f3Sbellardfi
3360831b7825Sthsif test "$target_linux_user" = "yes" ; then
336125be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
3362831b7825Sthsfi
3363831b7825Sthsif test "$target_darwin_user" = "yes" ; then
336425be210fSJuan Quintela  echo "CONFIG_DARWIN_USER=y" >> $config_target_mak
3365831b7825Sthsfi
3366111a38b0SRobert Relyeaif test "$smartcard_nss" = "yes" ; then
3367111a38b0SRobert Relyea  echo "subdir-$target: subdir-libcacard" >> $config_host_mak
3368111a38b0SRobert Relyea  echo "libcacard_libs=$libcacard_libs" >> $config_host_mak
3369111a38b0SRobert Relyea  echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak
3370111a38b0SRobert Relyeafi
337156aebc89Spbrooklist=""
337256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
337356aebc89Spbrook  for x in $gdb_xml_files; do
337456aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
337556aebc89Spbrook  done
337625be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
33773d0f1517SJuan Quintelafi
3378de83cd02Sbellard
3379eb8f7776SAurelien Jarnoecho "CONFIG_SOFTFLOAT=y" >> $config_target_mak
3380f57975fbSJuan Quintela
3381e5fe0c52Spbrookif test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
338225be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
3383e5fe0c52Spbrookfi
3384bd0c5661Spbrookif test "$target_user_only" = "yes" \
3385bd0c5661Spbrook        -a "$nptl" = "yes" -a "$target_nptl" = "yes"; then
338625be210fSJuan Quintela  echo "CONFIG_USE_NPTL=y" >> $config_target_mak
3387bd0c5661Spbrookfi
3388379f6698SPaul Brookif test "$target_user_only" = "yes" -a "$guest_base" = "yes"; then
338925be210fSJuan Quintela  echo "CONFIG_USE_GUEST_BASE=y" >> $config_target_mak
3390379f6698SPaul Brookfi
339184778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
339225be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
339384778508Sblueswir1fi
33945b0753e0Sbellard
33954afddb55SJuan Quintela# generate QEMU_CFLAGS/LDFLAGS for targets
3396fa282484SJuan Quintela
33974afddb55SJuan Quintelacflags=""
3398f9728943SPaolo Bonziniincludes=""
3399fa282484SJuan Quintelaldflags=""
34009b8e111fSJuan Quintela
340157ddfbf7SJuan Quintelaif test "$ARCH" = "sparc64" ; then
3402f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/sparc $includes"
340324e804ecSAlexander Grafelif test "$ARCH" = "s390x" ; then
3404f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/s390 $includes"
34055d8a4f8fSRichard Hendersonelif test "$ARCH" = "x86_64" ; then
3406f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/i386 $includes"
340757ddfbf7SJuan Quintelaelse
3408f9728943SPaolo Bonzini  includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes"
340957ddfbf7SJuan Quintelafi
3410f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/tcg $includes"
3411f9728943SPaolo Bonziniincludes="-I\$(SRC_PATH)/fpu $includes"
341257ddfbf7SJuan Quintela
34134d904533SBlue Swirlif test "$target_user_only" = "yes" ; then
34144d904533SBlue Swirl    libdis_config_mak=libdis-user/config.mak
34154d904533SBlue Swirlelse
34164d904533SBlue Swirl    libdis_config_mak=libdis/config.mak
34174d904533SBlue Swirlfi
34184d904533SBlue Swirl
341964656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
342064656024SJuan Quintela  case "$i" in
342164656024SJuan Quintela  alpha)
342225be210fSJuan Quintela    echo "CONFIG_ALPHA_DIS=y"  >> $config_target_mak
34234d904533SBlue Swirl    echo "CONFIG_ALPHA_DIS=y"  >> $libdis_config_mak
342464656024SJuan Quintela  ;;
342564656024SJuan Quintela  arm)
342625be210fSJuan Quintela    echo "CONFIG_ARM_DIS=y"  >> $config_target_mak
34274d904533SBlue Swirl    echo "CONFIG_ARM_DIS=y"  >> $libdis_config_mak
342864656024SJuan Quintela  ;;
342964656024SJuan Quintela  cris)
343025be210fSJuan Quintela    echo "CONFIG_CRIS_DIS=y"  >> $config_target_mak
34314d904533SBlue Swirl    echo "CONFIG_CRIS_DIS=y"  >> $libdis_config_mak
343264656024SJuan Quintela  ;;
343364656024SJuan Quintela  hppa)
343425be210fSJuan Quintela    echo "CONFIG_HPPA_DIS=y"  >> $config_target_mak
34354d904533SBlue Swirl    echo "CONFIG_HPPA_DIS=y"  >> $libdis_config_mak
343664656024SJuan Quintela  ;;
343764656024SJuan Quintela  i386|x86_64)
343825be210fSJuan Quintela    echo "CONFIG_I386_DIS=y"  >> $config_target_mak
34394d904533SBlue Swirl    echo "CONFIG_I386_DIS=y"  >> $libdis_config_mak
344064656024SJuan Quintela  ;;
3441903ec55cSAurelien Jarno  ia64*)
3442903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $config_target_mak
3443903ec55cSAurelien Jarno    echo "CONFIG_IA64_DIS=y"  >> $libdis_config_mak
3444903ec55cSAurelien Jarno  ;;
344564656024SJuan Quintela  m68k)
344625be210fSJuan Quintela    echo "CONFIG_M68K_DIS=y"  >> $config_target_mak
34474d904533SBlue Swirl    echo "CONFIG_M68K_DIS=y"  >> $libdis_config_mak
344864656024SJuan Quintela  ;;
3449877fdc12SEdgar E. Iglesias  microblaze*)
345025be210fSJuan Quintela    echo "CONFIG_MICROBLAZE_DIS=y"  >> $config_target_mak
34514d904533SBlue Swirl    echo "CONFIG_MICROBLAZE_DIS=y"  >> $libdis_config_mak
345264656024SJuan Quintela  ;;
345364656024SJuan Quintela  mips*)
345425be210fSJuan Quintela    echo "CONFIG_MIPS_DIS=y"  >> $config_target_mak
34554d904533SBlue Swirl    echo "CONFIG_MIPS_DIS=y"  >> $libdis_config_mak
345664656024SJuan Quintela  ;;
345764656024SJuan Quintela  ppc*)
345825be210fSJuan Quintela    echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
34594d904533SBlue Swirl    echo "CONFIG_PPC_DIS=y"  >> $libdis_config_mak
346064656024SJuan Quintela  ;;
346124e804ecSAlexander Graf  s390*)
346225be210fSJuan Quintela    echo "CONFIG_S390_DIS=y"  >> $config_target_mak
34634d904533SBlue Swirl    echo "CONFIG_S390_DIS=y"  >> $libdis_config_mak
346464656024SJuan Quintela  ;;
346564656024SJuan Quintela  sh4)
346625be210fSJuan Quintela    echo "CONFIG_SH4_DIS=y"  >> $config_target_mak
34674d904533SBlue Swirl    echo "CONFIG_SH4_DIS=y"  >> $libdis_config_mak
346864656024SJuan Quintela  ;;
346964656024SJuan Quintela  sparc*)
347025be210fSJuan Quintela    echo "CONFIG_SPARC_DIS=y"  >> $config_target_mak
34714d904533SBlue Swirl    echo "CONFIG_SPARC_DIS=y"  >> $libdis_config_mak
347264656024SJuan Quintela  ;;
347364656024SJuan Quintela  esac
347464656024SJuan Quinteladone
347564656024SJuan Quintela
34766ee7126fSJuan Quintelacase "$ARCH" in
34776ee7126fSJuan Quintelaalpha)
34786ee7126fSJuan Quintela  # Ensure there's only a single GP
34796ee7126fSJuan Quintela  cflags="-msmall-data $cflags"
34806ee7126fSJuan Quintela;;
34816ee7126fSJuan Quintelaesac
34826ee7126fSJuan Quintela
348355d9c04bSJuan Quintelaif test "$target_softmmu" = "yes" ; then
348455d9c04bSJuan Quintela  case "$TARGET_BASE_ARCH" in
348555d9c04bSJuan Quintela  arm)
348655d9c04bSJuan Quintela    cflags="-DHAS_AUDIO $cflags"
348755d9c04bSJuan Quintela  ;;
348825a8bb96SMichael Walle  lm32)
348925a8bb96SMichael Walle    cflags="-DHAS_AUDIO $cflags"
349025a8bb96SMichael Walle  ;;
349155d9c04bSJuan Quintela  i386|mips|ppc)
349255d9c04bSJuan Quintela    cflags="-DHAS_AUDIO -DHAS_AUDIO_CHOICE $cflags"
349355d9c04bSJuan Quintela  ;;
349455d9c04bSJuan Quintela  esac
349555d9c04bSJuan Quintelafi
349655d9c04bSJuan Quintela
349734005a00SKirill A. Shutemovif test "$target_user_only" = "yes" -a "$static" = "no" -a \
349834005a00SKirill A. Shutemov	"$user_pie" = "yes" ; then
349934005a00SKirill A. Shutemov  cflags="-fpie $cflags"
350034005a00SKirill A. Shutemov  ldflags="-pie $ldflags"
350134005a00SKirill A. Shutemovfi
350234005a00SKirill A. Shutemov
3503471857ddSJuan Quintelaif test "$target_softmmu" = "yes" -a \( \
3504471857ddSJuan Quintela        "$TARGET_ARCH" = "microblaze" -o \
3505471857ddSJuan Quintela        "$TARGET_ARCH" = "cris" \) ; then
350625be210fSJuan Quintela  echo "CONFIG_NEED_MMU=y" >> $config_target_mak
3507471857ddSJuan Quintelafi
3508471857ddSJuan Quintela
3509d02c1db3SJuan Quintelaif test "$gprof" = "yes" ; then
351025be210fSJuan Quintela  echo "TARGET_GPROF=yes" >> $config_target_mak
3511d02c1db3SJuan Quintela  if test "$target_linux_user" = "yes" ; then
3512d02c1db3SJuan Quintela    cflags="-p $cflags"
3513d02c1db3SJuan Quintela    ldflags="-p $ldflags"
3514d02c1db3SJuan Quintela  fi
3515d02c1db3SJuan Quintela  if test "$target_softmmu" = "yes" ; then
3516d02c1db3SJuan Quintela    ldflags="-p $ldflags"
351725be210fSJuan Quintela    echo "GPROF_CFLAGS=-p" >> $config_target_mak
3518d02c1db3SJuan Quintela  fi
3519d02c1db3SJuan Quintelafi
3520d02c1db3SJuan Quintela
35216ee7126fSJuan Quintelalinker_script="-Wl,-T../config-host.ld -Wl,-T,\$(SRC_PATH)/\$(ARCH).ld"
35229b8e111fSJuan Quintelaif test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
3523fa282484SJuan Quintela  case "$ARCH" in
3524fa282484SJuan Quintela  sparc)
3525fa282484SJuan Quintela    # -static is used to avoid g1/g3 usage by the dynamic linker
3526322e5878SJuan Quintela    ldflags="$linker_script -static $ldflags"
3527fa282484SJuan Quintela    ;;
35284d58be06SRichard Henderson  alpha | s390x)
35294d58be06SRichard Henderson    # The default placement of the application is fine.
35304d58be06SRichard Henderson    ;;
3531fd76e73aSRichard Henderson  *)
3532322e5878SJuan Quintela    ldflags="$linker_script $ldflags"
3533fa282484SJuan Quintela    ;;
3534fa282484SJuan Quintela  esac
3535fa282484SJuan Quintelafi
3536fa282484SJuan Quintela
353725be210fSJuan Quintelaecho "LDFLAGS+=$ldflags" >> $config_target_mak
353825be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
3539f9728943SPaolo Bonziniecho "QEMU_INCLUDES+=$includes" >> $config_target_mak
3540fa282484SJuan Quintela
354197a847bcSbellarddone # for target in $targets
35427d13299dSbellard
3543d1807a4fSPaolo Bonzini# build tree in object directory in case the source is not in the current directory
3544e1144d00SMark McLoughlinDIRS="tests tests/cris slirp audio block net pc-bios/optionrom"
3545446b9165SAndreas FärberDIRS="$DIRS pc-bios/spapr-rtas"
35462d9f27d2SAnthony LiguoriDIRS="$DIRS roms/seabios roms/vgabios"
35473e230dd2SCorentin CharyDIRS="$DIRS fsdev ui"
35487d13299dSbellardFILES="Makefile tests/Makefile"
3549e7daa605SthsFILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
3550ae0bfb79SBlue SwirlFILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
3551446b9165SAndreas FärberFILES="$FILES pc-bios/spapr-rtas/Makefile"
35522d9f27d2SAnthony LiguoriFILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
35535ee8ad71SAlex Williamsonfor bios_file in $source_path/pc-bios/*.bin $source_path/pc-bios/*.rom $source_path/pc-bios/*.dtb $source_path/pc-bios/openbios-*; do
35547ea78b74SJan Kiszka    FILES="$FILES pc-bios/`basename $bios_file`"
35557ea78b74SJan Kiszkadone
3556d1807a4fSPaolo Bonzinimkdir -p $DIRS
35577d13299dSbellardfor f in $FILES ; do
3558eae30c8fSAurelien Jarno    test -e $f || symlink $source_path/$f $f
35597d13299dSbellarddone
35601ad2134fSPaul Brook
3561c34ebfdcSAnthony Liguori# temporary config to build submodules
35622d9f27d2SAnthony Liguorifor rom in seabios vgabios ; do
3563c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
356437116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3565c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3566c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3567c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
3568c34ebfdcSAnthony Liguori    echo "CPP=${cross_prefix}cpp" >> $config_mak
3569c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3570c34ebfdcSAnthony Liguori    echo "IASL=iasl" >> $config_mak
3571c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
3572c34ebfdcSAnthony Liguoridone
3573c34ebfdcSAnthony Liguori
35741ad2134fSPaul Brookfor hwlib in 32 64; do
35751ad2134fSPaul Brook  d=libhw$hwlib
35761ad2134fSPaul Brook  mkdir -p $d
35779953b2fcSBlue Swirl  mkdir -p $d/ide
357811568d6dSPaolo Bonzini  symlink $source_path/Makefile.hw $d/Makefile
3579353ac78dSAneesh Kumar K.V  mkdir -p $d/9pfs
358037116c89SStefan Weil  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak
35811ad2134fSPaul Brookdone
3582add16157SBlue Swirl
3583111a38b0SRobert Relyeaif [ "$source_path" != `pwd` ]; then
3584111a38b0SRobert Relyea    # out of tree build
3585111a38b0SRobert Relyea    mkdir -p libcacard
3586111a38b0SRobert Relyea    rm -f libcacard/Makefile
3587111a38b0SRobert Relyea    ln -s "$source_path/libcacard/Makefile" libcacard/Makefile
3588111a38b0SRobert Relyeafi
3589111a38b0SRobert Relyea
3590add16157SBlue Swirld=libuser
3591add16157SBlue Swirlmkdir -p $d
359211568d6dSPaolo Bonzinisymlink $source_path/Makefile.user $d/Makefile
3593299060a0SKirill A. Shutemovif test "$static" = "no" -a "$user_pie" = "yes" ; then
3594299060a0SKirill A. Shutemov  echo "QEMU_CFLAGS+=-fpie" > $d/config.mak
3595299060a0SKirill A. Shutemovfi
3596b40292e7SJan Kiszka
3597b40292e7SJan Kiszkaif test "$docs" = "yes" ; then
3598b40292e7SJan Kiszka  mkdir -p QMP
3599b40292e7SJan Kiszkafi
3600