target/openrisc: Fix singlestep_enabled
[qemu.git] / configure
blob65548df1fc823cee0fb70cde6de63251b6b1d5c4
1 #!/bin/sh
3 # qemu configure script (c) 2003 Fabrice Bellard
6 # Unset some variables known to interfere with behavior of common tools,
7 # just as autoconf does.
8 CLICOLOR_FORCE= GREP_OPTIONS=
9 unset CLICOLOR_FORCE GREP_OPTIONS
11 # Don't allow CCACHE, if present, to use cached results of compile tests!
12 export CCACHE_RECACHE=yes
14 # Temporary directory used for files created while
15 # configure runs. Since it is in the build directory
16 # we can safely blow away any previous version of it
17 # (and we need not jump through hoops to try to delete
18 # it when configure exits.)
19 TMPDIR1="config-temp"
20 rm -rf "${TMPDIR1}"
21 mkdir -p "${TMPDIR1}"
22 if [ $? -ne 0 ]; then
23 echo "ERROR: failed to create temporary directory"
24 exit 1
27 TMPB="qemu-conf"
28 TMPC="${TMPDIR1}/${TMPB}.c"
29 TMPO="${TMPDIR1}/${TMPB}.o"
30 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
31 TMPE="${TMPDIR1}/${TMPB}.exe"
32 TMPMO="${TMPDIR1}/${TMPB}.mo"
34 rm -f config.log
36 # Print a helpful header at the top of config.log
37 echo "# QEMU configure log $(date)" >> config.log
38 printf "# Configured with:" >> config.log
39 printf " '%s'" "$0" "$@" >> config.log
40 echo >> config.log
41 echo "#" >> config.log
43 print_error() {
44 (echo
45 echo "ERROR: $1"
46 while test -n "$2"; do
47 echo " $2"
48 shift
49 done
50 echo) >&2
53 error_exit() {
54 print_error "$@"
55 exit 1
58 do_compiler() {
59 # Run the compiler, capturing its output to the log. First argument
60 # is compiler binary to execute.
61 local compiler="$1"
62 shift
63 if test -n "$BASH_VERSION"; then eval '
64 echo >>config.log "
65 funcs: ${FUNCNAME[*]}
66 lines: ${BASH_LINENO[*]}"
67 '; fi
68 echo $compiler "$@" >> config.log
69 $compiler "$@" >> config.log 2>&1 || return $?
70 # Test passed. If this is an --enable-werror build, rerun
71 # the test with -Werror and bail out if it fails. This
72 # makes warning-generating-errors in configure test code
73 # obvious to developers.
74 if test "$werror" != "yes"; then
75 return 0
77 # Don't bother rerunning the compile if we were already using -Werror
78 case "$*" in
79 *-Werror*)
80 return 0
82 esac
83 echo $compiler -Werror "$@" >> config.log
84 $compiler -Werror "$@" >> config.log 2>&1 && return $?
85 error_exit "configure test passed without -Werror but failed with -Werror." \
86 "This is probably a bug in the configure script. The failing command" \
87 "will be at the bottom of config.log." \
88 "You can run configure with --disable-werror to bypass this check."
91 do_cc() {
92 do_compiler "$cc" "$@"
95 do_cxx() {
96 do_compiler "$cxx" "$@"
99 update_cxxflags() {
100 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
101 # options which some versions of GCC's C++ compiler complain about
102 # because they only make sense for C programs.
103 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
105 for arg in $QEMU_CFLAGS; do
106 case $arg in
107 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
108 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
111 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
113 esac
114 done
117 compile_object() {
118 local_cflags="$1"
119 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
122 compile_prog() {
123 local_cflags="$1"
124 local_ldflags="$2"
125 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
128 # symbolically link $1 to $2. Portable version of "ln -sf".
129 symlink() {
130 rm -rf "$2"
131 mkdir -p "$(dirname "$2")"
132 ln -s "$1" "$2"
135 # check whether a command is available to this shell (may be either an
136 # executable or a builtin)
137 has() {
138 type "$1" >/dev/null 2>&1
141 # search for an executable in PATH
142 path_of() {
143 local_command="$1"
144 local_ifs="$IFS"
145 local_dir=""
147 # pathname has a dir component?
148 if [ "${local_command#*/}" != "$local_command" ]; then
149 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
150 echo "$local_command"
151 return 0
154 if [ -z "$local_command" ]; then
155 return 1
158 IFS=:
159 for local_dir in $PATH; do
160 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
161 echo "$local_dir/$local_command"
162 IFS="${local_ifs:-$(printf ' \t\n')}"
163 return 0
165 done
166 # not found
167 IFS="${local_ifs:-$(printf ' \t\n')}"
168 return 1
171 have_backend () {
172 echo "$trace_backends" | grep "$1" >/dev/null
175 glob() {
176 eval test -z '"${1#'"$2"'}"'
179 supported_hax_target() {
180 test "$hax" = "yes" || return 1
181 glob "$1" "*-softmmu" || return 1
182 case "${1%-softmmu}" in
183 i386|x86_64)
184 return 0
186 esac
187 return 1
190 supported_kvm_target() {
191 test "$kvm" = "yes" || return 1
192 glob "$1" "*-softmmu" || return 1
193 case "${1%-softmmu}:$cpu" in
194 arm:arm | aarch64:aarch64 | \
195 i386:i386 | i386:x86_64 | i386:x32 | \
196 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
197 mips:mips | mipsel:mips | \
198 ppc:ppc | ppcemb:ppc | ppc64:ppc | \
199 ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
200 s390x:s390x)
201 return 0
203 esac
204 return 1
207 supported_xen_target() {
208 test "$xen" = "yes" || return 1
209 glob "$1" "*-softmmu" || return 1
210 # Only i386 and x86_64 provide the xenpv machine.
211 case "${1%-softmmu}" in
212 i386|x86_64)
213 return 0
215 esac
216 return 1
219 supported_hvf_target() {
220 test "$hvf" = "yes" || return 1
221 glob "$1" "*-softmmu" || return 1
222 case "${1%-softmmu}" in
223 x86_64)
224 return 0
226 esac
227 return 1
230 supported_whpx_target() {
231 test "$whpx" = "yes" || return 1
232 glob "$1" "*-softmmu" || return 1
233 case "${1%-softmmu}" in
234 i386|x86_64)
235 return 0
237 esac
238 return 1
241 supported_target() {
242 case "$1" in
243 *-softmmu)
245 *-linux-user)
246 if test "$linux" != "yes"; then
247 print_error "Target '$target' is only available on a Linux host"
248 return 1
251 *-bsd-user)
252 if test "$bsd" != "yes"; then
253 print_error "Target '$target' is only available on a BSD host"
254 return 1
258 print_error "Invalid target name '$target'"
259 return 1
261 esac
262 test "$tcg" = "yes" && return 0
263 supported_kvm_target "$1" && return 0
264 supported_xen_target "$1" && return 0
265 supported_hax_target "$1" && return 0
266 supported_hvf_target "$1" && return 0
267 supported_whpx_target "$1" && return 0
268 print_error "TCG disabled, but hardware accelerator not available for '$target'"
269 return 1
273 ld_has() {
274 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
277 # default parameters
278 source_path=$(dirname "$0")
279 cpu=""
280 iasl="iasl"
281 interp_prefix="/usr/gnemul/qemu-%M"
282 static="no"
283 cross_prefix=""
284 audio_drv_list=""
285 block_drv_rw_whitelist=""
286 block_drv_ro_whitelist=""
287 host_cc="cc"
288 libs_softmmu=""
289 libs_tools=""
290 audio_pt_int=""
291 audio_win_int=""
292 libs_qga=""
293 debug_info="yes"
294 stack_protector=""
296 if test -e "$source_path/.git"
297 then
298 git_update=yes
299 git_submodules="ui/keycodemapdb"
300 else
301 git_update=no
302 git_submodules=""
304 git="git"
306 # Don't accept a target_list environment variable.
307 unset target_list
309 # Default value for a variable defining feature "foo".
310 # * foo="no" feature will only be used if --enable-foo arg is given
311 # * foo="" feature will be searched for, and if found, will be used
312 # unless --disable-foo is given
313 # * foo="yes" this value will only be set by --enable-foo flag.
314 # feature will searched for,
315 # if not found, configure exits with error
317 # Always add --enable-foo and --disable-foo command line args.
318 # Distributions want to ensure that several features are compiled in, and it
319 # is impossible without a --enable-foo that exits if a feature is not found.
321 bluez=""
322 brlapi=""
323 curl=""
324 curses=""
325 docs=""
326 fdt=""
327 netmap="no"
328 sdl=""
329 sdlabi=""
330 virtfs=""
331 mpath=""
332 vnc="yes"
333 sparse="no"
334 vde=""
335 vnc_sasl=""
336 vnc_jpeg=""
337 vnc_png=""
338 xkbcommon=""
339 xen=""
340 xen_ctrl_version=""
341 xen_pv_domain_build="no"
342 xen_pci_passthrough=""
343 linux_aio=""
344 cap_ng=""
345 attr=""
346 libattr=""
347 xfs=""
348 tcg="yes"
349 membarrier=""
350 vhost_net="no"
351 vhost_crypto="no"
352 vhost_scsi="no"
353 vhost_vsock="no"
354 vhost_user=""
355 kvm="no"
356 hax="no"
357 hvf="no"
358 whpx="no"
359 rdma=""
360 gprof="no"
361 debug_tcg="no"
362 debug="no"
363 sanitizers="no"
364 fortify_source=""
365 strip_opt="yes"
366 tcg_interpreter="no"
367 bigendian="no"
368 mingw32="no"
369 gcov="no"
370 gcov_tool="gcov"
371 EXESUF=""
372 DSOSUF=".so"
373 LDFLAGS_SHARED="-shared"
374 modules="no"
375 prefix="/usr/local"
376 mandir="\${prefix}/share/man"
377 datadir="\${prefix}/share"
378 firmwarepath="\${prefix}/share/qemu-firmware"
379 qemu_docdir="\${prefix}/share/doc/qemu"
380 bindir="\${prefix}/bin"
381 libdir="\${prefix}/lib"
382 libexecdir="\${prefix}/libexec"
383 includedir="\${prefix}/include"
384 sysconfdir="\${prefix}/etc"
385 local_statedir="\${prefix}/var"
386 confsuffix="/qemu"
387 slirp="yes"
388 oss_lib=""
389 bsd="no"
390 linux="no"
391 solaris="no"
392 profiler="no"
393 cocoa="no"
394 softmmu="yes"
395 linux_user="no"
396 bsd_user="no"
397 blobs="yes"
398 pkgversion=""
399 pie=""
400 qom_cast_debug="yes"
401 trace_backends="log"
402 trace_file="trace"
403 spice=""
404 rbd=""
405 smartcard=""
406 libusb=""
407 usb_redir=""
408 opengl=""
409 opengl_dmabuf="no"
410 cpuid_h="no"
411 avx2_opt="no"
412 zlib="yes"
413 capstone=""
414 lzo=""
415 snappy=""
416 bzip2=""
417 guest_agent=""
418 guest_agent_with_vss="no"
419 guest_agent_ntddscsi="no"
420 guest_agent_msi=""
421 vss_win32_sdk=""
422 win_sdk="no"
423 want_tools="yes"
424 libiscsi=""
425 libnfs=""
426 coroutine=""
427 coroutine_pool=""
428 debug_stack_usage="no"
429 crypto_afalg="no"
430 seccomp=""
431 glusterfs=""
432 glusterfs_xlator_opt="no"
433 glusterfs_discard="no"
434 glusterfs_fallocate="no"
435 glusterfs_zerofill="no"
436 gtk=""
437 gtkabi=""
438 gtk_gl="no"
439 tls_priority="NORMAL"
440 gnutls=""
441 gnutls_rnd=""
442 nettle=""
443 nettle_kdf="no"
444 gcrypt=""
445 gcrypt_hmac="no"
446 gcrypt_kdf="no"
447 vte=""
448 virglrenderer=""
449 tpm="yes"
450 libssh2=""
451 live_block_migration="yes"
452 numa=""
453 tcmalloc="no"
454 jemalloc="no"
455 replication="yes"
456 vxhs=""
457 libxml2=""
458 docker="no"
459 debug_mutex="no"
461 # cross compilers defaults, can be overridden with --cross-cc-ARCH
462 cross_cc_aarch64="aarch64-linux-gnu-gcc"
463 cross_cc_aarch64_be="$cross_cc_aarch64"
464 cross_cc_cflags_aarch64_be="-mbig-endian"
465 cross_cc_arm="arm-linux-gnueabihf-gcc"
466 cross_cc_cflags_armeb="-mbig-endian"
467 cross_cc_i386="i386-pc-linux-gnu-gcc"
468 cross_cc_cflags_i386=""
469 cross_cc_powerpc="powerpc-linux-gnu-gcc"
470 cross_cc_powerpc="powerpc-linux-gnu-gcc"
472 enabled_cross_compilers=""
474 supported_cpu="no"
475 supported_os="no"
476 bogus_os="no"
477 malloc_trim=""
479 # parse CC options first
480 for opt do
481 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
482 case "$opt" in
483 --cross-prefix=*) cross_prefix="$optarg"
485 --cc=*) CC="$optarg"
487 --cxx=*) CXX="$optarg"
489 --source-path=*) source_path="$optarg"
491 --cpu=*) cpu="$optarg"
493 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
495 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
497 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
498 EXTRA_LDFLAGS="$optarg"
500 --enable-debug-info) debug_info="yes"
502 --disable-debug-info) debug_info="no"
504 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
506 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
507 eval "cross_cc_cflags_${cc_arch}=\$optarg"
509 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
510 eval "cross_cc_${cc_arch}=\$optarg"
512 esac
513 done
514 # OS specific
515 # Using uname is really, really broken. Once we have the right set of checks
516 # we can eliminate its usage altogether.
518 # Preferred compiler:
519 # ${CC} (if set)
520 # ${cross_prefix}gcc (if cross-prefix specified)
521 # system compiler
522 if test -z "${CC}${cross_prefix}"; then
523 cc="$host_cc"
524 else
525 cc="${CC-${cross_prefix}gcc}"
528 if test -z "${CXX}${cross_prefix}"; then
529 cxx="c++"
530 else
531 cxx="${CXX-${cross_prefix}g++}"
534 ar="${AR-${cross_prefix}ar}"
535 as="${AS-${cross_prefix}as}"
536 ccas="${CCAS-$cc}"
537 cpp="${CPP-$cc -E}"
538 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
539 ld="${LD-${cross_prefix}ld}"
540 ranlib="${RANLIB-${cross_prefix}ranlib}"
541 nm="${NM-${cross_prefix}nm}"
542 strip="${STRIP-${cross_prefix}strip}"
543 windres="${WINDRES-${cross_prefix}windres}"
544 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
545 query_pkg_config() {
546 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
548 pkg_config=query_pkg_config
549 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
550 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
552 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
553 ARFLAGS="${ARFLAGS-rv}"
555 # default flags for all hosts
556 # We use -fwrapv to tell the compiler that we require a C dialect where
557 # left shift of signed integers is well defined and has the expected
558 # 2s-complement style results. (Both clang and gcc agree that it
559 # provides these semantics.)
560 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
561 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
562 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
563 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
564 QEMU_INCLUDES="-iquote . -iquote \$(SRC_PATH) -iquote \$(SRC_PATH)/accel/tcg -iquote \$(SRC_PATH)/include"
565 if test "$debug_info" = "yes"; then
566 CFLAGS="-g $CFLAGS"
567 LDFLAGS="-g $LDFLAGS"
570 # make source path absolute
571 source_path=$(cd "$source_path"; pwd)
573 # running configure in the source tree?
574 # we know that's the case if configure is there.
575 if test -f "./configure"; then
576 pwd_is_source_path="y"
577 else
578 pwd_is_source_path="n"
581 check_define() {
582 cat > $TMPC <<EOF
583 #if !defined($1)
584 #error $1 not defined
585 #endif
586 int main(void) { return 0; }
588 compile_object
591 check_include() {
592 cat > $TMPC <<EOF
593 #include <$1>
594 int main(void) { return 0; }
596 compile_object
599 write_c_skeleton() {
600 cat > $TMPC <<EOF
601 int main(void) { return 0; }
605 if check_define __linux__ ; then
606 targetos="Linux"
607 elif check_define _WIN32 ; then
608 targetos='MINGW32'
609 elif check_define __OpenBSD__ ; then
610 targetos='OpenBSD'
611 elif check_define __sun__ ; then
612 targetos='SunOS'
613 elif check_define __HAIKU__ ; then
614 targetos='Haiku'
615 elif check_define __FreeBSD__ ; then
616 targetos='FreeBSD'
617 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
618 targetos='GNU/kFreeBSD'
619 elif check_define __DragonFly__ ; then
620 targetos='DragonFly'
621 elif check_define __NetBSD__; then
622 targetos='NetBSD'
623 elif check_define __APPLE__; then
624 targetos='Darwin'
625 else
626 # This is a fatal error, but don't report it yet, because we
627 # might be going to just print the --help text, or it might
628 # be the result of a missing compiler.
629 targetos='bogus'
630 bogus_os='yes'
633 # Some host OSes need non-standard checks for which CPU to use.
634 # Note that these checks are broken for cross-compilation: if you're
635 # cross-compiling to one of these OSes then you'll need to specify
636 # the correct CPU with the --cpu option.
637 case $targetos in
638 Darwin)
639 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
640 # run 64-bit userspace code.
641 # If the user didn't specify a CPU explicitly and the kernel says this is
642 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
643 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
644 cpu="x86_64"
647 SunOS)
648 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
649 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
650 cpu="x86_64"
652 esac
654 if test ! -z "$cpu" ; then
655 # command line argument
657 elif check_define __i386__ ; then
658 cpu="i386"
659 elif check_define __x86_64__ ; then
660 if check_define __ILP32__ ; then
661 cpu="x32"
662 else
663 cpu="x86_64"
665 elif check_define __sparc__ ; then
666 if check_define __arch64__ ; then
667 cpu="sparc64"
668 else
669 cpu="sparc"
671 elif check_define _ARCH_PPC ; then
672 if check_define _ARCH_PPC64 ; then
673 cpu="ppc64"
674 else
675 cpu="ppc"
677 elif check_define __mips__ ; then
678 cpu="mips"
679 elif check_define __s390__ ; then
680 if check_define __s390x__ ; then
681 cpu="s390x"
682 else
683 cpu="s390"
685 elif check_define __arm__ ; then
686 cpu="arm"
687 elif check_define __aarch64__ ; then
688 cpu="aarch64"
689 else
690 cpu=$(uname -m)
693 ARCH=
694 # Normalise host CPU name and set ARCH.
695 # Note that this case should only have supported host CPUs, not guests.
696 case "$cpu" in
697 ppc|ppc64|s390|s390x|sparc64|x32)
698 cpu="$cpu"
699 supported_cpu="yes"
700 eval "cross_cc_${cpu}=\$host_cc"
702 i386|i486|i586|i686|i86pc|BePC)
703 cpu="i386"
704 supported_cpu="yes"
705 cross_cc_i386=$host_cc
707 x86_64|amd64)
708 cpu="x86_64"
709 supported_cpu="yes"
710 cross_cc_x86_64=$host_cc
712 armv*b|armv*l|arm)
713 cpu="arm"
714 supported_cpu="yes"
715 cross_cc_arm=$host_cc
717 aarch64)
718 cpu="aarch64"
719 supported_cpu="yes"
720 cross_cc_aarch64=$host_cc
722 mips*)
723 cpu="mips"
724 supported_cpu="yes"
725 cross_cc_mips=$host_cc
727 sparc|sun4[cdmuv])
728 cpu="sparc"
729 supported_cpu="yes"
730 cross_cc_sparc=$host_cc
733 # This will result in either an error or falling back to TCI later
734 ARCH=unknown
736 esac
737 if test -z "$ARCH"; then
738 ARCH="$cpu"
741 # OS specific
743 # host *BSD for user mode
744 HOST_VARIANT_DIR=""
746 case $targetos in
747 MINGW32*)
748 mingw32="yes"
749 hax="yes"
750 audio_possible_drivers="dsound sdl"
751 if check_include dsound.h; then
752 audio_drv_list="dsound"
753 else
754 audio_drv_list=""
756 supported_os="yes"
758 GNU/kFreeBSD)
759 bsd="yes"
760 audio_drv_list="oss"
761 audio_possible_drivers="oss sdl pa"
763 FreeBSD)
764 bsd="yes"
765 make="${MAKE-gmake}"
766 audio_drv_list="oss"
767 audio_possible_drivers="oss sdl pa"
768 # needed for kinfo_getvmmap(3) in libutil.h
769 LIBS="-lutil $LIBS"
770 # needed for kinfo_getproc
771 libs_qga="-lutil $libs_qga"
772 netmap="" # enable netmap autodetect
773 HOST_VARIANT_DIR="freebsd"
774 supported_os="yes"
776 DragonFly)
777 bsd="yes"
778 make="${MAKE-gmake}"
779 audio_drv_list="oss"
780 audio_possible_drivers="oss sdl pa"
781 HOST_VARIANT_DIR="dragonfly"
783 NetBSD)
784 bsd="yes"
785 make="${MAKE-gmake}"
786 audio_drv_list="oss"
787 audio_possible_drivers="oss sdl"
788 oss_lib="-lossaudio"
789 HOST_VARIANT_DIR="netbsd"
790 supported_os="yes"
792 OpenBSD)
793 bsd="yes"
794 make="${MAKE-gmake}"
795 audio_drv_list="sdl"
796 audio_possible_drivers="sdl"
797 HOST_VARIANT_DIR="openbsd"
798 supported_os="yes"
800 Darwin)
801 bsd="yes"
802 darwin="yes"
803 hax="yes"
804 hvf="yes"
805 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
806 if [ "$cpu" = "x86_64" ] ; then
807 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
808 LDFLAGS="-arch x86_64 $LDFLAGS"
810 cocoa="yes"
811 audio_drv_list="coreaudio"
812 audio_possible_drivers="coreaudio sdl"
813 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
814 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
815 # Disable attempts to use ObjectiveC features in os/object.h since they
816 # won't work when we're compiling with gcc as a C compiler.
817 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
818 HOST_VARIANT_DIR="darwin"
819 supported_os="yes"
821 SunOS)
822 solaris="yes"
823 make="${MAKE-gmake}"
824 install="${INSTALL-ginstall}"
825 smbd="${SMBD-/usr/sfw/sbin/smbd}"
826 if test -f /usr/include/sys/soundcard.h ; then
827 audio_drv_list="oss"
829 audio_possible_drivers="oss sdl"
830 # needed for CMSG_ macros in sys/socket.h
831 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
832 # needed for TIOCWIN* defines in termios.h
833 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
834 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
835 solarisnetlibs="-lsocket -lnsl -lresolv"
836 LIBS="$solarisnetlibs $LIBS"
837 libs_qga="$solarisnetlibs $libs_qga"
839 Haiku)
840 haiku="yes"
841 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
842 LIBS="-lposix_error_mapper -lnetwork $LIBS"
844 Linux)
845 audio_drv_list="oss"
846 audio_possible_drivers="oss alsa sdl pa"
847 linux="yes"
848 linux_user="yes"
849 kvm="yes"
850 vhost_net="yes"
851 vhost_crypto="yes"
852 vhost_scsi="yes"
853 vhost_vsock="yes"
854 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
855 supported_os="yes"
857 esac
859 if [ "$bsd" = "yes" ] ; then
860 if [ "$darwin" != "yes" ] ; then
861 bsd_user="yes"
865 : ${make=${MAKE-make}}
866 : ${install=${INSTALL-install}}
867 : ${python=${PYTHON-python}}
868 : ${smbd=${SMBD-/usr/sbin/smbd}}
870 # Default objcc to clang if available, otherwise use CC
871 if has clang; then
872 objcc=clang
873 else
874 objcc="$cc"
877 if test "$mingw32" = "yes" ; then
878 EXESUF=".exe"
879 DSOSUF=".dll"
880 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
881 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
882 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
883 # MinGW needs -mthreads for TLS and macro _MT.
884 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
885 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
886 write_c_skeleton;
887 if compile_prog "" "-liberty" ; then
888 LIBS="-liberty $LIBS"
890 prefix="c:/Program Files/QEMU"
891 mandir="\${prefix}"
892 datadir="\${prefix}"
893 qemu_docdir="\${prefix}"
894 bindir="\${prefix}"
895 sysconfdir="\${prefix}"
896 local_statedir=
897 confsuffix=""
898 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
901 werror=""
903 for opt do
904 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
905 case "$opt" in
906 --help|-h) show_help=yes
908 --version|-V) exec cat $source_path/VERSION
910 --prefix=*) prefix="$optarg"
912 --interp-prefix=*) interp_prefix="$optarg"
914 --source-path=*)
916 --cross-prefix=*)
918 --cc=*)
920 --host-cc=*) host_cc="$optarg"
922 --cxx=*)
924 --iasl=*) iasl="$optarg"
926 --objcc=*) objcc="$optarg"
928 --make=*) make="$optarg"
930 --install=*) install="$optarg"
932 --python=*) python="$optarg"
934 --gcov=*) gcov_tool="$optarg"
936 --smbd=*) smbd="$optarg"
938 --extra-cflags=*)
940 --extra-cxxflags=*)
942 --extra-ldflags=*)
944 --enable-debug-info)
946 --disable-debug-info)
948 --cross-cc-*)
950 --enable-modules)
951 modules="yes"
953 --disable-modules)
954 modules="no"
956 --cpu=*)
958 --target-list=*) target_list="$optarg"
960 --enable-trace-backends=*) trace_backends="$optarg"
962 # XXX: backwards compatibility
963 --enable-trace-backend=*) trace_backends="$optarg"
965 --with-trace-file=*) trace_file="$optarg"
967 --enable-gprof) gprof="yes"
969 --enable-gcov) gcov="yes"
971 --static)
972 static="yes"
973 LDFLAGS="-static $LDFLAGS"
974 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
976 --mandir=*) mandir="$optarg"
978 --bindir=*) bindir="$optarg"
980 --libdir=*) libdir="$optarg"
982 --libexecdir=*) libexecdir="$optarg"
984 --includedir=*) includedir="$optarg"
986 --datadir=*) datadir="$optarg"
988 --with-confsuffix=*) confsuffix="$optarg"
990 --docdir=*) qemu_docdir="$optarg"
992 --sysconfdir=*) sysconfdir="$optarg"
994 --localstatedir=*) local_statedir="$optarg"
996 --firmwarepath=*) firmwarepath="$optarg"
998 --host=*|--build=*|\
999 --disable-dependency-tracking|\
1000 --sbindir=*|--sharedstatedir=*|\
1001 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1002 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1003 # These switches are silently ignored, for compatibility with
1004 # autoconf-generated configure scripts. This allows QEMU's
1005 # configure to be used by RPM and similar macros that set
1006 # lots of directory switches by default.
1008 --disable-sdl) sdl="no"
1010 --enable-sdl) sdl="yes"
1012 --with-sdlabi=*) sdlabi="$optarg"
1014 --disable-qom-cast-debug) qom_cast_debug="no"
1016 --enable-qom-cast-debug) qom_cast_debug="yes"
1018 --disable-virtfs) virtfs="no"
1020 --enable-virtfs) virtfs="yes"
1022 --disable-mpath) mpath="no"
1024 --enable-mpath) mpath="yes"
1026 --disable-vnc) vnc="no"
1028 --enable-vnc) vnc="yes"
1030 --oss-lib=*) oss_lib="$optarg"
1032 --audio-drv-list=*) audio_drv_list="$optarg"
1034 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1036 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1038 --enable-debug-tcg) debug_tcg="yes"
1040 --disable-debug-tcg) debug_tcg="no"
1042 --enable-debug)
1043 # Enable debugging options that aren't excessively noisy
1044 debug_tcg="yes"
1045 debug_mutex="yes"
1046 debug="yes"
1047 strip_opt="no"
1048 fortify_source="no"
1050 --enable-sanitizers) sanitizers="yes"
1052 --disable-sanitizers) sanitizers="no"
1054 --enable-sparse) sparse="yes"
1056 --disable-sparse) sparse="no"
1058 --disable-strip) strip_opt="no"
1060 --disable-vnc-sasl) vnc_sasl="no"
1062 --enable-vnc-sasl) vnc_sasl="yes"
1064 --disable-vnc-jpeg) vnc_jpeg="no"
1066 --enable-vnc-jpeg) vnc_jpeg="yes"
1068 --disable-vnc-png) vnc_png="no"
1070 --enable-vnc-png) vnc_png="yes"
1072 --disable-slirp) slirp="no"
1074 --disable-vde) vde="no"
1076 --enable-vde) vde="yes"
1078 --disable-netmap) netmap="no"
1080 --enable-netmap) netmap="yes"
1082 --disable-xen) xen="no"
1084 --enable-xen) xen="yes"
1086 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1088 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1090 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
1092 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
1094 --disable-brlapi) brlapi="no"
1096 --enable-brlapi) brlapi="yes"
1098 --disable-bluez) bluez="no"
1100 --enable-bluez) bluez="yes"
1102 --disable-kvm) kvm="no"
1104 --enable-kvm) kvm="yes"
1106 --disable-hax) hax="no"
1108 --enable-hax) hax="yes"
1110 --disable-hvf) hvf="no"
1112 --enable-hvf) hvf="yes"
1114 --disable-whpx) whpx="no"
1116 --enable-whpx) whpx="yes"
1118 --disable-tcg-interpreter) tcg_interpreter="no"
1120 --enable-tcg-interpreter) tcg_interpreter="yes"
1122 --disable-cap-ng) cap_ng="no"
1124 --enable-cap-ng) cap_ng="yes"
1126 --disable-tcg) tcg="no"
1128 --enable-tcg) tcg="yes"
1130 --disable-malloc-trim) malloc_trim="no"
1132 --enable-malloc-trim) malloc_trim="yes"
1134 --disable-spice) spice="no"
1136 --enable-spice) spice="yes"
1138 --disable-libiscsi) libiscsi="no"
1140 --enable-libiscsi) libiscsi="yes"
1142 --disable-libnfs) libnfs="no"
1144 --enable-libnfs) libnfs="yes"
1146 --enable-profiler) profiler="yes"
1148 --disable-cocoa) cocoa="no"
1150 --enable-cocoa)
1151 cocoa="yes" ;
1152 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1154 --disable-system) softmmu="no"
1156 --enable-system) softmmu="yes"
1158 --disable-user)
1159 linux_user="no" ;
1160 bsd_user="no" ;
1162 --enable-user) ;;
1163 --disable-linux-user) linux_user="no"
1165 --enable-linux-user) linux_user="yes"
1167 --disable-bsd-user) bsd_user="no"
1169 --enable-bsd-user) bsd_user="yes"
1171 --enable-pie) pie="yes"
1173 --disable-pie) pie="no"
1175 --enable-werror) werror="yes"
1177 --disable-werror) werror="no"
1179 --enable-stack-protector) stack_protector="yes"
1181 --disable-stack-protector) stack_protector="no"
1183 --disable-curses) curses="no"
1185 --enable-curses) curses="yes"
1187 --disable-curl) curl="no"
1189 --enable-curl) curl="yes"
1191 --disable-fdt) fdt="no"
1193 --enable-fdt) fdt="yes"
1195 --disable-linux-aio) linux_aio="no"
1197 --enable-linux-aio) linux_aio="yes"
1199 --disable-attr) attr="no"
1201 --enable-attr) attr="yes"
1203 --disable-membarrier) membarrier="no"
1205 --enable-membarrier) membarrier="yes"
1207 --disable-blobs) blobs="no"
1209 --with-pkgversion=*) pkgversion="$optarg"
1211 --with-coroutine=*) coroutine="$optarg"
1213 --disable-coroutine-pool) coroutine_pool="no"
1215 --enable-coroutine-pool) coroutine_pool="yes"
1217 --enable-debug-stack-usage) debug_stack_usage="yes"
1219 --enable-crypto-afalg) crypto_afalg="yes"
1221 --disable-crypto-afalg) crypto_afalg="no"
1223 --disable-docs) docs="no"
1225 --enable-docs) docs="yes"
1227 --disable-vhost-net) vhost_net="no"
1229 --enable-vhost-net) vhost_net="yes"
1231 --disable-vhost-crypto) vhost_crypto="no"
1233 --enable-vhost-crypto)
1234 vhost_crypto="yes"
1235 if test "$mingw32" = "yes"; then
1236 error_exit "vhost-crypto isn't available on win32"
1239 --disable-vhost-scsi) vhost_scsi="no"
1241 --enable-vhost-scsi) vhost_scsi="yes"
1243 --disable-vhost-vsock) vhost_vsock="no"
1245 --enable-vhost-vsock) vhost_vsock="yes"
1247 --disable-opengl) opengl="no"
1249 --enable-opengl) opengl="yes"
1251 --disable-rbd) rbd="no"
1253 --enable-rbd) rbd="yes"
1255 --disable-xfsctl) xfs="no"
1257 --enable-xfsctl) xfs="yes"
1259 --disable-smartcard) smartcard="no"
1261 --enable-smartcard) smartcard="yes"
1263 --disable-libusb) libusb="no"
1265 --enable-libusb) libusb="yes"
1267 --disable-usb-redir) usb_redir="no"
1269 --enable-usb-redir) usb_redir="yes"
1271 --disable-zlib-test) zlib="no"
1273 --disable-lzo) lzo="no"
1275 --enable-lzo) lzo="yes"
1277 --disable-snappy) snappy="no"
1279 --enable-snappy) snappy="yes"
1281 --disable-bzip2) bzip2="no"
1283 --enable-bzip2) bzip2="yes"
1285 --enable-guest-agent) guest_agent="yes"
1287 --disable-guest-agent) guest_agent="no"
1289 --enable-guest-agent-msi) guest_agent_msi="yes"
1291 --disable-guest-agent-msi) guest_agent_msi="no"
1293 --with-vss-sdk) vss_win32_sdk=""
1295 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1297 --without-vss-sdk) vss_win32_sdk="no"
1299 --with-win-sdk) win_sdk=""
1301 --with-win-sdk=*) win_sdk="$optarg"
1303 --without-win-sdk) win_sdk="no"
1305 --enable-tools) want_tools="yes"
1307 --disable-tools) want_tools="no"
1309 --enable-seccomp) seccomp="yes"
1311 --disable-seccomp) seccomp="no"
1313 --disable-glusterfs) glusterfs="no"
1315 --enable-glusterfs) glusterfs="yes"
1317 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1318 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1320 --enable-vhdx|--disable-vhdx)
1321 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1323 --enable-uuid|--disable-uuid)
1324 echo "$0: $opt is obsolete, UUID support is always built" >&2
1326 --disable-gtk) gtk="no"
1328 --enable-gtk) gtk="yes"
1330 --tls-priority=*) tls_priority="$optarg"
1332 --disable-gnutls) gnutls="no"
1334 --enable-gnutls) gnutls="yes"
1336 --disable-nettle) nettle="no"
1338 --enable-nettle) nettle="yes"
1340 --disable-gcrypt) gcrypt="no"
1342 --enable-gcrypt) gcrypt="yes"
1344 --enable-rdma) rdma="yes"
1346 --disable-rdma) rdma="no"
1348 --with-gtkabi=*) gtkabi="$optarg"
1350 --disable-vte) vte="no"
1352 --enable-vte) vte="yes"
1354 --disable-virglrenderer) virglrenderer="no"
1356 --enable-virglrenderer) virglrenderer="yes"
1358 --disable-tpm) tpm="no"
1360 --enable-tpm) tpm="yes"
1362 --disable-libssh2) libssh2="no"
1364 --enable-libssh2) libssh2="yes"
1366 --disable-live-block-migration) live_block_migration="no"
1368 --enable-live-block-migration) live_block_migration="yes"
1370 --disable-numa) numa="no"
1372 --enable-numa) numa="yes"
1374 --disable-libxml2) libxml2="no"
1376 --enable-libxml2) libxml2="yes"
1378 --disable-tcmalloc) tcmalloc="no"
1380 --enable-tcmalloc) tcmalloc="yes"
1382 --disable-jemalloc) jemalloc="no"
1384 --enable-jemalloc) jemalloc="yes"
1386 --disable-replication) replication="no"
1388 --enable-replication) replication="yes"
1390 --disable-vxhs) vxhs="no"
1392 --enable-vxhs) vxhs="yes"
1394 --disable-vhost-user) vhost_user="no"
1396 --enable-vhost-user)
1397 vhost_user="yes"
1398 if test "$mingw32" = "yes"; then
1399 error_exit "vhost-user isn't available on win32"
1402 --disable-capstone) capstone="no"
1404 --enable-capstone) capstone="yes"
1406 --enable-capstone=git) capstone="git"
1408 --enable-capstone=system) capstone="system"
1410 --with-git=*) git="$optarg"
1412 --enable-git-update) git_update=yes
1414 --disable-git-update) git_update=no
1416 --enable-debug-mutex) debug_mutex=yes
1418 --disable-debug-mutex) debug_mutex=no
1421 echo "ERROR: unknown option $opt"
1422 echo "Try '$0 --help' for more information"
1423 exit 1
1425 esac
1426 done
1428 if test "$vhost_user" = ""; then
1429 if test "$mingw32" = "yes"; then
1430 vhost_user="no"
1431 else
1432 vhost_user="yes"
1436 case "$cpu" in
1437 ppc)
1438 CPU_CFLAGS="-m32"
1439 LDFLAGS="-m32 $LDFLAGS"
1440 cross_cc_powerpc=$cc
1441 cross_cc_cflags_powerpc=$CPU_CFLAGS
1443 ppc64)
1444 CPU_CFLAGS="-m64"
1445 LDFLAGS="-m64 $LDFLAGS"
1446 cross_cc_ppc64=$cc
1447 cross_cc_cflags_ppc64=$CPU_CFLAGS
1449 sparc)
1450 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1451 LDFLAGS="-m32 -mv8plus $LDFLAGS"
1452 cross_cc_sparc=$cc
1453 cross_cc_cflags_sparc=$CPU_CFLAGS
1455 sparc64)
1456 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1457 LDFLAGS="-m64 $LDFLAGS"
1458 cross_cc_sparc64=$cc
1459 cross_cc_cflags_sparc64=$CPU_CFLAGS
1461 s390)
1462 CPU_CFLAGS="-m31"
1463 LDFLAGS="-m31 $LDFLAGS"
1464 cross_cc_s390=$cc
1465 cross_cc_cflags_s390=$CPU_CFLAGS
1467 s390x)
1468 CPU_CFLAGS="-m64"
1469 LDFLAGS="-m64 $LDFLAGS"
1470 cross_cc_s390x=$cc
1471 cross_cc_cflags_s390x=$CPU_CFLAGS
1473 i386)
1474 CPU_CFLAGS="-m32"
1475 LDFLAGS="-m32 $LDFLAGS"
1476 cross_cc_i386=$cc
1477 cross_cc_cflags_i386=$CPU_CFLAGS
1479 x86_64)
1480 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1481 # If we truly care, we should simply detect this case at
1482 # runtime and generate the fallback to serial emulation.
1483 CPU_CFLAGS="-m64 -mcx16"
1484 LDFLAGS="-m64 $LDFLAGS"
1485 cross_cc_x86_64=$cc
1486 cross_cc_cflags_x86_64=$CPU_CFLAGS
1488 x32)
1489 CPU_CFLAGS="-mx32"
1490 LDFLAGS="-mx32 $LDFLAGS"
1491 cross_cc_i386=$cc
1492 cross_cc_cflags_i386=$CPU_CFLAGS
1494 # No special flags required for other host CPUs
1495 esac
1497 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1499 # For user-mode emulation the host arch has to be one we explicitly
1500 # support, even if we're using TCI.
1501 if [ "$ARCH" = "unknown" ]; then
1502 bsd_user="no"
1503 linux_user="no"
1506 default_target_list=""
1508 mak_wilds=""
1510 if [ "$softmmu" = "yes" ]; then
1511 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1513 if [ "$linux_user" = "yes" ]; then
1514 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1516 if [ "$bsd_user" = "yes" ]; then
1517 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1520 for config in $mak_wilds; do
1521 default_target_list="${default_target_list} $(basename "$config" .mak)"
1522 done
1524 # Enumerate public trace backends for --help output
1525 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1527 if test x"$show_help" = x"yes" ; then
1528 cat << EOF
1530 Usage: configure [options]
1531 Options: [defaults in brackets after descriptions]
1533 Standard options:
1534 --help print this message
1535 --prefix=PREFIX install in PREFIX [$prefix]
1536 --interp-prefix=PREFIX where to find shared libraries, etc.
1537 use %M for cpu name [$interp_prefix]
1538 --target-list=LIST set target list (default: build everything)
1539 $(echo Available targets: $default_target_list | \
1540 fold -s -w 53 | sed -e 's/^/ /')
1542 Advanced options (experts only):
1543 --source-path=PATH path of source code [$source_path]
1544 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1545 --cc=CC use C compiler CC [$cc]
1546 --iasl=IASL use ACPI compiler IASL [$iasl]
1547 --host-cc=CC use C compiler CC [$host_cc] for code run at
1548 build time
1549 --cxx=CXX use C++ compiler CXX [$cxx]
1550 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1551 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1552 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1553 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1554 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1555 --cross-cc-flags-ARCH= use compiler flags when building ARCH guest tests
1556 --make=MAKE use specified make [$make]
1557 --install=INSTALL use specified install [$install]
1558 --python=PYTHON use specified python [$python]
1559 --smbd=SMBD use specified smbd [$smbd]
1560 --with-git=GIT use specified git [$git]
1561 --static enable static build [$static]
1562 --mandir=PATH install man pages in PATH
1563 --datadir=PATH install firmware in PATH$confsuffix
1564 --docdir=PATH install documentation in PATH$confsuffix
1565 --bindir=PATH install binaries in PATH
1566 --libdir=PATH install libraries in PATH
1567 --libexecdir=PATH install helper binaries in PATH
1568 --sysconfdir=PATH install config in PATH$confsuffix
1569 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1570 --firmwarepath=PATH search PATH for firmware files
1571 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1572 --with-pkgversion=VERS use specified string as sub-version of the package
1573 --enable-debug enable common debug build options
1574 --enable-sanitizers enable default sanitizers
1575 --disable-strip disable stripping binaries
1576 --disable-werror disable compilation abort on warning
1577 --disable-stack-protector disable compiler-provided stack protection
1578 --audio-drv-list=LIST set audio drivers list:
1579 Available drivers: $audio_possible_drivers
1580 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1581 --block-drv-rw-whitelist=L
1582 set block driver read-write whitelist
1583 (affects only QEMU, not qemu-img)
1584 --block-drv-ro-whitelist=L
1585 set block driver read-only whitelist
1586 (affects only QEMU, not qemu-img)
1587 --enable-trace-backends=B Set trace backend
1588 Available backends: $trace_backend_list
1589 --with-trace-file=NAME Full PATH,NAME of file to store traces
1590 Default:trace-<pid>
1591 --disable-slirp disable SLIRP userspace network connectivity
1592 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1593 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1594 --oss-lib path to OSS library
1595 --cpu=CPU Build for host CPU [$cpu]
1596 --with-coroutine=BACKEND coroutine backend. Supported options:
1597 ucontext, sigaltstack, windows
1598 --enable-gcov enable test coverage analysis with gcov
1599 --gcov=GCOV use specified gcov [$gcov_tool]
1600 --disable-blobs disable installing provided firmware blobs
1601 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1602 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1603 --tls-priority default TLS protocol/cipher priority string
1604 --enable-gprof QEMU profiling with gprof
1605 --enable-profiler profiler support
1606 --enable-xen-pv-domain-build
1607 xen pv domain builder
1608 --enable-debug-stack-usage
1609 track the maximum stack usage of stacks created by qemu_alloc_stack
1611 Optional features, enabled with --enable-FEATURE and
1612 disabled with --disable-FEATURE, default is enabled if available:
1614 system all system emulation targets
1615 user supported user emulation targets
1616 linux-user all linux usermode emulation targets
1617 bsd-user all BSD usermode emulation targets
1618 docs build documentation
1619 guest-agent build the QEMU Guest Agent
1620 guest-agent-msi build guest agent Windows MSI installation package
1621 pie Position Independent Executables
1622 modules modules support
1623 debug-tcg TCG debugging (default is disabled)
1624 debug-info debugging information
1625 sparse sparse checker
1627 gnutls GNUTLS cryptography support
1628 nettle nettle cryptography support
1629 gcrypt libgcrypt cryptography support
1630 sdl SDL UI
1631 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1632 gtk gtk UI
1633 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1634 vte vte support for the gtk UI
1635 curses curses UI
1636 vnc VNC UI support
1637 vnc-sasl SASL encryption for VNC server
1638 vnc-jpeg JPEG lossy compression for VNC server
1639 vnc-png PNG compression for VNC server
1640 cocoa Cocoa UI (Mac OS X only)
1641 virtfs VirtFS
1642 mpath Multipath persistent reservation passthrough
1643 xen xen backend driver support
1644 xen-pci-passthrough PCI passthrough support for Xen
1645 brlapi BrlAPI (Braile)
1646 curl curl connectivity
1647 membarrier membarrier system call (for Linux 4.14+ or Windows)
1648 fdt fdt device tree
1649 bluez bluez stack connectivity
1650 kvm KVM acceleration support
1651 hax HAX acceleration support
1652 hvf Hypervisor.framework acceleration support
1653 whpx Windows Hypervisor Platform acceleration support
1654 rdma Enable RDMA-based migration and PVRDMA support
1655 vde support for vde network
1656 netmap support for netmap network
1657 linux-aio Linux AIO support
1658 cap-ng libcap-ng support
1659 attr attr and xattr support
1660 vhost-net vhost-net acceleration support
1661 vhost-crypto vhost-crypto acceleration support
1662 spice spice
1663 rbd rados block device (rbd)
1664 libiscsi iscsi support
1665 libnfs nfs support
1666 smartcard smartcard support (libcacard)
1667 libusb libusb (for usb passthrough)
1668 live-block-migration Block migration in the main migration stream
1669 usb-redir usb network redirection support
1670 lzo support of lzo compression library
1671 snappy support of snappy compression library
1672 bzip2 support of bzip2 compression library
1673 (for reading bzip2-compressed dmg images)
1674 seccomp seccomp support
1675 coroutine-pool coroutine freelist (better performance)
1676 glusterfs GlusterFS backend
1677 tpm TPM support
1678 libssh2 ssh block device support
1679 numa libnuma support
1680 libxml2 for Parallels image format
1681 tcmalloc tcmalloc support
1682 jemalloc jemalloc support
1683 replication replication support
1684 vhost-vsock virtio sockets device support
1685 opengl opengl support
1686 virglrenderer virgl rendering support
1687 xfsctl xfsctl support
1688 qom-cast-debug cast debugging support
1689 tools build qemu-io, qemu-nbd and qemu-image tools
1690 vxhs Veritas HyperScale vDisk backend support
1691 crypto-afalg Linux AF_ALG crypto backend driver
1692 vhost-user vhost-user support
1693 capstone capstone disassembler support
1694 debug-mutex mutex debugging support
1696 NOTE: The object files are built at the place where configure is launched
1698 exit 0
1701 if ! has $python; then
1702 error_exit "Python not found. Use --python=/path/to/python"
1705 # Note that if the Python conditional here evaluates True we will exit
1706 # with status 1 which is a shell 'false' value.
1707 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
1708 error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
1709 "Use --python=/path/to/python to specify a supported Python."
1712 # Suppress writing compiled files
1713 python="$python -B"
1715 # Check that the C compiler works. Doing this here before testing
1716 # the host CPU ensures that we had a valid CC to autodetect the
1717 # $cpu var (and we should bail right here if that's not the case).
1718 # It also allows the help message to be printed without a CC.
1719 write_c_skeleton;
1720 if compile_object ; then
1721 : C compiler works ok
1722 else
1723 error_exit "\"$cc\" either does not exist or does not work"
1725 if ! compile_prog ; then
1726 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1729 # Now we have handled --enable-tcg-interpreter and know we're not just
1730 # printing the help message, bail out if the host CPU isn't supported.
1731 if test "$ARCH" = "unknown"; then
1732 if test "$tcg_interpreter" = "yes" ; then
1733 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1734 else
1735 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1739 # Consult white-list to determine whether to enable werror
1740 # by default. Only enable by default for git builds
1741 if test -z "$werror" ; then
1742 if test -d "$source_path/.git" -a \
1743 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1744 werror="yes"
1745 else
1746 werror="no"
1750 if test "$bogus_os" = "yes"; then
1751 # Now that we know that we're not printing the help and that
1752 # the compiler works (so the results of the check_defines we used
1753 # to identify the OS are reliable), if we didn't recognize the
1754 # host OS we should stop now.
1755 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1758 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1759 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1760 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1761 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1762 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1763 gcc_flags="-Wno-string-plus-int $gcc_flags"
1764 gcc_flags="-Wno-error=address-of-packed-member $gcc_flags"
1765 # Note that we do not add -Werror to gcc_flags here, because that would
1766 # enable it for all configure tests. If a configure test failed due
1767 # to -Werror this would just silently disable some features,
1768 # so it's too error prone.
1770 cc_has_warning_flag() {
1771 write_c_skeleton;
1773 # Use the positive sense of the flag when testing for -Wno-wombat
1774 # support (gcc will happily accept the -Wno- form of unknown
1775 # warning options).
1776 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1777 compile_prog "-Werror $optflag" ""
1780 for flag in $gcc_flags; do
1781 if cc_has_warning_flag $flag ; then
1782 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1784 done
1786 if test "$stack_protector" != "no"; then
1787 cat > $TMPC << EOF
1788 int main(int argc, char *argv[])
1790 char arr[64], *p = arr, *c = argv[0];
1791 while (*c) {
1792 *p++ = *c++;
1794 return 0;
1797 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1798 sp_on=0
1799 for flag in $gcc_flags; do
1800 # We need to check both a compile and a link, since some compiler
1801 # setups fail only on a .c->.o compile and some only at link time
1802 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1803 compile_prog "-Werror $flag" ""; then
1804 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1805 sp_on=1
1806 break
1808 done
1809 if test "$stack_protector" = yes; then
1810 if test $sp_on = 0; then
1811 error_exit "Stack protector not supported"
1816 # Disable -Wmissing-braces on older compilers that warn even for
1817 # the "universal" C zero initializer {0}.
1818 cat > $TMPC << EOF
1819 struct {
1820 int a[2];
1821 } x = {0};
1823 if compile_object "-Werror" "" ; then
1825 else
1826 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1829 # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1830 # large functions that use global variables. The bug is in all releases of
1831 # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1832 # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1833 cat > $TMPC << EOF
1834 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1835 int main(void) { return 0; }
1836 #else
1837 #error No bug in this compiler.
1838 #endif
1840 if compile_prog "-Werror -fno-gcse" "" ; then
1841 TRANSLATE_OPT_CFLAGS=-fno-gcse
1844 if test "$static" = "yes" ; then
1845 if test "$modules" = "yes" ; then
1846 error_exit "static and modules are mutually incompatible"
1848 if test "$pie" = "yes" ; then
1849 error_exit "static and pie are mutually incompatible"
1850 else
1851 pie="no"
1855 # Unconditional check for compiler __thread support
1856 cat > $TMPC << EOF
1857 static __thread int tls_var;
1858 int main(void) { return tls_var; }
1861 if ! compile_prog "-Werror" "" ; then
1862 error_exit "Your compiler does not support the __thread specifier for " \
1863 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1866 if test "$pie" = ""; then
1867 case "$cpu-$targetos" in
1868 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1871 pie="no"
1873 esac
1876 if test "$pie" != "no" ; then
1877 cat > $TMPC << EOF
1879 #ifdef __linux__
1880 # define THREAD __thread
1881 #else
1882 # define THREAD
1883 #endif
1885 static THREAD int tls_var;
1887 int main(void) { return tls_var; }
1890 if compile_prog "-fPIE -DPIE" "-pie"; then
1891 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1892 LDFLAGS="-pie $LDFLAGS"
1893 pie="yes"
1894 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1895 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1897 else
1898 if test "$pie" = "yes"; then
1899 error_exit "PIE not available due to missing toolchain support"
1900 else
1901 echo "Disabling PIE due to missing toolchain support"
1902 pie="no"
1906 if compile_prog "-Werror -fno-pie" "-nopie"; then
1907 CFLAGS_NOPIE="-fno-pie"
1908 LDFLAGS_NOPIE="-nopie"
1912 ##########################################
1913 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1914 # use i686 as default anyway, but for those that don't, an explicit
1915 # specification is necessary
1917 if test "$cpu" = "i386"; then
1918 cat > $TMPC << EOF
1919 static int sfaa(int *ptr)
1921 return __sync_fetch_and_and(ptr, 0);
1924 int main(void)
1926 int val = 42;
1927 val = __sync_val_compare_and_swap(&val, 0, 1);
1928 sfaa(&val);
1929 return val;
1932 if ! compile_prog "" "" ; then
1933 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1937 #########################################
1938 # Solaris specific configure tool chain decisions
1940 if test "$solaris" = "yes" ; then
1941 if has $install; then
1943 else
1944 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1945 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1946 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1948 if test "$(path_of $install)" = "/usr/sbin/install" ; then
1949 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1950 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1951 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1953 if has ar; then
1955 else
1956 if test -f /usr/ccs/bin/ar ; then
1957 error_exit "No path includes ar" \
1958 "Add /usr/ccs/bin to your path and rerun configure"
1960 error_exit "No path includes ar"
1964 if test -z "${target_list+xxx}" ; then
1965 for target in $default_target_list; do
1966 supported_target $target 2>/dev/null && \
1967 target_list="$target_list $target"
1968 done
1969 target_list="${target_list# }"
1970 else
1971 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1972 for target in $target_list; do
1973 # Check that we recognised the target name; this allows a more
1974 # friendly error message than if we let it fall through.
1975 case " $default_target_list " in
1976 *" $target "*)
1979 error_exit "Unknown target name '$target'"
1981 esac
1982 supported_target $target || exit 1
1983 done
1986 # see if system emulation was really requested
1987 case " $target_list " in
1988 *"-softmmu "*) softmmu=yes
1990 *) softmmu=no
1992 esac
1994 feature_not_found() {
1995 feature=$1
1996 remedy=$2
1998 error_exit "User requested feature $feature" \
1999 "configure was not able to find it." \
2000 "$remedy"
2003 # ---
2004 # big/little endian test
2005 cat > $TMPC << EOF
2006 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
2007 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
2008 extern int foo(short *, short *);
2009 int main(int argc, char *argv[]) {
2010 return foo(big_endian, little_endian);
2014 if compile_object ; then
2015 if strings -a $TMPO | grep -q BiGeNdIaN ; then
2016 bigendian="yes"
2017 elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
2018 bigendian="no"
2019 else
2020 echo big/little test failed
2022 else
2023 echo big/little test failed
2026 ##########################################
2027 # cocoa implies not SDL or GTK
2028 # (the cocoa UI code currently assumes it is always the active UI
2029 # and doesn't interact well with other UI frontend code)
2030 if test "$cocoa" = "yes"; then
2031 if test "$sdl" = "yes"; then
2032 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2034 if test "$gtk" = "yes"; then
2035 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2037 gtk=no
2038 sdl=no
2041 # Some versions of Mac OS X incorrectly define SIZE_MAX
2042 cat > $TMPC << EOF
2043 #include <stdint.h>
2044 #include <stdio.h>
2045 int main(int argc, char *argv[]) {
2046 return printf("%zu", SIZE_MAX);
2049 have_broken_size_max=no
2050 if ! compile_object -Werror ; then
2051 have_broken_size_max=yes
2054 ##########################################
2055 # L2TPV3 probe
2057 cat > $TMPC <<EOF
2058 #include <sys/socket.h>
2059 #include <linux/ip.h>
2060 int main(void) { return sizeof(struct mmsghdr); }
2062 if compile_prog "" "" ; then
2063 l2tpv3=yes
2064 else
2065 l2tpv3=no
2068 ##########################################
2069 # MinGW / Mingw-w64 localtime_r/gmtime_r check
2071 if test "$mingw32" = "yes"; then
2072 # Some versions of MinGW / Mingw-w64 lack localtime_r
2073 # and gmtime_r entirely.
2075 # Some versions of Mingw-w64 define a macro for
2076 # localtime_r/gmtime_r.
2078 # Some versions of Mingw-w64 will define functions
2079 # for localtime_r/gmtime_r, but only if you have
2080 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
2081 # though, unistd.h and pthread.h both define
2082 # that for you.
2084 # So this #undef localtime_r and #include <unistd.h>
2085 # are not in fact redundant.
2086 cat > $TMPC << EOF
2087 #include <unistd.h>
2088 #include <time.h>
2089 #undef localtime_r
2090 int main(void) { localtime_r(NULL, NULL); return 0; }
2092 if compile_prog "" "" ; then
2093 localtime_r="yes"
2094 else
2095 localtime_r="no"
2099 ##########################################
2100 # pkg-config probe
2102 if ! has "$pkg_config_exe"; then
2103 error_exit "pkg-config binary '$pkg_config_exe' not found"
2106 ##########################################
2107 # NPTL probe
2109 if test "$linux_user" = "yes"; then
2110 cat > $TMPC <<EOF
2111 #include <sched.h>
2112 #include <linux/futex.h>
2113 int main(void) {
2114 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2115 #error bork
2116 #endif
2117 return 0;
2120 if ! compile_object ; then
2121 feature_not_found "nptl" "Install glibc and linux kernel headers."
2125 #########################################
2126 # zlib check
2128 if test "$zlib" != "no" ; then
2129 cat > $TMPC << EOF
2130 #include <zlib.h>
2131 int main(void) { zlibVersion(); return 0; }
2133 if compile_prog "" "-lz" ; then
2135 else
2136 error_exit "zlib check failed" \
2137 "Make sure to have the zlib libs and headers installed."
2140 LIBS="$LIBS -lz"
2142 ##########################################
2143 # lzo check
2145 if test "$lzo" != "no" ; then
2146 cat > $TMPC << EOF
2147 #include <lzo/lzo1x.h>
2148 int main(void) { lzo_version(); return 0; }
2150 if compile_prog "" "-llzo2" ; then
2151 libs_softmmu="$libs_softmmu -llzo2"
2152 lzo="yes"
2153 else
2154 if test "$lzo" = "yes"; then
2155 feature_not_found "liblzo2" "Install liblzo2 devel"
2157 lzo="no"
2161 ##########################################
2162 # snappy check
2164 if test "$snappy" != "no" ; then
2165 cat > $TMPC << EOF
2166 #include <snappy-c.h>
2167 int main(void) { snappy_max_compressed_length(4096); return 0; }
2169 if compile_prog "" "-lsnappy" ; then
2170 libs_softmmu="$libs_softmmu -lsnappy"
2171 snappy="yes"
2172 else
2173 if test "$snappy" = "yes"; then
2174 feature_not_found "libsnappy" "Install libsnappy devel"
2176 snappy="no"
2180 ##########################################
2181 # bzip2 check
2183 if test "$bzip2" != "no" ; then
2184 cat > $TMPC << EOF
2185 #include <bzlib.h>
2186 int main(void) { BZ2_bzlibVersion(); return 0; }
2188 if compile_prog "" "-lbz2" ; then
2189 bzip2="yes"
2190 else
2191 if test "$bzip2" = "yes"; then
2192 feature_not_found "libbzip2" "Install libbzip2 devel"
2194 bzip2="no"
2198 ##########################################
2199 # libseccomp check
2201 if test "$seccomp" != "no" ; then
2202 case "$cpu" in
2203 i386|x86_64)
2204 libseccomp_minver="2.1.0"
2206 mips)
2207 libseccomp_minver="2.2.0"
2209 arm|aarch64)
2210 libseccomp_minver="2.2.3"
2212 ppc|ppc64|s390x)
2213 libseccomp_minver="2.3.0"
2216 libseccomp_minver=""
2218 esac
2220 if test "$libseccomp_minver" != "" &&
2221 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2222 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2223 seccomp_libs="$($pkg_config --libs libseccomp)"
2224 seccomp="yes"
2225 else
2226 if test "$seccomp" = "yes" ; then
2227 if test "$libseccomp_minver" != "" ; then
2228 feature_not_found "libseccomp" \
2229 "Install libseccomp devel >= $libseccomp_minver"
2230 else
2231 feature_not_found "libseccomp" \
2232 "libseccomp is not supported for host cpu $cpu"
2235 seccomp="no"
2238 ##########################################
2239 # xen probe
2241 if test "$xen" != "no" ; then
2242 # Check whether Xen library path is specified via --extra-ldflags to avoid
2243 # overriding this setting with pkg-config output. If not, try pkg-config
2244 # to obtain all needed flags.
2246 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2247 $pkg_config --exists xencontrol ; then
2248 xen_ctrl_version="$(printf '%d%02d%02d' \
2249 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2250 xen=yes
2251 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2252 xen_pc="$xen_pc xenevtchn xendevicemodel"
2253 if $pkg_config --exists xentoolcore; then
2254 xen_pc="$xen_pc xentoolcore"
2256 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2257 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2258 LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2259 else
2261 xen_libs="-lxenstore -lxenctrl -lxenguest"
2262 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2264 # First we test whether Xen headers and libraries are available.
2265 # If no, we are done and there is no Xen support.
2266 # If yes, more tests are run to detect the Xen version.
2268 # Xen (any)
2269 cat > $TMPC <<EOF
2270 #include <xenctrl.h>
2271 int main(void) {
2272 return 0;
2275 if ! compile_prog "" "$xen_libs" ; then
2276 # Xen not found
2277 if test "$xen" = "yes" ; then
2278 feature_not_found "xen" "Install xen devel"
2280 xen=no
2282 # Xen unstable
2283 elif
2284 cat > $TMPC <<EOF &&
2285 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2286 #define __XEN_TOOLS__
2287 #include <xendevicemodel.h>
2288 #include <xenforeignmemory.h>
2289 int main(void) {
2290 xendevicemodel_handle *xd;
2291 xenforeignmemory_handle *xfmem;
2293 xd = xendevicemodel_open(0, 0);
2294 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
2296 xfmem = xenforeignmemory_open(0, 0);
2297 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2299 return 0;
2302 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2303 then
2304 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2305 xen_ctrl_version=41100
2306 xen=yes
2307 elif
2308 cat > $TMPC <<EOF &&
2309 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2310 #include <xenforeignmemory.h>
2311 #include <xentoolcore.h>
2312 int main(void) {
2313 xenforeignmemory_handle *xfmem;
2315 xfmem = xenforeignmemory_open(0, 0);
2316 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2317 xentoolcore_restrict_all(0);
2319 return 0;
2322 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
2323 then
2324 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
2325 xen_ctrl_version=41000
2326 xen=yes
2327 elif
2328 cat > $TMPC <<EOF &&
2329 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2330 #define __XEN_TOOLS__
2331 #include <xendevicemodel.h>
2332 int main(void) {
2333 xendevicemodel_handle *xd;
2335 xd = xendevicemodel_open(0, 0);
2336 xendevicemodel_close(xd);
2338 return 0;
2341 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2342 then
2343 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2344 xen_ctrl_version=40900
2345 xen=yes
2346 elif
2347 cat > $TMPC <<EOF &&
2349 * If we have stable libs the we don't want the libxc compat
2350 * layers, regardless of what CFLAGS we may have been given.
2352 * Also, check if xengnttab_grant_copy_segment_t is defined and
2353 * grant copy operation is implemented.
2355 #undef XC_WANT_COMPAT_EVTCHN_API
2356 #undef XC_WANT_COMPAT_GNTTAB_API
2357 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2358 #include <xenctrl.h>
2359 #include <xenstore.h>
2360 #include <xenevtchn.h>
2361 #include <xengnttab.h>
2362 #include <xenforeignmemory.h>
2363 #include <stdint.h>
2364 #include <xen/hvm/hvm_info_table.h>
2365 #if !defined(HVM_MAX_VCPUS)
2366 # error HVM_MAX_VCPUS not defined
2367 #endif
2368 int main(void) {
2369 xc_interface *xc = NULL;
2370 xenforeignmemory_handle *xfmem;
2371 xenevtchn_handle *xe;
2372 xengnttab_handle *xg;
2373 xen_domain_handle_t handle;
2374 xengnttab_grant_copy_segment_t* seg = NULL;
2376 xs_daemon_open();
2378 xc = xc_interface_open(0, 0, 0);
2379 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2380 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2381 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2382 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2383 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2385 xfmem = xenforeignmemory_open(0, 0);
2386 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2388 xe = xenevtchn_open(0, 0);
2389 xenevtchn_fd(xe);
2391 xg = xengnttab_open(0, 0);
2392 xengnttab_grant_copy(xg, 0, seg);
2394 return 0;
2397 compile_prog "" "$xen_libs $xen_stable_libs"
2398 then
2399 xen_ctrl_version=40800
2400 xen=yes
2401 elif
2402 cat > $TMPC <<EOF &&
2404 * If we have stable libs the we don't want the libxc compat
2405 * layers, regardless of what CFLAGS we may have been given.
2407 #undef XC_WANT_COMPAT_EVTCHN_API
2408 #undef XC_WANT_COMPAT_GNTTAB_API
2409 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2410 #include <xenctrl.h>
2411 #include <xenstore.h>
2412 #include <xenevtchn.h>
2413 #include <xengnttab.h>
2414 #include <xenforeignmemory.h>
2415 #include <stdint.h>
2416 #include <xen/hvm/hvm_info_table.h>
2417 #if !defined(HVM_MAX_VCPUS)
2418 # error HVM_MAX_VCPUS not defined
2419 #endif
2420 int main(void) {
2421 xc_interface *xc = NULL;
2422 xenforeignmemory_handle *xfmem;
2423 xenevtchn_handle *xe;
2424 xengnttab_handle *xg;
2425 xen_domain_handle_t handle;
2427 xs_daemon_open();
2429 xc = xc_interface_open(0, 0, 0);
2430 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2431 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2432 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2433 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2434 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2436 xfmem = xenforeignmemory_open(0, 0);
2437 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2439 xe = xenevtchn_open(0, 0);
2440 xenevtchn_fd(xe);
2442 xg = xengnttab_open(0, 0);
2443 xengnttab_map_grant_ref(xg, 0, 0, 0);
2445 return 0;
2448 compile_prog "" "$xen_libs $xen_stable_libs"
2449 then
2450 xen_ctrl_version=40701
2451 xen=yes
2452 elif
2453 cat > $TMPC <<EOF &&
2454 #include <xenctrl.h>
2455 #include <stdint.h>
2456 int main(void) {
2457 xc_interface *xc = NULL;
2458 xen_domain_handle_t handle;
2459 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2460 return 0;
2463 compile_prog "" "$xen_libs"
2464 then
2465 xen_ctrl_version=40700
2466 xen=yes
2468 # Xen 4.6
2469 elif
2470 cat > $TMPC <<EOF &&
2471 #include <xenctrl.h>
2472 #include <xenstore.h>
2473 #include <stdint.h>
2474 #include <xen/hvm/hvm_info_table.h>
2475 #if !defined(HVM_MAX_VCPUS)
2476 # error HVM_MAX_VCPUS not defined
2477 #endif
2478 int main(void) {
2479 xc_interface *xc;
2480 xs_daemon_open();
2481 xc = xc_interface_open(0, 0, 0);
2482 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2483 xc_gnttab_open(NULL, 0);
2484 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2485 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2486 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2487 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2488 return 0;
2491 compile_prog "" "$xen_libs"
2492 then
2493 xen_ctrl_version=40600
2494 xen=yes
2496 # Xen 4.5
2497 elif
2498 cat > $TMPC <<EOF &&
2499 #include <xenctrl.h>
2500 #include <xenstore.h>
2501 #include <stdint.h>
2502 #include <xen/hvm/hvm_info_table.h>
2503 #if !defined(HVM_MAX_VCPUS)
2504 # error HVM_MAX_VCPUS not defined
2505 #endif
2506 int main(void) {
2507 xc_interface *xc;
2508 xs_daemon_open();
2509 xc = xc_interface_open(0, 0, 0);
2510 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2511 xc_gnttab_open(NULL, 0);
2512 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2513 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2514 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2515 return 0;
2518 compile_prog "" "$xen_libs"
2519 then
2520 xen_ctrl_version=40500
2521 xen=yes
2523 elif
2524 cat > $TMPC <<EOF &&
2525 #include <xenctrl.h>
2526 #include <xenstore.h>
2527 #include <stdint.h>
2528 #include <xen/hvm/hvm_info_table.h>
2529 #if !defined(HVM_MAX_VCPUS)
2530 # error HVM_MAX_VCPUS not defined
2531 #endif
2532 int main(void) {
2533 xc_interface *xc;
2534 xs_daemon_open();
2535 xc = xc_interface_open(0, 0, 0);
2536 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2537 xc_gnttab_open(NULL, 0);
2538 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2539 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2540 return 0;
2543 compile_prog "" "$xen_libs"
2544 then
2545 xen_ctrl_version=40200
2546 xen=yes
2548 else
2549 if test "$xen" = "yes" ; then
2550 feature_not_found "xen (unsupported version)" \
2551 "Install a supported xen (xen 4.2 or newer)"
2553 xen=no
2556 if test "$xen" = yes; then
2557 if test $xen_ctrl_version -ge 40701 ; then
2558 libs_softmmu="$xen_stable_libs $libs_softmmu"
2560 libs_softmmu="$xen_libs $libs_softmmu"
2565 if test "$xen_pci_passthrough" != "no"; then
2566 if test "$xen" = "yes" && test "$linux" = "yes"; then
2567 xen_pci_passthrough=yes
2568 else
2569 if test "$xen_pci_passthrough" = "yes"; then
2570 error_exit "User requested feature Xen PCI Passthrough" \
2571 " but this feature requires /sys from Linux"
2573 xen_pci_passthrough=no
2577 if test "$xen_pv_domain_build" = "yes" &&
2578 test "$xen" != "yes"; then
2579 error_exit "User requested Xen PV domain builder support" \
2580 "which requires Xen support."
2583 ##########################################
2584 # Windows Hypervisor Platform accelerator (WHPX) check
2585 if test "$whpx" != "no" ; then
2586 if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
2587 whpx="yes"
2588 else
2589 if test "$whpx" = "yes"; then
2590 feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
2592 whpx="no"
2596 ##########################################
2597 # Sparse probe
2598 if test "$sparse" != "no" ; then
2599 if has cgcc; then
2600 sparse=yes
2601 else
2602 if test "$sparse" = "yes" ; then
2603 feature_not_found "sparse" "Install sparse binary"
2605 sparse=no
2609 ##########################################
2610 # X11 probe
2611 if $pkg_config --exists "x11"; then
2612 have_x11=yes
2613 x11_cflags=$($pkg_config --cflags x11)
2614 x11_libs=$($pkg_config --libs x11)
2617 ##########################################
2618 # GTK probe
2620 if test "$gtk" != "no"; then
2621 if test "$gtkabi" = ""; then
2622 # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
2623 # Use 2.0 as a fallback if that is available.
2624 if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2625 gtkabi=3.0
2626 elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2627 gtkabi=2.0
2628 else
2629 gtkabi=3.0
2632 gtkpackage="gtk+-$gtkabi"
2633 gtkx11package="gtk+-x11-$gtkabi"
2634 if test "$gtkabi" = "3.0" ; then
2635 gtkversion="3.0.0"
2636 else
2637 gtkversion="2.18.0"
2639 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2640 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2641 gtk_libs=$($pkg_config --libs $gtkpackage)
2642 gtk_version=$($pkg_config --modversion $gtkpackage)
2643 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2644 need_x11=yes
2645 gtk_cflags="$gtk_cflags $x11_cflags"
2646 gtk_libs="$gtk_libs $x11_libs"
2648 gtk="yes"
2649 elif test "$gtk" = "yes"; then
2650 feature_not_found "gtk" "Install gtk3-devel"
2651 else
2652 gtk="no"
2657 ##########################################
2658 # GNUTLS probe
2660 gnutls_works() {
2661 # Unfortunately some distros have bad pkg-config information for gnutls
2662 # such that it claims to exist but you get a compiler error if you try
2663 # to use the options returned by --libs. Specifically, Ubuntu for --static
2664 # builds doesn't work:
2665 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2667 # So sanity check the cflags/libs before assuming gnutls can be used.
2668 if ! $pkg_config --exists "gnutls"; then
2669 return 1
2672 write_c_skeleton
2673 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2676 gnutls_gcrypt=no
2677 gnutls_nettle=no
2678 if test "$gnutls" != "no"; then
2679 if gnutls_works; then
2680 gnutls_cflags=$($pkg_config --cflags gnutls)
2681 gnutls_libs=$($pkg_config --libs gnutls)
2682 libs_softmmu="$gnutls_libs $libs_softmmu"
2683 libs_tools="$gnutls_libs $libs_tools"
2684 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2685 gnutls="yes"
2687 # gnutls_rnd requires >= 2.11.0
2688 if $pkg_config --exists "gnutls >= 2.11.0"; then
2689 gnutls_rnd="yes"
2690 else
2691 gnutls_rnd="no"
2694 if $pkg_config --exists 'gnutls >= 3.0'; then
2695 gnutls_gcrypt=no
2696 gnutls_nettle=yes
2697 elif $pkg_config --exists 'gnutls >= 2.12'; then
2698 case $($pkg_config --libs --static gnutls) in
2699 *gcrypt*)
2700 gnutls_gcrypt=yes
2701 gnutls_nettle=no
2703 *nettle*)
2704 gnutls_gcrypt=no
2705 gnutls_nettle=yes
2708 gnutls_gcrypt=yes
2709 gnutls_nettle=no
2711 esac
2712 else
2713 gnutls_gcrypt=yes
2714 gnutls_nettle=no
2716 elif test "$gnutls" = "yes"; then
2717 feature_not_found "gnutls" "Install gnutls devel"
2718 else
2719 gnutls="no"
2720 gnutls_rnd="no"
2722 else
2723 gnutls_rnd="no"
2727 # If user didn't give a --disable/enable-gcrypt flag,
2728 # then mark as disabled if user requested nettle
2729 # explicitly, or if gnutls links to nettle
2730 if test -z "$gcrypt"
2731 then
2732 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2733 then
2734 gcrypt="no"
2738 # If user didn't give a --disable/enable-nettle flag,
2739 # then mark as disabled if user requested gcrypt
2740 # explicitly, or if gnutls links to gcrypt
2741 if test -z "$nettle"
2742 then
2743 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2744 then
2745 nettle="no"
2749 has_libgcrypt_config() {
2750 if ! has "libgcrypt-config"
2751 then
2752 return 1
2755 if test -n "$cross_prefix"
2756 then
2757 host=$(libgcrypt-config --host)
2758 if test "$host-" != $cross_prefix
2759 then
2760 return 1
2764 return 0
2767 if test "$gcrypt" != "no"; then
2768 if has_libgcrypt_config; then
2769 gcrypt_cflags=$(libgcrypt-config --cflags)
2770 gcrypt_libs=$(libgcrypt-config --libs)
2771 # Debian has remove -lgpg-error from libgcrypt-config
2772 # as it "spreads unnecessary dependencies" which in
2773 # turn breaks static builds...
2774 if test "$static" = "yes"
2775 then
2776 gcrypt_libs="$gcrypt_libs -lgpg-error"
2778 libs_softmmu="$gcrypt_libs $libs_softmmu"
2779 libs_tools="$gcrypt_libs $libs_tools"
2780 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2781 gcrypt="yes"
2782 if test -z "$nettle"; then
2783 nettle="no"
2786 cat > $TMPC << EOF
2787 #include <gcrypt.h>
2788 int main(void) {
2789 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2790 GCRY_MD_SHA256,
2791 NULL, 0, 0, 0, NULL);
2792 return 0;
2795 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2796 gcrypt_kdf=yes
2799 cat > $TMPC << EOF
2800 #include <gcrypt.h>
2801 int main(void) {
2802 gcry_mac_hd_t handle;
2803 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2804 GCRY_MAC_FLAG_SECURE, NULL);
2805 return 0;
2808 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2809 gcrypt_hmac=yes
2811 else
2812 if test "$gcrypt" = "yes"; then
2813 feature_not_found "gcrypt" "Install gcrypt devel"
2814 else
2815 gcrypt="no"
2821 if test "$nettle" != "no"; then
2822 if $pkg_config --exists "nettle"; then
2823 nettle_cflags=$($pkg_config --cflags nettle)
2824 nettle_libs=$($pkg_config --libs nettle)
2825 nettle_version=$($pkg_config --modversion nettle)
2826 libs_softmmu="$nettle_libs $libs_softmmu"
2827 libs_tools="$nettle_libs $libs_tools"
2828 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2829 nettle="yes"
2831 cat > $TMPC << EOF
2832 #include <stddef.h>
2833 #include <nettle/pbkdf2.h>
2834 int main(void) {
2835 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2836 return 0;
2839 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2840 nettle_kdf=yes
2842 else
2843 if test "$nettle" = "yes"; then
2844 feature_not_found "nettle" "Install nettle devel"
2845 else
2846 nettle="no"
2851 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2852 then
2853 error_exit "Only one of gcrypt & nettle can be enabled"
2856 ##########################################
2857 # libtasn1 - only for the TLS creds/session test suite
2859 tasn1=yes
2860 tasn1_cflags=""
2861 tasn1_libs=""
2862 if $pkg_config --exists "libtasn1"; then
2863 tasn1_cflags=$($pkg_config --cflags libtasn1)
2864 tasn1_libs=$($pkg_config --libs libtasn1)
2865 else
2866 tasn1=no
2870 ##########################################
2871 # getifaddrs (for tests/test-io-channel-socket )
2873 have_ifaddrs_h=yes
2874 if ! check_include "ifaddrs.h" ; then
2875 have_ifaddrs_h=no
2878 ##########################################
2879 # VTE probe
2881 if test "$vte" != "no"; then
2882 if test "$gtkabi" = "3.0"; then
2883 vteminversion="0.32.0"
2884 if $pkg_config --exists "vte-2.91"; then
2885 vtepackage="vte-2.91"
2886 else
2887 vtepackage="vte-2.90"
2889 else
2890 vtepackage="vte"
2891 vteminversion="0.24.0"
2893 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2894 vte_cflags=$($pkg_config --cflags $vtepackage)
2895 vte_libs=$($pkg_config --libs $vtepackage)
2896 vteversion=$($pkg_config --modversion $vtepackage)
2897 vte="yes"
2898 elif test "$vte" = "yes"; then
2899 if test "$gtkabi" = "3.0"; then
2900 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2901 else
2902 feature_not_found "vte" "Install libvte devel"
2904 else
2905 vte="no"
2909 ##########################################
2910 # SDL probe
2912 # Look for sdl configuration program (pkg-config or sdl-config). Try
2913 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2915 sdl_probe ()
2917 sdl_too_old=no
2918 if test "$sdlabi" = ""; then
2919 if $pkg_config --exists "sdl2"; then
2920 sdlabi=2.0
2921 elif $pkg_config --exists "sdl"; then
2922 sdlabi=1.2
2923 else
2924 sdlabi=2.0
2928 if test $sdlabi = "2.0"; then
2929 sdl_config=$sdl2_config
2930 sdlname=sdl2
2931 sdlconfigname=sdl2_config
2932 elif test $sdlabi = "1.2"; then
2933 sdlname=sdl
2934 sdlconfigname=sdl_config
2935 else
2936 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2939 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2940 sdl_config=$sdlconfigname
2943 if $pkg_config $sdlname --exists; then
2944 sdlconfig="$pkg_config $sdlname"
2945 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2946 elif has ${sdl_config}; then
2947 sdlconfig="$sdl_config"
2948 sdlversion=$($sdlconfig --version)
2949 else
2950 if test "$sdl" = "yes" ; then
2951 feature_not_found "sdl" "Install SDL2-devel"
2953 sdl=no
2954 # no need to do the rest
2955 return
2957 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2958 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2961 cat > $TMPC << EOF
2962 #include <SDL.h>
2963 #undef main /* We don't want SDL to override our main() */
2964 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2966 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2967 sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug
2968 if test "$static" = "yes" ; then
2969 if $pkg_config $sdlname --exists; then
2970 sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
2971 else
2972 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2974 else
2975 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2977 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2978 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
2979 sdl_too_old=yes
2980 else
2981 sdl=yes
2984 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2985 if test "$sdl" = "yes" -a "$static" = "yes" ; then
2986 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2987 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2988 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2990 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2992 else
2993 sdl=no
2995 fi # static link
2996 else # sdl not found
2997 if test "$sdl" = "yes" ; then
2998 feature_not_found "sdl" "Install SDL devel"
3000 sdl=no
3001 fi # sdl compile test
3004 if test "$sdl" != "no" ; then
3005 sdl_probe
3008 if test "$sdl" = "yes" ; then
3009 cat > $TMPC <<EOF
3010 #include <SDL.h>
3011 #if defined(SDL_VIDEO_DRIVER_X11)
3012 #include <X11/XKBlib.h>
3013 #else
3014 #error No x11 support
3015 #endif
3016 int main(void) { return 0; }
3018 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
3019 need_x11=yes
3020 sdl_cflags="$sdl_cflags $x11_cflags"
3021 sdl_libs="$sdl_libs $x11_libs"
3025 ##########################################
3026 # RDMA needs OpenFabrics libraries
3027 if test "$rdma" != "no" ; then
3028 cat > $TMPC <<EOF
3029 #include <rdma/rdma_cma.h>
3030 int main(void) { return 0; }
3032 rdma_libs="-lrdmacm -libverbs -libumad"
3033 if compile_prog "" "$rdma_libs" ; then
3034 rdma="yes"
3035 libs_softmmu="$libs_softmmu $rdma_libs"
3036 else
3037 if test "$rdma" = "yes" ; then
3038 error_exit \
3039 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
3040 " Your options:" \
3041 " (1) Fast: Install infiniband packages (devel) from your distro." \
3042 " (2) Cleanest: Install libraries from www.openfabrics.org" \
3043 " (3) Also: Install softiwarp if you don't have RDMA hardware"
3045 rdma="no"
3050 ##########################################
3051 # VNC SASL detection
3052 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
3053 cat > $TMPC <<EOF
3054 #include <sasl/sasl.h>
3055 #include <stdio.h>
3056 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
3058 # Assuming Cyrus-SASL installed in /usr prefix
3059 vnc_sasl_cflags=""
3060 vnc_sasl_libs="-lsasl2"
3061 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3062 vnc_sasl=yes
3063 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3064 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
3065 else
3066 if test "$vnc_sasl" = "yes" ; then
3067 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3069 vnc_sasl=no
3073 ##########################################
3074 # VNC JPEG detection
3075 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
3076 cat > $TMPC <<EOF
3077 #include <stdio.h>
3078 #include <jpeglib.h>
3079 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
3081 vnc_jpeg_cflags=""
3082 vnc_jpeg_libs="-ljpeg"
3083 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
3084 vnc_jpeg=yes
3085 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3086 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
3087 else
3088 if test "$vnc_jpeg" = "yes" ; then
3089 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
3091 vnc_jpeg=no
3095 ##########################################
3096 # VNC PNG detection
3097 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
3098 cat > $TMPC <<EOF
3099 //#include <stdio.h>
3100 #include <png.h>
3101 #include <stddef.h>
3102 int main(void) {
3103 png_structp png_ptr;
3104 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
3105 return png_ptr != 0;
3108 if $pkg_config libpng --exists; then
3109 vnc_png_cflags=$($pkg_config libpng --cflags)
3110 vnc_png_libs=$($pkg_config libpng --libs)
3111 else
3112 vnc_png_cflags=""
3113 vnc_png_libs="-lpng"
3115 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3116 vnc_png=yes
3117 libs_softmmu="$vnc_png_libs $libs_softmmu"
3118 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3119 else
3120 if test "$vnc_png" = "yes" ; then
3121 feature_not_found "vnc-png" "Install libpng devel"
3123 vnc_png=no
3127 ##########################################
3128 # xkbcommon probe
3129 if test "$xkbcommon" != "no" ; then
3130 if $pkg_config xkbcommon --exists; then
3131 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
3132 xkbcommon_libs=$($pkg_config xkbcommon --libs)
3133 xkbcommon=yes
3134 else
3135 if test "$xkbcommon" = "yes" ; then
3136 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
3138 xkbcommon=no
3142 ##########################################
3143 # fnmatch() probe, used for ACL routines
3144 fnmatch="no"
3145 cat > $TMPC << EOF
3146 #include <fnmatch.h>
3147 int main(void)
3149 fnmatch("foo", "foo", 0);
3150 return 0;
3153 if compile_prog "" "" ; then
3154 fnmatch="yes"
3157 ##########################################
3158 # xfsctl() probe, used for file-posix.c
3159 if test "$xfs" != "no" ; then
3160 cat > $TMPC << EOF
3161 #include <stddef.h> /* NULL */
3162 #include <xfs/xfs.h>
3163 int main(void)
3165 xfsctl(NULL, 0, 0, NULL);
3166 return 0;
3169 if compile_prog "" "" ; then
3170 xfs="yes"
3171 else
3172 if test "$xfs" = "yes" ; then
3173 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3175 xfs=no
3179 ##########################################
3180 # vde libraries probe
3181 if test "$vde" != "no" ; then
3182 vde_libs="-lvdeplug"
3183 cat > $TMPC << EOF
3184 #include <libvdeplug.h>
3185 int main(void)
3187 struct vde_open_args a = {0, 0, 0};
3188 char s[] = "";
3189 vde_open(s, s, &a);
3190 return 0;
3193 if compile_prog "" "$vde_libs" ; then
3194 vde=yes
3195 else
3196 if test "$vde" = "yes" ; then
3197 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3199 vde=no
3203 ##########################################
3204 # netmap support probe
3205 # Apart from looking for netmap headers, we make sure that the host API version
3206 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3207 # a minor/major version number. Minor new features will be marked with values up
3208 # to 15, and if something happens that requires a change to the backend we will
3209 # move above 15, submit the backend fixes and modify this two bounds.
3210 if test "$netmap" != "no" ; then
3211 cat > $TMPC << EOF
3212 #include <inttypes.h>
3213 #include <net/if.h>
3214 #include <net/netmap.h>
3215 #include <net/netmap_user.h>
3216 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3217 #error
3218 #endif
3219 int main(void) { return 0; }
3221 if compile_prog "" "" ; then
3222 netmap=yes
3223 else
3224 if test "$netmap" = "yes" ; then
3225 feature_not_found "netmap"
3227 netmap=no
3231 ##########################################
3232 # libcap-ng library probe
3233 if test "$cap_ng" != "no" ; then
3234 cap_libs="-lcap-ng"
3235 cat > $TMPC << EOF
3236 #include <cap-ng.h>
3237 int main(void)
3239 capng_capability_to_name(CAPNG_EFFECTIVE);
3240 return 0;
3243 if compile_prog "" "$cap_libs" ; then
3244 cap_ng=yes
3245 libs_tools="$cap_libs $libs_tools"
3246 else
3247 if test "$cap_ng" = "yes" ; then
3248 feature_not_found "cap_ng" "Install libcap-ng devel"
3250 cap_ng=no
3254 ##########################################
3255 # Sound support libraries probe
3257 audio_drv_probe()
3259 drv=$1
3260 hdr=$2
3261 lib=$3
3262 exp=$4
3263 cfl=$5
3264 cat > $TMPC << EOF
3265 #include <$hdr>
3266 int main(void) { $exp }
3268 if compile_prog "$cfl" "$lib" ; then
3270 else
3271 error_exit "$drv check failed" \
3272 "Make sure to have the $drv libs and headers installed."
3276 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3277 for drv in $audio_drv_list; do
3278 case $drv in
3279 alsa)
3280 audio_drv_probe $drv alsa/asoundlib.h -lasound \
3281 "return snd_pcm_close((snd_pcm_t *)0);"
3282 alsa_libs="-lasound"
3286 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3287 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3288 pulse_libs="-lpulse"
3289 audio_pt_int="yes"
3292 sdl)
3293 if test "$sdl" = "no"; then
3294 error_exit "sdl not found or disabled, can not use sdl audio driver"
3298 coreaudio)
3299 coreaudio_libs="-framework CoreAudio"
3302 dsound)
3303 dsound_libs="-lole32 -ldxguid"
3304 audio_win_int="yes"
3307 oss)
3308 oss_libs="$oss_lib"
3311 wav)
3312 # XXX: Probes for CoreAudio, DirectSound
3316 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3317 error_exit "Unknown driver '$drv' selected" \
3318 "Possible drivers are: $audio_possible_drivers"
3321 esac
3322 done
3324 ##########################################
3325 # BrlAPI probe
3327 if test "$brlapi" != "no" ; then
3328 brlapi_libs="-lbrlapi"
3329 cat > $TMPC << EOF
3330 #include <brlapi.h>
3331 #include <stddef.h>
3332 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3334 if compile_prog "" "$brlapi_libs" ; then
3335 brlapi=yes
3336 else
3337 if test "$brlapi" = "yes" ; then
3338 feature_not_found "brlapi" "Install brlapi devel"
3340 brlapi=no
3344 ##########################################
3345 # curses probe
3346 if test "$curses" != "no" ; then
3347 if test "$mingw32" = "yes" ; then
3348 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3349 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3350 else
3351 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3352 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3354 curses_found=no
3355 cat > $TMPC << EOF
3356 #include <locale.h>
3357 #include <curses.h>
3358 #include <wchar.h>
3359 int main(void) {
3360 wchar_t wch = L'w';
3361 setlocale(LC_ALL, "");
3362 resize_term(0, 0);
3363 addwstr(L"wide chars\n");
3364 addnwstr(&wch, 1);
3365 add_wch(WACS_DEGREE);
3366 return 0;
3369 IFS=:
3370 for curses_inc in $curses_inc_list; do
3371 # Make sure we get the wide character prototypes
3372 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3373 IFS=:
3374 for curses_lib in $curses_lib_list; do
3375 unset IFS
3376 if compile_prog "$curses_inc" "$curses_lib" ; then
3377 curses_found=yes
3378 break
3380 done
3381 if test "$curses_found" = yes ; then
3382 break
3384 done
3385 unset IFS
3386 if test "$curses_found" = "yes" ; then
3387 curses=yes
3388 else
3389 if test "$curses" = "yes" ; then
3390 feature_not_found "curses" "Install ncurses devel"
3392 curses=no
3396 ##########################################
3397 # curl probe
3398 if test "$curl" != "no" ; then
3399 if $pkg_config libcurl --exists; then
3400 curlconfig="$pkg_config libcurl"
3401 else
3402 curlconfig=curl-config
3404 cat > $TMPC << EOF
3405 #include <curl/curl.h>
3406 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3408 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3409 curl_libs=$($curlconfig --libs 2>/dev/null)
3410 if compile_prog "$curl_cflags" "$curl_libs" ; then
3411 curl=yes
3412 else
3413 if test "$curl" = "yes" ; then
3414 feature_not_found "curl" "Install libcurl devel"
3416 curl=no
3418 fi # test "$curl"
3420 ##########################################
3421 # bluez support probe
3422 if test "$bluez" != "no" ; then
3423 cat > $TMPC << EOF
3424 #include <bluetooth/bluetooth.h>
3425 int main(void) { return bt_error(0); }
3427 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3428 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3429 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3430 bluez=yes
3431 libs_softmmu="$bluez_libs $libs_softmmu"
3432 else
3433 if test "$bluez" = "yes" ; then
3434 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3436 bluez="no"
3440 ##########################################
3441 # glib support probe
3443 glib_req_ver=2.40
3444 glib_modules=gthread-2.0
3445 if test "$modules" = yes; then
3446 glib_modules="$glib_modules gmodule-export-2.0"
3449 # This workaround is required due to a bug in pkg-config file for glib as it
3450 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3452 if test "$static" = yes -a "$mingw32" = yes; then
3453 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3456 for i in $glib_modules; do
3457 if $pkg_config --atleast-version=$glib_req_ver $i; then
3458 glib_cflags=$($pkg_config --cflags $i)
3459 glib_libs=$($pkg_config --libs $i)
3460 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3461 LIBS="$glib_libs $LIBS"
3462 libs_qga="$glib_libs $libs_qga"
3463 else
3464 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3466 done
3468 # Sanity check that the current size_t matches the
3469 # size that glib thinks it should be. This catches
3470 # problems on multi-arch where people try to build
3471 # 32-bit QEMU while pointing at 64-bit glib headers
3472 cat > $TMPC <<EOF
3473 #include <glib.h>
3474 #include <unistd.h>
3476 #define QEMU_BUILD_BUG_ON(x) \
3477 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3479 int main(void) {
3480 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3481 return 0;
3485 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3486 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3487 "You probably need to set PKG_CONFIG_LIBDIR"\
3488 "to point to the right pkg-config files for your"\
3489 "build target"
3492 # g_test_trap_subprocess added in 2.38. Used by some tests.
3493 glib_subprocess=yes
3494 if ! $pkg_config --atleast-version=2.38 glib-2.0; then
3495 glib_subprocess=no
3498 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3499 cat > $TMPC << EOF
3500 #include <glib.h>
3501 int main(void) { return 0; }
3503 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3504 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3505 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3506 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3510 ##########################################
3511 # SHA command probe for modules
3512 if test "$modules" = yes; then
3513 shacmd_probe="sha1sum sha1 shasum"
3514 for c in $shacmd_probe; do
3515 if has $c; then
3516 shacmd="$c"
3517 break
3519 done
3520 if test "$shacmd" = ""; then
3521 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3525 ##########################################
3526 # pixman support probe
3528 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3529 pixman_cflags=
3530 pixman_libs=
3531 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3532 pixman_cflags=$($pkg_config --cflags pixman-1)
3533 pixman_libs=$($pkg_config --libs pixman-1)
3534 else
3535 error_exit "pixman >= 0.21.8 not present." \
3536 "Please install the pixman devel package."
3539 ##########################################
3540 # libmpathpersist probe
3542 if test "$mpath" != "no" ; then
3543 cat > $TMPC <<EOF
3544 #include <libudev.h>
3545 #include <mpath_persist.h>
3546 unsigned mpath_mx_alloc_len = 1024;
3547 int logsink;
3548 static struct config *multipath_conf;
3549 extern struct udev *udev;
3550 extern struct config *get_multipath_config(void);
3551 extern void put_multipath_config(struct config *conf);
3552 struct udev *udev;
3553 struct config *get_multipath_config(void) { return multipath_conf; }
3554 void put_multipath_config(struct config *conf) { }
3556 int main(void) {
3557 udev = udev_new();
3558 multipath_conf = mpath_lib_init();
3559 return 0;
3562 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3563 mpathpersist=yes
3564 else
3565 mpathpersist=no
3567 else
3568 mpathpersist=no
3571 ##########################################
3572 # libcap probe
3574 if test "$cap" != "no" ; then
3575 cat > $TMPC <<EOF
3576 #include <stdio.h>
3577 #include <sys/capability.h>
3578 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3580 if compile_prog "" "-lcap" ; then
3581 cap=yes
3582 else
3583 cap=no
3587 ##########################################
3588 # pthread probe
3589 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3591 pthread=no
3592 cat > $TMPC << EOF
3593 #include <pthread.h>
3594 static void *f(void *p) { return NULL; }
3595 int main(void) {
3596 pthread_t thread;
3597 pthread_create(&thread, 0, f, 0);
3598 return 0;
3601 if compile_prog "" "" ; then
3602 pthread=yes
3603 else
3604 for pthread_lib in $PTHREADLIBS_LIST; do
3605 if compile_prog "" "$pthread_lib" ; then
3606 pthread=yes
3607 found=no
3608 for lib_entry in $LIBS; do
3609 if test "$lib_entry" = "$pthread_lib"; then
3610 found=yes
3611 break
3613 done
3614 if test "$found" = "no"; then
3615 LIBS="$pthread_lib $LIBS"
3616 libs_qga="$pthread_lib $libs_qga"
3618 PTHREAD_LIB="$pthread_lib"
3619 break
3621 done
3624 if test "$mingw32" != yes -a "$pthread" = no; then
3625 error_exit "pthread check failed" \
3626 "Make sure to have the pthread libs and headers installed."
3629 # check for pthread_setname_np
3630 pthread_setname_np=no
3631 cat > $TMPC << EOF
3632 #include <pthread.h>
3634 static void *f(void *p) { return NULL; }
3635 int main(void)
3637 pthread_t thread;
3638 pthread_create(&thread, 0, f, 0);
3639 pthread_setname_np(thread, "QEMU");
3640 return 0;
3643 if compile_prog "" "$pthread_lib" ; then
3644 pthread_setname_np=yes
3647 ##########################################
3648 # rbd probe
3649 if test "$rbd" != "no" ; then
3650 cat > $TMPC <<EOF
3651 #include <stdio.h>
3652 #include <rbd/librbd.h>
3653 int main(void) {
3654 rados_t cluster;
3655 rados_create(&cluster, NULL);
3656 return 0;
3659 rbd_libs="-lrbd -lrados"
3660 if compile_prog "" "$rbd_libs" ; then
3661 rbd=yes
3662 else
3663 if test "$rbd" = "yes" ; then
3664 feature_not_found "rados block device" "Install librbd/ceph devel"
3666 rbd=no
3670 ##########################################
3671 # libssh2 probe
3672 min_libssh2_version=1.2.8
3673 if test "$libssh2" != "no" ; then
3674 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3675 libssh2_cflags=$($pkg_config libssh2 --cflags)
3676 libssh2_libs=$($pkg_config libssh2 --libs)
3677 libssh2=yes
3678 else
3679 if test "$libssh2" = "yes" ; then
3680 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3682 libssh2=no
3686 ##########################################
3687 # libssh2_sftp_fsync probe
3689 if test "$libssh2" = "yes"; then
3690 cat > $TMPC <<EOF
3691 #include <stdio.h>
3692 #include <libssh2.h>
3693 #include <libssh2_sftp.h>
3694 int main(void) {
3695 LIBSSH2_SESSION *session;
3696 LIBSSH2_SFTP *sftp;
3697 LIBSSH2_SFTP_HANDLE *sftp_handle;
3698 session = libssh2_session_init ();
3699 sftp = libssh2_sftp_init (session);
3700 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3701 libssh2_sftp_fsync (sftp_handle);
3702 return 0;
3705 # libssh2_cflags/libssh2_libs defined in previous test.
3706 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3707 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3711 ##########################################
3712 # linux-aio probe
3714 if test "$linux_aio" != "no" ; then
3715 cat > $TMPC <<EOF
3716 #include <libaio.h>
3717 #include <sys/eventfd.h>
3718 #include <stddef.h>
3719 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3721 if compile_prog "" "-laio" ; then
3722 linux_aio=yes
3723 else
3724 if test "$linux_aio" = "yes" ; then
3725 feature_not_found "linux AIO" "Install libaio devel"
3727 linux_aio=no
3731 ##########################################
3732 # TPM passthrough is only on x86 Linux
3734 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3735 tpm_passthrough=$tpm
3736 else
3737 tpm_passthrough=no
3740 # TPM emulator is for all posix systems
3741 if test "$mingw32" != "yes"; then
3742 tpm_emulator=$tpm
3743 else
3744 tpm_emulator=no
3746 ##########################################
3747 # attr probe
3749 if test "$attr" != "no" ; then
3750 cat > $TMPC <<EOF
3751 #include <stdio.h>
3752 #include <sys/types.h>
3753 #ifdef CONFIG_LIBATTR
3754 #include <attr/xattr.h>
3755 #else
3756 #include <sys/xattr.h>
3757 #endif
3758 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3760 if compile_prog "" "" ; then
3761 attr=yes
3762 # Older distros have <attr/xattr.h>, and need -lattr:
3763 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3764 attr=yes
3765 LIBS="-lattr $LIBS"
3766 libattr=yes
3767 else
3768 if test "$attr" = "yes" ; then
3769 feature_not_found "ATTR" "Install libc6 or libattr devel"
3771 attr=no
3775 ##########################################
3776 # iovec probe
3777 cat > $TMPC <<EOF
3778 #include <sys/types.h>
3779 #include <sys/uio.h>
3780 #include <unistd.h>
3781 int main(void) { return sizeof(struct iovec); }
3783 iovec=no
3784 if compile_prog "" "" ; then
3785 iovec=yes
3788 ##########################################
3789 # preadv probe
3790 cat > $TMPC <<EOF
3791 #include <sys/types.h>
3792 #include <sys/uio.h>
3793 #include <unistd.h>
3794 int main(void) { return preadv(0, 0, 0, 0); }
3796 preadv=no
3797 if compile_prog "" "" ; then
3798 preadv=yes
3801 ##########################################
3802 # fdt probe
3803 # fdt support is mandatory for at least some target architectures,
3804 # so insist on it if we're building those system emulators.
3805 fdt_required=no
3806 for target in $target_list; do
3807 case $target in
3808 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu)
3809 fdt_required=yes
3811 esac
3812 done
3814 if test "$fdt_required" = "yes"; then
3815 if test "$fdt" = "no"; then
3816 error_exit "fdt disabled but some requested targets require it." \
3817 "You can turn off fdt only if you also disable all the system emulation" \
3818 "targets which need it (by specifying a cut down --target-list)."
3820 fdt=yes
3823 if test "$fdt" != "no" ; then
3824 fdt_libs="-lfdt"
3825 # explicitly check for libfdt_env.h as it is missing in some stable installs
3826 # and test for required functions to make sure we are on a version >= 1.4.2
3827 cat > $TMPC << EOF
3828 #include <libfdt.h>
3829 #include <libfdt_env.h>
3830 int main(void) { fdt_first_subnode(0, 0); return 0; }
3832 if compile_prog "" "$fdt_libs" ; then
3833 # system DTC is good - use it
3834 fdt=system
3835 else
3836 # have GIT checkout, so activate dtc submodule
3837 if test -e "${source_path}/.git" ; then
3838 git_submodules="${git_submodules} dtc"
3840 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3841 fdt=git
3842 mkdir -p dtc
3843 if [ "$pwd_is_source_path" != "y" ] ; then
3844 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3845 symlink "$source_path/dtc/scripts" "dtc/scripts"
3847 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3848 fdt_ldflags="-L\$(BUILD_DIR)/dtc/libfdt"
3849 fdt_libs="$fdt_libs"
3850 elif test "$fdt" = "yes" ; then
3851 # Not a git build & no libfdt found, prompt for system install
3852 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3853 "Please install the DTC (libfdt) devel package"
3854 else
3855 # don't have and don't want
3856 fdt_libs=
3857 fdt=no
3862 libs_softmmu="$libs_softmmu $fdt_libs"
3864 ##########################################
3865 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3867 if test "$opengl" != "no" ; then
3868 opengl_pkgs="epoxy libdrm gbm"
3869 if $pkg_config $opengl_pkgs; then
3870 opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
3871 opengl_libs="$($pkg_config --libs $opengl_pkgs)"
3872 opengl=yes
3873 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3874 gtk_gl="yes"
3876 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
3877 else
3878 if test "$opengl" = "yes" ; then
3879 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
3881 opengl_cflags=""
3882 opengl_libs=""
3883 opengl=no
3887 if test "$opengl" = "yes"; then
3888 cat > $TMPC << EOF
3889 #include <epoxy/egl.h>
3890 #ifndef EGL_MESA_image_dma_buf_export
3891 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3892 #endif
3893 int main(void) { return 0; }
3895 if compile_prog "" "" ; then
3896 opengl_dmabuf=yes
3900 ##########################################
3901 # libxml2 probe
3902 if test "$libxml2" != "no" ; then
3903 if $pkg_config --exists libxml-2.0; then
3904 libxml2="yes"
3905 libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3906 libxml2_libs=$($pkg_config --libs libxml-2.0)
3907 else
3908 if test "$libxml2" = "yes"; then
3909 feature_not_found "libxml2" "Install libxml2 devel"
3911 libxml2="no"
3915 ##########################################
3916 # glusterfs probe
3917 if test "$glusterfs" != "no" ; then
3918 if $pkg_config --atleast-version=3 glusterfs-api; then
3919 glusterfs="yes"
3920 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3921 glusterfs_libs=$($pkg_config --libs glusterfs-api)
3922 if $pkg_config --atleast-version=4 glusterfs-api; then
3923 glusterfs_xlator_opt="yes"
3925 if $pkg_config --atleast-version=5 glusterfs-api; then
3926 glusterfs_discard="yes"
3928 if $pkg_config --atleast-version=6 glusterfs-api; then
3929 glusterfs_fallocate="yes"
3930 glusterfs_zerofill="yes"
3932 else
3933 if test "$glusterfs" = "yes" ; then
3934 feature_not_found "GlusterFS backend support" \
3935 "Install glusterfs-api devel >= 3"
3937 glusterfs="no"
3941 # Check for inotify functions when we are building linux-user
3942 # emulator. This is done because older glibc versions don't
3943 # have syscall stubs for these implemented. In that case we
3944 # don't provide them even if kernel supports them.
3946 inotify=no
3947 cat > $TMPC << EOF
3948 #include <sys/inotify.h>
3951 main(void)
3953 /* try to start inotify */
3954 return inotify_init();
3957 if compile_prog "" "" ; then
3958 inotify=yes
3961 inotify1=no
3962 cat > $TMPC << EOF
3963 #include <sys/inotify.h>
3966 main(void)
3968 /* try to start inotify */
3969 return inotify_init1(0);
3972 if compile_prog "" "" ; then
3973 inotify1=yes
3976 # check if pipe2 is there
3977 pipe2=no
3978 cat > $TMPC << EOF
3979 #include <unistd.h>
3980 #include <fcntl.h>
3982 int main(void)
3984 int pipefd[2];
3985 return pipe2(pipefd, O_CLOEXEC);
3988 if compile_prog "" "" ; then
3989 pipe2=yes
3992 # check if accept4 is there
3993 accept4=no
3994 cat > $TMPC << EOF
3995 #include <sys/socket.h>
3996 #include <stddef.h>
3998 int main(void)
4000 accept4(0, NULL, NULL, SOCK_CLOEXEC);
4001 return 0;
4004 if compile_prog "" "" ; then
4005 accept4=yes
4008 # check if tee/splice is there. vmsplice was added same time.
4009 splice=no
4010 cat > $TMPC << EOF
4011 #include <unistd.h>
4012 #include <fcntl.h>
4013 #include <limits.h>
4015 int main(void)
4017 int len, fd = 0;
4018 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
4019 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
4020 return 0;
4023 if compile_prog "" "" ; then
4024 splice=yes
4027 ##########################################
4028 # libnuma probe
4030 if test "$numa" != "no" ; then
4031 cat > $TMPC << EOF
4032 #include <numa.h>
4033 int main(void) { return numa_available(); }
4036 if compile_prog "" "-lnuma" ; then
4037 numa=yes
4038 libs_softmmu="-lnuma $libs_softmmu"
4039 else
4040 if test "$numa" = "yes" ; then
4041 feature_not_found "numa" "install numactl devel"
4043 numa=no
4047 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
4048 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
4049 exit 1
4052 # Even if malloc_trim() is available, these non-libc memory allocators
4053 # do not support it.
4054 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
4055 if test "$malloc_trim" = "yes" ; then
4056 echo "Disabling malloc_trim with non-libc memory allocator"
4058 malloc_trim="no"
4061 #######################################
4062 # malloc_trim
4064 if test "$malloc_trim" != "no" ; then
4065 cat > $TMPC << EOF
4066 #include <malloc.h>
4067 int main(void) { malloc_trim(0); return 0; }
4069 if compile_prog "" "" ; then
4070 malloc_trim="yes"
4071 else
4072 malloc_trim="no"
4076 ##########################################
4077 # tcmalloc probe
4079 if test "$tcmalloc" = "yes" ; then
4080 cat > $TMPC << EOF
4081 #include <stdlib.h>
4082 int main(void) { malloc(1); return 0; }
4085 if compile_prog "" "-ltcmalloc" ; then
4086 LIBS="-ltcmalloc $LIBS"
4087 else
4088 feature_not_found "tcmalloc" "install gperftools devel"
4092 ##########################################
4093 # jemalloc probe
4095 if test "$jemalloc" = "yes" ; then
4096 cat > $TMPC << EOF
4097 #include <stdlib.h>
4098 int main(void) { malloc(1); return 0; }
4101 if compile_prog "" "-ljemalloc" ; then
4102 LIBS="-ljemalloc $LIBS"
4103 else
4104 feature_not_found "jemalloc" "install jemalloc devel"
4108 ##########################################
4109 # signalfd probe
4110 signalfd="no"
4111 cat > $TMPC << EOF
4112 #include <unistd.h>
4113 #include <sys/syscall.h>
4114 #include <signal.h>
4115 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4118 if compile_prog "" "" ; then
4119 signalfd=yes
4122 # check if eventfd is supported
4123 eventfd=no
4124 cat > $TMPC << EOF
4125 #include <sys/eventfd.h>
4127 int main(void)
4129 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4132 if compile_prog "" "" ; then
4133 eventfd=yes
4136 # check if memfd is supported
4137 memfd=no
4138 cat > $TMPC << EOF
4139 #include <sys/mman.h>
4141 int main(void)
4143 return memfd_create("foo", MFD_ALLOW_SEALING);
4146 if compile_prog "" "" ; then
4147 memfd=yes
4152 # check for fallocate
4153 fallocate=no
4154 cat > $TMPC << EOF
4155 #include <fcntl.h>
4157 int main(void)
4159 fallocate(0, 0, 0, 0);
4160 return 0;
4163 if compile_prog "" "" ; then
4164 fallocate=yes
4167 # check for fallocate hole punching
4168 fallocate_punch_hole=no
4169 cat > $TMPC << EOF
4170 #include <fcntl.h>
4171 #include <linux/falloc.h>
4173 int main(void)
4175 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4176 return 0;
4179 if compile_prog "" "" ; then
4180 fallocate_punch_hole=yes
4183 # check that fallocate supports range zeroing inside the file
4184 fallocate_zero_range=no
4185 cat > $TMPC << EOF
4186 #include <fcntl.h>
4187 #include <linux/falloc.h>
4189 int main(void)
4191 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4192 return 0;
4195 if compile_prog "" "" ; then
4196 fallocate_zero_range=yes
4199 # check for posix_fallocate
4200 posix_fallocate=no
4201 cat > $TMPC << EOF
4202 #include <fcntl.h>
4204 int main(void)
4206 posix_fallocate(0, 0, 0);
4207 return 0;
4210 if compile_prog "" "" ; then
4211 posix_fallocate=yes
4214 # check for sync_file_range
4215 sync_file_range=no
4216 cat > $TMPC << EOF
4217 #include <fcntl.h>
4219 int main(void)
4221 sync_file_range(0, 0, 0, 0);
4222 return 0;
4225 if compile_prog "" "" ; then
4226 sync_file_range=yes
4229 # check for linux/fiemap.h and FS_IOC_FIEMAP
4230 fiemap=no
4231 cat > $TMPC << EOF
4232 #include <sys/ioctl.h>
4233 #include <linux/fs.h>
4234 #include <linux/fiemap.h>
4236 int main(void)
4238 ioctl(0, FS_IOC_FIEMAP, 0);
4239 return 0;
4242 if compile_prog "" "" ; then
4243 fiemap=yes
4246 # check for dup3
4247 dup3=no
4248 cat > $TMPC << EOF
4249 #include <unistd.h>
4251 int main(void)
4253 dup3(0, 0, 0);
4254 return 0;
4257 if compile_prog "" "" ; then
4258 dup3=yes
4261 # check for ppoll support
4262 ppoll=no
4263 cat > $TMPC << EOF
4264 #include <poll.h>
4266 int main(void)
4268 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4269 ppoll(&pfd, 1, 0, 0);
4270 return 0;
4273 if compile_prog "" "" ; then
4274 ppoll=yes
4277 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4278 prctl_pr_set_timerslack=no
4279 cat > $TMPC << EOF
4280 #include <sys/prctl.h>
4282 int main(void)
4284 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4285 return 0;
4288 if compile_prog "" "" ; then
4289 prctl_pr_set_timerslack=yes
4292 # check for epoll support
4293 epoll=no
4294 cat > $TMPC << EOF
4295 #include <sys/epoll.h>
4297 int main(void)
4299 epoll_create(0);
4300 return 0;
4303 if compile_prog "" "" ; then
4304 epoll=yes
4307 # epoll_create1 is a later addition
4308 # so we must check separately for its presence
4309 epoll_create1=no
4310 cat > $TMPC << EOF
4311 #include <sys/epoll.h>
4313 int main(void)
4315 /* Note that we use epoll_create1 as a value, not as
4316 * a function being called. This is necessary so that on
4317 * old SPARC glibc versions where the function was present in
4318 * the library but not declared in the header file we will
4319 * fail the configure check. (Otherwise we will get a compiler
4320 * warning but not an error, and will proceed to fail the
4321 * qemu compile where we compile with -Werror.)
4323 return (int)(uintptr_t)&epoll_create1;
4326 if compile_prog "" "" ; then
4327 epoll_create1=yes
4330 # check for sendfile support
4331 sendfile=no
4332 cat > $TMPC << EOF
4333 #include <sys/sendfile.h>
4335 int main(void)
4337 return sendfile(0, 0, 0, 0);
4340 if compile_prog "" "" ; then
4341 sendfile=yes
4344 # check for timerfd support (glibc 2.8 and newer)
4345 timerfd=no
4346 cat > $TMPC << EOF
4347 #include <sys/timerfd.h>
4349 int main(void)
4351 return(timerfd_create(CLOCK_REALTIME, 0));
4354 if compile_prog "" "" ; then
4355 timerfd=yes
4358 # check for setns and unshare support
4359 setns=no
4360 cat > $TMPC << EOF
4361 #include <sched.h>
4363 int main(void)
4365 int ret;
4366 ret = setns(0, 0);
4367 ret = unshare(0);
4368 return ret;
4371 if compile_prog "" "" ; then
4372 setns=yes
4375 # clock_adjtime probe
4376 clock_adjtime=no
4377 cat > $TMPC <<EOF
4378 #include <time.h>
4380 int main(void)
4382 return clock_adjtime(0, 0);
4385 clock_adjtime=no
4386 if compile_prog "" "" ; then
4387 clock_adjtime=yes
4390 # syncfs probe
4391 syncfs=no
4392 cat > $TMPC <<EOF
4393 #include <unistd.h>
4395 int main(void)
4397 return syncfs(0);
4400 syncfs=no
4401 if compile_prog "" "" ; then
4402 syncfs=yes
4405 # Check if tools are available to build documentation.
4406 if test "$docs" != "no" ; then
4407 if has makeinfo && has pod2man; then
4408 docs=yes
4409 else
4410 if test "$docs" = "yes" ; then
4411 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4413 docs=no
4417 # Search for bswap_32 function
4418 byteswap_h=no
4419 cat > $TMPC << EOF
4420 #include <byteswap.h>
4421 int main(void) { return bswap_32(0); }
4423 if compile_prog "" "" ; then
4424 byteswap_h=yes
4427 # Search for bswap32 function
4428 bswap_h=no
4429 cat > $TMPC << EOF
4430 #include <sys/endian.h>
4431 #include <sys/types.h>
4432 #include <machine/bswap.h>
4433 int main(void) { return bswap32(0); }
4435 if compile_prog "" "" ; then
4436 bswap_h=yes
4439 ##########################################
4440 # Do we have libiscsi >= 1.9.0
4441 if test "$libiscsi" != "no" ; then
4442 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4443 libiscsi="yes"
4444 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4445 libiscsi_libs=$($pkg_config --libs libiscsi)
4446 else
4447 if test "$libiscsi" = "yes" ; then
4448 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4450 libiscsi="no"
4454 ##########################################
4455 # Do we need libm
4456 cat > $TMPC << EOF
4457 #include <math.h>
4458 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4460 if compile_prog "" "" ; then
4462 elif compile_prog "" "-lm" ; then
4463 LIBS="-lm $LIBS"
4464 libs_qga="-lm $libs_qga"
4465 else
4466 error_exit "libm check failed"
4469 ##########################################
4470 # Do we need librt
4471 # uClibc provides 2 versions of clock_gettime(), one with realtime
4472 # support and one without. This means that the clock_gettime() don't
4473 # need -lrt. We still need it for timer_create() so we check for this
4474 # function in addition.
4475 cat > $TMPC <<EOF
4476 #include <signal.h>
4477 #include <time.h>
4478 int main(void) {
4479 timer_create(CLOCK_REALTIME, NULL, NULL);
4480 return clock_gettime(CLOCK_REALTIME, NULL);
4484 if compile_prog "" "" ; then
4486 # we need pthread for static linking. use previous pthread test result
4487 elif compile_prog "" "$pthread_lib -lrt" ; then
4488 LIBS="$LIBS -lrt"
4489 libs_qga="$libs_qga -lrt"
4492 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4493 "$haiku" != "yes" ; then
4494 libs_softmmu="-lutil $libs_softmmu"
4497 ##########################################
4498 # spice probe
4499 if test "$spice" != "no" ; then
4500 cat > $TMPC << EOF
4501 #include <spice.h>
4502 int main(void) { spice_server_new(); return 0; }
4504 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4505 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4506 if $pkg_config --atleast-version=0.12.0 spice-server && \
4507 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4508 compile_prog "$spice_cflags" "$spice_libs" ; then
4509 spice="yes"
4510 libs_softmmu="$libs_softmmu $spice_libs"
4511 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4512 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4513 spice_server_version=$($pkg_config --modversion spice-server)
4514 else
4515 if test "$spice" = "yes" ; then
4516 feature_not_found "spice" \
4517 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4519 spice="no"
4523 # check for smartcard support
4524 if test "$smartcard" != "no"; then
4525 if $pkg_config --atleast-version=2.5.1 libcacard; then
4526 libcacard_cflags=$($pkg_config --cflags libcacard)
4527 libcacard_libs=$($pkg_config --libs libcacard)
4528 smartcard="yes"
4529 else
4530 if test "$smartcard" = "yes"; then
4531 feature_not_found "smartcard" "Install libcacard devel"
4533 smartcard="no"
4537 # check for libusb
4538 if test "$libusb" != "no" ; then
4539 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4540 libusb="yes"
4541 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4542 libusb_libs=$($pkg_config --libs libusb-1.0)
4543 else
4544 if test "$libusb" = "yes"; then
4545 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4547 libusb="no"
4551 # check for usbredirparser for usb network redirection support
4552 if test "$usb_redir" != "no" ; then
4553 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4554 usb_redir="yes"
4555 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4556 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4557 else
4558 if test "$usb_redir" = "yes"; then
4559 feature_not_found "usb-redir" "Install usbredir devel"
4561 usb_redir="no"
4565 ##########################################
4566 # check if we have VSS SDK headers for win
4568 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4569 case "$vss_win32_sdk" in
4570 "") vss_win32_include="-isystem $source_path" ;;
4571 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4572 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4573 vss_win32_include="-isystem $source_path/.sdk/vss"
4574 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4576 *) vss_win32_include="-isystem $vss_win32_sdk"
4577 esac
4578 cat > $TMPC << EOF
4579 #define __MIDL_user_allocate_free_DEFINED__
4580 #include <inc/win2003/vss.h>
4581 int main(void) { return VSS_CTX_BACKUP; }
4583 if compile_prog "$vss_win32_include" "" ; then
4584 guest_agent_with_vss="yes"
4585 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4586 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4587 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4588 else
4589 if test "$vss_win32_sdk" != "" ; then
4590 echo "ERROR: Please download and install Microsoft VSS SDK:"
4591 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4592 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4593 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4594 echo "ERROR: The headers are extracted in the directory \`inc'."
4595 feature_not_found "VSS support"
4597 guest_agent_with_vss="no"
4601 ##########################################
4602 # lookup Windows platform SDK (if not specified)
4603 # The SDK is needed only to build .tlb (type library) file of guest agent
4604 # VSS provider from the source. It is usually unnecessary because the
4605 # pre-compiled .tlb file is included.
4607 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4608 if test -z "$win_sdk"; then
4609 programfiles="$PROGRAMFILES"
4610 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4611 if test -n "$programfiles"; then
4612 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4613 else
4614 feature_not_found "Windows SDK"
4616 elif test "$win_sdk" = "no"; then
4617 win_sdk=""
4621 ##########################################
4622 # check if mingw environment provides a recent ntddscsi.h
4623 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4624 cat > $TMPC << EOF
4625 #include <windows.h>
4626 #include <ntddscsi.h>
4627 int main(void) {
4628 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4629 #error Missing required ioctl definitions
4630 #endif
4631 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4632 return addr.Lun;
4635 if compile_prog "" "" ; then
4636 guest_agent_ntddscsi=yes
4637 libs_qga="-lsetupapi $libs_qga"
4641 ##########################################
4642 # virgl renderer probe
4644 if test "$virglrenderer" != "no" ; then
4645 cat > $TMPC << EOF
4646 #include <virglrenderer.h>
4647 int main(void) { virgl_renderer_poll(); return 0; }
4649 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4650 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4651 virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
4652 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4653 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4654 virglrenderer="yes"
4655 else
4656 if test "$virglrenderer" = "yes" ; then
4657 feature_not_found "virglrenderer"
4659 virglrenderer="no"
4663 ##########################################
4664 # capstone
4666 case "$capstone" in
4667 "" | yes)
4668 if $pkg_config capstone; then
4669 capstone=system
4670 elif test -e "${source_path}/.git" -a $git_update = 'yes' ; then
4671 capstone=git
4672 elif test -e "${source_path}/capstone/Makefile" ; then
4673 capstone=internal
4674 elif test -z "$capstone" ; then
4675 capstone=no
4676 else
4677 feature_not_found "capstone" "Install capstone devel or git submodule"
4681 system)
4682 if ! $pkg_config capstone; then
4683 feature_not_found "capstone" "Install capstone devel"
4686 esac
4688 case "$capstone" in
4689 git | internal)
4690 if test "$capstone" = git; then
4691 git_submodules="${git_submodules} capstone"
4693 mkdir -p capstone
4694 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4695 if test "$mingw32" = "yes"; then
4696 LIBCAPSTONE=capstone.lib
4697 else
4698 LIBCAPSTONE=libcapstone.a
4700 LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4703 system)
4704 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
4705 LIBS="$($pkg_config --libs capstone) $LIBS"
4711 error_exit "Unknown state for capstone: $capstone"
4713 esac
4715 ##########################################
4716 # check if we have fdatasync
4718 fdatasync=no
4719 cat > $TMPC << EOF
4720 #include <unistd.h>
4721 int main(void) {
4722 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4723 return fdatasync(0);
4724 #else
4725 #error Not supported
4726 #endif
4729 if compile_prog "" "" ; then
4730 fdatasync=yes
4733 ##########################################
4734 # check if we have madvise
4736 madvise=no
4737 cat > $TMPC << EOF
4738 #include <sys/types.h>
4739 #include <sys/mman.h>
4740 #include <stddef.h>
4741 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4743 if compile_prog "" "" ; then
4744 madvise=yes
4747 ##########################################
4748 # check if we have posix_madvise
4750 posix_madvise=no
4751 cat > $TMPC << EOF
4752 #include <sys/mman.h>
4753 #include <stddef.h>
4754 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4756 if compile_prog "" "" ; then
4757 posix_madvise=yes
4760 ##########################################
4761 # check if we have posix_memalign()
4763 posix_memalign=no
4764 cat > $TMPC << EOF
4765 #include <stdlib.h>
4766 int main(void) {
4767 void *p;
4768 return posix_memalign(&p, 8, 8);
4771 if compile_prog "" "" ; then
4772 posix_memalign=yes
4775 ##########################################
4776 # check if we have posix_syslog
4778 posix_syslog=no
4779 cat > $TMPC << EOF
4780 #include <syslog.h>
4781 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4783 if compile_prog "" "" ; then
4784 posix_syslog=yes
4787 ##########################################
4788 # check if we have sem_timedwait
4790 sem_timedwait=no
4791 cat > $TMPC << EOF
4792 #include <semaphore.h>
4793 int main(void) { return sem_timedwait(0, 0); }
4795 if compile_prog "" "" ; then
4796 sem_timedwait=yes
4799 ##########################################
4800 # check if we have strchrnul
4802 strchrnul=no
4803 cat > $TMPC << EOF
4804 #include <string.h>
4805 int main(void);
4806 // Use a haystack that the compiler shouldn't be able to constant fold
4807 char *haystack = (char*)&main;
4808 int main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
4810 if compile_prog "" "" ; then
4811 strchrnul=yes
4814 ##########################################
4815 # check if trace backend exists
4817 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4818 if test "$?" -ne 0 ; then
4819 error_exit "invalid trace backends" \
4820 "Please choose supported trace backends."
4823 ##########################################
4824 # For 'ust' backend, test if ust headers are present
4825 if have_backend "ust"; then
4826 cat > $TMPC << EOF
4827 #include <lttng/tracepoint.h>
4828 int main(void) { return 0; }
4830 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4831 if $pkg_config lttng-ust --exists; then
4832 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4833 else
4834 lttng_ust_libs="-llttng-ust -ldl"
4836 if $pkg_config liburcu-bp --exists; then
4837 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4838 else
4839 urcu_bp_libs="-lurcu-bp"
4842 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4843 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4844 else
4845 error_exit "Trace backend 'ust' missing lttng-ust header files"
4849 ##########################################
4850 # For 'dtrace' backend, test if 'dtrace' command is present
4851 if have_backend "dtrace"; then
4852 if ! has 'dtrace' ; then
4853 error_exit "dtrace command is not found in PATH $PATH"
4855 trace_backend_stap="no"
4856 if has 'stap' ; then
4857 trace_backend_stap="yes"
4861 ##########################################
4862 # check and set a backend for coroutine
4864 # We prefer ucontext, but it's not always possible. The fallback
4865 # is sigcontext. On Windows the only valid backend is the Windows
4866 # specific one.
4868 ucontext_works=no
4869 if test "$darwin" != "yes"; then
4870 cat > $TMPC << EOF
4871 #include <ucontext.h>
4872 #ifdef __stub_makecontext
4873 #error Ignoring glibc stub makecontext which will always fail
4874 #endif
4875 int main(void) { makecontext(0, 0, 0); return 0; }
4877 if compile_prog "" "" ; then
4878 ucontext_works=yes
4882 if test "$coroutine" = ""; then
4883 if test "$mingw32" = "yes"; then
4884 coroutine=win32
4885 elif test "$ucontext_works" = "yes"; then
4886 coroutine=ucontext
4887 else
4888 coroutine=sigaltstack
4890 else
4891 case $coroutine in
4892 windows)
4893 if test "$mingw32" != "yes"; then
4894 error_exit "'windows' coroutine backend only valid for Windows"
4896 # Unfortunately the user visible backend name doesn't match the
4897 # coroutine-*.c filename for this case, so we have to adjust it here.
4898 coroutine=win32
4900 ucontext)
4901 if test "$ucontext_works" != "yes"; then
4902 feature_not_found "ucontext"
4905 sigaltstack)
4906 if test "$mingw32" = "yes"; then
4907 error_exit "only the 'windows' coroutine backend is valid for Windows"
4911 error_exit "unknown coroutine backend $coroutine"
4913 esac
4916 if test "$coroutine_pool" = ""; then
4917 coroutine_pool=yes
4920 if test "$debug_stack_usage" = "yes"; then
4921 if test "$coroutine_pool" = "yes"; then
4922 echo "WARN: disabling coroutine pool for stack usage debugging"
4923 coroutine_pool=no
4928 ##########################################
4929 # check if we have open_by_handle_at
4931 open_by_handle_at=no
4932 cat > $TMPC << EOF
4933 #include <fcntl.h>
4934 #if !defined(AT_EMPTY_PATH)
4935 # error missing definition
4936 #else
4937 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4938 #endif
4940 if compile_prog "" "" ; then
4941 open_by_handle_at=yes
4944 ########################################
4945 # check if we have linux/magic.h
4947 linux_magic_h=no
4948 cat > $TMPC << EOF
4949 #include <linux/magic.h>
4950 int main(void) {
4951 return 0;
4954 if compile_prog "" "" ; then
4955 linux_magic_h=yes
4958 ########################################
4959 # check whether we can disable warning option with a pragma (this is needed
4960 # to silence warnings in the headers of some versions of external libraries).
4961 # This test has to be compiled with -Werror as otherwise an unknown pragma is
4962 # only a warning.
4964 # If we can't selectively disable warning in the code, disable -Werror so that
4965 # the build doesn't fail anyway.
4967 pragma_disable_unused_but_set=no
4968 cat > $TMPC << EOF
4969 #pragma GCC diagnostic push
4970 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
4971 #pragma GCC diagnostic pop
4973 int main(void) {
4974 return 0;
4977 if compile_prog "-Werror" "" ; then
4978 pragma_diagnostic_available=yes
4979 else
4980 werror=no
4983 ########################################
4984 # check if we have valgrind/valgrind.h
4986 valgrind_h=no
4987 cat > $TMPC << EOF
4988 #include <valgrind/valgrind.h>
4989 int main(void) {
4990 return 0;
4993 if compile_prog "" "" ; then
4994 valgrind_h=yes
4997 ########################################
4998 # check if environ is declared
5000 has_environ=no
5001 cat > $TMPC << EOF
5002 #include <unistd.h>
5003 int main(void) {
5004 environ = 0;
5005 return 0;
5008 if compile_prog "" "" ; then
5009 has_environ=yes
5012 ########################################
5013 # check if cpuid.h is usable.
5015 cat > $TMPC << EOF
5016 #include <cpuid.h>
5017 int main(void) {
5018 unsigned a, b, c, d;
5019 int max = __get_cpuid_max(0, 0);
5021 if (max >= 1) {
5022 __cpuid(1, a, b, c, d);
5025 if (max >= 7) {
5026 __cpuid_count(7, 0, a, b, c, d);
5029 return 0;
5032 if compile_prog "" "" ; then
5033 cpuid_h=yes
5036 ##########################################
5037 # avx2 optimization requirement check
5039 # There is no point enabling this if cpuid.h is not usable,
5040 # since we won't be able to select the new routines.
5042 if test $cpuid_h = yes; then
5043 cat > $TMPC << EOF
5044 #pragma GCC push_options
5045 #pragma GCC target("avx2")
5046 #include <cpuid.h>
5047 #include <immintrin.h>
5048 static int bar(void *a) {
5049 __m256i x = *(__m256i *)a;
5050 return _mm256_testz_si256(x, x);
5052 int main(int argc, char *argv[]) { return bar(argv[0]); }
5054 if compile_object "" ; then
5055 avx2_opt="yes"
5059 ########################################
5060 # check if __[u]int128_t is usable.
5062 int128=no
5063 cat > $TMPC << EOF
5064 #if defined(__clang_major__) && defined(__clang_minor__)
5065 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
5066 # error __int128_t does not work in CLANG before 3.2
5067 # endif
5068 #endif
5069 __int128_t a;
5070 __uint128_t b;
5071 int main (void) {
5072 a = a + b;
5073 b = a * b;
5074 a = a * a;
5075 return 0;
5078 if compile_prog "" "" ; then
5079 int128=yes
5082 #########################################
5083 # See if 128-bit atomic operations are supported.
5085 atomic128=no
5086 if test "$int128" = "yes"; then
5087 cat > $TMPC << EOF
5088 int main(void)
5090 unsigned __int128 x = 0, y = 0;
5091 y = __atomic_load_16(&x, 0);
5092 __atomic_store_16(&x, y, 0);
5093 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
5094 return 0;
5097 if compile_prog "" "" ; then
5098 atomic128=yes
5102 #########################################
5103 # See if 64-bit atomic operations are supported.
5104 # Note that without __atomic builtins, we can only
5105 # assume atomic loads/stores max at pointer size.
5107 cat > $TMPC << EOF
5108 #include <stdint.h>
5109 int main(void)
5111 uint64_t x = 0, y = 0;
5112 #ifdef __ATOMIC_RELAXED
5113 y = __atomic_load_8(&x, 0);
5114 __atomic_store_8(&x, y, 0);
5115 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5116 __atomic_exchange_8(&x, y, 0);
5117 __atomic_fetch_add_8(&x, y, 0);
5118 #else
5119 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5120 __sync_lock_test_and_set(&x, y);
5121 __sync_val_compare_and_swap(&x, y, 0);
5122 __sync_fetch_and_add(&x, y);
5123 #endif
5124 return 0;
5127 if compile_prog "" "" ; then
5128 atomic64=yes
5131 ########################################
5132 # See if 16-byte vector operations are supported.
5133 # Even without a vector unit the compiler may expand these.
5134 # There is a bug in old GCC for PPC that crashes here.
5135 # Unfortunately it's the system compiler for Centos 7.
5137 cat > $TMPC << EOF
5138 typedef unsigned char U1 __attribute__((vector_size(16)));
5139 typedef unsigned short U2 __attribute__((vector_size(16)));
5140 typedef unsigned int U4 __attribute__((vector_size(16)));
5141 typedef unsigned long long U8 __attribute__((vector_size(16)));
5142 typedef signed char S1 __attribute__((vector_size(16)));
5143 typedef signed short S2 __attribute__((vector_size(16)));
5144 typedef signed int S4 __attribute__((vector_size(16)));
5145 typedef signed long long S8 __attribute__((vector_size(16)));
5146 static U1 a1, b1;
5147 static U2 a2, b2;
5148 static U4 a4, b4;
5149 static U8 a8, b8;
5150 static S1 c1;
5151 static S2 c2;
5152 static S4 c4;
5153 static S8 c8;
5154 static int i;
5155 void helper(void *d, void *a, int shift, int i);
5156 void helper(void *d, void *a, int shift, int i)
5158 *(U1 *)(d + i) = *(U1 *)(a + i) << shift;
5159 *(U2 *)(d + i) = *(U2 *)(a + i) << shift;
5160 *(U4 *)(d + i) = *(U4 *)(a + i) << shift;
5161 *(U8 *)(d + i) = *(U8 *)(a + i) << shift;
5163 int main(void)
5165 a1 += b1; a2 += b2; a4 += b4; a8 += b8;
5166 a1 -= b1; a2 -= b2; a4 -= b4; a8 -= b8;
5167 a1 *= b1; a2 *= b2; a4 *= b4; a8 *= b8;
5168 a1 &= b1; a2 &= b2; a4 &= b4; a8 &= b8;
5169 a1 |= b1; a2 |= b2; a4 |= b4; a8 |= b8;
5170 a1 ^= b1; a2 ^= b2; a4 ^= b4; a8 ^= b8;
5171 a1 <<= i; a2 <<= i; a4 <<= i; a8 <<= i;
5172 a1 >>= i; a2 >>= i; a4 >>= i; a8 >>= i;
5173 c1 >>= i; c2 >>= i; c4 >>= i; c8 >>= i;
5174 return 0;
5178 vector16=no
5179 if compile_prog "" "" ; then
5180 vector16=yes
5183 ########################################
5184 # check if getauxval is available.
5186 getauxval=no
5187 cat > $TMPC << EOF
5188 #include <sys/auxv.h>
5189 int main(void) {
5190 return getauxval(AT_HWCAP) == 0;
5193 if compile_prog "" "" ; then
5194 getauxval=yes
5197 ########################################
5198 # check if ccache is interfering with
5199 # semantic analysis of macros
5201 unset CCACHE_CPP2
5202 ccache_cpp2=no
5203 cat > $TMPC << EOF
5204 static const int Z = 1;
5205 #define fn() ({ Z; })
5206 #define TAUT(X) ((X) == Z)
5207 #define PAREN(X, Y) (X == Y)
5208 #define ID(X) (X)
5209 int main(int argc, char *argv[])
5211 int x = 0, y = 0;
5212 x = ID(x);
5213 x = fn();
5214 fn();
5215 if (PAREN(x, y)) return 0;
5216 if (TAUT(Z)) return 0;
5217 return 0;
5221 if ! compile_object "-Werror"; then
5222 ccache_cpp2=yes
5225 #################################################
5226 # clang does not support glibc + FORTIFY_SOURCE.
5228 if test "$fortify_source" != "no"; then
5229 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5230 fortify_source="no";
5231 elif test -n "$cxx" && has $cxx &&
5232 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5233 fortify_source="no";
5234 else
5235 fortify_source="yes"
5239 ###############################################
5240 # Check if copy_file_range is provided by glibc
5241 have_copy_file_range=no
5242 cat > $TMPC << EOF
5243 #include <unistd.h>
5244 int main(void) {
5245 copy_file_range(0, NULL, 0, NULL, 0, 0);
5246 return 0;
5249 if compile_prog "" "" ; then
5250 have_copy_file_range=yes
5253 ##########################################
5254 # check if struct fsxattr is available via linux/fs.h
5256 have_fsxattr=no
5257 cat > $TMPC << EOF
5258 #include <linux/fs.h>
5259 struct fsxattr foo;
5260 int main(void) {
5261 return 0;
5264 if compile_prog "" "" ; then
5265 have_fsxattr=yes
5268 ##########################################
5269 # check for usable membarrier system call
5270 if test "$membarrier" = "yes"; then
5271 have_membarrier=no
5272 if test "$mingw32" = "yes" ; then
5273 have_membarrier=yes
5274 elif test "$linux" = "yes" ; then
5275 cat > $TMPC << EOF
5276 #include <linux/membarrier.h>
5277 #include <sys/syscall.h>
5278 #include <unistd.h>
5279 #include <stdlib.h>
5280 int main(void) {
5281 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5282 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5283 exit(0);
5286 if compile_prog "" "" ; then
5287 have_membarrier=yes
5290 if test "$have_membarrier" = "no"; then
5291 feature_not_found "membarrier" "membarrier system call not available"
5293 else
5294 # Do not enable it by default even for Mingw32, because it doesn't
5295 # work on Wine.
5296 membarrier=no
5299 ##########################################
5300 # check if rtnetlink.h exists and is useful
5301 have_rtnetlink=no
5302 cat > $TMPC << EOF
5303 #include <linux/rtnetlink.h>
5304 int main(void) {
5305 return IFLA_PROTO_DOWN;
5308 if compile_prog "" "" ; then
5309 have_rtnetlink=yes
5312 ##########################################
5313 # check for usable AF_VSOCK environment
5314 have_af_vsock=no
5315 cat > $TMPC << EOF
5316 #include <errno.h>
5317 #include <sys/types.h>
5318 #include <sys/socket.h>
5319 #if !defined(AF_VSOCK)
5320 # error missing AF_VSOCK flag
5321 #endif
5322 #include <linux/vm_sockets.h>
5323 int main(void) {
5324 int sock, ret;
5325 struct sockaddr_vm svm;
5326 socklen_t len = sizeof(svm);
5327 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
5328 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
5329 if ((ret == -1) && (errno == ENOTCONN)) {
5330 return 0;
5332 return -1;
5335 if compile_prog "" "" ; then
5336 have_af_vsock=yes
5339 ##########################################
5340 # check for usable AF_ALG environment
5341 hava_afalg=no
5342 cat > $TMPC << EOF
5343 #include <errno.h>
5344 #include <sys/types.h>
5345 #include <sys/socket.h>
5346 #include <linux/if_alg.h>
5347 int main(void) {
5348 int sock;
5349 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5350 return sock;
5353 if compile_prog "" "" ; then
5354 have_afalg=yes
5356 if test "$crypto_afalg" = "yes"
5357 then
5358 if test "$have_afalg" != "yes"
5359 then
5360 error_exit "AF_ALG requested but could not be detected"
5365 #################################################
5366 # Check to see if we have the Hypervisor framework
5367 if [ "$darwin" = "yes" ] ; then
5368 cat > $TMPC << EOF
5369 #include <Hypervisor/hv.h>
5370 int main() { return 0;}
5372 if ! compile_object ""; then
5373 hvf='no'
5374 else
5375 hvf='yes'
5376 LDFLAGS="-framework Hypervisor $LDFLAGS"
5380 #################################################
5381 # Sparc implicitly links with --relax, which is
5382 # incompatible with -r, so --no-relax should be
5383 # given. It does no harm to give it on other
5384 # platforms too.
5386 # Note: the prototype is needed since QEMU_CFLAGS
5387 # contains -Wmissing-prototypes
5388 cat > $TMPC << EOF
5389 extern int foo(void);
5390 int foo(void) { return 0; }
5392 if ! compile_object ""; then
5393 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5395 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5396 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5397 LD_REL_FLAGS=$i
5398 break
5400 done
5401 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5402 feature_not_found "modules" "Cannot find how to build relocatable objects"
5405 ##########################################
5406 # check for sysmacros.h
5408 have_sysmacros=no
5409 cat > $TMPC << EOF
5410 #include <sys/sysmacros.h>
5411 int main(void) {
5412 return makedev(0, 0);
5415 if compile_prog "" "" ; then
5416 have_sysmacros=yes
5419 ##########################################
5420 # Veritas HyperScale block driver VxHS
5421 # Check if libvxhs is installed
5423 if test "$vxhs" != "no" ; then
5424 cat > $TMPC <<EOF
5425 #include <stdint.h>
5426 #include <qnio/qnio_api.h>
5428 void *vxhs_callback;
5430 int main(void) {
5431 iio_init(QNIO_VERSION, vxhs_callback);
5432 return 0;
5435 vxhs_libs="-lvxhs -lssl"
5436 if compile_prog "" "$vxhs_libs" ; then
5437 vxhs=yes
5438 else
5439 if test "$vxhs" = "yes" ; then
5440 feature_not_found "vxhs block device" "Install libvxhs See github"
5442 vxhs=no
5446 ##########################################
5447 # check for _Static_assert()
5449 have_static_assert=no
5450 cat > $TMPC << EOF
5451 _Static_assert(1, "success");
5452 int main(void) {
5453 return 0;
5456 if compile_prog "" "" ; then
5457 have_static_assert=yes
5460 ##########################################
5461 # check for utmpx.h, it is missing e.g. on OpenBSD
5463 have_utmpx=no
5464 cat > $TMPC << EOF
5465 #include <utmpx.h>
5466 struct utmpx user_info;
5467 int main(void) {
5468 return 0;
5471 if compile_prog "" "" ; then
5472 have_utmpx=yes
5475 ##########################################
5476 # checks for sanitizers
5478 have_asan=no
5479 have_ubsan=no
5480 have_asan_iface_h=no
5481 have_asan_iface_fiber=no
5483 if test "$sanitizers" = "yes" ; then
5484 write_c_skeleton
5485 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5486 have_asan=yes
5489 # we could use a simple skeleton for flags checks, but this also
5490 # detect the static linking issue of ubsan, see also:
5491 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5492 cat > $TMPC << EOF
5493 #include <stdlib.h>
5494 int main(void) {
5495 void *tmp = malloc(10);
5496 return *(int *)(tmp + 2);
5499 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5500 have_ubsan=yes
5503 if check_include "sanitizer/asan_interface.h" ; then
5504 have_asan_iface_h=yes
5507 cat > $TMPC << EOF
5508 #include <sanitizer/asan_interface.h>
5509 int main(void) {
5510 __sanitizer_start_switch_fiber(0, 0, 0);
5511 return 0;
5514 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5515 have_asan_iface_fiber=yes
5519 ##########################################
5520 # Docker and cross-compiler support
5522 # This is specifically for building test
5523 # cases for foreign architectures, not
5524 # cross-compiling QEMU itself.
5526 if has "docker"; then
5527 docker=$($python $source_path/tests/docker/docker.py probe)
5530 ##########################################
5531 # End of CC checks
5532 # After here, no more $cc or $ld runs
5534 write_c_skeleton
5536 if test "$gcov" = "yes" ; then
5537 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
5538 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5539 elif test "$fortify_source" = "yes" ; then
5540 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
5541 elif test "$debug" = "no"; then
5542 CFLAGS="-O2 $CFLAGS"
5545 if test "$have_asan" = "yes"; then
5546 CFLAGS="-fsanitize=address $CFLAGS"
5547 if test "$have_asan_iface_h" = "no" ; then
5548 echo "ASAN build enabled, but ASAN header missing." \
5549 "Without code annotation, the report may be inferior."
5550 elif test "$have_asan_iface_fiber" = "no" ; then
5551 echo "ASAN build enabled, but ASAN header is too old." \
5552 "Without code annotation, the report may be inferior."
5555 if test "$have_ubsan" = "yes"; then
5556 CFLAGS="-fsanitize=undefined $CFLAGS"
5559 ##########################################
5560 # Do we have libnfs
5561 if test "$libnfs" != "no" ; then
5562 if $pkg_config --atleast-version=1.9.3 libnfs; then
5563 libnfs="yes"
5564 libnfs_libs=$($pkg_config --libs libnfs)
5565 else
5566 if test "$libnfs" = "yes" ; then
5567 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
5569 libnfs="no"
5573 # Now we've finished running tests it's OK to add -Werror to the compiler flags
5574 if test "$werror" = "yes"; then
5575 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
5578 if test "$solaris" = "no" ; then
5579 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5580 LDFLAGS="-Wl,--warn-common $LDFLAGS"
5584 # test if pod2man has --utf8 option
5585 if pod2man --help | grep -q utf8; then
5586 POD2MAN="pod2man --utf8"
5587 else
5588 POD2MAN="pod2man"
5591 # Use ASLR, no-SEH and DEP if available
5592 if test "$mingw32" = "yes" ; then
5593 for flag in --dynamicbase --no-seh --nxcompat; do
5594 if ld_has $flag ; then
5595 LDFLAGS="-Wl,$flag $LDFLAGS"
5597 done
5600 qemu_confdir=$sysconfdir$confsuffix
5601 qemu_moddir=$libdir$confsuffix
5602 qemu_datadir=$datadir$confsuffix
5603 qemu_localedir="$datadir/locale"
5605 # We can only support ivshmem if we have eventfd
5606 if [ "$eventfd" = "yes" ]; then
5607 ivshmem=yes
5610 tools=""
5611 if test "$want_tools" = "yes" ; then
5612 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
5613 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
5614 tools="qemu-nbd\$(EXESUF) $tools"
5616 if [ "$ivshmem" = "yes" ]; then
5617 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
5620 if test "$softmmu" = yes ; then
5621 if test "$linux" = yes; then
5622 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5623 virtfs=yes
5624 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5625 else
5626 if test "$virtfs" = yes; then
5627 error_exit "VirtFS requires libcap devel and libattr devel"
5629 virtfs=no
5631 if test "$mpath" != no && test "$mpathpersist" = yes ; then
5632 mpath=yes
5633 else
5634 if test "$mpath" = yes; then
5635 error_exit "Multipath requires libmpathpersist devel"
5637 mpath=no
5639 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5640 else
5641 if test "$virtfs" = yes; then
5642 error_exit "VirtFS is supported only on Linux"
5644 virtfs=no
5645 if test "$mpath" = yes; then
5646 error_exit "Multipath is supported only on Linux"
5648 mpath=no
5650 if test "$xkbcommon" = "yes"; then
5651 tools="qemu-keymap\$(EXESUF) $tools"
5655 # Probe for guest agent support/options
5657 if [ "$guest_agent" != "no" ]; then
5658 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5659 tools="qemu-ga $tools"
5660 guest_agent=yes
5661 elif [ "$guest_agent" != yes ]; then
5662 guest_agent=no
5663 else
5664 error_exit "Guest agent is not supported on this platform"
5668 # Guest agent Window MSI package
5670 if test "$guest_agent" != yes; then
5671 if test "$guest_agent_msi" = yes; then
5672 error_exit "MSI guest agent package requires guest agent enabled"
5674 guest_agent_msi=no
5675 elif test "$mingw32" != "yes"; then
5676 if test "$guest_agent_msi" = "yes"; then
5677 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
5679 guest_agent_msi=no
5680 elif ! has wixl; then
5681 if test "$guest_agent_msi" = "yes"; then
5682 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
5684 guest_agent_msi=no
5685 else
5686 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
5687 # disabled explicitly
5688 if test "$guest_agent_msi" != "no"; then
5689 guest_agent_msi=yes
5693 if test "$guest_agent_msi" = "yes"; then
5694 if test "$guest_agent_with_vss" = "yes"; then
5695 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
5698 if test "$QEMU_GA_MANUFACTURER" = ""; then
5699 QEMU_GA_MANUFACTURER=QEMU
5702 if test "$QEMU_GA_DISTRO" = ""; then
5703 QEMU_GA_DISTRO=Linux
5706 if test "$QEMU_GA_VERSION" = ""; then
5707 QEMU_GA_VERSION=$(cat $source_path/VERSION)
5710 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
5712 case "$cpu" in
5713 x86_64)
5714 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5716 i386)
5717 QEMU_GA_MSI_ARCH="-D Arch=32"
5720 error_exit "CPU $cpu not supported for building installation package"
5722 esac
5725 # Mac OS X ships with a broken assembler
5726 roms=
5727 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5728 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5729 "$softmmu" = yes ; then
5730 # Different host OS linkers have different ideas about the name of the ELF
5731 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5732 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5733 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5734 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5735 ld_i386_emulation="$emu"
5736 roms="optionrom"
5737 break
5739 done
5741 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
5742 roms="$roms spapr-rtas"
5745 if test "$cpu" = "s390x" ; then
5746 roms="$roms s390-ccw"
5749 # Probe for the need for relocating the user-only binary.
5750 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5751 textseg_addr=
5752 case "$cpu" in
5753 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5754 # ??? Rationale for choosing this address
5755 textseg_addr=0x60000000
5757 mips)
5758 # A 256M aligned address, high in the address space, with enough
5759 # room for the code_gen_buffer above it before the stack.
5760 textseg_addr=0x60000000
5762 esac
5763 if [ -n "$textseg_addr" ]; then
5764 cat > $TMPC <<EOF
5765 int main(void) { return 0; }
5767 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5768 if ! compile_prog "" "$textseg_ldflags"; then
5769 # In case ld does not support -Ttext-segment, edit the default linker
5770 # script via sed to set the .text start addr. This is needed on FreeBSD
5771 # at least.
5772 if ! $ld --verbose >/dev/null 2>&1; then
5773 error_exit \
5774 "We need to link the QEMU user mode binaries at a" \
5775 "specific text address. Unfortunately your linker" \
5776 "doesn't support either the -Ttext-segment option or" \
5777 "printing the default linker script with --verbose." \
5778 "If you don't want the user mode binaries, pass the" \
5779 "--disable-user option to configure."
5782 $ld --verbose | sed \
5783 -e '1,/==================================================/d' \
5784 -e '/==================================================/,$d' \
5785 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5786 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5787 textseg_ldflags="-Wl,-T../config-host.ld"
5792 # Check that the C++ compiler exists and works with the C compiler.
5793 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
5794 if has $cxx; then
5795 cat > $TMPC <<EOF
5796 int c_function(void);
5797 int main(void) { return c_function(); }
5800 compile_object
5802 cat > $TMPCXX <<EOF
5803 extern "C" {
5804 int c_function(void);
5806 int c_function(void) { return 42; }
5809 update_cxxflags
5811 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
5812 # C++ compiler $cxx works ok with C compiler $cc
5814 else
5815 echo "C++ compiler $cxx does not work with C compiler $cc"
5816 echo "Disabling C++ specific optional code"
5817 cxx=
5819 else
5820 echo "No C++ compiler available; disabling C++ specific optional code"
5821 cxx=
5824 echo_version() {
5825 if test "$1" = "yes" ; then
5826 echo "($2)"
5830 # prepend pixman and ftd flags after all config tests are done
5831 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5832 QEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
5833 libs_softmmu="$pixman_libs $libs_softmmu"
5835 echo "Install prefix $prefix"
5836 echo "BIOS directory $(eval echo $qemu_datadir)"
5837 echo "firmware path $(eval echo $firmwarepath)"
5838 echo "binary directory $(eval echo $bindir)"
5839 echo "library directory $(eval echo $libdir)"
5840 echo "module directory $(eval echo $qemu_moddir)"
5841 echo "libexec directory $(eval echo $libexecdir)"
5842 echo "include directory $(eval echo $includedir)"
5843 echo "config directory $(eval echo $sysconfdir)"
5844 if test "$mingw32" = "no" ; then
5845 echo "local state directory $(eval echo $local_statedir)"
5846 echo "Manual directory $(eval echo $mandir)"
5847 echo "ELF interp prefix $interp_prefix"
5848 else
5849 echo "local state directory queried at runtime"
5850 echo "Windows SDK $win_sdk"
5852 echo "Source path $source_path"
5853 echo "GIT binary $git"
5854 echo "GIT submodules $git_submodules"
5855 echo "C compiler $cc"
5856 echo "Host C compiler $host_cc"
5857 echo "C++ compiler $cxx"
5858 echo "Objective-C compiler $objcc"
5859 echo "ARFLAGS $ARFLAGS"
5860 echo "CFLAGS $CFLAGS"
5861 echo "QEMU_CFLAGS $QEMU_CFLAGS"
5862 echo "LDFLAGS $LDFLAGS"
5863 echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
5864 echo "make $make"
5865 echo "install $install"
5866 echo "python $python"
5867 if test "$slirp" = "yes" ; then
5868 echo "smbd $smbd"
5870 echo "module support $modules"
5871 echo "host CPU $cpu"
5872 echo "host big endian $bigendian"
5873 echo "target list $target_list"
5874 echo "gprof enabled $gprof"
5875 echo "sparse enabled $sparse"
5876 echo "strip binaries $strip_opt"
5877 echo "profiler $profiler"
5878 echo "static build $static"
5879 if test "$darwin" = "yes" ; then
5880 echo "Cocoa support $cocoa"
5882 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5883 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
5884 echo "GTK GL support $gtk_gl"
5885 echo "VTE support $vte $(echo_version $vte $vteversion)"
5886 echo "TLS priority $tls_priority"
5887 echo "GNUTLS support $gnutls"
5888 echo "GNUTLS rnd $gnutls_rnd"
5889 echo "libgcrypt $gcrypt"
5890 echo "libgcrypt kdf $gcrypt_kdf"
5891 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
5892 echo "nettle kdf $nettle_kdf"
5893 echo "libtasn1 $tasn1"
5894 echo "curses support $curses"
5895 echo "virgl support $virglrenderer $(echo_version $virglrenderer $virgl_version)"
5896 echo "curl support $curl"
5897 echo "mingw32 support $mingw32"
5898 echo "Audio drivers $audio_drv_list"
5899 echo "Block whitelist (rw) $block_drv_rw_whitelist"
5900 echo "Block whitelist (ro) $block_drv_ro_whitelist"
5901 echo "VirtFS support $virtfs"
5902 echo "Multipath support $mpath"
5903 echo "VNC support $vnc"
5904 if test "$vnc" = "yes" ; then
5905 echo "VNC SASL support $vnc_sasl"
5906 echo "VNC JPEG support $vnc_jpeg"
5907 echo "VNC PNG support $vnc_png"
5909 if test -n "$sparc_cpu"; then
5910 echo "Target Sparc Arch $sparc_cpu"
5912 echo "xen support $xen"
5913 if test "$xen" = "yes" ; then
5914 echo "xen ctrl version $xen_ctrl_version"
5915 echo "pv dom build $xen_pv_domain_build"
5917 echo "brlapi support $brlapi"
5918 echo "bluez support $bluez"
5919 echo "Documentation $docs"
5920 echo "PIE $pie"
5921 echo "vde support $vde"
5922 echo "netmap support $netmap"
5923 echo "Linux AIO support $linux_aio"
5924 echo "ATTR/XATTR support $attr"
5925 echo "Install blobs $blobs"
5926 echo "KVM support $kvm"
5927 echo "HAX support $hax"
5928 echo "HVF support $hvf"
5929 echo "WHPX support $whpx"
5930 echo "TCG support $tcg"
5931 if test "$tcg" = "yes" ; then
5932 echo "TCG debug enabled $debug_tcg"
5933 echo "TCG interpreter $tcg_interpreter"
5935 echo "malloc trim support $malloc_trim"
5936 echo "RDMA support $rdma"
5937 echo "fdt support $fdt"
5938 echo "membarrier $membarrier"
5939 echo "preadv support $preadv"
5940 echo "fdatasync $fdatasync"
5941 echo "madvise $madvise"
5942 echo "posix_madvise $posix_madvise"
5943 echo "posix_memalign $posix_memalign"
5944 echo "libcap-ng support $cap_ng"
5945 echo "vhost-net support $vhost_net"
5946 echo "vhost-crypto support $vhost_crypto"
5947 echo "vhost-scsi support $vhost_scsi"
5948 echo "vhost-vsock support $vhost_vsock"
5949 echo "vhost-user support $vhost_user"
5950 echo "Trace backends $trace_backends"
5951 if have_backend "simple"; then
5952 echo "Trace output file $trace_file-<pid>"
5954 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5955 echo "rbd support $rbd"
5956 echo "xfsctl support $xfs"
5957 echo "smartcard support $smartcard"
5958 echo "libusb $libusb"
5959 echo "usb net redir $usb_redir"
5960 echo "OpenGL support $opengl"
5961 echo "OpenGL dmabufs $opengl_dmabuf"
5962 echo "libiscsi support $libiscsi"
5963 echo "libnfs support $libnfs"
5964 echo "build guest agent $guest_agent"
5965 echo "QGA VSS support $guest_agent_with_vss"
5966 echo "QGA w32 disk info $guest_agent_ntddscsi"
5967 echo "QGA MSI support $guest_agent_msi"
5968 echo "seccomp support $seccomp"
5969 echo "coroutine backend $coroutine"
5970 echo "coroutine pool $coroutine_pool"
5971 echo "debug stack usage $debug_stack_usage"
5972 echo "mutex debugging $debug_mutex"
5973 echo "crypto afalg $crypto_afalg"
5974 echo "GlusterFS support $glusterfs"
5975 echo "gcov $gcov_tool"
5976 echo "gcov enabled $gcov"
5977 echo "TPM support $tpm"
5978 echo "libssh2 support $libssh2"
5979 echo "TPM passthrough $tpm_passthrough"
5980 echo "TPM emulator $tpm_emulator"
5981 echo "QOM debugging $qom_cast_debug"
5982 echo "Live block migration $live_block_migration"
5983 echo "lzo support $lzo"
5984 echo "snappy support $snappy"
5985 echo "bzip2 support $bzip2"
5986 echo "NUMA host support $numa"
5987 echo "libxml2 $libxml2"
5988 echo "tcmalloc support $tcmalloc"
5989 echo "jemalloc support $jemalloc"
5990 echo "avx2 optimization $avx2_opt"
5991 echo "replication support $replication"
5992 echo "VxHS block device $vxhs"
5993 echo "capstone $capstone"
5994 echo "docker $docker"
5996 if test "$sdl_too_old" = "yes"; then
5997 echo "-> Your SDL version is too old - please upgrade to have SDL support"
6000 if test "$gtkabi" = "2.0"; then
6001 echo
6002 echo "WARNING: Use of GTK 2.0 is deprecated and will be removed in"
6003 echo "WARNING: future releases. Please switch to using GTK 3.0"
6006 if test "$sdlabi" = "1.2"; then
6007 echo
6008 echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
6009 echo "WARNING: future releases. Please switch to using SDL 2.0"
6012 if test "$supported_cpu" = "no"; then
6013 echo
6014 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
6015 echo
6016 echo "CPU host architecture $cpu support is not currently maintained."
6017 echo "The QEMU project intends to remove support for this host CPU in"
6018 echo "a future release if nobody volunteers to maintain it and to"
6019 echo "provide a build host for our continuous integration setup."
6020 echo "configure has succeeded and you can continue to build, but"
6021 echo "if you care about QEMU on this platform you should contact"
6022 echo "us upstream at qemu-devel@nongnu.org."
6025 if test "$supported_os" = "no"; then
6026 echo
6027 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
6028 echo
6029 echo "Host OS $targetos support is not currently maintained."
6030 echo "The QEMU project intends to remove support for this host OS in"
6031 echo "a future release if nobody volunteers to maintain it and to"
6032 echo "provide a build host for our continuous integration setup."
6033 echo "configure has succeeded and you can continue to build, but"
6034 echo "if you care about QEMU on this platform you should contact"
6035 echo "us upstream at qemu-devel@nongnu.org."
6038 config_host_mak="config-host.mak"
6040 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
6042 echo "# Automatically generated by configure - do not modify" > $config_host_mak
6043 echo >> $config_host_mak
6045 echo all: >> $config_host_mak
6046 echo "prefix=$prefix" >> $config_host_mak
6047 echo "bindir=$bindir" >> $config_host_mak
6048 echo "libdir=$libdir" >> $config_host_mak
6049 echo "libexecdir=$libexecdir" >> $config_host_mak
6050 echo "includedir=$includedir" >> $config_host_mak
6051 echo "mandir=$mandir" >> $config_host_mak
6052 echo "sysconfdir=$sysconfdir" >> $config_host_mak
6053 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
6054 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
6055 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
6056 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
6057 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
6058 if test "$mingw32" = "no" ; then
6059 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
6061 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
6062 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
6063 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
6064 echo "GIT=$git" >> $config_host_mak
6065 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6066 echo "GIT_UPDATE=$git_update" >> $config_host_mak
6068 echo "ARCH=$ARCH" >> $config_host_mak
6070 if test "$debug_tcg" = "yes" ; then
6071 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6073 if test "$strip_opt" = "yes" ; then
6074 echo "STRIP=${strip}" >> $config_host_mak
6076 if test "$bigendian" = "yes" ; then
6077 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
6079 if test "$mingw32" = "yes" ; then
6080 echo "CONFIG_WIN32=y" >> $config_host_mak
6081 rc_version=$(cat $source_path/VERSION)
6082 version_major=${rc_version%%.*}
6083 rc_version=${rc_version#*.}
6084 version_minor=${rc_version%%.*}
6085 rc_version=${rc_version#*.}
6086 version_subminor=${rc_version%%.*}
6087 version_micro=0
6088 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6089 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6090 if test "$guest_agent_with_vss" = "yes" ; then
6091 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6092 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6093 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6095 if test "$guest_agent_ntddscsi" = "yes" ; then
6096 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
6098 if test "$guest_agent_msi" = "yes"; then
6099 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
6100 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
6101 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
6102 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
6103 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
6104 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
6105 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
6107 else
6108 echo "CONFIG_POSIX=y" >> $config_host_mak
6111 if test "$linux" = "yes" ; then
6112 echo "CONFIG_LINUX=y" >> $config_host_mak
6115 if test "$darwin" = "yes" ; then
6116 echo "CONFIG_DARWIN=y" >> $config_host_mak
6119 if test "$solaris" = "yes" ; then
6120 echo "CONFIG_SOLARIS=y" >> $config_host_mak
6122 if test "$haiku" = "yes" ; then
6123 echo "CONFIG_HAIKU=y" >> $config_host_mak
6125 if test "$static" = "yes" ; then
6126 echo "CONFIG_STATIC=y" >> $config_host_mak
6128 if test "$profiler" = "yes" ; then
6129 echo "CONFIG_PROFILER=y" >> $config_host_mak
6131 if test "$slirp" = "yes" ; then
6132 echo "CONFIG_SLIRP=y" >> $config_host_mak
6133 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6135 if test "$vde" = "yes" ; then
6136 echo "CONFIG_VDE=y" >> $config_host_mak
6137 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
6139 if test "$netmap" = "yes" ; then
6140 echo "CONFIG_NETMAP=y" >> $config_host_mak
6142 if test "$l2tpv3" = "yes" ; then
6143 echo "CONFIG_L2TPV3=y" >> $config_host_mak
6145 if test "$cap_ng" = "yes" ; then
6146 echo "CONFIG_LIBCAP=y" >> $config_host_mak
6148 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
6149 for drv in $audio_drv_list; do
6150 def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6151 case "$drv" in
6152 alsa | oss | pa | sdl)
6153 echo "$def=m" >> $config_host_mak ;;
6155 echo "$def=y" >> $config_host_mak ;;
6156 esac
6157 done
6158 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6159 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6160 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6161 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6162 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
6163 if test "$audio_pt_int" = "yes" ; then
6164 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
6166 if test "$audio_win_int" = "yes" ; then
6167 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6169 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6170 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6171 if test "$vnc" = "yes" ; then
6172 echo "CONFIG_VNC=y" >> $config_host_mak
6174 if test "$vnc_sasl" = "yes" ; then
6175 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
6177 if test "$vnc_jpeg" = "yes" ; then
6178 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
6180 if test "$vnc_png" = "yes" ; then
6181 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
6183 if test "$xkbcommon" = "yes" ; then
6184 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
6185 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
6187 if test "$fnmatch" = "yes" ; then
6188 echo "CONFIG_FNMATCH=y" >> $config_host_mak
6190 if test "$xfs" = "yes" ; then
6191 echo "CONFIG_XFS=y" >> $config_host_mak
6193 qemu_version=$(head $source_path/VERSION)
6194 echo "VERSION=$qemu_version" >>$config_host_mak
6195 echo "PKGVERSION=$pkgversion" >>$config_host_mak
6196 echo "SRC_PATH=$source_path" >> $config_host_mak
6197 echo "TARGET_LIST=$target_list" >> $config_host_mak
6198 if [ "$docs" = "yes" ] ; then
6199 echo "BUILD_DOCS=yes" >> $config_host_mak
6201 if test "$modules" = "yes"; then
6202 # $shacmd can generate a hash started with digit, which the compiler doesn't
6203 # like as an symbol. So prefix it with an underscore
6204 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
6205 echo "CONFIG_MODULES=y" >> $config_host_mak
6207 if test "$have_x11" = "yes" -a "$need_x11" = "yes"; then
6208 echo "CONFIG_X11=y" >> $config_host_mak
6209 echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
6210 echo "X11_LIBS=$x11_libs" >> $config_host_mak
6212 if test "$sdl" = "yes" ; then
6213 echo "CONFIG_SDL=m" >> $config_host_mak
6214 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
6215 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
6216 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
6218 if test "$cocoa" = "yes" ; then
6219 echo "CONFIG_COCOA=y" >> $config_host_mak
6221 if test "$curses" = "yes" ; then
6222 echo "CONFIG_CURSES=m" >> $config_host_mak
6223 echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
6224 echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6226 if test "$pipe2" = "yes" ; then
6227 echo "CONFIG_PIPE2=y" >> $config_host_mak
6229 if test "$accept4" = "yes" ; then
6230 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
6232 if test "$splice" = "yes" ; then
6233 echo "CONFIG_SPLICE=y" >> $config_host_mak
6235 if test "$eventfd" = "yes" ; then
6236 echo "CONFIG_EVENTFD=y" >> $config_host_mak
6238 if test "$memfd" = "yes" ; then
6239 echo "CONFIG_MEMFD=y" >> $config_host_mak
6241 if test "$fallocate" = "yes" ; then
6242 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6244 if test "$fallocate_punch_hole" = "yes" ; then
6245 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
6247 if test "$fallocate_zero_range" = "yes" ; then
6248 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6250 if test "$posix_fallocate" = "yes" ; then
6251 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6253 if test "$sync_file_range" = "yes" ; then
6254 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6256 if test "$fiemap" = "yes" ; then
6257 echo "CONFIG_FIEMAP=y" >> $config_host_mak
6259 if test "$dup3" = "yes" ; then
6260 echo "CONFIG_DUP3=y" >> $config_host_mak
6262 if test "$ppoll" = "yes" ; then
6263 echo "CONFIG_PPOLL=y" >> $config_host_mak
6265 if test "$prctl_pr_set_timerslack" = "yes" ; then
6266 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6268 if test "$epoll" = "yes" ; then
6269 echo "CONFIG_EPOLL=y" >> $config_host_mak
6271 if test "$epoll_create1" = "yes" ; then
6272 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
6274 if test "$sendfile" = "yes" ; then
6275 echo "CONFIG_SENDFILE=y" >> $config_host_mak
6277 if test "$timerfd" = "yes" ; then
6278 echo "CONFIG_TIMERFD=y" >> $config_host_mak
6280 if test "$setns" = "yes" ; then
6281 echo "CONFIG_SETNS=y" >> $config_host_mak
6283 if test "$clock_adjtime" = "yes" ; then
6284 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
6286 if test "$syncfs" = "yes" ; then
6287 echo "CONFIG_SYNCFS=y" >> $config_host_mak
6289 if test "$inotify" = "yes" ; then
6290 echo "CONFIG_INOTIFY=y" >> $config_host_mak
6292 if test "$inotify1" = "yes" ; then
6293 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6295 if test "$sem_timedwait" = "yes" ; then
6296 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6298 if test "$strchrnul" = "yes" ; then
6299 echo "HAVE_STRCHRNUL=y" >> $config_host_mak
6301 if test "$byteswap_h" = "yes" ; then
6302 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
6304 if test "$bswap_h" = "yes" ; then
6305 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
6307 if test "$curl" = "yes" ; then
6308 echo "CONFIG_CURL=m" >> $config_host_mak
6309 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6310 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6312 if test "$brlapi" = "yes" ; then
6313 echo "CONFIG_BRLAPI=y" >> $config_host_mak
6314 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
6316 if test "$bluez" = "yes" ; then
6317 echo "CONFIG_BLUEZ=y" >> $config_host_mak
6318 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6320 if test "$glib_subprocess" = "yes" ; then
6321 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
6323 if test "$gtk" = "yes" ; then
6324 echo "CONFIG_GTK=m" >> $config_host_mak
6325 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
6326 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6327 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6328 if test "$gtk_gl" = "yes" ; then
6329 echo "CONFIG_GTK_GL=y" >> $config_host_mak
6332 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6333 if test "$gnutls" = "yes" ; then
6334 echo "CONFIG_GNUTLS=y" >> $config_host_mak
6336 if test "$gnutls_rnd" = "yes" ; then
6337 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
6339 if test "$gcrypt" = "yes" ; then
6340 echo "CONFIG_GCRYPT=y" >> $config_host_mak
6341 if test "$gcrypt_hmac" = "yes" ; then
6342 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
6344 if test "$gcrypt_kdf" = "yes" ; then
6345 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
6348 if test "$nettle" = "yes" ; then
6349 echo "CONFIG_NETTLE=y" >> $config_host_mak
6350 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6351 if test "$nettle_kdf" = "yes" ; then
6352 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
6355 if test "$tasn1" = "yes" ; then
6356 echo "CONFIG_TASN1=y" >> $config_host_mak
6358 if test "$have_ifaddrs_h" = "yes" ; then
6359 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6361 if test "$have_broken_size_max" = "yes" ; then
6362 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
6365 # Work around a system header bug with some kernel/XFS header
6366 # versions where they both try to define 'struct fsxattr':
6367 # xfs headers will not try to redefine structs from linux headers
6368 # if this macro is set.
6369 if test "$have_fsxattr" = "yes" ; then
6370 echo "HAVE_FSXATTR=y" >> $config_host_mak
6372 if test "$have_copy_file_range" = "yes" ; then
6373 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
6375 if test "$vte" = "yes" ; then
6376 echo "CONFIG_VTE=y" >> $config_host_mak
6377 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6378 echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6380 if test "$virglrenderer" = "yes" ; then
6381 echo "CONFIG_VIRGL=y" >> $config_host_mak
6382 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
6383 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
6385 if test "$xen" = "yes" ; then
6386 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6387 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6388 if test "$xen_pv_domain_build" = "yes" ; then
6389 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
6392 if test "$linux_aio" = "yes" ; then
6393 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
6395 if test "$attr" = "yes" ; then
6396 echo "CONFIG_ATTR=y" >> $config_host_mak
6398 if test "$libattr" = "yes" ; then
6399 echo "CONFIG_LIBATTR=y" >> $config_host_mak
6401 if test "$virtfs" = "yes" ; then
6402 echo "CONFIG_VIRTFS=y" >> $config_host_mak
6404 if test "$mpath" = "yes" ; then
6405 echo "CONFIG_MPATH=y" >> $config_host_mak
6407 if test "$vhost_scsi" = "yes" ; then
6408 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
6410 if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
6411 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
6413 if test "$vhost_crypto" = "yes" ; then
6414 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6416 if test "$vhost_vsock" = "yes" ; then
6417 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6419 if test "$vhost_user" = "yes" ; then
6420 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6422 if test "$blobs" = "yes" ; then
6423 echo "INSTALL_BLOBS=yes" >> $config_host_mak
6425 if test "$iovec" = "yes" ; then
6426 echo "CONFIG_IOVEC=y" >> $config_host_mak
6428 if test "$preadv" = "yes" ; then
6429 echo "CONFIG_PREADV=y" >> $config_host_mak
6431 if test "$fdt" != "no" ; then
6432 echo "CONFIG_FDT=y" >> $config_host_mak
6434 if test "$membarrier" = "yes" ; then
6435 echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6437 if test "$signalfd" = "yes" ; then
6438 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6440 if test "$tcg" = "yes"; then
6441 echo "CONFIG_TCG=y" >> $config_host_mak
6442 if test "$tcg_interpreter" = "yes" ; then
6443 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
6446 if test "$fdatasync" = "yes" ; then
6447 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
6449 if test "$madvise" = "yes" ; then
6450 echo "CONFIG_MADVISE=y" >> $config_host_mak
6452 if test "$posix_madvise" = "yes" ; then
6453 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6455 if test "$posix_memalign" = "yes" ; then
6456 echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
6459 if test "$spice" = "yes" ; then
6460 echo "CONFIG_SPICE=y" >> $config_host_mak
6463 if test "$smartcard" = "yes" ; then
6464 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
6465 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
6466 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6469 if test "$libusb" = "yes" ; then
6470 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6471 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6472 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
6475 if test "$usb_redir" = "yes" ; then
6476 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6477 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6478 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
6481 if test "$opengl" = "yes" ; then
6482 echo "CONFIG_OPENGL=y" >> $config_host_mak
6483 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6484 if test "$opengl_dmabuf" = "yes" ; then
6485 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6489 if test "$malloc_trim" = "yes" ; then
6490 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
6493 if test "$avx2_opt" = "yes" ; then
6494 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
6497 if test "$lzo" = "yes" ; then
6498 echo "CONFIG_LZO=y" >> $config_host_mak
6501 if test "$snappy" = "yes" ; then
6502 echo "CONFIG_SNAPPY=y" >> $config_host_mak
6505 if test "$bzip2" = "yes" ; then
6506 echo "CONFIG_BZIP2=y" >> $config_host_mak
6507 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
6510 if test "$libiscsi" = "yes" ; then
6511 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6512 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
6513 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6516 if test "$libnfs" = "yes" ; then
6517 echo "CONFIG_LIBNFS=m" >> $config_host_mak
6518 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6521 if test "$seccomp" = "yes"; then
6522 echo "CONFIG_SECCOMP=y" >> $config_host_mak
6523 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6524 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6527 # XXX: suppress that
6528 if [ "$bsd" = "yes" ] ; then
6529 echo "CONFIG_BSD=y" >> $config_host_mak
6532 if test "$localtime_r" = "yes" ; then
6533 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
6535 if test "$qom_cast_debug" = "yes" ; then
6536 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
6538 if test "$rbd" = "yes" ; then
6539 echo "CONFIG_RBD=m" >> $config_host_mak
6540 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
6541 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6544 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
6545 if test "$coroutine_pool" = "yes" ; then
6546 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
6547 else
6548 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
6551 if test "$debug_stack_usage" = "yes" ; then
6552 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
6555 if test "$crypto_afalg" = "yes" ; then
6556 echo "CONFIG_AF_ALG=y" >> $config_host_mak
6559 if test "$open_by_handle_at" = "yes" ; then
6560 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6563 if test "$linux_magic_h" = "yes" ; then
6564 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6567 if test "$pragma_diagnostic_available" = "yes" ; then
6568 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
6571 if test "$valgrind_h" = "yes" ; then
6572 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
6575 if test "$have_asan_iface_fiber" = "yes" ; then
6576 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6579 if test "$has_environ" = "yes" ; then
6580 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
6583 if test "$cpuid_h" = "yes" ; then
6584 echo "CONFIG_CPUID_H=y" >> $config_host_mak
6587 if test "$int128" = "yes" ; then
6588 echo "CONFIG_INT128=y" >> $config_host_mak
6591 if test "$atomic128" = "yes" ; then
6592 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
6595 if test "$atomic64" = "yes" ; then
6596 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6599 if test "$vector16" = "yes" ; then
6600 echo "CONFIG_VECTOR16=y" >> $config_host_mak
6603 if test "$getauxval" = "yes" ; then
6604 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
6607 if test "$glusterfs" = "yes" ; then
6608 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6609 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
6610 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6613 if test "$glusterfs_xlator_opt" = "yes" ; then
6614 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6617 if test "$glusterfs_discard" = "yes" ; then
6618 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
6621 if test "$glusterfs_fallocate" = "yes" ; then
6622 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6625 if test "$glusterfs_zerofill" = "yes" ; then
6626 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
6629 if test "$libssh2" = "yes" ; then
6630 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6631 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
6632 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
6635 if test "$live_block_migration" = "yes" ; then
6636 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6639 if test "$tpm" = "yes"; then
6640 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6641 # TPM passthrough support?
6642 if test "$tpm_passthrough" = "yes"; then
6643 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
6645 # TPM emulator support?
6646 if test "$tpm_emulator" = "yes"; then
6647 echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6651 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
6652 if have_backend "nop"; then
6653 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
6655 if have_backend "simple"; then
6656 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
6657 # Set the appropriate trace file.
6658 trace_file="\"$trace_file-\" FMT_pid"
6660 if have_backend "log"; then
6661 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6663 if have_backend "ust"; then
6664 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6666 if have_backend "dtrace"; then
6667 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
6668 if test "$trace_backend_stap" = "yes" ; then
6669 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
6672 if have_backend "ftrace"; then
6673 if test "$linux" = "yes" ; then
6674 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6675 else
6676 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6679 if have_backend "syslog"; then
6680 if test "$posix_syslog" = "yes" ; then
6681 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
6682 else
6683 feature_not_found "syslog(trace backend)" "syslog not available"
6686 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
6688 if test "$rdma" = "yes" ; then
6689 echo "CONFIG_RDMA=y" >> $config_host_mak
6690 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
6693 if test "$have_rtnetlink" = "yes" ; then
6694 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6697 if test "$libxml2" = "yes" ; then
6698 echo "CONFIG_LIBXML2=y" >> $config_host_mak
6699 echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6700 echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6703 if test "$replication" = "yes" ; then
6704 echo "CONFIG_REPLICATION=y" >> $config_host_mak
6707 if test "$have_af_vsock" = "yes" ; then
6708 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
6711 if test "$have_sysmacros" = "yes" ; then
6712 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
6715 if test "$have_static_assert" = "yes" ; then
6716 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
6719 if test "$have_utmpx" = "yes" ; then
6720 echo "HAVE_UTMPX=y" >> $config_host_mak
6723 if test "$ivshmem" = "yes" ; then
6724 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6726 if test "$capstone" != "no" ; then
6727 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
6729 if test "$debug_mutex" = "yes" ; then
6730 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6733 # Hold two types of flag:
6734 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
6735 # a thread we have a handle to
6736 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
6737 # platform
6738 if test "$pthread_setname_np" = "yes" ; then
6739 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6740 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
6743 if test "$vxhs" = "yes" ; then
6744 echo "CONFIG_VXHS=y" >> $config_host_mak
6745 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6748 if test "$tcg_interpreter" = "yes"; then
6749 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
6750 elif test "$ARCH" = "sparc64" ; then
6751 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
6752 elif test "$ARCH" = "s390x" ; then
6753 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6754 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
6755 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
6756 elif test "$ARCH" = "ppc64" ; then
6757 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
6758 else
6759 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
6761 QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg $QEMU_INCLUDES"
6763 echo "TOOLS=$tools" >> $config_host_mak
6764 echo "ROMS=$roms" >> $config_host_mak
6765 echo "MAKE=$make" >> $config_host_mak
6766 echo "INSTALL=$install" >> $config_host_mak
6767 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
6768 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
6769 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
6770 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6771 echo "PYTHON=$python" >> $config_host_mak
6772 echo "CC=$cc" >> $config_host_mak
6773 if $iasl -h > /dev/null 2>&1; then
6774 echo "IASL=$iasl" >> $config_host_mak
6776 echo "HOST_CC=$host_cc" >> $config_host_mak
6777 echo "CXX=$cxx" >> $config_host_mak
6778 echo "OBJCC=$objcc" >> $config_host_mak
6779 echo "AR=$ar" >> $config_host_mak
6780 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
6781 echo "AS=$as" >> $config_host_mak
6782 echo "CCAS=$ccas" >> $config_host_mak
6783 echo "CPP=$cpp" >> $config_host_mak
6784 echo "OBJCOPY=$objcopy" >> $config_host_mak
6785 echo "LD=$ld" >> $config_host_mak
6786 echo "RANLIB=$ranlib" >> $config_host_mak
6787 echo "NM=$nm" >> $config_host_mak
6788 echo "WINDRES=$windres" >> $config_host_mak
6789 echo "CFLAGS=$CFLAGS" >> $config_host_mak
6790 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6791 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
6792 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6793 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6794 if test "$sparse" = "yes" ; then
6795 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
6796 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
6797 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
6798 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
6799 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6801 if test "$cross_prefix" != ""; then
6802 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
6803 else
6804 echo "AUTOCONF_HOST := " >> $config_host_mak
6806 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
6807 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
6808 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
6809 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6810 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
6811 echo "LIBS+=$LIBS" >> $config_host_mak
6812 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6813 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6814 echo "EXESUF=$EXESUF" >> $config_host_mak
6815 echo "DSOSUF=$DSOSUF" >> $config_host_mak
6816 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6817 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
6818 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
6819 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
6820 echo "POD2MAN=$POD2MAN" >> $config_host_mak
6821 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
6822 if test "$gcov" = "yes" ; then
6823 echo "CONFIG_GCOV=y" >> $config_host_mak
6824 echo "GCOV=$gcov_tool" >> $config_host_mak
6827 if test "$docker" != "no"; then
6828 echo "HAVE_USER_DOCKER=y" >> $config_host_mak
6831 # use included Linux headers
6832 if test "$linux" = "yes" ; then
6833 mkdir -p linux-headers
6834 case "$cpu" in
6835 i386|x86_64|x32)
6836 linux_arch=x86
6838 ppcemb|ppc|ppc64)
6839 linux_arch=powerpc
6841 s390x)
6842 linux_arch=s390
6844 aarch64)
6845 linux_arch=arm64
6847 mips64)
6848 linux_arch=mips
6851 # For most CPUs the kernel architecture name and QEMU CPU name match.
6852 linux_arch="$cpu"
6854 esac
6855 # For non-KVM architectures we will not have asm headers
6856 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
6857 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
6861 for target in $target_list; do
6862 target_dir="$target"
6863 config_target_mak=$target_dir/config-target.mak
6864 target_name=$(echo $target | cut -d '-' -f 1)
6865 target_bigendian="no"
6867 case "$target_name" in
6868 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6869 target_bigendian=yes
6871 esac
6872 target_softmmu="no"
6873 target_user_only="no"
6874 target_linux_user="no"
6875 target_bsd_user="no"
6876 case "$target" in
6877 ${target_name}-softmmu)
6878 target_softmmu="yes"
6880 ${target_name}-linux-user)
6881 target_user_only="yes"
6882 target_linux_user="yes"
6884 ${target_name}-bsd-user)
6885 target_user_only="yes"
6886 target_bsd_user="yes"
6889 error_exit "Target '$target' not recognised"
6890 exit 1
6892 esac
6894 target_compiler=""
6895 target_compiler_static=""
6896 target_compiler_cflags=""
6898 mkdir -p $target_dir
6899 echo "# Automatically generated by configure - do not modify" > $config_target_mak
6901 bflt="no"
6902 mttcg="no"
6903 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
6904 gdb_xml_files=""
6906 TARGET_ARCH="$target_name"
6907 TARGET_BASE_ARCH=""
6908 TARGET_ABI_DIR=""
6910 case "$target_name" in
6911 i386)
6912 gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
6913 target_compiler=$cross_cc_i386
6914 target_compiler_cflags=$cross_cc_ccflags_i386
6916 x86_64)
6917 TARGET_BASE_ARCH=i386
6918 gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
6919 target_compiler=$cross_cc_x86_64
6921 alpha)
6922 mttcg="yes"
6923 target_compiler=$cross_cc_alpha
6925 arm|armeb)
6926 TARGET_ARCH=arm
6927 bflt="yes"
6928 mttcg="yes"
6929 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6930 target_compiler=$cross_cc_arm
6931 eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
6933 aarch64|aarch64_be)
6934 TARGET_ARCH=aarch64
6935 TARGET_BASE_ARCH=arm
6936 bflt="yes"
6937 mttcg="yes"
6938 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6939 target_compiler=$cross_cc_aarch64
6940 eval "target_compiler_cflags=\$cross_cc_cflags_${target_name}"
6942 cris)
6943 target_compiler=$cross_cc_cris
6945 hppa)
6946 mttcg="yes"
6947 target_compiler=$cross_cc_hppa
6949 lm32)
6950 target_compiler=$cross_cc_lm32
6952 m68k)
6953 bflt="yes"
6954 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
6955 target_compiler=$cross_cc_m68k
6957 microblaze|microblazeel)
6958 TARGET_ARCH=microblaze
6959 bflt="yes"
6960 echo "TARGET_ABI32=y" >> $config_target_mak
6961 target_compiler=$cross_cc_microblaze
6963 mips|mipsel)
6964 TARGET_ARCH=mips
6965 target_compiler=$cross_cc_mips
6966 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
6968 mipsn32|mipsn32el)
6969 TARGET_ARCH=mips64
6970 TARGET_BASE_ARCH=mips
6971 target_compiler=$cross_cc_mipsn32
6972 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6973 echo "TARGET_ABI32=y" >> $config_target_mak
6975 mips64|mips64el)
6976 TARGET_ARCH=mips64
6977 TARGET_BASE_ARCH=mips
6978 target_compiler=$cross_cc_mips64
6979 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
6981 moxie)
6982 target_compiler=$cross_cc_moxie
6984 nios2)
6985 target_compiler=$cross_cc_nios2
6987 or1k)
6988 target_compiler=$cross_cc_or1k
6989 TARGET_ARCH=openrisc
6990 TARGET_BASE_ARCH=openrisc
6992 ppc)
6993 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6994 target_compiler=$cross_cc_powerpc
6996 ppcemb)
6997 TARGET_BASE_ARCH=ppc
6998 TARGET_ABI_DIR=ppc
6999 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
7000 target_compiler=$cross_cc_ppcemb
7002 ppc64)
7003 TARGET_BASE_ARCH=ppc
7004 TARGET_ABI_DIR=ppc
7005 mttcg=yes
7006 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7007 target_compiler=$cross_cc_ppc64
7009 ppc64le)
7010 TARGET_ARCH=ppc64
7011 TARGET_BASE_ARCH=ppc
7012 TARGET_ABI_DIR=ppc
7013 mttcg=yes
7014 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7015 target_compiler=$cross_cc_ppc64le
7017 ppc64abi32)
7018 TARGET_ARCH=ppc64
7019 TARGET_BASE_ARCH=ppc
7020 TARGET_ABI_DIR=ppc
7021 echo "TARGET_ABI32=y" >> $config_target_mak
7022 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
7023 target_compiler=$cross_cc_ppc64abi32
7025 riscv32)
7026 TARGET_BASE_ARCH=riscv
7027 TARGET_ABI_DIR=riscv
7028 mttcg=yes
7029 target_compiler=$cross_cc_riscv32
7031 riscv64)
7032 TARGET_BASE_ARCH=riscv
7033 TARGET_ABI_DIR=riscv
7034 mttcg=yes
7035 target_compiler=$cross_cc_riscv64
7037 sh4|sh4eb)
7038 TARGET_ARCH=sh4
7039 bflt="yes"
7040 target_compiler=$cross_cc_sh4
7042 sparc)
7043 target_compiler=$cross_cc_sparc
7045 sparc64)
7046 TARGET_BASE_ARCH=sparc
7047 target_compiler=$cross_cc_sparc64
7049 sparc32plus)
7050 TARGET_ARCH=sparc64
7051 TARGET_BASE_ARCH=sparc
7052 TARGET_ABI_DIR=sparc
7053 target_compiler=$cross_cc_sparc32plus
7054 echo "TARGET_ABI32=y" >> $config_target_mak
7056 s390x)
7057 mttcg=yes
7058 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
7059 target_compiler=$cross_cc_s390x
7061 tilegx)
7062 target_compiler=$cross_cc_tilegx
7064 tricore)
7065 target_compiler=$cross_cc_tricore
7067 unicore32)
7068 target_compiler=$cross_cc_unicore32
7070 xtensa|xtensaeb)
7071 TARGET_ARCH=xtensa
7072 mttcg="yes"
7073 target_compiler=$cross_cc_xtensa
7076 error_exit "Unsupported target CPU"
7078 esac
7079 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
7080 if [ "$TARGET_BASE_ARCH" = "" ]; then
7081 TARGET_BASE_ARCH=$TARGET_ARCH
7084 # Do we have a cross compiler for this target?
7085 if has $target_compiler; then
7087 write_c_skeleton
7089 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC -static ; then
7090 # For host systems we might get away with building without -static
7091 if ! do_compiler "$target_compiler" $target_compiler_cflags -o $TMPE $TMPC ; then
7092 target_compiler=""
7093 else
7094 enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7095 target_compiler_static="n"
7097 else
7098 enabled_cross_compilers="${enabled_cross_compilers} '${target_compiler}'"
7099 target_compiler_static="y"
7101 else
7102 target_compiler=""
7105 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
7107 upper() {
7108 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
7111 target_arch_name="$(upper $TARGET_ARCH)"
7112 echo "TARGET_$target_arch_name=y" >> $config_target_mak
7113 echo "TARGET_NAME=$target_name" >> $config_target_mak
7114 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7115 if [ "$TARGET_ABI_DIR" = "" ]; then
7116 TARGET_ABI_DIR=$TARGET_ARCH
7118 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7119 if [ "$HOST_VARIANT_DIR" != "" ]; then
7120 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7123 if supported_xen_target $target; then
7124 echo "CONFIG_XEN=y" >> $config_target_mak
7125 if test "$xen_pci_passthrough" = yes; then
7126 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7129 if supported_kvm_target $target; then
7130 echo "CONFIG_KVM=y" >> $config_target_mak
7131 if test "$vhost_net" = "yes" ; then
7132 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
7133 if test "$vhost_user" = "yes" ; then
7134 echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
7138 if supported_hax_target $target; then
7139 echo "CONFIG_HAX=y" >> $config_target_mak
7141 if supported_hvf_target $target; then
7142 echo "CONFIG_HVF=y" >> $config_target_mak
7144 if supported_whpx_target $target; then
7145 echo "CONFIG_WHPX=y" >> $config_target_mak
7147 if test "$target_bigendian" = "yes" ; then
7148 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
7150 if test "$target_softmmu" = "yes" ; then
7151 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7152 if test "$mttcg" = "yes" ; then
7153 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7156 if test "$target_user_only" = "yes" ; then
7157 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7158 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
7160 if test "$target_linux_user" = "yes" ; then
7161 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7163 list=""
7164 if test ! -z "$gdb_xml_files" ; then
7165 for x in $gdb_xml_files; do
7166 list="$list $source_path/gdb-xml/$x"
7167 done
7168 echo "TARGET_XML_FILES=$list" >> $config_target_mak
7171 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
7172 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7174 if test "$target_bsd_user" = "yes" ; then
7175 echo "CONFIG_BSD_USER=y" >> $config_target_mak
7178 if test -n "$target_compiler"; then
7179 echo "CROSS_CC_GUEST=\"$target_compiler\"" >> $config_target_mak
7181 if test -n "$target_compiler_static"; then
7182 echo "CROSS_CC_GUEST_STATIC=$target_compiler_static" >> $config_target_mak
7185 if test -n "$target_compiler_cflags"; then
7186 echo "CROSS_CC_GUEST_CFLAGS=$target_compiler_cflags" >> $config_target_mak
7191 # generate QEMU_CFLAGS/LDFLAGS for targets
7193 cflags=""
7194 ldflags=""
7196 disas_config() {
7197 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7198 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7201 for i in $ARCH $TARGET_BASE_ARCH ; do
7202 case "$i" in
7203 alpha)
7204 disas_config "ALPHA"
7206 aarch64)
7207 if test -n "${cxx}"; then
7208 disas_config "ARM_A64"
7211 arm)
7212 disas_config "ARM"
7213 if test -n "${cxx}"; then
7214 disas_config "ARM_A64"
7217 cris)
7218 disas_config "CRIS"
7220 hppa)
7221 disas_config "HPPA"
7223 i386|x86_64|x32)
7224 disas_config "I386"
7226 lm32)
7227 disas_config "LM32"
7229 m68k)
7230 disas_config "M68K"
7232 microblaze*)
7233 disas_config "MICROBLAZE"
7235 mips*)
7236 disas_config "MIPS"
7238 moxie*)
7239 disas_config "MOXIE"
7241 nios2)
7242 disas_config "NIOS2"
7244 or1k)
7245 disas_config "OPENRISC"
7247 ppc*)
7248 disas_config "PPC"
7250 riscv)
7251 disas_config "RISCV"
7253 s390*)
7254 disas_config "S390"
7256 sh4)
7257 disas_config "SH4"
7259 sparc*)
7260 disas_config "SPARC"
7262 xtensa*)
7263 disas_config "XTENSA"
7265 esac
7266 done
7267 if test "$tcg_interpreter" = "yes" ; then
7268 disas_config "TCI"
7271 case "$ARCH" in
7272 alpha)
7273 # Ensure there's only a single GP
7274 cflags="-msmall-data $cflags"
7276 esac
7278 if test "$gprof" = "yes" ; then
7279 echo "TARGET_GPROF=yes" >> $config_target_mak
7280 if test "$target_linux_user" = "yes" ; then
7281 cflags="-p $cflags"
7282 ldflags="-p $ldflags"
7284 if test "$target_softmmu" = "yes" ; then
7285 ldflags="-p $ldflags"
7286 echo "GPROF_CFLAGS=-p" >> $config_target_mak
7290 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
7291 ldflags="$ldflags $textseg_ldflags"
7294 # Newer kernels on s390 check for an S390_PGSTE program header and
7295 # enable the pgste page table extensions in that case. This makes
7296 # the vm.allocate_pgste sysctl unnecessary. We enable this program
7297 # header if
7298 # - we build on s390x
7299 # - we build the system emulation for s390x (qemu-system-s390x)
7300 # - KVM is enabled
7301 # - the linker supports --s390-pgste
7302 if test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes" -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
7303 if ld_has --s390-pgste ; then
7304 ldflags="-Wl,--s390-pgste $ldflags"
7308 echo "LDFLAGS+=$ldflags" >> $config_target_mak
7309 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
7311 done # for target in $targets
7313 if test -n "$enabled_cross_compilers"; then
7314 echo
7315 echo "NOTE: cross-compilers enabled: $enabled_cross_compilers"
7318 if [ "$fdt" = "git" ]; then
7319 echo "config-host.h: subdir-dtc" >> $config_host_mak
7321 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7322 echo "config-host.h: subdir-capstone" >> $config_host_mak
7324 if test -n "$LIBCAPSTONE"; then
7325 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7328 if test "$numa" = "yes"; then
7329 echo "CONFIG_NUMA=y" >> $config_host_mak
7332 if test "$ccache_cpp2" = "yes"; then
7333 echo "export CCACHE_CPP2=y" >> $config_host_mak
7336 # build tree in object directory in case the source is not in the current directory
7337 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
7338 DIRS="$DIRS docs docs/interop fsdev scsi"
7339 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
7340 DIRS="$DIRS roms/seabios roms/vgabios"
7341 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
7342 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
7343 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
7344 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
7345 FILES="$FILES pc-bios/spapr-rtas/Makefile"
7346 FILES="$FILES pc-bios/s390-ccw/Makefile"
7347 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
7348 FILES="$FILES pc-bios/qemu-icon.bmp"
7349 FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
7350 for bios_file in \
7351 $source_path/pc-bios/*.bin \
7352 $source_path/pc-bios/*.lid \
7353 $source_path/pc-bios/*.aml \
7354 $source_path/pc-bios/*.rom \
7355 $source_path/pc-bios/*.dtb \
7356 $source_path/pc-bios/*.img \
7357 $source_path/pc-bios/openbios-* \
7358 $source_path/pc-bios/u-boot.* \
7359 $source_path/pc-bios/palcode-*
7361 FILES="$FILES pc-bios/$(basename $bios_file)"
7362 done
7363 for test_file in $(find $source_path/tests/acpi-test-data -type f)
7365 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
7366 done
7367 mkdir -p $DIRS
7368 for f in $FILES ; do
7369 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
7370 symlink "$source_path/$f" "$f"
7372 done
7374 # temporary config to build submodules
7375 for rom in seabios vgabios ; do
7376 config_mak=roms/$rom/config.mak
7377 echo "# Automatically generated by configure - do not modify" > $config_mak
7378 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7379 echo "AS=$as" >> $config_mak
7380 echo "CCAS=$ccas" >> $config_mak
7381 echo "CC=$cc" >> $config_mak
7382 echo "BCC=bcc" >> $config_mak
7383 echo "CPP=$cpp" >> $config_mak
7384 echo "OBJCOPY=objcopy" >> $config_mak
7385 echo "IASL=$iasl" >> $config_mak
7386 echo "LD=$ld" >> $config_mak
7387 echo "RANLIB=$ranlib" >> $config_mak
7388 done
7390 # set up tests data directory
7391 for tests_subdir in acceptance data; do
7392 if [ ! -e tests/$tests_subdir ]; then
7393 symlink "$source_path/tests/$tests_subdir" tests/$tests_subdir
7395 done
7397 # set up qemu-iotests in this build directory
7398 iotests_common_env="tests/qemu-iotests/common.env"
7399 iotests_check="tests/qemu-iotests/check"
7401 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
7402 echo >> "$iotests_common_env"
7403 echo "export PYTHON='$python'" >> "$iotests_common_env"
7405 if [ ! -e "$iotests_check" ]; then
7406 symlink "$source_path/$iotests_check" "$iotests_check"
7409 # Save the configure command line for later reuse.
7410 cat <<EOD >config.status
7411 #!/bin/sh
7412 # Generated by configure.
7413 # Run this file to recreate the current configuration.
7414 # Compiler output produced by configure, useful for debugging
7415 # configure, is in config.log if it exists.
7417 printf "exec" >>config.status
7418 printf " '%s'" "$0" "$@" >>config.status
7419 echo ' "$@"' >>config.status
7420 chmod +x config.status
7422 rm -r "$TMPDIR1"