Merge tag 'v4.2.0-rc0'
[qemu/ar7.git] / configure
blob39b9555e7b656f71c14fca225f0bbc90b343e5c7
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"
106 for arg in $QEMU_CFLAGS; do
107 case $arg in
108 -Wno-override-init|\
109 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
110 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
112 -std=gnu99)
113 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98"
116 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
118 esac
119 done
122 compile_object() {
123 local_cflags="$1"
124 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
127 compile_prog() {
128 local_cflags="$1"
129 local_ldflags="$2"
130 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
133 # symbolically link $1 to $2. Portable version of "ln -sf".
134 symlink() {
135 rm -rf "$2"
136 mkdir -p "$(dirname "$2")"
137 ln -s "$1" "$2"
140 # check whether a command is available to this shell (may be either an
141 # executable or a builtin)
142 has() {
143 type "$1" >/dev/null 2>&1
146 # search for an executable in PATH
147 path_of() {
148 local_command="$1"
149 local_ifs="$IFS"
150 local_dir=""
152 # pathname has a dir component?
153 if [ "${local_command#*/}" != "$local_command" ]; then
154 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
155 echo "$local_command"
156 return 0
159 if [ -z "$local_command" ]; then
160 return 1
163 IFS=:
164 for local_dir in $PATH; do
165 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
166 echo "$local_dir/$local_command"
167 IFS="${local_ifs:-$(printf ' \t\n')}"
168 return 0
170 done
171 # not found
172 IFS="${local_ifs:-$(printf ' \t\n')}"
173 return 1
176 have_backend () {
177 echo "$trace_backends" | grep "$1" >/dev/null
180 glob() {
181 eval test -z '"${1#'"$2"'}"'
184 supported_hax_target() {
185 test "$hax" = "yes" || return 1
186 glob "$1" "*-softmmu" || return 1
187 case "${1%-softmmu}" in
188 i386|x86_64)
189 return 0
191 esac
192 return 1
195 supported_kvm_target() {
196 test "$kvm" = "yes" || return 1
197 glob "$1" "*-softmmu" || return 1
198 case "${1%-softmmu}:$cpu" in
199 arm:arm | aarch64:aarch64 | \
200 i386:i386 | i386:x86_64 | i386:x32 | \
201 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
202 mips:mips | mipsel:mips | \
203 ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | ppc64:ppc64le | \
204 s390x:s390x)
205 return 0
207 esac
208 return 1
211 supported_xen_target() {
212 test "$xen" = "yes" || return 1
213 glob "$1" "*-softmmu" || return 1
214 # Only i386 and x86_64 provide the xenpv machine.
215 case "${1%-softmmu}" in
216 i386|x86_64)
217 return 0
219 esac
220 return 1
223 supported_hvf_target() {
224 test "$hvf" = "yes" || return 1
225 glob "$1" "*-softmmu" || return 1
226 case "${1%-softmmu}" in
227 x86_64)
228 return 0
230 esac
231 return 1
234 supported_whpx_target() {
235 test "$whpx" = "yes" || return 1
236 glob "$1" "*-softmmu" || return 1
237 case "${1%-softmmu}" in
238 i386|x86_64)
239 return 0
241 esac
242 return 1
245 supported_target() {
246 case "$1" in
247 *-softmmu)
249 *-linux-user)
250 if test "$linux" != "yes"; then
251 print_error "Target '$target' is only available on a Linux host"
252 return 1
255 *-bsd-user)
256 if test "$bsd" != "yes"; then
257 print_error "Target '$target' is only available on a BSD host"
258 return 1
262 print_error "Invalid target name '$target'"
263 return 1
265 esac
266 test "$tcg" = "yes" && return 0
267 supported_kvm_target "$1" && return 0
268 supported_xen_target "$1" && return 0
269 supported_hax_target "$1" && return 0
270 supported_hvf_target "$1" && return 0
271 supported_whpx_target "$1" && return 0
272 print_error "TCG disabled, but hardware accelerator not available for '$target'"
273 return 1
277 ld_has() {
278 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
281 # make source path absolute
282 source_path=$(cd "$(dirname -- "$0")"; pwd)
284 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
285 then
286 error_exit "main directory cannot contain spaces nor colons"
289 # default parameters
290 cpu=""
291 iasl="iasl"
292 interp_prefix="/usr/gnemul/qemu-%M"
293 static="no"
294 cross_prefix=""
295 audio_drv_list=""
296 block_drv_rw_whitelist=""
297 block_drv_ro_whitelist=""
298 host_cc="cc"
299 libs_cpu=""
300 libs_softmmu=""
301 libs_tools=""
302 audio_win_int=""
303 libs_qga=""
304 debug_info="yes"
305 stack_protector=""
307 if test -e "$source_path/.git"
308 then
309 git_update=yes
310 git_submodules="ui/keycodemapdb"
311 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
312 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
313 else
314 git_update=no
315 git_submodules=""
317 if ! test -f "$source_path/ui/keycodemapdb/README"
318 then
319 echo
320 echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
321 echo
322 echo "This is not a GIT checkout but module content appears to"
323 echo "be missing. Do not use 'git archive' or GitHub download links"
324 echo "to acquire QEMU source archives. Non-GIT builds are only"
325 echo "supported with source archives linked from:"
326 echo
327 echo " https://www.qemu.org/download/#source"
328 echo
329 echo "Developers working with GIT can use scripts/archive-source.sh"
330 echo "if they need to create valid source archives."
331 echo
332 exit 1
335 git="git"
337 # Don't accept a target_list environment variable.
338 unset target_list
339 unset target_list_exclude
341 # Default value for a variable defining feature "foo".
342 # * foo="no" feature will only be used if --enable-foo arg is given
343 # * foo="" feature will be searched for, and if found, will be used
344 # unless --disable-foo is given
345 # * foo="yes" this value will only be set by --enable-foo flag.
346 # feature will searched for,
347 # if not found, configure exits with error
349 # Always add --enable-foo and --disable-foo command line args.
350 # Distributions want to ensure that several features are compiled in, and it
351 # is impossible without a --enable-foo that exits if a feature is not found.
353 bluez=""
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 cap_ng=""
376 attr=""
377 libattr=""
378 xfs=""
379 tcg="yes"
380 membarrier=""
381 vhost_net=""
382 vhost_crypto=""
383 vhost_scsi=""
384 vhost_vsock=""
385 vhost_user=""
386 vhost_user_fs=""
387 kvm="no"
388 hax="no"
389 hvf="no"
390 whpx="no"
391 rdma=""
392 pvrdma=""
393 gprof="no"
394 debug_tcg="no"
395 debug="no"
396 sanitizers="no"
397 fortify_source=""
398 strip_opt="yes"
399 tcg_interpreter="no"
400 bigendian="no"
401 mingw32="no"
402 gcov="no"
403 gcov_tool="gcov"
404 EXESUF=""
405 DSOSUF=".so"
406 LDFLAGS_SHARED="-shared"
407 modules="no"
408 prefix="/usr/local"
409 mandir="\${prefix}/share/man"
410 datadir="\${prefix}/share"
411 firmwarepath="\${prefix}/share/qemu-firmware"
412 qemu_docdir="\${prefix}/share/doc/qemu"
413 bindir="\${prefix}/bin"
414 libdir="\${prefix}/lib"
415 libexecdir="\${prefix}/libexec"
416 includedir="\${prefix}/include"
417 sysconfdir="\${prefix}/etc"
418 local_statedir="\${prefix}/var"
419 confsuffix="/qemu"
420 slirp=""
421 oss_lib=""
422 bsd="no"
423 haiku="no"
424 linux="no"
425 solaris="no"
426 profiler="no"
427 cocoa="no"
428 softmmu="yes"
429 linux_user="no"
430 bsd_user="no"
431 blobs="yes"
432 pkgversion=""
433 pie=""
434 qom_cast_debug="yes"
435 trace_backends="log"
436 trace_file="trace"
437 spice=""
438 rbd=""
439 smartcard=""
440 libusb=""
441 usb_redir=""
442 opengl=""
443 opengl_dmabuf="no"
444 cpuid_h="no"
445 avx2_opt=""
446 zlib="yes"
447 capstone=""
448 lzo=""
449 snappy=""
450 bzip2=""
451 lzfse=""
452 guest_agent=""
453 guest_agent_with_vss="no"
454 guest_agent_ntddscsi="no"
455 guest_agent_msi=""
456 vss_win32_sdk=""
457 win_sdk="no"
458 want_tools="yes"
459 libiscsi=""
460 libnfs=""
461 coroutine=""
462 coroutine_pool=""
463 debug_stack_usage="no"
464 crypto_afalg="no"
465 seccomp=""
466 glusterfs=""
467 glusterfs_xlator_opt="no"
468 glusterfs_discard="no"
469 glusterfs_fallocate="no"
470 glusterfs_zerofill="no"
471 glusterfs_ftruncate_has_stat="no"
472 glusterfs_iocb_has_stat="no"
473 gtk=""
474 gtk_gl="no"
475 tls_priority="NORMAL"
476 gnutls=""
477 nettle=""
478 nettle_xts="no"
479 gcrypt=""
480 gcrypt_hmac="no"
481 gcrypt_xts="no"
482 qemu_private_xts="yes"
483 auth_pam=""
484 vte=""
485 virglrenderer=""
486 tpm=""
487 libssh=""
488 live_block_migration="yes"
489 numa=""
490 tcmalloc="no"
491 jemalloc="no"
492 replication="yes"
493 vxhs=""
494 bochs="yes"
495 cloop="yes"
496 dmg="yes"
497 qcow1="yes"
498 vdi="yes"
499 vvfat="yes"
500 qed="yes"
501 parallels="yes"
502 sheepdog="yes"
503 libxml2=""
504 debug_mutex="no"
505 libpmem=""
506 default_devices="yes"
507 plugins="no"
509 supported_cpu="no"
510 supported_os="no"
511 bogus_os="no"
512 malloc_trim=""
514 # parse CC options first
515 for opt do
516 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
517 case "$opt" in
518 --cross-prefix=*) cross_prefix="$optarg"
520 --cc=*) CC="$optarg"
522 --cxx=*) CXX="$optarg"
524 --cpu=*) cpu="$optarg"
526 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
528 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
530 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
531 EXTRA_LDFLAGS="$optarg"
533 --enable-debug-info) debug_info="yes"
535 --disable-debug-info) debug_info="no"
537 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
539 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
540 eval "cross_cc_cflags_${cc_arch}=\$optarg"
541 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
543 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
544 cc_archs="$cc_archs $cc_arch"
545 eval "cross_cc_${cc_arch}=\$optarg"
546 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
548 esac
549 done
550 # OS specific
551 # Using uname is really, really broken. Once we have the right set of checks
552 # we can eliminate its usage altogether.
554 # Preferred compiler:
555 # ${CC} (if set)
556 # ${cross_prefix}gcc (if cross-prefix specified)
557 # system compiler
558 if test -z "${CC}${cross_prefix}"; then
559 cc="$host_cc"
560 else
561 cc="${CC-${cross_prefix}gcc}"
564 if test -z "${CXX}${cross_prefix}"; then
565 cxx="c++"
566 else
567 cxx="${CXX-${cross_prefix}g++}"
570 ar="${AR-${cross_prefix}ar}"
571 as="${AS-${cross_prefix}as}"
572 ccas="${CCAS-$cc}"
573 cpp="${CPP-$cc -E}"
574 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
575 ld="${LD-${cross_prefix}ld}"
576 ranlib="${RANLIB-${cross_prefix}ranlib}"
577 nm="${NM-${cross_prefix}nm}"
578 strip="${STRIP-${cross_prefix}strip}"
579 windres="${WINDRES-${cross_prefix}windres}"
580 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
581 query_pkg_config() {
582 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
584 pkg_config=query_pkg_config
585 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
587 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
588 ARFLAGS="${ARFLAGS-rv}"
590 # default flags for all hosts
591 # We use -fwrapv to tell the compiler that we require a C dialect where
592 # left shift of signed integers is well defined and has the expected
593 # 2s-complement style results. (Both clang and gcc agree that it
594 # provides these semantics.)
595 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS"
596 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
597 QEMU_CFLAGS="-Wimplicit-fallthrough=2 $QEMU_CFLAGS"
598 QEMU_CFLAGS="-Wmissing-format-attribute $QEMU_CFLAGS"
599 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
600 QEMU_CFLAGS="-Wno-unused-parameter $QEMU_CFLAGS"
601 QEMU_CFLAGS="-Wno-missing-field-initializers $QEMU_CFLAGS"
602 QEMU_CFLAGS="-Wno-sign-compare $QEMU_CFLAGS"
603 QEMU_CFLAGS="-Wno-override-init $QEMU_CFLAGS"
604 QEMU_CFLAGS="-Wno-error=cast-function-type $QEMU_CFLAGS"
605 QEMU_CFLAGS="-Wno-error=format $QEMU_CFLAGS"
606 QEMU_CFLAGS="-Wno-error=format-extra-args $QEMU_CFLAGS"
607 QEMU_CFLAGS="-Wno-error=implicit-fallthrough $QEMU_CFLAGS"
608 QEMU_CFLAGS="-Wno-error=parentheses $QEMU_CFLAGS"
609 QEMU_CFLAGS="-Wextra $QEMU_CFLAGS"
610 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
611 QEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
612 if test "$debug_info" = "yes"; then
613 CFLAGS="-g $CFLAGS"
614 LDFLAGS="-g $LDFLAGS"
617 #cc_macros=$($cc $QEMU_CFLAGS -E -dD - </dev/null)
619 # running configure in the source tree?
620 # we know that's the case if configure is there.
621 if test -f "./configure"; then
622 pwd_is_source_path="y"
623 else
624 pwd_is_source_path="n"
627 check_define() {
628 rm -f $TMPC
629 cat > $TMPC <<EOF
630 #if !defined($1)
631 #error $1 not defined
632 #endif
633 int main(void) { return 0; }
635 compile_object
638 check_include() {
639 cat > $TMPC <<EOF
640 #include <$1>
641 int main(void) { return 0; }
643 compile_object
646 write_c_skeleton() {
647 cat > $TMPC <<EOF
648 int main(void) { return 0; }
652 if check_define __linux__ ; then
653 targetos="Linux"
654 elif check_define _WIN32 ; then
655 targetos='MINGW32'
656 elif check_define __OpenBSD__ ; then
657 targetos='OpenBSD'
658 elif check_define __sun__ ; then
659 targetos='SunOS'
660 elif check_define __HAIKU__ ; then
661 targetos='Haiku'
662 elif check_define __FreeBSD__ ; then
663 targetos='FreeBSD'
664 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
665 targetos='GNU/kFreeBSD'
666 elif check_define __DragonFly__ ; then
667 targetos='DragonFly'
668 elif check_define __NetBSD__; then
669 targetos='NetBSD'
670 elif check_define __APPLE__; then
671 targetos='Darwin'
672 else
673 # This is a fatal error, but don't report it yet, because we
674 # might be going to just print the --help text, or it might
675 # be the result of a missing compiler.
676 targetos='bogus'
677 bogus_os='yes'
680 # Some host OSes need non-standard checks for which CPU to use.
681 # Note that these checks are broken for cross-compilation: if you're
682 # cross-compiling to one of these OSes then you'll need to specify
683 # the correct CPU with the --cpu option.
684 case $targetos in
685 Darwin)
686 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
687 # run 64-bit userspace code.
688 # If the user didn't specify a CPU explicitly and the kernel says this is
689 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
690 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
691 cpu="x86_64"
694 SunOS)
695 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
696 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
697 cpu="x86_64"
699 esac
701 if test ! -z "$cpu" ; then
702 # command line argument
704 elif check_define __i386__ ; then
705 cpu="i386"
706 elif check_define __x86_64__ ; then
707 if check_define __ILP32__ ; then
708 cpu="x32"
709 else
710 cpu="x86_64"
712 elif check_define __sparc__ ; then
713 if check_define __arch64__ ; then
714 cpu="sparc64"
715 else
716 cpu="sparc"
718 elif check_define _ARCH_PPC ; then
719 if check_define _ARCH_PPC64 ; then
720 if check_define _LITTLE_ENDIAN ; then
721 cpu="ppc64le"
722 else
723 cpu="ppc64"
725 else
726 cpu="ppc"
728 elif check_define __mips__ ; then
729 if check_define __mips64 ; then
730 cpu="mips64"
731 else
732 cpu="mips"
734 elif check_define __s390__ ; then
735 if check_define __s390x__ ; then
736 cpu="s390x"
737 else
738 cpu="s390"
740 elif check_define __riscv ; then
741 if check_define _LP64 ; then
742 cpu="riscv64"
743 else
744 cpu="riscv32"
746 elif check_define __arm__ ; then
747 cpu="arm"
748 elif check_define __aarch64__ ; then
749 cpu="aarch64"
750 else
751 cpu=$(uname -m)
754 ARCH=
755 # Normalise host CPU name and set ARCH.
756 # Note that this case should only have supported host CPUs, not guests.
757 case "$cpu" in
758 ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
759 supported_cpu="yes"
761 ppc64le)
762 ARCH="ppc64"
763 supported_cpu="yes"
765 i386|i486|i586|i686|i86pc|BePC)
766 cpu="i386"
767 supported_cpu="yes"
769 x86_64|amd64)
770 cpu="x86_64"
771 supported_cpu="yes"
773 armv*b|armv*l|arm)
774 cpu="arm"
775 supported_cpu="yes"
777 aarch64)
778 cpu="aarch64"
779 supported_cpu="yes"
781 mips*)
782 cpu="mips"
783 if check_define __MIPSEL__ ; then
784 cpu="${cpu}el"
786 supported_cpu="yes"
788 sparc|sun4[cdmuv])
789 cpu="sparc"
790 supported_cpu="yes"
792 sh4)
793 cpu="sh4"
796 # This will result in either an error or falling back to TCI later
797 ARCH=unknown
799 esac
800 if test -z "$ARCH"; then
801 ARCH="$cpu"
804 # OS specific
806 # host *BSD for user mode
807 HOST_VARIANT_DIR=""
809 case $targetos in
810 MINGW32*)
811 mingw32="yes"
812 hax="yes"
813 vhost_user="no"
814 audio_possible_drivers="dsound sdl"
815 if check_include dsound.h; then
816 audio_drv_list="dsound"
817 else
818 audio_drv_list=""
820 QEMU_INCLUDES="-I\$(SRC_PATH)/hosts/w32/include $QEMU_INCLUDES"
821 supported_os="yes"
823 GNU/kFreeBSD)
824 bsd="yes"
825 audio_drv_list="oss try-sdl"
826 audio_possible_drivers="oss sdl pa"
828 FreeBSD)
829 bsd="yes"
830 make="${MAKE-gmake}"
831 audio_drv_list="oss try-sdl"
832 audio_possible_drivers="oss sdl pa"
833 # needed for kinfo_getvmmap(3) in libutil.h
834 LIBS="-lutil $LIBS"
835 # needed for kinfo_getproc
836 libs_qga="-lutil $libs_qga"
837 netmap="" # enable netmap autodetect
838 HOST_VARIANT_DIR="freebsd"
839 supported_os="yes"
841 DragonFly)
842 bsd="yes"
843 make="${MAKE-gmake}"
844 audio_drv_list="oss try-sdl"
845 audio_possible_drivers="oss sdl pa"
846 HOST_VARIANT_DIR="dragonfly"
848 NetBSD)
849 bsd="yes"
850 hax="yes"
851 make="${MAKE-gmake}"
852 audio_drv_list="oss try-sdl"
853 audio_possible_drivers="oss sdl"
854 oss_lib="-lossaudio"
855 HOST_VARIANT_DIR="netbsd"
856 supported_os="yes"
858 OpenBSD)
859 bsd="yes"
860 make="${MAKE-gmake}"
861 audio_drv_list="try-sdl"
862 audio_possible_drivers="sdl"
863 HOST_VARIANT_DIR="openbsd"
864 supported_os="yes"
866 Darwin)
867 bsd="yes"
868 darwin="yes"
869 hax="yes"
870 hvf="yes"
871 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
872 if [ "$cpu" = "x86_64" ] ; then
873 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
874 LDFLAGS="-arch x86_64 $LDFLAGS"
876 cocoa="yes"
877 audio_drv_list="coreaudio try-sdl"
878 audio_possible_drivers="coreaudio sdl"
879 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
880 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
881 # Disable attempts to use ObjectiveC features in os/object.h since they
882 # won't work when we're compiling with gcc as a C compiler.
883 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
884 HOST_VARIANT_DIR="darwin"
885 supported_os="yes"
887 SunOS)
888 solaris="yes"
889 make="${MAKE-gmake}"
890 install="${INSTALL-ginstall}"
891 smbd="${SMBD-/usr/sfw/sbin/smbd}"
892 if test -f /usr/include/sys/soundcard.h ; then
893 audio_drv_list="oss try-sdl"
895 audio_possible_drivers="oss sdl"
896 # needed for CMSG_ macros in sys/socket.h
897 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
898 # needed for TIOCWIN* defines in termios.h
899 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
900 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
901 solarisnetlibs="-lsocket -lnsl -lresolv"
902 LIBS="$solarisnetlibs $LIBS"
903 libs_qga="$solarisnetlibs $libs_qga"
905 Haiku)
906 haiku="yes"
907 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
908 LIBS="-lposix_error_mapper -lnetwork $LIBS"
910 Linux)
911 audio_drv_list="try-pa oss"
912 audio_possible_drivers="oss alsa sdl pa"
913 linux="yes"
914 linux_user="yes"
915 kvm="yes"
916 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
917 supported_os="yes"
918 libudev="yes"
920 esac
922 if [ "$bsd" = "yes" ] ; then
923 if [ "$darwin" != "yes" ] ; then
924 bsd_user="yes"
928 : ${make=${MAKE-make}}
929 : ${install=${INSTALL-install}}
930 # We prefer python 3.x. A bare 'python' is traditionally
931 # python 2.x, but some distros have it as python 3.x, so
932 # we check that before python2
933 python=
934 for binary in "${PYTHON-python3}" python python2
936 if has "$binary"
937 then
938 python="$binary"
939 break
941 done
942 : ${smbd=${SMBD-/usr/sbin/smbd}}
944 # Default objcc to clang if available, otherwise use CC
945 if has clang; then
946 objcc=clang
947 else
948 objcc="$cc"
951 if test "$mingw32" = "yes" ; then
952 EXESUF=".exe"
953 DSOSUF=".dll"
954 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
955 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
956 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
957 # MinGW-w64 needs _POSIX defined.
958 QEMU_CFLAGS="-D_POSIX=1 $QEMU_CFLAGS"
959 # MinGW needs -mthreads for TLS and macro _MT.
960 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
961 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
962 write_c_skeleton;
963 if compile_prog "" "-liberty" ; then
964 LIBS="-liberty $LIBS"
966 prefix="c:/Program Files/QEMU"
967 mandir="\${prefix}"
968 datadir="\${prefix}"
969 qemu_docdir="\${prefix}"
970 bindir="\${prefix}"
971 sysconfdir="\${prefix}"
972 local_statedir=
973 confsuffix=""
974 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
977 werror=""
979 for opt do
980 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
981 case "$opt" in
982 --help|-h) show_help=yes
984 --version|-V) exec cat $source_path/VERSION
986 --prefix=*) prefix="$optarg"
988 --interp-prefix=*) interp_prefix="$optarg"
990 --cross-prefix=*)
992 --cc=*)
994 --host-cc=*) host_cc="$optarg"
996 --cxx=*)
998 --iasl=*) iasl="$optarg"
1000 --objcc=*) objcc="$optarg"
1002 --make=*) make="$optarg"
1004 --install=*) install="$optarg"
1006 --python=*) python="$optarg"
1008 --gcov=*) gcov_tool="$optarg"
1010 --smbd=*) smbd="$optarg"
1012 --extra-cflags=*)
1014 --extra-cxxflags=*)
1016 --extra-ldflags=*)
1018 --enable-debug-info)
1020 --disable-debug-info)
1022 --cross-cc-*)
1024 --enable-modules)
1025 modules="yes"
1027 --disable-modules)
1028 modules="no"
1030 --cpu=*)
1032 --target-list=*) target_list="$optarg"
1033 if test "$target_list_exclude"; then
1034 error_exit "Can't mix --target-list with --target-list-exclude"
1037 --target-list-exclude=*) target_list_exclude="$optarg"
1038 if test "$target_list"; then
1039 error_exit "Can't mix --target-list-exclude with --target-list"
1042 --enable-trace-backends=*) trace_backends="$optarg"
1044 # XXX: backwards compatibility
1045 --enable-trace-backend=*) trace_backends="$optarg"
1047 --with-trace-file=*) trace_file="$optarg"
1049 --with-default-devices) default_devices="yes"
1051 --without-default-devices) default_devices="no"
1053 --enable-gprof) gprof="yes"
1055 --enable-gcov) gcov="yes"
1057 --static)
1058 static="yes"
1059 LDFLAGS="-static $LDFLAGS"
1060 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
1062 --mandir=*) mandir="$optarg"
1064 --bindir=*) bindir="$optarg"
1066 --libdir=*) libdir="$optarg"
1068 --libexecdir=*) libexecdir="$optarg"
1070 --includedir=*) includedir="$optarg"
1072 --datadir=*) datadir="$optarg"
1074 --with-confsuffix=*) confsuffix="$optarg"
1076 --docdir=*) qemu_docdir="$optarg"
1078 --sysconfdir=*) sysconfdir="$optarg"
1080 --localstatedir=*) local_statedir="$optarg"
1082 --firmwarepath=*) firmwarepath="$optarg"
1084 --host=*|--build=*|\
1085 --disable-dependency-tracking|\
1086 --sbindir=*|--sharedstatedir=*|\
1087 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1088 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1089 # These switches are silently ignored, for compatibility with
1090 # autoconf-generated configure scripts. This allows QEMU's
1091 # configure to be used by RPM and similar macros that set
1092 # lots of directory switches by default.
1094 --disable-sdl) sdl="no"
1096 --enable-sdl) sdl="yes"
1098 --disable-sdl-image) sdl_image="no"
1100 --enable-sdl-image) sdl_image="yes"
1102 --disable-qom-cast-debug) qom_cast_debug="no"
1104 --enable-qom-cast-debug) qom_cast_debug="yes"
1106 --disable-virtfs) virtfs="no"
1108 --enable-virtfs) virtfs="yes"
1110 --disable-mpath) mpath="no"
1112 --enable-mpath) mpath="yes"
1114 --disable-vnc) vnc="no"
1116 --enable-vnc) vnc="yes"
1118 --oss-lib=*) oss_lib="$optarg"
1120 --audio-drv-list=*) audio_drv_list="$optarg"
1122 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1124 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1126 --enable-debug-tcg) debug_tcg="yes"
1128 --disable-debug-tcg) debug_tcg="no"
1130 --enable-debug)
1131 # Enable debugging options that aren't excessively noisy
1132 debug_tcg="yes"
1133 debug_mutex="yes"
1134 debug="yes"
1135 strip_opt="no"
1136 fortify_source="no"
1138 --enable-sanitizers) sanitizers="yes"
1140 --disable-sanitizers) sanitizers="no"
1142 --enable-sparse) sparse="yes"
1144 --disable-sparse) sparse="no"
1146 --disable-strip) strip_opt="no"
1148 --disable-vnc-sasl) vnc_sasl="no"
1150 --enable-vnc-sasl) vnc_sasl="yes"
1152 --disable-vnc-jpeg) vnc_jpeg="no"
1154 --enable-vnc-jpeg) vnc_jpeg="yes"
1156 --disable-vnc-png) vnc_png="no"
1158 --enable-vnc-png) vnc_png="yes"
1160 --disable-slirp) slirp="no"
1162 --enable-slirp=git) slirp="git"
1164 --enable-slirp=system) slirp="system"
1166 --disable-vde) vde="no"
1168 --enable-vde) vde="yes"
1170 --disable-netmap) netmap="no"
1172 --enable-netmap) netmap="yes"
1174 --disable-xen) xen="no"
1176 --enable-xen) xen="yes"
1178 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1180 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1182 --disable-brlapi) brlapi="no"
1184 --enable-brlapi) brlapi="yes"
1186 --disable-bluez) bluez="no"
1188 --enable-bluez) bluez="yes"
1190 --disable-kvm) kvm="no"
1192 --enable-kvm) kvm="yes"
1194 --disable-hax) hax="no"
1196 --enable-hax) hax="yes"
1198 --disable-hvf) hvf="no"
1200 --enable-hvf) hvf="yes"
1202 --disable-whpx) whpx="no"
1204 --enable-whpx) whpx="yes"
1206 --disable-tcg-interpreter) tcg_interpreter="no"
1208 --enable-tcg-interpreter) tcg_interpreter="yes"
1210 --disable-cap-ng) cap_ng="no"
1212 --enable-cap-ng) cap_ng="yes"
1214 --disable-tcg) tcg="no"
1216 --enable-tcg) tcg="yes"
1218 --disable-malloc-trim) malloc_trim="no"
1220 --enable-malloc-trim) malloc_trim="yes"
1222 --disable-spice) spice="no"
1224 --enable-spice) spice="yes"
1226 --disable-libiscsi) libiscsi="no"
1228 --enable-libiscsi) libiscsi="yes"
1230 --disable-libnfs) libnfs="no"
1232 --enable-libnfs) libnfs="yes"
1234 --enable-profiler) profiler="yes"
1236 --disable-cocoa) cocoa="no"
1238 --enable-cocoa)
1239 cocoa="yes" ;
1240 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1242 --disable-system) softmmu="no"
1244 --enable-system) softmmu="yes"
1246 --disable-user)
1247 linux_user="no" ;
1248 bsd_user="no" ;
1250 --enable-user) ;;
1251 --disable-linux-user) linux_user="no"
1253 --enable-linux-user) linux_user="yes"
1255 --disable-bsd-user) bsd_user="no"
1257 --enable-bsd-user) bsd_user="yes"
1259 --enable-pie) pie="yes"
1261 --disable-pie) pie="no"
1263 --enable-werror) werror="yes"
1265 --disable-werror) werror="no"
1267 --enable-stack-protector) stack_protector="yes"
1269 --disable-stack-protector) stack_protector="no"
1271 --disable-curses) curses="no"
1273 --enable-curses) curses="yes"
1275 --disable-iconv) iconv="no"
1277 --enable-iconv) iconv="yes"
1279 --disable-curl) curl="no"
1281 --enable-curl) curl="yes"
1283 --disable-fdt) fdt="no"
1285 --enable-fdt) fdt="yes"
1287 --disable-linux-aio) linux_aio="no"
1289 --enable-linux-aio) linux_aio="yes"
1291 --disable-attr) attr="no"
1293 --enable-attr) attr="yes"
1295 --disable-membarrier) membarrier="no"
1297 --enable-membarrier) membarrier="yes"
1299 --disable-blobs) blobs="no"
1301 --with-pkgversion=*) pkgversion="$optarg"
1303 --with-coroutine=*) coroutine="$optarg"
1305 --disable-coroutine-pool) coroutine_pool="no"
1307 --enable-coroutine-pool) coroutine_pool="yes"
1309 --enable-debug-stack-usage) debug_stack_usage="yes"
1311 --enable-crypto-afalg) crypto_afalg="yes"
1313 --disable-crypto-afalg) crypto_afalg="no"
1315 --disable-docs) docs="no"
1317 --enable-docs) docs="yes"
1319 --disable-vhost-net) vhost_net="no"
1321 --enable-vhost-net) vhost_net="yes"
1323 --disable-vhost-crypto) vhost_crypto="no"
1325 --enable-vhost-crypto) vhost_crypto="yes"
1327 --disable-vhost-scsi) vhost_scsi="no"
1329 --enable-vhost-scsi) vhost_scsi="yes"
1331 --disable-vhost-vsock) vhost_vsock="no"
1333 --enable-vhost-vsock) vhost_vsock="yes"
1335 --disable-vhost-user-fs) vhost_user_fs="no"
1337 --enable-vhost-user-fs) vhost_user_fs="yes"
1339 --disable-opengl) opengl="no"
1341 --enable-opengl) opengl="yes"
1343 --disable-rbd) rbd="no"
1345 --enable-rbd) rbd="yes"
1347 --disable-xfsctl) xfs="no"
1349 --enable-xfsctl) xfs="yes"
1351 --disable-smartcard) smartcard="no"
1353 --enable-smartcard) smartcard="yes"
1355 --disable-libusb) libusb="no"
1357 --enable-libusb) libusb="yes"
1359 --disable-usb-redir) usb_redir="no"
1361 --enable-usb-redir) usb_redir="yes"
1363 --disable-zlib-test) zlib="no"
1365 --disable-lzo) lzo="no"
1367 --enable-lzo) lzo="yes"
1369 --disable-snappy) snappy="no"
1371 --enable-snappy) snappy="yes"
1373 --disable-bzip2) bzip2="no"
1375 --enable-bzip2) bzip2="yes"
1377 --enable-lzfse) lzfse="yes"
1379 --disable-lzfse) lzfse="no"
1381 --enable-guest-agent) guest_agent="yes"
1383 --disable-guest-agent) guest_agent="no"
1385 --enable-guest-agent-msi) guest_agent_msi="yes"
1387 --disable-guest-agent-msi) guest_agent_msi="no"
1389 --with-vss-sdk) vss_win32_sdk=""
1391 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1393 --without-vss-sdk) vss_win32_sdk="no"
1395 --with-win-sdk) win_sdk=""
1397 --with-win-sdk=*) win_sdk="$optarg"
1399 --without-win-sdk) win_sdk="no"
1401 --enable-tools) want_tools="yes"
1403 --disable-tools) want_tools="no"
1405 --enable-seccomp) seccomp="yes"
1407 --disable-seccomp) seccomp="no"
1409 --disable-glusterfs) glusterfs="no"
1411 --disable-avx2) avx2_opt="no"
1413 --enable-avx2) avx2_opt="yes"
1415 --enable-glusterfs) glusterfs="yes"
1417 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1418 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1420 --enable-vhdx|--disable-vhdx)
1421 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1423 --enable-uuid|--disable-uuid)
1424 echo "$0: $opt is obsolete, UUID support is always built" >&2
1426 --disable-gtk) gtk="no"
1428 --enable-gtk) gtk="yes"
1430 --tls-priority=*) tls_priority="$optarg"
1432 --disable-gnutls) gnutls="no"
1434 --enable-gnutls) gnutls="yes"
1436 --disable-nettle) nettle="no"
1438 --enable-nettle) nettle="yes"
1440 --disable-gcrypt) gcrypt="no"
1442 --enable-gcrypt) gcrypt="yes"
1444 --disable-auth-pam) auth_pam="no"
1446 --enable-auth-pam) auth_pam="yes"
1448 --enable-rdma) rdma="yes"
1450 --disable-rdma) rdma="no"
1452 --enable-pvrdma) pvrdma="yes"
1454 --disable-pvrdma) pvrdma="no"
1456 --disable-vte) vte="no"
1458 --enable-vte) vte="yes"
1460 --disable-virglrenderer) virglrenderer="no"
1462 --enable-virglrenderer) virglrenderer="yes"
1464 --disable-tpm) tpm="no"
1466 --enable-tpm) tpm="yes"
1468 --disable-libssh) libssh="no"
1470 --enable-libssh) libssh="yes"
1472 --disable-live-block-migration) live_block_migration="no"
1474 --enable-live-block-migration) live_block_migration="yes"
1476 --disable-numa) numa="no"
1478 --enable-numa) numa="yes"
1480 --disable-libxml2) libxml2="no"
1482 --enable-libxml2) libxml2="yes"
1484 --disable-tcmalloc) tcmalloc="no"
1486 --enable-tcmalloc) tcmalloc="yes"
1488 --disable-jemalloc) jemalloc="no"
1490 --enable-jemalloc) jemalloc="yes"
1492 --disable-replication) replication="no"
1494 --enable-replication) replication="yes"
1496 --disable-vxhs) vxhs="no"
1498 --enable-vxhs) vxhs="yes"
1500 --disable-bochs) bochs="no"
1502 --enable-bochs) bochs="yes"
1504 --disable-cloop) cloop="no"
1506 --enable-cloop) cloop="yes"
1508 --disable-dmg) dmg="no"
1510 --enable-dmg) dmg="yes"
1512 --disable-qcow1) qcow1="no"
1514 --enable-qcow1) qcow1="yes"
1516 --disable-vdi) vdi="no"
1518 --enable-vdi) vdi="yes"
1520 --disable-vvfat) vvfat="no"
1522 --enable-vvfat) vvfat="yes"
1524 --disable-qed) qed="no"
1526 --enable-qed) qed="yes"
1528 --disable-parallels) parallels="no"
1530 --enable-parallels) parallels="yes"
1532 --disable-sheepdog) sheepdog="no"
1534 --enable-sheepdog) sheepdog="yes"
1536 --disable-vhost-user) vhost_user="no"
1538 --enable-vhost-user) vhost_user="yes"
1540 --disable-vhost-kernel) vhost_kernel="no"
1542 --enable-vhost-kernel) vhost_kernel="yes"
1544 --disable-capstone) capstone="no"
1546 --enable-capstone) capstone="yes"
1548 --enable-capstone=git) capstone="git"
1550 --enable-capstone=system) capstone="system"
1552 --with-git=*) git="$optarg"
1554 --enable-git-update) git_update=yes
1556 --disable-git-update) git_update=no
1558 --enable-debug-mutex) debug_mutex=yes
1560 --disable-debug-mutex) debug_mutex=no
1562 --enable-libpmem) libpmem=yes
1564 --disable-libpmem) libpmem=no
1566 --enable-xkbcommon) xkbcommon=yes
1568 --disable-xkbcommon) xkbcommon=no
1570 --enable-plugins) plugins="yes"
1572 --disable-plugins) plugins="no"
1575 echo "ERROR: unknown option $opt"
1576 echo "Try '$0 --help' for more information"
1577 exit 1
1579 esac
1580 done
1582 case "$cpu" in
1583 ppc)
1584 CPU_CFLAGS="-m32"
1585 LDFLAGS="-m32 $LDFLAGS"
1587 ppc64)
1588 CPU_CFLAGS="-m64"
1589 LDFLAGS="-m64 $LDFLAGS"
1591 sparc)
1592 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1593 LDFLAGS="-m32 -mv8plus $LDFLAGS"
1595 sparc64)
1596 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1597 LDFLAGS="-m64 $LDFLAGS"
1599 s390)
1600 CPU_CFLAGS="-m31"
1601 LDFLAGS="-m31 $LDFLAGS"
1603 s390x)
1604 CPU_CFLAGS="-m64"
1605 LDFLAGS="-m64 $LDFLAGS"
1607 i386)
1608 CPU_CFLAGS="-m32"
1609 LDFLAGS="-m32 $LDFLAGS"
1611 x86_64)
1612 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1613 # If we truly care, we should simply detect this case at
1614 # runtime and generate the fallback to serial emulation.
1615 CPU_CFLAGS="-m64 -mcx16"
1616 LDFLAGS="-m64 $LDFLAGS"
1618 x32)
1619 CPU_CFLAGS="-mx32"
1620 LDFLAGS="-mx32 $LDFLAGS"
1622 # No special flags required for other host CPUs
1623 esac
1625 eval "cross_cc_${cpu}=\$host_cc"
1626 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1627 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1629 # For user-mode emulation the host arch has to be one we explicitly
1630 # support, even if we're using TCI.
1631 if [ "$ARCH" = "unknown" ]; then
1632 bsd_user="no"
1633 linux_user="no"
1636 default_target_list=""
1638 mak_wilds=""
1640 if [ "$softmmu" = "yes" ]; then
1641 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1643 if [ "$linux_user" = "yes" ]; then
1644 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1646 if [ "$bsd_user" = "yes" ]; then
1647 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1650 if test -z "$target_list_exclude"; then
1651 for config in $mak_wilds; do
1652 default_target_list="${default_target_list} $(basename "$config" .mak)"
1653 done
1654 else
1655 exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1656 for config in $mak_wilds; do
1657 target="$(basename "$config" .mak)"
1658 exclude="no"
1659 for excl in $exclude_list; do
1660 if test "$excl" = "$target"; then
1661 exclude="yes"
1662 break;
1664 done
1665 if test "$exclude" = "no"; then
1666 default_target_list="${default_target_list} $target"
1668 done
1671 # Enumerate public trace backends for --help output
1672 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1674 if test x"$show_help" = x"yes" ; then
1675 cat << EOF
1677 Usage: configure [options]
1678 Options: [defaults in brackets after descriptions]
1680 Standard options:
1681 --help print this message
1682 --prefix=PREFIX install in PREFIX [$prefix]
1683 --interp-prefix=PREFIX where to find shared libraries, etc.
1684 use %M for cpu name [$interp_prefix]
1685 --target-list=LIST set target list (default: build everything)
1686 $(echo Available targets: $default_target_list | \
1687 fold -s -w 53 | sed -e 's/^/ /')
1688 --target-list-exclude=LIST exclude a set of targets from the default target-list
1690 Advanced options (experts only):
1691 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1692 --cc=CC use C compiler CC [$cc]
1693 --iasl=IASL use ACPI compiler IASL [$iasl]
1694 --host-cc=CC use C compiler CC [$host_cc] for code run at
1695 build time
1696 --cxx=CXX use C++ compiler CXX [$cxx]
1697 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1698 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1699 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1700 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1701 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1702 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
1703 --make=MAKE use specified make [$make]
1704 --install=INSTALL use specified install [$install]
1705 --python=PYTHON use specified python [$python]
1706 --smbd=SMBD use specified smbd [$smbd]
1707 --with-git=GIT use specified git [$git]
1708 --static enable static build [$static]
1709 --mandir=PATH install man pages in PATH
1710 --datadir=PATH install firmware in PATH$confsuffix
1711 --docdir=PATH install documentation in PATH$confsuffix
1712 --bindir=PATH install binaries in PATH
1713 --libdir=PATH install libraries in PATH
1714 --libexecdir=PATH install helper binaries in PATH
1715 --sysconfdir=PATH install config in PATH$confsuffix
1716 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1717 --firmwarepath=PATH search PATH for firmware files
1718 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1719 --with-pkgversion=VERS use specified string as sub-version of the package
1720 --enable-debug enable common debug build options
1721 --enable-sanitizers enable default sanitizers
1722 --disable-strip disable stripping binaries
1723 --disable-werror disable compilation abort on warning
1724 --disable-stack-protector disable compiler-provided stack protection
1725 --audio-drv-list=LIST set audio drivers list:
1726 Available drivers: $audio_possible_drivers
1727 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1728 --block-drv-rw-whitelist=L
1729 set block driver read-write whitelist
1730 (affects only QEMU, not qemu-img)
1731 --block-drv-ro-whitelist=L
1732 set block driver read-only whitelist
1733 (affects only QEMU, not qemu-img)
1734 --enable-trace-backends=B Set trace backend
1735 Available backends: $trace_backend_list
1736 --with-trace-file=NAME Full PATH,NAME of file to store traces
1737 Default:trace-<pid>
1738 --disable-slirp disable SLIRP userspace network connectivity
1739 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1740 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1741 --oss-lib path to OSS library
1742 --cpu=CPU Build for host CPU [$cpu]
1743 --with-coroutine=BACKEND coroutine backend. Supported options:
1744 ucontext, sigaltstack, windows
1745 --enable-gcov enable test coverage analysis with gcov
1746 --gcov=GCOV use specified gcov [$gcov_tool]
1747 --disable-blobs disable installing provided firmware blobs
1748 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1749 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1750 --tls-priority default TLS protocol/cipher priority string
1751 --enable-gprof QEMU profiling with gprof
1752 --enable-profiler profiler support
1753 --enable-debug-stack-usage
1754 track the maximum stack usage of stacks created by qemu_alloc_stack
1755 --enable-plugins
1756 enable plugins via shared library loading
1758 Optional features, enabled with --enable-FEATURE and
1759 disabled with --disable-FEATURE, default is enabled if available:
1761 system all system emulation targets
1762 user supported user emulation targets
1763 linux-user all linux usermode emulation targets
1764 bsd-user all BSD usermode emulation targets
1765 docs build documentation
1766 guest-agent build the QEMU Guest Agent
1767 guest-agent-msi build guest agent Windows MSI installation package
1768 pie Position Independent Executables
1769 modules modules support (non-Windows)
1770 debug-tcg TCG debugging (default is disabled)
1771 debug-info debugging information
1772 sparse sparse checker
1774 gnutls GNUTLS cryptography support
1775 nettle nettle cryptography support
1776 gcrypt libgcrypt cryptography support
1777 auth-pam PAM access control
1778 sdl SDL UI
1779 sdl-image SDL Image support for icons
1780 gtk gtk UI
1781 vte vte support for the gtk UI
1782 curses curses UI
1783 iconv font glyph conversion support
1784 vnc VNC UI support
1785 vnc-sasl SASL encryption for VNC server
1786 vnc-jpeg JPEG lossy compression for VNC server
1787 vnc-png PNG compression for VNC server
1788 cocoa Cocoa UI (Mac OS X only)
1789 virtfs VirtFS
1790 mpath Multipath persistent reservation passthrough
1791 xen xen backend driver support
1792 xen-pci-passthrough PCI passthrough support for Xen
1793 brlapi BrlAPI (Braile)
1794 curl curl connectivity
1795 membarrier membarrier system call (for Linux 4.14+ or Windows)
1796 fdt fdt device tree
1797 bluez bluez stack connectivity
1798 kvm KVM acceleration support
1799 hax HAX acceleration support
1800 hvf Hypervisor.framework acceleration support
1801 whpx Windows Hypervisor Platform acceleration support
1802 rdma Enable RDMA-based migration
1803 pvrdma Enable PVRDMA support
1804 vde support for vde network
1805 netmap support for netmap network
1806 linux-aio Linux AIO support
1807 cap-ng libcap-ng support
1808 attr attr and xattr support
1809 vhost-net vhost-net kernel acceleration support
1810 vhost-vsock virtio sockets device support
1811 vhost-scsi vhost-scsi kernel target support
1812 vhost-crypto vhost-user-crypto backend support
1813 vhost-kernel vhost kernel backend support
1814 vhost-user vhost-user backend support
1815 spice spice
1816 rbd rados block device (rbd)
1817 libiscsi iscsi support
1818 libnfs nfs support
1819 smartcard smartcard support (libcacard)
1820 libusb libusb (for usb passthrough)
1821 live-block-migration Block migration in the main migration stream
1822 usb-redir usb network redirection support
1823 lzo support of lzo compression library
1824 snappy support of snappy compression library
1825 bzip2 support of bzip2 compression library
1826 (for reading bzip2-compressed dmg images)
1827 lzfse support of lzfse compression library
1828 (for reading lzfse-compressed dmg images)
1829 seccomp seccomp support
1830 coroutine-pool coroutine freelist (better performance)
1831 glusterfs GlusterFS backend
1832 tpm TPM support
1833 libssh ssh block device support
1834 numa libnuma support
1835 libxml2 for Parallels image format
1836 tcmalloc tcmalloc support
1837 jemalloc jemalloc support
1838 avx2 AVX2 optimization support
1839 replication replication support
1840 opengl opengl support
1841 virglrenderer virgl rendering support
1842 xfsctl xfsctl support
1843 qom-cast-debug cast debugging support
1844 tools build qemu-io, qemu-nbd and qemu-img tools
1845 vxhs Veritas HyperScale vDisk backend support
1846 bochs bochs image format support
1847 cloop cloop image format support
1848 dmg dmg image format support
1849 qcow1 qcow v1 image format support
1850 vdi vdi image format support
1851 vvfat vvfat image format support
1852 qed qed image format support
1853 parallels parallels image format support
1854 sheepdog sheepdog block driver support
1855 crypto-afalg Linux AF_ALG crypto backend driver
1856 capstone capstone disassembler support
1857 debug-mutex mutex debugging support
1858 libpmem libpmem support
1859 xkbcommon xkbcommon support
1861 NOTE: The object files are built at the place where configure is launched
1863 exit 0
1866 # Remove old dependency files to make sure that they get properly regenerated
1867 rm -f */config-devices.mak.d
1869 if test -z "$python"
1870 then
1871 error_exit "Python not found. Use --python=/path/to/python"
1874 # Note that if the Python conditional here evaluates True we will exit
1875 # with status 1 which is a shell 'false' value.
1876 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
1877 error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1878 "Use --python=/path/to/python to specify a supported Python."
1881 # Preserve python version since some functionality is dependent on it
1882 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)
1884 # Suppress writing compiled files
1885 python="$python -B"
1887 # Check that the C compiler works. Doing this here before testing
1888 # the host CPU ensures that we had a valid CC to autodetect the
1889 # $cpu var (and we should bail right here if that's not the case).
1890 # It also allows the help message to be printed without a CC.
1891 write_c_skeleton;
1892 if compile_object ; then
1893 : C compiler works ok
1894 else
1895 error_exit "\"$cc\" either does not exist or does not work"
1897 if ! compile_prog ; then
1898 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1901 # Now we have handled --enable-tcg-interpreter and know we're not just
1902 # printing the help message, bail out if the host CPU isn't supported.
1903 if test "$ARCH" = "unknown"; then
1904 if test "$tcg_interpreter" = "yes" ; then
1905 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1906 else
1907 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1911 # Consult white-list to determine whether to enable werror
1912 # by default. Only enable by default for git builds
1913 if test -z "$werror" ; then
1914 if test -e "$source_path/.git" && \
1915 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1916 werror="yes"
1917 else
1918 werror="no"
1922 if test "$bogus_os" = "yes"; then
1923 # Now that we know that we're not printing the help and that
1924 # the compiler works (so the results of the check_defines we used
1925 # to identify the OS are reliable), if we didn't recognize the
1926 # host OS we should stop now.
1927 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1930 # Check whether the compiler matches our minimum requirements:
1931 cat > $TMPC << EOF
1932 #if defined(__clang_major__) && defined(__clang_minor__)
1933 # ifdef __apple_build_version__
1934 # if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1935 # error You need at least XCode Clang v5.1 to compile QEMU
1936 # endif
1937 # else
1938 # if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1939 # error You need at least Clang v3.4 to compile QEMU
1940 # endif
1941 # endif
1942 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1943 # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1944 # error You need at least GCC v4.8 to compile QEMU
1945 # endif
1946 #else
1947 # error You either need GCC or Clang to compiler QEMU
1948 #endif
1949 int main (void) { return 0; }
1951 if ! compile_prog "" "" ; then
1952 error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
1955 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1956 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1957 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1958 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1959 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1960 gcc_flags="-Wno-string-plus-int -Wno-typedef-redefinition $gcc_flags"
1961 # Note that we do not add -Werror to gcc_flags here, because that would
1962 # enable it for all configure tests. If a configure test failed due
1963 # to -Werror this would just silently disable some features,
1964 # so it's too error prone.
1966 cc_has_warning_flag() {
1967 write_c_skeleton;
1969 # Use the positive sense of the flag when testing for -Wno-wombat
1970 # support (gcc will happily accept the -Wno- form of unknown
1971 # warning options).
1972 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1973 compile_prog "-Werror $optflag" ""
1976 for flag in $gcc_flags; do
1977 if cc_has_warning_flag $flag ; then
1978 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1980 done
1982 if test "$mingw32" = "yes"; then
1983 stack_protector="no"
1985 if test "$stack_protector" != "no"; then
1986 cat > $TMPC << EOF
1987 int main(int argc, char *argv[])
1989 char arr[64], *p = arr, *c = argv[0];
1990 while (*c) {
1991 *p++ = *c++;
1993 return 0;
1996 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1997 sp_on=0
1998 for flag in $gcc_flags; do
1999 # We need to check both a compile and a link, since some compiler
2000 # setups fail only on a .c->.o compile and some only at link time
2001 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
2002 compile_prog "-Werror $flag" ""; then
2003 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2004 sp_on=1
2005 break
2007 done
2008 if test "$stack_protector" = yes; then
2009 if test $sp_on = 0; then
2010 error_exit "Stack protector not supported"
2015 # Disable -Wmissing-braces on older compilers that warn even for
2016 # the "universal" C zero initializer {0}.
2017 cat > $TMPC << EOF
2018 struct {
2019 int a[2];
2020 } x = {0};
2022 if compile_object "-Werror" "" ; then
2024 else
2025 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
2028 # Our module code doesn't support Windows
2029 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
2030 error_exit "Modules are not available for Windows"
2033 # Static linking is not possible with modules or PIE
2034 if test "$static" = "yes" ; then
2035 if test "$modules" = "yes" ; then
2036 error_exit "static and modules are mutually incompatible"
2038 if test "$pie" = "yes" ; then
2039 error_exit "static and pie are mutually incompatible"
2040 else
2041 pie="no"
2045 # Unconditional check for compiler __thread support
2046 cat > $TMPC << EOF
2047 static __thread int tls_var;
2048 int main(void) { return tls_var; }
2051 if ! compile_prog "-Werror" "" ; then
2052 error_exit "Your compiler does not support the __thread specifier for " \
2053 "Thread-Local Storage (TLS). Please upgrade to a version that does."
2056 if test "$pie" = ""; then
2057 case "$cpu-$targetos" in
2058 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
2061 pie="no"
2063 esac
2066 if test "$pie" != "no" ; then
2067 cat > $TMPC << EOF
2069 #ifdef __linux__
2070 # define THREAD __thread
2071 #else
2072 # define THREAD
2073 #endif
2075 static THREAD int tls_var;
2077 int main(void) { return tls_var; }
2080 # check we support --no-pie first...
2081 if compile_prog "-Werror -fno-pie" "-no-pie"; then
2082 CFLAGS_NOPIE="-fno-pie"
2083 LDFLAGS_NOPIE="-nopie"
2086 if compile_prog "-fPIE -DPIE" "-pie"; then
2087 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
2088 LDFLAGS="-pie $LDFLAGS"
2089 pie="yes"
2090 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2091 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
2093 else
2094 if test "$pie" = "yes"; then
2095 error_exit "PIE not available due to missing toolchain support"
2096 else
2097 echo "Disabling PIE due to missing toolchain support"
2098 pie="no"
2103 ##########################################
2104 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
2105 # use i686 as default anyway, but for those that don't, an explicit
2106 # specification is necessary
2108 if test "$cpu" = "i386"; then
2109 cat > $TMPC << EOF
2110 static int sfaa(int *ptr)
2112 return __sync_fetch_and_and(ptr, 0);
2115 int main(void)
2117 int val = 42;
2118 val = __sync_val_compare_and_swap(&val, 0, 1);
2119 sfaa(&val);
2120 return val;
2123 if ! compile_prog "" "" ; then
2124 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
2128 #########################################
2129 # Solaris specific configure tool chain decisions
2131 if test "$solaris" = "yes" ; then
2132 if has $install; then
2134 else
2135 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
2136 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
2137 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2139 if test "$(path_of $install)" = "/usr/sbin/install" ; then
2140 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
2141 "try ginstall from the GNU fileutils available from www.blastwave.org" \
2142 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2144 if has ar; then
2146 else
2147 if test -f /usr/ccs/bin/ar ; then
2148 error_exit "No path includes ar" \
2149 "Add /usr/ccs/bin to your path and rerun configure"
2151 error_exit "No path includes ar"
2155 if test -z "${target_list+xxx}" ; then
2156 for target in $default_target_list; do
2157 supported_target $target 2>/dev/null && \
2158 target_list="$target_list $target"
2159 done
2160 target_list="${target_list# }"
2161 else
2162 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2163 for target in $target_list; do
2164 # Check that we recognised the target name; this allows a more
2165 # friendly error message than if we let it fall through.
2166 case " $default_target_list " in
2167 *" $target "*)
2170 error_exit "Unknown target name '$target'"
2172 esac
2173 supported_target $target || exit 1
2174 done
2177 # see if system emulation was really requested
2178 case " $target_list " in
2179 *"-softmmu "*) softmmu=yes
2181 *) softmmu=no
2183 esac
2185 feature_not_found() {
2186 feature=$1
2187 remedy=$2
2189 error_exit "User requested feature $feature" \
2190 "configure was not able to find it." \
2191 "$remedy"
2194 # ---
2195 # big/little endian test
2196 cat > $TMPC << EOF
2197 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
2198 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2199 extern int foo(short *, short *);
2200 int main(int argc, char *argv[]) {
2201 return foo(big_endian, little_endian);
2205 if compile_object ; then
2206 if strings -a $TMPO | grep -q BiGeNdIaN ; then
2207 bigendian="yes"
2208 elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
2209 bigendian="no"
2210 else
2211 echo big/little test failed
2213 else
2214 echo big/little test failed
2217 ##########################################
2218 # cocoa implies not SDL or GTK
2219 # (the cocoa UI code currently assumes it is always the active UI
2220 # and doesn't interact well with other UI frontend code)
2221 if test "$cocoa" = "yes"; then
2222 if test "$sdl" = "yes"; then
2223 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2225 if test "$gtk" = "yes"; then
2226 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2228 gtk=no
2229 sdl=no
2232 # Some versions of Mac OS X incorrectly define SIZE_MAX
2233 cat > $TMPC << EOF
2234 #include <stdint.h>
2235 #include <stdio.h>
2236 int main(int argc, char *argv[]) {
2237 return printf("%zu", SIZE_MAX);
2240 have_broken_size_max=no
2241 if ! compile_object -Werror ; then
2242 have_broken_size_max=yes
2245 ##########################################
2246 # L2TPV3 probe
2248 cat > $TMPC <<EOF
2249 #include <sys/socket.h>
2250 #include <linux/ip.h>
2251 int main(void) { return sizeof(struct mmsghdr); }
2253 if compile_prog "" "" ; then
2254 l2tpv3=yes
2255 else
2256 l2tpv3=no
2259 #########################################
2260 # vhost interdependencies and host support
2262 # vhost backends
2263 test "$vhost_user" = "" && vhost_user=yes
2264 if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2265 error_exit "vhost-user isn't available on win32"
2267 test "$vhost_kernel" = "" && vhost_kernel=$linux
2268 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2269 error_exit "vhost-kernel is only available on Linux"
2272 # vhost-kernel devices
2273 test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2274 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2275 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2277 test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2278 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2279 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2282 # vhost-user backends
2283 test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2284 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2285 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2287 test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2288 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2289 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2291 test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
2292 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
2293 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
2296 # OR the vhost-kernel and vhost-user values for simplicity
2297 if test "$vhost_net" = ""; then
2298 test "$vhost_net_user" = "yes" && vhost_net=yes
2299 test "$vhost_kernel" = "yes" && vhost_net=yes
2302 ##########################################
2303 # MinGW / Mingw-w64 localtime_r/gmtime_r check
2305 if test "$mingw32" = "yes"; then
2306 # Some versions of MinGW / Mingw-w64 lack localtime_r
2307 # and gmtime_r entirely.
2309 # Some versions of Mingw-w64 define a macro for
2310 # localtime_r/gmtime_r.
2312 # Some versions of Mingw-w64 will define functions
2313 # for localtime_r/gmtime_r, but only if you have
2314 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
2315 # though, unistd.h and pthread.h both define
2316 # that for you.
2318 # So this #undef localtime_r and #include <unistd.h>
2319 # are not in fact redundant.
2320 cat > $TMPC << EOF
2321 #include <unistd.h>
2322 #include <time.h>
2323 #undef localtime_r
2324 int main(void) { localtime_r(NULL, NULL); return 0; }
2326 if compile_prog "" "" ; then
2327 localtime_r="yes"
2328 else
2329 localtime_r="no"
2333 ##########################################
2334 # pkg-config probe
2336 if ! has "$pkg_config_exe"; then
2337 error_exit "pkg-config binary '$pkg_config_exe' not found"
2340 ##########################################
2341 # NPTL probe
2343 if test "$linux_user" = "yes"; then
2344 cat > $TMPC <<EOF
2345 #include <sched.h>
2346 #include <linux/futex.h>
2347 int main(void) {
2348 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2349 #error bork
2350 #endif
2351 return 0;
2354 if ! compile_object ; then
2355 feature_not_found "nptl" "Install glibc and linux kernel headers."
2359 ##########################################
2360 # lzo check
2362 if test "$lzo" != "no" ; then
2363 cat > $TMPC << EOF
2364 #include <lzo/lzo1x.h>
2365 int main(void) { lzo_version(); return 0; }
2367 if compile_prog "" "-llzo2" ; then
2368 libs_softmmu="$libs_softmmu -llzo2"
2369 lzo="yes"
2370 else
2371 if test "$lzo" = "yes"; then
2372 feature_not_found "liblzo2" "Install liblzo2 devel"
2374 lzo="no"
2378 ##########################################
2379 # snappy check
2381 if test "$snappy" != "no" ; then
2382 cat > $TMPC << EOF
2383 #include <snappy-c.h>
2384 int main(void) { snappy_max_compressed_length(4096); return 0; }
2386 if compile_prog "" "-lsnappy" ; then
2387 libs_softmmu="$libs_softmmu -lsnappy"
2388 snappy="yes"
2389 else
2390 if test "$snappy" = "yes"; then
2391 feature_not_found "libsnappy" "Install libsnappy devel"
2393 snappy="no"
2397 ##########################################
2398 # bzip2 check
2400 if test "$bzip2" != "no" ; then
2401 cat > $TMPC << EOF
2402 #include <bzlib.h>
2403 int main(void) { BZ2_bzlibVersion(); return 0; }
2405 if compile_prog "" "-lbz2" ; then
2406 bzip2="yes"
2407 else
2408 if test "$bzip2" = "yes"; then
2409 feature_not_found "libbzip2" "Install libbzip2 devel"
2411 bzip2="no"
2415 ##########################################
2416 # lzfse check
2418 if test "$lzfse" != "no" ; then
2419 cat > $TMPC << EOF
2420 #include <lzfse.h>
2421 int main(void) { lzfse_decode_scratch_size(); return 0; }
2423 if compile_prog "" "-llzfse" ; then
2424 lzfse="yes"
2425 else
2426 if test "$lzfse" = "yes"; then
2427 feature_not_found "lzfse" "Install lzfse devel"
2429 lzfse="no"
2433 ##########################################
2434 # libseccomp check
2436 if test "$seccomp" != "no" ; then
2437 libseccomp_minver="2.3.0"
2438 if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2439 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2440 seccomp_libs="$($pkg_config --libs libseccomp)"
2441 seccomp="yes"
2442 else
2443 if test "$seccomp" = "yes" ; then
2444 feature_not_found "libseccomp" \
2445 "Install libseccomp devel >= $libseccomp_minver"
2447 seccomp="no"
2450 ##########################################
2451 # xen probe
2453 if test "$xen" != "no" ; then
2454 # Check whether Xen library path is specified via --extra-ldflags to avoid
2455 # overriding this setting with pkg-config output. If not, try pkg-config
2456 # to obtain all needed flags.
2458 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2459 $pkg_config --exists xencontrol ; then
2460 xen_ctrl_version="$(printf '%d%02d%02d' \
2461 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2462 xen=yes
2463 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2464 xen_pc="$xen_pc xenevtchn xendevicemodel"
2465 if $pkg_config --exists xentoolcore; then
2466 xen_pc="$xen_pc xentoolcore"
2468 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2469 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2470 else
2472 xen_libs="-lxenstore -lxenctrl -lxenguest"
2473 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2475 # First we test whether Xen headers and libraries are available.
2476 # If no, we are done and there is no Xen support.
2477 # If yes, more tests are run to detect the Xen version.
2479 # Xen (any)
2480 cat > $TMPC <<EOF
2481 #include <xenctrl.h>
2482 int main(void) {
2483 return 0;
2486 if ! compile_prog "" "$xen_libs" ; then
2487 # Xen not found
2488 if test "$xen" = "yes" ; then
2489 feature_not_found "xen" "Install xen devel"
2491 xen=no
2493 # Xen unstable
2494 elif
2495 cat > $TMPC <<EOF &&
2496 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2497 #define __XEN_TOOLS__
2498 #include <xendevicemodel.h>
2499 #include <xenforeignmemory.h>
2500 int main(void) {
2501 xendevicemodel_handle *xd;
2502 xenforeignmemory_handle *xfmem;
2504 xd = xendevicemodel_open(0, 0);
2505 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2507 xfmem = xenforeignmemory_open(0, 0);
2508 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2510 return 0;
2513 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2514 then
2515 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2516 xen_ctrl_version=41100
2517 xen=yes
2518 elif
2519 cat > $TMPC <<EOF &&
2520 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2521 #include <xenforeignmemory.h>
2522 #include <xentoolcore.h>
2523 int main(void) {
2524 xenforeignmemory_handle *xfmem;
2526 xfmem = xenforeignmemory_open(0, 0);
2527 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2528 xentoolcore_restrict_all(0);
2530 return 0;
2533 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2534 then
2535 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2536 xen_ctrl_version=41000
2537 xen=yes
2538 elif
2539 cat > $TMPC <<EOF &&
2540 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2541 #define __XEN_TOOLS__
2542 #include <xendevicemodel.h>
2543 int main(void) {
2544 xendevicemodel_handle *xd;
2546 xd = xendevicemodel_open(0, 0);
2547 xendevicemodel_close(xd);
2549 return 0;
2552 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2553 then
2554 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2555 xen_ctrl_version=40900
2556 xen=yes
2557 elif
2558 cat > $TMPC <<EOF &&
2560 * If we have stable libs the we don't want the libxc compat
2561 * layers, regardless of what CFLAGS we may have been given.
2563 * Also, check if xengnttab_grant_copy_segment_t is defined and
2564 * grant copy operation is implemented.
2566 #undef XC_WANT_COMPAT_EVTCHN_API
2567 #undef XC_WANT_COMPAT_GNTTAB_API
2568 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2569 #include <xenctrl.h>
2570 #include <xenstore.h>
2571 #include <xenevtchn.h>
2572 #include <xengnttab.h>
2573 #include <xenforeignmemory.h>
2574 #include <stdint.h>
2575 #include <xen/hvm/hvm_info_table.h>
2576 #if !defined(HVM_MAX_VCPUS)
2577 # error HVM_MAX_VCPUS not defined
2578 #endif
2579 int main(void) {
2580 xc_interface *xc = NULL;
2581 xenforeignmemory_handle *xfmem;
2582 xenevtchn_handle *xe;
2583 xengnttab_handle *xg;
2584 xengnttab_grant_copy_segment_t* seg = NULL;
2586 xs_daemon_open();
2588 xc = xc_interface_open(0, 0, 0);
2589 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2590 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2591 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2592 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2594 xfmem = xenforeignmemory_open(0, 0);
2595 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2597 xe = xenevtchn_open(0, 0);
2598 xenevtchn_fd(xe);
2600 xg = xengnttab_open(0, 0);
2601 xengnttab_grant_copy(xg, 0, seg);
2603 return 0;
2606 compile_prog "" "$xen_libs $xen_stable_libs"
2607 then
2608 xen_ctrl_version=40800
2609 xen=yes
2610 elif
2611 cat > $TMPC <<EOF &&
2613 * If we have stable libs the we don't want the libxc compat
2614 * layers, regardless of what CFLAGS we may have been given.
2616 #undef XC_WANT_COMPAT_EVTCHN_API
2617 #undef XC_WANT_COMPAT_GNTTAB_API
2618 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2619 #include <xenctrl.h>
2620 #include <xenstore.h>
2621 #include <xenevtchn.h>
2622 #include <xengnttab.h>
2623 #include <xenforeignmemory.h>
2624 #include <stdint.h>
2625 #include <xen/hvm/hvm_info_table.h>
2626 #if !defined(HVM_MAX_VCPUS)
2627 # error HVM_MAX_VCPUS not defined
2628 #endif
2629 int main(void) {
2630 xc_interface *xc = NULL;
2631 xenforeignmemory_handle *xfmem;
2632 xenevtchn_handle *xe;
2633 xengnttab_handle *xg;
2635 xs_daemon_open();
2637 xc = xc_interface_open(0, 0, 0);
2638 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2639 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2640 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2641 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2643 xfmem = xenforeignmemory_open(0, 0);
2644 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2646 xe = xenevtchn_open(0, 0);
2647 xenevtchn_fd(xe);
2649 xg = xengnttab_open(0, 0);
2650 xengnttab_map_grant_ref(xg, 0, 0, 0);
2652 return 0;
2655 compile_prog "" "$xen_libs $xen_stable_libs"
2656 then
2657 xen_ctrl_version=40701
2658 xen=yes
2660 # Xen 4.6
2661 elif
2662 cat > $TMPC <<EOF &&
2663 #include <xenctrl.h>
2664 #include <xenstore.h>
2665 #include <stdint.h>
2666 #include <xen/hvm/hvm_info_table.h>
2667 #if !defined(HVM_MAX_VCPUS)
2668 # error HVM_MAX_VCPUS not defined
2669 #endif
2670 int main(void) {
2671 xc_interface *xc;
2672 xs_daemon_open();
2673 xc = xc_interface_open(0, 0, 0);
2674 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2675 xc_gnttab_open(NULL, 0);
2676 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2677 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2678 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2679 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2680 return 0;
2683 compile_prog "" "$xen_libs"
2684 then
2685 xen_ctrl_version=40600
2686 xen=yes
2688 # Xen 4.5
2689 elif
2690 cat > $TMPC <<EOF &&
2691 #include <xenctrl.h>
2692 #include <xenstore.h>
2693 #include <stdint.h>
2694 #include <xen/hvm/hvm_info_table.h>
2695 #if !defined(HVM_MAX_VCPUS)
2696 # error HVM_MAX_VCPUS not defined
2697 #endif
2698 int main(void) {
2699 xc_interface *xc;
2700 xs_daemon_open();
2701 xc = xc_interface_open(0, 0, 0);
2702 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2703 xc_gnttab_open(NULL, 0);
2704 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2705 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2706 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2707 return 0;
2710 compile_prog "" "$xen_libs"
2711 then
2712 xen_ctrl_version=40500
2713 xen=yes
2715 elif
2716 cat > $TMPC <<EOF &&
2717 #include <xenctrl.h>
2718 #include <xenstore.h>
2719 #include <stdint.h>
2720 #include <xen/hvm/hvm_info_table.h>
2721 #if !defined(HVM_MAX_VCPUS)
2722 # error HVM_MAX_VCPUS not defined
2723 #endif
2724 int main(void) {
2725 xc_interface *xc;
2726 xs_daemon_open();
2727 xc = xc_interface_open(0, 0, 0);
2728 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2729 xc_gnttab_open(NULL, 0);
2730 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2731 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2732 return 0;
2735 compile_prog "" "$xen_libs"
2736 then
2737 xen_ctrl_version=40200
2738 xen=yes
2740 else
2741 if test "$xen" = "yes" ; then
2742 feature_not_found "xen (unsupported version)" \
2743 "Install a supported xen (xen 4.2 or newer)"
2745 xen=no
2748 if test "$xen" = yes; then
2749 if test $xen_ctrl_version -ge 40701 ; then
2750 libs_softmmu="$xen_stable_libs $libs_softmmu"
2752 libs_softmmu="$xen_libs $libs_softmmu"
2757 if test "$xen_pci_passthrough" != "no"; then
2758 if test "$xen" = "yes" && test "$linux" = "yes"; then
2759 xen_pci_passthrough=yes
2760 else
2761 if test "$xen_pci_passthrough" = "yes"; then
2762 error_exit "User requested feature Xen PCI Passthrough" \
2763 " but this feature requires /sys from Linux"
2765 xen_pci_passthrough=no
2769 ##########################################
2770 # Windows Hypervisor Platform accelerator (WHPX) check
2771 if test "$whpx" != "no" ; then
2772 if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2773 whpx="yes"
2774 else
2775 if test "$whpx" = "yes"; then
2776 feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2778 whpx="no"
2782 ##########################################
2783 # Sparse probe
2784 if test "$sparse" != "no" ; then
2785 if has cgcc; then
2786 sparse=yes
2787 else
2788 if test "$sparse" = "yes" ; then
2789 feature_not_found "sparse" "Install sparse binary"
2791 sparse=no
2795 ##########################################
2796 # X11 probe
2797 if $pkg_config --exists "x11"; then
2798 have_x11=yes
2799 x11_cflags=$($pkg_config --cflags x11)
2800 x11_libs=$($pkg_config --libs x11)
2803 ##########################################
2804 # GTK probe
2806 if test "$gtk" != "no"; then
2807 gtkpackage="gtk+-3.0"
2808 gtkx11package="gtk+-x11-3.0"
2809 gtkversion="3.14.0"
2810 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2811 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2812 gtk_libs=$($pkg_config --libs $gtkpackage)
2813 gtk_version=$($pkg_config --modversion $gtkpackage)
2814 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2815 need_x11=yes
2816 gtk_cflags="$gtk_cflags $x11_cflags"
2817 gtk_libs="$gtk_libs $x11_libs"
2819 gtk="yes"
2820 elif test "$gtk" = "yes"; then
2821 feature_not_found "gtk" "Install gtk3-devel"
2822 else
2823 gtk="no"
2828 ##########################################
2829 # GNUTLS probe
2831 if test "$gnutls" != "no"; then
2832 pass="no"
2833 if $pkg_config --exists "gnutls >= 3.1.18"; then
2834 gnutls_cflags=$($pkg_config --cflags gnutls)
2835 gnutls_libs=$($pkg_config --libs gnutls)
2836 # Packaging for the static libraries is not always correct.
2837 # At least ubuntu 18.04 ships only shared libraries.
2838 write_c_skeleton
2839 if compile_prog "" "$gnutls_libs" ; then
2840 LIBS="$gnutls_libs $LIBS"
2841 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2842 pass="yes"
2845 if test "$pass" = "no" && test "$gnutls" = "yes"; then
2846 feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2847 else
2848 gnutls="$pass"
2853 # If user didn't give a --disable/enable-gcrypt flag,
2854 # then mark as disabled if user requested nettle
2855 # explicitly
2856 if test -z "$gcrypt"
2857 then
2858 if test "$nettle" = "yes"
2859 then
2860 gcrypt="no"
2864 # If user didn't give a --disable/enable-nettle flag,
2865 # then mark as disabled if user requested gcrypt
2866 # explicitly
2867 if test -z "$nettle"
2868 then
2869 if test "$gcrypt" = "yes"
2870 then
2871 nettle="no"
2875 has_libgcrypt() {
2876 if ! has "libgcrypt-config"
2877 then
2878 return 1
2881 if test -n "$cross_prefix"
2882 then
2883 host=$(libgcrypt-config --host)
2884 if test "$host-" != $cross_prefix
2885 then
2886 return 1
2890 maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2891 min=`libgcrypt-config --version | awk -F . '{print $2}'`
2893 if test $maj != 1 || test $min -lt 5
2894 then
2895 return 1
2898 return 0
2902 if test "$nettle" != "no"; then
2903 pass="no"
2904 if $pkg_config --exists "nettle >= 2.7.1"; then
2905 nettle_cflags=$($pkg_config --cflags nettle)
2906 nettle_libs=$($pkg_config --libs nettle)
2907 nettle_version=$($pkg_config --modversion nettle)
2908 # Link test to make sure the given libraries work (e.g for static).
2909 write_c_skeleton
2910 if compile_prog "" "$nettle_libs" ; then
2911 LIBS="$nettle_libs $LIBS"
2912 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2913 if test -z "$gcrypt"; then
2914 gcrypt="no"
2916 pass="yes"
2919 if test "$pass" = "yes"
2920 then
2921 cat > $TMPC << EOF
2922 #include <nettle/xts.h>
2923 int main(void) {
2924 return 0;
2927 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2928 nettle_xts=yes
2929 qemu_private_xts=no
2932 if test "$pass" = "no" && test "$nettle" = "yes"; then
2933 feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2934 else
2935 nettle="$pass"
2939 if test "$gcrypt" != "no"; then
2940 pass="no"
2941 if has_libgcrypt; then
2942 gcrypt_cflags=$(libgcrypt-config --cflags)
2943 gcrypt_libs=$(libgcrypt-config --libs)
2944 # Debian has removed -lgpg-error from libgcrypt-config
2945 # as it "spreads unnecessary dependencies" which in
2946 # turn breaks static builds...
2947 if test "$static" = "yes"
2948 then
2949 gcrypt_libs="$gcrypt_libs -lgpg-error"
2952 # Link test to make sure the given libraries work (e.g for static).
2953 write_c_skeleton
2954 if compile_prog "" "$gcrypt_libs" ; then
2955 LIBS="$gcrypt_libs $LIBS"
2956 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2957 pass="yes"
2960 if test "$pass" = "yes"; then
2961 gcrypt="yes"
2962 cat > $TMPC << EOF
2963 #include <gcrypt.h>
2964 int main(void) {
2965 gcry_mac_hd_t handle;
2966 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2967 GCRY_MAC_FLAG_SECURE, NULL);
2968 return 0;
2971 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2972 gcrypt_hmac=yes
2974 cat > $TMPC << EOF
2975 #include <gcrypt.h>
2976 int main(void) {
2977 gcry_cipher_hd_t handle;
2978 gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
2979 return 0;
2982 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2983 gcrypt_xts=yes
2984 qemu_private_xts=no
2986 elif test "$gcrypt" = "yes"; then
2987 feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
2988 else
2989 gcrypt="no"
2994 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2995 then
2996 error_exit "Only one of gcrypt & nettle can be enabled"
2999 ##########################################
3000 # libtasn1 - only for the TLS creds/session test suite
3002 tasn1=yes
3003 tasn1_cflags=""
3004 tasn1_libs=""
3005 if $pkg_config --exists "libtasn1"; then
3006 tasn1_cflags=$($pkg_config --cflags libtasn1)
3007 tasn1_libs=$($pkg_config --libs libtasn1)
3008 else
3009 tasn1=no
3013 ##########################################
3014 # PAM probe
3016 if test "$auth_pam" != "no"; then
3017 cat > $TMPC <<EOF
3018 #include <security/pam_appl.h>
3019 #include <stdio.h>
3020 int main(void) {
3021 const char *service_name = "qemu";
3022 const char *user = "frank";
3023 const struct pam_conv pam_conv = { 0 };
3024 pam_handle_t *pamh = NULL;
3025 pam_start(service_name, user, &pam_conv, &pamh);
3026 return 0;
3029 if compile_prog "" "-lpam" ; then
3030 auth_pam=yes
3031 else
3032 if test "$auth_pam" = "yes"; then
3033 feature_not_found "PAM" "Install PAM development package"
3034 else
3035 auth_pam=no
3040 ##########################################
3041 # getifaddrs (for tests/test-io-channel-socket )
3043 have_ifaddrs_h=yes
3044 if ! check_include "ifaddrs.h" ; then
3045 have_ifaddrs_h=no
3048 ##########################################
3049 # VTE probe
3051 if test "$vte" != "no"; then
3052 vteminversion="0.32.0"
3053 if $pkg_config --exists "vte-2.91"; then
3054 vtepackage="vte-2.91"
3055 else
3056 vtepackage="vte-2.90"
3058 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
3059 vte_cflags=$($pkg_config --cflags $vtepackage)
3060 vte_libs=$($pkg_config --libs $vtepackage)
3061 vteversion=$($pkg_config --modversion $vtepackage)
3062 vte="yes"
3063 elif test "$vte" = "yes"; then
3064 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
3065 else
3066 vte="no"
3070 ##########################################
3071 # SDL probe
3073 # Look for sdl configuration program (pkg-config or sdl2-config). Try
3074 # sdl2-config even without cross prefix, and favour pkg-config over sdl2-config.
3076 sdl_probe ()
3078 if $pkg_config sdl2 --exists; then
3079 sdlconfig="$pkg_config sdl2"
3080 sdlversion=$($sdlconfig --modversion 2>/dev/null)
3081 elif has "$sdl2_config"; then
3082 sdlconfig="$sdl2_config"
3083 sdlversion=$($sdlconfig --version)
3084 else
3085 if test "$sdl" = "yes" ; then
3086 feature_not_found "sdl" "Install SDL2-devel"
3088 sdl=no
3089 # no need to do the rest
3090 return
3092 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl2-config; then
3093 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
3096 cat > $TMPC << EOF
3097 #include <SDL.h>
3098 #undef main /* We don't want SDL to override our main() */
3099 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
3101 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
3102 sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
3103 if test "$static" = "yes" ; then
3104 if $pkg_config sdl2 --exists; then
3105 sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
3106 else
3107 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
3109 else
3110 sdl_libs=$($sdlconfig --libs 2>/dev/null)
3112 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
3113 sdl=yes
3115 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
3116 if test "$sdl" = "yes" && test "$static" = "yes" ; then
3117 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
3118 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
3119 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
3121 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
3123 else
3124 sdl=no
3126 fi # static link
3127 else # sdl not found
3128 if test "$sdl" = "yes" ; then
3129 feature_not_found "sdl" "Install SDL2 devel"
3131 sdl=no
3132 fi # sdl compile test
3135 sdl_image_probe ()
3137 if test "$sdl_image" != "no" ; then
3138 if $pkg_config SDL2_image --exists; then
3139 if test "$static" = "yes"; then
3140 sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3141 else
3142 sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3144 sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3145 sdl_image=yes
3147 sdl_cflags="$sdl_cflags $sdl_image_cflags"
3148 sdl_libs="$sdl_libs $sdl_image_libs"
3149 else
3150 if test "$sdl_image" = "yes" ; then
3151 feature_not_found "sdl_image" "Install SDL Image devel"
3152 else
3153 sdl_image=no
3159 if test "$sdl" != "no" ; then
3160 sdl_probe
3163 if test "$sdl" = "yes" ; then
3164 sdl_image_probe
3165 else
3166 if test "$sdl_image" = "yes"; then
3167 echo "warning: SDL Image requested, but SDL is not available, disabling"
3169 sdl_image=no
3172 if test "$sdl" = "yes" ; then
3173 cat > $TMPC <<EOF
3174 #include <SDL.h>
3175 #if defined(SDL_VIDEO_DRIVER_X11)
3176 #include <X11/XKBlib.h>
3177 #else
3178 #error No x11 support
3179 #endif
3180 int main(void) { return 0; }
3182 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
3183 need_x11=yes
3184 sdl_cflags="$sdl_cflags $x11_cflags"
3185 sdl_libs="$sdl_libs $x11_libs"
3189 ##########################################
3190 # RDMA needs OpenFabrics libraries
3191 if test "$rdma" != "no" ; then
3192 cat > $TMPC <<EOF
3193 #include <rdma/rdma_cma.h>
3194 int main(void) { return 0; }
3196 rdma_libs="-lrdmacm -libverbs -libumad"
3197 if compile_prog "" "$rdma_libs" ; then
3198 rdma="yes"
3199 libs_softmmu="$libs_softmmu $rdma_libs"
3200 else
3201 if test "$rdma" = "yes" ; then
3202 error_exit \
3203 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
3204 " Your options:" \
3205 " (1) Fast: Install infiniband packages (devel) from your distro." \
3206 " (2) Cleanest: Install libraries from www.openfabrics.org" \
3207 " (3) Also: Install softiwarp if you don't have RDMA hardware"
3209 rdma="no"
3213 ##########################################
3214 # PVRDMA detection
3216 cat > $TMPC <<EOF &&
3217 #include <sys/mman.h>
3220 main(void)
3222 char buf = 0;
3223 void *addr = &buf;
3224 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
3226 return 0;
3230 if test "$rdma" = "yes" ; then
3231 case "$pvrdma" in
3233 if compile_prog "" ""; then
3234 pvrdma="yes"
3235 else
3236 pvrdma="no"
3239 "yes")
3240 if ! compile_prog "" ""; then
3241 error_exit "PVRDMA is not supported since mremap is not implemented"
3243 pvrdma="yes"
3245 "no")
3246 pvrdma="no"
3248 esac
3249 else
3250 if test "$pvrdma" = "yes" ; then
3251 error_exit "PVRDMA requires rdma suppport"
3253 pvrdma="no"
3256 # Let's see if enhanced reg_mr is supported
3257 if test "$pvrdma" = "yes" ; then
3259 cat > $TMPC <<EOF &&
3260 #include <infiniband/verbs.h>
3263 main(void)
3265 struct ibv_mr *mr;
3266 struct ibv_pd *pd = NULL;
3267 size_t length = 10;
3268 uint64_t iova = 0;
3269 int access = 0;
3270 void *addr = NULL;
3272 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3274 ibv_dereg_mr(mr);
3276 return 0;
3279 if ! compile_prog "" "-libverbs"; then
3280 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3284 ##########################################
3285 # VNC SASL detection
3286 if test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
3287 cat > $TMPC <<EOF
3288 #include <sasl/sasl.h>
3289 #include <stdio.h>
3290 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
3292 # Assuming Cyrus-SASL installed in /usr prefix
3293 vnc_sasl_cflags=""
3294 vnc_sasl_libs="-lsasl2"
3295 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3296 vnc_sasl=yes
3297 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3298 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
3299 else
3300 if test "$vnc_sasl" = "yes" ; then
3301 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3303 vnc_sasl=no
3307 ##########################################
3308 # VNC JPEG detection
3309 if test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
3310 if $pkg_config --exists libjpeg; then
3311 vnc_jpeg=yes
3312 libs_softmmu="$libs_softmmu $($pkg_config --libs libjpeg)"
3313 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libjpeg)"
3314 else
3315 cat > $TMPC <<EOF
3316 #include <stdio.h>
3317 #include <jpeglib.h>
3318 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
3320 vnc_jpeg_cflags=""
3321 vnc_jpeg_libs="-ljpeg"
3322 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
3323 vnc_jpeg=yes
3324 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3325 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
3326 else
3327 if test "$vnc_jpeg" = "yes" ; then
3328 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
3330 vnc_jpeg=no
3335 ##########################################
3336 # VNC PNG detection
3337 if test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
3338 cat > $TMPC <<EOF
3339 //#include <stdio.h>
3340 #include <png.h>
3341 #include <stddef.h>
3342 int main(void) {
3343 png_structp png_ptr;
3344 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
3345 return png_ptr != 0;
3348 if $pkg_config libpng --exists; then
3349 vnc_png_cflags=$($pkg_config libpng --cflags)
3350 vnc_png_libs=$($pkg_config libpng --libs)
3351 else
3352 vnc_png_cflags=""
3353 vnc_png_libs="-lpng"
3355 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3356 vnc_png=yes
3357 libs_softmmu="$vnc_png_libs $libs_softmmu"
3358 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3359 else
3360 if test "$vnc_png" = "yes" ; then
3361 feature_not_found "vnc-png" "Install libpng devel"
3363 vnc_png=no
3367 ##########################################
3368 # xkbcommon probe
3369 if test "$xkbcommon" != "no" ; then
3370 if $pkg_config xkbcommon --exists; then
3371 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
3372 xkbcommon_libs=$($pkg_config xkbcommon --libs)
3373 xkbcommon=yes
3374 else
3375 if test "$xkbcommon" = "yes" ; then
3376 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
3378 xkbcommon=no
3383 ##########################################
3384 # xfsctl() probe, used for file-posix.c
3385 if test "$xfs" != "no" ; then
3386 cat > $TMPC << EOF
3387 #include <stddef.h> /* NULL */
3388 #include <xfs/xfs.h>
3389 int main(void)
3391 xfsctl(NULL, 0, 0, NULL);
3392 return 0;
3395 if compile_prog "" "" ; then
3396 xfs="yes"
3397 else
3398 if test "$xfs" = "yes" ; then
3399 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3401 xfs=no
3405 ##########################################
3406 # vde libraries probe
3407 if test "$vde" != "no" ; then
3408 vde_libs="-lvdeplug"
3409 cat > $TMPC << EOF
3410 #include <stddef.h>
3411 #include <libvdeplug.h>
3412 int main(void)
3414 struct vde_open_args a = {0, 0, 0};
3415 char s[] = "";
3416 vde_open(s, s, &a);
3417 return 0;
3420 if compile_prog "" "$vde_libs" ; then
3421 vde=yes
3422 else
3423 if test "$vde" = "yes" ; then
3424 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3426 vde=no
3430 ##########################################
3431 # netmap support probe
3432 # Apart from looking for netmap headers, we make sure that the host API version
3433 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3434 # a minor/major version number. Minor new features will be marked with values up
3435 # to 15, and if something happens that requires a change to the backend we will
3436 # move above 15, submit the backend fixes and modify this two bounds.
3437 if test "$netmap" != "no" ; then
3438 cat > $TMPC << EOF
3439 #include <inttypes.h>
3440 #include <net/if.h>
3441 #include <net/netmap.h>
3442 #include <net/netmap_user.h>
3443 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3444 #error
3445 #endif
3446 int main(void) { return 0; }
3448 if compile_prog "" "" ; then
3449 netmap=yes
3450 else
3451 if test "$netmap" = "yes" ; then
3452 feature_not_found "netmap"
3454 netmap=no
3458 ##########################################
3459 # libcap-ng library probe
3460 if test "$cap_ng" != "no" ; then
3461 cap_libs="-lcap-ng"
3462 cat > $TMPC << EOF
3463 #include <cap-ng.h>
3464 int main(void)
3466 capng_capability_to_name(CAPNG_EFFECTIVE);
3467 return 0;
3470 if compile_prog "" "$cap_libs" ; then
3471 cap_ng=yes
3472 libs_tools="$cap_libs $libs_tools"
3473 else
3474 if test "$cap_ng" = "yes" ; then
3475 feature_not_found "cap_ng" "Install libcap-ng devel"
3477 cap_ng=no
3481 ##########################################
3482 # Sound support libraries probe
3484 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3485 for drv in $audio_drv_list; do
3486 case $drv in
3487 alsa | try-alsa)
3488 if $pkg_config alsa --exists; then
3489 alsa_libs=$($pkg_config alsa --libs)
3490 if test "$drv" = "try-alsa"; then
3491 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3493 else
3494 if test "$drv" = "try-alsa"; then
3495 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3496 else
3497 error_exit "$drv check failed" \
3498 "Make sure to have the $drv libs and headers installed."
3503 pa | try-pa)
3504 if $pkg_config libpulse --exists; then
3505 pulse_libs=$($pkg_config libpulse --libs)
3506 if test "$drv" = "try-pa"; then
3507 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3509 else
3510 if test "$drv" = "try-pa"; then
3511 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3512 else
3513 error_exit "$drv check failed" \
3514 "Make sure to have the $drv libs and headers installed."
3519 sdl)
3520 if test "$sdl" = "no"; then
3521 error_exit "sdl not found or disabled, can not use sdl audio driver"
3525 try-sdl)
3526 if test "$sdl" = "no"; then
3527 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3528 else
3529 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3533 coreaudio)
3534 coreaudio_libs="-framework CoreAudio"
3537 dsound)
3538 dsound_libs="-lole32 -ldxguid"
3539 audio_win_int="yes"
3542 oss)
3543 oss_libs="$oss_lib"
3547 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3548 error_exit "Unknown driver '$drv' selected" \
3549 "Possible drivers are: $audio_possible_drivers"
3552 esac
3553 done
3555 ##########################################
3556 # BrlAPI probe
3558 if test "$brlapi" != "no" ; then
3559 brlapi_libs="-lbrlapi"
3560 cat > $TMPC << EOF
3561 #include <brlapi.h>
3562 #include <stddef.h>
3563 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3565 if compile_prog "" "$brlapi_libs" ; then
3566 brlapi=yes
3567 else
3568 if test "$brlapi" = "yes" ; then
3569 feature_not_found "brlapi" "Install brlapi devel"
3571 brlapi=no
3575 ##########################################
3576 # iconv probe
3577 if test "$iconv" != "no" ; then
3578 cat > $TMPC << EOF
3579 #include <iconv.h>
3580 int main(void) {
3581 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3582 return conv != (iconv_t) -1;
3585 iconv_prefix_list="/usr/local:/usr"
3586 iconv_lib_list=":-liconv"
3587 IFS=:
3588 for iconv_prefix in $iconv_prefix_list; do
3589 IFS=:
3590 iconv_cflags="-I$iconv_prefix/include"
3591 iconv_ldflags="-L$iconv_prefix/lib"
3592 for iconv_link in $iconv_lib_list; do
3593 unset IFS
3594 iconv_lib="$iconv_ldflags $iconv_link"
3595 echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3596 if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3597 iconv_found=yes
3598 break
3600 done
3601 if test "$iconv_found" = yes ; then
3602 break
3604 done
3605 if test "$iconv_found" = "yes" ; then
3606 iconv=yes
3607 else
3608 if test "$iconv" = "yes" ; then
3609 feature_not_found "iconv" "Install iconv devel"
3611 iconv=no
3615 ##########################################
3616 # curses probe
3617 if test "$iconv" = "no" ; then
3618 # curses will need iconv
3619 curses=no
3621 if test "$curses" != "no" ; then
3622 if test "$mingw32" = "yes" ; then
3623 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3624 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3625 else
3626 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3627 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3629 curses_found=no
3630 cat > $TMPC << EOF
3631 #include <locale.h>
3632 #include <curses.h>
3633 #include <wchar.h>
3634 #include <langinfo.h>
3635 int main(void) {
3636 const char *codeset;
3637 wchar_t wch = L'w';
3638 setlocale(LC_ALL, "");
3639 resize_term(0, 0);
3640 addwstr(L"wide chars\n");
3641 addnwstr(&wch, 1);
3642 add_wch(WACS_DEGREE);
3643 codeset = nl_langinfo(CODESET);
3644 return codeset != 0;
3647 IFS=:
3648 for curses_inc in $curses_inc_list; do
3649 # Make sure we get the wide character prototypes
3650 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3651 IFS=:
3652 for curses_lib in $curses_lib_list; do
3653 unset IFS
3654 if compile_prog "$curses_inc" "$curses_lib" ; then
3655 curses_found=yes
3656 break
3658 done
3659 if test "$curses_found" = yes ; then
3660 break
3662 done
3663 unset IFS
3664 if test "$curses_found" = "yes" ; then
3665 curses=yes
3666 else
3667 if test "$curses" = "yes" ; then
3668 feature_not_found "curses" "Install ncurses devel"
3670 curses=no
3674 ##########################################
3675 # curl probe
3676 if test "$curl" != "no" ; then
3677 if $pkg_config libcurl --exists; then
3678 curlconfig="$pkg_config libcurl"
3679 else
3680 curlconfig=curl-config
3682 cat > $TMPC << EOF
3683 #include <curl/curl.h>
3684 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3686 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3687 curl_libs=$($curlconfig --libs 2>/dev/null)
3688 if compile_prog "$curl_cflags" "$curl_libs" ; then
3689 curl=yes
3690 else
3691 if test "$curl" = "yes" ; then
3692 feature_not_found "curl" "Install libcurl devel"
3694 curl=no
3696 fi # test "$curl"
3698 ##########################################
3699 # bluez support probe
3700 if test "$bluez" != "no" ; then
3701 cat > $TMPC << EOF
3702 #include <bluetooth/bluetooth.h>
3703 int main(void) { return bt_error(0); }
3705 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3706 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3707 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3708 bluez=yes
3709 libs_softmmu="$bluez_libs $libs_softmmu"
3710 else
3711 if test "$bluez" = "yes" ; then
3712 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3714 bluez="no"
3718 ##########################################
3719 # glib support probe
3721 glib_req_ver=2.48
3722 glib_modules=gthread-2.0
3723 if test "$modules" = yes; then
3724 glib_modules="$glib_modules gmodule-export-2.0"
3726 if test "$plugins" = yes; then
3727 glib_modules="$glib_modules gmodule-2.0"
3730 # This workaround is required due to a bug in pkg-config file for glib as it
3731 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3733 if test "$static" = yes && test "$mingw32" = yes; then
3734 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3737 for i in $glib_modules; do
3738 if $pkg_config --atleast-version=$glib_req_ver $i; then
3739 glib_cflags=$($pkg_config --cflags $i)
3740 glib_libs=$($pkg_config --libs $i)
3741 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3742 LIBS="$glib_libs $LIBS"
3743 libs_qga="$glib_libs $libs_qga"
3744 else
3745 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3747 done
3749 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3750 gio=yes
3751 gio_cflags=$($pkg_config --cflags gio-2.0)
3752 gio_libs=$($pkg_config --libs gio-2.0)
3753 else
3754 gio=no
3757 # Sanity check that the current size_t matches the
3758 # size that glib thinks it should be. This catches
3759 # problems on multi-arch where people try to build
3760 # 32-bit QEMU while pointing at 64-bit glib headers
3761 cat > $TMPC <<EOF
3762 #include <glib.h>
3763 #include <unistd.h>
3765 #define QEMU_BUILD_BUG_ON(x) \
3766 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3768 int main(void) {
3769 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3770 return 0;
3774 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3775 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3776 "You probably need to set PKG_CONFIG_LIBDIR"\
3777 "to point to the right pkg-config files for your"\
3778 "build target"
3781 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3782 cat > $TMPC << EOF
3783 #include <glib.h>
3784 int main(void) { return 0; }
3786 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3787 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3788 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3789 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3793 #########################################
3794 # zlib check
3796 if test "$zlib" != "no" ; then
3797 if $pkg_config --exists zlib; then
3798 zlib_cflags=$($pkg_config --cflags zlib)
3799 zlib_libs=$($pkg_config --libs zlib)
3800 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3801 LIBS="$zlib_libs $LIBS"
3802 else
3803 cat > $TMPC << EOF
3804 #include <zlib.h>
3805 int main(void) { zlibVersion(); return 0; }
3807 if compile_prog "" "-lz" ; then
3808 LIBS="$LIBS -lz"
3809 else
3810 error_exit "zlib check failed" \
3811 "Make sure to have the zlib libs and headers installed."
3816 ##########################################
3817 # SHA command probe for modules
3818 if test "$modules" = yes; then
3819 shacmd_probe="sha1sum sha1 shasum"
3820 for c in $shacmd_probe; do
3821 if has $c; then
3822 shacmd="$c"
3823 break
3825 done
3826 if test "$shacmd" = ""; then
3827 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3831 ##########################################
3832 # pixman support probe
3834 if test "$want_tools" = "no" && test "$softmmu" = "no"; then
3835 pixman_cflags=
3836 pixman_libs=
3837 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3838 pixman_cflags=$($pkg_config --cflags pixman-1)
3839 pixman_libs=$($pkg_config --libs pixman-1)
3840 else
3841 error_exit "pixman >= 0.21.8 not present." \
3842 "Please install the pixman devel package."
3845 ##########################################
3846 # libmpathpersist probe
3848 if test "$mpath" != "no" ; then
3849 # probe for the new API
3850 cat > $TMPC <<EOF
3851 #include <libudev.h>
3852 #include <mpath_persist.h>
3853 unsigned mpath_mx_alloc_len = 1024;
3854 int logsink;
3855 static struct config *multipath_conf;
3856 extern struct udev *udev;
3857 extern struct config *get_multipath_config(void);
3858 extern void put_multipath_config(struct config *conf);
3859 struct udev *udev;
3860 struct config *get_multipath_config(void) { return multipath_conf; }
3861 void put_multipath_config(struct config *conf) { }
3863 int main(void) {
3864 udev = udev_new();
3865 multipath_conf = mpath_lib_init();
3866 return 0;
3869 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3870 mpathpersist=yes
3871 mpathpersist_new_api=yes
3872 else
3873 # probe for the old API
3874 cat > $TMPC <<EOF
3875 #include <libudev.h>
3876 #include <mpath_persist.h>
3877 unsigned mpath_mx_alloc_len = 1024;
3878 int logsink;
3879 int main(void) {
3880 struct udev *udev = udev_new();
3881 mpath_lib_init(udev);
3882 return 0;
3885 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3886 mpathpersist=yes
3887 mpathpersist_new_api=no
3888 else
3889 mpathpersist=no
3892 else
3893 mpathpersist=no
3896 ##########################################
3897 # libcap probe
3899 if test "$cap" != "no" ; then
3900 cat > $TMPC <<EOF
3901 #include <stdio.h>
3902 #include <sys/capability.h>
3903 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3905 if compile_prog "" "-lcap" ; then
3906 cap=yes
3907 else
3908 cap=no
3912 ##########################################
3913 # pthread probe
3914 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3916 pthread=no
3917 cat > $TMPC << EOF
3918 #include <pthread.h>
3919 static void *f(void *p) { return NULL; }
3920 int main(void) {
3921 pthread_t thread;
3922 pthread_create(&thread, 0, f, 0);
3923 return 0;
3926 if compile_prog "" "" ; then
3927 pthread=yes
3928 else
3929 for pthread_lib in $PTHREADLIBS_LIST; do
3930 if compile_prog "" "$pthread_lib" ; then
3931 pthread=yes
3932 found=no
3933 for lib_entry in $LIBS; do
3934 if test "$lib_entry" = "$pthread_lib"; then
3935 found=yes
3936 break
3938 done
3939 if test "$found" = "no"; then
3940 LIBS="$pthread_lib $LIBS"
3941 libs_qga="$pthread_lib $libs_qga"
3943 PTHREAD_LIB="$pthread_lib"
3944 break
3946 done
3949 if test "$mingw32" != yes && test "$pthread" = no; then
3950 error_exit "pthread check failed" \
3951 "Make sure to have the pthread libs and headers installed."
3954 # check for pthread_setname_np with thread id
3955 pthread_setname_np_w_tid=no
3956 cat > $TMPC << EOF
3957 #include <pthread.h>
3959 static void *f(void *p) { return NULL; }
3960 int main(void)
3962 pthread_t thread;
3963 pthread_create(&thread, 0, f, 0);
3964 pthread_setname_np(thread, "QEMU");
3965 return 0;
3968 if compile_prog "" "$pthread_lib" ; then
3969 pthread_setname_np_w_tid=yes
3972 # check for pthread_setname_np without thread id
3973 pthread_setname_np_wo_tid=no
3974 cat > $TMPC << EOF
3975 #include <pthread.h>
3977 static void *f(void *p) { pthread_setname_np("QEMU"); }
3978 int main(void)
3980 pthread_t thread;
3981 pthread_create(&thread, 0, f, 0);
3982 return 0;
3985 if compile_prog "" "$pthread_lib" ; then
3986 pthread_setname_np_wo_tid=yes
3989 ##########################################
3990 # rbd probe
3991 if test "$rbd" != "no" ; then
3992 cat > $TMPC <<EOF
3993 #include <stdio.h>
3994 #include <rbd/librbd.h>
3995 int main(void) {
3996 rados_t cluster;
3997 rados_create(&cluster, NULL);
3998 return 0;
4001 rbd_libs="-lrbd -lrados"
4002 if compile_prog "" "$rbd_libs" ; then
4003 rbd=yes
4004 else
4005 if test "$rbd" = "yes" ; then
4006 feature_not_found "rados block device" "Install librbd/ceph devel"
4008 rbd=no
4012 ##########################################
4013 # libssh probe
4014 if test "$libssh" != "no" ; then
4015 if $pkg_config --exists libssh; then
4016 libssh_cflags=$($pkg_config libssh --cflags)
4017 libssh_libs=$($pkg_config libssh --libs)
4018 libssh=yes
4019 else
4020 if test "$libssh" = "yes" ; then
4021 error_exit "libssh required for --enable-libssh"
4023 libssh=no
4027 ##########################################
4028 # Check for libssh 0.8
4029 # This is done like this instead of using the LIBSSH_VERSION_* and
4030 # SSH_VERSION_* macros because some distributions in the past shipped
4031 # snapshots of the future 0.8 from Git, and those snapshots did not
4032 # have updated version numbers (still referring to 0.7.0).
4034 if test "$libssh" = "yes"; then
4035 cat > $TMPC <<EOF
4036 #include <libssh/libssh.h>
4037 int main(void) { return ssh_get_server_publickey(NULL, NULL); }
4039 if compile_prog "$libssh_cflags" "$libssh_libs"; then
4040 libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
4044 ##########################################
4045 # linux-aio probe
4047 if test "$linux_aio" != "no" ; then
4048 cat > $TMPC <<EOF
4049 #include <libaio.h>
4050 #include <sys/eventfd.h>
4051 #include <stddef.h>
4052 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
4054 if compile_prog "" "-laio" ; then
4055 linux_aio=yes
4056 else
4057 if test "$linux_aio" = "yes" ; then
4058 feature_not_found "linux AIO" "Install libaio devel"
4060 linux_aio=no
4064 ##########################################
4065 # TPM emulation is only on POSIX
4067 if test "$tpm" = ""; then
4068 if test "$mingw32" = "yes"; then
4069 tpm=no
4070 else
4071 tpm=yes
4073 elif test "$tpm" = "yes"; then
4074 if test "$mingw32" = "yes" ; then
4075 error_exit "TPM emulation only available on POSIX systems"
4079 ##########################################
4080 # attr probe
4082 if test "$attr" != "no" ; then
4083 cat > $TMPC <<EOF
4084 #include <stdio.h>
4085 #include <sys/types.h>
4086 #ifdef CONFIG_LIBATTR
4087 #include <attr/xattr.h>
4088 #else
4089 #include <sys/xattr.h>
4090 #endif
4091 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
4093 if compile_prog "" "" ; then
4094 attr=yes
4095 # Older distros have <attr/xattr.h>, and need -lattr:
4096 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
4097 attr=yes
4098 LIBS="-lattr $LIBS"
4099 libattr=yes
4100 else
4101 if test "$attr" = "yes" ; then
4102 feature_not_found "ATTR" "Install libc6 or libattr devel"
4104 attr=no
4108 ##########################################
4109 # iovec probe
4110 cat > $TMPC <<EOF
4111 #include <sys/types.h>
4112 #include <sys/uio.h>
4113 #include <unistd.h>
4114 int main(void) { return sizeof(struct iovec); }
4116 iovec=no
4117 if compile_prog "" "" ; then
4118 iovec=yes
4121 ##########################################
4122 # preadv probe
4123 cat > $TMPC <<EOF
4124 #include <sys/types.h>
4125 #include <sys/uio.h>
4126 #include <unistd.h>
4127 int main(void) { return preadv(0, 0, 0, 0); }
4129 preadv=no
4130 if compile_prog "" "" ; then
4131 preadv=yes
4134 ##########################################
4135 # fdt probe
4136 # fdt support is mandatory for at least some target architectures,
4137 # so insist on it if we're building those system emulators.
4138 fdt_required=no
4139 for target in $target_list; do
4140 case $target in
4141 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
4142 fdt_required=yes
4144 esac
4145 done
4147 if test "$fdt_required" = "yes"; then
4148 if test "$fdt" = "no"; then
4149 error_exit "fdt disabled but some requested targets require it." \
4150 "You can turn off fdt only if you also disable all the system emulation" \
4151 "targets which need it (by specifying a cut down --target-list)."
4153 fdt=yes
4156 if test "$fdt" != "no" ; then
4157 fdt_libs="-lfdt"
4158 # explicitly check for libfdt_env.h as it is missing in some stable installs
4159 # and test for required functions to make sure we are on a version >= 1.4.2
4160 cat > $TMPC << EOF
4161 #include <libfdt.h>
4162 #include <libfdt_env.h>
4163 int main(void) { fdt_check_full(NULL, 0); return 0; }
4165 if compile_prog "" "$fdt_libs" ; then
4166 # system DTC is good - use it
4167 fdt=system
4168 else
4169 # have GIT checkout, so activate dtc submodule
4170 if test -e "${source_path}/.git" ; then
4171 git_submodules="${git_submodules} dtc"
4173 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4174 fdt=git
4175 mkdir -p dtc
4176 if [ "$pwd_is_source_path" != "y" ] ; then
4177 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
4178 symlink "$source_path/dtc/scripts" "dtc/scripts"
4180 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
4181 fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
4182 fdt_libs="$fdt_libs"
4183 elif test "$fdt" = "yes" ; then
4184 # Not a git build & no libfdt found, prompt for system install
4185 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4186 "Please install the DTC (libfdt) devel package"
4187 else
4188 # don't have and don't want
4189 fdt_libs=
4190 fdt=no
4195 libs_softmmu="$libs_softmmu $fdt_libs"
4197 ##########################################
4198 # opengl probe (for sdl2, gtk, milkymist-tmu2)
4200 gbm="no"
4201 if $pkg_config gbm; then
4202 gbm_cflags="$($pkg_config --cflags gbm)"
4203 gbm_libs="$($pkg_config --libs gbm)"
4204 gbm="yes"
4207 if test "$opengl" != "no" ; then
4208 opengl_pkgs="epoxy gbm"
4209 if $pkg_config $opengl_pkgs; then
4210 opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
4211 opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4212 opengl=yes
4213 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4214 gtk_gl="yes"
4216 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
4217 else
4218 if test "$opengl" = "yes" ; then
4219 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
4221 opengl_cflags=""
4222 opengl_libs=""
4223 opengl=no
4227 if test "$opengl" = "yes"; then
4228 cat > $TMPC << EOF
4229 #include <epoxy/egl.h>
4230 #ifndef EGL_MESA_image_dma_buf_export
4231 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4232 #endif
4233 int main(void) { return 0; }
4235 if compile_prog "" "" ; then
4236 opengl_dmabuf=yes
4240 if test "$opengl" = "yes" && test "$have_x11" = "yes"; then
4241 for target in $target_list; do
4242 case $target in
4243 lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
4244 need_x11=yes
4246 esac
4247 done
4250 ##########################################
4251 # libxml2 probe
4252 if test "$libxml2" != "no" ; then
4253 if $pkg_config --exists libxml-2.0; then
4254 libxml2="yes"
4255 libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4256 libxml2_libs=$($pkg_config --libs libxml-2.0)
4257 else
4258 if test "$libxml2" = "yes"; then
4259 feature_not_found "libxml2" "Install libxml2 devel"
4261 libxml2="no"
4265 ##########################################
4266 # glusterfs probe
4267 if test "$glusterfs" != "no" ; then
4268 if $pkg_config --atleast-version=3 glusterfs-api; then
4269 glusterfs="yes"
4270 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
4271 glusterfs_libs=$($pkg_config --libs glusterfs-api)
4272 if $pkg_config --atleast-version=4 glusterfs-api; then
4273 glusterfs_xlator_opt="yes"
4275 if $pkg_config --atleast-version=5 glusterfs-api; then
4276 glusterfs_discard="yes"
4278 if $pkg_config --atleast-version=6 glusterfs-api; then
4279 glusterfs_fallocate="yes"
4280 glusterfs_zerofill="yes"
4282 cat > $TMPC << EOF
4283 #include <glusterfs/api/glfs.h>
4286 main(void)
4288 /* new glfs_ftruncate() passes two additional args */
4289 return glfs_ftruncate(NULL, 0, NULL, NULL);
4292 if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4293 glusterfs_ftruncate_has_stat="yes"
4295 cat > $TMPC << EOF
4296 #include <glusterfs/api/glfs.h>
4298 /* new glfs_io_cbk() passes two additional glfs_stat structs */
4299 static void
4300 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
4304 main(void)
4306 glfs_io_cbk iocb = &glusterfs_iocb;
4307 iocb(NULL, 0 , NULL, NULL, NULL);
4308 return 0;
4311 if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4312 glusterfs_iocb_has_stat="yes"
4314 else
4315 if test "$glusterfs" = "yes" ; then
4316 feature_not_found "GlusterFS backend support" \
4317 "Install glusterfs-api devel >= 3"
4319 glusterfs="no"
4323 # Check for inotify functions when we are building linux-user
4324 # emulator. This is done because older glibc versions don't
4325 # have syscall stubs for these implemented. In that case we
4326 # don't provide them even if kernel supports them.
4328 inotify=no
4329 cat > $TMPC << EOF
4330 #include <sys/inotify.h>
4333 main(void)
4335 /* try to start inotify */
4336 return inotify_init();
4339 if compile_prog "" "" ; then
4340 inotify=yes
4343 inotify1=no
4344 cat > $TMPC << EOF
4345 #include <sys/inotify.h>
4348 main(void)
4350 /* try to start inotify */
4351 return inotify_init1(0);
4354 if compile_prog "" "" ; then
4355 inotify1=yes
4358 # check if pipe2 is there
4359 pipe2=no
4360 cat > $TMPC << EOF
4361 #include <unistd.h>
4362 #include <fcntl.h>
4364 int main(void)
4366 int pipefd[2];
4367 return pipe2(pipefd, O_CLOEXEC);
4370 if compile_prog "" "" ; then
4371 pipe2=yes
4374 # check if accept4 is there
4375 accept4=no
4376 cat > $TMPC << EOF
4377 #include <sys/socket.h>
4378 #include <stddef.h>
4380 int main(void)
4382 accept4(0, NULL, NULL, SOCK_CLOEXEC);
4383 return 0;
4386 if compile_prog "" "" ; then
4387 accept4=yes
4390 # check if tee/splice is there. vmsplice was added same time.
4391 splice=no
4392 cat > $TMPC << EOF
4393 #include <unistd.h>
4394 #include <fcntl.h>
4395 #include <limits.h>
4397 int main(void)
4399 int len, fd = 0;
4400 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
4401 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
4402 return 0;
4405 if compile_prog "" "" ; then
4406 splice=yes
4409 ##########################################
4410 # libnuma probe
4412 if test "$numa" != "no" ; then
4413 cat > $TMPC << EOF
4414 #include <numa.h>
4415 int main(void) { return numa_available(); }
4418 if compile_prog "" "-lnuma" ; then
4419 numa=yes
4420 libs_softmmu="-lnuma $libs_softmmu"
4421 else
4422 if test "$numa" = "yes" ; then
4423 feature_not_found "numa" "install numactl devel"
4425 numa=no
4429 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
4430 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
4431 exit 1
4434 # Even if malloc_trim() is available, these non-libc memory allocators
4435 # do not support it.
4436 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
4437 if test "$malloc_trim" = "yes" ; then
4438 echo "Disabling malloc_trim with non-libc memory allocator"
4440 malloc_trim="no"
4443 #######################################
4444 # malloc_trim
4446 if test "$malloc_trim" != "no" ; then
4447 cat > $TMPC << EOF
4448 #include <malloc.h>
4449 int main(void) { malloc_trim(0); return 0; }
4451 if compile_prog "" "" ; then
4452 malloc_trim="yes"
4453 else
4454 malloc_trim="no"
4458 ##########################################
4459 # tcmalloc probe
4461 if test "$tcmalloc" = "yes" ; then
4462 cat > $TMPC << EOF
4463 #include <stdlib.h>
4464 int main(void) { malloc(1); return 0; }
4467 if compile_prog "" "-ltcmalloc" ; then
4468 LIBS="-ltcmalloc $LIBS"
4469 else
4470 feature_not_found "tcmalloc" "install gperftools devel"
4474 ##########################################
4475 # jemalloc probe
4477 if test "$jemalloc" = "yes" ; then
4478 cat > $TMPC << EOF
4479 #include <stdlib.h>
4480 int main(void) { malloc(1); return 0; }
4483 if compile_prog "" "-ljemalloc" ; then
4484 LIBS="-ljemalloc $LIBS"
4485 else
4486 feature_not_found "jemalloc" "install jemalloc devel"
4490 ##########################################
4491 # signalfd probe
4492 signalfd="no"
4493 cat > $TMPC << EOF
4494 #include <unistd.h>
4495 #include <sys/syscall.h>
4496 #include <signal.h>
4497 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4500 if compile_prog "" "" ; then
4501 signalfd=yes
4504 # check if optreset global is declared by <getopt.h>
4505 optreset="no"
4506 cat > $TMPC << EOF
4507 #include <getopt.h>
4508 int main(void) { return optreset; }
4511 if compile_prog "" "" ; then
4512 optreset=yes
4515 # check if eventfd is supported
4516 eventfd=no
4517 cat > $TMPC << EOF
4518 #include <sys/eventfd.h>
4520 int main(void)
4522 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4525 if compile_prog "" "" ; then
4526 eventfd=yes
4529 # check if memfd is supported
4530 memfd=no
4531 cat > $TMPC << EOF
4532 #include <sys/mman.h>
4534 int main(void)
4536 return memfd_create("foo", MFD_ALLOW_SEALING);
4539 if compile_prog "" "" ; then
4540 memfd=yes
4543 # check for usbfs
4544 have_usbfs=no
4545 if test "$linux_user" = "yes"; then
4546 cat > $TMPC << EOF
4547 #include <linux/usbdevice_fs.h>
4549 #ifndef USBDEVFS_GET_CAPABILITIES
4550 #error "USBDEVFS_GET_CAPABILITIES undefined"
4551 #endif
4553 #ifndef USBDEVFS_DISCONNECT_CLAIM
4554 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
4555 #endif
4557 int main(void)
4559 return 0;
4562 if compile_prog "" ""; then
4563 have_usbfs=yes
4567 # check for fallocate
4568 fallocate=no
4569 cat > $TMPC << EOF
4570 #include <fcntl.h>
4572 int main(void)
4574 fallocate(0, 0, 0, 0);
4575 return 0;
4578 if compile_prog "" "" ; then
4579 fallocate=yes
4582 # check for fallocate hole punching
4583 fallocate_punch_hole=no
4584 cat > $TMPC << EOF
4585 #include <fcntl.h>
4586 #include <linux/falloc.h>
4588 int main(void)
4590 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4591 return 0;
4594 if compile_prog "" "" ; then
4595 fallocate_punch_hole=yes
4598 # check that fallocate supports range zeroing inside the file
4599 fallocate_zero_range=no
4600 cat > $TMPC << EOF
4601 #include <fcntl.h>
4602 #include <linux/falloc.h>
4604 int main(void)
4606 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4607 return 0;
4610 if compile_prog "" "" ; then
4611 fallocate_zero_range=yes
4614 # check for posix_fallocate
4615 posix_fallocate=no
4616 cat > $TMPC << EOF
4617 #include <fcntl.h>
4619 int main(void)
4621 posix_fallocate(0, 0, 0);
4622 return 0;
4625 if compile_prog "" "" ; then
4626 posix_fallocate=yes
4629 # check for sync_file_range
4630 sync_file_range=no
4631 cat > $TMPC << EOF
4632 #include <fcntl.h>
4634 int main(void)
4636 sync_file_range(0, 0, 0, 0);
4637 return 0;
4640 if compile_prog "" "" ; then
4641 sync_file_range=yes
4644 # check for linux/fiemap.h and FS_IOC_FIEMAP
4645 fiemap=no
4646 cat > $TMPC << EOF
4647 #include <sys/ioctl.h>
4648 #include <linux/fs.h>
4649 #include <linux/fiemap.h>
4651 int main(void)
4653 ioctl(0, FS_IOC_FIEMAP, 0);
4654 return 0;
4657 if compile_prog "" "" ; then
4658 fiemap=yes
4661 # check for dup3
4662 dup3=no
4663 cat > $TMPC << EOF
4664 #include <unistd.h>
4666 int main(void)
4668 dup3(0, 0, 0);
4669 return 0;
4672 if compile_prog "" "" ; then
4673 dup3=yes
4676 # check for ppoll support
4677 ppoll=no
4678 cat > $TMPC << EOF
4679 #include <poll.h>
4681 int main(void)
4683 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4684 ppoll(&pfd, 1, 0, 0);
4685 return 0;
4688 if compile_prog "" "" ; then
4689 ppoll=yes
4692 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4693 prctl_pr_set_timerslack=no
4694 cat > $TMPC << EOF
4695 #include <sys/prctl.h>
4697 int main(void)
4699 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4700 return 0;
4703 if compile_prog "" "" ; then
4704 prctl_pr_set_timerslack=yes
4707 # check for epoll support
4708 epoll=no
4709 cat > $TMPC << EOF
4710 #include <sys/epoll.h>
4712 int main(void)
4714 epoll_create(0);
4715 return 0;
4718 if compile_prog "" "" ; then
4719 epoll=yes
4722 # epoll_create1 is a later addition
4723 # so we must check separately for its presence
4724 epoll_create1=no
4725 cat > $TMPC << EOF
4726 #include <sys/epoll.h>
4728 int main(void)
4730 /* Note that we use epoll_create1 as a value, not as
4731 * a function being called. This is necessary so that on
4732 * old SPARC glibc versions where the function was present in
4733 * the library but not declared in the header file we will
4734 * fail the configure check. (Otherwise we will get a compiler
4735 * warning but not an error, and will proceed to fail the
4736 * qemu compile where we compile with -Werror.)
4738 return (int)(uintptr_t)&epoll_create1;
4741 if compile_prog "" "" ; then
4742 epoll_create1=yes
4745 # check for sendfile support
4746 sendfile=no
4747 cat > $TMPC << EOF
4748 #include <sys/sendfile.h>
4750 int main(void)
4752 return sendfile(0, 0, 0, 0);
4755 if compile_prog "" "" ; then
4756 sendfile=yes
4759 # check for timerfd support (glibc 2.8 and newer)
4760 timerfd=no
4761 cat > $TMPC << EOF
4762 #include <sys/timerfd.h>
4764 int main(void)
4766 return(timerfd_create(CLOCK_REALTIME, 0));
4769 if compile_prog "" "" ; then
4770 timerfd=yes
4773 # check for setns and unshare support
4774 setns=no
4775 cat > $TMPC << EOF
4776 #include <sched.h>
4778 int main(void)
4780 int ret;
4781 ret = setns(0, 0);
4782 ret = unshare(0);
4783 return ret;
4786 if compile_prog "" "" ; then
4787 setns=yes
4790 # clock_adjtime probe
4791 clock_adjtime=no
4792 cat > $TMPC <<EOF
4793 #include <time.h>
4795 int main(void)
4797 return clock_adjtime(0, 0);
4800 clock_adjtime=no
4801 if compile_prog "" "" ; then
4802 clock_adjtime=yes
4805 # syncfs probe
4806 syncfs=no
4807 cat > $TMPC <<EOF
4808 #include <unistd.h>
4810 int main(void)
4812 return syncfs(0);
4815 syncfs=no
4816 if compile_prog "" "" ; then
4817 syncfs=yes
4820 # Check we have a new enough version of sphinx-build
4821 has_sphinx_build() {
4822 # This is a bit awkward but works: create a trivial document and
4823 # try to run it with our configuration file (which enforces a
4824 # version requirement). This will fail if either
4825 # sphinx-build doesn't exist at all or if it is too old.
4826 mkdir -p "$TMPDIR1/sphinx"
4827 touch "$TMPDIR1/sphinx/index.rst"
4828 sphinx-build -c "$source_path/docs" -b html "$TMPDIR1/sphinx" "$TMPDIR1/sphinx/out" >/dev/null 2>&1
4831 # Check if tools are available to build documentation.
4832 if test "$docs" != "no" ; then
4833 if has makeinfo && has pod2man && has_sphinx_build; then
4834 docs=yes
4835 else
4836 if test "$docs" = "yes" ; then
4837 feature_not_found "docs" "Install texinfo, Perl/perl-podlators and python-sphinx"
4839 docs=no
4843 # Search for bswap_32 function
4844 byteswap_h=no
4845 cat > $TMPC << EOF
4846 #include <byteswap.h>
4847 int main(void) { return bswap_32(0); }
4849 if compile_prog "" "" ; then
4850 byteswap_h=yes
4853 # Search for bswap32 function
4854 bswap_h=no
4855 cat > $TMPC << EOF
4856 #include <sys/endian.h>
4857 #include <sys/types.h>
4858 #include <machine/bswap.h>
4859 int main(void) { return bswap32(0); }
4861 if compile_prog "" "" ; then
4862 bswap_h=yes
4865 ##########################################
4866 # Do we have libiscsi >= 1.9.0
4867 if test "$libiscsi" != "no" ; then
4868 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4869 libiscsi="yes"
4870 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4871 libiscsi_libs=$($pkg_config --libs libiscsi)
4872 else
4873 if test "$libiscsi" = "yes" ; then
4874 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4876 libiscsi="no"
4880 ##########################################
4881 # Do we need libm
4882 cat > $TMPC << EOF
4883 #include <math.h>
4884 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4886 if compile_prog "" "" ; then
4888 elif compile_prog "" "-lm" ; then
4889 LIBS="-lm $LIBS"
4890 libs_qga="-lm $libs_qga"
4891 else
4892 error_exit "libm check failed"
4895 ##########################################
4896 # Do we need librt
4897 # uClibc provides 2 versions of clock_gettime(), one with realtime
4898 # support and one without. This means that the clock_gettime() don't
4899 # need -lrt. We still need it for timer_create() so we check for this
4900 # function in addition.
4901 cat > $TMPC <<EOF
4902 #include <signal.h>
4903 #include <time.h>
4904 int main(void) {
4905 timer_create(CLOCK_REALTIME, NULL, NULL);
4906 return clock_gettime(CLOCK_REALTIME, NULL);
4910 if compile_prog "" "" ; then
4912 # we need pthread for static linking. use previous pthread test result
4913 elif compile_prog "" "$pthread_lib -lrt" ; then
4914 LIBS="$LIBS -lrt"
4915 libs_qga="$libs_qga -lrt"
4918 # Check whether we need to link libutil for openpty()
4919 cat > $TMPC << EOF
4920 extern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4921 int main(void) { return openpty(0, 0, 0, 0, 0); }
4924 if ! compile_prog "" "" ; then
4925 if compile_prog "" "-lutil" ; then
4926 libs_softmmu="-lutil $libs_softmmu"
4927 libs_tools="-lutil $libs_tools"
4931 ##########################################
4932 # spice probe
4933 if test "$spice" != "no" ; then
4934 cat > $TMPC << EOF
4935 #include <spice.h>
4936 int main(void) { spice_server_new(); return 0; }
4938 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4939 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4940 if $pkg_config --atleast-version=0.12.5 spice-server && \
4941 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4942 compile_prog "$spice_cflags" "$spice_libs" ; then
4943 spice="yes"
4944 libs_softmmu="$libs_softmmu $spice_libs"
4945 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4946 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4947 spice_server_version=$($pkg_config --modversion spice-server)
4948 else
4949 if test "$spice" = "yes" ; then
4950 feature_not_found "spice" \
4951 "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4953 spice="no"
4957 # check for smartcard support
4958 if test "$smartcard" != "no"; then
4959 if $pkg_config --atleast-version=2.5.1 libcacard; then
4960 libcacard_cflags=$($pkg_config --cflags libcacard)
4961 libcacard_libs=$($pkg_config --libs libcacard)
4962 smartcard="yes"
4963 else
4964 if test "$smartcard" = "yes"; then
4965 feature_not_found "smartcard" "Install libcacard devel"
4967 smartcard="no"
4971 # check for libusb
4972 if test "$libusb" != "no" ; then
4973 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4974 libusb="yes"
4975 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4976 libusb_libs=$($pkg_config --libs libusb-1.0)
4977 else
4978 if test "$libusb" = "yes"; then
4979 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4981 libusb="no"
4985 # check for usbredirparser for usb network redirection support
4986 if test "$usb_redir" != "no" ; then
4987 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4988 usb_redir="yes"
4989 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4990 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4991 else
4992 if test "$usb_redir" = "yes"; then
4993 feature_not_found "usb-redir" "Install usbredir devel"
4995 usb_redir="no"
4999 ##########################################
5000 # check if we have VSS SDK headers for win
5002 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5003 test "$vss_win32_sdk" != "no" ; then
5004 case "$vss_win32_sdk" in
5005 "") vss_win32_include="-isystem $source_path" ;;
5006 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
5007 # handle path with spaces. So we symlink the headers into ".sdk/vss".
5008 vss_win32_include="-isystem $source_path/.sdk/vss"
5009 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
5011 *) vss_win32_include="-isystem $vss_win32_sdk"
5012 esac
5013 cat > $TMPC << EOF
5014 #define __MIDL_user_allocate_free_DEFINED__
5015 #include <inc/win2003/vss.h>
5016 int main(void) { return VSS_CTX_BACKUP; }
5018 if compile_prog "$vss_win32_include" "" ; then
5019 guest_agent_with_vss="yes"
5020 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
5021 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
5022 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
5023 else
5024 if test "$vss_win32_sdk" != "" ; then
5025 echo "ERROR: Please download and install Microsoft VSS SDK:"
5026 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
5027 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
5028 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
5029 echo "ERROR: The headers are extracted in the directory \`inc'."
5030 feature_not_found "VSS support"
5032 guest_agent_with_vss="no"
5036 ##########################################
5037 # lookup Windows platform SDK (if not specified)
5038 # The SDK is needed only to build .tlb (type library) file of guest agent
5039 # VSS provider from the source. It is usually unnecessary because the
5040 # pre-compiled .tlb file is included.
5042 if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5043 test "$guest_agent_with_vss" = "yes" ; then
5044 if test -z "$win_sdk"; then
5045 programfiles="$PROGRAMFILES"
5046 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
5047 if test -n "$programfiles"; then
5048 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
5049 else
5050 feature_not_found "Windows SDK"
5052 elif test "$win_sdk" = "no"; then
5053 win_sdk=""
5057 ##########################################
5058 # check if mingw environment provides a recent ntddscsi.h
5059 if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
5060 cat > $TMPC << EOF
5061 #include <windows.h>
5062 #include <ntddscsi.h>
5063 int main(void) {
5064 #if !defined(IOCTL_SCSI_GET_ADDRESS)
5065 #error Missing required ioctl definitions
5066 #endif
5067 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
5068 return addr.Lun;
5071 if compile_prog "" "" ; then
5072 guest_agent_ntddscsi=yes
5073 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
5077 ##########################################
5078 # virgl renderer probe
5080 if test "$virglrenderer" != "no" ; then
5081 cat > $TMPC << EOF
5082 #include <virglrenderer.h>
5083 int main(void) { virgl_renderer_poll(); return 0; }
5085 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
5086 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
5087 virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
5088 if $pkg_config virglrenderer >/dev/null 2>&1 && \
5089 compile_prog "$virgl_cflags" "$virgl_libs" ; then
5090 virglrenderer="yes"
5091 else
5092 if test "$virglrenderer" = "yes" ; then
5093 feature_not_found "virglrenderer"
5095 virglrenderer="no"
5099 ##########################################
5100 # capstone
5102 case "$capstone" in
5103 "" | yes)
5104 if $pkg_config capstone; then
5105 capstone=system
5106 elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5107 capstone=git
5108 elif test -e "${source_path}/capstone/Makefile" ; then
5109 capstone=internal
5110 elif test -z "$capstone" ; then
5111 capstone=no
5112 else
5113 feature_not_found "capstone" "Install capstone devel or git submodule"
5117 system)
5118 if ! $pkg_config capstone; then
5119 feature_not_found "capstone" "Install capstone devel"
5122 esac
5124 case "$capstone" in
5125 git | internal)
5126 if test "$capstone" = git; then
5127 git_submodules="${git_submodules} capstone"
5129 mkdir -p capstone
5130 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
5131 if test "$mingw32" = "yes"; then
5132 LIBCAPSTONE=capstone.lib
5133 else
5134 LIBCAPSTONE=libcapstone.a
5136 libs_cpu="-L\$(BUILD_DIR)/capstone -lcapstone $libs_cpu"
5139 system)
5140 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
5141 libs_cpu="$($pkg_config --libs capstone) $libs_cpu"
5147 error_exit "Unknown state for capstone: $capstone"
5149 esac
5151 ##########################################
5152 # check if we have fdatasync
5154 fdatasync=no
5155 cat > $TMPC << EOF
5156 #include <unistd.h>
5157 int main(void) {
5158 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5159 return fdatasync(0);
5160 #else
5161 #error Not supported
5162 #endif
5165 if compile_prog "" "" ; then
5166 fdatasync=yes
5169 ##########################################
5170 # check if we have madvise
5172 madvise=no
5173 cat > $TMPC << EOF
5174 #include <sys/types.h>
5175 #include <sys/mman.h>
5176 #include <stddef.h>
5177 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5179 if compile_prog "" "" ; then
5180 madvise=yes
5183 ##########################################
5184 # check if we have posix_madvise
5186 posix_madvise=no
5187 cat > $TMPC << EOF
5188 #include <sys/mman.h>
5189 #include <stddef.h>
5190 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5192 if compile_prog "" "" ; then
5193 posix_madvise=yes
5196 ##########################################
5197 # check if we have posix_memalign()
5199 posix_memalign=no
5200 cat > $TMPC << EOF
5201 #include <stdlib.h>
5202 int main(void) {
5203 void *p;
5204 return posix_memalign(&p, 8, 8);
5207 if compile_prog "" "" ; then
5208 posix_memalign=yes
5211 ##########################################
5212 # check if we have posix_syslog
5214 posix_syslog=no
5215 cat > $TMPC << EOF
5216 #include <syslog.h>
5217 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
5219 if compile_prog "" "" ; then
5220 posix_syslog=yes
5223 ##########################################
5224 # check if we have sem_timedwait
5226 sem_timedwait=no
5227 cat > $TMPC << EOF
5228 #include <semaphore.h>
5229 int main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5231 if compile_prog "" "" ; then
5232 sem_timedwait=yes
5235 ##########################################
5236 # check if we have strchrnul
5238 strchrnul=no
5239 cat > $TMPC << EOF
5240 #include <string.h>
5241 int main(void);
5242 // Use a haystack that the compiler shouldn't be able to constant fold
5243 char *haystack = (char*)&main;
5244 int main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
5246 if compile_prog "" "" ; then
5247 strchrnul=yes
5250 ##########################################
5251 # check if trace backend exists
5253 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
5254 if test "$?" -ne 0 ; then
5255 error_exit "invalid trace backends" \
5256 "Please choose supported trace backends."
5259 ##########################################
5260 # For 'ust' backend, test if ust headers are present
5261 if have_backend "ust"; then
5262 cat > $TMPC << EOF
5263 #include <lttng/tracepoint.h>
5264 int main(void) { return 0; }
5266 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5267 if $pkg_config lttng-ust --exists; then
5268 lttng_ust_libs=$($pkg_config --libs lttng-ust)
5269 else
5270 lttng_ust_libs="-llttng-ust -ldl"
5272 if $pkg_config liburcu-bp --exists; then
5273 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5274 else
5275 urcu_bp_libs="-lurcu-bp"
5278 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5279 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
5280 else
5281 error_exit "Trace backend 'ust' missing lttng-ust header files"
5285 ##########################################
5286 # For 'dtrace' backend, test if 'dtrace' command is present
5287 if have_backend "dtrace"; then
5288 if ! has 'dtrace' ; then
5289 error_exit "dtrace command is not found in PATH $PATH"
5291 trace_backend_stap="no"
5292 if has 'stap' ; then
5293 trace_backend_stap="yes"
5297 ##########################################
5298 # check and set a backend for coroutine
5300 # We prefer ucontext, but it's not always possible. The fallback
5301 # is sigcontext. On Windows the only valid backend is the Windows
5302 # specific one.
5304 ucontext_works=no
5305 if test "$darwin" != "yes"; then
5306 cat > $TMPC << EOF
5307 #include <ucontext.h>
5308 #ifdef __stub_makecontext
5309 #error Ignoring glibc stub makecontext which will always fail
5310 #endif
5311 int main(void) { makecontext(0, 0, 0); return 0; }
5313 if compile_prog "" "" ; then
5314 ucontext_works=yes
5318 if test "$coroutine" = ""; then
5319 if test "$mingw32" = "yes"; then
5320 coroutine=win32
5321 elif test "$ucontext_works" = "yes"; then
5322 coroutine=ucontext
5323 else
5324 coroutine=sigaltstack
5326 else
5327 case $coroutine in
5328 windows)
5329 if test "$mingw32" != "yes"; then
5330 error_exit "'windows' coroutine backend only valid for Windows"
5332 # Unfortunately the user visible backend name doesn't match the
5333 # coroutine-*.c filename for this case, so we have to adjust it here.
5334 coroutine=win32
5336 ucontext)
5337 if test "$ucontext_works" != "yes"; then
5338 feature_not_found "ucontext"
5341 sigaltstack)
5342 if test "$mingw32" = "yes"; then
5343 error_exit "only the 'windows' coroutine backend is valid for Windows"
5347 error_exit "unknown coroutine backend $coroutine"
5349 esac
5352 if test "$coroutine_pool" = ""; then
5353 if test "$coroutine" = "gthread" -o "$coroutine" = "win32"; then
5354 coroutine_pool=no
5355 else
5356 coroutine_pool=yes
5359 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
5360 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
5363 if test "$debug_stack_usage" = "yes"; then
5364 if test "$coroutine_pool" = "yes"; then
5365 echo "WARN: disabling coroutine pool for stack usage debugging"
5366 coroutine_pool=no
5371 ##########################################
5372 # check if we have open_by_handle_at
5374 open_by_handle_at=no
5375 cat > $TMPC << EOF
5376 #include <fcntl.h>
5377 #if !defined(AT_EMPTY_PATH)
5378 # error missing definition
5379 #else
5380 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5381 #endif
5383 if compile_prog "" "" ; then
5384 open_by_handle_at=yes
5387 ########################################
5388 # check if we have linux/magic.h
5390 linux_magic_h=no
5391 cat > $TMPC << EOF
5392 #include <linux/magic.h>
5393 int main(void) {
5394 return 0;
5397 if compile_prog "" "" ; then
5398 linux_magic_h=yes
5401 ########################################
5402 # check whether we can disable warning option with a pragma (this is needed
5403 # to silence warnings in the headers of some versions of external libraries).
5404 # This test has to be compiled with -Werror as otherwise an unknown pragma is
5405 # only a warning.
5407 # If we can't selectively disable warning in the code, disable -Werror so that
5408 # the build doesn't fail anyway.
5410 pragma_disable_unused_but_set=no
5411 cat > $TMPC << EOF
5412 #pragma GCC diagnostic push
5413 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
5414 #pragma GCC diagnostic pop
5416 int main(void) {
5417 return 0;
5420 if compile_prog "-Werror" "" ; then
5421 pragma_diagnostic_available=yes
5424 ########################################
5425 # check if we have valgrind/valgrind.h
5427 valgrind_h=no
5428 cat > $TMPC << EOF
5429 #include <valgrind/valgrind.h>
5430 int main(void) {
5431 return 0;
5434 if compile_prog "" "" ; then
5435 valgrind_h=yes
5438 ########################################
5439 # check if environ is declared
5441 has_environ=no
5442 cat > $TMPC << EOF
5443 #include <unistd.h>
5444 int main(void) {
5445 environ = 0;
5446 return 0;
5449 if compile_prog "" "" ; then
5450 has_environ=yes
5453 ########################################
5454 # check if cpuid.h is usable.
5456 cat > $TMPC << EOF
5457 #include <cpuid.h>
5458 int main(void) {
5459 unsigned a, b, c, d;
5460 int max = __get_cpuid_max(0, 0);
5462 if (max >= 1) {
5463 __cpuid(1, a, b, c, d);
5466 if (max >= 7) {
5467 __cpuid_count(7, 0, a, b, c, d);
5470 return 0;
5473 if compile_prog "" "" ; then
5474 cpuid_h=yes
5477 ##########################################
5478 # avx2 optimization requirement check
5480 # There is no point enabling this if cpuid.h is not usable,
5481 # since we won't be able to select the new routines.
5483 if test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
5484 cat > $TMPC << EOF
5485 #pragma GCC push_options
5486 #pragma GCC target("avx2")
5487 #include <cpuid.h>
5488 #include <immintrin.h>
5489 static int bar(void *a) {
5490 __m256i x = *(__m256i *)a;
5491 return _mm256_testz_si256(x, x);
5493 int main(int argc, char *argv[]) { return bar(argv[0]); }
5495 if compile_object "" ; then
5496 avx2_opt="yes"
5497 else
5498 avx2_opt="no"
5502 ########################################
5503 # check if __[u]int128_t is usable.
5505 int128=no
5506 cat > $TMPC << EOF
5507 __int128_t a;
5508 __uint128_t b;
5509 int main (void) {
5510 a = a + b;
5511 b = a * b;
5512 a = a * a;
5513 return 0;
5516 if compile_prog "" "" ; then
5517 int128=yes
5520 #########################################
5521 # See if 128-bit atomic operations are supported.
5523 atomic128=no
5524 if test "$int128" = "yes"; then
5525 cat > $TMPC << EOF
5526 int main(void)
5528 unsigned __int128 x = 0, y = 0;
5529 y = __atomic_load_16(&x, 0);
5530 __atomic_store_16(&x, y, 0);
5531 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
5532 return 0;
5535 if compile_prog "" "" ; then
5536 atomic128=yes
5540 cmpxchg128=no
5541 if test "$int128" = yes && test "$atomic128" = no; then
5542 cat > $TMPC << EOF
5543 int main(void)
5545 unsigned __int128 x = 0, y = 0;
5546 __sync_val_compare_and_swap_16(&x, y, x);
5547 return 0;
5550 if compile_prog "" "" ; then
5551 cmpxchg128=yes
5555 #########################################
5556 # See if 64-bit atomic operations are supported.
5557 # Note that without __atomic builtins, we can only
5558 # assume atomic loads/stores max at pointer size.
5560 cat > $TMPC << EOF
5561 #include <stdint.h>
5562 int main(void)
5564 uint64_t x = 0, y = 0;
5565 #ifdef __ATOMIC_RELAXED
5566 y = __atomic_load_8(&x, 0);
5567 __atomic_store_8(&x, y, 0);
5568 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5569 __atomic_exchange_8(&x, y, 0);
5570 __atomic_fetch_add_8(&x, y, 0);
5571 #else
5572 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5573 __sync_lock_test_and_set(&x, y);
5574 __sync_val_compare_and_swap(&x, y, 0);
5575 __sync_fetch_and_add(&x, y);
5576 #endif
5577 return 0;
5580 if compile_prog "" "" ; then
5581 atomic64=yes
5584 #########################################
5585 # See if --dynamic-list is supported by the linker
5586 ld_dynamic_list="no"
5587 if test "$static" = "no" ; then
5588 cat > $TMPTXT <<EOF
5590 foo;
5594 cat > $TMPC <<EOF
5595 #include <stdio.h>
5596 void foo(void);
5598 void foo(void)
5600 printf("foo\n");
5603 int main(void)
5605 foo();
5606 return 0;
5610 if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
5611 ld_dynamic_list="yes"
5615 #########################################
5616 # See if -exported_symbols_list is supported by the linker
5618 ld_exported_symbols_list="no"
5619 if test "$static" = "no" ; then
5620 cat > $TMPTXT <<EOF
5621 _foo
5624 if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
5625 ld_exported_symbols_list="yes"
5629 if test "$plugins" = "yes" &&
5630 test "$ld_dynamic_list" = "no" &&
5631 test "$ld_exported_symbols_list" = "no" ; then
5632 error_exit \
5633 "Plugin support requires dynamic linking and specifying a set of symbols " \
5634 "that are exported to plugins. Unfortunately your linker doesn't " \
5635 "support the flag (--dynamic-list or -exported_symbols_list) used " \
5636 "for this purpose. You can't build with --static."
5639 ########################################
5640 # See if 16-byte vector operations are supported.
5641 # Even without a vector unit the compiler may expand these.
5642 # There is a bug in old GCC for PPC that crashes here.
5643 # Unfortunately it's the system compiler for Centos 7.
5645 cat > $TMPC << EOF
5646 typedef unsigned char U1 __attribute__((vector_size(16)));
5647 typedef unsigned short U2 __attribute__((vector_size(16)));
5648 typedef unsigned int U4 __attribute__((vector_size(16)));
5649 typedef unsigned long long U8 __attribute__((vector_size(16)));
5650 typedef signed char S1 __attribute__((vector_size(16)));
5651 typedef signed short S2 __attribute__((vector_size(16)));
5652 typedef signed int S4 __attribute__((vector_size(16)));
5653 typedef signed long long S8 __attribute__((vector_size(16)));
5654 static U1 a1, b1;
5655 static U2 a2, b2;
5656 static U4 a4, b4;
5657 static U8 a8, b8;
5658 static S1 c1;
5659 static S2 c2;
5660 static S4 c4;
5661 static S8 c8;
5662 static int i;
5663 void helper(void *d, void *a, int shift, int i);
5664 void helper(void *d, void *a, int shift, int i)
5666 *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
5667 *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
5668 *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
5669 *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
5671 int main(void)
5673 a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5674 a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5675 a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5676 a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5677 a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5678 a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5679 a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5680 a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5681 c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5682 return 0;
5686 vector16=no
5687 if compile_prog "" "" ; then
5688 vector16=yes
5691 ########################################
5692 # See if __attribute__((alias)) is supported.
5693 # This false for Xcode 9, but has been remedied for Xcode 10.
5694 # Unfortunately, travis uses Xcode 9 by default.
5696 attralias=no
5697 cat > $TMPC << EOF
5698 int x = 1;
5699 extern const int y __attribute__((alias("x")));
5700 int main(void) { return 0; }
5702 if compile_prog "" "" ; then
5703 attralias=yes
5706 ########################################
5707 # check if getauxval is available.
5709 getauxval=no
5710 cat > $TMPC << EOF
5711 #include <sys/auxv.h>
5712 int main(void) {
5713 return getauxval(AT_HWCAP) == 0;
5716 if compile_prog "" "" ; then
5717 getauxval=yes
5720 ########################################
5721 # check if ccache is interfering with
5722 # semantic analysis of macros
5724 unset CCACHE_CPP2
5725 ccache_cpp2=no
5726 cat > $TMPC << EOF
5727 static const int Z = 1;
5728 #define fn() ({ Z; })
5729 #define TAUT(X) ((X) == Z)
5730 #define PAREN(X, Y) (X == Y)
5731 #define ID(X) (X)
5732 int main(int argc, char *argv[])
5734 int x = 0, y = 0;
5735 x = ID(x);
5736 x = fn();
5737 fn();
5738 if (PAREN(x, y)) return 0;
5739 if (TAUT(Z)) return 0;
5740 return 0;
5744 if ! compile_object "-Werror"; then
5745 ccache_cpp2=yes
5748 #################################################
5749 # clang does not support glibc + FORTIFY_SOURCE.
5751 if test "$fortify_source" != "no"; then
5752 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5753 fortify_source="no";
5754 elif test -n "$cxx" && has $cxx &&
5755 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5756 fortify_source="no";
5757 else
5758 fortify_source="yes"
5762 ###############################################
5763 # Check if copy_file_range is provided by glibc
5764 have_copy_file_range=no
5765 cat > $TMPC << EOF
5766 #include <unistd.h>
5767 int main(void) {
5768 copy_file_range(0, NULL, 0, NULL, 0, 0);
5769 return 0;
5772 if compile_prog "" "" ; then
5773 have_copy_file_range=yes
5776 ##########################################
5777 # check if struct fsxattr is available via linux/fs.h
5779 have_fsxattr=no
5780 cat > $TMPC << EOF
5781 #include <linux/fs.h>
5782 struct fsxattr foo;
5783 int main(void) {
5784 return 0;
5787 if compile_prog "" "" ; then
5788 have_fsxattr=yes
5791 ##########################################
5792 # check for usable membarrier system call
5793 if test "$membarrier" = "yes"; then
5794 have_membarrier=no
5795 if test "$mingw32" = "yes" ; then
5796 have_membarrier=yes
5797 elif test "$linux" = "yes" ; then
5798 cat > $TMPC << EOF
5799 #include <linux/membarrier.h>
5800 #include <sys/syscall.h>
5801 #include <unistd.h>
5802 #include <stdlib.h>
5803 int main(void) {
5804 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5805 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5806 exit(0);
5809 if compile_prog "" "" ; then
5810 have_membarrier=yes
5813 if test "$have_membarrier" = "no"; then
5814 feature_not_found "membarrier" "membarrier system call not available"
5816 else
5817 # Do not enable it by default even for Mingw32, because it doesn't
5818 # work on Wine.
5819 membarrier=no
5822 ##########################################
5823 # check if rtnetlink.h exists and is useful
5824 have_rtnetlink=no
5825 cat > $TMPC << EOF
5826 #include <linux/rtnetlink.h>
5827 int main(void) {
5828 return IFLA_PROTO_DOWN;
5831 if compile_prog "" "" ; then
5832 have_rtnetlink=yes
5835 ##########################################
5836 # check for usable AF_VSOCK environment
5837 have_af_vsock=no
5838 cat > $TMPC << EOF
5839 #include <errno.h>
5840 #include <sys/types.h>
5841 #include <sys/socket.h>
5842 #if !defined(AF_VSOCK)
5843 # error missing AF_VSOCK flag
5844 #endif
5845 #include <linux/vm_sockets.h>
5846 int main(void) {
5847 int sock, ret;
5848 struct sockaddr_vm svm;
5849 socklen_t len = sizeof(svm);
5850 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
5851 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
5852 if ((ret == -1) && (errno == ENOTCONN)) {
5853 return 0;
5855 return -1;
5858 if compile_prog "" "" ; then
5859 have_af_vsock=yes
5862 ##########################################
5863 # check for usable AF_ALG environment
5864 hava_afalg=no
5865 cat > $TMPC << EOF
5866 #include <errno.h>
5867 #include <sys/types.h>
5868 #include <sys/socket.h>
5869 #include <linux/if_alg.h>
5870 int main(void) {
5871 int sock;
5872 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5873 return sock;
5876 if compile_prog "" "" ; then
5877 have_afalg=yes
5879 if test "$crypto_afalg" = "yes"
5880 then
5881 if test "$have_afalg" != "yes"
5882 then
5883 error_exit "AF_ALG requested but could not be detected"
5888 #################################################
5889 # Check to see if we have the Hypervisor framework
5890 if [ "$darwin" = "yes" ] ; then
5891 cat > $TMPC << EOF
5892 #include <Hypervisor/hv.h>
5893 int main() { return 0;}
5895 if ! compile_object ""; then
5896 hvf='no'
5897 else
5898 hvf='yes'
5899 LDFLAGS="-framework Hypervisor $LDFLAGS"
5903 #################################################
5904 # Sparc implicitly links with --relax, which is
5905 # incompatible with -r, so --no-relax should be
5906 # given. It does no harm to give it on other
5907 # platforms too.
5909 # Note: the prototype is needed since QEMU_CFLAGS
5910 # contains -Wmissing-prototypes
5911 cat > $TMPC << EOF
5912 extern int foo(void);
5913 int foo(void) { return 0; }
5915 if ! compile_object ""; then
5916 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5918 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5919 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5920 LD_REL_FLAGS=$i
5921 break
5923 done
5924 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5925 feature_not_found "modules" "Cannot find how to build relocatable objects"
5928 ##########################################
5929 # check for sysmacros.h
5931 have_sysmacros=no
5932 cat > $TMPC << EOF
5933 #include <sys/sysmacros.h>
5934 int main(void) {
5935 return makedev(0, 0);
5938 if compile_prog "" "" ; then
5939 have_sysmacros=yes
5942 ##########################################
5943 # Veritas HyperScale block driver VxHS
5944 # Check if libvxhs is installed
5946 if test "$vxhs" != "no" ; then
5947 cat > $TMPC <<EOF
5948 #include <stdint.h>
5949 #include <qnio/qnio_api.h>
5951 void *vxhs_callback;
5953 int main(void) {
5954 iio_init(QNIO_VERSION, vxhs_callback);
5955 return 0;
5958 vxhs_libs="-lvxhs -lssl"
5959 if compile_prog "" "$vxhs_libs" ; then
5960 vxhs=yes
5961 else
5962 if test "$vxhs" = "yes" ; then
5963 feature_not_found "vxhs block device" "Install libvxhs See github"
5965 vxhs=no
5969 ##########################################
5970 # check for _Static_assert()
5972 have_static_assert=no
5973 cat > $TMPC << EOF
5974 _Static_assert(1, "success");
5975 int main(void) {
5976 return 0;
5979 if compile_prog "" "" ; then
5980 have_static_assert=yes
5983 ##########################################
5984 # check for utmpx.h, it is missing e.g. on OpenBSD
5986 have_utmpx=no
5987 cat > $TMPC << EOF
5988 #include <utmpx.h>
5989 struct utmpx user_info;
5990 int main(void) {
5991 return 0;
5994 if compile_prog "" "" ; then
5995 have_utmpx=yes
5998 ##########################################
5999 # check for getrandom()
6001 have_getrandom=no
6002 cat > $TMPC << EOF
6003 #include <sys/random.h>
6004 int main(void) {
6005 return getrandom(0, 0, GRND_NONBLOCK);
6008 if compile_prog "" "" ; then
6009 have_getrandom=yes
6012 ##########################################
6013 # checks for sanitizers
6015 have_asan=no
6016 have_ubsan=no
6017 have_asan_iface_h=no
6018 have_asan_iface_fiber=no
6020 if test "$sanitizers" = "yes" ; then
6021 write_c_skeleton
6022 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
6023 have_asan=yes
6026 # we could use a simple skeleton for flags checks, but this also
6027 # detect the static linking issue of ubsan, see also:
6028 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
6029 cat > $TMPC << EOF
6030 #include <stdlib.h>
6031 int main(void) {
6032 void *tmp = malloc(10);
6033 return *(int *)(tmp + 2);
6036 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
6037 have_ubsan=yes
6040 if check_include "sanitizer/asan_interface.h" ; then
6041 have_asan_iface_h=yes
6044 cat > $TMPC << EOF
6045 #include <sanitizer/asan_interface.h>
6046 int main(void) {
6047 __sanitizer_start_switch_fiber(0, 0, 0);
6048 return 0;
6051 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
6052 have_asan_iface_fiber=yes
6056 ##########################################
6057 # check for libpmem
6059 if test "$libpmem" != "no"; then
6060 if $pkg_config --exists "libpmem"; then
6061 libpmem="yes"
6062 libpmem_libs=$($pkg_config --libs libpmem)
6063 libpmem_cflags=$($pkg_config --cflags libpmem)
6064 libs_softmmu="$libs_softmmu $libpmem_libs"
6065 QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
6066 else
6067 if test "$libpmem" = "yes" ; then
6068 feature_not_found "libpmem" "Install nvml or pmdk"
6070 libpmem="no"
6074 ##########################################
6075 # check for slirp
6077 case "$slirp" in
6078 "" | yes)
6079 if $pkg_config slirp; then
6080 slirp=system
6081 elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
6082 slirp=git
6083 elif test -e "${source_path}/slirp/Makefile" ; then
6084 slirp=internal
6085 elif test -z "$slirp" ; then
6086 slirp=no
6087 else
6088 feature_not_found "slirp" "Install slirp devel or git submodule"
6092 system)
6093 if ! $pkg_config slirp; then
6094 feature_not_found "slirp" "Install slirp devel"
6097 esac
6099 case "$slirp" in
6100 git | internal)
6101 if test "$slirp" = git; then
6102 git_submodules="${git_submodules} slirp"
6104 mkdir -p slirp
6105 slirp_cflags="-I\$(SRC_PATH)/slirp/src -I\$(BUILD_DIR)/slirp/src"
6106 slirp_libs="-L\$(BUILD_DIR)/slirp -lslirp"
6109 system)
6110 slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
6111 slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
6112 slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
6118 error_exit "Unknown state for slirp: $slirp"
6120 esac
6123 ##########################################
6124 # End of CC checks
6125 # After here, no more $cc or $ld runs
6127 write_c_skeleton
6129 if test "$gcov" = "yes" ; then
6130 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
6131 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
6132 elif test "$fortify_source" = "yes" ; then
6133 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
6134 elif test "$debug" = "no"; then
6135 CFLAGS="-O2 $CFLAGS"
6138 if test "$have_asan" = "yes"; then
6139 CFLAGS="-fsanitize=address $CFLAGS"
6140 if test "$have_asan_iface_h" = "no" ; then
6141 echo "ASAN build enabled, but ASAN header missing." \
6142 "Without code annotation, the report may be inferior."
6143 elif test "$have_asan_iface_fiber" = "no" ; then
6144 echo "ASAN build enabled, but ASAN header is too old." \
6145 "Without code annotation, the report may be inferior."
6148 if test "$have_ubsan" = "yes"; then
6149 CFLAGS="-fsanitize=undefined $CFLAGS"
6152 ##########################################
6153 # Do we have libnfs
6154 if test "$libnfs" != "no" ; then
6155 if $pkg_config --atleast-version=1.9.3 libnfs; then
6156 libnfs="yes"
6157 libnfs_libs=$($pkg_config --libs libnfs)
6158 else
6159 if test "$libnfs" = "yes" ; then
6160 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
6162 libnfs="no"
6166 ##########################################
6167 # Do we have libudev
6168 if test "$libudev" != "no" ; then
6169 if $pkg_config libudev && test "$static" != "yes"; then
6170 libudev="yes"
6171 libudev_libs=$($pkg_config --libs libudev)
6172 else
6173 libudev="no"
6177 # Now we've finished running tests it's OK to add -Werror to the compiler flags
6178 if test "$werror" = "yes"; then
6179 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
6182 if test "$solaris" = "no" ; then
6183 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
6184 LDFLAGS="-Wl,--warn-common $LDFLAGS"
6188 # test if pod2man has --utf8 option
6189 if pod2man --help | grep -q utf8; then
6190 POD2MAN="pod2man --utf8"
6191 else
6192 POD2MAN="pod2man"
6195 # Use large addresses, ASLR, no-SEH and DEP if available.
6196 if test "$mingw32" = "yes" ; then
6197 if test "$cpu" = i386; then
6198 LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
6200 for flag in --dynamicbase --no-seh --nxcompat; do
6201 if ld_has $flag ; then
6202 LDFLAGS="-Wl,$flag $LDFLAGS"
6204 done
6207 # Disable OpenBSD W^X if available
6208 if test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
6209 cat > $TMPC <<EOF
6210 int main(void) { return 0; }
6212 wx_ldflags="-Wl,-z,wxneeded"
6213 if compile_prog "" "$wx_ldflags"; then
6214 QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
6218 qemu_confdir=$sysconfdir$confsuffix
6219 qemu_moddir=$libdir$confsuffix
6220 qemu_datadir=$datadir$confsuffix
6221 qemu_localedir="$datadir/locale"
6222 qemu_icondir="$datadir/icons"
6223 qemu_desktopdir="$datadir/applications"
6225 # We can only support ivshmem if we have eventfd
6226 if [ "$eventfd" = "yes" ]; then
6227 ivshmem=yes
6230 tools=""
6231 if test "$want_tools" = "yes" ; then
6232 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) qemu-edid\$(EXESUF) $tools"
6233 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
6234 tools="qemu-nbd\$(EXESUF) $tools"
6236 if [ "$ivshmem" = "yes" ]; then
6237 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
6239 if [ "$curl" = "yes" ]; then
6240 tools="elf2dmp\$(EXESUF) $tools"
6243 if test "$softmmu" = yes ; then
6244 if test "$linux" = yes; then
6245 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
6246 virtfs=yes
6247 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
6248 else
6249 if test "$virtfs" = yes; then
6250 error_exit "VirtFS requires libcap devel and libattr devel"
6252 virtfs=no
6254 if test "$mpath" != no && test "$mpathpersist" = yes ; then
6255 mpath=yes
6256 else
6257 if test "$mpath" = yes; then
6258 error_exit "Multipath requires libmpathpersist devel"
6260 mpath=no
6262 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
6263 else
6264 if test "$virtfs" = yes; then
6265 error_exit "VirtFS is supported only on Linux"
6267 virtfs=no
6268 if test "$mpath" = yes; then
6269 error_exit "Multipath is supported only on Linux"
6271 mpath=no
6273 if test "$xkbcommon" = "yes"; then
6274 tools="qemu-keymap\$(EXESUF) $tools"
6278 # Probe for guest agent support/options
6280 if [ "$guest_agent" != "no" ]; then
6281 if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6282 guest_agent=no
6283 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
6284 tools="qemu-ga\$(EXESUF) $tools"
6285 guest_agent=yes
6286 elif [ "$guest_agent" != yes ]; then
6287 guest_agent=no
6288 else
6289 error_exit "Guest agent is not supported on this platform"
6293 # Guest agent Window MSI package
6295 if test "$guest_agent" != yes; then
6296 if test "$guest_agent_msi" = yes; then
6297 error_exit "MSI guest agent package requires guest agent enabled"
6299 guest_agent_msi=no
6300 elif test "$mingw32" != "yes"; then
6301 if test "$guest_agent_msi" = "yes"; then
6302 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
6304 guest_agent_msi=no
6305 elif ! has wixl; then
6306 if test "$guest_agent_msi" = "yes"; then
6307 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
6309 guest_agent_msi=no
6310 else
6311 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
6312 # disabled explicitly
6313 if test "$guest_agent_msi" != "no"; then
6314 guest_agent_msi=yes
6318 if test "$guest_agent_msi" = "yes"; then
6319 if test "$guest_agent_with_vss" = "yes"; then
6320 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
6323 if test "$QEMU_GA_MANUFACTURER" = ""; then
6324 QEMU_GA_MANUFACTURER=QEMU
6327 if test "$QEMU_GA_DISTRO" = ""; then
6328 QEMU_GA_DISTRO=Linux
6331 if test "$QEMU_GA_VERSION" = ""; then
6332 QEMU_GA_VERSION=$(cat $source_path/VERSION)
6335 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
6337 case "$cpu" in
6338 x86_64)
6339 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
6341 i386)
6342 QEMU_GA_MSI_ARCH="-D Arch=32"
6345 error_exit "CPU $cpu not supported for building installation package"
6347 esac
6350 # Mac OS X ships with a broken assembler
6351 roms=
6352 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6353 test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6354 test "$softmmu" = yes ; then
6355 # Different host OS linkers have different ideas about the name of the ELF
6356 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6357 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6358 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6359 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6360 ld_i386_emulation="$emu"
6361 roms="optionrom"
6362 break
6364 done
6367 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
6368 if test "$cpu" = "s390x" ; then
6369 write_c_skeleton
6370 if compile_prog "-march=z900" ""; then
6371 roms="$roms s390-ccw"
6375 # Probe for the need for relocating the user-only binary.
6376 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
6377 textseg_addr=
6378 case "$cpu" in
6379 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
6380 # ??? Rationale for choosing this address
6381 textseg_addr=0x60000000
6383 mips)
6384 # A 256M aligned address, high in the address space, with enough
6385 # room for the code_gen_buffer above it before the stack.
6386 textseg_addr=0x60000000
6388 esac
6389 if [ -n "$textseg_addr" ]; then
6390 cat > $TMPC <<EOF
6391 int main(void) { return 0; }
6393 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
6394 if ! compile_prog "" "$textseg_ldflags"; then
6395 # In case ld does not support -Ttext-segment, edit the default linker
6396 # script via sed to set the .text start addr. This is needed on FreeBSD
6397 # at least.
6398 if ! $ld --verbose >/dev/null 2>&1; then
6399 error_exit \
6400 "We need to link the QEMU user mode binaries at a" \
6401 "specific text address. Unfortunately your linker" \
6402 "doesn't support either the -Ttext-segment option or" \
6403 "printing the default linker script with --verbose." \
6404 "If you don't want the user mode binaries, pass the" \
6405 "--disable-user option to configure."
6408 $ld --verbose | sed \
6409 -e '1,/==================================================/d' \
6410 -e '/==================================================/,$d' \
6411 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
6412 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
6413 textseg_ldflags="-Wl,-T../config-host.ld"
6418 # Check that the C++ compiler exists and works with the C compiler.
6419 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to not miss any other that could be added.
6420 if has $cxx; then
6421 cat > $TMPC <<EOF
6422 int c_function(void);
6423 int main(void) { return c_function(); }
6426 compile_object
6428 cat > $TMPCXX <<EOF
6429 extern "C" {
6430 int c_function(void);
6432 int c_function(void) { return 42; }
6435 update_cxxflags
6437 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
6438 # C++ compiler $cxx works ok with C compiler $cc
6440 else
6441 echo "C++ compiler $cxx does not work with C compiler $cc"
6442 echo "Disabling C++ specific optional code"
6443 cxx=
6445 else
6446 echo "No C++ compiler available; disabling C++ specific optional code"
6447 cxx=
6450 echo_version() {
6451 if test "$1" = "yes" ; then
6452 echo "($2)"
6456 # prepend pixman and ftd flags after all config tests are done
6457 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
6458 QEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
6459 libs_softmmu="$pixman_libs $libs_softmmu"
6461 echo "Install prefix $prefix"
6462 echo "BIOS directory $(eval echo $qemu_datadir)"
6463 echo "firmware path $(eval echo $firmwarepath)"
6464 echo "binary directory $(eval echo $bindir)"
6465 echo "library directory $(eval echo $libdir)"
6466 echo "module directory $(eval echo $qemu_moddir)"
6467 echo "libexec directory $(eval echo $libexecdir)"
6468 echo "include directory $(eval echo $includedir)"
6469 echo "config directory $(eval echo $sysconfdir)"
6470 if test "$mingw32" = "no" ; then
6471 echo "local state directory $(eval echo $local_statedir)"
6472 echo "Manual directory $(eval echo $mandir)"
6473 echo "ELF interp prefix $interp_prefix"
6474 else
6475 echo "local state directory queried at runtime"
6476 echo "Windows SDK $win_sdk"
6478 echo "Source path $source_path"
6479 echo "GIT binary $git"
6480 echo "GIT submodules $git_submodules"
6481 echo "C compiler $cc"
6482 echo "Host C compiler $host_cc"
6483 echo "C++ compiler $cxx"
6484 echo "Objective-C compiler $objcc"
6485 echo "ARFLAGS $ARFLAGS"
6486 echo "CFLAGS $CFLAGS"
6487 echo "QEMU_CFLAGS $QEMU_CFLAGS"
6488 echo "LDFLAGS $LDFLAGS"
6489 echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
6490 echo "make $make"
6491 echo "install $install"
6492 echo "python $python ($python_version)"
6493 echo "slirp support $slirp $(echo_version $slirp $slirp_version)"
6494 if test "$slirp" != "no" ; then
6495 echo "smbd $smbd"
6497 echo "module support $modules"
6498 echo "host CPU $cpu"
6499 echo "host big endian $bigendian"
6500 echo "target list $target_list"
6501 echo "gprof enabled $gprof"
6502 echo "sparse enabled $sparse"
6503 echo "strip binaries $strip_opt"
6504 echo "profiler $profiler"
6505 echo "static build $static"
6506 if test "$darwin" = "yes" ; then
6507 echo "Cocoa support $cocoa"
6509 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
6510 echo "SDL image support $sdl_image"
6511 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
6512 echo "GTK GL support $gtk_gl"
6513 echo "VTE support $vte $(echo_version $vte $vteversion)"
6514 echo "TLS priority $tls_priority"
6515 echo "GNUTLS support $gnutls"
6516 echo "libgcrypt $gcrypt"
6517 if test "$gcrypt" = "yes"
6518 then
6519 echo " hmac $gcrypt_hmac"
6520 echo " XTS $gcrypt_xts"
6522 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
6523 if test "$nettle" = "yes"
6524 then
6525 echo " XTS $nettle_xts"
6527 echo "libtasn1 $tasn1"
6528 echo "PAM $auth_pam"
6529 echo "iconv support $iconv"
6530 echo "curses support $curses"
6531 echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
6532 echo "curl support $curl"
6533 echo "mingw32 support $mingw32"
6534 echo "Audio drivers $audio_drv_list"
6535 echo "Block whitelist (rw) $block_drv_rw_whitelist"
6536 echo "Block whitelist (ro) $block_drv_ro_whitelist"
6537 echo "VirtFS support $virtfs"
6538 echo "Multipath support $mpath"
6539 echo "VNC support $vnc"
6540 if test "$vnc" = "yes" ; then
6541 echo "VNC SASL support $vnc_sasl"
6542 echo "VNC JPEG support $vnc_jpeg"
6543 echo "VNC PNG support $vnc_png"
6545 echo "xen support $xen"
6546 if test "$xen" = "yes" ; then
6547 echo "xen ctrl version $xen_ctrl_version"
6549 echo "brlapi support $brlapi"
6550 echo "bluez support $bluez"
6551 echo "Documentation $docs"
6552 echo "Tools $tools"
6553 echo "PIE $pie"
6554 echo "vde support $vde"
6555 echo "netmap support $netmap"
6556 echo "Linux AIO support $linux_aio"
6557 echo "(X)ATTR support $attr"
6558 echo "Install blobs $blobs"
6559 echo "KVM support $kvm"
6560 echo "HAX support $hax"
6561 echo "HVF support $hvf"
6562 echo "WHPX support $whpx"
6563 echo "TCG support $tcg"
6564 if test "$tcg" = "yes" ; then
6565 echo "TCG debug enabled $debug_tcg"
6566 echo "TCG interpreter $tcg_interpreter"
6568 echo "malloc trim support $malloc_trim"
6569 echo "RDMA support $rdma"
6570 echo "PVRDMA support $pvrdma"
6571 echo "fdt support $fdt"
6572 echo "membarrier $membarrier"
6573 echo "preadv support $preadv"
6574 echo "fdatasync $fdatasync"
6575 echo "madvise $madvise"
6576 echo "posix_madvise $posix_madvise"
6577 echo "posix_memalign $posix_memalign"
6578 echo "libcap-ng support $cap_ng"
6579 echo "vhost-net support $vhost_net"
6580 echo "vhost-crypto support $vhost_crypto"
6581 echo "vhost-scsi support $vhost_scsi"
6582 echo "vhost-vsock support $vhost_vsock"
6583 echo "vhost-user support $vhost_user"
6584 echo "vhost-user-fs support $vhost_user_fs"
6585 echo "Trace backends $trace_backends"
6586 if have_backend "simple"; then
6587 echo "Trace output file $trace_file-<pid>"
6589 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
6590 echo "rbd support $rbd"
6591 echo "xfsctl support $xfs"
6592 echo "smartcard support $smartcard"
6593 echo "libusb $libusb"
6594 echo "usb net redir $usb_redir"
6595 echo "OpenGL support $opengl"
6596 echo "OpenGL dmabufs $opengl_dmabuf"
6597 echo "libiscsi support $libiscsi"
6598 echo "libnfs support $libnfs"
6599 echo "build guest agent $guest_agent"
6600 echo "QGA VSS support $guest_agent_with_vss"
6601 echo "QGA w32 disk info $guest_agent_ntddscsi"
6602 echo "QGA MSI support $guest_agent_msi"
6603 echo "seccomp support $seccomp"
6604 echo "coroutine backend $coroutine"
6605 echo "coroutine pool $coroutine_pool"
6606 echo "debug stack usage $debug_stack_usage"
6607 echo "mutex debugging $debug_mutex"
6608 echo "crypto afalg $crypto_afalg"
6609 echo "GlusterFS support $glusterfs"
6610 echo "gcov $gcov_tool"
6611 echo "gcov enabled $gcov"
6612 echo "TPM support $tpm"
6613 echo "libssh support $libssh"
6614 echo "QOM debugging $qom_cast_debug"
6615 echo "Live block migration $live_block_migration"
6616 echo "lzo support $lzo"
6617 echo "snappy support $snappy"
6618 echo "bzip2 support $bzip2"
6619 echo "lzfse support $lzfse"
6620 echo "NUMA host support $numa"
6621 echo "libxml2 $libxml2"
6622 echo "tcmalloc support $tcmalloc"
6623 echo "jemalloc support $jemalloc"
6624 echo "avx2 optimization $avx2_opt"
6625 echo "replication support $replication"
6626 echo "VxHS block device $vxhs"
6627 echo "bochs support $bochs"
6628 echo "cloop support $cloop"
6629 echo "dmg support $dmg"
6630 echo "qcow v1 support $qcow1"
6631 echo "vdi support $vdi"
6632 echo "vvfat support $vvfat"
6633 echo "qed support $qed"
6634 echo "parallels support $parallels"
6635 echo "sheepdog support $sheepdog"
6636 echo "capstone $capstone"
6637 echo "libpmem support $libpmem"
6638 echo "libudev $libudev"
6639 echo "default devices $default_devices"
6640 echo "plugin support $plugins"
6642 if test "$supported_cpu" = "no"; then
6643 echo
6644 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6645 echo
6646 echo "CPU host architecture $cpu support is not currently maintained."
6647 echo "The QEMU project intends to remove support for this host CPU in"
6648 echo "a future release if nobody volunteers to maintain it and to"
6649 echo "provide a build host for our continuous integration setup."
6650 echo "configure has succeeded and you can continue to build, but"
6651 echo "if you care about QEMU on this platform you should contact"
6652 echo "us upstream at qemu-devel@nongnu.org."
6655 if test "$supported_os" = "no"; then
6656 echo
6657 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6658 echo
6659 echo "Host OS $targetos support is not currently maintained."
6660 echo "The QEMU project intends to remove support for this host OS in"
6661 echo "a future release if nobody volunteers to maintain it and to"
6662 echo "provide a build host for our continuous integration setup."
6663 echo "configure has succeeded and you can continue to build, but"
6664 echo "if you care about QEMU on this platform you should contact"
6665 echo "us upstream at qemu-devel@nongnu.org."
6668 # Note that if the Python conditional here evaluates True we will exit
6669 # with status 1 which is a shell 'false' value.
6670 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,0))'; then
6671 echo
6672 echo "warning: Python 2 support is deprecated" >&2
6673 echo "warning: Python 3 will be required for building future versions of QEMU" >&2
6674 python2="y"
6677 config_host_mak="config-host.mak"
6679 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
6681 echo "# Automatically generated by configure - do not modify" > $config_host_mak
6682 echo >> $config_host_mak
6684 echo all: >> $config_host_mak
6685 echo "prefix=$prefix" >> $config_host_mak
6686 echo "bindir=$bindir" >> $config_host_mak
6687 echo "libdir=$libdir" >> $config_host_mak
6688 echo "libexecdir=$libexecdir" >> $config_host_mak
6689 echo "includedir=$includedir" >> $config_host_mak
6690 echo "mandir=$mandir" >> $config_host_mak
6691 echo "sysconfdir=$sysconfdir" >> $config_host_mak
6692 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
6693 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
6694 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
6695 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
6696 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
6697 if test "$mingw32" = "no" ; then
6698 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
6700 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
6701 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
6702 echo "qemu_icondir=$qemu_icondir" >> $config_host_mak
6703 echo "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
6704 echo "libs_cpu=$libs_cpu" >> $config_host_mak
6705 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
6706 echo "GIT=$git" >> $config_host_mak
6707 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6708 echo "GIT_UPDATE=$git_update" >> $config_host_mak
6710 echo "ARCH=$ARCH" >> $config_host_mak
6712 if test "$default_devices" = "yes" ; then
6713 echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6714 else
6715 echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6717 if test "$debug_tcg" = "yes" ; then
6718 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6720 if test "$strip_opt" = "yes" ; then
6721 echo "STRIP=${strip}" >> $config_host_mak
6723 if test "$bigendian" = "yes" ; then
6724 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
6726 if test "$mingw32" = "yes" ; then
6727 echo "CONFIG_WIN32=y" >> $config_host_mak
6728 echo "CONFIG_INSTALLER=y" >> $config_host_mak
6729 rc_version=$(cat $source_path/VERSION)
6730 version_major=${rc_version%%.*}
6731 rc_version=${rc_version#*.}
6732 version_minor=${rc_version%%.*}
6733 rc_version=${rc_version#*.}
6734 version_subminor=${rc_version%%.*}
6735 version_micro=0
6736 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6737 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6738 if test "$guest_agent_with_vss" = "yes" ; then
6739 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6740 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6741 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6743 if test "$guest_agent_ntddscsi" = "yes" ; then
6744 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
6746 if test "$guest_agent_msi" = "yes"; then
6747 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
6748 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
6749 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
6750 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
6751 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
6752 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
6753 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
6755 else
6756 echo "CONFIG_POSIX=y" >> $config_host_mak
6759 if test "$linux" = "yes" ; then
6760 echo "CONFIG_LINUX=y" >> $config_host_mak
6763 if test "$darwin" = "yes" ; then
6764 echo "CONFIG_DARWIN=y" >> $config_host_mak
6767 if test "$solaris" = "yes" ; then
6768 echo "CONFIG_SOLARIS=y" >> $config_host_mak
6770 if test "$haiku" = "yes" ; then
6771 echo "CONFIG_HAIKU=y" >> $config_host_mak
6773 if test "$static" = "yes" ; then
6774 echo "CONFIG_STATIC=y" >> $config_host_mak
6776 if test "$profiler" = "yes" ; then
6777 echo "CONFIG_PROFILER=y" >> $config_host_mak
6779 if test "$want_tools" = "yes" ; then
6780 echo "CONFIG_TOOLS=y" >> $config_host_mak
6782 if test "$slirp" != "no"; then
6783 echo "CONFIG_SLIRP=y" >> $config_host_mak
6784 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6785 echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
6786 echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
6788 if [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
6789 echo "config-host.h: slirp/all" >> $config_host_mak
6791 if test "$vde" = "yes" ; then
6792 echo "CONFIG_VDE=y" >> $config_host_mak
6793 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
6795 if test "$netmap" = "yes" ; then
6796 echo "CONFIG_NETMAP=y" >> $config_host_mak
6798 if test "$l2tpv3" = "yes" ; then
6799 echo "CONFIG_L2TPV3=y" >> $config_host_mak
6801 if test "$cap_ng" = "yes" ; then
6802 echo "CONFIG_LIBCAP=y" >> $config_host_mak
6804 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
6805 for drv in $audio_drv_list; do
6806 def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6807 case "$drv" in
6808 alsa | oss | pa | sdl)
6809 echo "$def=m" >> $config_host_mak ;;
6811 echo "$def=y" >> $config_host_mak ;;
6812 esac
6813 done
6814 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6815 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6816 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6817 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6818 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
6819 if test "$audio_win_int" = "yes" ; then
6820 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6822 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6823 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6824 if test "$vnc" = "yes" ; then
6825 echo "CONFIG_VNC=y" >> $config_host_mak
6827 if test "$vnc_sasl" = "yes" ; then
6828 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
6830 if test "$vnc_jpeg" = "yes" ; then
6831 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
6833 if test "$vnc_png" = "yes" ; then
6834 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6836 if test "$xkbcommon" = "yes" ; then
6837 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
6838 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
6840 if test "$xfs" = "yes" ; then
6841 echo "CONFIG_XFS=y" >> $config_host_mak
6843 qemu_version=$(head $source_path/VERSION)
6844 echo "VERSION=$qemu_version" >>$config_host_mak
6845 echo "PKGVERSION=$pkgversion" >>$config_host_mak
6846 echo "SRC_PATH=$source_path" >> $config_host_mak
6847 echo "TARGET_DIRS=$target_list" >> $config_host_mak
6848 if [ "$docs" = "yes" ] ; then
6849 echo "BUILD_DOCS=yes" >> $config_host_mak
6851 if [ "$want_tools" = "yes" ] ; then
6852 echo "BUILD_TOOLS=yes" >> $config_host_mak
6854 if test "$modules" = "yes"; then
6855 # $shacmd can generate a hash started with digit, which the compiler doesn't
6856 # like as an symbol. So prefix it with an underscore
6857 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
6858 echo "CONFIG_MODULES=y" >> $config_host_mak
6860 if test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
6861 echo "CONFIG_X11=y" >> $config_host_mak
6862 echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
6863 echo "X11_LIBS=$x11_libs" >> $config_host_mak
6865 if test "$sdl" = "yes" ; then
6866 echo "CONFIG_SDL=m" >> $config_host_mak
6867 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
6868 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
6869 if test "$sdl_image" = "yes" ; then
6870 echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
6873 if test "$cocoa" = "yes" ; then
6874 echo "CONFIG_COCOA=y" >> $config_host_mak
6876 if test "$iconv" = "yes" ; then
6877 echo "CONFIG_ICONV=y" >> $config_host_mak
6878 echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
6879 echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
6881 if test "$curses" = "yes" ; then
6882 echo "CONFIG_CURSES=m" >> $config_host_mak
6883 echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
6884 echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6886 if test "$pipe2" = "yes" ; then
6887 echo "CONFIG_PIPE2=y" >> $config_host_mak
6889 if test "$accept4" = "yes" ; then
6890 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
6892 if test "$splice" = "yes" ; then
6893 echo "CONFIG_SPLICE=y" >> $config_host_mak
6895 if test "$eventfd" = "yes" ; then
6896 echo "CONFIG_EVENTFD=y" >> $config_host_mak
6898 if test "$memfd" = "yes" ; then
6899 echo "CONFIG_MEMFD=y" >> $config_host_mak
6901 if test "$have_usbfs" = "yes" ; then
6902 echo "CONFIG_USBFS=y" >> $config_host_mak
6904 if test "$fallocate" = "yes" ; then
6905 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6907 if test "$fallocate_punch_hole" = "yes" ; then
6908 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
6910 if test "$fallocate_zero_range" = "yes" ; then
6911 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6913 if test "$posix_fallocate" = "yes" ; then
6914 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6916 if test "$sync_file_range" = "yes" ; then
6917 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6919 if test "$fiemap" = "yes" ; then
6920 echo "CONFIG_FIEMAP=y" >> $config_host_mak
6922 if test "$dup3" = "yes" ; then
6923 echo "CONFIG_DUP3=y" >> $config_host_mak
6925 if test "$ppoll" = "yes" ; then
6926 echo "CONFIG_PPOLL=y" >> $config_host_mak
6928 if test "$prctl_pr_set_timerslack" = "yes" ; then
6929 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6931 if test "$epoll" = "yes" ; then
6932 echo "CONFIG_EPOLL=y" >> $config_host_mak
6934 if test "$epoll_create1" = "yes" ; then
6935 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
6937 if test "$sendfile" = "yes" ; then
6938 echo "CONFIG_SENDFILE=y" >> $config_host_mak
6940 if test "$timerfd" = "yes" ; then
6941 echo "CONFIG_TIMERFD=y" >> $config_host_mak
6943 if test "$setns" = "yes" ; then
6944 echo "CONFIG_SETNS=y" >> $config_host_mak
6946 if test "$clock_adjtime" = "yes" ; then
6947 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
6949 if test "$syncfs" = "yes" ; then
6950 echo "CONFIG_SYNCFS=y" >> $config_host_mak
6952 if test "$inotify" = "yes" ; then
6953 echo "CONFIG_INOTIFY=y" >> $config_host_mak
6955 if test "$inotify1" = "yes" ; then
6956 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6958 if test "$sem_timedwait" = "yes" ; then
6959 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6961 if test "$strchrnul" = "yes" ; then
6962 echo "HAVE_STRCHRNUL=y" >> $config_host_mak
6964 if test "$byteswap_h" = "yes" ; then
6965 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
6967 if test "$bswap_h" = "yes" ; then
6968 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
6970 if test "$curl" = "yes" ; then
6971 echo "CONFIG_CURL=m" >> $config_host_mak
6972 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6973 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6975 if test "$brlapi" = "yes" ; then
6976 echo "CONFIG_BRLAPI=y" >> $config_host_mak
6977 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
6979 if test "$bluez" = "yes" ; then
6980 echo "CONFIG_BLUEZ=y" >> $config_host_mak
6981 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6983 if test "$gtk" = "yes" ; then
6984 echo "CONFIG_GTK=m" >> $config_host_mak
6985 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6986 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6987 if test "$gtk_gl" = "yes" ; then
6988 echo "CONFIG_GTK_GL=y" >> $config_host_mak
6991 if test "$gio" = "yes" ; then
6992 echo "CONFIG_GIO=y" >> $config_host_mak
6993 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
6994 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
6996 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6997 if test "$gnutls" = "yes" ; then
6998 echo "CONFIG_GNUTLS=y" >> $config_host_mak
7000 if test "$gcrypt" = "yes" ; then
7001 echo "CONFIG_GCRYPT=y" >> $config_host_mak
7002 if test "$gcrypt_hmac" = "yes" ; then
7003 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
7006 if test "$nettle" = "yes" ; then
7007 echo "CONFIG_NETTLE=y" >> $config_host_mak
7008 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
7010 if test "$qemu_private_xts" = "yes" ; then
7011 echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
7013 if test "$tasn1" = "yes" ; then
7014 echo "CONFIG_TASN1=y" >> $config_host_mak
7016 if test "$auth_pam" = "yes" ; then
7017 echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
7019 if test "$have_ifaddrs_h" = "yes" ; then
7020 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
7022 if test "$have_broken_size_max" = "yes" ; then
7023 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
7026 # Work around a system header bug with some kernel/XFS header
7027 # versions where they both try to define 'struct fsxattr':
7028 # xfs headers will not try to redefine structs from linux headers
7029 # if this macro is set.
7030 if test "$have_fsxattr" = "yes" ; then
7031 echo "HAVE_FSXATTR=y" >> $config_host_mak
7033 if test "$have_copy_file_range" = "yes" ; then
7034 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
7036 if test "$vte" = "yes" ; then
7037 echo "CONFIG_VTE=y" >> $config_host_mak
7038 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
7039 echo "VTE_LIBS=$vte_libs" >> $config_host_mak
7041 if test "$virglrenderer" = "yes" ; then
7042 echo "CONFIG_VIRGL=y" >> $config_host_mak
7043 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
7044 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
7046 if test "$xen" = "yes" ; then
7047 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
7048 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
7050 if test "$linux_aio" = "yes" ; then
7051 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
7053 if test "$attr" = "yes" ; then
7054 echo "CONFIG_ATTR=y" >> $config_host_mak
7056 if test "$libattr" = "yes" ; then
7057 echo "CONFIG_LIBATTR=y" >> $config_host_mak
7059 if test "$virtfs" = "yes" ; then
7060 echo "CONFIG_VIRTFS=y" >> $config_host_mak
7062 if test "$mpath" = "yes" ; then
7063 echo "CONFIG_MPATH=y" >> $config_host_mak
7064 if test "$mpathpersist_new_api" = "yes"; then
7065 echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
7068 if test "$vhost_scsi" = "yes" ; then
7069 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
7071 if test "$vhost_net" = "yes" ; then
7072 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
7074 if test "$vhost_net_user" = "yes" ; then
7075 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
7077 if test "$vhost_crypto" = "yes" ; then
7078 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
7080 if test "$vhost_vsock" = "yes" ; then
7081 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
7083 if test "$vhost_kernel" = "yes" ; then
7084 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
7086 if test "$vhost_user" = "yes" ; then
7087 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
7089 if test "$vhost_user_fs" = "yes" ; then
7090 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
7092 if test "$blobs" = "yes" ; then
7093 echo "INSTALL_BLOBS=yes" >> $config_host_mak
7095 if test "$iovec" = "yes" ; then
7096 echo "CONFIG_IOVEC=y" >> $config_host_mak
7098 if test "$preadv" = "yes" ; then
7099 echo "CONFIG_PREADV=y" >> $config_host_mak
7101 if test "$fdt" != "no" ; then
7102 echo "CONFIG_FDT=y" >> $config_host_mak
7104 if test "$membarrier" = "yes" ; then
7105 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
7107 if test "$signalfd" = "yes" ; then
7108 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
7110 if test "$optreset" = "yes" ; then
7111 echo "HAVE_OPTRESET=y" >> $config_host_mak
7113 if test "$tcg" = "yes"; then
7114 echo "CONFIG_TCG=y" >> $config_host_mak
7115 if test "$tcg_interpreter" = "yes" ; then
7116 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
7119 if test "$fdatasync" = "yes" ; then
7120 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
7122 if test "$madvise" = "yes" ; then
7123 echo "CONFIG_MADVISE=y" >> $config_host_mak
7125 if test "$posix_madvise" = "yes" ; then
7126 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
7128 if test "$posix_memalign" = "yes" ; then
7129 echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
7132 if test "$spice" = "yes" ; then
7133 echo "CONFIG_SPICE=y" >> $config_host_mak
7136 if test "$smartcard" = "yes" ; then
7137 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
7138 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
7139 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
7142 if test "$libusb" = "yes" ; then
7143 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
7144 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
7145 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
7148 if test "$usb_redir" = "yes" ; then
7149 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
7150 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
7151 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
7154 if test "$opengl" = "yes" ; then
7155 echo "CONFIG_OPENGL=y" >> $config_host_mak
7156 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
7157 if test "$opengl_dmabuf" = "yes" ; then
7158 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
7162 if test "$gbm" = "yes" ; then
7163 echo "CONFIG_GBM=y" >> $config_host_mak
7164 echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
7165 echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
7169 if test "$malloc_trim" = "yes" ; then
7170 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
7173 if test "$avx2_opt" = "yes" ; then
7174 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
7177 if test "$lzo" = "yes" ; then
7178 echo "CONFIG_LZO=y" >> $config_host_mak
7181 if test "$snappy" = "yes" ; then
7182 echo "CONFIG_SNAPPY=y" >> $config_host_mak
7185 if test "$bzip2" = "yes" ; then
7186 echo "CONFIG_BZIP2=y" >> $config_host_mak
7187 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
7190 if test "$lzfse" = "yes" ; then
7191 echo "CONFIG_LZFSE=y" >> $config_host_mak
7192 echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
7195 if test "$libiscsi" = "yes" ; then
7196 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
7197 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
7198 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
7201 if test "$libnfs" = "yes" ; then
7202 echo "CONFIG_LIBNFS=m" >> $config_host_mak
7203 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
7206 if test "$seccomp" = "yes"; then
7207 echo "CONFIG_SECCOMP=y" >> $config_host_mak
7208 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7209 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7212 # XXX: suppress that
7213 if [ "$bsd" = "yes" ] ; then
7214 echo "CONFIG_BSD=y" >> $config_host_mak
7217 if test "$localtime_r" = "yes" ; then
7218 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
7220 if test "$qom_cast_debug" = "yes" ; then
7221 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
7223 if test "$rbd" = "yes" ; then
7224 echo "CONFIG_RBD=m" >> $config_host_mak
7225 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
7226 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7229 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
7230 if test "$coroutine_pool" = "yes" ; then
7231 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
7232 else
7233 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
7236 if test "$debug_stack_usage" = "yes" ; then
7237 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
7240 if test "$crypto_afalg" = "yes" ; then
7241 echo "CONFIG_AF_ALG=y" >> $config_host_mak
7244 if test "$open_by_handle_at" = "yes" ; then
7245 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7248 if test "$linux_magic_h" = "yes" ; then
7249 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7252 if test "$pragma_diagnostic_available" = "yes" ; then
7253 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
7256 if test "$valgrind_h" = "yes" ; then
7257 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
7260 if test "$have_asan_iface_fiber" = "yes" ; then
7261 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7264 if test "$has_environ" = "yes" ; then
7265 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
7268 if test "$cpuid_h" = "yes" ; then
7269 echo "CONFIG_CPUID_H=y" >> $config_host_mak
7272 if test "$int128" = "yes" ; then
7273 echo "CONFIG_INT128=y" >> $config_host_mak
7276 if test "$atomic128" = "yes" ; then
7277 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
7280 if test "$cmpxchg128" = "yes" ; then
7281 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7284 if test "$atomic64" = "yes" ; then
7285 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7288 if test "$vector16" = "yes" ; then
7289 echo "CONFIG_VECTOR16=y" >> $config_host_mak
7292 if test "$attralias" = "yes" ; then
7293 echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
7296 if test "$getauxval" = "yes" ; then
7297 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
7300 if test "$glusterfs" = "yes" ; then
7301 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
7302 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
7303 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7306 if test "$glusterfs_xlator_opt" = "yes" ; then
7307 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7310 if test "$glusterfs_discard" = "yes" ; then
7311 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
7314 if test "$glusterfs_fallocate" = "yes" ; then
7315 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7318 if test "$glusterfs_zerofill" = "yes" ; then
7319 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
7322 if test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7323 echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7326 if test "$glusterfs_iocb_has_stat" = "yes" ; then
7327 echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
7330 if test "$libssh" = "yes" ; then
7331 echo "CONFIG_LIBSSH=m" >> $config_host_mak
7332 echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7333 echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
7336 if test "$live_block_migration" = "yes" ; then
7337 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7340 if test "$tpm" = "yes"; then
7341 echo 'CONFIG_TPM=y' >> $config_host_mak
7344 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
7345 if have_backend "nop"; then
7346 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
7348 if have_backend "simple"; then
7349 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
7350 # Set the appropriate trace file.
7351 trace_file="\"$trace_file-\" FMT_pid"
7353 if have_backend "log"; then
7354 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
7356 if have_backend "ust"; then
7357 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
7359 if have_backend "dtrace"; then
7360 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
7361 if test "$trace_backend_stap" = "yes" ; then
7362 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
7365 if have_backend "ftrace"; then
7366 if test "$linux" = "yes" ; then
7367 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7368 else
7369 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7372 if have_backend "syslog"; then
7373 if test "$posix_syslog" = "yes" ; then
7374 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
7375 else
7376 feature_not_found "syslog(trace backend)" "syslog not available"
7379 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
7381 if test "$rdma" = "yes" ; then
7382 echo "CONFIG_RDMA=y" >> $config_host_mak
7383 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
7386 if test "$pvrdma" = "yes" ; then
7387 echo "CONFIG_PVRDMA=y" >> $config_host_mak
7390 if test "$have_rtnetlink" = "yes" ; then
7391 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7394 if test "$libxml2" = "yes" ; then
7395 echo "CONFIG_LIBXML2=y" >> $config_host_mak
7396 echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7397 echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7400 if test "$replication" = "yes" ; then
7401 echo "CONFIG_REPLICATION=y" >> $config_host_mak
7404 if test "$have_af_vsock" = "yes" ; then
7405 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
7408 if test "$have_sysmacros" = "yes" ; then
7409 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
7412 if test "$have_static_assert" = "yes" ; then
7413 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
7416 if test "$have_utmpx" = "yes" ; then
7417 echo "HAVE_UTMPX=y" >> $config_host_mak
7419 if test "$have_getrandom" = "yes" ; then
7420 echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7422 if test "$ivshmem" = "yes" ; then
7423 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7425 if test "$capstone" != "no" ; then
7426 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
7428 if test "$debug_mutex" = "yes" ; then
7429 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7432 # Hold two types of flag:
7433 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
7434 # a thread we have a handle to
7435 # CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
7436 # platform
7437 if test "$pthread_setname_np_w_tid" = "yes" ; then
7438 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7439 echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7440 elif test "$pthread_setname_np_wo_tid" = "yes" ; then
7441 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7442 echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
7445 if test "$vxhs" = "yes" ; then
7446 echo "CONFIG_VXHS=y" >> $config_host_mak
7447 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
7450 if test "$libpmem" = "yes" ; then
7451 echo "CONFIG_LIBPMEM=y" >> $config_host_mak
7454 if test "$bochs" = "yes" ; then
7455 echo "CONFIG_BOCHS=y" >> $config_host_mak
7457 if test "$cloop" = "yes" ; then
7458 echo "CONFIG_CLOOP=y" >> $config_host_mak
7460 if test "$dmg" = "yes" ; then
7461 echo "CONFIG_DMG=y" >> $config_host_mak
7463 if test "$qcow1" = "yes" ; then
7464 echo "CONFIG_QCOW1=y" >> $config_host_mak
7466 if test "$vdi" = "yes" ; then
7467 echo "CONFIG_VDI=y" >> $config_host_mak
7469 if test "$vvfat" = "yes" ; then
7470 echo "CONFIG_VVFAT=y" >> $config_host_mak
7472 if test "$qed" = "yes" ; then
7473 echo "CONFIG_QED=y" >> $config_host_mak
7475 if test "$parallels" = "yes" ; then
7476 echo "CONFIG_PARALLELS=y" >> $config_host_mak
7478 if test "$sheepdog" = "yes" ; then
7479 echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
7482 if test "$plugins" = "yes" ; then
7483 echo "CONFIG_PLUGIN=y" >> $config_host_mak
7484 LIBS="-ldl $LIBS"
7485 # Copy the export object list to the build dir
7486 if test "$ld_dynamic_list" = "yes" ; then
7487 echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
7488 ld_symbols=qemu-plugins-ld.symbols
7489 cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
7490 elif test "$ld_exported_symbols_list" = "yes" ; then
7491 echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
7492 ld64_symbols=qemu-plugins-ld64.symbols
7493 echo "# Automatically generated by configure - do not modify" > $ld64_symbols
7494 grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
7495 sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
7496 else
7497 error_exit \
7498 "If \$plugins=yes, either \$ld_dynamic_list or " \
7499 "\$ld_exported_symbols_list should have been set to 'yes'."
7503 if test "$tcg_interpreter" = "yes"; then
7504 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
7505 elif test "$ARCH" = "sparc64" ; then
7506 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
7507 elif test "$ARCH" = "s390x" ; then
7508 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
7509 elif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
7510 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
7511 elif test "$ARCH" = "ppc64" ; then
7512 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
7513 elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
7514 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES"
7515 else
7516 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
7518 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
7520 echo "TOOLS=$tools" >> $config_host_mak
7521 echo "ROMS=$roms" >> $config_host_mak
7522 echo "MAKE=$make" >> $config_host_mak
7523 echo "INSTALL=$install" >> $config_host_mak
7524 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
7525 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
7526 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
7527 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7528 echo "PYTHON=$python" >> $config_host_mak
7529 echo "PYTHON2=$python2" >> $config_host_mak
7530 echo "CC=$cc" >> $config_host_mak
7531 if $iasl -h > /dev/null 2>&1; then
7532 echo "IASL=$iasl" >> $config_host_mak
7534 echo "HOST_CC=$host_cc" >> $config_host_mak
7535 echo "CXX=$cxx" >> $config_host_mak
7536 echo "OBJCC=$objcc" >> $config_host_mak
7537 echo "AR=$ar" >> $config_host_mak
7538 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
7539 echo "AS=$as" >> $config_host_mak
7540 echo "CCAS=$ccas" >> $config_host_mak
7541 echo "CPP=$cpp" >> $config_host_mak
7542 echo "OBJCOPY=$objcopy" >> $config_host_mak
7543 echo "LD=$ld" >> $config_host_mak
7544 echo "RANLIB=$ranlib" >> $config_host_mak
7545 echo "NM=$nm" >> $config_host_mak
7546 echo "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
7547 echo "WINDRES=$windres" >> $config_host_mak
7548 echo "CFLAGS=$CFLAGS" >> $config_host_mak
7549 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7550 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
7551 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7552 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7553 if test "$sparse" = "yes" ; then
7554 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
7555 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
7556 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
7557 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
7558 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7560 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
7561 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
7562 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
7563 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7564 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
7565 echo "LIBS+=$LIBS" >> $config_host_mak
7566 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7567 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7568 echo "EXESUF=$EXESUF" >> $config_host_mak
7569 echo "DSOSUF=$DSOSUF" >> $config_host_mak
7570 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7571 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
7572 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
7573 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
7574 echo "POD2MAN=$POD2MAN" >> $config_host_mak
7575 if test "$gcov" = "yes" ; then
7576 echo "CONFIG_GCOV=y" >> $config_host_mak
7577 echo "GCOV=$gcov_tool" >> $config_host_mak
7580 if test "$libudev" != "no"; then
7581 echo "CONFIG_LIBUDEV=y" >> $config_host_mak
7582 echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
7585 # use included Linux headers
7586 if test "$linux" = "yes" ; then
7587 mkdir -p linux-headers
7588 case "$cpu" in
7589 i386|x86_64|x32)
7590 linux_arch=x86
7592 ppc|ppc64|ppc64le)
7593 linux_arch=powerpc
7595 s390x)
7596 linux_arch=s390
7598 aarch64)
7599 linux_arch=arm64
7601 mips64)
7602 linux_arch=mips
7605 # For most CPUs the kernel architecture name and QEMU CPU name match.
7606 linux_arch="$cpu"
7608 esac
7609 # For non-KVM architectures we will not have asm headers
7610 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
7611 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
7615 for target in $target_list; do
7616 target_dir="$target"
7617 config_target_mak=$target_dir/config-target.mak
7618 target_name=$(echo $target | cut -d '-' -f 1)
7619 target_aligned_only="no"
7620 case "$target_name" in
7621 alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
7622 target_aligned_only="yes"
7624 esac
7625 target_bigendian="no"
7626 case "$target_name" in
7627 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
7628 target_bigendian="yes"
7630 esac
7631 target_softmmu="no"
7632 target_user_only="no"
7633 target_linux_user="no"
7634 target_bsd_user="no"
7635 case "$target" in
7636 ${target_name}-softmmu)
7637 target_softmmu="yes"
7639 ${target_name}-linux-user)
7640 target_user_only="yes"
7641 target_linux_user="yes"
7643 ${target_name}-bsd-user)
7644 target_user_only="yes"
7645 target_bsd_user="yes"
7648 error_exit "Target '$target' not recognised"
7649 exit 1
7651 esac
7653 mkdir -p $target_dir
7654 echo "# Automatically generated by configure - do not modify" > $config_target_mak
7656 bflt="no"
7657 mttcg="no"
7658 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
7659 gdb_xml_files=""
7661 TARGET_ARCH="$target_name"
7662 TARGET_BASE_ARCH=""
7663 TARGET_ABI_DIR=""
7665 case "$target_name" in
7666 i386)
7667 mttcg="yes"
7668 gdb_xml_files="i386-32bit.xml"
7670 x86_64)
7671 TARGET_BASE_ARCH=i386
7672 mttcg="yes"
7673 gdb_xml_files="i386-64bit.xml"
7675 alpha)
7676 mttcg="yes"
7678 arm|armeb)
7679 TARGET_ARCH=arm
7680 bflt="yes"
7681 mttcg="yes"
7682 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7684 aarch64|aarch64_be)
7685 TARGET_ARCH=aarch64
7686 TARGET_BASE_ARCH=arm
7687 bflt="yes"
7688 mttcg="yes"
7689 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
7691 cris)
7693 hppa)
7694 mttcg="yes"
7696 lm32)
7698 m68k)
7699 bflt="yes"
7700 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
7702 microblaze|microblazeel)
7703 TARGET_ARCH=microblaze
7704 bflt="yes"
7705 echo "TARGET_ABI32=y" >> $config_target_mak
7707 mips|mipsel)
7708 mttcg="yes"
7709 TARGET_ARCH=mips
7710 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
7712 mipsn32|mipsn32el)
7713 mttcg="yes"
7714 TARGET_ARCH=mips64
7715 TARGET_BASE_ARCH=mips
7716 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7717 echo "TARGET_ABI32=y" >> $config_target_mak
7719 mips64|mips64el)
7720 mttcg="yes"
7721 TARGET_ARCH=mips64
7722 TARGET_BASE_ARCH=mips
7723 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
7725 moxie)
7727 nios2)
7729 or1k)
7730 TARGET_ARCH=openrisc
7731 TARGET_BASE_ARCH=openrisc
7733 ppc)
7734 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7736 ppc64)
7737 TARGET_BASE_ARCH=ppc
7738 TARGET_ABI_DIR=ppc
7739 mttcg=yes
7740 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7742 ppc64le)
7743 TARGET_ARCH=ppc64
7744 TARGET_BASE_ARCH=ppc
7745 TARGET_ABI_DIR=ppc
7746 mttcg=yes
7747 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7749 ppc64abi32)
7750 TARGET_ARCH=ppc64
7751 TARGET_BASE_ARCH=ppc
7752 TARGET_ABI_DIR=ppc
7753 echo "TARGET_ABI32=y" >> $config_target_mak
7754 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7756 riscv32)
7757 TARGET_BASE_ARCH=riscv
7758 TARGET_ABI_DIR=riscv
7759 mttcg=yes
7760 gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-32bit-csr.xml riscv-32bit-virtual.xml"
7762 riscv64)
7763 TARGET_BASE_ARCH=riscv
7764 TARGET_ABI_DIR=riscv
7765 mttcg=yes
7766 gdb_xml_files="riscv-64bit-cpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml"
7768 sh4|sh4eb)
7769 TARGET_ARCH=sh4
7770 bflt="yes"
7772 sparc)
7774 sparc64)
7775 TARGET_BASE_ARCH=sparc
7777 sparc32plus)
7778 TARGET_ARCH=sparc64
7779 TARGET_BASE_ARCH=sparc
7780 TARGET_ABI_DIR=sparc
7781 echo "TARGET_ABI32=y" >> $config_target_mak
7783 s390x)
7784 mttcg=yes
7785 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
7787 tilegx)
7789 tricore)
7791 unicore32)
7793 xtensa|xtensaeb)
7794 TARGET_ARCH=xtensa
7795 bflt="yes"
7796 mttcg="yes"
7799 error_exit "Unsupported target CPU"
7801 esac
7802 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
7803 if [ "$TARGET_BASE_ARCH" = "" ]; then
7804 TARGET_BASE_ARCH=$TARGET_ARCH
7807 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
7809 upper() {
7810 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
7813 target_arch_name="$(upper $TARGET_ARCH)"
7814 echo "TARGET_$target_arch_name=y" >> $config_target_mak
7815 echo "TARGET_NAME=$target_name" >> $config_target_mak
7816 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7817 if [ "$TARGET_ABI_DIR" = "" ]; then
7818 TARGET_ABI_DIR=$TARGET_ARCH
7820 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7821 if [ "$HOST_VARIANT_DIR" != "" ]; then
7822 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7825 if supported_xen_target $target; then
7826 echo "CONFIG_XEN=y" >> $config_target_mak
7827 echo "$target/config-devices.mak: CONFIG_XEN=y" >> $config_host_mak
7828 if test "$xen_pci_passthrough" = yes; then
7829 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7831 else
7832 echo "$target/config-devices.mak: CONFIG_XEN=n" >> $config_host_mak
7834 if supported_kvm_target $target; then
7835 echo "CONFIG_KVM=y" >> $config_target_mak
7836 echo "$target/config-devices.mak: CONFIG_KVM=y" >> $config_host_mak
7837 else
7838 echo "$target/config-devices.mak: CONFIG_KVM=n" >> $config_host_mak
7840 if supported_hax_target $target; then
7841 echo "CONFIG_HAX=y" >> $config_target_mak
7843 if supported_hvf_target $target; then
7844 echo "CONFIG_HVF=y" >> $config_target_mak
7846 if supported_whpx_target $target; then
7847 echo "CONFIG_WHPX=y" >> $config_target_mak
7849 if test "$target_aligned_only" = "yes" ; then
7850 echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
7852 if test "$target_bigendian" = "yes" ; then
7853 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
7855 if test "$target_softmmu" = "yes" ; then
7856 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7857 if test "$mttcg" = "yes" ; then
7858 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7861 if test "$target_user_only" = "yes" ; then
7862 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7863 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7865 if test "$target_linux_user" = "yes" ; then
7866 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7868 list=""
7869 if test ! -z "$gdb_xml_files" ; then
7870 for x in $gdb_xml_files; do
7871 list="$list $source_path/gdb-xml/$x"
7872 done
7873 echo "TARGET_XML_FILES=$list" >> $config_target_mak
7876 if test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
7877 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7879 if test "$target_bsd_user" = "yes" ; then
7880 echo "CONFIG_BSD_USER=y" >> $config_target_mak
7884 # generate QEMU_CFLAGS/LDFLAGS for targets
7886 cflags=""
7887 ldflags=""
7889 disas_config() {
7890 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7891 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7894 for i in $ARCH $TARGET_BASE_ARCH ; do
7895 case "$i" in
7896 alpha)
7897 disas_config "ALPHA"
7899 aarch64)
7900 if test -n "${cxx}"; then
7901 disas_config "ARM_A64"
7904 arm)
7905 disas_config "ARM"
7906 if test -n "${cxx}"; then
7907 disas_config "ARM_A64"
7910 cris)
7911 disas_config "CRIS"
7913 hppa)
7914 disas_config "HPPA"
7916 i386|x86_64|x32)
7917 disas_config "I386"
7919 lm32)
7920 disas_config "LM32"
7922 m68k)
7923 disas_config "M68K"
7925 microblaze*)
7926 disas_config "MICROBLAZE"
7928 mips*)
7929 disas_config "MIPS"
7930 if test -n "${cxx}"; then
7931 disas_config "NANOMIPS"
7934 moxie*)
7935 disas_config "MOXIE"
7937 nios2)
7938 disas_config "NIOS2"
7940 or1k)
7941 disas_config "OPENRISC"
7943 ppc*)
7944 disas_config "PPC"
7946 riscv*)
7947 disas_config "RISCV"
7949 s390*)
7950 disas_config "S390"
7952 sh4)
7953 disas_config "SH4"
7955 sparc*)
7956 disas_config "SPARC"
7958 xtensa*)
7959 disas_config "XTENSA"
7961 esac
7962 done
7963 if test "$tcg_interpreter" = "yes" ; then
7964 disas_config "TCI"
7967 case "$ARCH" in
7968 alpha)
7969 # Ensure there's only a single GP
7970 cflags="-msmall-data $cflags"
7972 esac
7974 if test "$gprof" = "yes" ; then
7975 echo "TARGET_GPROF=y" >> $config_target_mak
7976 if test "$target_linux_user" = "yes" ; then
7977 cflags="-p $cflags"
7978 ldflags="-p $ldflags"
7980 if test "$target_softmmu" = "yes" ; then
7981 ldflags="-p $ldflags"
7982 echo "GPROF_CFLAGS=-p" >> $config_target_mak
7986 if test "$target_linux_user" = "yes" || test "$target_bsd_user" = "yes" ; then
7987 ldflags="$ldflags $textseg_ldflags"
7990 # Newer kernels on s390 check for an S390_PGSTE program header and
7991 # enable the pgste page table extensions in that case. This makes
7992 # the vm.allocate_pgste sysctl unnecessary. We enable this program
7993 # header if
7994 # - we build on s390x
7995 # - we build the system emulation for s390x (qemu-system-s390x)
7996 # - KVM is enabled
7997 # - the linker supports --s390-pgste
7998 if test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
7999 test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
8000 if ld_has --s390-pgste ; then
8001 ldflags="-Wl,--s390-pgste $ldflags"
8005 echo "LDFLAGS+=$ldflags" >> $config_target_mak
8006 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
8008 done # for target in $targets
8010 echo "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak
8011 echo "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak
8013 if [ "$fdt" = "git" ]; then
8014 echo "config-host.h: dtc/all" >> $config_host_mak
8016 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
8017 echo "config-host.h: capstone/all" >> $config_host_mak
8019 if test -n "$LIBCAPSTONE"; then
8020 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
8023 if test "$numa" = "yes"; then
8024 echo "CONFIG_NUMA=y" >> $config_host_mak
8027 if test "$ccache_cpp2" = "yes"; then
8028 echo "export CCACHE_CPP2=y" >> $config_host_mak
8031 # If we're using a separate build tree, set it up now.
8032 # DIRS are directories which we simply mkdir in the build tree;
8033 # LINKS are things to symlink back into the source tree
8034 # (these can be both files and directories).
8035 # Caution: do not add files or directories here using wildcards. This
8036 # will result in problems later if a new file matching the wildcard is
8037 # added to the source tree -- nothing will cause configure to be rerun
8038 # so the build tree will be missing the link back to the new file, and
8039 # tests might fail. Prefer to keep the relevant files in their own
8040 # directory and symlink the directory instead.
8041 DIRS="tests tests/tcg tests/tcg/lm32 tests/libqos tests/qapi-schema tests/qemu-iotests tests/vm"
8042 DIRS="$DIRS tests/fp tests/qgraph"
8043 DIRS="$DIRS docs docs/interop fsdev scsi"
8044 DIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
8045 DIRS="$DIRS roms/seabios roms/vgabios"
8046 LINKS="Makefile"
8047 LINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
8048 LINKS="$LINKS tests/tcg/Makefile.target tests/fp/Makefile"
8049 LINKS="$LINKS tests/plugin/Makefile"
8050 LINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
8051 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
8052 LINKS="$LINKS roms/seabios/Makefile roms/vgabios/Makefile"
8053 LINKS="$LINKS pc-bios/qemu-icon.bmp"
8054 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
8055 LINKS="$LINKS tests/acceptance tests/data"
8056 LINKS="$LINKS tests/qemu-iotests/check"
8057 LINKS="$LINKS python"
8058 for bios_file in \
8059 $source_path/pc-bios/*.bin \
8060 $source_path/pc-bios/*.lid \
8061 $source_path/pc-bios/*.rom \
8062 $source_path/pc-bios/*.dtb \
8063 $source_path/pc-bios/*.img \
8064 $source_path/pc-bios/openbios-* \
8065 $source_path/pc-bios/u-boot.* \
8066 $source_path/pc-bios/edk2-*.fd.bz2 \
8067 $source_path/pc-bios/palcode-*
8069 LINKS="$LINKS pc-bios/$(basename $bios_file)"
8070 done
8071 mkdir -p $DIRS
8072 for f in $LINKS ; do
8073 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
8074 symlink "$source_path/$f" "$f"
8076 done
8078 (for i in $cross_cc_vars; do
8079 export $i
8080 done
8081 export target_list source_path
8082 $source_path/tests/tcg/configure.sh)
8084 # temporary config to build submodules
8085 for rom in seabios vgabios ; do
8086 config_mak=roms/$rom/config.mak
8087 echo "# Automatically generated by configure - do not modify" > $config_mak
8088 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
8089 echo "AS=$as" >> $config_mak
8090 echo "CCAS=$ccas" >> $config_mak
8091 echo "CC=$cc" >> $config_mak
8092 echo "BCC=bcc" >> $config_mak
8093 echo "CPP=$cpp" >> $config_mak
8094 echo "OBJCOPY=objcopy" >> $config_mak
8095 echo "IASL=$iasl" >> $config_mak
8096 echo "LD=$ld" >> $config_mak
8097 echo "RANLIB=$ranlib" >> $config_mak
8098 done
8100 # set up qemu-iotests in this build directory
8101 iotests_common_env="tests/qemu-iotests/common.env"
8103 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
8104 echo >> "$iotests_common_env"
8105 echo "export PYTHON='$python'" >> "$iotests_common_env"
8107 # Save the configure command line for later reuse.
8108 cat <<EOD >config.status
8109 #!/bin/sh
8110 # Generated by configure.
8111 # Run this file to recreate the current configuration.
8112 # Compiler output produced by configure, useful for debugging
8113 # configure, is in config.log if it exists.
8116 preserve_env() {
8117 envname=$1
8119 eval envval=\$$envname
8121 if test -n "$envval"
8122 then
8123 echo "$envname='$envval'" >> config.status
8124 echo "export $envname" >> config.status
8125 else
8126 echo "unset $envname" >> config.status
8130 # Preserve various env variables that influence what
8131 # features/build target configure will detect
8132 preserve_env AR
8133 preserve_env AS
8134 preserve_env CC
8135 preserve_env CPP
8136 preserve_env CXX
8137 preserve_env INSTALL
8138 preserve_env LD
8139 preserve_env LD_LIBRARY_PATH
8140 preserve_env LIBTOOL
8141 preserve_env MAKE
8142 preserve_env NM
8143 preserve_env OBJCOPY
8144 preserve_env PATH
8145 preserve_env PKG_CONFIG
8146 preserve_env PKG_CONFIG_LIBDIR
8147 preserve_env PKG_CONFIG_PATH
8148 preserve_env PYTHON
8149 preserve_env SDL2_CONFIG
8150 preserve_env SMBD
8151 preserve_env STRIP
8152 preserve_env WINDRES
8154 printf "exec" >>config.status
8155 printf " '%s'" "$0" "$@" >>config.status
8156 echo ' "$@"' >>config.status
8157 chmod +x config.status
8159 rm -r "$TMPDIR1"