Merge remote-tracking branch 'qemu/master'
[qemu/ar7.git] / configure
blobf9f5a1087e6b74d42b584239eb580491393915f5
1 #!/bin/sh
3 # qemu configure script (c) 2003 Fabrice Bellard
6 # Unset some variables known to interfere with behavior of common tools,
7 # just as autoconf does.
8 CLICOLOR_FORCE= GREP_OPTIONS=
9 unset CLICOLOR_FORCE GREP_OPTIONS
11 # Don't allow CCACHE, if present, to use cached results of compile tests!
12 export CCACHE_RECACHE=yes
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.)
19 TMPDIR1="config-temp"
20 rm -rf "${TMPDIR1}"
21 mkdir -p "${TMPDIR1}"
22 if [ $? -ne 0 ]; then
23 echo "ERROR: failed to create temporary directory"
24 exit 1
27 TMPB="qemu-conf"
28 TMPC="${TMPDIR1}/${TMPB}.c"
29 TMPO="${TMPDIR1}/${TMPB}.o"
30 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
31 TMPE="${TMPDIR1}/${TMPB}.exe"
32 TMPMO="${TMPDIR1}/${TMPB}.mo"
34 rm -f config.log
36 # Print a helpful header at the top of config.log
37 echo "# QEMU configure log $(date)" >> config.log
38 printf "# Configured with:" >> config.log
39 printf " '%s'" "$0" "$@" >> config.log
40 echo >> config.log
41 echo "#" >> config.log
43 print_error() {
44 (echo
45 echo "ERROR: $1"
46 while test -n "$2"; do
47 echo " $2"
48 shift
49 done
50 echo) >&2
53 error_exit() {
54 print_error "$@"
55 exit 1
58 do_compiler() {
59 # Run the compiler, capturing its output to the log. First argument
60 # is compiler binary to execute.
61 local compiler="$1"
62 shift
63 if test -n "$BASH_VERSION"; then eval '
64 echo >>config.log "
65 funcs: ${FUNCNAME[*]}
66 lines: ${BASH_LINENO[*]}"
67 '; fi
68 echo $compiler "$@" >> config.log
69 $compiler "$@" >> config.log 2>&1 || return $?
70 # Test passed. If this is an --enable-werror build, rerun
71 # the test with -Werror and bail out if it fails. This
72 # makes warning-generating-errors in configure test code
73 # obvious to developers.
74 if test "$werror" != "yes"; then
75 return 0
77 # Don't bother rerunning the compile if we were already using -Werror
78 case "$*" in
79 *-Werror*)
80 return 0
82 esac
83 echo $compiler -Werror "$@" >> config.log
84 $compiler -Werror "$@" >> config.log 2>&1 && return $?
85 error_exit "configure test passed without -Werror but failed with -Werror." \
86 "This is probably a bug in the configure script. The failing command" \
87 "will be at the bottom of config.log." \
88 "You can run configure with --disable-werror to bypass this check."
91 do_cc() {
92 do_compiler "$cc" "$@"
95 do_cxx() {
96 do_compiler "$cxx" "$@"
99 update_cxxflags() {
100 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
101 # options which some versions of GCC's C++ compiler complain about
102 # because they only make sense for C programs.
103 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
105 for arg in $QEMU_CFLAGS; do
106 case $arg in
107 -Wno-override-init|\
108 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
109 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
112 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
114 esac
115 done
118 compile_object() {
119 local_cflags="$1"
120 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
123 compile_prog() {
124 local_cflags="$1"
125 local_ldflags="$2"
126 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
129 # symbolically link $1 to $2. Portable version of "ln -sf".
130 symlink() {
131 rm -rf "$2"
132 mkdir -p "$(dirname "$2")"
133 ln -s "$1" "$2"
136 # check whether a command is available to this shell (may be either an
137 # executable or a builtin)
138 has() {
139 type "$1" >/dev/null 2>&1
142 # search for an executable in PATH
143 path_of() {
144 local_command="$1"
145 local_ifs="$IFS"
146 local_dir=""
148 # pathname has a dir component?
149 if [ "${local_command#*/}" != "$local_command" ]; then
150 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
151 echo "$local_command"
152 return 0
155 if [ -z "$local_command" ]; then
156 return 1
159 IFS=:
160 for local_dir in $PATH; do
161 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
162 echo "$local_dir/$local_command"
163 IFS="${local_ifs:-$(printf ' \t\n')}"
164 return 0
166 done
167 # not found
168 IFS="${local_ifs:-$(printf ' \t\n')}"
169 return 1
172 have_backend () {
173 echo "$trace_backends" | grep "$1" >/dev/null
176 glob() {
177 eval test -z '"${1#'"$2"'}"'
180 supported_hax_target() {
181 test "$hax" = "yes" || return 1
182 glob "$1" "*-softmmu" || return 1
183 case "${1%-softmmu}" in
184 i386|x86_64)
185 return 0
187 esac
188 return 1
191 supported_kvm_target() {
192 test "$kvm" = "yes" || return 1
193 glob "$1" "*-softmmu" || return 1
194 case "${1%-softmmu}:$cpu" in
195 arm:arm | aarch64:aarch64 | \
196 i386:i386 | i386:x86_64 | i386:x32 | \
197 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
198 mips:mips | mipsel:mips | \
199 ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | \
200 s390x:s390x)
201 return 0
203 esac
204 return 1
207 supported_xen_target() {
208 test "$xen" = "yes" || return 1
209 glob "$1" "*-softmmu" || return 1
210 # Only i386 and x86_64 provide the xenpv machine.
211 case "${1%-softmmu}" in
212 i386|x86_64)
213 return 0
215 esac
216 return 1
219 supported_hvf_target() {
220 test "$hvf" = "yes" || return 1
221 glob "$1" "*-softmmu" || return 1
222 case "${1%-softmmu}" in
223 x86_64)
224 return 0
226 esac
227 return 1
230 supported_whpx_target() {
231 test "$whpx" = "yes" || return 1
232 glob "$1" "*-softmmu" || return 1
233 case "${1%-softmmu}" in
234 i386|x86_64)
235 return 0
237 esac
238 return 1
241 supported_target() {
242 case "$1" in
243 *-softmmu)
245 *-linux-user)
246 if test "$linux" != "yes"; then
247 print_error "Target '$target' is only available on a Linux host"
248 return 1
251 *-bsd-user)
252 if test "$bsd" != "yes"; then
253 print_error "Target '$target' is only available on a BSD host"
254 return 1
258 print_error "Invalid target name '$target'"
259 return 1
261 esac
262 test "$tcg" = "yes" && return 0
263 supported_kvm_target "$1" && return 0
264 supported_xen_target "$1" && return 0
265 supported_hax_target "$1" && return 0
266 supported_hvf_target "$1" && return 0
267 supported_whpx_target "$1" && return 0
268 print_error "TCG disabled, but hardware accelerator not available for '$target'"
269 return 1
273 ld_has() {
274 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
277 # default parameters
278 source_path=$(dirname "$0")
279 cpu=""
280 iasl="iasl"
281 interp_prefix="/usr/gnemul/qemu-%M"
282 static="no"
283 cross_prefix=""
284 audio_drv_list=""
285 block_drv_rw_whitelist=""
286 block_drv_ro_whitelist=""
287 host_cc="cc"
288 libs_softmmu=""
289 libs_tools=""
290 audio_pt_int=""
291 audio_win_int=""
292 libs_qga=""
293 debug_info="yes"
294 stack_protector=""
296 if test -e "$source_path/.git"
297 then
298 git_update=yes
299 git_submodules="ui/keycodemapdb"
300 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
301 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
302 else
303 git_update=no
304 git_submodules=""
306 if ! test -f "$source_path/ui/keycodemapdb/README"
307 then
308 echo
309 echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
310 echo
311 echo "This is not a GIT checkout but module content appears to"
312 echo "be missing. Do not use 'git archive' or GitHub download links"
313 echo "to acquire QEMU source archives. Non-GIT builds are only"
314 echo "supported with source archives linked from:"
315 echo
316 echo " https://www.qemu.org/download/"
317 echo
318 echo "Developers working with GIT can use scripts/archive-source.sh"
319 echo "if they need to create valid source archives."
320 echo
321 exit 1
324 git="git"
326 # Don't accept a target_list environment variable.
327 unset target_list
329 # Default value for a variable defining feature "foo".
330 # * foo="no" feature will only be used if --enable-foo arg is given
331 # * foo="" feature will be searched for, and if found, will be used
332 # unless --disable-foo is given
333 # * foo="yes" this value will only be set by --enable-foo flag.
334 # feature will searched for,
335 # if not found, configure exits with error
337 # Always add --enable-foo and --disable-foo command line args.
338 # Distributions want to ensure that several features are compiled in, and it
339 # is impossible without a --enable-foo that exits if a feature is not found.
341 bluez=""
342 brlapi=""
343 curl=""
344 curses=""
345 docs=""
346 fdt=""
347 netmap="no"
348 sdl=""
349 sdlabi=""
350 virtfs=""
351 mpath=""
352 vnc="yes"
353 sparse="no"
354 vde=""
355 vnc_sasl=""
356 vnc_jpeg=""
357 vnc_png=""
358 xkbcommon=""
359 xen=""
360 xen_ctrl_version=""
361 xen_pv_domain_build="no"
362 xen_pci_passthrough=""
363 linux_aio=""
364 cap_ng=""
365 attr=""
366 libattr=""
367 xfs=""
368 tcg="yes"
369 membarrier=""
370 vhost_net="no"
371 vhost_crypto="no"
372 vhost_scsi="no"
373 vhost_vsock="no"
374 vhost_user=""
375 kvm="no"
376 hax="no"
377 hvf="no"
378 whpx="no"
379 rdma=""
380 pvrdma=""
381 gprof="no"
382 debug_tcg="no"
383 debug="no"
384 sanitizers="no"
385 fortify_source=""
386 strip_opt="yes"
387 tcg_interpreter="no"
388 bigendian="no"
389 mingw32="no"
390 gcov="no"
391 gcov_tool="gcov"
392 EXESUF=""
393 DSOSUF=".so"
394 LDFLAGS_SHARED="-shared"
395 modules="no"
396 prefix="/usr/local"
397 mandir="\${prefix}/share/man"
398 datadir="\${prefix}/share"
399 firmwarepath="\${prefix}/share/qemu-firmware"
400 qemu_docdir="\${prefix}/share/doc/qemu"
401 bindir="\${prefix}/bin"
402 libdir="\${prefix}/lib"
403 libexecdir="\${prefix}/libexec"
404 includedir="\${prefix}/include"
405 sysconfdir="\${prefix}/etc"
406 local_statedir="\${prefix}/var"
407 confsuffix="/qemu"
408 slirp="yes"
409 oss_lib=""
410 bsd="no"
411 haiku="no"
412 linux="no"
413 solaris="no"
414 profiler="no"
415 cocoa="no"
416 softmmu="yes"
417 linux_user="no"
418 bsd_user="no"
419 blobs="yes"
420 pkgversion=""
421 pie=""
422 qom_cast_debug="yes"
423 trace_backends="log"
424 trace_file="trace"
425 spice=""
426 rbd=""
427 smartcard=""
428 libusb=""
429 usb_redir=""
430 opengl=""
431 opengl_dmabuf="no"
432 cpuid_h="no"
433 avx2_opt=""
434 zlib="yes"
435 capstone=""
436 lzo=""
437 snappy=""
438 bzip2=""
439 lzfse=""
440 guest_agent=""
441 guest_agent_with_vss="no"
442 guest_agent_ntddscsi="no"
443 guest_agent_msi=""
444 vss_win32_sdk=""
445 win_sdk="no"
446 want_tools="yes"
447 libiscsi=""
448 libnfs=""
449 coroutine=""
450 coroutine_pool=""
451 debug_stack_usage="no"
452 crypto_afalg="no"
453 seccomp=""
454 glusterfs=""
455 glusterfs_xlator_opt="no"
456 glusterfs_discard="no"
457 glusterfs_fallocate="no"
458 glusterfs_zerofill="no"
459 gtk=""
460 gtk_gl="no"
461 tls_priority="NORMAL"
462 gnutls=""
463 nettle=""
464 gcrypt=""
465 gcrypt_hmac="no"
466 vte=""
467 virglrenderer=""
468 tpm="yes"
469 libssh2=""
470 live_block_migration="yes"
471 numa=""
472 tcmalloc="no"
473 jemalloc="no"
474 replication="yes"
475 vxhs=""
476 bochs="yes"
477 cloop="yes"
478 dmg="yes"
479 qcow1="yes"
480 vdi="yes"
481 vvfat="yes"
482 qed="yes"
483 parallels="yes"
484 sheepdog="yes"
485 libxml2=""
486 docker="no"
487 debug_mutex="no"
488 libpmem=""
489 libudev="no"
491 # cross compilers defaults, can be overridden with --cross-cc-ARCH
492 cross_cc_aarch64="aarch64-linux-gnu-gcc"
493 cross_cc_aarch64_be="$cross_cc_aarch64"
494 cross_cc_cflags_aarch64_be="-mbig-endian"
495 cross_cc_arm="arm-linux-gnueabihf-gcc"
496 cross_cc_cflags_armeb="-mbig-endian"
497 cross_cc_i386="i386-pc-linux-gnu-gcc"
498 cross_cc_cflags_i386=""
499 cross_cc_powerpc="powerpc-linux-gnu-gcc"
500 cross_cc_powerpc="powerpc-linux-gnu-gcc"
502 enabled_cross_compilers=""
504 supported_cpu="no"
505 supported_os="no"
506 bogus_os="no"
507 malloc_trim=""
509 # parse CC options first
510 for opt do
511 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
512 case "$opt" in
513 --cross-prefix=*) cross_prefix="$optarg"
515 --cc=*) CC="$optarg"
517 --cxx=*) CXX="$optarg"
519 --source-path=*) source_path="$optarg"
521 --cpu=*) cpu="$optarg"
523 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
525 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
527 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
528 EXTRA_LDFLAGS="$optarg"
530 --enable-debug-info) debug_info="yes"
532 --disable-debug-info) debug_info="no"
534 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
536 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
537 eval "cross_cc_cflags_${cc_arch}=\$optarg"
539 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
540 eval "cross_cc_${cc_arch}=\$optarg"
542 esac
543 done
544 # OS specific
545 # Using uname is really, really broken. Once we have the right set of checks
546 # we can eliminate its usage altogether.
548 # Preferred compiler:
549 # ${CC} (if set)
550 # ${cross_prefix}gcc (if cross-prefix specified)
551 # system compiler
552 if test -z "${CC}${cross_prefix}"; then
553 cc="$host_cc"
554 else
555 cc="${CC-${cross_prefix}gcc}"
558 if test -z "${CXX}${cross_prefix}"; then
559 cxx="c++"
560 else
561 cxx="${CXX-${cross_prefix}g++}"
564 ar="${AR-${cross_prefix}ar}"
565 as="${AS-${cross_prefix}as}"
566 ccas="${CCAS-$cc}"
567 cpp="${CPP-$cc -E}"
568 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
569 ld="${LD-${cross_prefix}ld}"
570 ranlib="${RANLIB-${cross_prefix}ranlib}"
571 nm="${NM-${cross_prefix}nm}"
572 strip="${STRIP-${cross_prefix}strip}"
573 windres="${WINDRES-${cross_prefix}windres}"
574 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
575 query_pkg_config() {
576 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
578 pkg_config=query_pkg_config
579 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
580 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
582 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
583 ARFLAGS="${ARFLAGS-rv}"
585 # default flags for all hosts
586 # We use -fwrapv to tell the compiler that we require a C dialect where
587 # left shift of signed integers is well defined and has the expected
588 # 2s-complement style results. (Both clang and gcc agree that it
589 # provides these semantics.)
590 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
591 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
592 QEMU_CFLAGS="-Wmissing-format-attribute $QEMU_CFLAGS"
593 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
594 QEMU_CFLAGS="-Wno-unused-parameter $QEMU_CFLAGS"
595 QEMU_CFLAGS="-Wno-missing-field-initializers $QEMU_CFLAGS"
596 QEMU_CFLAGS="-Wno-sign-compare $QEMU_CFLAGS"
597 QEMU_CFLAGS="-Wno-override-init $QEMU_CFLAGS"
598 QEMU_CFLAGS="-Wno-error=format $QEMU_CFLAGS"
599 QEMU_CFLAGS="-Wno-error=format-extra-args $QEMU_CFLAGS"
600 QEMU_CFLAGS="-Wno-error=parentheses $QEMU_CFLAGS"
601 QEMU_CFLAGS="-Wextra $QEMU_CFLAGS"
602 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
603 QEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
604 if test "$debug_info" = "yes"; then
605 CFLAGS="-g $CFLAGS"
606 LDFLAGS="-g $LDFLAGS"
609 # make source path absolute
610 source_path=$(cd "$source_path"; pwd)
612 cc_macros=$($cc $QEMU_CFLAGS -E -dD - </dev/null)
614 # running configure in the source tree?
615 # we know that's the case if configure is there.
616 if test -f "./configure"; then
617 pwd_is_source_path="y"
618 else
619 pwd_is_source_path="n"
622 check_define() {
623 rm -f $TMPC
624 cat > $TMPC <<EOF
625 #if !defined($1)
626 #error $1 not defined
627 #endif
628 int main(void) { return 0; }
630 compile_object
633 check_include() {
634 cat > $TMPC <<EOF
635 #include <$1>
636 int main(void) { return 0; }
638 compile_object
641 write_c_skeleton() {
642 cat > $TMPC <<EOF
643 int main(void) { return 0; }
647 if check_define __linux__ ; then
648 targetos="Linux"
649 elif check_define _WIN32 ; then
650 targetos='MINGW32'
651 elif check_define __OpenBSD__ ; then
652 targetos='OpenBSD'
653 elif check_define __sun__ ; then
654 targetos='SunOS'
655 elif check_define __HAIKU__ ; then
656 targetos='Haiku'
657 elif check_define __FreeBSD__ ; then
658 targetos='FreeBSD'
659 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
660 targetos='GNU/kFreeBSD'
661 elif check_define __DragonFly__ ; then
662 targetos='DragonFly'
663 elif check_define __NetBSD__; then
664 targetos='NetBSD'
665 elif check_define __APPLE__; then
666 targetos='Darwin'
667 else
668 # This is a fatal error, but don't report it yet, because we
669 # might be going to just print the --help text, or it might
670 # be the result of a missing compiler.
671 targetos='bogus'
672 bogus_os='yes'
675 # Some host OSes need non-standard checks for which CPU to use.
676 # Note that these checks are broken for cross-compilation: if you're
677 # cross-compiling to one of these OSes then you'll need to specify
678 # the correct CPU with the --cpu option.
679 case $targetos in
680 Darwin)
681 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
682 # run 64-bit userspace code.
683 # If the user didn't specify a CPU explicitly and the kernel says this is
684 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
685 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
686 cpu="x86_64"
689 SunOS)
690 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
691 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
692 cpu="x86_64"
694 esac
696 if test ! -z "$cpu" ; then
697 # command line argument
699 elif check_define __i386__ ; then
700 cpu="i386"
701 elif check_define __x86_64__ ; then
702 if check_define __ILP32__ ; then
703 cpu="x32"
704 else
705 cpu="x86_64"
707 elif check_define __sparc__ ; then
708 if check_define __arch64__ ; then
709 cpu="sparc64"
710 else
711 cpu="sparc"
713 elif check_define _ARCH_PPC ; then
714 if check_define _ARCH_PPC64 ; then
715 cpu="ppc64"
716 else
717 cpu="ppc"
719 elif check_define __mips__ ; then
720 if check_define __mips64 ; then
721 cpu="mips64"
722 else
723 cpu="mips"
725 elif check_define __s390__ ; then
726 if check_define __s390x__ ; then
727 cpu="s390x"
728 else
729 cpu="s390"
731 elif check_define __arm__ ; then
732 cpu="arm"
733 elif check_define __aarch64__ ; then
734 cpu="aarch64"
735 else
736 cpu=$(uname -m)
739 ARCH=
740 # Normalise host CPU name and set ARCH.
741 # Note that this case should only have supported host CPUs, not guests.
742 case "$cpu" in
743 ppc|ppc64|s390|s390x|sparc64|x32)
744 cpu="$cpu"
745 supported_cpu="yes"
746 eval "cross_cc_${cpu}=\$host_cc"
748 i386|i486|i586|i686|i86pc|BePC)
749 cpu="i386"
750 supported_cpu="yes"
751 cross_cc_i386=$host_cc
753 x86_64|amd64)
754 cpu="x86_64"
755 supported_cpu="yes"
756 cross_cc_x86_64=$host_cc
758 armv*b|armv*l|arm)
759 cpu="arm"
760 supported_cpu="yes"
761 cross_cc_arm=$host_cc
763 aarch64)
764 cpu="aarch64"
765 supported_cpu="yes"
766 cross_cc_aarch64=$host_cc
768 mips*)
769 cpu="mips"
770 if check_define __MIPSEL__ ; then
771 cpu="${cpu}el"
773 supported_cpu="yes"
774 cross_cc_mips=$host_cc
776 sparc|sun4[cdmuv])
777 cpu="sparc"
778 supported_cpu="yes"
779 cross_cc_sparc=$host_cc
781 sh4)
782 cpu="sh4"
785 # This will result in either an error or falling back to TCI later
786 ARCH=unknown
788 esac
789 if test -z "$ARCH"; then
790 ARCH="$cpu"
793 # OS specific
795 # host *BSD for user mode
796 HOST_VARIANT_DIR=""
798 case $targetos in
799 MINGW32*)
800 mingw32="yes"
801 hax="yes"
802 audio_possible_drivers="dsound sdl"
803 if check_include dsound.h; then
804 audio_drv_list="dsound"
805 else
806 audio_drv_list=""
808 supported_os="yes"
810 GNU/kFreeBSD)
811 bsd="yes"
812 audio_drv_list="oss"
813 audio_possible_drivers="oss sdl pa"
815 FreeBSD)
816 bsd="yes"
817 make="${MAKE-gmake}"
818 audio_drv_list="oss"
819 audio_possible_drivers="oss sdl pa"
820 # needed for kinfo_getvmmap(3) in libutil.h
821 LIBS="-lutil $LIBS"
822 # needed for kinfo_getproc
823 libs_qga="-lutil $libs_qga"
824 netmap="" # enable netmap autodetect
825 HOST_VARIANT_DIR="freebsd"
826 supported_os="yes"
828 DragonFly)
829 bsd="yes"
830 make="${MAKE-gmake}"
831 audio_drv_list="oss"
832 audio_possible_drivers="oss sdl pa"
833 HOST_VARIANT_DIR="dragonfly"
835 NetBSD)
836 bsd="yes"
837 make="${MAKE-gmake}"
838 audio_drv_list="oss"
839 audio_possible_drivers="oss sdl"
840 oss_lib="-lossaudio"
841 HOST_VARIANT_DIR="netbsd"
842 supported_os="yes"
844 OpenBSD)
845 bsd="yes"
846 make="${MAKE-gmake}"
847 audio_drv_list="sdl"
848 audio_possible_drivers="sdl"
849 HOST_VARIANT_DIR="openbsd"
850 supported_os="yes"
852 Darwin)
853 bsd="yes"
854 darwin="yes"
855 hax="yes"
856 hvf="yes"
857 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
858 if [ "$cpu" = "x86_64" ] ; then
859 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
860 LDFLAGS="-arch x86_64 $LDFLAGS"
862 cocoa="yes"
863 audio_drv_list="coreaudio"
864 audio_possible_drivers="coreaudio sdl"
865 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
866 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
867 # Disable attempts to use ObjectiveC features in os/object.h since they
868 # won't work when we're compiling with gcc as a C compiler.
869 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
870 HOST_VARIANT_DIR="darwin"
871 supported_os="yes"
873 SunOS)
874 solaris="yes"
875 make="${MAKE-gmake}"
876 install="${INSTALL-ginstall}"
877 smbd="${SMBD-/usr/sfw/sbin/smbd}"
878 if test -f /usr/include/sys/soundcard.h ; then
879 audio_drv_list="oss"
881 audio_possible_drivers="oss sdl"
882 # needed for CMSG_ macros in sys/socket.h
883 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
884 # needed for TIOCWIN* defines in termios.h
885 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
886 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
887 solarisnetlibs="-lsocket -lnsl -lresolv"
888 LIBS="$solarisnetlibs $LIBS"
889 libs_qga="$solarisnetlibs $libs_qga"
891 Haiku)
892 haiku="yes"
893 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
894 LIBS="-lposix_error_mapper -lnetwork $LIBS"
896 Linux)
897 audio_drv_list="oss"
898 audio_possible_drivers="oss alsa sdl pa"
899 linux="yes"
900 linux_user="yes"
901 kvm="yes"
902 vhost_net="yes"
903 vhost_crypto="yes"
904 vhost_scsi="yes"
905 vhost_vsock="yes"
906 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
907 supported_os="yes"
908 libudev="yes"
910 esac
912 if [ "$bsd" = "yes" ] ; then
913 if [ "$darwin" != "yes" ] ; then
914 bsd_user="yes"
918 : ${make=${MAKE-make}}
919 : ${install=${INSTALL-install}}
920 : ${python=${PYTHON-python}}
921 : ${smbd=${SMBD-/usr/sbin/smbd}}
923 # Default objcc to clang if available, otherwise use CC
924 if has clang; then
925 objcc=clang
926 else
927 objcc="$cc"
930 if test "$mingw32" = "yes" ; then
931 EXESUF=".exe"
932 DSOSUF=".dll"
933 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
934 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
935 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
936 # MinGW-w64 needs _POSIX defined.
937 QEMU_CFLAGS="-D_POSIX=1 $QEMU_CFLAGS"
938 # MinGW needs -mthreads for TLS and macro _MT.
939 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
940 QEMU_CFLAGS="-I\$(SRC_PATH)/hosts/w32/include $QEMU_CFLAGS"
941 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
942 write_c_skeleton;
943 if compile_prog "" "-liberty" ; then
944 LIBS="-liberty $LIBS"
946 prefix="c:/Program Files/QEMU"
947 mandir="\${prefix}"
948 datadir="\${prefix}"
949 qemu_docdir="\${prefix}"
950 bindir="\${prefix}"
951 sysconfdir="\${prefix}"
952 local_statedir=
953 confsuffix=""
954 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
957 werror=""
959 for opt do
960 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
961 case "$opt" in
962 --help|-h) show_help=yes
964 --version|-V) exec cat $source_path/VERSION
966 --prefix=*) prefix="$optarg"
968 --interp-prefix=*) interp_prefix="$optarg"
970 --source-path=*)
972 --cross-prefix=*)
974 --cc=*)
976 --host-cc=*) host_cc="$optarg"
978 --cxx=*)
980 --iasl=*) iasl="$optarg"
982 --objcc=*) objcc="$optarg"
984 --make=*) make="$optarg"
986 --install=*) install="$optarg"
988 --python=*) python="$optarg"
990 --gcov=*) gcov_tool="$optarg"
992 --smbd=*) smbd="$optarg"
994 --extra-cflags=*)
996 --extra-cxxflags=*)
998 --extra-ldflags=*)
1000 --enable-debug-info)
1002 --disable-debug-info)
1004 --cross-cc-*)
1006 --enable-modules)
1007 modules="yes"
1009 --disable-modules)
1010 modules="no"
1012 --cpu=*)
1014 --target-list=*) target_list="$optarg"
1016 --enable-trace-backends=*) trace_backends="$optarg"
1018 # XXX: backwards compatibility
1019 --enable-trace-backend=*) trace_backends="$optarg"
1021 --with-trace-file=*) trace_file="$optarg"
1023 --enable-gprof) gprof="yes"
1025 --enable-gcov) gcov="yes"
1027 --static)
1028 static="yes"
1029 LDFLAGS="-static $LDFLAGS"
1030 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
1032 --mandir=*) mandir="$optarg"
1034 --bindir=*) bindir="$optarg"
1036 --libdir=*) libdir="$optarg"
1038 --libexecdir=*) libexecdir="$optarg"
1040 --includedir=*) includedir="$optarg"
1042 --datadir=*) datadir="$optarg"
1044 --with-confsuffix=*) confsuffix="$optarg"
1046 --docdir=*) qemu_docdir="$optarg"
1048 --sysconfdir=*) sysconfdir="$optarg"
1050 --localstatedir=*) local_statedir="$optarg"
1052 --firmwarepath=*) firmwarepath="$optarg"
1054 --host=*|--build=*|\
1055 --disable-dependency-tracking|\
1056 --sbindir=*|--sharedstatedir=*|\
1057 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1058 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1059 # These switches are silently ignored, for compatibility with
1060 # autoconf-generated configure scripts. This allows QEMU's
1061 # configure to be used by RPM and similar macros that set
1062 # lots of directory switches by default.
1064 --disable-sdl) sdl="no"
1066 --enable-sdl) sdl="yes"
1068 --with-sdlabi=*) sdlabi="$optarg"
1070 --disable-qom-cast-debug) qom_cast_debug="no"
1072 --enable-qom-cast-debug) qom_cast_debug="yes"
1074 --disable-virtfs) virtfs="no"
1076 --enable-virtfs) virtfs="yes"
1078 --disable-mpath) mpath="no"
1080 --enable-mpath) mpath="yes"
1082 --disable-vnc) vnc="no"
1084 --enable-vnc) vnc="yes"
1086 --oss-lib=*) oss_lib="$optarg"
1088 --audio-drv-list=*) audio_drv_list="$optarg"
1090 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1092 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1094 --enable-debug-tcg) debug_tcg="yes"
1096 --disable-debug-tcg) debug_tcg="no"
1098 --enable-debug)
1099 # Enable debugging options that aren't excessively noisy
1100 debug_tcg="yes"
1101 debug_mutex="yes"
1102 debug="yes"
1103 strip_opt="no"
1104 fortify_source="no"
1106 --enable-sanitizers) sanitizers="yes"
1108 --disable-sanitizers) sanitizers="no"
1110 --enable-sparse) sparse="yes"
1112 --disable-sparse) sparse="no"
1114 --disable-strip) strip_opt="no"
1116 --disable-vnc-sasl) vnc_sasl="no"
1118 --enable-vnc-sasl) vnc_sasl="yes"
1120 --disable-vnc-jpeg) vnc_jpeg="no"
1122 --enable-vnc-jpeg) vnc_jpeg="yes"
1124 --disable-vnc-png) vnc_png="no"
1126 --enable-vnc-png) vnc_png="yes"
1128 --disable-slirp) slirp="no"
1130 --disable-vde) vde="no"
1132 --enable-vde) vde="yes"
1134 --disable-netmap) netmap="no"
1136 --enable-netmap) netmap="yes"
1138 --disable-xen) xen="no"
1140 --enable-xen) xen="yes"
1142 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1144 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1146 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
1148 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
1150 --disable-brlapi) brlapi="no"
1152 --enable-brlapi) brlapi="yes"
1154 --disable-bluez) bluez="no"
1156 --enable-bluez) bluez="yes"
1158 --disable-kvm) kvm="no"
1160 --enable-kvm) kvm="yes"
1162 --disable-hax) hax="no"
1164 --enable-hax) hax="yes"
1166 --disable-hvf) hvf="no"
1168 --enable-hvf) hvf="yes"
1170 --disable-whpx) whpx="no"
1172 --enable-whpx) whpx="yes"
1174 --disable-tcg-interpreter) tcg_interpreter="no"
1176 --enable-tcg-interpreter) tcg_interpreter="yes"
1178 --disable-cap-ng) cap_ng="no"
1180 --enable-cap-ng) cap_ng="yes"
1182 --disable-tcg) tcg="no"
1184 --enable-tcg) tcg="yes"
1186 --disable-malloc-trim) malloc_trim="no"
1188 --enable-malloc-trim) malloc_trim="yes"
1190 --disable-spice) spice="no"
1192 --enable-spice) spice="yes"
1194 --disable-libiscsi) libiscsi="no"
1196 --enable-libiscsi) libiscsi="yes"
1198 --disable-libnfs) libnfs="no"
1200 --enable-libnfs) libnfs="yes"
1202 --enable-profiler) profiler="yes"
1204 --disable-cocoa) cocoa="no"
1206 --enable-cocoa)
1207 cocoa="yes" ;
1208 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1210 --disable-system) softmmu="no"
1212 --enable-system) softmmu="yes"
1214 --disable-user)
1215 linux_user="no" ;
1216 bsd_user="no" ;
1218 --enable-user) ;;
1219 --disable-linux-user) linux_user="no"
1221 --enable-linux-user) linux_user="yes"
1223 --disable-bsd-user) bsd_user="no"
1225 --enable-bsd-user) bsd_user="yes"
1227 --enable-pie) pie="yes"
1229 --disable-pie) pie="no"
1231 --enable-werror) werror="yes"
1233 --disable-werror) werror="no"
1235 --enable-stack-protector) stack_protector="yes"
1237 --disable-stack-protector) stack_protector="no"
1239 --disable-curses) curses="no"
1241 --enable-curses) curses="yes"
1243 --disable-curl) curl="no"
1245 --enable-curl) curl="yes"
1247 --disable-fdt) fdt="no"
1249 --enable-fdt) fdt="yes"
1251 --disable-linux-aio) linux_aio="no"
1253 --enable-linux-aio) linux_aio="yes"
1255 --disable-attr) attr="no"
1257 --enable-attr) attr="yes"
1259 --disable-membarrier) membarrier="no"
1261 --enable-membarrier) membarrier="yes"
1263 --disable-blobs) blobs="no"
1265 --with-pkgversion=*) pkgversion="$optarg"
1267 --with-coroutine=*) coroutine="$optarg"
1269 --disable-coroutine-pool) coroutine_pool="no"
1271 --enable-coroutine-pool) coroutine_pool="yes"
1273 --enable-debug-stack-usage) debug_stack_usage="yes"
1275 --enable-crypto-afalg) crypto_afalg="yes"
1277 --disable-crypto-afalg) crypto_afalg="no"
1279 --disable-docs) docs="no"
1281 --enable-docs) docs="yes"
1283 --disable-vhost-net) vhost_net="no"
1285 --enable-vhost-net) vhost_net="yes"
1287 --disable-vhost-crypto) vhost_crypto="no"
1289 --enable-vhost-crypto)
1290 vhost_crypto="yes"
1291 if test "$mingw32" = "yes"; then
1292 error_exit "vhost-crypto isn't available on win32"
1295 --disable-vhost-scsi) vhost_scsi="no"
1297 --enable-vhost-scsi) vhost_scsi="yes"
1299 --disable-vhost-vsock) vhost_vsock="no"
1301 --enable-vhost-vsock) vhost_vsock="yes"
1303 --disable-opengl) opengl="no"
1305 --enable-opengl) opengl="yes"
1307 --disable-rbd) rbd="no"
1309 --enable-rbd) rbd="yes"
1311 --disable-xfsctl) xfs="no"
1313 --enable-xfsctl) xfs="yes"
1315 --disable-smartcard) smartcard="no"
1317 --enable-smartcard) smartcard="yes"
1319 --disable-libusb) libusb="no"
1321 --enable-libusb) libusb="yes"
1323 --disable-usb-redir) usb_redir="no"
1325 --enable-usb-redir) usb_redir="yes"
1327 --disable-zlib-test) zlib="no"
1329 --disable-lzo) lzo="no"
1331 --enable-lzo) lzo="yes"
1333 --disable-snappy) snappy="no"
1335 --enable-snappy) snappy="yes"
1337 --disable-bzip2) bzip2="no"
1339 --enable-bzip2) bzip2="yes"
1341 --enable-lzfse) lzfse="yes"
1343 --disable-lzfse) lzfse="no"
1345 --enable-guest-agent) guest_agent="yes"
1347 --disable-guest-agent) guest_agent="no"
1349 --enable-guest-agent-msi) guest_agent_msi="yes"
1351 --disable-guest-agent-msi) guest_agent_msi="no"
1353 --with-vss-sdk) vss_win32_sdk=""
1355 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1357 --without-vss-sdk) vss_win32_sdk="no"
1359 --with-win-sdk) win_sdk=""
1361 --with-win-sdk=*) win_sdk="$optarg"
1363 --without-win-sdk) win_sdk="no"
1365 --enable-tools) want_tools="yes"
1367 --disable-tools) want_tools="no"
1369 --enable-seccomp) seccomp="yes"
1371 --disable-seccomp) seccomp="no"
1373 --disable-glusterfs) glusterfs="no"
1375 --disable-avx2) avx2_opt="no"
1377 --enable-avx2) avx2_opt="yes"
1379 --enable-glusterfs) glusterfs="yes"
1381 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1382 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1384 --enable-vhdx|--disable-vhdx)
1385 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1387 --enable-uuid|--disable-uuid)
1388 echo "$0: $opt is obsolete, UUID support is always built" >&2
1390 --disable-gtk) gtk="no"
1392 --enable-gtk) gtk="yes"
1394 --tls-priority=*) tls_priority="$optarg"
1396 --disable-gnutls) gnutls="no"
1398 --enable-gnutls) gnutls="yes"
1400 --disable-nettle) nettle="no"
1402 --enable-nettle) nettle="yes"
1404 --disable-gcrypt) gcrypt="no"
1406 --enable-gcrypt) gcrypt="yes"
1408 --enable-rdma) rdma="yes"
1410 --disable-rdma) rdma="no"
1412 --enable-pvrdma) pvrdma="yes"
1414 --disable-pvrdma) pvrdma="no"
1416 --disable-vte) vte="no"
1418 --enable-vte) vte="yes"
1420 --disable-virglrenderer) virglrenderer="no"
1422 --enable-virglrenderer) virglrenderer="yes"
1424 --disable-tpm) tpm="no"
1426 --enable-tpm) tpm="yes"
1428 --disable-libssh2) libssh2="no"
1430 --enable-libssh2) libssh2="yes"
1432 --disable-live-block-migration) live_block_migration="no"
1434 --enable-live-block-migration) live_block_migration="yes"
1436 --disable-numa) numa="no"
1438 --enable-numa) numa="yes"
1440 --disable-libxml2) libxml2="no"
1442 --enable-libxml2) libxml2="yes"
1444 --disable-tcmalloc) tcmalloc="no"
1446 --enable-tcmalloc) tcmalloc="yes"
1448 --disable-jemalloc) jemalloc="no"
1450 --enable-jemalloc) jemalloc="yes"
1452 --disable-replication) replication="no"
1454 --enable-replication) replication="yes"
1456 --disable-vxhs) vxhs="no"
1458 --enable-vxhs) vxhs="yes"
1460 --disable-bochs) bochs="no"
1462 --enable-bochs) bochs="yes"
1464 --disable-cloop) cloop="no"
1466 --enable-cloop) cloop="yes"
1468 --disable-dmg) dmg="no"
1470 --enable-dmg) dmg="yes"
1472 --disable-qcow1) qcow1="no"
1474 --enable-qcow1) qcow1="yes"
1476 --disable-vdi) vdi="no"
1478 --enable-vdi) vdi="yes"
1480 --disable-vvfat) vvfat="no"
1482 --enable-vvfat) vvfat="yes"
1484 --disable-qed) qed="no"
1486 --enable-qed) qed="yes"
1488 --disable-parallels) parallels="no"
1490 --enable-parallels) parallels="yes"
1492 --disable-sheepdog) sheepdog="no"
1494 --enable-sheepdog) sheepdog="yes"
1496 --disable-vhost-user) vhost_user="no"
1498 --enable-vhost-user)
1499 vhost_user="yes"
1500 if test "$mingw32" = "yes"; then
1501 error_exit "vhost-user isn't available on win32"
1504 --disable-capstone) capstone="no"
1506 --enable-capstone) capstone="yes"
1508 --enable-capstone=git) capstone="git"
1510 --enable-capstone=system) capstone="system"
1512 --with-git=*) git="$optarg"
1514 --enable-git-update) git_update=yes
1516 --disable-git-update) git_update=no
1518 --enable-debug-mutex) debug_mutex=yes
1520 --disable-debug-mutex) debug_mutex=no
1522 --enable-libpmem) libpmem=yes
1524 --disable-libpmem) libpmem=no
1527 echo "ERROR: unknown option $opt"
1528 echo "Try '$0 --help' for more information"
1529 exit 1
1531 esac
1532 done
1534 if test "$vhost_user" = ""; then
1535 if test "$mingw32" = "yes"; then
1536 vhost_user="no"
1537 else
1538 vhost_user="yes"
1542 case "$cpu" in
1543 ppc)
1544 CPU_CFLAGS="-m32"
1545 LDFLAGS="-m32 $LDFLAGS"
1546 cross_cc_powerpc=$cc
1547 cross_cc_cflags_powerpc=$CPU_CFLAGS
1549 ppc64)
1550 CPU_CFLAGS="-m64"
1551 LDFLAGS="-m64 $LDFLAGS"
1552 cross_cc_ppc64=$cc
1553 cross_cc_cflags_ppc64=$CPU_CFLAGS
1555 sparc)
1556 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1557 LDFLAGS="-m32 -mv8plus $LDFLAGS"
1558 cross_cc_sparc=$cc
1559 cross_cc_cflags_sparc=$CPU_CFLAGS
1561 sparc64)
1562 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1563 LDFLAGS="-m64 $LDFLAGS"
1564 cross_cc_sparc64=$cc
1565 cross_cc_cflags_sparc64=$CPU_CFLAGS
1567 s390)
1568 CPU_CFLAGS="-m31"
1569 LDFLAGS="-m31 $LDFLAGS"
1570 cross_cc_s390=$cc
1571 cross_cc_cflags_s390=$CPU_CFLAGS
1573 s390x)
1574 CPU_CFLAGS="-m64"
1575 LDFLAGS="-m64 $LDFLAGS"
1576 cross_cc_s390x=$cc
1577 cross_cc_cflags_s390x=$CPU_CFLAGS
1579 i386)
1580 CPU_CFLAGS="-m32"
1581 LDFLAGS="-m32 $LDFLAGS"
1582 cross_cc_i386=$cc
1583 cross_cc_cflags_i386=$CPU_CFLAGS
1585 x86_64)
1586 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1587 # If we truly care, we should simply detect this case at
1588 # runtime and generate the fallback to serial emulation.
1589 CPU_CFLAGS="-m64 -mcx16"
1590 LDFLAGS="-m64 $LDFLAGS"
1591 cross_cc_x86_64=$cc
1592 cross_cc_cflags_x86_64=$CPU_CFLAGS
1594 x32)
1595 CPU_CFLAGS="-mx32"
1596 LDFLAGS="-mx32 $LDFLAGS"
1597 cross_cc_i386=$cc
1598 cross_cc_cflags_i386=$CPU_CFLAGS
1600 # No special flags required for other host CPUs
1601 esac
1603 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1605 # For user-mode emulation the host arch has to be one we explicitly
1606 # support, even if we're using TCI.
1607 if [ "$ARCH" = "unknown" ]; then
1608 bsd_user="no"
1609 linux_user="no"
1612 default_target_list=""
1614 mak_wilds=""
1616 if [ "$softmmu" = "yes" ]; then
1617 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1619 if [ "$linux_user" = "yes" ]; then
1620 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1622 if [ "$bsd_user" = "yes" ]; then
1623 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1626 for config in $mak_wilds; do
1627 default_target_list="${default_target_list} $(basename "$config" .mak)"
1628 done
1630 # Enumerate public trace backends for --help output
1631 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1633 if test x"$show_help" = x"yes" ; then
1634 cat << EOF
1636 Usage: configure [options]
1637 Options: [defaults in brackets after descriptions]
1639 Standard options:
1640 --help print this message
1641 --prefix=PREFIX install in PREFIX [$prefix]
1642 --interp-prefix=PREFIX where to find shared libraries, etc.
1643 use %M for cpu name [$interp_prefix]
1644 --target-list=LIST set target list (default: build everything)
1645 $(echo Available targets: $default_target_list | \
1646 fold -s -w 53 | sed -e 's/^/ /')
1648 Advanced options (experts only):
1649 --source-path=PATH path of source code [$source_path]
1650 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1651 --cc=CC use C compiler CC [$cc]
1652 --iasl=IASL use ACPI compiler IASL [$iasl]
1653 --host-cc=CC use C compiler CC [$host_cc] for code run at
1654 build time
1655 --cxx=CXX use C++ compiler CXX [$cxx]
1656 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1657 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1658 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1659 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1660 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1661 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
1662 --make=MAKE use specified make [$make]
1663 --install=INSTALL use specified install [$install]
1664 --python=PYTHON use specified python [$python]
1665 --smbd=SMBD use specified smbd [$smbd]
1666 --with-git=GIT use specified git [$git]
1667 --static enable static build [$static]
1668 --mandir=PATH install man pages in PATH
1669 --datadir=PATH install firmware in PATH$confsuffix
1670 --docdir=PATH install documentation in PATH$confsuffix
1671 --bindir=PATH install binaries in PATH
1672 --libdir=PATH install libraries in PATH
1673 --libexecdir=PATH install helper binaries in PATH
1674 --sysconfdir=PATH install config in PATH$confsuffix
1675 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1676 --firmwarepath=PATH search PATH for firmware files
1677 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1678 --with-pkgversion=VERS use specified string as sub-version of the package
1679 --enable-debug enable common debug build options
1680 --enable-sanitizers enable default sanitizers
1681 --disable-strip disable stripping binaries
1682 --disable-werror disable compilation abort on warning
1683 --disable-stack-protector disable compiler-provided stack protection
1684 --audio-drv-list=LIST set audio drivers list:
1685 Available drivers: $audio_possible_drivers
1686 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1687 --block-drv-rw-whitelist=L
1688 set block driver read-write whitelist
1689 (affects only QEMU, not qemu-img)
1690 --block-drv-ro-whitelist=L
1691 set block driver read-only whitelist
1692 (affects only QEMU, not qemu-img)
1693 --enable-trace-backends=B Set trace backend
1694 Available backends: $trace_backend_list
1695 --with-trace-file=NAME Full PATH,NAME of file to store traces
1696 Default:trace-<pid>
1697 --disable-slirp disable SLIRP userspace network connectivity
1698 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1699 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1700 --oss-lib path to OSS library
1701 --cpu=CPU Build for host CPU [$cpu]
1702 --with-coroutine=BACKEND coroutine backend. Supported options:
1703 ucontext, sigaltstack, windows
1704 --enable-gcov enable test coverage analysis with gcov
1705 --gcov=GCOV use specified gcov [$gcov_tool]
1706 --disable-blobs disable installing provided firmware blobs
1707 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1708 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1709 --tls-priority default TLS protocol/cipher priority string
1710 --enable-gprof QEMU profiling with gprof
1711 --enable-profiler profiler support
1712 --enable-xen-pv-domain-build
1713 xen pv domain builder
1714 --enable-debug-stack-usage
1715 track the maximum stack usage of stacks created by qemu_alloc_stack
1717 Optional features, enabled with --enable-FEATURE and
1718 disabled with --disable-FEATURE, default is enabled if available:
1720 system all system emulation targets
1721 user supported user emulation targets
1722 linux-user all linux usermode emulation targets
1723 bsd-user all BSD usermode emulation targets
1724 docs build documentation
1725 guest-agent build the QEMU Guest Agent
1726 guest-agent-msi build guest agent Windows MSI installation package
1727 pie Position Independent Executables
1728 modules modules support
1729 debug-tcg TCG debugging (default is disabled)
1730 debug-info debugging information
1731 sparse sparse checker
1733 gnutls GNUTLS cryptography support
1734 nettle nettle cryptography support
1735 gcrypt libgcrypt cryptography support
1736 sdl SDL UI
1737 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1738 gtk gtk UI
1739 vte vte support for the gtk UI
1740 curses curses UI
1741 vnc VNC UI support
1742 vnc-sasl SASL encryption for VNC server
1743 vnc-jpeg JPEG lossy compression for VNC server
1744 vnc-png PNG compression for VNC server
1745 cocoa Cocoa UI (Mac OS X only)
1746 virtfs VirtFS
1747 mpath Multipath persistent reservation passthrough
1748 xen xen backend driver support
1749 xen-pci-passthrough PCI passthrough support for Xen
1750 brlapi BrlAPI (Braile)
1751 curl curl connectivity
1752 membarrier membarrier system call (for Linux 4.14+ or Windows)
1753 fdt fdt device tree
1754 bluez bluez stack connectivity
1755 kvm KVM acceleration support
1756 hax HAX acceleration support
1757 hvf Hypervisor.framework acceleration support
1758 whpx Windows Hypervisor Platform acceleration support
1759 rdma Enable RDMA-based migration
1760 pvrdma Enable PVRDMA support
1761 vde support for vde network
1762 netmap support for netmap network
1763 linux-aio Linux AIO support
1764 cap-ng libcap-ng support
1765 attr attr and xattr support
1766 vhost-net vhost-net acceleration support
1767 vhost-crypto vhost-crypto acceleration support
1768 spice spice
1769 rbd rados block device (rbd)
1770 libiscsi iscsi support
1771 libnfs nfs support
1772 smartcard smartcard support (libcacard)
1773 libusb libusb (for usb passthrough)
1774 live-block-migration Block migration in the main migration stream
1775 usb-redir usb network redirection support
1776 lzo support of lzo compression library
1777 snappy support of snappy compression library
1778 bzip2 support of bzip2 compression library
1779 (for reading bzip2-compressed dmg images)
1780 lzfse support of lzfse compression library
1781 (for reading lzfse-compressed dmg images)
1782 seccomp seccomp support
1783 coroutine-pool coroutine freelist (better performance)
1784 glusterfs GlusterFS backend
1785 tpm TPM support
1786 libssh2 ssh block device support
1787 numa libnuma support
1788 libxml2 for Parallels image format
1789 tcmalloc tcmalloc support
1790 jemalloc jemalloc support
1791 avx2 AVX2 optimization support
1792 replication replication support
1793 vhost-vsock virtio sockets device support
1794 opengl opengl support
1795 virglrenderer virgl rendering support
1796 xfsctl xfsctl support
1797 qom-cast-debug cast debugging support
1798 tools build qemu-io, qemu-nbd and qemu-image tools
1799 vxhs Veritas HyperScale vDisk backend support
1800 bochs bochs image format support
1801 cloop cloop image format support
1802 dmg dmg image format support
1803 qcow1 qcow v1 image format support
1804 vdi vdi image format support
1805 vvfat vvfat image format support
1806 qed qed image format support
1807 parallels parallels image format support
1808 sheepdog sheepdog block driver support
1809 crypto-afalg Linux AF_ALG crypto backend driver
1810 vhost-user vhost-user support
1811 capstone capstone disassembler support
1812 debug-mutex mutex debugging support
1813 libpmem libpmem support
1815 NOTE: The object files are built at the place where configure is launched
1817 exit 0
1820 if ! has $python; then
1821 error_exit "Python not found. Use --python=/path/to/python"
1824 # Note that if the Python conditional here evaluates True we will exit
1825 # with status 1 which is a shell 'false' value.
1826 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
1827 error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1828 "Use --python=/path/to/python to specify a supported Python."
1831 # Suppress writing compiled files
1832 python="$python -B"
1834 # Check that the C compiler works. Doing this here before testing
1835 # the host CPU ensures that we had a valid CC to autodetect the
1836 # $cpu var (and we should bail right here if that's not the case).
1837 # It also allows the help message to be printed without a CC.
1838 write_c_skeleton;
1839 if compile_object ; then
1840 : C compiler works ok
1841 else
1842 error_exit "\"$cc\" either does not exist or does not work"
1844 if ! compile_prog ; then
1845 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1848 # Now we have handled --enable-tcg-interpreter and know we're not just
1849 # printing the help message, bail out if the host CPU isn't supported.
1850 if test "$ARCH" = "unknown"; then
1851 if test "$tcg_interpreter" = "yes" ; then
1852 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1853 else
1854 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1858 # Consult white-list to determine whether to enable werror
1859 # by default. Only enable by default for git builds
1860 if test -z "$werror" ; then
1861 if test -d "$source_path/.git" -a \
1862 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1863 werror="yes"
1864 else
1865 werror="no"
1869 if test "$bogus_os" = "yes"; then
1870 # Now that we know that we're not printing the help and that
1871 # the compiler works (so the results of the check_defines we used
1872 # to identify the OS are reliable), if we didn't recognize the
1873 # host OS we should stop now.
1874 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1877 # Check whether the compiler matches our minimum requirements:
1878 cat > $TMPC << EOF
1879 #if defined(__clang_major__) && defined(__clang_minor__)
1880 # ifdef __apple_build_version__
1881 # if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1882 # error You need at least XCode Clang v5.1 to compile QEMU
1883 # endif
1884 # else
1885 # if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1886 # error You need at least Clang v3.4 to compile QEMU
1887 # endif
1888 # endif
1889 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1890 # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1891 # error You need at least GCC v4.8 to compile QEMU
1892 # endif
1893 #else
1894 # error You either need GCC or Clang to compiler QEMU
1895 #endif
1896 int main (void) { return 0; }
1898 if ! compile_prog "" "" ; then
1899 error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
1902 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1903 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1904 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1905 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1906 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1907 gcc_flags="-Wno-string-plus-int $gcc_flags"
1908 gcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
1909 # Note that we do not add -Werror to gcc_flags here, because that would
1910 # enable it for all configure tests. If a configure test failed due
1911 # to -Werror this would just silently disable some features,
1912 # so it's too error prone.
1914 cc_has_warning_flag() {
1915 write_c_skeleton;
1917 # Use the positive sense of the flag when testing for -Wno-wombat
1918 # support (gcc will happily accept the -Wno- form of unknown
1919 # warning options).
1920 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1921 compile_prog "-Werror $optflag" ""
1924 for flag in $gcc_flags; do
1925 if cc_has_warning_flag $flag ; then
1926 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1928 done
1930 if test "$mingw32" = "yes"; then
1931 stack_protector="no"
1933 if test "$stack_protector" != "no"; then
1934 cat > $TMPC << EOF
1935 int main(int argc, char *argv[])
1937 char arr[64], *p = arr, *c = argv[0];
1938 while (*c) {
1939 *p++ = *c++;
1941 return 0;
1944 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1945 sp_on=0
1946 for flag in $gcc_flags; do
1947 # We need to check both a compile and a link, since some compiler
1948 # setups fail only on a .c->.o compile and some only at link time
1949 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1950 compile_prog "-Werror $flag" ""; then
1951 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1952 sp_on=1
1953 break
1955 done
1956 if test "$stack_protector" = yes; then
1957 if test $sp_on = 0; then
1958 error_exit "Stack protector not supported"
1963 # Disable -Wmissing-braces on older compilers that warn even for
1964 # the "universal" C zero initializer {0}.
1965 cat > $TMPC << EOF
1966 struct {
1967 int a[2];
1968 } x = {0};
1970 if compile_object "-Werror" "" ; then
1972 else
1973 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1976 # Static linking is not possible with modules or PIE
1977 if test "$static" = "yes" ; then
1978 if test "$modules" = "yes" ; then
1979 error_exit "static and modules are mutually incompatible"
1981 if test "$pie" = "yes" ; then
1982 error_exit "static and pie are mutually incompatible"
1983 else
1984 pie="no"
1988 # Unconditional check for compiler __thread support
1989 cat > $TMPC << EOF
1990 static __thread int tls_var;
1991 int main(void) { return tls_var; }
1994 if ! compile_prog "-Werror" "" ; then
1995 error_exit "Your compiler does not support the __thread specifier for " \
1996 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1999 if test "$pie" = ""; then
2000 case "$cpu-$targetos" in
2001 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
2004 pie="no"
2006 esac
2009 if test "$pie" != "no" ; then
2010 cat > $TMPC << EOF
2012 #ifdef __linux__
2013 # define THREAD __thread
2014 #else
2015 # define THREAD
2016 #endif
2018 static THREAD int tls_var;
2020 int main(void) { return tls_var; }
2023 if compile_prog "-fPIE -DPIE" "-pie"; then
2024 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
2025 LDFLAGS="-pie $LDFLAGS"
2026 pie="yes"
2027 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2028 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
2030 else
2031 if test "$pie" = "yes"; then
2032 error_exit "PIE not available due to missing toolchain support"
2033 else
2034 echo "Disabling PIE due to missing toolchain support"
2035 pie="no"
2039 if compile_prog "-Werror -fno-pie" "-nopie"; then
2040 CFLAGS_NOPIE="-fno-pie"
2041 LDFLAGS_NOPIE="-nopie"
2045 ##########################################
2046 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
2047 # use i686 as default anyway, but for those that don't, an explicit
2048 # specification is necessary
2050 if test "$cpu" = "i386"; then
2051 cat > $TMPC << EOF
2052 static int sfaa(int *ptr)
2054 return __sync_fetch_and_and(ptr, 0);
2057 int main(void)
2059 int val = 42;
2060 val = __sync_val_compare_and_swap(&val, 0, 1);
2061 sfaa(&val);
2062 return val;
2065 if ! compile_prog "" "" ; then
2066 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2070 #########################################
2071 # Solaris specific configure tool chain decisions
2073 if test "$solaris" = "yes" ; then
2074 if has $install; then
2076 else
2077 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
2078 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
2079 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2081 if test "$(path_of $install)" = "/usr/sbin/install" ; then
2082 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
2083 "try ginstall from the GNU fileutils available from www.blastwave.org" \
2084 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2086 if has ar; then
2088 else
2089 if test -f /usr/ccs/bin/ar ; then
2090 error_exit "No path includes ar" \
2091 "Add /usr/ccs/bin to your path and rerun configure"
2093 error_exit "No path includes ar"
2097 if test -z "${target_list+xxx}" ; then
2098 for target in $default_target_list; do
2099 supported_target $target 2>/dev/null && \
2100 target_list="$target_list $target"
2101 done
2102 target_list="${target_list# }"
2103 else
2104 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2105 for target in $target_list; do
2106 # Check that we recognised the target name; this allows a more
2107 # friendly error message than if we let it fall through.
2108 case " $default_target_list " in
2109 *" $target "*)
2112 error_exit "Unknown target name '$target'"
2114 esac
2115 supported_target $target || exit 1
2116 done
2119 # see if system emulation was really requested
2120 case " $target_list " in
2121 *"-softmmu "*) softmmu=yes
2123 *) softmmu=no
2125 esac
2127 feature_not_found() {
2128 feature=$1
2129 remedy=$2
2131 error_exit "User requested feature $feature" \
2132 "configure was not able to find it." \
2133 "$remedy"
2136 # ---
2137 # big/little endian test
2138 cat > $TMPC << EOF
2139 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
2140 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2141 extern int foo(short *, short *);
2142 int main(int argc, char *argv[]) {
2143 return foo(big_endian, little_endian);
2147 if compile_object ; then
2148 if strings -a $TMPO | grep -q BiGeNdIaN ; then
2149 bigendian="yes"
2150 elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
2151 bigendian="no"
2152 else
2153 echo big/little test failed
2155 else
2156 echo big/little test failed
2159 ##########################################
2160 # cocoa implies not SDL or GTK
2161 # (the cocoa UI code currently assumes it is always the active UI
2162 # and doesn't interact well with other UI frontend code)
2163 if test "$cocoa" = "yes"; then
2164 if test "$sdl" = "yes"; then
2165 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2167 if test "$gtk" = "yes"; then
2168 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2170 gtk=no
2171 sdl=no
2174 # Some versions of Mac OS X incorrectly define SIZE_MAX
2175 cat > $TMPC << EOF
2176 #include <stdint.h>
2177 #include <stdio.h>
2178 int main(int argc, char *argv[]) {
2179 return printf("%zu", SIZE_MAX);
2182 have_broken_size_max=no
2183 if ! compile_object -Werror ; then
2184 have_broken_size_max=yes
2187 ##########################################
2188 # L2TPV3 probe
2190 cat > $TMPC <<EOF
2191 #include <sys/socket.h>
2192 #include <linux/ip.h>
2193 int main(void) { return sizeof(struct mmsghdr); }
2195 if compile_prog "" "" ; then
2196 l2tpv3=yes
2197 else
2198 l2tpv3=no
2201 ##########################################
2202 # MinGW / Mingw-w64 localtime_r/gmtime_r check
2204 if test "$mingw32" = "yes"; then
2205 # Some versions of MinGW / Mingw-w64 lack localtime_r
2206 # and gmtime_r entirely.
2208 # Some versions of Mingw-w64 define a macro for
2209 # localtime_r/gmtime_r.
2211 # Some versions of Mingw-w64 will define functions
2212 # for localtime_r/gmtime_r, but only if you have
2213 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
2214 # though, unistd.h and pthread.h both define
2215 # that for you.
2217 # So this #undef localtime_r and #include <unistd.h>
2218 # are not in fact redundant.
2219 cat > $TMPC << EOF
2220 #include <unistd.h>
2221 #include <time.h>
2222 #undef localtime_r
2223 int main(void) { localtime_r(NULL, NULL); return 0; }
2225 if compile_prog "" "" ; then
2226 localtime_r="yes"
2227 else
2228 localtime_r="no"
2232 ##########################################
2233 # pkg-config probe
2235 if ! has "$pkg_config_exe"; then
2236 error_exit "pkg-config binary '$pkg_config_exe' not found"
2239 ##########################################
2240 # NPTL probe
2242 if test "$linux_user" = "yes"; then
2243 cat > $TMPC <<EOF
2244 #include <sched.h>
2245 #include <linux/futex.h>
2246 int main(void) {
2247 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2248 #error bork
2249 #endif
2250 return 0;
2253 if ! compile_object ; then
2254 feature_not_found "nptl" "Install glibc and linux kernel headers."
2258 ##########################################
2259 # lzo check
2261 if test "$lzo" != "no" ; then
2262 cat > $TMPC << EOF
2263 #include <lzo/lzo1x.h>
2264 int main(void) { lzo_version(); return 0; }
2266 if compile_prog "" "-llzo2" ; then
2267 libs_softmmu="$libs_softmmu -llzo2"
2268 lzo="yes"
2269 else
2270 if test "$lzo" = "yes"; then
2271 feature_not_found "liblzo2" "Install liblzo2 devel"
2273 lzo="no"
2277 ##########################################
2278 # snappy check
2280 if test "$snappy" != "no" ; then
2281 cat > $TMPC << EOF
2282 #include <snappy-c.h>
2283 int main(void) { snappy_max_compressed_length(4096); return 0; }
2285 if compile_prog "" "-lsnappy" ; then
2286 libs_softmmu="$libs_softmmu -lsnappy"
2287 snappy="yes"
2288 else
2289 if test "$snappy" = "yes"; then
2290 feature_not_found "libsnappy" "Install libsnappy devel"
2292 snappy="no"
2296 ##########################################
2297 # bzip2 check
2299 if test "$bzip2" != "no" ; then
2300 cat > $TMPC << EOF
2301 #include <bzlib.h>
2302 int main(void) { BZ2_bzlibVersion(); return 0; }
2304 if compile_prog "" "-lbz2" ; then
2305 bzip2="yes"
2306 else
2307 if test "$bzip2" = "yes"; then
2308 feature_not_found "libbzip2" "Install libbzip2 devel"
2310 bzip2="no"
2314 ##########################################
2315 # lzfse check
2317 if test "$lzfse" != "no" ; then
2318 cat > $TMPC << EOF
2319 #include <lzfse.h>
2320 int main(void) { lzfse_decode_scratch_size(); return 0; }
2322 if compile_prog "" "-llzfse" ; then
2323 lzfse="yes"
2324 else
2325 if test "$lzfse" = "yes"; then
2326 feature_not_found "lzfse" "Install lzfse devel"
2328 lzfse="no"
2332 ##########################################
2333 # libseccomp check
2335 libseccomp_minver="2.2.0"
2336 if test "$seccomp" != "no" ; then
2337 case "$cpu" in
2338 i386|x86_64|mips)
2340 arm|aarch64)
2341 libseccomp_minver="2.2.3"
2343 ppc|ppc64|s390x)
2344 libseccomp_minver="2.3.0"
2347 libseccomp_minver=""
2349 esac
2351 if test "$libseccomp_minver" != "" &&
2352 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2353 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2354 seccomp_libs="$($pkg_config --libs libseccomp)"
2355 seccomp="yes"
2356 else
2357 if test "$seccomp" = "yes" ; then
2358 if test "$libseccomp_minver" != "" ; then
2359 feature_not_found "libseccomp" \
2360 "Install libseccomp devel >= $libseccomp_minver"
2361 else
2362 feature_not_found "libseccomp" \
2363 "libseccomp is not supported for host cpu $cpu"
2366 seccomp="no"
2369 ##########################################
2370 # xen probe
2372 if test "$xen" != "no" ; then
2373 # Check whether Xen library path is specified via --extra-ldflags to avoid
2374 # overriding this setting with pkg-config output. If not, try pkg-config
2375 # to obtain all needed flags.
2377 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2378 $pkg_config --exists xencontrol ; then
2379 xen_ctrl_version="$(printf '%d%02d%02d' \
2380 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2381 xen=yes
2382 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2383 xen_pc="$xen_pc xenevtchn xendevicemodel"
2384 if $pkg_config --exists xentoolcore; then
2385 xen_pc="$xen_pc xentoolcore"
2387 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2388 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2389 LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2390 else
2392 xen_libs="-lxenstore -lxenctrl -lxenguest"
2393 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2395 # First we test whether Xen headers and libraries are available.
2396 # If no, we are done and there is no Xen support.
2397 # If yes, more tests are run to detect the Xen version.
2399 # Xen (any)
2400 cat > $TMPC <<EOF
2401 #include <xenctrl.h>
2402 int main(void) {
2403 return 0;
2406 if ! compile_prog "" "$xen_libs" ; then
2407 # Xen not found
2408 if test "$xen" = "yes" ; then
2409 feature_not_found "xen" "Install xen devel"
2411 xen=no
2413 # Xen unstable
2414 elif
2415 cat > $TMPC <<EOF &&
2416 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2417 #define __XEN_TOOLS__
2418 #include <xendevicemodel.h>
2419 #include <xenforeignmemory.h>
2420 int main(void) {
2421 xendevicemodel_handle *xd;
2422 xenforeignmemory_handle *xfmem;
2424 xd = xendevicemodel_open(0, 0);
2425 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2427 xfmem = xenforeignmemory_open(0, 0);
2428 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2430 return 0;
2433 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2434 then
2435 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2436 xen_ctrl_version=41100
2437 xen=yes
2438 elif
2439 cat > $TMPC <<EOF &&
2440 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2441 #include <xenforeignmemory.h>
2442 #include <xentoolcore.h>
2443 int main(void) {
2444 xenforeignmemory_handle *xfmem;
2446 xfmem = xenforeignmemory_open(0, 0);
2447 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2448 xentoolcore_restrict_all(0);
2450 return 0;
2453 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2454 then
2455 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2456 xen_ctrl_version=41000
2457 xen=yes
2458 elif
2459 cat > $TMPC <<EOF &&
2460 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2461 #define __XEN_TOOLS__
2462 #include <xendevicemodel.h>
2463 int main(void) {
2464 xendevicemodel_handle *xd;
2466 xd = xendevicemodel_open(0, 0);
2467 xendevicemodel_close(xd);
2469 return 0;
2472 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2473 then
2474 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2475 xen_ctrl_version=40900
2476 xen=yes
2477 elif
2478 cat > $TMPC <<EOF &&
2480 * If we have stable libs the we don't want the libxc compat
2481 * layers, regardless of what CFLAGS we may have been given.
2483 * Also, check if xengnttab_grant_copy_segment_t is defined and
2484 * grant copy operation is implemented.
2486 #undef XC_WANT_COMPAT_EVTCHN_API
2487 #undef XC_WANT_COMPAT_GNTTAB_API
2488 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2489 #include <xenctrl.h>
2490 #include <xenstore.h>
2491 #include <xenevtchn.h>
2492 #include <xengnttab.h>
2493 #include <xenforeignmemory.h>
2494 #include <stdint.h>
2495 #include <xen/hvm/hvm_info_table.h>
2496 #if !defined(HVM_MAX_VCPUS)
2497 # error HVM_MAX_VCPUS not defined
2498 #endif
2499 int main(void) {
2500 xc_interface *xc = NULL;
2501 xenforeignmemory_handle *xfmem;
2502 xenevtchn_handle *xe;
2503 xengnttab_handle *xg;
2504 xen_domain_handle_t handle;
2505 xengnttab_grant_copy_segment_t* seg = NULL;
2507 xs_daemon_open();
2509 xc = xc_interface_open(0, 0, 0);
2510 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2511 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2512 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2513 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2514 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2516 xfmem = xenforeignmemory_open(0, 0);
2517 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2519 xe = xenevtchn_open(0, 0);
2520 xenevtchn_fd(xe);
2522 xg = xengnttab_open(0, 0);
2523 xengnttab_grant_copy(xg, 0, seg);
2525 return 0;
2528 compile_prog "" "$xen_libs $xen_stable_libs"
2529 then
2530 xen_ctrl_version=40800
2531 xen=yes
2532 elif
2533 cat > $TMPC <<EOF &&
2535 * If we have stable libs the we don't want the libxc compat
2536 * layers, regardless of what CFLAGS we may have been given.
2538 #undef XC_WANT_COMPAT_EVTCHN_API
2539 #undef XC_WANT_COMPAT_GNTTAB_API
2540 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2541 #include <xenctrl.h>
2542 #include <xenstore.h>
2543 #include <xenevtchn.h>
2544 #include <xengnttab.h>
2545 #include <xenforeignmemory.h>
2546 #include <stdint.h>
2547 #include <xen/hvm/hvm_info_table.h>
2548 #if !defined(HVM_MAX_VCPUS)
2549 # error HVM_MAX_VCPUS not defined
2550 #endif
2551 int main(void) {
2552 xc_interface *xc = NULL;
2553 xenforeignmemory_handle *xfmem;
2554 xenevtchn_handle *xe;
2555 xengnttab_handle *xg;
2556 xen_domain_handle_t handle;
2558 xs_daemon_open();
2560 xc = xc_interface_open(0, 0, 0);
2561 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2562 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2563 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2564 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2565 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2567 xfmem = xenforeignmemory_open(0, 0);
2568 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2570 xe = xenevtchn_open(0, 0);
2571 xenevtchn_fd(xe);
2573 xg = xengnttab_open(0, 0);
2574 xengnttab_map_grant_ref(xg, 0, 0, 0);
2576 return 0;
2579 compile_prog "" "$xen_libs $xen_stable_libs"
2580 then
2581 xen_ctrl_version=40701
2582 xen=yes
2583 elif
2584 cat > $TMPC <<EOF &&
2585 #include <xenctrl.h>
2586 #include <stdint.h>
2587 int main(void) {
2588 xc_interface *xc = NULL;
2589 xen_domain_handle_t handle;
2590 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2591 return 0;
2594 compile_prog "" "$xen_libs"
2595 then
2596 xen_ctrl_version=40700
2597 xen=yes
2599 # Xen 4.6
2600 elif
2601 cat > $TMPC <<EOF &&
2602 #include <xenctrl.h>
2603 #include <xenstore.h>
2604 #include <stdint.h>
2605 #include <xen/hvm/hvm_info_table.h>
2606 #if !defined(HVM_MAX_VCPUS)
2607 # error HVM_MAX_VCPUS not defined
2608 #endif
2609 int main(void) {
2610 xc_interface *xc;
2611 xs_daemon_open();
2612 xc = xc_interface_open(0, 0, 0);
2613 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2614 xc_gnttab_open(NULL, 0);
2615 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2616 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2617 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2618 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2619 return 0;
2622 compile_prog "" "$xen_libs"
2623 then
2624 xen_ctrl_version=40600
2625 xen=yes
2627 # Xen 4.5
2628 elif
2629 cat > $TMPC <<EOF &&
2630 #include <xenctrl.h>
2631 #include <xenstore.h>
2632 #include <stdint.h>
2633 #include <xen/hvm/hvm_info_table.h>
2634 #if !defined(HVM_MAX_VCPUS)
2635 # error HVM_MAX_VCPUS not defined
2636 #endif
2637 int main(void) {
2638 xc_interface *xc;
2639 xs_daemon_open();
2640 xc = xc_interface_open(0, 0, 0);
2641 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2642 xc_gnttab_open(NULL, 0);
2643 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2644 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2645 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2646 return 0;
2649 compile_prog "" "$xen_libs"
2650 then
2651 xen_ctrl_version=40500
2652 xen=yes
2654 elif
2655 cat > $TMPC <<EOF &&
2656 #include <xenctrl.h>
2657 #include <xenstore.h>
2658 #include <stdint.h>
2659 #include <xen/hvm/hvm_info_table.h>
2660 #if !defined(HVM_MAX_VCPUS)
2661 # error HVM_MAX_VCPUS not defined
2662 #endif
2663 int main(void) {
2664 xc_interface *xc;
2665 xs_daemon_open();
2666 xc = xc_interface_open(0, 0, 0);
2667 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2668 xc_gnttab_open(NULL, 0);
2669 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2670 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2671 return 0;
2674 compile_prog "" "$xen_libs"
2675 then
2676 xen_ctrl_version=40200
2677 xen=yes
2679 else
2680 if test "$xen" = "yes" ; then
2681 feature_not_found "xen (unsupported version)" \
2682 "Install a supported xen (xen 4.2 or newer)"
2684 xen=no
2687 if test "$xen" = yes; then
2688 if test $xen_ctrl_version -ge 40701 ; then
2689 libs_softmmu="$xen_stable_libs $libs_softmmu"
2691 libs_softmmu="$xen_libs $libs_softmmu"
2696 if test "$xen_pci_passthrough" != "no"; then
2697 if test "$xen" = "yes" && test "$linux" = "yes"; then
2698 xen_pci_passthrough=yes
2699 else
2700 if test "$xen_pci_passthrough" = "yes"; then
2701 error_exit "User requested feature Xen PCI Passthrough" \
2702 " but this feature requires /sys from Linux"
2704 xen_pci_passthrough=no
2708 if test "$xen_pv_domain_build" = "yes" &&
2709 test "$xen" != "yes"; then
2710 error_exit "User requested Xen PV domain builder support" \
2711 "which requires Xen support."
2714 ##########################################
2715 # Windows Hypervisor Platform accelerator (WHPX) check
2716 if test "$whpx" != "no" ; then
2717 if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2718 whpx="yes"
2719 else
2720 if test "$whpx" = "yes"; then
2721 feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2723 whpx="no"
2727 ##########################################
2728 # Sparse probe
2729 if test "$sparse" != "no" ; then
2730 if has cgcc; then
2731 sparse=yes
2732 else
2733 if test "$sparse" = "yes" ; then
2734 feature_not_found "sparse" "Install sparse binary"
2736 sparse=no
2740 ##########################################
2741 # X11 probe
2742 if $pkg_config --exists "x11"; then
2743 have_x11=yes
2744 x11_cflags=$($pkg_config --cflags x11)
2745 x11_libs=$($pkg_config --libs x11)
2748 ##########################################
2749 # GTK probe
2751 if test "$gtk" != "no"; then
2752 gtkpackage="gtk+-3.0"
2753 gtkx11package="gtk+-x11-3.0"
2754 gtkversion="3.14.0"
2755 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2756 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2757 gtk_libs=$($pkg_config --libs $gtkpackage)
2758 gtk_version=$($pkg_config --modversion $gtkpackage)
2759 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2760 need_x11=yes
2761 gtk_cflags="$gtk_cflags $x11_cflags"
2762 gtk_libs="$gtk_libs $x11_libs"
2764 gtk="yes"
2765 elif test "$gtk" = "yes"; then
2766 feature_not_found "gtk" "Install gtk3-devel"
2767 else
2768 gtk="no"
2773 ##########################################
2774 # GNUTLS probe
2776 if test "$gnutls" != "no"; then
2777 if $pkg_config --exists "gnutls >= 3.1.18"; then
2778 gnutls_cflags=$($pkg_config --cflags gnutls)
2779 gnutls_libs=$($pkg_config --libs gnutls)
2780 libs_softmmu="$gnutls_libs $libs_softmmu"
2781 libs_tools="$gnutls_libs $libs_tools"
2782 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2783 gnutls="yes"
2784 elif test "$gnutls" = "yes"; then
2785 feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2786 else
2787 gnutls="no"
2792 # If user didn't give a --disable/enable-gcrypt flag,
2793 # then mark as disabled if user requested nettle
2794 # explicitly
2795 if test -z "$gcrypt"
2796 then
2797 if test "$nettle" = "yes"
2798 then
2799 gcrypt="no"
2803 # If user didn't give a --disable/enable-nettle flag,
2804 # then mark as disabled if user requested gcrypt
2805 # explicitly
2806 if test -z "$nettle"
2807 then
2808 if test "$gcrypt" = "yes"
2809 then
2810 nettle="no"
2814 has_libgcrypt() {
2815 if ! has "libgcrypt-config"
2816 then
2817 return 1
2820 if test -n "$cross_prefix"
2821 then
2822 host=$(libgcrypt-config --host)
2823 if test "$host-" != $cross_prefix
2824 then
2825 return 1
2829 maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2830 min=`libgcrypt-config --version | awk -F . '{print $2}'`
2832 if test $maj != 1 || test $min -lt 5
2833 then
2834 return 1
2837 return 0
2841 if test "$nettle" != "no"; then
2842 if $pkg_config --exists "nettle >= 2.7.1"; then
2843 nettle_cflags=$($pkg_config --cflags nettle)
2844 nettle_libs=$($pkg_config --libs nettle)
2845 nettle_version=$($pkg_config --modversion nettle)
2846 libs_softmmu="$nettle_libs $libs_softmmu"
2847 libs_tools="$nettle_libs $libs_tools"
2848 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2849 nettle="yes"
2851 if test -z "$gcrypt"; then
2852 gcrypt="no"
2854 else
2855 if test "$nettle" = "yes"; then
2856 feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2857 else
2858 nettle="no"
2863 if test "$gcrypt" != "no"; then
2864 if has_libgcrypt; then
2865 gcrypt_cflags=$(libgcrypt-config --cflags)
2866 gcrypt_libs=$(libgcrypt-config --libs)
2867 # Debian has remove -lgpg-error from libgcrypt-config
2868 # as it "spreads unnecessary dependencies" which in
2869 # turn breaks static builds...
2870 if test "$static" = "yes"
2871 then
2872 gcrypt_libs="$gcrypt_libs -lgpg-error"
2874 libs_softmmu="$gcrypt_libs $libs_softmmu"
2875 libs_tools="$gcrypt_libs $libs_tools"
2876 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2877 gcrypt="yes"
2879 cat > $TMPC << EOF
2880 #include <gcrypt.h>
2881 int main(void) {
2882 gcry_mac_hd_t handle;
2883 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2884 GCRY_MAC_FLAG_SECURE, NULL);
2885 return 0;
2888 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2889 gcrypt_hmac=yes
2891 else
2892 if test "$gcrypt" = "yes"; then
2893 feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
2894 else
2895 gcrypt="no"
2901 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2902 then
2903 error_exit "Only one of gcrypt & nettle can be enabled"
2906 ##########################################
2907 # libtasn1 - only for the TLS creds/session test suite
2909 tasn1=yes
2910 tasn1_cflags=""
2911 tasn1_libs=""
2912 if $pkg_config --exists "libtasn1"; then
2913 tasn1_cflags=$($pkg_config --cflags libtasn1)
2914 tasn1_libs=$($pkg_config --libs libtasn1)
2915 else
2916 tasn1=no
2920 ##########################################
2921 # getifaddrs (for tests/test-io-channel-socket )
2923 have_ifaddrs_h=yes
2924 if ! check_include "ifaddrs.h" ; then
2925 have_ifaddrs_h=no
2928 ##########################################
2929 # VTE probe
2931 if test "$vte" != "no"; then
2932 vteminversion="0.32.0"
2933 if $pkg_config --exists "vte-2.91"; then
2934 vtepackage="vte-2.91"
2935 else
2936 vtepackage="vte-2.90"
2938 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2939 vte_cflags=$($pkg_config --cflags $vtepackage)
2940 vte_libs=$($pkg_config --libs $vtepackage)
2941 vteversion=$($pkg_config --modversion $vtepackage)
2942 vte="yes"
2943 elif test "$vte" = "yes"; then
2944 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2945 else
2946 vte="no"
2950 ##########################################
2951 # SDL probe
2953 # Look for sdl configuration program (pkg-config or sdl-config). Try
2954 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2956 sdl_probe ()
2958 sdl_too_old=no
2959 if test "$sdlabi" = ""; then
2960 if $pkg_config --exists "sdl2"; then
2961 sdlabi=2.0
2962 elif $pkg_config --exists "sdl"; then
2963 sdlabi=1.2
2964 else
2965 sdlabi=2.0
2969 if test $sdlabi = "2.0"; then
2970 sdl_config=$sdl2_config
2971 sdlname=sdl2
2972 sdlconfigname=sdl2_config
2973 elif test $sdlabi = "1.2"; then
2974 sdlname=sdl
2975 sdlconfigname=sdl_config
2976 else
2977 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2980 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2981 sdl_config=$sdlconfigname
2984 if $pkg_config $sdlname --exists; then
2985 sdlconfig="$pkg_config $sdlname"
2986 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2987 elif has ${sdl_config}; then
2988 sdlconfig="$sdl_config"
2989 sdlversion=$($sdlconfig --version)
2990 else
2991 if test "$sdl" = "yes" ; then
2992 feature_not_found "sdl" "Install SDL2-devel"
2994 sdl=no
2995 # no need to do the rest
2996 return
2998 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2999 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
3002 cat > $TMPC << EOF
3003 #include <SDL.h>
3004 #undef main /* We don't want SDL to override our main() */
3005 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
3007 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
3008 sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
3009 if test "$static" = "yes" ; then
3010 if $pkg_config $sdlname --exists; then
3011 sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
3012 else
3013 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
3015 else
3016 sdl_libs=$($sdlconfig --libs 2>/dev/null)
3018 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
3019 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
3020 sdl_too_old=yes
3021 else
3022 sdl=yes
3025 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
3026 if test "$sdl" = "yes" -a "$static" = "yes" ; then
3027 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
3028 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
3029 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
3031 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
3033 else
3034 sdl=no
3036 fi # static link
3037 else # sdl not found
3038 if test "$sdl" = "yes" ; then
3039 feature_not_found "sdl" "Install SDL devel"
3041 sdl=no
3042 fi # sdl compile test
3045 if test "$sdl" != "no" ; then
3046 sdl_probe
3049 if test "$sdl" = "yes" ; then
3050 cat > $TMPC <<EOF
3051 #include <SDL.h>
3052 #if defined(SDL_VIDEO_DRIVER_X11)
3053 #include <X11/XKBlib.h>
3054 #else
3055 #error No x11 support
3056 #endif
3057 int main(void) { return 0; }
3059 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
3060 need_x11=yes
3061 sdl_cflags="$sdl_cflags $x11_cflags"
3062 sdl_libs="$sdl_libs $x11_libs"
3066 ##########################################
3067 # RDMA needs OpenFabrics libraries
3068 if test "$rdma" != "no" ; then
3069 cat > $TMPC <<EOF
3070 #include <rdma/rdma_cma.h>
3071 int main(void) { return 0; }
3073 rdma_libs="-lrdmacm -libverbs -libumad"
3074 if compile_prog "" "$rdma_libs" ; then
3075 rdma="yes"
3076 libs_softmmu="$libs_softmmu $rdma_libs"
3077 else
3078 if test "$rdma" = "yes" ; then
3079 error_exit \
3080 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
3081 " Your options:" \
3082 " (1) Fast: Install infiniband packages (devel) from your distro." \
3083 " (2) Cleanest: Install libraries from www.openfabrics.org" \
3084 " (3) Also: Install softiwarp if you don't have RDMA hardware"
3086 rdma="no"
3090 ##########################################
3091 # PVRDMA detection
3093 cat > $TMPC <<EOF &&
3094 #include <sys/mman.h>
3097 main(void)
3099 char buf = 0;
3100 void *addr = &buf;
3101 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
3103 return 0;
3107 if test "$rdma" = "yes" ; then
3108 case "$pvrdma" in
3110 if compile_prog "" ""; then
3111 pvrdma="yes"
3112 else
3113 pvrdma="no"
3116 "yes")
3117 if ! compile_prog "" ""; then
3118 error_exit "PVRDMA is not supported since mremap is not implemented"
3120 pvrdma="yes"
3122 "no")
3123 pvrdma="no"
3125 esac
3126 else
3127 if test "$pvrdma" = "yes" ; then
3128 error_exit "PVRDMA requires rdma suppport"
3130 pvrdma="no"
3133 ##########################################
3134 # VNC SASL detection
3135 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
3136 cat > $TMPC <<EOF
3137 #include <sasl/sasl.h>
3138 #include <stdio.h>
3139 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
3141 # Assuming Cyrus-SASL installed in /usr prefix
3142 vnc_sasl_cflags=""
3143 vnc_sasl_libs="-lsasl2"
3144 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3145 vnc_sasl=yes
3146 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3147 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
3148 else
3149 if test "$vnc_sasl" = "yes" ; then
3150 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3152 vnc_sasl=no
3156 ##########################################
3157 # VNC JPEG detection
3158 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
3159 if $pkg_config --exists libjpeg; then
3160 vnc_jpeg=yes
3161 libs_softmmu="$libs_softmmu $($pkg_config --libs libjpeg)"
3162 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libjpeg)"
3163 else
3164 cat > $TMPC <<EOF
3165 #include <stdio.h>
3166 #include <jpeglib.h>
3167 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
3169 vnc_jpeg_cflags=""
3170 vnc_jpeg_libs="-ljpeg"
3171 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
3172 vnc_jpeg=yes
3173 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3174 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
3175 else
3176 if test "$vnc_jpeg" = "yes" ; then
3177 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
3179 vnc_jpeg=no
3184 ##########################################
3185 # VNC PNG detection
3186 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
3187 cat > $TMPC <<EOF
3188 //#include <stdio.h>
3189 #include <png.h>
3190 #include <stddef.h>
3191 int main(void) {
3192 png_structp png_ptr;
3193 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
3194 return png_ptr != 0;
3197 if $pkg_config libpng --exists; then
3198 vnc_png_cflags=$($pkg_config libpng --cflags)
3199 vnc_png_libs=$($pkg_config libpng --libs)
3200 else
3201 vnc_png_cflags=""
3202 vnc_png_libs="-lpng"
3204 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3205 vnc_png=yes
3206 libs_softmmu="$vnc_png_libs $libs_softmmu"
3207 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3208 else
3209 if test "$vnc_png" = "yes" ; then
3210 feature_not_found "vnc-png" "Install libpng devel"
3212 vnc_png=no
3216 ##########################################
3217 # xkbcommon probe
3218 if test "$xkbcommon" != "no" ; then
3219 if $pkg_config xkbcommon --exists; then
3220 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
3221 xkbcommon_libs=$($pkg_config xkbcommon --libs)
3222 xkbcommon=yes
3223 else
3224 if test "$xkbcommon" = "yes" ; then
3225 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
3227 xkbcommon=no
3231 ##########################################
3232 # fnmatch() probe, used for ACL routines
3233 fnmatch="no"
3234 cat > $TMPC << EOF
3235 #include <fnmatch.h>
3236 int main(void)
3238 fnmatch("foo", "foo", 0);
3239 return 0;
3242 if compile_prog "" "" ; then
3243 fnmatch="yes"
3246 ##########################################
3247 # xfsctl() probe, used for file-posix.c
3248 if test "$xfs" != "no" ; then
3249 cat > $TMPC << EOF
3250 #include <stddef.h> /* NULL */
3251 #include <xfs/xfs.h>
3252 int main(void)
3254 xfsctl(NULL, 0, 0, NULL);
3255 return 0;
3258 if compile_prog "" "" ; then
3259 xfs="yes"
3260 else
3261 if test "$xfs" = "yes" ; then
3262 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3264 xfs=no
3268 ##########################################
3269 # vde libraries probe
3270 if test "$vde" != "no" ; then
3271 vde_libs="-lvdeplug"
3272 cat > $TMPC << EOF
3273 #include <stddef.h>
3274 #include <libvdeplug.h>
3275 int main(void)
3277 struct vde_open_args a = {0, 0, 0};
3278 char s[] = "";
3279 vde_open(s, s, &a);
3280 return 0;
3283 if compile_prog "" "$vde_libs" ; then
3284 vde=yes
3285 else
3286 if test "$vde" = "yes" ; then
3287 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3289 vde=no
3293 ##########################################
3294 # netmap support probe
3295 # Apart from looking for netmap headers, we make sure that the host API version
3296 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3297 # a minor/major version number. Minor new features will be marked with values up
3298 # to 15, and if something happens that requires a change to the backend we will
3299 # move above 15, submit the backend fixes and modify this two bounds.
3300 if test "$netmap" != "no" ; then
3301 cat > $TMPC << EOF
3302 #include <inttypes.h>
3303 #include <net/if.h>
3304 #include <net/netmap.h>
3305 #include <net/netmap_user.h>
3306 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3307 #error
3308 #endif
3309 int main(void) { return 0; }
3311 if compile_prog "" "" ; then
3312 netmap=yes
3313 else
3314 if test "$netmap" = "yes" ; then
3315 feature_not_found "netmap"
3317 netmap=no
3321 ##########################################
3322 # libcap-ng library probe
3323 if test "$cap_ng" != "no" ; then
3324 cap_libs="-lcap-ng"
3325 cat > $TMPC << EOF
3326 #include <cap-ng.h>
3327 int main(void)
3329 capng_capability_to_name(CAPNG_EFFECTIVE);
3330 return 0;
3333 if compile_prog "" "$cap_libs" ; then
3334 cap_ng=yes
3335 libs_tools="$cap_libs $libs_tools"
3336 else
3337 if test "$cap_ng" = "yes" ; then
3338 feature_not_found "cap_ng" "Install libcap-ng devel"
3340 cap_ng=no
3344 ##########################################
3345 # Sound support libraries probe
3347 audio_drv_probe()
3349 drv=$1
3350 hdr=$2
3351 lib=$3
3352 exp=$4
3353 cfl=$5
3354 cat > $TMPC << EOF
3355 #include <$hdr>
3356 int main(void) { $exp }
3358 if compile_prog "$cfl" "$lib" ; then
3360 else
3361 error_exit "$drv check failed" \
3362 "Make sure to have the $drv libs and headers installed."
3366 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3367 for drv in $audio_drv_list; do
3368 case $drv in
3369 alsa)
3370 audio_drv_probe $drv alsa/asoundlib.h -lasound \
3371 "return snd_pcm_close((snd_pcm_t *)0);"
3372 alsa_libs="-lasound"
3376 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3377 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3378 pulse_libs="-lpulse"
3379 audio_pt_int="yes"
3382 sdl)
3383 if test "$sdl" = "no"; then
3384 error_exit "sdl not found or disabled, can not use sdl audio driver"
3388 coreaudio)
3389 coreaudio_libs="-framework CoreAudio"
3392 dsound)
3393 dsound_libs="-lole32 -ldxguid"
3394 audio_win_int="yes"
3397 oss)
3398 oss_libs="$oss_lib"
3401 wav)
3402 # XXX: Probes for CoreAudio, DirectSound
3406 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3407 error_exit "Unknown driver '$drv' selected" \
3408 "Possible drivers are: $audio_possible_drivers"
3411 esac
3412 done
3414 ##########################################
3415 # BrlAPI probe
3417 if test "$brlapi" != "no" ; then
3418 brlapi_libs="-lbrlapi"
3419 cat > $TMPC << EOF
3420 #include <brlapi.h>
3421 #include <stddef.h>
3422 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3424 if compile_prog "" "$brlapi_libs" ; then
3425 brlapi=yes
3426 else
3427 if test "$brlapi" = "yes" ; then
3428 feature_not_found "brlapi" "Install brlapi devel"
3430 brlapi=no
3434 ##########################################
3435 # curses probe
3436 if test "$curses" != "no" ; then
3437 if test "$mingw32" = "yes" ; then
3438 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3439 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3440 else
3441 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3442 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3444 curses_found=no
3445 cat > $TMPC << EOF
3446 #include <locale.h>
3447 #include <curses.h>
3448 #include <wchar.h>
3449 int main(void) {
3450 wchar_t wch = L'w';
3451 setlocale(LC_ALL, "");
3452 resize_term(0, 0);
3453 addwstr(L"wide chars\n");
3454 addnwstr(&wch, 1);
3455 add_wch(WACS_DEGREE);
3456 return 0;
3459 IFS=:
3460 for curses_inc in $curses_inc_list; do
3461 # Make sure we get the wide character prototypes
3462 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3463 IFS=:
3464 for curses_lib in $curses_lib_list; do
3465 unset IFS
3466 if compile_prog "$curses_inc" "$curses_lib" ; then
3467 curses_found=yes
3468 break
3470 done
3471 if test "$curses_found" = yes ; then
3472 break
3474 done
3475 unset IFS
3476 if test "$curses_found" = "yes" ; then
3477 curses=yes
3478 else
3479 if test "$curses" = "yes" ; then
3480 feature_not_found "curses" "Install ncurses devel"
3482 curses=no
3486 ##########################################
3487 # curl probe
3488 if test "$curl" != "no" ; then
3489 if $pkg_config libcurl --exists; then
3490 curlconfig="$pkg_config libcurl"
3491 else
3492 curlconfig=curl-config
3494 cat > $TMPC << EOF
3495 #include <curl/curl.h>
3496 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3498 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3499 curl_libs=$($curlconfig --libs 2>/dev/null)
3500 if compile_prog "$curl_cflags" "$curl_libs" ; then
3501 curl=yes
3502 else
3503 if test "$curl" = "yes" ; then
3504 feature_not_found "curl" "Install libcurl devel"
3506 curl=no
3508 fi # test "$curl"
3510 ##########################################
3511 # bluez support probe
3512 if test "$bluez" != "no" ; then
3513 cat > $TMPC << EOF
3514 #include <bluetooth/bluetooth.h>
3515 int main(void) { return bt_error(0); }
3517 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3518 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3519 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3520 bluez=yes
3521 libs_softmmu="$bluez_libs $libs_softmmu"
3522 else
3523 if test "$bluez" = "yes" ; then
3524 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3526 bluez="no"
3530 ##########################################
3531 # glib support probe
3533 glib_req_ver=2.40
3534 glib_modules=gthread-2.0
3535 if test "$modules" = yes; then
3536 glib_modules="$glib_modules gmodule-export-2.0"
3539 # This workaround is required due to a bug in pkg-config file for glib as it
3540 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3542 if test "$static" = yes -a "$mingw32" = yes; then
3543 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3546 for i in $glib_modules; do
3547 if $pkg_config --atleast-version=$glib_req_ver $i; then
3548 glib_cflags=$($pkg_config --cflags $i)
3549 glib_libs=$($pkg_config --libs $i)
3550 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3551 LIBS="$glib_libs $LIBS"
3552 libs_qga="$glib_libs $libs_qga"
3553 else
3554 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3556 done
3558 # Sanity check that the current size_t matches the
3559 # size that glib thinks it should be. This catches
3560 # problems on multi-arch where people try to build
3561 # 32-bit QEMU while pointing at 64-bit glib headers
3562 cat > $TMPC <<EOF
3563 #include <glib.h>
3564 #include <unistd.h>
3566 #define QEMU_BUILD_BUG_ON(x) \
3567 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3569 int main(void) {
3570 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3571 return 0;
3575 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3576 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3577 "You probably need to set PKG_CONFIG_LIBDIR"\
3578 "to point to the right pkg-config files for your"\
3579 "build target"
3582 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3583 cat > $TMPC << EOF
3584 #include <glib.h>
3585 int main(void) { return 0; }
3587 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3588 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3589 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3590 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3594 #########################################
3595 # zlib check
3597 if test "$zlib" != "no" ; then
3598 if $pkg_config --exists zlib; then
3599 zlib_cflags=$($pkg_config --cflags zlib)
3600 zlib_libs=$($pkg_config --libs zlib)
3601 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3602 LIBS="$zlib_libs $LIBS"
3603 else
3604 cat > $TMPC << EOF
3605 #include <zlib.h>
3606 int main(void) { zlibVersion(); return 0; }
3608 if compile_prog "" "-lz" ; then
3609 LIBS="$LIBS -lz"
3610 else
3611 error_exit "zlib check failed" \
3612 "Make sure to have the zlib libs and headers installed."
3617 ##########################################
3618 # SHA command probe for modules
3619 if test "$modules" = yes; then
3620 shacmd_probe="sha1sum sha1 shasum"
3621 for c in $shacmd_probe; do
3622 if has $c; then
3623 shacmd="$c"
3624 break
3626 done
3627 if test "$shacmd" = ""; then
3628 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3632 ##########################################
3633 # pixman support probe
3635 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3636 pixman_cflags=
3637 pixman_libs=
3638 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3639 pixman_cflags=$($pkg_config --cflags pixman-1)
3640 pixman_libs=$($pkg_config --libs pixman-1)
3641 else
3642 error_exit "pixman >= 0.21.8 not present." \
3643 "Please install the pixman devel package."
3646 ##########################################
3647 # libmpathpersist probe
3649 if test "$mpath" != "no" ; then
3650 # probe for the new API
3651 cat > $TMPC <<EOF
3652 #include <libudev.h>
3653 #include <mpath_persist.h>
3654 unsigned mpath_mx_alloc_len = 1024;
3655 int logsink;
3656 static struct config *multipath_conf;
3657 extern struct udev *udev;
3658 extern struct config *get_multipath_config(void);
3659 extern void put_multipath_config(struct config *conf);
3660 struct udev *udev;
3661 struct config *get_multipath_config(void) { return multipath_conf; }
3662 void put_multipath_config(struct config *conf) { }
3664 int main(void) {
3665 udev = udev_new();
3666 multipath_conf = mpath_lib_init();
3667 return 0;
3670 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3671 mpathpersist=yes
3672 mpathpersist_new_api=yes
3673 else
3674 # probe for the old API
3675 cat > $TMPC <<EOF
3676 #include <libudev.h>
3677 #include <mpath_persist.h>
3678 unsigned mpath_mx_alloc_len = 1024;
3679 int logsink;
3680 int main(void) {
3681 struct udev *udev = udev_new();
3682 mpath_lib_init(udev);
3683 return 0;
3686 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3687 mpathpersist=yes
3688 mpathpersist_new_api=no
3689 else
3690 mpathpersist=no
3693 else
3694 mpathpersist=no
3697 ##########################################
3698 # libcap probe
3700 if test "$cap" != "no" ; then
3701 cat > $TMPC <<EOF
3702 #include <stdio.h>
3703 #include <sys/capability.h>
3704 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3706 if compile_prog "" "-lcap" ; then
3707 cap=yes
3708 else
3709 cap=no
3713 ##########################################
3714 # pthread probe
3715 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3717 pthread=no
3718 cat > $TMPC << EOF
3719 #include <pthread.h>
3720 static void *f(void *p) { return NULL; }
3721 int main(void) {
3722 pthread_t thread;
3723 pthread_create(&thread, 0, f, 0);
3724 return 0;
3727 if compile_prog "" "" ; then
3728 pthread=yes
3729 else
3730 for pthread_lib in $PTHREADLIBS_LIST; do
3731 if compile_prog "" "$pthread_lib" ; then
3732 pthread=yes
3733 found=no
3734 for lib_entry in $LIBS; do
3735 if test "$lib_entry" = "$pthread_lib"; then
3736 found=yes
3737 break
3739 done
3740 if test "$found" = "no"; then
3741 LIBS="$pthread_lib $LIBS"
3742 libs_qga="$pthread_lib $libs_qga"
3744 PTHREAD_LIB="$pthread_lib"
3745 break
3747 done
3750 if test "$mingw32" != yes -a "$pthread" = no; then
3751 error_exit "pthread check failed" \
3752 "Make sure to have the pthread libs and headers installed."
3755 # check for pthread_setname_np
3756 pthread_setname_np=no
3757 cat > $TMPC << EOF
3758 #include <pthread.h>
3760 static void *f(void *p) { return NULL; }
3761 int main(void)
3763 pthread_t thread;
3764 pthread_create(&thread, 0, f, 0);
3765 pthread_setname_np(thread, "QEMU");
3766 return 0;
3769 if compile_prog "" "$pthread_lib" ; then
3770 pthread_setname_np=yes
3773 ##########################################
3774 # rbd probe
3775 if test "$rbd" != "no" ; then
3776 cat > $TMPC <<EOF
3777 #include <stdio.h>
3778 #include <rbd/librbd.h>
3779 int main(void) {
3780 rados_t cluster;
3781 rados_create(&cluster, NULL);
3782 return 0;
3785 rbd_libs="-lrbd -lrados"
3786 if compile_prog "" "$rbd_libs" ; then
3787 rbd=yes
3788 else
3789 if test "$rbd" = "yes" ; then
3790 feature_not_found "rados block device" "Install librbd/ceph devel"
3792 rbd=no
3796 ##########################################
3797 # libssh2 probe
3798 min_libssh2_version=1.2.8
3799 if test "$libssh2" != "no" ; then
3800 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3801 libssh2_cflags=$($pkg_config libssh2 --cflags)
3802 libssh2_libs=$($pkg_config libssh2 --libs)
3803 libssh2=yes
3804 else
3805 if test "$libssh2" = "yes" ; then
3806 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3808 libssh2=no
3812 ##########################################
3813 # libssh2_sftp_fsync probe
3815 if test "$libssh2" = "yes"; then
3816 cat > $TMPC <<EOF
3817 #include <stdio.h>
3818 #include <libssh2.h>
3819 #include <libssh2_sftp.h>
3820 int main(void) {
3821 LIBSSH2_SESSION *session;
3822 LIBSSH2_SFTP *sftp;
3823 LIBSSH2_SFTP_HANDLE *sftp_handle;
3824 session = libssh2_session_init ();
3825 sftp = libssh2_sftp_init (session);
3826 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3827 libssh2_sftp_fsync (sftp_handle);
3828 return 0;
3831 # libssh2_cflags/libssh2_libs defined in previous test.
3832 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3833 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3837 ##########################################
3838 # linux-aio probe
3840 if test "$linux_aio" != "no" ; then
3841 cat > $TMPC <<EOF
3842 #include <libaio.h>
3843 #include <sys/eventfd.h>
3844 #include <stddef.h>
3845 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3847 if compile_prog "" "-laio" ; then
3848 linux_aio=yes
3849 else
3850 if test "$linux_aio" = "yes" ; then
3851 feature_not_found "linux AIO" "Install libaio devel"
3853 linux_aio=no
3857 ##########################################
3858 # TPM passthrough is only on x86 Linux
3860 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3861 tpm_passthrough=$tpm
3862 else
3863 tpm_passthrough=no
3866 # TPM emulator is for all posix systems
3867 if test "$mingw32" != "yes"; then
3868 tpm_emulator=$tpm
3869 else
3870 tpm_emulator=no
3872 ##########################################
3873 # attr probe
3875 if test "$attr" != "no" ; then
3876 cat > $TMPC <<EOF
3877 #include <stdio.h>
3878 #include <sys/types.h>
3879 #ifdef CONFIG_LIBATTR
3880 #include <attr/xattr.h>
3881 #else
3882 #include <sys/xattr.h>
3883 #endif
3884 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3886 if compile_prog "" "" ; then
3887 attr=yes
3888 # Older distros have <attr/xattr.h>, and need -lattr:
3889 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3890 attr=yes
3891 LIBS="-lattr $LIBS"
3892 libattr=yes
3893 else
3894 if test "$attr" = "yes" ; then
3895 feature_not_found "ATTR" "Install libc6 or libattr devel"
3897 attr=no
3901 ##########################################
3902 # iovec probe
3903 cat > $TMPC <<EOF
3904 #include <sys/types.h>
3905 #include <sys/uio.h>
3906 #include <unistd.h>
3907 int main(void) { return sizeof(struct iovec); }
3909 iovec=no
3910 if compile_prog "" "" ; then
3911 iovec=yes
3914 ##########################################
3915 # preadv probe
3916 cat > $TMPC <<EOF
3917 #include <sys/types.h>
3918 #include <sys/uio.h>
3919 #include <unistd.h>
3920 int main(void) { return preadv(0, 0, 0, 0); }
3922 preadv=no
3923 if compile_prog "" "" ; then
3924 preadv=yes
3927 ##########################################
3928 # fdt probe
3929 # fdt support is mandatory for at least some target architectures,
3930 # so insist on it if we're building those system emulators.
3931 fdt_required=no
3932 for target in $target_list; do
3933 case $target in
3934 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
3935 fdt_required=yes
3937 esac
3938 done
3940 if test "$fdt_required" = "yes"; then
3941 if test "$fdt" = "no"; then
3942 error_exit "fdt disabled but some requested targets require it." \
3943 "You can turn off fdt only if you also disable all the system emulation" \
3944 "targets which need it (by specifying a cut down --target-list)."
3946 fdt=yes
3949 if test "$fdt" != "no" ; then
3950 fdt_libs="-lfdt"
3951 # explicitly check for libfdt_env.h as it is missing in some stable installs
3952 # and test for required functions to make sure we are on a version >= 1.4.2
3953 cat > $TMPC << EOF
3954 #include <libfdt.h>
3955 #include <libfdt_env.h>
3956 int main(void) { fdt_first_subnode(0, 0); return 0; }
3958 if compile_prog "" "$fdt_libs" ; then
3959 # system DTC is good - use it
3960 fdt=system
3961 else
3962 # have GIT checkout, so activate dtc submodule
3963 if test -e "${source_path}/.git" ; then
3964 git_submodules="${git_submodules} dtc"
3966 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3967 fdt=git
3968 mkdir -p dtc
3969 if [ "$pwd_is_source_path" != "y" ] ; then
3970 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3971 symlink "$source_path/dtc/scripts" "dtc/scripts"
3973 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3974 fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
3975 fdt_libs="$fdt_libs"
3976 elif test "$fdt" = "yes" ; then
3977 # Not a git build & no libfdt found, prompt for system install
3978 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3979 "Please install the DTC (libfdt) devel package"
3980 else
3981 # don't have and don't want
3982 fdt_libs=
3983 fdt=no
3988 libs_softmmu="$libs_softmmu $fdt_libs"
3990 ##########################################
3991 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3993 if test "$opengl" != "no" ; then
3994 opengl_pkgs="epoxy gbm"
3995 if $pkg_config $opengl_pkgs; then
3996 opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
3997 opengl_libs="$($pkg_config --libs $opengl_pkgs)"
3998 opengl=yes
3999 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4000 gtk_gl="yes"
4002 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
4003 else
4004 if test "$opengl" = "yes" ; then
4005 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
4007 opengl_cflags=""
4008 opengl_libs=""
4009 opengl=no
4013 if test "$opengl" = "yes"; then
4014 cat > $TMPC << EOF
4015 #include <epoxy/egl.h>
4016 #ifndef EGL_MESA_image_dma_buf_export
4017 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4018 #endif
4019 int main(void) { return 0; }
4021 if compile_prog "" "" ; then
4022 opengl_dmabuf=yes
4026 ##########################################
4027 # libxml2 probe
4028 if test "$libxml2" != "no" ; then
4029 if $pkg_config --exists libxml-2.0; then
4030 libxml2="yes"
4031 libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4032 libxml2_libs=$($pkg_config --libs libxml-2.0)
4033 else
4034 if test "$libxml2" = "yes"; then
4035 feature_not_found "libxml2" "Install libxml2 devel"
4037 libxml2="no"
4041 ##########################################
4042 # glusterfs probe
4043 if test "$glusterfs" != "no" ; then
4044 if $pkg_config --atleast-version=3 glusterfs-api; then
4045 glusterfs="yes"
4046 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
4047 glusterfs_libs=$($pkg_config --libs glusterfs-api)
4048 if $pkg_config --atleast-version=4 glusterfs-api; then
4049 glusterfs_xlator_opt="yes"
4051 if $pkg_config --atleast-version=5 glusterfs-api; then
4052 glusterfs_discard="yes"
4054 if $pkg_config --atleast-version=6 glusterfs-api; then
4055 glusterfs_fallocate="yes"
4056 glusterfs_zerofill="yes"
4058 else
4059 if test "$glusterfs" = "yes" ; then
4060 feature_not_found "GlusterFS backend support" \
4061 "Install glusterfs-api devel >= 3"
4063 glusterfs="no"
4067 # Check for inotify functions when we are building linux-user
4068 # emulator. This is done because older glibc versions don't
4069 # have syscall stubs for these implemented. In that case we
4070 # don't provide them even if kernel supports them.
4072 inotify=no
4073 cat > $TMPC << EOF
4074 #include <sys/inotify.h>
4077 main(void)
4079 /* try to start inotify */
4080 return inotify_init();
4083 if compile_prog "" "" ; then
4084 inotify=yes
4087 inotify1=no
4088 cat > $TMPC << EOF
4089 #include <sys/inotify.h>
4092 main(void)
4094 /* try to start inotify */
4095 return inotify_init1(0);
4098 if compile_prog "" "" ; then
4099 inotify1=yes
4102 # check if pipe2 is there
4103 pipe2=no
4104 cat > $TMPC << EOF
4105 #include <unistd.h>
4106 #include <fcntl.h>
4108 int main(void)
4110 int pipefd[2];
4111 return pipe2(pipefd, O_CLOEXEC);
4114 if compile_prog "" "" ; then
4115 pipe2=yes
4118 # check if accept4 is there
4119 accept4=no
4120 cat > $TMPC << EOF
4121 #include <sys/socket.h>
4122 #include <stddef.h>
4124 int main(void)
4126 accept4(0, NULL, NULL, SOCK_CLOEXEC);
4127 return 0;
4130 if compile_prog "" "" ; then
4131 accept4=yes
4134 # check if tee/splice is there. vmsplice was added same time.
4135 splice=no
4136 cat > $TMPC << EOF
4137 #include <unistd.h>
4138 #include <fcntl.h>
4139 #include <limits.h>
4141 int main(void)
4143 int len, fd = 0;
4144 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
4145 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
4146 return 0;
4149 if compile_prog "" "" ; then
4150 splice=yes
4153 ##########################################
4154 # libnuma probe
4156 if test "$numa" != "no" ; then
4157 cat > $TMPC << EOF
4158 #include <numa.h>
4159 int main(void) { return numa_available(); }
4162 if compile_prog "" "-lnuma" ; then
4163 numa=yes
4164 libs_softmmu="-lnuma $libs_softmmu"
4165 else
4166 if test "$numa" = "yes" ; then
4167 feature_not_found "numa" "install numactl devel"
4169 numa=no
4173 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
4174 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
4175 exit 1
4178 # Even if malloc_trim() is available, these non-libc memory allocators
4179 # do not support it.
4180 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
4181 if test "$malloc_trim" = "yes" ; then
4182 echo "Disabling malloc_trim with non-libc memory allocator"
4184 malloc_trim="no"
4187 #######################################
4188 # malloc_trim
4190 if test "$malloc_trim" != "no" ; then
4191 cat > $TMPC << EOF
4192 #include <malloc.h>
4193 int main(void) { malloc_trim(0); return 0; }
4195 if compile_prog "" "" ; then
4196 malloc_trim="yes"
4197 else
4198 malloc_trim="no"
4202 ##########################################
4203 # tcmalloc probe
4205 if test "$tcmalloc" = "yes" ; then
4206 cat > $TMPC << EOF
4207 #include <stdlib.h>
4208 int main(void) { malloc(1); return 0; }
4211 if compile_prog "" "-ltcmalloc" ; then
4212 LIBS="-ltcmalloc $LIBS"
4213 else
4214 feature_not_found "tcmalloc" "install gperftools devel"
4218 ##########################################
4219 # jemalloc probe
4221 if test "$jemalloc" = "yes" ; then
4222 cat > $TMPC << EOF
4223 #include <stdlib.h>
4224 int main(void) { malloc(1); return 0; }
4227 if compile_prog "" "-ljemalloc" ; then
4228 LIBS="-ljemalloc $LIBS"
4229 else
4230 feature_not_found "jemalloc" "install jemalloc devel"
4234 ##########################################
4235 # signalfd probe
4236 signalfd="no"
4237 cat > $TMPC << EOF
4238 #include <unistd.h>
4239 #include <sys/syscall.h>
4240 #include <signal.h>
4241 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4244 if compile_prog "" "" ; then
4245 signalfd=yes
4248 # check if eventfd is supported
4249 eventfd=no
4250 cat > $TMPC << EOF
4251 #include <sys/eventfd.h>
4253 int main(void)
4255 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4258 if compile_prog "" "" ; then
4259 eventfd=yes
4262 # check if memfd is supported
4263 memfd=no
4264 cat > $TMPC << EOF
4265 #include <sys/mman.h>
4267 int main(void)
4269 return memfd_create("foo", MFD_ALLOW_SEALING);
4272 if compile_prog "" "" ; then
4273 memfd=yes
4276 # check for usbfs
4277 have_usbfs=no
4278 if test "$linux_user" = "yes"; then
4279 if check_include linux/usbdevice_fs.h; then
4280 have_usbfs=yes
4282 have_usbfs=yes
4285 # check for fallocate
4286 fallocate=no
4287 cat > $TMPC << EOF
4288 #include <fcntl.h>
4290 int main(void)
4292 fallocate(0, 0, 0, 0);
4293 return 0;
4296 if compile_prog "" "" ; then
4297 fallocate=yes
4300 # check for fallocate hole punching
4301 fallocate_punch_hole=no
4302 cat > $TMPC << EOF
4303 #include <fcntl.h>
4304 #include <linux/falloc.h>
4306 int main(void)
4308 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4309 return 0;
4312 if compile_prog "" "" ; then
4313 fallocate_punch_hole=yes
4316 # check that fallocate supports range zeroing inside the file
4317 fallocate_zero_range=no
4318 cat > $TMPC << EOF
4319 #include <fcntl.h>
4320 #include <linux/falloc.h>
4322 int main(void)
4324 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4325 return 0;
4328 if compile_prog "" "" ; then
4329 fallocate_zero_range=yes
4332 # check for posix_fallocate
4333 posix_fallocate=no
4334 cat > $TMPC << EOF
4335 #include <fcntl.h>
4337 int main(void)
4339 posix_fallocate(0, 0, 0);
4340 return 0;
4343 if compile_prog "" "" ; then
4344 posix_fallocate=yes
4347 # check for sync_file_range
4348 sync_file_range=no
4349 cat > $TMPC << EOF
4350 #include <fcntl.h>
4352 int main(void)
4354 sync_file_range(0, 0, 0, 0);
4355 return 0;
4358 if compile_prog "" "" ; then
4359 sync_file_range=yes
4362 # check for linux/fiemap.h and FS_IOC_FIEMAP
4363 fiemap=no
4364 cat > $TMPC << EOF
4365 #include <sys/ioctl.h>
4366 #include <linux/fs.h>
4367 #include <linux/fiemap.h>
4369 int main(void)
4371 ioctl(0, FS_IOC_FIEMAP, 0);
4372 return 0;
4375 if compile_prog "" "" ; then
4376 fiemap=yes
4379 # check for dup3
4380 dup3=no
4381 cat > $TMPC << EOF
4382 #include <unistd.h>
4384 int main(void)
4386 dup3(0, 0, 0);
4387 return 0;
4390 if compile_prog "" "" ; then
4391 dup3=yes
4394 # check for ppoll support
4395 ppoll=no
4396 cat > $TMPC << EOF
4397 #include <poll.h>
4399 int main(void)
4401 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4402 ppoll(&pfd, 1, 0, 0);
4403 return 0;
4406 if compile_prog "" "" ; then
4407 ppoll=yes
4410 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4411 prctl_pr_set_timerslack=no
4412 cat > $TMPC << EOF
4413 #include <sys/prctl.h>
4415 int main(void)
4417 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4418 return 0;
4421 if compile_prog "" "" ; then
4422 prctl_pr_set_timerslack=yes
4425 # check for epoll support
4426 epoll=no
4427 cat > $TMPC << EOF
4428 #include <sys/epoll.h>
4430 int main(void)
4432 epoll_create(0);
4433 return 0;
4436 if compile_prog "" "" ; then
4437 epoll=yes
4440 # epoll_create1 is a later addition
4441 # so we must check separately for its presence
4442 epoll_create1=no
4443 cat > $TMPC << EOF
4444 #include <sys/epoll.h>
4446 int main(void)
4448 /* Note that we use epoll_create1 as a value, not as
4449 * a function being called. This is necessary so that on
4450 * old SPARC glibc versions where the function was present in
4451 * the library but not declared in the header file we will
4452 * fail the configure check. (Otherwise we will get a compiler
4453 * warning but not an error, and will proceed to fail the
4454 * qemu compile where we compile with -Werror.)
4456 return (int)(uintptr_t)&epoll_create1;
4459 if compile_prog "" "" ; then
4460 epoll_create1=yes
4463 # check for sendfile support
4464 sendfile=no
4465 cat > $TMPC << EOF
4466 #include <sys/sendfile.h>
4468 int main(void)
4470 return sendfile(0, 0, 0, 0);
4473 if compile_prog "" "" ; then
4474 sendfile=yes
4477 # check for timerfd support (glibc 2.8 and newer)
4478 timerfd=no
4479 cat > $TMPC << EOF
4480 #include <sys/timerfd.h>
4482 int main(void)
4484 return(timerfd_create(CLOCK_REALTIME, 0));
4487 if compile_prog "" "" ; then
4488 timerfd=yes
4491 # check for setns and unshare support
4492 setns=no
4493 cat > $TMPC << EOF
4494 #include <sched.h>
4496 int main(void)
4498 int ret;
4499 ret = setns(0, 0);
4500 ret = unshare(0);
4501 return ret;
4504 if compile_prog "" "" ; then
4505 setns=yes
4508 # clock_adjtime probe
4509 clock_adjtime=no
4510 cat > $TMPC <<EOF
4511 #include <time.h>
4513 int main(void)
4515 return clock_adjtime(0, 0);
4518 clock_adjtime=no
4519 if compile_prog "" "" ; then
4520 clock_adjtime=yes
4523 # syncfs probe
4524 syncfs=no
4525 cat > $TMPC <<EOF
4526 #include <unistd.h>
4528 int main(void)
4530 return syncfs(0);
4533 syncfs=no
4534 if compile_prog "" "" ; then
4535 syncfs=yes
4538 # Check if tools are available to build documentation.
4539 if test "$docs" != "no" ; then
4540 if has makeinfo && has pod2man; then
4541 docs=yes
4542 else
4543 if test "$docs" = "yes" ; then
4544 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4546 docs=no
4550 # Search for bswap_32 function
4551 byteswap_h=no
4552 cat > $TMPC << EOF
4553 #include <byteswap.h>
4554 int main(void) { return bswap_32(0); }
4556 if compile_prog "" "" ; then
4557 byteswap_h=yes
4560 # Search for bswap32 function
4561 bswap_h=no
4562 cat > $TMPC << EOF
4563 #include <sys/endian.h>
4564 #include <sys/types.h>
4565 #include <machine/bswap.h>
4566 int main(void) { return bswap32(0); }
4568 if compile_prog "" "" ; then
4569 bswap_h=yes
4572 ##########################################
4573 # Do we have libiscsi >= 1.9.0
4574 if test "$libiscsi" != "no" ; then
4575 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4576 libiscsi="yes"
4577 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4578 libiscsi_libs=$($pkg_config --libs libiscsi)
4579 else
4580 if test "$libiscsi" = "yes" ; then
4581 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4583 libiscsi="no"
4587 ##########################################
4588 # Do we need libm
4589 cat > $TMPC << EOF
4590 #include <math.h>
4591 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4593 if compile_prog "" "" ; then
4595 elif compile_prog "" "-lm" ; then
4596 LIBS="-lm $LIBS"
4597 libs_qga="-lm $libs_qga"
4598 else
4599 error_exit "libm check failed"
4602 ##########################################
4603 # Do we need librt
4604 # uClibc provides 2 versions of clock_gettime(), one with realtime
4605 # support and one without. This means that the clock_gettime() don't
4606 # need -lrt. We still need it for timer_create() so we check for this
4607 # function in addition.
4608 cat > $TMPC <<EOF
4609 #include <signal.h>
4610 #include <time.h>
4611 int main(void) {
4612 timer_create(CLOCK_REALTIME, NULL, NULL);
4613 return clock_gettime(CLOCK_REALTIME, NULL);
4617 if compile_prog "" "" ; then
4619 # we need pthread for static linking. use previous pthread test result
4620 elif compile_prog "" "$pthread_lib -lrt" ; then
4621 LIBS="$LIBS -lrt"
4622 libs_qga="$libs_qga -lrt"
4625 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4626 "$haiku" != "yes" ; then
4627 libs_softmmu="-lutil $libs_softmmu"
4630 ##########################################
4631 # spice probe
4632 if test "$spice" != "no" ; then
4633 cat > $TMPC << EOF
4634 #include <spice.h>
4635 int main(void) { spice_server_new(); return 0; }
4637 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4638 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4639 if $pkg_config --atleast-version=0.12.0 spice-server && \
4640 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4641 compile_prog "$spice_cflags" "$spice_libs" ; then
4642 spice="yes"
4643 libs_softmmu="$libs_softmmu $spice_libs"
4644 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4645 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4646 spice_server_version=$($pkg_config --modversion spice-server)
4647 else
4648 if test "$spice" = "yes" ; then
4649 feature_not_found "spice" \
4650 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4652 spice="no"
4656 # check for smartcard support
4657 if test "$smartcard" != "no"; then
4658 if $pkg_config --atleast-version=2.5.1 libcacard; then
4659 libcacard_cflags=$($pkg_config --cflags libcacard)
4660 libcacard_libs=$($pkg_config --libs libcacard)
4661 smartcard="yes"
4662 else
4663 if test "$smartcard" = "yes"; then
4664 feature_not_found "smartcard" "Install libcacard devel"
4666 smartcard="no"
4670 # check for libusb
4671 if test "$libusb" != "no" ; then
4672 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4673 libusb="yes"
4674 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4675 libusb_libs=$($pkg_config --libs libusb-1.0)
4676 else
4677 if test "$libusb" = "yes"; then
4678 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4680 libusb="no"
4684 # check for usbredirparser for usb network redirection support
4685 if test "$usb_redir" != "no" ; then
4686 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4687 usb_redir="yes"
4688 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4689 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4690 else
4691 if test "$usb_redir" = "yes"; then
4692 feature_not_found "usb-redir" "Install usbredir devel"
4694 usb_redir="no"
4698 ##########################################
4699 # check if we have VSS SDK headers for win
4701 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4702 case "$vss_win32_sdk" in
4703 "") vss_win32_include="-isystem $source_path" ;;
4704 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4705 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4706 vss_win32_include="-isystem $source_path/.sdk/vss"
4707 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4709 *) vss_win32_include="-isystem $vss_win32_sdk"
4710 esac
4711 cat > $TMPC << EOF
4712 #define __MIDL_user_allocate_free_DEFINED__
4713 #include <inc/win2003/vss.h>
4714 int main(void) { return VSS_CTX_BACKUP; }
4716 if compile_prog "$vss_win32_include" "" ; then
4717 guest_agent_with_vss="yes"
4718 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4719 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4720 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4721 else
4722 if test "$vss_win32_sdk" != "" ; then
4723 echo "ERROR: Please download and install Microsoft VSS SDK:"
4724 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4725 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4726 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4727 echo "ERROR: The headers are extracted in the directory \`inc'."
4728 feature_not_found "VSS support"
4730 guest_agent_with_vss="no"
4734 ##########################################
4735 # lookup Windows platform SDK (if not specified)
4736 # The SDK is needed only to build .tlb (type library) file of guest agent
4737 # VSS provider from the source. It is usually unnecessary because the
4738 # pre-compiled .tlb file is included.
4740 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4741 if test -z "$win_sdk"; then
4742 programfiles="$PROGRAMFILES"
4743 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4744 if test -n "$programfiles"; then
4745 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4746 else
4747 feature_not_found "Windows SDK"
4749 elif test "$win_sdk" = "no"; then
4750 win_sdk=""
4754 ##########################################
4755 # check if mingw environment provides a recent ntddscsi.h
4756 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4757 cat > $TMPC << EOF
4758 #include <windows.h>
4759 #include <ntddscsi.h>
4760 int main(void) {
4761 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4762 #error Missing required ioctl definitions
4763 #endif
4764 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4765 return addr.Lun;
4768 if compile_prog "" "" ; then
4769 guest_agent_ntddscsi=yes
4770 libs_qga="-lsetupapi $libs_qga"
4774 ##########################################
4775 # virgl renderer probe
4777 if test "$virglrenderer" != "no" ; then
4778 cat > $TMPC << EOF
4779 #include <virglrenderer.h>
4780 int main(void) { virgl_renderer_poll(); return 0; }
4782 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4783 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4784 virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
4785 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4786 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4787 virglrenderer="yes"
4788 else
4789 if test "$virglrenderer" = "yes" ; then
4790 feature_not_found "virglrenderer"
4792 virglrenderer="no"
4796 ##########################################
4797 # capstone
4799 case "$capstone" in
4800 "" | yes)
4801 if $pkg_config capstone; then
4802 capstone=system
4803 elif test -e "${source_path}/.git" -a $git_update = 'yes' ; then
4804 capstone=git
4805 elif test -e "${source_path}/capstone/Makefile" ; then
4806 capstone=internal
4807 elif test -z "$capstone" ; then
4808 capstone=no
4809 else
4810 feature_not_found "capstone" "Install capstone devel or git submodule"
4814 system)
4815 if ! $pkg_config capstone; then
4816 feature_not_found "capstone" "Install capstone devel"
4819 esac
4821 case "$capstone" in
4822 git | internal)
4823 if test "$capstone" = git; then
4824 git_submodules="${git_submodules} capstone"
4826 mkdir -p capstone
4827 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4828 if test "$mingw32" = "yes"; then
4829 LIBCAPSTONE=capstone.lib
4830 else
4831 LIBCAPSTONE=libcapstone.a
4833 LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4836 system)
4837 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
4838 LIBS="$($pkg_config --libs capstone) $LIBS"
4844 error_exit "Unknown state for capstone: $capstone"
4846 esac
4848 ##########################################
4849 # check if we have fdatasync
4851 fdatasync=no
4852 cat > $TMPC << EOF
4853 #include <unistd.h>
4854 int main(void) {
4855 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4856 return fdatasync(0);
4857 #else
4858 #error Not supported
4859 #endif
4862 if compile_prog "" "" ; then
4863 fdatasync=yes
4866 ##########################################
4867 # check if we have madvise
4869 madvise=no
4870 cat > $TMPC << EOF
4871 #include <sys/types.h>
4872 #include <sys/mman.h>
4873 #include <stddef.h>
4874 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4876 if compile_prog "" "" ; then
4877 madvise=yes
4880 ##########################################
4881 # check if we have posix_madvise
4883 posix_madvise=no
4884 cat > $TMPC << EOF
4885 #include <sys/mman.h>
4886 #include <stddef.h>
4887 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4889 if compile_prog "" "" ; then
4890 posix_madvise=yes
4893 ##########################################
4894 # check if we have posix_memalign()
4896 posix_memalign=no
4897 cat > $TMPC << EOF
4898 #include <stdlib.h>
4899 int main(void) {
4900 void *p;
4901 return posix_memalign(&p, 8, 8);
4904 if compile_prog "" "" ; then
4905 posix_memalign=yes
4908 ##########################################
4909 # check if we have posix_syslog
4911 posix_syslog=no
4912 cat > $TMPC << EOF
4913 #include <syslog.h>
4914 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4916 if compile_prog "" "" ; then
4917 posix_syslog=yes
4920 ##########################################
4921 # check if we have sem_timedwait
4923 sem_timedwait=no
4924 cat > $TMPC << EOF
4925 #include <semaphore.h>
4926 int main(void) { return sem_timedwait(0, 0); }
4928 if compile_prog "" "" ; then
4929 sem_timedwait=yes
4932 ##########################################
4933 # check if we have strchrnul
4935 strchrnul=no
4936 cat > $TMPC << EOF
4937 #include <string.h>
4938 int main(void);
4939 // Use a haystack that the compiler shouldn't be able to constant fold
4940 char *haystack = (char*)&main;
4941 int main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
4943 if compile_prog "" "" ; then
4944 strchrnul=yes
4947 ##########################################
4948 # check if trace backend exists
4950 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4951 if test "$?" -ne 0 ; then
4952 error_exit "invalid trace backends" \
4953 "Please choose supported trace backends."
4956 ##########################################
4957 # For 'ust' backend, test if ust headers are present
4958 if have_backend "ust"; then
4959 cat > $TMPC << EOF
4960 #include <lttng/tracepoint.h>
4961 int main(void) { return 0; }
4963 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4964 if $pkg_config lttng-ust --exists; then
4965 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4966 else
4967 lttng_ust_libs="-llttng-ust -ldl"
4969 if $pkg_config liburcu-bp --exists; then
4970 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4971 else
4972 urcu_bp_libs="-lurcu-bp"
4975 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4976 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4977 else
4978 error_exit "Trace backend 'ust' missing lttng-ust header files"
4982 ##########################################
4983 # For 'dtrace' backend, test if 'dtrace' command is present
4984 if have_backend "dtrace"; then
4985 if ! has 'dtrace' ; then
4986 error_exit "dtrace command is not found in PATH $PATH"
4988 trace_backend_stap="no"
4989 if has 'stap' ; then
4990 trace_backend_stap="yes"
4994 ##########################################
4995 # check and set a backend for coroutine
4997 # We prefer ucontext, but it's not always possible. The fallback
4998 # is sigcontext. On Windows the only valid backend is the Windows
4999 # specific one.
5001 ucontext_works=no
5002 if test "$darwin" != "yes"; then
5003 cat > $TMPC << EOF
5004 #include <ucontext.h>
5005 #ifdef __stub_makecontext
5006 #error Ignoring glibc stub makecontext which will always fail
5007 #endif
5008 int main(void) { makecontext(0, 0, 0); return 0; }
5010 if compile_prog "" "" ; then
5011 ucontext_works=yes
5015 if test "$coroutine" = ""; then
5016 if test "$mingw32" = "yes"; then
5017 coroutine=win32
5018 elif test "$ucontext_works" = "yes"; then
5019 coroutine=ucontext
5020 else
5021 coroutine=sigaltstack
5023 else
5024 case $coroutine in
5025 windows)
5026 if test "$mingw32" != "yes"; then
5027 error_exit "'windows' coroutine backend only valid for Windows"
5029 # Unfortunately the user visible backend name doesn't match the
5030 # coroutine-*.c filename for this case, so we have to adjust it here.
5031 coroutine=win32
5033 ucontext)
5034 if test "$ucontext_works" != "yes"; then
5035 feature_not_found "ucontext"
5038 sigaltstack)
5039 if test "$mingw32" = "yes"; then
5040 error_exit "only the 'windows' coroutine backend is valid for Windows"
5044 error_exit "unknown coroutine backend $coroutine"
5046 esac
5049 if test "$coroutine_pool" = ""; then
5050 if test "$coroutine" = "gthread" -o "$coroutine" = "win32"; then
5051 coroutine_pool=no
5052 else
5053 coroutine_pool=yes
5056 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
5057 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
5060 if test "$debug_stack_usage" = "yes"; then
5061 if test "$coroutine_pool" = "yes"; then
5062 echo "WARN: disabling coroutine pool for stack usage debugging"
5063 coroutine_pool=no
5068 ##########################################
5069 # check if we have open_by_handle_at
5071 open_by_handle_at=no
5072 cat > $TMPC << EOF
5073 #include <fcntl.h>
5074 #if !defined(AT_EMPTY_PATH)
5075 # error missing definition
5076 #else
5077 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5078 #endif
5080 if compile_prog "" "" ; then
5081 open_by_handle_at=yes
5084 ########################################
5085 # check if we have linux/magic.h
5087 linux_magic_h=no
5088 cat > $TMPC << EOF
5089 #include <linux/magic.h>
5090 int main(void) {
5091 return 0;
5094 if compile_prog "" "" ; then
5095 linux_magic_h=yes
5098 ########################################
5099 # check whether we can disable warning option with a pragma (this is needed
5100 # to silence warnings in the headers of some versions of external libraries).
5101 # This test has to be compiled with -Werror as otherwise an unknown pragma is
5102 # only a warning.
5104 # If we can't selectively disable warning in the code, disable -Werror so that
5105 # the build doesn't fail anyway.
5107 pragma_disable_unused_but_set=no
5108 cat > $TMPC << EOF
5109 #pragma GCC diagnostic push
5110 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
5111 #pragma GCC diagnostic pop
5113 int main(void) {
5114 return 0;
5117 if compile_prog "-Werror" "" ; then
5118 pragma_diagnostic_available=yes
5121 ########################################
5122 # check if we have valgrind/valgrind.h
5124 valgrind_h=no
5125 cat > $TMPC << EOF
5126 #include <valgrind/valgrind.h>
5127 int main(void) {
5128 return 0;
5131 if compile_prog "" "" ; then
5132 valgrind_h=yes
5135 ########################################
5136 # check if environ is declared
5138 has_environ=no
5139 cat > $TMPC << EOF
5140 #include <unistd.h>
5141 int main(void) {
5142 environ = 0;
5143 return 0;
5146 if compile_prog "" "" ; then
5147 has_environ=yes
5150 ########################################
5151 # check if cpuid.h is usable.
5153 cat > $TMPC << EOF
5154 #include <cpuid.h>
5155 int main(void) {
5156 unsigned a, b, c, d;
5157 int max = __get_cpuid_max(0, 0);
5159 if (max >= 1) {
5160 __cpuid(1, a, b, c, d);
5163 if (max >= 7) {
5164 __cpuid_count(7, 0, a, b, c, d);
5167 return 0;
5170 if compile_prog "" "" ; then
5171 cpuid_h=yes
5174 ##########################################
5175 # avx2 optimization requirement check
5177 # There is no point enabling this if cpuid.h is not usable,
5178 # since we won't be able to select the new routines.
5180 if test "$cpuid_h" = "yes" -a "$avx2_opt" != "no"; then
5181 cat > $TMPC << EOF
5182 #pragma GCC push_options
5183 #pragma GCC target("avx2")
5184 #include <cpuid.h>
5185 #include <immintrin.h>
5186 static int bar(void *a) {
5187 __m256i x = *(__m256i *)a;
5188 return _mm256_testz_si256(x, x);
5190 int main(int argc, char *argv[]) { return bar(argv[0]); }
5192 if compile_object "" ; then
5193 avx2_opt="yes"
5194 else
5195 avx2_opt="no"
5199 ########################################
5200 # check if __[u]int128_t is usable.
5202 int128=no
5203 cat > $TMPC << EOF
5204 __int128_t a;
5205 __uint128_t b;
5206 int main (void) {
5207 a = a + b;
5208 b = a * b;
5209 a = a * a;
5210 return 0;
5213 if compile_prog "" "" ; then
5214 int128=yes
5217 #########################################
5218 # See if 128-bit atomic operations are supported.
5220 atomic128=no
5221 if test "$int128" = "yes"; then
5222 cat > $TMPC << EOF
5223 int main(void)
5225 unsigned __int128 x = 0, y = 0;
5226 y = __atomic_load_16(&x, 0);
5227 __atomic_store_16(&x, y, 0);
5228 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
5229 return 0;
5232 if compile_prog "" "" ; then
5233 atomic128=yes
5237 cmpxchg128=no
5238 if test "$int128" = yes -a "$atomic128" = no; then
5239 cat > $TMPC << EOF
5240 int main(void)
5242 unsigned __int128 x = 0, y = 0;
5243 __sync_val_compare_and_swap_16(&x, y, x);
5244 return 0;
5247 if compile_prog "" "" ; then
5248 cmpxchg128=yes
5252 #########################################
5253 # See if 64-bit atomic operations are supported.
5254 # Note that without __atomic builtins, we can only
5255 # assume atomic loads/stores max at pointer size.
5257 cat > $TMPC << EOF
5258 #include <stdint.h>
5259 int main(void)
5261 uint64_t x = 0, y = 0;
5262 #ifdef __ATOMIC_RELAXED
5263 y = __atomic_load_8(&x, 0);
5264 __atomic_store_8(&x, y, 0);
5265 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5266 __atomic_exchange_8(&x, y, 0);
5267 __atomic_fetch_add_8(&x, y, 0);
5268 #else
5269 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5270 __sync_lock_test_and_set(&x, y);
5271 __sync_val_compare_and_swap(&x, y, 0);
5272 __sync_fetch_and_add(&x, y);
5273 #endif
5274 return 0;
5277 if compile_prog "" "" ; then
5278 atomic64=yes
5281 ########################################
5282 # See if 16-byte vector operations are supported.
5283 # Even without a vector unit the compiler may expand these.
5284 # There is a bug in old GCC for PPC that crashes here.
5285 # Unfortunately it's the system compiler for Centos 7.
5287 cat > $TMPC << EOF
5288 typedef unsigned char U1 __attribute__((vector_size(16)));
5289 typedef unsigned short U2 __attribute__((vector_size(16)));
5290 typedef unsigned int U4 __attribute__((vector_size(16)));
5291 typedef unsigned long long U8 __attribute__((vector_size(16)));
5292 typedef signed char S1 __attribute__((vector_size(16)));
5293 typedef signed short S2 __attribute__((vector_size(16)));
5294 typedef signed int S4 __attribute__((vector_size(16)));
5295 typedef signed long long S8 __attribute__((vector_size(16)));
5296 static U1 a1, b1;
5297 static U2 a2, b2;
5298 static U4 a4, b4;
5299 static U8 a8, b8;
5300 static S1 c1;
5301 static S2 c2;
5302 static S4 c4;
5303 static S8 c8;
5304 static int i;
5305 void helper(void *d, void *a, int shift, int i);
5306 void helper(void *d, void *a, int shift, int i)
5308 *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
5309 *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
5310 *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
5311 *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
5313 int main(void)
5315 a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5316 a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5317 a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5318 a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5319 a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5320 a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5321 a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5322 a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5323 c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5324 return 0;
5328 vector16=no
5329 if compile_prog "" "" ; then
5330 vector16=yes
5333 ########################################
5334 # check if getauxval is available.
5336 getauxval=no
5337 cat > $TMPC << EOF
5338 #include <sys/auxv.h>
5339 int main(void) {
5340 return getauxval(AT_HWCAP) == 0;
5343 if compile_prog "" "" ; then
5344 getauxval=yes
5347 ########################################
5348 # check if ccache is interfering with
5349 # semantic analysis of macros
5351 unset CCACHE_CPP2
5352 ccache_cpp2=no
5353 cat > $TMPC << EOF
5354 static const int Z = 1;
5355 #define fn() ({ Z; })
5356 #define TAUT(X) ((X) == Z)
5357 #define PAREN(X, Y) (X == Y)
5358 #define ID(X) (X)
5359 int main(int argc, char *argv[])
5361 int x = 0, y = 0;
5362 x = ID(x);
5363 x = fn();
5364 fn();
5365 if (PAREN(x, y)) return 0;
5366 if (TAUT(Z)) return 0;
5367 return 0;
5371 if ! compile_object "-Werror"; then
5372 ccache_cpp2=yes
5375 #################################################
5376 # clang does not support glibc + FORTIFY_SOURCE.
5378 if test "$fortify_source" != "no"; then
5379 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5380 fortify_source="no";
5381 elif test -n "$cxx" && has $cxx &&
5382 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5383 fortify_source="no";
5384 else
5385 fortify_source="yes"
5389 ###############################################
5390 # Check if copy_file_range is provided by glibc
5391 have_copy_file_range=no
5392 cat > $TMPC << EOF
5393 #include <unistd.h>
5394 int main(void) {
5395 copy_file_range(0, NULL, 0, NULL, 0, 0);
5396 return 0;
5399 if compile_prog "" "" ; then
5400 have_copy_file_range=yes
5403 ##########################################
5404 # check if struct fsxattr is available via linux/fs.h
5406 have_fsxattr=no
5407 cat > $TMPC << EOF
5408 #include <linux/fs.h>
5409 struct fsxattr foo;
5410 int main(void) {
5411 return 0;
5414 if compile_prog "" "" ; then
5415 have_fsxattr=yes
5418 ##########################################
5419 # check for usable membarrier system call
5420 if test "$membarrier" = "yes"; then
5421 have_membarrier=no
5422 if test "$mingw32" = "yes" ; then
5423 have_membarrier=yes
5424 elif test "$linux" = "yes" ; then
5425 cat > $TMPC << EOF
5426 #include <linux/membarrier.h>
5427 #include <sys/syscall.h>
5428 #include <unistd.h>
5429 #include <stdlib.h>
5430 int main(void) {
5431 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5432 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5433 exit(0);
5436 if compile_prog "" "" ; then
5437 have_membarrier=yes
5440 if test "$have_membarrier" = "no"; then
5441 feature_not_found "membarrier" "membarrier system call not available"
5443 else
5444 # Do not enable it by default even for Mingw32, because it doesn't
5445 # work on Wine.
5446 membarrier=no
5449 ##########################################
5450 # check if rtnetlink.h exists and is useful
5451 have_rtnetlink=no
5452 cat > $TMPC << EOF
5453 #include <linux/rtnetlink.h>
5454 int main(void) {
5455 return IFLA_PROTO_DOWN;
5458 if compile_prog "" "" ; then
5459 have_rtnetlink=yes
5462 ##########################################
5463 # check for usable AF_VSOCK environment
5464 have_af_vsock=no
5465 cat > $TMPC << EOF
5466 #include <errno.h>
5467 #include <sys/types.h>
5468 #include <sys/socket.h>
5469 #if !defined(AF_VSOCK)
5470 # error missing AF_VSOCK flag
5471 #endif
5472 #include <linux/vm_sockets.h>
5473 int main(void) {
5474 int sock, ret;
5475 struct sockaddr_vm svm;
5476 socklen_t len = sizeof(svm);
5477 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
5478 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
5479 if ((ret == -1) && (errno == ENOTCONN)) {
5480 return 0;
5482 return -1;
5485 if compile_prog "" "" ; then
5486 have_af_vsock=yes
5489 ##########################################
5490 # check for usable AF_ALG environment
5491 hava_afalg=no
5492 cat > $TMPC << EOF
5493 #include <errno.h>
5494 #include <sys/types.h>
5495 #include <sys/socket.h>
5496 #include <linux/if_alg.h>
5497 int main(void) {
5498 int sock;
5499 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5500 return sock;
5503 if compile_prog "" "" ; then
5504 have_afalg=yes
5506 if test "$crypto_afalg" = "yes"
5507 then
5508 if test "$have_afalg" != "yes"
5509 then
5510 error_exit "AF_ALG requested but could not be detected"
5515 #################################################
5516 # Check to see if we have the Hypervisor framework
5517 if [ "$darwin" = "yes" ] ; then
5518 cat > $TMPC << EOF
5519 #include <Hypervisor/hv.h>
5520 int main() { return 0;}
5522 if ! compile_object ""; then
5523 hvf='no'
5524 else
5525 hvf='yes'
5526 LDFLAGS="-framework Hypervisor $LDFLAGS"
5530 #################################################
5531 # Sparc implicitly links with --relax, which is
5532 # incompatible with -r, so --no-relax should be
5533 # given. It does no harm to give it on other
5534 # platforms too.
5536 # Note: the prototype is needed since QEMU_CFLAGS
5537 # contains -Wmissing-prototypes
5538 cat > $TMPC << EOF
5539 extern int foo(void);
5540 int foo(void) { return 0; }
5542 if ! compile_object ""; then
5543 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5545 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5546 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5547 LD_REL_FLAGS=$i
5548 break
5550 done
5551 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5552 feature_not_found "modules" "Cannot find how to build relocatable objects"
5555 ##########################################
5556 # check for sysmacros.h
5558 have_sysmacros=no
5559 cat > $TMPC << EOF
5560 #include <sys/sysmacros.h>
5561 int main(void) {
5562 return makedev(0, 0);
5565 if compile_prog "" "" ; then
5566 have_sysmacros=yes
5569 ##########################################
5570 # Veritas HyperScale block driver VxHS
5571 # Check if libvxhs is installed
5573 if test "$vxhs" != "no" ; then
5574 cat > $TMPC <<EOF
5575 #include <stdint.h>
5576 #include <qnio/qnio_api.h>
5578 void *vxhs_callback;
5580 int main(void) {
5581 iio_init(QNIO_VERSION, vxhs_callback);
5582 return 0;
5585 vxhs_libs="-lvxhs -lssl"
5586 if compile_prog "" "$vxhs_libs" ; then
5587 vxhs=yes
5588 else
5589 if test "$vxhs" = "yes" ; then
5590 feature_not_found "vxhs block device" "Install libvxhs See github"
5592 vxhs=no
5596 ##########################################
5597 # check for _Static_assert()
5599 have_static_assert=no
5600 cat > $TMPC << EOF
5601 _Static_assert(1, "success");
5602 int main(void) {
5603 return 0;
5606 if compile_prog "" "" ; then
5607 have_static_assert=yes
5610 ##########################################
5611 # check for utmpx.h, it is missing e.g. on OpenBSD
5613 have_utmpx=no
5614 cat > $TMPC << EOF
5615 #include <utmpx.h>
5616 struct utmpx user_info;
5617 int main(void) {
5618 return 0;
5621 if compile_prog "" "" ; then
5622 have_utmpx=yes
5625 ##########################################
5626 # checks for sanitizers
5628 have_asan=no
5629 have_ubsan=no
5630 have_asan_iface_h=no
5631 have_asan_iface_fiber=no
5633 if test "$sanitizers" = "yes" ; then
5634 write_c_skeleton
5635 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5636 have_asan=yes
5639 # we could use a simple skeleton for flags checks, but this also
5640 # detect the static linking issue of ubsan, see also:
5641 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5642 cat > $TMPC << EOF
5643 #include <stdlib.h>
5644 int main(void) {
5645 void *tmp = malloc(10);
5646 return *(int *)(tmp + 2);
5649 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5650 have_ubsan=yes
5653 if check_include "sanitizer/asan_interface.h" ; then
5654 have_asan_iface_h=yes
5657 cat > $TMPC << EOF
5658 #include <sanitizer/asan_interface.h>
5659 int main(void) {
5660 __sanitizer_start_switch_fiber(0, 0, 0);
5661 return 0;
5664 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5665 have_asan_iface_fiber=yes
5669 ##########################################
5670 # Docker and cross-compiler support
5672 # This is specifically for building test
5673 # cases for foreign architectures, not
5674 # cross-compiling QEMU itself.
5676 if has "docker"; then
5677 docker=$($python $source_path/tests/docker/docker.py probe)
5680 ##########################################
5681 # check for libpmem
5683 if test "$libpmem" != "no"; then
5684 if $pkg_config --exists "libpmem"; then
5685 libpmem="yes"
5686 libpmem_libs=$($pkg_config --libs libpmem)
5687 libpmem_cflags=$($pkg_config --cflags libpmem)
5688 libs_softmmu="$libs_softmmu $libpmem_libs"
5689 QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
5690 else
5691 if test "$libpmem" = "yes" ; then
5692 feature_not_found "libpmem" "Install nvml or pmdk"
5694 libpmem="no"
5698 ##########################################
5699 # End of CC checks
5700 # After here, no more $cc or $ld runs
5702 write_c_skeleton
5704 if test "$gcov" = "yes" ; then
5705 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
5706 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5707 elif test "$fortify_source" = "yes" ; then
5708 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
5709 elif test "$debug" = "no"; then
5710 CFLAGS="-O2 $CFLAGS"
5713 if test "$have_asan" = "yes"; then
5714 CFLAGS="-fsanitize=address $CFLAGS"
5715 if test "$have_asan_iface_h" = "no" ; then
5716 echo "ASAN build enabled, but ASAN header missing." \
5717 "Without code annotation, the report may be inferior."
5718 elif test "$have_asan_iface_fiber" = "no" ; then
5719 echo "ASAN build enabled, but ASAN header is too old." \
5720 "Without code annotation, the report may be inferior."
5723 if test "$have_ubsan" = "yes"; then
5724 CFLAGS="-fsanitize=undefined $CFLAGS"
5727 ##########################################
5728 # Do we have libnfs
5729 if test "$libnfs" != "no" ; then
5730 if $pkg_config --atleast-version=1.9.3 libnfs; then
5731 libnfs="yes"
5732 libnfs_libs=$($pkg_config --libs libnfs)
5733 else
5734 if test "$libnfs" = "yes" ; then
5735 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
5737 libnfs="no"
5741 ##########################################
5742 # Do we have libudev
5743 if test "$libudev" != "no" ; then
5744 if $pkg_config libudev && test "$static" != "yes"; then
5745 libudev="yes"
5746 libudev_libs=$($pkg_config --libs libudev)
5747 else
5748 libudev="no"
5752 # Now we've finished running tests it's OK to add -Werror to the compiler flags
5753 if test "$werror" = "yes"; then
5754 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
5757 if test "$solaris" = "no" ; then
5758 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5759 LDFLAGS="-Wl,--warn-common $LDFLAGS"
5763 # test if pod2man has --utf8 option
5764 if pod2man --help | grep -q utf8; then
5765 POD2MAN="pod2man --utf8"
5766 else
5767 POD2MAN="pod2man"
5770 # Use large addresses, ASLR, no-SEH and DEP if available.
5771 if test "$mingw32" = "yes" ; then
5772 if test "$cpu" = i386; then
5773 LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
5775 for flag in --dynamicbase --no-seh --nxcompat; do
5776 if ld_has $flag ; then
5777 LDFLAGS="-Wl,$flag $LDFLAGS"
5779 done
5782 qemu_confdir=$sysconfdir$confsuffix
5783 qemu_moddir=$libdir$confsuffix
5784 qemu_datadir=$datadir$confsuffix
5785 qemu_localedir="$datadir/locale"
5787 # We can only support ivshmem if we have eventfd
5788 if [ "$eventfd" = "yes" ]; then
5789 ivshmem=yes
5792 tools=""
5793 if test "$want_tools" = "yes" ; then
5794 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
5795 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
5796 tools="qemu-nbd\$(EXESUF) $tools"
5798 if [ "$ivshmem" = "yes" ]; then
5799 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
5801 if [ "$posix" = "yes" ] && [ "$curl" = "yes" ]; then
5802 tools="elf2dmp $tools"
5805 if test "$softmmu" = yes ; then
5806 if test "$linux" = yes; then
5807 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5808 virtfs=yes
5809 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5810 else
5811 if test "$virtfs" = yes; then
5812 error_exit "VirtFS requires libcap devel and libattr devel"
5814 virtfs=no
5816 if test "$mpath" != no && test "$mpathpersist" = yes ; then
5817 mpath=yes
5818 else
5819 if test "$mpath" = yes; then
5820 error_exit "Multipath requires libmpathpersist devel"
5822 mpath=no
5824 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5825 else
5826 if test "$virtfs" = yes; then
5827 error_exit "VirtFS is supported only on Linux"
5829 virtfs=no
5830 if test "$mpath" = yes; then
5831 error_exit "Multipath is supported only on Linux"
5833 mpath=no
5835 if test "$xkbcommon" = "yes"; then
5836 tools="qemu-keymap\$(EXESUF) $tools"
5840 # Probe for guest agent support/options
5842 if [ "$guest_agent" != "no" ]; then
5843 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5844 tools="qemu-ga $tools"
5845 guest_agent=yes
5846 elif [ "$guest_agent" != yes ]; then
5847 guest_agent=no
5848 else
5849 error_exit "Guest agent is not supported on this platform"
5853 # Guest agent Window MSI package
5855 if test "$guest_agent" != yes; then
5856 if test "$guest_agent_msi" = yes; then
5857 error_exit "MSI guest agent package requires guest agent enabled"
5859 guest_agent_msi=no
5860 elif test "$mingw32" != "yes"; then
5861 if test "$guest_agent_msi" = "yes"; then
5862 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
5864 guest_agent_msi=no
5865 elif ! has wixl; then
5866 if test "$guest_agent_msi" = "yes"; then
5867 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
5869 guest_agent_msi=no
5870 else
5871 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
5872 # disabled explicitly
5873 if test "$guest_agent_msi" != "no"; then
5874 guest_agent_msi=yes
5878 if test "$guest_agent_msi" = "yes"; then
5879 if test "$guest_agent_with_vss" = "yes"; then
5880 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
5883 if test "$QEMU_GA_MANUFACTURER" = ""; then
5884 QEMU_GA_MANUFACTURER=QEMU
5887 if test "$QEMU_GA_DISTRO" = ""; then
5888 QEMU_GA_DISTRO=Linux
5891 if test "$QEMU_GA_VERSION" = ""; then
5892 QEMU_GA_VERSION=$(cat $source_path/VERSION)
5895 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
5897 case "$cpu" in
5898 x86_64)
5899 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5901 i386)
5902 QEMU_GA_MSI_ARCH="-D Arch=32"
5905 error_exit "CPU $cpu not supported for building installation package"
5907 esac
5910 # Mac OS X ships with a broken assembler
5911 roms=
5912 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5913 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5914 "$softmmu" = yes ; then
5915 # Different host OS linkers have different ideas about the name of the ELF
5916 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5917 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5918 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5919 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5920 ld_i386_emulation="$emu"
5921 roms="optionrom"
5922 break
5924 done
5926 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
5927 roms="$roms spapr-rtas"
5930 if test "$cpu" = "s390x" ; then
5931 roms="$roms s390-ccw"
5934 # Probe for the need for relocating the user-only binary.
5935 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5936 textseg_addr=
5937 case "$cpu" in
5938 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5939 # ??? Rationale for choosing this address
5940 textseg_addr=0x60000000
5942 mips)
5943 # A 256M aligned address, high in the address space, with enough
5944 # room for the code_gen_buffer above it before the stack.
5945 textseg_addr=0x60000000
5947 esac
5948 if [ -n "$textseg_addr" ]; then
5949 cat > $TMPC <<EOF
5950 int main(void) { return 0; }
5952 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5953 if ! compile_prog "" "$textseg_ldflags"; then
5954 # In case ld does not support -Ttext-segment, edit the default linker
5955 # script via sed to set the .text start addr. This is needed on FreeBSD
5956 # at least.
5957 if ! $ld --verbose >/dev/null 2>&1; then
5958 error_exit \
5959 "We need to link the QEMU user mode binaries at a" \
5960 "specific text address. Unfortunately your linker" \
5961 "doesn't support either the -Ttext-segment option or" \
5962 "printing the default linker script with --verbose." \
5963 "If you don't want the user mode binaries, pass the" \
5964 "--disable-user option to configure."
5967 $ld --verbose | sed \
5968 -e '1,/==================================================/d' \
5969 -e '/==================================================/,$d' \
5970 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5971 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5972 textseg_ldflags="-Wl,-T../config-host.ld"
5977 # Check that the C++ compiler exists and works with the C compiler.
5978 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
5979 if has $cxx; then
5980 cat > $TMPC <<EOF
5981 int c_function(void);
5982 int main(void) { return c_function(); }
5985 compile_object
5987 cat > $TMPCXX <<EOF
5988 extern "C" {
5989 int c_function(void);
5991 int c_function(void) { return 42; }
5994 update_cxxflags
5996 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
5997 # C++ compiler $cxx works ok with C compiler $cc
5999 else
6000 echo "C++ compiler $cxx does not work with C compiler $cc"
6001 echo "Disabling C++ specific optional code"
6002 cxx=
6004 else
6005 echo "No C++ compiler available; disabling C++ specific optional code"
6006 cxx=
6009 echo_version() {
6010 if test "$1" = "yes" ; then
6011 echo "($2)"
6015 # prepend pixman and ftd flags after all config tests are done
6016 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
6017 QEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
6018 libs_softmmu="$pixman_libs $libs_softmmu"
6020 echo "Install prefix $prefix"
6021 echo "BIOS directory $(eval echo $qemu_datadir)"
6022 echo "firmware path $(eval echo $firmwarepath)"
6023 echo "binary directory $(eval echo $bindir)"
6024 echo "library directory $(eval echo $libdir)"
6025 echo "module directory $(eval echo $qemu_moddir)"
6026 echo "libexec directory $(eval echo $libexecdir)"
6027 echo "include directory $(eval echo $includedir)"
6028 echo "config directory $(eval echo $sysconfdir)"
6029 if test "$mingw32" = "no" ; then
6030 echo "local state directory $(eval echo $local_statedir)"
6031 echo "Manual directory $(eval echo $mandir)"
6032 echo "ELF interp prefix $interp_prefix"
6033 else
6034 echo "local state directory queried at runtime"
6035 echo "Windows SDK $win_sdk"
6037 echo "Source path $source_path"
6038 echo "GIT binary $git"
6039 echo "GIT submodules $git_submodules"
6040 echo "C compiler $cc"
6041 echo "Host C compiler $host_cc"
6042 echo "C++ compiler $cxx"
6043 echo "Objective-C compiler $objcc"
6044 echo "ARFLAGS $ARFLAGS"
6045 echo "CFLAGS $CFLAGS"
6046 echo "QEMU_CFLAGS $QEMU_CFLAGS"
6047 echo "LDFLAGS $LDFLAGS"
6048 echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
6049 echo "make $make"
6050 echo "install $install"
6051 echo "python $python"
6052 if test "$slirp" = "yes" ; then
6053 echo "smbd $smbd"
6055 echo "module support $modules"
6056 echo "host CPU $cpu"
6057 echo "host big endian $bigendian"
6058 echo "target list $target_list"
6059 echo "gprof enabled $gprof"
6060 echo "sparse enabled $sparse"
6061 echo "strip binaries $strip_opt"
6062 echo "profiler $profiler"
6063 echo "static build $static"
6064 if test "$darwin" = "yes" ; then
6065 echo "Cocoa support $cocoa"
6067 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
6068 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
6069 echo "GTK GL support $gtk_gl"
6070 echo "VTE support $vte $(echo_version $vte $vteversion)"
6071 echo "TLS priority $tls_priority"
6072 echo "GNUTLS support $gnutls"
6073 echo "libgcrypt $gcrypt"
6074 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
6075 echo "libtasn1 $tasn1"
6076 echo "curses support $curses"
6077 echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6078 echo "curl support $curl"
6079 echo "mingw32 support $mingw32"
6080 echo "Audio drivers $audio_drv_list"
6081 echo "Block whitelist (rw) $block_drv_rw_whitelist"
6082 echo "Block whitelist (ro) $block_drv_ro_whitelist"
6083 echo "VirtFS support $virtfs"
6084 echo "Multipath support $mpath"
6085 echo "VNC support $vnc"
6086 if test "$vnc" = "yes" ; then
6087 echo "VNC SASL support $vnc_sasl"
6088 echo "VNC JPEG support $vnc_jpeg"
6089 echo "VNC PNG support $vnc_png"
6091 if test -n "$sparc_cpu"; then
6092 echo "Target Sparc Arch $sparc_cpu"
6094 echo "xen support $xen"
6095 if test "$xen" = "yes" ; then
6096 echo "xen ctrl version $xen_ctrl_version"
6097 echo "pv dom build $xen_pv_domain_build"
6099 echo "brlapi support $brlapi"
6100 echo "bluez support $bluez"
6101 echo "Documentation $docs"
6102 echo "Tools $tools"
6103 echo "PIE $pie"
6104 echo "vde support $vde"
6105 echo "netmap support $netmap"
6106 echo "Linux AIO support $linux_aio"
6107 echo "(X)ATTR support $attr"
6108 echo "Install blobs $blobs"
6109 echo "KVM support $kvm"
6110 echo "HAX support $hax"
6111 echo "HVF support $hvf"
6112 echo "WHPX support $whpx"
6113 echo "TCG support $tcg"
6114 if test "$tcg" = "yes" ; then
6115 echo "TCG debug enabled $debug_tcg"
6116 echo "TCG interpreter $tcg_interpreter"
6118 echo "malloc trim support $malloc_trim"
6119 echo "RDMA support $rdma"
6120 echo "PVRDMA support $pvrdma"
6121 echo "fdt support $fdt"
6122 echo "membarrier $membarrier"
6123 echo "preadv support $preadv"
6124 echo "fdatasync $fdatasync"
6125 echo "madvise $madvise"
6126 echo "posix_madvise $posix_madvise"
6127 echo "posix_memalign $posix_memalign"
6128 echo "libcap-ng support $cap_ng"
6129 echo "vhost-net support $vhost_net"
6130 echo "vhost-crypto support $vhost_crypto"
6131 echo "vhost-scsi support $vhost_scsi"
6132 echo "vhost-vsock support $vhost_vsock"
6133 echo "vhost-user support $vhost_user"
6134 echo "Trace backends $trace_backends"
6135 if have_backend "simple"; then
6136 echo "Trace output file $trace_file-<pid>"
6138 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6139 echo "rbd support $rbd"
6140 echo "xfsctl support $xfs"
6141 echo "smartcard support $smartcard"
6142 echo "libusb $libusb"
6143 echo "usb net redir $usb_redir"
6144 echo "OpenGL support $opengl"
6145 echo "OpenGL dmabufs $opengl_dmabuf"
6146 echo "libiscsi support $libiscsi"
6147 echo "libnfs support $libnfs"
6148 echo "build guest agent $guest_agent"
6149 echo "QGA VSS support $guest_agent_with_vss"
6150 echo "QGA w32 disk info $guest_agent_ntddscsi"
6151 echo "QGA MSI support $guest_agent_msi"
6152 echo "seccomp support $seccomp"
6153 echo "coroutine backend $coroutine"
6154 echo "coroutine pool $coroutine_pool"
6155 echo "debug stack usage $debug_stack_usage"
6156 echo "mutex debugging $debug_mutex"
6157 echo "crypto afalg $crypto_afalg"
6158 echo "GlusterFS support $glusterfs"
6159 echo "gcov $gcov_tool"
6160 echo "gcov enabled $gcov"
6161 echo "TPM support $tpm"
6162 echo "libssh2 support $libssh2"
6163 echo "TPM passthrough $tpm_passthrough"
6164 echo "TPM emulator $tpm_emulator"
6165 echo "QOM debugging $qom_cast_debug"
6166 echo "Live block migration $live_block_migration"
6167 echo "lzo support $lzo"
6168 echo "snappy support $snappy"
6169 echo "bzip2 support $bzip2"
6170 echo "lzfse support $lzfse"
6171 echo "NUMA host support $numa"
6172 echo "libxml2 $libxml2"
6173 echo "tcmalloc support $tcmalloc"
6174 echo "jemalloc support $jemalloc"
6175 echo "avx2 optimization $avx2_opt"
6176 echo "replication support $replication"
6177 echo "VxHS block device $vxhs"
6178 echo "bochs support $bochs"
6179 echo "cloop support $cloop"
6180 echo "dmg support $dmg"
6181 echo "qcow v1 support $qcow1"
6182 echo "vdi support $vdi"
6183 echo "vvfat support $vvfat"
6184 echo "qed support $qed"
6185 echo "parallels support $parallels"
6186 echo "sheepdog support $sheepdog"
6187 echo "capstone $capstone"
6188 echo "docker $docker"
6189 echo "libpmem support $libpmem"
6190 echo "libudev $libudev"
6192 if test "$sdl_too_old" = "yes"; then
6193 echo "-> Your SDL version is too old - please upgrade to have SDL support"
6196 if test "$sdlabi" = "1.2"; then
6197 echo
6198 echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
6199 echo "WARNING: future releases. Please switch to using SDL 2.0"
6202 if test "$supported_cpu" = "no"; then
6203 echo
6204 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6205 echo
6206 echo "CPU host architecture $cpu support is not currently maintained."
6207 echo "The QEMU project intends to remove support for this host CPU in"
6208 echo "a future release if nobody volunteers to maintain it and to"
6209 echo "provide a build host for our continuous integration setup."
6210 echo "configure has succeeded and you can continue to build, but"
6211 echo "if you care about QEMU on this platform you should contact"
6212 echo "us upstream at qemu-devel@nongnu.org."
6215 if test "$supported_os" = "no"; then
6216 echo
6217 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6218 echo
6219 echo "Host OS $targetos support is not currently maintained."
6220 echo "The QEMU project intends to remove support for this host OS in"
6221 echo "a future release if nobody volunteers to maintain it and to"
6222 echo "provide a build host for our continuous integration setup."
6223 echo "configure has succeeded and you can continue to build, but"
6224 echo "if you care about QEMU on this platform you should contact"
6225 echo "us upstream at qemu-devel@nongnu.org."
6228 config_host_mak="config-host.mak"
6230 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
6232 echo "# Automatically generated by configure - do not modify" > $config_host_mak
6233 echo >> $config_host_mak
6235 echo all: >> $config_host_mak
6236 echo "prefix=$prefix" >> $config_host_mak
6237 echo "bindir=$bindir" >> $config_host_mak
6238 echo "libdir=$libdir" >> $config_host_mak
6239 echo "libexecdir=$libexecdir" >> $config_host_mak
6240 echo "includedir=$includedir" >> $config_host_mak
6241 echo "mandir=$mandir" >> $config_host_mak
6242 echo "sysconfdir=$sysconfdir" >> $config_host_mak
6243 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
6244 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
6245 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
6246 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
6247 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
6248 if test "$mingw32" = "no" ; then
6249 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
6251 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
6252 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
6253 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
6254 echo "GIT=$git" >> $config_host_mak
6255 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6256 echo "GIT_UPDATE=$git_update" >> $config_host_mak
6258 echo "ARCH=$ARCH" >> $config_host_mak
6260 if test "$debug_tcg" = "yes" ; then
6261 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6263 if test "$strip_opt" = "yes" ; then
6264 echo "STRIP=${strip}" >> $config_host_mak
6266 if test "$bigendian" = "yes" ; then
6267 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
6269 if test "$mingw32" = "yes" ; then
6270 echo "CONFIG_WIN32=y" >> $config_host_mak
6271 echo "CONFIG_INSTALLER=y" >> $config_host_mak
6272 rc_version=$(cat $source_path/VERSION)
6273 version_major=${rc_version%%.*}
6274 rc_version=${rc_version#*.}
6275 version_minor=${rc_version%%.*}
6276 rc_version=${rc_version#*.}
6277 version_subminor=${rc_version%%.*}
6278 version_micro=0
6279 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6280 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6281 if test "$guest_agent_with_vss" = "yes" ; then
6282 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6283 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6284 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6286 if test "$guest_agent_ntddscsi" = "yes" ; then
6287 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
6289 if test "$guest_agent_msi" = "yes"; then
6290 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
6291 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
6292 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
6293 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
6294 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
6295 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
6296 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
6298 else
6299 echo "CONFIG_POSIX=y" >> $config_host_mak
6302 if test "$linux" = "yes" ; then
6303 echo "CONFIG_LINUX=y" >> $config_host_mak
6306 if test "$darwin" = "yes" ; then
6307 echo "CONFIG_DARWIN=y" >> $config_host_mak
6310 if test "$solaris" = "yes" ; then
6311 echo "CONFIG_SOLARIS=y" >> $config_host_mak
6313 if test "$haiku" = "yes" ; then
6314 echo "CONFIG_HAIKU=y" >> $config_host_mak
6316 if test "$static" = "yes" ; then
6317 echo "CONFIG_STATIC=y" >> $config_host_mak
6319 if test "$profiler" = "yes" ; then
6320 echo "CONFIG_PROFILER=y" >> $config_host_mak
6322 if test "$slirp" = "yes" ; then
6323 echo "CONFIG_SLIRP=y" >> $config_host_mak
6324 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6326 if test "$vde" = "yes" ; then
6327 echo "CONFIG_VDE=y" >> $config_host_mak
6328 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
6330 if test "$netmap" = "yes" ; then
6331 echo "CONFIG_NETMAP=y" >> $config_host_mak
6333 if test "$l2tpv3" = "yes" ; then
6334 echo "CONFIG_L2TPV3=y" >> $config_host_mak
6336 if test "$cap_ng" = "yes" ; then
6337 echo "CONFIG_LIBCAP=y" >> $config_host_mak
6339 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
6340 for drv in $audio_drv_list; do
6341 def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6342 case "$drv" in
6343 alsa | oss | pa | sdl)
6344 echo "$def=m" >> $config_host_mak ;;
6346 echo "$def=y" >> $config_host_mak ;;
6347 esac
6348 done
6349 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6350 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6351 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6352 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6353 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
6354 if test "$audio_pt_int" = "yes" ; then
6355 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
6357 if test "$audio_win_int" = "yes" ; then
6358 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6360 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6361 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6362 if test "$vnc" = "yes" ; then
6363 echo "CONFIG_VNC=y" >> $config_host_mak
6365 if test "$vnc_sasl" = "yes" ; then
6366 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
6368 if test "$vnc_jpeg" = "yes" ; then
6369 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
6371 if test "$vnc_png" = "yes" ; then
6372 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6374 if test "$xkbcommon" = "yes" ; then
6375 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
6376 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
6378 if test "$fnmatch" = "yes" ; then
6379 echo "CONFIG_FNMATCH=y" >> $config_host_mak
6381 if test "$xfs" = "yes" ; then
6382 echo "CONFIG_XFS=y" >> $config_host_mak
6384 qemu_version=$(head $source_path/VERSION)
6385 echo "VERSION=$qemu_version" >>$config_host_mak
6386 echo "PKGVERSION=$pkgversion" >>$config_host_mak
6387 echo "SRC_PATH=$source_path" >> $config_host_mak
6388 echo "TARGET_DIRS=$target_list" >> $config_host_mak
6389 if [ "$docs" = "yes" ] ; then
6390 echo "BUILD_DOCS=yes" >> $config_host_mak
6392 if [ "$want_tools" = "yes" ] ; then
6393 echo "BUILD_TOOLS=yes" >> $config_host_mak
6395 if test "$modules" = "yes"; then
6396 # $shacmd can generate a hash started with digit, which the compiler doesn't
6397 # like as an symbol. So prefix it with an underscore
6398 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
6399 echo "CONFIG_MODULES=y" >> $config_host_mak
6401 if test "$have_x11" = "yes" -a "$need_x11" = "yes"; then
6402 echo "CONFIG_X11=y" >> $config_host_mak
6403 echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
6404 echo "X11_LIBS=$x11_libs" >> $config_host_mak
6406 if test "$sdl" = "yes" ; then
6407 echo "CONFIG_SDL=m" >> $config_host_mak
6408 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
6409 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
6410 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
6412 if test "$cocoa" = "yes" ; then
6413 echo "CONFIG_COCOA=y" >> $config_host_mak
6415 if test "$curses" = "yes" ; then
6416 echo "CONFIG_CURSES=m" >> $config_host_mak
6417 echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
6418 echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6420 if test "$pipe2" = "yes" ; then
6421 echo "CONFIG_PIPE2=y" >> $config_host_mak
6423 if test "$accept4" = "yes" ; then
6424 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
6426 if test "$splice" = "yes" ; then
6427 echo "CONFIG_SPLICE=y" >> $config_host_mak
6429 if test "$eventfd" = "yes" ; then
6430 echo "CONFIG_EVENTFD=y" >> $config_host_mak
6432 if test "$memfd" = "yes" ; then
6433 echo "CONFIG_MEMFD=y" >> $config_host_mak
6435 if test "$have_usbfs" = "yes" ; then
6436 echo "CONFIG_USBFS=y" >> $config_host_mak
6438 if test "$fallocate" = "yes" ; then
6439 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6441 if test "$fallocate_punch_hole" = "yes" ; then
6442 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
6444 if test "$fallocate_zero_range" = "yes" ; then
6445 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6447 if test "$posix_fallocate" = "yes" ; then
6448 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6450 if test "$sync_file_range" = "yes" ; then
6451 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6453 if test "$fiemap" = "yes" ; then
6454 echo "CONFIG_FIEMAP=y" >> $config_host_mak
6456 if test "$dup3" = "yes" ; then
6457 echo "CONFIG_DUP3=y" >> $config_host_mak
6459 if test "$ppoll" = "yes" ; then
6460 echo "CONFIG_PPOLL=y" >> $config_host_mak
6462 if test "$prctl_pr_set_timerslack" = "yes" ; then
6463 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6465 if test "$epoll" = "yes" ; then
6466 echo "CONFIG_EPOLL=y" >> $config_host_mak
6468 if test "$epoll_create1" = "yes" ; then
6469 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
6471 if test "$sendfile" = "yes" ; then
6472 echo "CONFIG_SENDFILE=y" >> $config_host_mak
6474 if test "$timerfd" = "yes" ; then
6475 echo "CONFIG_TIMERFD=y" >> $config_host_mak
6477 if test "$setns" = "yes" ; then
6478 echo "CONFIG_SETNS=y" >> $config_host_mak
6480 if test "$clock_adjtime" = "yes" ; then
6481 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
6483 if test "$syncfs" = "yes" ; then
6484 echo "CONFIG_SYNCFS=y" >> $config_host_mak
6486 if test "$inotify" = "yes" ; then
6487 echo "CONFIG_INOTIFY=y" >> $config_host_mak
6489 if test "$inotify1" = "yes" ; then
6490 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6492 if test "$sem_timedwait" = "yes" ; then
6493 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6495 if test "$strchrnul" = "yes" ; then
6496 echo "HAVE_STRCHRNUL=y" >> $config_host_mak
6498 if test "$byteswap_h" = "yes" ; then
6499 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
6501 if test "$bswap_h" = "yes" ; then
6502 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
6504 if test "$curl" = "yes" ; then
6505 echo "CONFIG_CURL=m" >> $config_host_mak
6506 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6507 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6509 if test "$brlapi" = "yes" ; then
6510 echo "CONFIG_BRLAPI=y" >> $config_host_mak
6511 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
6513 if test "$bluez" = "yes" ; then
6514 echo "CONFIG_BLUEZ=y" >> $config_host_mak
6515 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6517 if test "$gtk" = "yes" ; then
6518 echo "CONFIG_GTK=m" >> $config_host_mak
6519 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6520 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6521 if test "$gtk_gl" = "yes" ; then
6522 echo "CONFIG_GTK_GL=y" >> $config_host_mak
6525 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6526 if test "$gnutls" = "yes" ; then
6527 echo "CONFIG_GNUTLS=y" >> $config_host_mak
6529 if test "$gcrypt" = "yes" ; then
6530 echo "CONFIG_GCRYPT=y" >> $config_host_mak
6531 if test "$gcrypt_hmac" = "yes" ; then
6532 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
6535 if test "$nettle" = "yes" ; then
6536 echo "CONFIG_NETTLE=y" >> $config_host_mak
6537 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6539 if test "$tasn1" = "yes" ; then
6540 echo "CONFIG_TASN1=y" >> $config_host_mak
6542 if test "$have_ifaddrs_h" = "yes" ; then
6543 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6545 if test "$have_broken_size_max" = "yes" ; then
6546 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
6549 # Work around a system header bug with some kernel/XFS header
6550 # versions where they both try to define 'struct fsxattr':
6551 # xfs headers will not try to redefine structs from linux headers
6552 # if this macro is set.
6553 if test "$have_fsxattr" = "yes" ; then
6554 echo "HAVE_FSXATTR=y" >> $config_host_mak
6556 if test "$have_copy_file_range" = "yes" ; then
6557 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
6559 if test "$vte" = "yes" ; then
6560 echo "CONFIG_VTE=y" >> $config_host_mak
6561 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6562 echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6564 if test "$virglrenderer" = "yes" ; then
6565 echo "CONFIG_VIRGL=y" >> $config_host_mak
6566 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
6567 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
6569 if test "$xen" = "yes" ; then
6570 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6571 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6572 if test "$xen_pv_domain_build" = "yes" ; then
6573 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
6576 if test "$linux_aio" = "yes" ; then
6577 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
6579 if test "$attr" = "yes" ; then
6580 echo "CONFIG_ATTR=y" >> $config_host_mak
6582 if test "$libattr" = "yes" ; then
6583 echo "CONFIG_LIBATTR=y" >> $config_host_mak
6585 if test "$virtfs" = "yes" ; then
6586 echo "CONFIG_VIRTFS=y" >> $config_host_mak
6588 if test "$mpath" = "yes" ; then
6589 echo "CONFIG_MPATH=y" >> $config_host_mak
6590 if test "$mpathpersist_new_api" = "yes"; then
6591 echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
6594 if test "$vhost_scsi" = "yes" ; then
6595 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
6597 if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
6598 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
6600 if test "$vhost_crypto" = "yes" ; then
6601 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6603 if test "$vhost_vsock" = "yes" ; then
6604 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6606 if test "$vhost_user" = "yes" ; then
6607 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6609 if test "$blobs" = "yes" ; then
6610 echo "INSTALL_BLOBS=yes" >> $config_host_mak
6612 if test "$iovec" = "yes" ; then
6613 echo "CONFIG_IOVEC=y" >> $config_host_mak
6615 if test "$preadv" = "yes" ; then
6616 echo "CONFIG_PREADV=y" >> $config_host_mak
6618 if test "$fdt" != "no" ; then
6619 echo "CONFIG_FDT=y" >> $config_host_mak
6621 if test "$membarrier" = "yes" ; then
6622 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6624 if test "$signalfd" = "yes" ; then
6625 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6627 if test "$tcg" = "yes"; then
6628 echo "CONFIG_TCG=y" >> $config_host_mak
6629 if test "$tcg_interpreter" = "yes" ; then
6630 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
6633 if test "$fdatasync" = "yes" ; then
6634 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
6636 if test "$madvise" = "yes" ; then
6637 echo "CONFIG_MADVISE=y" >> $config_host_mak
6639 if test "$posix_madvise" = "yes" ; then
6640 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6642 if test "$posix_memalign" = "yes" ; then
6643 echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
6646 if test "$spice" = "yes" ; then
6647 echo "CONFIG_SPICE=y" >> $config_host_mak
6650 if test "$smartcard" = "yes" ; then
6651 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
6652 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
6653 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6656 if test "$libusb" = "yes" ; then
6657 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6658 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6659 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
6662 if test "$usb_redir" = "yes" ; then
6663 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6664 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6665 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
6668 if test "$opengl" = "yes" ; then
6669 echo "CONFIG_OPENGL=y" >> $config_host_mak
6670 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6671 if test "$opengl_dmabuf" = "yes" ; then
6672 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6676 if test "$malloc_trim" = "yes" ; then
6677 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
6680 if test "$avx2_opt" = "yes" ; then
6681 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
6684 if test "$lzo" = "yes" ; then
6685 echo "CONFIG_LZO=y" >> $config_host_mak
6688 if test "$snappy" = "yes" ; then
6689 echo "CONFIG_SNAPPY=y" >> $config_host_mak
6692 if test "$bzip2" = "yes" ; then
6693 echo "CONFIG_BZIP2=y" >> $config_host_mak
6694 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
6697 if test "$lzfse" = "yes" ; then
6698 echo "CONFIG_LZFSE=y" >> $config_host_mak
6699 echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
6702 if test "$libiscsi" = "yes" ; then
6703 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6704 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
6705 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6708 if test "$libnfs" = "yes" ; then
6709 echo "CONFIG_LIBNFS=m" >> $config_host_mak
6710 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6713 if test "$seccomp" = "yes"; then
6714 echo "CONFIG_SECCOMP=y" >> $config_host_mak
6715 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6716 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6719 # XXX: suppress that
6720 if [ "$bsd" = "yes" ] ; then
6721 echo "CONFIG_BSD=y" >> $config_host_mak
6724 if test "$localtime_r" = "yes" ; then
6725 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
6727 if test "$qom_cast_debug" = "yes" ; then
6728 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
6730 if test "$rbd" = "yes" ; then
6731 echo "CONFIG_RBD=m" >> $config_host_mak
6732 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
6733 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6736 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
6737 if test "$coroutine_pool" = "yes" ; then
6738 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
6739 else
6740 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
6743 if test "$debug_stack_usage" = "yes" ; then
6744 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
6747 if test "$crypto_afalg" = "yes" ; then
6748 echo "CONFIG_AF_ALG=y" >> $config_host_mak
6751 if test "$open_by_handle_at" = "yes" ; then
6752 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6755 if test "$linux_magic_h" = "yes" ; then
6756 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6759 if test "$pragma_diagnostic_available" = "yes" ; then
6760 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
6763 if test "$valgrind_h" = "yes" ; then
6764 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
6767 if test "$have_asan_iface_fiber" = "yes" ; then
6768 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6771 if test "$has_environ" = "yes" ; then
6772 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
6775 if test "$cpuid_h" = "yes" ; then
6776 echo "CONFIG_CPUID_H=y" >> $config_host_mak
6779 if test "$int128" = "yes" ; then
6780 echo "CONFIG_INT128=y" >> $config_host_mak
6783 if test "$atomic128" = "yes" ; then
6784 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
6787 if test "$cmpxchg128" = "yes" ; then
6788 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
6791 if test "$atomic64" = "yes" ; then
6792 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6795 if test "$vector16" = "yes" ; then
6796 echo "CONFIG_VECTOR16=y" >> $config_host_mak
6799 if test "$getauxval" = "yes" ; then
6800 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
6803 if test "$glusterfs" = "yes" ; then
6804 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6805 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
6806 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6809 if test "$glusterfs_xlator_opt" = "yes" ; then
6810 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6813 if test "$glusterfs_discard" = "yes" ; then
6814 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
6817 if test "$glusterfs_fallocate" = "yes" ; then
6818 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6821 if test "$glusterfs_zerofill" = "yes" ; then
6822 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
6825 if test "$libssh2" = "yes" ; then
6826 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6827 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
6828 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
6831 if test "$live_block_migration" = "yes" ; then
6832 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6835 if test "$tpm" = "yes"; then
6836 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6837 # TPM passthrough support?
6838 if test "$tpm_passthrough" = "yes"; then
6839 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
6841 # TPM emulator support?
6842 if test "$tpm_emulator" = "yes"; then
6843 echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6847 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
6848 if have_backend "nop"; then
6849 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
6851 if have_backend "simple"; then
6852 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
6853 # Set the appropriate trace file.
6854 trace_file="\"$trace_file-\" FMT_pid"
6856 if have_backend "log"; then
6857 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6859 if have_backend "ust"; then
6860 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6862 if have_backend "dtrace"; then
6863 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
6864 if test "$trace_backend_stap" = "yes" ; then
6865 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
6868 if have_backend "ftrace"; then
6869 if test "$linux" = "yes" ; then
6870 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6871 else
6872 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6875 if have_backend "syslog"; then
6876 if test "$posix_syslog" = "yes" ; then
6877 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
6878 else
6879 feature_not_found "syslog(trace backend)" "syslog not available"
6882 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
6884 if test "$rdma" = "yes" ; then
6885 echo "CONFIG_RDMA=y" >> $config_host_mak
6886 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
6889 if test "$pvrdma" = "yes" ; then
6890 echo "CONFIG_PVRDMA=y" >> $config_host_mak
6893 if test "$have_rtnetlink" = "yes" ; then
6894 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6897 if test "$libxml2" = "yes" ; then
6898 echo "CONFIG_LIBXML2=y" >> $config_host_mak
6899 echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6900 echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6903 if test "$replication" = "yes" ; then
6904 echo "CONFIG_REPLICATION=y" >> $config_host_mak
6907 if test "$have_af_vsock" = "yes" ; then
6908 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
6911 if test "$have_sysmacros" = "yes" ; then
6912 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
6915 if test "$have_static_assert" = "yes" ; then
6916 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
6919 if test "$have_utmpx" = "yes" ; then
6920 echo "HAVE_UTMPX=y" >> $config_host_mak
6923 if test "$ivshmem" = "yes" ; then
6924 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6926 if test "$capstone" != "no" ; then
6927 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
6929 if test "$debug_mutex" = "yes" ; then
6930 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6933 # Hold two types of flag:
6934 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
6935 # a thread we have a handle to
6936 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
6937 # platform
6938 if test "$pthread_setname_np" = "yes" ; then
6939 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6940 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
6943 if test "$vxhs" = "yes" ; then
6944 echo "CONFIG_VXHS=y" >> $config_host_mak
6945 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6948 if test "$libpmem" = "yes" ; then
6949 echo "CONFIG_LIBPMEM=y" >> $config_host_mak
6952 if test "$bochs" = "yes" ; then
6953 echo "CONFIG_BOCHS=y" >> $config_host_mak
6955 if test "$cloop" = "yes" ; then
6956 echo "CONFIG_CLOOP=y" >> $config_host_mak
6958 if test "$dmg" = "yes" ; then
6959 echo "CONFIG_DMG=y" >> $config_host_mak
6961 if test "$qcow1" = "yes" ; then
6962 echo "CONFIG_QCOW1=y" >> $config_host_mak
6964 if test "$vdi" = "yes" ; then
6965 echo "CONFIG_VDI=y" >> $config_host_mak
6967 if test "$vvfat" = "yes" ; then
6968 echo "CONFIG_VVFAT=y" >> $config_host_mak
6970 if test "$qed" = "yes" ; then
6971 echo "CONFIG_QED=y" >> $config_host_mak
6973 if test "$parallels" = "yes" ; then
6974 echo "CONFIG_PARALLELS=y" >> $config_host_mak
6976 if test "$sheepdog" = "yes" ; then
6977 echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
6980 if test "$tcg_interpreter" = "yes"; then
6981 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
6982 elif test "$ARCH" = "sparc64" ; then
6983 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
6984 elif test "$ARCH" = "s390x" ; then
6985 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6986 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
6987 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
6988 elif test "$ARCH" = "ppc64" ; then
6989 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
6990 else
6991 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
6993 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
6995 echo "TOOLS=$tools" >> $config_host_mak
6996 echo "ROMS=$roms" >> $config_host_mak
6997 echo "MAKE=$make" >> $config_host_mak
6998 echo "INSTALL=$install" >> $config_host_mak
6999 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
7000 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
7001 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
7002 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7003 echo "PYTHON=$python" >> $config_host_mak
7004 echo "CC=$cc" >> $config_host_mak
7005 if $iasl -h > /dev/null 2>&1; then
7006 echo "IASL=$iasl" >> $config_host_mak
7008 echo "HOST_CC=$host_cc" >> $config_host_mak
7009 echo "CXX=$cxx" >> $config_host_mak
7010 echo "OBJCC=$objcc" >> $config_host_mak
7011 echo "AR=$ar" >> $config_host_mak
7012 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
7013 echo "AS=$as" >> $config_host_mak
7014 echo "CCAS=$ccas" >> $config_host_mak
7015 echo "CPP=$cpp" >> $config_host_mak
7016 echo "OBJCOPY=$objcopy" >> $config_host_mak
7017 echo "LD=$ld" >> $config_host_mak
7018 echo "RANLIB=$ranlib" >> $config_host_mak
7019 echo "NM=$nm" >> $config_host_mak
7020 echo "WINDRES=$windres" >> $config_host_mak
7021 echo "CFLAGS=$CFLAGS" >> $config_host_mak
7022 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7023 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
7024 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7025 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7026 if test "$sparse" = "yes" ; then
7027 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
7028 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
7029 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
7030 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
7031 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7033 if test "$cross_prefix" != ""; then
7034 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
7035 else
7036 echo "AUTOCONF_HOST := " >> $config_host_mak
7038 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
7039 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
7040 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
7041 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7042 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
7043 echo "LIBS+=$LIBS" >> $config_host_mak
7044 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7045 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7046 echo "EXESUF=$EXESUF" >> $config_host_mak
7047 echo "DSOSUF=$DSOSUF" >> $config_host_mak
7048 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7049 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
7050 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
7051 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
7052 echo "POD2MAN=$POD2MAN" >> $config_host_mak
7053 if test "$gcov" = "yes" ; then
7054 echo "CONFIG_GCOV=y" >> $config_host_mak
7055 echo "GCOV=$gcov_tool" >> $config_host_mak
7058 if test "$docker" != "no"; then
7059 echo "HAVE_USER_DOCKER=y" >> $config_host_mak
7062 if test "$libudev" != "no"; then
7063 echo "CONFIG_LIBUDEV=y" >> $config_host_mak
7064 echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
7067 # use included Linux headers
7068 if test "$linux" = "yes" ; then
7069 mkdir -p linux-headers
7070 case "$cpu" in
7071 i386|x86_64|x32)
7072 linux_arch=x86
7074 ppc|ppc64)
7075 linux_arch=powerpc
7077 s390x)
7078 linux_arch=s390
7080 aarch64)
7081 linux_arch=arm64
7083 mips64)
7084 linux_arch=mips
7087 # For most CPUs the kernel architecture name and QEMU CPU name match.
7088 linux_arch="$cpu"
7090 esac
7091 # For non-KVM architectures we will not have asm headers
7092 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
7093 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
7097 for target in $target_list; do
7098 target_dir="$target"
7099 config_target_mak=$target_dir/config-target.mak
7100 target_name=$(echo $target | cut -d '-' -f 1)
7101 target_bigendian="no"
7103 case "$target_name" in
7104 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
7105 target_bigendian=yes
7107 esac
7108 target_softmmu="no"
7109 target_user_only="no"
7110 target_linux_user="no"
7111 target_bsd_user="no"
7112 case "$target" in
7113 ${target_name}-softmmu)
7114 target_softmmu="yes"
7116 ${target_name}-linux-user)
7117 target_user_only="yes"
7118 target_linux_user="yes"
7120 ${target_name}-bsd-user)
7121 target_user_only="yes"
7122 target_bsd_user="yes"
7125 error_exit "Target '$target' not recognised"
7126 exit 1
7128 esac
7130 target_compiler=""
7131 target_compiler_static=""
7132 target_compiler_cflags=""
7134 mkdir -p $target_dir
7135 echo "# Automatically generated by configure - do not modify" > $config_target_mak
7137 bflt="no"
7138 mttcg="no"
7139 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
7140 gdb_xml_files=""
7142 TARGET_ARCH="$target_name"
7143 TARGET_BASE_ARCH=""
7144 TARGET_ABI_DIR=""
7146 case "$target_name" in
7147 i386)
7148 mttcg="yes"
7149 gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
7150 target_compiler=$cross_cc_i386
7151 target_compiler_cflags=$cross_cc_ccflags_i386
7153 x86_64)
7154 TARGET_BASE_ARCH=i386
7155 mttcg="yes"
7156 gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
7157 target_compiler=$cross_cc_x86_64
7159 alpha)
7160 mttcg="yes"
7161 target_compiler=$cross_cc_alpha
7163 arm|armeb)
7164 TARGET_ARCH=arm
7165 bflt="yes"
7166 mttcg="yes"
7167 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7168 target_compiler=$cross_cc_arm
7169 eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
7171 aarch64|aarch64_be)
7172 TARGET_ARCH=aarch64
7173 TARGET_BASE_ARCH=arm
7174 bflt="yes"
7175 mttcg="yes"
7176 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7177 target_compiler=$cross_cc_aarch64
7178 eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
7180 cris)
7181 target_compiler=$cross_cc_cris
7183 hppa)
7184 mttcg="yes"
7185 target_compiler=$cross_cc_hppa
7187 lm32)
7188 target_compiler=$cross_cc_lm32
7190 m68k)
7191 bflt="yes"
7192 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
7193 target_compiler=$cross_cc_m68k
7195 microblaze|microblazeel)
7196 TARGET_ARCH=microblaze
7197 bflt="yes"
7198 echo "TARGET_ABI32=y" >> $config_target_mak
7199 target_compiler=$cross_cc_microblaze
7201 mips|mipsel)
7202 TARGET_ARCH=mips
7203 target_compiler=$cross_cc_mips
7204 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
7206 mipsn32|mipsn32el)
7207 TARGET_ARCH=mips64
7208 TARGET_BASE_ARCH=mips
7209 target_compiler=$cross_cc_mipsn32
7210 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7211 echo "TARGET_ABI32=y" >> $config_target_mak
7213 mips64|mips64el)
7214 TARGET_ARCH=mips64
7215 TARGET_BASE_ARCH=mips
7216 target_compiler=$cross_cc_mips64
7217 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
7219 moxie)
7220 target_compiler=$cross_cc_moxie
7222 nios2)
7223 target_compiler=$cross_cc_nios2
7225 or1k)
7226 target_compiler=$cross_cc_or1k
7227 TARGET_ARCH=openrisc
7228 TARGET_BASE_ARCH=openrisc
7230 ppc)
7231 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7232 target_compiler=$cross_cc_powerpc
7234 ppc64)
7235 TARGET_BASE_ARCH=ppc
7236 TARGET_ABI_DIR=ppc
7237 mttcg=yes
7238 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7239 target_compiler=$cross_cc_ppc64
7241 ppc64le)
7242 TARGET_ARCH=ppc64
7243 TARGET_BASE_ARCH=ppc
7244 TARGET_ABI_DIR=ppc
7245 mttcg=yes
7246 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7247 target_compiler=$cross_cc_ppc64le
7249 ppc64abi32)
7250 TARGET_ARCH=ppc64
7251 TARGET_BASE_ARCH=ppc
7252 TARGET_ABI_DIR=ppc
7253 echo "TARGET_ABI32=y" >> $config_target_mak
7254 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7255 target_compiler=$cross_cc_ppc64abi32
7257 riscv32)
7258 TARGET_BASE_ARCH=riscv
7259 TARGET_ABI_DIR=riscv
7260 mttcg=yes
7261 target_compiler=$cross_cc_riscv32
7263 riscv64)
7264 TARGET_BASE_ARCH=riscv
7265 TARGET_ABI_DIR=riscv
7266 mttcg=yes
7267 target_compiler=$cross_cc_riscv64
7269 sh4|sh4eb)
7270 TARGET_ARCH=sh4
7271 bflt="yes"
7272 target_compiler=$cross_cc_sh4
7274 sparc)
7275 target_compiler=$cross_cc_sparc
7277 sparc64)
7278 TARGET_BASE_ARCH=sparc
7279 target_compiler=$cross_cc_sparc64
7281 sparc32plus)
7282 TARGET_ARCH=sparc64
7283 TARGET_BASE_ARCH=sparc
7284 TARGET_ABI_DIR=sparc
7285 target_compiler=$cross_cc_sparc32plus
7286 echo "TARGET_ABI32=y" >> $config_target_mak
7288 s390x)
7289 mttcg=yes
7290 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
7291 target_compiler=$cross_cc_s390x
7293 tilegx)
7294 target_compiler=$cross_cc_tilegx
7296 tricore)
7297 target_compiler=$cross_cc_tricore
7299 unicore32)
7300 target_compiler=$cross_cc_unicore32
7302 xtensa|xtensaeb)
7303 TARGET_ARCH=xtensa
7304 bflt="yes"
7305 mttcg="yes"
7306 target_compiler=$cross_cc_xtensa
7309 error_exit "Unsupported target CPU"
7311 esac
7312 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
7313 if [ "$TARGET_BASE_ARCH" = "" ]; then
7314 TARGET_BASE_ARCH=$TARGET_ARCH
7317 # Do we have a cross compiler for this target?
7318 if has $target_compiler; then
7320 write_c_skeleton
7322 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
7323 # For host systems we might get away with building without -static
7324 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
7325 target_compiler=""
7326 else
7327 enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7328 target_compiler_static="n"
7330 else
7331 enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7332 target_compiler_static="y"
7334 else
7335 target_compiler=""
7338 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
7340 upper() {
7341 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
7344 target_arch_name="$(upper $TARGET_ARCH)"
7345 echo "TARGET_$target_arch_name=y" >> $config_target_mak
7346 echo "TARGET_NAME=$target_name" >> $config_target_mak
7347 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7348 if [ "$TARGET_ABI_DIR" = "" ]; then
7349 TARGET_ABI_DIR=$TARGET_ARCH
7351 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7352 if [ "$HOST_VARIANT_DIR" != "" ]; then
7353 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7356 if supported_xen_target $target; then
7357 echo "CONFIG_XEN=y" >> $config_target_mak
7358 if test "$xen_pci_passthrough" = yes; then
7359 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7362 if supported_kvm_target $target; then
7363 echo "CONFIG_KVM=y" >> $config_target_mak
7364 if test "$vhost_net" = "yes" ; then
7365 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
7366 if test "$vhost_user" = "yes" ; then
7367 echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
7371 if supported_hax_target $target; then
7372 echo "CONFIG_HAX=y" >> $config_target_mak
7374 if supported_hvf_target $target; then
7375 echo "CONFIG_HVF=y" >> $config_target_mak
7377 if supported_whpx_target $target; then
7378 echo "CONFIG_WHPX=y" >> $config_target_mak
7380 if test "$target_bigendian" = "yes" ; then
7381 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
7383 if test "$target_softmmu" = "yes" ; then
7384 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7385 if test "$mttcg" = "yes" ; then
7386 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7389 if test "$target_user_only" = "yes" ; then
7390 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7391 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7393 if test "$target_linux_user" = "yes" ; then
7394 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7396 list=""
7397 if test ! -z "$gdb_xml_files" ; then
7398 for x in $gdb_xml_files; do
7399 list="$list $source_path/gdb-xml/$x"
7400 done
7401 echo "TARGET_XML_FILES=$list" >> $config_target_mak
7404 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
7405 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7407 if test "$target_bsd_user" = "yes" ; then
7408 echo "CONFIG_BSD_USER=y" >> $config_target_mak
7411 if test -n "$target_compiler"; then
7412 echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7414 if test -n "$target_compiler_static"; then
7415 echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7418 if test -n "$target_compiler_cflags"; then
7419 echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
7424 # generate QEMU_CFLAGS/LDFLAGS for targets
7426 cflags=""
7427 ldflags=""
7429 disas_config() {
7430 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7431 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7434 for i in $ARCH $TARGET_BASE_ARCH ; do
7435 case "$i" in
7436 alpha)
7437 disas_config "ALPHA"
7439 aarch64)
7440 if test -n "${cxx}"; then
7441 disas_config "ARM_A64"
7444 arm)
7445 disas_config "ARM"
7446 if test -n "${cxx}"; then
7447 disas_config "ARM_A64"
7450 cris)
7451 disas_config "CRIS"
7453 hppa)
7454 disas_config "HPPA"
7456 i386|x86_64|x32)
7457 disas_config "I386"
7459 lm32)
7460 disas_config "LM32"
7462 m68k)
7463 disas_config "M68K"
7465 microblaze*)
7466 disas_config "MICROBLAZE"
7468 mips*)
7469 disas_config "MIPS"
7470 if test -n "${cxx}"; then
7471 disas_config "NANOMIPS"
7474 moxie*)
7475 disas_config "MOXIE"
7477 nios2)
7478 disas_config "NIOS2"
7480 or1k)
7481 disas_config "OPENRISC"
7483 ppc*)
7484 disas_config "PPC"
7486 riscv)
7487 disas_config "RISCV"
7489 s390*)
7490 disas_config "S390"
7492 sh4)
7493 disas_config "SH4"
7495 sparc*)
7496 disas_config "SPARC"
7498 xtensa*)
7499 disas_config "XTENSA"
7501 esac
7502 done
7503 if test "$tcg_interpreter" = "yes" ; then
7504 disas_config "TCI"
7507 case "$ARCH" in
7508 alpha)
7509 # Ensure there's only a single GP
7510 cflags="-msmall-data $cflags"
7512 esac
7514 if test "$gprof" = "yes" ; then
7515 echo "TARGET_GPROF=yes" >> $config_target_mak
7516 if test "$target_linux_user" = "yes" ; then
7517 cflags="-p $cflags"
7518 ldflags="-p $ldflags"
7520 if test "$target_softmmu" = "yes" ; then
7521 ldflags="-p $ldflags"
7522 echo "GPROF_CFLAGS=-p" >> $config_target_mak
7526 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
7527 ldflags="$ldflags $textseg_ldflags"
7530 # Newer kernels on s390 check for an S390_PGSTE program header and
7531 # enable the pgste page table extensions in that case. This makes
7532 # the vm.allocate_pgste sysctl unnecessary. We enable this program
7533 # header if
7534 # - we build on s390x
7535 # - we build the system emulation for s390x (qemu-system-s390x)
7536 # - KVM is enabled
7537 # - the linker supports --s390-pgste
7538 if test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes" -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
7539 if ld_has --s390-pgste ; then
7540 ldflags="-Wl,--s390-pgste $ldflags"
7544 echo "LDFLAGS+=$ldflags" >> $config_target_mak
7545 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7547 done # for target in $targets
7549 if test -n "$enabled_cross_compilers"; then
7550 echo
7551 echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7554 if [ "$fdt" = "git" ]; then
7555 echo "config-host.h: subdir-dtc" >> $config_host_mak
7557 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7558 echo "config-host.h: subdir-capstone" >> $config_host_mak
7560 if test -n "$LIBCAPSTONE"; then
7561 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7564 if test "$numa" = "yes"; then
7565 echo "CONFIG_NUMA=y" >> $config_host_mak
7568 if test "$ccache_cpp2" = "yes"; then
7569 echo "export CCACHE_CPP2=y" >> $config_host_mak
7572 # If we're using a separate build tree, set it up now.
7573 # DIRS are directories which we simply mkdir in the build tree;
7574 # LINKS are things to symlink back into the source tree
7575 # (these can be both files and directories).
7576 # Caution: do not add files or directories here using wildcards. This
7577 # will result in problems later if a new file matching the wildcard is
7578 # added to the source tree -- nothing will cause configure to be rerun
7579 # so the build tree will be missing the link back to the new file, and
7580 # tests might fail. Prefer to keep the relevant files in their own
7581 # directory and symlink the directory instead.
7582 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
7583 DIRS="$DIRS tests/fp"
7584 DIRS="$DIRS docs docs/interop fsdev scsi"
7585 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
7586 DIRS="$DIRS roms/seabios roms/vgabios"
7587 LINKS="Makefile tests/tcg/Makefile qdict-test-data.txt"
7588 LINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
7589 LINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
7590 LINKS="$LINKS tests/fp/Makefile"
7591 LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
7592 LINKS="$LINKS pc-bios/spapr-rtas/Makefile"
7593 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
7594 LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
7595 LINKS="$LINKS pc-bios/qemu-icon.bmp"
7596 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
7597 LINKS="$LINKS tests/acceptance tests/data"
7598 LINKS="$LINKS tests/qemu-iotests/check"
7599 for bios_file in \
7600 $source_path/pc-bios/*.bin \
7601 $source_path/pc-bios/*.lid \
7602 $source_path/pc-bios/*.rom \
7603 $source_path/pc-bios/*.dtb \
7604 $source_path/pc-bios/*.img \
7605 $source_path/pc-bios/openbios-* \
7606 $source_path/pc-bios/u-boot.* \
7607 $source_path/pc-bios/palcode-*
7609 LINKS="$LINKS pc-bios/$(basename $bios_file)"
7610 done
7611 mkdir -p $DIRS
7612 for f in $LINKS ; do
7613 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7614 symlink "$source_path/$f" "$f"
7616 done
7618 # temporary config to build submodules
7619 for rom in seabios vgabios ; do
7620 config_mak=roms/$rom/config.mak
7621 echo "# Automatically generated by configure - do not modify" > $config_mak
7622 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7623 echo "AS=$as" >> $config_mak
7624 echo "CCAS=$ccas" >> $config_mak
7625 echo "CC=$cc" >> $config_mak
7626 echo "BCC=bcc" >> $config_mak
7627 echo "CPP=$cpp" >> $config_mak
7628 echo "OBJCOPY=objcopy" >> $config_mak
7629 echo "IASL=$iasl" >> $config_mak
7630 echo "LD=$ld" >> $config_mak
7631 echo "RANLIB=$ranlib" >> $config_mak
7632 done
7634 # set up qemu-iotests in this build directory
7635 iotests_common_env="tests/qemu-iotests/common.env"
7637 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
7638 echo >> "$iotests_common_env"
7639 echo "export PYTHON='$python'" >> "$iotests_common_env"
7641 # Save the configure command line for later reuse.
7642 cat <<EOD >config.status
7643 #!/bin/sh
7644 # Generated by configure.
7645 # Run this file to recreate the current configuration.
7646 # Compiler output produced by configure, useful for debugging
7647 # configure, is in config.log if it exists.
7650 preserve_env() {
7651 envname=$1
7653 eval envval=\$$envname
7655 if test -n "$envval"
7656 then
7657 echo "$envname='$envval'" >> config.status
7658 echo "export $envname" >> config.status
7659 else
7660 echo "unset $envname" >> config.status
7664 # Preserve various env variables that influence what
7665 # features/build target configure will detect
7666 preserve_env AR
7667 preserve_env AS
7668 preserve_env CC
7669 preserve_env CPP
7670 preserve_env CXX
7671 preserve_env INSTALL
7672 preserve_env LD
7673 preserve_env LD_LIBRARY_PATH
7674 preserve_env LIBTOOL
7675 preserve_env MAKE
7676 preserve_env NM
7677 preserve_env OBJCOPY
7678 preserve_env PATH
7679 preserve_env PKG_CONFIG
7680 preserve_env PKG_CONFIG_LIBDIR
7681 preserve_env PKG_CONFIG_PATH
7682 preserve_env PYTHON
7683 preserve_env SDL_CONFIG
7684 preserve_env SDL2_CONFIG
7685 preserve_env SMBD
7686 preserve_env STRIP
7687 preserve_env WINDRES
7689 printf "exec" >>config.status
7690 printf " '%s'" "$0" "$@" >>config.status
7691 echo ' "$@"' >>config.status
7692 chmod +x config.status
7694 rm -r "$TMPDIR1"