block: Refactor subdirectory recursion during make
[qemu/ar7.git] / configure
blobb01b5e3bed001e1f541bc13d653af4f370940c73
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"
33 TMPTXT="${TMPDIR1}/${TMPB}.txt"
35 rm -f config.log
37 # Print a helpful header at the top of config.log
38 echo "# QEMU configure log $(date)" >> config.log
39 printf "# Configured with:" >> config.log
40 printf " '%s'" "$0" "$@" >> config.log
41 echo >> config.log
42 echo "#" >> config.log
44 print_error() {
45 (echo
46 echo "ERROR: $1"
47 while test -n "$2"; do
48 echo " $2"
49 shift
50 done
51 echo) >&2
54 error_exit() {
55 print_error "$@"
56 exit 1
59 do_compiler() {
60 # Run the compiler, capturing its output to the log. First argument
61 # is compiler binary to execute.
62 local compiler="$1"
63 shift
64 if test -n "$BASH_VERSION"; then eval '
65 echo >>config.log "
66 funcs: ${FUNCNAME[*]}
67 lines: ${BASH_LINENO[*]}"
68 '; fi
69 echo $compiler "$@" >> config.log
70 $compiler "$@" >> config.log 2>&1 || return $?
71 # Test passed. If this is an --enable-werror build, rerun
72 # the test with -Werror and bail out if it fails. This
73 # makes warning-generating-errors in configure test code
74 # obvious to developers.
75 if test "$werror" != "yes"; then
76 return 0
78 # Don't bother rerunning the compile if we were already using -Werror
79 case "$*" in
80 *-Werror*)
81 return 0
83 esac
84 echo $compiler -Werror "$@" >> config.log
85 $compiler -Werror "$@" >> config.log 2>&1 && return $?
86 error_exit "configure test passed without -Werror but failed with -Werror." \
87 "This is probably a bug in the configure script. The failing command" \
88 "will be at the bottom of config.log." \
89 "You can run configure with --disable-werror to bypass this check."
92 do_cc() {
93 do_compiler "$cc" "$@"
96 do_cxx() {
97 do_compiler "$cxx" "$@"
100 update_cxxflags() {
101 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
102 # options which some versions of GCC's C++ compiler complain about
103 # because they only make sense for C programs.
104 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
106 for arg in $QEMU_CFLAGS; do
107 case $arg in
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 $QEMU_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 | mips64:mips | mips64el:mips | \
202 ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | ppc64:ppc64le | \
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 # make source path absolute
281 source_path=$(cd "$(dirname -- "$0")"; pwd)
283 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
284 then
285 error_exit "main directory cannot contain spaces nor colons"
288 # default parameters
289 cpu=""
290 iasl="iasl"
291 interp_prefix="/usr/gnemul/qemu-%M"
292 static="no"
293 cross_prefix=""
294 audio_drv_list=""
295 block_drv_rw_whitelist=""
296 block_drv_ro_whitelist=""
297 host_cc="cc"
298 libs_cpu=""
299 libs_softmmu=""
300 libs_tools=""
301 audio_win_int=""
302 libs_qga=""
303 debug_info="yes"
304 stack_protector=""
305 use_containers="yes"
306 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
308 if test -e "$source_path/.git"
309 then
310 git_update=yes
311 git_submodules="ui/keycodemapdb"
312 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
313 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
314 else
315 git_update=no
316 git_submodules=""
318 if ! test -f "$source_path/ui/keycodemapdb/README"
319 then
320 echo
321 echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
322 echo
323 echo "This is not a GIT checkout but module content appears to"
324 echo "be missing. Do not use 'git archive' or GitHub download links"
325 echo "to acquire QEMU source archives. Non-GIT builds are only"
326 echo "supported with source archives linked from:"
327 echo
328 echo " https://www.qemu.org/download/#source"
329 echo
330 echo "Developers working with GIT can use scripts/archive-source.sh"
331 echo "if they need to create valid source archives."
332 echo
333 exit 1
336 git="git"
338 # Don't accept a target_list environment variable.
339 unset target_list
340 unset target_list_exclude
342 # Default value for a variable defining feature "foo".
343 # * foo="no" feature will only be used if --enable-foo arg is given
344 # * foo="" feature will be searched for, and if found, will be used
345 # unless --disable-foo is given
346 # * foo="yes" this value will only be set by --enable-foo flag.
347 # feature will searched for,
348 # if not found, configure exits with error
350 # Always add --enable-foo and --disable-foo command line args.
351 # Distributions want to ensure that several features are compiled in, and it
352 # is impossible without a --enable-foo that exits if a feature is not found.
354 brlapi=""
355 curl=""
356 curses=""
357 docs=""
358 fdt=""
359 netmap="no"
360 sdl=""
361 sdl_image=""
362 virtfs=""
363 mpath=""
364 vnc="yes"
365 sparse="no"
366 vde=""
367 vnc_sasl=""
368 vnc_jpeg=""
369 vnc_png=""
370 xkbcommon=""
371 xen=""
372 xen_ctrl_version=""
373 xen_pci_passthrough=""
374 linux_aio=""
375 linux_io_uring=""
376 cap_ng=""
377 attr=""
378 libattr=""
379 xfs=""
380 tcg="yes"
381 membarrier=""
382 vhost_net=""
383 vhost_crypto=""
384 vhost_scsi=""
385 vhost_vsock=""
386 vhost_user=""
387 vhost_user_fs=""
388 kvm="no"
389 hax="no"
390 hvf="no"
391 whpx="no"
392 rdma=""
393 pvrdma=""
394 gprof="no"
395 debug_tcg="no"
396 debug="no"
397 sanitizers="no"
398 tsan="no"
399 fortify_source=""
400 strip_opt="yes"
401 tcg_interpreter="no"
402 bigendian="no"
403 mingw32="no"
404 gcov="no"
405 gcov_tool="gcov"
406 EXESUF=""
407 DSOSUF=".so"
408 LDFLAGS_SHARED="-shared"
409 modules="no"
410 module_upgrades="no"
411 prefix="/usr/local"
412 mandir="\${prefix}/share/man"
413 datadir="\${prefix}/share"
414 firmwarepath="\${prefix}/share/qemu-firmware"
415 qemu_docdir="\${prefix}/share/doc/qemu"
416 bindir="\${prefix}/bin"
417 libdir="\${prefix}/lib"
418 libexecdir="\${prefix}/libexec"
419 includedir="\${prefix}/include"
420 sysconfdir="\${prefix}/etc"
421 local_statedir="\${prefix}/var"
422 confsuffix="/qemu"
423 slirp=""
424 oss_lib=""
425 bsd="no"
426 linux="no"
427 solaris="no"
428 profiler="no"
429 cocoa="no"
430 softmmu="yes"
431 linux_user="no"
432 bsd_user="no"
433 blobs="yes"
434 edk2_blobs="no"
435 pkgversion=""
436 pie=""
437 qom_cast_debug="yes"
438 trace_backends="log"
439 trace_file="trace"
440 spice=""
441 rbd=""
442 smartcard=""
443 libusb=""
444 usb_redir=""
445 opengl=""
446 opengl_dmabuf="no"
447 cpuid_h="no"
448 avx2_opt=""
449 zlib="yes"
450 capstone=""
451 lzo=""
452 snappy=""
453 bzip2=""
454 lzfse=""
455 zstd=""
456 guest_agent=""
457 guest_agent_with_vss="no"
458 guest_agent_ntddscsi="no"
459 guest_agent_msi=""
460 vss_win32_sdk=""
461 win_sdk="no"
462 want_tools=""
463 libiscsi=""
464 libnfs=""
465 coroutine=""
466 coroutine_pool=""
467 debug_stack_usage="no"
468 crypto_afalg="no"
469 seccomp=""
470 glusterfs=""
471 glusterfs_xlator_opt="no"
472 glusterfs_discard="no"
473 glusterfs_fallocate="no"
474 glusterfs_zerofill="no"
475 glusterfs_ftruncate_has_stat="no"
476 glusterfs_iocb_has_stat="no"
477 gtk=""
478 gtk_gl="no"
479 tls_priority="NORMAL"
480 gnutls=""
481 nettle=""
482 nettle_xts="no"
483 gcrypt=""
484 gcrypt_hmac="no"
485 gcrypt_xts="no"
486 qemu_private_xts="yes"
487 auth_pam=""
488 vte=""
489 virglrenderer=""
490 tpm=""
491 libssh=""
492 live_block_migration="yes"
493 numa=""
494 tcmalloc="no"
495 jemalloc="no"
496 replication="yes"
497 vxhs=""
498 bochs="yes"
499 cloop="yes"
500 dmg="yes"
501 qcow1="yes"
502 vdi="yes"
503 vvfat="yes"
504 qed="yes"
505 parallels="yes"
506 sheepdog="yes"
507 libxml2=""
508 debug_mutex="no"
509 libpmem=""
510 default_devices="yes"
511 plugins="no"
512 fuzzing="no"
513 rng_none="no"
514 secret_keyring=""
516 supported_cpu="no"
517 supported_os="no"
518 bogus_os="no"
519 malloc_trim=""
521 # parse CC options first
522 for opt do
523 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
524 case "$opt" in
525 --cross-prefix=*) cross_prefix="$optarg"
527 --cc=*) CC="$optarg"
529 --cxx=*) CXX="$optarg"
531 --cpu=*) cpu="$optarg"
533 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
534 QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
536 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
538 --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
539 EXTRA_LDFLAGS="$optarg"
541 --enable-debug-info) debug_info="yes"
543 --disable-debug-info) debug_info="no"
545 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
547 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
548 eval "cross_cc_cflags_${cc_arch}=\$optarg"
549 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
551 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
552 cc_archs="$cc_archs $cc_arch"
553 eval "cross_cc_${cc_arch}=\$optarg"
554 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
556 esac
557 done
558 # OS specific
559 # Using uname is really, really broken. Once we have the right set of checks
560 # we can eliminate its usage altogether.
562 # Preferred compiler:
563 # ${CC} (if set)
564 # ${cross_prefix}gcc (if cross-prefix specified)
565 # system compiler
566 if test -z "${CC}${cross_prefix}"; then
567 cc="$host_cc"
568 else
569 cc="${CC-${cross_prefix}gcc}"
572 if test -z "${CXX}${cross_prefix}"; then
573 cxx="c++"
574 else
575 cxx="${CXX-${cross_prefix}g++}"
578 ar="${AR-${cross_prefix}ar}"
579 as="${AS-${cross_prefix}as}"
580 ccas="${CCAS-$cc}"
581 cpp="${CPP-$cc -E}"
582 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
583 ld="${LD-${cross_prefix}ld}"
584 ranlib="${RANLIB-${cross_prefix}ranlib}"
585 nm="${NM-${cross_prefix}nm}"
586 strip="${STRIP-${cross_prefix}strip}"
587 windres="${WINDRES-${cross_prefix}windres}"
588 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
589 query_pkg_config() {
590 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
592 pkg_config=query_pkg_config
593 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
595 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
596 ARFLAGS="${ARFLAGS-rv}"
598 # default flags for all hosts
599 # We use -fwrapv to tell the compiler that we require a C dialect where
600 # left shift of signed integers is well defined and has the expected
601 # 2s-complement style results. (Both clang and gcc agree that it
602 # provides these semantics.)
603 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
604 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
605 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
606 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
607 QEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
608 QEMU_INCLUDES="$QEMU_INCLUDES -iquote \$(SRC_PATH)/disas/libvixl"
609 if test "$debug_info" = "yes"; then
610 CFLAGS="-g $CFLAGS"
613 # running configure in the source tree?
614 # we know that's the case if configure is there.
615 if test -f "./configure"; then
616 pwd_is_source_path="y"
617 else
618 pwd_is_source_path="n"
621 check_define() {
622 cat > $TMPC <<EOF
623 #if !defined($1)
624 #error $1 not defined
625 #endif
626 int main(void) { return 0; }
628 compile_object
631 check_include() {
632 cat > $TMPC <<EOF
633 #include <$1>
634 int main(void) { return 0; }
636 compile_object
639 write_c_skeleton() {
640 cat > $TMPC <<EOF
641 int main(void) { return 0; }
645 write_c_fuzzer_skeleton() {
646 cat > $TMPC <<EOF
647 #include <stdint.h>
648 #include <sys/types.h>
649 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
650 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
654 if check_define __linux__ ; then
655 targetos="Linux"
656 elif check_define _WIN32 ; then
657 targetos='MINGW32'
658 elif check_define __OpenBSD__ ; then
659 targetos='OpenBSD'
660 elif check_define __sun__ ; then
661 targetos='SunOS'
662 elif check_define __HAIKU__ ; then
663 targetos='Haiku'
664 elif check_define __FreeBSD__ ; then
665 targetos='FreeBSD'
666 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
667 targetos='GNU/kFreeBSD'
668 elif check_define __DragonFly__ ; then
669 targetos='DragonFly'
670 elif check_define __NetBSD__; then
671 targetos='NetBSD'
672 elif check_define __APPLE__; then
673 targetos='Darwin'
674 else
675 # This is a fatal error, but don't report it yet, because we
676 # might be going to just print the --help text, or it might
677 # be the result of a missing compiler.
678 targetos='bogus'
679 bogus_os='yes'
682 # Some host OSes need non-standard checks for which CPU to use.
683 # Note that these checks are broken for cross-compilation: if you're
684 # cross-compiling to one of these OSes then you'll need to specify
685 # the correct CPU with the --cpu option.
686 case $targetos in
687 Darwin)
688 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
689 # run 64-bit userspace code.
690 # If the user didn't specify a CPU explicitly and the kernel says this is
691 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
692 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
693 cpu="x86_64"
696 SunOS)
697 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
698 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
699 cpu="x86_64"
701 esac
703 if test ! -z "$cpu" ; then
704 # command line argument
706 elif check_define __i386__ ; then
707 cpu="i386"
708 elif check_define __x86_64__ ; then
709 if check_define __ILP32__ ; then
710 cpu="x32"
711 else
712 cpu="x86_64"
714 elif check_define __sparc__ ; then
715 if check_define __arch64__ ; then
716 cpu="sparc64"
717 else
718 cpu="sparc"
720 elif check_define _ARCH_PPC ; then
721 if check_define _ARCH_PPC64 ; then
722 if check_define _LITTLE_ENDIAN ; then
723 cpu="ppc64le"
724 else
725 cpu="ppc64"
727 else
728 cpu="ppc"
730 elif check_define __mips__ ; then
731 cpu="mips"
732 elif check_define __s390__ ; then
733 if check_define __s390x__ ; then
734 cpu="s390x"
735 else
736 cpu="s390"
738 elif check_define __riscv ; then
739 if check_define _LP64 ; then
740 cpu="riscv64"
741 else
742 cpu="riscv32"
744 elif check_define __arm__ ; then
745 cpu="arm"
746 elif check_define __aarch64__ ; then
747 cpu="aarch64"
748 else
749 cpu=$(uname -m)
752 ARCH=
753 # Normalise host CPU name and set ARCH.
754 # Note that this case should only have supported host CPUs, not guests.
755 case "$cpu" in
756 ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
757 supported_cpu="yes"
759 ppc64le)
760 ARCH="ppc64"
761 supported_cpu="yes"
763 i386|i486|i586|i686|i86pc|BePC)
764 cpu="i386"
765 supported_cpu="yes"
767 x86_64|amd64)
768 cpu="x86_64"
769 supported_cpu="yes"
771 armv*b|armv*l|arm)
772 cpu="arm"
773 supported_cpu="yes"
775 aarch64)
776 cpu="aarch64"
777 supported_cpu="yes"
779 mips*)
780 cpu="mips"
781 supported_cpu="yes"
783 sparc|sun4[cdmuv])
784 cpu="sparc"
785 supported_cpu="yes"
788 # This will result in either an error or falling back to TCI later
789 ARCH=unknown
791 esac
792 if test -z "$ARCH"; then
793 ARCH="$cpu"
796 # OS specific
798 # host *BSD for user mode
799 HOST_VARIANT_DIR=""
801 case $targetos in
802 MINGW32*)
803 mingw32="yes"
804 hax="yes"
805 vhost_user="no"
806 audio_possible_drivers="dsound sdl"
807 if check_include dsound.h; then
808 audio_drv_list="dsound"
809 else
810 audio_drv_list=""
812 supported_os="yes"
813 pie="no"
815 GNU/kFreeBSD)
816 bsd="yes"
817 audio_drv_list="oss try-sdl"
818 audio_possible_drivers="oss sdl pa"
820 FreeBSD)
821 bsd="yes"
822 make="${MAKE-gmake}"
823 audio_drv_list="oss try-sdl"
824 audio_possible_drivers="oss sdl pa"
825 # needed for kinfo_getvmmap(3) in libutil.h
826 LIBS="-lutil $LIBS"
827 # needed for kinfo_getproc
828 libs_qga="-lutil $libs_qga"
829 netmap="" # enable netmap autodetect
830 HOST_VARIANT_DIR="freebsd"
831 supported_os="yes"
833 DragonFly)
834 bsd="yes"
835 make="${MAKE-gmake}"
836 audio_drv_list="oss try-sdl"
837 audio_possible_drivers="oss sdl pa"
838 HOST_VARIANT_DIR="dragonfly"
840 NetBSD)
841 bsd="yes"
842 hax="yes"
843 make="${MAKE-gmake}"
844 audio_drv_list="oss try-sdl"
845 audio_possible_drivers="oss sdl"
846 oss_lib="-lossaudio"
847 HOST_VARIANT_DIR="netbsd"
848 supported_os="yes"
850 OpenBSD)
851 bsd="yes"
852 make="${MAKE-gmake}"
853 audio_drv_list="try-sdl"
854 audio_possible_drivers="sdl"
855 HOST_VARIANT_DIR="openbsd"
856 supported_os="yes"
858 Darwin)
859 bsd="yes"
860 darwin="yes"
861 hax="yes"
862 hvf="yes"
863 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
864 if [ "$cpu" = "x86_64" ] ; then
865 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
866 QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
868 cocoa="yes"
869 audio_drv_list="coreaudio try-sdl"
870 audio_possible_drivers="coreaudio sdl"
871 QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
872 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
873 # Disable attempts to use ObjectiveC features in os/object.h since they
874 # won't work when we're compiling with gcc as a C compiler.
875 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
876 HOST_VARIANT_DIR="darwin"
877 supported_os="yes"
879 SunOS)
880 solaris="yes"
881 make="${MAKE-gmake}"
882 install="${INSTALL-ginstall}"
883 smbd="${SMBD-/usr/sfw/sbin/smbd}"
884 if test -f /usr/include/sys/soundcard.h ; then
885 audio_drv_list="oss try-sdl"
887 audio_possible_drivers="oss sdl"
888 # needed for CMSG_ macros in sys/socket.h
889 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
890 # needed for TIOCWIN* defines in termios.h
891 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
892 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
893 solarisnetlibs="-lsocket -lnsl -lresolv"
894 LIBS="$solarisnetlibs $LIBS"
895 libs_qga="$solarisnetlibs $libs_qga"
897 Haiku)
898 haiku="yes"
899 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
900 LIBS="-lposix_error_mapper -lnetwork $LIBS"
902 Linux)
903 audio_drv_list="try-pa oss"
904 audio_possible_drivers="oss alsa sdl pa"
905 linux="yes"
906 linux_user="yes"
907 kvm="yes"
908 QEMU_INCLUDES="-isystem \$(SRC_PATH)/linux-headers -isystem $PWD/linux-headers $QEMU_INCLUDES"
909 supported_os="yes"
910 libudev="yes"
912 esac
914 if [ "$bsd" = "yes" ] ; then
915 if [ "$darwin" != "yes" ] ; then
916 bsd_user="yes"
920 : ${make=${MAKE-make}}
921 : ${install=${INSTALL-install}}
922 # We prefer python 3.x. A bare 'python' is traditionally
923 # python 2.x, but some distros have it as python 3.x, so
924 # we check that too
925 python=
926 for binary in "${PYTHON-python3}" python
928 if has "$binary"
929 then
930 python=$(command -v "$binary")
931 break
933 done
935 sphinx_build=
936 for binary in sphinx-build-3 sphinx-build
938 if has "$binary"
939 then
940 sphinx_build=$(command -v "$binary")
941 break
943 done
945 # Check for ancillary tools used in testing
946 genisoimage=
947 for binary in genisoimage mkisofs
949 if has $binary
950 then
951 genisoimage=$(command -v "$binary")
952 break
954 done
956 : ${smbd=${SMBD-/usr/sbin/smbd}}
958 # Default objcc to clang if available, otherwise use CC
959 if has clang; then
960 objcc=clang
961 else
962 objcc="$cc"
965 if test "$mingw32" = "yes" ; then
966 EXESUF=".exe"
967 DSOSUF=".dll"
968 # MinGW needs -mthreads for TLS and macro _MT.
969 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
970 LIBS="-lwinmm -lws2_32 $LIBS"
971 write_c_skeleton;
972 if compile_prog "" "-liberty" ; then
973 LIBS="-liberty $LIBS"
975 prefix="c:/Program Files/QEMU"
976 mandir="\${prefix}"
977 datadir="\${prefix}"
978 qemu_docdir="\${prefix}"
979 bindir="\${prefix}"
980 sysconfdir="\${prefix}"
981 local_statedir=
982 confsuffix=""
983 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
986 werror=""
988 for opt do
989 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
990 case "$opt" in
991 --help|-h) show_help=yes
993 --version|-V) exec cat $source_path/VERSION
995 --prefix=*) prefix="$optarg"
997 --interp-prefix=*) interp_prefix="$optarg"
999 --cross-prefix=*)
1001 --cc=*)
1003 --host-cc=*) host_cc="$optarg"
1005 --cxx=*)
1007 --iasl=*) iasl="$optarg"
1009 --objcc=*) objcc="$optarg"
1011 --make=*) make="$optarg"
1013 --install=*) install="$optarg"
1015 --python=*) python="$optarg"
1017 --sphinx-build=*) sphinx_build="$optarg"
1019 --gcov=*) gcov_tool="$optarg"
1021 --smbd=*) smbd="$optarg"
1023 --extra-cflags=*)
1025 --extra-cxxflags=*)
1027 --extra-ldflags=*)
1029 --enable-debug-info)
1031 --disable-debug-info)
1033 --cross-cc-*)
1035 --enable-modules)
1036 modules="yes"
1038 --disable-modules)
1039 modules="no"
1041 --disable-module-upgrades) module_upgrades="no"
1043 --enable-module-upgrades) module_upgrades="yes"
1045 --cpu=*)
1047 --target-list=*) target_list="$optarg"
1048 if test "$target_list_exclude"; then
1049 error_exit "Can't mix --target-list with --target-list-exclude"
1052 --target-list-exclude=*) target_list_exclude="$optarg"
1053 if test "$target_list"; then
1054 error_exit "Can't mix --target-list-exclude with --target-list"
1057 --enable-trace-backends=*) trace_backends="$optarg"
1059 # XXX: backwards compatibility
1060 --enable-trace-backend=*) trace_backends="$optarg"
1062 --with-trace-file=*) trace_file="$optarg"
1064 --with-default-devices) default_devices="yes"
1066 --without-default-devices) default_devices="no"
1068 --enable-gprof) gprof="yes"
1070 --enable-gcov) gcov="yes"
1072 --static)
1073 static="yes"
1074 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
1076 --mandir=*) mandir="$optarg"
1078 --bindir=*) bindir="$optarg"
1080 --libdir=*) libdir="$optarg"
1082 --libexecdir=*) libexecdir="$optarg"
1084 --includedir=*) includedir="$optarg"
1086 --datadir=*) datadir="$optarg"
1088 --with-confsuffix=*) confsuffix="$optarg"
1090 --docdir=*) qemu_docdir="$optarg"
1092 --sysconfdir=*) sysconfdir="$optarg"
1094 --localstatedir=*) local_statedir="$optarg"
1096 --firmwarepath=*) firmwarepath="$optarg"
1098 --host=*|--build=*|\
1099 --disable-dependency-tracking|\
1100 --sbindir=*|--sharedstatedir=*|\
1101 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1102 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1103 # These switches are silently ignored, for compatibility with
1104 # autoconf-generated configure scripts. This allows QEMU's
1105 # configure to be used by RPM and similar macros that set
1106 # lots of directory switches by default.
1108 --disable-sdl) sdl="no"
1110 --enable-sdl) sdl="yes"
1112 --disable-sdl-image) sdl_image="no"
1114 --enable-sdl-image) sdl_image="yes"
1116 --disable-qom-cast-debug) qom_cast_debug="no"
1118 --enable-qom-cast-debug) qom_cast_debug="yes"
1120 --disable-virtfs) virtfs="no"
1122 --enable-virtfs) virtfs="yes"
1124 --disable-mpath) mpath="no"
1126 --enable-mpath) mpath="yes"
1128 --disable-vnc) vnc="no"
1130 --enable-vnc) vnc="yes"
1132 --oss-lib=*) oss_lib="$optarg"
1134 --audio-drv-list=*) audio_drv_list="$optarg"
1136 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1138 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1140 --enable-debug-tcg) debug_tcg="yes"
1142 --disable-debug-tcg) debug_tcg="no"
1144 --enable-debug)
1145 # Enable debugging options that aren't excessively noisy
1146 debug_tcg="yes"
1147 debug_mutex="yes"
1148 debug="yes"
1149 strip_opt="no"
1150 fortify_source="no"
1152 --enable-sanitizers) sanitizers="yes"
1154 --disable-sanitizers) sanitizers="no"
1156 --enable-tsan) tsan="yes"
1158 --disable-tsan) tsan="no"
1160 --enable-sparse) sparse="yes"
1162 --disable-sparse) sparse="no"
1164 --disable-strip) strip_opt="no"
1166 --disable-vnc-sasl) vnc_sasl="no"
1168 --enable-vnc-sasl) vnc_sasl="yes"
1170 --disable-vnc-jpeg) vnc_jpeg="no"
1172 --enable-vnc-jpeg) vnc_jpeg="yes"
1174 --disable-vnc-png) vnc_png="no"
1176 --enable-vnc-png) vnc_png="yes"
1178 --disable-slirp) slirp="no"
1180 --enable-slirp=git) slirp="git"
1182 --enable-slirp=system) slirp="system"
1184 --disable-vde) vde="no"
1186 --enable-vde) vde="yes"
1188 --disable-netmap) netmap="no"
1190 --enable-netmap) netmap="yes"
1192 --disable-xen) xen="no"
1194 --enable-xen) xen="yes"
1196 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1198 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1200 --disable-brlapi) brlapi="no"
1202 --enable-brlapi) brlapi="yes"
1204 --disable-kvm) kvm="no"
1206 --enable-kvm) kvm="yes"
1208 --disable-hax) hax="no"
1210 --enable-hax) hax="yes"
1212 --disable-hvf) hvf="no"
1214 --enable-hvf) hvf="yes"
1216 --disable-whpx) whpx="no"
1218 --enable-whpx) whpx="yes"
1220 --disable-tcg-interpreter) tcg_interpreter="no"
1222 --enable-tcg-interpreter) tcg_interpreter="yes"
1224 --disable-cap-ng) cap_ng="no"
1226 --enable-cap-ng) cap_ng="yes"
1228 --disable-tcg) tcg="no"
1230 --enable-tcg) tcg="yes"
1232 --disable-malloc-trim) malloc_trim="no"
1234 --enable-malloc-trim) malloc_trim="yes"
1236 --disable-spice) spice="no"
1238 --enable-spice) spice="yes"
1240 --disable-libiscsi) libiscsi="no"
1242 --enable-libiscsi) libiscsi="yes"
1244 --disable-libnfs) libnfs="no"
1246 --enable-libnfs) libnfs="yes"
1248 --enable-profiler) profiler="yes"
1250 --disable-cocoa) cocoa="no"
1252 --enable-cocoa)
1253 cocoa="yes" ;
1254 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1256 --disable-system) softmmu="no"
1258 --enable-system) softmmu="yes"
1260 --disable-user)
1261 linux_user="no" ;
1262 bsd_user="no" ;
1264 --enable-user) ;;
1265 --disable-linux-user) linux_user="no"
1267 --enable-linux-user) linux_user="yes"
1269 --disable-bsd-user) bsd_user="no"
1271 --enable-bsd-user) bsd_user="yes"
1273 --enable-pie) pie="yes"
1275 --disable-pie) pie="no"
1277 --enable-werror) werror="yes"
1279 --disable-werror) werror="no"
1281 --enable-stack-protector) stack_protector="yes"
1283 --disable-stack-protector) stack_protector="no"
1285 --disable-curses) curses="no"
1287 --enable-curses) curses="yes"
1289 --disable-iconv) iconv="no"
1291 --enable-iconv) iconv="yes"
1293 --disable-curl) curl="no"
1295 --enable-curl) curl="yes"
1297 --disable-fdt) fdt="no"
1299 --enable-fdt) fdt="yes"
1301 --disable-linux-aio) linux_aio="no"
1303 --enable-linux-aio) linux_aio="yes"
1305 --disable-linux-io-uring) linux_io_uring="no"
1307 --enable-linux-io-uring) linux_io_uring="yes"
1309 --disable-attr) attr="no"
1311 --enable-attr) attr="yes"
1313 --disable-membarrier) membarrier="no"
1315 --enable-membarrier) membarrier="yes"
1317 --disable-blobs) blobs="no"
1319 --with-pkgversion=*) pkgversion="$optarg"
1321 --with-coroutine=*) coroutine="$optarg"
1323 --disable-coroutine-pool) coroutine_pool="no"
1325 --enable-coroutine-pool) coroutine_pool="yes"
1327 --enable-debug-stack-usage) debug_stack_usage="yes"
1329 --enable-crypto-afalg) crypto_afalg="yes"
1331 --disable-crypto-afalg) crypto_afalg="no"
1333 --disable-docs) docs="no"
1335 --enable-docs) docs="yes"
1337 --disable-vhost-net) vhost_net="no"
1339 --enable-vhost-net) vhost_net="yes"
1341 --disable-vhost-crypto) vhost_crypto="no"
1343 --enable-vhost-crypto) vhost_crypto="yes"
1345 --disable-vhost-scsi) vhost_scsi="no"
1347 --enable-vhost-scsi) vhost_scsi="yes"
1349 --disable-vhost-vsock) vhost_vsock="no"
1351 --enable-vhost-vsock) vhost_vsock="yes"
1353 --disable-vhost-user-fs) vhost_user_fs="no"
1355 --enable-vhost-user-fs) vhost_user_fs="yes"
1357 --disable-opengl) opengl="no"
1359 --enable-opengl) opengl="yes"
1361 --disable-rbd) rbd="no"
1363 --enable-rbd) rbd="yes"
1365 --disable-xfsctl) xfs="no"
1367 --enable-xfsctl) xfs="yes"
1369 --disable-smartcard) smartcard="no"
1371 --enable-smartcard) smartcard="yes"
1373 --disable-libusb) libusb="no"
1375 --enable-libusb) libusb="yes"
1377 --disable-usb-redir) usb_redir="no"
1379 --enable-usb-redir) usb_redir="yes"
1381 --disable-zlib-test) zlib="no"
1383 --disable-lzo) lzo="no"
1385 --enable-lzo) lzo="yes"
1387 --disable-snappy) snappy="no"
1389 --enable-snappy) snappy="yes"
1391 --disable-bzip2) bzip2="no"
1393 --enable-bzip2) bzip2="yes"
1395 --enable-lzfse) lzfse="yes"
1397 --disable-lzfse) lzfse="no"
1399 --disable-zstd) zstd="no"
1401 --enable-zstd) zstd="yes"
1403 --enable-guest-agent) guest_agent="yes"
1405 --disable-guest-agent) guest_agent="no"
1407 --enable-guest-agent-msi) guest_agent_msi="yes"
1409 --disable-guest-agent-msi) guest_agent_msi="no"
1411 --with-vss-sdk) vss_win32_sdk=""
1413 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1415 --without-vss-sdk) vss_win32_sdk="no"
1417 --with-win-sdk) win_sdk=""
1419 --with-win-sdk=*) win_sdk="$optarg"
1421 --without-win-sdk) win_sdk="no"
1423 --enable-tools) want_tools="yes"
1425 --disable-tools) want_tools="no"
1427 --enable-seccomp) seccomp="yes"
1429 --disable-seccomp) seccomp="no"
1431 --disable-glusterfs) glusterfs="no"
1433 --disable-avx2) avx2_opt="no"
1435 --enable-avx2) avx2_opt="yes"
1437 --disable-avx512f) avx512f_opt="no"
1439 --enable-avx512f) avx512f_opt="yes"
1442 --enable-glusterfs) glusterfs="yes"
1444 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1445 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1447 --enable-vhdx|--disable-vhdx)
1448 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1450 --enable-uuid|--disable-uuid)
1451 echo "$0: $opt is obsolete, UUID support is always built" >&2
1453 --disable-gtk) gtk="no"
1455 --enable-gtk) gtk="yes"
1457 --tls-priority=*) tls_priority="$optarg"
1459 --disable-gnutls) gnutls="no"
1461 --enable-gnutls) gnutls="yes"
1463 --disable-nettle) nettle="no"
1465 --enable-nettle) nettle="yes"
1467 --disable-gcrypt) gcrypt="no"
1469 --enable-gcrypt) gcrypt="yes"
1471 --disable-auth-pam) auth_pam="no"
1473 --enable-auth-pam) auth_pam="yes"
1475 --enable-rdma) rdma="yes"
1477 --disable-rdma) rdma="no"
1479 --enable-pvrdma) pvrdma="yes"
1481 --disable-pvrdma) pvrdma="no"
1483 --disable-vte) vte="no"
1485 --enable-vte) vte="yes"
1487 --disable-virglrenderer) virglrenderer="no"
1489 --enable-virglrenderer) virglrenderer="yes"
1491 --disable-tpm) tpm="no"
1493 --enable-tpm) tpm="yes"
1495 --disable-libssh) libssh="no"
1497 --enable-libssh) libssh="yes"
1499 --disable-live-block-migration) live_block_migration="no"
1501 --enable-live-block-migration) live_block_migration="yes"
1503 --disable-numa) numa="no"
1505 --enable-numa) numa="yes"
1507 --disable-libxml2) libxml2="no"
1509 --enable-libxml2) libxml2="yes"
1511 --disable-tcmalloc) tcmalloc="no"
1513 --enable-tcmalloc) tcmalloc="yes"
1515 --disable-jemalloc) jemalloc="no"
1517 --enable-jemalloc) jemalloc="yes"
1519 --disable-replication) replication="no"
1521 --enable-replication) replication="yes"
1523 --disable-vxhs) vxhs="no"
1525 --enable-vxhs) vxhs="yes"
1527 --disable-bochs) bochs="no"
1529 --enable-bochs) bochs="yes"
1531 --disable-cloop) cloop="no"
1533 --enable-cloop) cloop="yes"
1535 --disable-dmg) dmg="no"
1537 --enable-dmg) dmg="yes"
1539 --disable-qcow1) qcow1="no"
1541 --enable-qcow1) qcow1="yes"
1543 --disable-vdi) vdi="no"
1545 --enable-vdi) vdi="yes"
1547 --disable-vvfat) vvfat="no"
1549 --enable-vvfat) vvfat="yes"
1551 --disable-qed) qed="no"
1553 --enable-qed) qed="yes"
1555 --disable-parallels) parallels="no"
1557 --enable-parallels) parallels="yes"
1559 --disable-sheepdog) sheepdog="no"
1561 --enable-sheepdog) sheepdog="yes"
1563 --disable-vhost-user) vhost_user="no"
1565 --enable-vhost-user) vhost_user="yes"
1567 --disable-vhost-kernel) vhost_kernel="no"
1569 --enable-vhost-kernel) vhost_kernel="yes"
1571 --disable-capstone) capstone="no"
1573 --enable-capstone) capstone="yes"
1575 --enable-capstone=git) capstone="git"
1577 --enable-capstone=system) capstone="system"
1579 --with-git=*) git="$optarg"
1581 --enable-git-update) git_update=yes
1583 --disable-git-update) git_update=no
1585 --enable-debug-mutex) debug_mutex=yes
1587 --disable-debug-mutex) debug_mutex=no
1589 --enable-libpmem) libpmem=yes
1591 --disable-libpmem) libpmem=no
1593 --enable-xkbcommon) xkbcommon=yes
1595 --disable-xkbcommon) xkbcommon=no
1597 --enable-plugins) plugins="yes"
1599 --disable-plugins) plugins="no"
1601 --enable-containers) use_containers="yes"
1603 --disable-containers) use_containers="no"
1605 --enable-fuzzing) fuzzing=yes
1607 --disable-fuzzing) fuzzing=no
1609 --gdb=*) gdb_bin="$optarg"
1611 --enable-rng-none) rng_none=yes
1613 --disable-rng-none) rng_none=no
1615 --enable-keyring) secret_keyring="yes"
1617 --disable-keyring) secret_keyring="no"
1620 echo "ERROR: unknown option $opt"
1621 echo "Try '$0 --help' for more information"
1622 exit 1
1624 esac
1625 done
1627 case "$cpu" in
1628 ppc)
1629 CPU_CFLAGS="-m32"
1630 QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1632 ppc64)
1633 CPU_CFLAGS="-m64"
1634 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1636 sparc)
1637 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1638 QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
1640 sparc64)
1641 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1642 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1644 s390)
1645 CPU_CFLAGS="-m31"
1646 QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
1648 s390x)
1649 CPU_CFLAGS="-m64"
1650 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1652 i386)
1653 CPU_CFLAGS="-m32"
1654 QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1656 x86_64)
1657 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1658 # If we truly care, we should simply detect this case at
1659 # runtime and generate the fallback to serial emulation.
1660 CPU_CFLAGS="-m64 -mcx16"
1661 QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1663 x32)
1664 CPU_CFLAGS="-mx32"
1665 QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1667 # No special flags required for other host CPUs
1668 esac
1670 eval "cross_cc_${cpu}=\$host_cc"
1671 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1672 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1674 # For user-mode emulation the host arch has to be one we explicitly
1675 # support, even if we're using TCI.
1676 if [ "$ARCH" = "unknown" ]; then
1677 bsd_user="no"
1678 linux_user="no"
1681 if [ "$bsd_user" = "no" -a "$linux_user" = "no" -a "$softmmu" = "no" ] ; then
1682 tcg="no"
1685 default_target_list=""
1687 mak_wilds=""
1689 if [ "$softmmu" = "yes" ]; then
1690 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1692 if [ "$linux_user" = "yes" ]; then
1693 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1695 if [ "$bsd_user" = "yes" ]; then
1696 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1699 if test -z "$target_list_exclude"; then
1700 for config in $mak_wilds; do
1701 default_target_list="${default_target_list} $(basename "$config" .mak)"
1702 done
1703 else
1704 exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1705 for config in $mak_wilds; do
1706 target="$(basename "$config" .mak)"
1707 exclude="no"
1708 for excl in $exclude_list; do
1709 if test "$excl" = "$target"; then
1710 exclude="yes"
1711 break;
1713 done
1714 if test "$exclude" = "no"; then
1715 default_target_list="${default_target_list} $target"
1717 done
1720 # Enumerate public trace backends for --help output
1721 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1723 if test x"$show_help" = x"yes" ; then
1724 cat << EOF
1726 Usage: configure [options]
1727 Options: [defaults in brackets after descriptions]
1729 Standard options:
1730 --help print this message
1731 --prefix=PREFIX install in PREFIX [$prefix]
1732 --interp-prefix=PREFIX where to find shared libraries, etc.
1733 use %M for cpu name [$interp_prefix]
1734 --target-list=LIST set target list (default: build everything)
1735 $(echo Available targets: $default_target_list | \
1736 fold -s -w 53 | sed -e 's/^/ /')
1737 --target-list-exclude=LIST exclude a set of targets from the default target-list
1739 Advanced options (experts only):
1740 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1741 --cc=CC use C compiler CC [$cc]
1742 --iasl=IASL use ACPI compiler IASL [$iasl]
1743 --host-cc=CC use C compiler CC [$host_cc] for code run at
1744 build time
1745 --cxx=CXX use C++ compiler CXX [$cxx]
1746 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1747 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1748 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1749 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1750 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1751 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
1752 --make=MAKE use specified make [$make]
1753 --install=INSTALL use specified install [$install]
1754 --python=PYTHON use specified python [$python]
1755 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
1756 --smbd=SMBD use specified smbd [$smbd]
1757 --with-git=GIT use specified git [$git]
1758 --static enable static build [$static]
1759 --mandir=PATH install man pages in PATH
1760 --datadir=PATH install firmware in PATH$confsuffix
1761 --docdir=PATH install documentation in PATH$confsuffix
1762 --bindir=PATH install binaries in PATH
1763 --libdir=PATH install libraries in PATH
1764 --libexecdir=PATH install helper binaries in PATH
1765 --sysconfdir=PATH install config in PATH$confsuffix
1766 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1767 --firmwarepath=PATH search PATH for firmware files
1768 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1769 --with-pkgversion=VERS use specified string as sub-version of the package
1770 --enable-debug enable common debug build options
1771 --enable-sanitizers enable default sanitizers
1772 --enable-tsan enable thread sanitizer
1773 --disable-strip disable stripping binaries
1774 --disable-werror disable compilation abort on warning
1775 --disable-stack-protector disable compiler-provided stack protection
1776 --audio-drv-list=LIST set audio drivers list:
1777 Available drivers: $audio_possible_drivers
1778 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1779 --block-drv-rw-whitelist=L
1780 set block driver read-write whitelist
1781 (affects only QEMU, not qemu-img)
1782 --block-drv-ro-whitelist=L
1783 set block driver read-only whitelist
1784 (affects only QEMU, not qemu-img)
1785 --enable-trace-backends=B Set trace backend
1786 Available backends: $trace_backend_list
1787 --with-trace-file=NAME Full PATH,NAME of file to store traces
1788 Default:trace-<pid>
1789 --disable-slirp disable SLIRP userspace network connectivity
1790 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1791 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1792 --oss-lib path to OSS library
1793 --cpu=CPU Build for host CPU [$cpu]
1794 --with-coroutine=BACKEND coroutine backend. Supported options:
1795 ucontext, sigaltstack, windows
1796 --enable-gcov enable test coverage analysis with gcov
1797 --gcov=GCOV use specified gcov [$gcov_tool]
1798 --disable-blobs disable installing provided firmware blobs
1799 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1800 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1801 --tls-priority default TLS protocol/cipher priority string
1802 --enable-gprof QEMU profiling with gprof
1803 --enable-profiler profiler support
1804 --enable-debug-stack-usage
1805 track the maximum stack usage of stacks created by qemu_alloc_stack
1806 --enable-plugins
1807 enable plugins via shared library loading
1808 --disable-containers don't use containers for cross-building
1809 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1811 Optional features, enabled with --enable-FEATURE and
1812 disabled with --disable-FEATURE, default is enabled if available:
1814 system all system emulation targets
1815 user supported user emulation targets
1816 linux-user all linux usermode emulation targets
1817 bsd-user all BSD usermode emulation targets
1818 docs build documentation
1819 guest-agent build the QEMU Guest Agent
1820 guest-agent-msi build guest agent Windows MSI installation package
1821 pie Position Independent Executables
1822 modules modules support (non-Windows)
1823 module-upgrades try to load modules from alternate paths for upgrades
1824 debug-tcg TCG debugging (default is disabled)
1825 debug-info debugging information
1826 sparse sparse checker
1828 gnutls GNUTLS cryptography support
1829 nettle nettle cryptography support
1830 gcrypt libgcrypt cryptography support
1831 auth-pam PAM access control
1832 sdl SDL UI
1833 sdl-image SDL Image support for icons
1834 gtk gtk UI
1835 vte vte support for the gtk UI
1836 curses curses UI
1837 iconv font glyph conversion support
1838 vnc VNC UI support
1839 vnc-sasl SASL encryption for VNC server
1840 vnc-jpeg JPEG lossy compression for VNC server
1841 vnc-png PNG compression for VNC server
1842 cocoa Cocoa UI (Mac OS X only)
1843 virtfs VirtFS
1844 mpath Multipath persistent reservation passthrough
1845 xen xen backend driver support
1846 xen-pci-passthrough PCI passthrough support for Xen
1847 brlapi BrlAPI (Braile)
1848 curl curl connectivity
1849 membarrier membarrier system call (for Linux 4.14+ or Windows)
1850 fdt fdt device tree
1851 kvm KVM acceleration support
1852 hax HAX acceleration support
1853 hvf Hypervisor.framework acceleration support
1854 whpx Windows Hypervisor Platform acceleration support
1855 rdma Enable RDMA-based migration
1856 pvrdma Enable PVRDMA support
1857 vde support for vde network
1858 netmap support for netmap network
1859 linux-aio Linux AIO support
1860 linux-io-uring Linux io_uring support
1861 cap-ng libcap-ng support
1862 attr attr and xattr support
1863 vhost-net vhost-net kernel acceleration support
1864 vhost-vsock virtio sockets device support
1865 vhost-scsi vhost-scsi kernel target support
1866 vhost-crypto vhost-user-crypto backend support
1867 vhost-kernel vhost kernel backend support
1868 vhost-user vhost-user backend support
1869 spice spice
1870 rbd rados block device (rbd)
1871 libiscsi iscsi support
1872 libnfs nfs support
1873 smartcard smartcard support (libcacard)
1874 libusb libusb (for usb passthrough)
1875 live-block-migration Block migration in the main migration stream
1876 usb-redir usb network redirection support
1877 lzo support of lzo compression library
1878 snappy support of snappy compression library
1879 bzip2 support of bzip2 compression library
1880 (for reading bzip2-compressed dmg images)
1881 lzfse support of lzfse compression library
1882 (for reading lzfse-compressed dmg images)
1883 zstd support for zstd compression library
1884 (for migration compression and qcow2 cluster compression)
1885 seccomp seccomp support
1886 coroutine-pool coroutine freelist (better performance)
1887 glusterfs GlusterFS backend
1888 tpm TPM support
1889 libssh ssh block device support
1890 numa libnuma support
1891 libxml2 for Parallels image format
1892 tcmalloc tcmalloc support
1893 jemalloc jemalloc support
1894 avx2 AVX2 optimization support
1895 avx512f AVX512F optimization support
1896 replication replication support
1897 opengl opengl support
1898 virglrenderer virgl rendering support
1899 xfsctl xfsctl support
1900 qom-cast-debug cast debugging support
1901 tools build qemu-io, qemu-nbd and qemu-img tools
1902 vxhs Veritas HyperScale vDisk backend support
1903 bochs bochs image format support
1904 cloop cloop image format support
1905 dmg dmg image format support
1906 qcow1 qcow v1 image format support
1907 vdi vdi image format support
1908 vvfat vvfat image format support
1909 qed qed image format support
1910 parallels parallels image format support
1911 sheepdog sheepdog block driver support
1912 crypto-afalg Linux AF_ALG crypto backend driver
1913 capstone capstone disassembler support
1914 debug-mutex mutex debugging support
1915 libpmem libpmem support
1916 xkbcommon xkbcommon support
1917 rng-none dummy RNG, avoid using /dev/(u)random and getrandom()
1919 NOTE: The object files are built at the place where configure is launched
1921 exit 0
1924 # Remove old dependency files to make sure that they get properly regenerated
1925 rm -f */config-devices.mak.d
1927 # Remove syscall_nr.h to be sure they will be regenerated in the build
1928 # directory, not in the source directory
1929 for arch in alpha hppa m68k xtensa sh4 microblaze arm ppc s390x sparc sparc64 \
1930 i386 x86_64 mips mips64 ; do
1931 # remove the file if it has been generated in the source directory
1932 rm -f "${source_path}/linux-user/${arch}/syscall_nr.h"
1933 # remove the dependency files
1934 for target in ${arch}*-linux-user ; do
1935 test -d "${target}" && find "${target}" -type f -name "*.d" \
1936 -exec grep -q "${source_path}/linux-user/${arch}/syscall_nr.h" {} \; \
1937 -print | while read file ; do rm "${file}" "${file%.d}.o" ; done
1938 done
1939 done
1941 if test -z "$python"
1942 then
1943 error_exit "Python not found. Use --python=/path/to/python"
1946 # Note that if the Python conditional here evaluates True we will exit
1947 # with status 1 which is a shell 'false' value.
1948 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,5))'; then
1949 error_exit "Cannot use '$python', Python >= 3.5 is required." \
1950 "Use --python=/path/to/python to specify a supported Python."
1953 # Preserve python version since some functionality is dependent on it
1954 python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
1956 # Suppress writing compiled files
1957 python="$python -B"
1959 # Check that the C compiler works. Doing this here before testing
1960 # the host CPU ensures that we had a valid CC to autodetect the
1961 # $cpu var (and we should bail right here if that's not the case).
1962 # It also allows the help message to be printed without a CC.
1963 write_c_skeleton;
1964 if compile_object ; then
1965 : C compiler works ok
1966 else
1967 error_exit "\"$cc\" either does not exist or does not work"
1969 if ! compile_prog ; then
1970 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1973 # Now we have handled --enable-tcg-interpreter and know we're not just
1974 # printing the help message, bail out if the host CPU isn't supported.
1975 if test "$ARCH" = "unknown"; then
1976 if test "$tcg_interpreter" = "yes" ; then
1977 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1978 else
1979 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1983 # Consult white-list to determine whether to enable werror
1984 # by default. Only enable by default for git builds
1985 if test -z "$werror" ; then
1986 if test -e "$source_path/.git" && \
1987 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1988 werror="yes"
1989 else
1990 werror="no"
1994 if test "$bogus_os" = "yes"; then
1995 # Now that we know that we're not printing the help and that
1996 # the compiler works (so the results of the check_defines we used
1997 # to identify the OS are reliable), if we didn't recognize the
1998 # host OS we should stop now.
1999 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2002 # Check whether the compiler matches our minimum requirements:
2003 cat > $TMPC << EOF
2004 #if defined(__clang_major__) && defined(__clang_minor__)
2005 # ifdef __apple_build_version__
2006 # if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
2007 # error You need at least XCode Clang v5.1 to compile QEMU
2008 # endif
2009 # else
2010 # if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
2011 # error You need at least Clang v3.4 to compile QEMU
2012 # endif
2013 # endif
2014 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2015 # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
2016 # error You need at least GCC v4.8 to compile QEMU
2017 # endif
2018 #else
2019 # error You either need GCC or Clang to compiler QEMU
2020 #endif
2021 int main (void) { return 0; }
2023 if ! compile_prog "" "" ; then
2024 error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2027 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
2028 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
2029 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
2030 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
2031 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
2032 gcc_flags="-Wno-string-plus-int -Wno-typedef-redefinition $gcc_flags"
2033 # Note that we do not add -Werror to gcc_flags here, because that would
2034 # enable it for all configure tests. If a configure test failed due
2035 # to -Werror this would just silently disable some features,
2036 # so it's too error prone.
2038 cc_has_warning_flag() {
2039 write_c_skeleton;
2041 # Use the positive sense of the flag when testing for -Wno-wombat
2042 # support (gcc will happily accept the -Wno- form of unknown
2043 # warning options).
2044 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
2045 compile_prog "-Werror $optflag" ""
2048 for flag in $gcc_flags; do
2049 if cc_has_warning_flag $flag ; then
2050 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2052 done
2054 if test "$stack_protector" != "no"; then
2055 cat > $TMPC << EOF
2056 int main(int argc, char *argv[])
2058 char arr[64], *p = arr, *c = argv[0];
2059 while (*c) {
2060 *p++ = *c++;
2062 return 0;
2065 gcc_flags="-fstack-protector-strong -fstack-protector-all"
2066 sp_on=0
2067 for flag in $gcc_flags; do
2068 # We need to check both a compile and a link, since some compiler
2069 # setups fail only on a .c->.o compile and some only at link time
2070 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
2071 compile_prog "-Werror $flag" ""; then
2072 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2073 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2074 sp_on=1
2075 break
2077 done
2078 if test "$stack_protector" = yes; then
2079 if test $sp_on = 0; then
2080 error_exit "Stack protector not supported"
2085 # Disable -Wmissing-braces on older compilers that warn even for
2086 # the "universal" C zero initializer {0}.
2087 cat > $TMPC << EOF
2088 struct {
2089 int a[2];
2090 } x = {0};
2092 if compile_object "-Werror" "" ; then
2094 else
2095 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
2098 # Our module code doesn't support Windows
2099 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
2100 error_exit "Modules are not available for Windows"
2103 # module_upgrades is only reasonable if modules are enabled
2104 if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2105 error_exit "Can't enable module-upgrades as Modules are not enabled"
2108 # Static linking is not possible with modules or PIE
2109 if test "$static" = "yes" ; then
2110 if test "$modules" = "yes" ; then
2111 error_exit "static and modules are mutually incompatible"
2115 # Unconditional check for compiler __thread support
2116 cat > $TMPC << EOF
2117 static __thread int tls_var;
2118 int main(void) { return tls_var; }
2121 if ! compile_prog "-Werror" "" ; then
2122 error_exit "Your compiler does not support the __thread specifier for " \
2123 "Thread-Local Storage (TLS). Please upgrade to a version that does."
2126 cat > $TMPC << EOF
2128 #ifdef __linux__
2129 # define THREAD __thread
2130 #else
2131 # define THREAD
2132 #endif
2133 static THREAD int tls_var;
2134 int main(void) { return tls_var; }
2137 # Check we support --no-pie first; we will need this for building ROMs.
2138 if compile_prog "-Werror -fno-pie" "-no-pie"; then
2139 CFLAGS_NOPIE="-fno-pie"
2140 LDFLAGS_NOPIE="-no-pie"
2143 if test "$static" = "yes"; then
2144 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
2145 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
2146 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
2147 pie="yes"
2148 elif test "$pie" = "yes"; then
2149 error_exit "-static-pie not available due to missing toolchain support"
2150 else
2151 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
2152 pie="no"
2154 elif test "$pie" = "no"; then
2155 QEMU_CFLAGS="$CFLAGS_NOPIE $QEMU_CFLAGS"
2156 QEMU_LDFLAGS="$LDFLAGS_NOPIE $QEMU_LDFLAGS"
2157 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
2158 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
2159 QEMU_LDFLAGS="-pie $QEMU_LDFLAGS"
2160 pie="yes"
2161 elif test "$pie" = "yes"; then
2162 error_exit "PIE not available due to missing toolchain support"
2163 else
2164 echo "Disabling PIE due to missing toolchain support"
2165 pie="no"
2168 # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2169 # The combination is known as "full relro", because .got.plt is read-only too.
2170 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2171 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2174 ##########################################
2175 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
2176 # use i686 as default anyway, but for those that don't, an explicit
2177 # specification is necessary
2179 if test "$cpu" = "i386"; then
2180 cat > $TMPC << EOF
2181 static int sfaa(int *ptr)
2183 return __sync_fetch_and_and(ptr, 0);
2186 int main(void)
2188 int val = 42;
2189 val = __sync_val_compare_and_swap(&val, 0, 1);
2190 sfaa(&val);
2191 return val;
2194 if ! compile_prog "" "" ; then
2195 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2199 #########################################
2200 # Solaris specific configure tool chain decisions
2202 if test "$solaris" = "yes" ; then
2203 if has $install; then
2205 else
2206 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
2207 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
2208 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2210 if test "$(path_of $install)" = "/usr/sbin/install" ; then
2211 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
2212 "try ginstall from the GNU fileutils available from www.blastwave.org" \
2213 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2215 if has ar; then
2217 else
2218 if test -f /usr/ccs/bin/ar ; then
2219 error_exit "No path includes ar" \
2220 "Add /usr/ccs/bin to your path and rerun configure"
2222 error_exit "No path includes ar"
2226 if test -z "${target_list+xxx}" ; then
2227 for target in $default_target_list; do
2228 supported_target $target 2>/dev/null && \
2229 target_list="$target_list $target"
2230 done
2231 target_list="${target_list# }"
2232 else
2233 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2234 for target in $target_list; do
2235 # Check that we recognised the target name; this allows a more
2236 # friendly error message than if we let it fall through.
2237 case " $default_target_list " in
2238 *" $target "*)
2241 error_exit "Unknown target name '$target'"
2243 esac
2244 supported_target $target || exit 1
2245 done
2248 # see if system emulation was really requested
2249 case " $target_list " in
2250 *"-softmmu "*) softmmu=yes
2252 *) softmmu=no
2254 esac
2256 for target in $target_list; do
2257 case "$target" in
2258 arm-softmmu | aarch64-softmmu | i386-softmmu | x86_64-softmmu)
2259 edk2_blobs="yes"
2261 esac
2262 done
2263 # The EDK2 binaries are compressed with bzip2
2264 if test "$edk2_blobs" = "yes" && ! has bzip2; then
2265 error_exit "The bzip2 program is required for building QEMU"
2268 feature_not_found() {
2269 feature=$1
2270 remedy=$2
2272 error_exit "User requested feature $feature" \
2273 "configure was not able to find it." \
2274 "$remedy"
2277 # ---
2278 # big/little endian test
2279 cat > $TMPC << EOF
2280 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
2281 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2282 extern int foo(short *, short *);
2283 int main(int argc, char *argv[]) {
2284 return foo(big_endian, little_endian);
2288 if compile_object ; then
2289 if strings -a $TMPO | grep -q BiGeNdIaN ; then
2290 bigendian="yes"
2291 elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
2292 bigendian="no"
2293 else
2294 echo big/little test failed
2296 else
2297 echo big/little test failed
2300 ##########################################
2301 # system tools
2302 if test -z "$want_tools"; then
2303 if test "$softmmu" = "no"; then
2304 want_tools=no
2305 else
2306 want_tools=yes
2310 ##########################################
2311 # cocoa implies not SDL or GTK
2312 # (the cocoa UI code currently assumes it is always the active UI
2313 # and doesn't interact well with other UI frontend code)
2314 if test "$cocoa" = "yes"; then
2315 if test "$sdl" = "yes"; then
2316 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2318 if test "$gtk" = "yes"; then
2319 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2321 gtk=no
2322 sdl=no
2325 # Some versions of Mac OS X incorrectly define SIZE_MAX
2326 cat > $TMPC << EOF
2327 #include <stdint.h>
2328 #include <stdio.h>
2329 int main(int argc, char *argv[]) {
2330 return printf("%zu", SIZE_MAX);
2333 have_broken_size_max=no
2334 if ! compile_object -Werror ; then
2335 have_broken_size_max=yes
2338 ##########################################
2339 # L2TPV3 probe
2341 cat > $TMPC <<EOF
2342 #include <sys/socket.h>
2343 #include <linux/ip.h>
2344 int main(void) { return sizeof(struct mmsghdr); }
2346 if compile_prog "" "" ; then
2347 l2tpv3=yes
2348 else
2349 l2tpv3=no
2352 #########################################
2353 # vhost interdependencies and host support
2355 # vhost backends
2356 test "$vhost_user" = "" && vhost_user=yes
2357 if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2358 error_exit "vhost-user isn't available on win32"
2360 test "$vhost_kernel" = "" && vhost_kernel=$linux
2361 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2362 error_exit "vhost-kernel is only available on Linux"
2365 # vhost-kernel devices
2366 test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2367 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2368 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2370 test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2371 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2372 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2375 # vhost-user backends
2376 test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2377 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2378 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2380 test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2381 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2382 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2384 test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
2385 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
2386 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
2389 # OR the vhost-kernel and vhost-user values for simplicity
2390 if test "$vhost_net" = ""; then
2391 test "$vhost_net_user" = "yes" && vhost_net=yes
2392 test "$vhost_kernel" = "yes" && vhost_net=yes
2395 ##########################################
2396 # MinGW / Mingw-w64 localtime_r/gmtime_r check
2398 if test "$mingw32" = "yes"; then
2399 # Some versions of MinGW / Mingw-w64 lack localtime_r
2400 # and gmtime_r entirely.
2402 # Some versions of Mingw-w64 define a macro for
2403 # localtime_r/gmtime_r.
2405 # Some versions of Mingw-w64 will define functions
2406 # for localtime_r/gmtime_r, but only if you have
2407 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
2408 # though, unistd.h and pthread.h both define
2409 # that for you.
2411 # So this #undef localtime_r and #include <unistd.h>
2412 # are not in fact redundant.
2413 cat > $TMPC << EOF
2414 #include <unistd.h>
2415 #include <time.h>
2416 #undef localtime_r
2417 int main(void) { localtime_r(NULL, NULL); return 0; }
2419 if compile_prog "" "" ; then
2420 localtime_r="yes"
2421 else
2422 localtime_r="no"
2426 ##########################################
2427 # pkg-config probe
2429 if ! has "$pkg_config_exe"; then
2430 error_exit "pkg-config binary '$pkg_config_exe' not found"
2433 ##########################################
2434 # NPTL probe
2436 if test "$linux_user" = "yes"; then
2437 cat > $TMPC <<EOF
2438 #include <sched.h>
2439 #include <linux/futex.h>
2440 int main(void) {
2441 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2442 #error bork
2443 #endif
2444 return 0;
2447 if ! compile_object ; then
2448 feature_not_found "nptl" "Install glibc and linux kernel headers."
2452 ##########################################
2453 # lzo check
2455 if test "$lzo" != "no" ; then
2456 cat > $TMPC << EOF
2457 #include <lzo/lzo1x.h>
2458 int main(void) { lzo_version(); return 0; }
2460 if compile_prog "" "-llzo2" ; then
2461 libs_softmmu="$libs_softmmu -llzo2"
2462 lzo="yes"
2463 else
2464 if test "$lzo" = "yes"; then
2465 feature_not_found "liblzo2" "Install liblzo2 devel"
2467 lzo="no"
2471 ##########################################
2472 # snappy check
2474 if test "$snappy" != "no" ; then
2475 cat > $TMPC << EOF
2476 #include <snappy-c.h>
2477 int main(void) { snappy_max_compressed_length(4096); return 0; }
2479 if compile_prog "" "-lsnappy" ; then
2480 libs_softmmu="$libs_softmmu -lsnappy"
2481 snappy="yes"
2482 else
2483 if test "$snappy" = "yes"; then
2484 feature_not_found "libsnappy" "Install libsnappy devel"
2486 snappy="no"
2490 ##########################################
2491 # bzip2 check
2493 if test "$bzip2" != "no" ; then
2494 cat > $TMPC << EOF
2495 #include <bzlib.h>
2496 int main(void) { BZ2_bzlibVersion(); return 0; }
2498 if compile_prog "" "-lbz2" ; then
2499 bzip2="yes"
2500 else
2501 if test "$bzip2" = "yes"; then
2502 feature_not_found "libbzip2" "Install libbzip2 devel"
2504 bzip2="no"
2508 ##########################################
2509 # lzfse check
2511 if test "$lzfse" != "no" ; then
2512 cat > $TMPC << EOF
2513 #include <lzfse.h>
2514 int main(void) { lzfse_decode_scratch_size(); return 0; }
2516 if compile_prog "" "-llzfse" ; then
2517 lzfse="yes"
2518 else
2519 if test "$lzfse" = "yes"; then
2520 feature_not_found "lzfse" "Install lzfse devel"
2522 lzfse="no"
2526 ##########################################
2527 # zstd check
2529 if test "$zstd" != "no" ; then
2530 libzstd_minver="1.4.0"
2531 if $pkg_config --atleast-version=$libzstd_minver libzstd ; then
2532 zstd_cflags="$($pkg_config --cflags libzstd)"
2533 zstd_libs="$($pkg_config --libs libzstd)"
2534 LIBS="$zstd_libs $LIBS"
2535 QEMU_CFLAGS="$QEMU_CFLAGS $zstd_cflags"
2536 zstd="yes"
2537 else
2538 if test "$zstd" = "yes" ; then
2539 feature_not_found "libzstd" "Install libzstd devel"
2541 zstd="no"
2545 ##########################################
2546 # libseccomp check
2548 if test "$seccomp" != "no" ; then
2549 libseccomp_minver="2.3.0"
2550 if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2551 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2552 seccomp_libs="$($pkg_config --libs libseccomp)"
2553 seccomp="yes"
2554 else
2555 if test "$seccomp" = "yes" ; then
2556 feature_not_found "libseccomp" \
2557 "Install libseccomp devel >= $libseccomp_minver"
2559 seccomp="no"
2562 ##########################################
2563 # xen probe
2565 if test "$xen" != "no" ; then
2566 # Check whether Xen library path is specified via --extra-ldflags to avoid
2567 # overriding this setting with pkg-config output. If not, try pkg-config
2568 # to obtain all needed flags.
2570 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2571 $pkg_config --exists xencontrol ; then
2572 xen_ctrl_version="$(printf '%d%02d%02d' \
2573 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2574 xen=yes
2575 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2576 xen_pc="$xen_pc xenevtchn xendevicemodel"
2577 if $pkg_config --exists xentoolcore; then
2578 xen_pc="$xen_pc xentoolcore"
2580 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2581 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2582 else
2584 xen_libs="-lxenstore -lxenctrl -lxenguest"
2585 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2587 # First we test whether Xen headers and libraries are available.
2588 # If no, we are done and there is no Xen support.
2589 # If yes, more tests are run to detect the Xen version.
2591 # Xen (any)
2592 cat > $TMPC <<EOF
2593 #include <xenctrl.h>
2594 int main(void) {
2595 return 0;
2598 if ! compile_prog "" "$xen_libs" ; then
2599 # Xen not found
2600 if test "$xen" = "yes" ; then
2601 feature_not_found "xen" "Install xen devel"
2603 xen=no
2605 # Xen unstable
2606 elif
2607 cat > $TMPC <<EOF &&
2608 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2609 #define __XEN_TOOLS__
2610 #include <xendevicemodel.h>
2611 #include <xenforeignmemory.h>
2612 int main(void) {
2613 xendevicemodel_handle *xd;
2614 xenforeignmemory_handle *xfmem;
2616 xd = xendevicemodel_open(0, 0);
2617 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2619 xfmem = xenforeignmemory_open(0, 0);
2620 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2622 return 0;
2625 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2626 then
2627 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2628 xen_ctrl_version=41100
2629 xen=yes
2630 elif
2631 cat > $TMPC <<EOF &&
2632 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2633 #include <xenforeignmemory.h>
2634 #include <xentoolcore.h>
2635 int main(void) {
2636 xenforeignmemory_handle *xfmem;
2638 xfmem = xenforeignmemory_open(0, 0);
2639 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2640 xentoolcore_restrict_all(0);
2642 return 0;
2645 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2646 then
2647 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2648 xen_ctrl_version=41000
2649 xen=yes
2650 elif
2651 cat > $TMPC <<EOF &&
2652 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2653 #define __XEN_TOOLS__
2654 #include <xendevicemodel.h>
2655 int main(void) {
2656 xendevicemodel_handle *xd;
2658 xd = xendevicemodel_open(0, 0);
2659 xendevicemodel_close(xd);
2661 return 0;
2664 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2665 then
2666 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2667 xen_ctrl_version=40900
2668 xen=yes
2669 elif
2670 cat > $TMPC <<EOF &&
2672 * If we have stable libs the we don't want the libxc compat
2673 * layers, regardless of what CFLAGS we may have been given.
2675 * Also, check if xengnttab_grant_copy_segment_t is defined and
2676 * grant copy operation is implemented.
2678 #undef XC_WANT_COMPAT_EVTCHN_API
2679 #undef XC_WANT_COMPAT_GNTTAB_API
2680 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2681 #include <xenctrl.h>
2682 #include <xenstore.h>
2683 #include <xenevtchn.h>
2684 #include <xengnttab.h>
2685 #include <xenforeignmemory.h>
2686 #include <stdint.h>
2687 #include <xen/hvm/hvm_info_table.h>
2688 #if !defined(HVM_MAX_VCPUS)
2689 # error HVM_MAX_VCPUS not defined
2690 #endif
2691 int main(void) {
2692 xc_interface *xc = NULL;
2693 xenforeignmemory_handle *xfmem;
2694 xenevtchn_handle *xe;
2695 xengnttab_handle *xg;
2696 xengnttab_grant_copy_segment_t* seg = NULL;
2698 xs_daemon_open();
2700 xc = xc_interface_open(0, 0, 0);
2701 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2702 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2703 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2704 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2706 xfmem = xenforeignmemory_open(0, 0);
2707 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2709 xe = xenevtchn_open(0, 0);
2710 xenevtchn_fd(xe);
2712 xg = xengnttab_open(0, 0);
2713 xengnttab_grant_copy(xg, 0, seg);
2715 return 0;
2718 compile_prog "" "$xen_libs $xen_stable_libs"
2719 then
2720 xen_ctrl_version=40800
2721 xen=yes
2722 elif
2723 cat > $TMPC <<EOF &&
2725 * If we have stable libs the we don't want the libxc compat
2726 * layers, regardless of what CFLAGS we may have been given.
2728 #undef XC_WANT_COMPAT_EVTCHN_API
2729 #undef XC_WANT_COMPAT_GNTTAB_API
2730 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2731 #include <xenctrl.h>
2732 #include <xenstore.h>
2733 #include <xenevtchn.h>
2734 #include <xengnttab.h>
2735 #include <xenforeignmemory.h>
2736 #include <stdint.h>
2737 #include <xen/hvm/hvm_info_table.h>
2738 #if !defined(HVM_MAX_VCPUS)
2739 # error HVM_MAX_VCPUS not defined
2740 #endif
2741 int main(void) {
2742 xc_interface *xc = NULL;
2743 xenforeignmemory_handle *xfmem;
2744 xenevtchn_handle *xe;
2745 xengnttab_handle *xg;
2747 xs_daemon_open();
2749 xc = xc_interface_open(0, 0, 0);
2750 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2751 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2752 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2753 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2755 xfmem = xenforeignmemory_open(0, 0);
2756 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2758 xe = xenevtchn_open(0, 0);
2759 xenevtchn_fd(xe);
2761 xg = xengnttab_open(0, 0);
2762 xengnttab_map_grant_ref(xg, 0, 0, 0);
2764 return 0;
2767 compile_prog "" "$xen_libs $xen_stable_libs"
2768 then
2769 xen_ctrl_version=40701
2770 xen=yes
2772 # Xen 4.6
2773 elif
2774 cat > $TMPC <<EOF &&
2775 #include <xenctrl.h>
2776 #include <xenstore.h>
2777 #include <stdint.h>
2778 #include <xen/hvm/hvm_info_table.h>
2779 #if !defined(HVM_MAX_VCPUS)
2780 # error HVM_MAX_VCPUS not defined
2781 #endif
2782 int main(void) {
2783 xc_interface *xc;
2784 xs_daemon_open();
2785 xc = xc_interface_open(0, 0, 0);
2786 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2787 xc_gnttab_open(NULL, 0);
2788 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2789 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2790 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2791 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2792 return 0;
2795 compile_prog "" "$xen_libs"
2796 then
2797 xen_ctrl_version=40600
2798 xen=yes
2800 # Xen 4.5
2801 elif
2802 cat > $TMPC <<EOF &&
2803 #include <xenctrl.h>
2804 #include <xenstore.h>
2805 #include <stdint.h>
2806 #include <xen/hvm/hvm_info_table.h>
2807 #if !defined(HVM_MAX_VCPUS)
2808 # error HVM_MAX_VCPUS not defined
2809 #endif
2810 int main(void) {
2811 xc_interface *xc;
2812 xs_daemon_open();
2813 xc = xc_interface_open(0, 0, 0);
2814 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2815 xc_gnttab_open(NULL, 0);
2816 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2817 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2818 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2819 return 0;
2822 compile_prog "" "$xen_libs"
2823 then
2824 xen_ctrl_version=40500
2825 xen=yes
2827 elif
2828 cat > $TMPC <<EOF &&
2829 #include <xenctrl.h>
2830 #include <xenstore.h>
2831 #include <stdint.h>
2832 #include <xen/hvm/hvm_info_table.h>
2833 #if !defined(HVM_MAX_VCPUS)
2834 # error HVM_MAX_VCPUS not defined
2835 #endif
2836 int main(void) {
2837 xc_interface *xc;
2838 xs_daemon_open();
2839 xc = xc_interface_open(0, 0, 0);
2840 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2841 xc_gnttab_open(NULL, 0);
2842 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2843 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2844 return 0;
2847 compile_prog "" "$xen_libs"
2848 then
2849 xen_ctrl_version=40200
2850 xen=yes
2852 else
2853 if test "$xen" = "yes" ; then
2854 feature_not_found "xen (unsupported version)" \
2855 "Install a supported xen (xen 4.2 or newer)"
2857 xen=no
2860 if test "$xen" = yes; then
2861 if test $xen_ctrl_version -ge 40701 ; then
2862 libs_softmmu="$xen_stable_libs $libs_softmmu"
2864 libs_softmmu="$xen_libs $libs_softmmu"
2869 if test "$xen_pci_passthrough" != "no"; then
2870 if test "$xen" = "yes" && test "$linux" = "yes"; then
2871 xen_pci_passthrough=yes
2872 else
2873 if test "$xen_pci_passthrough" = "yes"; then
2874 error_exit "User requested feature Xen PCI Passthrough" \
2875 " but this feature requires /sys from Linux"
2877 xen_pci_passthrough=no
2881 ##########################################
2882 # Windows Hypervisor Platform accelerator (WHPX) check
2883 if test "$whpx" != "no" ; then
2884 if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2885 whpx="yes"
2886 else
2887 if test "$whpx" = "yes"; then
2888 feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2890 whpx="no"
2894 ##########################################
2895 # Sparse probe
2896 if test "$sparse" != "no" ; then
2897 if has cgcc; then
2898 sparse=yes
2899 else
2900 if test "$sparse" = "yes" ; then
2901 feature_not_found "sparse" "Install sparse binary"
2903 sparse=no
2907 ##########################################
2908 # X11 probe
2909 if $pkg_config --exists "x11"; then
2910 have_x11=yes
2911 x11_cflags=$($pkg_config --cflags x11)
2912 x11_libs=$($pkg_config --libs x11)
2915 ##########################################
2916 # GTK probe
2918 if test "$gtk" != "no"; then
2919 gtkpackage="gtk+-3.0"
2920 gtkx11package="gtk+-x11-3.0"
2921 gtkversion="3.22.0"
2922 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2923 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2924 gtk_libs=$($pkg_config --libs $gtkpackage)
2925 gtk_version=$($pkg_config --modversion $gtkpackage)
2926 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2927 need_x11=yes
2928 gtk_cflags="$gtk_cflags $x11_cflags"
2929 gtk_libs="$gtk_libs $x11_libs"
2931 gtk="yes"
2932 elif test "$gtk" = "yes"; then
2933 feature_not_found "gtk" "Install gtk3-devel"
2934 else
2935 gtk="no"
2940 ##########################################
2941 # GNUTLS probe
2943 if test "$gnutls" != "no"; then
2944 pass="no"
2945 if $pkg_config --exists "gnutls >= 3.1.18"; then
2946 gnutls_cflags=$($pkg_config --cflags gnutls)
2947 gnutls_libs=$($pkg_config --libs gnutls)
2948 # Packaging for the static libraries is not always correct.
2949 # At least ubuntu 18.04 ships only shared libraries.
2950 write_c_skeleton
2951 if compile_prog "" "$gnutls_libs" ; then
2952 LIBS="$gnutls_libs $LIBS"
2953 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2954 pass="yes"
2957 if test "$pass" = "no" && test "$gnutls" = "yes"; then
2958 feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2959 else
2960 gnutls="$pass"
2965 # If user didn't give a --disable/enable-gcrypt flag,
2966 # then mark as disabled if user requested nettle
2967 # explicitly
2968 if test -z "$gcrypt"
2969 then
2970 if test "$nettle" = "yes"
2971 then
2972 gcrypt="no"
2976 # If user didn't give a --disable/enable-nettle flag,
2977 # then mark as disabled if user requested gcrypt
2978 # explicitly
2979 if test -z "$nettle"
2980 then
2981 if test "$gcrypt" = "yes"
2982 then
2983 nettle="no"
2987 has_libgcrypt() {
2988 if ! has "libgcrypt-config"
2989 then
2990 return 1
2993 if test -n "$cross_prefix"
2994 then
2995 host=$(libgcrypt-config --host)
2996 if test "$host-" != $cross_prefix
2997 then
2998 return 1
3002 maj=`libgcrypt-config --version | awk -F . '{print $1}'`
3003 min=`libgcrypt-config --version | awk -F . '{print $2}'`
3005 if test $maj != 1 || test $min -lt 5
3006 then
3007 return 1
3010 return 0
3014 if test "$nettle" != "no"; then
3015 pass="no"
3016 if $pkg_config --exists "nettle >= 2.7.1"; then
3017 nettle_cflags=$($pkg_config --cflags nettle)
3018 nettle_libs=$($pkg_config --libs nettle)
3019 nettle_version=$($pkg_config --modversion nettle)
3020 # Link test to make sure the given libraries work (e.g for static).
3021 write_c_skeleton
3022 if compile_prog "" "$nettle_libs" ; then
3023 LIBS="$nettle_libs $LIBS"
3024 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
3025 if test -z "$gcrypt"; then
3026 gcrypt="no"
3028 pass="yes"
3031 if test "$pass" = "yes"
3032 then
3033 cat > $TMPC << EOF
3034 #include <nettle/xts.h>
3035 int main(void) {
3036 return 0;
3039 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
3040 nettle_xts=yes
3041 qemu_private_xts=no
3044 if test "$pass" = "no" && test "$nettle" = "yes"; then
3045 feature_not_found "nettle" "Install nettle devel >= 2.7.1"
3046 else
3047 nettle="$pass"
3051 if test "$gcrypt" != "no"; then
3052 pass="no"
3053 if has_libgcrypt; then
3054 gcrypt_cflags=$(libgcrypt-config --cflags)
3055 gcrypt_libs=$(libgcrypt-config --libs)
3056 # Debian has removed -lgpg-error from libgcrypt-config
3057 # as it "spreads unnecessary dependencies" which in
3058 # turn breaks static builds...
3059 if test "$static" = "yes"
3060 then
3061 gcrypt_libs="$gcrypt_libs -lgpg-error"
3064 # Link test to make sure the given libraries work (e.g for static).
3065 write_c_skeleton
3066 if compile_prog "" "$gcrypt_libs" ; then
3067 LIBS="$gcrypt_libs $LIBS"
3068 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
3069 pass="yes"
3072 if test "$pass" = "yes"; then
3073 gcrypt="yes"
3074 cat > $TMPC << EOF
3075 #include <gcrypt.h>
3076 int main(void) {
3077 gcry_mac_hd_t handle;
3078 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
3079 GCRY_MAC_FLAG_SECURE, NULL);
3080 return 0;
3083 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3084 gcrypt_hmac=yes
3086 cat > $TMPC << EOF
3087 #include <gcrypt.h>
3088 int main(void) {
3089 gcry_cipher_hd_t handle;
3090 gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
3091 return 0;
3094 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3095 gcrypt_xts=yes
3096 qemu_private_xts=no
3098 elif test "$gcrypt" = "yes"; then
3099 feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
3100 else
3101 gcrypt="no"
3106 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
3107 then
3108 error_exit "Only one of gcrypt & nettle can be enabled"
3111 ##########################################
3112 # libtasn1 - only for the TLS creds/session test suite
3114 tasn1=yes
3115 tasn1_cflags=""
3116 tasn1_libs=""
3117 if $pkg_config --exists "libtasn1"; then
3118 tasn1_cflags=$($pkg_config --cflags libtasn1)
3119 tasn1_libs=$($pkg_config --libs libtasn1)
3120 else
3121 tasn1=no
3125 ##########################################
3126 # PAM probe
3128 if test "$auth_pam" != "no"; then
3129 cat > $TMPC <<EOF
3130 #include <security/pam_appl.h>
3131 #include <stdio.h>
3132 int main(void) {
3133 const char *service_name = "qemu";
3134 const char *user = "frank";
3135 const struct pam_conv pam_conv = { 0 };
3136 pam_handle_t *pamh = NULL;
3137 pam_start(service_name, user, &pam_conv, &pamh);
3138 return 0;
3141 if compile_prog "" "-lpam" ; then
3142 auth_pam=yes
3143 else
3144 if test "$auth_pam" = "yes"; then
3145 feature_not_found "PAM" "Install PAM development package"
3146 else
3147 auth_pam=no
3152 ##########################################
3153 # getifaddrs (for tests/test-io-channel-socket )
3155 have_ifaddrs_h=yes
3156 if ! check_include "ifaddrs.h" ; then
3157 have_ifaddrs_h=no
3160 ##########################################
3161 # VTE probe
3163 if test "$vte" != "no"; then
3164 vteminversion="0.32.0"
3165 if $pkg_config --exists "vte-2.91"; then
3166 vtepackage="vte-2.91"
3167 else
3168 vtepackage="vte-2.90"
3170 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
3171 vte_cflags=$($pkg_config --cflags $vtepackage)
3172 vte_libs=$($pkg_config --libs $vtepackage)
3173 vteversion=$($pkg_config --modversion $vtepackage)
3174 vte="yes"
3175 elif test "$vte" = "yes"; then
3176 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
3177 else
3178 vte="no"
3182 ##########################################
3183 # SDL probe
3185 # Look for sdl configuration program (pkg-config or sdl2-config). Try
3186 # sdl2-config even without cross prefix, and favour pkg-config over sdl2-config.
3188 sdl_probe ()
3190 if $pkg_config sdl2 --exists; then
3191 sdlconfig="$pkg_config sdl2"
3192 sdlversion=$($sdlconfig --modversion 2>/dev/null)
3193 elif has "$sdl2_config"; then
3194 sdlconfig="$sdl2_config"
3195 sdlversion=$($sdlconfig --version)
3196 else
3197 if test "$sdl" = "yes" ; then
3198 feature_not_found "sdl" "Install SDL2-devel"
3200 sdl=no
3201 # no need to do the rest
3202 return
3204 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl2-config; then
3205 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
3208 cat > $TMPC << EOF
3209 #include <SDL.h>
3210 #undef main /* We don't want SDL to override our main() */
3211 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
3213 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
3214 sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
3215 if test "$static" = "yes" ; then
3216 if $pkg_config sdl2 --exists; then
3217 sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
3218 else
3219 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
3221 else
3222 sdl_libs=$($sdlconfig --libs 2>/dev/null)
3224 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
3225 sdl=yes
3227 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
3228 if test "$sdl" = "yes" && test "$static" = "yes" ; then
3229 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
3230 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
3231 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
3233 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
3235 else
3236 sdl=no
3238 fi # static link
3239 else # sdl not found
3240 if test "$sdl" = "yes" ; then
3241 feature_not_found "sdl" "Install SDL2 devel"
3243 sdl=no
3244 fi # sdl compile test
3247 sdl_image_probe ()
3249 if test "$sdl_image" != "no" ; then
3250 if $pkg_config SDL2_image --exists; then
3251 if test "$static" = "yes"; then
3252 sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3253 else
3254 sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3256 sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3257 sdl_image=yes
3259 sdl_cflags="$sdl_cflags $sdl_image_cflags"
3260 sdl_libs="$sdl_libs $sdl_image_libs"
3261 else
3262 if test "$sdl_image" = "yes" ; then
3263 feature_not_found "sdl_image" "Install SDL Image devel"
3264 else
3265 sdl_image=no
3271 if test "$sdl" != "no" ; then
3272 sdl_probe
3275 if test "$sdl" = "yes" ; then
3276 sdl_image_probe
3277 else
3278 if test "$sdl_image" = "yes"; then
3279 echo "warning: SDL Image requested, but SDL is not available, disabling"
3281 sdl_image=no
3284 if test "$sdl" = "yes" ; then
3285 cat > $TMPC <<EOF
3286 #include <SDL.h>
3287 #if defined(SDL_VIDEO_DRIVER_X11)
3288 #include <X11/XKBlib.h>
3289 #else
3290 #error No x11 support
3291 #endif
3292 int main(void) { return 0; }
3294 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
3295 need_x11=yes
3296 sdl_cflags="$sdl_cflags $x11_cflags"
3297 sdl_libs="$sdl_libs $x11_libs"
3301 ##########################################
3302 # RDMA needs OpenFabrics libraries
3303 if test "$rdma" != "no" ; then
3304 cat > $TMPC <<EOF
3305 #include <rdma/rdma_cma.h>
3306 int main(void) { return 0; }
3308 rdma_libs="-lrdmacm -libverbs -libumad"
3309 if compile_prog "" "$rdma_libs" ; then
3310 rdma="yes"
3311 libs_softmmu="$libs_softmmu $rdma_libs"
3312 else
3313 if test "$rdma" = "yes" ; then
3314 error_exit \
3315 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
3316 " Your options:" \
3317 " (1) Fast: Install infiniband packages (devel) from your distro." \
3318 " (2) Cleanest: Install libraries from www.openfabrics.org" \
3319 " (3) Also: Install softiwarp if you don't have RDMA hardware"
3321 rdma="no"
3325 ##########################################
3326 # PVRDMA detection
3328 cat > $TMPC <<EOF &&
3329 #include <sys/mman.h>
3332 main(void)
3334 char buf = 0;
3335 void *addr = &buf;
3336 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
3338 return 0;
3342 if test "$rdma" = "yes" ; then
3343 case "$pvrdma" in
3345 if compile_prog "" ""; then
3346 pvrdma="yes"
3347 else
3348 pvrdma="no"
3351 "yes")
3352 if ! compile_prog "" ""; then
3353 error_exit "PVRDMA is not supported since mremap is not implemented"
3355 pvrdma="yes"
3357 "no")
3358 pvrdma="no"
3360 esac
3361 else
3362 if test "$pvrdma" = "yes" ; then
3363 error_exit "PVRDMA requires rdma suppport"
3365 pvrdma="no"
3368 # Let's see if enhanced reg_mr is supported
3369 if test "$pvrdma" = "yes" ; then
3371 cat > $TMPC <<EOF &&
3372 #include <infiniband/verbs.h>
3375 main(void)
3377 struct ibv_mr *mr;
3378 struct ibv_pd *pd = NULL;
3379 size_t length = 10;
3380 uint64_t iova = 0;
3381 int access = 0;
3382 void *addr = NULL;
3384 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3386 ibv_dereg_mr(mr);
3388 return 0;
3391 if ! compile_prog "" "-libverbs"; then
3392 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3396 ##########################################
3397 # VNC SASL detection
3398 if test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
3399 cat > $TMPC <<EOF
3400 #include <sasl/sasl.h>
3401 #include <stdio.h>
3402 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
3404 # Assuming Cyrus-SASL installed in /usr prefix
3405 # QEMU defines struct iovec in "qemu/osdep.h",
3406 # we don't want libsasl to redefine it in <sasl/sasl.h>.
3407 vnc_sasl_cflags="-DSTRUCT_IOVEC_DEFINED"
3408 vnc_sasl_libs="-lsasl2"
3409 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3410 vnc_sasl=yes
3411 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3412 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
3413 else
3414 if test "$vnc_sasl" = "yes" ; then
3415 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3417 vnc_sasl=no
3421 ##########################################
3422 # VNC JPEG detection
3423 if test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
3424 cat > $TMPC <<EOF
3425 #include <stdio.h>
3426 #include <jpeglib.h>
3427 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
3429 vnc_jpeg_cflags=""
3430 vnc_jpeg_libs="-ljpeg"
3431 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
3432 vnc_jpeg=yes
3433 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3434 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
3435 else
3436 if test "$vnc_jpeg" = "yes" ; then
3437 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
3439 vnc_jpeg=no
3443 ##########################################
3444 # VNC PNG detection
3445 if test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
3446 cat > $TMPC <<EOF
3447 //#include <stdio.h>
3448 #include <png.h>
3449 #include <stddef.h>
3450 int main(void) {
3451 png_structp png_ptr;
3452 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
3453 return png_ptr != 0;
3456 if $pkg_config libpng --exists; then
3457 vnc_png_cflags=$($pkg_config libpng --cflags)
3458 vnc_png_libs=$($pkg_config libpng --libs)
3459 else
3460 vnc_png_cflags=""
3461 vnc_png_libs="-lpng"
3463 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3464 vnc_png=yes
3465 libs_softmmu="$vnc_png_libs $libs_softmmu"
3466 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3467 else
3468 if test "$vnc_png" = "yes" ; then
3469 feature_not_found "vnc-png" "Install libpng devel"
3471 vnc_png=no
3475 ##########################################
3476 # xkbcommon probe
3477 if test "$xkbcommon" != "no" ; then
3478 if $pkg_config xkbcommon --exists; then
3479 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
3480 xkbcommon_libs=$($pkg_config xkbcommon --libs)
3481 xkbcommon=yes
3482 else
3483 if test "$xkbcommon" = "yes" ; then
3484 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
3486 xkbcommon=no
3491 ##########################################
3492 # xfsctl() probe, used for file-posix.c
3493 if test "$xfs" != "no" ; then
3494 cat > $TMPC << EOF
3495 #include <stddef.h> /* NULL */
3496 #include <xfs/xfs.h>
3497 int main(void)
3499 xfsctl(NULL, 0, 0, NULL);
3500 return 0;
3503 if compile_prog "" "" ; then
3504 xfs="yes"
3505 else
3506 if test "$xfs" = "yes" ; then
3507 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3509 xfs=no
3513 ##########################################
3514 # vde libraries probe
3515 if test "$vde" != "no" ; then
3516 vde_libs="-lvdeplug"
3517 cat > $TMPC << EOF
3518 #include <libvdeplug.h>
3519 int main(void)
3521 struct vde_open_args a = {0, 0, 0};
3522 char s[] = "";
3523 vde_open(s, s, &a);
3524 return 0;
3527 if compile_prog "" "$vde_libs" ; then
3528 vde=yes
3529 else
3530 if test "$vde" = "yes" ; then
3531 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3533 vde=no
3537 ##########################################
3538 # netmap support probe
3539 # Apart from looking for netmap headers, we make sure that the host API version
3540 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3541 # a minor/major version number. Minor new features will be marked with values up
3542 # to 15, and if something happens that requires a change to the backend we will
3543 # move above 15, submit the backend fixes and modify this two bounds.
3544 if test "$netmap" != "no" ; then
3545 cat > $TMPC << EOF
3546 #include <inttypes.h>
3547 #include <net/if.h>
3548 #include <net/netmap.h>
3549 #include <net/netmap_user.h>
3550 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3551 #error
3552 #endif
3553 int main(void) { return 0; }
3555 if compile_prog "" "" ; then
3556 netmap=yes
3557 else
3558 if test "$netmap" = "yes" ; then
3559 feature_not_found "netmap"
3561 netmap=no
3565 ##########################################
3566 # libcap-ng library probe
3567 if test "$cap_ng" != "no" ; then
3568 cap_libs="-lcap-ng"
3569 cat > $TMPC << EOF
3570 #include <cap-ng.h>
3571 int main(void)
3573 capng_capability_to_name(CAPNG_EFFECTIVE);
3574 return 0;
3577 if compile_prog "" "$cap_libs" ; then
3578 cap_ng=yes
3579 libs_tools="$cap_libs $libs_tools"
3580 else
3581 if test "$cap_ng" = "yes" ; then
3582 feature_not_found "cap_ng" "Install libcap-ng devel"
3584 cap_ng=no
3588 ##########################################
3589 # Sound support libraries probe
3591 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3592 for drv in $audio_drv_list; do
3593 case $drv in
3594 alsa | try-alsa)
3595 if $pkg_config alsa --exists; then
3596 alsa_libs=$($pkg_config alsa --libs)
3597 if test "$drv" = "try-alsa"; then
3598 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3600 else
3601 if test "$drv" = "try-alsa"; then
3602 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3603 else
3604 error_exit "$drv check failed" \
3605 "Make sure to have the $drv libs and headers installed."
3610 pa | try-pa)
3611 if $pkg_config libpulse --exists; then
3612 pulse_libs=$($pkg_config libpulse --libs)
3613 if test "$drv" = "try-pa"; then
3614 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3616 else
3617 if test "$drv" = "try-pa"; then
3618 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3619 else
3620 error_exit "$drv check failed" \
3621 "Make sure to have the $drv libs and headers installed."
3626 sdl)
3627 if test "$sdl" = "no"; then
3628 error_exit "sdl not found or disabled, can not use sdl audio driver"
3632 try-sdl)
3633 if test "$sdl" = "no"; then
3634 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3635 else
3636 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3640 coreaudio)
3641 coreaudio_libs="-framework CoreAudio"
3644 dsound)
3645 dsound_libs="-lole32 -ldxguid"
3646 audio_win_int="yes"
3649 oss)
3650 oss_libs="$oss_lib"
3653 jack | try-jack)
3654 if $pkg_config jack --exists; then
3655 jack_libs=$($pkg_config jack --libs)
3656 if test "$drv" = "try-jack"; then
3657 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
3659 else
3660 if test "$drv" = "try-jack"; then
3661 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
3662 else
3663 error_exit "$drv check failed" \
3664 "Make sure to have the $drv libs and headers installed."
3670 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3671 error_exit "Unknown driver '$drv' selected" \
3672 "Possible drivers are: $audio_possible_drivers"
3675 esac
3676 done
3678 ##########################################
3679 # BrlAPI probe
3681 if test "$brlapi" != "no" ; then
3682 brlapi_libs="-lbrlapi"
3683 cat > $TMPC << EOF
3684 #include <brlapi.h>
3685 #include <stddef.h>
3686 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3688 if compile_prog "" "$brlapi_libs" ; then
3689 brlapi=yes
3690 else
3691 if test "$brlapi" = "yes" ; then
3692 feature_not_found "brlapi" "Install brlapi devel"
3694 brlapi=no
3698 ##########################################
3699 # iconv probe
3700 if test "$iconv" != "no" ; then
3701 cat > $TMPC << EOF
3702 #include <iconv.h>
3703 int main(void) {
3704 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3705 return conv != (iconv_t) -1;
3708 iconv_prefix_list="/usr/local:/usr"
3709 iconv_lib_list=":-liconv"
3710 IFS=:
3711 for iconv_prefix in $iconv_prefix_list; do
3712 IFS=:
3713 iconv_cflags="-I$iconv_prefix/include"
3714 iconv_ldflags="-L$iconv_prefix/lib"
3715 for iconv_link in $iconv_lib_list; do
3716 unset IFS
3717 iconv_lib="$iconv_ldflags $iconv_link"
3718 echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3719 if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3720 iconv_found=yes
3721 break
3723 done
3724 if test "$iconv_found" = yes ; then
3725 break
3727 done
3728 if test "$iconv_found" = "yes" ; then
3729 iconv=yes
3730 else
3731 if test "$iconv" = "yes" ; then
3732 feature_not_found "iconv" "Install iconv devel"
3734 iconv=no
3738 ##########################################
3739 # curses probe
3740 if test "$iconv" = "no" ; then
3741 # curses will need iconv
3742 curses=no
3744 if test "$curses" != "no" ; then
3745 if test "$mingw32" = "yes" ; then
3746 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3747 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3748 else
3749 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3750 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3752 curses_found=no
3753 cat > $TMPC << EOF
3754 #include <locale.h>
3755 #include <curses.h>
3756 #include <wchar.h>
3757 #include <langinfo.h>
3758 int main(void) {
3759 const char *codeset;
3760 wchar_t wch = L'w';
3761 setlocale(LC_ALL, "");
3762 resize_term(0, 0);
3763 addwstr(L"wide chars\n");
3764 addnwstr(&wch, 1);
3765 add_wch(WACS_DEGREE);
3766 codeset = nl_langinfo(CODESET);
3767 return codeset != 0;
3770 IFS=:
3771 for curses_inc in $curses_inc_list; do
3772 # Make sure we get the wide character prototypes
3773 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3774 IFS=:
3775 for curses_lib in $curses_lib_list; do
3776 unset IFS
3777 if compile_prog "$curses_inc" "$curses_lib" ; then
3778 curses_found=yes
3779 break
3781 done
3782 if test "$curses_found" = yes ; then
3783 break
3785 done
3786 unset IFS
3787 if test "$curses_found" = "yes" ; then
3788 curses=yes
3789 else
3790 if test "$curses" = "yes" ; then
3791 feature_not_found "curses" "Install ncurses devel"
3793 curses=no
3797 ##########################################
3798 # curl probe
3799 if test "$curl" != "no" ; then
3800 if $pkg_config libcurl --exists; then
3801 curlconfig="$pkg_config libcurl"
3802 else
3803 curlconfig=curl-config
3805 cat > $TMPC << EOF
3806 #include <curl/curl.h>
3807 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3809 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3810 curl_libs=$($curlconfig --libs 2>/dev/null)
3811 if compile_prog "$curl_cflags" "$curl_libs" ; then
3812 curl=yes
3813 else
3814 if test "$curl" = "yes" ; then
3815 feature_not_found "curl" "Install libcurl devel"
3817 curl=no
3819 fi # test "$curl"
3821 ##########################################
3822 # glib support probe
3824 glib_req_ver=2.48
3825 glib_modules=gthread-2.0
3826 if test "$modules" = yes; then
3827 glib_modules="$glib_modules gmodule-export-2.0"
3829 if test "$plugins" = yes; then
3830 glib_modules="$glib_modules gmodule-2.0"
3833 # This workaround is required due to a bug in pkg-config file for glib as it
3834 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3836 if test "$static" = yes && test "$mingw32" = yes; then
3837 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3840 for i in $glib_modules; do
3841 if $pkg_config --atleast-version=$glib_req_ver $i; then
3842 glib_cflags=$($pkg_config --cflags $i)
3843 glib_libs=$($pkg_config --libs $i)
3844 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3845 LIBS="$glib_libs $LIBS"
3846 libs_qga="$glib_libs $libs_qga"
3847 else
3848 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3850 done
3852 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3853 gio=yes
3854 gio_cflags=$($pkg_config --cflags gio-2.0)
3855 gio_libs=$($pkg_config --libs gio-2.0)
3856 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
3857 if [ ! -x "$gdbus_codegen" ]; then
3858 gdbus_codegen=
3860 else
3861 gio=no
3864 if $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
3865 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
3866 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
3869 # Sanity check that the current size_t matches the
3870 # size that glib thinks it should be. This catches
3871 # problems on multi-arch where people try to build
3872 # 32-bit QEMU while pointing at 64-bit glib headers
3873 cat > $TMPC <<EOF
3874 #include <glib.h>
3875 #include <unistd.h>
3877 #define QEMU_BUILD_BUG_ON(x) \
3878 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3880 int main(void) {
3881 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3882 return 0;
3886 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3887 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3888 "You probably need to set PKG_CONFIG_LIBDIR"\
3889 "to point to the right pkg-config files for your"\
3890 "build target"
3893 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3894 cat > $TMPC << EOF
3895 #include <glib.h>
3896 int main(void) { return 0; }
3898 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3899 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3900 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3901 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3905 # Silence clang warnings triggered by glib < 2.57.2
3906 cat > $TMPC << EOF
3907 #include <glib.h>
3908 typedef struct Foo {
3909 int i;
3910 } Foo;
3911 static void foo_free(Foo *f)
3913 g_free(f);
3915 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
3916 int main(void) { return 0; }
3918 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3919 if cc_has_warning_flag "-Wno-unused-function"; then
3920 glib_cflags="$glib_cflags -Wno-unused-function"
3921 CFLAGS="$CFLAGS -Wno-unused-function"
3925 #########################################
3926 # zlib check
3928 if test "$zlib" != "no" ; then
3929 if $pkg_config --exists zlib; then
3930 zlib_cflags=$($pkg_config --cflags zlib)
3931 zlib_libs=$($pkg_config --libs zlib)
3932 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3933 LIBS="$zlib_libs $LIBS"
3934 else
3935 cat > $TMPC << EOF
3936 #include <zlib.h>
3937 int main(void) { zlibVersion(); return 0; }
3939 if compile_prog "" "-lz" ; then
3940 LIBS="$LIBS -lz"
3941 else
3942 error_exit "zlib check failed" \
3943 "Make sure to have the zlib libs and headers installed."
3948 ##########################################
3949 # SHA command probe for modules
3950 if test "$modules" = yes; then
3951 shacmd_probe="sha1sum sha1 shasum"
3952 for c in $shacmd_probe; do
3953 if has $c; then
3954 shacmd="$c"
3955 break
3957 done
3958 if test "$shacmd" = ""; then
3959 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3963 ##########################################
3964 # pixman support probe
3966 if test "$want_tools" = "no" && test "$softmmu" = "no"; then
3967 pixman_cflags=
3968 pixman_libs=
3969 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3970 pixman_cflags=$($pkg_config --cflags pixman-1)
3971 pixman_libs=$($pkg_config --libs pixman-1)
3972 else
3973 error_exit "pixman >= 0.21.8 not present." \
3974 "Please install the pixman devel package."
3977 ##########################################
3978 # libmpathpersist probe
3980 if test "$mpath" != "no" ; then
3981 # probe for the new API
3982 cat > $TMPC <<EOF
3983 #include <libudev.h>
3984 #include <mpath_persist.h>
3985 unsigned mpath_mx_alloc_len = 1024;
3986 int logsink;
3987 static struct config *multipath_conf;
3988 extern struct udev *udev;
3989 extern struct config *get_multipath_config(void);
3990 extern void put_multipath_config(struct config *conf);
3991 struct udev *udev;
3992 struct config *get_multipath_config(void) { return multipath_conf; }
3993 void put_multipath_config(struct config *conf) { }
3995 int main(void) {
3996 udev = udev_new();
3997 multipath_conf = mpath_lib_init();
3998 return 0;
4001 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
4002 mpathpersist=yes
4003 mpathpersist_new_api=yes
4004 else
4005 # probe for the old API
4006 cat > $TMPC <<EOF
4007 #include <libudev.h>
4008 #include <mpath_persist.h>
4009 unsigned mpath_mx_alloc_len = 1024;
4010 int logsink;
4011 int main(void) {
4012 struct udev *udev = udev_new();
4013 mpath_lib_init(udev);
4014 return 0;
4017 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
4018 mpathpersist=yes
4019 mpathpersist_new_api=no
4020 else
4021 mpathpersist=no
4024 else
4025 mpathpersist=no
4028 ##########################################
4029 # pthread probe
4030 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
4032 pthread=no
4033 cat > $TMPC << EOF
4034 #include <pthread.h>
4035 static void *f(void *p) { return NULL; }
4036 int main(void) {
4037 pthread_t thread;
4038 pthread_create(&thread, 0, f, 0);
4039 return 0;
4042 if compile_prog "" "" ; then
4043 pthread=yes
4044 else
4045 for pthread_lib in $PTHREADLIBS_LIST; do
4046 if compile_prog "" "$pthread_lib" ; then
4047 pthread=yes
4048 found=no
4049 for lib_entry in $LIBS; do
4050 if test "$lib_entry" = "$pthread_lib"; then
4051 found=yes
4052 break
4054 done
4055 if test "$found" = "no"; then
4056 LIBS="$pthread_lib $LIBS"
4057 libs_qga="$pthread_lib $libs_qga"
4059 PTHREAD_LIB="$pthread_lib"
4060 break
4062 done
4065 if test "$mingw32" != yes && test "$pthread" = no; then
4066 error_exit "pthread check failed" \
4067 "Make sure to have the pthread libs and headers installed."
4070 # check for pthread_setname_np with thread id
4071 pthread_setname_np_w_tid=no
4072 cat > $TMPC << EOF
4073 #include <pthread.h>
4075 static void *f(void *p) { return NULL; }
4076 int main(void)
4078 pthread_t thread;
4079 pthread_create(&thread, 0, f, 0);
4080 pthread_setname_np(thread, "QEMU");
4081 return 0;
4084 if compile_prog "" "$pthread_lib" ; then
4085 pthread_setname_np_w_tid=yes
4088 # check for pthread_setname_np without thread id
4089 pthread_setname_np_wo_tid=no
4090 cat > $TMPC << EOF
4091 #include <pthread.h>
4093 static void *f(void *p) { pthread_setname_np("QEMU"); }
4094 int main(void)
4096 pthread_t thread;
4097 pthread_create(&thread, 0, f, 0);
4098 return 0;
4101 if compile_prog "" "$pthread_lib" ; then
4102 pthread_setname_np_wo_tid=yes
4105 ##########################################
4106 # rbd probe
4107 if test "$rbd" != "no" ; then
4108 cat > $TMPC <<EOF
4109 #include <stdio.h>
4110 #include <rbd/librbd.h>
4111 int main(void) {
4112 rados_t cluster;
4113 rados_create(&cluster, NULL);
4114 return 0;
4117 rbd_libs="-lrbd -lrados"
4118 if compile_prog "" "$rbd_libs" ; then
4119 rbd=yes
4120 else
4121 if test "$rbd" = "yes" ; then
4122 feature_not_found "rados block device" "Install librbd/ceph devel"
4124 rbd=no
4128 ##########################################
4129 # libssh probe
4130 if test "$libssh" != "no" ; then
4131 if $pkg_config --exists libssh; then
4132 libssh_cflags=$($pkg_config libssh --cflags)
4133 libssh_libs=$($pkg_config libssh --libs)
4134 libssh=yes
4135 else
4136 if test "$libssh" = "yes" ; then
4137 error_exit "libssh required for --enable-libssh"
4139 libssh=no
4143 ##########################################
4144 # Check for libssh 0.8
4145 # This is done like this instead of using the LIBSSH_VERSION_* and
4146 # SSH_VERSION_* macros because some distributions in the past shipped
4147 # snapshots of the future 0.8 from Git, and those snapshots did not
4148 # have updated version numbers (still referring to 0.7.0).
4150 if test "$libssh" = "yes"; then
4151 cat > $TMPC <<EOF
4152 #include <libssh/libssh.h>
4153 int main(void) { return ssh_get_server_publickey(NULL, NULL); }
4155 if compile_prog "$libssh_cflags" "$libssh_libs"; then
4156 libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
4160 ##########################################
4161 # linux-aio probe
4163 if test "$linux_aio" != "no" ; then
4164 cat > $TMPC <<EOF
4165 #include <libaio.h>
4166 #include <sys/eventfd.h>
4167 #include <stddef.h>
4168 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
4170 if compile_prog "" "-laio" ; then
4171 linux_aio=yes
4172 else
4173 if test "$linux_aio" = "yes" ; then
4174 feature_not_found "linux AIO" "Install libaio devel"
4176 linux_aio=no
4179 ##########################################
4180 # linux-io-uring probe
4182 if test "$linux_io_uring" != "no" ; then
4183 if $pkg_config liburing; then
4184 linux_io_uring_cflags=$($pkg_config --cflags liburing)
4185 linux_io_uring_libs=$($pkg_config --libs liburing)
4186 linux_io_uring=yes
4188 # io_uring is used in libqemuutil.a where per-file -libs variables are not
4189 # seen by programs linking the archive. It's not ideal, but just add the
4190 # library dependency globally.
4191 LIBS="$linux_io_uring_libs $LIBS"
4192 else
4193 if test "$linux_io_uring" = "yes" ; then
4194 feature_not_found "linux io_uring" "Install liburing devel"
4196 linux_io_uring=no
4200 ##########################################
4201 # TPM emulation is only on POSIX
4203 if test "$tpm" = ""; then
4204 if test "$mingw32" = "yes"; then
4205 tpm=no
4206 else
4207 tpm=yes
4209 elif test "$tpm" = "yes"; then
4210 if test "$mingw32" = "yes" ; then
4211 error_exit "TPM emulation only available on POSIX systems"
4215 ##########################################
4216 # attr probe
4218 if test "$attr" != "no" ; then
4219 cat > $TMPC <<EOF
4220 #include <stdio.h>
4221 #include <sys/types.h>
4222 #ifdef CONFIG_LIBATTR
4223 #include <attr/xattr.h>
4224 #else
4225 #include <sys/xattr.h>
4226 #endif
4227 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
4229 if compile_prog "" "" ; then
4230 attr=yes
4231 # Older distros have <attr/xattr.h>, and need -lattr:
4232 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
4233 attr=yes
4234 LIBS="-lattr $LIBS"
4235 libattr=yes
4236 else
4237 if test "$attr" = "yes" ; then
4238 feature_not_found "ATTR" "Install libc6 or libattr devel"
4240 attr=no
4244 ##########################################
4245 # iovec probe
4246 cat > $TMPC <<EOF
4247 #include <sys/types.h>
4248 #include <sys/uio.h>
4249 #include <unistd.h>
4250 int main(void) { return sizeof(struct iovec); }
4252 iovec=no
4253 if compile_prog "" "" ; then
4254 iovec=yes
4257 ##########################################
4258 # preadv probe
4259 cat > $TMPC <<EOF
4260 #include <sys/types.h>
4261 #include <sys/uio.h>
4262 #include <unistd.h>
4263 int main(void) { return preadv(0, 0, 0, 0); }
4265 preadv=no
4266 if compile_prog "" "" ; then
4267 preadv=yes
4270 ##########################################
4271 # fdt probe
4272 # fdt support is mandatory for at least some target architectures,
4273 # so insist on it if we're building those system emulators.
4274 fdt_required=no
4275 for target in $target_list; do
4276 case $target in
4277 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu|rx-softmmu)
4278 fdt_required=yes
4280 esac
4281 done
4283 if test "$fdt_required" = "yes"; then
4284 if test "$fdt" = "no"; then
4285 error_exit "fdt disabled but some requested targets require it." \
4286 "You can turn off fdt only if you also disable all the system emulation" \
4287 "targets which need it (by specifying a cut down --target-list)."
4289 fdt=yes
4290 elif test "$fdt" != "yes" ; then
4291 fdt=no
4294 # fdt is only required when building softmmu targets
4295 if test -z "$fdt" -a "$softmmu" != "yes" ; then
4296 fdt="no"
4299 if test "$fdt" != "no" ; then
4300 fdt_libs="-lfdt"
4301 # explicitly check for libfdt_env.h as it is missing in some stable installs
4302 # and test for required functions to make sure we are on a version >= 1.4.2
4303 cat > $TMPC << EOF
4304 #include <libfdt.h>
4305 #include <libfdt_env.h>
4306 int main(void) { fdt_check_full(NULL, 0); return 0; }
4308 if compile_prog "" "$fdt_libs" ; then
4309 # system DTC is good - use it
4310 fdt=system
4311 else
4312 # have GIT checkout, so activate dtc submodule
4313 if test -e "${source_path}/.git" ; then
4314 git_submodules="${git_submodules} dtc"
4316 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4317 fdt=git
4318 mkdir -p dtc
4319 if [ "$pwd_is_source_path" != "y" ] ; then
4320 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
4322 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
4323 fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
4324 fdt_libs="$fdt_libs"
4325 elif test "$fdt" = "yes" ; then
4326 # Not a git build & no libfdt found, prompt for system install
4327 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4328 "Please install the DTC (libfdt) devel package"
4329 else
4330 # don't have and don't want
4331 fdt_libs=
4332 fdt=no
4337 libs_softmmu="$libs_softmmu $fdt_libs"
4339 ##########################################
4340 # opengl probe (for sdl2, gtk, milkymist-tmu2)
4342 gbm="no"
4343 if $pkg_config gbm; then
4344 gbm_cflags="$($pkg_config --cflags gbm)"
4345 gbm_libs="$($pkg_config --libs gbm)"
4346 gbm="yes"
4349 if test "$opengl" != "no" ; then
4350 opengl_pkgs="epoxy gbm"
4351 if $pkg_config $opengl_pkgs; then
4352 opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
4353 opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4354 opengl=yes
4355 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4356 gtk_gl="yes"
4358 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
4359 else
4360 if test "$opengl" = "yes" ; then
4361 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
4363 opengl_cflags=""
4364 opengl_libs=""
4365 opengl=no
4369 if test "$opengl" = "yes"; then
4370 cat > $TMPC << EOF
4371 #include <epoxy/egl.h>
4372 #ifndef EGL_MESA_image_dma_buf_export
4373 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4374 #endif
4375 int main(void) { return 0; }
4377 if compile_prog "" "" ; then
4378 opengl_dmabuf=yes
4382 if test "$opengl" = "yes" && test "$have_x11" = "yes"; then
4383 for target in $target_list; do
4384 case $target in
4385 lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
4386 need_x11=yes
4388 esac
4389 done
4392 ##########################################
4393 # libxml2 probe
4394 if test "$libxml2" != "no" ; then
4395 if $pkg_config --exists libxml-2.0; then
4396 libxml2="yes"
4397 libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4398 libxml2_libs=$($pkg_config --libs libxml-2.0)
4399 else
4400 if test "$libxml2" = "yes"; then
4401 feature_not_found "libxml2" "Install libxml2 devel"
4403 libxml2="no"
4407 ##########################################
4408 # glusterfs probe
4409 if test "$glusterfs" != "no" ; then
4410 if $pkg_config --atleast-version=3 glusterfs-api; then
4411 glusterfs="yes"
4412 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
4413 glusterfs_libs=$($pkg_config --libs glusterfs-api)
4414 if $pkg_config --atleast-version=4 glusterfs-api; then
4415 glusterfs_xlator_opt="yes"
4417 if $pkg_config --atleast-version=5 glusterfs-api; then
4418 glusterfs_discard="yes"
4420 if $pkg_config --atleast-version=6 glusterfs-api; then
4421 glusterfs_fallocate="yes"
4422 glusterfs_zerofill="yes"
4424 cat > $TMPC << EOF
4425 #include <glusterfs/api/glfs.h>
4428 main(void)
4430 /* new glfs_ftruncate() passes two additional args */
4431 return glfs_ftruncate(NULL, 0, NULL, NULL);
4434 if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4435 glusterfs_ftruncate_has_stat="yes"
4437 cat > $TMPC << EOF
4438 #include <glusterfs/api/glfs.h>
4440 /* new glfs_io_cbk() passes two additional glfs_stat structs */
4441 static void
4442 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
4446 main(void)
4448 glfs_io_cbk iocb = &glusterfs_iocb;
4449 iocb(NULL, 0 , NULL, NULL, NULL);
4450 return 0;
4453 if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4454 glusterfs_iocb_has_stat="yes"
4456 else
4457 if test "$glusterfs" = "yes" ; then
4458 feature_not_found "GlusterFS backend support" \
4459 "Install glusterfs-api devel >= 3"
4461 glusterfs="no"
4465 # Check for inotify functions when we are building linux-user
4466 # emulator. This is done because older glibc versions don't
4467 # have syscall stubs for these implemented. In that case we
4468 # don't provide them even if kernel supports them.
4470 inotify=no
4471 cat > $TMPC << EOF
4472 #include <sys/inotify.h>
4475 main(void)
4477 /* try to start inotify */
4478 return inotify_init();
4481 if compile_prog "" "" ; then
4482 inotify=yes
4485 inotify1=no
4486 cat > $TMPC << EOF
4487 #include <sys/inotify.h>
4490 main(void)
4492 /* try to start inotify */
4493 return inotify_init1(0);
4496 if compile_prog "" "" ; then
4497 inotify1=yes
4500 # check if pipe2 is there
4501 pipe2=no
4502 cat > $TMPC << EOF
4503 #include <unistd.h>
4504 #include <fcntl.h>
4506 int main(void)
4508 int pipefd[2];
4509 return pipe2(pipefd, O_CLOEXEC);
4512 if compile_prog "" "" ; then
4513 pipe2=yes
4516 # check if accept4 is there
4517 accept4=no
4518 cat > $TMPC << EOF
4519 #include <sys/socket.h>
4520 #include <stddef.h>
4522 int main(void)
4524 accept4(0, NULL, NULL, SOCK_CLOEXEC);
4525 return 0;
4528 if compile_prog "" "" ; then
4529 accept4=yes
4532 # check if tee/splice is there. vmsplice was added same time.
4533 splice=no
4534 cat > $TMPC << EOF
4535 #include <unistd.h>
4536 #include <fcntl.h>
4537 #include <limits.h>
4539 int main(void)
4541 int len, fd = 0;
4542 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
4543 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
4544 return 0;
4547 if compile_prog "" "" ; then
4548 splice=yes
4551 ##########################################
4552 # libnuma probe
4554 if test "$numa" != "no" ; then
4555 cat > $TMPC << EOF
4556 #include <numa.h>
4557 int main(void) { return numa_available(); }
4560 if compile_prog "" "-lnuma" ; then
4561 numa=yes
4562 libs_softmmu="-lnuma $libs_softmmu"
4563 else
4564 if test "$numa" = "yes" ; then
4565 feature_not_found "numa" "install numactl devel"
4567 numa=no
4571 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
4572 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
4573 exit 1
4576 # Even if malloc_trim() is available, these non-libc memory allocators
4577 # do not support it.
4578 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
4579 if test "$malloc_trim" = "yes" ; then
4580 echo "Disabling malloc_trim with non-libc memory allocator"
4582 malloc_trim="no"
4585 #######################################
4586 # malloc_trim
4588 if test "$malloc_trim" != "no" ; then
4589 cat > $TMPC << EOF
4590 #include <malloc.h>
4591 int main(void) { malloc_trim(0); return 0; }
4593 if compile_prog "" "" ; then
4594 malloc_trim="yes"
4595 else
4596 malloc_trim="no"
4600 ##########################################
4601 # tcmalloc probe
4603 if test "$tcmalloc" = "yes" ; then
4604 cat > $TMPC << EOF
4605 #include <stdlib.h>
4606 int main(void) {
4607 void *tmp = malloc(1);
4608 if (tmp != NULL) {
4609 return 0;
4611 return 1;
4615 if compile_prog "" "-ltcmalloc" ; then
4616 LIBS="-ltcmalloc $LIBS"
4617 else
4618 feature_not_found "tcmalloc" "install gperftools devel"
4622 ##########################################
4623 # jemalloc probe
4625 if test "$jemalloc" = "yes" ; then
4626 cat > $TMPC << EOF
4627 #include <stdlib.h>
4628 int main(void) {
4629 void *tmp = malloc(1);
4630 if (tmp != NULL) {
4631 return 0;
4633 return 1;
4637 if compile_prog "" "-ljemalloc" ; then
4638 LIBS="-ljemalloc $LIBS"
4639 else
4640 feature_not_found "jemalloc" "install jemalloc devel"
4644 ##########################################
4645 # signalfd probe
4646 signalfd="no"
4647 cat > $TMPC << EOF
4648 #include <unistd.h>
4649 #include <sys/syscall.h>
4650 #include <signal.h>
4651 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4654 if compile_prog "" "" ; then
4655 signalfd=yes
4658 # check if optreset global is declared by <getopt.h>
4659 optreset="no"
4660 cat > $TMPC << EOF
4661 #include <getopt.h>
4662 int main(void) { return optreset; }
4665 if compile_prog "" "" ; then
4666 optreset=yes
4669 # check if eventfd is supported
4670 eventfd=no
4671 cat > $TMPC << EOF
4672 #include <sys/eventfd.h>
4674 int main(void)
4676 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4679 if compile_prog "" "" ; then
4680 eventfd=yes
4683 # check if memfd is supported
4684 memfd=no
4685 cat > $TMPC << EOF
4686 #include <sys/mman.h>
4688 int main(void)
4690 return memfd_create("foo", MFD_ALLOW_SEALING);
4693 if compile_prog "" "" ; then
4694 memfd=yes
4697 # check for usbfs
4698 have_usbfs=no
4699 if test "$linux_user" = "yes"; then
4700 cat > $TMPC << EOF
4701 #include <linux/usbdevice_fs.h>
4703 #ifndef USBDEVFS_GET_CAPABILITIES
4704 #error "USBDEVFS_GET_CAPABILITIES undefined"
4705 #endif
4707 #ifndef USBDEVFS_DISCONNECT_CLAIM
4708 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
4709 #endif
4711 int main(void)
4713 return 0;
4716 if compile_prog "" ""; then
4717 have_usbfs=yes
4721 # check for fallocate
4722 fallocate=no
4723 cat > $TMPC << EOF
4724 #include <fcntl.h>
4726 int main(void)
4728 fallocate(0, 0, 0, 0);
4729 return 0;
4732 if compile_prog "" "" ; then
4733 fallocate=yes
4736 # check for fallocate hole punching
4737 fallocate_punch_hole=no
4738 cat > $TMPC << EOF
4739 #include <fcntl.h>
4740 #include <linux/falloc.h>
4742 int main(void)
4744 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4745 return 0;
4748 if compile_prog "" "" ; then
4749 fallocate_punch_hole=yes
4752 # check that fallocate supports range zeroing inside the file
4753 fallocate_zero_range=no
4754 cat > $TMPC << EOF
4755 #include <fcntl.h>
4756 #include <linux/falloc.h>
4758 int main(void)
4760 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4761 return 0;
4764 if compile_prog "" "" ; then
4765 fallocate_zero_range=yes
4768 # check for posix_fallocate
4769 posix_fallocate=no
4770 cat > $TMPC << EOF
4771 #include <fcntl.h>
4773 int main(void)
4775 posix_fallocate(0, 0, 0);
4776 return 0;
4779 if compile_prog "" "" ; then
4780 posix_fallocate=yes
4783 # check for sync_file_range
4784 sync_file_range=no
4785 cat > $TMPC << EOF
4786 #include <fcntl.h>
4788 int main(void)
4790 sync_file_range(0, 0, 0, 0);
4791 return 0;
4794 if compile_prog "" "" ; then
4795 sync_file_range=yes
4798 # check for linux/fiemap.h and FS_IOC_FIEMAP
4799 fiemap=no
4800 cat > $TMPC << EOF
4801 #include <sys/ioctl.h>
4802 #include <linux/fs.h>
4803 #include <linux/fiemap.h>
4805 int main(void)
4807 ioctl(0, FS_IOC_FIEMAP, 0);
4808 return 0;
4811 if compile_prog "" "" ; then
4812 fiemap=yes
4815 # check for dup3
4816 dup3=no
4817 cat > $TMPC << EOF
4818 #include <unistd.h>
4820 int main(void)
4822 dup3(0, 0, 0);
4823 return 0;
4826 if compile_prog "" "" ; then
4827 dup3=yes
4830 # check for ppoll support
4831 ppoll=no
4832 cat > $TMPC << EOF
4833 #include <poll.h>
4835 int main(void)
4837 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4838 ppoll(&pfd, 1, 0, 0);
4839 return 0;
4842 if compile_prog "" "" ; then
4843 ppoll=yes
4846 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4847 prctl_pr_set_timerslack=no
4848 cat > $TMPC << EOF
4849 #include <sys/prctl.h>
4851 int main(void)
4853 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4854 return 0;
4857 if compile_prog "" "" ; then
4858 prctl_pr_set_timerslack=yes
4861 # check for epoll support
4862 epoll=no
4863 cat > $TMPC << EOF
4864 #include <sys/epoll.h>
4866 int main(void)
4868 epoll_create(0);
4869 return 0;
4872 if compile_prog "" "" ; then
4873 epoll=yes
4876 # epoll_create1 is a later addition
4877 # so we must check separately for its presence
4878 epoll_create1=no
4879 cat > $TMPC << EOF
4880 #include <sys/epoll.h>
4882 int main(void)
4884 /* Note that we use epoll_create1 as a value, not as
4885 * a function being called. This is necessary so that on
4886 * old SPARC glibc versions where the function was present in
4887 * the library but not declared in the header file we will
4888 * fail the configure check. (Otherwise we will get a compiler
4889 * warning but not an error, and will proceed to fail the
4890 * qemu compile where we compile with -Werror.)
4892 return (int)(uintptr_t)&epoll_create1;
4895 if compile_prog "" "" ; then
4896 epoll_create1=yes
4899 # check for sendfile support
4900 sendfile=no
4901 cat > $TMPC << EOF
4902 #include <sys/sendfile.h>
4904 int main(void)
4906 return sendfile(0, 0, 0, 0);
4909 if compile_prog "" "" ; then
4910 sendfile=yes
4913 # check for timerfd support (glibc 2.8 and newer)
4914 timerfd=no
4915 cat > $TMPC << EOF
4916 #include <sys/timerfd.h>
4918 int main(void)
4920 return(timerfd_create(CLOCK_REALTIME, 0));
4923 if compile_prog "" "" ; then
4924 timerfd=yes
4927 # check for setns and unshare support
4928 setns=no
4929 cat > $TMPC << EOF
4930 #include <sched.h>
4932 int main(void)
4934 int ret;
4935 ret = setns(0, 0);
4936 ret = unshare(0);
4937 return ret;
4940 if compile_prog "" "" ; then
4941 setns=yes
4944 # clock_adjtime probe
4945 clock_adjtime=no
4946 cat > $TMPC <<EOF
4947 #include <time.h>
4949 int main(void)
4951 return clock_adjtime(0, 0);
4954 clock_adjtime=no
4955 if compile_prog "" "" ; then
4956 clock_adjtime=yes
4959 # syncfs probe
4960 syncfs=no
4961 cat > $TMPC <<EOF
4962 #include <unistd.h>
4964 int main(void)
4966 return syncfs(0);
4969 syncfs=no
4970 if compile_prog "" "" ; then
4971 syncfs=yes
4974 # check for kcov support (kernel must be 4.4+, compiled with certain options)
4975 kcov=no
4976 if check_include sys/kcov.h ; then
4977 kcov=yes
4980 # If we're making warnings fatal, apply this to Sphinx runs as well
4981 sphinx_werror=""
4982 if test "$werror" = "yes"; then
4983 sphinx_werror="-W"
4986 # Check we have a new enough version of sphinx-build
4987 has_sphinx_build() {
4988 # This is a bit awkward but works: create a trivial document and
4989 # try to run it with our configuration file (which enforces a
4990 # version requirement). This will fail if either
4991 # sphinx-build doesn't exist at all or if it is too old.
4992 mkdir -p "$TMPDIR1/sphinx"
4993 touch "$TMPDIR1/sphinx/index.rst"
4994 "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
4995 -b html "$TMPDIR1/sphinx" \
4996 "$TMPDIR1/sphinx/out" >> config.log 2>&1
4999 # Check if tools are available to build documentation.
5000 if test "$docs" != "no" ; then
5001 if has_sphinx_build; then
5002 sphinx_ok=yes
5003 else
5004 sphinx_ok=no
5006 if has makeinfo && has pod2man && test "$sphinx_ok" = "yes"; then
5007 docs=yes
5008 else
5009 if test "$docs" = "yes" ; then
5010 if has $sphinx_build && test "$sphinx_ok" != "yes"; then
5011 echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
5013 feature_not_found "docs" "Install texinfo, Perl/perl-podlators and a Python 3 version of python-sphinx"
5015 docs=no
5019 # Search for bswap_32 function
5020 byteswap_h=no
5021 cat > $TMPC << EOF
5022 #include <byteswap.h>
5023 int main(void) { return bswap_32(0); }
5025 if compile_prog "" "" ; then
5026 byteswap_h=yes
5029 # Search for bswap32 function
5030 bswap_h=no
5031 cat > $TMPC << EOF
5032 #include <sys/endian.h>
5033 #include <sys/types.h>
5034 #include <machine/bswap.h>
5035 int main(void) { return bswap32(0); }
5037 if compile_prog "" "" ; then
5038 bswap_h=yes
5041 ##########################################
5042 # Do we have libiscsi >= 1.9.0
5043 if test "$libiscsi" != "no" ; then
5044 if $pkg_config --atleast-version=1.9.0 libiscsi; then
5045 libiscsi="yes"
5046 libiscsi_cflags=$($pkg_config --cflags libiscsi)
5047 libiscsi_libs=$($pkg_config --libs libiscsi)
5048 else
5049 if test "$libiscsi" = "yes" ; then
5050 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
5052 libiscsi="no"
5056 ##########################################
5057 # Do we need libm
5058 cat > $TMPC << EOF
5059 #include <math.h>
5060 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
5062 if compile_prog "" "" ; then
5064 elif compile_prog "" "-lm" ; then
5065 LIBS="-lm $LIBS"
5066 libs_qga="-lm $libs_qga"
5067 else
5068 error_exit "libm check failed"
5071 ##########################################
5072 # Do we need librt
5073 # uClibc provides 2 versions of clock_gettime(), one with realtime
5074 # support and one without. This means that the clock_gettime() don't
5075 # need -lrt. We still need it for timer_create() so we check for this
5076 # function in addition.
5077 cat > $TMPC <<EOF
5078 #include <signal.h>
5079 #include <time.h>
5080 int main(void) {
5081 timer_create(CLOCK_REALTIME, NULL, NULL);
5082 return clock_gettime(CLOCK_REALTIME, NULL);
5086 if compile_prog "" "" ; then
5088 # we need pthread for static linking. use previous pthread test result
5089 elif compile_prog "" "$pthread_lib -lrt" ; then
5090 LIBS="$LIBS -lrt"
5091 libs_qga="$libs_qga -lrt"
5094 # Check whether we need to link libutil for openpty()
5095 cat > $TMPC << EOF
5096 extern int openpty(int *am, int *as, char *name, void *termp, void *winp);
5097 int main(void) { return openpty(0, 0, 0, 0, 0); }
5100 if ! compile_prog "" "" ; then
5101 if compile_prog "" "-lutil" ; then
5102 libs_softmmu="-lutil $libs_softmmu"
5103 libs_tools="-lutil $libs_tools"
5107 ##########################################
5108 # spice probe
5109 if test "$spice" != "no" ; then
5110 cat > $TMPC << EOF
5111 #include <spice.h>
5112 int main(void) { spice_server_new(); return 0; }
5114 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
5115 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
5116 if $pkg_config --atleast-version=0.12.5 spice-server && \
5117 $pkg_config --atleast-version=0.12.3 spice-protocol && \
5118 compile_prog "$spice_cflags" "$spice_libs" ; then
5119 spice="yes"
5120 libs_softmmu="$libs_softmmu $spice_libs"
5121 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
5122 spice_protocol_version=$($pkg_config --modversion spice-protocol)
5123 spice_server_version=$($pkg_config --modversion spice-server)
5124 else
5125 if test "$spice" = "yes" ; then
5126 feature_not_found "spice" \
5127 "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
5129 spice="no"
5133 # check for smartcard support
5134 if test "$smartcard" != "no"; then
5135 if $pkg_config --atleast-version=2.5.1 libcacard; then
5136 libcacard_cflags=$($pkg_config --cflags libcacard)
5137 libcacard_libs=$($pkg_config --libs libcacard)
5138 smartcard="yes"
5139 else
5140 if test "$smartcard" = "yes"; then
5141 feature_not_found "smartcard" "Install libcacard devel"
5143 smartcard="no"
5147 # check for libusb
5148 if test "$libusb" != "no" ; then
5149 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
5150 libusb="yes"
5151 libusb_cflags=$($pkg_config --cflags libusb-1.0)
5152 libusb_libs=$($pkg_config --libs libusb-1.0)
5153 else
5154 if test "$libusb" = "yes"; then
5155 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
5157 libusb="no"
5161 # check for usbredirparser for usb network redirection support
5162 if test "$usb_redir" != "no" ; then
5163 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
5164 usb_redir="yes"
5165 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
5166 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
5167 else
5168 if test "$usb_redir" = "yes"; then
5169 feature_not_found "usb-redir" "Install usbredir devel"
5171 usb_redir="no"
5175 ##########################################
5176 # check if we have VSS SDK headers for win
5178 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5179 test "$vss_win32_sdk" != "no" ; then
5180 case "$vss_win32_sdk" in
5181 "") vss_win32_include="-isystem $source_path" ;;
5182 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
5183 # handle path with spaces. So we symlink the headers into ".sdk/vss".
5184 vss_win32_include="-isystem $source_path/.sdk/vss"
5185 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
5187 *) vss_win32_include="-isystem $vss_win32_sdk"
5188 esac
5189 cat > $TMPC << EOF
5190 #define __MIDL_user_allocate_free_DEFINED__
5191 #include <inc/win2003/vss.h>
5192 int main(void) { return VSS_CTX_BACKUP; }
5194 if compile_prog "$vss_win32_include" "" ; then
5195 guest_agent_with_vss="yes"
5196 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
5197 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
5198 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
5199 else
5200 if test "$vss_win32_sdk" != "" ; then
5201 echo "ERROR: Please download and install Microsoft VSS SDK:"
5202 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
5203 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
5204 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
5205 echo "ERROR: The headers are extracted in the directory \`inc'."
5206 feature_not_found "VSS support"
5208 guest_agent_with_vss="no"
5212 ##########################################
5213 # lookup Windows platform SDK (if not specified)
5214 # The SDK is needed only to build .tlb (type library) file of guest agent
5215 # VSS provider from the source. It is usually unnecessary because the
5216 # pre-compiled .tlb file is included.
5218 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5219 test "$guest_agent_with_vss" = "yes" ; then
5220 if test -z "$win_sdk"; then
5221 programfiles="$PROGRAMFILES"
5222 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
5223 if test -n "$programfiles"; then
5224 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
5225 else
5226 feature_not_found "Windows SDK"
5228 elif test "$win_sdk" = "no"; then
5229 win_sdk=""
5233 ##########################################
5234 # check if mingw environment provides a recent ntddscsi.h
5235 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
5236 cat > $TMPC << EOF
5237 #include <windows.h>
5238 #include <ntddscsi.h>
5239 int main(void) {
5240 #if !defined(IOCTL_SCSI_GET_ADDRESS)
5241 #error Missing required ioctl definitions
5242 #endif
5243 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
5244 return addr.Lun;
5247 if compile_prog "" "" ; then
5248 guest_agent_ntddscsi=yes
5249 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
5253 ##########################################
5254 # virgl renderer probe
5256 if test "$virglrenderer" != "no" ; then
5257 cat > $TMPC << EOF
5258 #include <virglrenderer.h>
5259 int main(void) { virgl_renderer_poll(); return 0; }
5261 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
5262 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
5263 virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
5264 if $pkg_config virglrenderer >/dev/null 2>&1 && \
5265 compile_prog "$virgl_cflags" "$virgl_libs" ; then
5266 virglrenderer="yes"
5267 else
5268 if test "$virglrenderer" = "yes" ; then
5269 feature_not_found "virglrenderer"
5271 virglrenderer="no"
5275 ##########################################
5276 # capstone
5278 case "$capstone" in
5279 "" | yes)
5280 if $pkg_config capstone; then
5281 capstone=system
5282 elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5283 capstone=git
5284 elif test -e "${source_path}/capstone/Makefile" ; then
5285 capstone=internal
5286 elif test -z "$capstone" ; then
5287 capstone=no
5288 else
5289 feature_not_found "capstone" "Install capstone devel or git submodule"
5293 system)
5294 if ! $pkg_config capstone; then
5295 feature_not_found "capstone" "Install capstone devel"
5298 esac
5300 case "$capstone" in
5301 git | internal)
5302 if test "$capstone" = git; then
5303 git_submodules="${git_submodules} capstone"
5305 mkdir -p capstone
5306 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
5307 if test "$mingw32" = "yes"; then
5308 LIBCAPSTONE=capstone.lib
5309 else
5310 LIBCAPSTONE=libcapstone.a
5312 libs_cpu="-L\$(BUILD_DIR)/capstone -lcapstone $libs_cpu"
5315 system)
5316 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
5317 libs_cpu="$($pkg_config --libs capstone) $libs_cpu"
5323 error_exit "Unknown state for capstone: $capstone"
5325 esac
5327 ##########################################
5328 # check if we have fdatasync
5330 fdatasync=no
5331 cat > $TMPC << EOF
5332 #include <unistd.h>
5333 int main(void) {
5334 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5335 return fdatasync(0);
5336 #else
5337 #error Not supported
5338 #endif
5341 if compile_prog "" "" ; then
5342 fdatasync=yes
5345 ##########################################
5346 # check if we have madvise
5348 madvise=no
5349 cat > $TMPC << EOF
5350 #include <sys/types.h>
5351 #include <sys/mman.h>
5352 #include <stddef.h>
5353 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5355 if compile_prog "" "" ; then
5356 madvise=yes
5359 ##########################################
5360 # check if we have posix_madvise
5362 posix_madvise=no
5363 cat > $TMPC << EOF
5364 #include <sys/mman.h>
5365 #include <stddef.h>
5366 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5368 if compile_prog "" "" ; then
5369 posix_madvise=yes
5372 ##########################################
5373 # check if we have posix_memalign()
5375 posix_memalign=no
5376 cat > $TMPC << EOF
5377 #include <stdlib.h>
5378 int main(void) {
5379 void *p;
5380 return posix_memalign(&p, 8, 8);
5383 if compile_prog "" "" ; then
5384 posix_memalign=yes
5387 ##########################################
5388 # check if we have posix_syslog
5390 posix_syslog=no
5391 cat > $TMPC << EOF
5392 #include <syslog.h>
5393 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
5395 if compile_prog "" "" ; then
5396 posix_syslog=yes
5399 ##########################################
5400 # check if we have sem_timedwait
5402 sem_timedwait=no
5403 cat > $TMPC << EOF
5404 #include <semaphore.h>
5405 int main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5407 if compile_prog "" "" ; then
5408 sem_timedwait=yes
5411 ##########################################
5412 # check if we have strchrnul
5414 strchrnul=no
5415 cat > $TMPC << EOF
5416 #include <string.h>
5417 int main(void);
5418 // Use a haystack that the compiler shouldn't be able to constant fold
5419 char *haystack = (char*)&main;
5420 int main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
5422 if compile_prog "" "" ; then
5423 strchrnul=yes
5426 #########################################
5427 # check if we have st_atim
5429 st_atim=no
5430 cat > $TMPC << EOF
5431 #include <sys/stat.h>
5432 #include <stddef.h>
5433 int main(void) { return offsetof(struct stat, st_atim); }
5435 if compile_prog "" "" ; then
5436 st_atim=yes
5439 ##########################################
5440 # check if trace backend exists
5442 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
5443 if test "$?" -ne 0 ; then
5444 error_exit "invalid trace backends" \
5445 "Please choose supported trace backends."
5448 ##########################################
5449 # For 'ust' backend, test if ust headers are present
5450 if have_backend "ust"; then
5451 cat > $TMPC << EOF
5452 #include <lttng/tracepoint.h>
5453 int main(void) { return 0; }
5455 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5456 if $pkg_config lttng-ust --exists; then
5457 lttng_ust_libs=$($pkg_config --libs lttng-ust)
5458 else
5459 lttng_ust_libs="-llttng-ust -ldl"
5461 if $pkg_config liburcu-bp --exists; then
5462 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5463 else
5464 urcu_bp_libs="-lurcu-bp"
5467 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5468 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
5469 else
5470 error_exit "Trace backend 'ust' missing lttng-ust header files"
5474 ##########################################
5475 # For 'dtrace' backend, test if 'dtrace' command is present
5476 if have_backend "dtrace"; then
5477 if ! has 'dtrace' ; then
5478 error_exit "dtrace command is not found in PATH $PATH"
5480 trace_backend_stap="no"
5481 if has 'stap' ; then
5482 trace_backend_stap="yes"
5486 ##########################################
5487 # check and set a backend for coroutine
5489 # We prefer ucontext, but it's not always possible. The fallback
5490 # is sigcontext. On Windows the only valid backend is the Windows
5491 # specific one.
5493 ucontext_works=no
5494 if test "$darwin" != "yes"; then
5495 cat > $TMPC << EOF
5496 #include <ucontext.h>
5497 #ifdef __stub_makecontext
5498 #error Ignoring glibc stub makecontext which will always fail
5499 #endif
5500 int main(void) { makecontext(0, 0, 0); return 0; }
5502 if compile_prog "" "" ; then
5503 ucontext_works=yes
5507 if test "$coroutine" = ""; then
5508 if test "$mingw32" = "yes"; then
5509 coroutine=win32
5510 elif test "$ucontext_works" = "yes"; then
5511 coroutine=ucontext
5512 else
5513 coroutine=sigaltstack
5515 else
5516 case $coroutine in
5517 windows)
5518 if test "$mingw32" != "yes"; then
5519 error_exit "'windows' coroutine backend only valid for Windows"
5521 # Unfortunately the user visible backend name doesn't match the
5522 # coroutine-*.c filename for this case, so we have to adjust it here.
5523 coroutine=win32
5525 ucontext)
5526 if test "$ucontext_works" != "yes"; then
5527 feature_not_found "ucontext"
5530 sigaltstack)
5531 if test "$mingw32" = "yes"; then
5532 error_exit "only the 'windows' coroutine backend is valid for Windows"
5536 error_exit "unknown coroutine backend $coroutine"
5538 esac
5541 if test "$coroutine_pool" = ""; then
5542 coroutine_pool=yes
5545 if test "$debug_stack_usage" = "yes"; then
5546 if test "$coroutine_pool" = "yes"; then
5547 echo "WARN: disabling coroutine pool for stack usage debugging"
5548 coroutine_pool=no
5553 ##########################################
5554 # check if we have open_by_handle_at
5556 open_by_handle_at=no
5557 cat > $TMPC << EOF
5558 #include <fcntl.h>
5559 #if !defined(AT_EMPTY_PATH)
5560 # error missing definition
5561 #else
5562 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5563 #endif
5565 if compile_prog "" "" ; then
5566 open_by_handle_at=yes
5569 ########################################
5570 # check if we have linux/magic.h
5572 linux_magic_h=no
5573 cat > $TMPC << EOF
5574 #include <linux/magic.h>
5575 int main(void) {
5576 return 0;
5579 if compile_prog "" "" ; then
5580 linux_magic_h=yes
5583 ########################################
5584 # check whether we can disable warning option with a pragma (this is needed
5585 # to silence warnings in the headers of some versions of external libraries).
5586 # This test has to be compiled with -Werror as otherwise an unknown pragma is
5587 # only a warning.
5589 # If we can't selectively disable warning in the code, disable -Werror so that
5590 # the build doesn't fail anyway.
5592 pragma_disable_unused_but_set=no
5593 cat > $TMPC << EOF
5594 #pragma GCC diagnostic push
5595 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
5596 #pragma GCC diagnostic pop
5598 int main(void) {
5599 return 0;
5602 if compile_prog "-Werror" "" ; then
5603 pragma_diagnostic_available=yes
5604 else
5605 werror=no
5608 ########################################
5609 # check if we have valgrind/valgrind.h
5611 valgrind_h=no
5612 cat > $TMPC << EOF
5613 #include <valgrind/valgrind.h>
5614 int main(void) {
5615 return 0;
5618 if compile_prog "" "" ; then
5619 valgrind_h=yes
5622 ########################################
5623 # check if environ is declared
5625 has_environ=no
5626 cat > $TMPC << EOF
5627 #include <unistd.h>
5628 int main(void) {
5629 environ = 0;
5630 return 0;
5633 if compile_prog "" "" ; then
5634 has_environ=yes
5637 ########################################
5638 # check if cpuid.h is usable.
5640 cat > $TMPC << EOF
5641 #include <cpuid.h>
5642 int main(void) {
5643 unsigned a, b, c, d;
5644 int max = __get_cpuid_max(0, 0);
5646 if (max >= 1) {
5647 __cpuid(1, a, b, c, d);
5650 if (max >= 7) {
5651 __cpuid_count(7, 0, a, b, c, d);
5654 return 0;
5657 if compile_prog "" "" ; then
5658 cpuid_h=yes
5661 ##########################################
5662 # avx2 optimization requirement check
5664 # There is no point enabling this if cpuid.h is not usable,
5665 # since we won't be able to select the new routines.
5667 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
5668 cat > $TMPC << EOF
5669 #pragma GCC push_options
5670 #pragma GCC target("avx2")
5671 #include <cpuid.h>
5672 #include <immintrin.h>
5673 static int bar(void *a) {
5674 __m256i x = *(__m256i *)a;
5675 return _mm256_testz_si256(x, x);
5677 int main(int argc, char *argv[]) { return bar(argv[0]); }
5679 if compile_object "" ; then
5680 avx2_opt="yes"
5681 else
5682 avx2_opt="no"
5686 ##########################################
5687 # avx512f optimization requirement check
5689 # There is no point enabling this if cpuid.h is not usable,
5690 # since we won't be able to select the new routines.
5691 # by default, it is turned off.
5692 # if user explicitly want to enable it, check environment
5694 if test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
5695 cat > $TMPC << EOF
5696 #pragma GCC push_options
5697 #pragma GCC target("avx512f")
5698 #include <cpuid.h>
5699 #include <immintrin.h>
5700 static int bar(void *a) {
5701 __m512i x = *(__m512i *)a;
5702 return _mm512_test_epi64_mask(x, x);
5704 int main(int argc, char *argv[])
5706 return bar(argv[0]);
5709 if ! compile_object "" ; then
5710 avx512f_opt="no"
5712 else
5713 avx512f_opt="no"
5716 ########################################
5717 # check if __[u]int128_t is usable.
5719 int128=no
5720 cat > $TMPC << EOF
5721 __int128_t a;
5722 __uint128_t b;
5723 int main (void) {
5724 a = a + b;
5725 b = a * b;
5726 a = a * a;
5727 return 0;
5730 if compile_prog "" "" ; then
5731 int128=yes
5734 #########################################
5735 # See if 128-bit atomic operations are supported.
5737 atomic128=no
5738 if test "$int128" = "yes"; then
5739 cat > $TMPC << EOF
5740 int main(void)
5742 unsigned __int128 x = 0, y = 0;
5743 y = __atomic_load_16(&x, 0);
5744 __atomic_store_16(&x, y, 0);
5745 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
5746 return 0;
5749 if compile_prog "" "" ; then
5750 atomic128=yes
5754 cmpxchg128=no
5755 if test "$int128" = yes && test "$atomic128" = no; then
5756 cat > $TMPC << EOF
5757 int main(void)
5759 unsigned __int128 x = 0, y = 0;
5760 __sync_val_compare_and_swap_16(&x, y, x);
5761 return 0;
5764 if compile_prog "" "" ; then
5765 cmpxchg128=yes
5769 #########################################
5770 # See if 64-bit atomic operations are supported.
5771 # Note that without __atomic builtins, we can only
5772 # assume atomic loads/stores max at pointer size.
5774 cat > $TMPC << EOF
5775 #include <stdint.h>
5776 int main(void)
5778 uint64_t x = 0, y = 0;
5779 #ifdef __ATOMIC_RELAXED
5780 y = __atomic_load_8(&x, 0);
5781 __atomic_store_8(&x, y, 0);
5782 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5783 __atomic_exchange_8(&x, y, 0);
5784 __atomic_fetch_add_8(&x, y, 0);
5785 #else
5786 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5787 __sync_lock_test_and_set(&x, y);
5788 __sync_val_compare_and_swap(&x, y, 0);
5789 __sync_fetch_and_add(&x, y);
5790 #endif
5791 return 0;
5794 if compile_prog "" "" ; then
5795 atomic64=yes
5798 #########################################
5799 # See if --dynamic-list is supported by the linker
5800 ld_dynamic_list="no"
5801 if test "$static" = "no" ; then
5802 cat > $TMPTXT <<EOF
5804 foo;
5808 cat > $TMPC <<EOF
5809 #include <stdio.h>
5810 void foo(void);
5812 void foo(void)
5814 printf("foo\n");
5817 int main(void)
5819 foo();
5820 return 0;
5824 if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
5825 ld_dynamic_list="yes"
5829 #########################################
5830 # See if -exported_symbols_list is supported by the linker
5832 ld_exported_symbols_list="no"
5833 if test "$static" = "no" ; then
5834 cat > $TMPTXT <<EOF
5835 _foo
5838 if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
5839 ld_exported_symbols_list="yes"
5843 if test "$plugins" = "yes" &&
5844 test "$ld_dynamic_list" = "no" &&
5845 test "$ld_exported_symbols_list" = "no" ; then
5846 error_exit \
5847 "Plugin support requires dynamic linking and specifying a set of symbols " \
5848 "that are exported to plugins. Unfortunately your linker doesn't " \
5849 "support the flag (--dynamic-list or -exported_symbols_list) used " \
5850 "for this purpose. You can't build with --static."
5853 ########################################
5854 # See if __attribute__((alias)) is supported.
5855 # This false for Xcode 9, but has been remedied for Xcode 10.
5856 # Unfortunately, travis uses Xcode 9 by default.
5858 attralias=no
5859 cat > $TMPC << EOF
5860 int x = 1;
5861 extern const int y __attribute__((alias("x")));
5862 int main(void) { return 0; }
5864 if compile_prog "" "" ; then
5865 attralias=yes
5868 ########################################
5869 # check if getauxval is available.
5871 getauxval=no
5872 cat > $TMPC << EOF
5873 #include <sys/auxv.h>
5874 int main(void) {
5875 return getauxval(AT_HWCAP) == 0;
5878 if compile_prog "" "" ; then
5879 getauxval=yes
5882 ########################################
5883 # check if ccache is interfering with
5884 # semantic analysis of macros
5886 unset CCACHE_CPP2
5887 ccache_cpp2=no
5888 cat > $TMPC << EOF
5889 static const int Z = 1;
5890 #define fn() ({ Z; })
5891 #define TAUT(X) ((X) == Z)
5892 #define PAREN(X, Y) (X == Y)
5893 #define ID(X) (X)
5894 int main(int argc, char *argv[])
5896 int x = 0, y = 0;
5897 x = ID(x);
5898 x = fn();
5899 fn();
5900 if (PAREN(x, y)) return 0;
5901 if (TAUT(Z)) return 0;
5902 return 0;
5906 if ! compile_object "-Werror"; then
5907 ccache_cpp2=yes
5910 #################################################
5911 # clang does not support glibc + FORTIFY_SOURCE.
5913 if test "$fortify_source" != "no"; then
5914 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5915 fortify_source="no";
5916 elif test -n "$cxx" && has $cxx &&
5917 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5918 fortify_source="no";
5919 else
5920 fortify_source="yes"
5924 ###############################################
5925 # Check if copy_file_range is provided by glibc
5926 have_copy_file_range=no
5927 cat > $TMPC << EOF
5928 #include <unistd.h>
5929 int main(void) {
5930 copy_file_range(0, NULL, 0, NULL, 0, 0);
5931 return 0;
5934 if compile_prog "" "" ; then
5935 have_copy_file_range=yes
5938 ##########################################
5939 # check if struct fsxattr is available via linux/fs.h
5941 have_fsxattr=no
5942 cat > $TMPC << EOF
5943 #include <linux/fs.h>
5944 struct fsxattr foo;
5945 int main(void) {
5946 return 0;
5949 if compile_prog "" "" ; then
5950 have_fsxattr=yes
5953 ##########################################
5954 # check for usable membarrier system call
5955 if test "$membarrier" = "yes"; then
5956 have_membarrier=no
5957 if test "$mingw32" = "yes" ; then
5958 have_membarrier=yes
5959 elif test "$linux" = "yes" ; then
5960 cat > $TMPC << EOF
5961 #include <linux/membarrier.h>
5962 #include <sys/syscall.h>
5963 #include <unistd.h>
5964 #include <stdlib.h>
5965 int main(void) {
5966 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5967 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5968 exit(0);
5971 if compile_prog "" "" ; then
5972 have_membarrier=yes
5975 if test "$have_membarrier" = "no"; then
5976 feature_not_found "membarrier" "membarrier system call not available"
5978 else
5979 # Do not enable it by default even for Mingw32, because it doesn't
5980 # work on Wine.
5981 membarrier=no
5984 ##########################################
5985 # check if rtnetlink.h exists and is useful
5986 have_rtnetlink=no
5987 cat > $TMPC << EOF
5988 #include <linux/rtnetlink.h>
5989 int main(void) {
5990 return IFLA_PROTO_DOWN;
5993 if compile_prog "" "" ; then
5994 have_rtnetlink=yes
5997 ##########################################
5998 # check for usable AF_VSOCK environment
5999 have_af_vsock=no
6000 cat > $TMPC << EOF
6001 #include <errno.h>
6002 #include <sys/types.h>
6003 #include <sys/socket.h>
6004 #if !defined(AF_VSOCK)
6005 # error missing AF_VSOCK flag
6006 #endif
6007 #include <linux/vm_sockets.h>
6008 int main(void) {
6009 int sock, ret;
6010 struct sockaddr_vm svm;
6011 socklen_t len = sizeof(svm);
6012 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
6013 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
6014 if ((ret == -1) && (errno == ENOTCONN)) {
6015 return 0;
6017 return -1;
6020 if compile_prog "" "" ; then
6021 have_af_vsock=yes
6024 ##########################################
6025 # check for usable AF_ALG environment
6026 have_afalg=no
6027 cat > $TMPC << EOF
6028 #include <errno.h>
6029 #include <sys/types.h>
6030 #include <sys/socket.h>
6031 #include <linux/if_alg.h>
6032 int main(void) {
6033 int sock;
6034 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
6035 return sock;
6038 if compile_prog "" "" ; then
6039 have_afalg=yes
6041 if test "$crypto_afalg" = "yes"
6042 then
6043 if test "$have_afalg" != "yes"
6044 then
6045 error_exit "AF_ALG requested but could not be detected"
6050 #################################################
6051 # Check to see if we have the Hypervisor framework
6052 if [ "$darwin" = "yes" ] ; then
6053 cat > $TMPC << EOF
6054 #include <Hypervisor/hv.h>
6055 int main() { return 0;}
6057 if ! compile_object ""; then
6058 hvf='no'
6059 else
6060 hvf='yes'
6061 QEMU_LDFLAGS="-framework Hypervisor $QEMU_LDFLAGS"
6065 #################################################
6066 # Sparc implicitly links with --relax, which is
6067 # incompatible with -r, so --no-relax should be
6068 # given. It does no harm to give it on other
6069 # platforms too.
6071 # Note: the prototype is needed since QEMU_CFLAGS
6072 # contains -Wmissing-prototypes
6073 cat > $TMPC << EOF
6074 extern int foo(void);
6075 int foo(void) { return 0; }
6077 if ! compile_object ""; then
6078 error_exit "Failed to compile object file for LD_REL_FLAGS test"
6080 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
6081 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
6082 LD_REL_FLAGS=$i
6083 break
6085 done
6086 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
6087 feature_not_found "modules" "Cannot find how to build relocatable objects"
6090 ##########################################
6091 # check for sysmacros.h
6093 have_sysmacros=no
6094 cat > $TMPC << EOF
6095 #include <sys/sysmacros.h>
6096 int main(void) {
6097 return makedev(0, 0);
6100 if compile_prog "" "" ; then
6101 have_sysmacros=yes
6104 ##########################################
6105 # Veritas HyperScale block driver VxHS
6106 # Check if libvxhs is installed
6108 if test "$vxhs" != "no" ; then
6109 cat > $TMPC <<EOF
6110 #include <stdint.h>
6111 #include <qnio/qnio_api.h>
6113 void *vxhs_callback;
6115 int main(void) {
6116 iio_init(QNIO_VERSION, vxhs_callback);
6117 return 0;
6120 vxhs_libs="-lvxhs -lssl"
6121 if compile_prog "" "$vxhs_libs" ; then
6122 vxhs=yes
6123 else
6124 if test "$vxhs" = "yes" ; then
6125 feature_not_found "vxhs block device" "Install libvxhs See github"
6127 vxhs=no
6131 ##########################################
6132 # check for _Static_assert()
6134 have_static_assert=no
6135 cat > $TMPC << EOF
6136 _Static_assert(1, "success");
6137 int main(void) {
6138 return 0;
6141 if compile_prog "" "" ; then
6142 have_static_assert=yes
6145 ##########################################
6146 # check for utmpx.h, it is missing e.g. on OpenBSD
6148 have_utmpx=no
6149 cat > $TMPC << EOF
6150 #include <utmpx.h>
6151 struct utmpx user_info;
6152 int main(void) {
6153 return 0;
6156 if compile_prog "" "" ; then
6157 have_utmpx=yes
6160 ##########################################
6161 # check for getrandom()
6163 have_getrandom=no
6164 cat > $TMPC << EOF
6165 #include <sys/random.h>
6166 int main(void) {
6167 return getrandom(0, 0, GRND_NONBLOCK);
6170 if compile_prog "" "" ; then
6171 have_getrandom=yes
6174 ##########################################
6175 # checks for sanitizers
6177 have_asan=no
6178 have_ubsan=no
6179 have_asan_iface_h=no
6180 have_asan_iface_fiber=no
6182 if test "$sanitizers" = "yes" ; then
6183 write_c_skeleton
6184 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
6185 have_asan=yes
6188 # we could use a simple skeleton for flags checks, but this also
6189 # detect the static linking issue of ubsan, see also:
6190 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
6191 cat > $TMPC << EOF
6192 #include <stdlib.h>
6193 int main(void) {
6194 void *tmp = malloc(10);
6195 if (tmp != NULL) {
6196 return *(int *)(tmp + 2);
6200 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
6201 have_ubsan=yes
6204 if check_include "sanitizer/asan_interface.h" ; then
6205 have_asan_iface_h=yes
6208 cat > $TMPC << EOF
6209 #include <sanitizer/asan_interface.h>
6210 int main(void) {
6211 __sanitizer_start_switch_fiber(0, 0, 0);
6212 return 0;
6215 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
6216 have_asan_iface_fiber=yes
6220 ##########################################
6221 # checks for fuzzer
6222 if test "$fuzzing" = "yes" ; then
6223 write_c_fuzzer_skeleton
6224 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address,fuzzer" ""; then
6225 have_fuzzer=yes
6229 # Thread sanitizer is, for now, much noisier than the other sanitizers;
6230 # keep it separate until that is not the case.
6231 if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
6232 error_exit "TSAN is not supported with other sanitiziers."
6234 have_tsan=no
6235 have_tsan_iface_fiber=no
6236 if test "$tsan" = "yes" ; then
6237 write_c_skeleton
6238 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
6239 have_tsan=yes
6241 cat > $TMPC << EOF
6242 #include <sanitizer/tsan_interface.h>
6243 int main(void) {
6244 __tsan_create_fiber(0);
6245 return 0;
6248 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
6249 have_tsan_iface_fiber=yes
6253 ##########################################
6254 # check for libpmem
6256 if test "$libpmem" != "no"; then
6257 if $pkg_config --exists "libpmem"; then
6258 libpmem="yes"
6259 libpmem_libs=$($pkg_config --libs libpmem)
6260 libpmem_cflags=$($pkg_config --cflags libpmem)
6261 libs_softmmu="$libs_softmmu $libpmem_libs"
6262 QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
6263 else
6264 if test "$libpmem" = "yes" ; then
6265 feature_not_found "libpmem" "Install nvml or pmdk"
6267 libpmem="no"
6271 ##########################################
6272 # check for slirp
6274 # slirp is only required when building softmmu targets
6275 if test -z "$slirp" -a "$softmmu" != "yes" ; then
6276 slirp="no"
6279 case "$slirp" in
6280 "" | yes)
6281 if $pkg_config slirp; then
6282 slirp=system
6283 elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
6284 slirp=git
6285 elif test -e "${source_path}/slirp/Makefile" ; then
6286 slirp=internal
6287 elif test -z "$slirp" ; then
6288 slirp=no
6289 else
6290 feature_not_found "slirp" "Install slirp devel or git submodule"
6294 system)
6295 if ! $pkg_config slirp; then
6296 feature_not_found "slirp" "Install slirp devel"
6299 esac
6301 case "$slirp" in
6302 git | internal)
6303 if test "$slirp" = git; then
6304 git_submodules="${git_submodules} slirp"
6306 mkdir -p slirp
6307 slirp_cflags="-I\$(SRC_PATH)/slirp/src -I\$(BUILD_DIR)/slirp/src"
6308 slirp_libs="-L\$(BUILD_DIR)/slirp -lslirp"
6309 if test "$mingw32" = "yes" ; then
6310 slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
6314 system)
6315 slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
6316 slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
6317 slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
6323 error_exit "Unknown state for slirp: $slirp"
6325 esac
6327 ##########################################
6328 # check for usable __NR_keyctl syscall
6330 if test "$linux" = "yes" ; then
6332 have_keyring=no
6333 cat > $TMPC << EOF
6334 #include <errno.h>
6335 #include <asm/unistd.h>
6336 #include <linux/keyctl.h>
6337 #include <unistd.h>
6338 int main(void) {
6339 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
6342 if compile_prog "" "" ; then
6343 have_keyring=yes
6346 if test "$secret_keyring" != "no"
6347 then
6348 if test "$have_keyring" == "yes"
6349 then
6350 secret_keyring=yes
6351 else
6352 if test "$secret_keyring" = "yes"
6353 then
6354 error_exit "syscall __NR_keyctl requested, \
6355 but not implemented on your system"
6356 else
6357 secret_keyring=no
6362 ##########################################
6363 # check for usable keyutils.h
6365 if test "$linux" = "yes" ; then
6367 have_keyutils=no
6368 cat > $TMPC << EOF
6369 #include <errno.h>
6370 #include <asm/unistd.h>
6371 #include <unistd.h>
6372 #include <sys/types.h>
6373 #include <keyutils.h>
6374 int main(void) {
6375 return request_key("user", NULL, NULL, 0);
6378 if compile_prog "" "-lkeyutils"; then
6379 have_keyutils=yes
6384 ##########################################
6385 # End of CC checks
6386 # After here, no more $cc or $ld runs
6388 write_c_skeleton
6390 if test "$gcov" = "yes" ; then
6391 QEMU_CFLAGS="-fprofile-arcs -ftest-coverage -g $QEMU_CFLAGS"
6392 QEMU_LDFLAGS="-fprofile-arcs -ftest-coverage $QEMU_LDFLAGS"
6393 elif test "$fortify_source" = "yes" ; then
6394 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
6395 elif test "$debug" = "no"; then
6396 CFLAGS="-O2 $CFLAGS"
6399 if test "$have_asan" = "yes"; then
6400 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
6401 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
6402 if test "$have_asan_iface_h" = "no" ; then
6403 echo "ASAN build enabled, but ASAN header missing." \
6404 "Without code annotation, the report may be inferior."
6405 elif test "$have_asan_iface_fiber" = "no" ; then
6406 echo "ASAN build enabled, but ASAN header is too old." \
6407 "Without code annotation, the report may be inferior."
6410 if test "$have_tsan" = "yes" ; then
6411 if test "$have_tsan_iface_fiber" = "yes" ; then
6412 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
6413 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
6414 else
6415 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
6417 elif test "$tsan" = "yes" ; then
6418 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
6420 if test "$have_ubsan" = "yes"; then
6421 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
6422 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
6425 ##########################################
6426 # Do we have libnfs
6427 if test "$libnfs" != "no" ; then
6428 if $pkg_config --atleast-version=1.9.3 libnfs; then
6429 libnfs="yes"
6430 libnfs_libs=$($pkg_config --libs libnfs)
6431 else
6432 if test "$libnfs" = "yes" ; then
6433 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
6435 libnfs="no"
6439 ##########################################
6440 # Do we have libudev
6441 if test "$libudev" != "no" ; then
6442 if $pkg_config libudev && test "$static" != "yes"; then
6443 libudev="yes"
6444 libudev_libs=$($pkg_config --libs libudev)
6445 else
6446 libudev="no"
6450 # Now we've finished running tests it's OK to add -Werror to the compiler flags
6451 if test "$werror" = "yes"; then
6452 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
6455 # Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
6456 if test "$solaris" = "no" && test "$tsan" = "no"; then
6457 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
6458 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
6462 # test if pod2man has --utf8 option
6463 if pod2man --help | grep -q utf8; then
6464 POD2MAN="pod2man --utf8"
6465 else
6466 POD2MAN="pod2man"
6469 # Use ASLR, no-SEH and DEP if available
6470 if test "$mingw32" = "yes" ; then
6471 for flag in --dynamicbase --no-seh --nxcompat; do
6472 if ld_has $flag ; then
6473 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
6475 done
6478 # Disable OpenBSD W^X if available
6479 if test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
6480 cat > $TMPC <<EOF
6481 int main(void) { return 0; }
6483 wx_ldflags="-Wl,-z,wxneeded"
6484 if compile_prog "" "$wx_ldflags"; then
6485 QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
6489 qemu_confdir=$sysconfdir$confsuffix
6490 qemu_moddir=$libdir$confsuffix
6491 qemu_datadir=$datadir$confsuffix
6492 qemu_localedir="$datadir/locale"
6493 qemu_icondir="$datadir/icons"
6494 qemu_desktopdir="$datadir/applications"
6496 # We can only support ivshmem if we have eventfd
6497 if [ "$eventfd" = "yes" ]; then
6498 ivshmem=yes
6501 tools=""
6502 if test "$want_tools" = "yes" ; then
6503 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
6504 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
6505 tools="qemu-nbd\$(EXESUF) qemu-storage-daemon\$(EXESUF) $tools"
6507 if [ "$ivshmem" = "yes" ]; then
6508 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
6510 if [ "$curl" = "yes" ]; then
6511 tools="elf2dmp\$(EXESUF) $tools"
6514 if test "$softmmu" = yes ; then
6515 if test "$linux" = yes; then
6516 if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
6517 virtfs=yes
6518 helpers="$helpers fsdev/virtfs-proxy-helper\$(EXESUF)"
6519 else
6520 if test "$virtfs" = yes; then
6521 error_exit "VirtFS requires libcap-ng devel and libattr devel"
6523 virtfs=no
6525 if test "$mpath" != no && test "$mpathpersist" = yes ; then
6526 mpath=yes
6527 else
6528 if test "$mpath" = yes; then
6529 error_exit "Multipath requires libmpathpersist devel"
6531 mpath=no
6533 helpers="$helpers scsi/qemu-pr-helper\$(EXESUF)"
6534 else
6535 if test "$virtfs" = yes; then
6536 error_exit "VirtFS is supported only on Linux"
6538 virtfs=no
6539 if test "$mpath" = yes; then
6540 error_exit "Multipath is supported only on Linux"
6542 mpath=no
6544 if test "$xkbcommon" = "yes"; then
6545 tools="qemu-keymap\$(EXESUF) $tools"
6549 # Probe for guest agent support/options
6551 if [ "$guest_agent" != "no" ]; then
6552 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6553 guest_agent=no
6554 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
6555 tools="qemu-ga\$(EXESUF) $tools"
6556 guest_agent=yes
6557 elif [ "$guest_agent" != yes ]; then
6558 guest_agent=no
6559 else
6560 error_exit "Guest agent is not supported on this platform"
6564 # Guest agent Window MSI package
6566 if test "$guest_agent" != yes; then
6567 if test "$guest_agent_msi" = yes; then
6568 error_exit "MSI guest agent package requires guest agent enabled"
6570 guest_agent_msi=no
6571 elif test "$mingw32" != "yes"; then
6572 if test "$guest_agent_msi" = "yes"; then
6573 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
6575 guest_agent_msi=no
6576 elif ! has wixl; then
6577 if test "$guest_agent_msi" = "yes"; then
6578 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
6580 guest_agent_msi=no
6581 else
6582 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
6583 # disabled explicitly
6584 if test "$guest_agent_msi" != "no"; then
6585 guest_agent_msi=yes
6589 if test "$guest_agent_msi" = "yes"; then
6590 if test "$guest_agent_with_vss" = "yes"; then
6591 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
6594 if test "$QEMU_GA_MANUFACTURER" = ""; then
6595 QEMU_GA_MANUFACTURER=QEMU
6598 if test "$QEMU_GA_DISTRO" = ""; then
6599 QEMU_GA_DISTRO=Linux
6602 if test "$QEMU_GA_VERSION" = ""; then
6603 QEMU_GA_VERSION=$(cat $source_path/VERSION)
6606 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
6608 case "$cpu" in
6609 x86_64)
6610 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
6612 i386)
6613 QEMU_GA_MSI_ARCH="-D Arch=32"
6616 error_exit "CPU $cpu not supported for building installation package"
6618 esac
6621 # Mac OS X ships with a broken assembler
6622 roms=
6623 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6624 test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6625 test "$softmmu" = yes ; then
6626 # Different host OS linkers have different ideas about the name of the ELF
6627 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6628 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6629 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6630 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6631 ld_i386_emulation="$emu"
6632 roms="optionrom"
6633 break
6635 done
6638 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
6639 if test "$cpu" = "s390x" ; then
6640 write_c_skeleton
6641 if compile_prog "-march=z900" ""; then
6642 roms="$roms s390-ccw"
6643 # SLOF is required for building the s390-ccw firmware on s390x,
6644 # since it is using the libnet code from SLOF for network booting.
6645 if test -e "${source_path}/.git" ; then
6646 git_submodules="${git_submodules} roms/SLOF"
6651 # Check that the C++ compiler exists and works with the C compiler.
6652 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
6653 if has $cxx; then
6654 cat > $TMPC <<EOF
6655 int c_function(void);
6656 int main(void) { return c_function(); }
6659 compile_object
6661 cat > $TMPCXX <<EOF
6662 extern "C" {
6663 int c_function(void);
6665 int c_function(void) { return 42; }
6668 update_cxxflags
6670 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
6671 # C++ compiler $cxx works ok with C compiler $cc
6673 else
6674 echo "C++ compiler $cxx does not work with C compiler $cc"
6675 echo "Disabling C++ specific optional code"
6676 cxx=
6678 else
6679 echo "No C++ compiler available; disabling C++ specific optional code"
6680 cxx=
6683 echo_version() {
6684 if test "$1" = "yes" ; then
6685 echo "($2)"
6689 # prepend pixman and ftd flags after all config tests are done
6690 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
6691 QEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
6692 libs_softmmu="$pixman_libs $libs_softmmu"
6694 echo "Install prefix $prefix"
6695 echo "BIOS directory $(eval echo $qemu_datadir)"
6696 echo "firmware path $(eval echo $firmwarepath)"
6697 echo "binary directory $(eval echo $bindir)"
6698 echo "library directory $(eval echo $libdir)"
6699 echo "module directory $(eval echo $qemu_moddir)"
6700 echo "libexec directory $(eval echo $libexecdir)"
6701 echo "include directory $(eval echo $includedir)"
6702 echo "config directory $(eval echo $sysconfdir)"
6703 if test "$mingw32" = "no" ; then
6704 echo "local state directory $(eval echo $local_statedir)"
6705 echo "Manual directory $(eval echo $mandir)"
6706 echo "ELF interp prefix $interp_prefix"
6707 else
6708 echo "local state directory queried at runtime"
6709 echo "Windows SDK $win_sdk"
6711 echo "Build directory $(pwd)"
6712 echo "Source path $source_path"
6713 echo "GIT binary $git"
6714 echo "GIT submodules $git_submodules"
6715 echo "C compiler $cc"
6716 echo "Host C compiler $host_cc"
6717 echo "C++ compiler $cxx"
6718 echo "Objective-C compiler $objcc"
6719 echo "ARFLAGS $ARFLAGS"
6720 echo "CFLAGS $CFLAGS"
6721 echo "QEMU_CFLAGS $QEMU_CFLAGS"
6722 echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
6723 echo "make $make"
6724 echo "install $install"
6725 echo "python $python ($python_version)"
6726 if test "$docs" != "no"; then
6727 echo "sphinx-build $sphinx_build"
6729 echo "genisoimage $genisoimage"
6730 echo "slirp support $slirp $(echo_version $slirp $slirp_version)"
6731 if test "$slirp" != "no" ; then
6732 echo "smbd $smbd"
6734 echo "module support $modules"
6735 echo "alt path mod load $module_upgrades"
6736 echo "host CPU $cpu"
6737 echo "host big endian $bigendian"
6738 echo "target list $target_list"
6739 echo "gprof enabled $gprof"
6740 echo "sparse enabled $sparse"
6741 echo "strip binaries $strip_opt"
6742 echo "profiler $profiler"
6743 echo "static build $static"
6744 if test "$darwin" = "yes" ; then
6745 echo "Cocoa support $cocoa"
6747 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
6748 echo "SDL image support $sdl_image"
6749 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
6750 echo "GTK GL support $gtk_gl"
6751 echo "VTE support $vte $(echo_version $vte $vteversion)"
6752 echo "TLS priority $tls_priority"
6753 echo "GNUTLS support $gnutls"
6754 echo "libgcrypt $gcrypt"
6755 if test "$gcrypt" = "yes"
6756 then
6757 echo " hmac $gcrypt_hmac"
6758 echo " XTS $gcrypt_xts"
6760 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
6761 if test "$nettle" = "yes"
6762 then
6763 echo " XTS $nettle_xts"
6765 echo "libtasn1 $tasn1"
6766 echo "PAM $auth_pam"
6767 echo "iconv support $iconv"
6768 echo "curses support $curses"
6769 echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6770 echo "curl support $curl"
6771 echo "mingw32 support $mingw32"
6772 echo "Audio drivers $audio_drv_list"
6773 echo "Block whitelist (rw) $block_drv_rw_whitelist"
6774 echo "Block whitelist (ro) $block_drv_ro_whitelist"
6775 echo "VirtFS support $virtfs"
6776 echo "Multipath support $mpath"
6777 echo "VNC support $vnc"
6778 if test "$vnc" = "yes" ; then
6779 echo "VNC SASL support $vnc_sasl"
6780 echo "VNC JPEG support $vnc_jpeg"
6781 echo "VNC PNG support $vnc_png"
6783 echo "xen support $xen"
6784 if test "$xen" = "yes" ; then
6785 echo "xen ctrl version $xen_ctrl_version"
6787 echo "brlapi support $brlapi"
6788 echo "Documentation $docs"
6789 echo "PIE $pie"
6790 echo "vde support $vde"
6791 echo "netmap support $netmap"
6792 echo "Linux AIO support $linux_aio"
6793 echo "Linux io_uring support $linux_io_uring"
6794 echo "ATTR/XATTR support $attr"
6795 echo "Install blobs $blobs"
6796 echo "KVM support $kvm"
6797 echo "HAX support $hax"
6798 echo "HVF support $hvf"
6799 echo "WHPX support $whpx"
6800 echo "TCG support $tcg"
6801 if test "$tcg" = "yes" ; then
6802 echo "TCG debug enabled $debug_tcg"
6803 echo "TCG interpreter $tcg_interpreter"
6805 echo "malloc trim support $malloc_trim"
6806 echo "RDMA support $rdma"
6807 echo "PVRDMA support $pvrdma"
6808 echo "fdt support $fdt"
6809 echo "membarrier $membarrier"
6810 echo "preadv support $preadv"
6811 echo "fdatasync $fdatasync"
6812 echo "madvise $madvise"
6813 echo "posix_madvise $posix_madvise"
6814 echo "posix_memalign $posix_memalign"
6815 echo "libcap-ng support $cap_ng"
6816 echo "vhost-net support $vhost_net"
6817 echo "vhost-crypto support $vhost_crypto"
6818 echo "vhost-scsi support $vhost_scsi"
6819 echo "vhost-vsock support $vhost_vsock"
6820 echo "vhost-user support $vhost_user"
6821 echo "vhost-user-fs support $vhost_user_fs"
6822 echo "Trace backends $trace_backends"
6823 if have_backend "simple"; then
6824 echo "Trace output file $trace_file-<pid>"
6826 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6827 echo "rbd support $rbd"
6828 echo "xfsctl support $xfs"
6829 echo "smartcard support $smartcard"
6830 echo "libusb $libusb"
6831 echo "usb net redir $usb_redir"
6832 echo "OpenGL support $opengl"
6833 echo "OpenGL dmabufs $opengl_dmabuf"
6834 echo "libiscsi support $libiscsi"
6835 echo "libnfs support $libnfs"
6836 echo "build guest agent $guest_agent"
6837 echo "QGA VSS support $guest_agent_with_vss"
6838 echo "QGA w32 disk info $guest_agent_ntddscsi"
6839 echo "QGA MSI support $guest_agent_msi"
6840 echo "seccomp support $seccomp"
6841 echo "coroutine backend $coroutine"
6842 echo "coroutine pool $coroutine_pool"
6843 echo "debug stack usage $debug_stack_usage"
6844 echo "mutex debugging $debug_mutex"
6845 echo "crypto afalg $crypto_afalg"
6846 echo "GlusterFS support $glusterfs"
6847 echo "gcov $gcov_tool"
6848 echo "gcov enabled $gcov"
6849 echo "TPM support $tpm"
6850 echo "libssh support $libssh"
6851 echo "QOM debugging $qom_cast_debug"
6852 echo "Live block migration $live_block_migration"
6853 echo "lzo support $lzo"
6854 echo "snappy support $snappy"
6855 echo "bzip2 support $bzip2"
6856 echo "lzfse support $lzfse"
6857 echo "zstd support $zstd"
6858 echo "NUMA host support $numa"
6859 echo "libxml2 $libxml2"
6860 echo "tcmalloc support $tcmalloc"
6861 echo "jemalloc support $jemalloc"
6862 echo "avx2 optimization $avx2_opt"
6863 echo "avx512f optimization $avx512f_opt"
6864 echo "replication support $replication"
6865 echo "VxHS block device $vxhs"
6866 echo "bochs support $bochs"
6867 echo "cloop support $cloop"
6868 echo "dmg support $dmg"
6869 echo "qcow v1 support $qcow1"
6870 echo "vdi support $vdi"
6871 echo "vvfat support $vvfat"
6872 echo "qed support $qed"
6873 echo "parallels support $parallels"
6874 echo "sheepdog support $sheepdog"
6875 echo "capstone $capstone"
6876 echo "libpmem support $libpmem"
6877 echo "libudev $libudev"
6878 echo "default devices $default_devices"
6879 echo "plugin support $plugins"
6880 echo "fuzzing support $fuzzing"
6881 echo "gdb $gdb_bin"
6882 echo "rng-none $rng_none"
6883 echo "Linux keyring $secret_keyring"
6885 if test "$supported_cpu" = "no"; then
6886 echo
6887 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6888 echo
6889 echo "CPU host architecture $cpu support is not currently maintained."
6890 echo "The QEMU project intends to remove support for this host CPU in"
6891 echo "a future release if nobody volunteers to maintain it and to"
6892 echo "provide a build host for our continuous integration setup."
6893 echo "configure has succeeded and you can continue to build, but"
6894 echo "if you care about QEMU on this platform you should contact"
6895 echo "us upstream at qemu-devel@nongnu.org."
6898 if test "$supported_os" = "no"; then
6899 echo
6900 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6901 echo
6902 echo "Host OS $targetos support is not currently maintained."
6903 echo "The QEMU project intends to remove support for this host OS in"
6904 echo "a future release if nobody volunteers to maintain it and to"
6905 echo "provide a build host for our continuous integration setup."
6906 echo "configure has succeeded and you can continue to build, but"
6907 echo "if you care about QEMU on this platform you should contact"
6908 echo "us upstream at qemu-devel@nongnu.org."
6911 config_host_mak="config-host.mak"
6913 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
6915 echo "# Automatically generated by configure - do not modify" > $config_host_mak
6916 echo >> $config_host_mak
6918 echo all: >> $config_host_mak
6919 echo "prefix=$prefix" >> $config_host_mak
6920 echo "bindir=$bindir" >> $config_host_mak
6921 echo "libdir=$libdir" >> $config_host_mak
6922 echo "libexecdir=$libexecdir" >> $config_host_mak
6923 echo "includedir=$includedir" >> $config_host_mak
6924 echo "mandir=$mandir" >> $config_host_mak
6925 echo "sysconfdir=$sysconfdir" >> $config_host_mak
6926 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
6927 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
6928 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
6929 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
6930 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
6931 if test "$mingw32" = "no" ; then
6932 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
6934 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
6935 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
6936 echo "qemu_icondir=$qemu_icondir" >> $config_host_mak
6937 echo "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
6938 echo "libs_cpu=$libs_cpu" >> $config_host_mak
6939 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
6940 echo "GIT=$git" >> $config_host_mak
6941 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6942 echo "GIT_UPDATE=$git_update" >> $config_host_mak
6944 echo "ARCH=$ARCH" >> $config_host_mak
6946 if test "$default_devices" = "yes" ; then
6947 echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6948 else
6949 echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6951 if test "$debug_tcg" = "yes" ; then
6952 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6954 if test "$strip_opt" = "yes" ; then
6955 echo "STRIP=${strip}" >> $config_host_mak
6957 if test "$bigendian" = "yes" ; then
6958 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
6960 if test "$mingw32" = "yes" ; then
6961 echo "CONFIG_WIN32=y" >> $config_host_mak
6962 rc_version=$(cat $source_path/VERSION)
6963 version_major=${rc_version%%.*}
6964 rc_version=${rc_version#*.}
6965 version_minor=${rc_version%%.*}
6966 rc_version=${rc_version#*.}
6967 version_subminor=${rc_version%%.*}
6968 version_micro=0
6969 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6970 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6971 if test "$guest_agent_with_vss" = "yes" ; then
6972 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6973 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6974 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6976 if test "$guest_agent_ntddscsi" = "yes" ; then
6977 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
6979 if test "$guest_agent_msi" = "yes"; then
6980 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
6981 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
6982 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
6983 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
6984 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
6985 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
6986 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
6988 else
6989 echo "CONFIG_POSIX=y" >> $config_host_mak
6992 if test "$linux" = "yes" ; then
6993 echo "CONFIG_LINUX=y" >> $config_host_mak
6996 if test "$darwin" = "yes" ; then
6997 echo "CONFIG_DARWIN=y" >> $config_host_mak
7000 if test "$solaris" = "yes" ; then
7001 echo "CONFIG_SOLARIS=y" >> $config_host_mak
7003 if test "$haiku" = "yes" ; then
7004 echo "CONFIG_HAIKU=y" >> $config_host_mak
7006 if test "$static" = "yes" ; then
7007 echo "CONFIG_STATIC=y" >> $config_host_mak
7009 if test "$profiler" = "yes" ; then
7010 echo "CONFIG_PROFILER=y" >> $config_host_mak
7012 if test "$want_tools" = "yes" ; then
7013 echo "CONFIG_TOOLS=y" >> $config_host_mak
7015 if test "$slirp" != "no"; then
7016 echo "CONFIG_SLIRP=y" >> $config_host_mak
7017 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
7018 echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
7019 echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
7021 if [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
7022 echo "config-host.h: slirp/all" >> $config_host_mak
7024 if test "$vde" = "yes" ; then
7025 echo "CONFIG_VDE=y" >> $config_host_mak
7026 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
7028 if test "$netmap" = "yes" ; then
7029 echo "CONFIG_NETMAP=y" >> $config_host_mak
7031 if test "$l2tpv3" = "yes" ; then
7032 echo "CONFIG_L2TPV3=y" >> $config_host_mak
7034 if test "$gprof" = "yes" ; then
7035 echo "CONFIG_GPROF=y" >> $config_host_mak
7037 if test "$cap_ng" = "yes" ; then
7038 echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak
7040 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
7041 for drv in $audio_drv_list; do
7042 def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
7043 case "$drv" in
7044 alsa | oss | pa | sdl)
7045 echo "$def=m" >> $config_host_mak ;;
7047 echo "$def=y" >> $config_host_mak ;;
7048 esac
7049 done
7050 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
7051 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
7052 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
7053 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
7054 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
7055 echo "JACK_LIBS=$jack_libs" >> $config_host_mak
7056 if test "$audio_win_int" = "yes" ; then
7057 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
7059 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
7060 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
7061 if test "$vnc" = "yes" ; then
7062 echo "CONFIG_VNC=y" >> $config_host_mak
7064 if test "$vnc_sasl" = "yes" ; then
7065 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
7067 if test "$vnc_jpeg" = "yes" ; then
7068 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
7070 if test "$vnc_png" = "yes" ; then
7071 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
7073 if test "$xkbcommon" = "yes" ; then
7074 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
7075 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
7077 if test "$xfs" = "yes" ; then
7078 echo "CONFIG_XFS=y" >> $config_host_mak
7080 qemu_version=$(head $source_path/VERSION)
7081 echo "VERSION=$qemu_version" >>$config_host_mak
7082 echo "PKGVERSION=$pkgversion" >>$config_host_mak
7083 echo "SRC_PATH=$source_path" >> $config_host_mak
7084 echo "TARGET_DIRS=$target_list" >> $config_host_mak
7085 if [ "$docs" = "yes" ] ; then
7086 echo "BUILD_DOCS=yes" >> $config_host_mak
7088 if test "$modules" = "yes"; then
7089 # $shacmd can generate a hash started with digit, which the compiler doesn't
7090 # like as an symbol. So prefix it with an underscore
7091 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
7092 echo "CONFIG_MODULES=y" >> $config_host_mak
7094 if test "$module_upgrades" = "yes"; then
7095 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
7097 if test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
7098 echo "CONFIG_X11=y" >> $config_host_mak
7099 echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
7100 echo "X11_LIBS=$x11_libs" >> $config_host_mak
7102 if test "$sdl" = "yes" ; then
7103 echo "CONFIG_SDL=m" >> $config_host_mak
7104 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
7105 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
7106 if test "$sdl_image" = "yes" ; then
7107 echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
7110 if test "$cocoa" = "yes" ; then
7111 echo "CONFIG_COCOA=y" >> $config_host_mak
7113 if test "$iconv" = "yes" ; then
7114 echo "CONFIG_ICONV=y" >> $config_host_mak
7115 echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
7116 echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
7118 if test "$curses" = "yes" ; then
7119 echo "CONFIG_CURSES=m" >> $config_host_mak
7120 echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
7121 echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
7123 if test "$pipe2" = "yes" ; then
7124 echo "CONFIG_PIPE2=y" >> $config_host_mak
7126 if test "$accept4" = "yes" ; then
7127 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
7129 if test "$splice" = "yes" ; then
7130 echo "CONFIG_SPLICE=y" >> $config_host_mak
7132 if test "$eventfd" = "yes" ; then
7133 echo "CONFIG_EVENTFD=y" >> $config_host_mak
7135 if test "$memfd" = "yes" ; then
7136 echo "CONFIG_MEMFD=y" >> $config_host_mak
7138 if test "$have_usbfs" = "yes" ; then
7139 echo "CONFIG_USBFS=y" >> $config_host_mak
7141 if test "$fallocate" = "yes" ; then
7142 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
7144 if test "$fallocate_punch_hole" = "yes" ; then
7145 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
7147 if test "$fallocate_zero_range" = "yes" ; then
7148 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
7150 if test "$posix_fallocate" = "yes" ; then
7151 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
7153 if test "$sync_file_range" = "yes" ; then
7154 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
7156 if test "$fiemap" = "yes" ; then
7157 echo "CONFIG_FIEMAP=y" >> $config_host_mak
7159 if test "$dup3" = "yes" ; then
7160 echo "CONFIG_DUP3=y" >> $config_host_mak
7162 if test "$ppoll" = "yes" ; then
7163 echo "CONFIG_PPOLL=y" >> $config_host_mak
7165 if test "$prctl_pr_set_timerslack" = "yes" ; then
7166 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
7168 if test "$epoll" = "yes" ; then
7169 echo "CONFIG_EPOLL=y" >> $config_host_mak
7171 if test "$epoll_create1" = "yes" ; then
7172 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
7174 if test "$sendfile" = "yes" ; then
7175 echo "CONFIG_SENDFILE=y" >> $config_host_mak
7177 if test "$timerfd" = "yes" ; then
7178 echo "CONFIG_TIMERFD=y" >> $config_host_mak
7180 if test "$setns" = "yes" ; then
7181 echo "CONFIG_SETNS=y" >> $config_host_mak
7183 if test "$clock_adjtime" = "yes" ; then
7184 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
7186 if test "$syncfs" = "yes" ; then
7187 echo "CONFIG_SYNCFS=y" >> $config_host_mak
7189 if test "$kcov" = "yes" ; then
7190 echo "CONFIG_KCOV=y" >> $config_host_mak
7192 if test "$inotify" = "yes" ; then
7193 echo "CONFIG_INOTIFY=y" >> $config_host_mak
7195 if test "$inotify1" = "yes" ; then
7196 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
7198 if test "$sem_timedwait" = "yes" ; then
7199 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
7201 if test "$strchrnul" = "yes" ; then
7202 echo "HAVE_STRCHRNUL=y" >> $config_host_mak
7204 if test "$st_atim" = "yes" ; then
7205 echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
7207 if test "$byteswap_h" = "yes" ; then
7208 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
7210 if test "$bswap_h" = "yes" ; then
7211 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
7213 if test "$curl" = "yes" ; then
7214 echo "CONFIG_CURL=m" >> $config_host_mak
7215 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
7216 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
7218 if test "$brlapi" = "yes" ; then
7219 echo "CONFIG_BRLAPI=y" >> $config_host_mak
7220 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
7222 if test "$gtk" = "yes" ; then
7223 echo "CONFIG_GTK=m" >> $config_host_mak
7224 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
7225 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
7226 if test "$gtk_gl" = "yes" ; then
7227 echo "CONFIG_GTK_GL=y" >> $config_host_mak
7230 if test "$gio" = "yes" ; then
7231 echo "CONFIG_GIO=y" >> $config_host_mak
7232 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
7233 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
7234 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
7236 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
7237 if test "$gnutls" = "yes" ; then
7238 echo "CONFIG_GNUTLS=y" >> $config_host_mak
7240 if test "$gcrypt" = "yes" ; then
7241 echo "CONFIG_GCRYPT=y" >> $config_host_mak
7242 if test "$gcrypt_hmac" = "yes" ; then
7243 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
7246 if test "$nettle" = "yes" ; then
7247 echo "CONFIG_NETTLE=y" >> $config_host_mak
7248 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
7250 if test "$qemu_private_xts" = "yes" ; then
7251 echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
7253 if test "$tasn1" = "yes" ; then
7254 echo "CONFIG_TASN1=y" >> $config_host_mak
7256 if test "$auth_pam" = "yes" ; then
7257 echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
7259 if test "$have_ifaddrs_h" = "yes" ; then
7260 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
7262 if test "$have_broken_size_max" = "yes" ; then
7263 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
7266 # Work around a system header bug with some kernel/XFS header
7267 # versions where they both try to define 'struct fsxattr':
7268 # xfs headers will not try to redefine structs from linux headers
7269 # if this macro is set.
7270 if test "$have_fsxattr" = "yes" ; then
7271 echo "HAVE_FSXATTR=y" >> $config_host_mak
7273 if test "$have_copy_file_range" = "yes" ; then
7274 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
7276 if test "$vte" = "yes" ; then
7277 echo "CONFIG_VTE=y" >> $config_host_mak
7278 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
7279 echo "VTE_LIBS=$vte_libs" >> $config_host_mak
7281 if test "$virglrenderer" = "yes" ; then
7282 echo "CONFIG_VIRGL=y" >> $config_host_mak
7283 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
7284 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
7286 if test "$xen" = "yes" ; then
7287 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
7288 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
7290 if test "$linux_aio" = "yes" ; then
7291 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
7293 if test "$linux_io_uring" = "yes" ; then
7294 echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
7295 echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
7296 echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
7298 if test "$attr" = "yes" ; then
7299 echo "CONFIG_ATTR=y" >> $config_host_mak
7301 if test "$libattr" = "yes" ; then
7302 echo "CONFIG_LIBATTR=y" >> $config_host_mak
7304 if test "$virtfs" = "yes" ; then
7305 echo "CONFIG_VIRTFS=y" >> $config_host_mak
7307 if test "$mpath" = "yes" ; then
7308 echo "CONFIG_MPATH=y" >> $config_host_mak
7309 if test "$mpathpersist_new_api" = "yes"; then
7310 echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
7313 if test "$vhost_scsi" = "yes" ; then
7314 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
7316 if test "$vhost_net" = "yes" ; then
7317 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
7319 if test "$vhost_net_user" = "yes" ; then
7320 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
7322 if test "$vhost_crypto" = "yes" ; then
7323 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
7325 if test "$vhost_vsock" = "yes" ; then
7326 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
7327 if test "$vhost_user" = "yes" ; then
7328 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
7331 if test "$vhost_kernel" = "yes" ; then
7332 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
7334 if test "$vhost_user" = "yes" ; then
7335 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
7337 if test "$vhost_user_fs" = "yes" ; then
7338 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
7340 if test "$blobs" = "yes" ; then
7341 echo "INSTALL_BLOBS=yes" >> $config_host_mak
7343 if test "$iovec" = "yes" ; then
7344 echo "CONFIG_IOVEC=y" >> $config_host_mak
7346 if test "$preadv" = "yes" ; then
7347 echo "CONFIG_PREADV=y" >> $config_host_mak
7349 if test "$fdt" != "no" ; then
7350 echo "CONFIG_FDT=y" >> $config_host_mak
7352 if test "$membarrier" = "yes" ; then
7353 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
7355 if test "$signalfd" = "yes" ; then
7356 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
7358 if test "$optreset" = "yes" ; then
7359 echo "HAVE_OPTRESET=y" >> $config_host_mak
7361 if test "$tcg" = "yes"; then
7362 echo "CONFIG_TCG=y" >> $config_host_mak
7363 if test "$tcg_interpreter" = "yes" ; then
7364 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
7367 if test "$fdatasync" = "yes" ; then
7368 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
7370 if test "$madvise" = "yes" ; then
7371 echo "CONFIG_MADVISE=y" >> $config_host_mak
7373 if test "$posix_madvise" = "yes" ; then
7374 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
7376 if test "$posix_memalign" = "yes" ; then
7377 echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
7380 if test "$spice" = "yes" ; then
7381 echo "CONFIG_SPICE=y" >> $config_host_mak
7384 if test "$smartcard" = "yes" ; then
7385 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
7386 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
7387 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
7390 if test "$libusb" = "yes" ; then
7391 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
7392 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
7393 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
7396 if test "$usb_redir" = "yes" ; then
7397 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
7398 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
7399 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
7402 if test "$opengl" = "yes" ; then
7403 echo "CONFIG_OPENGL=y" >> $config_host_mak
7404 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
7405 if test "$opengl_dmabuf" = "yes" ; then
7406 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
7410 if test "$gbm" = "yes" ; then
7411 echo "CONFIG_GBM=y" >> $config_host_mak
7412 echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
7413 echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
7417 if test "$malloc_trim" = "yes" ; then
7418 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
7421 if test "$avx2_opt" = "yes" ; then
7422 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
7425 if test "$avx512f_opt" = "yes" ; then
7426 echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
7429 if test "$lzo" = "yes" ; then
7430 echo "CONFIG_LZO=y" >> $config_host_mak
7433 if test "$snappy" = "yes" ; then
7434 echo "CONFIG_SNAPPY=y" >> $config_host_mak
7437 if test "$bzip2" = "yes" ; then
7438 echo "CONFIG_BZIP2=y" >> $config_host_mak
7439 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
7442 if test "$lzfse" = "yes" ; then
7443 echo "CONFIG_LZFSE=y" >> $config_host_mak
7444 echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
7447 if test "$zstd" = "yes" ; then
7448 echo "CONFIG_ZSTD=y" >> $config_host_mak
7451 if test "$libiscsi" = "yes" ; then
7452 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
7453 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
7454 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
7457 if test "$libnfs" = "yes" ; then
7458 echo "CONFIG_LIBNFS=m" >> $config_host_mak
7459 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
7462 if test "$seccomp" = "yes"; then
7463 echo "CONFIG_SECCOMP=y" >> $config_host_mak
7464 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7465 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7468 # XXX: suppress that
7469 if [ "$bsd" = "yes" ] ; then
7470 echo "CONFIG_BSD=y" >> $config_host_mak
7473 if test "$localtime_r" = "yes" ; then
7474 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
7476 if test "$qom_cast_debug" = "yes" ; then
7477 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
7479 if test "$rbd" = "yes" ; then
7480 echo "CONFIG_RBD=m" >> $config_host_mak
7481 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
7482 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7485 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
7486 if test "$coroutine_pool" = "yes" ; then
7487 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
7488 else
7489 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
7492 if test "$debug_stack_usage" = "yes" ; then
7493 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
7496 if test "$crypto_afalg" = "yes" ; then
7497 echo "CONFIG_AF_ALG=y" >> $config_host_mak
7500 if test "$open_by_handle_at" = "yes" ; then
7501 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7504 if test "$linux_magic_h" = "yes" ; then
7505 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7508 if test "$pragma_diagnostic_available" = "yes" ; then
7509 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
7512 if test "$valgrind_h" = "yes" ; then
7513 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
7516 if test "$have_asan_iface_fiber" = "yes" ; then
7517 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7520 if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
7521 echo "CONFIG_TSAN=y" >> $config_host_mak
7524 if test "$has_environ" = "yes" ; then
7525 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
7528 if test "$cpuid_h" = "yes" ; then
7529 echo "CONFIG_CPUID_H=y" >> $config_host_mak
7532 if test "$int128" = "yes" ; then
7533 echo "CONFIG_INT128=y" >> $config_host_mak
7536 if test "$atomic128" = "yes" ; then
7537 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
7540 if test "$cmpxchg128" = "yes" ; then
7541 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7544 if test "$atomic64" = "yes" ; then
7545 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7548 if test "$attralias" = "yes" ; then
7549 echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
7552 if test "$getauxval" = "yes" ; then
7553 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
7556 if test "$glusterfs" = "yes" ; then
7557 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
7558 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
7559 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7562 if test "$glusterfs_xlator_opt" = "yes" ; then
7563 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7566 if test "$glusterfs_discard" = "yes" ; then
7567 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
7570 if test "$glusterfs_fallocate" = "yes" ; then
7571 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7574 if test "$glusterfs_zerofill" = "yes" ; then
7575 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
7578 if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7579 echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7582 if test "$glusterfs_iocb_has_stat" = "yes" ; then
7583 echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
7586 if test "$libssh" = "yes" ; then
7587 echo "CONFIG_LIBSSH=m" >> $config_host_mak
7588 echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7589 echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
7592 if test "$live_block_migration" = "yes" ; then
7593 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7596 if test "$tpm" = "yes"; then
7597 echo 'CONFIG_TPM=y' >> $config_host_mak
7600 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
7601 if have_backend "nop"; then
7602 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
7604 if have_backend "simple"; then
7605 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
7606 # Set the appropriate trace file.
7607 trace_file="\"$trace_file-\" FMT_pid"
7609 if have_backend "log"; then
7610 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
7612 if have_backend "ust"; then
7613 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
7615 if have_backend "dtrace"; then
7616 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
7617 if test "$trace_backend_stap" = "yes" ; then
7618 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
7621 if have_backend "ftrace"; then
7622 if test "$linux" = "yes" ; then
7623 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7624 else
7625 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7628 if have_backend "syslog"; then
7629 if test "$posix_syslog" = "yes" ; then
7630 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
7631 else
7632 feature_not_found "syslog(trace backend)" "syslog not available"
7635 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
7637 if test "$rdma" = "yes" ; then
7638 echo "CONFIG_RDMA=y" >> $config_host_mak
7639 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
7642 if test "$pvrdma" = "yes" ; then
7643 echo "CONFIG_PVRDMA=y" >> $config_host_mak
7646 if test "$have_rtnetlink" = "yes" ; then
7647 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7650 if test "$libxml2" = "yes" ; then
7651 echo "CONFIG_LIBXML2=y" >> $config_host_mak
7652 echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7653 echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7656 if test "$replication" = "yes" ; then
7657 echo "CONFIG_REPLICATION=y" >> $config_host_mak
7660 if test "$have_af_vsock" = "yes" ; then
7661 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
7664 if test "$have_sysmacros" = "yes" ; then
7665 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
7668 if test "$have_static_assert" = "yes" ; then
7669 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
7672 if test "$have_utmpx" = "yes" ; then
7673 echo "HAVE_UTMPX=y" >> $config_host_mak
7675 if test "$have_getrandom" = "yes" ; then
7676 echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7678 if test "$ivshmem" = "yes" ; then
7679 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7681 if test "$capstone" != "no" ; then
7682 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
7684 if test "$debug_mutex" = "yes" ; then
7685 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7688 # Hold two types of flag:
7689 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
7690 # a thread we have a handle to
7691 # CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
7692 # platform
7693 if test "$pthread_setname_np_w_tid" = "yes" ; then
7694 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7695 echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7696 elif test "$pthread_setname_np_wo_tid" = "yes" ; then
7697 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7698 echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
7701 if test "$vxhs" = "yes" ; then
7702 echo "CONFIG_VXHS=y" >> $config_host_mak
7703 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
7706 if test "$libpmem" = "yes" ; then
7707 echo "CONFIG_LIBPMEM=y" >> $config_host_mak
7710 if test "$bochs" = "yes" ; then
7711 echo "CONFIG_BOCHS=y" >> $config_host_mak
7713 if test "$cloop" = "yes" ; then
7714 echo "CONFIG_CLOOP=y" >> $config_host_mak
7716 if test "$dmg" = "yes" ; then
7717 echo "CONFIG_DMG=y" >> $config_host_mak
7719 if test "$qcow1" = "yes" ; then
7720 echo "CONFIG_QCOW1=y" >> $config_host_mak
7722 if test "$vdi" = "yes" ; then
7723 echo "CONFIG_VDI=y" >> $config_host_mak
7725 if test "$vvfat" = "yes" ; then
7726 echo "CONFIG_VVFAT=y" >> $config_host_mak
7728 if test "$qed" = "yes" ; then
7729 echo "CONFIG_QED=y" >> $config_host_mak
7731 if test "$parallels" = "yes" ; then
7732 echo "CONFIG_PARALLELS=y" >> $config_host_mak
7734 if test "$sheepdog" = "yes" ; then
7735 echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
7737 if test "$fuzzing" = "yes" ; then
7738 if test "$have_fuzzer" = "yes"; then
7739 FUZZ_LDFLAGS=" -fsanitize=address,fuzzer"
7740 FUZZ_CFLAGS=" -fsanitize=address,fuzzer"
7741 CFLAGS=" -fsanitize=address,fuzzer-no-link"
7742 else
7743 error_exit "Your compiler doesn't support -fsanitize=address,fuzzer"
7744 exit 1
7748 if test "$plugins" = "yes" ; then
7749 echo "CONFIG_PLUGIN=y" >> $config_host_mak
7750 LIBS="-ldl $LIBS"
7751 # Copy the export object list to the build dir
7752 if test "$ld_dynamic_list" = "yes" ; then
7753 echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
7754 ld_symbols=qemu-plugins-ld.symbols
7755 cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
7756 elif test "$ld_exported_symbols_list" = "yes" ; then
7757 echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
7758 ld64_symbols=qemu-plugins-ld64.symbols
7759 echo "# Automatically generated by configure - do not modify" > $ld64_symbols
7760 grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
7761 sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
7762 else
7763 error_exit \
7764 "If \$plugins=yes, either \$ld_dynamic_list or " \
7765 "\$ld_exported_symbols_list should have been set to 'yes'."
7769 if test -n "$gdb_bin" ; then
7770 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
7773 if test "$secret_keyring" = "yes" ; then
7774 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
7775 if test "$have_keyutils" = "yes" ; then
7776 echo "CONFIG_TEST_SECRET_KEYRING=y" >> $config_host_mak
7780 if test "$tcg_interpreter" = "yes"; then
7781 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
7782 elif test "$ARCH" = "sparc64" ; then
7783 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
7784 elif test "$ARCH" = "s390x" ; then
7785 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
7786 elif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
7787 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
7788 elif test "$ARCH" = "ppc64" ; then
7789 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
7790 elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
7791 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES"
7792 else
7793 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
7796 echo "HELPERS=$helpers" >> $config_host_mak
7797 echo "TOOLS=$tools" >> $config_host_mak
7798 echo "ROMS=$roms" >> $config_host_mak
7799 echo "MAKE=$make" >> $config_host_mak
7800 echo "INSTALL=$install" >> $config_host_mak
7801 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
7802 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
7803 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
7804 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7805 echo "PYTHON=$python" >> $config_host_mak
7806 echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
7807 echo "SPHINX_WERROR=$sphinx_werror" >> $config_host_mak
7808 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
7809 echo "CC=$cc" >> $config_host_mak
7810 if $iasl -h > /dev/null 2>&1; then
7811 echo "IASL=$iasl" >> $config_host_mak
7813 echo "HOST_CC=$host_cc" >> $config_host_mak
7814 echo "CXX=$cxx" >> $config_host_mak
7815 echo "OBJCC=$objcc" >> $config_host_mak
7816 echo "AR=$ar" >> $config_host_mak
7817 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
7818 echo "AS=$as" >> $config_host_mak
7819 echo "CCAS=$ccas" >> $config_host_mak
7820 echo "CPP=$cpp" >> $config_host_mak
7821 echo "OBJCOPY=$objcopy" >> $config_host_mak
7822 echo "LD=$ld" >> $config_host_mak
7823 echo "RANLIB=$ranlib" >> $config_host_mak
7824 echo "NM=$nm" >> $config_host_mak
7825 echo "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
7826 echo "WINDRES=$windres" >> $config_host_mak
7827 echo "CFLAGS=$CFLAGS" >> $config_host_mak
7828 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7829 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
7830 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7831 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7832 if test "$sparse" = "yes" ; then
7833 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
7834 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
7835 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
7836 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
7837 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7839 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
7840 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
7841 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7842 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
7843 echo "LIBS+=$LIBS" >> $config_host_mak
7844 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7845 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7846 echo "EXESUF=$EXESUF" >> $config_host_mak
7847 echo "DSOSUF=$DSOSUF" >> $config_host_mak
7848 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7849 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
7850 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
7851 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
7852 echo "POD2MAN=$POD2MAN" >> $config_host_mak
7853 if test "$gcov" = "yes" ; then
7854 echo "CONFIG_GCOV=y" >> $config_host_mak
7855 echo "GCOV=$gcov_tool" >> $config_host_mak
7858 if test "$libudev" != "no"; then
7859 echo "CONFIG_LIBUDEV=y" >> $config_host_mak
7860 echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
7862 if test "$fuzzing" != "no"; then
7863 echo "CONFIG_FUZZ=y" >> $config_host_mak
7864 echo "FUZZ_CFLAGS=$FUZZ_CFLAGS" >> $config_host_mak
7865 echo "FUZZ_LDFLAGS=$FUZZ_LDFLAGS" >> $config_host_mak
7868 if test "$edk2_blobs" = "yes" ; then
7869 echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
7872 if test "$rng_none" = "yes"; then
7873 echo "CONFIG_RNG_NONE=y" >> $config_host_mak
7876 # use included Linux headers
7877 if test "$linux" = "yes" ; then
7878 mkdir -p linux-headers
7879 case "$cpu" in
7880 i386|x86_64|x32)
7881 linux_arch=x86
7883 ppc|ppc64|ppc64le)
7884 linux_arch=powerpc
7886 s390x)
7887 linux_arch=s390
7889 aarch64)
7890 linux_arch=arm64
7892 mips64)
7893 linux_arch=mips
7896 # For most CPUs the kernel architecture name and QEMU CPU name match.
7897 linux_arch="$cpu"
7899 esac
7900 # For non-KVM architectures we will not have asm headers
7901 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
7902 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
7906 for target in $target_list; do
7907 target_dir="$target"
7908 config_target_mak=$target_dir/config-target.mak
7909 target_name=$(echo $target | cut -d '-' -f 1)
7910 target_aligned_only="no"
7911 case "$target_name" in
7912 alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
7913 target_aligned_only="yes"
7915 esac
7916 target_bigendian="no"
7917 case "$target_name" in
7918 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
7919 target_bigendian="yes"
7921 esac
7922 target_softmmu="no"
7923 target_user_only="no"
7924 target_linux_user="no"
7925 target_bsd_user="no"
7926 case "$target" in
7927 ${target_name}-softmmu)
7928 target_softmmu="yes"
7930 ${target_name}-linux-user)
7931 target_user_only="yes"
7932 target_linux_user="yes"
7934 ${target_name}-bsd-user)
7935 target_user_only="yes"
7936 target_bsd_user="yes"
7939 error_exit "Target '$target' not recognised"
7940 exit 1
7942 esac
7944 mkdir -p $target_dir
7945 echo "# Automatically generated by configure - do not modify" > $config_target_mak
7947 bflt="no"
7948 mttcg="no"
7949 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
7950 gdb_xml_files=""
7952 TARGET_ARCH="$target_name"
7953 TARGET_BASE_ARCH=""
7954 TARGET_ABI_DIR=""
7956 case "$target_name" in
7957 i386)
7958 mttcg="yes"
7959 gdb_xml_files="i386-32bit.xml"
7960 TARGET_SYSTBL_ABI=i386
7962 x86_64)
7963 TARGET_BASE_ARCH=i386
7964 TARGET_SYSTBL_ABI=common,64
7965 mttcg="yes"
7966 gdb_xml_files="i386-64bit.xml"
7968 alpha)
7969 mttcg="yes"
7970 TARGET_SYSTBL_ABI=common
7972 arm|armeb)
7973 TARGET_ARCH=arm
7974 TARGET_SYSTBL_ABI=common,oabi
7975 bflt="yes"
7976 mttcg="yes"
7977 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
7979 aarch64|aarch64_be)
7980 TARGET_ARCH=aarch64
7981 TARGET_BASE_ARCH=arm
7982 bflt="yes"
7983 mttcg="yes"
7984 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
7986 cris)
7988 hppa)
7989 mttcg="yes"
7990 TARGET_SYSTBL_ABI=common,32
7992 lm32)
7994 m68k)
7995 bflt="yes"
7996 gdb_xml_files="cf-core.xml cf-fp.xml m68k-core.xml m68k-fp.xml"
7997 TARGET_SYSTBL_ABI=common
7999 microblaze|microblazeel)
8000 TARGET_ARCH=microblaze
8001 TARGET_SYSTBL_ABI=common
8002 bflt="yes"
8003 echo "TARGET_ABI32=y" >> $config_target_mak
8005 mips|mipsel)
8006 mttcg="yes"
8007 TARGET_ARCH=mips
8008 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
8009 TARGET_SYSTBL_ABI=o32
8011 mipsn32|mipsn32el)
8012 mttcg="yes"
8013 TARGET_ARCH=mips64
8014 TARGET_BASE_ARCH=mips
8015 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
8016 echo "TARGET_ABI32=y" >> $config_target_mak
8017 TARGET_SYSTBL_ABI=n32
8019 mips64|mips64el)
8020 mttcg="no"
8021 TARGET_ARCH=mips64
8022 TARGET_BASE_ARCH=mips
8023 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
8024 TARGET_SYSTBL_ABI=n64
8026 moxie)
8028 nios2)
8030 or1k)
8031 TARGET_ARCH=openrisc
8032 TARGET_BASE_ARCH=openrisc
8034 ppc)
8035 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
8036 TARGET_SYSTBL_ABI=common,nospu,32
8038 ppc64)
8039 TARGET_BASE_ARCH=ppc
8040 TARGET_ABI_DIR=ppc
8041 TARGET_SYSTBL_ABI=common,nospu,64
8042 mttcg=yes
8043 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
8045 ppc64le)
8046 TARGET_ARCH=ppc64
8047 TARGET_BASE_ARCH=ppc
8048 TARGET_ABI_DIR=ppc
8049 TARGET_SYSTBL_ABI=common,nospu,64
8050 mttcg=yes
8051 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
8053 ppc64abi32)
8054 TARGET_ARCH=ppc64
8055 TARGET_BASE_ARCH=ppc
8056 TARGET_ABI_DIR=ppc
8057 TARGET_SYSTBL_ABI=common,nospu,32
8058 echo "TARGET_ABI32=y" >> $config_target_mak
8059 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
8061 riscv32)
8062 TARGET_BASE_ARCH=riscv
8063 TARGET_ABI_DIR=riscv
8064 mttcg=yes
8065 gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-32bit-csr.xml riscv-32bit-virtual.xml"
8067 riscv64)
8068 TARGET_BASE_ARCH=riscv
8069 TARGET_ABI_DIR=riscv
8070 mttcg=yes
8071 gdb_xml_files="riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml"
8074 TARGET_ARCH=rx
8075 bflt="yes"
8076 target_compiler=$cross_cc_rx
8077 gdb_xml_files="rx-core.xml"
8079 sh4|sh4eb)
8080 TARGET_ARCH=sh4
8081 TARGET_SYSTBL_ABI=common
8082 bflt="yes"
8084 sparc)
8085 TARGET_SYSTBL_ABI=common,32
8087 sparc64)
8088 TARGET_BASE_ARCH=sparc
8089 TARGET_SYSTBL_ABI=common,64
8091 sparc32plus)
8092 TARGET_ARCH=sparc64
8093 TARGET_BASE_ARCH=sparc
8094 TARGET_ABI_DIR=sparc
8095 TARGET_SYSTBL_ABI=common,32
8096 echo "TARGET_ABI32=y" >> $config_target_mak
8098 s390x)
8099 TARGET_SYSTBL_ABI=common,64
8100 mttcg=yes
8101 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
8103 tilegx)
8105 tricore)
8107 unicore32)
8109 xtensa|xtensaeb)
8110 TARGET_ARCH=xtensa
8111 TARGET_SYSTBL_ABI=common
8112 bflt="yes"
8113 mttcg="yes"
8116 error_exit "Unsupported target CPU"
8118 esac
8119 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
8120 if [ "$TARGET_BASE_ARCH" = "" ]; then
8121 TARGET_BASE_ARCH=$TARGET_ARCH
8124 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
8126 upper() {
8127 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
8130 target_arch_name="$(upper $TARGET_ARCH)"
8131 echo "TARGET_$target_arch_name=y" >> $config_target_mak
8132 echo "TARGET_NAME=$target_name" >> $config_target_mak
8133 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
8134 if [ "$TARGET_ABI_DIR" = "" ]; then
8135 TARGET_ABI_DIR=$TARGET_ARCH
8137 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
8138 if [ "$HOST_VARIANT_DIR" != "" ]; then
8139 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
8141 if [ "$TARGET_SYSTBL_ABI" != "" ]; then
8142 echo "TARGET_SYSTBL_ABI=$TARGET_SYSTBL_ABI" >> $config_target_mak
8145 if supported_xen_target $target; then
8146 echo "CONFIG_XEN=y" >> $config_target_mak
8147 echo "$target/config-devices.mak: CONFIG_XEN=y" >> $config_host_mak
8148 if test "$xen_pci_passthrough" = yes; then
8149 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
8151 else
8152 echo "$target/config-devices.mak: CONFIG_XEN=n" >> $config_host_mak
8154 if supported_kvm_target $target; then
8155 echo "CONFIG_KVM=y" >> $config_target_mak
8156 echo "$target/config-devices.mak: CONFIG_KVM=y" >> $config_host_mak
8157 else
8158 echo "$target/config-devices.mak: CONFIG_KVM=n" >> $config_host_mak
8160 if supported_hax_target $target; then
8161 echo "CONFIG_HAX=y" >> $config_target_mak
8163 if supported_hvf_target $target; then
8164 echo "CONFIG_HVF=y" >> $config_target_mak
8166 if supported_whpx_target $target; then
8167 echo "CONFIG_WHPX=y" >> $config_target_mak
8169 if test "$target_aligned_only" = "yes" ; then
8170 echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
8172 if test "$target_bigendian" = "yes" ; then
8173 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
8175 if test "$target_softmmu" = "yes" ; then
8176 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
8177 if test "$mttcg" = "yes" ; then
8178 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
8181 if test "$target_user_only" = "yes" ; then
8182 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
8183 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
8185 if test "$target_linux_user" = "yes" ; then
8186 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
8188 list=""
8189 if test ! -z "$gdb_xml_files" ; then
8190 for x in $gdb_xml_files; do
8191 list="$list $source_path/gdb-xml/$x"
8192 done
8193 echo "TARGET_XML_FILES=$list" >> $config_target_mak
8196 if test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
8197 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
8199 if test "$target_bsd_user" = "yes" ; then
8200 echo "CONFIG_BSD_USER=y" >> $config_target_mak
8204 # generate QEMU_CFLAGS/QEMU_LDFLAGS for targets
8206 cflags=""
8207 ldflags=""
8209 disas_config() {
8210 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
8211 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
8214 for i in $ARCH $TARGET_BASE_ARCH ; do
8215 case "$i" in
8216 alpha)
8217 disas_config "ALPHA"
8219 aarch64)
8220 if test -n "${cxx}"; then
8221 disas_config "ARM_A64"
8224 arm)
8225 disas_config "ARM"
8226 if test -n "${cxx}"; then
8227 disas_config "ARM_A64"
8230 cris)
8231 disas_config "CRIS"
8233 hppa)
8234 disas_config "HPPA"
8236 i386|x86_64|x32)
8237 disas_config "I386"
8239 lm32)
8240 disas_config "LM32"
8242 m68k)
8243 disas_config "M68K"
8245 microblaze*)
8246 disas_config "MICROBLAZE"
8248 mips*)
8249 disas_config "MIPS"
8250 if test -n "${cxx}"; then
8251 disas_config "NANOMIPS"
8254 moxie*)
8255 disas_config "MOXIE"
8257 nios2)
8258 disas_config "NIOS2"
8260 or1k)
8261 disas_config "OPENRISC"
8263 ppc*)
8264 disas_config "PPC"
8266 riscv*)
8267 disas_config "RISCV"
8270 disas_config "RX"
8272 s390*)
8273 disas_config "S390"
8275 sh4)
8276 disas_config "SH4"
8278 sparc*)
8279 disas_config "SPARC"
8281 xtensa*)
8282 disas_config "XTENSA"
8284 esac
8285 done
8286 if test "$tcg_interpreter" = "yes" ; then
8287 disas_config "TCI"
8290 case "$ARCH" in
8291 alpha)
8292 # Ensure there's only a single GP
8293 cflags="-msmall-data $cflags"
8295 esac
8297 if test "$gprof" = "yes" ; then
8298 if test "$target_linux_user" = "yes" ; then
8299 cflags="-p $cflags"
8300 ldflags="-p $ldflags"
8302 if test "$target_softmmu" = "yes" ; then
8303 ldflags="-p $ldflags"
8304 echo "GPROF_CFLAGS=-p" >> $config_target_mak
8308 # Newer kernels on s390 check for an S390_PGSTE program header and
8309 # enable the pgste page table extensions in that case. This makes
8310 # the vm.allocate_pgste sysctl unnecessary. We enable this program
8311 # header if
8312 # - we build on s390x
8313 # - we build the system emulation for s390x (qemu-system-s390x)
8314 # - KVM is enabled
8315 # - the linker supports --s390-pgste
8316 if test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
8317 test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
8318 if ld_has --s390-pgste ; then
8319 ldflags="-Wl,--s390-pgste $ldflags"
8323 echo "QEMU_LDFLAGS+=$ldflags" >> $config_target_mak
8324 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
8326 done # for target in $targets
8328 echo "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak
8329 echo "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak
8331 if [ "$fdt" = "git" ]; then
8332 echo "config-host.h: dtc/all" >> $config_host_mak
8334 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
8335 echo "config-host.h: capstone/all" >> $config_host_mak
8337 if test -n "$LIBCAPSTONE"; then
8338 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
8341 if test "$numa" = "yes"; then
8342 echo "CONFIG_NUMA=y" >> $config_host_mak
8345 if test "$ccache_cpp2" = "yes"; then
8346 echo "export CCACHE_CPP2=y" >> $config_host_mak
8349 # If we're using a separate build tree, set it up now.
8350 # DIRS are directories which we simply mkdir in the build tree;
8351 # LINKS are things to symlink back into the source tree
8352 # (these can be both files and directories).
8353 # Caution: do not add files or directories here using wildcards. This
8354 # will result in problems later if a new file matching the wildcard is
8355 # added to the source tree -- nothing will cause configure to be rerun
8356 # so the build tree will be missing the link back to the new file, and
8357 # tests might fail. Prefer to keep the relevant files in their own
8358 # directory and symlink the directory instead.
8359 DIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
8360 DIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
8361 DIRS="$DIRS docs docs/interop fsdev scsi"
8362 DIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
8363 DIRS="$DIRS roms/seabios roms/vgabios"
8364 LINKS="Makefile"
8365 LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
8366 LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
8367 LINKS="$LINKS tests/plugin/Makefile"
8368 LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
8369 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
8370 LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
8371 LINKS="$LINKS pc-bios/qemu-icon.bmp"
8372 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
8373 LINKS="$LINKS tests/acceptance tests/data"
8374 LINKS="$LINKS tests/qemu-iotests/check"
8375 LINKS="$LINKS python"
8376 for bios_file in \
8377 $source_path/pc-bios/*.bin \
8378 $source_path/pc-bios/*.lid \
8379 $source_path/pc-bios/*.rom \
8380 $source_path/pc-bios/*.dtb \
8381 $source_path/pc-bios/*.img \
8382 $source_path/pc-bios/openbios-* \
8383 $source_path/pc-bios/u-boot.* \
8384 $source_path/pc-bios/edk2-*.fd.bz2 \
8385 $source_path/pc-bios/palcode-*
8387 LINKS="$LINKS pc-bios/$(basename $bios_file)"
8388 done
8389 mkdir -p $DIRS
8390 for f in $LINKS ; do
8391 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
8392 symlink "$source_path/$f" "$f"
8394 done
8396 (for i in $cross_cc_vars; do
8397 export $i
8398 done
8399 export target_list source_path use_containers
8400 $source_path/tests/tcg/configure.sh)
8402 # temporary config to build submodules
8403 for rom in seabios vgabios ; do
8404 config_mak=roms/$rom/config.mak
8405 echo "# Automatically generated by configure - do not modify" > $config_mak
8406 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
8407 echo "AS=$as" >> $config_mak
8408 echo "CCAS=$ccas" >> $config_mak
8409 echo "CC=$cc" >> $config_mak
8410 echo "BCC=bcc" >> $config_mak
8411 echo "CPP=$cpp" >> $config_mak
8412 echo "OBJCOPY=objcopy" >> $config_mak
8413 echo "IASL=$iasl" >> $config_mak
8414 echo "LD=$ld" >> $config_mak
8415 echo "RANLIB=$ranlib" >> $config_mak
8416 done
8418 # set up qemu-iotests in this build directory
8419 iotests_common_env="tests/qemu-iotests/common.env"
8421 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
8422 echo >> "$iotests_common_env"
8423 echo "export PYTHON='$python'" >> "$iotests_common_env"
8425 # Save the configure command line for later reuse.
8426 cat <<EOD >config.status
8427 #!/bin/sh
8428 # Generated by configure.
8429 # Run this file to recreate the current configuration.
8430 # Compiler output produced by configure, useful for debugging
8431 # configure, is in config.log if it exists.
8434 preserve_env() {
8435 envname=$1
8437 eval envval=\$$envname
8439 if test -n "$envval"
8440 then
8441 echo "$envname='$envval'" >> config.status
8442 echo "export $envname" >> config.status
8443 else
8444 echo "unset $envname" >> config.status
8448 # Preserve various env variables that influence what
8449 # features/build target configure will detect
8450 preserve_env AR
8451 preserve_env AS
8452 preserve_env CC
8453 preserve_env CPP
8454 preserve_env CXX
8455 preserve_env INSTALL
8456 preserve_env LD
8457 preserve_env LD_LIBRARY_PATH
8458 preserve_env LIBTOOL
8459 preserve_env MAKE
8460 preserve_env NM
8461 preserve_env OBJCOPY
8462 preserve_env PATH
8463 preserve_env PKG_CONFIG
8464 preserve_env PKG_CONFIG_LIBDIR
8465 preserve_env PKG_CONFIG_PATH
8466 preserve_env PYTHON
8467 preserve_env SDL2_CONFIG
8468 preserve_env SMBD
8469 preserve_env STRIP
8470 preserve_env WINDRES
8472 printf "exec" >>config.status
8473 printf " '%s'" "$0" "$@" >>config.status
8474 echo ' "$@"' >>config.status
8475 chmod +x config.status
8477 rm -r "$TMPDIR1"