]> git.proxmox.com Git - mirror_qemu.git/blame - configure
pc-bios/s390-ccw.img: rebuild image
[mirror_qemu.git] / configure
CommitLineData
7d13299d
FB
1#!/bin/sh
2#
3ef693a0 3# qemu configure script (c) 2003 Fabrice Bellard
7d13299d 4#
8cd05ab6 5
99519e67
CH
6# Unset some variables known to interfere with behavior of common tools,
7# just as autoconf does.
8CLICOLOR_FORCE= GREP_OPTIONS=
9unset CLICOLOR_FORCE GREP_OPTIONS
10
5e4dfd3d
JS
11# Don't allow CCACHE, if present, to use cached results of compile tests!
12export CCACHE_RECACHE=yes
13
8cd05ab6
PM
14# Temporary directory used for files created while
15# configure runs. Since it is in the build directory
16# we can safely blow away any previous version of it
17# (and we need not jump through hoops to try to delete
18# it when configure exits.)
19TMPDIR1="config-temp"
20rm -rf "${TMPDIR1}"
21mkdir -p "${TMPDIR1}"
22if [ $? -ne 0 ]; then
23 echo "ERROR: failed to create temporary directory"
24 exit 1
7d13299d
FB
25fi
26
8cd05ab6
PM
27TMPB="qemu-conf"
28TMPC="${TMPDIR1}/${TMPB}.c"
66518bf6 29TMPO="${TMPDIR1}/${TMPB}.o"
9c83ffd8 30TMPCXX="${TMPDIR1}/${TMPB}.cxx"
8cd05ab6 31TMPE="${TMPDIR1}/${TMPB}.exe"
6969ec6c 32TMPMO="${TMPDIR1}/${TMPB}.mo"
7d13299d 33
da1d85e3 34rm -f config.log
9ac81bbb 35
b48e3611
PM
36# Print a helpful header at the top of config.log
37echo "# QEMU configure log $(date)" >> config.log
979ae168
PM
38printf "# Configured with:" >> config.log
39printf " '%s'" "$0" "$@" >> config.log
40echo >> config.log
b48e3611
PM
41echo "#" >> config.log
42
76ad07a4
PM
43error_exit() {
44 echo
45 echo "ERROR: $1"
46 while test -n "$2"; do
47 echo " $2"
48 shift
49 done
50 echo
51 exit 1
52}
53
9c83ffd8
PM
54do_compiler() {
55 # Run the compiler, capturing its output to the log. First argument
56 # is compiler binary to execute.
57 local compiler="$1"
58 shift
59 echo $compiler "$@" >> config.log
60 $compiler "$@" >> config.log 2>&1 || return $?
8dc38a78
PM
61 # Test passed. If this is an --enable-werror build, rerun
62 # the test with -Werror and bail out if it fails. This
63 # makes warning-generating-errors in configure test code
64 # obvious to developers.
65 if test "$werror" != "yes"; then
66 return 0
67 fi
68 # Don't bother rerunning the compile if we were already using -Werror
69 case "$*" in
70 *-Werror*)
71 return 0
72 ;;
73 esac
9c83ffd8
PM
74 echo $compiler -Werror "$@" >> config.log
75 $compiler -Werror "$@" >> config.log 2>&1 && return $?
76ad07a4
PM
76 error_exit "configure test passed without -Werror but failed with -Werror." \
77 "This is probably a bug in the configure script. The failing command" \
78 "will be at the bottom of config.log." \
79 "You can run configure with --disable-werror to bypass this check."
8dc38a78
PM
80}
81
9c83ffd8
PM
82do_cc() {
83 do_compiler "$cc" "$@"
84}
85
86do_cxx() {
87 do_compiler "$cxx" "$@"
88}
89
90update_cxxflags() {
91 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
92 # options which some versions of GCC's C++ compiler complain about
93 # because they only make sense for C programs.
94 QEMU_CXXFLAGS=
95 for arg in $QEMU_CFLAGS; do
96 case $arg in
97 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
98 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
99 ;;
100 *)
101 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
102 ;;
103 esac
104 done
105}
106
52166aa0 107compile_object() {
fd0e6053
JS
108 local_cflags="$1"
109 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
52166aa0
JQ
110}
111
112compile_prog() {
113 local_cflags="$1"
114 local_ldflags="$2"
8dc38a78 115 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
52166aa0
JQ
116}
117
11568d6d
PB
118# symbolically link $1 to $2. Portable version of "ln -sf".
119symlink() {
72b8b5a1 120 rm -rf "$2"
ec5b06d7 121 mkdir -p "$(dirname "$2")"
72b8b5a1 122 ln -s "$1" "$2"
11568d6d
PB
123}
124
0dba6195
LM
125# check whether a command is available to this shell (may be either an
126# executable or a builtin)
127has() {
128 type "$1" >/dev/null 2>&1
129}
130
131# search for an executable in PATH
132path_of() {
133 local_command="$1"
134 local_ifs="$IFS"
135 local_dir=""
136
137 # pathname has a dir component?
138 if [ "${local_command#*/}" != "$local_command" ]; then
139 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
140 echo "$local_command"
141 return 0
142 fi
143 fi
144 if [ -z "$local_command" ]; then
145 return 1
146 fi
147
148 IFS=:
149 for local_dir in $PATH; do
150 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
151 echo "$local_dir/$local_command"
152 IFS="${local_ifs:-$(printf ' \t\n')}"
153 return 0
154 fi
155 done
156 # not found
157 IFS="${local_ifs:-$(printf ' \t\n')}"
158 return 1
159}
160
5b808275
LV
161have_backend () {
162 echo "$trace_backends" | grep "$1" >/dev/null
163}
164
7d13299d 165# default parameters
89138857 166source_path=$(dirname "$0")
2ff6b91e 167cpu=""
a31a8642 168iasl="iasl"
1e43adfc 169interp_prefix="/usr/gnemul/qemu-%M"
43ce4dfe 170static="no"
7d13299d 171cross_prefix=""
0c58ac1c 172audio_drv_list=""
b64ec4e4
FZ
173block_drv_rw_whitelist=""
174block_drv_ro_whitelist=""
e49d021e 175host_cc="cc"
73da375e 176libs_softmmu=""
3e2e0e6b 177libs_tools=""
67f86e8e 178audio_pt_int=""
d5631638 179audio_win_int=""
2b2e59e6 180cc_i386=i386-pc-linux-gnu-gcc
957f1f99 181libs_qga=""
5bc62e01 182debug_info="yes"
63678e17 183stack_protector=""
ac0df51d 184
afb63ebd
SW
185# Don't accept a target_list environment variable.
186unset target_list
377529c0
PB
187
188# Default value for a variable defining feature "foo".
189# * foo="no" feature will only be used if --enable-foo arg is given
190# * foo="" feature will be searched for, and if found, will be used
191# unless --disable-foo is given
192# * foo="yes" this value will only be set by --enable-foo flag.
193# feature will searched for,
194# if not found, configure exits with error
195#
196# Always add --enable-foo and --disable-foo command line args.
197# Distributions want to ensure that several features are compiled in, and it
198# is impossible without a --enable-foo that exits if a feature is not found.
199
200bluez=""
201brlapi=""
202curl=""
203curses=""
204docs=""
205fdt=""
58952137 206netmap="no"
e2134eb9 207pixman=""
377529c0 208sdl=""
ee8466d0 209sdlabi=""
983eef5a 210virtfs=""
821601ea 211vnc="yes"
377529c0 212sparse="no"
377529c0 213vde=""
377529c0
PB
214vnc_sasl=""
215vnc_jpeg=""
216vnc_png=""
377529c0 217xen=""
d5b93ddf 218xen_ctrl_version=""
64a7ad6f 219xen_pv_domain_build="no"
eb6fda0f 220xen_pci_passthrough=""
377529c0 221linux_aio=""
47e98658 222cap_ng=""
377529c0 223attr=""
4f26f2b6 224libattr=""
377529c0
PB
225xfs=""
226
d41a75a2 227vhost_net="no"
5e9be92d 228vhost_scsi="no"
fc0b9b0e 229vhost_vsock="no"
d41a75a2 230kvm="no"
b0cb0a66 231hax="no"
2da776db 232rdma=""
377529c0
PB
233gprof="no"
234debug_tcg="no"
377529c0 235debug="no"
b553a042 236fortify_source=""
377529c0 237strip_opt="yes"
9195b2c2 238tcg_interpreter="no"
377529c0
PB
239bigendian="no"
240mingw32="no"
1d728c39
BS
241gcov="no"
242gcov_tool="gcov"
377529c0 243EXESUF=""
17969268
FZ
244DSOSUF=".so"
245LDFLAGS_SHARED="-shared"
246modules="no"
377529c0
PB
247prefix="/usr/local"
248mandir="\${prefix}/share/man"
528ae5b8 249datadir="\${prefix}/share"
850da188 250qemu_docdir="\${prefix}/share/doc/qemu"
377529c0 251bindir="\${prefix}/bin"
3aa5d2be 252libdir="\${prefix}/lib"
8bf188aa 253libexecdir="\${prefix}/libexec"
0f94d6da 254includedir="\${prefix}/include"
377529c0 255sysconfdir="\${prefix}/etc"
785c23ae 256local_statedir="\${prefix}/var"
377529c0
PB
257confsuffix="/qemu"
258slirp="yes"
377529c0
PB
259oss_lib=""
260bsd="no"
261linux="no"
262solaris="no"
263profiler="no"
264cocoa="no"
265softmmu="yes"
266linux_user="no"
377529c0 267bsd_user="no"
377529c0
PB
268aix="no"
269blobs="yes"
270pkgversion=""
40d6444e 271pie=""
3556c233 272qom_cast_debug="yes"
baf86d6b 273trace_backends="log"
377529c0
PB
274trace_file="trace"
275spice=""
276rbd=""
7b02f544 277smartcard=""
2b2325ff 278libusb=""
69354a83 279usb_redir=""
da076ffe 280opengl=""
014cb152 281opengl_dmabuf="no"
99f2dbd3 282avx2_opt="no"
1ece9905 283zlib="yes"
b25c9dff
SW
284lzo=""
285snappy=""
6b383c08 286bzip2=""
e8ef31a3 287guest_agent=""
d9840e25 288guest_agent_with_vss="no"
50cbebb9 289guest_agent_ntddscsi="no"
9dacf32d 290guest_agent_msi=""
d9840e25
TS
291vss_win32_sdk=""
292win_sdk="no"
4b1c11fd 293want_tools="yes"
c589b249 294libiscsi=""
6542aa9c 295libnfs=""
519175a2 296coroutine=""
70c60c08 297coroutine_pool=""
7d992e4d 298debug_stack_usage="no"
f794573e 299seccomp=""
eb100396 300glusterfs=""
d85fa9eb 301glusterfs_xlator_opt="no"
0c14fb47 302glusterfs_discard="no"
7c815372 303glusterfs_zerofill="no"
a4ccabcf 304gtk=""
9e04c683 305gtkabi=""
925a0400 306gtk_gl="no"
a1c5e949 307tls_priority="NORMAL"
ddbb0d09 308gnutls=""
b917da4c 309gnutls_rnd=""
91bfcdb0 310nettle=""
fff2f982 311nettle_kdf="no"
91bfcdb0 312gcrypt=""
1f923c70 313gcrypt_hmac="no"
37788f25 314gcrypt_kdf="no"
bbbf9bfb 315vte=""
9d9e1521 316virglrenderer=""
e91c793c 317tpm="yes"
0a12ec87 318libssh2=""
a99d57bb 319numa=""
2847b469 320tcmalloc="no"
7b01cb97 321jemalloc="no"
a6b1d4c0 322replication="yes"
da92c3ff 323vxhs=""
377529c0 324
898be3e0
PM
325supported_cpu="no"
326supported_os="no"
fb59dabd 327bogus_os="no"
898be3e0 328
ac0df51d
AL
329# parse CC options first
330for opt do
89138857 331 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
ac0df51d
AL
332 case "$opt" in
333 --cross-prefix=*) cross_prefix="$optarg"
334 ;;
3d8df640 335 --cc=*) CC="$optarg"
ac0df51d 336 ;;
83f73fce
TS
337 --cxx=*) CXX="$optarg"
338 ;;
ca4deeb1
PB
339 --source-path=*) source_path="$optarg"
340 ;;
2ff6b91e
JQ
341 --cpu=*) cpu="$optarg"
342 ;;
de385287 343 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
f9943cd5 344 EXTRA_CFLAGS="$optarg"
e2a2ed06 345 ;;
a4969e90 346 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
f9943cd5 347 EXTRA_LDFLAGS="$optarg"
e2a2ed06 348 ;;
5bc62e01
GH
349 --enable-debug-info) debug_info="yes"
350 ;;
351 --disable-debug-info) debug_info="no"
352 ;;
ac0df51d
AL
353 esac
354done
ac0df51d
AL
355# OS specific
356# Using uname is really, really broken. Once we have the right set of checks
93148aa5 357# we can eliminate its usage altogether.
ac0df51d 358
e49d021e
PM
359# Preferred compiler:
360# ${CC} (if set)
361# ${cross_prefix}gcc (if cross-prefix specified)
362# system compiler
363if test -z "${CC}${cross_prefix}"; then
364 cc="$host_cc"
365else
366 cc="${CC-${cross_prefix}gcc}"
367fi
368
83f73fce
TS
369if test -z "${CXX}${cross_prefix}"; then
370 cxx="c++"
371else
372 cxx="${CXX-${cross_prefix}g++}"
373fi
374
b3198cc2 375ar="${AR-${cross_prefix}ar}"
cdbd727c 376as="${AS-${cross_prefix}as}"
5f6f0e27 377ccas="${CCAS-$cc}"
3dd46c78 378cpp="${CPP-$cc -E}"
b3198cc2
SY
379objcopy="${OBJCOPY-${cross_prefix}objcopy}"
380ld="${LD-${cross_prefix}ld}"
4852ee95 381nm="${NM-${cross_prefix}nm}"
b3198cc2
SY
382strip="${STRIP-${cross_prefix}strip}"
383windres="${WINDRES-${cross_prefix}windres}"
17884d7b
ST
384pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
385query_pkg_config() {
386 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
387}
388pkg_config=query_pkg_config
b3198cc2 389sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
47c03744 390sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
ac0df51d 391
45d285ab
PM
392# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
393ARFLAGS="${ARFLAGS-rv}"
394
be17dc90 395# default flags for all hosts
2d31515b
PM
396# We use -fwrapv to tell the compiler that we require a C dialect where
397# left shift of signed integers is well defined and has the expected
398# 2s-complement style results. (Both clang and gcc agree that it
399# provides these semantics.)
400QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
f9188227 401QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
c95e3080 402QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
be17dc90 403QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
6b4c305c 404QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/include"
5bc62e01
GH
405if test "$debug_info" = "yes"; then
406 CFLAGS="-g $CFLAGS"
407 LDFLAGS="-g $LDFLAGS"
408fi
be17dc90 409
ca4deeb1 410# make source path absolute
89138857 411source_path=$(cd "$source_path"; pwd)
ca4deeb1 412
cab00a5a
MT
413# running configure in the source tree?
414# we know that's the case if configure is there.
415if test -f "./configure"; then
416 pwd_is_source_path="y"
417else
418 pwd_is_source_path="n"
419fi
420
ac0df51d
AL
421check_define() {
422cat > $TMPC <<EOF
423#if !defined($1)
fd786e1a 424#error $1 not defined
ac0df51d
AL
425#endif
426int main(void) { return 0; }
427EOF
52166aa0 428 compile_object
ac0df51d
AL
429}
430
307119e7
GH
431check_include() {
432cat > $TMPC <<EOF
433#include <$1>
434int main(void) { return 0; }
435EOF
436 compile_object
437}
438
93b25869
JS
439write_c_skeleton() {
440 cat > $TMPC <<EOF
441int main(void) { return 0; }
442EOF
443}
444
bbea4050
PM
445if check_define __linux__ ; then
446 targetos="Linux"
447elif check_define _WIN32 ; then
448 targetos='MINGW32'
449elif check_define __OpenBSD__ ; then
450 targetos='OpenBSD'
451elif check_define __sun__ ; then
452 targetos='SunOS'
453elif check_define __HAIKU__ ; then
454 targetos='Haiku'
455else
89138857 456 targetos=$(uname -s)
bbea4050
PM
457fi
458
459# Some host OSes need non-standard checks for which CPU to use.
460# Note that these checks are broken for cross-compilation: if you're
461# cross-compiling to one of these OSes then you'll need to specify
462# the correct CPU with the --cpu option.
463case $targetos in
464Darwin)
465 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
466 # run 64-bit userspace code.
467 # If the user didn't specify a CPU explicitly and the kernel says this is
468 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
469 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
470 cpu="x86_64"
471 fi
472 ;;
473SunOS)
89138857 474 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
bbea4050
PM
475 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
476 cpu="x86_64"
477 fi
478esac
479
2ff6b91e
JQ
480if test ! -z "$cpu" ; then
481 # command line argument
482 :
483elif check_define __i386__ ; then
ac0df51d
AL
484 cpu="i386"
485elif check_define __x86_64__ ; then
c72b26ec
RH
486 if check_define __ILP32__ ; then
487 cpu="x32"
488 else
489 cpu="x86_64"
490 fi
3aa9bd6c 491elif check_define __sparc__ ; then
3aa9bd6c
BS
492 if check_define __arch64__ ; then
493 cpu="sparc64"
494 else
495 cpu="sparc"
496 fi
fdf7ed96 497elif check_define _ARCH_PPC ; then
498 if check_define _ARCH_PPC64 ; then
499 cpu="ppc64"
500 else
501 cpu="ppc"
502 fi
afa05235
AJ
503elif check_define __mips__ ; then
504 cpu="mips"
477ba620
AJ
505elif check_define __ia64__ ; then
506 cpu="ia64"
d66ed0ea
AJ
507elif check_define __s390__ ; then
508 if check_define __s390x__ ; then
509 cpu="s390x"
510 else
511 cpu="s390"
512 fi
21d89f84
PM
513elif check_define __arm__ ; then
514 cpu="arm"
1f080313
CF
515elif check_define __aarch64__ ; then
516 cpu="aarch64"
ac0df51d 517else
89138857 518 cpu=$(uname -m)
ac0df51d
AL
519fi
520
359bc95d
PM
521ARCH=
522# Normalise host CPU name and set ARCH.
523# Note that this case should only have supported host CPUs, not guests.
7d13299d 524case "$cpu" in
6499fd15 525 ppc|ppc64|s390|s390x|sparc64|x32)
898be3e0
PM
526 cpu="$cpu"
527 supported_cpu="yes"
528 ;;
6499fd15 529 ia64)
ea8f20f8
JQ
530 cpu="$cpu"
531 ;;
7d13299d 532 i386|i486|i586|i686|i86pc|BePC)
97a847bc 533 cpu="i386"
898be3e0 534 supported_cpu="yes"
7d13299d 535 ;;
aaa5fa14
AJ
536 x86_64|amd64)
537 cpu="x86_64"
898be3e0 538 supported_cpu="yes"
aaa5fa14 539 ;;
21d89f84
PM
540 armv*b|armv*l|arm)
541 cpu="arm"
898be3e0 542 supported_cpu="yes"
7d13299d 543 ;;
1f080313
CF
544 aarch64)
545 cpu="aarch64"
898be3e0 546 supported_cpu="yes"
1f080313 547 ;;
afa05235
AJ
548 mips*)
549 cpu="mips"
898be3e0 550 supported_cpu="yes"
afa05235 551 ;;
3142255c 552 sparc|sun4[cdmuv])
ae228531 553 cpu="sparc"
6499fd15 554 supported_cpu="yes"
ae228531 555 ;;
7d13299d 556 *)
359bc95d
PM
557 # This will result in either an error or falling back to TCI later
558 ARCH=unknown
7d13299d
FB
559 ;;
560esac
359bc95d
PM
561if test -z "$ARCH"; then
562 ARCH="$cpu"
563fi
e2d52ad3 564
7d13299d 565# OS specific
0dbfc675 566
adfc3e91
SS
567# host *BSD for user mode
568HOST_VARIANT_DIR=""
569
7d13299d 570case $targetos in
67b915a5 571MINGW32*)
0dbfc675 572 mingw32="yes"
b0cb0a66 573 hax="yes"
3cec7cc2 574 audio_possible_drivers="dsound sdl"
307119e7
GH
575 if check_include dsound.h; then
576 audio_drv_list="dsound"
577 else
578 audio_drv_list=""
579 fi
898be3e0 580 supported_os="yes"
67b915a5 581;;
5c40d2bd 582GNU/kFreeBSD)
a167ba50 583 bsd="yes"
0dbfc675 584 audio_drv_list="oss"
0bac1111 585 audio_possible_drivers="oss sdl pa"
5c40d2bd 586;;
7d3505c5 587FreeBSD)
0dbfc675 588 bsd="yes"
0db4a067 589 make="${MAKE-gmake}"
0dbfc675 590 audio_drv_list="oss"
0bac1111 591 audio_possible_drivers="oss sdl pa"
f01576f1
JL
592 # needed for kinfo_getvmmap(3) in libutil.h
593 LIBS="-lutil $LIBS"
a7764f15
EM
594 # needed for kinfo_getproc
595 libs_qga="-lutil $libs_qga"
58952137 596 netmap="" # enable netmap autodetect
adfc3e91 597 HOST_VARIANT_DIR="freebsd"
898be3e0 598 supported_os="yes"
7d3505c5 599;;
c5e97233 600DragonFly)
0dbfc675 601 bsd="yes"
0db4a067 602 make="${MAKE-gmake}"
0dbfc675 603 audio_drv_list="oss"
0bac1111 604 audio_possible_drivers="oss sdl pa"
adfc3e91 605 HOST_VARIANT_DIR="dragonfly"
c5e97233 606;;
7d3505c5 607NetBSD)
0dbfc675 608 bsd="yes"
0db4a067 609 make="${MAKE-gmake}"
0dbfc675 610 audio_drv_list="oss"
0bac1111 611 audio_possible_drivers="oss sdl"
0dbfc675 612 oss_lib="-lossaudio"
adfc3e91 613 HOST_VARIANT_DIR="netbsd"
3c2bdbc1 614 supported_os="yes"
7d3505c5
FB
615;;
616OpenBSD)
0dbfc675 617 bsd="yes"
0db4a067 618 make="${MAKE-gmake}"
4f6ab397 619 audio_drv_list="sdl"
0bac1111 620 audio_possible_drivers="sdl"
adfc3e91 621 HOST_VARIANT_DIR="openbsd"
7d3505c5 622;;
83fb7adf 623Darwin)
0dbfc675
JQ
624 bsd="yes"
625 darwin="yes"
b0cb0a66 626 hax="yes"
17969268 627 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
0dbfc675 628 if [ "$cpu" = "x86_64" ] ; then
a558ee17 629 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
0c439cbf 630 LDFLAGS="-arch x86_64 $LDFLAGS"
0dbfc675 631 fi
0dbfc675
JQ
632 cocoa="yes"
633 audio_drv_list="coreaudio"
14382605 634 audio_possible_drivers="coreaudio sdl"
0dbfc675 635 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
7973f21c 636 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
a0b7cf6b
PM
637 # Disable attempts to use ObjectiveC features in os/object.h since they
638 # won't work when we're compiling with gcc as a C compiler.
639 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
adfc3e91 640 HOST_VARIANT_DIR="darwin"
898be3e0 641 supported_os="yes"
83fb7adf 642;;
ec530c81 643SunOS)
0dbfc675 644 solaris="yes"
0db4a067
PB
645 make="${MAKE-gmake}"
646 install="${INSTALL-ginstall}"
fa58948d 647 ld="gld"
e2d8830e 648 smbd="${SMBD-/usr/sfw/sbin/smbd}"
0dbfc675 649 needs_libsunmath="no"
89138857 650 solarisrev=$(uname -r | cut -f2 -d.)
0dbfc675
JQ
651 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
652 if test "$solarisrev" -le 9 ; then
653 if test -f /opt/SUNWspro/prod/lib/libsunmath.so.1; then
654 needs_libsunmath="yes"
f14bfdf9
JQ
655 QEMU_CFLAGS="-I/opt/SUNWspro/prod/include/cc $QEMU_CFLAGS"
656 LDFLAGS="-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib $LDFLAGS"
657 LIBS="-lsunmath $LIBS"
0dbfc675 658 else
76ad07a4
PM
659 error_exit "QEMU will not link correctly on Solaris 8/X86 or 9/x86 without" \
660 "libsunmath from the Sun Studio compilers tools, due to a lack of" \
661 "C99 math features in libm.so in Solaris 8/x86 and Solaris 9/x86" \
662 "Studio 11 can be downloaded from www.sun.com."
0dbfc675 663 fi
86b2bd93 664 fi
0dbfc675
JQ
665 fi
666 if test -f /usr/include/sys/soundcard.h ; then
667 audio_drv_list="oss"
668 fi
669 audio_possible_drivers="oss sdl"
d741429a
BS
670# needed for CMSG_ macros in sys/socket.h
671 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
672# needed for TIOCWIN* defines in termios.h
673 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
a558ee17 674 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
560d375f
AF
675 solarisnetlibs="-lsocket -lnsl -lresolv"
676 LIBS="$solarisnetlibs $LIBS"
677 libs_qga="$solarisnetlibs $libs_qga"
86b2bd93 678;;
b29fe3ed 679AIX)
0dbfc675 680 aix="yes"
0db4a067 681 make="${MAKE-gmake}"
b29fe3ed 682;;
179cf400
AF
683Haiku)
684 haiku="yes"
685 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
686 LIBS="-lposix_error_mapper -lnetwork $LIBS"
687;;
898be3e0 688Linux)
0dbfc675 689 audio_drv_list="oss"
0bac1111 690 audio_possible_drivers="oss alsa sdl pa"
0dbfc675
JQ
691 linux="yes"
692 linux_user="yes"
af2be207
JK
693 kvm="yes"
694 vhost_net="yes"
5e9be92d 695 vhost_scsi="yes"
fc0b9b0e 696 vhost_vsock="yes"
a585140d 697 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
898be3e0
PM
698 supported_os="yes"
699;;
700*)
fb59dabd
PM
701 # This is a fatal error, but don't report it yet, because we
702 # might be going to just print the --help text, or it might
703 # be the result of a missing compiler.
704 bogus_os="yes"
fb065187 705;;
7d13299d
FB
706esac
707
7d3505c5 708if [ "$bsd" = "yes" ] ; then
b1a550a0 709 if [ "$darwin" != "yes" ] ; then
08de3949 710 bsd_user="yes"
83fb7adf 711 fi
7d3505c5
FB
712fi
713
0db4a067
PB
714: ${make=${MAKE-make}}
715: ${install=${INSTALL-install}}
52510f8b 716: ${python=${PYTHON-python}}
e2d8830e 717: ${smbd=${SMBD-/usr/sbin/smbd}}
0db4a067 718
3c4a4d0d
PM
719# Default objcc to clang if available, otherwise use CC
720if has clang; then
721 objcc=clang
722else
723 objcc="$cc"
724fi
725
3457a3f8 726if test "$mingw32" = "yes" ; then
3457a3f8 727 EXESUF=".exe"
17969268 728 DSOSUF=".dll"
a558ee17 729 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
e94a7936
SW
730 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
731 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
78e9d4ad
SW
732 # MinGW needs -mthreads for TLS and macro _MT.
733 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
f7cf5d5b 734 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
93b25869 735 write_c_skeleton;
f7cf5d5b
SW
736 if compile_prog "" "-liberty" ; then
737 LIBS="-liberty $LIBS"
738 fi
c5ec15ea 739 prefix="c:/Program Files/QEMU"
683035de 740 mandir="\${prefix}"
528ae5b8 741 datadir="\${prefix}"
850da188 742 qemu_docdir="\${prefix}"
683035de
PB
743 bindir="\${prefix}"
744 sysconfdir="\${prefix}"
5a699bbb 745 local_statedir=
683035de 746 confsuffix=""
161a56a9 747 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -liphlpapi -lnetapi32 $libs_qga"
3457a3f8
JQ
748fi
749
487fefdb 750werror=""
85aa5189 751
7d13299d 752for opt do
89138857 753 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
7d13299d 754 case "$opt" in
2efc3265
FB
755 --help|-h) show_help=yes
756 ;;
99123e13
MF
757 --version|-V) exec cat $source_path/VERSION
758 ;;
b1a550a0 759 --prefix=*) prefix="$optarg"
7d13299d 760 ;;
b1a550a0 761 --interp-prefix=*) interp_prefix="$optarg"
32ce6337 762 ;;
ca4deeb1 763 --source-path=*)
7d13299d 764 ;;
ac0df51d 765 --cross-prefix=*)
7d13299d 766 ;;
ac0df51d 767 --cc=*)
7d13299d 768 ;;
b1a550a0 769 --host-cc=*) host_cc="$optarg"
83469015 770 ;;
83f73fce
TS
771 --cxx=*)
772 ;;
e007dbec
MT
773 --iasl=*) iasl="$optarg"
774 ;;
3c4a4d0d
PM
775 --objcc=*) objcc="$optarg"
776 ;;
b1a550a0 777 --make=*) make="$optarg"
7d13299d 778 ;;
6a882643
PB
779 --install=*) install="$optarg"
780 ;;
c886edfb
BS
781 --python=*) python="$optarg"
782 ;;
1d728c39
BS
783 --gcov=*) gcov_tool="$optarg"
784 ;;
e2d8830e
BS
785 --smbd=*) smbd="$optarg"
786 ;;
e2a2ed06 787 --extra-cflags=*)
7d13299d 788 ;;
e2a2ed06 789 --extra-ldflags=*)
7d13299d 790 ;;
5bc62e01
GH
791 --enable-debug-info)
792 ;;
793 --disable-debug-info)
794 ;;
17969268
FZ
795 --enable-modules)
796 modules="yes"
3aa88b31
SH
797 ;;
798 --disable-modules)
799 modules="no"
17969268 800 ;;
2ff6b91e 801 --cpu=*)
7d13299d 802 ;;
b1a550a0 803 --target-list=*) target_list="$optarg"
de83cd02 804 ;;
5b808275
LV
805 --enable-trace-backends=*) trace_backends="$optarg"
806 ;;
807 # XXX: backwards compatibility
808 --enable-trace-backend=*) trace_backends="$optarg"
94a420b1 809 ;;
74242e0f 810 --with-trace-file=*) trace_file="$optarg"
9410b56c 811 ;;
7d13299d
FB
812 --enable-gprof) gprof="yes"
813 ;;
1d728c39
BS
814 --enable-gcov) gcov="yes"
815 ;;
79427693
LM
816 --static)
817 static="yes"
818 LDFLAGS="-static $LDFLAGS"
17884d7b 819 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
43ce4dfe 820 ;;
0b24e75f
PB
821 --mandir=*) mandir="$optarg"
822 ;;
823 --bindir=*) bindir="$optarg"
824 ;;
3aa5d2be
AL
825 --libdir=*) libdir="$optarg"
826 ;;
8bf188aa
MT
827 --libexecdir=*) libexecdir="$optarg"
828 ;;
0f94d6da
AL
829 --includedir=*) includedir="$optarg"
830 ;;
528ae5b8 831 --datadir=*) datadir="$optarg"
0b24e75f 832 ;;
023d3d67
EH
833 --with-confsuffix=*) confsuffix="$optarg"
834 ;;
850da188 835 --docdir=*) qemu_docdir="$optarg"
0b24e75f 836 ;;
ca2fb938 837 --sysconfdir=*) sysconfdir="$optarg"
07381cc1 838 ;;
785c23ae
LC
839 --localstatedir=*) local_statedir="$optarg"
840 ;;
841 --sbindir=*|--sharedstatedir=*|\
023ddd74
MF
842 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
843 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
844 # These switches are silently ignored, for compatibility with
845 # autoconf-generated configure scripts. This allows QEMU's
846 # configure to be used by RPM and similar macros that set
847 # lots of directory switches by default.
848 ;;
e2134eb9
GH
849 --with-system-pixman) pixman="system"
850 ;;
851 --without-system-pixman) pixman="internal"
852 ;;
74880fe2
RS
853 --without-pixman) pixman="none"
854 ;;
97a847bc
FB
855 --disable-sdl) sdl="no"
856 ;;
c4198157
JQ
857 --enable-sdl) sdl="yes"
858 ;;
47c03744
DA
859 --with-sdlabi=*) sdlabi="$optarg"
860 ;;
3556c233
PB
861 --disable-qom-cast-debug) qom_cast_debug="no"
862 ;;
863 --enable-qom-cast-debug) qom_cast_debug="yes"
864 ;;
983eef5a
MI
865 --disable-virtfs) virtfs="no"
866 ;;
867 --enable-virtfs) virtfs="yes"
868 ;;
821601ea
JS
869 --disable-vnc) vnc="no"
870 ;;
871 --enable-vnc) vnc="yes"
872 ;;
2f6a1ab0
BS
873 --oss-lib=*) oss_lib="$optarg"
874 ;;
0c58ac1c 875 --audio-drv-list=*) audio_drv_list="$optarg"
102a52e4 876 ;;
89138857 877 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
b64ec4e4 878 ;;
89138857 879 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
eb852011 880 ;;
f8393946
AJ
881 --enable-debug-tcg) debug_tcg="yes"
882 ;;
883 --disable-debug-tcg) debug_tcg="no"
884 ;;
f3d08ee6
PB
885 --enable-debug)
886 # Enable debugging options that aren't excessively noisy
887 debug_tcg="yes"
888 debug="yes"
889 strip_opt="no"
b553a042 890 fortify_source="no"
f3d08ee6 891 ;;
03b4fe7d
AL
892 --enable-sparse) sparse="yes"
893 ;;
894 --disable-sparse) sparse="no"
895 ;;
1625af87
AL
896 --disable-strip) strip_opt="no"
897 ;;
2f9606b3
AL
898 --disable-vnc-sasl) vnc_sasl="no"
899 ;;
ea784e3b
JQ
900 --enable-vnc-sasl) vnc_sasl="yes"
901 ;;
2f6f5c7a
CC
902 --disable-vnc-jpeg) vnc_jpeg="no"
903 ;;
904 --enable-vnc-jpeg) vnc_jpeg="yes"
905 ;;
efe556ad
CC
906 --disable-vnc-png) vnc_png="no"
907 ;;
908 --enable-vnc-png) vnc_png="yes"
909 ;;
443f1376 910 --disable-slirp) slirp="no"
1d14ffa9 911 ;;
e0e6c8c0 912 --disable-vde) vde="no"
8a16d273 913 ;;
dfb278bd
JQ
914 --enable-vde) vde="yes"
915 ;;
58952137
VM
916 --disable-netmap) netmap="no"
917 ;;
918 --enable-netmap) netmap="yes"
919 ;;
e37630ca
AL
920 --disable-xen) xen="no"
921 ;;
fc321b4b
JQ
922 --enable-xen) xen="yes"
923 ;;
eb6fda0f
AP
924 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
925 ;;
926 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
927 ;;
64a7ad6f
IC
928 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
929 ;;
930 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
931 ;;
2e4d9fb1
AJ
932 --disable-brlapi) brlapi="no"
933 ;;
4ffcedb6
JQ
934 --enable-brlapi) brlapi="yes"
935 ;;
fb599c9a
AZ
936 --disable-bluez) bluez="no"
937 ;;
a20a6f46
JQ
938 --enable-bluez) bluez="yes"
939 ;;
7ba1e619
AL
940 --disable-kvm) kvm="no"
941 ;;
b31a0277
JQ
942 --enable-kvm) kvm="yes"
943 ;;
b0cb0a66 944 --disable-hax) hax="no"
180fb750 945 ;;
b0cb0a66 946 --enable-hax) hax="yes"
180fb750 947 ;;
9195b2c2
SW
948 --disable-tcg-interpreter) tcg_interpreter="no"
949 ;;
950 --enable-tcg-interpreter) tcg_interpreter="yes"
951 ;;
47e98658
CB
952 --disable-cap-ng) cap_ng="no"
953 ;;
954 --enable-cap-ng) cap_ng="yes"
955 ;;
cd4ec0b4
GH
956 --disable-spice) spice="no"
957 ;;
958 --enable-spice) spice="yes"
959 ;;
c589b249
RS
960 --disable-libiscsi) libiscsi="no"
961 ;;
962 --enable-libiscsi) libiscsi="yes"
963 ;;
6542aa9c
PL
964 --disable-libnfs) libnfs="no"
965 ;;
966 --enable-libnfs) libnfs="yes"
967 ;;
05c2a3e7
FB
968 --enable-profiler) profiler="yes"
969 ;;
14821030
PB
970 --disable-cocoa) cocoa="no"
971 ;;
c2de5c91 972 --enable-cocoa)
973 cocoa="yes" ;
89138857 974 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1d14ffa9 975 ;;
cad25d69 976 --disable-system) softmmu="no"
0a8e90f4 977 ;;
cad25d69 978 --enable-system) softmmu="yes"
0a8e90f4 979 ;;
0953a80f
ZA
980 --disable-user)
981 linux_user="no" ;
982 bsd_user="no" ;
0953a80f
ZA
983 ;;
984 --enable-user) ;;
831b7825 985 --disable-linux-user) linux_user="no"
0a8e90f4 986 ;;
831b7825
TS
987 --enable-linux-user) linux_user="yes"
988 ;;
84778508
BS
989 --disable-bsd-user) bsd_user="no"
990 ;;
991 --enable-bsd-user) bsd_user="yes"
992 ;;
40d6444e 993 --enable-pie) pie="yes"
34005a00 994 ;;
40d6444e 995 --disable-pie) pie="no"
34005a00 996 ;;
85aa5189
FB
997 --enable-werror) werror="yes"
998 ;;
999 --disable-werror) werror="no"
1000 ;;
63678e17
SN
1001 --enable-stack-protector) stack_protector="yes"
1002 ;;
1003 --disable-stack-protector) stack_protector="no"
1004 ;;
4d3b6f6e
AZ
1005 --disable-curses) curses="no"
1006 ;;
c584a6d0
JQ
1007 --enable-curses) curses="yes"
1008 ;;
769ce76d
AG
1009 --disable-curl) curl="no"
1010 ;;
788c8196
JQ
1011 --enable-curl) curl="yes"
1012 ;;
2df87df7
JQ
1013 --disable-fdt) fdt="no"
1014 ;;
1015 --enable-fdt) fdt="yes"
1016 ;;
5c6c3a6c
CH
1017 --disable-linux-aio) linux_aio="no"
1018 ;;
1019 --enable-linux-aio) linux_aio="yes"
1020 ;;
758e8e38
VJ
1021 --disable-attr) attr="no"
1022 ;;
1023 --enable-attr) attr="yes"
1024 ;;
77755340
TS
1025 --disable-blobs) blobs="no"
1026 ;;
4a19f1ec
PB
1027 --with-pkgversion=*) pkgversion=" ($optarg)"
1028 ;;
519175a2
AB
1029 --with-coroutine=*) coroutine="$optarg"
1030 ;;
70c60c08
SH
1031 --disable-coroutine-pool) coroutine_pool="no"
1032 ;;
1033 --enable-coroutine-pool) coroutine_pool="yes"
1034 ;;
7d992e4d
PL
1035 --enable-debug-stack-usage) debug_stack_usage="yes"
1036 ;;
a25dba17 1037 --disable-docs) docs="no"
70ec5dc0 1038 ;;
a25dba17 1039 --enable-docs) docs="yes"
83a3ab8b 1040 ;;
d5970055
MT
1041 --disable-vhost-net) vhost_net="no"
1042 ;;
1043 --enable-vhost-net) vhost_net="yes"
1044 ;;
5e9be92d
NB
1045 --disable-vhost-scsi) vhost_scsi="no"
1046 ;;
1047 --enable-vhost-scsi) vhost_scsi="yes"
1048 ;;
fc0b9b0e
SH
1049 --disable-vhost-vsock) vhost_vsock="no"
1050 ;;
1051 --enable-vhost-vsock) vhost_vsock="yes"
1052 ;;
da076ffe 1053 --disable-opengl) opengl="no"
20ff075b 1054 ;;
da076ffe 1055 --enable-opengl) opengl="yes"
20ff075b 1056 ;;
f27aaf4b
CB
1057 --disable-rbd) rbd="no"
1058 ;;
1059 --enable-rbd) rbd="yes"
1060 ;;
8c84cf11
ST
1061 --disable-xfsctl) xfs="no"
1062 ;;
1063 --enable-xfsctl) xfs="yes"
1064 ;;
7b02f544 1065 --disable-smartcard) smartcard="no"
111a38b0 1066 ;;
7b02f544 1067 --enable-smartcard) smartcard="yes"
111a38b0 1068 ;;
2b2325ff
GH
1069 --disable-libusb) libusb="no"
1070 ;;
1071 --enable-libusb) libusb="yes"
1072 ;;
69354a83
HG
1073 --disable-usb-redir) usb_redir="no"
1074 ;;
1075 --enable-usb-redir) usb_redir="yes"
1076 ;;
1ece9905
AL
1077 --disable-zlib-test) zlib="no"
1078 ;;
b25c9dff
SW
1079 --disable-lzo) lzo="no"
1080 ;;
607dacd0
QN
1081 --enable-lzo) lzo="yes"
1082 ;;
b25c9dff
SW
1083 --disable-snappy) snappy="no"
1084 ;;
607dacd0
QN
1085 --enable-snappy) snappy="yes"
1086 ;;
6b383c08
PW
1087 --disable-bzip2) bzip2="no"
1088 ;;
1089 --enable-bzip2) bzip2="yes"
1090 ;;
d138cee9
MR
1091 --enable-guest-agent) guest_agent="yes"
1092 ;;
1093 --disable-guest-agent) guest_agent="no"
1094 ;;
9dacf32d
YH
1095 --enable-guest-agent-msi) guest_agent_msi="yes"
1096 ;;
1097 --disable-guest-agent-msi) guest_agent_msi="no"
1098 ;;
d9840e25
TS
1099 --with-vss-sdk) vss_win32_sdk=""
1100 ;;
1101 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1102 ;;
1103 --without-vss-sdk) vss_win32_sdk="no"
1104 ;;
1105 --with-win-sdk) win_sdk=""
1106 ;;
1107 --with-win-sdk=*) win_sdk="$optarg"
1108 ;;
1109 --without-win-sdk) win_sdk="no"
1110 ;;
4b1c11fd
DB
1111 --enable-tools) want_tools="yes"
1112 ;;
1113 --disable-tools) want_tools="no"
1114 ;;
f794573e
EO
1115 --enable-seccomp) seccomp="yes"
1116 ;;
1117 --disable-seccomp) seccomp="no"
1118 ;;
eb100396
BR
1119 --disable-glusterfs) glusterfs="no"
1120 ;;
1121 --enable-glusterfs) glusterfs="yes"
1122 ;;
52b53c04
FZ
1123 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1124 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
583f6e7b 1125 ;;
cb6414df
FZ
1126 --enable-vhdx|--disable-vhdx)
1127 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1128 ;;
315d3184
FZ
1129 --enable-uuid|--disable-uuid)
1130 echo "$0: $opt is obsolete, UUID support is always built" >&2
1131 ;;
a4ccabcf
AL
1132 --disable-gtk) gtk="no"
1133 ;;
1134 --enable-gtk) gtk="yes"
1135 ;;
a1c5e949
DB
1136 --tls-priority=*) tls_priority="$optarg"
1137 ;;
ddbb0d09
DB
1138 --disable-gnutls) gnutls="no"
1139 ;;
1140 --enable-gnutls) gnutls="yes"
1141 ;;
91bfcdb0
DB
1142 --disable-nettle) nettle="no"
1143 ;;
1144 --enable-nettle) nettle="yes"
1145 ;;
1146 --disable-gcrypt) gcrypt="no"
1147 ;;
1148 --enable-gcrypt) gcrypt="yes"
1149 ;;
2da776db
MH
1150 --enable-rdma) rdma="yes"
1151 ;;
1152 --disable-rdma) rdma="no"
1153 ;;
528de90a
DB
1154 --with-gtkabi=*) gtkabi="$optarg"
1155 ;;
bbbf9bfb
SW
1156 --disable-vte) vte="no"
1157 ;;
1158 --enable-vte) vte="yes"
1159 ;;
9d9e1521
GH
1160 --disable-virglrenderer) virglrenderer="no"
1161 ;;
1162 --enable-virglrenderer) virglrenderer="yes"
1163 ;;
e91c793c
CR
1164 --disable-tpm) tpm="no"
1165 ;;
ab214c29
SB
1166 --enable-tpm) tpm="yes"
1167 ;;
0a12ec87
RJ
1168 --disable-libssh2) libssh2="no"
1169 ;;
1170 --enable-libssh2) libssh2="yes"
1171 ;;
a99d57bb
WG
1172 --disable-numa) numa="no"
1173 ;;
1174 --enable-numa) numa="yes"
1175 ;;
2847b469
FZ
1176 --disable-tcmalloc) tcmalloc="no"
1177 ;;
1178 --enable-tcmalloc) tcmalloc="yes"
1179 ;;
7b01cb97
AD
1180 --disable-jemalloc) jemalloc="no"
1181 ;;
1182 --enable-jemalloc) jemalloc="yes"
1183 ;;
a6b1d4c0
CX
1184 --disable-replication) replication="no"
1185 ;;
1186 --enable-replication) replication="yes"
1187 ;;
da92c3ff
AM
1188 --disable-vxhs) vxhs="no"
1189 ;;
1190 --enable-vxhs) vxhs="yes"
1191 ;;
2d2ad6d0
FZ
1192 *)
1193 echo "ERROR: unknown option $opt"
1194 echo "Try '$0 --help' for more information"
1195 exit 1
7f1559c6 1196 ;;
7d13299d
FB
1197 esac
1198done
1199
40293e58 1200case "$cpu" in
e3608d66
RH
1201 ppc)
1202 CPU_CFLAGS="-m32"
1203 LDFLAGS="-m32 $LDFLAGS"
1204 ;;
1205 ppc64)
1206 CPU_CFLAGS="-m64"
1207 LDFLAGS="-m64 $LDFLAGS"
1208 ;;
9b9c37c3 1209 sparc)
ed968ff1 1210 LDFLAGS="-m32 $LDFLAGS"
79f3b12f 1211 CPU_CFLAGS="-m32 -mcpu=ultrasparc"
3142255c 1212 ;;
ed968ff1 1213 sparc64)
ed968ff1 1214 LDFLAGS="-m64 $LDFLAGS"
79f3b12f 1215 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
3142255c 1216 ;;
76d83bde 1217 s390)
061cdd81 1218 CPU_CFLAGS="-m31"
28d7cc49
RH
1219 LDFLAGS="-m31 $LDFLAGS"
1220 ;;
1221 s390x)
061cdd81 1222 CPU_CFLAGS="-m64"
28d7cc49 1223 LDFLAGS="-m64 $LDFLAGS"
76d83bde 1224 ;;
40293e58 1225 i386)
79f3b12f 1226 CPU_CFLAGS="-m32"
0c439cbf 1227 LDFLAGS="-m32 $LDFLAGS"
2b2e59e6 1228 cc_i386='$(CC) -m32'
40293e58
FB
1229 ;;
1230 x86_64)
7ebee43e
RH
1231 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1232 # If we truly care, we should simply detect this case at
1233 # runtime and generate the fallback to serial emulation.
1234 CPU_CFLAGS="-m64 -mcx16"
0c439cbf 1235 LDFLAGS="-m64 $LDFLAGS"
2b2e59e6 1236 cc_i386='$(CC) -m32'
d2fbca94 1237 ;;
c72b26ec
RH
1238 x32)
1239 CPU_CFLAGS="-mx32"
1240 LDFLAGS="-mx32 $LDFLAGS"
1241 cc_i386='$(CC) -m32'
1242 ;;
30163d89 1243 # No special flags required for other host CPUs
3142255c
BS
1244esac
1245
79f3b12f
PC
1246QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1247EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1248
affc88cc
PM
1249# For user-mode emulation the host arch has to be one we explicitly
1250# support, even if we're using TCI.
1251if [ "$ARCH" = "unknown" ]; then
1252 bsd_user="no"
1253 linux_user="no"
1254fi
1255
60e0df25
PM
1256default_target_list=""
1257
6e92f823
PM
1258mak_wilds=""
1259
1260if [ "$softmmu" = "yes" ]; then
1261 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
60e0df25 1262fi
6e92f823
PM
1263if [ "$linux_user" = "yes" ]; then
1264 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
60e0df25 1265fi
6e92f823
PM
1266if [ "$bsd_user" = "yes" ]; then
1267 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
60e0df25
PM
1268fi
1269
6e92f823
PM
1270for config in $mak_wilds; do
1271 default_target_list="${default_target_list} $(basename "$config" .mak)"
1272done
1273
c53eeaf7 1274# Enumerate public trace backends for --help output
64a6047d 1275trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
c53eeaf7 1276
af5db58e
PB
1277if test x"$show_help" = x"yes" ; then
1278cat << EOF
1279
1280Usage: configure [options]
1281Options: [defaults in brackets after descriptions]
1282
08fb77ed
SW
1283Standard options:
1284 --help print this message
1285 --prefix=PREFIX install in PREFIX [$prefix]
1286 --interp-prefix=PREFIX where to find shared libraries, etc.
1287 use %M for cpu name [$interp_prefix]
1288 --target-list=LIST set target list (default: build everything)
1289$(echo Available targets: $default_target_list | \
1290 fold -s -w 53 | sed -e 's/^/ /')
1291
1292Advanced options (experts only):
1293 --source-path=PATH path of source code [$source_path]
1294 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1295 --cc=CC use C compiler CC [$cc]
1296 --iasl=IASL use ACPI compiler IASL [$iasl]
1297 --host-cc=CC use C compiler CC [$host_cc] for code run at
1298 build time
1299 --cxx=CXX use C++ compiler CXX [$cxx]
1300 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1301 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1302 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1303 --make=MAKE use specified make [$make]
1304 --install=INSTALL use specified install [$install]
1305 --python=PYTHON use specified python [$python]
1306 --smbd=SMBD use specified smbd [$smbd]
1307 --static enable static build [$static]
1308 --mandir=PATH install man pages in PATH
1309 --datadir=PATH install firmware in PATH$confsuffix
1310 --docdir=PATH install documentation in PATH$confsuffix
1311 --bindir=PATH install binaries in PATH
1312 --libdir=PATH install libraries in PATH
1313 --sysconfdir=PATH install config in PATH$confsuffix
1314 --localstatedir=PATH install local state in PATH (set at runtime on win32)
e26110cf 1315 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
08fb77ed 1316 --enable-debug enable common debug build options
08fb77ed
SW
1317 --disable-strip disable stripping binaries
1318 --disable-werror disable compilation abort on warning
63678e17 1319 --disable-stack-protector disable compiler-provided stack protection
08fb77ed
SW
1320 --audio-drv-list=LIST set audio drivers list:
1321 Available drivers: $audio_possible_drivers
1322 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1323 --block-drv-rw-whitelist=L
1324 set block driver read-write whitelist
1325 (affects only QEMU, not qemu-img)
1326 --block-drv-ro-whitelist=L
1327 set block driver read-only whitelist
1328 (affects only QEMU, not qemu-img)
5b808275 1329 --enable-trace-backends=B Set trace backend
c53eeaf7 1330 Available backends: $trace_backend_list
08fb77ed
SW
1331 --with-trace-file=NAME Full PATH,NAME of file to store traces
1332 Default:trace-<pid>
c23f23b9
MT
1333 --disable-slirp disable SLIRP userspace network connectivity
1334 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1335 --oss-lib path to OSS library
1336 --cpu=CPU Build for host CPU [$cpu]
08fb77ed 1337 --with-coroutine=BACKEND coroutine backend. Supported options:
33c53c54 1338 ucontext, sigaltstack, windows
08fb77ed
SW
1339 --enable-gcov enable test coverage analysis with gcov
1340 --gcov=GCOV use specified gcov [$gcov_tool]
c23f23b9
MT
1341 --disable-blobs disable installing provided firmware blobs
1342 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1343 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
a1c5e949 1344 --tls-priority default TLS protocol/cipher priority string
c12d66aa
LM
1345 --enable-gprof QEMU profiling with gprof
1346 --enable-profiler profiler support
1347 --enable-xen-pv-domain-build
1348 xen pv domain builder
1349 --enable-debug-stack-usage
1350 track the maximum stack usage of stacks created by qemu_alloc_stack
c23f23b9
MT
1351
1352Optional features, enabled with --enable-FEATURE and
1353disabled with --disable-FEATURE, default is enabled if available:
1354
1355 system all system emulation targets
1356 user supported user emulation targets
1357 linux-user all linux usermode emulation targets
1358 bsd-user all BSD usermode emulation targets
c23f23b9
MT
1359 docs build documentation
1360 guest-agent build the QEMU Guest Agent
1361 guest-agent-msi build guest agent Windows MSI installation package
1362 pie Position Independent Executables
1363 modules modules support
1364 debug-tcg TCG debugging (default is disabled)
1365 debug-info debugging information
1366 sparse sparse checker
1367
ddbb0d09 1368 gnutls GNUTLS cryptography support
91bfcdb0
DB
1369 nettle nettle cryptography support
1370 gcrypt libgcrypt cryptography support
c23f23b9
MT
1371 sdl SDL UI
1372 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1373 gtk gtk UI
1374 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1375 vte vte support for the gtk UI
1376 curses curses UI
1377 vnc VNC UI support
c23f23b9
MT
1378 vnc-sasl SASL encryption for VNC server
1379 vnc-jpeg JPEG lossy compression for VNC server
1380 vnc-png PNG compression for VNC server
c23f23b9
MT
1381 cocoa Cocoa UI (Mac OS X only)
1382 virtfs VirtFS
1383 xen xen backend driver support
1384 xen-pci-passthrough
1385 brlapi BrlAPI (Braile)
1386 curl curl connectivity
1387 fdt fdt device tree
1388 bluez bluez stack connectivity
1389 kvm KVM acceleration support
b0cb0a66 1390 hax HAX acceleration support
c23f23b9 1391 rdma RDMA-based migration support
c23f23b9
MT
1392 vde support for vde network
1393 netmap support for netmap network
1394 linux-aio Linux AIO support
1395 cap-ng libcap-ng support
1396 attr attr and xattr support
1397 vhost-net vhost-net acceleration support
1398 spice spice
1399 rbd rados block device (rbd)
1400 libiscsi iscsi support
1401 libnfs nfs support
7b02f544 1402 smartcard smartcard support (libcacard)
c23f23b9
MT
1403 libusb libusb (for usb passthrough)
1404 usb-redir usb network redirection support
1405 lzo support of lzo compression library
1406 snappy support of snappy compression library
1407 bzip2 support of bzip2 compression library
1408 (for reading bzip2-compressed dmg images)
1409 seccomp seccomp support
1410 coroutine-pool coroutine freelist (better performance)
1411 glusterfs GlusterFS backend
c23f23b9
MT
1412 tpm TPM support
1413 libssh2 ssh block device support
c23f23b9
MT
1414 numa libnuma support
1415 tcmalloc tcmalloc support
7b01cb97 1416 jemalloc jemalloc support
a6b1d4c0 1417 replication replication support
c12d66aa
LM
1418 vhost-vsock virtio sockets device support
1419 opengl opengl support
1420 virglrenderer virgl rendering support
1421 xfsctl xfsctl support
1422 qom-cast-debug cast debugging support
1423 tools build qemu-io, qemu-nbd and qemu-image tools
da92c3ff 1424 vxhs Veritas HyperScale vDisk backend support
08fb77ed
SW
1425
1426NOTE: The object files are built at the place where configure is launched
af5db58e 1427EOF
2d2ad6d0 1428exit 0
af5db58e
PB
1429fi
1430
c53eeaf7
SH
1431if ! has $python; then
1432 error_exit "Python not found. Use --python=/path/to/python"
1433fi
1434
1435# Note that if the Python conditional here evaluates True we will exit
1436# with status 1 which is a shell 'false' value.
1437if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1438 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1439 "Note that Python 3 or later is not yet supported." \
1440 "Use --python=/path/to/python to specify a supported Python."
1441fi
1442
1443# Suppress writing compiled files
1444python="$python -B"
1445
359bc95d
PM
1446# Now we have handled --enable-tcg-interpreter and know we're not just
1447# printing the help message, bail out if the host CPU isn't supported.
1448if test "$ARCH" = "unknown"; then
1449 if test "$tcg_interpreter" = "yes" ; then
1450 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
359bc95d 1451 else
76ad07a4 1452 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
359bc95d
PM
1453 fi
1454fi
1455
9c83ffd8
PM
1456# Consult white-list to determine whether to enable werror
1457# by default. Only enable by default for git builds
9c83ffd8
PM
1458if test -z "$werror" ; then
1459 if test -d "$source_path/.git" -a \
e4650c81 1460 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
9c83ffd8
PM
1461 werror="yes"
1462 else
1463 werror="no"
1464 fi
1465fi
1466
8d05095c 1467# check that the C compiler works.
93b25869 1468write_c_skeleton;
8d05095c
PB
1469if compile_object ; then
1470 : C compiler works ok
1471else
76ad07a4 1472 error_exit "\"$cc\" either does not exist or does not work"
8d05095c 1473fi
0ef74c74
PM
1474if ! compile_prog ; then
1475 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1476fi
8d05095c 1477
fb59dabd
PM
1478if test "$bogus_os" = "yes"; then
1479 # Now that we know that we're not printing the help and that
1480 # the compiler works (so the results of the check_defines we used
1481 # to identify the OS are reliable), if we didn't recognize the
1482 # host OS we should stop now.
1483 error_exit "Unrecognized host OS $targetos"
1484fi
1485
98b21dcd
PM
1486# Check that the C++ compiler exists and works with the C compiler
1487if has $cxx; then
1488 cat > $TMPC <<EOF
1489int c_function(void);
1490int main(void) { return c_function(); }
1491EOF
1492
1493 compile_object
1494
9c83ffd8 1495 cat > $TMPCXX <<EOF
98b21dcd
PM
1496extern "C" {
1497 int c_function(void);
1498}
1499int c_function(void) { return 42; }
1500EOF
1501
9c83ffd8
PM
1502 update_cxxflags
1503
1504 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
98b21dcd
PM
1505 # C++ compiler $cxx works ok with C compiler $cc
1506 :
1507 else
1508 echo "C++ compiler $cxx does not work with C compiler $cc"
1509 echo "Disabling C++ specific optional code"
1510 cxx=
1511 fi
1512else
1513 echo "No C++ compiler available; disabling C++ specific optional code"
1514 cxx=
1515fi
1516
8d05095c
PB
1517gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1518gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
ac7568bd 1519gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
435405ac 1520gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
c1556a81 1521gcc_flags="-Wno-initializer-overrides $gcc_flags"
71429097 1522gcc_flags="-Wno-string-plus-int $gcc_flags"
6ca026cb
PM
1523# Note that we do not add -Werror to gcc_flags here, because that would
1524# enable it for all configure tests. If a configure test failed due
1525# to -Werror this would just silently disable some features,
1526# so it's too error prone.
93b25869
JS
1527
1528cc_has_warning_flag() {
1529 write_c_skeleton;
1530
a1d29d6c
PM
1531 # Use the positive sense of the flag when testing for -Wno-wombat
1532 # support (gcc will happily accept the -Wno- form of unknown
1533 # warning options).
93b25869
JS
1534 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1535 compile_prog "-Werror $optflag" ""
1536}
1537
1538for flag in $gcc_flags; do
1539 if cc_has_warning_flag $flag ; then
1540 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
8d05095c
PB
1541 fi
1542done
1543
3b463a3f 1544if test "$stack_protector" != "no"; then
fccd35a0
RR
1545 cat > $TMPC << EOF
1546int main(int argc, char *argv[])
1547{
1548 char arr[64], *p = arr, *c = argv[0];
1549 while (*c) {
1550 *p++ = *c++;
1551 }
1552 return 0;
1553}
1554EOF
63678e17 1555 gcc_flags="-fstack-protector-strong -fstack-protector-all"
3b463a3f 1556 sp_on=0
63678e17 1557 for flag in $gcc_flags; do
590e5dd9
PM
1558 # We need to check both a compile and a link, since some compiler
1559 # setups fail only on a .c->.o compile and some only at link time
1560 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1561 compile_prog "-Werror $flag" ""; then
63678e17 1562 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
3b463a3f 1563 sp_on=1
63678e17
SN
1564 break
1565 fi
1566 done
3b463a3f
MR
1567 if test "$stack_protector" = yes; then
1568 if test $sp_on = 0; then
1569 error_exit "Stack protector not supported"
1570 fi
1571 fi
37746c5e
MAL
1572fi
1573
cbdd1999
PB
1574# Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1575# large functions that use global variables. The bug is in all releases of
1576# GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1577# 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1578cat > $TMPC << EOF
1579#if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1580int main(void) { return 0; }
1581#else
1582#error No bug in this compiler.
1583#endif
1584EOF
1585if compile_prog "-Werror -fno-gcse" "" ; then
1586 TRANSLATE_OPT_CFLAGS=-fno-gcse
1587fi
1588
40d6444e 1589if test "$static" = "yes" ; then
aa0d1f44
PB
1590 if test "$modules" = "yes" ; then
1591 error_exit "static and modules are mutually incompatible"
1592 fi
40d6444e 1593 if test "$pie" = "yes" ; then
76ad07a4 1594 error_exit "static and pie are mutually incompatible"
40d6444e
AK
1595 else
1596 pie="no"
1597 fi
1598fi
1599
768b7855
EC
1600# Unconditional check for compiler __thread support
1601 cat > $TMPC << EOF
1602static __thread int tls_var;
1603int main(void) { return tls_var; }
1604EOF
1605
1606if ! compile_prog "-Werror" "" ; then
1607 error_exit "Your compiler does not support the __thread specifier for " \
1608 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1609fi
1610
40d6444e
AK
1611if test "$pie" = ""; then
1612 case "$cpu-$targetos" in
c72b26ec 1613 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
40d6444e
AK
1614 ;;
1615 *)
1616 pie="no"
1617 ;;
1618 esac
1619fi
1620
1621if test "$pie" != "no" ; then
1622 cat > $TMPC << EOF
21d4a791
AK
1623
1624#ifdef __linux__
1625# define THREAD __thread
1626#else
1627# define THREAD
1628#endif
1629
1630static THREAD int tls_var;
1631
1632int main(void) { return tls_var; }
1633
40d6444e
AK
1634EOF
1635 if compile_prog "-fPIE -DPIE" "-pie"; then
1636 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1637 LDFLAGS="-pie $LDFLAGS"
1638 pie="yes"
1639 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1640 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1641 fi
1642 else
1643 if test "$pie" = "yes"; then
76ad07a4 1644 error_exit "PIE not available due to missing toolchain support"
40d6444e
AK
1645 else
1646 echo "Disabling PIE due to missing toolchain support"
1647 pie="no"
1648 fi
1649 fi
46eef33b 1650
e4a7b344 1651 if compile_prog "-Werror -fno-pie" "-nopie"; then
46eef33b
BS
1652 CFLAGS_NOPIE="-fno-pie"
1653 LDFLAGS_NOPIE="-nopie"
1654 fi
40d6444e
AK
1655fi
1656
09dada40
PB
1657##########################################
1658# __sync_fetch_and_and requires at least -march=i486. Many toolchains
1659# use i686 as default anyway, but for those that don't, an explicit
1660# specification is necessary
1661
1662if test "$cpu" = "i386"; then
1663 cat > $TMPC << EOF
1664static int sfaa(int *ptr)
1665{
1666 return __sync_fetch_and_and(ptr, 0);
1667}
1668
1669int main(void)
1670{
1671 int val = 42;
1405b629 1672 val = __sync_val_compare_and_swap(&val, 0, 1);
09dada40
PB
1673 sfaa(&val);
1674 return val;
1675}
1676EOF
1677 if ! compile_prog "" "" ; then
1678 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1679 fi
1680fi
1681
1682#########################################
ec530c81 1683# Solaris specific configure tool chain decisions
09dada40 1684
ec530c81 1685if test "$solaris" = "yes" ; then
6792aa11
LM
1686 if has $install; then
1687 :
1688 else
76ad07a4
PM
1689 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1690 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1691 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
ec530c81 1692 fi
89138857 1693 if test "$(path_of $install)" = "/usr/sbin/install" ; then
76ad07a4
PM
1694 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1695 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1696 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
ec530c81 1697 fi
6792aa11
LM
1698 if has ar; then
1699 :
1700 else
ec530c81 1701 if test -f /usr/ccs/bin/ar ; then
76ad07a4
PM
1702 error_exit "No path includes ar" \
1703 "Add /usr/ccs/bin to your path and rerun configure"
ec530c81 1704 fi
76ad07a4 1705 error_exit "No path includes ar"
ec530c81 1706 fi
5fafdf24 1707fi
ec530c81 1708
afb63ebd 1709if test -z "${target_list+xxx}" ; then
121afa9e
AL
1710 target_list="$default_target_list"
1711else
89138857 1712 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
121afa9e 1713fi
25b48338
PM
1714
1715# Check that we recognised the target name; this allows a more
1716# friendly error message than if we let it fall through.
1717for target in $target_list; do
1718 case " $default_target_list " in
1719 *" $target "*)
1720 ;;
1721 *)
1722 error_exit "Unknown target name '$target'"
1723 ;;
1724 esac
1725done
1726
f55fe278
PB
1727# see if system emulation was really requested
1728case " $target_list " in
1729 *"-softmmu "*) softmmu=yes
1730 ;;
1731 *) softmmu=no
1732 ;;
1733esac
5327cf48 1734
249247c9
JQ
1735feature_not_found() {
1736 feature=$1
21684af0 1737 remedy=$2
249247c9 1738
76ad07a4 1739 error_exit "User requested feature $feature" \
21684af0
SS
1740 "configure was not able to find it." \
1741 "$remedy"
249247c9
JQ
1742}
1743
7d13299d
FB
1744# ---
1745# big/little endian test
1746cat > $TMPC << EOF
61cc919f
MF
1747short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1748short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1749extern int foo(short *, short *);
1750int main(int argc, char *argv[]) {
1751 return foo(big_endian, little_endian);
7d13299d
FB
1752}
1753EOF
1754
61cc919f
MF
1755if compile_object ; then
1756 if grep -q BiGeNdIaN $TMPO ; then
1757 bigendian="yes"
1758 elif grep -q LiTtLeEnDiAn $TMPO ; then
1759 bigendian="no"
1760 else
1761 echo big/little test failed
21d89f84 1762 fi
61cc919f
MF
1763else
1764 echo big/little test failed
7d13299d
FB
1765fi
1766
a30878e7
PM
1767##########################################
1768# cocoa implies not SDL or GTK
1769# (the cocoa UI code currently assumes it is always the active UI
1770# and doesn't interact well with other UI frontend code)
1771if test "$cocoa" = "yes"; then
1772 if test "$sdl" = "yes"; then
1773 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1774 fi
1775 if test "$gtk" = "yes"; then
1776 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1777 fi
1778 gtk=no
1779 sdl=no
1780fi
1781
6b39b063
EB
1782# Some versions of Mac OS X incorrectly define SIZE_MAX
1783cat > $TMPC << EOF
1784#include <stdint.h>
1785#include <stdio.h>
1786int main(int argc, char *argv[]) {
1787 return printf("%zu", SIZE_MAX);
1788}
1789EOF
1790have_broken_size_max=no
1791if ! compile_object -Werror ; then
1792 have_broken_size_max=yes
1793fi
1794
015a33bd
GA
1795##########################################
1796# L2TPV3 probe
1797
1798cat > $TMPC <<EOF
1799#include <sys/socket.h>
bff6cb72 1800#include <linux/ip.h>
015a33bd
GA
1801int main(void) { return sizeof(struct mmsghdr); }
1802EOF
1803if compile_prog "" "" ; then
1804 l2tpv3=yes
1805else
1806 l2tpv3=no
1807fi
1808
4d9310f4
DB
1809##########################################
1810# MinGW / Mingw-w64 localtime_r/gmtime_r check
1811
1812if test "$mingw32" = "yes"; then
1813 # Some versions of MinGW / Mingw-w64 lack localtime_r
1814 # and gmtime_r entirely.
1815 #
1816 # Some versions of Mingw-w64 define a macro for
1817 # localtime_r/gmtime_r.
1818 #
1819 # Some versions of Mingw-w64 will define functions
1820 # for localtime_r/gmtime_r, but only if you have
1821 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1822 # though, unistd.h and pthread.h both define
1823 # that for you.
1824 #
1825 # So this #undef localtime_r and #include <unistd.h>
1826 # are not in fact redundant.
1827cat > $TMPC << EOF
1828#include <unistd.h>
1829#include <time.h>
1830#undef localtime_r
1831int main(void) { localtime_r(NULL, NULL); return 0; }
1832EOF
1833 if compile_prog "" "" ; then
1834 localtime_r="yes"
1835 else
1836 localtime_r="no"
1837 fi
1838fi
1839
779ab5e3
SW
1840##########################################
1841# pkg-config probe
1842
1843if ! has "$pkg_config_exe"; then
76ad07a4 1844 error_exit "pkg-config binary '$pkg_config_exe' not found"
779ab5e3
SW
1845fi
1846
b0a47e79
JQ
1847##########################################
1848# NPTL probe
1849
24cb36a6 1850if test "$linux_user" = "yes"; then
b0a47e79 1851 cat > $TMPC <<EOF
bd0c5661 1852#include <sched.h>
30813cea 1853#include <linux/futex.h>
182eacc0 1854int main(void) {
bd0c5661
PB
1855#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
1856#error bork
1857#endif
182eacc0 1858 return 0;
bd0c5661
PB
1859}
1860EOF
24cb36a6 1861 if ! compile_object ; then
21684af0 1862 feature_not_found "nptl" "Install glibc and linux kernel headers."
b0a47e79 1863 fi
bd0c5661
PB
1864fi
1865
ac62922e 1866##########################################
99f2dbd3
LL
1867# avx2 optimization requirement check
1868
5e33a872 1869cat > $TMPC << EOF
4fb8320a
DDAG
1870#pragma GCC push_options
1871#pragma GCC target("avx2")
1872#include <cpuid.h>
1873#include <immintrin.h>
4fb8320a 1874static int bar(void *a) {
5e33a872
RH
1875 __m256i x = *(__m256i *)a;
1876 return _mm256_testz_si256(x, x);
4fb8320a 1877}
5e33a872 1878int main(int argc, char *argv[]) { return bar(argv[0]); }
99f2dbd3 1879EOF
5e33a872
RH
1880if compile_object "" ; then
1881 avx2_opt="yes"
99f2dbd3
LL
1882fi
1883
1884#########################################
ac62922e
AZ
1885# zlib check
1886
1ece9905
AL
1887if test "$zlib" != "no" ; then
1888 cat > $TMPC << EOF
ac62922e
AZ
1889#include <zlib.h>
1890int main(void) { zlibVersion(); return 0; }
1891EOF
1ece9905
AL
1892 if compile_prog "" "-lz" ; then
1893 :
1894 else
76ad07a4
PM
1895 error_exit "zlib check failed" \
1896 "Make sure to have the zlib libs and headers installed."
1ece9905 1897 fi
ac62922e 1898fi
eb0ecd5a 1899LIBS="$LIBS -lz"
ac62922e 1900
607dacd0
QN
1901##########################################
1902# lzo check
1903
1904if test "$lzo" != "no" ; then
1905 cat > $TMPC << EOF
1906#include <lzo/lzo1x.h>
1907int main(void) { lzo_version(); return 0; }
1908EOF
1909 if compile_prog "" "-llzo2" ; then
b25c9dff
SW
1910 libs_softmmu="$libs_softmmu -llzo2"
1911 lzo="yes"
607dacd0 1912 else
b25c9dff
SW
1913 if test "$lzo" = "yes"; then
1914 feature_not_found "liblzo2" "Install liblzo2 devel"
1915 fi
1916 lzo="no"
607dacd0 1917 fi
607dacd0
QN
1918fi
1919
1920##########################################
1921# snappy check
1922
1923if test "$snappy" != "no" ; then
1924 cat > $TMPC << EOF
1925#include <snappy-c.h>
1926int main(void) { snappy_max_compressed_length(4096); return 0; }
1927EOF
1928 if compile_prog "" "-lsnappy" ; then
b25c9dff
SW
1929 libs_softmmu="$libs_softmmu -lsnappy"
1930 snappy="yes"
607dacd0 1931 else
b25c9dff
SW
1932 if test "$snappy" = "yes"; then
1933 feature_not_found "libsnappy" "Install libsnappy devel"
1934 fi
1935 snappy="no"
607dacd0 1936 fi
607dacd0
QN
1937fi
1938
6b383c08
PW
1939##########################################
1940# bzip2 check
1941
1942if test "$bzip2" != "no" ; then
1943 cat > $TMPC << EOF
1944#include <bzlib.h>
1945int main(void) { BZ2_bzlibVersion(); return 0; }
1946EOF
1947 if compile_prog "" "-lbz2" ; then
1948 bzip2="yes"
1949 else
1950 if test "$bzip2" = "yes"; then
1951 feature_not_found "libbzip2" "Install libbzip2 devel"
1952 fi
1953 bzip2="no"
1954 fi
1955fi
1956
f794573e
EO
1957##########################################
1958# libseccomp check
1959
1960if test "$seccomp" != "no" ; then
693e5910
AJ
1961 case "$cpu" in
1962 i386|x86_64)
ba060c53 1963 libseccomp_minver="2.1.0"
693e5910 1964 ;;
5ce43972
JH
1965 mips)
1966 libseccomp_minver="2.2.0"
1967 ;;
693e5910
AJ
1968 arm|aarch64)
1969 libseccomp_minver="2.2.3"
1970 ;;
3e684455
MS
1971 ppc|ppc64)
1972 libseccomp_minver="2.3.0"
1973 ;;
693e5910
AJ
1974 *)
1975 libseccomp_minver=""
1976 ;;
1977 esac
1978
1979 if test "$libseccomp_minver" != "" &&
1980 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
89138857
SW
1981 libs_softmmu="$libs_softmmu $($pkg_config --libs libseccomp)"
1982 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libseccomp)"
693e5910 1983 seccomp="yes"
f794573e 1984 else
693e5910
AJ
1985 if test "$seccomp" = "yes" ; then
1986 if test "$libseccomp_minver" != "" ; then
1987 feature_not_found "libseccomp" \
1988 "Install libseccomp devel >= $libseccomp_minver"
1989 else
1990 feature_not_found "libseccomp" \
1991 "libseccomp is not supported for host cpu $cpu"
1992 fi
1993 fi
1994 seccomp="no"
f794573e
EO
1995 fi
1996fi
e37630ca
AL
1997##########################################
1998# xen probe
1999
fc321b4b 2000if test "$xen" != "no" ; then
c1cdd9d5
JG
2001 # Check whether Xen library path is specified via --extra-ldflags to avoid
2002 # overriding this setting with pkg-config output. If not, try pkg-config
2003 # to obtain all needed flags.
2004
2005 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2006 $pkg_config --exists xencontrol ; then
2007 xen_ctrl_version="$(printf '%d%02d%02d' \
2008 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2009 xen=yes
2010 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2011 xen_pc="$xen_pc xenevtchn xendevicemodel"
2012 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2013 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2014 LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2015 else
d5b93ddf 2016
c1cdd9d5 2017 xen_libs="-lxenstore -lxenctrl -lxenguest"
d9506cab 2018 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
50ced5b3 2019
c1cdd9d5
JG
2020 # First we test whether Xen headers and libraries are available.
2021 # If no, we are done and there is no Xen support.
2022 # If yes, more tests are run to detect the Xen version.
2023
2024 # Xen (any)
2025 cat > $TMPC <<EOF
e37630ca 2026#include <xenctrl.h>
50ced5b3
SW
2027int main(void) {
2028 return 0;
2029}
2030EOF
c1cdd9d5
JG
2031 if ! compile_prog "" "$xen_libs" ; then
2032 # Xen not found
2033 if test "$xen" = "yes" ; then
2034 feature_not_found "xen" "Install xen devel"
2035 fi
2036 xen=no
50ced5b3 2037
c1cdd9d5
JG
2038 # Xen unstable
2039 elif
2040 cat > $TMPC <<EOF &&
da8090cc
PD
2041#undef XC_WANT_COMPAT_DEVICEMODEL_API
2042#define __XEN_TOOLS__
2043#include <xendevicemodel.h>
2044int main(void) {
2045 xendevicemodel_handle *xd;
2046
2047 xd = xendevicemodel_open(0, 0);
2048 xendevicemodel_close(xd);
50ced5b3 2049
da8090cc
PD
2050 return 0;
2051}
2052EOF
c1cdd9d5
JG
2053 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2054 then
2055 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2056 xen_ctrl_version=40900
2057 xen=yes
2058 elif
2059 cat > $TMPC <<EOF &&
b6eb9b45
PS
2060/*
2061 * If we have stable libs the we don't want the libxc compat
2062 * layers, regardless of what CFLAGS we may have been given.
2063 *
2064 * Also, check if xengnttab_grant_copy_segment_t is defined and
2065 * grant copy operation is implemented.
2066 */
2067#undef XC_WANT_COMPAT_EVTCHN_API
2068#undef XC_WANT_COMPAT_GNTTAB_API
2069#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2070#include <xenctrl.h>
2071#include <xenstore.h>
2072#include <xenevtchn.h>
2073#include <xengnttab.h>
2074#include <xenforeignmemory.h>
2075#include <stdint.h>
2076#include <xen/hvm/hvm_info_table.h>
2077#if !defined(HVM_MAX_VCPUS)
2078# error HVM_MAX_VCPUS not defined
2079#endif
2080int main(void) {
2081 xc_interface *xc = NULL;
2082 xenforeignmemory_handle *xfmem;
2083 xenevtchn_handle *xe;
2084 xengnttab_handle *xg;
2085 xen_domain_handle_t handle;
2086 xengnttab_grant_copy_segment_t* seg = NULL;
2087
2088 xs_daemon_open();
2089
2090 xc = xc_interface_open(0, 0, 0);
2091 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2092 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2093 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2094 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2095 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2096
2097 xfmem = xenforeignmemory_open(0, 0);
2098 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2099
2100 xe = xenevtchn_open(0, 0);
2101 xenevtchn_fd(xe);
2102
2103 xg = xengnttab_open(0, 0);
2104 xengnttab_grant_copy(xg, 0, seg);
2105
2106 return 0;
2107}
2108EOF
c1cdd9d5
JG
2109 compile_prog "" "$xen_libs $xen_stable_libs"
2110 then
2111 xen_ctrl_version=40800
2112 xen=yes
2113 elif
2114 cat > $TMPC <<EOF &&
5eeb39c2
IC
2115/*
2116 * If we have stable libs the we don't want the libxc compat
2117 * layers, regardless of what CFLAGS we may have been given.
2118 */
2119#undef XC_WANT_COMPAT_EVTCHN_API
2120#undef XC_WANT_COMPAT_GNTTAB_API
2121#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2122#include <xenctrl.h>
2123#include <xenstore.h>
2124#include <xenevtchn.h>
2125#include <xengnttab.h>
2126#include <xenforeignmemory.h>
2127#include <stdint.h>
2128#include <xen/hvm/hvm_info_table.h>
2129#if !defined(HVM_MAX_VCPUS)
2130# error HVM_MAX_VCPUS not defined
2131#endif
2132int main(void) {
2133 xc_interface *xc = NULL;
2134 xenforeignmemory_handle *xfmem;
2135 xenevtchn_handle *xe;
2136 xengnttab_handle *xg;
2137 xen_domain_handle_t handle;
2138
2139 xs_daemon_open();
2140
2141 xc = xc_interface_open(0, 0, 0);
2142 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2143 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2144 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2145 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2146 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2147
2148 xfmem = xenforeignmemory_open(0, 0);
2149 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2150
2151 xe = xenevtchn_open(0, 0);
2152 xenevtchn_fd(xe);
2153
2154 xg = xengnttab_open(0, 0);
2155 xengnttab_map_grant_ref(xg, 0, 0, 0);
2156
2157 return 0;
2158}
2159EOF
c1cdd9d5
JG
2160 compile_prog "" "$xen_libs $xen_stable_libs"
2161 then
2162 xen_ctrl_version=40701
2163 xen=yes
2164 elif
2165 cat > $TMPC <<EOF &&
50ced5b3 2166#include <xenctrl.h>
cdadde39
RPM
2167#include <stdint.h>
2168int main(void) {
2169 xc_interface *xc = NULL;
2170 xen_domain_handle_t handle;
2171 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2172 return 0;
2173}
2174EOF
c1cdd9d5
JG
2175 compile_prog "" "$xen_libs"
2176 then
2177 xen_ctrl_version=40700
2178 xen=yes
2179
2180 # Xen 4.6
2181 elif
2182 cat > $TMPC <<EOF &&
cdadde39 2183#include <xenctrl.h>
e108a3c1 2184#include <xenstore.h>
d5b93ddf
AP
2185#include <stdint.h>
2186#include <xen/hvm/hvm_info_table.h>
2187#if !defined(HVM_MAX_VCPUS)
2188# error HVM_MAX_VCPUS not defined
2189#endif
d8b441a3
JB
2190int main(void) {
2191 xc_interface *xc;
2192 xs_daemon_open();
2193 xc = xc_interface_open(0, 0, 0);
2194 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2195 xc_gnttab_open(NULL, 0);
2196 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2197 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2198 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
20a544c7 2199 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
d8b441a3
JB
2200 return 0;
2201}
2202EOF
c1cdd9d5
JG
2203 compile_prog "" "$xen_libs"
2204 then
2205 xen_ctrl_version=40600
2206 xen=yes
2207
2208 # Xen 4.5
2209 elif
2210 cat > $TMPC <<EOF &&
d8b441a3
JB
2211#include <xenctrl.h>
2212#include <xenstore.h>
2213#include <stdint.h>
2214#include <xen/hvm/hvm_info_table.h>
2215#if !defined(HVM_MAX_VCPUS)
2216# error HVM_MAX_VCPUS not defined
2217#endif
3996e85c
PD
2218int main(void) {
2219 xc_interface *xc;
2220 xs_daemon_open();
2221 xc = xc_interface_open(0, 0, 0);
2222 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2223 xc_gnttab_open(NULL, 0);
2224 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2225 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2226 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2227 return 0;
2228}
2229EOF
c1cdd9d5
JG
2230 compile_prog "" "$xen_libs"
2231 then
2232 xen_ctrl_version=40500
2233 xen=yes
3996e85c 2234
c1cdd9d5
JG
2235 elif
2236 cat > $TMPC <<EOF &&
3996e85c
PD
2237#include <xenctrl.h>
2238#include <xenstore.h>
2239#include <stdint.h>
2240#include <xen/hvm/hvm_info_table.h>
2241#if !defined(HVM_MAX_VCPUS)
2242# error HVM_MAX_VCPUS not defined
2243#endif
8688e065
SS
2244int main(void) {
2245 xc_interface *xc;
2246 xs_daemon_open();
2247 xc = xc_interface_open(0, 0, 0);
2248 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2249 xc_gnttab_open(NULL, 0);
2250 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2251 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2252 return 0;
2253}
2254EOF
c1cdd9d5
JG
2255 compile_prog "" "$xen_libs"
2256 then
2257 xen_ctrl_version=40200
2258 xen=yes
8688e065 2259
c1cdd9d5
JG
2260 else
2261 if test "$xen" = "yes" ; then
2262 feature_not_found "xen (unsupported version)" \
2263 "Install a supported xen (xen 4.2 or newer)"
2264 fi
2265 xen=no
fc321b4b 2266 fi
d5b93ddf 2267
c1cdd9d5
JG
2268 if test "$xen" = yes; then
2269 if test $xen_ctrl_version -ge 40701 ; then
2270 libs_softmmu="$xen_stable_libs $libs_softmmu"
2271 fi
2272 libs_softmmu="$xen_libs $libs_softmmu"
5eeb39c2 2273 fi
d5b93ddf 2274 fi
e37630ca
AL
2275fi
2276
eb6fda0f 2277if test "$xen_pci_passthrough" != "no"; then
edfb07ed 2278 if test "$xen" = "yes" && test "$linux" = "yes"; then
eb6fda0f
AP
2279 xen_pci_passthrough=yes
2280 else
2281 if test "$xen_pci_passthrough" = "yes"; then
76ad07a4
PM
2282 error_exit "User requested feature Xen PCI Passthrough" \
2283 " but this feature requires /sys from Linux"
eb6fda0f
AP
2284 fi
2285 xen_pci_passthrough=no
2286 fi
2287fi
2288
64a7ad6f
IC
2289if test "$xen_pv_domain_build" = "yes" &&
2290 test "$xen" != "yes"; then
2291 error_exit "User requested Xen PV domain builder support" \
2292 "which requires Xen support."
2293fi
2294
dfffc653
JQ
2295##########################################
2296# Sparse probe
2297if test "$sparse" != "no" ; then
0dba6195 2298 if has cgcc; then
dfffc653
JQ
2299 sparse=yes
2300 else
2301 if test "$sparse" = "yes" ; then
21684af0 2302 feature_not_found "sparse" "Install sparse binary"
dfffc653
JQ
2303 fi
2304 sparse=no
2305 fi
2306fi
2307
f676c67e
JW
2308##########################################
2309# X11 probe
2310x11_cflags=
2311x11_libs=-lX11
2312if $pkg_config --exists "x11"; then
89138857
SW
2313 x11_cflags=$($pkg_config --cflags x11)
2314 x11_libs=$($pkg_config --libs x11)
f676c67e
JW
2315fi
2316
a4ccabcf
AL
2317##########################################
2318# GTK probe
2319
9e04c683
SW
2320if test "$gtkabi" = ""; then
2321 # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
2322 # Use 3.0 as a fallback if that is available.
2323 if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2324 gtkabi=2.0
2325 elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2326 gtkabi=3.0
2327 else
2328 gtkabi=2.0
2329 fi
2330fi
2331
a4ccabcf 2332if test "$gtk" != "no"; then
528de90a 2333 gtkpackage="gtk+-$gtkabi"
0a337ed0 2334 gtkx11package="gtk+-x11-$gtkabi"
528de90a
DB
2335 if test "$gtkabi" = "3.0" ; then
2336 gtkversion="3.0.0"
bbbf9bfb
SW
2337 else
2338 gtkversion="2.18.0"
2339 fi
2340 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
89138857
SW
2341 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2342 gtk_libs=$($pkg_config --libs $gtkpackage)
2343 gtk_version=$($pkg_config --modversion $gtkpackage)
0a337ed0 2344 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
f676c67e
JW
2345 gtk_cflags="$gtk_cflags $x11_cflags"
2346 gtk_libs="$gtk_libs $x11_libs"
0a337ed0 2347 fi
bbbf9bfb
SW
2348 libs_softmmu="$gtk_libs $libs_softmmu"
2349 gtk="yes"
2350 elif test "$gtk" = "yes"; then
9e04c683 2351 feature_not_found "gtk" "Install gtk2 or gtk3 devel"
bbbf9bfb
SW
2352 else
2353 gtk="no"
2354 fi
2355fi
2356
ddbb0d09
DB
2357
2358##########################################
2359# GNUTLS probe
2360
37371299
PM
2361gnutls_works() {
2362 # Unfortunately some distros have bad pkg-config information for gnutls
2363 # such that it claims to exist but you get a compiler error if you try
2364 # to use the options returned by --libs. Specifically, Ubuntu for --static
2365 # builds doesn't work:
2366 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2367 #
2368 # So sanity check the cflags/libs before assuming gnutls can be used.
2369 if ! $pkg_config --exists "gnutls"; then
2370 return 1
2371 fi
2372
2373 write_c_skeleton
2374 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2375}
2376
62893b67 2377gnutls_gcrypt=no
ed754746 2378gnutls_nettle=no
ddbb0d09 2379if test "$gnutls" != "no"; then
37371299 2380 if gnutls_works; then
89138857
SW
2381 gnutls_cflags=$($pkg_config --cflags gnutls)
2382 gnutls_libs=$($pkg_config --libs gnutls)
ddbb0d09
DB
2383 libs_softmmu="$gnutls_libs $libs_softmmu"
2384 libs_tools="$gnutls_libs $libs_tools"
2385 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2386 gnutls="yes"
2387
b917da4c
DB
2388 # gnutls_rnd requires >= 2.11.0
2389 if $pkg_config --exists "gnutls >= 2.11.0"; then
2390 gnutls_rnd="yes"
2391 else
2392 gnutls_rnd="no"
2393 fi
2394
62893b67
DB
2395 if $pkg_config --exists 'gnutls >= 3.0'; then
2396 gnutls_gcrypt=no
ed754746 2397 gnutls_nettle=yes
62893b67 2398 elif $pkg_config --exists 'gnutls >= 2.12'; then
89138857 2399 case $($pkg_config --libs --static gnutls) in
ed754746
DB
2400 *gcrypt*)
2401 gnutls_gcrypt=yes
2402 gnutls_nettle=no
2403 ;;
2404 *nettle*)
2405 gnutls_gcrypt=no
2406 gnutls_nettle=yes
2407 ;;
2408 *)
2409 gnutls_gcrypt=yes
2410 gnutls_nettle=no
2411 ;;
62893b67
DB
2412 esac
2413 else
2414 gnutls_gcrypt=yes
ed754746 2415 gnutls_nettle=no
62893b67 2416 fi
ddbb0d09
DB
2417 elif test "$gnutls" = "yes"; then
2418 feature_not_found "gnutls" "Install gnutls devel"
2419 else
2420 gnutls="no"
b917da4c 2421 gnutls_rnd="no"
ddbb0d09
DB
2422 fi
2423else
b917da4c 2424 gnutls_rnd="no"
ddbb0d09
DB
2425fi
2426
91bfcdb0
DB
2427
2428# If user didn't give a --disable/enable-gcrypt flag,
2429# then mark as disabled if user requested nettle
2430# explicitly, or if gnutls links to nettle
2431if test -z "$gcrypt"
2432then
2433 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2434 then
2435 gcrypt="no"
2436 fi
2437fi
2438
2439# If user didn't give a --disable/enable-nettle flag,
2440# then mark as disabled if user requested gcrypt
2441# explicitly, or if gnutls links to gcrypt
2442if test -z "$nettle"
2443then
2444 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2445 then
2446 nettle="no"
2447 fi
2448fi
2449
2450has_libgcrypt_config() {
2451 if ! has "libgcrypt-config"
2452 then
2453 return 1
2454 fi
2455
2456 if test -n "$cross_prefix"
2457 then
89138857 2458 host=$(libgcrypt-config --host)
91bfcdb0
DB
2459 if test "$host-" != $cross_prefix
2460 then
2461 return 1
2462 fi
2463 fi
2464
2465 return 0
2466}
2467
2468if test "$gcrypt" != "no"; then
2469 if has_libgcrypt_config; then
89138857
SW
2470 gcrypt_cflags=$(libgcrypt-config --cflags)
2471 gcrypt_libs=$(libgcrypt-config --libs)
91bfcdb0
DB
2472 # Debian has remove -lgpg-error from libgcrypt-config
2473 # as it "spreads unnecessary dependencies" which in
2474 # turn breaks static builds...
2475 if test "$static" = "yes"
2476 then
2477 gcrypt_libs="$gcrypt_libs -lgpg-error"
2478 fi
62893b67
DB
2479 libs_softmmu="$gcrypt_libs $libs_softmmu"
2480 libs_tools="$gcrypt_libs $libs_tools"
2481 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
91bfcdb0
DB
2482 gcrypt="yes"
2483 if test -z "$nettle"; then
2484 nettle="no"
2485 fi
37788f25
DB
2486
2487 cat > $TMPC << EOF
2488#include <gcrypt.h>
2489int main(void) {
2490 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2491 GCRY_MD_SHA256,
2492 NULL, 0, 0, 0, NULL);
2493 return 0;
2494}
2495EOF
2496 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2497 gcrypt_kdf=yes
2498 fi
1f923c70
LM
2499
2500 cat > $TMPC << EOF
2501#include <gcrypt.h>
2502int main(void) {
2503 gcry_mac_hd_t handle;
2504 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2505 GCRY_MAC_FLAG_SECURE, NULL);
2506 return 0;
2507}
2508EOF
2509 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2510 gcrypt_hmac=yes
2511 fi
62893b67 2512 else
91bfcdb0
DB
2513 if test "$gcrypt" = "yes"; then
2514 feature_not_found "gcrypt" "Install gcrypt devel"
2515 else
2516 gcrypt="no"
2517 fi
62893b67
DB
2518 fi
2519fi
2520
ddbb0d09 2521
91bfcdb0 2522if test "$nettle" != "no"; then
ed754746 2523 if $pkg_config --exists "nettle"; then
89138857
SW
2524 nettle_cflags=$($pkg_config --cflags nettle)
2525 nettle_libs=$($pkg_config --libs nettle)
2526 nettle_version=$($pkg_config --modversion nettle)
ed754746
DB
2527 libs_softmmu="$nettle_libs $libs_softmmu"
2528 libs_tools="$nettle_libs $libs_tools"
2529 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
91bfcdb0 2530 nettle="yes"
fff2f982
DB
2531
2532 cat > $TMPC << EOF
9e87a691 2533#include <stddef.h>
fff2f982
DB
2534#include <nettle/pbkdf2.h>
2535int main(void) {
2536 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2537 return 0;
2538}
2539EOF
2540 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2541 nettle_kdf=yes
2542 fi
ed754746 2543 else
91bfcdb0
DB
2544 if test "$nettle" = "yes"; then
2545 feature_not_found "nettle" "Install nettle devel"
2546 else
2547 nettle="no"
2548 fi
ed754746
DB
2549 fi
2550fi
2551
91bfcdb0
DB
2552if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2553then
2554 error_exit "Only one of gcrypt & nettle can be enabled"
2555fi
2556
9a2fd434
DB
2557##########################################
2558# libtasn1 - only for the TLS creds/session test suite
2559
2560tasn1=yes
90246037
DB
2561tasn1_cflags=""
2562tasn1_libs=""
9a2fd434 2563if $pkg_config --exists "libtasn1"; then
89138857
SW
2564 tasn1_cflags=$($pkg_config --cflags libtasn1)
2565 tasn1_libs=$($pkg_config --libs libtasn1)
9a2fd434
DB
2566else
2567 tasn1=no
2568fi
2569
ed754746 2570
559607ea
DB
2571##########################################
2572# getifaddrs (for tests/test-io-channel-socket )
2573
2574have_ifaddrs_h=yes
2575if ! check_include "ifaddrs.h" ; then
2576 have_ifaddrs_h=no
2577fi
2578
bbbf9bfb
SW
2579##########################################
2580# VTE probe
2581
2582if test "$vte" != "no"; then
2583 if test "$gtkabi" = "3.0"; then
c6feff9e
CR
2584 vteminversion="0.32.0"
2585 if $pkg_config --exists "vte-2.91"; then
2586 vtepackage="vte-2.91"
2587 else
2588 vtepackage="vte-2.90"
2589 fi
528de90a 2590 else
528de90a 2591 vtepackage="vte"
c6feff9e 2592 vteminversion="0.24.0"
528de90a 2593 fi
c6feff9e 2594 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
89138857
SW
2595 vte_cflags=$($pkg_config --cflags $vtepackage)
2596 vte_libs=$($pkg_config --libs $vtepackage)
2597 vteversion=$($pkg_config --modversion $vtepackage)
bbbf9bfb
SW
2598 libs_softmmu="$vte_libs $libs_softmmu"
2599 vte="yes"
2600 elif test "$vte" = "yes"; then
9e04c683 2601 if test "$gtkabi" = "3.0"; then
c6feff9e 2602 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
9e04c683
SW
2603 else
2604 feature_not_found "vte" "Install libvte devel"
2605 fi
0d185e63 2606 else
bbbf9bfb 2607 vte="no"
a4ccabcf
AL
2608 fi
2609fi
2610
11d9f695
FB
2611##########################################
2612# SDL probe
2613
3ec87ffe
PB
2614# Look for sdl configuration program (pkg-config or sdl-config). Try
2615# sdl-config even without cross prefix, and favour pkg-config over sdl-config.
47c03744 2616
ee8466d0
CR
2617if test "$sdlabi" = ""; then
2618 if $pkg_config --exists "sdl"; then
2619 sdlabi=1.2
2620 elif $pkg_config --exists "sdl2"; then
2621 sdlabi=2.0
2622 else
2623 sdlabi=1.2
2624 fi
2625fi
2626
47c03744
DA
2627if test $sdlabi = "2.0"; then
2628 sdl_config=$sdl2_config
2629 sdlname=sdl2
2630 sdlconfigname=sdl2_config
e07047cf 2631elif test $sdlabi = "1.2"; then
47c03744
DA
2632 sdlname=sdl
2633 sdlconfigname=sdl_config
e07047cf
CR
2634else
2635 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
47c03744
DA
2636fi
2637
89138857 2638if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
47c03744 2639 sdl_config=$sdlconfigname
3ec87ffe
PB
2640fi
2641
47c03744
DA
2642if $pkg_config $sdlname --exists; then
2643 sdlconfig="$pkg_config $sdlname"
89138857 2644 sdlversion=$($sdlconfig --modversion 2>/dev/null)
3ec87ffe
PB
2645elif has ${sdl_config}; then
2646 sdlconfig="$sdl_config"
89138857 2647 sdlversion=$($sdlconfig --version)
a0dfd8a4
LM
2648else
2649 if test "$sdl" = "yes" ; then
21684af0 2650 feature_not_found "sdl" "Install SDL devel"
a0dfd8a4
LM
2651 fi
2652 sdl=no
9316f803 2653fi
29e5bada 2654if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
3ec87ffe
PB
2655 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2656fi
11d9f695 2657
9316f803 2658sdl_too_old=no
c4198157 2659if test "$sdl" != "no" ; then
ac119f9d 2660 cat > $TMPC << EOF
11d9f695
FB
2661#include <SDL.h>
2662#undef main /* We don't want SDL to override our main() */
2663int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2664EOF
89138857 2665 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
74f42e18 2666 if test "$static" = "yes" ; then
89138857 2667 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
74f42e18 2668 else
89138857 2669 sdl_libs=$($sdlconfig --libs 2>/dev/null)
74f42e18 2670 fi
52166aa0 2671 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
89138857 2672 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
ac119f9d
JQ
2673 sdl_too_old=yes
2674 else
a30878e7 2675 sdl=yes
ac119f9d 2676 fi
cd01b4a3 2677
67c274d3 2678 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
ac119f9d 2679 if test "$sdl" = "yes" -a "$static" = "yes" ; then
67c274d3 2680 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
89138857
SW
2681 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2682 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
ac119f9d 2683 fi
52166aa0 2684 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
ac119f9d
JQ
2685 :
2686 else
2687 sdl=no
2688 fi
2689 fi # static link
c4198157
JQ
2690 else # sdl not found
2691 if test "$sdl" = "yes" ; then
21684af0 2692 feature_not_found "sdl" "Install SDL devel"
c4198157
JQ
2693 fi
2694 sdl=no
ac119f9d 2695 fi # sdl compile test
a68551bc 2696fi
11d9f695 2697
5368a422 2698if test "$sdl" = "yes" ; then
ac119f9d 2699 cat > $TMPC <<EOF
5368a422
AL
2700#include <SDL.h>
2701#if defined(SDL_VIDEO_DRIVER_X11)
2702#include <X11/XKBlib.h>
2703#else
2704#error No x11 support
2705#endif
2706int main(void) { return 0; }
2707EOF
f676c67e
JW
2708 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2709 sdl_cflags="$sdl_cflags $x11_cflags"
2710 sdl_libs="$sdl_libs $x11_libs"
ac119f9d 2711 fi
0705667e 2712 libs_softmmu="$sdl_libs $libs_softmmu"
5368a422
AL
2713fi
2714
2da776db
MH
2715##########################################
2716# RDMA needs OpenFabrics libraries
2717if test "$rdma" != "no" ; then
2718 cat > $TMPC <<EOF
2719#include <rdma/rdma_cma.h>
2720int main(void) { return 0; }
2721EOF
2722 rdma_libs="-lrdmacm -libverbs"
2723 if compile_prog "" "$rdma_libs" ; then
2724 rdma="yes"
2725 libs_softmmu="$libs_softmmu $rdma_libs"
2726 else
2727 if test "$rdma" = "yes" ; then
2728 error_exit \
2729 " OpenFabrics librdmacm/libibverbs not present." \
2730 " Your options:" \
2731 " (1) Fast: Install infiniband packages from your distro." \
2732 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2733 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2734 fi
2735 rdma="no"
2736 fi
2737fi
2738
95c6bff3 2739
2f9606b3
AL
2740##########################################
2741# VNC SASL detection
821601ea 2742if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
ea784e3b 2743 cat > $TMPC <<EOF
2f9606b3
AL
2744#include <sasl/sasl.h>
2745#include <stdio.h>
2746int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2747EOF
ea784e3b
JQ
2748 # Assuming Cyrus-SASL installed in /usr prefix
2749 vnc_sasl_cflags=""
2750 vnc_sasl_libs="-lsasl2"
2751 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2752 vnc_sasl=yes
2753 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
ca273d58 2754 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
ea784e3b
JQ
2755 else
2756 if test "$vnc_sasl" = "yes" ; then
21684af0 2757 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2f9606b3 2758 fi
ea784e3b
JQ
2759 vnc_sasl=no
2760 fi
2f9606b3
AL
2761fi
2762
2f6f5c7a
CC
2763##########################################
2764# VNC JPEG detection
821601ea 2765if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2f6f5c7a
CC
2766cat > $TMPC <<EOF
2767#include <stdio.h>
2768#include <jpeglib.h>
2769int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2770EOF
2771 vnc_jpeg_cflags=""
2772 vnc_jpeg_libs="-ljpeg"
2773 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2774 vnc_jpeg=yes
2775 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
ca273d58 2776 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2f6f5c7a
CC
2777 else
2778 if test "$vnc_jpeg" = "yes" ; then
21684af0 2779 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2f6f5c7a
CC
2780 fi
2781 vnc_jpeg=no
2782 fi
2783fi
2784
efe556ad
CC
2785##########################################
2786# VNC PNG detection
821601ea 2787if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
efe556ad
CC
2788cat > $TMPC <<EOF
2789//#include <stdio.h>
2790#include <png.h>
832ce9c2 2791#include <stddef.h>
efe556ad
CC
2792int main(void) {
2793 png_structp png_ptr;
2794 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
7edc3fed 2795 return png_ptr != 0;
efe556ad
CC
2796}
2797EOF
65d5d3f9 2798 if $pkg_config libpng --exists; then
89138857
SW
2799 vnc_png_cflags=$($pkg_config libpng --cflags)
2800 vnc_png_libs=$($pkg_config libpng --libs)
9af8025e 2801 else
efe556ad
CC
2802 vnc_png_cflags=""
2803 vnc_png_libs="-lpng"
9af8025e 2804 fi
efe556ad
CC
2805 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2806 vnc_png=yes
2807 libs_softmmu="$vnc_png_libs $libs_softmmu"
9af8025e 2808 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
efe556ad
CC
2809 else
2810 if test "$vnc_png" = "yes" ; then
21684af0 2811 feature_not_found "vnc-png" "Install libpng devel"
efe556ad
CC
2812 fi
2813 vnc_png=no
2814 fi
2815fi
2816
76655d6d
AL
2817##########################################
2818# fnmatch() probe, used for ACL routines
2819fnmatch="no"
2820cat > $TMPC << EOF
2821#include <fnmatch.h>
2822int main(void)
2823{
2824 fnmatch("foo", "foo", 0);
2825 return 0;
2826}
2827EOF
52166aa0 2828if compile_prog "" "" ; then
76655d6d
AL
2829 fnmatch="yes"
2830fi
2831
ee682d27 2832##########################################
c1bb86cd 2833# xfsctl() probe, used for file-posix.c
dce512de
CH
2834if test "$xfs" != "no" ; then
2835 cat > $TMPC << EOF
ffc41d10 2836#include <stddef.h> /* NULL */
dce512de
CH
2837#include <xfs/xfs.h>
2838int main(void)
2839{
2840 xfsctl(NULL, 0, 0, NULL);
2841 return 0;
2842}
2843EOF
2844 if compile_prog "" "" ; then
2845 xfs="yes"
2846 else
2847 if test "$xfs" = "yes" ; then
21684af0 2848 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
dce512de
CH
2849 fi
2850 xfs=no
2851 fi
2852fi
2853
8a16d273
TS
2854##########################################
2855# vde libraries probe
dfb278bd 2856if test "$vde" != "no" ; then
4baae0ac 2857 vde_libs="-lvdeplug"
8a16d273
TS
2858 cat > $TMPC << EOF
2859#include <libvdeplug.h>
4a7f0e06
PB
2860int main(void)
2861{
2862 struct vde_open_args a = {0, 0, 0};
fea08e08
PM
2863 char s[] = "";
2864 vde_open(s, s, &a);
4a7f0e06
PB
2865 return 0;
2866}
8a16d273 2867EOF
52166aa0 2868 if compile_prog "" "$vde_libs" ; then
4baae0ac 2869 vde=yes
8e02e54c
JQ
2870 libs_softmmu="$vde_libs $libs_softmmu"
2871 libs_tools="$vde_libs $libs_tools"
dfb278bd
JQ
2872 else
2873 if test "$vde" = "yes" ; then
21684af0 2874 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
dfb278bd
JQ
2875 fi
2876 vde=no
4baae0ac 2877 fi
8a16d273
TS
2878fi
2879
58952137 2880##########################################
0a985b37
VM
2881# netmap support probe
2882# Apart from looking for netmap headers, we make sure that the host API version
2883# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
2884# a minor/major version number. Minor new features will be marked with values up
2885# to 15, and if something happens that requires a change to the backend we will
2886# move above 15, submit the backend fixes and modify this two bounds.
58952137
VM
2887if test "$netmap" != "no" ; then
2888 cat > $TMPC << EOF
2889#include <inttypes.h>
2890#include <net/if.h>
2891#include <net/netmap.h>
2892#include <net/netmap_user.h>
0a985b37
VM
2893#if (NETMAP_API < 11) || (NETMAP_API > 15)
2894#error
2895#endif
58952137
VM
2896int main(void) { return 0; }
2897EOF
2898 if compile_prog "" "" ; then
2899 netmap=yes
2900 else
2901 if test "$netmap" = "yes" ; then
2902 feature_not_found "netmap"
2903 fi
2904 netmap=no
2905 fi
2906fi
2907
47e98658
CB
2908##########################################
2909# libcap-ng library probe
2910if test "$cap_ng" != "no" ; then
2911 cap_libs="-lcap-ng"
2912 cat > $TMPC << EOF
2913#include <cap-ng.h>
2914int main(void)
2915{
2916 capng_capability_to_name(CAPNG_EFFECTIVE);
2917 return 0;
2918}
2919EOF
2920 if compile_prog "" "$cap_libs" ; then
2921 cap_ng=yes
2922 libs_tools="$cap_libs $libs_tools"
2923 else
2924 if test "$cap_ng" = "yes" ; then
21684af0 2925 feature_not_found "cap_ng" "Install libcap-ng devel"
47e98658
CB
2926 fi
2927 cap_ng=no
2928 fi
2929fi
2930
8f28f3fb 2931##########################################
c2de5c91 2932# Sound support libraries probe
8f28f3fb 2933
c2de5c91 2934audio_drv_probe()
2935{
2936 drv=$1
2937 hdr=$2
2938 lib=$3
2939 exp=$4
2940 cfl=$5
2941 cat > $TMPC << EOF
2942#include <$hdr>
2943int main(void) { $exp }
8f28f3fb 2944EOF
52166aa0 2945 if compile_prog "$cfl" "$lib" ; then
c2de5c91 2946 :
2947 else
76ad07a4
PM
2948 error_exit "$drv check failed" \
2949 "Make sure to have the $drv libs and headers installed."
c2de5c91 2950 fi
2951}
2952
89138857 2953audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
c2de5c91 2954for drv in $audio_drv_list; do
2955 case $drv in
2956 alsa)
2957 audio_drv_probe $drv alsa/asoundlib.h -lasound \
e35bcb0c 2958 "return snd_pcm_close((snd_pcm_t *)0);"
a4bf6780 2959 libs_softmmu="-lasound $libs_softmmu"
c2de5c91 2960 ;;
2961
b8e59f18 2962 pa)
e58ff62d
PK
2963 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
2964 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
a394aed2 2965 libs_softmmu="-lpulse $libs_softmmu"
67f86e8e 2966 audio_pt_int="yes"
b8e59f18 2967 ;;
2968
373967b2
GH
2969 sdl)
2970 if test "$sdl" = "no"; then
2971 error_exit "sdl not found or disabled, can not use sdl audio driver"
2972 fi
2973 ;;
2974
997e690a
JQ
2975 coreaudio)
2976 libs_softmmu="-framework CoreAudio $libs_softmmu"
2977 ;;
2978
a4bf6780
JQ
2979 dsound)
2980 libs_softmmu="-lole32 -ldxguid $libs_softmmu"
d5631638 2981 audio_win_int="yes"
a4bf6780
JQ
2982 ;;
2983
2984 oss)
2985 libs_softmmu="$oss_lib $libs_softmmu"
2986 ;;
2987
373967b2
GH
2988 wav)
2989 # XXX: Probes for CoreAudio, DirectSound
2f6a1ab0
BS
2990 ;;
2991
e4c63a6a 2992 *)
1c9b2a52 2993 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
76ad07a4
PM
2994 error_exit "Unknown driver '$drv' selected" \
2995 "Possible drivers are: $audio_possible_drivers"
e4c63a6a 2996 }
2997 ;;
c2de5c91 2998 esac
2999done
8f28f3fb 3000
2e4d9fb1
AJ
3001##########################################
3002# BrlAPI probe
3003
4ffcedb6 3004if test "$brlapi" != "no" ; then
eb82284f
JQ
3005 brlapi_libs="-lbrlapi"
3006 cat > $TMPC << EOF
2e4d9fb1 3007#include <brlapi.h>
832ce9c2 3008#include <stddef.h>
2e4d9fb1
AJ
3009int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3010EOF
52166aa0 3011 if compile_prog "" "$brlapi_libs" ; then
eb82284f 3012 brlapi=yes
264606b3 3013 libs_softmmu="$brlapi_libs $libs_softmmu"
4ffcedb6
JQ
3014 else
3015 if test "$brlapi" = "yes" ; then
21684af0 3016 feature_not_found "brlapi" "Install brlapi devel"
4ffcedb6
JQ
3017 fi
3018 brlapi=no
eb82284f
JQ
3019 fi
3020fi
2e4d9fb1 3021
4d3b6f6e
AZ
3022##########################################
3023# curses probe
a3605bf6
MT
3024if test "$curses" != "no" ; then
3025 if test "$mingw32" = "yes" ; then
8ddc5bf9
ST
3026 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3027 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
a3605bf6 3028 else
7c703002 3029 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
8ddc5bf9 3030 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
a3605bf6 3031 fi
c584a6d0 3032 curses_found=no
4d3b6f6e 3033 cat > $TMPC << EOF
8ddc5bf9 3034#include <locale.h>
4d3b6f6e 3035#include <curses.h>
8ddc5bf9 3036#include <wchar.h>
ef9a2524
SW
3037int main(void) {
3038 const char *s = curses_version();
8ddc5bf9
ST
3039 wchar_t wch = L'w';
3040 setlocale(LC_ALL, "");
ef9a2524 3041 resize_term(0, 0);
8ddc5bf9
ST
3042 addwstr(L"wide chars\n");
3043 addnwstr(&wch, 1);
7c703002 3044 add_wch(WACS_DEGREE);
ef9a2524
SW
3045 return s != 0;
3046}
4d3b6f6e 3047EOF
ecbe251f 3048 IFS=:
8ddc5bf9 3049 for curses_inc in $curses_inc_list; do
7c703002 3050 IFS=:
8ddc5bf9
ST
3051 for curses_lib in $curses_lib_list; do
3052 unset IFS
3053 if compile_prog "$curses_inc" "$curses_lib" ; then
3054 curses_found=yes
3055 QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
3056 libs_softmmu="$curses_lib $libs_softmmu"
3057 break
3058 fi
3059 done
7c703002
ST
3060 if test "$curses_found" = yes ; then
3061 break
3062 fi
4f78ef9a 3063 done
ecbe251f 3064 unset IFS
c584a6d0
JQ
3065 if test "$curses_found" = "yes" ; then
3066 curses=yes
3067 else
3068 if test "$curses" = "yes" ; then
21684af0 3069 feature_not_found "curses" "Install ncurses devel"
c584a6d0
JQ
3070 fi
3071 curses=no
3072 fi
4f78ef9a 3073fi
4d3b6f6e 3074
769ce76d
AG
3075##########################################
3076# curl probe
788c8196 3077if test "$curl" != "no" ; then
65d5d3f9 3078 if $pkg_config libcurl --exists; then
a3605bf6
MT
3079 curlconfig="$pkg_config libcurl"
3080 else
3081 curlconfig=curl-config
3082 fi
769ce76d
AG
3083 cat > $TMPC << EOF
3084#include <curl/curl.h>
0b862ced 3085int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
769ce76d 3086EOF
89138857
SW
3087 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3088 curl_libs=$($curlconfig --libs 2>/dev/null)
b1d5a277 3089 if compile_prog "$curl_cflags" "$curl_libs" ; then
769ce76d 3090 curl=yes
788c8196
JQ
3091 else
3092 if test "$curl" = "yes" ; then
21684af0 3093 feature_not_found "curl" "Install libcurl devel"
788c8196
JQ
3094 fi
3095 curl=no
769ce76d
AG
3096 fi
3097fi # test "$curl"
3098
fb599c9a
AZ
3099##########################################
3100# bluez support probe
a20a6f46 3101if test "$bluez" != "no" ; then
e820e3f4
AZ
3102 cat > $TMPC << EOF
3103#include <bluetooth/bluetooth.h>
3104int main(void) { return bt_error(0); }
3105EOF
89138857
SW
3106 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3107 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
52166aa0 3108 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
a20a6f46 3109 bluez=yes
e482d56a 3110 libs_softmmu="$bluez_libs $libs_softmmu"
e820e3f4 3111 else
a20a6f46 3112 if test "$bluez" = "yes" ; then
21684af0 3113 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
a20a6f46 3114 fi
e820e3f4
AZ
3115 bluez="no"
3116 fi
fb599c9a
AZ
3117fi
3118
e18df141
AL
3119##########################################
3120# glib support probe
a52d28af 3121
ad04d8cb
PM
3122if test "$mingw32" = yes; then
3123 glib_req_ver=2.30
3124else
3125 glib_req_ver=2.22
3126fi
aa0d1f44
PB
3127glib_modules=gthread-2.0
3128if test "$modules" = yes; then
3129 glib_modules="$glib_modules gmodule-2.0"
3130fi
e26110cf 3131
4eaf7202
SJ
3132# This workaround is required due to a bug in pkg-config file for glib as it
3133# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3134
3135if test "$static" = yes -a "$mingw32" = yes; then
3136 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3137fi
3138
aa0d1f44 3139for i in $glib_modules; do
e26110cf 3140 if $pkg_config --atleast-version=$glib_req_ver $i; then
89138857
SW
3141 glib_cflags=$($pkg_config --cflags $i)
3142 glib_libs=$($pkg_config --libs $i)
4a058899 3143 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
e26110cf
FZ
3144 LIBS="$glib_libs $LIBS"
3145 libs_qga="$glib_libs $libs_qga"
3146 else
3147 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3148 fi
3149done
3150
977a82ab
DB
3151# Sanity check that the current size_t matches the
3152# size that glib thinks it should be. This catches
3153# problems on multi-arch where people try to build
3154# 32-bit QEMU while pointing at 64-bit glib headers
3155cat > $TMPC <<EOF
3156#include <glib.h>
3157#include <unistd.h>
3158
3159#define QEMU_BUILD_BUG_ON(x) \
3160 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3161
3162int main(void) {
3163 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3164 return 0;
3165}
3166EOF
3167
5919e032 3168if ! compile_prog "$CFLAGS" "$LIBS" ; then
977a82ab
DB
3169 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3170 "You probably need to set PKG_CONFIG_LIBDIR"\
3171 "to point to the right pkg-config files for your"\
3172 "build target"
3173fi
3174
9d41401b
MT
3175# g_test_trap_subprocess added in 2.38. Used by some tests.
3176glib_subprocess=yes
a049223a 3177if ! $pkg_config --atleast-version=2.38 glib-2.0; then
9d41401b
MT
3178 glib_subprocess=no
3179fi
3180
bbbf2e04
JS
3181# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3182cat > $TMPC << EOF
3183#include <glib.h>
3184int main(void) { return 0; }
3185EOF
3186if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3187 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3188 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3189 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3190 fi
3191fi
3192
e26110cf
FZ
3193##########################################
3194# SHA command probe for modules
3195if test "$modules" = yes; then
3196 shacmd_probe="sha1sum sha1 shasum"
3197 for c in $shacmd_probe; do
8ccefb91 3198 if has $c; then
e26110cf
FZ
3199 shacmd="$c"
3200 break
3201 fi
3202 done
3203 if test "$shacmd" = ""; then
3204 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3205 fi
e18df141
AL
3206fi
3207
e2134eb9
GH
3208##########################################
3209# pixman support probe
3210
3211if test "$pixman" = ""; then
74880fe2
RS
3212 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3213 pixman="none"
236f282c 3214 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
e2134eb9
GH
3215 pixman="system"
3216 else
3217 pixman="internal"
3218 fi
3219fi
74880fe2
RS
3220if test "$pixman" = "none"; then
3221 if test "$want_tools" != "no" -o "$softmmu" != "no"; then
76ad07a4
PM
3222 error_exit "pixman disabled but system emulation or tools build" \
3223 "enabled. You can turn off pixman only if you also" \
3224 "disable all system emulation targets and the tools" \
3225 "build with '--disable-tools --disable-system'."
74880fe2
RS
3226 fi
3227 pixman_cflags=
3228 pixman_libs=
3229elif test "$pixman" = "system"; then
236f282c 3230 # pixman version has been checked above
89138857
SW
3231 pixman_cflags=$($pkg_config --cflags pixman-1)
3232 pixman_libs=$($pkg_config --libs pixman-1)
e2134eb9
GH
3233else
3234 if test ! -d ${source_path}/pixman/pixman; then
236f282c 3235 error_exit "pixman >= 0.21.8 not present. Your options:" \
76ad07a4
PM
3236 " (1) Preferred: Install the pixman devel package (any recent" \
3237 " distro should have packages as Xorg needs pixman too)." \
3238 " (2) Fetch the pixman submodule, using:" \
3239 " git submodule update --init pixman"
e2134eb9 3240 fi
5ca9388a
GH
3241 mkdir -p pixman/pixman
3242 pixman_cflags="-I\$(SRC_PATH)/pixman/pixman -I\$(BUILD_DIR)/pixman/pixman"
3243 pixman_libs="-L\$(BUILD_DIR)/pixman/pixman/.libs -lpixman-1"
e2134eb9 3244fi
e2134eb9 3245
17bff52b
MK
3246##########################################
3247# libcap probe
3248
3249if test "$cap" != "no" ; then
3250 cat > $TMPC <<EOF
3251#include <stdio.h>
3252#include <sys/capability.h>
cc939743 3253int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
17bff52b
MK
3254EOF
3255 if compile_prog "" "-lcap" ; then
3256 cap=yes
3257 else
3258 cap=no
3259 fi
3260fi
3261
414f0dab 3262##########################################
e5d355d1 3263# pthread probe
4b29ec41 3264PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3c529d93 3265
4dd75c70 3266pthread=no
e5d355d1 3267cat > $TMPC << EOF
3c529d93 3268#include <pthread.h>
7a42bbe4
SW
3269static void *f(void *p) { return NULL; }
3270int main(void) {
3271 pthread_t thread;
3272 pthread_create(&thread, 0, f, 0);
3273 return 0;
3274}
414f0dab 3275EOF
bd00d539
AF
3276if compile_prog "" "" ; then
3277 pthread=yes
3278else
3279 for pthread_lib in $PTHREADLIBS_LIST; do
3280 if compile_prog "" "$pthread_lib" ; then
3281 pthread=yes
e3c56761
PP
3282 found=no
3283 for lib_entry in $LIBS; do
3284 if test "$lib_entry" = "$pthread_lib"; then
3285 found=yes
3286 break
3287 fi
3288 done
3289 if test "$found" = "no"; then
3290 LIBS="$pthread_lib $LIBS"
3291 fi
409437e1 3292 PTHREAD_LIB="$pthread_lib"
bd00d539
AF
3293 break
3294 fi
3295 done
3296fi
414f0dab 3297
4617e593 3298if test "$mingw32" != yes -a "$pthread" = no; then
76ad07a4
PM
3299 error_exit "pthread check failed" \
3300 "Make sure to have the pthread libs and headers installed."
e5d355d1
AL
3301fi
3302
5c312079
DDAG
3303# check for pthread_setname_np
3304pthread_setname_np=no
3305cat > $TMPC << EOF
3306#include <pthread.h>
3307
3308static void *f(void *p) { return NULL; }
3309int main(void)
3310{
3311 pthread_t thread;
3312 pthread_create(&thread, 0, f, 0);
3313 pthread_setname_np(thread, "QEMU");
3314 return 0;
3315}
3316EOF
3317if compile_prog "" "$pthread_lib" ; then
3318 pthread_setname_np=yes
3319fi
3320
f27aaf4b
CB
3321##########################################
3322# rbd probe
3323if test "$rbd" != "no" ; then
3324 cat > $TMPC <<EOF
3325#include <stdio.h>
ad32e9c0 3326#include <rbd/librbd.h>
f27aaf4b 3327int main(void) {
ad32e9c0
JD
3328 rados_t cluster;
3329 rados_create(&cluster, NULL);
f27aaf4b
CB
3330 return 0;
3331}
3332EOF
ad32e9c0
JD
3333 rbd_libs="-lrbd -lrados"
3334 if compile_prog "" "$rbd_libs" ; then
3335 rbd=yes
f27aaf4b
CB
3336 else
3337 if test "$rbd" = "yes" ; then
21684af0 3338 feature_not_found "rados block device" "Install librbd/ceph devel"
f27aaf4b
CB
3339 fi
3340 rbd=no
3341 fi
f27aaf4b
CB
3342fi
3343
0a12ec87
RJ
3344##########################################
3345# libssh2 probe
4fc16838 3346min_libssh2_version=1.2.8
0a12ec87 3347if test "$libssh2" != "no" ; then
65d5d3f9 3348 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
89138857
SW
3349 libssh2_cflags=$($pkg_config libssh2 --cflags)
3350 libssh2_libs=$($pkg_config libssh2 --libs)
0a12ec87 3351 libssh2=yes
0a12ec87
RJ
3352 else
3353 if test "$libssh2" = "yes" ; then
4fc16838 3354 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
0a12ec87
RJ
3355 fi
3356 libssh2=no
3357 fi
3358fi
3359
9a2d462e
RJ
3360##########################################
3361# libssh2_sftp_fsync probe
3362
3363if test "$libssh2" = "yes"; then
3364 cat > $TMPC <<EOF
3365#include <stdio.h>
3366#include <libssh2.h>
3367#include <libssh2_sftp.h>
3368int main(void) {
3369 LIBSSH2_SESSION *session;
3370 LIBSSH2_SFTP *sftp;
3371 LIBSSH2_SFTP_HANDLE *sftp_handle;
3372 session = libssh2_session_init ();
3373 sftp = libssh2_sftp_init (session);
3374 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3375 libssh2_sftp_fsync (sftp_handle);
3376 return 0;
3377}
3378EOF
3379 # libssh2_cflags/libssh2_libs defined in previous test.
3380 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3381 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3382 fi
3383fi
3384
5c6c3a6c
CH
3385##########################################
3386# linux-aio probe
5c6c3a6c
CH
3387
3388if test "$linux_aio" != "no" ; then
3389 cat > $TMPC <<EOF
3390#include <libaio.h>
3391#include <sys/eventfd.h>
832ce9c2 3392#include <stddef.h>
5c6c3a6c
CH
3393int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3394EOF
3395 if compile_prog "" "-laio" ; then
3396 linux_aio=yes
5c6c3a6c
CH
3397 else
3398 if test "$linux_aio" = "yes" ; then
21684af0 3399 feature_not_found "linux AIO" "Install libaio devel"
5c6c3a6c 3400 fi
3cfcae3c 3401 linux_aio=no
5c6c3a6c
CH
3402 fi
3403fi
3404
3b8acc11
PB
3405##########################################
3406# TPM passthrough is only on x86 Linux
3407
3408if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3409 tpm_passthrough=$tpm
3410else
3411 tpm_passthrough=no
3412fi
3413
758e8e38
VJ
3414##########################################
3415# attr probe
3416
3417if test "$attr" != "no" ; then
3418 cat > $TMPC <<EOF
3419#include <stdio.h>
3420#include <sys/types.h>
f2338fb4
PB
3421#ifdef CONFIG_LIBATTR
3422#include <attr/xattr.h>
3423#else
4f26f2b6 3424#include <sys/xattr.h>
f2338fb4 3425#endif
758e8e38
VJ
3426int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3427EOF
4f26f2b6
AK
3428 if compile_prog "" "" ; then
3429 attr=yes
3430 # Older distros have <attr/xattr.h>, and need -lattr:
f2338fb4 3431 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
758e8e38
VJ
3432 attr=yes
3433 LIBS="-lattr $LIBS"
4f26f2b6 3434 libattr=yes
758e8e38
VJ
3435 else
3436 if test "$attr" = "yes" ; then
21684af0 3437 feature_not_found "ATTR" "Install libc6 or libattr devel"
758e8e38
VJ
3438 fi
3439 attr=no
3440 fi
3441fi
3442
bf9298b9
AL
3443##########################################
3444# iovec probe
3445cat > $TMPC <<EOF
db34f0b3 3446#include <sys/types.h>
bf9298b9 3447#include <sys/uio.h>
db34f0b3 3448#include <unistd.h>
f91f9bee 3449int main(void) { return sizeof(struct iovec); }
bf9298b9
AL
3450EOF
3451iovec=no
52166aa0 3452if compile_prog "" "" ; then
bf9298b9
AL
3453 iovec=yes
3454fi
3455
ceb42de8
AL
3456##########################################
3457# preadv probe
3458cat > $TMPC <<EOF
3459#include <sys/types.h>
3460#include <sys/uio.h>
3461#include <unistd.h>
c075a723 3462int main(void) { return preadv(0, 0, 0, 0); }
ceb42de8
AL
3463EOF
3464preadv=no
52166aa0 3465if compile_prog "" "" ; then
ceb42de8
AL
3466 preadv=yes
3467fi
3468
f652e6af
AJ
3469##########################################
3470# fdt probe
e169e1e1
PM
3471# fdt support is mandatory for at least some target architectures,
3472# so insist on it if we're building those system emulators.
3473fdt_required=no
3474for target in $target_list; do
3475 case $target in
df1d8a1f 3476 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
e169e1e1
PM
3477 fdt_required=yes
3478 ;;
3479 esac
3480done
3481
3482if test "$fdt_required" = "yes"; then
3483 if test "$fdt" = "no"; then
3484 error_exit "fdt disabled but some requested targets require it." \
3485 "You can turn off fdt only if you also disable all the system emulation" \
3486 "targets which need it (by specifying a cut down --target-list)."
3487 fi
3488 fdt=yes
3489fi
3490
2df87df7 3491if test "$fdt" != "no" ; then
b41af4ba 3492 fdt_libs="-lfdt"
96ce6545 3493 # explicitly check for libfdt_env.h as it is missing in some stable installs
6e85fce0 3494 # and test for required functions to make sure we are on a version >= 1.4.2
b41af4ba 3495 cat > $TMPC << EOF
31ce0adb 3496#include <libfdt.h>
96ce6545 3497#include <libfdt_env.h>
6e85fce0 3498int main(void) { fdt_first_subnode(0, 0); return 0; }
f652e6af 3499EOF
52166aa0 3500 if compile_prog "" "$fdt_libs" ; then
a540f158 3501 # system DTC is good - use it
f652e6af 3502 fdt=yes
a540f158
PC
3503 elif test -d ${source_path}/dtc/libfdt ; then
3504 # have submodule DTC - use it
3505 fdt=yes
3506 dtc_internal="yes"
3507 mkdir -p dtc
cab00a5a 3508 if [ "$pwd_is_source_path" != "y" ] ; then
a540f158
PC
3509 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3510 symlink "$source_path/dtc/scripts" "dtc/scripts"
2df87df7 3511 fi
a540f158
PC
3512 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3513 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3514 elif test "$fdt" = "yes" ; then
3515 # have neither and want - prompt for system/submodule install
6e85fce0 3516 error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
3f281822 3517 " (1) Preferred: Install the DTC (libfdt) devel package" \
a540f158
PC
3518 " (2) Fetch the DTC submodule, using:" \
3519 " git submodule update --init dtc"
3520 else
3521 # don't have and don't want
de3a354a 3522 fdt_libs=
2df87df7 3523 fdt=no
f652e6af
AJ
3524 fi
3525fi
3526
a540f158
PC
3527libs_softmmu="$libs_softmmu $fdt_libs"
3528
20ff075b 3529##########################################
fb719563 3530# opengl probe (for sdl2, gtk, milkymist-tmu2)
b1546f32 3531
da076ffe 3532if test "$opengl" != "no" ; then
014cb152 3533 opengl_pkgs="epoxy libdrm gbm"
fb719563 3534 if $pkg_config $opengl_pkgs x11; then
f676c67e
JW
3535 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3536 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
da076ffe 3537 opengl=yes
925a0400
GH
3538 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3539 gtk_gl="yes"
3540 fi
cc720a5d 3541 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
20ff075b 3542 else
da076ffe 3543 if test "$opengl" = "yes" ; then
dcf30025 3544 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
20ff075b 3545 fi
f676c67e 3546 opengl_cflags=""
da076ffe
GH
3547 opengl_libs=""
3548 opengl=no
20ff075b
MW
3549 fi
3550fi
3551
014cb152
GH
3552if test "$opengl" = "yes"; then
3553 cat > $TMPC << EOF
3554#include <epoxy/egl.h>
3555#ifndef EGL_MESA_image_dma_buf_export
3556# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3557#endif
3558int main(void) { return 0; }
3559EOF
3560 if compile_prog "" "" ; then
3561 opengl_dmabuf=yes
3562 fi
3563fi
c9a12e75 3564
c9a12e75 3565
eb100396
BR
3566##########################################
3567# glusterfs probe
3568if test "$glusterfs" != "no" ; then
65d5d3f9 3569 if $pkg_config --atleast-version=3 glusterfs-api; then
e01bee08 3570 glusterfs="yes"
89138857
SW
3571 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3572 glusterfs_libs=$($pkg_config --libs glusterfs-api)
d85fa9eb
JC
3573 if $pkg_config --atleast-version=4 glusterfs-api; then
3574 glusterfs_xlator_opt="yes"
3575 fi
65d5d3f9 3576 if $pkg_config --atleast-version=5 glusterfs-api; then
0c14fb47
BR
3577 glusterfs_discard="yes"
3578 fi
7c815372
BR
3579 if $pkg_config --atleast-version=6 glusterfs-api; then
3580 glusterfs_zerofill="yes"
3581 fi
eb100396
BR
3582 else
3583 if test "$glusterfs" = "yes" ; then
8efc9363
HT
3584 feature_not_found "GlusterFS backend support" \
3585 "Install glusterfs-api devel >= 3"
eb100396 3586 fi
e01bee08 3587 glusterfs="no"
eb100396
BR
3588 fi
3589fi
3590
39386ac7 3591# Check for inotify functions when we are building linux-user
3b3f24ad
AJ
3592# emulator. This is done because older glibc versions don't
3593# have syscall stubs for these implemented. In that case we
3594# don't provide them even if kernel supports them.
3595#
3596inotify=no
67ba57f6 3597cat > $TMPC << EOF
3b3f24ad
AJ
3598#include <sys/inotify.h>
3599
3600int
3601main(void)
3602{
3603 /* try to start inotify */
8690e420 3604 return inotify_init();
3b3f24ad
AJ
3605}
3606EOF
52166aa0 3607if compile_prog "" "" ; then
67ba57f6 3608 inotify=yes
3b3f24ad
AJ
3609fi
3610
c05c7a73
RV
3611inotify1=no
3612cat > $TMPC << EOF
3613#include <sys/inotify.h>
3614
3615int
3616main(void)
3617{
3618 /* try to start inotify */
3619 return inotify_init1(0);
3620}
3621EOF
3622if compile_prog "" "" ; then
3623 inotify1=yes
3624fi
3625
ebc996f3
RV
3626# check if utimensat and futimens are supported
3627utimens=no
3628cat > $TMPC << EOF
3629#define _ATFILE_SOURCE
ebc996f3
RV
3630#include <stddef.h>
3631#include <fcntl.h>
3014ee00 3632#include <sys/stat.h>
ebc996f3
RV
3633
3634int main(void)
3635{
3636 utimensat(AT_FDCWD, "foo", NULL, 0);
3637 futimens(0, NULL);
3638 return 0;
3639}
3640EOF
52166aa0 3641if compile_prog "" "" ; then
ebc996f3
RV
3642 utimens=yes
3643fi
3644
099d6b0f
RV
3645# check if pipe2 is there
3646pipe2=no
3647cat > $TMPC << EOF
099d6b0f
RV
3648#include <unistd.h>
3649#include <fcntl.h>
3650
3651int main(void)
3652{
3653 int pipefd[2];
9bca8162 3654 return pipe2(pipefd, O_CLOEXEC);
099d6b0f
RV
3655}
3656EOF
52166aa0 3657if compile_prog "" "" ; then
099d6b0f
RV
3658 pipe2=yes
3659fi
3660
40ff6d7e
KW
3661# check if accept4 is there
3662accept4=no
3663cat > $TMPC << EOF
40ff6d7e
KW
3664#include <sys/socket.h>
3665#include <stddef.h>
3666
3667int main(void)
3668{
3669 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3670 return 0;
3671}
3672EOF
3673if compile_prog "" "" ; then
3674 accept4=yes
3675fi
3676
3ce34dfb
VS
3677# check if tee/splice is there. vmsplice was added same time.
3678splice=no
3679cat > $TMPC << EOF
3ce34dfb
VS
3680#include <unistd.h>
3681#include <fcntl.h>
3682#include <limits.h>
3683
3684int main(void)
3685{
66ea0f22 3686 int len, fd = 0;
3ce34dfb
VS
3687 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3688 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3689 return 0;
3690}
3691EOF
52166aa0 3692if compile_prog "" "" ; then
3ce34dfb
VS
3693 splice=yes
3694fi
3695
a99d57bb
WG
3696##########################################
3697# libnuma probe
3698
3699if test "$numa" != "no" ; then
3700 cat > $TMPC << EOF
3701#include <numa.h>
3702int main(void) { return numa_available(); }
3703EOF
3704
3705 if compile_prog "" "-lnuma" ; then
3706 numa=yes
3707 libs_softmmu="-lnuma $libs_softmmu"
3708 else
3709 if test "$numa" = "yes" ; then
3710 feature_not_found "numa" "install numactl devel"
3711 fi
3712 numa=no
3713 fi
3714fi
3715
7b01cb97
AD
3716if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3717 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3718 exit 1
3719fi
3720
2847b469
FZ
3721##########################################
3722# tcmalloc probe
3723
3724if test "$tcmalloc" = "yes" ; then
3725 cat > $TMPC << EOF
3726#include <stdlib.h>
3727int main(void) { malloc(1); return 0; }
3728EOF
3729
3730 if compile_prog "" "-ltcmalloc" ; then
3731 LIBS="-ltcmalloc $LIBS"
3732 else
3733 feature_not_found "tcmalloc" "install gperftools devel"
3734 fi
3735fi
3736
7b01cb97
AD
3737##########################################
3738# jemalloc probe
3739
3740if test "$jemalloc" = "yes" ; then
3741 cat > $TMPC << EOF
3742#include <stdlib.h>
3743int main(void) { malloc(1); return 0; }
3744EOF
3745
3746 if compile_prog "" "-ljemalloc" ; then
3747 LIBS="-ljemalloc $LIBS"
3748 else
3749 feature_not_found "jemalloc" "install jemalloc devel"
3750 fi
3751fi
3752
dcc38d1c
MT
3753##########################################
3754# signalfd probe
3755signalfd="no"
3756cat > $TMPC << EOF
dcc38d1c
MT
3757#include <unistd.h>
3758#include <sys/syscall.h>
3759#include <signal.h>
3760int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3761EOF
3762
3763if compile_prog "" "" ; then
3764 signalfd=yes
3765fi
3766
c2882b96
RV
3767# check if eventfd is supported
3768eventfd=no
3769cat > $TMPC << EOF
3770#include <sys/eventfd.h>
3771
3772int main(void)
3773{
55cc7f3e 3774 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
c2882b96
RV
3775}
3776EOF
3777if compile_prog "" "" ; then
3778 eventfd=yes
3779fi
3780
751bcc39
MAL
3781# check if memfd is supported
3782memfd=no
3783cat > $TMPC << EOF
3784#include <sys/memfd.h>
3785
3786int main(void)
3787{
3788 return memfd_create("foo", MFD_ALLOW_SEALING);
3789}
3790EOF
3791if compile_prog "" "" ; then
3792 memfd=yes
3793fi
3794
3795
3796
d0927938
UH
3797# check for fallocate
3798fallocate=no
3799cat > $TMPC << EOF
3800#include <fcntl.h>
3801
3802int main(void)
3803{
3804 fallocate(0, 0, 0, 0);
3805 return 0;
3806}
3807EOF
8fb03151 3808if compile_prog "" "" ; then
d0927938
UH
3809 fallocate=yes
3810fi
3811
3d4fa43e
KK
3812# check for fallocate hole punching
3813fallocate_punch_hole=no
3814cat > $TMPC << EOF
3815#include <fcntl.h>
3816#include <linux/falloc.h>
3817
3818int main(void)
3819{
3820 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
3821 return 0;
3822}
3823EOF
3824if compile_prog "" "" ; then
3825 fallocate_punch_hole=yes
3826fi
3827
b953f075
DL
3828# check that fallocate supports range zeroing inside the file
3829fallocate_zero_range=no
3830cat > $TMPC << EOF
3831#include <fcntl.h>
3832#include <linux/falloc.h>
3833
3834int main(void)
3835{
3836 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3837 return 0;
3838}
3839EOF
3840if compile_prog "" "" ; then
3841 fallocate_zero_range=yes
3842fi
3843
ed911435
KW
3844# check for posix_fallocate
3845posix_fallocate=no
3846cat > $TMPC << EOF
3847#include <fcntl.h>
3848
3849int main(void)
3850{
3851 posix_fallocate(0, 0, 0);
3852 return 0;
3853}
3854EOF
3855if compile_prog "" "" ; then
3856 posix_fallocate=yes
3857fi
3858
c727f47d
PM
3859# check for sync_file_range
3860sync_file_range=no
3861cat > $TMPC << EOF
3862#include <fcntl.h>
3863
3864int main(void)
3865{
3866 sync_file_range(0, 0, 0, 0);
3867 return 0;
3868}
3869EOF
8fb03151 3870if compile_prog "" "" ; then
c727f47d
PM
3871 sync_file_range=yes
3872fi
3873
dace20dc
PM
3874# check for linux/fiemap.h and FS_IOC_FIEMAP
3875fiemap=no
3876cat > $TMPC << EOF
3877#include <sys/ioctl.h>
3878#include <linux/fs.h>
3879#include <linux/fiemap.h>
3880
3881int main(void)
3882{
3883 ioctl(0, FS_IOC_FIEMAP, 0);
3884 return 0;
3885}
3886EOF
8fb03151 3887if compile_prog "" "" ; then
dace20dc
PM
3888 fiemap=yes
3889fi
3890
d0927938
UH
3891# check for dup3
3892dup3=no
3893cat > $TMPC << EOF
3894#include <unistd.h>
3895
3896int main(void)
3897{
3898 dup3(0, 0, 0);
3899 return 0;
3900}
3901EOF
78f5d726 3902if compile_prog "" "" ; then
d0927938
UH
3903 dup3=yes
3904fi
3905
4e0c6529
AB
3906# check for ppoll support
3907ppoll=no
3908cat > $TMPC << EOF
3909#include <poll.h>
3910
3911int main(void)
3912{
3913 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
3914 ppoll(&pfd, 1, 0, 0);
3915 return 0;
3916}
3917EOF
3918if compile_prog "" "" ; then
3919 ppoll=yes
3920fi
3921
cd758dd0
AB
3922# check for prctl(PR_SET_TIMERSLACK , ... ) support
3923prctl_pr_set_timerslack=no
3924cat > $TMPC << EOF
3925#include <sys/prctl.h>
3926
3927int main(void)
3928{
3929 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3930 return 0;
3931}
3932EOF
3933if compile_prog "" "" ; then
3934 prctl_pr_set_timerslack=yes
3935fi
3936
3b6edd16
PM
3937# check for epoll support
3938epoll=no
3939cat > $TMPC << EOF
3940#include <sys/epoll.h>
3941
3942int main(void)
3943{
3944 epoll_create(0);
3945 return 0;
3946}
3947EOF
8fb03151 3948if compile_prog "" "" ; then
3b6edd16
PM
3949 epoll=yes
3950fi
3951
227f0214
PM
3952# epoll_create1 is a later addition
3953# so we must check separately for its presence
3b6edd16
PM
3954epoll_create1=no
3955cat > $TMPC << EOF
3956#include <sys/epoll.h>
3957
3958int main(void)
3959{
19e83f6b
PM
3960 /* Note that we use epoll_create1 as a value, not as
3961 * a function being called. This is necessary so that on
3962 * old SPARC glibc versions where the function was present in
3963 * the library but not declared in the header file we will
3964 * fail the configure check. (Otherwise we will get a compiler
3965 * warning but not an error, and will proceed to fail the
3966 * qemu compile where we compile with -Werror.)
3967 */
c075a723 3968 return (int)(uintptr_t)&epoll_create1;
3b6edd16
PM
3969}
3970EOF
8fb03151 3971if compile_prog "" "" ; then
3b6edd16
PM
3972 epoll_create1=yes
3973fi
3974
a8fd1aba
PM
3975# check for sendfile support
3976sendfile=no
3977cat > $TMPC << EOF
3978#include <sys/sendfile.h>
3979
3980int main(void)
3981{
3982 return sendfile(0, 0, 0, 0);
3983}
3984EOF
3985if compile_prog "" "" ; then
3986 sendfile=yes
3987fi
3988
51834341
RV
3989# check for timerfd support (glibc 2.8 and newer)
3990timerfd=no
3991cat > $TMPC << EOF
3992#include <sys/timerfd.h>
3993
3994int main(void)
3995{
3996 return(timerfd_create(CLOCK_REALTIME, 0));
3997}
3998EOF
3999if compile_prog "" "" ; then
4000 timerfd=yes
4001fi
4002
9af5c906
RV
4003# check for setns and unshare support
4004setns=no
4005cat > $TMPC << EOF
4006#include <sched.h>
4007
4008int main(void)
4009{
4010 int ret;
4011 ret = setns(0, 0);
4012 ret = unshare(0);
4013 return ret;
4014}
4015EOF
4016if compile_prog "" "" ; then
4017 setns=yes
4018fi
4019
38860a03
AM
4020# clock_adjtime probe
4021clock_adjtime=no
4022cat > $TMPC <<EOF
4023#include <time.h>
4024
4025int main(void)
4026{
4027 return clock_adjtime(0, 0);
4028}
4029EOF
4030clock_adjtime=no
4031if compile_prog "" "" ; then
4032 clock_adjtime=yes
4033fi
4034
5a03cd00
AM
4035# syncfs probe
4036syncfs=no
4037cat > $TMPC <<EOF
4038#include <unistd.h>
4039
4040int main(void)
4041{
4042 return syncfs(0);
4043}
4044EOF
4045syncfs=no
4046if compile_prog "" "" ; then
4047 syncfs=yes
4048fi
4049
cc8ae6de 4050# Check if tools are available to build documentation.
a25dba17 4051if test "$docs" != "no" ; then
01668d98 4052 if has makeinfo && has pod2man; then
a25dba17 4053 docs=yes
83a3ab8b 4054 else
a25dba17 4055 if test "$docs" = "yes" ; then
21684af0 4056 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
83a3ab8b 4057 fi
a25dba17 4058 docs=no
83a3ab8b 4059 fi
cc8ae6de
PB
4060fi
4061
f514f41c 4062# Search for bswap_32 function
6ae9a1f4
JQ
4063byteswap_h=no
4064cat > $TMPC << EOF
4065#include <byteswap.h>
4066int main(void) { return bswap_32(0); }
4067EOF
52166aa0 4068if compile_prog "" "" ; then
6ae9a1f4
JQ
4069 byteswap_h=yes
4070fi
4071
75f13596 4072# Search for bswap32 function
6ae9a1f4
JQ
4073bswap_h=no
4074cat > $TMPC << EOF
4075#include <sys/endian.h>
4076#include <sys/types.h>
4077#include <machine/bswap.h>
4078int main(void) { return bswap32(0); }
4079EOF
52166aa0 4080if compile_prog "" "" ; then
6ae9a1f4
JQ
4081 bswap_h=yes
4082fi
4083
c589b249 4084##########################################
e49ab19f 4085# Do we have libiscsi >= 1.9.0
c589b249 4086if test "$libiscsi" != "no" ; then
e49ab19f 4087 if $pkg_config --atleast-version=1.9.0 libiscsi; then
3c33ea96 4088 libiscsi="yes"
ca871ec8
SW
4089 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4090 libiscsi_libs=$($pkg_config --libs libiscsi)
c589b249
RS
4091 else
4092 if test "$libiscsi" = "yes" ; then
e49ab19f 4093 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
c589b249
RS
4094 fi
4095 libiscsi="no"
4096 fi
4097fi
4098
8bacde8d
NC
4099##########################################
4100# Do we need libm
4101cat > $TMPC << EOF
4102#include <math.h>
f80ea986 4103int main(int argc, char **argv) { return isnan(sin((double)argc)); }
8bacde8d
NC
4104EOF
4105if compile_prog "" "" ; then
4106 :
4107elif compile_prog "" "-lm" ; then
4108 LIBS="-lm $LIBS"
4109 libs_qga="-lm $libs_qga"
4110else
76ad07a4 4111 error_exit "libm check failed"
8bacde8d
NC
4112fi
4113
da93a1fd
AL
4114##########################################
4115# Do we need librt
8bacde8d
NC
4116# uClibc provides 2 versions of clock_gettime(), one with realtime
4117# support and one without. This means that the clock_gettime() don't
4118# need -lrt. We still need it for timer_create() so we check for this
4119# function in addition.
da93a1fd
AL
4120cat > $TMPC <<EOF
4121#include <signal.h>
4122#include <time.h>
8bacde8d
NC
4123int main(void) {
4124 timer_create(CLOCK_REALTIME, NULL, NULL);
4125 return clock_gettime(CLOCK_REALTIME, NULL);
4126}
da93a1fd
AL
4127EOF
4128
52166aa0 4129if compile_prog "" "" ; then
07ffa4bd 4130 :
8bacde8d 4131# we need pthread for static linking. use previous pthread test result
18e588b1
RL
4132elif compile_prog "" "$pthread_lib -lrt" ; then
4133 LIBS="$LIBS -lrt"
4134 libs_qga="$libs_qga -lrt"
da93a1fd
AL
4135fi
4136
31ff504d 4137if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
179cf400 4138 "$aix" != "yes" -a "$haiku" != "yes" ; then
6362a53f
JQ
4139 libs_softmmu="-lutil $libs_softmmu"
4140fi
4141
de5071c5 4142##########################################
cd4ec0b4
GH
4143# spice probe
4144if test "$spice" != "no" ; then
4145 cat > $TMPC << EOF
4146#include <spice.h>
4147int main(void) { spice_server_new(); return 0; }
4148EOF
710fc4f5
JD
4149 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4150 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
65d5d3f9
SW
4151 if $pkg_config --atleast-version=0.12.0 spice-server && \
4152 $pkg_config --atleast-version=0.12.3 spice-protocol && \
cd4ec0b4
GH
4153 compile_prog "$spice_cflags" "$spice_libs" ; then
4154 spice="yes"
4155 libs_softmmu="$libs_softmmu $spice_libs"
4156 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
2e0e3c39
AL
4157 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4158 spice_server_version=$($pkg_config --modversion spice-server)
cd4ec0b4
GH
4159 else
4160 if test "$spice" = "yes" ; then
8efc9363
HT
4161 feature_not_found "spice" \
4162 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
cd4ec0b4
GH
4163 fi
4164 spice="no"
4165 fi
4166fi
4167
7b02f544 4168# check for smartcard support
afd347ab 4169smartcard_cflags=""
7b02f544
MAL
4170if test "$smartcard" != "no"; then
4171 if $pkg_config libcacard; then
4172 libcacard_cflags=$($pkg_config --cflags libcacard)
4173 libcacard_libs=$($pkg_config --libs libcacard)
4174 QEMU_CFLAGS="$QEMU_CFLAGS $libcacard_cflags"
4175 libs_softmmu="$libs_softmmu $libcacard_libs"
4176 smartcard="yes"
afd347ab 4177 else
7b02f544
MAL
4178 if test "$smartcard" = "yes"; then
4179 feature_not_found "smartcard" "Install libcacard devel"
111a38b0 4180 fi
7b02f544 4181 smartcard="no"
111a38b0
RR
4182 fi
4183fi
111a38b0 4184
2b2325ff
GH
4185# check for libusb
4186if test "$libusb" != "no" ; then
65d5d3f9 4187 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
2b2325ff 4188 libusb="yes"
ca871ec8
SW
4189 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4190 libusb_libs=$($pkg_config --libs libusb-1.0)
2b2325ff
GH
4191 QEMU_CFLAGS="$QEMU_CFLAGS $libusb_cflags"
4192 libs_softmmu="$libs_softmmu $libusb_libs"
4193 else
4194 if test "$libusb" = "yes"; then
8efc9363 4195 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
2b2325ff
GH
4196 fi
4197 libusb="no"
4198 fi
4199fi
4200
69354a83
HG
4201# check for usbredirparser for usb network redirection support
4202if test "$usb_redir" != "no" ; then
65d5d3f9 4203 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
69354a83 4204 usb_redir="yes"
ca871ec8
SW
4205 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4206 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
69354a83 4207 QEMU_CFLAGS="$QEMU_CFLAGS $usb_redir_cflags"
56ab2ad1 4208 libs_softmmu="$libs_softmmu $usb_redir_libs"
69354a83
HG
4209 else
4210 if test "$usb_redir" = "yes"; then
21684af0 4211 feature_not_found "usb-redir" "Install usbredir devel"
69354a83
HG
4212 fi
4213 usb_redir="no"
4214 fi
4215fi
4216
d9840e25
TS
4217##########################################
4218# check if we have VSS SDK headers for win
4219
4220if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4221 case "$vss_win32_sdk" in
690604f6 4222 "") vss_win32_include="-isystem $source_path" ;;
d9840e25
TS
4223 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4224 # handle path with spaces. So we symlink the headers into ".sdk/vss".
690604f6 4225 vss_win32_include="-isystem $source_path/.sdk/vss"
d9840e25
TS
4226 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4227 ;;
690604f6 4228 *) vss_win32_include="-isystem $vss_win32_sdk"
d9840e25
TS
4229 esac
4230 cat > $TMPC << EOF
4231#define __MIDL_user_allocate_free_DEFINED__
4232#include <inc/win2003/vss.h>
4233int main(void) { return VSS_CTX_BACKUP; }
4234EOF
4235 if compile_prog "$vss_win32_include" "" ; then
4236 guest_agent_with_vss="yes"
4237 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
315d3184 4238 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
f33ca81f 4239 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
d9840e25
TS
4240 else
4241 if test "$vss_win32_sdk" != "" ; then
4242 echo "ERROR: Please download and install Microsoft VSS SDK:"
4243 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4244 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4245 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4246 echo "ERROR: The headers are extracted in the directory \`inc'."
4247 feature_not_found "VSS support"
4248 fi
4249 guest_agent_with_vss="no"
4250 fi
4251fi
4252
4253##########################################
4254# lookup Windows platform SDK (if not specified)
4255# The SDK is needed only to build .tlb (type library) file of guest agent
4256# VSS provider from the source. It is usually unnecessary because the
4257# pre-compiled .tlb file is included.
4258
4259if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4260 if test -z "$win_sdk"; then
4261 programfiles="$PROGRAMFILES"
4262 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4263 if test -n "$programfiles"; then
4264 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4265 else
4266 feature_not_found "Windows SDK"
4267 fi
4268 elif test "$win_sdk" = "no"; then
4269 win_sdk=""
4270 fi
4271fi
4272
50cbebb9
MR
4273##########################################
4274# check if mingw environment provides a recent ntddscsi.h
4275if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4276 cat > $TMPC << EOF
4277#include <windows.h>
4278#include <ntddscsi.h>
4279int main(void) {
4280#if !defined(IOCTL_SCSI_GET_ADDRESS)
4281#error Missing required ioctl definitions
4282#endif
4283 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4284 return addr.Lun;
4285}
4286EOF
4287 if compile_prog "" "" ; then
4288 guest_agent_ntddscsi=yes
c54e1eb4 4289 libs_qga="-lsetupapi $libs_qga"
50cbebb9
MR
4290 fi
4291fi
4292
9d9e1521
GH
4293##########################################
4294# virgl renderer probe
4295
4296if test "$virglrenderer" != "no" ; then
4297 cat > $TMPC << EOF
4298#include <virglrenderer.h>
4299int main(void) { virgl_renderer_poll(); return 0; }
4300EOF
4301 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4302 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4303 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4304 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4305 virglrenderer="yes"
4306 else
4307 if test "$virglrenderer" = "yes" ; then
4308 feature_not_found "virglrenderer"
4309 fi
4310 virglrenderer="no"
4311 fi
4312fi
4313
5f6b9e8f
BS
4314##########################################
4315# check if we have fdatasync
4316
4317fdatasync=no
4318cat > $TMPC << EOF
4319#include <unistd.h>
d1722a27
AR
4320int main(void) {
4321#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4322return fdatasync(0);
4323#else
e172fe11 4324#error Not supported
d1722a27
AR
4325#endif
4326}
5f6b9e8f
BS
4327EOF
4328if compile_prog "" "" ; then
4329 fdatasync=yes
4330fi
4331
e78815a5
AF
4332##########################################
4333# check if we have madvise
4334
4335madvise=no
4336cat > $TMPC << EOF
4337#include <sys/types.h>
4338#include <sys/mman.h>
832ce9c2 4339#include <stddef.h>
e78815a5
AF
4340int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4341EOF
4342if compile_prog "" "" ; then
4343 madvise=yes
4344fi
4345
4346##########################################
4347# check if we have posix_madvise
4348
4349posix_madvise=no
4350cat > $TMPC << EOF
4351#include <sys/mman.h>
832ce9c2 4352#include <stddef.h>
e78815a5
AF
4353int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4354EOF
4355if compile_prog "" "" ; then
4356 posix_madvise=yes
4357fi
4358
0a852417
PD
4359##########################################
4360# check if we have posix_syslog
4361
4362posix_syslog=no
4363cat > $TMPC << EOF
4364#include <syslog.h>
4365int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4366EOF
4367if compile_prog "" "" ; then
4368 posix_syslog=yes
4369fi
4370
94a420b1
SH
4371##########################################
4372# check if trace backend exists
4373
5b808275 4374$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
94a420b1 4375if test "$?" -ne 0 ; then
5b808275
LV
4376 error_exit "invalid trace backends" \
4377 "Please choose supported trace backends."
94a420b1
SH
4378fi
4379
7e24e92a
SH
4380##########################################
4381# For 'ust' backend, test if ust headers are present
5b808275 4382if have_backend "ust"; then
7e24e92a 4383 cat > $TMPC << EOF
bf15f63c 4384#include <lttng/tracepoint.h>
7e24e92a
SH
4385int main(void) { return 0; }
4386EOF
c79ed23d 4387 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
bf15f63c 4388 if $pkg_config lttng-ust --exists; then
89138857 4389 lttng_ust_libs=$($pkg_config --libs lttng-ust)
bf15f63c 4390 else
c79ed23d 4391 lttng_ust_libs="-llttng-ust -ldl"
bf15f63c
MG
4392 fi
4393 if $pkg_config liburcu-bp --exists; then
89138857 4394 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
bf15f63c
MG
4395 else
4396 urcu_bp_libs="-lurcu-bp"
4397 fi
4398
4399 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4400 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
7e24e92a 4401 else
bf15f63c 4402 error_exit "Trace backend 'ust' missing lttng-ust header files"
7e24e92a
SH
4403 fi
4404fi
b3d08c02
DB
4405
4406##########################################
4407# For 'dtrace' backend, test if 'dtrace' command is present
5b808275 4408if have_backend "dtrace"; then
b3d08c02 4409 if ! has 'dtrace' ; then
76ad07a4 4410 error_exit "dtrace command is not found in PATH $PATH"
b3d08c02 4411 fi
c276b17d
DB
4412 trace_backend_stap="no"
4413 if has 'stap' ; then
4414 trace_backend_stap="yes"
4415 fi
b3d08c02
DB
4416fi
4417
023367e6 4418##########################################
519175a2 4419# check and set a backend for coroutine
d0e2fce5 4420
7c2acc70 4421# We prefer ucontext, but it's not always possible. The fallback
33c53c54
DB
4422# is sigcontext. On Windows the only valid backend is the Windows
4423# specific one.
7c2acc70
PM
4424
4425ucontext_works=no
4426if test "$darwin" != "yes"; then
4427 cat > $TMPC << EOF
d0e2fce5 4428#include <ucontext.h>
cdf84806
PM
4429#ifdef __stub_makecontext
4430#error Ignoring glibc stub makecontext which will always fail
4431#endif
75cafad7 4432int main(void) { makecontext(0, 0, 0); return 0; }
d0e2fce5 4433EOF
7c2acc70
PM
4434 if compile_prog "" "" ; then
4435 ucontext_works=yes
4436 fi
4437fi
4438
4439if test "$coroutine" = ""; then
4440 if test "$mingw32" = "yes"; then
4441 coroutine=win32
4442 elif test "$ucontext_works" = "yes"; then
4443 coroutine=ucontext
4444 else
4445 coroutine=sigaltstack
d0e2fce5 4446 fi
519175a2 4447else
7c2acc70
PM
4448 case $coroutine in
4449 windows)
4450 if test "$mingw32" != "yes"; then
4451 error_exit "'windows' coroutine backend only valid for Windows"
4452 fi
4453 # Unfortunately the user visible backend name doesn't match the
4454 # coroutine-*.c filename for this case, so we have to adjust it here.
4455 coroutine=win32
4456 ;;
4457 ucontext)
4458 if test "$ucontext_works" != "yes"; then
4459 feature_not_found "ucontext"
4460 fi
4461 ;;
33c53c54 4462 sigaltstack)
7c2acc70
PM
4463 if test "$mingw32" = "yes"; then
4464 error_exit "only the 'windows' coroutine backend is valid for Windows"
4465 fi
4466 ;;
4467 *)
4468 error_exit "unknown coroutine backend $coroutine"
4469 ;;
4470 esac
d0e2fce5
AK
4471fi
4472
70c60c08 4473if test "$coroutine_pool" = ""; then
33c53c54 4474 coroutine_pool=yes
70c60c08
SH
4475fi
4476
7d992e4d
PL
4477if test "$debug_stack_usage" = "yes"; then
4478 if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
4479 error_exit "stack usage debugging is not supported for $cpu"
4480 fi
4481 if test "$coroutine_pool" = "yes"; then
4482 echo "WARN: disabling coroutine pool for stack usage debugging"
4483 coroutine_pool=no
4484 fi
4485fi
4486
4487
d2042378
AK
4488##########################################
4489# check if we have open_by_handle_at
4490
4e1797f9 4491open_by_handle_at=no
d2042378
AK
4492cat > $TMPC << EOF
4493#include <fcntl.h>
acc55ba8
SW
4494#if !defined(AT_EMPTY_PATH)
4495# error missing definition
4496#else
75cafad7 4497int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
acc55ba8 4498#endif
d2042378
AK
4499EOF
4500if compile_prog "" "" ; then
4501 open_by_handle_at=yes
4502fi
4503
e06a765e
HPB
4504########################################
4505# check if we have linux/magic.h
4506
4507linux_magic_h=no
4508cat > $TMPC << EOF
4509#include <linux/magic.h>
4510int main(void) {
75cafad7 4511 return 0;
e06a765e
HPB
4512}
4513EOF
4514if compile_prog "" "" ; then
4515 linux_magic_h=yes
4516fi
4517
06d71fa1 4518########################################
c95e3080
KW
4519# check whether we can disable warning option with a pragma (this is needed
4520# to silence warnings in the headers of some versions of external libraries).
4521# This test has to be compiled with -Werror as otherwise an unknown pragma is
4522# only a warning.
4523#
4524# If we can't selectively disable warning in the code, disable -Werror so that
4525# the build doesn't fail anyway.
4526
06d71fa1
PM
4527pragma_disable_unused_but_set=no
4528cat > $TMPC << EOF
e6f53fd5 4529#pragma GCC diagnostic push
06d71fa1 4530#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
c95e3080 4531#pragma GCC diagnostic ignored "-Wstrict-prototypes"
e6f53fd5 4532#pragma GCC diagnostic pop
c95e3080 4533
06d71fa1
PM
4534int main(void) {
4535 return 0;
4536}
4537EOF
4538if compile_prog "-Werror" "" ; then
cc6e3ca9 4539 pragma_diagnostic_available=yes
c95e3080
KW
4540else
4541 werror=no
06d71fa1
PM
4542fi
4543
3f4349dc 4544########################################
541be927 4545# check if we have valgrind/valgrind.h
3f4349dc
KW
4546
4547valgrind_h=no
4548cat > $TMPC << EOF
4549#include <valgrind/valgrind.h>
3f4349dc 4550int main(void) {
3f4349dc
KW
4551 return 0;
4552}
4553EOF
4554if compile_prog "" "" ; then
4555 valgrind_h=yes
4556fi
4557
8ab1bf12
LC
4558########################################
4559# check if environ is declared
4560
4561has_environ=no
4562cat > $TMPC << EOF
4563#include <unistd.h>
4564int main(void) {
c075a723 4565 environ = 0;
8ab1bf12
LC
4566 return 0;
4567}
4568EOF
4569if compile_prog "" "" ; then
4570 has_environ=yes
4571fi
4572
76a347e1
RH
4573########################################
4574# check if cpuid.h is usable.
4575
4576cpuid_h=no
4577cat > $TMPC << EOF
4578#include <cpuid.h>
4579int main(void) {
774d566c
PM
4580 unsigned a, b, c, d;
4581 int max = __get_cpuid_max(0, 0);
4582
4583 if (max >= 1) {
4584 __cpuid(1, a, b, c, d);
4585 }
4586
4587 if (max >= 7) {
4588 __cpuid_count(7, 0, a, b, c, d);
4589 }
4590
4591 return 0;
76a347e1
RH
4592}
4593EOF
4594if compile_prog "" "" ; then
4595 cpuid_h=yes
4596fi
4597
f540166b
RH
4598########################################
4599# check if __[u]int128_t is usable.
4600
4601int128=no
4602cat > $TMPC << EOF
a00f66ab
SW
4603#if defined(__clang_major__) && defined(__clang_minor__)
4604# if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4605# error __int128_t does not work in CLANG before 3.2
4606# endif
4607#endif
f540166b
RH
4608__int128_t a;
4609__uint128_t b;
4610int main (void) {
4611 a = a + b;
4612 b = a * b;
464e3671 4613 a = a * a;
f540166b
RH
4614 return 0;
4615}
4616EOF
4617if compile_prog "" "" ; then
4618 int128=yes
4619fi
76a347e1 4620
7ebee43e
RH
4621#########################################
4622# See if 128-bit atomic operations are supported.
4623
4624atomic128=no
4625if test "$int128" = "yes"; then
4626 cat > $TMPC << EOF
4627int main(void)
4628{
4629 unsigned __int128 x = 0, y = 0;
4630 y = __atomic_load_16(&x, 0);
4631 __atomic_store_16(&x, y, 0);
4632 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
4633 return 0;
4634}
4635EOF
4636 if compile_prog "" "" ; then
4637 atomic128=yes
4638 fi
4639fi
4640
df79b996
RH
4641#########################################
4642# See if 64-bit atomic operations are supported.
4643# Note that without __atomic builtins, we can only
4644# assume atomic loads/stores max at pointer size.
4645
4646cat > $TMPC << EOF
4647#include <stdint.h>
4648int main(void)
4649{
4650 uint64_t x = 0, y = 0;
4651#ifdef __ATOMIC_RELAXED
4652 y = __atomic_load_8(&x, 0);
4653 __atomic_store_8(&x, y, 0);
4654 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4655 __atomic_exchange_8(&x, y, 0);
4656 __atomic_fetch_add_8(&x, y, 0);
4657#else
4658 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4659 __sync_lock_test_and_set(&x, y);
4660 __sync_val_compare_and_swap(&x, y, 0);
4661 __sync_fetch_and_add(&x, y);
4662#endif
4663 return 0;
4664}
4665EOF
4666if compile_prog "" "" ; then
4667 atomic64=yes
4668fi
4669
1e6e9aca
RH
4670########################################
4671# check if getauxval is available.
4672
4673getauxval=no
4674cat > $TMPC << EOF
4675#include <sys/auxv.h>
4676int main(void) {
4677 return getauxval(AT_HWCAP) == 0;
4678}
4679EOF
4680if compile_prog "" "" ; then
4681 getauxval=yes
4682fi
4683
fd0e6053
JS
4684########################################
4685# check if ccache is interfering with
4686# semantic analysis of macros
4687
5e4dfd3d 4688unset CCACHE_CPP2
fd0e6053
JS
4689ccache_cpp2=no
4690cat > $TMPC << EOF
4691static const int Z = 1;
4692#define fn() ({ Z; })
4693#define TAUT(X) ((X) == Z)
4694#define PAREN(X, Y) (X == Y)
4695#define ID(X) (X)
4696int main(int argc, char *argv[])
4697{
4698 int x = 0, y = 0;
4699 x = ID(x);
4700 x = fn();
4701 fn();
4702 if (PAREN(x, y)) return 0;
4703 if (TAUT(Z)) return 0;
4704 return 0;
4705}
4706EOF
4707
4708if ! compile_object "-Werror"; then
4709 ccache_cpp2=yes
4710fi
4711
b553a042
JS
4712#################################################
4713# clang does not support glibc + FORTIFY_SOURCE.
4714
4715if test "$fortify_source" != "no"; then
4716 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4717 fortify_source="no";
cfcc7c14
JS
4718 elif test -n "$cxx" &&
4719 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
b553a042
JS
4720 fortify_source="no";
4721 else
4722 fortify_source="yes"
4723 fi
4724fi
4725
277abf15
JV
4726##########################################
4727# check if struct fsxattr is available via linux/fs.h
4728
4729have_fsxattr=no
4730cat > $TMPC << EOF
4731#include <linux/fs.h>
4732struct fsxattr foo;
4733int main(void) {
4734 return 0;
4735}
4736EOF
4737if compile_prog "" "" ; then
4738 have_fsxattr=yes
4739fi
4740
b66e10e4
PM
4741##########################################
4742# check if rtnetlink.h exists and is useful
575b22b1
LV
4743have_rtnetlink=no
4744cat > $TMPC << EOF
4745#include <linux/rtnetlink.h>
4746int main(void) {
4747 return IFLA_PROTO_DOWN;
4748}
4749EOF
4750if compile_prog "" "" ; then
4751 have_rtnetlink=yes
4752fi
4753
6a02c806
SH
4754##########################################
4755# check for usable AF_VSOCK environment
4756have_af_vsock=no
4757cat > $TMPC << EOF
4758#include <errno.h>
4759#include <sys/types.h>
4760#include <sys/socket.h>
4761#if !defined(AF_VSOCK)
4762# error missing AF_VSOCK flag
4763#endif
4764#include <linux/vm_sockets.h>
4765int main(void) {
4766 int sock, ret;
4767 struct sockaddr_vm svm;
4768 socklen_t len = sizeof(svm);
4769 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
4770 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
4771 if ((ret == -1) && (errno == ENOTCONN)) {
4772 return 0;
4773 }
4774 return -1;
4775}
4776EOF
4777if compile_prog "" "" ; then
4778 have_af_vsock=yes
4779fi
4780
6969ec6c
JC
4781#################################################
4782# Sparc implicitly links with --relax, which is
4783# incompatible with -r, so --no-relax should be
4784# given. It does no harm to give it on other
4785# platforms too.
4786
4787# Note: the prototype is needed since QEMU_CFLAGS
4788# contains -Wmissing-prototypes
4789cat > $TMPC << EOF
4790extern int foo(void);
4791int foo(void) { return 0; }
4792EOF
4793if ! compile_object ""; then
4794 error_exit "Failed to compile object file for LD_REL_FLAGS test"
4795fi
7ecf44a5
PB
4796for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
4797 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
4798 LD_REL_FLAGS=$i
4799 break
4800 fi
4801done
4802if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
4803 feature_not_found "modules" "Cannot find how to build relocatable objects"
6969ec6c
JC
4804fi
4805
4d04351f
CC
4806##########################################
4807# check for sysmacros.h
4808
4809have_sysmacros=no
4810cat > $TMPC << EOF
4811#include <sys/sysmacros.h>
4812int main(void) {
4813 return makedev(0, 0);
4814}
4815EOF
4816if compile_prog "" "" ; then
4817 have_sysmacros=yes
4818fi
4819
da92c3ff
AM
4820##########################################
4821# Veritas HyperScale block driver VxHS
4822# Check if libvxhs is installed
4823
4824if test "$vxhs" != "no" ; then
4825 cat > $TMPC <<EOF
4826#include <stdint.h>
4827#include <qnio/qnio_api.h>
4828
4829void *vxhs_callback;
4830
4831int main(void) {
4832 iio_init(QNIO_VERSION, vxhs_callback);
4833 return 0;
4834}
4835EOF
4836 vxhs_libs="-lvxhs -lssl"
4837 if compile_prog "" "$vxhs_libs" ; then
4838 vxhs=yes
4839 else
4840 if test "$vxhs" = "yes" ; then
4841 feature_not_found "vxhs block device" "Install libvxhs See github"
4842 fi
4843 vxhs=no
4844 fi
4845fi
4846
49e00a18
AG
4847##########################################
4848# check for _Static_assert()
4849
4850have_static_assert=no
4851cat > $TMPC << EOF
4852_Static_assert(1, "success");
4853int main(void) {
4854 return 0;
4855}
4856EOF
4857if compile_prog "" "" ; then
4858 have_static_assert=yes
4859fi
4860
7e24e92a 4861##########################################
e86ecd4b
JQ
4862# End of CC checks
4863# After here, no more $cc or $ld runs
4864
1d728c39
BS
4865if test "$gcov" = "yes" ; then
4866 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
4867 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
b553a042 4868elif test "$fortify_source" = "yes" ; then
e600cdf3 4869 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
ce278618
PM
4870elif test "$debug" = "no"; then
4871 CFLAGS="-O2 $CFLAGS"
e86ecd4b 4872fi
a316e378 4873
6542aa9c
PL
4874##########################################
4875# Do we have libnfs
4876if test "$libnfs" != "no" ; then
b7d769c9 4877 if $pkg_config --atleast-version=1.9.3 libnfs; then
6542aa9c
PL
4878 libnfs="yes"
4879 libnfs_libs=$($pkg_config --libs libnfs)
6542aa9c
PL
4880 else
4881 if test "$libnfs" = "yes" ; then
8efc9363 4882 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
6542aa9c
PL
4883 fi
4884 libnfs="no"
4885 fi
4886fi
1d728c39 4887
6ca026cb
PM
4888# Now we've finished running tests it's OK to add -Werror to the compiler flags
4889if test "$werror" = "yes"; then
4890 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
4891fi
4892
e86ecd4b
JQ
4893if test "$solaris" = "no" ; then
4894 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
1156c669 4895 LDFLAGS="-Wl,--warn-common $LDFLAGS"
e86ecd4b
JQ
4896 fi
4897fi
4898
94dd53c5
GH
4899# test if pod2man has --utf8 option
4900if pod2man --help | grep -q utf8; then
4901 POD2MAN="pod2man --utf8"
4902else
4903 POD2MAN="pod2man"
4904fi
4905
952afb71
BS
4906# Use ASLR, no-SEH and DEP if available
4907if test "$mingw32" = "yes" ; then
4908 for flag in --dynamicbase --no-seh --nxcompat; do
4909 if $ld --help 2>/dev/null | grep ".$flag" >/dev/null 2>/dev/null ; then
4910 LDFLAGS="-Wl,$flag $LDFLAGS"
4911 fi
4912 done
4913fi
4914
10ea68b3 4915qemu_confdir=$sysconfdir$confsuffix
e26110cf 4916qemu_moddir=$libdir$confsuffix
528ae5b8 4917qemu_datadir=$datadir$confsuffix
834574ea 4918qemu_localedir="$datadir/locale"
e7b45cc4 4919
4b1c11fd
DB
4920tools=""
4921if test "$want_tools" = "yes" ; then
ca35f780 4922 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
4b1c11fd
DB
4923 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
4924 tools="qemu-nbd\$(EXESUF) $tools"
a75eb03b 4925 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
4b1c11fd
DB
4926 fi
4927fi
4928if test "$softmmu" = yes ; then
983eef5a 4929 if test "$virtfs" != no ; then
aabfd88d
AF
4930 if test "$cap" = yes && test "$linux" = yes && test "$attr" = yes ; then
4931 virtfs=yes
4932 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
4933 else
4934 if test "$virtfs" = yes; then
3f3b5388 4935 error_exit "VirtFS is supported only on Linux and requires libcap devel and libattr devel"
983eef5a 4936 fi
17500370 4937 virtfs=no
aabfd88d 4938 fi
17bff52b 4939 fi
e8ef31a3 4940fi
9d6bc27b
MR
4941
4942# Probe for guest agent support/options
4943
e8ef31a3 4944if [ "$guest_agent" != "no" ]; then
b39297ae 4945 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
fafcaf1d 4946 tools="qemu-ga $tools"
e8ef31a3
MT
4947 guest_agent=yes
4948 elif [ "$guest_agent" != yes ]; then
4949 guest_agent=no
4950 else
4951 error_exit "Guest agent is not supported on this platform"
ca35f780 4952 fi
00c705fb 4953fi
ca35f780 4954
9d6bc27b
MR
4955# Guest agent Window MSI package
4956
4957if test "$guest_agent" != yes; then
4958 if test "$guest_agent_msi" = yes; then
4959 error_exit "MSI guest agent package requires guest agent enabled"
4960 fi
4961 guest_agent_msi=no
4962elif test "$mingw32" != "yes"; then
4963 if test "$guest_agent_msi" = "yes"; then
4964 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
4965 fi
4966 guest_agent_msi=no
4967elif ! has wixl; then
4968 if test "$guest_agent_msi" = "yes"; then
4969 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
4970 fi
4971 guest_agent_msi=no
1a34904e
MR
4972else
4973 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
4974 # disabled explicitly
4975 if test "$guest_agent_msi" != "no"; then
4976 guest_agent_msi=yes
4977 fi
9d6bc27b
MR
4978fi
4979
1a34904e 4980if test "$guest_agent_msi" = "yes"; then
9d6bc27b
MR
4981 if test "$guest_agent_with_vss" = "yes"; then
4982 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
4983 fi
4984
4985 if test "$QEMU_GA_MANUFACTURER" = ""; then
4986 QEMU_GA_MANUFACTURER=QEMU
4987 fi
4988
4989 if test "$QEMU_GA_DISTRO" = ""; then
4990 QEMU_GA_DISTRO=Linux
4991 fi
4992
4993 if test "$QEMU_GA_VERSION" = ""; then
89138857 4994 QEMU_GA_VERSION=$(cat $source_path/VERSION)
9d6bc27b
MR
4995 fi
4996
89138857 4997 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
9d6bc27b
MR
4998
4999 case "$cpu" in
5000 x86_64)
5001 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5002 ;;
5003 i386)
5004 QEMU_GA_MSI_ARCH="-D Arch=32"
5005 ;;
5006 *)
5007 error_exit "CPU $cpu not supported for building installation package"
5008 ;;
5009 esac
5010fi
5011
ca35f780
PB
5012# Mac OS X ships with a broken assembler
5013roms=
5014if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5015 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5016 "$softmmu" = yes ; then
e57218b6
PM
5017 # Different host OS linkers have different ideas about the name of the ELF
5018 # emulation. Linux and OpenBSD use 'elf_i386'; FreeBSD uses the _fbsd
5019 # variant; and Windows uses i386pe.
5020 for emu in elf_i386 elf_i386_fbsd i386pe; do
5021 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5022 ld_i386_emulation="$emu"
5023 roms="optionrom"
5024 break
5025 fi
5026 done
ca35f780 5027fi
d0384d1d 5028if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
39ac8455
DG
5029 roms="$roms spapr-rtas"
5030fi
ca35f780 5031
9933c305
CB
5032if test "$cpu" = "s390x" ; then
5033 roms="$roms s390-ccw"
5034fi
5035
964c6fa1 5036# Probe for the need for relocating the user-only binary.
92fe2ba8 5037if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
964c6fa1
RH
5038 textseg_addr=
5039 case "$cpu" in
479eb121
RH
5040 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5041 # ??? Rationale for choosing this address
964c6fa1
RH
5042 textseg_addr=0x60000000
5043 ;;
5044 mips)
479eb121
RH
5045 # A 256M aligned address, high in the address space, with enough
5046 # room for the code_gen_buffer above it before the stack.
5047 textseg_addr=0x60000000
964c6fa1
RH
5048 ;;
5049 esac
5050 if [ -n "$textseg_addr" ]; then
5051 cat > $TMPC <<EOF
5052 int main(void) { return 0; }
5053EOF
5054 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5055 if ! compile_prog "" "$textseg_ldflags"; then
5056 # In case ld does not support -Ttext-segment, edit the default linker
5057 # script via sed to set the .text start addr. This is needed on FreeBSD
5058 # at least.
92fe2ba8
PM
5059 if ! $ld --verbose >/dev/null 2>&1; then
5060 error_exit \
5061 "We need to link the QEMU user mode binaries at a" \
5062 "specific text address. Unfortunately your linker" \
5063 "doesn't support either the -Ttext-segment option or" \
5064 "printing the default linker script with --verbose." \
5065 "If you don't want the user mode binaries, pass the" \
5066 "--disable-user option to configure."
5067 fi
5068
964c6fa1
RH
5069 $ld --verbose | sed \
5070 -e '1,/==================================================/d' \
5071 -e '/==================================================/,$d' \
5072 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5073 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5074 textseg_ldflags="-Wl,-T../config-host.ld"
5075 fi
5076 fi
5077fi
5078
02d34f62
CR
5079echo_version() {
5080 if test "$1" = "yes" ; then
5081 echo "($2)"
5082 fi
5083}
5084
50e12060
JK
5085# prepend pixman and ftd flags after all config tests are done
5086QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5087libs_softmmu="$pixman_libs $libs_softmmu"
5ca9388a 5088
43ce4dfe 5089echo "Install prefix $prefix"
89138857
SW
5090echo "BIOS directory $(eval echo $qemu_datadir)"
5091echo "binary directory $(eval echo $bindir)"
5092echo "library directory $(eval echo $libdir)"
5093echo "module directory $(eval echo $qemu_moddir)"
5094echo "libexec directory $(eval echo $libexecdir)"
5095echo "include directory $(eval echo $includedir)"
5096echo "config directory $(eval echo $sysconfdir)"
11d9f695 5097if test "$mingw32" = "no" ; then
89138857
SW
5098echo "local state directory $(eval echo $local_statedir)"
5099echo "Manual directory $(eval echo $mandir)"
43ce4dfe 5100echo "ELF interp prefix $interp_prefix"
5a699bbb
LE
5101else
5102echo "local state directory queried at runtime"
d9840e25 5103echo "Windows SDK $win_sdk"
11d9f695 5104fi
5a67135a 5105echo "Source path $source_path"
43ce4dfe 5106echo "C compiler $cc"
83469015 5107echo "Host C compiler $host_cc"
83f73fce 5108echo "C++ compiler $cxx"
3c4a4d0d 5109echo "Objective-C compiler $objcc"
45d285ab 5110echo "ARFLAGS $ARFLAGS"
0c439cbf 5111echo "CFLAGS $CFLAGS"
a558ee17 5112echo "QEMU_CFLAGS $QEMU_CFLAGS"
0c439cbf 5113echo "LDFLAGS $LDFLAGS"
43ce4dfe 5114echo "make $make"
6a882643 5115echo "install $install"
c886edfb 5116echo "python $python"
e2d8830e
BS
5117if test "$slirp" = "yes" ; then
5118 echo "smbd $smbd"
5119fi
17969268 5120echo "module support $modules"
43ce4dfe 5121echo "host CPU $cpu"
de83cd02 5122echo "host big endian $bigendian"
97a847bc 5123echo "target list $target_list"
ade25b0d 5124echo "tcg debug enabled $debug_tcg"
43ce4dfe 5125echo "gprof enabled $gprof"
03b4fe7d 5126echo "sparse enabled $sparse"
1625af87 5127echo "strip binaries $strip_opt"
05c2a3e7 5128echo "profiler $profiler"
43ce4dfe 5129echo "static build $static"
5b0753e0
FB
5130if test "$darwin" = "yes" ; then
5131 echo "Cocoa support $cocoa"
5132fi
e2134eb9 5133echo "pixman $pixman"
89138857
SW
5134echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5135echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
925a0400 5136echo "GTK GL support $gtk_gl"
89138857 5137echo "VTE support $vte $(echo_version $vte $vteversion)"
a1c5e949 5138echo "TLS priority $tls_priority"
ddbb0d09 5139echo "GNUTLS support $gnutls"
b917da4c 5140echo "GNUTLS rnd $gnutls_rnd"
91bfcdb0 5141echo "libgcrypt $gcrypt"
37788f25 5142echo "libgcrypt kdf $gcrypt_kdf"
89138857 5143echo "nettle $nettle $(echo_version $nettle $nettle_version)"
fff2f982 5144echo "nettle kdf $nettle_kdf"
9a2fd434 5145echo "libtasn1 $tasn1"
4d3b6f6e 5146echo "curses support $curses"
9d9e1521 5147echo "virgl support $virglrenderer"
769ce76d 5148echo "curl support $curl"
67b915a5 5149echo "mingw32 support $mingw32"
0c58ac1c 5150echo "Audio drivers $audio_drv_list"
b64ec4e4
FZ
5151echo "Block whitelist (rw) $block_drv_rw_whitelist"
5152echo "Block whitelist (ro) $block_drv_ro_whitelist"
983eef5a 5153echo "VirtFS support $virtfs"
821601ea
JS
5154echo "VNC support $vnc"
5155if test "$vnc" = "yes" ; then
821601ea
JS
5156 echo "VNC SASL support $vnc_sasl"
5157 echo "VNC JPEG support $vnc_jpeg"
5158 echo "VNC PNG support $vnc_png"
821601ea 5159fi
3142255c
BS
5160if test -n "$sparc_cpu"; then
5161 echo "Target Sparc Arch $sparc_cpu"
5162fi
e37630ca 5163echo "xen support $xen"
3996e85c
PD
5164if test "$xen" = "yes" ; then
5165 echo "xen ctrl version $xen_ctrl_version"
64a7ad6f 5166 echo "pv dom build $xen_pv_domain_build"
3996e85c 5167fi
2e4d9fb1 5168echo "brlapi support $brlapi"
a20a6f46 5169echo "bluez support $bluez"
a25dba17 5170echo "Documentation $docs"
40d6444e 5171echo "PIE $pie"
8a16d273 5172echo "vde support $vde"
58952137 5173echo "netmap support $netmap"
5c6c3a6c 5174echo "Linux AIO support $linux_aio"
758e8e38 5175echo "ATTR/XATTR support $attr"
77755340 5176echo "Install blobs $blobs"
b31a0277 5177echo "KVM support $kvm"
b0cb0a66 5178echo "HAX support $hax"
2da776db 5179echo "RDMA support $rdma"
9195b2c2 5180echo "TCG interpreter $tcg_interpreter"
f652e6af 5181echo "fdt support $fdt"
ceb42de8 5182echo "preadv support $preadv"
5f6b9e8f 5183echo "fdatasync $fdatasync"
e78815a5
AF
5184echo "madvise $madvise"
5185echo "posix_madvise $posix_madvise"
47e98658 5186echo "libcap-ng support $cap_ng"
d5970055 5187echo "vhost-net support $vhost_net"
5e9be92d 5188echo "vhost-scsi support $vhost_scsi"
fc0b9b0e 5189echo "vhost-vsock support $vhost_vsock"
5b808275 5190echo "Trace backends $trace_backends"
713572a7 5191if have_backend "simple"; then
9410b56c 5192echo "Trace output file $trace_file-<pid>"
e00e36fb 5193fi
89138857 5194echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
f27aaf4b 5195echo "rbd support $rbd"
dce512de 5196echo "xfsctl support $xfs"
7b02f544 5197echo "smartcard support $smartcard"
2b2325ff 5198echo "libusb $libusb"
69354a83 5199echo "usb net redir $usb_redir"
da076ffe 5200echo "OpenGL support $opengl"
014cb152 5201echo "OpenGL dmabufs $opengl_dmabuf"
c589b249 5202echo "libiscsi support $libiscsi"
6542aa9c 5203echo "libnfs support $libnfs"
d138cee9 5204echo "build guest agent $guest_agent"
d9840e25 5205echo "QGA VSS support $guest_agent_with_vss"
50cbebb9 5206echo "QGA w32 disk info $guest_agent_ntddscsi"
4c875d89 5207echo "QGA MSI support $guest_agent_msi"
f794573e 5208echo "seccomp support $seccomp"
7c2acc70 5209echo "coroutine backend $coroutine"
70c60c08 5210echo "coroutine pool $coroutine_pool"
7d992e4d 5211echo "debug stack usage $debug_stack_usage"
eb100396 5212echo "GlusterFS support $glusterfs"
1d728c39
BS
5213echo "gcov $gcov_tool"
5214echo "gcov enabled $gcov"
ab214c29 5215echo "TPM support $tpm"
0a12ec87 5216echo "libssh2 support $libssh2"
3b8acc11 5217echo "TPM passthrough $tpm_passthrough"
3556c233 5218echo "QOM debugging $qom_cast_debug"
607dacd0
QN
5219echo "lzo support $lzo"
5220echo "snappy support $snappy"
6b383c08 5221echo "bzip2 support $bzip2"
a99d57bb 5222echo "NUMA host support $numa"
2847b469 5223echo "tcmalloc support $tcmalloc"
7b01cb97 5224echo "jemalloc support $jemalloc"
99f2dbd3 5225echo "avx2 optimization $avx2_opt"
a6b1d4c0 5226echo "replication support $replication"
da92c3ff 5227echo "VxHS block device $vxhs"
67b915a5 5228
1ba16968 5229if test "$sdl_too_old" = "yes"; then
24b55b96 5230echo "-> Your SDL version is too old - please upgrade to have SDL support"
7c1f25b4 5231fi
7d13299d 5232
898be3e0
PM
5233if test "$supported_cpu" = "no"; then
5234 echo
5235 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5236 echo
5237 echo "CPU host architecture $cpu support is not currently maintained."
5238 echo "The QEMU project intends to remove support for this host CPU in"
5239 echo "a future release if nobody volunteers to maintain it and to"
5240 echo "provide a build host for our continuous integration setup."
5241 echo "configure has succeeded and you can continue to build, but"
5242 echo "if you care about QEMU on this platform you should contact"
5243 echo "us upstream at qemu-devel@nongnu.org."
5244fi
5245
5246if test "$supported_os" = "no"; then
5247 echo
5248 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5249 echo
c50126aa
PM
5250 echo "Host OS $targetos support is not currently maintained."
5251 echo "The QEMU project intends to remove support for this host OS in"
898be3e0
PM
5252 echo "a future release if nobody volunteers to maintain it and to"
5253 echo "provide a build host for our continuous integration setup."
5254 echo "configure has succeeded and you can continue to build, but"
5255 echo "if you care about QEMU on this platform you should contact"
5256 echo "us upstream at qemu-devel@nongnu.org."
5257fi
5258
98ec69ac 5259config_host_mak="config-host.mak"
98ec69ac 5260
dbd99ae3
SW
5261echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
5262
98ec69ac 5263echo "# Automatically generated by configure - do not modify" > $config_host_mak
98ec69ac 5264echo >> $config_host_mak
98ec69ac 5265
e6c3b0f7 5266echo all: >> $config_host_mak
99d7cc75
PB
5267echo "prefix=$prefix" >> $config_host_mak
5268echo "bindir=$bindir" >> $config_host_mak
3aa5d2be 5269echo "libdir=$libdir" >> $config_host_mak
8bf188aa 5270echo "libexecdir=$libexecdir" >> $config_host_mak
0f94d6da 5271echo "includedir=$includedir" >> $config_host_mak
99d7cc75 5272echo "mandir=$mandir" >> $config_host_mak
99d7cc75 5273echo "sysconfdir=$sysconfdir" >> $config_host_mak
22d07038 5274echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
9afa52ce
EH
5275echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
5276echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
e26110cf 5277echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5a699bbb
LE
5278if test "$mingw32" = "no" ; then
5279 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
5280fi
f354b1a1 5281echo "qemu_helperdir=$libexecdir" >> $config_host_mak
f9943cd5
GH
5282echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
5283echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
834574ea 5284echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
f544a488 5285echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
804edf29 5286
98ec69ac 5287echo "ARCH=$ARCH" >> $config_host_mak
727e5283 5288
f8393946 5289if test "$debug_tcg" = "yes" ; then
2358a494 5290 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
f8393946 5291fi
1625af87 5292if test "$strip_opt" = "yes" ; then
52ba784d 5293 echo "STRIP=${strip}" >> $config_host_mak
1625af87 5294fi
7d13299d 5295if test "$bigendian" = "yes" ; then
e2542fe2 5296 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
97a847bc 5297fi
67b915a5 5298if test "$mingw32" = "yes" ; then
98ec69ac 5299 echo "CONFIG_WIN32=y" >> $config_host_mak
89138857 5300 rc_version=$(cat $source_path/VERSION)
9fe6de94
BS
5301 version_major=${rc_version%%.*}
5302 rc_version=${rc_version#*.}
5303 version_minor=${rc_version%%.*}
5304 rc_version=${rc_version#*.}
5305 version_subminor=${rc_version%%.*}
5306 version_micro=0
5307 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5308 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
d9840e25
TS
5309 if test "$guest_agent_with_vss" = "yes" ; then
5310 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
f33ca81f 5311 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
d9840e25
TS
5312 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5313 fi
50cbebb9
MR
5314 if test "$guest_agent_ntddscsi" = "yes" ; then
5315 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
5316 fi
1a34904e 5317 if test "$guest_agent_msi" = "yes"; then
9dacf32d
YH
5318 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
5319 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
5320 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
5321 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
5322 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
5323 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
5324 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5325 fi
210fa556 5326else
35f4df27 5327 echo "CONFIG_POSIX=y" >> $config_host_mak
dffcb71c
MM
5328fi
5329
5330if test "$linux" = "yes" ; then
5331 echo "CONFIG_LINUX=y" >> $config_host_mak
67b915a5 5332fi
128ab2ff 5333
83fb7adf 5334if test "$darwin" = "yes" ; then
98ec69ac 5335 echo "CONFIG_DARWIN=y" >> $config_host_mak
83fb7adf 5336fi
b29fe3ed 5337
5338if test "$aix" = "yes" ; then
98ec69ac 5339 echo "CONFIG_AIX=y" >> $config_host_mak
b29fe3ed 5340fi
5341
ec530c81 5342if test "$solaris" = "yes" ; then
98ec69ac 5343 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2358a494 5344 echo "CONFIG_SOLARIS_VERSION=$solarisrev" >> $config_host_mak
0475a5ca 5345 if test "$needs_libsunmath" = "yes" ; then
75b5a697 5346 echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
0475a5ca 5347 fi
ec530c81 5348fi
179cf400
AF
5349if test "$haiku" = "yes" ; then
5350 echo "CONFIG_HAIKU=y" >> $config_host_mak
5351fi
97a847bc 5352if test "$static" = "yes" ; then
98ec69ac 5353 echo "CONFIG_STATIC=y" >> $config_host_mak
7d13299d 5354fi
1ba16968 5355if test "$profiler" = "yes" ; then
2358a494 5356 echo "CONFIG_PROFILER=y" >> $config_host_mak
05c2a3e7 5357fi
c20709aa 5358if test "$slirp" = "yes" ; then
98ec69ac 5359 echo "CONFIG_SLIRP=y" >> $config_host_mak
e2d8830e 5360 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
c20709aa 5361fi
8a16d273 5362if test "$vde" = "yes" ; then
98ec69ac 5363 echo "CONFIG_VDE=y" >> $config_host_mak
8a16d273 5364fi
58952137
VM
5365if test "$netmap" = "yes" ; then
5366 echo "CONFIG_NETMAP=y" >> $config_host_mak
5367fi
015a33bd
GA
5368if test "$l2tpv3" = "yes" ; then
5369 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5370fi
47e98658
CB
5371if test "$cap_ng" = "yes" ; then
5372 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5373fi
2358a494 5374echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
0c58ac1c 5375for drv in $audio_drv_list; do
89138857 5376 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
98ec69ac 5377 echo "$def=y" >> $config_host_mak
0c58ac1c 5378done
67f86e8e
JQ
5379if test "$audio_pt_int" = "yes" ; then
5380 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5381fi
d5631638 5382if test "$audio_win_int" = "yes" ; then
5383 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5384fi
b64ec4e4
FZ
5385echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5386echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
821601ea
JS
5387if test "$vnc" = "yes" ; then
5388 echo "CONFIG_VNC=y" >> $config_host_mak
5389fi
2f9606b3 5390if test "$vnc_sasl" = "yes" ; then
98ec69ac 5391 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
2f9606b3 5392fi
821601ea 5393if test "$vnc_jpeg" = "yes" ; then
2f6f5c7a 5394 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
2f6f5c7a 5395fi
821601ea 5396if test "$vnc_png" = "yes" ; then
efe556ad 5397 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
efe556ad 5398fi
76655d6d 5399if test "$fnmatch" = "yes" ; then
2358a494 5400 echo "CONFIG_FNMATCH=y" >> $config_host_mak
76655d6d 5401fi
dce512de
CH
5402if test "$xfs" = "yes" ; then
5403 echo "CONFIG_XFS=y" >> $config_host_mak
5404fi
89138857 5405qemu_version=$(head $source_path/VERSION)
98ec69ac 5406echo "VERSION=$qemu_version" >>$config_host_mak
2358a494 5407echo "PKGVERSION=$pkgversion" >>$config_host_mak
98ec69ac 5408echo "SRC_PATH=$source_path" >> $config_host_mak
98ec69ac 5409echo "TARGET_DIRS=$target_list" >> $config_host_mak
a25dba17 5410if [ "$docs" = "yes" ] ; then
98ec69ac 5411 echo "BUILD_DOCS=yes" >> $config_host_mak
cc8ae6de 5412fi
17969268 5413if test "$modules" = "yes"; then
e26110cf
FZ
5414 # $shacmd can generate a hash started with digit, which the compiler doesn't
5415 # like as an symbol. So prefix it with an underscore
89138857 5416 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
17969268
FZ
5417 echo "CONFIG_MODULES=y" >> $config_host_mak
5418fi
1ac88f28 5419if test "$sdl" = "yes" ; then
98ec69ac 5420 echo "CONFIG_SDL=y" >> $config_host_mak
a3f4d63d 5421 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
1ac88f28 5422 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
49ecc3fa
FB
5423fi
5424if test "$cocoa" = "yes" ; then
98ec69ac 5425 echo "CONFIG_COCOA=y" >> $config_host_mak
4d3b6f6e
AZ
5426fi
5427if test "$curses" = "yes" ; then
98ec69ac 5428 echo "CONFIG_CURSES=y" >> $config_host_mak
49ecc3fa 5429fi
ebc996f3 5430if test "$utimens" = "yes" ; then
2358a494 5431 echo "CONFIG_UTIMENSAT=y" >> $config_host_mak
ebc996f3 5432fi
099d6b0f 5433if test "$pipe2" = "yes" ; then
2358a494 5434 echo "CONFIG_PIPE2=y" >> $config_host_mak
099d6b0f 5435fi
40ff6d7e
KW
5436if test "$accept4" = "yes" ; then
5437 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5438fi
3ce34dfb 5439if test "$splice" = "yes" ; then
2358a494 5440 echo "CONFIG_SPLICE=y" >> $config_host_mak
3ce34dfb 5441fi
c2882b96
RV
5442if test "$eventfd" = "yes" ; then
5443 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5444fi
751bcc39
MAL
5445if test "$memfd" = "yes" ; then
5446 echo "CONFIG_MEMFD=y" >> $config_host_mak
5447fi
d0927938
UH
5448if test "$fallocate" = "yes" ; then
5449 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5450fi
3d4fa43e
KK
5451if test "$fallocate_punch_hole" = "yes" ; then
5452 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5453fi
b953f075
DL
5454if test "$fallocate_zero_range" = "yes" ; then
5455 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5456fi
ed911435
KW
5457if test "$posix_fallocate" = "yes" ; then
5458 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5459fi
c727f47d
PM
5460if test "$sync_file_range" = "yes" ; then
5461 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5462fi
dace20dc
PM
5463if test "$fiemap" = "yes" ; then
5464 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5465fi
d0927938
UH
5466if test "$dup3" = "yes" ; then
5467 echo "CONFIG_DUP3=y" >> $config_host_mak
5468fi
4e0c6529
AB
5469if test "$ppoll" = "yes" ; then
5470 echo "CONFIG_PPOLL=y" >> $config_host_mak
5471fi
cd758dd0
AB
5472if test "$prctl_pr_set_timerslack" = "yes" ; then
5473 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5474fi
3b6edd16
PM
5475if test "$epoll" = "yes" ; then
5476 echo "CONFIG_EPOLL=y" >> $config_host_mak
5477fi
5478if test "$epoll_create1" = "yes" ; then
5479 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5480fi
a8fd1aba
PM
5481if test "$sendfile" = "yes" ; then
5482 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5483fi
51834341
RV
5484if test "$timerfd" = "yes" ; then
5485 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5486fi
9af5c906
RV
5487if test "$setns" = "yes" ; then
5488 echo "CONFIG_SETNS=y" >> $config_host_mak
5489fi
38860a03
AM
5490if test "$clock_adjtime" = "yes" ; then
5491 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
5492fi
5a03cd00
AM
5493if test "$syncfs" = "yes" ; then
5494 echo "CONFIG_SYNCFS=y" >> $config_host_mak
5495fi
3b3f24ad 5496if test "$inotify" = "yes" ; then
2358a494 5497 echo "CONFIG_INOTIFY=y" >> $config_host_mak
3b3f24ad 5498fi
c05c7a73
RV
5499if test "$inotify1" = "yes" ; then
5500 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5501fi
6ae9a1f4
JQ
5502if test "$byteswap_h" = "yes" ; then
5503 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5504fi
5505if test "$bswap_h" = "yes" ; then
5506 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5507fi
769ce76d 5508if test "$curl" = "yes" ; then
d3399d7c 5509 echo "CONFIG_CURL=m" >> $config_host_mak
b1d5a277 5510 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6ebc91e5 5511 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
769ce76d 5512fi
2e4d9fb1 5513if test "$brlapi" = "yes" ; then
98ec69ac 5514 echo "CONFIG_BRLAPI=y" >> $config_host_mak
2e4d9fb1 5515fi
fb599c9a 5516if test "$bluez" = "yes" ; then
98ec69ac 5517 echo "CONFIG_BLUEZ=y" >> $config_host_mak
ef7635ec 5518 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
fb599c9a 5519fi
d46f7c9e 5520if test "$glib_subprocess" = "yes" ; then
9d41401b
MT
5521 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5522fi
a4ccabcf
AL
5523if test "$gtk" = "yes" ; then
5524 echo "CONFIG_GTK=y" >> $config_host_mak
a3f4d63d 5525 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
a4ccabcf 5526 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
014cb152 5527 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
925a0400
GH
5528 if test "$gtk_gl" = "yes" ; then
5529 echo "CONFIG_GTK_GL=y" >> $config_host_mak
5530 fi
bbbf9bfb 5531fi
a1c5e949 5532echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
ddbb0d09
DB
5533if test "$gnutls" = "yes" ; then
5534 echo "CONFIG_GNUTLS=y" >> $config_host_mak
5535fi
b917da4c
DB
5536if test "$gnutls_rnd" = "yes" ; then
5537 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5538fi
91bfcdb0
DB
5539if test "$gcrypt" = "yes" ; then
5540 echo "CONFIG_GCRYPT=y" >> $config_host_mak
1f923c70
LM
5541 if test "$gcrypt_hmac" = "yes" ; then
5542 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
5543 fi
37788f25
DB
5544 if test "$gcrypt_kdf" = "yes" ; then
5545 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
5546 fi
62893b67 5547fi
91bfcdb0
DB
5548if test "$nettle" = "yes" ; then
5549 echo "CONFIG_NETTLE=y" >> $config_host_mak
becaeb72 5550 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
fff2f982
DB
5551 if test "$nettle_kdf" = "yes" ; then
5552 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5553 fi
ed754746 5554fi
9a2fd434
DB
5555if test "$tasn1" = "yes" ; then
5556 echo "CONFIG_TASN1=y" >> $config_host_mak
5557fi
559607ea
DB
5558if test "$have_ifaddrs_h" = "yes" ; then
5559 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
5560fi
6b39b063
EB
5561if test "$have_broken_size_max" = "yes" ; then
5562 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
5563fi
277abf15
JV
5564
5565# Work around a system header bug with some kernel/XFS header
5566# versions where they both try to define 'struct fsxattr':
5567# xfs headers will not try to redefine structs from linux headers
5568# if this macro is set.
5569if test "$have_fsxattr" = "yes" ; then
5570 echo "HAVE_FSXATTR=y" >> $config_host_mak
5571fi
bbbf9bfb
SW
5572if test "$vte" = "yes" ; then
5573 echo "CONFIG_VTE=y" >> $config_host_mak
a4ccabcf
AL
5574 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5575fi
9d9e1521
GH
5576if test "$virglrenderer" = "yes" ; then
5577 echo "CONFIG_VIRGL=y" >> $config_host_mak
5578 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
5579 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
5580fi
e37630ca 5581if test "$xen" = "yes" ; then
6dbd588a 5582 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
d5b93ddf 5583 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
64a7ad6f
IC
5584 if test "$xen_pv_domain_build" = "yes" ; then
5585 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
5586 fi
e37630ca 5587fi
5c6c3a6c
CH
5588if test "$linux_aio" = "yes" ; then
5589 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
5590fi
758e8e38
VJ
5591if test "$attr" = "yes" ; then
5592 echo "CONFIG_ATTR=y" >> $config_host_mak
5593fi
4f26f2b6
AK
5594if test "$libattr" = "yes" ; then
5595 echo "CONFIG_LIBATTR=y" >> $config_host_mak
5596fi
983eef5a
MI
5597if test "$virtfs" = "yes" ; then
5598 echo "CONFIG_VIRTFS=y" >> $config_host_mak
758e8e38 5599fi
5e9be92d
NB
5600if test "$vhost_scsi" = "yes" ; then
5601 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
5602fi
03ce5744
NN
5603if test "$vhost_net" = "yes" ; then
5604 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
5605fi
fc0b9b0e
SH
5606if test "$vhost_vsock" = "yes" ; then
5607 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
5608fi
77755340 5609if test "$blobs" = "yes" ; then
98ec69ac 5610 echo "INSTALL_BLOBS=yes" >> $config_host_mak
77755340 5611fi
bf9298b9 5612if test "$iovec" = "yes" ; then
2358a494 5613 echo "CONFIG_IOVEC=y" >> $config_host_mak
bf9298b9 5614fi
ceb42de8 5615if test "$preadv" = "yes" ; then
2358a494 5616 echo "CONFIG_PREADV=y" >> $config_host_mak
ceb42de8 5617fi
f652e6af 5618if test "$fdt" = "yes" ; then
3f0855b1 5619 echo "CONFIG_FDT=y" >> $config_host_mak
f652e6af 5620fi
dcc38d1c
MT
5621if test "$signalfd" = "yes" ; then
5622 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5623fi
9195b2c2
SW
5624if test "$tcg_interpreter" = "yes" ; then
5625 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
5626fi
5f6b9e8f
BS
5627if test "$fdatasync" = "yes" ; then
5628 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
5629fi
e78815a5
AF
5630if test "$madvise" = "yes" ; then
5631 echo "CONFIG_MADVISE=y" >> $config_host_mak
5632fi
5633if test "$posix_madvise" = "yes" ; then
5634 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5635fi
97a847bc 5636
cd4ec0b4
GH
5637if test "$spice" = "yes" ; then
5638 echo "CONFIG_SPICE=y" >> $config_host_mak
5639fi
36707144 5640
7b02f544
MAL
5641if test "$smartcard" = "yes" ; then
5642 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
111a38b0
RR
5643fi
5644
2b2325ff
GH
5645if test "$libusb" = "yes" ; then
5646 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5647fi
5648
69354a83
HG
5649if test "$usb_redir" = "yes" ; then
5650 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5651fi
5652
da076ffe
GH
5653if test "$opengl" = "yes" ; then
5654 echo "CONFIG_OPENGL=y" >> $config_host_mak
5655 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
014cb152
GH
5656 if test "$opengl_dmabuf" = "yes" ; then
5657 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5658 fi
20ff075b
MW
5659fi
5660
99f2dbd3
LL
5661if test "$avx2_opt" = "yes" ; then
5662 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
5663fi
5664
607dacd0
QN
5665if test "$lzo" = "yes" ; then
5666 echo "CONFIG_LZO=y" >> $config_host_mak
5667fi
5668
5669if test "$snappy" = "yes" ; then
5670 echo "CONFIG_SNAPPY=y" >> $config_host_mak
5671fi
5672
6b383c08
PW
5673if test "$bzip2" = "yes" ; then
5674 echo "CONFIG_BZIP2=y" >> $config_host_mak
5675 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
5676fi
5677
c589b249 5678if test "$libiscsi" = "yes" ; then
d3399d7c 5679 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6ebc91e5
FZ
5680 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
5681 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
c589b249
RS
5682fi
5683
6542aa9c 5684if test "$libnfs" = "yes" ; then
4be4879f
CL
5685 echo "CONFIG_LIBNFS=m" >> $config_host_mak
5686 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6542aa9c
PL
5687fi
5688
f794573e
EO
5689if test "$seccomp" = "yes"; then
5690 echo "CONFIG_SECCOMP=y" >> $config_host_mak
5691fi
5692
83fb7adf 5693# XXX: suppress that
7d3505c5 5694if [ "$bsd" = "yes" ] ; then
2358a494 5695 echo "CONFIG_BSD=y" >> $config_host_mak
7d3505c5
FB
5696fi
5697
4d9310f4
DB
5698if test "$localtime_r" = "yes" ; then
5699 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
5700fi
3556c233
PB
5701if test "$qom_cast_debug" = "yes" ; then
5702 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
5703fi
f27aaf4b 5704if test "$rbd" = "yes" ; then
d3399d7c 5705 echo "CONFIG_RBD=m" >> $config_host_mak
6ebc91e5
FZ
5706 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
5707 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
d0e2fce5
AK
5708fi
5709
7c2acc70 5710echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
70c60c08
SH
5711if test "$coroutine_pool" = "yes" ; then
5712 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
5713else
5714 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
5715fi
20ff6c80 5716
7d992e4d
PL
5717if test "$debug_stack_usage" = "yes" ; then
5718 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
5719fi
5720
d2042378
AK
5721if test "$open_by_handle_at" = "yes" ; then
5722 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5723fi
5724
e06a765e
HPB
5725if test "$linux_magic_h" = "yes" ; then
5726 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
8ab1bf12
LC
5727fi
5728
cc6e3ca9
GH
5729if test "$pragma_diagnostic_available" = "yes" ; then
5730 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
06d71fa1
PM
5731fi
5732
3f4349dc
KW
5733if test "$valgrind_h" = "yes" ; then
5734 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
5735fi
5736
8ab1bf12
LC
5737if test "$has_environ" = "yes" ; then
5738 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
e06a765e
HPB
5739fi
5740
76a347e1
RH
5741if test "$cpuid_h" = "yes" ; then
5742 echo "CONFIG_CPUID_H=y" >> $config_host_mak
5743fi
5744
f540166b
RH
5745if test "$int128" = "yes" ; then
5746 echo "CONFIG_INT128=y" >> $config_host_mak
5747fi
5748
7ebee43e
RH
5749if test "$atomic128" = "yes" ; then
5750 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
5751fi
5752
df79b996
RH
5753if test "$atomic64" = "yes" ; then
5754 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5755fi
5756
1e6e9aca
RH
5757if test "$getauxval" = "yes" ; then
5758 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
5759fi
5760
eb100396 5761if test "$glusterfs" = "yes" ; then
d3399d7c 5762 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6ebc91e5
FZ
5763 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
5764 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
0c14fb47
BR
5765fi
5766
d85fa9eb
JC
5767if test "$glusterfs_xlator_opt" = "yes" ; then
5768 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
5769fi
5770
0c14fb47
BR
5771if test "$glusterfs_discard" = "yes" ; then
5772 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
eb100396 5773fi
e06a765e 5774
7c815372
BR
5775if test "$glusterfs_zerofill" = "yes" ; then
5776 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
5777fi
5778
0a12ec87 5779if test "$libssh2" = "yes" ; then
d3399d7c 5780 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6ebc91e5
FZ
5781 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
5782 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
0a12ec87
RJ
5783fi
5784
68063649 5785# USB host support
b5613fdc
GH
5786if test "$libusb" = "yes"; then
5787 echo "HOST_USB=libusb legacy" >> $config_host_mak
5788else
98ec69ac 5789 echo "HOST_USB=stub" >> $config_host_mak
b5613fdc 5790fi
68063649 5791
3b8acc11
PB
5792# TPM passthrough support?
5793if test "$tpm" = "yes"; then
5794 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
5795 if test "$tpm_passthrough" = "yes"; then
5796 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
5797 fi
5798fi
5799
5b808275
LV
5800echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
5801if have_backend "nop"; then
6d8a764e 5802 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
22890ab5 5803fi
5b808275 5804if have_backend "simple"; then
6d8a764e
LV
5805 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
5806 # Set the appropriate trace file.
953ffe0f 5807 trace_file="\"$trace_file-\" FMT_pid"
9410b56c 5808fi
ed7f5f1d
PB
5809if have_backend "log"; then
5810 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6d8a764e 5811fi
5b808275 5812if have_backend "ust"; then
6d8a764e
LV
5813 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5814fi
5b808275 5815if have_backend "dtrace"; then
6d8a764e
LV
5816 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
5817 if test "$trace_backend_stap" = "yes" ; then
5818 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
5819 fi
c276b17d 5820fi
5b808275 5821if have_backend "ftrace"; then
781e9545
ET
5822 if test "$linux" = "yes" ; then
5823 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
781e9545 5824 else
21684af0 5825 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
781e9545
ET
5826 fi
5827fi
0a852417
PD
5828if have_backend "syslog"; then
5829 if test "$posix_syslog" = "yes" ; then
5830 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
5831 else
5832 feature_not_found "syslog(trace backend)" "syslog not available"
5833 fi
5834fi
9410b56c
PS
5835echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
5836
2da776db
MH
5837if test "$rdma" = "yes" ; then
5838 echo "CONFIG_RDMA=y" >> $config_host_mak
5839fi
5840
575b22b1
LV
5841if test "$have_rtnetlink" = "yes" ; then
5842 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5843fi
5844
a6b1d4c0
CX
5845if test "$replication" = "yes" ; then
5846 echo "CONFIG_REPLICATION=y" >> $config_host_mak
5847fi
5848
6a02c806
SH
5849if test "$have_af_vsock" = "yes" ; then
5850 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
5851fi
5852
4d04351f
CC
5853if test "$have_sysmacros" = "yes" ; then
5854 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
5855fi
5856
49e00a18
AG
5857if test "$have_static_assert" = "yes" ; then
5858 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
5859fi
5860
5c312079
DDAG
5861# Hold two types of flag:
5862# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
5863# a thread we have a handle to
5864# CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
5865# platform
5866if test "$pthread_setname_np" = "yes" ; then
5867 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5868 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
5869fi
5870
da92c3ff
AM
5871if test "$vxhs" = "yes" ; then
5872 echo "CONFIG_VXHS=y" >> $config_host_mak
5873 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
5874fi
5875
5b5e3037
PB
5876if test "$tcg_interpreter" = "yes"; then
5877 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
5878elif test "$ARCH" = "sparc64" ; then
5879 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
5880elif test "$ARCH" = "s390x" ; then
5881 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
c72b26ec 5882elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
5b5e3037 5883 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
40d964b5
RH
5884elif test "$ARCH" = "ppc64" ; then
5885 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
5b5e3037
PB
5886else
5887 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
5888fi
5889QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
5890
98ec69ac 5891echo "TOOLS=$tools" >> $config_host_mak
98ec69ac 5892echo "ROMS=$roms" >> $config_host_mak
804edf29
JQ
5893echo "MAKE=$make" >> $config_host_mak
5894echo "INSTALL=$install" >> $config_host_mak
1901cb14
BS
5895echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
5896echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
e999ee44
MT
5897echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
5898echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
c886edfb 5899echo "PYTHON=$python" >> $config_host_mak
804edf29 5900echo "CC=$cc" >> $config_host_mak
a31a8642
MT
5901if $iasl -h > /dev/null 2>&1; then
5902 echo "IASL=$iasl" >> $config_host_mak
5903fi
2b2e59e6 5904echo "CC_I386=$cc_i386" >> $config_host_mak
804edf29 5905echo "HOST_CC=$host_cc" >> $config_host_mak
83f73fce 5906echo "CXX=$cxx" >> $config_host_mak
3c4a4d0d 5907echo "OBJCC=$objcc" >> $config_host_mak
804edf29 5908echo "AR=$ar" >> $config_host_mak
45d285ab 5909echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
cdbd727c 5910echo "AS=$as" >> $config_host_mak
5f6f0e27 5911echo "CCAS=$ccas" >> $config_host_mak
3dd46c78 5912echo "CPP=$cpp" >> $config_host_mak
804edf29
JQ
5913echo "OBJCOPY=$objcopy" >> $config_host_mak
5914echo "LD=$ld" >> $config_host_mak
4852ee95 5915echo "NM=$nm" >> $config_host_mak
9fe6de94 5916echo "WINDRES=$windres" >> $config_host_mak
e2a2ed06 5917echo "CFLAGS=$CFLAGS" >> $config_host_mak
46eef33b 5918echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
a558ee17 5919echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
f9728943 5920echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
e39f0062
PB
5921if test "$sparse" = "yes" ; then
5922 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
80fd48df 5923 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
2944d742 5924 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
e39f0062
PB
5925 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
5926 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
5927fi
42da6041
GH
5928if test "$cross_prefix" != ""; then
5929 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
5930else
5931 echo "AUTOCONF_HOST := " >> $config_host_mak
5932fi
e2a2ed06 5933echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
46eef33b 5934echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
6969ec6c 5935echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
e57218b6 5936echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
73da375e 5937echo "LIBS+=$LIBS" >> $config_host_mak
3e2e0e6b 5938echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
409437e1 5939echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
804edf29 5940echo "EXESUF=$EXESUF" >> $config_host_mak
17969268
FZ
5941echo "DSOSUF=$DSOSUF" >> $config_host_mak
5942echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
957f1f99 5943echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
90246037
DB
5944echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
5945echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
94dd53c5 5946echo "POD2MAN=$POD2MAN" >> $config_host_mak
cbdd1999 5947echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
1d728c39
BS
5948if test "$gcov" = "yes" ; then
5949 echo "CONFIG_GCOV=y" >> $config_host_mak
5950 echo "GCOV=$gcov_tool" >> $config_host_mak
5951fi
804edf29 5952
6efd7517
PM
5953# use included Linux headers
5954if test "$linux" = "yes" ; then
a307beb6 5955 mkdir -p linux-headers
6efd7517 5956 case "$cpu" in
c72b26ec 5957 i386|x86_64|x32)
08312a63 5958 linux_arch=x86
6efd7517
PM
5959 ;;
5960 ppcemb|ppc|ppc64)
08312a63 5961 linux_arch=powerpc
6efd7517
PM
5962 ;;
5963 s390x)
08312a63
PM
5964 linux_arch=s390
5965 ;;
1f080313
CF
5966 aarch64)
5967 linux_arch=arm64
5968 ;;
222e7d11
SL
5969 mips64)
5970 linux_arch=mips
5971 ;;
08312a63
PM
5972 *)
5973 # For most CPUs the kernel architecture name and QEMU CPU name match.
5974 linux_arch="$cpu"
6efd7517
PM
5975 ;;
5976 esac
08312a63
PM
5977 # For non-KVM architectures we will not have asm headers
5978 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
5979 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
5980 fi
6efd7517
PM
5981fi
5982
1d14ffa9 5983for target in $target_list; do
97a847bc 5984target_dir="$target"
25be210f 5985config_target_mak=$target_dir/config-target.mak
89138857 5986target_name=$(echo $target | cut -d '-' -f 1)
97a847bc 5987target_bigendian="no"
1f3d3c8f 5988
c1799a84 5989case "$target_name" in
4a09d0bb 5990 armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
ea2d6a39
JQ
5991 target_bigendian=yes
5992 ;;
5993esac
97a847bc 5994target_softmmu="no"
997344f3 5995target_user_only="no"
831b7825 5996target_linux_user="no"
84778508 5997target_bsd_user="no"
9e407a85 5998case "$target" in
c1799a84 5999 ${target_name}-softmmu)
9e407a85
PB
6000 target_softmmu="yes"
6001 ;;
c1799a84 6002 ${target_name}-linux-user)
9c7a4202 6003 if test "$linux" != "yes" ; then
76ad07a4 6004 error_exit "Target '$target' is only available on a Linux host"
9c7a4202 6005 fi
9e407a85
PB
6006 target_user_only="yes"
6007 target_linux_user="yes"
6008 ;;
c1799a84 6009 ${target_name}-bsd-user)
9cf55765 6010 if test "$bsd" != "yes" ; then
76ad07a4 6011 error_exit "Target '$target' is only available on a BSD host"
9c7a4202 6012 fi
84778508
BS
6013 target_user_only="yes"
6014 target_bsd_user="yes"
6015 ;;
9e407a85 6016 *)
76ad07a4 6017 error_exit "Target '$target' not recognised"
9e407a85
PB
6018 exit 1
6019 ;;
6020esac
831b7825 6021
97a847bc 6022mkdir -p $target_dir
25be210f 6023echo "# Automatically generated by configure - do not modify" > $config_target_mak
de83cd02 6024
e5fe0c52 6025bflt="no"
ca759f9e 6026mttcg="no"
89138857 6027interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
56aebc89 6028gdb_xml_files=""
7ba1e619 6029
c1799a84 6030TARGET_ARCH="$target_name"
6acff7da 6031TARGET_BASE_ARCH=""
e6e91b9c 6032TARGET_ABI_DIR=""
e73aae67 6033
c1799a84 6034case "$target_name" in
2408a527 6035 i386)
00fcd100 6036 gdb_xml_files="i386-32bit-core.xml"
2408a527
AJ
6037 ;;
6038 x86_64)
6acff7da 6039 TARGET_BASE_ARCH=i386
00fcd100 6040 gdb_xml_files="i386-64bit-core.xml"
2408a527
AJ
6041 ;;
6042 alpha)
5ee4f3c2 6043 mttcg="yes"
2408a527
AJ
6044 ;;
6045 arm|armeb)
b498c8a0 6046 TARGET_ARCH=arm
2408a527 6047 bflt="yes"
ca759f9e 6048 mttcg="yes"
56aebc89 6049 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
2408a527 6050 ;;
6a49fa95
AG
6051 aarch64)
6052 TARGET_BASE_ARCH=arm
6053 bflt="yes"
ca759f9e 6054 mttcg="yes"
8f95ce2e 6055 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6a49fa95 6056 ;;
2408a527 6057 cris)
2408a527 6058 ;;
61766fe9
RH
6059 hppa)
6060 ;;
613a22c9 6061 lm32)
613a22c9 6062 ;;
2408a527 6063 m68k)
2408a527 6064 bflt="yes"
56aebc89 6065 gdb_xml_files="cf-core.xml cf-fp.xml"
2408a527 6066 ;;
877fdc12
EI
6067 microblaze|microblazeel)
6068 TARGET_ARCH=microblaze
72b675ca 6069 bflt="yes"
72b675ca 6070 ;;
0adcffb1 6071 mips|mipsel)
b498c8a0 6072 TARGET_ARCH=mips
25be210f 6073 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
2408a527
AJ
6074 ;;
6075 mipsn32|mipsn32el)
597e2cec 6076 TARGET_ARCH=mips64
6acff7da 6077 TARGET_BASE_ARCH=mips
25be210f 6078 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
597e2cec 6079 echo "TARGET_ABI32=y" >> $config_target_mak
2408a527
AJ
6080 ;;
6081 mips64|mips64el)
b498c8a0 6082 TARGET_ARCH=mips64
6acff7da 6083 TARGET_BASE_ARCH=mips
25be210f 6084 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
2408a527 6085 ;;
d15a9c23
AG
6086 moxie)
6087 ;;
e671711c
MV
6088 nios2)
6089 ;;
4a09d0bb 6090 or1k)
e67db06e
JL
6091 TARGET_ARCH=openrisc
6092 TARGET_BASE_ARCH=openrisc
e67db06e 6093 ;;
2408a527 6094 ppc)
c8b3532d 6095 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2408a527
AJ
6096 ;;
6097 ppcemb)
6acff7da 6098 TARGET_BASE_ARCH=ppc
e6e91b9c 6099 TARGET_ABI_DIR=ppc
c8b3532d 6100 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
2408a527
AJ
6101 ;;
6102 ppc64)
6acff7da 6103 TARGET_BASE_ARCH=ppc
e6e91b9c 6104 TARGET_ABI_DIR=ppc
f0b0685d 6105 mttcg=yes
1438eff3 6106 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
2408a527 6107 ;;
9c35126c
DK
6108 ppc64le)
6109 TARGET_ARCH=ppc64
6110 TARGET_BASE_ARCH=ppc
6111 TARGET_ABI_DIR=ppc
f0b0685d 6112 mttcg=yes
1438eff3 6113 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
9c35126c 6114 ;;
2408a527 6115 ppc64abi32)
b498c8a0 6116 TARGET_ARCH=ppc64
6acff7da 6117 TARGET_BASE_ARCH=ppc
e6e91b9c 6118 TARGET_ABI_DIR=ppc
25be210f 6119 echo "TARGET_ABI32=y" >> $config_target_mak
1438eff3 6120 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
2408a527
AJ
6121 ;;
6122 sh4|sh4eb)
b498c8a0 6123 TARGET_ARCH=sh4
2408a527
AJ
6124 bflt="yes"
6125 ;;
6126 sparc)
2408a527
AJ
6127 ;;
6128 sparc64)
6acff7da 6129 TARGET_BASE_ARCH=sparc
2408a527
AJ
6130 ;;
6131 sparc32plus)
b498c8a0 6132 TARGET_ARCH=sparc64
6acff7da 6133 TARGET_BASE_ARCH=sparc
e6e91b9c 6134 TARGET_ABI_DIR=sparc
25be210f 6135 echo "TARGET_ABI32=y" >> $config_target_mak
2408a527 6136 ;;
24e804ec 6137 s390x)
8a641ff6 6138 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml"
24e804ec 6139 ;;
444e06b1
CG
6140 tilegx)
6141 ;;
5ecaa4ed
PC
6142 tricore)
6143 ;;
d2fbca94 6144 unicore32)
d2fbca94 6145 ;;
cfa550c6
MF
6146 xtensa|xtensaeb)
6147 TARGET_ARCH=xtensa
cfa550c6 6148 ;;
2408a527 6149 *)
76ad07a4 6150 error_exit "Unsupported target CPU"
2408a527
AJ
6151 ;;
6152esac
5e8861a0
PB
6153# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6154if [ "$TARGET_BASE_ARCH" = "" ]; then
6155 TARGET_BASE_ARCH=$TARGET_ARCH
6156fi
6157
5e8861a0
PB
6158symlink "$source_path/Makefile.target" "$target_dir/Makefile"
6159
99afc91d
DB
6160upper() {
6161 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
6162}
6163
89138857 6164target_arch_name="$(upper $TARGET_ARCH)"
25be210f 6165echo "TARGET_$target_arch_name=y" >> $config_target_mak
c1799a84 6166echo "TARGET_NAME=$target_name" >> $config_target_mak
25be210f 6167echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
e6e91b9c
JQ
6168if [ "$TARGET_ABI_DIR" = "" ]; then
6169 TARGET_ABI_DIR=$TARGET_ARCH
6170fi
25be210f 6171echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
adfc3e91
SS
6172if [ "$HOST_VARIANT_DIR" != "" ]; then
6173 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6174fi
c1799a84 6175case "$target_name" in
1b0c87fc
JQ
6176 i386|x86_64)
6177 if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
25be210f 6178 echo "CONFIG_XEN=y" >> $config_target_mak
eb6fda0f
AP
6179 if test "$xen_pci_passthrough" = yes; then
6180 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6181 fi
1b0c87fc 6182 fi
59d21e53
AG
6183 ;;
6184 *)
1b0c87fc 6185esac
c1799a84 6186case "$target_name" in
222e7d11 6187 aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
c59249f9
JQ
6188 # Make sure the target and host cpus are compatible
6189 if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
c1799a84
PB
6190 \( "$target_name" = "$cpu" -o \
6191 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
6192 \( "$target_name" = "ppc64" -a "$cpu" = "ppc" \) -o \
6193 \( "$target_name" = "ppc" -a "$cpu" = "ppc64" \) -o \
6194 \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
222e7d11 6195 \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
c1799a84 6196 \( "$target_name" = "x86_64" -a "$cpu" = "i386" \) -o \
18b8263e
MT
6197 \( "$target_name" = "i386" -a "$cpu" = "x86_64" \) -o \
6198 \( "$target_name" = "x86_64" -a "$cpu" = "x32" \) -o \
6199 \( "$target_name" = "i386" -a "$cpu" = "x32" \) \) ; then
25be210f 6200 echo "CONFIG_KVM=y" >> $config_target_mak
1ba16968 6201 if test "$vhost_net" = "yes" ; then
d5970055 6202 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
421f4448 6203 echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
d5970055 6204 fi
c59249f9
JQ
6205 fi
6206esac
b0cb0a66
VP
6207if test "$hax" = "yes" ; then
6208 if test "$target_softmmu" = "yes" ; then
6209 case "$target_name" in
6210 i386|x86_64)
6211 echo "CONFIG_HAX=y" >> $config_target_mak
6212 ;;
6213 esac
6214 fi
6215fi
de83cd02 6216if test "$target_bigendian" = "yes" ; then
25be210f 6217 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
de83cd02 6218fi
97a847bc 6219if test "$target_softmmu" = "yes" ; then
25be210f 6220 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
ca759f9e
AB
6221 if test "$mttcg" = "yes" ; then
6222 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6223 fi
43ce4dfe 6224fi
997344f3 6225if test "$target_user_only" = "yes" ; then
25be210f 6226 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
a2c80be9 6227 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
997344f3 6228fi
831b7825 6229if test "$target_linux_user" = "yes" ; then
25be210f 6230 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
831b7825 6231fi
56aebc89
PB
6232list=""
6233if test ! -z "$gdb_xml_files" ; then
6234 for x in $gdb_xml_files; do
6235 list="$list $source_path/gdb-xml/$x"
6236 done
3d0f1517 6237 echo "TARGET_XML_FILES=$list" >> $config_target_mak
56aebc89 6238fi
97a847bc 6239
e5fe0c52 6240if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
25be210f 6241 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
e5fe0c52 6242fi
84778508 6243if test "$target_bsd_user" = "yes" ; then
25be210f 6244 echo "CONFIG_BSD_USER=y" >> $config_target_mak
84778508 6245fi
5b0753e0 6246
4afddb55 6247# generate QEMU_CFLAGS/LDFLAGS for targets
fa282484 6248
4afddb55 6249cflags=""
fa282484 6250ldflags=""
9b8e111f 6251
c765fcac
PC
6252disas_config() {
6253 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6254 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6255}
6256
64656024
JQ
6257for i in $ARCH $TARGET_BASE_ARCH ; do
6258 case "$i" in
6259 alpha)
c765fcac 6260 disas_config "ALPHA"
64656024 6261 ;;
82295d8a
RH
6262 aarch64)
6263 if test -n "${cxx}"; then
c765fcac 6264 disas_config "ARM_A64"
82295d8a
RH
6265 fi
6266 ;;
64656024 6267 arm)
c765fcac 6268 disas_config "ARM"
999b53ec 6269 if test -n "${cxx}"; then
c765fcac 6270 disas_config "ARM_A64"
999b53ec 6271 fi
64656024
JQ
6272 ;;
6273 cris)
c765fcac 6274 disas_config "CRIS"
64656024 6275 ;;
429b31a2
RH
6276 hppa)
6277 disas_config "HPPA"
6278 ;;
c72b26ec 6279 i386|x86_64|x32)
c765fcac 6280 disas_config "I386"
64656024 6281 ;;
903ec55c 6282 ia64*)
c765fcac 6283 disas_config "IA64"
903ec55c 6284 ;;
79368f49 6285 lm32)
c765fcac 6286 disas_config "LM32"
79368f49 6287 ;;
64656024 6288 m68k)
c765fcac 6289 disas_config "M68K"
64656024 6290 ;;
877fdc12 6291 microblaze*)
c765fcac 6292 disas_config "MICROBLAZE"
64656024
JQ
6293 ;;
6294 mips*)
c765fcac 6295 disas_config "MIPS"
64656024 6296 ;;
d15a9c23 6297 moxie*)
c765fcac 6298 disas_config "MOXIE"
d15a9c23 6299 ;;
e671711c
MV
6300 nios2)
6301 disas_config "NIOS2"
6302 ;;
4a09d0bb 6303 or1k)
c765fcac 6304 disas_config "OPENRISC"
e67db06e 6305 ;;
64656024 6306 ppc*)
c765fcac 6307 disas_config "PPC"
64656024 6308 ;;
24e804ec 6309 s390*)
c765fcac 6310 disas_config "S390"
64656024
JQ
6311 ;;
6312 sh4)
c765fcac 6313 disas_config "SH4"
64656024
JQ
6314 ;;
6315 sparc*)
c765fcac 6316 disas_config "SPARC"
64656024 6317 ;;
cfa550c6 6318 xtensa*)
c765fcac 6319 disas_config "XTENSA"
cfa550c6 6320 ;;
64656024
JQ
6321 esac
6322done
9195b2c2 6323if test "$tcg_interpreter" = "yes" ; then
c765fcac 6324 disas_config "TCI"
9195b2c2 6325fi
64656024 6326
6ee7126f
JQ
6327case "$ARCH" in
6328alpha)
6329 # Ensure there's only a single GP
6330 cflags="-msmall-data $cflags"
6331;;
6332esac
6333
d02c1db3 6334if test "$gprof" = "yes" ; then
25be210f 6335 echo "TARGET_GPROF=yes" >> $config_target_mak
d02c1db3
JQ
6336 if test "$target_linux_user" = "yes" ; then
6337 cflags="-p $cflags"
6338 ldflags="-p $ldflags"
6339 fi
6340 if test "$target_softmmu" = "yes" ; then
6341 ldflags="-p $ldflags"
25be210f 6342 echo "GPROF_CFLAGS=-p" >> $config_target_mak
d02c1db3
JQ
6343 fi
6344fi
6345
9b8e111f 6346if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
964c6fa1 6347 ldflags="$ldflags $textseg_ldflags"
fa282484 6348fi
fa282484 6349
25be210f
JQ
6350echo "LDFLAGS+=$ldflags" >> $config_target_mak
6351echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
fa282484 6352
97a847bc 6353done # for target in $targets
7d13299d 6354
b776eca1
GH
6355if [ "$pixman" = "internal" ]; then
6356 echo "config-host.h: subdir-pixman" >> $config_host_mak
2da776db
MH
6357fi
6358
a540f158
PC
6359if [ "$dtc_internal" = "yes" ]; then
6360 echo "config-host.h: subdir-dtc" >> $config_host_mak
6361fi
6362
a99d57bb
WG
6363if test "$numa" = "yes"; then
6364 echo "CONFIG_NUMA=y" >> $config_host_mak
6365fi
6366
fd0e6053
JS
6367if test "$ccache_cpp2" = "yes"; then
6368 echo "export CCACHE_CPP2=y" >> $config_host_mak
6369fi
6370
d1807a4f 6371# build tree in object directory in case the source is not in the current directory
f93296ea 6372DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests"
56e8bdd4 6373DIRS="$DIRS docs fsdev"
9933c305 6374DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
d1807a4f 6375DIRS="$DIRS roms/seabios roms/vgabios"
2dee8d54 6376DIRS="$DIRS qapi-generated"
c09015dd
AL
6377FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6378FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
aaa2ebc5 6379FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
d1807a4f 6380FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
446b9165 6381FILES="$FILES pc-bios/spapr-rtas/Makefile"
9933c305 6382FILES="$FILES pc-bios/s390-ccw/Makefile"
d1807a4f 6383FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
4652b792 6384FILES="$FILES pc-bios/qemu-icon.bmp"
753d11f2
RH
6385for bios_file in \
6386 $source_path/pc-bios/*.bin \
225a9ab8 6387 $source_path/pc-bios/*.lid \
5acc2ec0 6388 $source_path/pc-bios/*.aml \
753d11f2
RH
6389 $source_path/pc-bios/*.rom \
6390 $source_path/pc-bios/*.dtb \
e89e33e1 6391 $source_path/pc-bios/*.img \
753d11f2 6392 $source_path/pc-bios/openbios-* \
4e73c781 6393 $source_path/pc-bios/u-boot.* \
753d11f2
RH
6394 $source_path/pc-bios/palcode-*
6395do
89138857 6396 FILES="$FILES pc-bios/$(basename $bios_file)"
d1807a4f 6397done
89138857 6398for test_file in $(find $source_path/tests/acpi-test-data -type f)
c2304b52 6399do
89138857 6400 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
c2304b52 6401done
d1807a4f
PB
6402mkdir -p $DIRS
6403for f in $FILES ; do
cab00a5a 6404 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
f9245e10
PM
6405 symlink "$source_path/$f" "$f"
6406 fi
d1807a4f 6407done
1ad2134f 6408
c34ebfdc 6409# temporary config to build submodules
2d9f27d2 6410for rom in seabios vgabios ; do
c34ebfdc 6411 config_mak=roms/$rom/config.mak
37116c89 6412 echo "# Automatically generated by configure - do not modify" > $config_mak
c34ebfdc 6413 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
cdbd727c 6414 echo "AS=$as" >> $config_mak
5f6f0e27 6415 echo "CCAS=$ccas" >> $config_mak
c34ebfdc
AL
6416 echo "CC=$cc" >> $config_mak
6417 echo "BCC=bcc" >> $config_mak
3dd46c78 6418 echo "CPP=$cpp" >> $config_mak
c34ebfdc 6419 echo "OBJCOPY=objcopy" >> $config_mak
a31a8642 6420 echo "IASL=$iasl" >> $config_mak
c34ebfdc
AL
6421 echo "LD=$ld" >> $config_mak
6422done
6423
fe31017f
MAL
6424# set up tests data directory
6425if [ ! -e tests/data ]; then
6426 symlink "$source_path/tests/data" tests/data
6427fi
6428
76c7560a
HR
6429# set up qemu-iotests in this build directory
6430iotests_common_env="tests/qemu-iotests/common.env"
6431iotests_check="tests/qemu-iotests/check"
6432
6433echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
6434echo >> "$iotests_common_env"
6435echo "export PYTHON='$python'" >> "$iotests_common_env"
6436
6437if [ ! -e "$iotests_check" ]; then
6438 symlink "$source_path/$iotests_check" "$iotests_check"
6439fi
6440
dc655404
MT
6441# Save the configure command line for later reuse.
6442cat <<EOD >config.status
6443#!/bin/sh
6444# Generated by configure.
6445# Run this file to recreate the current configuration.
6446# Compiler output produced by configure, useful for debugging
6447# configure, is in config.log if it exists.
6448EOD
6449printf "exec" >>config.status
6450printf " '%s'" "$0" "$@" >>config.status
cf7cc929 6451echo ' "$@"' >>config.status
dc655404
MT
6452chmod +x config.status
6453
8cd05ab6 6454rm -r "$TMPDIR1"