Update help text for supported accelerators
[qemu/ar7.git] / configure
blobdae87f308f7ca73604f77a1a56028361e461a5e4
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)
111 -std=gnu99)
112 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98"
115 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
117 esac
118 done
121 compile_object() {
122 local_cflags="$1"
123 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
126 compile_prog() {
127 local_cflags="$1"
128 local_ldflags="$2"
129 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
132 # symbolically link $1 to $2. Portable version of "ln -sf".
133 symlink() {
134 rm -rf "$2"
135 mkdir -p "$(dirname "$2")"
136 ln -s "$1" "$2"
139 # check whether a command is available to this shell (may be either an
140 # executable or a builtin)
141 has() {
142 type "$1" >/dev/null 2>&1
145 # search for an executable in PATH
146 path_of() {
147 local_command="$1"
148 local_ifs="$IFS"
149 local_dir=""
151 # pathname has a dir component?
152 if [ "${local_command#*/}" != "$local_command" ]; then
153 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
154 echo "$local_command"
155 return 0
158 if [ -z "$local_command" ]; then
159 return 1
162 IFS=:
163 for local_dir in $PATH; do
164 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
165 echo "$local_dir/$local_command"
166 IFS="${local_ifs:-$(printf ' \t\n')}"
167 return 0
169 done
170 # not found
171 IFS="${local_ifs:-$(printf ' \t\n')}"
172 return 1
175 have_backend () {
176 echo "$trace_backends" | grep "$1" >/dev/null
179 glob() {
180 eval test -z '"${1#'"$2"'}"'
183 supported_hax_target() {
184 test "$hax" = "yes" || return 1
185 glob "$1" "*-softmmu" || return 1
186 case "${1%-softmmu}" in
187 i386|x86_64)
188 return 0
190 esac
191 return 1
194 supported_kvm_target() {
195 test "$kvm" = "yes" || return 1
196 glob "$1" "*-softmmu" || return 1
197 case "${1%-softmmu}:$cpu" in
198 arm:arm | aarch64:aarch64 | \
199 i386:i386 | i386:x86_64 | i386:x32 | \
200 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
201 mips:mips | mipsel:mips | \
202 ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | \
203 s390x:s390x)
204 return 0
206 esac
207 return 1
210 supported_xen_target() {
211 test "$xen" = "yes" || return 1
212 glob "$1" "*-softmmu" || return 1
213 # Only i386 and x86_64 provide the xenpv machine.
214 case "${1%-softmmu}" in
215 i386|x86_64)
216 return 0
218 esac
219 return 1
222 supported_hvf_target() {
223 test "$hvf" = "yes" || return 1
224 glob "$1" "*-softmmu" || return 1
225 case "${1%-softmmu}" in
226 x86_64)
227 return 0
229 esac
230 return 1
233 supported_whpx_target() {
234 test "$whpx" = "yes" || return 1
235 glob "$1" "*-softmmu" || return 1
236 case "${1%-softmmu}" in
237 i386|x86_64)
238 return 0
240 esac
241 return 1
244 supported_target() {
245 case "$1" in
246 *-softmmu)
248 *-linux-user)
249 if test "$linux" != "yes"; then
250 print_error "Target '$target' is only available on a Linux host"
251 return 1
254 *-bsd-user)
255 if test "$bsd" != "yes"; then
256 print_error "Target '$target' is only available on a BSD host"
257 return 1
261 print_error "Invalid target name '$target'"
262 return 1
264 esac
265 test "$tcg" = "yes" && return 0
266 supported_kvm_target "$1" && return 0
267 supported_xen_target "$1" && return 0
268 supported_hax_target "$1" && return 0
269 supported_hvf_target "$1" && return 0
270 supported_whpx_target "$1" && return 0
271 print_error "TCG disabled, but hardware accelerator not available for '$target'"
272 return 1
276 ld_has() {
277 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
280 # default parameters
281 source_path=$(dirname "$0")
282 cpu=""
283 iasl="iasl"
284 interp_prefix="/usr/gnemul/qemu-%M"
285 static="no"
286 cross_prefix=""
287 audio_drv_list=""
288 block_drv_rw_whitelist=""
289 block_drv_ro_whitelist=""
290 host_cc="cc"
291 libs_softmmu=""
292 libs_tools=""
293 audio_pt_int=""
294 audio_win_int=""
295 libs_qga=""
296 debug_info="yes"
297 stack_protector=""
299 if test -e "$source_path/.git"
300 then
301 git_update=yes
302 git_submodules="ui/keycodemapdb"
303 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
304 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
305 else
306 git_update=no
307 git_submodules=""
309 if ! test -f "$source_path/ui/keycodemapdb/README"
310 then
311 echo
312 echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
313 echo
314 echo "This is not a GIT checkout but module content appears to"
315 echo "be missing. Do not use 'git archive' or GitHub download links"
316 echo "to acquire QEMU source archives. Non-GIT builds are only"
317 echo "supported with source archives linked from:"
318 echo
319 echo " https://www.qemu.org/download/"
320 echo
321 echo "Developers working with GIT can use scripts/archive-source.sh"
322 echo "if they need to create valid source archives."
323 echo
324 exit 1
327 git="git"
329 # Don't accept a target_list environment variable.
330 unset target_list
332 # Default value for a variable defining feature "foo".
333 # * foo="no" feature will only be used if --enable-foo arg is given
334 # * foo="" feature will be searched for, and if found, will be used
335 # unless --disable-foo is given
336 # * foo="yes" this value will only be set by --enable-foo flag.
337 # feature will searched for,
338 # if not found, configure exits with error
340 # Always add --enable-foo and --disable-foo command line args.
341 # Distributions want to ensure that several features are compiled in, and it
342 # is impossible without a --enable-foo that exits if a feature is not found.
344 bluez=""
345 brlapi=""
346 curl=""
347 curses=""
348 docs=""
349 fdt=""
350 netmap="no"
351 sdl=""
352 sdl_image=""
353 virtfs=""
354 mpath=""
355 vnc="yes"
356 sparse="no"
357 vde=""
358 vnc_sasl=""
359 vnc_jpeg=""
360 vnc_png=""
361 xkbcommon=""
362 xen=""
363 xen_ctrl_version=""
364 xen_pci_passthrough=""
365 linux_aio=""
366 cap_ng=""
367 attr=""
368 libattr=""
369 xfs=""
370 tcg="yes"
371 membarrier=""
372 vhost_net="no"
373 vhost_crypto="no"
374 vhost_scsi="no"
375 vhost_vsock="no"
376 vhost_user=""
377 kvm="no"
378 hax="no"
379 hvf="no"
380 whpx="no"
381 rdma=""
382 pvrdma=""
383 gprof="no"
384 debug_tcg="no"
385 debug="no"
386 sanitizers="no"
387 fortify_source=""
388 strip_opt="yes"
389 tcg_interpreter="no"
390 bigendian="no"
391 mingw32="no"
392 gcov="no"
393 gcov_tool="gcov"
394 EXESUF=""
395 DSOSUF=".so"
396 LDFLAGS_SHARED="-shared"
397 modules="no"
398 prefix="/usr/local"
399 mandir="\${prefix}/share/man"
400 datadir="\${prefix}/share"
401 firmwarepath="\${prefix}/share/qemu-firmware"
402 qemu_docdir="\${prefix}/share/doc/qemu"
403 bindir="\${prefix}/bin"
404 libdir="\${prefix}/lib"
405 libexecdir="\${prefix}/libexec"
406 includedir="\${prefix}/include"
407 sysconfdir="\${prefix}/etc"
408 local_statedir="\${prefix}/var"
409 confsuffix="/qemu"
410 slirp="yes"
411 oss_lib=""
412 bsd="no"
413 haiku="no"
414 linux="no"
415 solaris="no"
416 profiler="no"
417 cocoa="no"
418 softmmu="yes"
419 linux_user="no"
420 bsd_user="no"
421 blobs="yes"
422 pkgversion=""
423 pie=""
424 qom_cast_debug="yes"
425 trace_backends="log"
426 trace_file="trace"
427 spice=""
428 rbd=""
429 smartcard=""
430 libusb=""
431 usb_redir=""
432 opengl=""
433 opengl_dmabuf="no"
434 cpuid_h="no"
435 avx2_opt=""
436 zlib="yes"
437 capstone=""
438 lzo=""
439 snappy=""
440 bzip2=""
441 lzfse=""
442 guest_agent=""
443 guest_agent_with_vss="no"
444 guest_agent_ntddscsi="no"
445 guest_agent_msi=""
446 vss_win32_sdk=""
447 win_sdk="no"
448 want_tools="yes"
449 libiscsi=""
450 libnfs=""
451 coroutine=""
452 coroutine_pool=""
453 debug_stack_usage="no"
454 crypto_afalg="no"
455 seccomp=""
456 glusterfs=""
457 glusterfs_xlator_opt="no"
458 glusterfs_discard="no"
459 glusterfs_fallocate="no"
460 glusterfs_zerofill="no"
461 gtk=""
462 gtk_gl="no"
463 tls_priority="NORMAL"
464 gnutls=""
465 nettle=""
466 gcrypt=""
467 gcrypt_hmac="no"
468 vte=""
469 virglrenderer=""
470 tpm="yes"
471 libssh2=""
472 live_block_migration="yes"
473 numa=""
474 tcmalloc="no"
475 jemalloc="no"
476 replication="yes"
477 vxhs=""
478 bochs="yes"
479 cloop="yes"
480 dmg="yes"
481 qcow1="yes"
482 vdi="yes"
483 vvfat="yes"
484 qed="yes"
485 parallels="yes"
486 sheepdog="yes"
487 libxml2=""
488 docker="no"
489 debug_mutex="no"
490 libpmem=""
491 libudev="no"
493 # cross compilers defaults, can be overridden with --cross-cc-ARCH
494 cross_cc_aarch64="aarch64-linux-gnu-gcc"
495 cross_cc_aarch64_be="$cross_cc_aarch64"
496 cross_cc_cflags_aarch64_be="-mbig-endian"
497 cross_cc_arm="arm-linux-gnueabihf-gcc"
498 cross_cc_cflags_armeb="-mbig-endian"
499 cross_cc_i386="i386-pc-linux-gnu-gcc"
500 cross_cc_cflags_i386=""
501 cross_cc_powerpc="powerpc-linux-gnu-gcc"
502 cross_cc_powerpc="powerpc-linux-gnu-gcc"
504 enabled_cross_compilers=""
506 supported_cpu="no"
507 supported_os="no"
508 bogus_os="no"
509 malloc_trim=""
511 # parse CC options first
512 for opt do
513 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
514 case "$opt" in
515 --cross-prefix=*) cross_prefix="$optarg"
517 --cc=*) CC="$optarg"
519 --cxx=*) CXX="$optarg"
521 --source-path=*) source_path="$optarg"
523 --cpu=*) cpu="$optarg"
525 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
527 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
529 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
530 EXTRA_LDFLAGS="$optarg"
532 --enable-debug-info) debug_info="yes"
534 --disable-debug-info) debug_info="no"
536 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
538 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
539 eval "cross_cc_cflags_${cc_arch}=\$optarg"
541 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
542 eval "cross_cc_${cc_arch}=\$optarg"
544 esac
545 done
546 # OS specific
547 # Using uname is really, really broken. Once we have the right set of checks
548 # we can eliminate its usage altogether.
550 # Preferred compiler:
551 # ${CC} (if set)
552 # ${cross_prefix}gcc (if cross-prefix specified)
553 # system compiler
554 if test -z "${CC}${cross_prefix}"; then
555 cc="$host_cc"
556 else
557 cc="${CC-${cross_prefix}gcc}"
560 if test -z "${CXX}${cross_prefix}"; then
561 cxx="c++"
562 else
563 cxx="${CXX-${cross_prefix}g++}"
566 ar="${AR-${cross_prefix}ar}"
567 as="${AS-${cross_prefix}as}"
568 ccas="${CCAS-$cc}"
569 cpp="${CPP-$cc -E}"
570 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
571 ld="${LD-${cross_prefix}ld}"
572 ranlib="${RANLIB-${cross_prefix}ranlib}"
573 nm="${NM-${cross_prefix}nm}"
574 strip="${STRIP-${cross_prefix}strip}"
575 windres="${WINDRES-${cross_prefix}windres}"
576 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
577 query_pkg_config() {
578 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
580 pkg_config=query_pkg_config
581 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
583 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
584 ARFLAGS="${ARFLAGS-rv}"
586 # default flags for all hosts
587 # We use -fwrapv to tell the compiler that we require a C dialect where
588 # left shift of signed integers is well defined and has the expected
589 # 2s-complement style results. (Both clang and gcc agree that it
590 # provides these semantics.)
591 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
592 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
593 QEMU_CFLAGS="-Wmissing-format-attribute $QEMU_CFLAGS"
594 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
595 QEMU_CFLAGS="-Wno-unused-parameter $QEMU_CFLAGS"
596 QEMU_CFLAGS="-Wno-missing-field-initializers $QEMU_CFLAGS"
597 QEMU_CFLAGS="-Wno-sign-compare $QEMU_CFLAGS"
598 QEMU_CFLAGS="-Wno-override-init $QEMU_CFLAGS"
599 QEMU_CFLAGS="-Wno-error=format $QEMU_CFLAGS"
600 QEMU_CFLAGS="-Wno-error=format-extra-args $QEMU_CFLAGS"
601 QEMU_CFLAGS="-Wno-error=parentheses $QEMU_CFLAGS"
602 QEMU_CFLAGS="-Wextra $QEMU_CFLAGS"
603 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
604 QEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
605 if test "$debug_info" = "yes"; then
606 CFLAGS="-g $CFLAGS"
607 LDFLAGS="-g $LDFLAGS"
610 # make source path absolute
611 source_path=$(cd "$source_path"; pwd)
613 cc_macros=$($cc $QEMU_CFLAGS -E -dD - </dev/null)
615 # running configure in the source tree?
616 # we know that's the case if configure is there.
617 if test -f "./configure"; then
618 pwd_is_source_path="y"
619 else
620 pwd_is_source_path="n"
623 check_define() {
624 rm -f $TMPC
625 cat > $TMPC <<EOF
626 #if !defined($1)
627 #error $1 not defined
628 #endif
629 int main(void) { return 0; }
631 compile_object
634 check_include() {
635 cat > $TMPC <<EOF
636 #include <$1>
637 int main(void) { return 0; }
639 compile_object
642 write_c_skeleton() {
643 cat > $TMPC <<EOF
644 int main(void) { return 0; }
648 if check_define __linux__ ; then
649 targetos="Linux"
650 elif check_define _WIN32 ; then
651 targetos='MINGW32'
652 elif check_define __OpenBSD__ ; then
653 targetos='OpenBSD'
654 elif check_define __sun__ ; then
655 targetos='SunOS'
656 elif check_define __HAIKU__ ; then
657 targetos='Haiku'
658 elif check_define __FreeBSD__ ; then
659 targetos='FreeBSD'
660 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
661 targetos='GNU/kFreeBSD'
662 elif check_define __DragonFly__ ; then
663 targetos='DragonFly'
664 elif check_define __NetBSD__; then
665 targetos='NetBSD'
666 elif check_define __APPLE__; then
667 targetos='Darwin'
668 else
669 # This is a fatal error, but don't report it yet, because we
670 # might be going to just print the --help text, or it might
671 # be the result of a missing compiler.
672 targetos='bogus'
673 bogus_os='yes'
676 # Some host OSes need non-standard checks for which CPU to use.
677 # Note that these checks are broken for cross-compilation: if you're
678 # cross-compiling to one of these OSes then you'll need to specify
679 # the correct CPU with the --cpu option.
680 case $targetos in
681 Darwin)
682 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
683 # run 64-bit userspace code.
684 # If the user didn't specify a CPU explicitly and the kernel says this is
685 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
686 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
687 cpu="x86_64"
690 SunOS)
691 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
692 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
693 cpu="x86_64"
695 esac
697 if test ! -z "$cpu" ; then
698 # command line argument
700 elif check_define __i386__ ; then
701 cpu="i386"
702 elif check_define __x86_64__ ; then
703 if check_define __ILP32__ ; then
704 cpu="x32"
705 else
706 cpu="x86_64"
708 elif check_define __sparc__ ; then
709 if check_define __arch64__ ; then
710 cpu="sparc64"
711 else
712 cpu="sparc"
714 elif check_define _ARCH_PPC ; then
715 if check_define _ARCH_PPC64 ; then
716 cpu="ppc64"
717 else
718 cpu="ppc"
720 elif check_define __mips__ ; then
721 if check_define __mips64 ; then
722 cpu="mips64"
723 else
724 cpu="mips"
726 elif check_define __s390__ ; then
727 if check_define __s390x__ ; then
728 cpu="s390x"
729 else
730 cpu="s390"
732 elif check_define __riscv ; then
733 if check_define _LP64 ; then
734 cpu="riscv64"
735 else
736 cpu="riscv32"
738 elif check_define __arm__ ; then
739 cpu="arm"
740 elif check_define __aarch64__ ; then
741 cpu="aarch64"
742 else
743 cpu=$(uname -m)
746 ARCH=
747 # Normalise host CPU name and set ARCH.
748 # Note that this case should only have supported host CPUs, not guests.
749 case "$cpu" in
750 ppc|ppc64|s390|s390x|sparc64|x32|riscv32|riscv64)
751 cpu="$cpu"
752 supported_cpu="yes"
753 eval "cross_cc_${cpu}=\$host_cc"
755 i386|i486|i586|i686|i86pc|BePC)
756 cpu="i386"
757 supported_cpu="yes"
758 cross_cc_i386=$host_cc
760 x86_64|amd64)
761 cpu="x86_64"
762 supported_cpu="yes"
763 cross_cc_x86_64=$host_cc
765 armv*b|armv*l|arm)
766 cpu="arm"
767 supported_cpu="yes"
768 cross_cc_arm=$host_cc
770 aarch64)
771 cpu="aarch64"
772 supported_cpu="yes"
773 cross_cc_aarch64=$host_cc
775 mips*)
776 cpu="mips"
777 if check_define __MIPSEL__ ; then
778 cpu="${cpu}el"
780 supported_cpu="yes"
781 cross_cc_mips=$host_cc
783 sparc|sun4[cdmuv])
784 cpu="sparc"
785 supported_cpu="yes"
786 cross_cc_sparc=$host_cc
788 sh4)
789 cpu="sh4"
792 # This will result in either an error or falling back to TCI later
793 ARCH=unknown
795 esac
796 if test -z "$ARCH"; then
797 ARCH="$cpu"
800 # OS specific
802 # host *BSD for user mode
803 HOST_VARIANT_DIR=""
805 case $targetos in
806 MINGW32*)
807 mingw32="yes"
808 hax="yes"
809 audio_possible_drivers="dsound sdl"
810 if check_include dsound.h; then
811 audio_drv_list="dsound"
812 else
813 audio_drv_list=""
815 QEMU_INCLUDES="-I\$(SRC_PATH)/hosts/w32/include $QEMU_INCLUDES"
816 supported_os="yes"
818 GNU/kFreeBSD)
819 bsd="yes"
820 audio_drv_list="oss try-sdl"
821 audio_possible_drivers="oss sdl pa"
823 FreeBSD)
824 bsd="yes"
825 make="${MAKE-gmake}"
826 audio_drv_list="oss try-sdl"
827 audio_possible_drivers="oss sdl pa"
828 # needed for kinfo_getvmmap(3) in libutil.h
829 LIBS="-lutil $LIBS"
830 # needed for kinfo_getproc
831 libs_qga="-lutil $libs_qga"
832 netmap="" # enable netmap autodetect
833 HOST_VARIANT_DIR="freebsd"
834 supported_os="yes"
836 DragonFly)
837 bsd="yes"
838 make="${MAKE-gmake}"
839 audio_drv_list="oss try-sdl"
840 audio_possible_drivers="oss sdl pa"
841 HOST_VARIANT_DIR="dragonfly"
843 NetBSD)
844 bsd="yes"
845 hax="yes"
846 make="${MAKE-gmake}"
847 audio_drv_list="oss try-sdl"
848 audio_possible_drivers="oss sdl"
849 oss_lib="-lossaudio"
850 HOST_VARIANT_DIR="netbsd"
851 supported_os="yes"
853 OpenBSD)
854 bsd="yes"
855 make="${MAKE-gmake}"
856 audio_drv_list="try-sdl"
857 audio_possible_drivers="sdl"
858 HOST_VARIANT_DIR="openbsd"
859 supported_os="yes"
861 Darwin)
862 bsd="yes"
863 darwin="yes"
864 hax="yes"
865 hvf="yes"
866 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
867 if [ "$cpu" = "x86_64" ] ; then
868 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
869 LDFLAGS="-arch x86_64 $LDFLAGS"
871 cocoa="yes"
872 audio_drv_list="coreaudio try-sdl"
873 audio_possible_drivers="coreaudio sdl"
874 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
875 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
876 # Disable attempts to use ObjectiveC features in os/object.h since they
877 # won't work when we're compiling with gcc as a C compiler.
878 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
879 HOST_VARIANT_DIR="darwin"
880 supported_os="yes"
882 SunOS)
883 solaris="yes"
884 make="${MAKE-gmake}"
885 install="${INSTALL-ginstall}"
886 smbd="${SMBD-/usr/sfw/sbin/smbd}"
887 if test -f /usr/include/sys/soundcard.h ; then
888 audio_drv_list="oss try-sdl"
890 audio_possible_drivers="oss sdl"
891 # needed for CMSG_ macros in sys/socket.h
892 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
893 # needed for TIOCWIN* defines in termios.h
894 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
895 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
896 solarisnetlibs="-lsocket -lnsl -lresolv"
897 LIBS="$solarisnetlibs $LIBS"
898 libs_qga="$solarisnetlibs $libs_qga"
900 Haiku)
901 haiku="yes"
902 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
903 LIBS="-lposix_error_mapper -lnetwork $LIBS"
905 Linux)
906 audio_drv_list="try-pa try-alsa try-sdl oss"
907 audio_possible_drivers="oss alsa sdl pa"
908 linux="yes"
909 linux_user="yes"
910 kvm="yes"
911 vhost_net="yes"
912 vhost_crypto="yes"
913 vhost_scsi="yes"
914 vhost_vsock="yes"
915 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
916 supported_os="yes"
917 libudev="yes"
919 esac
921 if [ "$bsd" = "yes" ] ; then
922 if [ "$darwin" != "yes" ] ; then
923 bsd_user="yes"
927 : ${make=${MAKE-make}}
928 : ${install=${INSTALL-install}}
929 : ${python=${PYTHON-python}}
930 : ${smbd=${SMBD-/usr/sbin/smbd}}
932 # Default objcc to clang if available, otherwise use CC
933 if has clang; then
934 objcc=clang
935 else
936 objcc="$cc"
939 if test "$mingw32" = "yes" ; then
940 EXESUF=".exe"
941 DSOSUF=".dll"
942 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
943 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
944 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
945 # MinGW-w64 needs _POSIX defined.
946 QEMU_CFLAGS="-D_POSIX=1 $QEMU_CFLAGS"
947 # MinGW needs -mthreads for TLS and macro _MT.
948 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
949 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
950 write_c_skeleton;
951 if compile_prog "" "-liberty" ; then
952 LIBS="-liberty $LIBS"
954 prefix="c:/Program Files/QEMU"
955 mandir="\${prefix}"
956 datadir="\${prefix}"
957 qemu_docdir="\${prefix}"
958 bindir="\${prefix}"
959 sysconfdir="\${prefix}"
960 local_statedir=
961 confsuffix=""
962 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
965 werror=""
967 for opt do
968 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
969 case "$opt" in
970 --help|-h) show_help=yes
972 --version|-V) exec cat $source_path/VERSION
974 --prefix=*) prefix="$optarg"
976 --interp-prefix=*) interp_prefix="$optarg"
978 --source-path=*)
980 --cross-prefix=*)
982 --cc=*)
984 --host-cc=*) host_cc="$optarg"
986 --cxx=*)
988 --iasl=*) iasl="$optarg"
990 --objcc=*) objcc="$optarg"
992 --make=*) make="$optarg"
994 --install=*) install="$optarg"
996 --python=*) python="$optarg"
998 --gcov=*) gcov_tool="$optarg"
1000 --smbd=*) smbd="$optarg"
1002 --extra-cflags=*)
1004 --extra-cxxflags=*)
1006 --extra-ldflags=*)
1008 --enable-debug-info)
1010 --disable-debug-info)
1012 --cross-cc-*)
1014 --enable-modules)
1015 modules="yes"
1017 --disable-modules)
1018 modules="no"
1020 --cpu=*)
1022 --target-list=*) target_list="$optarg"
1024 --enable-trace-backends=*) trace_backends="$optarg"
1026 # XXX: backwards compatibility
1027 --enable-trace-backend=*) trace_backends="$optarg"
1029 --with-trace-file=*) trace_file="$optarg"
1031 --enable-gprof) gprof="yes"
1033 --enable-gcov) gcov="yes"
1035 --static)
1036 static="yes"
1037 LDFLAGS="-static $LDFLAGS"
1038 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
1040 --mandir=*) mandir="$optarg"
1042 --bindir=*) bindir="$optarg"
1044 --libdir=*) libdir="$optarg"
1046 --libexecdir=*) libexecdir="$optarg"
1048 --includedir=*) includedir="$optarg"
1050 --datadir=*) datadir="$optarg"
1052 --with-confsuffix=*) confsuffix="$optarg"
1054 --docdir=*) qemu_docdir="$optarg"
1056 --sysconfdir=*) sysconfdir="$optarg"
1058 --localstatedir=*) local_statedir="$optarg"
1060 --firmwarepath=*) firmwarepath="$optarg"
1062 --host=*|--build=*|\
1063 --disable-dependency-tracking|\
1064 --sbindir=*|--sharedstatedir=*|\
1065 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1066 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1067 # These switches are silently ignored, for compatibility with
1068 # autoconf-generated configure scripts. This allows QEMU's
1069 # configure to be used by RPM and similar macros that set
1070 # lots of directory switches by default.
1072 --disable-sdl) sdl="no"
1074 --enable-sdl) sdl="yes"
1076 --disable-sdl-image) sdl_image="no"
1078 --enable-sdl-image) sdl_image="yes"
1080 --disable-qom-cast-debug) qom_cast_debug="no"
1082 --enable-qom-cast-debug) qom_cast_debug="yes"
1084 --disable-virtfs) virtfs="no"
1086 --enable-virtfs) virtfs="yes"
1088 --disable-mpath) mpath="no"
1090 --enable-mpath) mpath="yes"
1092 --disable-vnc) vnc="no"
1094 --enable-vnc) vnc="yes"
1096 --oss-lib=*) oss_lib="$optarg"
1098 --audio-drv-list=*) audio_drv_list="$optarg"
1100 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1102 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1104 --enable-debug-tcg) debug_tcg="yes"
1106 --disable-debug-tcg) debug_tcg="no"
1108 --enable-debug)
1109 # Enable debugging options that aren't excessively noisy
1110 debug_tcg="yes"
1111 debug_mutex="yes"
1112 debug="yes"
1113 strip_opt="no"
1114 fortify_source="no"
1116 --enable-sanitizers) sanitizers="yes"
1118 --disable-sanitizers) sanitizers="no"
1120 --enable-sparse) sparse="yes"
1122 --disable-sparse) sparse="no"
1124 --disable-strip) strip_opt="no"
1126 --disable-vnc-sasl) vnc_sasl="no"
1128 --enable-vnc-sasl) vnc_sasl="yes"
1130 --disable-vnc-jpeg) vnc_jpeg="no"
1132 --enable-vnc-jpeg) vnc_jpeg="yes"
1134 --disable-vnc-png) vnc_png="no"
1136 --enable-vnc-png) vnc_png="yes"
1138 --disable-slirp) slirp="no"
1140 --disable-vde) vde="no"
1142 --enable-vde) vde="yes"
1144 --disable-netmap) netmap="no"
1146 --enable-netmap) netmap="yes"
1148 --disable-xen) xen="no"
1150 --enable-xen) xen="yes"
1152 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1154 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1156 --disable-brlapi) brlapi="no"
1158 --enable-brlapi) brlapi="yes"
1160 --disable-bluez) bluez="no"
1162 --enable-bluez) bluez="yes"
1164 --disable-kvm) kvm="no"
1166 --enable-kvm) kvm="yes"
1168 --disable-hax) hax="no"
1170 --enable-hax) hax="yes"
1172 --disable-hvf) hvf="no"
1174 --enable-hvf) hvf="yes"
1176 --disable-whpx) whpx="no"
1178 --enable-whpx) whpx="yes"
1180 --disable-tcg-interpreter) tcg_interpreter="no"
1182 --enable-tcg-interpreter) tcg_interpreter="yes"
1184 --disable-cap-ng) cap_ng="no"
1186 --enable-cap-ng) cap_ng="yes"
1188 --disable-tcg) tcg="no"
1190 --enable-tcg) tcg="yes"
1192 --disable-malloc-trim) malloc_trim="no"
1194 --enable-malloc-trim) malloc_trim="yes"
1196 --disable-spice) spice="no"
1198 --enable-spice) spice="yes"
1200 --disable-libiscsi) libiscsi="no"
1202 --enable-libiscsi) libiscsi="yes"
1204 --disable-libnfs) libnfs="no"
1206 --enable-libnfs) libnfs="yes"
1208 --enable-profiler) profiler="yes"
1210 --disable-cocoa) cocoa="no"
1212 --enable-cocoa)
1213 cocoa="yes" ;
1214 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1216 --disable-system) softmmu="no"
1218 --enable-system) softmmu="yes"
1220 --disable-user)
1221 linux_user="no" ;
1222 bsd_user="no" ;
1224 --enable-user) ;;
1225 --disable-linux-user) linux_user="no"
1227 --enable-linux-user) linux_user="yes"
1229 --disable-bsd-user) bsd_user="no"
1231 --enable-bsd-user) bsd_user="yes"
1233 --enable-pie) pie="yes"
1235 --disable-pie) pie="no"
1237 --enable-werror) werror="yes"
1239 --disable-werror) werror="no"
1241 --enable-stack-protector) stack_protector="yes"
1243 --disable-stack-protector) stack_protector="no"
1245 --disable-curses) curses="no"
1247 --enable-curses) curses="yes"
1249 --disable-curl) curl="no"
1251 --enable-curl) curl="yes"
1253 --disable-fdt) fdt="no"
1255 --enable-fdt) fdt="yes"
1257 --disable-linux-aio) linux_aio="no"
1259 --enable-linux-aio) linux_aio="yes"
1261 --disable-attr) attr="no"
1263 --enable-attr) attr="yes"
1265 --disable-membarrier) membarrier="no"
1267 --enable-membarrier) membarrier="yes"
1269 --disable-blobs) blobs="no"
1271 --with-pkgversion=*) pkgversion="$optarg"
1273 --with-coroutine=*) coroutine="$optarg"
1275 --disable-coroutine-pool) coroutine_pool="no"
1277 --enable-coroutine-pool) coroutine_pool="yes"
1279 --enable-debug-stack-usage) debug_stack_usage="yes"
1281 --enable-crypto-afalg) crypto_afalg="yes"
1283 --disable-crypto-afalg) crypto_afalg="no"
1285 --disable-docs) docs="no"
1287 --enable-docs) docs="yes"
1289 --disable-vhost-net) vhost_net="no"
1291 --enable-vhost-net) vhost_net="yes"
1293 --disable-vhost-crypto) vhost_crypto="no"
1295 --enable-vhost-crypto)
1296 vhost_crypto="yes"
1297 if test "$mingw32" = "yes"; then
1298 error_exit "vhost-crypto isn't available on win32"
1301 --disable-vhost-scsi) vhost_scsi="no"
1303 --enable-vhost-scsi) vhost_scsi="yes"
1305 --disable-vhost-vsock) vhost_vsock="no"
1307 --enable-vhost-vsock) vhost_vsock="yes"
1309 --disable-opengl) opengl="no"
1311 --enable-opengl) opengl="yes"
1313 --disable-rbd) rbd="no"
1315 --enable-rbd) rbd="yes"
1317 --disable-xfsctl) xfs="no"
1319 --enable-xfsctl) xfs="yes"
1321 --disable-smartcard) smartcard="no"
1323 --enable-smartcard) smartcard="yes"
1325 --disable-libusb) libusb="no"
1327 --enable-libusb) libusb="yes"
1329 --disable-usb-redir) usb_redir="no"
1331 --enable-usb-redir) usb_redir="yes"
1333 --disable-zlib-test) zlib="no"
1335 --disable-lzo) lzo="no"
1337 --enable-lzo) lzo="yes"
1339 --disable-snappy) snappy="no"
1341 --enable-snappy) snappy="yes"
1343 --disable-bzip2) bzip2="no"
1345 --enable-bzip2) bzip2="yes"
1347 --enable-lzfse) lzfse="yes"
1349 --disable-lzfse) lzfse="no"
1351 --enable-guest-agent) guest_agent="yes"
1353 --disable-guest-agent) guest_agent="no"
1355 --enable-guest-agent-msi) guest_agent_msi="yes"
1357 --disable-guest-agent-msi) guest_agent_msi="no"
1359 --with-vss-sdk) vss_win32_sdk=""
1361 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1363 --without-vss-sdk) vss_win32_sdk="no"
1365 --with-win-sdk) win_sdk=""
1367 --with-win-sdk=*) win_sdk="$optarg"
1369 --without-win-sdk) win_sdk="no"
1371 --enable-tools) want_tools="yes"
1373 --disable-tools) want_tools="no"
1375 --enable-seccomp) seccomp="yes"
1377 --disable-seccomp) seccomp="no"
1379 --disable-glusterfs) glusterfs="no"
1381 --disable-avx2) avx2_opt="no"
1383 --enable-avx2) avx2_opt="yes"
1385 --enable-glusterfs) glusterfs="yes"
1387 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1388 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1390 --enable-vhdx|--disable-vhdx)
1391 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1393 --enable-uuid|--disable-uuid)
1394 echo "$0: $opt is obsolete, UUID support is always built" >&2
1396 --disable-gtk) gtk="no"
1398 --enable-gtk) gtk="yes"
1400 --tls-priority=*) tls_priority="$optarg"
1402 --disable-gnutls) gnutls="no"
1404 --enable-gnutls) gnutls="yes"
1406 --disable-nettle) nettle="no"
1408 --enable-nettle) nettle="yes"
1410 --disable-gcrypt) gcrypt="no"
1412 --enable-gcrypt) gcrypt="yes"
1414 --enable-rdma) rdma="yes"
1416 --disable-rdma) rdma="no"
1418 --enable-pvrdma) pvrdma="yes"
1420 --disable-pvrdma) pvrdma="no"
1422 --disable-vte) vte="no"
1424 --enable-vte) vte="yes"
1426 --disable-virglrenderer) virglrenderer="no"
1428 --enable-virglrenderer) virglrenderer="yes"
1430 --disable-tpm) tpm="no"
1432 --enable-tpm) tpm="yes"
1434 --disable-libssh2) libssh2="no"
1436 --enable-libssh2) libssh2="yes"
1438 --disable-live-block-migration) live_block_migration="no"
1440 --enable-live-block-migration) live_block_migration="yes"
1442 --disable-numa) numa="no"
1444 --enable-numa) numa="yes"
1446 --disable-libxml2) libxml2="no"
1448 --enable-libxml2) libxml2="yes"
1450 --disable-tcmalloc) tcmalloc="no"
1452 --enable-tcmalloc) tcmalloc="yes"
1454 --disable-jemalloc) jemalloc="no"
1456 --enable-jemalloc) jemalloc="yes"
1458 --disable-replication) replication="no"
1460 --enable-replication) replication="yes"
1462 --disable-vxhs) vxhs="no"
1464 --enable-vxhs) vxhs="yes"
1466 --disable-bochs) bochs="no"
1468 --enable-bochs) bochs="yes"
1470 --disable-cloop) cloop="no"
1472 --enable-cloop) cloop="yes"
1474 --disable-dmg) dmg="no"
1476 --enable-dmg) dmg="yes"
1478 --disable-qcow1) qcow1="no"
1480 --enable-qcow1) qcow1="yes"
1482 --disable-vdi) vdi="no"
1484 --enable-vdi) vdi="yes"
1486 --disable-vvfat) vvfat="no"
1488 --enable-vvfat) vvfat="yes"
1490 --disable-qed) qed="no"
1492 --enable-qed) qed="yes"
1494 --disable-parallels) parallels="no"
1496 --enable-parallels) parallels="yes"
1498 --disable-sheepdog) sheepdog="no"
1500 --enable-sheepdog) sheepdog="yes"
1502 --disable-vhost-user) vhost_user="no"
1504 --enable-vhost-user)
1505 vhost_user="yes"
1506 if test "$mingw32" = "yes"; then
1507 error_exit "vhost-user isn't available on win32"
1510 --disable-capstone) capstone="no"
1512 --enable-capstone) capstone="yes"
1514 --enable-capstone=git) capstone="git"
1516 --enable-capstone=system) capstone="system"
1518 --with-git=*) git="$optarg"
1520 --enable-git-update) git_update=yes
1522 --disable-git-update) git_update=no
1524 --enable-debug-mutex) debug_mutex=yes
1526 --disable-debug-mutex) debug_mutex=no
1528 --enable-libpmem) libpmem=yes
1530 --disable-libpmem) libpmem=no
1533 echo "ERROR: unknown option $opt"
1534 echo "Try '$0 --help' for more information"
1535 exit 1
1537 esac
1538 done
1540 if test "$vhost_user" = ""; then
1541 if test "$mingw32" = "yes"; then
1542 vhost_user="no"
1543 else
1544 vhost_user="yes"
1548 case "$cpu" in
1549 ppc)
1550 CPU_CFLAGS="-m32"
1551 LDFLAGS="-m32 $LDFLAGS"
1552 cross_cc_powerpc=$cc
1553 cross_cc_cflags_powerpc=$CPU_CFLAGS
1555 ppc64)
1556 CPU_CFLAGS="-m64"
1557 LDFLAGS="-m64 $LDFLAGS"
1558 cross_cc_ppc64=$cc
1559 cross_cc_cflags_ppc64=$CPU_CFLAGS
1561 sparc)
1562 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1563 LDFLAGS="-m32 -mv8plus $LDFLAGS"
1564 cross_cc_sparc=$cc
1565 cross_cc_cflags_sparc=$CPU_CFLAGS
1567 sparc64)
1568 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1569 LDFLAGS="-m64 $LDFLAGS"
1570 cross_cc_sparc64=$cc
1571 cross_cc_cflags_sparc64=$CPU_CFLAGS
1573 s390)
1574 CPU_CFLAGS="-m31"
1575 LDFLAGS="-m31 $LDFLAGS"
1576 cross_cc_s390=$cc
1577 cross_cc_cflags_s390=$CPU_CFLAGS
1579 s390x)
1580 CPU_CFLAGS="-m64"
1581 LDFLAGS="-m64 $LDFLAGS"
1582 cross_cc_s390x=$cc
1583 cross_cc_cflags_s390x=$CPU_CFLAGS
1585 i386)
1586 CPU_CFLAGS="-m32"
1587 LDFLAGS="-m32 $LDFLAGS"
1588 cross_cc_i386=$cc
1589 cross_cc_cflags_i386=$CPU_CFLAGS
1591 x86_64)
1592 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1593 # If we truly care, we should simply detect this case at
1594 # runtime and generate the fallback to serial emulation.
1595 CPU_CFLAGS="-m64 -mcx16"
1596 LDFLAGS="-m64 $LDFLAGS"
1597 cross_cc_x86_64=$cc
1598 cross_cc_cflags_x86_64=$CPU_CFLAGS
1600 x32)
1601 CPU_CFLAGS="-mx32"
1602 LDFLAGS="-mx32 $LDFLAGS"
1603 cross_cc_i386=$cc
1604 cross_cc_cflags_i386=$CPU_CFLAGS
1606 # No special flags required for other host CPUs
1607 esac
1609 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1611 # For user-mode emulation the host arch has to be one we explicitly
1612 # support, even if we're using TCI.
1613 if [ "$ARCH" = "unknown" ]; then
1614 bsd_user="no"
1615 linux_user="no"
1618 default_target_list=""
1620 mak_wilds=""
1622 if [ "$softmmu" = "yes" ]; then
1623 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1625 if [ "$linux_user" = "yes" ]; then
1626 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1628 if [ "$bsd_user" = "yes" ]; then
1629 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1632 for config in $mak_wilds; do
1633 default_target_list="${default_target_list} $(basename "$config" .mak)"
1634 done
1636 # Enumerate public trace backends for --help output
1637 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1639 if test x"$show_help" = x"yes" ; then
1640 cat << EOF
1642 Usage: configure [options]
1643 Options: [defaults in brackets after descriptions]
1645 Standard options:
1646 --help print this message
1647 --prefix=PREFIX install in PREFIX [$prefix]
1648 --interp-prefix=PREFIX where to find shared libraries, etc.
1649 use %M for cpu name [$interp_prefix]
1650 --target-list=LIST set target list (default: build everything)
1651 $(echo Available targets: $default_target_list | \
1652 fold -s -w 53 | sed -e 's/^/ /')
1654 Advanced options (experts only):
1655 --source-path=PATH path of source code [$source_path]
1656 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1657 --cc=CC use C compiler CC [$cc]
1658 --iasl=IASL use ACPI compiler IASL [$iasl]
1659 --host-cc=CC use C compiler CC [$host_cc] for code run at
1660 build time
1661 --cxx=CXX use C++ compiler CXX [$cxx]
1662 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1663 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1664 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1665 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1666 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1667 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
1668 --make=MAKE use specified make [$make]
1669 --install=INSTALL use specified install [$install]
1670 --python=PYTHON use specified python [$python]
1671 --smbd=SMBD use specified smbd [$smbd]
1672 --with-git=GIT use specified git [$git]
1673 --static enable static build [$static]
1674 --mandir=PATH install man pages in PATH
1675 --datadir=PATH install firmware in PATH$confsuffix
1676 --docdir=PATH install documentation in PATH$confsuffix
1677 --bindir=PATH install binaries in PATH
1678 --libdir=PATH install libraries in PATH
1679 --libexecdir=PATH install helper binaries in PATH
1680 --sysconfdir=PATH install config in PATH$confsuffix
1681 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1682 --firmwarepath=PATH search PATH for firmware files
1683 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1684 --with-pkgversion=VERS use specified string as sub-version of the package
1685 --enable-debug enable common debug build options
1686 --enable-sanitizers enable default sanitizers
1687 --disable-strip disable stripping binaries
1688 --disable-werror disable compilation abort on warning
1689 --disable-stack-protector disable compiler-provided stack protection
1690 --audio-drv-list=LIST set audio drivers list:
1691 Available drivers: $audio_possible_drivers
1692 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1693 --block-drv-rw-whitelist=L
1694 set block driver read-write whitelist
1695 (affects only QEMU, not qemu-img)
1696 --block-drv-ro-whitelist=L
1697 set block driver read-only whitelist
1698 (affects only QEMU, not qemu-img)
1699 --enable-trace-backends=B Set trace backend
1700 Available backends: $trace_backend_list
1701 --with-trace-file=NAME Full PATH,NAME of file to store traces
1702 Default:trace-<pid>
1703 --disable-slirp disable SLIRP userspace network connectivity
1704 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1705 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1706 --oss-lib path to OSS library
1707 --cpu=CPU Build for host CPU [$cpu]
1708 --with-coroutine=BACKEND coroutine backend. Supported options:
1709 ucontext, sigaltstack, windows
1710 --enable-gcov enable test coverage analysis with gcov
1711 --gcov=GCOV use specified gcov [$gcov_tool]
1712 --disable-blobs disable installing provided firmware blobs
1713 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1714 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1715 --tls-priority default TLS protocol/cipher priority string
1716 --enable-gprof QEMU profiling with gprof
1717 --enable-profiler profiler support
1718 --enable-debug-stack-usage
1719 track the maximum stack usage of stacks created by qemu_alloc_stack
1721 Optional features, enabled with --enable-FEATURE and
1722 disabled with --disable-FEATURE, default is enabled if available:
1724 system all system emulation targets
1725 user supported user emulation targets
1726 linux-user all linux usermode emulation targets
1727 bsd-user all BSD usermode emulation targets
1728 docs build documentation
1729 guest-agent build the QEMU Guest Agent
1730 guest-agent-msi build guest agent Windows MSI installation package
1731 pie Position Independent Executables
1732 modules modules support
1733 debug-tcg TCG debugging (default is disabled)
1734 debug-info debugging information
1735 sparse sparse checker
1737 gnutls GNUTLS cryptography support
1738 nettle nettle cryptography support
1739 gcrypt libgcrypt cryptography support
1740 sdl SDL UI
1741 sdl_image SDL Image support for icons
1742 gtk gtk UI
1743 vte vte support for the gtk UI
1744 curses curses UI
1745 vnc VNC UI support
1746 vnc-sasl SASL encryption for VNC server
1747 vnc-jpeg JPEG lossy compression for VNC server
1748 vnc-png PNG compression for VNC server
1749 cocoa Cocoa UI (Mac OS X only)
1750 virtfs VirtFS
1751 mpath Multipath persistent reservation passthrough
1752 xen xen backend driver support
1753 xen-pci-passthrough PCI passthrough support for Xen
1754 brlapi BrlAPI (Braile)
1755 curl curl connectivity
1756 membarrier membarrier system call (for Linux 4.14+ or Windows)
1757 fdt fdt device tree
1758 bluez bluez stack connectivity
1759 kvm KVM acceleration support
1760 hax HAX acceleration support
1761 hvf Hypervisor.framework acceleration support
1762 whpx Windows Hypervisor Platform acceleration support
1763 rdma Enable RDMA-based migration
1764 pvrdma Enable PVRDMA support
1765 vde support for vde network
1766 netmap support for netmap network
1767 linux-aio Linux AIO support
1768 cap-ng libcap-ng support
1769 attr attr and xattr support
1770 vhost-net vhost-net acceleration support
1771 vhost-crypto vhost-crypto acceleration support
1772 spice spice
1773 rbd rados block device (rbd)
1774 libiscsi iscsi support
1775 libnfs nfs support
1776 smartcard smartcard support (libcacard)
1777 libusb libusb (for usb passthrough)
1778 live-block-migration Block migration in the main migration stream
1779 usb-redir usb network redirection support
1780 lzo support of lzo compression library
1781 snappy support of snappy compression library
1782 bzip2 support of bzip2 compression library
1783 (for reading bzip2-compressed dmg images)
1784 lzfse support of lzfse compression library
1785 (for reading lzfse-compressed dmg images)
1786 seccomp seccomp support
1787 coroutine-pool coroutine freelist (better performance)
1788 glusterfs GlusterFS backend
1789 tpm TPM support
1790 libssh2 ssh block device support
1791 numa libnuma support
1792 libxml2 for Parallels image format
1793 tcmalloc tcmalloc support
1794 jemalloc jemalloc support
1795 avx2 AVX2 optimization support
1796 replication replication support
1797 vhost-vsock virtio sockets device support
1798 opengl opengl support
1799 virglrenderer virgl rendering support
1800 xfsctl xfsctl support
1801 qom-cast-debug cast debugging support
1802 tools build qemu-io, qemu-nbd and qemu-img tools
1803 vxhs Veritas HyperScale vDisk backend support
1804 bochs bochs image format support
1805 cloop cloop image format support
1806 dmg dmg image format support
1807 qcow1 qcow v1 image format support
1808 vdi vdi image format support
1809 vvfat vvfat image format support
1810 qed qed image format support
1811 parallels parallels image format support
1812 sheepdog sheepdog block driver support
1813 crypto-afalg Linux AF_ALG crypto backend driver
1814 vhost-user vhost-user support
1815 capstone capstone disassembler support
1816 debug-mutex mutex debugging support
1817 libpmem libpmem support
1819 NOTE: The object files are built at the place where configure is launched
1821 exit 0
1824 if ! has $python; then
1825 error_exit "Python not found. Use --python=/path/to/python"
1828 # Note that if the Python conditional here evaluates True we will exit
1829 # with status 1 which is a shell 'false' value.
1830 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
1831 error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1832 "Use --python=/path/to/python to specify a supported Python."
1835 # Preserve python version since some functionality is dependent on it
1836 python_version=$($python -V 2>&1 | sed -e 's/Python\ //')
1838 # Suppress writing compiled files
1839 python="$python -B"
1841 # Check that the C compiler works. Doing this here before testing
1842 # the host CPU ensures that we had a valid CC to autodetect the
1843 # $cpu var (and we should bail right here if that's not the case).
1844 # It also allows the help message to be printed without a CC.
1845 write_c_skeleton;
1846 if compile_object ; then
1847 : C compiler works ok
1848 else
1849 error_exit "\"$cc\" either does not exist or does not work"
1851 if ! compile_prog ; then
1852 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1855 # Now we have handled --enable-tcg-interpreter and know we're not just
1856 # printing the help message, bail out if the host CPU isn't supported.
1857 if test "$ARCH" = "unknown"; then
1858 if test "$tcg_interpreter" = "yes" ; then
1859 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1860 else
1861 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1865 # Consult white-list to determine whether to enable werror
1866 # by default. Only enable by default for git builds
1867 if test -z "$werror" ; then
1868 if test -d "$source_path/.git" && \
1869 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1870 werror="yes"
1871 else
1872 werror="no"
1876 if test "$bogus_os" = "yes"; then
1877 # Now that we know that we're not printing the help and that
1878 # the compiler works (so the results of the check_defines we used
1879 # to identify the OS are reliable), if we didn't recognize the
1880 # host OS we should stop now.
1881 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1884 # Check whether the compiler matches our minimum requirements:
1885 cat > $TMPC << EOF
1886 #if defined(__clang_major__) && defined(__clang_minor__)
1887 # ifdef __apple_build_version__
1888 # if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1889 # error You need at least XCode Clang v5.1 to compile QEMU
1890 # endif
1891 # else
1892 # if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1893 # error You need at least Clang v3.4 to compile QEMU
1894 # endif
1895 # endif
1896 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1897 # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1898 # error You need at least GCC v4.8 to compile QEMU
1899 # endif
1900 #else
1901 # error You either need GCC or Clang to compiler QEMU
1902 #endif
1903 int main (void) { return 0; }
1905 if ! compile_prog "" "" ; then
1906 error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
1909 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1910 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1911 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1912 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1913 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1914 gcc_flags="-Wno-string-plus-int $gcc_flags"
1915 # Note that we do not add -Werror to gcc_flags here, because that would
1916 # enable it for all configure tests. If a configure test failed due
1917 # to -Werror this would just silently disable some features,
1918 # so it's too error prone.
1920 cc_has_warning_flag() {
1921 write_c_skeleton;
1923 # Use the positive sense of the flag when testing for -Wno-wombat
1924 # support (gcc will happily accept the -Wno- form of unknown
1925 # warning options).
1926 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1927 compile_prog "-Werror $optflag" ""
1930 for flag in $gcc_flags; do
1931 if cc_has_warning_flag $flag ; then
1932 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1934 done
1936 if test "$mingw32" = "yes"; then
1937 stack_protector="no"
1939 if test "$stack_protector" != "no"; then
1940 cat > $TMPC << EOF
1941 int main(int argc, char *argv[])
1943 char arr[64], *p = arr, *c = argv[0];
1944 while (*c) {
1945 *p++ = *c++;
1947 return 0;
1950 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1951 sp_on=0
1952 for flag in $gcc_flags; do
1953 # We need to check both a compile and a link, since some compiler
1954 # setups fail only on a .c->.o compile and some only at link time
1955 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1956 compile_prog "-Werror $flag" ""; then
1957 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1958 sp_on=1
1959 break
1961 done
1962 if test "$stack_protector" = yes; then
1963 if test $sp_on = 0; then
1964 error_exit "Stack protector not supported"
1969 # Disable -Wmissing-braces on older compilers that warn even for
1970 # the "universal" C zero initializer {0}.
1971 cat > $TMPC << EOF
1972 struct {
1973 int a[2];
1974 } x = {0};
1976 if compile_object "-Werror" "" ; then
1978 else
1979 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1982 # Static linking is not possible with modules or PIE
1983 if test "$static" = "yes" ; then
1984 if test "$modules" = "yes" ; then
1985 error_exit "static and modules are mutually incompatible"
1987 if test "$pie" = "yes" ; then
1988 error_exit "static and pie are mutually incompatible"
1989 else
1990 pie="no"
1994 # Unconditional check for compiler __thread support
1995 cat > $TMPC << EOF
1996 static __thread int tls_var;
1997 int main(void) { return tls_var; }
2000 if ! compile_prog "-Werror" "" ; then
2001 error_exit "Your compiler does not support the __thread specifier for " \
2002 "Thread-Local Storage (TLS). Please upgrade to a version that does."
2005 if test "$pie" = ""; then
2006 case "$cpu-$targetos" in
2007 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
2010 pie="no"
2012 esac
2015 if test "$pie" != "no" ; then
2016 cat > $TMPC << EOF
2018 #ifdef __linux__
2019 # define THREAD __thread
2020 #else
2021 # define THREAD
2022 #endif
2024 static THREAD int tls_var;
2026 int main(void) { return tls_var; }
2029 if compile_prog "-fPIE -DPIE" "-pie"; then
2030 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
2031 LDFLAGS="-pie $LDFLAGS"
2032 pie="yes"
2033 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2034 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
2036 else
2037 if test "$pie" = "yes"; then
2038 error_exit "PIE not available due to missing toolchain support"
2039 else
2040 echo "Disabling PIE due to missing toolchain support"
2041 pie="no"
2045 if compile_prog "-Werror -fno-pie" "-nopie"; then
2046 CFLAGS_NOPIE="-fno-pie"
2047 LDFLAGS_NOPIE="-nopie"
2051 ##########################################
2052 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
2053 # use i686 as default anyway, but for those that don't, an explicit
2054 # specification is necessary
2056 if test "$cpu" = "i386"; then
2057 cat > $TMPC << EOF
2058 static int sfaa(int *ptr)
2060 return __sync_fetch_and_and(ptr, 0);
2063 int main(void)
2065 int val = 42;
2066 val = __sync_val_compare_and_swap(&val, 0, 1);
2067 sfaa(&val);
2068 return val;
2071 if ! compile_prog "" "" ; then
2072 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2076 #########################################
2077 # Solaris specific configure tool chain decisions
2079 if test "$solaris" = "yes" ; then
2080 if has $install; then
2082 else
2083 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
2084 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
2085 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2087 if test "$(path_of $install)" = "/usr/sbin/install" ; then
2088 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
2089 "try ginstall from the GNU fileutils available from www.blastwave.org" \
2090 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2092 if has ar; then
2094 else
2095 if test -f /usr/ccs/bin/ar ; then
2096 error_exit "No path includes ar" \
2097 "Add /usr/ccs/bin to your path and rerun configure"
2099 error_exit "No path includes ar"
2103 if test -z "${target_list+xxx}" ; then
2104 for target in $default_target_list; do
2105 supported_target $target 2>/dev/null && \
2106 target_list="$target_list $target"
2107 done
2108 target_list="${target_list# }"
2109 else
2110 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2111 for target in $target_list; do
2112 # Check that we recognised the target name; this allows a more
2113 # friendly error message than if we let it fall through.
2114 case " $default_target_list " in
2115 *" $target "*)
2118 error_exit "Unknown target name '$target'"
2120 esac
2121 supported_target $target || exit 1
2122 done
2125 # see if system emulation was really requested
2126 case " $target_list " in
2127 *"-softmmu "*) softmmu=yes
2129 *) softmmu=no
2131 esac
2133 feature_not_found() {
2134 feature=$1
2135 remedy=$2
2137 error_exit "User requested feature $feature" \
2138 "configure was not able to find it." \
2139 "$remedy"
2142 # ---
2143 # big/little endian test
2144 cat > $TMPC << EOF
2145 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
2146 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2147 extern int foo(short *, short *);
2148 int main(int argc, char *argv[]) {
2149 return foo(big_endian, little_endian);
2153 if compile_object ; then
2154 if strings -a $TMPO | grep -q BiGeNdIaN ; then
2155 bigendian="yes"
2156 elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
2157 bigendian="no"
2158 else
2159 echo big/little test failed
2161 else
2162 echo big/little test failed
2165 ##########################################
2166 # cocoa implies not SDL or GTK
2167 # (the cocoa UI code currently assumes it is always the active UI
2168 # and doesn't interact well with other UI frontend code)
2169 if test "$cocoa" = "yes"; then
2170 if test "$sdl" = "yes"; then
2171 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2173 if test "$gtk" = "yes"; then
2174 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2176 gtk=no
2177 sdl=no
2180 # Some versions of Mac OS X incorrectly define SIZE_MAX
2181 cat > $TMPC << EOF
2182 #include <stdint.h>
2183 #include <stdio.h>
2184 int main(int argc, char *argv[]) {
2185 return printf("%zu", SIZE_MAX);
2188 have_broken_size_max=no
2189 if ! compile_object -Werror ; then
2190 have_broken_size_max=yes
2193 ##########################################
2194 # L2TPV3 probe
2196 cat > $TMPC <<EOF
2197 #include <sys/socket.h>
2198 #include <linux/ip.h>
2199 int main(void) { return sizeof(struct mmsghdr); }
2201 if compile_prog "" "" ; then
2202 l2tpv3=yes
2203 else
2204 l2tpv3=no
2207 ##########################################
2208 # MinGW / Mingw-w64 localtime_r/gmtime_r check
2210 if test "$mingw32" = "yes"; then
2211 # Some versions of MinGW / Mingw-w64 lack localtime_r
2212 # and gmtime_r entirely.
2214 # Some versions of Mingw-w64 define a macro for
2215 # localtime_r/gmtime_r.
2217 # Some versions of Mingw-w64 will define functions
2218 # for localtime_r/gmtime_r, but only if you have
2219 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
2220 # though, unistd.h and pthread.h both define
2221 # that for you.
2223 # So this #undef localtime_r and #include <unistd.h>
2224 # are not in fact redundant.
2225 cat > $TMPC << EOF
2226 #include <unistd.h>
2227 #include <time.h>
2228 #undef localtime_r
2229 int main(void) { localtime_r(NULL, NULL); return 0; }
2231 if compile_prog "" "" ; then
2232 localtime_r="yes"
2233 else
2234 localtime_r="no"
2238 ##########################################
2239 # pkg-config probe
2241 if ! has "$pkg_config_exe"; then
2242 error_exit "pkg-config binary '$pkg_config_exe' not found"
2245 ##########################################
2246 # NPTL probe
2248 if test "$linux_user" = "yes"; then
2249 cat > $TMPC <<EOF
2250 #include <sched.h>
2251 #include <linux/futex.h>
2252 int main(void) {
2253 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2254 #error bork
2255 #endif
2256 return 0;
2259 if ! compile_object ; then
2260 feature_not_found "nptl" "Install glibc and linux kernel headers."
2264 ##########################################
2265 # lzo check
2267 if test "$lzo" != "no" ; then
2268 cat > $TMPC << EOF
2269 #include <lzo/lzo1x.h>
2270 int main(void) { lzo_version(); return 0; }
2272 if compile_prog "" "-llzo2" ; then
2273 libs_softmmu="$libs_softmmu -llzo2"
2274 lzo="yes"
2275 else
2276 if test "$lzo" = "yes"; then
2277 feature_not_found "liblzo2" "Install liblzo2 devel"
2279 lzo="no"
2283 ##########################################
2284 # snappy check
2286 if test "$snappy" != "no" ; then
2287 cat > $TMPC << EOF
2288 #include <snappy-c.h>
2289 int main(void) { snappy_max_compressed_length(4096); return 0; }
2291 if compile_prog "" "-lsnappy" ; then
2292 libs_softmmu="$libs_softmmu -lsnappy"
2293 snappy="yes"
2294 else
2295 if test "$snappy" = "yes"; then
2296 feature_not_found "libsnappy" "Install libsnappy devel"
2298 snappy="no"
2302 ##########################################
2303 # bzip2 check
2305 if test "$bzip2" != "no" ; then
2306 cat > $TMPC << EOF
2307 #include <bzlib.h>
2308 int main(void) { BZ2_bzlibVersion(); return 0; }
2310 if compile_prog "" "-lbz2" ; then
2311 bzip2="yes"
2312 else
2313 if test "$bzip2" = "yes"; then
2314 feature_not_found "libbzip2" "Install libbzip2 devel"
2316 bzip2="no"
2320 ##########################################
2321 # lzfse check
2323 if test "$lzfse" != "no" ; then
2324 cat > $TMPC << EOF
2325 #include <lzfse.h>
2326 int main(void) { lzfse_decode_scratch_size(); return 0; }
2328 if compile_prog "" "-llzfse" ; then
2329 lzfse="yes"
2330 else
2331 if test "$lzfse" = "yes"; then
2332 feature_not_found "lzfse" "Install lzfse devel"
2334 lzfse="no"
2338 ##########################################
2339 # libseccomp check
2341 libseccomp_minver="2.2.0"
2342 if test "$seccomp" != "no" ; then
2343 case "$cpu" in
2344 i386|x86_64|mips)
2346 arm|aarch64)
2347 libseccomp_minver="2.2.3"
2349 ppc|ppc64|s390x)
2350 libseccomp_minver="2.3.0"
2353 libseccomp_minver=""
2355 esac
2357 if test "$libseccomp_minver" != "" &&
2358 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2359 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2360 seccomp_libs="$($pkg_config --libs libseccomp)"
2361 seccomp="yes"
2362 else
2363 if test "$seccomp" = "yes" ; then
2364 if test "$libseccomp_minver" != "" ; then
2365 feature_not_found "libseccomp" \
2366 "Install libseccomp devel >= $libseccomp_minver"
2367 else
2368 feature_not_found "libseccomp" \
2369 "libseccomp is not supported for host cpu $cpu"
2372 seccomp="no"
2375 ##########################################
2376 # xen probe
2378 if test "$xen" != "no" ; then
2379 # Check whether Xen library path is specified via --extra-ldflags to avoid
2380 # overriding this setting with pkg-config output. If not, try pkg-config
2381 # to obtain all needed flags.
2383 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2384 $pkg_config --exists xencontrol ; then
2385 xen_ctrl_version="$(printf '%d%02d%02d' \
2386 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2387 xen=yes
2388 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2389 xen_pc="$xen_pc xenevtchn xendevicemodel"
2390 if $pkg_config --exists xentoolcore; then
2391 xen_pc="$xen_pc xentoolcore"
2393 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2394 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2395 else
2397 xen_libs="-lxenstore -lxenctrl -lxenguest"
2398 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2400 # First we test whether Xen headers and libraries are available.
2401 # If no, we are done and there is no Xen support.
2402 # If yes, more tests are run to detect the Xen version.
2404 # Xen (any)
2405 cat > $TMPC <<EOF
2406 #include <xenctrl.h>
2407 int main(void) {
2408 return 0;
2411 if ! compile_prog "" "$xen_libs" ; then
2412 # Xen not found
2413 if test "$xen" = "yes" ; then
2414 feature_not_found "xen" "Install xen devel"
2416 xen=no
2418 # Xen unstable
2419 elif
2420 cat > $TMPC <<EOF &&
2421 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2422 #define __XEN_TOOLS__
2423 #include <xendevicemodel.h>
2424 #include <xenforeignmemory.h>
2425 int main(void) {
2426 xendevicemodel_handle *xd;
2427 xenforeignmemory_handle *xfmem;
2429 xd = xendevicemodel_open(0, 0);
2430 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2432 xfmem = xenforeignmemory_open(0, 0);
2433 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2435 return 0;
2438 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2439 then
2440 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2441 xen_ctrl_version=41100
2442 xen=yes
2443 elif
2444 cat > $TMPC <<EOF &&
2445 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2446 #include <xenforeignmemory.h>
2447 #include <xentoolcore.h>
2448 int main(void) {
2449 xenforeignmemory_handle *xfmem;
2451 xfmem = xenforeignmemory_open(0, 0);
2452 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2453 xentoolcore_restrict_all(0);
2455 return 0;
2458 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2459 then
2460 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2461 xen_ctrl_version=41000
2462 xen=yes
2463 elif
2464 cat > $TMPC <<EOF &&
2465 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2466 #define __XEN_TOOLS__
2467 #include <xendevicemodel.h>
2468 int main(void) {
2469 xendevicemodel_handle *xd;
2471 xd = xendevicemodel_open(0, 0);
2472 xendevicemodel_close(xd);
2474 return 0;
2477 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2478 then
2479 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2480 xen_ctrl_version=40900
2481 xen=yes
2482 elif
2483 cat > $TMPC <<EOF &&
2485 * If we have stable libs the we don't want the libxc compat
2486 * layers, regardless of what CFLAGS we may have been given.
2488 * Also, check if xengnttab_grant_copy_segment_t is defined and
2489 * grant copy operation is implemented.
2491 #undef XC_WANT_COMPAT_EVTCHN_API
2492 #undef XC_WANT_COMPAT_GNTTAB_API
2493 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2494 #include <xenctrl.h>
2495 #include <xenstore.h>
2496 #include <xenevtchn.h>
2497 #include <xengnttab.h>
2498 #include <xenforeignmemory.h>
2499 #include <stdint.h>
2500 #include <xen/hvm/hvm_info_table.h>
2501 #if !defined(HVM_MAX_VCPUS)
2502 # error HVM_MAX_VCPUS not defined
2503 #endif
2504 int main(void) {
2505 xc_interface *xc = NULL;
2506 xenforeignmemory_handle *xfmem;
2507 xenevtchn_handle *xe;
2508 xengnttab_handle *xg;
2509 xengnttab_grant_copy_segment_t* seg = NULL;
2511 xs_daemon_open();
2513 xc = xc_interface_open(0, 0, 0);
2514 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2515 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2516 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2517 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2519 xfmem = xenforeignmemory_open(0, 0);
2520 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2522 xe = xenevtchn_open(0, 0);
2523 xenevtchn_fd(xe);
2525 xg = xengnttab_open(0, 0);
2526 xengnttab_grant_copy(xg, 0, seg);
2528 return 0;
2531 compile_prog "" "$xen_libs $xen_stable_libs"
2532 then
2533 xen_ctrl_version=40800
2534 xen=yes
2535 elif
2536 cat > $TMPC <<EOF &&
2538 * If we have stable libs the we don't want the libxc compat
2539 * layers, regardless of what CFLAGS we may have been given.
2541 #undef XC_WANT_COMPAT_EVTCHN_API
2542 #undef XC_WANT_COMPAT_GNTTAB_API
2543 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2544 #include <xenctrl.h>
2545 #include <xenstore.h>
2546 #include <xenevtchn.h>
2547 #include <xengnttab.h>
2548 #include <xenforeignmemory.h>
2549 #include <stdint.h>
2550 #include <xen/hvm/hvm_info_table.h>
2551 #if !defined(HVM_MAX_VCPUS)
2552 # error HVM_MAX_VCPUS not defined
2553 #endif
2554 int main(void) {
2555 xc_interface *xc = NULL;
2556 xenforeignmemory_handle *xfmem;
2557 xenevtchn_handle *xe;
2558 xengnttab_handle *xg;
2560 xs_daemon_open();
2562 xc = xc_interface_open(0, 0, 0);
2563 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2564 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2565 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2566 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2568 xfmem = xenforeignmemory_open(0, 0);
2569 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2571 xe = xenevtchn_open(0, 0);
2572 xenevtchn_fd(xe);
2574 xg = xengnttab_open(0, 0);
2575 xengnttab_map_grant_ref(xg, 0, 0, 0);
2577 return 0;
2580 compile_prog "" "$xen_libs $xen_stable_libs"
2581 then
2582 xen_ctrl_version=40701
2583 xen=yes
2585 # Xen 4.6
2586 elif
2587 cat > $TMPC <<EOF &&
2588 #include <xenctrl.h>
2589 #include <xenstore.h>
2590 #include <stdint.h>
2591 #include <xen/hvm/hvm_info_table.h>
2592 #if !defined(HVM_MAX_VCPUS)
2593 # error HVM_MAX_VCPUS not defined
2594 #endif
2595 int main(void) {
2596 xc_interface *xc;
2597 xs_daemon_open();
2598 xc = xc_interface_open(0, 0, 0);
2599 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2600 xc_gnttab_open(NULL, 0);
2601 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2602 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2603 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2604 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2605 return 0;
2608 compile_prog "" "$xen_libs"
2609 then
2610 xen_ctrl_version=40600
2611 xen=yes
2613 # Xen 4.5
2614 elif
2615 cat > $TMPC <<EOF &&
2616 #include <xenctrl.h>
2617 #include <xenstore.h>
2618 #include <stdint.h>
2619 #include <xen/hvm/hvm_info_table.h>
2620 #if !defined(HVM_MAX_VCPUS)
2621 # error HVM_MAX_VCPUS not defined
2622 #endif
2623 int main(void) {
2624 xc_interface *xc;
2625 xs_daemon_open();
2626 xc = xc_interface_open(0, 0, 0);
2627 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2628 xc_gnttab_open(NULL, 0);
2629 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2630 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2631 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2632 return 0;
2635 compile_prog "" "$xen_libs"
2636 then
2637 xen_ctrl_version=40500
2638 xen=yes
2640 elif
2641 cat > $TMPC <<EOF &&
2642 #include <xenctrl.h>
2643 #include <xenstore.h>
2644 #include <stdint.h>
2645 #include <xen/hvm/hvm_info_table.h>
2646 #if !defined(HVM_MAX_VCPUS)
2647 # error HVM_MAX_VCPUS not defined
2648 #endif
2649 int main(void) {
2650 xc_interface *xc;
2651 xs_daemon_open();
2652 xc = xc_interface_open(0, 0, 0);
2653 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2654 xc_gnttab_open(NULL, 0);
2655 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2656 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2657 return 0;
2660 compile_prog "" "$xen_libs"
2661 then
2662 xen_ctrl_version=40200
2663 xen=yes
2665 else
2666 if test "$xen" = "yes" ; then
2667 feature_not_found "xen (unsupported version)" \
2668 "Install a supported xen (xen 4.2 or newer)"
2670 xen=no
2673 if test "$xen" = yes; then
2674 if test $xen_ctrl_version -ge 40701 ; then
2675 libs_softmmu="$xen_stable_libs $libs_softmmu"
2677 libs_softmmu="$xen_libs $libs_softmmu"
2682 if test "$xen_pci_passthrough" != "no"; then
2683 if test "$xen" = "yes" && test "$linux" = "yes"; then
2684 xen_pci_passthrough=yes
2685 else
2686 if test "$xen_pci_passthrough" = "yes"; then
2687 error_exit "User requested feature Xen PCI Passthrough" \
2688 " but this feature requires /sys from Linux"
2690 xen_pci_passthrough=no
2694 ##########################################
2695 # Windows Hypervisor Platform accelerator (WHPX) check
2696 if test "$whpx" != "no" ; then
2697 if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2698 whpx="yes"
2699 else
2700 if test "$whpx" = "yes"; then
2701 feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2703 whpx="no"
2707 ##########################################
2708 # Sparse probe
2709 if test "$sparse" != "no" ; then
2710 if has cgcc; then
2711 sparse=yes
2712 else
2713 if test "$sparse" = "yes" ; then
2714 feature_not_found "sparse" "Install sparse binary"
2716 sparse=no
2720 ##########################################
2721 # X11 probe
2722 if $pkg_config --exists "x11"; then
2723 have_x11=yes
2724 x11_cflags=$($pkg_config --cflags x11)
2725 x11_libs=$($pkg_config --libs x11)
2728 ##########################################
2729 # GTK probe
2731 if test "$gtk" != "no"; then
2732 gtkpackage="gtk+-3.0"
2733 gtkx11package="gtk+-x11-3.0"
2734 gtkversion="3.14.0"
2735 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2736 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2737 gtk_libs=$($pkg_config --libs $gtkpackage)
2738 gtk_version=$($pkg_config --modversion $gtkpackage)
2739 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2740 need_x11=yes
2741 gtk_cflags="$gtk_cflags $x11_cflags"
2742 gtk_libs="$gtk_libs $x11_libs"
2744 gtk="yes"
2745 elif test "$gtk" = "yes"; then
2746 feature_not_found "gtk" "Install gtk3-devel"
2747 else
2748 gtk="no"
2753 ##########################################
2754 # GNUTLS probe
2756 if test "$gnutls" != "no"; then
2757 if $pkg_config --exists "gnutls >= 3.1.18"; then
2758 gnutls_cflags=$($pkg_config --cflags gnutls)
2759 gnutls_libs=$($pkg_config --libs gnutls)
2760 libs_softmmu="$gnutls_libs $libs_softmmu"
2761 libs_tools="$gnutls_libs $libs_tools"
2762 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2763 gnutls="yes"
2764 elif test "$gnutls" = "yes"; then
2765 feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2766 else
2767 gnutls="no"
2772 # If user didn't give a --disable/enable-gcrypt flag,
2773 # then mark as disabled if user requested nettle
2774 # explicitly
2775 if test -z "$gcrypt"
2776 then
2777 if test "$nettle" = "yes"
2778 then
2779 gcrypt="no"
2783 # If user didn't give a --disable/enable-nettle flag,
2784 # then mark as disabled if user requested gcrypt
2785 # explicitly
2786 if test -z "$nettle"
2787 then
2788 if test "$gcrypt" = "yes"
2789 then
2790 nettle="no"
2794 has_libgcrypt() {
2795 if ! has "libgcrypt-config"
2796 then
2797 return 1
2800 if test -n "$cross_prefix"
2801 then
2802 host=$(libgcrypt-config --host)
2803 if test "$host-" != $cross_prefix
2804 then
2805 return 1
2809 maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2810 min=`libgcrypt-config --version | awk -F . '{print $2}'`
2812 if test $maj != 1 || test $min -lt 5
2813 then
2814 return 1
2817 return 0
2821 if test "$nettle" != "no"; then
2822 if $pkg_config --exists "nettle >= 2.7.1"; then
2823 nettle_cflags=$($pkg_config --cflags nettle)
2824 nettle_libs=$($pkg_config --libs nettle)
2825 nettle_version=$($pkg_config --modversion nettle)
2826 libs_softmmu="$nettle_libs $libs_softmmu"
2827 libs_tools="$nettle_libs $libs_tools"
2828 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2829 nettle="yes"
2831 if test -z "$gcrypt"; then
2832 gcrypt="no"
2834 else
2835 if test "$nettle" = "yes"; then
2836 feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2837 else
2838 nettle="no"
2843 if test "$gcrypt" != "no"; then
2844 if has_libgcrypt; then
2845 gcrypt_cflags=$(libgcrypt-config --cflags)
2846 gcrypt_libs=$(libgcrypt-config --libs)
2847 # Debian has remove -lgpg-error from libgcrypt-config
2848 # as it "spreads unnecessary dependencies" which in
2849 # turn breaks static builds...
2850 if test "$static" = "yes"
2851 then
2852 gcrypt_libs="$gcrypt_libs -lgpg-error"
2854 libs_softmmu="$gcrypt_libs $libs_softmmu"
2855 libs_tools="$gcrypt_libs $libs_tools"
2856 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2857 gcrypt="yes"
2859 cat > $TMPC << EOF
2860 #include <gcrypt.h>
2861 int main(void) {
2862 gcry_mac_hd_t handle;
2863 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2864 GCRY_MAC_FLAG_SECURE, NULL);
2865 return 0;
2868 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2869 gcrypt_hmac=yes
2871 else
2872 if test "$gcrypt" = "yes"; then
2873 feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
2874 else
2875 gcrypt="no"
2881 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2882 then
2883 error_exit "Only one of gcrypt & nettle can be enabled"
2886 ##########################################
2887 # libtasn1 - only for the TLS creds/session test suite
2889 tasn1=yes
2890 tasn1_cflags=""
2891 tasn1_libs=""
2892 if $pkg_config --exists "libtasn1"; then
2893 tasn1_cflags=$($pkg_config --cflags libtasn1)
2894 tasn1_libs=$($pkg_config --libs libtasn1)
2895 else
2896 tasn1=no
2900 ##########################################
2901 # getifaddrs (for tests/test-io-channel-socket )
2903 have_ifaddrs_h=yes
2904 if ! check_include "ifaddrs.h" ; then
2905 have_ifaddrs_h=no
2908 ##########################################
2909 # VTE probe
2911 if test "$vte" != "no"; then
2912 vteminversion="0.32.0"
2913 if $pkg_config --exists "vte-2.91"; then
2914 vtepackage="vte-2.91"
2915 else
2916 vtepackage="vte-2.90"
2918 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2919 vte_cflags=$($pkg_config --cflags $vtepackage)
2920 vte_libs=$($pkg_config --libs $vtepackage)
2921 vteversion=$($pkg_config --modversion $vtepackage)
2922 vte="yes"
2923 elif test "$vte" = "yes"; then
2924 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2925 else
2926 vte="no"
2930 ##########################################
2931 # SDL probe
2933 # Look for sdl configuration program (pkg-config or sdl-config). Try
2934 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2936 sdl_probe ()
2938 if $pkg_config sdl2 --exists; then
2939 sdlconfig="$pkg_config sdl2"
2940 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2941 elif has ${sdl_config}; then
2942 sdlconfig="$sdl2_config"
2943 sdlversion=$($sdlconfig --version)
2944 else
2945 if test "$sdl" = "yes" ; then
2946 feature_not_found "sdl" "Install SDL2-devel"
2948 sdl=no
2949 # no need to do the rest
2950 return
2952 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2953 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2956 cat > $TMPC << EOF
2957 #include <SDL.h>
2958 #undef main /* We don't want SDL to override our main() */
2959 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2961 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2962 sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
2963 if test "$static" = "yes" ; then
2964 if $pkg_config sdl2 --exists; then
2965 sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
2966 else
2967 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2969 else
2970 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2972 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2973 sdl=yes
2975 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2976 if test "$sdl" = "yes" && test "$static" = "yes" ; then
2977 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2978 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2979 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2981 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2983 else
2984 sdl=no
2986 fi # static link
2987 else # sdl not found
2988 if test "$sdl" = "yes" ; then
2989 feature_not_found "sdl" "Install SDL2 devel"
2991 sdl=no
2992 fi # sdl compile test
2995 sdl_image_probe ()
2997 if test "$sdl_image" != "no" ; then
2998 if $pkg_config SDL2_image --exists; then
2999 if test "$static" = "yes"; then
3000 sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3001 else
3002 sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3004 sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3005 sdl_image=yes
3007 sdl_cflags="$sdl_cflags $sdl_image_cflags"
3008 sdl_libs="$sdl_libs $sdl_image_libs"
3009 else
3010 if test "$sdl_image" = "yes" ; then
3011 feature_not_found "sdl_image" "Install SDL Image devel"
3012 else
3013 sdl_image=no
3019 if test "$sdl" != "no" ; then
3020 sdl_probe
3023 if test "$sdl" = "yes" ; then
3024 sdl_image_probe
3025 else
3026 if test "$sdl_image" = "yes"; then
3027 echo "warning: SDL Image requested, but SDL is not available, disabling"
3029 sdl_image=no
3032 if test "$sdl" = "yes" ; then
3033 cat > $TMPC <<EOF
3034 #include <SDL.h>
3035 #if defined(SDL_VIDEO_DRIVER_X11)
3036 #include <X11/XKBlib.h>
3037 #else
3038 #error No x11 support
3039 #endif
3040 int main(void) { return 0; }
3042 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
3043 need_x11=yes
3044 sdl_cflags="$sdl_cflags $x11_cflags"
3045 sdl_libs="$sdl_libs $x11_libs"
3049 ##########################################
3050 # RDMA needs OpenFabrics libraries
3051 if test "$rdma" != "no" ; then
3052 cat > $TMPC <<EOF
3053 #include <rdma/rdma_cma.h>
3054 int main(void) { return 0; }
3056 rdma_libs="-lrdmacm -libverbs -libumad"
3057 if compile_prog "" "$rdma_libs" ; then
3058 rdma="yes"
3059 libs_softmmu="$libs_softmmu $rdma_libs"
3060 else
3061 if test "$rdma" = "yes" ; then
3062 error_exit \
3063 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
3064 " Your options:" \
3065 " (1) Fast: Install infiniband packages (devel) from your distro." \
3066 " (2) Cleanest: Install libraries from www.openfabrics.org" \
3067 " (3) Also: Install softiwarp if you don't have RDMA hardware"
3069 rdma="no"
3073 ##########################################
3074 # PVRDMA detection
3076 cat > $TMPC <<EOF &&
3077 #include <sys/mman.h>
3080 main(void)
3082 char buf = 0;
3083 void *addr = &buf;
3084 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
3086 return 0;
3090 if test "$rdma" = "yes" ; then
3091 case "$pvrdma" in
3093 if compile_prog "" ""; then
3094 pvrdma="yes"
3095 else
3096 pvrdma="no"
3099 "yes")
3100 if ! compile_prog "" ""; then
3101 error_exit "PVRDMA is not supported since mremap is not implemented"
3103 pvrdma="yes"
3105 "no")
3106 pvrdma="no"
3108 esac
3109 else
3110 if test "$pvrdma" = "yes" ; then
3111 error_exit "PVRDMA requires rdma suppport"
3113 pvrdma="no"
3116 ##########################################
3117 # VNC SASL detection
3118 if test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
3119 cat > $TMPC <<EOF
3120 #include <sasl/sasl.h>
3121 #include <stdio.h>
3122 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
3124 # Assuming Cyrus-SASL installed in /usr prefix
3125 vnc_sasl_cflags=""
3126 vnc_sasl_libs="-lsasl2"
3127 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3128 vnc_sasl=yes
3129 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3130 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
3131 else
3132 if test "$vnc_sasl" = "yes" ; then
3133 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3135 vnc_sasl=no
3139 ##########################################
3140 # VNC JPEG detection
3141 if test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
3142 if $pkg_config --exists libjpeg; then
3143 vnc_jpeg=yes
3144 libs_softmmu="$libs_softmmu $($pkg_config --libs libjpeg)"
3145 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libjpeg)"
3146 else
3147 cat > $TMPC <<EOF
3148 #include <stdio.h>
3149 #include <jpeglib.h>
3150 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
3152 vnc_jpeg_cflags=""
3153 vnc_jpeg_libs="-ljpeg"
3154 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
3155 vnc_jpeg=yes
3156 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3157 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
3158 else
3159 if test "$vnc_jpeg" = "yes" ; then
3160 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
3162 vnc_jpeg=no
3167 ##########################################
3168 # VNC PNG detection
3169 if test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
3170 cat > $TMPC <<EOF
3171 //#include <stdio.h>
3172 #include <png.h>
3173 #include <stddef.h>
3174 int main(void) {
3175 png_structp png_ptr;
3176 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
3177 return png_ptr != 0;
3180 if $pkg_config libpng --exists; then
3181 vnc_png_cflags=$($pkg_config libpng --cflags)
3182 vnc_png_libs=$($pkg_config libpng --libs)
3183 else
3184 vnc_png_cflags=""
3185 vnc_png_libs="-lpng"
3187 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3188 vnc_png=yes
3189 libs_softmmu="$vnc_png_libs $libs_softmmu"
3190 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3191 else
3192 if test "$vnc_png" = "yes" ; then
3193 feature_not_found "vnc-png" "Install libpng devel"
3195 vnc_png=no
3199 ##########################################
3200 # xkbcommon probe
3201 if test "$xkbcommon" != "no" ; then
3202 if $pkg_config xkbcommon --exists; then
3203 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
3204 xkbcommon_libs=$($pkg_config xkbcommon --libs)
3205 xkbcommon=yes
3206 else
3207 if test "$xkbcommon" = "yes" ; then
3208 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
3210 xkbcommon=no
3214 ##########################################
3215 # fnmatch() probe, used for ACL routines
3216 fnmatch="no"
3217 cat > $TMPC << EOF
3218 #include <fnmatch.h>
3219 int main(void)
3221 fnmatch("foo", "foo", 0);
3222 return 0;
3225 if compile_prog "" "" ; then
3226 fnmatch="yes"
3229 ##########################################
3230 # xfsctl() probe, used for file-posix.c
3231 if test "$xfs" != "no" ; then
3232 cat > $TMPC << EOF
3233 #include <stddef.h> /* NULL */
3234 #include <xfs/xfs.h>
3235 int main(void)
3237 xfsctl(NULL, 0, 0, NULL);
3238 return 0;
3241 if compile_prog "" "" ; then
3242 xfs="yes"
3243 else
3244 if test "$xfs" = "yes" ; then
3245 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3247 xfs=no
3251 ##########################################
3252 # vde libraries probe
3253 if test "$vde" != "no" ; then
3254 vde_libs="-lvdeplug"
3255 cat > $TMPC << EOF
3256 #include <stddef.h>
3257 #include <libvdeplug.h>
3258 int main(void)
3260 struct vde_open_args a = {0, 0, 0};
3261 char s[] = "";
3262 vde_open(s, s, &a);
3263 return 0;
3266 if compile_prog "" "$vde_libs" ; then
3267 vde=yes
3268 else
3269 if test "$vde" = "yes" ; then
3270 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3272 vde=no
3276 ##########################################
3277 # netmap support probe
3278 # Apart from looking for netmap headers, we make sure that the host API version
3279 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3280 # a minor/major version number. Minor new features will be marked with values up
3281 # to 15, and if something happens that requires a change to the backend we will
3282 # move above 15, submit the backend fixes and modify this two bounds.
3283 if test "$netmap" != "no" ; then
3284 cat > $TMPC << EOF
3285 #include <inttypes.h>
3286 #include <net/if.h>
3287 #include <net/netmap.h>
3288 #include <net/netmap_user.h>
3289 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3290 #error
3291 #endif
3292 int main(void) { return 0; }
3294 if compile_prog "" "" ; then
3295 netmap=yes
3296 else
3297 if test "$netmap" = "yes" ; then
3298 feature_not_found "netmap"
3300 netmap=no
3304 ##########################################
3305 # libcap-ng library probe
3306 if test "$cap_ng" != "no" ; then
3307 cap_libs="-lcap-ng"
3308 cat > $TMPC << EOF
3309 #include <cap-ng.h>
3310 int main(void)
3312 capng_capability_to_name(CAPNG_EFFECTIVE);
3313 return 0;
3316 if compile_prog "" "$cap_libs" ; then
3317 cap_ng=yes
3318 libs_tools="$cap_libs $libs_tools"
3319 else
3320 if test "$cap_ng" = "yes" ; then
3321 feature_not_found "cap_ng" "Install libcap-ng devel"
3323 cap_ng=no
3327 ##########################################
3328 # Sound support libraries probe
3330 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3331 for drv in $audio_drv_list; do
3332 case $drv in
3333 alsa | try-alsa)
3334 if $pkg_config alsa --exists; then
3335 alsa_libs=$($pkg_config alsa --libs)
3336 if test "$drv" = "try-alsa"; then
3337 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3339 else
3340 if test "$drv" = "try-alsa"; then
3341 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3342 else
3343 error_exit "$drv check failed" \
3344 "Make sure to have the $drv libs and headers installed."
3349 pa | try-pa)
3350 if $pkg_config libpulse --exists; then
3351 pulse_libs=$($pkg_config libpulse --libs)
3352 audio_pt_int="yes"
3353 if test "$drv" = "try-pa"; then
3354 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3356 else
3357 if test "$drv" = "try-pa"; then
3358 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3359 else
3360 error_exit "$drv check failed" \
3361 "Make sure to have the $drv libs and headers installed."
3366 sdl)
3367 if test "$sdl" = "no"; then
3368 error_exit "sdl not found or disabled, can not use sdl audio driver"
3372 try-sdl)
3373 if test "$sdl" = "no"; then
3374 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3375 else
3376 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3380 coreaudio)
3381 coreaudio_libs="-framework CoreAudio"
3384 dsound)
3385 dsound_libs="-lole32 -ldxguid"
3386 audio_win_int="yes"
3389 oss)
3390 oss_libs="$oss_lib"
3394 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3395 error_exit "Unknown driver '$drv' selected" \
3396 "Possible drivers are: $audio_possible_drivers"
3399 esac
3400 done
3402 ##########################################
3403 # BrlAPI probe
3405 if test "$brlapi" != "no" ; then
3406 brlapi_libs="-lbrlapi"
3407 cat > $TMPC << EOF
3408 #include <brlapi.h>
3409 #include <stddef.h>
3410 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3412 if compile_prog "" "$brlapi_libs" ; then
3413 brlapi=yes
3414 else
3415 if test "$brlapi" = "yes" ; then
3416 feature_not_found "brlapi" "Install brlapi devel"
3418 brlapi=no
3422 ##########################################
3423 # curses probe
3424 if test "$curses" != "no" ; then
3425 if test "$mingw32" = "yes" ; then
3426 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3427 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3428 else
3429 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3430 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3432 curses_found=no
3433 cat > $TMPC << EOF
3434 #include <locale.h>
3435 #include <curses.h>
3436 #include <wchar.h>
3437 int main(void) {
3438 wchar_t wch = L'w';
3439 setlocale(LC_ALL, "");
3440 resize_term(0, 0);
3441 addwstr(L"wide chars\n");
3442 addnwstr(&wch, 1);
3443 add_wch(WACS_DEGREE);
3444 return 0;
3447 IFS=:
3448 for curses_inc in $curses_inc_list; do
3449 # Make sure we get the wide character prototypes
3450 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3451 IFS=:
3452 for curses_lib in $curses_lib_list; do
3453 unset IFS
3454 if compile_prog "$curses_inc" "$curses_lib" ; then
3455 curses_found=yes
3456 break
3458 done
3459 if test "$curses_found" = yes ; then
3460 break
3462 done
3463 unset IFS
3464 if test "$curses_found" = "yes" ; then
3465 curses=yes
3466 else
3467 if test "$curses" = "yes" ; then
3468 feature_not_found "curses" "Install ncurses devel"
3470 curses=no
3474 ##########################################
3475 # curl probe
3476 if test "$curl" != "no" ; then
3477 if $pkg_config libcurl --exists; then
3478 curlconfig="$pkg_config libcurl"
3479 else
3480 curlconfig=curl-config
3482 cat > $TMPC << EOF
3483 #include <curl/curl.h>
3484 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3486 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3487 curl_libs=$($curlconfig --libs 2>/dev/null)
3488 if compile_prog "$curl_cflags" "$curl_libs" ; then
3489 curl=yes
3490 else
3491 if test "$curl" = "yes" ; then
3492 feature_not_found "curl" "Install libcurl devel"
3494 curl=no
3496 fi # test "$curl"
3498 ##########################################
3499 # bluez support probe
3500 if test "$bluez" != "no" ; then
3501 cat > $TMPC << EOF
3502 #include <bluetooth/bluetooth.h>
3503 int main(void) { return bt_error(0); }
3505 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3506 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3507 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3508 bluez=yes
3509 libs_softmmu="$bluez_libs $libs_softmmu"
3510 else
3511 if test "$bluez" = "yes" ; then
3512 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3514 bluez="no"
3518 ##########################################
3519 # glib support probe
3521 glib_req_ver=2.40
3522 glib_modules=gthread-2.0
3523 if test "$modules" = yes; then
3524 glib_modules="$glib_modules gmodule-export-2.0"
3527 # This workaround is required due to a bug in pkg-config file for glib as it
3528 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3530 if test "$static" = yes && test "$mingw32" = yes; then
3531 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3534 for i in $glib_modules; do
3535 if $pkg_config --atleast-version=$glib_req_ver $i; then
3536 glib_cflags=$($pkg_config --cflags $i)
3537 glib_libs=$($pkg_config --libs $i)
3538 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3539 LIBS="$glib_libs $LIBS"
3540 libs_qga="$glib_libs $libs_qga"
3541 else
3542 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3544 done
3546 # Sanity check that the current size_t matches the
3547 # size that glib thinks it should be. This catches
3548 # problems on multi-arch where people try to build
3549 # 32-bit QEMU while pointing at 64-bit glib headers
3550 cat > $TMPC <<EOF
3551 #include <glib.h>
3552 #include <unistd.h>
3554 #define QEMU_BUILD_BUG_ON(x) \
3555 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3557 int main(void) {
3558 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3559 return 0;
3563 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3564 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3565 "You probably need to set PKG_CONFIG_LIBDIR"\
3566 "to point to the right pkg-config files for your"\
3567 "build target"
3570 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3571 cat > $TMPC << EOF
3572 #include <glib.h>
3573 int main(void) { return 0; }
3575 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3576 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3577 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3578 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3582 #########################################
3583 # zlib check
3585 if test "$zlib" != "no" ; then
3586 if $pkg_config --exists zlib; then
3587 zlib_cflags=$($pkg_config --cflags zlib)
3588 zlib_libs=$($pkg_config --libs zlib)
3589 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3590 LIBS="$zlib_libs $LIBS"
3591 else
3592 cat > $TMPC << EOF
3593 #include <zlib.h>
3594 int main(void) { zlibVersion(); return 0; }
3596 if compile_prog "" "-lz" ; then
3597 LIBS="$LIBS -lz"
3598 else
3599 error_exit "zlib check failed" \
3600 "Make sure to have the zlib libs and headers installed."
3605 ##########################################
3606 # SHA command probe for modules
3607 if test "$modules" = yes; then
3608 shacmd_probe="sha1sum sha1 shasum"
3609 for c in $shacmd_probe; do
3610 if has $c; then
3611 shacmd="$c"
3612 break
3614 done
3615 if test "$shacmd" = ""; then
3616 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3620 ##########################################
3621 # pixman support probe
3623 if test "$want_tools" = "no" && test "$softmmu" = "no"; then
3624 pixman_cflags=
3625 pixman_libs=
3626 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3627 pixman_cflags=$($pkg_config --cflags pixman-1)
3628 pixman_libs=$($pkg_config --libs pixman-1)
3629 else
3630 error_exit "pixman >= 0.21.8 not present." \
3631 "Please install the pixman devel package."
3634 ##########################################
3635 # libmpathpersist probe
3637 if test "$mpath" != "no" ; then
3638 # probe for the new API
3639 cat > $TMPC <<EOF
3640 #include <libudev.h>
3641 #include <mpath_persist.h>
3642 unsigned mpath_mx_alloc_len = 1024;
3643 int logsink;
3644 static struct config *multipath_conf;
3645 extern struct udev *udev;
3646 extern struct config *get_multipath_config(void);
3647 extern void put_multipath_config(struct config *conf);
3648 struct udev *udev;
3649 struct config *get_multipath_config(void) { return multipath_conf; }
3650 void put_multipath_config(struct config *conf) { }
3652 int main(void) {
3653 udev = udev_new();
3654 multipath_conf = mpath_lib_init();
3655 return 0;
3658 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3659 mpathpersist=yes
3660 mpathpersist_new_api=yes
3661 else
3662 # probe for the old API
3663 cat > $TMPC <<EOF
3664 #include <libudev.h>
3665 #include <mpath_persist.h>
3666 unsigned mpath_mx_alloc_len = 1024;
3667 int logsink;
3668 int main(void) {
3669 struct udev *udev = udev_new();
3670 mpath_lib_init(udev);
3671 return 0;
3674 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3675 mpathpersist=yes
3676 mpathpersist_new_api=no
3677 else
3678 mpathpersist=no
3681 else
3682 mpathpersist=no
3685 ##########################################
3686 # libcap probe
3688 if test "$cap" != "no" ; then
3689 cat > $TMPC <<EOF
3690 #include <stdio.h>
3691 #include <sys/capability.h>
3692 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3694 if compile_prog "" "-lcap" ; then
3695 cap=yes
3696 else
3697 cap=no
3701 ##########################################
3702 # pthread probe
3703 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3705 pthread=no
3706 cat > $TMPC << EOF
3707 #include <pthread.h>
3708 static void *f(void *p) { return NULL; }
3709 int main(void) {
3710 pthread_t thread;
3711 pthread_create(&thread, 0, f, 0);
3712 return 0;
3715 if compile_prog "" "" ; then
3716 pthread=yes
3717 else
3718 for pthread_lib in $PTHREADLIBS_LIST; do
3719 if compile_prog "" "$pthread_lib" ; then
3720 pthread=yes
3721 found=no
3722 for lib_entry in $LIBS; do
3723 if test "$lib_entry" = "$pthread_lib"; then
3724 found=yes
3725 break
3727 done
3728 if test "$found" = "no"; then
3729 LIBS="$pthread_lib $LIBS"
3730 libs_qga="$pthread_lib $libs_qga"
3732 PTHREAD_LIB="$pthread_lib"
3733 break
3735 done
3738 if test "$mingw32" != yes && test "$pthread" = no; then
3739 error_exit "pthread check failed" \
3740 "Make sure to have the pthread libs and headers installed."
3743 # check for pthread_setname_np with thread id
3744 pthread_setname_np_w_tid=no
3745 cat > $TMPC << EOF
3746 #include <pthread.h>
3748 static void *f(void *p) { return NULL; }
3749 int main(void)
3751 pthread_t thread;
3752 pthread_create(&thread, 0, f, 0);
3753 pthread_setname_np(thread, "QEMU");
3754 return 0;
3757 if compile_prog "" "$pthread_lib" ; then
3758 pthread_setname_np_w_tid=yes
3761 # check for pthread_setname_np without thread id
3762 pthread_setname_np_wo_tid=no
3763 cat > $TMPC << EOF
3764 #include <pthread.h>
3766 static void *f(void *p) { pthread_setname_np("QEMU"); }
3767 int main(void)
3769 pthread_t thread;
3770 pthread_create(&thread, 0, f, 0);
3771 return 0;
3774 if compile_prog "" "$pthread_lib" ; then
3775 pthread_setname_np_wo_tid=yes
3778 ##########################################
3779 # rbd probe
3780 if test "$rbd" != "no" ; then
3781 cat > $TMPC <<EOF
3782 #include <stdio.h>
3783 #include <rbd/librbd.h>
3784 int main(void) {
3785 rados_t cluster;
3786 rados_create(&cluster, NULL);
3787 return 0;
3790 rbd_libs="-lrbd -lrados"
3791 if compile_prog "" "$rbd_libs" ; then
3792 rbd=yes
3793 else
3794 if test "$rbd" = "yes" ; then
3795 feature_not_found "rados block device" "Install librbd/ceph devel"
3797 rbd=no
3801 ##########################################
3802 # libssh2 probe
3803 min_libssh2_version=1.2.8
3804 if test "$libssh2" != "no" ; then
3805 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3806 libssh2_cflags=$($pkg_config libssh2 --cflags)
3807 libssh2_libs=$($pkg_config libssh2 --libs)
3808 libssh2=yes
3809 else
3810 if test "$libssh2" = "yes" ; then
3811 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3813 libssh2=no
3817 ##########################################
3818 # libssh2_sftp_fsync probe
3820 if test "$libssh2" = "yes"; then
3821 cat > $TMPC <<EOF
3822 #include <stdio.h>
3823 #include <libssh2.h>
3824 #include <libssh2_sftp.h>
3825 int main(void) {
3826 LIBSSH2_SESSION *session;
3827 LIBSSH2_SFTP *sftp;
3828 LIBSSH2_SFTP_HANDLE *sftp_handle;
3829 session = libssh2_session_init ();
3830 sftp = libssh2_sftp_init (session);
3831 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3832 libssh2_sftp_fsync (sftp_handle);
3833 return 0;
3836 # libssh2_cflags/libssh2_libs defined in previous test.
3837 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3838 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3842 ##########################################
3843 # linux-aio probe
3845 if test "$linux_aio" != "no" ; then
3846 cat > $TMPC <<EOF
3847 #include <libaio.h>
3848 #include <sys/eventfd.h>
3849 #include <stddef.h>
3850 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3852 if compile_prog "" "-laio" ; then
3853 linux_aio=yes
3854 else
3855 if test "$linux_aio" = "yes" ; then
3856 feature_not_found "linux AIO" "Install libaio devel"
3858 linux_aio=no
3862 ##########################################
3863 # TPM passthrough is only on x86 Linux
3865 if test "$targetos" = Linux && { test "$cpu" = i386 || test "$cpu" = x86_64; }; then
3866 tpm_passthrough=$tpm
3867 else
3868 tpm_passthrough=no
3871 # TPM emulator is for all posix systems
3872 if test "$mingw32" != "yes"; then
3873 tpm_emulator=$tpm
3874 else
3875 tpm_emulator=no
3877 ##########################################
3878 # attr probe
3880 if test "$attr" != "no" ; then
3881 cat > $TMPC <<EOF
3882 #include <stdio.h>
3883 #include <sys/types.h>
3884 #ifdef CONFIG_LIBATTR
3885 #include <attr/xattr.h>
3886 #else
3887 #include <sys/xattr.h>
3888 #endif
3889 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3891 if compile_prog "" "" ; then
3892 attr=yes
3893 # Older distros have <attr/xattr.h>, and need -lattr:
3894 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3895 attr=yes
3896 LIBS="-lattr $LIBS"
3897 libattr=yes
3898 else
3899 if test "$attr" = "yes" ; then
3900 feature_not_found "ATTR" "Install libc6 or libattr devel"
3902 attr=no
3906 ##########################################
3907 # iovec probe
3908 cat > $TMPC <<EOF
3909 #include <sys/types.h>
3910 #include <sys/uio.h>
3911 #include <unistd.h>
3912 int main(void) { return sizeof(struct iovec); }
3914 iovec=no
3915 if compile_prog "" "" ; then
3916 iovec=yes
3919 ##########################################
3920 # preadv probe
3921 cat > $TMPC <<EOF
3922 #include <sys/types.h>
3923 #include <sys/uio.h>
3924 #include <unistd.h>
3925 int main(void) { return preadv(0, 0, 0, 0); }
3927 preadv=no
3928 if compile_prog "" "" ; then
3929 preadv=yes
3932 ##########################################
3933 # fdt probe
3934 # fdt support is mandatory for at least some target architectures,
3935 # so insist on it if we're building those system emulators.
3936 fdt_required=no
3937 for target in $target_list; do
3938 case $target in
3939 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
3940 fdt_required=yes
3942 esac
3943 done
3945 if test "$fdt_required" = "yes"; then
3946 if test "$fdt" = "no"; then
3947 error_exit "fdt disabled but some requested targets require it." \
3948 "You can turn off fdt only if you also disable all the system emulation" \
3949 "targets which need it (by specifying a cut down --target-list)."
3951 fdt=yes
3954 if test "$fdt" != "no" ; then
3955 fdt_libs="-lfdt"
3956 # explicitly check for libfdt_env.h as it is missing in some stable installs
3957 # and test for required functions to make sure we are on a version >= 1.4.2
3958 cat > $TMPC << EOF
3959 #include <libfdt.h>
3960 #include <libfdt_env.h>
3961 int main(void) { fdt_check_full(NULL, 0); return 0; }
3963 if compile_prog "" "$fdt_libs" ; then
3964 # system DTC is good - use it
3965 fdt=system
3966 else
3967 # have GIT checkout, so activate dtc submodule
3968 if test -e "${source_path}/.git" ; then
3969 git_submodules="${git_submodules} dtc"
3971 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3972 fdt=git
3973 mkdir -p dtc
3974 if [ "$pwd_is_source_path" != "y" ] ; then
3975 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3976 symlink "$source_path/dtc/scripts" "dtc/scripts"
3978 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3979 fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
3980 fdt_libs="$fdt_libs"
3981 elif test "$fdt" = "yes" ; then
3982 # Not a git build & no libfdt found, prompt for system install
3983 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3984 "Please install the DTC (libfdt) devel package"
3985 else
3986 # don't have and don't want
3987 fdt_libs=
3988 fdt=no
3993 libs_softmmu="$libs_softmmu $fdt_libs"
3995 ##########################################
3996 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3998 if test "$opengl" != "no" ; then
3999 opengl_pkgs="epoxy gbm"
4000 if $pkg_config $opengl_pkgs; then
4001 opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
4002 opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4003 opengl=yes
4004 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4005 gtk_gl="yes"
4007 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
4008 else
4009 if test "$opengl" = "yes" ; then
4010 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
4012 opengl_cflags=""
4013 opengl_libs=""
4014 opengl=no
4018 if test "$opengl" = "yes"; then
4019 cat > $TMPC << EOF
4020 #include <epoxy/egl.h>
4021 #ifndef EGL_MESA_image_dma_buf_export
4022 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4023 #endif
4024 int main(void) { return 0; }
4026 if compile_prog "" "" ; then
4027 opengl_dmabuf=yes
4031 if test "$opengl" = "yes" && test "$have_x11" = "yes"; then
4032 for target in $target_list; do
4033 case $target in
4034 lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
4035 need_x11=yes
4037 esac
4038 done
4041 ##########################################
4042 # libxml2 probe
4043 if test "$libxml2" != "no" ; then
4044 if $pkg_config --exists libxml-2.0; then
4045 libxml2="yes"
4046 libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4047 libxml2_libs=$($pkg_config --libs libxml-2.0)
4048 else
4049 if test "$libxml2" = "yes"; then
4050 feature_not_found "libxml2" "Install libxml2 devel"
4052 libxml2="no"
4056 ##########################################
4057 # glusterfs probe
4058 if test "$glusterfs" != "no" ; then
4059 if $pkg_config --atleast-version=3 glusterfs-api; then
4060 glusterfs="yes"
4061 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
4062 glusterfs_libs=$($pkg_config --libs glusterfs-api)
4063 if $pkg_config --atleast-version=4 glusterfs-api; then
4064 glusterfs_xlator_opt="yes"
4066 if $pkg_config --atleast-version=5 glusterfs-api; then
4067 glusterfs_discard="yes"
4069 if $pkg_config --atleast-version=6 glusterfs-api; then
4070 glusterfs_fallocate="yes"
4071 glusterfs_zerofill="yes"
4073 else
4074 if test "$glusterfs" = "yes" ; then
4075 feature_not_found "GlusterFS backend support" \
4076 "Install glusterfs-api devel >= 3"
4078 glusterfs="no"
4082 # Check for inotify functions when we are building linux-user
4083 # emulator. This is done because older glibc versions don't
4084 # have syscall stubs for these implemented. In that case we
4085 # don't provide them even if kernel supports them.
4087 inotify=no
4088 cat > $TMPC << EOF
4089 #include <sys/inotify.h>
4092 main(void)
4094 /* try to start inotify */
4095 return inotify_init();
4098 if compile_prog "" "" ; then
4099 inotify=yes
4102 inotify1=no
4103 cat > $TMPC << EOF
4104 #include <sys/inotify.h>
4107 main(void)
4109 /* try to start inotify */
4110 return inotify_init1(0);
4113 if compile_prog "" "" ; then
4114 inotify1=yes
4117 # check if pipe2 is there
4118 pipe2=no
4119 cat > $TMPC << EOF
4120 #include <unistd.h>
4121 #include <fcntl.h>
4123 int main(void)
4125 int pipefd[2];
4126 return pipe2(pipefd, O_CLOEXEC);
4129 if compile_prog "" "" ; then
4130 pipe2=yes
4133 # check if accept4 is there
4134 accept4=no
4135 cat > $TMPC << EOF
4136 #include <sys/socket.h>
4137 #include <stddef.h>
4139 int main(void)
4141 accept4(0, NULL, NULL, SOCK_CLOEXEC);
4142 return 0;
4145 if compile_prog "" "" ; then
4146 accept4=yes
4149 # check if tee/splice is there. vmsplice was added same time.
4150 splice=no
4151 cat > $TMPC << EOF
4152 #include <unistd.h>
4153 #include <fcntl.h>
4154 #include <limits.h>
4156 int main(void)
4158 int len, fd = 0;
4159 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
4160 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
4161 return 0;
4164 if compile_prog "" "" ; then
4165 splice=yes
4168 ##########################################
4169 # libnuma probe
4171 if test "$numa" != "no" ; then
4172 cat > $TMPC << EOF
4173 #include <numa.h>
4174 int main(void) { return numa_available(); }
4177 if compile_prog "" "-lnuma" ; then
4178 numa=yes
4179 libs_softmmu="-lnuma $libs_softmmu"
4180 else
4181 if test "$numa" = "yes" ; then
4182 feature_not_found "numa" "install numactl devel"
4184 numa=no
4188 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
4189 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
4190 exit 1
4193 # Even if malloc_trim() is available, these non-libc memory allocators
4194 # do not support it.
4195 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
4196 if test "$malloc_trim" = "yes" ; then
4197 echo "Disabling malloc_trim with non-libc memory allocator"
4199 malloc_trim="no"
4202 #######################################
4203 # malloc_trim
4205 if test "$malloc_trim" != "no" ; then
4206 cat > $TMPC << EOF
4207 #include <malloc.h>
4208 int main(void) { malloc_trim(0); return 0; }
4210 if compile_prog "" "" ; then
4211 malloc_trim="yes"
4212 else
4213 malloc_trim="no"
4217 ##########################################
4218 # tcmalloc probe
4220 if test "$tcmalloc" = "yes" ; then
4221 cat > $TMPC << EOF
4222 #include <stdlib.h>
4223 int main(void) { malloc(1); return 0; }
4226 if compile_prog "" "-ltcmalloc" ; then
4227 LIBS="-ltcmalloc $LIBS"
4228 else
4229 feature_not_found "tcmalloc" "install gperftools devel"
4233 ##########################################
4234 # jemalloc probe
4236 if test "$jemalloc" = "yes" ; then
4237 cat > $TMPC << EOF
4238 #include <stdlib.h>
4239 int main(void) { malloc(1); return 0; }
4242 if compile_prog "" "-ljemalloc" ; then
4243 LIBS="-ljemalloc $LIBS"
4244 else
4245 feature_not_found "jemalloc" "install jemalloc devel"
4249 ##########################################
4250 # signalfd probe
4251 signalfd="no"
4252 cat > $TMPC << EOF
4253 #include <unistd.h>
4254 #include <sys/syscall.h>
4255 #include <signal.h>
4256 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4259 if compile_prog "" "" ; then
4260 signalfd=yes
4263 # check if optreset global is declared by <getopt.h>
4264 optreset="no"
4265 cat > $TMPC << EOF
4266 #include <getopt.h>
4267 int main(void) { return optreset; }
4270 if compile_prog "" "" ; then
4271 optreset=yes
4274 # check if eventfd is supported
4275 eventfd=no
4276 cat > $TMPC << EOF
4277 #include <sys/eventfd.h>
4279 int main(void)
4281 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4284 if compile_prog "" "" ; then
4285 eventfd=yes
4288 # check if memfd is supported
4289 memfd=no
4290 cat > $TMPC << EOF
4291 #include <sys/mman.h>
4293 int main(void)
4295 return memfd_create("foo", MFD_ALLOW_SEALING);
4298 if compile_prog "" "" ; then
4299 memfd=yes
4302 # check for usbfs
4303 have_usbfs=no
4304 if test "$linux_user" = "yes"; then
4305 cat > $TMPC << EOF
4306 #include <linux/usbdevice_fs.h>
4308 #ifndef USBDEVFS_GET_CAPABILITIES
4309 #error "USBDEVFS_GET_CAPABILITIES undefined"
4310 #endif
4312 #ifndef USBDEVFS_DISCONNECT_CLAIM
4313 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
4314 #endif
4316 int main(void)
4318 return 0;
4321 if compile_prog "" ""; then
4322 have_usbfs=yes
4326 # check for fallocate
4327 fallocate=no
4328 cat > $TMPC << EOF
4329 #include <fcntl.h>
4331 int main(void)
4333 fallocate(0, 0, 0, 0);
4334 return 0;
4337 if compile_prog "" "" ; then
4338 fallocate=yes
4341 # check for fallocate hole punching
4342 fallocate_punch_hole=no
4343 cat > $TMPC << EOF
4344 #include <fcntl.h>
4345 #include <linux/falloc.h>
4347 int main(void)
4349 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4350 return 0;
4353 if compile_prog "" "" ; then
4354 fallocate_punch_hole=yes
4357 # check that fallocate supports range zeroing inside the file
4358 fallocate_zero_range=no
4359 cat > $TMPC << EOF
4360 #include <fcntl.h>
4361 #include <linux/falloc.h>
4363 int main(void)
4365 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4366 return 0;
4369 if compile_prog "" "" ; then
4370 fallocate_zero_range=yes
4373 # check for posix_fallocate
4374 posix_fallocate=no
4375 cat > $TMPC << EOF
4376 #include <fcntl.h>
4378 int main(void)
4380 posix_fallocate(0, 0, 0);
4381 return 0;
4384 if compile_prog "" "" ; then
4385 posix_fallocate=yes
4388 # check for sync_file_range
4389 sync_file_range=no
4390 cat > $TMPC << EOF
4391 #include <fcntl.h>
4393 int main(void)
4395 sync_file_range(0, 0, 0, 0);
4396 return 0;
4399 if compile_prog "" "" ; then
4400 sync_file_range=yes
4403 # check for linux/fiemap.h and FS_IOC_FIEMAP
4404 fiemap=no
4405 cat > $TMPC << EOF
4406 #include <sys/ioctl.h>
4407 #include <linux/fs.h>
4408 #include <linux/fiemap.h>
4410 int main(void)
4412 ioctl(0, FS_IOC_FIEMAP, 0);
4413 return 0;
4416 if compile_prog "" "" ; then
4417 fiemap=yes
4420 # check for dup3
4421 dup3=no
4422 cat > $TMPC << EOF
4423 #include <unistd.h>
4425 int main(void)
4427 dup3(0, 0, 0);
4428 return 0;
4431 if compile_prog "" "" ; then
4432 dup3=yes
4435 # check for ppoll support
4436 ppoll=no
4437 cat > $TMPC << EOF
4438 #include <poll.h>
4440 int main(void)
4442 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4443 ppoll(&pfd, 1, 0, 0);
4444 return 0;
4447 if compile_prog "" "" ; then
4448 ppoll=yes
4451 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4452 prctl_pr_set_timerslack=no
4453 cat > $TMPC << EOF
4454 #include <sys/prctl.h>
4456 int main(void)
4458 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4459 return 0;
4462 if compile_prog "" "" ; then
4463 prctl_pr_set_timerslack=yes
4466 # check for epoll support
4467 epoll=no
4468 cat > $TMPC << EOF
4469 #include <sys/epoll.h>
4471 int main(void)
4473 epoll_create(0);
4474 return 0;
4477 if compile_prog "" "" ; then
4478 epoll=yes
4481 # epoll_create1 is a later addition
4482 # so we must check separately for its presence
4483 epoll_create1=no
4484 cat > $TMPC << EOF
4485 #include <sys/epoll.h>
4487 int main(void)
4489 /* Note that we use epoll_create1 as a value, not as
4490 * a function being called. This is necessary so that on
4491 * old SPARC glibc versions where the function was present in
4492 * the library but not declared in the header file we will
4493 * fail the configure check. (Otherwise we will get a compiler
4494 * warning but not an error, and will proceed to fail the
4495 * qemu compile where we compile with -Werror.)
4497 return (int)(uintptr_t)&epoll_create1;
4500 if compile_prog "" "" ; then
4501 epoll_create1=yes
4504 # check for sendfile support
4505 sendfile=no
4506 cat > $TMPC << EOF
4507 #include <sys/sendfile.h>
4509 int main(void)
4511 return sendfile(0, 0, 0, 0);
4514 if compile_prog "" "" ; then
4515 sendfile=yes
4518 # check for timerfd support (glibc 2.8 and newer)
4519 timerfd=no
4520 cat > $TMPC << EOF
4521 #include <sys/timerfd.h>
4523 int main(void)
4525 return(timerfd_create(CLOCK_REALTIME, 0));
4528 if compile_prog "" "" ; then
4529 timerfd=yes
4532 # check for setns and unshare support
4533 setns=no
4534 cat > $TMPC << EOF
4535 #include <sched.h>
4537 int main(void)
4539 int ret;
4540 ret = setns(0, 0);
4541 ret = unshare(0);
4542 return ret;
4545 if compile_prog "" "" ; then
4546 setns=yes
4549 # clock_adjtime probe
4550 clock_adjtime=no
4551 cat > $TMPC <<EOF
4552 #include <time.h>
4554 int main(void)
4556 return clock_adjtime(0, 0);
4559 clock_adjtime=no
4560 if compile_prog "" "" ; then
4561 clock_adjtime=yes
4564 # syncfs probe
4565 syncfs=no
4566 cat > $TMPC <<EOF
4567 #include <unistd.h>
4569 int main(void)
4571 return syncfs(0);
4574 syncfs=no
4575 if compile_prog "" "" ; then
4576 syncfs=yes
4579 # Check if tools are available to build documentation.
4580 if test "$docs" != "no" ; then
4581 if has makeinfo && has pod2man; then
4582 docs=yes
4583 else
4584 if test "$docs" = "yes" ; then
4585 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4587 docs=no
4591 # Search for bswap_32 function
4592 byteswap_h=no
4593 cat > $TMPC << EOF
4594 #include <byteswap.h>
4595 int main(void) { return bswap_32(0); }
4597 if compile_prog "" "" ; then
4598 byteswap_h=yes
4601 # Search for bswap32 function
4602 bswap_h=no
4603 cat > $TMPC << EOF
4604 #include <sys/endian.h>
4605 #include <sys/types.h>
4606 #include <machine/bswap.h>
4607 int main(void) { return bswap32(0); }
4609 if compile_prog "" "" ; then
4610 bswap_h=yes
4613 ##########################################
4614 # Do we have libiscsi >= 1.9.0
4615 if test "$libiscsi" != "no" ; then
4616 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4617 libiscsi="yes"
4618 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4619 libiscsi_libs=$($pkg_config --libs libiscsi)
4620 else
4621 if test "$libiscsi" = "yes" ; then
4622 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4624 libiscsi="no"
4628 ##########################################
4629 # Do we need libm
4630 cat > $TMPC << EOF
4631 #include <math.h>
4632 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4634 if compile_prog "" "" ; then
4636 elif compile_prog "" "-lm" ; then
4637 LIBS="-lm $LIBS"
4638 libs_qga="-lm $libs_qga"
4639 else
4640 error_exit "libm check failed"
4643 ##########################################
4644 # Do we need librt
4645 # uClibc provides 2 versions of clock_gettime(), one with realtime
4646 # support and one without. This means that the clock_gettime() don't
4647 # need -lrt. We still need it for timer_create() so we check for this
4648 # function in addition.
4649 cat > $TMPC <<EOF
4650 #include <signal.h>
4651 #include <time.h>
4652 int main(void) {
4653 timer_create(CLOCK_REALTIME, NULL, NULL);
4654 return clock_gettime(CLOCK_REALTIME, NULL);
4658 if compile_prog "" "" ; then
4660 # we need pthread for static linking. use previous pthread test result
4661 elif compile_prog "" "$pthread_lib -lrt" ; then
4662 LIBS="$LIBS -lrt"
4663 libs_qga="$libs_qga -lrt"
4666 # Check whether we need to link libutil for openpty()
4667 cat > $TMPC << EOF
4668 extern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4669 int main(void) { return openpty(0, 0, 0, 0, 0); }
4672 if ! compile_prog "" "" ; then
4673 if compile_prog "" "-lutil" ; then
4674 libs_softmmu="-lutil $libs_softmmu"
4675 libs_tools="-lutil $libs_tools"
4679 ##########################################
4680 # spice probe
4681 if test "$spice" != "no" ; then
4682 cat > $TMPC << EOF
4683 #include <spice.h>
4684 int main(void) { spice_server_new(); return 0; }
4686 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4687 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4688 if $pkg_config --atleast-version=0.12.5 spice-server && \
4689 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4690 compile_prog "$spice_cflags" "$spice_libs" ; then
4691 spice="yes"
4692 libs_softmmu="$libs_softmmu $spice_libs"
4693 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4694 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4695 spice_server_version=$($pkg_config --modversion spice-server)
4696 else
4697 if test "$spice" = "yes" ; then
4698 feature_not_found "spice" \
4699 "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4701 spice="no"
4705 # check for smartcard support
4706 if test "$smartcard" != "no"; then
4707 if $pkg_config --atleast-version=2.5.1 libcacard; then
4708 libcacard_cflags=$($pkg_config --cflags libcacard)
4709 libcacard_libs=$($pkg_config --libs libcacard)
4710 smartcard="yes"
4711 else
4712 if test "$smartcard" = "yes"; then
4713 feature_not_found "smartcard" "Install libcacard devel"
4715 smartcard="no"
4719 # check for libusb
4720 if test "$libusb" != "no" ; then
4721 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4722 libusb="yes"
4723 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4724 libusb_libs=$($pkg_config --libs libusb-1.0)
4725 else
4726 if test "$libusb" = "yes"; then
4727 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4729 libusb="no"
4733 # check for usbredirparser for usb network redirection support
4734 if test "$usb_redir" != "no" ; then
4735 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4736 usb_redir="yes"
4737 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4738 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4739 else
4740 if test "$usb_redir" = "yes"; then
4741 feature_not_found "usb-redir" "Install usbredir devel"
4743 usb_redir="no"
4747 ##########################################
4748 # check if we have VSS SDK headers for win
4750 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4751 test "$vss_win32_sdk" != "no" ; then
4752 case "$vss_win32_sdk" in
4753 "") vss_win32_include="-isystem $source_path" ;;
4754 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4755 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4756 vss_win32_include="-isystem $source_path/.sdk/vss"
4757 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4759 *) vss_win32_include="-isystem $vss_win32_sdk"
4760 esac
4761 cat > $TMPC << EOF
4762 #define __MIDL_user_allocate_free_DEFINED__
4763 #include <inc/win2003/vss.h>
4764 int main(void) { return VSS_CTX_BACKUP; }
4766 if compile_prog "$vss_win32_include" "" ; then
4767 guest_agent_with_vss="yes"
4768 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4769 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4770 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4771 else
4772 if test "$vss_win32_sdk" != "" ; then
4773 echo "ERROR: Please download and install Microsoft VSS SDK:"
4774 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4775 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4776 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4777 echo "ERROR: The headers are extracted in the directory \`inc'."
4778 feature_not_found "VSS support"
4780 guest_agent_with_vss="no"
4784 ##########################################
4785 # lookup Windows platform SDK (if not specified)
4786 # The SDK is needed only to build .tlb (type library) file of guest agent
4787 # VSS provider from the source. It is usually unnecessary because the
4788 # pre-compiled .tlb file is included.
4790 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4791 test "$guest_agent_with_vss" = "yes" ; then
4792 if test -z "$win_sdk"; then
4793 programfiles="$PROGRAMFILES"
4794 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4795 if test -n "$programfiles"; then
4796 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4797 else
4798 feature_not_found "Windows SDK"
4800 elif test "$win_sdk" = "no"; then
4801 win_sdk=""
4805 ##########################################
4806 # check if mingw environment provides a recent ntddscsi.h
4807 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
4808 cat > $TMPC << EOF
4809 #include <windows.h>
4810 #include <ntddscsi.h>
4811 int main(void) {
4812 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4813 #error Missing required ioctl definitions
4814 #endif
4815 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4816 return addr.Lun;
4819 if compile_prog "" "" ; then
4820 guest_agent_ntddscsi=yes
4821 libs_qga="-lsetupapi $libs_qga"
4825 ##########################################
4826 # virgl renderer probe
4828 if test "$virglrenderer" != "no" ; then
4829 cat > $TMPC << EOF
4830 #include <virglrenderer.h>
4831 int main(void) { virgl_renderer_poll(); return 0; }
4833 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4834 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4835 virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
4836 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4837 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4838 virglrenderer="yes"
4839 else
4840 if test "$virglrenderer" = "yes" ; then
4841 feature_not_found "virglrenderer"
4843 virglrenderer="no"
4847 ##########################################
4848 # capstone
4850 case "$capstone" in
4851 "" | yes)
4852 if $pkg_config capstone; then
4853 capstone=system
4854 elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
4855 capstone=git
4856 elif test -e "${source_path}/capstone/Makefile" ; then
4857 capstone=internal
4858 elif test -z "$capstone" ; then
4859 capstone=no
4860 else
4861 feature_not_found "capstone" "Install capstone devel or git submodule"
4865 system)
4866 if ! $pkg_config capstone; then
4867 feature_not_found "capstone" "Install capstone devel"
4870 esac
4872 case "$capstone" in
4873 git | internal)
4874 if test "$capstone" = git; then
4875 git_submodules="${git_submodules} capstone"
4877 mkdir -p capstone
4878 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4879 if test "$mingw32" = "yes"; then
4880 LIBCAPSTONE=capstone.lib
4881 else
4882 LIBCAPSTONE=libcapstone.a
4884 LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4887 system)
4888 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
4889 LIBS="$($pkg_config --libs capstone) $LIBS"
4895 error_exit "Unknown state for capstone: $capstone"
4897 esac
4899 ##########################################
4900 # check if we have fdatasync
4902 fdatasync=no
4903 cat > $TMPC << EOF
4904 #include <unistd.h>
4905 int main(void) {
4906 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4907 return fdatasync(0);
4908 #else
4909 #error Not supported
4910 #endif
4913 if compile_prog "" "" ; then
4914 fdatasync=yes
4917 ##########################################
4918 # check if we have madvise
4920 madvise=no
4921 cat > $TMPC << EOF
4922 #include <sys/types.h>
4923 #include <sys/mman.h>
4924 #include <stddef.h>
4925 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4927 if compile_prog "" "" ; then
4928 madvise=yes
4931 ##########################################
4932 # check if we have posix_madvise
4934 posix_madvise=no
4935 cat > $TMPC << EOF
4936 #include <sys/mman.h>
4937 #include <stddef.h>
4938 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4940 if compile_prog "" "" ; then
4941 posix_madvise=yes
4944 ##########################################
4945 # check if we have posix_memalign()
4947 posix_memalign=no
4948 cat > $TMPC << EOF
4949 #include <stdlib.h>
4950 int main(void) {
4951 void *p;
4952 return posix_memalign(&p, 8, 8);
4955 if compile_prog "" "" ; then
4956 posix_memalign=yes
4959 ##########################################
4960 # check if we have posix_syslog
4962 posix_syslog=no
4963 cat > $TMPC << EOF
4964 #include <syslog.h>
4965 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4967 if compile_prog "" "" ; then
4968 posix_syslog=yes
4971 ##########################################
4972 # check if we have sem_timedwait
4974 sem_timedwait=no
4975 cat > $TMPC << EOF
4976 #include <semaphore.h>
4977 int main(void) { return sem_timedwait(0, 0); }
4979 if compile_prog "" "" ; then
4980 sem_timedwait=yes
4983 ##########################################
4984 # check if we have strchrnul
4986 strchrnul=no
4987 cat > $TMPC << EOF
4988 #include <string.h>
4989 int main(void);
4990 // Use a haystack that the compiler shouldn't be able to constant fold
4991 char *haystack = (char*)&main;
4992 int main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
4994 if compile_prog "" "" ; then
4995 strchrnul=yes
4998 ##########################################
4999 # check if trace backend exists
5001 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
5002 if test "$?" -ne 0 ; then
5003 error_exit "invalid trace backends" \
5004 "Please choose supported trace backends."
5007 ##########################################
5008 # For 'ust' backend, test if ust headers are present
5009 if have_backend "ust"; then
5010 cat > $TMPC << EOF
5011 #include <lttng/tracepoint.h>
5012 int main(void) { return 0; }
5014 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5015 if $pkg_config lttng-ust --exists; then
5016 lttng_ust_libs=$($pkg_config --libs lttng-ust)
5017 else
5018 lttng_ust_libs="-llttng-ust -ldl"
5020 if $pkg_config liburcu-bp --exists; then
5021 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5022 else
5023 urcu_bp_libs="-lurcu-bp"
5026 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5027 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
5028 else
5029 error_exit "Trace backend 'ust' missing lttng-ust header files"
5033 ##########################################
5034 # For 'dtrace' backend, test if 'dtrace' command is present
5035 if have_backend "dtrace"; then
5036 if ! has 'dtrace' ; then
5037 error_exit "dtrace command is not found in PATH $PATH"
5039 trace_backend_stap="no"
5040 if has 'stap' ; then
5041 trace_backend_stap="yes"
5045 ##########################################
5046 # check and set a backend for coroutine
5048 # We prefer ucontext, but it's not always possible. The fallback
5049 # is sigcontext. On Windows the only valid backend is the Windows
5050 # specific one.
5052 ucontext_works=no
5053 if test "$darwin" != "yes"; then
5054 cat > $TMPC << EOF
5055 #include <ucontext.h>
5056 #ifdef __stub_makecontext
5057 #error Ignoring glibc stub makecontext which will always fail
5058 #endif
5059 int main(void) { makecontext(0, 0, 0); return 0; }
5061 if compile_prog "" "" ; then
5062 ucontext_works=yes
5066 if test "$coroutine" = ""; then
5067 if test "$mingw32" = "yes"; then
5068 coroutine=win32
5069 elif test "$ucontext_works" = "yes"; then
5070 coroutine=ucontext
5071 else
5072 coroutine=sigaltstack
5074 else
5075 case $coroutine in
5076 windows)
5077 if test "$mingw32" != "yes"; then
5078 error_exit "'windows' coroutine backend only valid for Windows"
5080 # Unfortunately the user visible backend name doesn't match the
5081 # coroutine-*.c filename for this case, so we have to adjust it here.
5082 coroutine=win32
5084 ucontext)
5085 if test "$ucontext_works" != "yes"; then
5086 feature_not_found "ucontext"
5089 sigaltstack)
5090 if test "$mingw32" = "yes"; then
5091 error_exit "only the 'windows' coroutine backend is valid for Windows"
5095 error_exit "unknown coroutine backend $coroutine"
5097 esac
5100 if test "$coroutine_pool" = ""; then
5101 if test "$coroutine" = "gthread" -o "$coroutine" = "win32"; then
5102 coroutine_pool=no
5103 else
5104 coroutine_pool=yes
5107 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
5108 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
5111 if test "$debug_stack_usage" = "yes"; then
5112 if test "$coroutine_pool" = "yes"; then
5113 echo "WARN: disabling coroutine pool for stack usage debugging"
5114 coroutine_pool=no
5119 ##########################################
5120 # check if we have open_by_handle_at
5122 open_by_handle_at=no
5123 cat > $TMPC << EOF
5124 #include <fcntl.h>
5125 #if !defined(AT_EMPTY_PATH)
5126 # error missing definition
5127 #else
5128 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5129 #endif
5131 if compile_prog "" "" ; then
5132 open_by_handle_at=yes
5135 ########################################
5136 # check if we have linux/magic.h
5138 linux_magic_h=no
5139 cat > $TMPC << EOF
5140 #include <linux/magic.h>
5141 int main(void) {
5142 return 0;
5145 if compile_prog "" "" ; then
5146 linux_magic_h=yes
5149 ########################################
5150 # check whether we can disable warning option with a pragma (this is needed
5151 # to silence warnings in the headers of some versions of external libraries).
5152 # This test has to be compiled with -Werror as otherwise an unknown pragma is
5153 # only a warning.
5155 # If we can't selectively disable warning in the code, disable -Werror so that
5156 # the build doesn't fail anyway.
5158 pragma_disable_unused_but_set=no
5159 cat > $TMPC << EOF
5160 #pragma GCC diagnostic push
5161 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
5162 #pragma GCC diagnostic pop
5164 int main(void) {
5165 return 0;
5168 if compile_prog "-Werror" "" ; then
5169 pragma_diagnostic_available=yes
5172 ########################################
5173 # check if we have valgrind/valgrind.h
5175 valgrind_h=no
5176 cat > $TMPC << EOF
5177 #include <valgrind/valgrind.h>
5178 int main(void) {
5179 return 0;
5182 if compile_prog "" "" ; then
5183 valgrind_h=yes
5186 ########################################
5187 # check if environ is declared
5189 has_environ=no
5190 cat > $TMPC << EOF
5191 #include <unistd.h>
5192 int main(void) {
5193 environ = 0;
5194 return 0;
5197 if compile_prog "" "" ; then
5198 has_environ=yes
5201 ########################################
5202 # check if cpuid.h is usable.
5204 cat > $TMPC << EOF
5205 #include <cpuid.h>
5206 int main(void) {
5207 unsigned a, b, c, d;
5208 int max = __get_cpuid_max(0, 0);
5210 if (max >= 1) {
5211 __cpuid(1, a, b, c, d);
5214 if (max >= 7) {
5215 __cpuid_count(7, 0, a, b, c, d);
5218 return 0;
5221 if compile_prog "" "" ; then
5222 cpuid_h=yes
5225 ##########################################
5226 # avx2 optimization requirement check
5228 # There is no point enabling this if cpuid.h is not usable,
5229 # since we won't be able to select the new routines.
5231 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
5232 cat > $TMPC << EOF
5233 #pragma GCC push_options
5234 #pragma GCC target("avx2")
5235 #include <cpuid.h>
5236 #include <immintrin.h>
5237 static int bar(void *a) {
5238 __m256i x = *(__m256i *)a;
5239 return _mm256_testz_si256(x, x);
5241 int main(int argc, char *argv[]) { return bar(argv[0]); }
5243 if compile_object "" ; then
5244 avx2_opt="yes"
5245 else
5246 avx2_opt="no"
5250 ########################################
5251 # check if __[u]int128_t is usable.
5253 int128=no
5254 cat > $TMPC << EOF
5255 __int128_t a;
5256 __uint128_t b;
5257 int main (void) {
5258 a = a + b;
5259 b = a * b;
5260 a = a * a;
5261 return 0;
5264 if compile_prog "" "" ; then
5265 int128=yes
5268 #########################################
5269 # See if 128-bit atomic operations are supported.
5271 atomic128=no
5272 if test "$int128" = "yes"; then
5273 cat > $TMPC << EOF
5274 int main(void)
5276 unsigned __int128 x = 0, y = 0;
5277 y = __atomic_load_16(&x, 0);
5278 __atomic_store_16(&x, y, 0);
5279 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
5280 return 0;
5283 if compile_prog "" "" ; then
5284 atomic128=yes
5288 cmpxchg128=no
5289 if test "$int128" = yes && test "$atomic128" = no; then
5290 cat > $TMPC << EOF
5291 int main(void)
5293 unsigned __int128 x = 0, y = 0;
5294 __sync_val_compare_and_swap_16(&x, y, x);
5295 return 0;
5298 if compile_prog "" "" ; then
5299 cmpxchg128=yes
5303 #########################################
5304 # See if 64-bit atomic operations are supported.
5305 # Note that without __atomic builtins, we can only
5306 # assume atomic loads/stores max at pointer size.
5308 cat > $TMPC << EOF
5309 #include <stdint.h>
5310 int main(void)
5312 uint64_t x = 0, y = 0;
5313 #ifdef __ATOMIC_RELAXED
5314 y = __atomic_load_8(&x, 0);
5315 __atomic_store_8(&x, y, 0);
5316 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5317 __atomic_exchange_8(&x, y, 0);
5318 __atomic_fetch_add_8(&x, y, 0);
5319 #else
5320 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5321 __sync_lock_test_and_set(&x, y);
5322 __sync_val_compare_and_swap(&x, y, 0);
5323 __sync_fetch_and_add(&x, y);
5324 #endif
5325 return 0;
5328 if compile_prog "" "" ; then
5329 atomic64=yes
5332 ########################################
5333 # See if 16-byte vector operations are supported.
5334 # Even without a vector unit the compiler may expand these.
5335 # There is a bug in old GCC for PPC that crashes here.
5336 # Unfortunately it's the system compiler for Centos 7.
5338 cat > $TMPC << EOF
5339 typedef unsigned char U1 __attribute__((vector_size(16)));
5340 typedef unsigned short U2 __attribute__((vector_size(16)));
5341 typedef unsigned int U4 __attribute__((vector_size(16)));
5342 typedef unsigned long long U8 __attribute__((vector_size(16)));
5343 typedef signed char S1 __attribute__((vector_size(16)));
5344 typedef signed short S2 __attribute__((vector_size(16)));
5345 typedef signed int S4 __attribute__((vector_size(16)));
5346 typedef signed long long S8 __attribute__((vector_size(16)));
5347 static U1 a1, b1;
5348 static U2 a2, b2;
5349 static U4 a4, b4;
5350 static U8 a8, b8;
5351 static S1 c1;
5352 static S2 c2;
5353 static S4 c4;
5354 static S8 c8;
5355 static int i;
5356 void helper(void *d, void *a, int shift, int i);
5357 void helper(void *d, void *a, int shift, int i)
5359 *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
5360 *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
5361 *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
5362 *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
5364 int main(void)
5366 a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5367 a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5368 a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5369 a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5370 a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5371 a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5372 a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5373 a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5374 c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5375 return 0;
5379 vector16=no
5380 if compile_prog "" "" ; then
5381 vector16=yes
5384 ########################################
5385 # check if getauxval is available.
5387 getauxval=no
5388 cat > $TMPC << EOF
5389 #include <sys/auxv.h>
5390 int main(void) {
5391 return getauxval(AT_HWCAP) == 0;
5394 if compile_prog "" "" ; then
5395 getauxval=yes
5398 ########################################
5399 # check if ccache is interfering with
5400 # semantic analysis of macros
5402 unset CCACHE_CPP2
5403 ccache_cpp2=no
5404 cat > $TMPC << EOF
5405 static const int Z = 1;
5406 #define fn() ({ Z; })
5407 #define TAUT(X) ((X) == Z)
5408 #define PAREN(X, Y) (X == Y)
5409 #define ID(X) (X)
5410 int main(int argc, char *argv[])
5412 int x = 0, y = 0;
5413 x = ID(x);
5414 x = fn();
5415 fn();
5416 if (PAREN(x, y)) return 0;
5417 if (TAUT(Z)) return 0;
5418 return 0;
5422 if ! compile_object "-Werror"; then
5423 ccache_cpp2=yes
5426 #################################################
5427 # clang does not support glibc + FORTIFY_SOURCE.
5429 if test "$fortify_source" != "no"; then
5430 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5431 fortify_source="no";
5432 elif test -n "$cxx" && has $cxx &&
5433 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5434 fortify_source="no";
5435 else
5436 fortify_source="yes"
5440 ###############################################
5441 # Check if copy_file_range is provided by glibc
5442 have_copy_file_range=no
5443 cat > $TMPC << EOF
5444 #include <unistd.h>
5445 int main(void) {
5446 copy_file_range(0, NULL, 0, NULL, 0, 0);
5447 return 0;
5450 if compile_prog "" "" ; then
5451 have_copy_file_range=yes
5454 ##########################################
5455 # check if struct fsxattr is available via linux/fs.h
5457 have_fsxattr=no
5458 cat > $TMPC << EOF
5459 #include <linux/fs.h>
5460 struct fsxattr foo;
5461 int main(void) {
5462 return 0;
5465 if compile_prog "" "" ; then
5466 have_fsxattr=yes
5469 ##########################################
5470 # check for usable membarrier system call
5471 if test "$membarrier" = "yes"; then
5472 have_membarrier=no
5473 if test "$mingw32" = "yes" ; then
5474 have_membarrier=yes
5475 elif test "$linux" = "yes" ; then
5476 cat > $TMPC << EOF
5477 #include <linux/membarrier.h>
5478 #include <sys/syscall.h>
5479 #include <unistd.h>
5480 #include <stdlib.h>
5481 int main(void) {
5482 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5483 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5484 exit(0);
5487 if compile_prog "" "" ; then
5488 have_membarrier=yes
5491 if test "$have_membarrier" = "no"; then
5492 feature_not_found "membarrier" "membarrier system call not available"
5494 else
5495 # Do not enable it by default even for Mingw32, because it doesn't
5496 # work on Wine.
5497 membarrier=no
5500 ##########################################
5501 # check if rtnetlink.h exists and is useful
5502 have_rtnetlink=no
5503 cat > $TMPC << EOF
5504 #include <linux/rtnetlink.h>
5505 int main(void) {
5506 return IFLA_PROTO_DOWN;
5509 if compile_prog "" "" ; then
5510 have_rtnetlink=yes
5513 ##########################################
5514 # check for usable AF_VSOCK environment
5515 have_af_vsock=no
5516 cat > $TMPC << EOF
5517 #include <errno.h>
5518 #include <sys/types.h>
5519 #include <sys/socket.h>
5520 #if !defined(AF_VSOCK)
5521 # error missing AF_VSOCK flag
5522 #endif
5523 #include <linux/vm_sockets.h>
5524 int main(void) {
5525 int sock, ret;
5526 struct sockaddr_vm svm;
5527 socklen_t len = sizeof(svm);
5528 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
5529 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
5530 if ((ret == -1) && (errno == ENOTCONN)) {
5531 return 0;
5533 return -1;
5536 if compile_prog "" "" ; then
5537 have_af_vsock=yes
5540 ##########################################
5541 # check for usable AF_ALG environment
5542 hava_afalg=no
5543 cat > $TMPC << EOF
5544 #include <errno.h>
5545 #include <sys/types.h>
5546 #include <sys/socket.h>
5547 #include <linux/if_alg.h>
5548 int main(void) {
5549 int sock;
5550 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5551 return sock;
5554 if compile_prog "" "" ; then
5555 have_afalg=yes
5557 if test "$crypto_afalg" = "yes"
5558 then
5559 if test "$have_afalg" != "yes"
5560 then
5561 error_exit "AF_ALG requested but could not be detected"
5566 #################################################
5567 # Check to see if we have the Hypervisor framework
5568 if [ "$darwin" = "yes" ] ; then
5569 cat > $TMPC << EOF
5570 #include <Hypervisor/hv.h>
5571 int main() { return 0;}
5573 if ! compile_object ""; then
5574 hvf='no'
5575 else
5576 hvf='yes'
5577 LDFLAGS="-framework Hypervisor $LDFLAGS"
5581 #################################################
5582 # Sparc implicitly links with --relax, which is
5583 # incompatible with -r, so --no-relax should be
5584 # given. It does no harm to give it on other
5585 # platforms too.
5587 # Note: the prototype is needed since QEMU_CFLAGS
5588 # contains -Wmissing-prototypes
5589 cat > $TMPC << EOF
5590 extern int foo(void);
5591 int foo(void) { return 0; }
5593 if ! compile_object ""; then
5594 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5596 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5597 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5598 LD_REL_FLAGS=$i
5599 break
5601 done
5602 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5603 feature_not_found "modules" "Cannot find how to build relocatable objects"
5606 ##########################################
5607 # check for sysmacros.h
5609 have_sysmacros=no
5610 cat > $TMPC << EOF
5611 #include <sys/sysmacros.h>
5612 int main(void) {
5613 return makedev(0, 0);
5616 if compile_prog "" "" ; then
5617 have_sysmacros=yes
5620 ##########################################
5621 # Veritas HyperScale block driver VxHS
5622 # Check if libvxhs is installed
5624 if test "$vxhs" != "no" ; then
5625 cat > $TMPC <<EOF
5626 #include <stdint.h>
5627 #include <qnio/qnio_api.h>
5629 void *vxhs_callback;
5631 int main(void) {
5632 iio_init(QNIO_VERSION, vxhs_callback);
5633 return 0;
5636 vxhs_libs="-lvxhs -lssl"
5637 if compile_prog "" "$vxhs_libs" ; then
5638 vxhs=yes
5639 else
5640 if test "$vxhs" = "yes" ; then
5641 feature_not_found "vxhs block device" "Install libvxhs See github"
5643 vxhs=no
5647 ##########################################
5648 # check for _Static_assert()
5650 have_static_assert=no
5651 cat > $TMPC << EOF
5652 _Static_assert(1, "success");
5653 int main(void) {
5654 return 0;
5657 if compile_prog "" "" ; then
5658 have_static_assert=yes
5661 ##########################################
5662 # check for utmpx.h, it is missing e.g. on OpenBSD
5664 have_utmpx=no
5665 cat > $TMPC << EOF
5666 #include <utmpx.h>
5667 struct utmpx user_info;
5668 int main(void) {
5669 return 0;
5672 if compile_prog "" "" ; then
5673 have_utmpx=yes
5676 ##########################################
5677 # checks for sanitizers
5679 have_asan=no
5680 have_ubsan=no
5681 have_asan_iface_h=no
5682 have_asan_iface_fiber=no
5684 if test "$sanitizers" = "yes" ; then
5685 write_c_skeleton
5686 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5687 have_asan=yes
5690 # we could use a simple skeleton for flags checks, but this also
5691 # detect the static linking issue of ubsan, see also:
5692 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5693 cat > $TMPC << EOF
5694 #include <stdlib.h>
5695 int main(void) {
5696 void *tmp = malloc(10);
5697 return *(int *)(tmp + 2);
5700 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5701 have_ubsan=yes
5704 if check_include "sanitizer/asan_interface.h" ; then
5705 have_asan_iface_h=yes
5708 cat > $TMPC << EOF
5709 #include <sanitizer/asan_interface.h>
5710 int main(void) {
5711 __sanitizer_start_switch_fiber(0, 0, 0);
5712 return 0;
5715 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5716 have_asan_iface_fiber=yes
5720 ##########################################
5721 # Docker and cross-compiler support
5723 # This is specifically for building test
5724 # cases for foreign architectures, not
5725 # cross-compiling QEMU itself.
5727 if has "docker"; then
5728 docker=$($python $source_path/tests/docker/docker.py probe)
5731 ##########################################
5732 # check for libpmem
5734 if test "$libpmem" != "no"; then
5735 if $pkg_config --exists "libpmem"; then
5736 libpmem="yes"
5737 libpmem_libs=$($pkg_config --libs libpmem)
5738 libpmem_cflags=$($pkg_config --cflags libpmem)
5739 libs_softmmu="$libs_softmmu $libpmem_libs"
5740 QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
5741 else
5742 if test "$libpmem" = "yes" ; then
5743 feature_not_found "libpmem" "Install nvml or pmdk"
5745 libpmem="no"
5749 ##########################################
5750 # End of CC checks
5751 # After here, no more $cc or $ld runs
5753 write_c_skeleton
5755 if test "$gcov" = "yes" ; then
5756 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
5757 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5758 elif test "$fortify_source" = "yes" ; then
5759 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
5760 elif test "$debug" = "no"; then
5761 CFLAGS="-O2 $CFLAGS"
5764 if test "$have_asan" = "yes"; then
5765 CFLAGS="-fsanitize=address $CFLAGS"
5766 if test "$have_asan_iface_h" = "no" ; then
5767 echo "ASAN build enabled, but ASAN header missing." \
5768 "Without code annotation, the report may be inferior."
5769 elif test "$have_asan_iface_fiber" = "no" ; then
5770 echo "ASAN build enabled, but ASAN header is too old." \
5771 "Without code annotation, the report may be inferior."
5774 if test "$have_ubsan" = "yes"; then
5775 CFLAGS="-fsanitize=undefined $CFLAGS"
5778 ##########################################
5779 # Do we have libnfs
5780 if test "$libnfs" != "no" ; then
5781 if $pkg_config --atleast-version=1.9.3 libnfs; then
5782 libnfs="yes"
5783 libnfs_libs=$($pkg_config --libs libnfs)
5784 else
5785 if test "$libnfs" = "yes" ; then
5786 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
5788 libnfs="no"
5792 ##########################################
5793 # Do we have libudev
5794 if test "$libudev" != "no" ; then
5795 if $pkg_config libudev && test "$static" != "yes"; then
5796 libudev="yes"
5797 libudev_libs=$($pkg_config --libs libudev)
5798 else
5799 libudev="no"
5803 # Now we've finished running tests it's OK to add -Werror to the compiler flags
5804 if test "$werror" = "yes"; then
5805 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
5808 if test "$solaris" = "no" ; then
5809 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5810 LDFLAGS="-Wl,--warn-common $LDFLAGS"
5814 # test if pod2man has --utf8 option
5815 if pod2man --help | grep -q utf8; then
5816 POD2MAN="pod2man --utf8"
5817 else
5818 POD2MAN="pod2man"
5821 # Use large addresses, ASLR, no-SEH and DEP if available.
5822 if test "$mingw32" = "yes" ; then
5823 if test "$cpu" = i386; then
5824 LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
5826 for flag in --dynamicbase --no-seh --nxcompat; do
5827 if ld_has $flag ; then
5828 LDFLAGS="-Wl,$flag $LDFLAGS"
5830 done
5833 qemu_confdir=$sysconfdir$confsuffix
5834 qemu_moddir=$libdir$confsuffix
5835 qemu_datadir=$datadir$confsuffix
5836 qemu_localedir="$datadir/locale"
5837 qemu_icondir="$datadir/icons"
5838 qemu_desktopdir="$datadir/applications"
5840 # We can only support ivshmem if we have eventfd
5841 if [ "$eventfd" = "yes" ]; then
5842 ivshmem=yes
5845 tools=""
5846 if test "$want_tools" = "yes" ; then
5847 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
5848 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
5849 tools="qemu-nbd\$(EXESUF) $tools"
5851 if [ "$ivshmem" = "yes" ]; then
5852 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
5854 if [ "$curl" = "yes" ]; then
5855 tools="elf2dmp\$(EXESUF) $tools"
5858 if test "$softmmu" = yes ; then
5859 if test "$linux" = yes; then
5860 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5861 virtfs=yes
5862 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5863 else
5864 if test "$virtfs" = yes; then
5865 error_exit "VirtFS requires libcap devel and libattr devel"
5867 virtfs=no
5869 if test "$mpath" != no && test "$mpathpersist" = yes ; then
5870 mpath=yes
5871 else
5872 if test "$mpath" = yes; then
5873 error_exit "Multipath requires libmpathpersist devel"
5875 mpath=no
5877 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5878 else
5879 if test "$virtfs" = yes; then
5880 error_exit "VirtFS is supported only on Linux"
5882 virtfs=no
5883 if test "$mpath" = yes; then
5884 error_exit "Multipath is supported only on Linux"
5886 mpath=no
5888 if test "$xkbcommon" = "yes"; then
5889 tools="qemu-keymap\$(EXESUF) $tools"
5893 # Probe for guest agent support/options
5895 if [ "$guest_agent" != "no" ]; then
5896 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5897 tools="qemu-ga $tools"
5898 guest_agent=yes
5899 elif [ "$guest_agent" != yes ]; then
5900 guest_agent=no
5901 else
5902 error_exit "Guest agent is not supported on this platform"
5906 # Guest agent Window MSI package
5908 if test "$guest_agent" != yes; then
5909 if test "$guest_agent_msi" = yes; then
5910 error_exit "MSI guest agent package requires guest agent enabled"
5912 guest_agent_msi=no
5913 elif test "$mingw32" != "yes"; then
5914 if test "$guest_agent_msi" = "yes"; then
5915 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
5917 guest_agent_msi=no
5918 elif ! has wixl; then
5919 if test "$guest_agent_msi" = "yes"; then
5920 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
5922 guest_agent_msi=no
5923 else
5924 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
5925 # disabled explicitly
5926 if test "$guest_agent_msi" != "no"; then
5927 guest_agent_msi=yes
5931 if test "$guest_agent_msi" = "yes"; then
5932 if test "$guest_agent_with_vss" = "yes"; then
5933 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
5936 if test "$QEMU_GA_MANUFACTURER" = ""; then
5937 QEMU_GA_MANUFACTURER=QEMU
5940 if test "$QEMU_GA_DISTRO" = ""; then
5941 QEMU_GA_DISTRO=Linux
5944 if test "$QEMU_GA_VERSION" = ""; then
5945 QEMU_GA_VERSION=$(cat $source_path/VERSION)
5948 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
5950 case "$cpu" in
5951 x86_64)
5952 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5954 i386)
5955 QEMU_GA_MSI_ARCH="-D Arch=32"
5958 error_exit "CPU $cpu not supported for building installation package"
5960 esac
5963 # Mac OS X ships with a broken assembler
5964 roms=
5965 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
5966 test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
5967 test "$softmmu" = yes ; then
5968 # Different host OS linkers have different ideas about the name of the ELF
5969 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5970 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5971 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5972 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5973 ld_i386_emulation="$emu"
5974 roms="optionrom"
5975 break
5977 done
5979 if test "$cpu" = "ppc64" && test "$targetos" != "Darwin" ; then
5980 roms="$roms spapr-rtas"
5983 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
5984 if test "$cpu" = "s390x" ; then
5985 write_c_skeleton
5986 if compile_prog "-march=z900" ""; then
5987 roms="$roms s390-ccw"
5991 # Probe for the need for relocating the user-only binary.
5992 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5993 textseg_addr=
5994 case "$cpu" in
5995 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5996 # ??? Rationale for choosing this address
5997 textseg_addr=0x60000000
5999 mips)
6000 # A 256M aligned address, high in the address space, with enough
6001 # room for the code_gen_buffer above it before the stack.
6002 textseg_addr=0x60000000
6004 esac
6005 if [ -n "$textseg_addr" ]; then
6006 cat > $TMPC <<EOF
6007 int main(void) { return 0; }
6009 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
6010 if ! compile_prog "" "$textseg_ldflags"; then
6011 # In case ld does not support -Ttext-segment, edit the default linker
6012 # script via sed to set the .text start addr. This is needed on FreeBSD
6013 # at least.
6014 if ! $ld --verbose >/dev/null 2>&1; then
6015 error_exit \
6016 "We need to link the QEMU user mode binaries at a" \
6017 "specific text address. Unfortunately your linker" \
6018 "doesn't support either the -Ttext-segment option or" \
6019 "printing the default linker script with --verbose." \
6020 "If you don't want the user mode binaries, pass the" \
6021 "--disable-user option to configure."
6024 $ld --verbose | sed \
6025 -e '1,/==================================================/d' \
6026 -e '/==================================================/,$d' \
6027 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
6028 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
6029 textseg_ldflags="-Wl,-T../config-host.ld"
6034 # Check that the C++ compiler exists and works with the C compiler.
6035 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to not miss any other that could be added.
6036 if has $cxx; then
6037 cat > $TMPC <<EOF
6038 int c_function(void);
6039 int main(void) { return c_function(); }
6042 compile_object
6044 cat > $TMPCXX <<EOF
6045 extern "C" {
6046 int c_function(void);
6048 int c_function(void) { return 42; }
6051 update_cxxflags
6053 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
6054 # C++ compiler $cxx works ok with C compiler $cc
6056 else
6057 echo "C++ compiler $cxx does not work with C compiler $cc"
6058 echo "Disabling C++ specific optional code"
6059 cxx=
6061 else
6062 echo "No C++ compiler available; disabling C++ specific optional code"
6063 cxx=
6066 echo_version() {
6067 if test "$1" = "yes" ; then
6068 echo "($2)"
6072 # prepend pixman and ftd flags after all config tests are done
6073 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
6074 QEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
6075 libs_softmmu="$pixman_libs $libs_softmmu"
6077 echo "Install prefix $prefix"
6078 echo "BIOS directory $(eval echo $qemu_datadir)"
6079 echo "firmware path $(eval echo $firmwarepath)"
6080 echo "binary directory $(eval echo $bindir)"
6081 echo "library directory $(eval echo $libdir)"
6082 echo "module directory $(eval echo $qemu_moddir)"
6083 echo "libexec directory $(eval echo $libexecdir)"
6084 echo "include directory $(eval echo $includedir)"
6085 echo "config directory $(eval echo $sysconfdir)"
6086 if test "$mingw32" = "no" ; then
6087 echo "local state directory $(eval echo $local_statedir)"
6088 echo "Manual directory $(eval echo $mandir)"
6089 echo "ELF interp prefix $interp_prefix"
6090 else
6091 echo "local state directory queried at runtime"
6092 echo "Windows SDK $win_sdk"
6094 echo "Source path $source_path"
6095 echo "GIT binary $git"
6096 echo "GIT submodules $git_submodules"
6097 echo "C compiler $cc"
6098 echo "Host C compiler $host_cc"
6099 echo "C++ compiler $cxx"
6100 echo "Objective-C compiler $objcc"
6101 echo "ARFLAGS $ARFLAGS"
6102 echo "CFLAGS $CFLAGS"
6103 echo "QEMU_CFLAGS $QEMU_CFLAGS"
6104 echo "LDFLAGS $LDFLAGS"
6105 echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
6106 echo "make $make"
6107 echo "install $install"
6108 echo "python $python ($python_version)"
6109 if test "$slirp" = "yes" ; then
6110 echo "smbd $smbd"
6112 echo "module support $modules"
6113 echo "host CPU $cpu"
6114 echo "host big endian $bigendian"
6115 echo "target list $target_list"
6116 echo "gprof enabled $gprof"
6117 echo "sparse enabled $sparse"
6118 echo "strip binaries $strip_opt"
6119 echo "profiler $profiler"
6120 echo "static build $static"
6121 if test "$darwin" = "yes" ; then
6122 echo "Cocoa support $cocoa"
6124 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
6125 echo "SDL image support $sdl_image"
6126 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
6127 echo "GTK GL support $gtk_gl"
6128 echo "VTE support $vte $(echo_version $vte $vteversion)"
6129 echo "TLS priority $tls_priority"
6130 echo "GNUTLS support $gnutls"
6131 echo "libgcrypt $gcrypt"
6132 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
6133 echo "libtasn1 $tasn1"
6134 echo "curses support $curses"
6135 echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6136 echo "curl support $curl"
6137 echo "mingw32 support $mingw32"
6138 echo "Audio drivers $audio_drv_list"
6139 echo "Block whitelist (rw) $block_drv_rw_whitelist"
6140 echo "Block whitelist (ro) $block_drv_ro_whitelist"
6141 echo "VirtFS support $virtfs"
6142 echo "Multipath support $mpath"
6143 echo "VNC support $vnc"
6144 if test "$vnc" = "yes" ; then
6145 echo "VNC SASL support $vnc_sasl"
6146 echo "VNC JPEG support $vnc_jpeg"
6147 echo "VNC PNG support $vnc_png"
6149 if test -n "$sparc_cpu"; then
6150 echo "Target Sparc Arch $sparc_cpu"
6152 echo "xen support $xen"
6153 if test "$xen" = "yes" ; then
6154 echo "xen ctrl version $xen_ctrl_version"
6156 echo "brlapi support $brlapi"
6157 echo "bluez support $bluez"
6158 echo "Documentation $docs"
6159 echo "Tools $tools"
6160 echo "PIE $pie"
6161 echo "vde support $vde"
6162 echo "netmap support $netmap"
6163 echo "Linux AIO support $linux_aio"
6164 echo "(X)ATTR support $attr"
6165 echo "Install blobs $blobs"
6166 echo "KVM support $kvm"
6167 echo "HAX support $hax"
6168 echo "HVF support $hvf"
6169 echo "WHPX support $whpx"
6170 echo "TCG support $tcg"
6171 if test "$tcg" = "yes" ; then
6172 echo "TCG debug enabled $debug_tcg"
6173 echo "TCG interpreter $tcg_interpreter"
6175 echo "malloc trim support $malloc_trim"
6176 echo "RDMA support $rdma"
6177 echo "PVRDMA support $pvrdma"
6178 echo "fdt support $fdt"
6179 echo "membarrier $membarrier"
6180 echo "preadv support $preadv"
6181 echo "fdatasync $fdatasync"
6182 echo "madvise $madvise"
6183 echo "posix_madvise $posix_madvise"
6184 echo "posix_memalign $posix_memalign"
6185 echo "libcap-ng support $cap_ng"
6186 echo "vhost-net support $vhost_net"
6187 echo "vhost-crypto support $vhost_crypto"
6188 echo "vhost-scsi support $vhost_scsi"
6189 echo "vhost-vsock support $vhost_vsock"
6190 echo "vhost-user support $vhost_user"
6191 echo "Trace backends $trace_backends"
6192 if have_backend "simple"; then
6193 echo "Trace output file $trace_file-<pid>"
6195 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6196 echo "rbd support $rbd"
6197 echo "xfsctl support $xfs"
6198 echo "smartcard support $smartcard"
6199 echo "libusb $libusb"
6200 echo "usb net redir $usb_redir"
6201 echo "OpenGL support $opengl"
6202 echo "OpenGL dmabufs $opengl_dmabuf"
6203 echo "libiscsi support $libiscsi"
6204 echo "libnfs support $libnfs"
6205 echo "build guest agent $guest_agent"
6206 echo "QGA VSS support $guest_agent_with_vss"
6207 echo "QGA w32 disk info $guest_agent_ntddscsi"
6208 echo "QGA MSI support $guest_agent_msi"
6209 echo "seccomp support $seccomp"
6210 echo "coroutine backend $coroutine"
6211 echo "coroutine pool $coroutine_pool"
6212 echo "debug stack usage $debug_stack_usage"
6213 echo "mutex debugging $debug_mutex"
6214 echo "crypto afalg $crypto_afalg"
6215 echo "GlusterFS support $glusterfs"
6216 echo "gcov $gcov_tool"
6217 echo "gcov enabled $gcov"
6218 echo "TPM support $tpm"
6219 echo "libssh2 support $libssh2"
6220 echo "TPM passthrough $tpm_passthrough"
6221 echo "TPM emulator $tpm_emulator"
6222 echo "QOM debugging $qom_cast_debug"
6223 echo "Live block migration $live_block_migration"
6224 echo "lzo support $lzo"
6225 echo "snappy support $snappy"
6226 echo "bzip2 support $bzip2"
6227 echo "lzfse support $lzfse"
6228 echo "NUMA host support $numa"
6229 echo "libxml2 $libxml2"
6230 echo "tcmalloc support $tcmalloc"
6231 echo "jemalloc support $jemalloc"
6232 echo "avx2 optimization $avx2_opt"
6233 echo "replication support $replication"
6234 echo "VxHS block device $vxhs"
6235 echo "bochs support $bochs"
6236 echo "cloop support $cloop"
6237 echo "dmg support $dmg"
6238 echo "qcow v1 support $qcow1"
6239 echo "vdi support $vdi"
6240 echo "vvfat support $vvfat"
6241 echo "qed support $qed"
6242 echo "parallels support $parallels"
6243 echo "sheepdog support $sheepdog"
6244 echo "capstone $capstone"
6245 echo "docker $docker"
6246 echo "libpmem support $libpmem"
6247 echo "libudev $libudev"
6249 if test "$supported_cpu" = "no"; then
6250 echo
6251 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6252 echo
6253 echo "CPU host architecture $cpu support is not currently maintained."
6254 echo "The QEMU project intends to remove support for this host CPU in"
6255 echo "a future release if nobody volunteers to maintain it and to"
6256 echo "provide a build host for our continuous integration setup."
6257 echo "configure has succeeded and you can continue to build, but"
6258 echo "if you care about QEMU on this platform you should contact"
6259 echo "us upstream at qemu-devel@nongnu.org."
6262 if test "$supported_os" = "no"; then
6263 echo
6264 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6265 echo
6266 echo "Host OS $targetos support is not currently maintained."
6267 echo "The QEMU project intends to remove support for this host OS in"
6268 echo "a future release if nobody volunteers to maintain it and to"
6269 echo "provide a build host for our continuous integration setup."
6270 echo "configure has succeeded and you can continue to build, but"
6271 echo "if you care about QEMU on this platform you should contact"
6272 echo "us upstream at qemu-devel@nongnu.org."
6275 config_host_mak="config-host.mak"
6277 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
6279 echo "# Automatically generated by configure - do not modify" > $config_host_mak
6280 echo >> $config_host_mak
6282 echo all: >> $config_host_mak
6283 echo "prefix=$prefix" >> $config_host_mak
6284 echo "bindir=$bindir" >> $config_host_mak
6285 echo "libdir=$libdir" >> $config_host_mak
6286 echo "libexecdir=$libexecdir" >> $config_host_mak
6287 echo "includedir=$includedir" >> $config_host_mak
6288 echo "mandir=$mandir" >> $config_host_mak
6289 echo "sysconfdir=$sysconfdir" >> $config_host_mak
6290 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
6291 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
6292 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
6293 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
6294 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
6295 if test "$mingw32" = "no" ; then
6296 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
6298 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
6299 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
6300 echo "qemu_icondir=$qemu_icondir" >> $config_host_mak
6301 echo "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
6302 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
6303 echo "GIT=$git" >> $config_host_mak
6304 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6305 echo "GIT_UPDATE=$git_update" >> $config_host_mak
6307 echo "ARCH=$ARCH" >> $config_host_mak
6309 if test "$debug_tcg" = "yes" ; then
6310 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6312 if test "$strip_opt" = "yes" ; then
6313 echo "STRIP=${strip}" >> $config_host_mak
6315 if test "$bigendian" = "yes" ; then
6316 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
6318 if test "$mingw32" = "yes" ; then
6319 echo "CONFIG_WIN32=y" >> $config_host_mak
6320 echo "CONFIG_INSTALLER=y" >> $config_host_mak
6321 rc_version=$(cat $source_path/VERSION)
6322 version_major=${rc_version%%.*}
6323 rc_version=${rc_version#*.}
6324 version_minor=${rc_version%%.*}
6325 rc_version=${rc_version#*.}
6326 version_subminor=${rc_version%%.*}
6327 version_micro=0
6328 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6329 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6330 if test "$guest_agent_with_vss" = "yes" ; then
6331 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6332 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6333 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6335 if test "$guest_agent_ntddscsi" = "yes" ; then
6336 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
6338 if test "$guest_agent_msi" = "yes"; then
6339 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
6340 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
6341 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
6342 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
6343 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
6344 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
6345 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
6347 else
6348 echo "CONFIG_POSIX=y" >> $config_host_mak
6351 if test "$linux" = "yes" ; then
6352 echo "CONFIG_LINUX=y" >> $config_host_mak
6355 if test "$darwin" = "yes" ; then
6356 echo "CONFIG_DARWIN=y" >> $config_host_mak
6359 if test "$solaris" = "yes" ; then
6360 echo "CONFIG_SOLARIS=y" >> $config_host_mak
6362 if test "$haiku" = "yes" ; then
6363 echo "CONFIG_HAIKU=y" >> $config_host_mak
6365 if test "$static" = "yes" ; then
6366 echo "CONFIG_STATIC=y" >> $config_host_mak
6368 if test "$profiler" = "yes" ; then
6369 echo "CONFIG_PROFILER=y" >> $config_host_mak
6371 if test "$slirp" = "yes" ; then
6372 echo "CONFIG_SLIRP=y" >> $config_host_mak
6373 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6375 if test "$vde" = "yes" ; then
6376 echo "CONFIG_VDE=y" >> $config_host_mak
6377 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
6379 if test "$netmap" = "yes" ; then
6380 echo "CONFIG_NETMAP=y" >> $config_host_mak
6382 if test "$l2tpv3" = "yes" ; then
6383 echo "CONFIG_L2TPV3=y" >> $config_host_mak
6385 if test "$cap_ng" = "yes" ; then
6386 echo "CONFIG_LIBCAP=y" >> $config_host_mak
6388 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
6389 for drv in $audio_drv_list; do
6390 def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6391 case "$drv" in
6392 alsa | oss | pa | sdl)
6393 echo "$def=m" >> $config_host_mak ;;
6395 echo "$def=y" >> $config_host_mak ;;
6396 esac
6397 done
6398 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6399 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6400 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6401 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6402 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
6403 if test "$audio_pt_int" = "yes" ; then
6404 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
6406 if test "$audio_win_int" = "yes" ; then
6407 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6409 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6410 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6411 if test "$vnc" = "yes" ; then
6412 echo "CONFIG_VNC=y" >> $config_host_mak
6414 if test "$vnc_sasl" = "yes" ; then
6415 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
6417 if test "$vnc_jpeg" = "yes" ; then
6418 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
6420 if test "$vnc_png" = "yes" ; then
6421 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6423 if test "$xkbcommon" = "yes" ; then
6424 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
6425 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
6427 if test "$fnmatch" = "yes" ; then
6428 echo "CONFIG_FNMATCH=y" >> $config_host_mak
6430 if test "$xfs" = "yes" ; then
6431 echo "CONFIG_XFS=y" >> $config_host_mak
6433 qemu_version=$(head $source_path/VERSION)
6434 echo "VERSION=$qemu_version" >>$config_host_mak
6435 echo "PKGVERSION=$pkgversion" >>$config_host_mak
6436 echo "SRC_PATH=$source_path" >> $config_host_mak
6437 echo "TARGET_DIRS=$target_list" >> $config_host_mak
6438 if [ "$docs" = "yes" ] ; then
6439 echo "BUILD_DOCS=yes" >> $config_host_mak
6441 if [ "$want_tools" = "yes" ] ; then
6442 echo "BUILD_TOOLS=yes" >> $config_host_mak
6444 if test "$modules" = "yes"; then
6445 # $shacmd can generate a hash started with digit, which the compiler doesn't
6446 # like as an symbol. So prefix it with an underscore
6447 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
6448 echo "CONFIG_MODULES=y" >> $config_host_mak
6450 if test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
6451 echo "CONFIG_X11=y" >> $config_host_mak
6452 echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
6453 echo "X11_LIBS=$x11_libs" >> $config_host_mak
6455 if test "$sdl" = "yes" ; then
6456 echo "CONFIG_SDL=m" >> $config_host_mak
6457 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
6458 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
6459 if test "$sdl_image" = "yes" ; then
6460 echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
6463 if test "$cocoa" = "yes" ; then
6464 echo "CONFIG_COCOA=y" >> $config_host_mak
6466 if test "$curses" = "yes" ; then
6467 echo "CONFIG_CURSES=m" >> $config_host_mak
6468 echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
6469 echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6471 if test "$pipe2" = "yes" ; then
6472 echo "CONFIG_PIPE2=y" >> $config_host_mak
6474 if test "$accept4" = "yes" ; then
6475 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
6477 if test "$splice" = "yes" ; then
6478 echo "CONFIG_SPLICE=y" >> $config_host_mak
6480 if test "$eventfd" = "yes" ; then
6481 echo "CONFIG_EVENTFD=y" >> $config_host_mak
6483 if test "$memfd" = "yes" ; then
6484 echo "CONFIG_MEMFD=y" >> $config_host_mak
6486 if test "$have_usbfs" = "yes" ; then
6487 echo "CONFIG_USBFS=y" >> $config_host_mak
6489 if test "$fallocate" = "yes" ; then
6490 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6492 if test "$fallocate_punch_hole" = "yes" ; then
6493 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
6495 if test "$fallocate_zero_range" = "yes" ; then
6496 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6498 if test "$posix_fallocate" = "yes" ; then
6499 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6501 if test "$sync_file_range" = "yes" ; then
6502 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6504 if test "$fiemap" = "yes" ; then
6505 echo "CONFIG_FIEMAP=y" >> $config_host_mak
6507 if test "$dup3" = "yes" ; then
6508 echo "CONFIG_DUP3=y" >> $config_host_mak
6510 if test "$ppoll" = "yes" ; then
6511 echo "CONFIG_PPOLL=y" >> $config_host_mak
6513 if test "$prctl_pr_set_timerslack" = "yes" ; then
6514 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6516 if test "$epoll" = "yes" ; then
6517 echo "CONFIG_EPOLL=y" >> $config_host_mak
6519 if test "$epoll_create1" = "yes" ; then
6520 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
6522 if test "$sendfile" = "yes" ; then
6523 echo "CONFIG_SENDFILE=y" >> $config_host_mak
6525 if test "$timerfd" = "yes" ; then
6526 echo "CONFIG_TIMERFD=y" >> $config_host_mak
6528 if test "$setns" = "yes" ; then
6529 echo "CONFIG_SETNS=y" >> $config_host_mak
6531 if test "$clock_adjtime" = "yes" ; then
6532 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
6534 if test "$syncfs" = "yes" ; then
6535 echo "CONFIG_SYNCFS=y" >> $config_host_mak
6537 if test "$inotify" = "yes" ; then
6538 echo "CONFIG_INOTIFY=y" >> $config_host_mak
6540 if test "$inotify1" = "yes" ; then
6541 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6543 if test "$sem_timedwait" = "yes" ; then
6544 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6546 if test "$strchrnul" = "yes" ; then
6547 echo "HAVE_STRCHRNUL=y" >> $config_host_mak
6549 if test "$byteswap_h" = "yes" ; then
6550 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
6552 if test "$bswap_h" = "yes" ; then
6553 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
6555 if test "$curl" = "yes" ; then
6556 echo "CONFIG_CURL=m" >> $config_host_mak
6557 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6558 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6560 if test "$brlapi" = "yes" ; then
6561 echo "CONFIG_BRLAPI=y" >> $config_host_mak
6562 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
6564 if test "$bluez" = "yes" ; then
6565 echo "CONFIG_BLUEZ=y" >> $config_host_mak
6566 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6568 if test "$gtk" = "yes" ; then
6569 echo "CONFIG_GTK=m" >> $config_host_mak
6570 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6571 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6572 if test "$gtk_gl" = "yes" ; then
6573 echo "CONFIG_GTK_GL=y" >> $config_host_mak
6576 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6577 if test "$gnutls" = "yes" ; then
6578 echo "CONFIG_GNUTLS=y" >> $config_host_mak
6580 if test "$gcrypt" = "yes" ; then
6581 echo "CONFIG_GCRYPT=y" >> $config_host_mak
6582 if test "$gcrypt_hmac" = "yes" ; then
6583 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
6586 if test "$nettle" = "yes" ; then
6587 echo "CONFIG_NETTLE=y" >> $config_host_mak
6588 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6590 if test "$tasn1" = "yes" ; then
6591 echo "CONFIG_TASN1=y" >> $config_host_mak
6593 if test "$have_ifaddrs_h" = "yes" ; then
6594 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6596 if test "$have_broken_size_max" = "yes" ; then
6597 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
6600 # Work around a system header bug with some kernel/XFS header
6601 # versions where they both try to define 'struct fsxattr':
6602 # xfs headers will not try to redefine structs from linux headers
6603 # if this macro is set.
6604 if test "$have_fsxattr" = "yes" ; then
6605 echo "HAVE_FSXATTR=y" >> $config_host_mak
6607 if test "$have_copy_file_range" = "yes" ; then
6608 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
6610 if test "$vte" = "yes" ; then
6611 echo "CONFIG_VTE=y" >> $config_host_mak
6612 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6613 echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6615 if test "$virglrenderer" = "yes" ; then
6616 echo "CONFIG_VIRGL=y" >> $config_host_mak
6617 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
6618 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
6620 if test "$xen" = "yes" ; then
6621 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6622 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6624 if test "$linux_aio" = "yes" ; then
6625 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
6627 if test "$attr" = "yes" ; then
6628 echo "CONFIG_ATTR=y" >> $config_host_mak
6630 if test "$libattr" = "yes" ; then
6631 echo "CONFIG_LIBATTR=y" >> $config_host_mak
6633 if test "$virtfs" = "yes" ; then
6634 echo "CONFIG_VIRTFS=y" >> $config_host_mak
6636 if test "$mpath" = "yes" ; then
6637 echo "CONFIG_MPATH=y" >> $config_host_mak
6638 if test "$mpathpersist_new_api" = "yes"; then
6639 echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
6642 if test "$vhost_scsi" = "yes" ; then
6643 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
6645 if test "$vhost_net" = "yes" && test "$vhost_user" = "yes"; then
6646 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
6648 if test "$vhost_crypto" = "yes" ; then
6649 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6651 if test "$vhost_vsock" = "yes" ; then
6652 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6654 if test "$vhost_user" = "yes" ; then
6655 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6657 if test "$blobs" = "yes" ; then
6658 echo "INSTALL_BLOBS=yes" >> $config_host_mak
6660 if test "$iovec" = "yes" ; then
6661 echo "CONFIG_IOVEC=y" >> $config_host_mak
6663 if test "$preadv" = "yes" ; then
6664 echo "CONFIG_PREADV=y" >> $config_host_mak
6666 if test "$fdt" != "no" ; then
6667 echo "CONFIG_FDT=y" >> $config_host_mak
6669 if test "$membarrier" = "yes" ; then
6670 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6672 if test "$signalfd" = "yes" ; then
6673 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6675 if test "$optreset" = "yes" ; then
6676 echo "HAVE_OPTRESET=y" >> $config_host_mak
6678 if test "$tcg" = "yes"; then
6679 echo "CONFIG_TCG=y" >> $config_host_mak
6680 if test "$tcg_interpreter" = "yes" ; then
6681 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
6684 if test "$fdatasync" = "yes" ; then
6685 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
6687 if test "$madvise" = "yes" ; then
6688 echo "CONFIG_MADVISE=y" >> $config_host_mak
6690 if test "$posix_madvise" = "yes" ; then
6691 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6693 if test "$posix_memalign" = "yes" ; then
6694 echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
6697 if test "$spice" = "yes" ; then
6698 echo "CONFIG_SPICE=y" >> $config_host_mak
6701 if test "$smartcard" = "yes" ; then
6702 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
6703 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
6704 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6707 if test "$libusb" = "yes" ; then
6708 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6709 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6710 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
6713 if test "$usb_redir" = "yes" ; then
6714 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6715 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6716 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
6719 if test "$opengl" = "yes" ; then
6720 echo "CONFIG_OPENGL=y" >> $config_host_mak
6721 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6722 if test "$opengl_dmabuf" = "yes" ; then
6723 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6727 if test "$malloc_trim" = "yes" ; then
6728 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
6731 if test "$avx2_opt" = "yes" ; then
6732 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
6735 if test "$lzo" = "yes" ; then
6736 echo "CONFIG_LZO=y" >> $config_host_mak
6739 if test "$snappy" = "yes" ; then
6740 echo "CONFIG_SNAPPY=y" >> $config_host_mak
6743 if test "$bzip2" = "yes" ; then
6744 echo "CONFIG_BZIP2=y" >> $config_host_mak
6745 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
6748 if test "$lzfse" = "yes" ; then
6749 echo "CONFIG_LZFSE=y" >> $config_host_mak
6750 echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
6753 if test "$libiscsi" = "yes" ; then
6754 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6755 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
6756 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6759 if test "$libnfs" = "yes" ; then
6760 echo "CONFIG_LIBNFS=m" >> $config_host_mak
6761 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6764 if test "$seccomp" = "yes"; then
6765 echo "CONFIG_SECCOMP=y" >> $config_host_mak
6766 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6767 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6770 # XXX: suppress that
6771 if [ "$bsd" = "yes" ] ; then
6772 echo "CONFIG_BSD=y" >> $config_host_mak
6775 if test "$localtime_r" = "yes" ; then
6776 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
6778 if test "$qom_cast_debug" = "yes" ; then
6779 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
6781 if test "$rbd" = "yes" ; then
6782 echo "CONFIG_RBD=m" >> $config_host_mak
6783 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
6784 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6787 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
6788 if test "$coroutine_pool" = "yes" ; then
6789 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
6790 else
6791 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
6794 if test "$debug_stack_usage" = "yes" ; then
6795 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
6798 if test "$crypto_afalg" = "yes" ; then
6799 echo "CONFIG_AF_ALG=y" >> $config_host_mak
6802 if test "$open_by_handle_at" = "yes" ; then
6803 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6806 if test "$linux_magic_h" = "yes" ; then
6807 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6810 if test "$pragma_diagnostic_available" = "yes" ; then
6811 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
6814 if test "$valgrind_h" = "yes" ; then
6815 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
6818 if test "$have_asan_iface_fiber" = "yes" ; then
6819 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6822 if test "$has_environ" = "yes" ; then
6823 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
6826 if test "$cpuid_h" = "yes" ; then
6827 echo "CONFIG_CPUID_H=y" >> $config_host_mak
6830 if test "$int128" = "yes" ; then
6831 echo "CONFIG_INT128=y" >> $config_host_mak
6834 if test "$atomic128" = "yes" ; then
6835 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
6838 if test "$cmpxchg128" = "yes" ; then
6839 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
6842 if test "$atomic64" = "yes" ; then
6843 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6846 if test "$vector16" = "yes" ; then
6847 echo "CONFIG_VECTOR16=y" >> $config_host_mak
6850 if test "$getauxval" = "yes" ; then
6851 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
6854 if test "$glusterfs" = "yes" ; then
6855 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6856 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
6857 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6860 if test "$glusterfs_xlator_opt" = "yes" ; then
6861 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6864 if test "$glusterfs_discard" = "yes" ; then
6865 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
6868 if test "$glusterfs_fallocate" = "yes" ; then
6869 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6872 if test "$glusterfs_zerofill" = "yes" ; then
6873 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
6876 if test "$libssh2" = "yes" ; then
6877 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6878 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
6879 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
6882 if test "$live_block_migration" = "yes" ; then
6883 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6886 if test "$tpm" = "yes"; then
6887 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6888 # TPM passthrough support?
6889 if test "$tpm_passthrough" = "yes"; then
6890 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
6892 # TPM emulator support?
6893 if test "$tpm_emulator" = "yes"; then
6894 echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6898 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
6899 if have_backend "nop"; then
6900 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
6902 if have_backend "simple"; then
6903 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
6904 # Set the appropriate trace file.
6905 trace_file="\"$trace_file-\" FMT_pid"
6907 if have_backend "log"; then
6908 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6910 if have_backend "ust"; then
6911 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6913 if have_backend "dtrace"; then
6914 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
6915 if test "$trace_backend_stap" = "yes" ; then
6916 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
6919 if have_backend "ftrace"; then
6920 if test "$linux" = "yes" ; then
6921 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6922 else
6923 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6926 if have_backend "syslog"; then
6927 if test "$posix_syslog" = "yes" ; then
6928 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
6929 else
6930 feature_not_found "syslog(trace backend)" "syslog not available"
6933 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
6935 if test "$rdma" = "yes" ; then
6936 echo "CONFIG_RDMA=y" >> $config_host_mak
6937 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
6940 if test "$pvrdma" = "yes" ; then
6941 echo "CONFIG_PVRDMA=y" >> $config_host_mak
6944 if test "$have_rtnetlink" = "yes" ; then
6945 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6948 if test "$libxml2" = "yes" ; then
6949 echo "CONFIG_LIBXML2=y" >> $config_host_mak
6950 echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6951 echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6954 if test "$replication" = "yes" ; then
6955 echo "CONFIG_REPLICATION=y" >> $config_host_mak
6958 if test "$have_af_vsock" = "yes" ; then
6959 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
6962 if test "$have_sysmacros" = "yes" ; then
6963 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
6966 if test "$have_static_assert" = "yes" ; then
6967 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
6970 if test "$have_utmpx" = "yes" ; then
6971 echo "HAVE_UTMPX=y" >> $config_host_mak
6974 if test "$ivshmem" = "yes" ; then
6975 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6977 if test "$capstone" != "no" ; then
6978 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
6980 if test "$debug_mutex" = "yes" ; then
6981 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6984 # Hold two types of flag:
6985 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
6986 # a thread we have a handle to
6987 # CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
6988 # platform
6989 if test "$pthread_setname_np_w_tid" = "yes" ; then
6990 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6991 echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
6992 elif test "$pthread_setname_np_wo_tid" = "yes" ; then
6993 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6994 echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
6997 if test "$vxhs" = "yes" ; then
6998 echo "CONFIG_VXHS=y" >> $config_host_mak
6999 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
7002 if test "$libpmem" = "yes" ; then
7003 echo "CONFIG_LIBPMEM=y" >> $config_host_mak
7006 if test "$bochs" = "yes" ; then
7007 echo "CONFIG_BOCHS=y" >> $config_host_mak
7009 if test "$cloop" = "yes" ; then
7010 echo "CONFIG_CLOOP=y" >> $config_host_mak
7012 if test "$dmg" = "yes" ; then
7013 echo "CONFIG_DMG=y" >> $config_host_mak
7015 if test "$qcow1" = "yes" ; then
7016 echo "CONFIG_QCOW1=y" >> $config_host_mak
7018 if test "$vdi" = "yes" ; then
7019 echo "CONFIG_VDI=y" >> $config_host_mak
7021 if test "$vvfat" = "yes" ; then
7022 echo "CONFIG_VVFAT=y" >> $config_host_mak
7024 if test "$qed" = "yes" ; then
7025 echo "CONFIG_QED=y" >> $config_host_mak
7027 if test "$parallels" = "yes" ; then
7028 echo "CONFIG_PARALLELS=y" >> $config_host_mak
7030 if test "$sheepdog" = "yes" ; then
7031 echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
7034 if test "$tcg_interpreter" = "yes"; then
7035 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
7036 elif test "$ARCH" = "sparc64" ; then
7037 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
7038 elif test "$ARCH" = "s390x" ; then
7039 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
7040 elif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
7041 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
7042 elif test "$ARCH" = "ppc64" ; then
7043 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
7044 elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
7045 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES"
7046 else
7047 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
7049 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
7051 echo "TOOLS=$tools" >> $config_host_mak
7052 echo "ROMS=$roms" >> $config_host_mak
7053 echo "MAKE=$make" >> $config_host_mak
7054 echo "INSTALL=$install" >> $config_host_mak
7055 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
7056 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
7057 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
7058 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7059 echo "PYTHON=$python" >> $config_host_mak
7060 echo "PYTHON_VERSION=$python_version" >> $config_host_mak
7061 echo "CC=$cc" >> $config_host_mak
7062 if $iasl -h > /dev/null 2>&1; then
7063 echo "IASL=$iasl" >> $config_host_mak
7065 echo "HOST_CC=$host_cc" >> $config_host_mak
7066 echo "CXX=$cxx" >> $config_host_mak
7067 echo "OBJCC=$objcc" >> $config_host_mak
7068 echo "AR=$ar" >> $config_host_mak
7069 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
7070 echo "AS=$as" >> $config_host_mak
7071 echo "CCAS=$ccas" >> $config_host_mak
7072 echo "CPP=$cpp" >> $config_host_mak
7073 echo "OBJCOPY=$objcopy" >> $config_host_mak
7074 echo "LD=$ld" >> $config_host_mak
7075 echo "RANLIB=$ranlib" >> $config_host_mak
7076 echo "NM=$nm" >> $config_host_mak
7077 echo "WINDRES=$windres" >> $config_host_mak
7078 echo "CFLAGS=$CFLAGS" >> $config_host_mak
7079 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7080 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
7081 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7082 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7083 if test "$sparse" = "yes" ; then
7084 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
7085 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
7086 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
7087 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
7088 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7090 if test "$cross_prefix" != ""; then
7091 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
7092 else
7093 echo "AUTOCONF_HOST := " >> $config_host_mak
7095 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
7096 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
7097 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
7098 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7099 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
7100 echo "LIBS+=$LIBS" >> $config_host_mak
7101 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7102 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7103 echo "EXESUF=$EXESUF" >> $config_host_mak
7104 echo "DSOSUF=$DSOSUF" >> $config_host_mak
7105 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7106 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
7107 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
7108 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
7109 echo "POD2MAN=$POD2MAN" >> $config_host_mak
7110 if test "$gcov" = "yes" ; then
7111 echo "CONFIG_GCOV=y" >> $config_host_mak
7112 echo "GCOV=$gcov_tool" >> $config_host_mak
7115 if test "$docker" != "no"; then
7116 echo "HAVE_USER_DOCKER=y" >> $config_host_mak
7119 if test "$libudev" != "no"; then
7120 echo "CONFIG_LIBUDEV=y" >> $config_host_mak
7121 echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
7124 # use included Linux headers
7125 if test "$linux" = "yes" ; then
7126 mkdir -p linux-headers
7127 case "$cpu" in
7128 i386|x86_64|x32)
7129 linux_arch=x86
7131 ppc|ppc64)
7132 linux_arch=powerpc
7134 s390x)
7135 linux_arch=s390
7137 aarch64)
7138 linux_arch=arm64
7140 mips64)
7141 linux_arch=mips
7144 # For most CPUs the kernel architecture name and QEMU CPU name match.
7145 linux_arch="$cpu"
7147 esac
7148 # For non-KVM architectures we will not have asm headers
7149 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
7150 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
7154 for target in $target_list; do
7155 target_dir="$target"
7156 config_target_mak=$target_dir/config-target.mak
7157 target_name=$(echo $target | cut -d '-' -f 1)
7158 target_bigendian="no"
7160 case "$target_name" in
7161 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
7162 target_bigendian=yes
7164 esac
7165 target_softmmu="no"
7166 target_user_only="no"
7167 target_linux_user="no"
7168 target_bsd_user="no"
7169 case "$target" in
7170 ${target_name}-softmmu)
7171 target_softmmu="yes"
7173 ${target_name}-linux-user)
7174 target_user_only="yes"
7175 target_linux_user="yes"
7177 ${target_name}-bsd-user)
7178 target_user_only="yes"
7179 target_bsd_user="yes"
7182 error_exit "Target '$target' not recognised"
7183 exit 1
7185 esac
7187 target_compiler=""
7188 target_compiler_static=""
7189 target_compiler_cflags=""
7191 mkdir -p $target_dir
7192 echo "# Automatically generated by configure - do not modify" > $config_target_mak
7194 bflt="no"
7195 mttcg="no"
7196 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
7197 gdb_xml_files=""
7199 TARGET_ARCH="$target_name"
7200 TARGET_BASE_ARCH=""
7201 TARGET_ABI_DIR=""
7203 case "$target_name" in
7204 i386)
7205 mttcg="yes"
7206 gdb_xml_files="i386-32bit.xml"
7207 target_compiler=$cross_cc_i386
7208 target_compiler_cflags=$cross_cc_ccflags_i386
7210 x86_64)
7211 TARGET_BASE_ARCH=i386
7212 mttcg="yes"
7213 gdb_xml_files="i386-64bit.xml"
7214 target_compiler=$cross_cc_x86_64
7216 alpha)
7217 mttcg="yes"
7218 target_compiler=$cross_cc_alpha
7220 arm|armeb)
7221 TARGET_ARCH=arm
7222 bflt="yes"
7223 mttcg="yes"
7224 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7225 target_compiler=$cross_cc_arm
7226 eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
7228 aarch64|aarch64_be)
7229 TARGET_ARCH=aarch64
7230 TARGET_BASE_ARCH=arm
7231 bflt="yes"
7232 mttcg="yes"
7233 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7234 target_compiler=$cross_cc_aarch64
7235 eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
7237 cris)
7238 target_compiler=$cross_cc_cris
7240 hppa)
7241 mttcg="yes"
7242 target_compiler=$cross_cc_hppa
7244 lm32)
7245 target_compiler=$cross_cc_lm32
7247 m68k)
7248 bflt="yes"
7249 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
7250 target_compiler=$cross_cc_m68k
7252 microblaze|microblazeel)
7253 TARGET_ARCH=microblaze
7254 bflt="yes"
7255 echo "TARGET_ABI32=y" >> $config_target_mak
7256 target_compiler=$cross_cc_microblaze
7258 mips|mipsel)
7259 mttcg="yes"
7260 TARGET_ARCH=mips
7261 target_compiler=$cross_cc_mips
7262 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
7264 mipsn32|mipsn32el)
7265 mttcg="yes"
7266 TARGET_ARCH=mips64
7267 TARGET_BASE_ARCH=mips
7268 target_compiler=$cross_cc_mipsn32
7269 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7270 echo "TARGET_ABI32=y" >> $config_target_mak
7272 mips64|mips64el)
7273 mttcg="yes"
7274 TARGET_ARCH=mips64
7275 TARGET_BASE_ARCH=mips
7276 target_compiler=$cross_cc_mips64
7277 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
7279 moxie)
7280 target_compiler=$cross_cc_moxie
7282 nios2)
7283 target_compiler=$cross_cc_nios2
7285 or1k)
7286 target_compiler=$cross_cc_or1k
7287 TARGET_ARCH=openrisc
7288 TARGET_BASE_ARCH=openrisc
7290 ppc)
7291 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7292 target_compiler=$cross_cc_powerpc
7294 ppc64)
7295 TARGET_BASE_ARCH=ppc
7296 TARGET_ABI_DIR=ppc
7297 mttcg=yes
7298 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7299 target_compiler=$cross_cc_ppc64
7301 ppc64le)
7302 TARGET_ARCH=ppc64
7303 TARGET_BASE_ARCH=ppc
7304 TARGET_ABI_DIR=ppc
7305 mttcg=yes
7306 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7307 target_compiler=$cross_cc_ppc64le
7309 ppc64abi32)
7310 TARGET_ARCH=ppc64
7311 TARGET_BASE_ARCH=ppc
7312 TARGET_ABI_DIR=ppc
7313 echo "TARGET_ABI32=y" >> $config_target_mak
7314 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7315 target_compiler=$cross_cc_ppc64abi32
7317 riscv32)
7318 TARGET_BASE_ARCH=riscv
7319 TARGET_ABI_DIR=riscv
7320 mttcg=yes
7321 target_compiler=$cross_cc_riscv32
7323 riscv64)
7324 TARGET_BASE_ARCH=riscv
7325 TARGET_ABI_DIR=riscv
7326 mttcg=yes
7327 target_compiler=$cross_cc_riscv64
7329 sh4|sh4eb)
7330 TARGET_ARCH=sh4
7331 bflt="yes"
7332 target_compiler=$cross_cc_sh4
7334 sparc)
7335 target_compiler=$cross_cc_sparc
7337 sparc64)
7338 TARGET_BASE_ARCH=sparc
7339 target_compiler=$cross_cc_sparc64
7341 sparc32plus)
7342 TARGET_ARCH=sparc64
7343 TARGET_BASE_ARCH=sparc
7344 TARGET_ABI_DIR=sparc
7345 target_compiler=$cross_cc_sparc32plus
7346 echo "TARGET_ABI32=y" >> $config_target_mak
7348 s390x)
7349 mttcg=yes
7350 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
7351 target_compiler=$cross_cc_s390x
7353 tilegx)
7354 target_compiler=$cross_cc_tilegx
7356 tricore)
7357 target_compiler=$cross_cc_tricore
7359 unicore32)
7360 target_compiler=$cross_cc_unicore32
7362 xtensa|xtensaeb)
7363 TARGET_ARCH=xtensa
7364 bflt="yes"
7365 mttcg="yes"
7366 target_compiler=$cross_cc_xtensa
7369 error_exit "Unsupported target CPU"
7371 esac
7372 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
7373 if [ "$TARGET_BASE_ARCH" = "" ]; then
7374 TARGET_BASE_ARCH=$TARGET_ARCH
7377 # Do we have a cross compiler for this target?
7378 if has $target_compiler; then
7380 write_c_skeleton
7382 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
7383 # For host systems we might get away with building without -static
7384 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
7385 target_compiler=""
7386 else
7387 enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7388 target_compiler_static="n"
7390 else
7391 enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7392 target_compiler_static="y"
7394 else
7395 target_compiler=""
7398 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
7400 upper() {
7401 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
7404 target_arch_name="$(upper $TARGET_ARCH)"
7405 echo "TARGET_$target_arch_name=y" >> $config_target_mak
7406 echo "TARGET_NAME=$target_name" >> $config_target_mak
7407 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7408 if [ "$TARGET_ABI_DIR" = "" ]; then
7409 TARGET_ABI_DIR=$TARGET_ARCH
7411 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7412 if [ "$HOST_VARIANT_DIR" != "" ]; then
7413 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7416 if supported_xen_target $target; then
7417 echo "CONFIG_XEN=y" >> $config_target_mak
7418 if test "$xen_pci_passthrough" = yes; then
7419 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7422 if supported_kvm_target $target; then
7423 echo "CONFIG_KVM=y" >> $config_target_mak
7424 if test "$vhost_net" = "yes" ; then
7425 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
7426 if test "$vhost_user" = "yes" ; then
7427 echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
7431 if supported_hax_target $target; then
7432 echo "CONFIG_HAX=y" >> $config_target_mak
7434 if supported_hvf_target $target; then
7435 echo "CONFIG_HVF=y" >> $config_target_mak
7437 if supported_whpx_target $target; then
7438 echo "CONFIG_WHPX=y" >> $config_target_mak
7440 if test "$target_bigendian" = "yes" ; then
7441 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
7443 if test "$target_softmmu" = "yes" ; then
7444 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7445 if test "$mttcg" = "yes" ; then
7446 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7449 if test "$target_user_only" = "yes" ; then
7450 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7451 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7453 if test "$target_linux_user" = "yes" ; then
7454 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7456 list=""
7457 if test ! -z "$gdb_xml_files" ; then
7458 for x in $gdb_xml_files; do
7459 list="$list $source_path/gdb-xml/$x"
7460 done
7461 echo "TARGET_XML_FILES=$list" >> $config_target_mak
7464 if test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
7465 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7467 if test "$target_bsd_user" = "yes" ; then
7468 echo "CONFIG_BSD_USER=y" >> $config_target_mak
7471 if test -n "$target_compiler"; then
7472 echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7474 if test -n "$target_compiler_static"; then
7475 echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7478 if test -n "$target_compiler_cflags"; then
7479 echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
7484 # generate QEMU_CFLAGS/LDFLAGS for targets
7486 cflags=""
7487 ldflags=""
7489 disas_config() {
7490 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7491 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7494 for i in $ARCH $TARGET_BASE_ARCH ; do
7495 case "$i" in
7496 alpha)
7497 disas_config "ALPHA"
7499 aarch64)
7500 if test -n "${cxx}"; then
7501 disas_config "ARM_A64"
7504 arm)
7505 disas_config "ARM"
7506 if test -n "${cxx}"; then
7507 disas_config "ARM_A64"
7510 cris)
7511 disas_config "CRIS"
7513 hppa)
7514 disas_config "HPPA"
7516 i386|x86_64|x32)
7517 disas_config "I386"
7519 lm32)
7520 disas_config "LM32"
7522 m68k)
7523 disas_config "M68K"
7525 microblaze*)
7526 disas_config "MICROBLAZE"
7528 mips*)
7529 disas_config "MIPS"
7530 if test -n "${cxx}"; then
7531 disas_config "NANOMIPS"
7534 moxie*)
7535 disas_config "MOXIE"
7537 nios2)
7538 disas_config "NIOS2"
7540 or1k)
7541 disas_config "OPENRISC"
7543 ppc*)
7544 disas_config "PPC"
7546 riscv*)
7547 disas_config "RISCV"
7549 s390*)
7550 disas_config "S390"
7552 sh4)
7553 disas_config "SH4"
7555 sparc*)
7556 disas_config "SPARC"
7558 xtensa*)
7559 disas_config "XTENSA"
7561 esac
7562 done
7563 if test "$tcg_interpreter" = "yes" ; then
7564 disas_config "TCI"
7567 case "$ARCH" in
7568 alpha)
7569 # Ensure there's only a single GP
7570 cflags="-msmall-data $cflags"
7572 esac
7574 if test "$gprof" = "yes" ; then
7575 echo "TARGET_GPROF=y" >> $config_target_mak
7576 if test "$target_linux_user" = "yes" ; then
7577 cflags="-p $cflags"
7578 ldflags="-p $ldflags"
7580 if test "$target_softmmu" = "yes" ; then
7581 ldflags="-p $ldflags"
7582 echo "GPROF_CFLAGS=-p" >> $config_target_mak
7586 if test "$target_linux_user" = "yes" || test "$target_bsd_user" = "yes" ; then
7587 ldflags="$ldflags $textseg_ldflags"
7590 # Newer kernels on s390 check for an S390_PGSTE program header and
7591 # enable the pgste page table extensions in that case. This makes
7592 # the vm.allocate_pgste sysctl unnecessary. We enable this program
7593 # header if
7594 # - we build on s390x
7595 # - we build the system emulation for s390x (qemu-system-s390x)
7596 # - KVM is enabled
7597 # - the linker supports --s390-pgste
7598 if test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
7599 test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
7600 if ld_has --s390-pgste ; then
7601 ldflags="-Wl,--s390-pgste $ldflags"
7605 echo "LDFLAGS+=$ldflags" >> $config_target_mak
7606 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7608 done # for target in $targets
7610 if test -n "$enabled_cross_compilers"; then
7611 echo
7612 echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7615 if [ "$fdt" = "git" ]; then
7616 echo "config-host.h: subdir-dtc" >> $config_host_mak
7618 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7619 echo "config-host.h: subdir-capstone" >> $config_host_mak
7621 if test -n "$LIBCAPSTONE"; then
7622 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7625 if test "$numa" = "yes"; then
7626 echo "CONFIG_NUMA=y" >> $config_host_mak
7629 if test "$ccache_cpp2" = "yes"; then
7630 echo "export CCACHE_CPP2=y" >> $config_host_mak
7633 # If we're using a separate build tree, set it up now.
7634 # DIRS are directories which we simply mkdir in the build tree;
7635 # LINKS are things to symlink back into the source tree
7636 # (these can be both files and directories).
7637 # Caution: do not add files or directories here using wildcards. This
7638 # will result in problems later if a new file matching the wildcard is
7639 # added to the source tree -- nothing will cause configure to be rerun
7640 # so the build tree will be missing the link back to the new file, and
7641 # tests might fail. Prefer to keep the relevant files in their own
7642 # directory and symlink the directory instead.
7643 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
7644 DIRS="$DIRS tests/fp"
7645 DIRS="$DIRS docs docs/interop fsdev scsi"
7646 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
7647 DIRS="$DIRS roms/seabios roms/vgabios"
7648 LINKS="Makefile tests/tcg/Makefile qdict-test-data.txt"
7649 LINKS="$LINKS tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
7650 LINKS="$LINKS tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
7651 LINKS="$LINKS tests/fp/Makefile"
7652 LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
7653 LINKS="$LINKS pc-bios/spapr-rtas/Makefile"
7654 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
7655 LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
7656 LINKS="$LINKS pc-bios/qemu-icon.bmp"
7657 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
7658 LINKS="$LINKS tests/acceptance tests/data"
7659 LINKS="$LINKS tests/qemu-iotests/check"
7660 for bios_file in \
7661 $source_path/pc-bios/*.bin \
7662 $source_path/pc-bios/*.lid \
7663 $source_path/pc-bios/*.rom \
7664 $source_path/pc-bios/*.dtb \
7665 $source_path/pc-bios/*.img \
7666 $source_path/pc-bios/openbios-* \
7667 $source_path/pc-bios/u-boot.* \
7668 $source_path/pc-bios/palcode-*
7670 LINKS="$LINKS pc-bios/$(basename $bios_file)"
7671 done
7672 mkdir -p $DIRS
7673 for f in $LINKS ; do
7674 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7675 symlink "$source_path/$f" "$f"
7677 done
7679 # temporary config to build submodules
7680 for rom in seabios vgabios ; do
7681 config_mak=roms/$rom/config.mak
7682 echo "# Automatically generated by configure - do not modify" > $config_mak
7683 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7684 echo "AS=$as" >> $config_mak
7685 echo "CCAS=$ccas" >> $config_mak
7686 echo "CC=$cc" >> $config_mak
7687 echo "BCC=bcc" >> $config_mak
7688 echo "CPP=$cpp" >> $config_mak
7689 echo "OBJCOPY=objcopy" >> $config_mak
7690 echo "IASL=$iasl" >> $config_mak
7691 echo "LD=$ld" >> $config_mak
7692 echo "RANLIB=$ranlib" >> $config_mak
7693 done
7695 # set up qemu-iotests in this build directory
7696 iotests_common_env="tests/qemu-iotests/common.env"
7698 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
7699 echo >> "$iotests_common_env"
7700 echo "export PYTHON='$python'" >> "$iotests_common_env"
7702 # Save the configure command line for later reuse.
7703 cat <<EOD >config.status
7704 #!/bin/sh
7705 # Generated by configure.
7706 # Run this file to recreate the current configuration.
7707 # Compiler output produced by configure, useful for debugging
7708 # configure, is in config.log if it exists.
7711 preserve_env() {
7712 envname=$1
7714 eval envval=\$$envname
7716 if test -n "$envval"
7717 then
7718 echo "$envname='$envval'" >> config.status
7719 echo "export $envname" >> config.status
7720 else
7721 echo "unset $envname" >> config.status
7725 # Preserve various env variables that influence what
7726 # features/build target configure will detect
7727 preserve_env AR
7728 preserve_env AS
7729 preserve_env CC
7730 preserve_env CPP
7731 preserve_env CXX
7732 preserve_env INSTALL
7733 preserve_env LD
7734 preserve_env LD_LIBRARY_PATH
7735 preserve_env LIBTOOL
7736 preserve_env MAKE
7737 preserve_env NM
7738 preserve_env OBJCOPY
7739 preserve_env PATH
7740 preserve_env PKG_CONFIG
7741 preserve_env PKG_CONFIG_LIBDIR
7742 preserve_env PKG_CONFIG_PATH
7743 preserve_env PYTHON
7744 preserve_env SDL_CONFIG
7745 preserve_env SDL2_CONFIG
7746 preserve_env SMBD
7747 preserve_env STRIP
7748 preserve_env WINDRES
7750 printf "exec" >>config.status
7751 printf " '%s'" "$0" "$@" >>config.status
7752 echo ' "$@"' >>config.status
7753 chmod +x config.status
7755 rm -r "$TMPDIR1"