cpus: tcg: unregister thread with RCU, fix exiting of loop on unplug
[qemu/ar7.git] / configure
blob529aad5491bcb05e0ea5323ea2bd1d92ba04cf25
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 echo $compiler "$@" >> config.log
64 $compiler "$@" >> config.log 2>&1 || return $?
65 # Test passed. If this is an --enable-werror build, rerun
66 # the test with -Werror and bail out if it fails. This
67 # makes warning-generating-errors in configure test code
68 # obvious to developers.
69 if test "$werror" != "yes"; then
70 return 0
72 # Don't bother rerunning the compile if we were already using -Werror
73 case "$*" in
74 *-Werror*)
75 return 0
77 esac
78 echo $compiler -Werror "$@" >> config.log
79 $compiler -Werror "$@" >> config.log 2>&1 && return $?
80 error_exit "configure test passed without -Werror but failed with -Werror." \
81 "This is probably a bug in the configure script. The failing command" \
82 "will be at the bottom of config.log." \
83 "You can run configure with --disable-werror to bypass this check."
86 do_cc() {
87 do_compiler "$cc" "$@"
90 do_cxx() {
91 do_compiler "$cxx" "$@"
94 update_cxxflags() {
95 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
96 # options which some versions of GCC's C++ compiler complain about
97 # because they only make sense for C programs.
98 QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS"
100 for arg in $QEMU_CFLAGS; do
101 case $arg in
102 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
103 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
106 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
108 esac
109 done
112 compile_object() {
113 local_cflags="$1"
114 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
117 compile_prog() {
118 local_cflags="$1"
119 local_ldflags="$2"
120 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
123 # symbolically link $1 to $2. Portable version of "ln -sf".
124 symlink() {
125 rm -rf "$2"
126 mkdir -p "$(dirname "$2")"
127 ln -s "$1" "$2"
130 # check whether a command is available to this shell (may be either an
131 # executable or a builtin)
132 has() {
133 type "$1" >/dev/null 2>&1
136 # search for an executable in PATH
137 path_of() {
138 local_command="$1"
139 local_ifs="$IFS"
140 local_dir=""
142 # pathname has a dir component?
143 if [ "${local_command#*/}" != "$local_command" ]; then
144 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
145 echo "$local_command"
146 return 0
149 if [ -z "$local_command" ]; then
150 return 1
153 IFS=:
154 for local_dir in $PATH; do
155 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
156 echo "$local_dir/$local_command"
157 IFS="${local_ifs:-$(printf ' \t\n')}"
158 return 0
160 done
161 # not found
162 IFS="${local_ifs:-$(printf ' \t\n')}"
163 return 1
166 have_backend () {
167 echo "$trace_backends" | grep "$1" >/dev/null
170 glob() {
171 eval test -z '"${1#'"$2"'}"'
174 supported_hax_target() {
175 test "$hax" = "yes" || return 1
176 glob "$1" "*-softmmu" || return 1
177 case "${1%-softmmu}" in
178 i386|x86_64)
179 return 0
181 esac
182 return 1
185 supported_kvm_target() {
186 test "$kvm" = "yes" || return 1
187 glob "$1" "*-softmmu" || return 1
188 case "${1%-softmmu}:$cpu" in
189 arm:arm | aarch64:aarch64 | \
190 i386:i386 | i386:x86_64 | i386:x32 | \
191 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
192 mips:mips | mipsel:mips | \
193 ppc:ppc | ppcemb:ppc | ppc64:ppc | \
194 ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
195 s390x:s390x)
196 return 0
198 esac
199 return 1
202 supported_xen_target() {
203 test "$xen" = "yes" || return 1
204 glob "$1" "*-softmmu" || return 1
205 # Only i386 and x86_64 provide the xenpv machine.
206 case "${1%-softmmu}" in
207 i386|x86_64)
208 return 0
210 esac
211 return 1
214 supported_hvf_target() {
215 test "$hvf" = "yes" || return 1
216 glob "$1" "*-softmmu" || return 1
217 case "${1%-softmmu}" in
218 x86_64)
219 return 0
221 esac
222 return 1
225 supported_target() {
226 case "$1" in
227 *-softmmu)
229 *-linux-user)
230 if test "$linux" != "yes"; then
231 print_error "Target '$target' is only available on a Linux host"
232 return 1
235 *-bsd-user)
236 if test "$bsd" != "yes"; then
237 print_error "Target '$target' is only available on a BSD host"
238 return 1
242 print_error "Invalid target name '$target'"
243 return 1
245 esac
246 test "$tcg" = "yes" && return 0
247 supported_kvm_target "$1" && return 0
248 supported_xen_target "$1" && return 0
249 supported_hax_target "$1" && return 0
250 supported_hvf_target "$1" && return 0
251 print_error "TCG disabled, but hardware accelerator not available for '$target'"
252 return 1
256 ld_has() {
257 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
260 # default parameters
261 source_path=$(dirname "$0")
262 cpu=""
263 iasl="iasl"
264 interp_prefix="/usr/gnemul/qemu-%M"
265 static="no"
266 cross_prefix=""
267 audio_drv_list=""
268 block_drv_rw_whitelist=""
269 block_drv_ro_whitelist=""
270 host_cc="cc"
271 libs_softmmu=""
272 libs_tools=""
273 audio_pt_int=""
274 audio_win_int=""
275 cc_i386=i386-pc-linux-gnu-gcc
276 libs_qga=""
277 debug_info="yes"
278 stack_protector=""
280 if test -e "$source_path/.git"
281 then
282 git_update=yes
283 git_submodules="ui/keycodemapdb"
284 else
285 git_update=no
286 git_submodules=""
288 git="git"
290 # Don't accept a target_list environment variable.
291 unset target_list
293 # Default value for a variable defining feature "foo".
294 # * foo="no" feature will only be used if --enable-foo arg is given
295 # * foo="" feature will be searched for, and if found, will be used
296 # unless --disable-foo is given
297 # * foo="yes" this value will only be set by --enable-foo flag.
298 # feature will searched for,
299 # if not found, configure exits with error
301 # Always add --enable-foo and --disable-foo command line args.
302 # Distributions want to ensure that several features are compiled in, and it
303 # is impossible without a --enable-foo that exits if a feature is not found.
305 bluez=""
306 brlapi=""
307 curl=""
308 curses=""
309 docs=""
310 fdt=""
311 netmap="no"
312 sdl=""
313 sdlabi=""
314 virtfs=""
315 mpath=""
316 vnc="yes"
317 sparse="no"
318 vde=""
319 vnc_sasl=""
320 vnc_jpeg=""
321 vnc_png=""
322 xkbcommon=""
323 xen=""
324 xen_ctrl_version=""
325 xen_pv_domain_build="no"
326 xen_pci_passthrough=""
327 linux_aio=""
328 cap_ng=""
329 attr=""
330 libattr=""
331 xfs=""
332 tcg="yes"
334 vhost_net="no"
335 vhost_scsi="no"
336 vhost_vsock="no"
337 vhost_user=""
338 kvm="no"
339 hax="no"
340 hvf="no"
341 rdma=""
342 gprof="no"
343 debug_tcg="no"
344 debug="no"
345 sanitizers="no"
346 fortify_source=""
347 strip_opt="yes"
348 tcg_interpreter="no"
349 bigendian="no"
350 mingw32="no"
351 gcov="no"
352 gcov_tool="gcov"
353 EXESUF=""
354 DSOSUF=".so"
355 LDFLAGS_SHARED="-shared"
356 modules="no"
357 prefix="/usr/local"
358 mandir="\${prefix}/share/man"
359 datadir="\${prefix}/share"
360 firmwarepath="\${prefix}/share/qemu-firmware"
361 qemu_docdir="\${prefix}/share/doc/qemu"
362 bindir="\${prefix}/bin"
363 libdir="\${prefix}/lib"
364 libexecdir="\${prefix}/libexec"
365 includedir="\${prefix}/include"
366 sysconfdir="\${prefix}/etc"
367 local_statedir="\${prefix}/var"
368 confsuffix="/qemu"
369 slirp="yes"
370 oss_lib=""
371 bsd="no"
372 linux="no"
373 solaris="no"
374 profiler="no"
375 cocoa="no"
376 softmmu="yes"
377 linux_user="no"
378 bsd_user="no"
379 blobs="yes"
380 pkgversion=""
381 pie=""
382 qom_cast_debug="yes"
383 trace_backends="log"
384 trace_file="trace"
385 spice=""
386 rbd=""
387 smartcard=""
388 libusb=""
389 usb_redir=""
390 opengl=""
391 opengl_dmabuf="no"
392 cpuid_h="no"
393 avx2_opt="no"
394 zlib="yes"
395 capstone=""
396 lzo=""
397 snappy=""
398 bzip2=""
399 guest_agent=""
400 guest_agent_with_vss="no"
401 guest_agent_ntddscsi="no"
402 guest_agent_msi=""
403 vss_win32_sdk=""
404 win_sdk="no"
405 want_tools="yes"
406 libiscsi=""
407 libnfs=""
408 coroutine=""
409 coroutine_pool=""
410 debug_stack_usage="no"
411 crypto_afalg="no"
412 seccomp=""
413 glusterfs=""
414 glusterfs_xlator_opt="no"
415 glusterfs_discard="no"
416 glusterfs_fallocate="no"
417 glusterfs_zerofill="no"
418 gtk=""
419 gtkabi=""
420 gtk_gl="no"
421 tls_priority="NORMAL"
422 gnutls=""
423 gnutls_rnd=""
424 nettle=""
425 nettle_kdf="no"
426 gcrypt=""
427 gcrypt_hmac="no"
428 gcrypt_kdf="no"
429 vte=""
430 virglrenderer=""
431 tpm="yes"
432 libssh2=""
433 live_block_migration="yes"
434 numa=""
435 tcmalloc="no"
436 jemalloc="no"
437 replication="yes"
438 vxhs=""
439 libxml2=""
441 supported_cpu="no"
442 supported_os="no"
443 bogus_os="no"
444 malloc_trim=""
446 # parse CC options first
447 for opt do
448 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
449 case "$opt" in
450 --cross-prefix=*) cross_prefix="$optarg"
452 --cc=*) CC="$optarg"
454 --cxx=*) CXX="$optarg"
456 --source-path=*) source_path="$optarg"
458 --cpu=*) cpu="$optarg"
460 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
461 EXTRA_CFLAGS="$optarg"
463 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
464 EXTRA_CXXFLAGS="$optarg"
466 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
467 EXTRA_LDFLAGS="$optarg"
469 --enable-debug-info) debug_info="yes"
471 --disable-debug-info) debug_info="no"
473 esac
474 done
475 # OS specific
476 # Using uname is really, really broken. Once we have the right set of checks
477 # we can eliminate its usage altogether.
479 # Preferred compiler:
480 # ${CC} (if set)
481 # ${cross_prefix}gcc (if cross-prefix specified)
482 # system compiler
483 if test -z "${CC}${cross_prefix}"; then
484 cc="$host_cc"
485 else
486 cc="${CC-${cross_prefix}gcc}"
489 if test -z "${CXX}${cross_prefix}"; then
490 cxx="c++"
491 else
492 cxx="${CXX-${cross_prefix}g++}"
495 ar="${AR-${cross_prefix}ar}"
496 as="${AS-${cross_prefix}as}"
497 ccas="${CCAS-$cc}"
498 cpp="${CPP-$cc -E}"
499 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
500 ld="${LD-${cross_prefix}ld}"
501 ranlib="${RANLIB-${cross_prefix}ranlib}"
502 nm="${NM-${cross_prefix}nm}"
503 strip="${STRIP-${cross_prefix}strip}"
504 windres="${WINDRES-${cross_prefix}windres}"
505 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
506 query_pkg_config() {
507 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
509 pkg_config=query_pkg_config
510 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
511 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
513 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
514 ARFLAGS="${ARFLAGS-rv}"
516 # default flags for all hosts
517 # We use -fwrapv to tell the compiler that we require a C dialect where
518 # left shift of signed integers is well defined and has the expected
519 # 2s-complement style results. (Both clang and gcc agree that it
520 # provides these semantics.)
521 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
522 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
523 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
524 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
525 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
526 if test "$debug_info" = "yes"; then
527 CFLAGS="-g $CFLAGS"
528 LDFLAGS="-g $LDFLAGS"
531 # make source path absolute
532 source_path=$(cd "$source_path"; pwd)
534 # running configure in the source tree?
535 # we know that's the case if configure is there.
536 if test -f "./configure"; then
537 pwd_is_source_path="y"
538 else
539 pwd_is_source_path="n"
542 check_define() {
543 cat > $TMPC <<EOF
544 #if !defined($1)
545 #error $1 not defined
546 #endif
547 int main(void) { return 0; }
549 compile_object
552 check_include() {
553 cat > $TMPC <<EOF
554 #include <$1>
555 int main(void) { return 0; }
557 compile_object
560 write_c_skeleton() {
561 cat > $TMPC <<EOF
562 int main(void) { return 0; }
566 if check_define __linux__ ; then
567 targetos="Linux"
568 elif check_define _WIN32 ; then
569 targetos='MINGW32'
570 elif check_define __OpenBSD__ ; then
571 targetos='OpenBSD'
572 elif check_define __sun__ ; then
573 targetos='SunOS'
574 elif check_define __HAIKU__ ; then
575 targetos='Haiku'
576 elif check_define __FreeBSD__ ; then
577 targetos='FreeBSD'
578 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
579 targetos='GNU/kFreeBSD'
580 elif check_define __DragonFly__ ; then
581 targetos='DragonFly'
582 elif check_define __NetBSD__; then
583 targetos='NetBSD'
584 elif check_define __APPLE__; then
585 targetos='Darwin'
586 else
587 # This is a fatal error, but don't report it yet, because we
588 # might be going to just print the --help text, or it might
589 # be the result of a missing compiler.
590 targetos='bogus'
591 bogus_os='yes'
594 # Some host OSes need non-standard checks for which CPU to use.
595 # Note that these checks are broken for cross-compilation: if you're
596 # cross-compiling to one of these OSes then you'll need to specify
597 # the correct CPU with the --cpu option.
598 case $targetos in
599 Darwin)
600 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
601 # run 64-bit userspace code.
602 # If the user didn't specify a CPU explicitly and the kernel says this is
603 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
604 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
605 cpu="x86_64"
608 SunOS)
609 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
610 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
611 cpu="x86_64"
613 esac
615 if test ! -z "$cpu" ; then
616 # command line argument
618 elif check_define __i386__ ; then
619 cpu="i386"
620 elif check_define __x86_64__ ; then
621 if check_define __ILP32__ ; then
622 cpu="x32"
623 else
624 cpu="x86_64"
626 elif check_define __sparc__ ; then
627 if check_define __arch64__ ; then
628 cpu="sparc64"
629 else
630 cpu="sparc"
632 elif check_define _ARCH_PPC ; then
633 if check_define _ARCH_PPC64 ; then
634 cpu="ppc64"
635 else
636 cpu="ppc"
638 elif check_define __mips__ ; then
639 cpu="mips"
640 elif check_define __s390__ ; then
641 if check_define __s390x__ ; then
642 cpu="s390x"
643 else
644 cpu="s390"
646 elif check_define __arm__ ; then
647 cpu="arm"
648 elif check_define __aarch64__ ; then
649 cpu="aarch64"
650 else
651 cpu=$(uname -m)
654 ARCH=
655 # Normalise host CPU name and set ARCH.
656 # Note that this case should only have supported host CPUs, not guests.
657 case "$cpu" in
658 ppc|ppc64|s390|s390x|sparc64|x32)
659 cpu="$cpu"
660 supported_cpu="yes"
662 i386|i486|i586|i686|i86pc|BePC)
663 cpu="i386"
664 supported_cpu="yes"
666 x86_64|amd64)
667 cpu="x86_64"
668 supported_cpu="yes"
670 armv*b|armv*l|arm)
671 cpu="arm"
672 supported_cpu="yes"
674 aarch64)
675 cpu="aarch64"
676 supported_cpu="yes"
678 mips*)
679 cpu="mips"
680 supported_cpu="yes"
682 sparc|sun4[cdmuv])
683 cpu="sparc"
684 supported_cpu="yes"
687 # This will result in either an error or falling back to TCI later
688 ARCH=unknown
690 esac
691 if test -z "$ARCH"; then
692 ARCH="$cpu"
695 # OS specific
697 # host *BSD for user mode
698 HOST_VARIANT_DIR=""
700 case $targetos in
701 MINGW32*)
702 mingw32="yes"
703 hax="yes"
704 audio_possible_drivers="dsound sdl"
705 if check_include dsound.h; then
706 audio_drv_list="dsound"
707 else
708 audio_drv_list=""
710 supported_os="yes"
712 GNU/kFreeBSD)
713 bsd="yes"
714 audio_drv_list="oss"
715 audio_possible_drivers="oss sdl pa"
717 FreeBSD)
718 bsd="yes"
719 make="${MAKE-gmake}"
720 audio_drv_list="oss"
721 audio_possible_drivers="oss sdl pa"
722 # needed for kinfo_getvmmap(3) in libutil.h
723 LIBS="-lutil $LIBS"
724 # needed for kinfo_getproc
725 libs_qga="-lutil $libs_qga"
726 netmap="" # enable netmap autodetect
727 HOST_VARIANT_DIR="freebsd"
728 supported_os="yes"
730 DragonFly)
731 bsd="yes"
732 make="${MAKE-gmake}"
733 audio_drv_list="oss"
734 audio_possible_drivers="oss sdl pa"
735 HOST_VARIANT_DIR="dragonfly"
737 NetBSD)
738 bsd="yes"
739 make="${MAKE-gmake}"
740 audio_drv_list="oss"
741 audio_possible_drivers="oss sdl"
742 oss_lib="-lossaudio"
743 HOST_VARIANT_DIR="netbsd"
744 supported_os="yes"
746 OpenBSD)
747 bsd="yes"
748 make="${MAKE-gmake}"
749 audio_drv_list="sdl"
750 audio_possible_drivers="sdl"
751 HOST_VARIANT_DIR="openbsd"
753 Darwin)
754 bsd="yes"
755 darwin="yes"
756 hax="yes"
757 hvf="yes"
758 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
759 if [ "$cpu" = "x86_64" ] ; then
760 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
761 LDFLAGS="-arch x86_64 $LDFLAGS"
763 cocoa="yes"
764 audio_drv_list="coreaudio"
765 audio_possible_drivers="coreaudio sdl"
766 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
767 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
768 # Disable attempts to use ObjectiveC features in os/object.h since they
769 # won't work when we're compiling with gcc as a C compiler.
770 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
771 HOST_VARIANT_DIR="darwin"
772 supported_os="yes"
774 SunOS)
775 solaris="yes"
776 make="${MAKE-gmake}"
777 install="${INSTALL-ginstall}"
778 smbd="${SMBD-/usr/sfw/sbin/smbd}"
779 if test -f /usr/include/sys/soundcard.h ; then
780 audio_drv_list="oss"
782 audio_possible_drivers="oss sdl"
783 # needed for CMSG_ macros in sys/socket.h
784 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
785 # needed for TIOCWIN* defines in termios.h
786 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
787 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
788 solarisnetlibs="-lsocket -lnsl -lresolv"
789 LIBS="$solarisnetlibs $LIBS"
790 libs_qga="$solarisnetlibs $libs_qga"
792 Haiku)
793 haiku="yes"
794 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
795 LIBS="-lposix_error_mapper -lnetwork $LIBS"
797 Linux)
798 audio_drv_list="oss"
799 audio_possible_drivers="oss alsa sdl pa"
800 linux="yes"
801 linux_user="yes"
802 kvm="yes"
803 vhost_net="yes"
804 vhost_scsi="yes"
805 vhost_vsock="yes"
806 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
807 supported_os="yes"
809 esac
811 if [ "$bsd" = "yes" ] ; then
812 if [ "$darwin" != "yes" ] ; then
813 bsd_user="yes"
817 : ${make=${MAKE-make}}
818 : ${install=${INSTALL-install}}
819 : ${python=${PYTHON-python}}
820 : ${smbd=${SMBD-/usr/sbin/smbd}}
822 # Default objcc to clang if available, otherwise use CC
823 if has clang; then
824 objcc=clang
825 else
826 objcc="$cc"
829 if test "$mingw32" = "yes" ; then
830 EXESUF=".exe"
831 DSOSUF=".dll"
832 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
833 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
834 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
835 # MinGW needs -mthreads for TLS and macro _MT.
836 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
837 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
838 write_c_skeleton;
839 if compile_prog "" "-liberty" ; then
840 LIBS="-liberty $LIBS"
842 prefix="c:/Program Files/QEMU"
843 mandir="\${prefix}"
844 datadir="\${prefix}"
845 qemu_docdir="\${prefix}"
846 bindir="\${prefix}"
847 sysconfdir="\${prefix}"
848 local_statedir=
849 confsuffix=""
850 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
853 werror=""
855 for opt do
856 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
857 case "$opt" in
858 --help|-h) show_help=yes
860 --version|-V) exec cat $source_path/VERSION
862 --prefix=*) prefix="$optarg"
864 --interp-prefix=*) interp_prefix="$optarg"
866 --source-path=*)
868 --cross-prefix=*)
870 --cc=*)
872 --host-cc=*) host_cc="$optarg"
874 --cxx=*)
876 --iasl=*) iasl="$optarg"
878 --objcc=*) objcc="$optarg"
880 --make=*) make="$optarg"
882 --install=*) install="$optarg"
884 --python=*) python="$optarg"
886 --gcov=*) gcov_tool="$optarg"
888 --smbd=*) smbd="$optarg"
890 --extra-cflags=*)
892 --extra-cxxflags=*)
894 --extra-ldflags=*)
896 --enable-debug-info)
898 --disable-debug-info)
900 --enable-modules)
901 modules="yes"
903 --disable-modules)
904 modules="no"
906 --cpu=*)
908 --target-list=*) target_list="$optarg"
910 --enable-trace-backends=*) trace_backends="$optarg"
912 # XXX: backwards compatibility
913 --enable-trace-backend=*) trace_backends="$optarg"
915 --with-trace-file=*) trace_file="$optarg"
917 --enable-gprof) gprof="yes"
919 --enable-gcov) gcov="yes"
921 --static)
922 static="yes"
923 LDFLAGS="-static $LDFLAGS"
924 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
926 --mandir=*) mandir="$optarg"
928 --bindir=*) bindir="$optarg"
930 --libdir=*) libdir="$optarg"
932 --libexecdir=*) libexecdir="$optarg"
934 --includedir=*) includedir="$optarg"
936 --datadir=*) datadir="$optarg"
938 --with-confsuffix=*) confsuffix="$optarg"
940 --docdir=*) qemu_docdir="$optarg"
942 --sysconfdir=*) sysconfdir="$optarg"
944 --localstatedir=*) local_statedir="$optarg"
946 --firmwarepath=*) firmwarepath="$optarg"
948 --sbindir=*|--sharedstatedir=*|\
949 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
950 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
951 # These switches are silently ignored, for compatibility with
952 # autoconf-generated configure scripts. This allows QEMU's
953 # configure to be used by RPM and similar macros that set
954 # lots of directory switches by default.
956 --disable-sdl) sdl="no"
958 --enable-sdl) sdl="yes"
960 --with-sdlabi=*) sdlabi="$optarg"
962 --disable-qom-cast-debug) qom_cast_debug="no"
964 --enable-qom-cast-debug) qom_cast_debug="yes"
966 --disable-virtfs) virtfs="no"
968 --enable-virtfs) virtfs="yes"
970 --disable-mpath) mpath="no"
972 --enable-mpath) mpath="yes"
974 --disable-vnc) vnc="no"
976 --enable-vnc) vnc="yes"
978 --oss-lib=*) oss_lib="$optarg"
980 --audio-drv-list=*) audio_drv_list="$optarg"
982 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
984 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
986 --enable-debug-tcg) debug_tcg="yes"
988 --disable-debug-tcg) debug_tcg="no"
990 --enable-debug)
991 # Enable debugging options that aren't excessively noisy
992 debug_tcg="yes"
993 debug="yes"
994 strip_opt="no"
995 fortify_source="no"
997 --enable-sanitizers) sanitizers="yes"
999 --disable-sanitizers) sanitizers="no"
1001 --enable-sparse) sparse="yes"
1003 --disable-sparse) sparse="no"
1005 --disable-strip) strip_opt="no"
1007 --disable-vnc-sasl) vnc_sasl="no"
1009 --enable-vnc-sasl) vnc_sasl="yes"
1011 --disable-vnc-jpeg) vnc_jpeg="no"
1013 --enable-vnc-jpeg) vnc_jpeg="yes"
1015 --disable-vnc-png) vnc_png="no"
1017 --enable-vnc-png) vnc_png="yes"
1019 --disable-slirp) slirp="no"
1021 --disable-vde) vde="no"
1023 --enable-vde) vde="yes"
1025 --disable-netmap) netmap="no"
1027 --enable-netmap) netmap="yes"
1029 --disable-xen) xen="no"
1031 --enable-xen) xen="yes"
1033 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1035 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1037 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
1039 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
1041 --disable-brlapi) brlapi="no"
1043 --enable-brlapi) brlapi="yes"
1045 --disable-bluez) bluez="no"
1047 --enable-bluez) bluez="yes"
1049 --disable-kvm) kvm="no"
1051 --enable-kvm) kvm="yes"
1053 --disable-hax) hax="no"
1055 --enable-hax) hax="yes"
1057 --disable-hvf) hvf="no"
1059 --enable-hvf) hvf="yes"
1061 --disable-tcg-interpreter) tcg_interpreter="no"
1063 --enable-tcg-interpreter) tcg_interpreter="yes"
1065 --disable-cap-ng) cap_ng="no"
1067 --enable-cap-ng) cap_ng="yes"
1069 --disable-tcg) tcg="no"
1071 --enable-tcg) tcg="yes"
1073 --disable-malloc-trim) malloc_trim="no"
1075 --enable-malloc-trim) malloc_trim="yes"
1077 --disable-spice) spice="no"
1079 --enable-spice) spice="yes"
1081 --disable-libiscsi) libiscsi="no"
1083 --enable-libiscsi) libiscsi="yes"
1085 --disable-libnfs) libnfs="no"
1087 --enable-libnfs) libnfs="yes"
1089 --enable-profiler) profiler="yes"
1091 --disable-cocoa) cocoa="no"
1093 --enable-cocoa)
1094 cocoa="yes" ;
1095 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1097 --disable-system) softmmu="no"
1099 --enable-system) softmmu="yes"
1101 --disable-user)
1102 linux_user="no" ;
1103 bsd_user="no" ;
1105 --enable-user) ;;
1106 --disable-linux-user) linux_user="no"
1108 --enable-linux-user) linux_user="yes"
1110 --disable-bsd-user) bsd_user="no"
1112 --enable-bsd-user) bsd_user="yes"
1114 --enable-pie) pie="yes"
1116 --disable-pie) pie="no"
1118 --enable-werror) werror="yes"
1120 --disable-werror) werror="no"
1122 --enable-stack-protector) stack_protector="yes"
1124 --disable-stack-protector) stack_protector="no"
1126 --disable-curses) curses="no"
1128 --enable-curses) curses="yes"
1130 --disable-curl) curl="no"
1132 --enable-curl) curl="yes"
1134 --disable-fdt) fdt="no"
1136 --enable-fdt) fdt="yes"
1138 --disable-linux-aio) linux_aio="no"
1140 --enable-linux-aio) linux_aio="yes"
1142 --disable-attr) attr="no"
1144 --enable-attr) attr="yes"
1146 --disable-blobs) blobs="no"
1148 --with-pkgversion=*) pkgversion=" ($optarg)"
1150 --with-coroutine=*) coroutine="$optarg"
1152 --disable-coroutine-pool) coroutine_pool="no"
1154 --enable-coroutine-pool) coroutine_pool="yes"
1156 --enable-debug-stack-usage) debug_stack_usage="yes"
1158 --enable-crypto-afalg) crypto_afalg="yes"
1160 --disable-crypto-afalg) crypto_afalg="no"
1162 --disable-docs) docs="no"
1164 --enable-docs) docs="yes"
1166 --disable-vhost-net) vhost_net="no"
1168 --enable-vhost-net) vhost_net="yes"
1170 --disable-vhost-scsi) vhost_scsi="no"
1172 --enable-vhost-scsi) vhost_scsi="yes"
1174 --disable-vhost-vsock) vhost_vsock="no"
1176 --enable-vhost-vsock) vhost_vsock="yes"
1178 --disable-opengl) opengl="no"
1180 --enable-opengl) opengl="yes"
1182 --disable-rbd) rbd="no"
1184 --enable-rbd) rbd="yes"
1186 --disable-xfsctl) xfs="no"
1188 --enable-xfsctl) xfs="yes"
1190 --disable-smartcard) smartcard="no"
1192 --enable-smartcard) smartcard="yes"
1194 --disable-libusb) libusb="no"
1196 --enable-libusb) libusb="yes"
1198 --disable-usb-redir) usb_redir="no"
1200 --enable-usb-redir) usb_redir="yes"
1202 --disable-zlib-test) zlib="no"
1204 --disable-lzo) lzo="no"
1206 --enable-lzo) lzo="yes"
1208 --disable-snappy) snappy="no"
1210 --enable-snappy) snappy="yes"
1212 --disable-bzip2) bzip2="no"
1214 --enable-bzip2) bzip2="yes"
1216 --enable-guest-agent) guest_agent="yes"
1218 --disable-guest-agent) guest_agent="no"
1220 --enable-guest-agent-msi) guest_agent_msi="yes"
1222 --disable-guest-agent-msi) guest_agent_msi="no"
1224 --with-vss-sdk) vss_win32_sdk=""
1226 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1228 --without-vss-sdk) vss_win32_sdk="no"
1230 --with-win-sdk) win_sdk=""
1232 --with-win-sdk=*) win_sdk="$optarg"
1234 --without-win-sdk) win_sdk="no"
1236 --enable-tools) want_tools="yes"
1238 --disable-tools) want_tools="no"
1240 --enable-seccomp) seccomp="yes"
1242 --disable-seccomp) seccomp="no"
1244 --disable-glusterfs) glusterfs="no"
1246 --enable-glusterfs) glusterfs="yes"
1248 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1249 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1251 --enable-vhdx|--disable-vhdx)
1252 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1254 --enable-uuid|--disable-uuid)
1255 echo "$0: $opt is obsolete, UUID support is always built" >&2
1257 --disable-gtk) gtk="no"
1259 --enable-gtk) gtk="yes"
1261 --tls-priority=*) tls_priority="$optarg"
1263 --disable-gnutls) gnutls="no"
1265 --enable-gnutls) gnutls="yes"
1267 --disable-nettle) nettle="no"
1269 --enable-nettle) nettle="yes"
1271 --disable-gcrypt) gcrypt="no"
1273 --enable-gcrypt) gcrypt="yes"
1275 --enable-rdma) rdma="yes"
1277 --disable-rdma) rdma="no"
1279 --with-gtkabi=*) gtkabi="$optarg"
1281 --disable-vte) vte="no"
1283 --enable-vte) vte="yes"
1285 --disable-virglrenderer) virglrenderer="no"
1287 --enable-virglrenderer) virglrenderer="yes"
1289 --disable-tpm) tpm="no"
1291 --enable-tpm) tpm="yes"
1293 --disable-libssh2) libssh2="no"
1295 --enable-libssh2) libssh2="yes"
1297 --disable-live-block-migration) live_block_migration="no"
1299 --enable-live-block-migration) live_block_migration="yes"
1301 --disable-numa) numa="no"
1303 --enable-numa) numa="yes"
1305 --disable-libxml2) libxml2="no"
1307 --enable-libxml2) libxml2="yes"
1309 --disable-tcmalloc) tcmalloc="no"
1311 --enable-tcmalloc) tcmalloc="yes"
1313 --disable-jemalloc) jemalloc="no"
1315 --enable-jemalloc) jemalloc="yes"
1317 --disable-replication) replication="no"
1319 --enable-replication) replication="yes"
1321 --disable-vxhs) vxhs="no"
1323 --enable-vxhs) vxhs="yes"
1325 --disable-vhost-user) vhost_user="no"
1327 --enable-vhost-user)
1328 vhost_user="yes"
1329 if test "$mingw32" = "yes"; then
1330 error_exit "vhost-user isn't available on win32"
1333 --disable-capstone) capstone="no"
1335 --enable-capstone) capstone="yes"
1337 --enable-capstone=git) capstone="git"
1339 --enable-capstone=system) capstone="system"
1341 --with-git=*) git="$optarg"
1343 --enable-git-update) git_update=yes
1345 --disable-git-update) git_update=no
1348 echo "ERROR: unknown option $opt"
1349 echo "Try '$0 --help' for more information"
1350 exit 1
1352 esac
1353 done
1355 if test "$vhost_user" = ""; then
1356 if test "$mingw32" = "yes"; then
1357 vhost_user="no"
1358 else
1359 vhost_user="yes"
1363 case "$cpu" in
1364 ppc)
1365 CPU_CFLAGS="-m32"
1366 LDFLAGS="-m32 $LDFLAGS"
1368 ppc64)
1369 CPU_CFLAGS="-m64"
1370 LDFLAGS="-m64 $LDFLAGS"
1372 sparc)
1373 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1374 LDFLAGS="-m32 -mv8plus $LDFLAGS"
1376 sparc64)
1377 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1378 LDFLAGS="-m64 $LDFLAGS"
1380 s390)
1381 CPU_CFLAGS="-m31"
1382 LDFLAGS="-m31 $LDFLAGS"
1384 s390x)
1385 CPU_CFLAGS="-m64"
1386 LDFLAGS="-m64 $LDFLAGS"
1388 i386)
1389 CPU_CFLAGS="-m32"
1390 LDFLAGS="-m32 $LDFLAGS"
1391 cc_i386='$(CC) -m32'
1393 x86_64)
1394 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1395 # If we truly care, we should simply detect this case at
1396 # runtime and generate the fallback to serial emulation.
1397 CPU_CFLAGS="-m64 -mcx16"
1398 LDFLAGS="-m64 $LDFLAGS"
1399 cc_i386='$(CC) -m32'
1401 x32)
1402 CPU_CFLAGS="-mx32"
1403 LDFLAGS="-mx32 $LDFLAGS"
1404 cc_i386='$(CC) -m32'
1406 # No special flags required for other host CPUs
1407 esac
1409 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1410 EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1412 # For user-mode emulation the host arch has to be one we explicitly
1413 # support, even if we're using TCI.
1414 if [ "$ARCH" = "unknown" ]; then
1415 bsd_user="no"
1416 linux_user="no"
1419 default_target_list=""
1421 mak_wilds=""
1423 if [ "$softmmu" = "yes" ]; then
1424 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1426 if [ "$linux_user" = "yes" ]; then
1427 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1429 if [ "$bsd_user" = "yes" ]; then
1430 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1433 for config in $mak_wilds; do
1434 default_target_list="${default_target_list} $(basename "$config" .mak)"
1435 done
1437 # Enumerate public trace backends for --help output
1438 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1440 if test x"$show_help" = x"yes" ; then
1441 cat << EOF
1443 Usage: configure [options]
1444 Options: [defaults in brackets after descriptions]
1446 Standard options:
1447 --help print this message
1448 --prefix=PREFIX install in PREFIX [$prefix]
1449 --interp-prefix=PREFIX where to find shared libraries, etc.
1450 use %M for cpu name [$interp_prefix]
1451 --target-list=LIST set target list (default: build everything)
1452 $(echo Available targets: $default_target_list | \
1453 fold -s -w 53 | sed -e 's/^/ /')
1455 Advanced options (experts only):
1456 --source-path=PATH path of source code [$source_path]
1457 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1458 --cc=CC use C compiler CC [$cc]
1459 --iasl=IASL use ACPI compiler IASL [$iasl]
1460 --host-cc=CC use C compiler CC [$host_cc] for code run at
1461 build time
1462 --cxx=CXX use C++ compiler CXX [$cxx]
1463 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1464 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1465 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1466 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1467 --make=MAKE use specified make [$make]
1468 --install=INSTALL use specified install [$install]
1469 --python=PYTHON use specified python [$python]
1470 --smbd=SMBD use specified smbd [$smbd]
1471 --static enable static build [$static]
1472 --mandir=PATH install man pages in PATH
1473 --datadir=PATH install firmware in PATH$confsuffix
1474 --docdir=PATH install documentation in PATH$confsuffix
1475 --bindir=PATH install binaries in PATH
1476 --libdir=PATH install libraries in PATH
1477 --sysconfdir=PATH install config in PATH$confsuffix
1478 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1479 --firmwarepath=PATH search PATH for firmware files
1480 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1481 --enable-debug enable common debug build options
1482 --enable-sanitizers enable default sanitizers
1483 --disable-strip disable stripping binaries
1484 --disable-werror disable compilation abort on warning
1485 --disable-stack-protector disable compiler-provided stack protection
1486 --audio-drv-list=LIST set audio drivers list:
1487 Available drivers: $audio_possible_drivers
1488 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1489 --block-drv-rw-whitelist=L
1490 set block driver read-write whitelist
1491 (affects only QEMU, not qemu-img)
1492 --block-drv-ro-whitelist=L
1493 set block driver read-only whitelist
1494 (affects only QEMU, not qemu-img)
1495 --enable-trace-backends=B Set trace backend
1496 Available backends: $trace_backend_list
1497 --with-trace-file=NAME Full PATH,NAME of file to store traces
1498 Default:trace-<pid>
1499 --disable-slirp disable SLIRP userspace network connectivity
1500 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1501 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1502 --oss-lib path to OSS library
1503 --cpu=CPU Build for host CPU [$cpu]
1504 --with-coroutine=BACKEND coroutine backend. Supported options:
1505 ucontext, sigaltstack, windows
1506 --enable-gcov enable test coverage analysis with gcov
1507 --gcov=GCOV use specified gcov [$gcov_tool]
1508 --disable-blobs disable installing provided firmware blobs
1509 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1510 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1511 --tls-priority default TLS protocol/cipher priority string
1512 --enable-gprof QEMU profiling with gprof
1513 --enable-profiler profiler support
1514 --enable-xen-pv-domain-build
1515 xen pv domain builder
1516 --enable-debug-stack-usage
1517 track the maximum stack usage of stacks created by qemu_alloc_stack
1519 Optional features, enabled with --enable-FEATURE and
1520 disabled with --disable-FEATURE, default is enabled if available:
1522 system all system emulation targets
1523 user supported user emulation targets
1524 linux-user all linux usermode emulation targets
1525 bsd-user all BSD usermode emulation targets
1526 docs build documentation
1527 guest-agent build the QEMU Guest Agent
1528 guest-agent-msi build guest agent Windows MSI installation package
1529 pie Position Independent Executables
1530 modules modules support
1531 debug-tcg TCG debugging (default is disabled)
1532 debug-info debugging information
1533 sparse sparse checker
1535 gnutls GNUTLS cryptography support
1536 nettle nettle cryptography support
1537 gcrypt libgcrypt cryptography support
1538 sdl SDL UI
1539 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1540 gtk gtk UI
1541 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1542 vte vte support for the gtk UI
1543 curses curses UI
1544 vnc VNC UI support
1545 vnc-sasl SASL encryption for VNC server
1546 vnc-jpeg JPEG lossy compression for VNC server
1547 vnc-png PNG compression for VNC server
1548 cocoa Cocoa UI (Mac OS X only)
1549 virtfs VirtFS
1550 mpath Multipath persistent reservation passthrough
1551 xen xen backend driver support
1552 xen-pci-passthrough
1553 brlapi BrlAPI (Braile)
1554 curl curl connectivity
1555 fdt fdt device tree
1556 bluez bluez stack connectivity
1557 kvm KVM acceleration support
1558 hax HAX acceleration support
1559 hvf Hypervisor.framework acceleration support
1560 rdma RDMA-based migration support
1561 vde support for vde network
1562 netmap support for netmap network
1563 linux-aio Linux AIO support
1564 cap-ng libcap-ng support
1565 attr attr and xattr support
1566 vhost-net vhost-net acceleration support
1567 spice spice
1568 rbd rados block device (rbd)
1569 libiscsi iscsi support
1570 libnfs nfs support
1571 smartcard smartcard support (libcacard)
1572 libusb libusb (for usb passthrough)
1573 live-block-migration Block migration in the main migration stream
1574 usb-redir usb network redirection support
1575 lzo support of lzo compression library
1576 snappy support of snappy compression library
1577 bzip2 support of bzip2 compression library
1578 (for reading bzip2-compressed dmg images)
1579 seccomp seccomp support
1580 coroutine-pool coroutine freelist (better performance)
1581 glusterfs GlusterFS backend
1582 tpm TPM support
1583 libssh2 ssh block device support
1584 numa libnuma support
1585 libxml2 for Parallels image format
1586 tcmalloc tcmalloc support
1587 jemalloc jemalloc support
1588 replication replication support
1589 vhost-vsock virtio sockets device support
1590 opengl opengl support
1591 virglrenderer virgl rendering support
1592 xfsctl xfsctl support
1593 qom-cast-debug cast debugging support
1594 tools build qemu-io, qemu-nbd and qemu-image tools
1595 vxhs Veritas HyperScale vDisk backend support
1596 crypto-afalg Linux AF_ALG crypto backend driver
1597 vhost-user vhost-user support
1598 capstone capstone disassembler support
1600 NOTE: The object files are built at the place where configure is launched
1602 exit 0
1605 if ! has $python; then
1606 error_exit "Python not found. Use --python=/path/to/python"
1609 # Note that if the Python conditional here evaluates True we will exit
1610 # with status 1 which is a shell 'false' value.
1611 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1612 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1613 "Note that Python 3 or later is not yet supported." \
1614 "Use --python=/path/to/python to specify a supported Python."
1617 # Suppress writing compiled files
1618 python="$python -B"
1620 # Check that the C compiler works. Doing this here before testing
1621 # the host CPU ensures that we had a valid CC to autodetect the
1622 # $cpu var (and we should bail right here if that's not the case).
1623 # It also allows the help message to be printed without a CC.
1624 write_c_skeleton;
1625 if compile_object ; then
1626 : C compiler works ok
1627 else
1628 error_exit "\"$cc\" either does not exist or does not work"
1630 if ! compile_prog ; then
1631 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1634 # Now we have handled --enable-tcg-interpreter and know we're not just
1635 # printing the help message, bail out if the host CPU isn't supported.
1636 if test "$ARCH" = "unknown"; then
1637 if test "$tcg_interpreter" = "yes" ; then
1638 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1639 else
1640 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1644 # Consult white-list to determine whether to enable werror
1645 # by default. Only enable by default for git builds
1646 if test -z "$werror" ; then
1647 if test -d "$source_path/.git" -a \
1648 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1649 werror="yes"
1650 else
1651 werror="no"
1655 if test "$bogus_os" = "yes"; then
1656 # Now that we know that we're not printing the help and that
1657 # the compiler works (so the results of the check_defines we used
1658 # to identify the OS are reliable), if we didn't recognize the
1659 # host OS we should stop now.
1660 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1663 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1664 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1665 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1666 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1667 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1668 gcc_flags="-Wno-string-plus-int $gcc_flags"
1669 # Note that we do not add -Werror to gcc_flags here, because that would
1670 # enable it for all configure tests. If a configure test failed due
1671 # to -Werror this would just silently disable some features,
1672 # so it's too error prone.
1674 cc_has_warning_flag() {
1675 write_c_skeleton;
1677 # Use the positive sense of the flag when testing for -Wno-wombat
1678 # support (gcc will happily accept the -Wno- form of unknown
1679 # warning options).
1680 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1681 compile_prog "-Werror $optflag" ""
1684 for flag in $gcc_flags; do
1685 if cc_has_warning_flag $flag ; then
1686 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1688 done
1690 if test "$stack_protector" != "no"; then
1691 cat > $TMPC << EOF
1692 int main(int argc, char *argv[])
1694 char arr[64], *p = arr, *c = argv[0];
1695 while (*c) {
1696 *p++ = *c++;
1698 return 0;
1701 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1702 sp_on=0
1703 for flag in $gcc_flags; do
1704 # We need to check both a compile and a link, since some compiler
1705 # setups fail only on a .c->.o compile and some only at link time
1706 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1707 compile_prog "-Werror $flag" ""; then
1708 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1709 sp_on=1
1710 break
1712 done
1713 if test "$stack_protector" = yes; then
1714 if test $sp_on = 0; then
1715 error_exit "Stack protector not supported"
1720 # Disable -Wmissing-braces on older compilers that warn even for
1721 # the "universal" C zero initializer {0}.
1722 cat > $TMPC << EOF
1723 struct {
1724 int a[2];
1725 } x = {0};
1727 if compile_object "-Werror" "" ; then
1729 else
1730 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1733 # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1734 # large functions that use global variables. The bug is in all releases of
1735 # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1736 # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1737 cat > $TMPC << EOF
1738 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1739 int main(void) { return 0; }
1740 #else
1741 #error No bug in this compiler.
1742 #endif
1744 if compile_prog "-Werror -fno-gcse" "" ; then
1745 TRANSLATE_OPT_CFLAGS=-fno-gcse
1748 if test "$static" = "yes" ; then
1749 if test "$modules" = "yes" ; then
1750 error_exit "static and modules are mutually incompatible"
1752 if test "$pie" = "yes" ; then
1753 error_exit "static and pie are mutually incompatible"
1754 else
1755 pie="no"
1759 # Unconditional check for compiler __thread support
1760 cat > $TMPC << EOF
1761 static __thread int tls_var;
1762 int main(void) { return tls_var; }
1765 if ! compile_prog "-Werror" "" ; then
1766 error_exit "Your compiler does not support the __thread specifier for " \
1767 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1770 if test "$pie" = ""; then
1771 case "$cpu-$targetos" in
1772 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1775 pie="no"
1777 esac
1780 if test "$pie" != "no" ; then
1781 cat > $TMPC << EOF
1783 #ifdef __linux__
1784 # define THREAD __thread
1785 #else
1786 # define THREAD
1787 #endif
1789 static THREAD int tls_var;
1791 int main(void) { return tls_var; }
1794 if compile_prog "-fPIE -DPIE" "-pie"; then
1795 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1796 LDFLAGS="-pie $LDFLAGS"
1797 pie="yes"
1798 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1799 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1801 else
1802 if test "$pie" = "yes"; then
1803 error_exit "PIE not available due to missing toolchain support"
1804 else
1805 echo "Disabling PIE due to missing toolchain support"
1806 pie="no"
1810 if compile_prog "-Werror -fno-pie" "-nopie"; then
1811 CFLAGS_NOPIE="-fno-pie"
1812 LDFLAGS_NOPIE="-nopie"
1816 ##########################################
1817 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1818 # use i686 as default anyway, but for those that don't, an explicit
1819 # specification is necessary
1821 if test "$cpu" = "i386"; then
1822 cat > $TMPC << EOF
1823 static int sfaa(int *ptr)
1825 return __sync_fetch_and_and(ptr, 0);
1828 int main(void)
1830 int val = 42;
1831 val = __sync_val_compare_and_swap(&val, 0, 1);
1832 sfaa(&val);
1833 return val;
1836 if ! compile_prog "" "" ; then
1837 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1841 #########################################
1842 # Solaris specific configure tool chain decisions
1844 if test "$solaris" = "yes" ; then
1845 if has $install; then
1847 else
1848 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1849 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1850 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1852 if test "$(path_of $install)" = "/usr/sbin/install" ; then
1853 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1854 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1855 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1857 if has ar; then
1859 else
1860 if test -f /usr/ccs/bin/ar ; then
1861 error_exit "No path includes ar" \
1862 "Add /usr/ccs/bin to your path and rerun configure"
1864 error_exit "No path includes ar"
1868 if test -z "${target_list+xxx}" ; then
1869 for target in $default_target_list; do
1870 supported_target $target 2>/dev/null && \
1871 target_list="$target_list $target"
1872 done
1873 target_list="${target_list# }"
1874 else
1875 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1876 for target in $target_list; do
1877 # Check that we recognised the target name; this allows a more
1878 # friendly error message than if we let it fall through.
1879 case " $default_target_list " in
1880 *" $target "*)
1883 error_exit "Unknown target name '$target'"
1885 esac
1886 supported_target $target || exit 1
1887 done
1890 # see if system emulation was really requested
1891 case " $target_list " in
1892 *"-softmmu "*) softmmu=yes
1894 *) softmmu=no
1896 esac
1898 feature_not_found() {
1899 feature=$1
1900 remedy=$2
1902 error_exit "User requested feature $feature" \
1903 "configure was not able to find it." \
1904 "$remedy"
1907 # ---
1908 # big/little endian test
1909 cat > $TMPC << EOF
1910 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1911 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1912 extern int foo(short *, short *);
1913 int main(int argc, char *argv[]) {
1914 return foo(big_endian, little_endian);
1918 if compile_object ; then
1919 if grep -q BiGeNdIaN $TMPO ; then
1920 bigendian="yes"
1921 elif grep -q LiTtLeEnDiAn $TMPO ; then
1922 bigendian="no"
1923 else
1924 echo big/little test failed
1926 else
1927 echo big/little test failed
1930 ##########################################
1931 # cocoa implies not SDL or GTK
1932 # (the cocoa UI code currently assumes it is always the active UI
1933 # and doesn't interact well with other UI frontend code)
1934 if test "$cocoa" = "yes"; then
1935 if test "$sdl" = "yes"; then
1936 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1938 if test "$gtk" = "yes"; then
1939 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1941 gtk=no
1942 sdl=no
1945 # Some versions of Mac OS X incorrectly define SIZE_MAX
1946 cat > $TMPC << EOF
1947 #include <stdint.h>
1948 #include <stdio.h>
1949 int main(int argc, char *argv[]) {
1950 return printf("%zu", SIZE_MAX);
1953 have_broken_size_max=no
1954 if ! compile_object -Werror ; then
1955 have_broken_size_max=yes
1958 ##########################################
1959 # L2TPV3 probe
1961 cat > $TMPC <<EOF
1962 #include <sys/socket.h>
1963 #include <linux/ip.h>
1964 int main(void) { return sizeof(struct mmsghdr); }
1966 if compile_prog "" "" ; then
1967 l2tpv3=yes
1968 else
1969 l2tpv3=no
1972 ##########################################
1973 # MinGW / Mingw-w64 localtime_r/gmtime_r check
1975 if test "$mingw32" = "yes"; then
1976 # Some versions of MinGW / Mingw-w64 lack localtime_r
1977 # and gmtime_r entirely.
1979 # Some versions of Mingw-w64 define a macro for
1980 # localtime_r/gmtime_r.
1982 # Some versions of Mingw-w64 will define functions
1983 # for localtime_r/gmtime_r, but only if you have
1984 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1985 # though, unistd.h and pthread.h both define
1986 # that for you.
1988 # So this #undef localtime_r and #include <unistd.h>
1989 # are not in fact redundant.
1990 cat > $TMPC << EOF
1991 #include <unistd.h>
1992 #include <time.h>
1993 #undef localtime_r
1994 int main(void) { localtime_r(NULL, NULL); return 0; }
1996 if compile_prog "" "" ; then
1997 localtime_r="yes"
1998 else
1999 localtime_r="no"
2003 ##########################################
2004 # pkg-config probe
2006 if ! has "$pkg_config_exe"; then
2007 error_exit "pkg-config binary '$pkg_config_exe' not found"
2010 ##########################################
2011 # NPTL probe
2013 if test "$linux_user" = "yes"; then
2014 cat > $TMPC <<EOF
2015 #include <sched.h>
2016 #include <linux/futex.h>
2017 int main(void) {
2018 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2019 #error bork
2020 #endif
2021 return 0;
2024 if ! compile_object ; then
2025 feature_not_found "nptl" "Install glibc and linux kernel headers."
2029 #########################################
2030 # zlib check
2032 if test "$zlib" != "no" ; then
2033 cat > $TMPC << EOF
2034 #include <zlib.h>
2035 int main(void) { zlibVersion(); return 0; }
2037 if compile_prog "" "-lz" ; then
2039 else
2040 error_exit "zlib check failed" \
2041 "Make sure to have the zlib libs and headers installed."
2044 LIBS="$LIBS -lz"
2046 ##########################################
2047 # lzo check
2049 if test "$lzo" != "no" ; then
2050 cat > $TMPC << EOF
2051 #include <lzo/lzo1x.h>
2052 int main(void) { lzo_version(); return 0; }
2054 if compile_prog "" "-llzo2" ; then
2055 libs_softmmu="$libs_softmmu -llzo2"
2056 lzo="yes"
2057 else
2058 if test "$lzo" = "yes"; then
2059 feature_not_found "liblzo2" "Install liblzo2 devel"
2061 lzo="no"
2065 ##########################################
2066 # snappy check
2068 if test "$snappy" != "no" ; then
2069 cat > $TMPC << EOF
2070 #include <snappy-c.h>
2071 int main(void) { snappy_max_compressed_length(4096); return 0; }
2073 if compile_prog "" "-lsnappy" ; then
2074 libs_softmmu="$libs_softmmu -lsnappy"
2075 snappy="yes"
2076 else
2077 if test "$snappy" = "yes"; then
2078 feature_not_found "libsnappy" "Install libsnappy devel"
2080 snappy="no"
2084 ##########################################
2085 # bzip2 check
2087 if test "$bzip2" != "no" ; then
2088 cat > $TMPC << EOF
2089 #include <bzlib.h>
2090 int main(void) { BZ2_bzlibVersion(); return 0; }
2092 if compile_prog "" "-lbz2" ; then
2093 bzip2="yes"
2094 else
2095 if test "$bzip2" = "yes"; then
2096 feature_not_found "libbzip2" "Install libbzip2 devel"
2098 bzip2="no"
2102 ##########################################
2103 # libseccomp check
2105 if test "$seccomp" != "no" ; then
2106 case "$cpu" in
2107 i386|x86_64)
2108 libseccomp_minver="2.1.0"
2110 mips)
2111 libseccomp_minver="2.2.0"
2113 arm|aarch64)
2114 libseccomp_minver="2.2.3"
2116 ppc|ppc64|s390x)
2117 libseccomp_minver="2.3.0"
2120 libseccomp_minver=""
2122 esac
2124 if test "$libseccomp_minver" != "" &&
2125 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2126 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2127 seccomp_libs="$($pkg_config --libs libseccomp)"
2128 seccomp="yes"
2129 else
2130 if test "$seccomp" = "yes" ; then
2131 if test "$libseccomp_minver" != "" ; then
2132 feature_not_found "libseccomp" \
2133 "Install libseccomp devel >= $libseccomp_minver"
2134 else
2135 feature_not_found "libseccomp" \
2136 "libseccomp is not supported for host cpu $cpu"
2139 seccomp="no"
2142 ##########################################
2143 # xen probe
2145 if test "$xen" != "no" ; then
2146 # Check whether Xen library path is specified via --extra-ldflags to avoid
2147 # overriding this setting with pkg-config output. If not, try pkg-config
2148 # to obtain all needed flags.
2150 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2151 $pkg_config --exists xencontrol ; then
2152 xen_ctrl_version="$(printf '%d%02d%02d' \
2153 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2154 xen=yes
2155 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2156 xen_pc="$xen_pc xenevtchn xendevicemodel"
2157 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2158 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2159 LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2160 else
2162 xen_libs="-lxenstore -lxenctrl -lxenguest"
2163 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2165 # First we test whether Xen headers and libraries are available.
2166 # If no, we are done and there is no Xen support.
2167 # If yes, more tests are run to detect the Xen version.
2169 # Xen (any)
2170 cat > $TMPC <<EOF
2171 #include <xenctrl.h>
2172 int main(void) {
2173 return 0;
2176 if ! compile_prog "" "$xen_libs" ; then
2177 # Xen not found
2178 if test "$xen" = "yes" ; then
2179 feature_not_found "xen" "Install xen devel"
2181 xen=no
2183 # Xen unstable
2184 elif
2185 cat > $TMPC <<EOF &&
2186 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2187 #include <xenforeignmemory.h>
2188 int main(void) {
2189 xenforeignmemory_handle *xfmem;
2191 xfmem = xenforeignmemory_open(0, 0);
2192 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2194 return 0;
2197 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2198 then
2199 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2200 xen_ctrl_version=41000
2201 xen=yes
2202 elif
2203 cat > $TMPC <<EOF &&
2204 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2205 #define __XEN_TOOLS__
2206 #include <xendevicemodel.h>
2207 int main(void) {
2208 xendevicemodel_handle *xd;
2210 xd = xendevicemodel_open(0, 0);
2211 xendevicemodel_close(xd);
2213 return 0;
2216 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2217 then
2218 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2219 xen_ctrl_version=40900
2220 xen=yes
2221 elif
2222 cat > $TMPC <<EOF &&
2224 * If we have stable libs the we don't want the libxc compat
2225 * layers, regardless of what CFLAGS we may have been given.
2227 * Also, check if xengnttab_grant_copy_segment_t is defined and
2228 * grant copy operation is implemented.
2230 #undef XC_WANT_COMPAT_EVTCHN_API
2231 #undef XC_WANT_COMPAT_GNTTAB_API
2232 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2233 #include <xenctrl.h>
2234 #include <xenstore.h>
2235 #include <xenevtchn.h>
2236 #include <xengnttab.h>
2237 #include <xenforeignmemory.h>
2238 #include <stdint.h>
2239 #include <xen/hvm/hvm_info_table.h>
2240 #if !defined(HVM_MAX_VCPUS)
2241 # error HVM_MAX_VCPUS not defined
2242 #endif
2243 int main(void) {
2244 xc_interface *xc = NULL;
2245 xenforeignmemory_handle *xfmem;
2246 xenevtchn_handle *xe;
2247 xengnttab_handle *xg;
2248 xen_domain_handle_t handle;
2249 xengnttab_grant_copy_segment_t* seg = NULL;
2251 xs_daemon_open();
2253 xc = xc_interface_open(0, 0, 0);
2254 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2255 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2256 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2257 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2258 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2260 xfmem = xenforeignmemory_open(0, 0);
2261 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2263 xe = xenevtchn_open(0, 0);
2264 xenevtchn_fd(xe);
2266 xg = xengnttab_open(0, 0);
2267 xengnttab_grant_copy(xg, 0, seg);
2269 return 0;
2272 compile_prog "" "$xen_libs $xen_stable_libs"
2273 then
2274 xen_ctrl_version=40800
2275 xen=yes
2276 elif
2277 cat > $TMPC <<EOF &&
2279 * If we have stable libs the we don't want the libxc compat
2280 * layers, regardless of what CFLAGS we may have been given.
2282 #undef XC_WANT_COMPAT_EVTCHN_API
2283 #undef XC_WANT_COMPAT_GNTTAB_API
2284 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2285 #include <xenctrl.h>
2286 #include <xenstore.h>
2287 #include <xenevtchn.h>
2288 #include <xengnttab.h>
2289 #include <xenforeignmemory.h>
2290 #include <stdint.h>
2291 #include <xen/hvm/hvm_info_table.h>
2292 #if !defined(HVM_MAX_VCPUS)
2293 # error HVM_MAX_VCPUS not defined
2294 #endif
2295 int main(void) {
2296 xc_interface *xc = NULL;
2297 xenforeignmemory_handle *xfmem;
2298 xenevtchn_handle *xe;
2299 xengnttab_handle *xg;
2300 xen_domain_handle_t handle;
2302 xs_daemon_open();
2304 xc = xc_interface_open(0, 0, 0);
2305 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2306 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2307 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2308 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2309 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2311 xfmem = xenforeignmemory_open(0, 0);
2312 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2314 xe = xenevtchn_open(0, 0);
2315 xenevtchn_fd(xe);
2317 xg = xengnttab_open(0, 0);
2318 xengnttab_map_grant_ref(xg, 0, 0, 0);
2320 return 0;
2323 compile_prog "" "$xen_libs $xen_stable_libs"
2324 then
2325 xen_ctrl_version=40701
2326 xen=yes
2327 elif
2328 cat > $TMPC <<EOF &&
2329 #include <xenctrl.h>
2330 #include <stdint.h>
2331 int main(void) {
2332 xc_interface *xc = NULL;
2333 xen_domain_handle_t handle;
2334 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2335 return 0;
2338 compile_prog "" "$xen_libs"
2339 then
2340 xen_ctrl_version=40700
2341 xen=yes
2343 # Xen 4.6
2344 elif
2345 cat > $TMPC <<EOF &&
2346 #include <xenctrl.h>
2347 #include <xenstore.h>
2348 #include <stdint.h>
2349 #include <xen/hvm/hvm_info_table.h>
2350 #if !defined(HVM_MAX_VCPUS)
2351 # error HVM_MAX_VCPUS not defined
2352 #endif
2353 int main(void) {
2354 xc_interface *xc;
2355 xs_daemon_open();
2356 xc = xc_interface_open(0, 0, 0);
2357 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2358 xc_gnttab_open(NULL, 0);
2359 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2360 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2361 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2362 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2363 return 0;
2366 compile_prog "" "$xen_libs"
2367 then
2368 xen_ctrl_version=40600
2369 xen=yes
2371 # Xen 4.5
2372 elif
2373 cat > $TMPC <<EOF &&
2374 #include <xenctrl.h>
2375 #include <xenstore.h>
2376 #include <stdint.h>
2377 #include <xen/hvm/hvm_info_table.h>
2378 #if !defined(HVM_MAX_VCPUS)
2379 # error HVM_MAX_VCPUS not defined
2380 #endif
2381 int main(void) {
2382 xc_interface *xc;
2383 xs_daemon_open();
2384 xc = xc_interface_open(0, 0, 0);
2385 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2386 xc_gnttab_open(NULL, 0);
2387 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2388 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2389 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2390 return 0;
2393 compile_prog "" "$xen_libs"
2394 then
2395 xen_ctrl_version=40500
2396 xen=yes
2398 elif
2399 cat > $TMPC <<EOF &&
2400 #include <xenctrl.h>
2401 #include <xenstore.h>
2402 #include <stdint.h>
2403 #include <xen/hvm/hvm_info_table.h>
2404 #if !defined(HVM_MAX_VCPUS)
2405 # error HVM_MAX_VCPUS not defined
2406 #endif
2407 int main(void) {
2408 xc_interface *xc;
2409 xs_daemon_open();
2410 xc = xc_interface_open(0, 0, 0);
2411 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2412 xc_gnttab_open(NULL, 0);
2413 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2414 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2415 return 0;
2418 compile_prog "" "$xen_libs"
2419 then
2420 xen_ctrl_version=40200
2421 xen=yes
2423 else
2424 if test "$xen" = "yes" ; then
2425 feature_not_found "xen (unsupported version)" \
2426 "Install a supported xen (xen 4.2 or newer)"
2428 xen=no
2431 if test "$xen" = yes; then
2432 if test $xen_ctrl_version -ge 40701 ; then
2433 libs_softmmu="$xen_stable_libs $libs_softmmu"
2435 libs_softmmu="$xen_libs $libs_softmmu"
2440 if test "$xen_pci_passthrough" != "no"; then
2441 if test "$xen" = "yes" && test "$linux" = "yes"; then
2442 xen_pci_passthrough=yes
2443 else
2444 if test "$xen_pci_passthrough" = "yes"; then
2445 error_exit "User requested feature Xen PCI Passthrough" \
2446 " but this feature requires /sys from Linux"
2448 xen_pci_passthrough=no
2452 if test "$xen_pv_domain_build" = "yes" &&
2453 test "$xen" != "yes"; then
2454 error_exit "User requested Xen PV domain builder support" \
2455 "which requires Xen support."
2458 ##########################################
2459 # Sparse probe
2460 if test "$sparse" != "no" ; then
2461 if has cgcc; then
2462 sparse=yes
2463 else
2464 if test "$sparse" = "yes" ; then
2465 feature_not_found "sparse" "Install sparse binary"
2467 sparse=no
2471 ##########################################
2472 # X11 probe
2473 x11_cflags=
2474 x11_libs=-lX11
2475 if $pkg_config --exists "x11"; then
2476 x11_cflags=$($pkg_config --cflags x11)
2477 x11_libs=$($pkg_config --libs x11)
2480 ##########################################
2481 # GTK probe
2483 if test "$gtkabi" = ""; then
2484 # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
2485 # Use 2.0 as a fallback if that is available.
2486 if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2487 gtkabi=3.0
2488 elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2489 gtkabi=2.0
2490 else
2491 gtkabi=3.0
2495 if test "$gtk" != "no"; then
2496 gtkpackage="gtk+-$gtkabi"
2497 gtkx11package="gtk+-x11-$gtkabi"
2498 if test "$gtkabi" = "3.0" ; then
2499 gtkversion="3.0.0"
2500 else
2501 gtkversion="2.18.0"
2503 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2504 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2505 gtk_libs=$($pkg_config --libs $gtkpackage)
2506 gtk_version=$($pkg_config --modversion $gtkpackage)
2507 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2508 gtk_cflags="$gtk_cflags $x11_cflags"
2509 gtk_libs="$gtk_libs $x11_libs"
2511 libs_softmmu="$gtk_libs $libs_softmmu"
2512 gtk="yes"
2513 elif test "$gtk" = "yes"; then
2514 feature_not_found "gtk" "Install gtk3-devel"
2515 else
2516 gtk="no"
2521 ##########################################
2522 # GNUTLS probe
2524 gnutls_works() {
2525 # Unfortunately some distros have bad pkg-config information for gnutls
2526 # such that it claims to exist but you get a compiler error if you try
2527 # to use the options returned by --libs. Specifically, Ubuntu for --static
2528 # builds doesn't work:
2529 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2531 # So sanity check the cflags/libs before assuming gnutls can be used.
2532 if ! $pkg_config --exists "gnutls"; then
2533 return 1
2536 write_c_skeleton
2537 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2540 gnutls_gcrypt=no
2541 gnutls_nettle=no
2542 if test "$gnutls" != "no"; then
2543 if gnutls_works; then
2544 gnutls_cflags=$($pkg_config --cflags gnutls)
2545 gnutls_libs=$($pkg_config --libs gnutls)
2546 libs_softmmu="$gnutls_libs $libs_softmmu"
2547 libs_tools="$gnutls_libs $libs_tools"
2548 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2549 gnutls="yes"
2551 # gnutls_rnd requires >= 2.11.0
2552 if $pkg_config --exists "gnutls >= 2.11.0"; then
2553 gnutls_rnd="yes"
2554 else
2555 gnutls_rnd="no"
2558 if $pkg_config --exists 'gnutls >= 3.0'; then
2559 gnutls_gcrypt=no
2560 gnutls_nettle=yes
2561 elif $pkg_config --exists 'gnutls >= 2.12'; then
2562 case $($pkg_config --libs --static gnutls) in
2563 *gcrypt*)
2564 gnutls_gcrypt=yes
2565 gnutls_nettle=no
2567 *nettle*)
2568 gnutls_gcrypt=no
2569 gnutls_nettle=yes
2572 gnutls_gcrypt=yes
2573 gnutls_nettle=no
2575 esac
2576 else
2577 gnutls_gcrypt=yes
2578 gnutls_nettle=no
2580 elif test "$gnutls" = "yes"; then
2581 feature_not_found "gnutls" "Install gnutls devel"
2582 else
2583 gnutls="no"
2584 gnutls_rnd="no"
2586 else
2587 gnutls_rnd="no"
2591 # If user didn't give a --disable/enable-gcrypt flag,
2592 # then mark as disabled if user requested nettle
2593 # explicitly, or if gnutls links to nettle
2594 if test -z "$gcrypt"
2595 then
2596 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2597 then
2598 gcrypt="no"
2602 # If user didn't give a --disable/enable-nettle flag,
2603 # then mark as disabled if user requested gcrypt
2604 # explicitly, or if gnutls links to gcrypt
2605 if test -z "$nettle"
2606 then
2607 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2608 then
2609 nettle="no"
2613 has_libgcrypt_config() {
2614 if ! has "libgcrypt-config"
2615 then
2616 return 1
2619 if test -n "$cross_prefix"
2620 then
2621 host=$(libgcrypt-config --host)
2622 if test "$host-" != $cross_prefix
2623 then
2624 return 1
2628 return 0
2631 if test "$gcrypt" != "no"; then
2632 if has_libgcrypt_config; then
2633 gcrypt_cflags=$(libgcrypt-config --cflags)
2634 gcrypt_libs=$(libgcrypt-config --libs)
2635 # Debian has remove -lgpg-error from libgcrypt-config
2636 # as it "spreads unnecessary dependencies" which in
2637 # turn breaks static builds...
2638 if test "$static" = "yes"
2639 then
2640 gcrypt_libs="$gcrypt_libs -lgpg-error"
2642 libs_softmmu="$gcrypt_libs $libs_softmmu"
2643 libs_tools="$gcrypt_libs $libs_tools"
2644 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2645 gcrypt="yes"
2646 if test -z "$nettle"; then
2647 nettle="no"
2650 cat > $TMPC << EOF
2651 #include <gcrypt.h>
2652 int main(void) {
2653 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2654 GCRY_MD_SHA256,
2655 NULL, 0, 0, 0, NULL);
2656 return 0;
2659 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2660 gcrypt_kdf=yes
2663 cat > $TMPC << EOF
2664 #include <gcrypt.h>
2665 int main(void) {
2666 gcry_mac_hd_t handle;
2667 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2668 GCRY_MAC_FLAG_SECURE, NULL);
2669 return 0;
2672 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2673 gcrypt_hmac=yes
2675 else
2676 if test "$gcrypt" = "yes"; then
2677 feature_not_found "gcrypt" "Install gcrypt devel"
2678 else
2679 gcrypt="no"
2685 if test "$nettle" != "no"; then
2686 if $pkg_config --exists "nettle"; then
2687 nettle_cflags=$($pkg_config --cflags nettle)
2688 nettle_libs=$($pkg_config --libs nettle)
2689 nettle_version=$($pkg_config --modversion nettle)
2690 libs_softmmu="$nettle_libs $libs_softmmu"
2691 libs_tools="$nettle_libs $libs_tools"
2692 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2693 nettle="yes"
2695 cat > $TMPC << EOF
2696 #include <stddef.h>
2697 #include <nettle/pbkdf2.h>
2698 int main(void) {
2699 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2700 return 0;
2703 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2704 nettle_kdf=yes
2706 else
2707 if test "$nettle" = "yes"; then
2708 feature_not_found "nettle" "Install nettle devel"
2709 else
2710 nettle="no"
2715 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2716 then
2717 error_exit "Only one of gcrypt & nettle can be enabled"
2720 ##########################################
2721 # libtasn1 - only for the TLS creds/session test suite
2723 tasn1=yes
2724 tasn1_cflags=""
2725 tasn1_libs=""
2726 if $pkg_config --exists "libtasn1"; then
2727 tasn1_cflags=$($pkg_config --cflags libtasn1)
2728 tasn1_libs=$($pkg_config --libs libtasn1)
2729 else
2730 tasn1=no
2734 ##########################################
2735 # getifaddrs (for tests/test-io-channel-socket )
2737 have_ifaddrs_h=yes
2738 if ! check_include "ifaddrs.h" ; then
2739 have_ifaddrs_h=no
2742 ##########################################
2743 # VTE probe
2745 if test "$vte" != "no"; then
2746 if test "$gtkabi" = "3.0"; then
2747 vteminversion="0.32.0"
2748 if $pkg_config --exists "vte-2.91"; then
2749 vtepackage="vte-2.91"
2750 else
2751 vtepackage="vte-2.90"
2753 else
2754 vtepackage="vte"
2755 vteminversion="0.24.0"
2757 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2758 vte_cflags=$($pkg_config --cflags $vtepackage)
2759 vte_libs=$($pkg_config --libs $vtepackage)
2760 vteversion=$($pkg_config --modversion $vtepackage)
2761 libs_softmmu="$vte_libs $libs_softmmu"
2762 vte="yes"
2763 elif test "$vte" = "yes"; then
2764 if test "$gtkabi" = "3.0"; then
2765 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2766 else
2767 feature_not_found "vte" "Install libvte devel"
2769 else
2770 vte="no"
2774 ##########################################
2775 # SDL probe
2777 # Look for sdl configuration program (pkg-config or sdl-config). Try
2778 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2780 if test "$sdlabi" = ""; then
2781 if $pkg_config --exists "sdl2"; then
2782 sdlabi=2.0
2783 elif $pkg_config --exists "sdl"; then
2784 sdlabi=1.2
2785 else
2786 sdlabi=2.0
2790 if test $sdlabi = "2.0"; then
2791 sdl_config=$sdl2_config
2792 sdlname=sdl2
2793 sdlconfigname=sdl2_config
2794 elif test $sdlabi = "1.2"; then
2795 sdlname=sdl
2796 sdlconfigname=sdl_config
2797 else
2798 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2801 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2802 sdl_config=$sdlconfigname
2805 if $pkg_config $sdlname --exists; then
2806 sdlconfig="$pkg_config $sdlname"
2807 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2808 elif has ${sdl_config}; then
2809 sdlconfig="$sdl_config"
2810 sdlversion=$($sdlconfig --version)
2811 else
2812 if test "$sdl" = "yes" ; then
2813 feature_not_found "sdl" "Install SDL2-devel"
2815 sdl=no
2817 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2818 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2821 sdl_too_old=no
2822 if test "$sdl" != "no" ; then
2823 cat > $TMPC << EOF
2824 #include <SDL.h>
2825 #undef main /* We don't want SDL to override our main() */
2826 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2828 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2829 if test "$static" = "yes" ; then
2830 if $pkg_config $sdlname --exists; then
2831 sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
2832 else
2833 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2835 else
2836 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2838 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2839 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
2840 sdl_too_old=yes
2841 else
2842 sdl=yes
2845 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2846 if test "$sdl" = "yes" -a "$static" = "yes" ; then
2847 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2848 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2849 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2851 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2853 else
2854 sdl=no
2856 fi # static link
2857 else # sdl not found
2858 if test "$sdl" = "yes" ; then
2859 feature_not_found "sdl" "Install SDL devel"
2861 sdl=no
2862 fi # sdl compile test
2865 if test "$sdl" = "yes" ; then
2866 cat > $TMPC <<EOF
2867 #include <SDL.h>
2868 #if defined(SDL_VIDEO_DRIVER_X11)
2869 #include <X11/XKBlib.h>
2870 #else
2871 #error No x11 support
2872 #endif
2873 int main(void) { return 0; }
2875 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2876 sdl_cflags="$sdl_cflags $x11_cflags"
2877 sdl_libs="$sdl_libs $x11_libs"
2881 ##########################################
2882 # RDMA needs OpenFabrics libraries
2883 if test "$rdma" != "no" ; then
2884 cat > $TMPC <<EOF
2885 #include <rdma/rdma_cma.h>
2886 int main(void) { return 0; }
2888 rdma_libs="-lrdmacm -libverbs"
2889 if compile_prog "" "$rdma_libs" ; then
2890 rdma="yes"
2891 else
2892 if test "$rdma" = "yes" ; then
2893 error_exit \
2894 " OpenFabrics librdmacm/libibverbs not present." \
2895 " Your options:" \
2896 " (1) Fast: Install infiniband packages from your distro." \
2897 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2898 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2900 rdma="no"
2905 ##########################################
2906 # VNC SASL detection
2907 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
2908 cat > $TMPC <<EOF
2909 #include <sasl/sasl.h>
2910 #include <stdio.h>
2911 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2913 # Assuming Cyrus-SASL installed in /usr prefix
2914 vnc_sasl_cflags=""
2915 vnc_sasl_libs="-lsasl2"
2916 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2917 vnc_sasl=yes
2918 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2919 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
2920 else
2921 if test "$vnc_sasl" = "yes" ; then
2922 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2924 vnc_sasl=no
2928 ##########################################
2929 # VNC JPEG detection
2930 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2931 cat > $TMPC <<EOF
2932 #include <stdio.h>
2933 #include <jpeglib.h>
2934 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2936 vnc_jpeg_cflags=""
2937 vnc_jpeg_libs="-ljpeg"
2938 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2939 vnc_jpeg=yes
2940 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2941 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2942 else
2943 if test "$vnc_jpeg" = "yes" ; then
2944 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2946 vnc_jpeg=no
2950 ##########################################
2951 # VNC PNG detection
2952 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2953 cat > $TMPC <<EOF
2954 //#include <stdio.h>
2955 #include <png.h>
2956 #include <stddef.h>
2957 int main(void) {
2958 png_structp png_ptr;
2959 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
2960 return png_ptr != 0;
2963 if $pkg_config libpng --exists; then
2964 vnc_png_cflags=$($pkg_config libpng --cflags)
2965 vnc_png_libs=$($pkg_config libpng --libs)
2966 else
2967 vnc_png_cflags=""
2968 vnc_png_libs="-lpng"
2970 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2971 vnc_png=yes
2972 libs_softmmu="$vnc_png_libs $libs_softmmu"
2973 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2974 else
2975 if test "$vnc_png" = "yes" ; then
2976 feature_not_found "vnc-png" "Install libpng devel"
2978 vnc_png=no
2982 ##########################################
2983 # xkbcommon probe
2984 if test "$xkbcommon" != "no" ; then
2985 if $pkg_config xkbcommon --exists; then
2986 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
2987 xkbcommon_libs=$($pkg_config xkbcommon --libs)
2988 xkbcommon=yes
2989 else
2990 if test "$xkbcommon" = "yes" ; then
2991 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
2993 xkbcommon=no
2997 ##########################################
2998 # fnmatch() probe, used for ACL routines
2999 fnmatch="no"
3000 cat > $TMPC << EOF
3001 #include <fnmatch.h>
3002 int main(void)
3004 fnmatch("foo", "foo", 0);
3005 return 0;
3008 if compile_prog "" "" ; then
3009 fnmatch="yes"
3012 ##########################################
3013 # xfsctl() probe, used for file-posix.c
3014 if test "$xfs" != "no" ; then
3015 cat > $TMPC << EOF
3016 #include <stddef.h> /* NULL */
3017 #include <xfs/xfs.h>
3018 int main(void)
3020 xfsctl(NULL, 0, 0, NULL);
3021 return 0;
3024 if compile_prog "" "" ; then
3025 xfs="yes"
3026 else
3027 if test "$xfs" = "yes" ; then
3028 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3030 xfs=no
3034 ##########################################
3035 # vde libraries probe
3036 if test "$vde" != "no" ; then
3037 vde_libs="-lvdeplug"
3038 cat > $TMPC << EOF
3039 #include <libvdeplug.h>
3040 int main(void)
3042 struct vde_open_args a = {0, 0, 0};
3043 char s[] = "";
3044 vde_open(s, s, &a);
3045 return 0;
3048 if compile_prog "" "$vde_libs" ; then
3049 vde=yes
3050 else
3051 if test "$vde" = "yes" ; then
3052 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3054 vde=no
3058 ##########################################
3059 # netmap support probe
3060 # Apart from looking for netmap headers, we make sure that the host API version
3061 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3062 # a minor/major version number. Minor new features will be marked with values up
3063 # to 15, and if something happens that requires a change to the backend we will
3064 # move above 15, submit the backend fixes and modify this two bounds.
3065 if test "$netmap" != "no" ; then
3066 cat > $TMPC << EOF
3067 #include <inttypes.h>
3068 #include <net/if.h>
3069 #include <net/netmap.h>
3070 #include <net/netmap_user.h>
3071 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3072 #error
3073 #endif
3074 int main(void) { return 0; }
3076 if compile_prog "" "" ; then
3077 netmap=yes
3078 else
3079 if test "$netmap" = "yes" ; then
3080 feature_not_found "netmap"
3082 netmap=no
3086 ##########################################
3087 # libcap-ng library probe
3088 if test "$cap_ng" != "no" ; then
3089 cap_libs="-lcap-ng"
3090 cat > $TMPC << EOF
3091 #include <cap-ng.h>
3092 int main(void)
3094 capng_capability_to_name(CAPNG_EFFECTIVE);
3095 return 0;
3098 if compile_prog "" "$cap_libs" ; then
3099 cap_ng=yes
3100 libs_tools="$cap_libs $libs_tools"
3101 else
3102 if test "$cap_ng" = "yes" ; then
3103 feature_not_found "cap_ng" "Install libcap-ng devel"
3105 cap_ng=no
3109 ##########################################
3110 # Sound support libraries probe
3112 audio_drv_probe()
3114 drv=$1
3115 hdr=$2
3116 lib=$3
3117 exp=$4
3118 cfl=$5
3119 cat > $TMPC << EOF
3120 #include <$hdr>
3121 int main(void) { $exp }
3123 if compile_prog "$cfl" "$lib" ; then
3125 else
3126 error_exit "$drv check failed" \
3127 "Make sure to have the $drv libs and headers installed."
3131 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3132 for drv in $audio_drv_list; do
3133 case $drv in
3134 alsa)
3135 audio_drv_probe $drv alsa/asoundlib.h -lasound \
3136 "return snd_pcm_close((snd_pcm_t *)0);"
3137 alsa_libs="-lasound"
3141 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3142 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3143 pulse_libs="-lpulse"
3144 audio_pt_int="yes"
3147 sdl)
3148 if test "$sdl" = "no"; then
3149 error_exit "sdl not found or disabled, can not use sdl audio driver"
3153 coreaudio)
3154 coreaudio_libs="-framework CoreAudio"
3157 dsound)
3158 dsound_libs="-lole32 -ldxguid"
3159 audio_win_int="yes"
3162 oss)
3163 oss_libs="$oss_lib"
3166 wav)
3167 # XXX: Probes for CoreAudio, DirectSound
3171 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3172 error_exit "Unknown driver '$drv' selected" \
3173 "Possible drivers are: $audio_possible_drivers"
3176 esac
3177 done
3179 ##########################################
3180 # BrlAPI probe
3182 if test "$brlapi" != "no" ; then
3183 brlapi_libs="-lbrlapi"
3184 cat > $TMPC << EOF
3185 #include <brlapi.h>
3186 #include <stddef.h>
3187 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3189 if compile_prog "" "$brlapi_libs" ; then
3190 brlapi=yes
3191 else
3192 if test "$brlapi" = "yes" ; then
3193 feature_not_found "brlapi" "Install brlapi devel"
3195 brlapi=no
3199 ##########################################
3200 # curses probe
3201 if test "$curses" != "no" ; then
3202 if test "$mingw32" = "yes" ; then
3203 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3204 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3205 else
3206 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3207 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3209 curses_found=no
3210 cat > $TMPC << EOF
3211 #include <locale.h>
3212 #include <curses.h>
3213 #include <wchar.h>
3214 int main(void) {
3215 wchar_t wch = L'w';
3216 setlocale(LC_ALL, "");
3217 resize_term(0, 0);
3218 addwstr(L"wide chars\n");
3219 addnwstr(&wch, 1);
3220 add_wch(WACS_DEGREE);
3221 return 0;
3224 IFS=:
3225 for curses_inc in $curses_inc_list; do
3226 # Make sure we get the wide character prototypes
3227 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3228 IFS=:
3229 for curses_lib in $curses_lib_list; do
3230 unset IFS
3231 if compile_prog "$curses_inc" "$curses_lib" ; then
3232 curses_found=yes
3233 QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
3234 libs_softmmu="$curses_lib $libs_softmmu"
3235 break
3237 done
3238 if test "$curses_found" = yes ; then
3239 break
3241 done
3242 unset IFS
3243 if test "$curses_found" = "yes" ; then
3244 curses=yes
3245 else
3246 if test "$curses" = "yes" ; then
3247 feature_not_found "curses" "Install ncurses devel"
3249 curses=no
3253 ##########################################
3254 # curl probe
3255 if test "$curl" != "no" ; then
3256 if $pkg_config libcurl --exists; then
3257 curlconfig="$pkg_config libcurl"
3258 else
3259 curlconfig=curl-config
3261 cat > $TMPC << EOF
3262 #include <curl/curl.h>
3263 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3265 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3266 curl_libs=$($curlconfig --libs 2>/dev/null)
3267 if compile_prog "$curl_cflags" "$curl_libs" ; then
3268 curl=yes
3269 else
3270 if test "$curl" = "yes" ; then
3271 feature_not_found "curl" "Install libcurl devel"
3273 curl=no
3275 fi # test "$curl"
3277 ##########################################
3278 # bluez support probe
3279 if test "$bluez" != "no" ; then
3280 cat > $TMPC << EOF
3281 #include <bluetooth/bluetooth.h>
3282 int main(void) { return bt_error(0); }
3284 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3285 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3286 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3287 bluez=yes
3288 libs_softmmu="$bluez_libs $libs_softmmu"
3289 else
3290 if test "$bluez" = "yes" ; then
3291 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3293 bluez="no"
3297 ##########################################
3298 # glib support probe
3300 if test "$mingw32" = yes; then
3301 glib_req_ver=2.30
3302 else
3303 glib_req_ver=2.22
3305 glib_modules=gthread-2.0
3306 if test "$modules" = yes; then
3307 glib_modules="$glib_modules gmodule-2.0"
3310 # This workaround is required due to a bug in pkg-config file for glib as it
3311 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3313 if test "$static" = yes -a "$mingw32" = yes; then
3314 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3317 for i in $glib_modules; do
3318 if $pkg_config --atleast-version=$glib_req_ver $i; then
3319 glib_cflags=$($pkg_config --cflags $i)
3320 glib_libs=$($pkg_config --libs $i)
3321 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3322 LIBS="$glib_libs $LIBS"
3323 libs_qga="$glib_libs $libs_qga"
3324 else
3325 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3327 done
3329 # Sanity check that the current size_t matches the
3330 # size that glib thinks it should be. This catches
3331 # problems on multi-arch where people try to build
3332 # 32-bit QEMU while pointing at 64-bit glib headers
3333 cat > $TMPC <<EOF
3334 #include <glib.h>
3335 #include <unistd.h>
3337 #define QEMU_BUILD_BUG_ON(x) \
3338 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3340 int main(void) {
3341 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3342 return 0;
3346 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3347 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3348 "You probably need to set PKG_CONFIG_LIBDIR"\
3349 "to point to the right pkg-config files for your"\
3350 "build target"
3353 # g_test_trap_subprocess added in 2.38. Used by some tests.
3354 glib_subprocess=yes
3355 if ! $pkg_config --atleast-version=2.38 glib-2.0; then
3356 glib_subprocess=no
3359 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3360 cat > $TMPC << EOF
3361 #include <glib.h>
3362 int main(void) { return 0; }
3364 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3365 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3366 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3367 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3371 ##########################################
3372 # SHA command probe for modules
3373 if test "$modules" = yes; then
3374 shacmd_probe="sha1sum sha1 shasum"
3375 for c in $shacmd_probe; do
3376 if has $c; then
3377 shacmd="$c"
3378 break
3380 done
3381 if test "$shacmd" = ""; then
3382 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3386 ##########################################
3387 # pixman support probe
3389 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3390 pixman_cflags=
3391 pixman_libs=
3392 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3393 pixman_cflags=$($pkg_config --cflags pixman-1)
3394 pixman_libs=$($pkg_config --libs pixman-1)
3395 else
3396 error_exit "pixman >= 0.21.8 not present." \
3397 "Please install the pixman devel package."
3400 ##########################################
3401 # libmpathpersist probe
3403 if test "$mpath" != "no" ; then
3404 cat > $TMPC <<EOF
3405 #include <libudev.h>
3406 #include <mpath_persist.h>
3407 unsigned mpath_mx_alloc_len = 1024;
3408 int logsink;
3409 static struct config *multipath_conf;
3410 extern struct udev *udev;
3411 extern struct config *get_multipath_config(void);
3412 extern void put_multipath_config(struct config *conf);
3413 struct udev *udev;
3414 struct config *get_multipath_config(void) { return multipath_conf; }
3415 void put_multipath_config(struct config *conf) { }
3417 int main(void) {
3418 udev = udev_new();
3419 multipath_conf = mpath_lib_init();
3420 return 0;
3423 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3424 mpathpersist=yes
3425 else
3426 mpathpersist=no
3428 else
3429 mpathpersist=no
3432 ##########################################
3433 # libcap probe
3435 if test "$cap" != "no" ; then
3436 cat > $TMPC <<EOF
3437 #include <stdio.h>
3438 #include <sys/capability.h>
3439 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3441 if compile_prog "" "-lcap" ; then
3442 cap=yes
3443 else
3444 cap=no
3448 ##########################################
3449 # pthread probe
3450 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3452 pthread=no
3453 cat > $TMPC << EOF
3454 #include <pthread.h>
3455 static void *f(void *p) { return NULL; }
3456 int main(void) {
3457 pthread_t thread;
3458 pthread_create(&thread, 0, f, 0);
3459 return 0;
3462 if compile_prog "" "" ; then
3463 pthread=yes
3464 else
3465 for pthread_lib in $PTHREADLIBS_LIST; do
3466 if compile_prog "" "$pthread_lib" ; then
3467 pthread=yes
3468 found=no
3469 for lib_entry in $LIBS; do
3470 if test "$lib_entry" = "$pthread_lib"; then
3471 found=yes
3472 break
3474 done
3475 if test "$found" = "no"; then
3476 LIBS="$pthread_lib $LIBS"
3477 libs_qga="$pthread_lib $libs_qga"
3479 PTHREAD_LIB="$pthread_lib"
3480 break
3482 done
3485 if test "$mingw32" != yes -a "$pthread" = no; then
3486 error_exit "pthread check failed" \
3487 "Make sure to have the pthread libs and headers installed."
3490 # check for pthread_setname_np
3491 pthread_setname_np=no
3492 cat > $TMPC << EOF
3493 #include <pthread.h>
3495 static void *f(void *p) { return NULL; }
3496 int main(void)
3498 pthread_t thread;
3499 pthread_create(&thread, 0, f, 0);
3500 pthread_setname_np(thread, "QEMU");
3501 return 0;
3504 if compile_prog "" "$pthread_lib" ; then
3505 pthread_setname_np=yes
3508 ##########################################
3509 # rbd probe
3510 if test "$rbd" != "no" ; then
3511 cat > $TMPC <<EOF
3512 #include <stdio.h>
3513 #include <rbd/librbd.h>
3514 int main(void) {
3515 rados_t cluster;
3516 rados_create(&cluster, NULL);
3517 return 0;
3520 rbd_libs="-lrbd -lrados"
3521 if compile_prog "" "$rbd_libs" ; then
3522 rbd=yes
3523 else
3524 if test "$rbd" = "yes" ; then
3525 feature_not_found "rados block device" "Install librbd/ceph devel"
3527 rbd=no
3531 ##########################################
3532 # libssh2 probe
3533 min_libssh2_version=1.2.8
3534 if test "$libssh2" != "no" ; then
3535 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3536 libssh2_cflags=$($pkg_config libssh2 --cflags)
3537 libssh2_libs=$($pkg_config libssh2 --libs)
3538 libssh2=yes
3539 else
3540 if test "$libssh2" = "yes" ; then
3541 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3543 libssh2=no
3547 ##########################################
3548 # libssh2_sftp_fsync probe
3550 if test "$libssh2" = "yes"; then
3551 cat > $TMPC <<EOF
3552 #include <stdio.h>
3553 #include <libssh2.h>
3554 #include <libssh2_sftp.h>
3555 int main(void) {
3556 LIBSSH2_SESSION *session;
3557 LIBSSH2_SFTP *sftp;
3558 LIBSSH2_SFTP_HANDLE *sftp_handle;
3559 session = libssh2_session_init ();
3560 sftp = libssh2_sftp_init (session);
3561 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3562 libssh2_sftp_fsync (sftp_handle);
3563 return 0;
3566 # libssh2_cflags/libssh2_libs defined in previous test.
3567 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3568 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3572 ##########################################
3573 # linux-aio probe
3575 if test "$linux_aio" != "no" ; then
3576 cat > $TMPC <<EOF
3577 #include <libaio.h>
3578 #include <sys/eventfd.h>
3579 #include <stddef.h>
3580 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3582 if compile_prog "" "-laio" ; then
3583 linux_aio=yes
3584 else
3585 if test "$linux_aio" = "yes" ; then
3586 feature_not_found "linux AIO" "Install libaio devel"
3588 linux_aio=no
3592 ##########################################
3593 # TPM passthrough is only on x86 Linux
3595 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3596 tpm_passthrough=$tpm
3597 else
3598 tpm_passthrough=no
3601 # TPM emulator is for all posix systems
3602 if test "$mingw32" != "yes"; then
3603 tpm_emulator=$tpm
3604 else
3605 tpm_emulator=no
3607 ##########################################
3608 # attr probe
3610 if test "$attr" != "no" ; then
3611 cat > $TMPC <<EOF
3612 #include <stdio.h>
3613 #include <sys/types.h>
3614 #ifdef CONFIG_LIBATTR
3615 #include <attr/xattr.h>
3616 #else
3617 #include <sys/xattr.h>
3618 #endif
3619 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3621 if compile_prog "" "" ; then
3622 attr=yes
3623 # Older distros have <attr/xattr.h>, and need -lattr:
3624 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3625 attr=yes
3626 LIBS="-lattr $LIBS"
3627 libattr=yes
3628 else
3629 if test "$attr" = "yes" ; then
3630 feature_not_found "ATTR" "Install libc6 or libattr devel"
3632 attr=no
3636 ##########################################
3637 # iovec probe
3638 cat > $TMPC <<EOF
3639 #include <sys/types.h>
3640 #include <sys/uio.h>
3641 #include <unistd.h>
3642 int main(void) { return sizeof(struct iovec); }
3644 iovec=no
3645 if compile_prog "" "" ; then
3646 iovec=yes
3649 ##########################################
3650 # preadv probe
3651 cat > $TMPC <<EOF
3652 #include <sys/types.h>
3653 #include <sys/uio.h>
3654 #include <unistd.h>
3655 int main(void) { return preadv(0, 0, 0, 0); }
3657 preadv=no
3658 if compile_prog "" "" ; then
3659 preadv=yes
3662 ##########################################
3663 # fdt probe
3664 # fdt support is mandatory for at least some target architectures,
3665 # so insist on it if we're building those system emulators.
3666 fdt_required=no
3667 for target in $target_list; do
3668 case $target in
3669 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3670 fdt_required=yes
3672 esac
3673 done
3675 if test "$fdt_required" = "yes"; then
3676 if test "$fdt" = "no"; then
3677 error_exit "fdt disabled but some requested targets require it." \
3678 "You can turn off fdt only if you also disable all the system emulation" \
3679 "targets which need it (by specifying a cut down --target-list)."
3681 fdt=yes
3684 if test "$fdt" != "no" ; then
3685 fdt_libs="-lfdt"
3686 # explicitly check for libfdt_env.h as it is missing in some stable installs
3687 # and test for required functions to make sure we are on a version >= 1.4.2
3688 cat > $TMPC << EOF
3689 #include <libfdt.h>
3690 #include <libfdt_env.h>
3691 int main(void) { fdt_first_subnode(0, 0); return 0; }
3693 if compile_prog "" "$fdt_libs" ; then
3694 # system DTC is good - use it
3695 fdt=yes
3696 else
3697 # have GIT checkout, so activate dtc submodule
3698 if test -e "${source_path}/.git" ; then
3699 git_submodules="${git_submodules} dtc"
3701 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3702 fdt=yes
3703 dtc_internal="yes"
3704 mkdir -p dtc
3705 if [ "$pwd_is_source_path" != "y" ] ; then
3706 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3707 symlink "$source_path/dtc/scripts" "dtc/scripts"
3709 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3710 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3711 elif test "$fdt" = "yes" ; then
3712 # Not a git build & no libfdt found, prompt for system install
3713 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3714 "Please install the DTC (libfdt) devel package"
3715 else
3716 # don't have and don't want
3717 fdt_libs=
3718 fdt=no
3723 libs_softmmu="$libs_softmmu $fdt_libs"
3725 ##########################################
3726 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3728 if test "$opengl" != "no" ; then
3729 opengl_pkgs="epoxy libdrm gbm"
3730 if $pkg_config $opengl_pkgs x11; then
3731 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3732 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3733 opengl=yes
3734 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3735 gtk_gl="yes"
3737 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
3738 else
3739 if test "$opengl" = "yes" ; then
3740 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
3742 opengl_cflags=""
3743 opengl_libs=""
3744 opengl=no
3748 if test "$opengl" = "yes"; then
3749 cat > $TMPC << EOF
3750 #include <epoxy/egl.h>
3751 #ifndef EGL_MESA_image_dma_buf_export
3752 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3753 #endif
3754 int main(void) { return 0; }
3756 if compile_prog "" "" ; then
3757 opengl_dmabuf=yes
3761 ##########################################
3762 # libxml2 probe
3763 if test "$libxml2" != "no" ; then
3764 if $pkg_config --exists libxml-2.0; then
3765 libxml2="yes"
3766 libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3767 libxml2_libs=$($pkg_config --libs libxml-2.0)
3768 else
3769 if test "$libxml2" = "yes"; then
3770 feature_not_found "libxml2" "Install libxml2 devel"
3772 libxml2="no"
3776 ##########################################
3777 # glusterfs probe
3778 if test "$glusterfs" != "no" ; then
3779 if $pkg_config --atleast-version=3 glusterfs-api; then
3780 glusterfs="yes"
3781 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3782 glusterfs_libs=$($pkg_config --libs glusterfs-api)
3783 if $pkg_config --atleast-version=4 glusterfs-api; then
3784 glusterfs_xlator_opt="yes"
3786 if $pkg_config --atleast-version=5 glusterfs-api; then
3787 glusterfs_discard="yes"
3789 if $pkg_config --atleast-version=6 glusterfs-api; then
3790 glusterfs_fallocate="yes"
3791 glusterfs_zerofill="yes"
3793 else
3794 if test "$glusterfs" = "yes" ; then
3795 feature_not_found "GlusterFS backend support" \
3796 "Install glusterfs-api devel >= 3"
3798 glusterfs="no"
3802 # Check for inotify functions when we are building linux-user
3803 # emulator. This is done because older glibc versions don't
3804 # have syscall stubs for these implemented. In that case we
3805 # don't provide them even if kernel supports them.
3807 inotify=no
3808 cat > $TMPC << EOF
3809 #include <sys/inotify.h>
3812 main(void)
3814 /* try to start inotify */
3815 return inotify_init();
3818 if compile_prog "" "" ; then
3819 inotify=yes
3822 inotify1=no
3823 cat > $TMPC << EOF
3824 #include <sys/inotify.h>
3827 main(void)
3829 /* try to start inotify */
3830 return inotify_init1(0);
3833 if compile_prog "" "" ; then
3834 inotify1=yes
3837 # check if pipe2 is there
3838 pipe2=no
3839 cat > $TMPC << EOF
3840 #include <unistd.h>
3841 #include <fcntl.h>
3843 int main(void)
3845 int pipefd[2];
3846 return pipe2(pipefd, O_CLOEXEC);
3849 if compile_prog "" "" ; then
3850 pipe2=yes
3853 # check if accept4 is there
3854 accept4=no
3855 cat > $TMPC << EOF
3856 #include <sys/socket.h>
3857 #include <stddef.h>
3859 int main(void)
3861 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3862 return 0;
3865 if compile_prog "" "" ; then
3866 accept4=yes
3869 # check if tee/splice is there. vmsplice was added same time.
3870 splice=no
3871 cat > $TMPC << EOF
3872 #include <unistd.h>
3873 #include <fcntl.h>
3874 #include <limits.h>
3876 int main(void)
3878 int len, fd = 0;
3879 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3880 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3881 return 0;
3884 if compile_prog "" "" ; then
3885 splice=yes
3888 ##########################################
3889 # libnuma probe
3891 if test "$numa" != "no" ; then
3892 cat > $TMPC << EOF
3893 #include <numa.h>
3894 int main(void) { return numa_available(); }
3897 if compile_prog "" "-lnuma" ; then
3898 numa=yes
3899 libs_softmmu="-lnuma $libs_softmmu"
3900 else
3901 if test "$numa" = "yes" ; then
3902 feature_not_found "numa" "install numactl devel"
3904 numa=no
3908 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3909 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3910 exit 1
3913 # Even if malloc_trim() is available, these non-libc memory allocators
3914 # do not support it.
3915 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
3916 if test "$malloc_trim" = "yes" ; then
3917 echo "Disabling malloc_trim with non-libc memory allocator"
3919 malloc_trim="no"
3922 #######################################
3923 # malloc_trim
3925 if test "$malloc_trim" != "no" ; then
3926 cat > $TMPC << EOF
3927 #include <malloc.h>
3928 int main(void) { malloc_trim(0); return 0; }
3930 if compile_prog "" "" ; then
3931 malloc_trim="yes"
3932 else
3933 malloc_trim="no"
3937 ##########################################
3938 # tcmalloc probe
3940 if test "$tcmalloc" = "yes" ; then
3941 cat > $TMPC << EOF
3942 #include <stdlib.h>
3943 int main(void) { malloc(1); return 0; }
3946 if compile_prog "" "-ltcmalloc" ; then
3947 LIBS="-ltcmalloc $LIBS"
3948 else
3949 feature_not_found "tcmalloc" "install gperftools devel"
3953 ##########################################
3954 # jemalloc probe
3956 if test "$jemalloc" = "yes" ; then
3957 cat > $TMPC << EOF
3958 #include <stdlib.h>
3959 int main(void) { malloc(1); return 0; }
3962 if compile_prog "" "-ljemalloc" ; then
3963 LIBS="-ljemalloc $LIBS"
3964 else
3965 feature_not_found "jemalloc" "install jemalloc devel"
3969 ##########################################
3970 # signalfd probe
3971 signalfd="no"
3972 cat > $TMPC << EOF
3973 #include <unistd.h>
3974 #include <sys/syscall.h>
3975 #include <signal.h>
3976 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3979 if compile_prog "" "" ; then
3980 signalfd=yes
3983 # check if eventfd is supported
3984 eventfd=no
3985 cat > $TMPC << EOF
3986 #include <sys/eventfd.h>
3988 int main(void)
3990 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3993 if compile_prog "" "" ; then
3994 eventfd=yes
3997 # check if memfd is supported
3998 memfd=no
3999 cat > $TMPC << EOF
4000 #include <sys/mman.h>
4002 int main(void)
4004 return memfd_create("foo", MFD_ALLOW_SEALING);
4007 if compile_prog "" "" ; then
4008 memfd=yes
4013 # check for fallocate
4014 fallocate=no
4015 cat > $TMPC << EOF
4016 #include <fcntl.h>
4018 int main(void)
4020 fallocate(0, 0, 0, 0);
4021 return 0;
4024 if compile_prog "" "" ; then
4025 fallocate=yes
4028 # check for fallocate hole punching
4029 fallocate_punch_hole=no
4030 cat > $TMPC << EOF
4031 #include <fcntl.h>
4032 #include <linux/falloc.h>
4034 int main(void)
4036 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4037 return 0;
4040 if compile_prog "" "" ; then
4041 fallocate_punch_hole=yes
4044 # check that fallocate supports range zeroing inside the file
4045 fallocate_zero_range=no
4046 cat > $TMPC << EOF
4047 #include <fcntl.h>
4048 #include <linux/falloc.h>
4050 int main(void)
4052 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4053 return 0;
4056 if compile_prog "" "" ; then
4057 fallocate_zero_range=yes
4060 # check for posix_fallocate
4061 posix_fallocate=no
4062 cat > $TMPC << EOF
4063 #include <fcntl.h>
4065 int main(void)
4067 posix_fallocate(0, 0, 0);
4068 return 0;
4071 if compile_prog "" "" ; then
4072 posix_fallocate=yes
4075 # check for sync_file_range
4076 sync_file_range=no
4077 cat > $TMPC << EOF
4078 #include <fcntl.h>
4080 int main(void)
4082 sync_file_range(0, 0, 0, 0);
4083 return 0;
4086 if compile_prog "" "" ; then
4087 sync_file_range=yes
4090 # check for linux/fiemap.h and FS_IOC_FIEMAP
4091 fiemap=no
4092 cat > $TMPC << EOF
4093 #include <sys/ioctl.h>
4094 #include <linux/fs.h>
4095 #include <linux/fiemap.h>
4097 int main(void)
4099 ioctl(0, FS_IOC_FIEMAP, 0);
4100 return 0;
4103 if compile_prog "" "" ; then
4104 fiemap=yes
4107 # check for dup3
4108 dup3=no
4109 cat > $TMPC << EOF
4110 #include <unistd.h>
4112 int main(void)
4114 dup3(0, 0, 0);
4115 return 0;
4118 if compile_prog "" "" ; then
4119 dup3=yes
4122 # check for ppoll support
4123 ppoll=no
4124 cat > $TMPC << EOF
4125 #include <poll.h>
4127 int main(void)
4129 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4130 ppoll(&pfd, 1, 0, 0);
4131 return 0;
4134 if compile_prog "" "" ; then
4135 ppoll=yes
4138 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4139 prctl_pr_set_timerslack=no
4140 cat > $TMPC << EOF
4141 #include <sys/prctl.h>
4143 int main(void)
4145 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4146 return 0;
4149 if compile_prog "" "" ; then
4150 prctl_pr_set_timerslack=yes
4153 # check for epoll support
4154 epoll=no
4155 cat > $TMPC << EOF
4156 #include <sys/epoll.h>
4158 int main(void)
4160 epoll_create(0);
4161 return 0;
4164 if compile_prog "" "" ; then
4165 epoll=yes
4168 # epoll_create1 is a later addition
4169 # so we must check separately for its presence
4170 epoll_create1=no
4171 cat > $TMPC << EOF
4172 #include <sys/epoll.h>
4174 int main(void)
4176 /* Note that we use epoll_create1 as a value, not as
4177 * a function being called. This is necessary so that on
4178 * old SPARC glibc versions where the function was present in
4179 * the library but not declared in the header file we will
4180 * fail the configure check. (Otherwise we will get a compiler
4181 * warning but not an error, and will proceed to fail the
4182 * qemu compile where we compile with -Werror.)
4184 return (int)(uintptr_t)&epoll_create1;
4187 if compile_prog "" "" ; then
4188 epoll_create1=yes
4191 # check for sendfile support
4192 sendfile=no
4193 cat > $TMPC << EOF
4194 #include <sys/sendfile.h>
4196 int main(void)
4198 return sendfile(0, 0, 0, 0);
4201 if compile_prog "" "" ; then
4202 sendfile=yes
4205 # check for timerfd support (glibc 2.8 and newer)
4206 timerfd=no
4207 cat > $TMPC << EOF
4208 #include <sys/timerfd.h>
4210 int main(void)
4212 return(timerfd_create(CLOCK_REALTIME, 0));
4215 if compile_prog "" "" ; then
4216 timerfd=yes
4219 # check for setns and unshare support
4220 setns=no
4221 cat > $TMPC << EOF
4222 #include <sched.h>
4224 int main(void)
4226 int ret;
4227 ret = setns(0, 0);
4228 ret = unshare(0);
4229 return ret;
4232 if compile_prog "" "" ; then
4233 setns=yes
4236 # clock_adjtime probe
4237 clock_adjtime=no
4238 cat > $TMPC <<EOF
4239 #include <time.h>
4241 int main(void)
4243 return clock_adjtime(0, 0);
4246 clock_adjtime=no
4247 if compile_prog "" "" ; then
4248 clock_adjtime=yes
4251 # syncfs probe
4252 syncfs=no
4253 cat > $TMPC <<EOF
4254 #include <unistd.h>
4256 int main(void)
4258 return syncfs(0);
4261 syncfs=no
4262 if compile_prog "" "" ; then
4263 syncfs=yes
4266 # Check if tools are available to build documentation.
4267 if test "$docs" != "no" ; then
4268 if has makeinfo && has pod2man; then
4269 docs=yes
4270 else
4271 if test "$docs" = "yes" ; then
4272 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4274 docs=no
4278 # Search for bswap_32 function
4279 byteswap_h=no
4280 cat > $TMPC << EOF
4281 #include <byteswap.h>
4282 int main(void) { return bswap_32(0); }
4284 if compile_prog "" "" ; then
4285 byteswap_h=yes
4288 # Search for bswap32 function
4289 bswap_h=no
4290 cat > $TMPC << EOF
4291 #include <sys/endian.h>
4292 #include <sys/types.h>
4293 #include <machine/bswap.h>
4294 int main(void) { return bswap32(0); }
4296 if compile_prog "" "" ; then
4297 bswap_h=yes
4300 ##########################################
4301 # Do we have libiscsi >= 1.9.0
4302 if test "$libiscsi" != "no" ; then
4303 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4304 libiscsi="yes"
4305 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4306 libiscsi_libs=$($pkg_config --libs libiscsi)
4307 else
4308 if test "$libiscsi" = "yes" ; then
4309 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4311 libiscsi="no"
4315 ##########################################
4316 # Do we need libm
4317 cat > $TMPC << EOF
4318 #include <math.h>
4319 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4321 if compile_prog "" "" ; then
4323 elif compile_prog "" "-lm" ; then
4324 LIBS="-lm $LIBS"
4325 libs_qga="-lm $libs_qga"
4326 else
4327 error_exit "libm check failed"
4330 ##########################################
4331 # Do we need librt
4332 # uClibc provides 2 versions of clock_gettime(), one with realtime
4333 # support and one without. This means that the clock_gettime() don't
4334 # need -lrt. We still need it for timer_create() so we check for this
4335 # function in addition.
4336 cat > $TMPC <<EOF
4337 #include <signal.h>
4338 #include <time.h>
4339 int main(void) {
4340 timer_create(CLOCK_REALTIME, NULL, NULL);
4341 return clock_gettime(CLOCK_REALTIME, NULL);
4345 if compile_prog "" "" ; then
4347 # we need pthread for static linking. use previous pthread test result
4348 elif compile_prog "" "$pthread_lib -lrt" ; then
4349 LIBS="$LIBS -lrt"
4350 libs_qga="$libs_qga -lrt"
4353 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4354 "$haiku" != "yes" ; then
4355 libs_softmmu="-lutil $libs_softmmu"
4358 ##########################################
4359 # spice probe
4360 if test "$spice" != "no" ; then
4361 cat > $TMPC << EOF
4362 #include <spice.h>
4363 int main(void) { spice_server_new(); return 0; }
4365 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4366 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4367 if $pkg_config --atleast-version=0.12.0 spice-server && \
4368 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4369 compile_prog "$spice_cflags" "$spice_libs" ; then
4370 spice="yes"
4371 libs_softmmu="$libs_softmmu $spice_libs"
4372 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4373 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4374 spice_server_version=$($pkg_config --modversion spice-server)
4375 else
4376 if test "$spice" = "yes" ; then
4377 feature_not_found "spice" \
4378 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4380 spice="no"
4384 # check for smartcard support
4385 if test "$smartcard" != "no"; then
4386 if $pkg_config libcacard; then
4387 libcacard_cflags=$($pkg_config --cflags libcacard)
4388 libcacard_libs=$($pkg_config --libs libcacard)
4389 smartcard="yes"
4390 else
4391 if test "$smartcard" = "yes"; then
4392 feature_not_found "smartcard" "Install libcacard devel"
4394 smartcard="no"
4398 # check for libusb
4399 if test "$libusb" != "no" ; then
4400 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4401 libusb="yes"
4402 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4403 libusb_libs=$($pkg_config --libs libusb-1.0)
4404 else
4405 if test "$libusb" = "yes"; then
4406 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4408 libusb="no"
4412 # check for usbredirparser for usb network redirection support
4413 if test "$usb_redir" != "no" ; then
4414 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4415 usb_redir="yes"
4416 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4417 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4418 else
4419 if test "$usb_redir" = "yes"; then
4420 feature_not_found "usb-redir" "Install usbredir devel"
4422 usb_redir="no"
4426 ##########################################
4427 # check if we have VSS SDK headers for win
4429 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4430 case "$vss_win32_sdk" in
4431 "") vss_win32_include="-isystem $source_path" ;;
4432 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4433 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4434 vss_win32_include="-isystem $source_path/.sdk/vss"
4435 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4437 *) vss_win32_include="-isystem $vss_win32_sdk"
4438 esac
4439 cat > $TMPC << EOF
4440 #define __MIDL_user_allocate_free_DEFINED__
4441 #include <inc/win2003/vss.h>
4442 int main(void) { return VSS_CTX_BACKUP; }
4444 if compile_prog "$vss_win32_include" "" ; then
4445 guest_agent_with_vss="yes"
4446 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4447 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4448 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4449 else
4450 if test "$vss_win32_sdk" != "" ; then
4451 echo "ERROR: Please download and install Microsoft VSS SDK:"
4452 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4453 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4454 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4455 echo "ERROR: The headers are extracted in the directory \`inc'."
4456 feature_not_found "VSS support"
4458 guest_agent_with_vss="no"
4462 ##########################################
4463 # lookup Windows platform SDK (if not specified)
4464 # The SDK is needed only to build .tlb (type library) file of guest agent
4465 # VSS provider from the source. It is usually unnecessary because the
4466 # pre-compiled .tlb file is included.
4468 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4469 if test -z "$win_sdk"; then
4470 programfiles="$PROGRAMFILES"
4471 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4472 if test -n "$programfiles"; then
4473 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4474 else
4475 feature_not_found "Windows SDK"
4477 elif test "$win_sdk" = "no"; then
4478 win_sdk=""
4482 ##########################################
4483 # check if mingw environment provides a recent ntddscsi.h
4484 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4485 cat > $TMPC << EOF
4486 #include <windows.h>
4487 #include <ntddscsi.h>
4488 int main(void) {
4489 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4490 #error Missing required ioctl definitions
4491 #endif
4492 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4493 return addr.Lun;
4496 if compile_prog "" "" ; then
4497 guest_agent_ntddscsi=yes
4498 libs_qga="-lsetupapi $libs_qga"
4502 ##########################################
4503 # virgl renderer probe
4505 if test "$virglrenderer" != "no" ; then
4506 cat > $TMPC << EOF
4507 #include <virglrenderer.h>
4508 int main(void) { virgl_renderer_poll(); return 0; }
4510 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4511 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4512 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4513 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4514 virglrenderer="yes"
4515 else
4516 if test "$virglrenderer" = "yes" ; then
4517 feature_not_found "virglrenderer"
4519 virglrenderer="no"
4523 ##########################################
4524 # capstone
4526 case "$capstone" in
4527 "" | yes)
4528 if $pkg_config capstone; then
4529 capstone=system
4530 elif test -e "${source_path}/.git" ; then
4531 capstone=git
4532 elif test -e "${source_path}/capstone/Makefile" ; then
4533 capstone=internal
4534 elif test -z "$capstone" ; then
4535 capstone=no
4536 else
4537 feature_not_found "capstone" "Install capstone devel or git submodule"
4541 system)
4542 if ! $pkg_config capstone; then
4543 feature_not_found "capstone" "Install capstone devel"
4546 esac
4548 case "$capstone" in
4549 git | internal)
4550 if test "$capstone" = git; then
4551 git_submodules="${git_submodules} capstone"
4553 mkdir -p capstone
4554 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4555 if test "$mingw32" = "yes"; then
4556 LIBCAPSTONE=capstone.lib
4557 else
4558 LIBCAPSTONE=libcapstone.a
4560 LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4563 system)
4564 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
4565 LIBS="$($pkg_config --libs capstone) $LIBS"
4571 error_exit "Unknown state for capstone: $capstone"
4573 esac
4575 ##########################################
4576 # check if we have fdatasync
4578 fdatasync=no
4579 cat > $TMPC << EOF
4580 #include <unistd.h>
4581 int main(void) {
4582 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4583 return fdatasync(0);
4584 #else
4585 #error Not supported
4586 #endif
4589 if compile_prog "" "" ; then
4590 fdatasync=yes
4593 ##########################################
4594 # check if we have madvise
4596 madvise=no
4597 cat > $TMPC << EOF
4598 #include <sys/types.h>
4599 #include <sys/mman.h>
4600 #include <stddef.h>
4601 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4603 if compile_prog "" "" ; then
4604 madvise=yes
4607 ##########################################
4608 # check if we have posix_madvise
4610 posix_madvise=no
4611 cat > $TMPC << EOF
4612 #include <sys/mman.h>
4613 #include <stddef.h>
4614 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4616 if compile_prog "" "" ; then
4617 posix_madvise=yes
4620 ##########################################
4621 # check if we have posix_syslog
4623 posix_syslog=no
4624 cat > $TMPC << EOF
4625 #include <syslog.h>
4626 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4628 if compile_prog "" "" ; then
4629 posix_syslog=yes
4632 ##########################################
4633 # check if we have sem_timedwait
4635 sem_timedwait=no
4636 cat > $TMPC << EOF
4637 #include <semaphore.h>
4638 int main(void) { return sem_timedwait(0, 0); }
4640 if compile_prog "" "" ; then
4641 sem_timedwait=yes
4644 ##########################################
4645 # check if trace backend exists
4647 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4648 if test "$?" -ne 0 ; then
4649 error_exit "invalid trace backends" \
4650 "Please choose supported trace backends."
4653 ##########################################
4654 # For 'ust' backend, test if ust headers are present
4655 if have_backend "ust"; then
4656 cat > $TMPC << EOF
4657 #include <lttng/tracepoint.h>
4658 int main(void) { return 0; }
4660 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4661 if $pkg_config lttng-ust --exists; then
4662 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4663 else
4664 lttng_ust_libs="-llttng-ust -ldl"
4666 if $pkg_config liburcu-bp --exists; then
4667 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4668 else
4669 urcu_bp_libs="-lurcu-bp"
4672 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4673 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4674 else
4675 error_exit "Trace backend 'ust' missing lttng-ust header files"
4679 ##########################################
4680 # For 'dtrace' backend, test if 'dtrace' command is present
4681 if have_backend "dtrace"; then
4682 if ! has 'dtrace' ; then
4683 error_exit "dtrace command is not found in PATH $PATH"
4685 trace_backend_stap="no"
4686 if has 'stap' ; then
4687 trace_backend_stap="yes"
4691 ##########################################
4692 # check and set a backend for coroutine
4694 # We prefer ucontext, but it's not always possible. The fallback
4695 # is sigcontext. On Windows the only valid backend is the Windows
4696 # specific one.
4698 ucontext_works=no
4699 if test "$darwin" != "yes"; then
4700 cat > $TMPC << EOF
4701 #include <ucontext.h>
4702 #ifdef __stub_makecontext
4703 #error Ignoring glibc stub makecontext which will always fail
4704 #endif
4705 int main(void) { makecontext(0, 0, 0); return 0; }
4707 if compile_prog "" "" ; then
4708 ucontext_works=yes
4712 if test "$coroutine" = ""; then
4713 if test "$mingw32" = "yes"; then
4714 coroutine=win32
4715 elif test "$ucontext_works" = "yes"; then
4716 coroutine=ucontext
4717 else
4718 coroutine=sigaltstack
4720 else
4721 case $coroutine in
4722 windows)
4723 if test "$mingw32" != "yes"; then
4724 error_exit "'windows' coroutine backend only valid for Windows"
4726 # Unfortunately the user visible backend name doesn't match the
4727 # coroutine-*.c filename for this case, so we have to adjust it here.
4728 coroutine=win32
4730 ucontext)
4731 if test "$ucontext_works" != "yes"; then
4732 feature_not_found "ucontext"
4735 sigaltstack)
4736 if test "$mingw32" = "yes"; then
4737 error_exit "only the 'windows' coroutine backend is valid for Windows"
4741 error_exit "unknown coroutine backend $coroutine"
4743 esac
4746 if test "$coroutine_pool" = ""; then
4747 coroutine_pool=yes
4750 if test "$debug_stack_usage" = "yes"; then
4751 if test "$coroutine_pool" = "yes"; then
4752 echo "WARN: disabling coroutine pool for stack usage debugging"
4753 coroutine_pool=no
4758 ##########################################
4759 # check if we have open_by_handle_at
4761 open_by_handle_at=no
4762 cat > $TMPC << EOF
4763 #include <fcntl.h>
4764 #if !defined(AT_EMPTY_PATH)
4765 # error missing definition
4766 #else
4767 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4768 #endif
4770 if compile_prog "" "" ; then
4771 open_by_handle_at=yes
4774 ########################################
4775 # check if we have linux/magic.h
4777 linux_magic_h=no
4778 cat > $TMPC << EOF
4779 #include <linux/magic.h>
4780 int main(void) {
4781 return 0;
4784 if compile_prog "" "" ; then
4785 linux_magic_h=yes
4788 ########################################
4789 # check whether we can disable warning option with a pragma (this is needed
4790 # to silence warnings in the headers of some versions of external libraries).
4791 # This test has to be compiled with -Werror as otherwise an unknown pragma is
4792 # only a warning.
4794 # If we can't selectively disable warning in the code, disable -Werror so that
4795 # the build doesn't fail anyway.
4797 pragma_disable_unused_but_set=no
4798 cat > $TMPC << EOF
4799 #pragma GCC diagnostic push
4800 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4801 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
4802 #pragma GCC diagnostic pop
4804 int main(void) {
4805 return 0;
4808 if compile_prog "-Werror" "" ; then
4809 pragma_diagnostic_available=yes
4810 else
4811 werror=no
4814 ########################################
4815 # check if we have valgrind/valgrind.h
4817 valgrind_h=no
4818 cat > $TMPC << EOF
4819 #include <valgrind/valgrind.h>
4820 int main(void) {
4821 return 0;
4824 if compile_prog "" "" ; then
4825 valgrind_h=yes
4828 ########################################
4829 # check if environ is declared
4831 has_environ=no
4832 cat > $TMPC << EOF
4833 #include <unistd.h>
4834 int main(void) {
4835 environ = 0;
4836 return 0;
4839 if compile_prog "" "" ; then
4840 has_environ=yes
4843 ########################################
4844 # check if cpuid.h is usable.
4846 cat > $TMPC << EOF
4847 #include <cpuid.h>
4848 int main(void) {
4849 unsigned a, b, c, d;
4850 int max = __get_cpuid_max(0, 0);
4852 if (max >= 1) {
4853 __cpuid(1, a, b, c, d);
4856 if (max >= 7) {
4857 __cpuid_count(7, 0, a, b, c, d);
4860 return 0;
4863 if compile_prog "" "" ; then
4864 cpuid_h=yes
4867 ##########################################
4868 # avx2 optimization requirement check
4870 # There is no point enabling this if cpuid.h is not usable,
4871 # since we won't be able to select the new routines.
4873 if test $cpuid_h = yes; then
4874 cat > $TMPC << EOF
4875 #pragma GCC push_options
4876 #pragma GCC target("avx2")
4877 #include <cpuid.h>
4878 #include <immintrin.h>
4879 static int bar(void *a) {
4880 __m256i x = *(__m256i *)a;
4881 return _mm256_testz_si256(x, x);
4883 int main(int argc, char *argv[]) { return bar(argv[0]); }
4885 if compile_object "" ; then
4886 avx2_opt="yes"
4890 ########################################
4891 # check if __[u]int128_t is usable.
4893 int128=no
4894 cat > $TMPC << EOF
4895 #if defined(__clang_major__) && defined(__clang_minor__)
4896 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4897 # error __int128_t does not work in CLANG before 3.2
4898 # endif
4899 #endif
4900 __int128_t a;
4901 __uint128_t b;
4902 int main (void) {
4903 a = a + b;
4904 b = a * b;
4905 a = a * a;
4906 return 0;
4909 if compile_prog "" "" ; then
4910 int128=yes
4913 #########################################
4914 # See if 128-bit atomic operations are supported.
4916 atomic128=no
4917 if test "$int128" = "yes"; then
4918 cat > $TMPC << EOF
4919 int main(void)
4921 unsigned __int128 x = 0, y = 0;
4922 y = __atomic_load_16(&x, 0);
4923 __atomic_store_16(&x, y, 0);
4924 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
4925 return 0;
4928 if compile_prog "" "" ; then
4929 atomic128=yes
4933 #########################################
4934 # See if 64-bit atomic operations are supported.
4935 # Note that without __atomic builtins, we can only
4936 # assume atomic loads/stores max at pointer size.
4938 cat > $TMPC << EOF
4939 #include <stdint.h>
4940 int main(void)
4942 uint64_t x = 0, y = 0;
4943 #ifdef __ATOMIC_RELAXED
4944 y = __atomic_load_8(&x, 0);
4945 __atomic_store_8(&x, y, 0);
4946 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4947 __atomic_exchange_8(&x, y, 0);
4948 __atomic_fetch_add_8(&x, y, 0);
4949 #else
4950 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4951 __sync_lock_test_and_set(&x, y);
4952 __sync_val_compare_and_swap(&x, y, 0);
4953 __sync_fetch_and_add(&x, y);
4954 #endif
4955 return 0;
4958 if compile_prog "" "" ; then
4959 atomic64=yes
4962 ########################################
4963 # check if getauxval is available.
4965 getauxval=no
4966 cat > $TMPC << EOF
4967 #include <sys/auxv.h>
4968 int main(void) {
4969 return getauxval(AT_HWCAP) == 0;
4972 if compile_prog "" "" ; then
4973 getauxval=yes
4976 ########################################
4977 # check if ccache is interfering with
4978 # semantic analysis of macros
4980 unset CCACHE_CPP2
4981 ccache_cpp2=no
4982 cat > $TMPC << EOF
4983 static const int Z = 1;
4984 #define fn() ({ Z; })
4985 #define TAUT(X) ((X) == Z)
4986 #define PAREN(X, Y) (X == Y)
4987 #define ID(X) (X)
4988 int main(int argc, char *argv[])
4990 int x = 0, y = 0;
4991 x = ID(x);
4992 x = fn();
4993 fn();
4994 if (PAREN(x, y)) return 0;
4995 if (TAUT(Z)) return 0;
4996 return 0;
5000 if ! compile_object "-Werror"; then
5001 ccache_cpp2=yes
5004 #################################################
5005 # clang does not support glibc + FORTIFY_SOURCE.
5007 if test "$fortify_source" != "no"; then
5008 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5009 fortify_source="no";
5010 elif test -n "$cxx" && has $cxx &&
5011 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5012 fortify_source="no";
5013 else
5014 fortify_source="yes"
5018 ##########################################
5019 # check if struct fsxattr is available via linux/fs.h
5021 have_fsxattr=no
5022 cat > $TMPC << EOF
5023 #include <linux/fs.h>
5024 struct fsxattr foo;
5025 int main(void) {
5026 return 0;
5029 if compile_prog "" "" ; then
5030 have_fsxattr=yes
5033 ##########################################
5034 # check if rtnetlink.h exists and is useful
5035 have_rtnetlink=no
5036 cat > $TMPC << EOF
5037 #include <linux/rtnetlink.h>
5038 int main(void) {
5039 return IFLA_PROTO_DOWN;
5042 if compile_prog "" "" ; then
5043 have_rtnetlink=yes
5046 ##########################################
5047 # check for usable AF_VSOCK environment
5048 have_af_vsock=no
5049 cat > $TMPC << EOF
5050 #include <errno.h>
5051 #include <sys/types.h>
5052 #include <sys/socket.h>
5053 #if !defined(AF_VSOCK)
5054 # error missing AF_VSOCK flag
5055 #endif
5056 #include <linux/vm_sockets.h>
5057 int main(void) {
5058 int sock, ret;
5059 struct sockaddr_vm svm;
5060 socklen_t len = sizeof(svm);
5061 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
5062 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
5063 if ((ret == -1) && (errno == ENOTCONN)) {
5064 return 0;
5066 return -1;
5069 if compile_prog "" "" ; then
5070 have_af_vsock=yes
5073 ##########################################
5074 # check for usable AF_ALG environment
5075 hava_afalg=no
5076 cat > $TMPC << EOF
5077 #include <errno.h>
5078 #include <sys/types.h>
5079 #include <sys/socket.h>
5080 #include <linux/if_alg.h>
5081 int main(void) {
5082 int sock;
5083 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5084 return sock;
5087 if compile_prog "" "" ; then
5088 have_afalg=yes
5090 if test "$crypto_afalg" = "yes"
5091 then
5092 if test "$have_afalg" != "yes"
5093 then
5094 error_exit "AF_ALG requested but could not be detected"
5099 #################################################
5100 # Check to see if we have the Hypervisor framework
5101 if [ "$darwin" = "yes" ] ; then
5102 cat > $TMPC << EOF
5103 #include <Hypervisor/hv.h>
5104 int main() { return 0;}
5106 if ! compile_object ""; then
5107 hvf='no'
5108 else
5109 hvf='yes'
5110 LDFLAGS="-framework Hypervisor $LDFLAGS"
5114 #################################################
5115 # Sparc implicitly links with --relax, which is
5116 # incompatible with -r, so --no-relax should be
5117 # given. It does no harm to give it on other
5118 # platforms too.
5120 # Note: the prototype is needed since QEMU_CFLAGS
5121 # contains -Wmissing-prototypes
5122 cat > $TMPC << EOF
5123 extern int foo(void);
5124 int foo(void) { return 0; }
5126 if ! compile_object ""; then
5127 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5129 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5130 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5131 LD_REL_FLAGS=$i
5132 break
5134 done
5135 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5136 feature_not_found "modules" "Cannot find how to build relocatable objects"
5139 ##########################################
5140 # check for sysmacros.h
5142 have_sysmacros=no
5143 cat > $TMPC << EOF
5144 #include <sys/sysmacros.h>
5145 int main(void) {
5146 return makedev(0, 0);
5149 if compile_prog "" "" ; then
5150 have_sysmacros=yes
5153 ##########################################
5154 # Veritas HyperScale block driver VxHS
5155 # Check if libvxhs is installed
5157 if test "$vxhs" != "no" ; then
5158 cat > $TMPC <<EOF
5159 #include <stdint.h>
5160 #include <qnio/qnio_api.h>
5162 void *vxhs_callback;
5164 int main(void) {
5165 iio_init(QNIO_VERSION, vxhs_callback);
5166 return 0;
5169 vxhs_libs="-lvxhs -lssl"
5170 if compile_prog "" "$vxhs_libs" ; then
5171 vxhs=yes
5172 else
5173 if test "$vxhs" = "yes" ; then
5174 feature_not_found "vxhs block device" "Install libvxhs See github"
5176 vxhs=no
5180 ##########################################
5181 # check for _Static_assert()
5183 have_static_assert=no
5184 cat > $TMPC << EOF
5185 _Static_assert(1, "success");
5186 int main(void) {
5187 return 0;
5190 if compile_prog "" "" ; then
5191 have_static_assert=yes
5194 ##########################################
5195 # check for utmpx.h, it is missing e.g. on OpenBSD
5197 have_utmpx=no
5198 cat > $TMPC << EOF
5199 #include <utmpx.h>
5200 struct utmpx user_info;
5201 int main(void) {
5202 return 0;
5205 if compile_prog "" "" ; then
5206 have_utmpx=yes
5209 ##########################################
5210 # checks for sanitizers
5212 write_c_skeleton
5214 have_asan=no
5215 have_ubsan=no
5216 have_asan_iface_h=no
5217 have_asan_iface_fiber=no
5219 if test "$sanitizers" = "yes" ; then
5220 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5221 have_asan=yes
5223 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5224 have_ubsan=yes
5227 if check_include "sanitizer/asan_interface.h" ; then
5228 have_asan_iface_h=yes
5231 cat > $TMPC << EOF
5232 #include <sanitizer/asan_interface.h>
5233 int main(void) {
5234 __sanitizer_start_switch_fiber(0, 0, 0);
5235 return 0;
5238 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5239 have_asan_iface_fiber=yes
5243 ##########################################
5244 # End of CC checks
5245 # After here, no more $cc or $ld runs
5247 write_c_skeleton
5249 if test "$gcov" = "yes" ; then
5250 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
5251 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5252 elif test "$fortify_source" = "yes" ; then
5253 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
5254 elif test "$debug" = "yes"; then
5255 if compile_prog "-Og" ""; then
5256 CFLAGS="-Og $CFLAGS"
5257 elif compile_prog "-O1" ""; then
5258 CFLAGS="-O1 $CFLAGS"
5260 # Workaround GCC false-positive Wuninitialized bugs with Og or O1:
5261 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
5262 if cc_has_warning_flag "-Wno-maybe-uninitialized"; then
5263 CFLAGS="-Wno-maybe-uninitialized $CFLAGS"
5265 else
5266 CFLAGS="-O2 $CFLAGS"
5269 if test "$have_asan" = "yes"; then
5270 CFLAGS="-fsanitize=address $CFLAGS"
5271 if test "$have_asan_iface_h" = "no" ; then
5272 echo "ASAN build enabled, but ASAN header missing." \
5273 "Without code annotation, the report may be inferior."
5274 elif test "$have_asan_iface_fiber" = "no" ; then
5275 echo "ASAN build enabled, but ASAN header is too old." \
5276 "Without code annotation, the report may be inferior."
5279 if test "$have_ubsan" = "yes"; then
5280 CFLAGS="-fsanitize=undefined $CFLAGS"
5283 ##########################################
5284 # Do we have libnfs
5285 if test "$libnfs" != "no" ; then
5286 if $pkg_config --atleast-version=1.9.3 libnfs; then
5287 libnfs="yes"
5288 libnfs_libs=$($pkg_config --libs libnfs)
5289 else
5290 if test "$libnfs" = "yes" ; then
5291 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
5293 libnfs="no"
5297 # Now we've finished running tests it's OK to add -Werror to the compiler flags
5298 if test "$werror" = "yes"; then
5299 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
5302 if test "$solaris" = "no" ; then
5303 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5304 LDFLAGS="-Wl,--warn-common $LDFLAGS"
5308 # test if pod2man has --utf8 option
5309 if pod2man --help | grep -q utf8; then
5310 POD2MAN="pod2man --utf8"
5311 else
5312 POD2MAN="pod2man"
5315 # Use ASLR, no-SEH and DEP if available
5316 if test "$mingw32" = "yes" ; then
5317 for flag in --dynamicbase --no-seh --nxcompat; do
5318 if ld_has $flag ; then
5319 LDFLAGS="-Wl,$flag $LDFLAGS"
5321 done
5324 qemu_confdir=$sysconfdir$confsuffix
5325 qemu_moddir=$libdir$confsuffix
5326 qemu_datadir=$datadir$confsuffix
5327 qemu_localedir="$datadir/locale"
5329 # We can only support ivshmem if we have eventfd
5330 if [ "$eventfd" = "yes" ]; then
5331 ivshmem=yes
5334 tools=""
5335 if test "$want_tools" = "yes" ; then
5336 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
5337 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
5338 tools="qemu-nbd\$(EXESUF) $tools"
5340 if [ "$ivshmem" = "yes" ]; then
5341 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
5344 if test "$softmmu" = yes ; then
5345 if test "$linux" = yes; then
5346 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5347 virtfs=yes
5348 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5349 else
5350 if test "$virtfs" = yes; then
5351 error_exit "VirtFS requires libcap devel and libattr devel"
5353 virtfs=no
5355 if test "$mpath" != no && test "$mpathpersist" = yes ; then
5356 mpath=yes
5357 else
5358 if test "$mpath" = yes; then
5359 error_exit "Multipath requires libmpathpersist devel"
5361 mpath=no
5363 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5364 else
5365 if test "$virtfs" = yes; then
5366 error_exit "VirtFS is supported only on Linux"
5368 virtfs=no
5369 if test "$mpath" = yes; then
5370 error_exit "Multipath is supported only on Linux"
5372 mpath=no
5374 if test "$xkbcommon" = "yes"; then
5375 tools="qemu-keymap\$(EXESUF) $tools"
5379 # Probe for guest agent support/options
5381 if [ "$guest_agent" != "no" ]; then
5382 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5383 tools="qemu-ga $tools"
5384 guest_agent=yes
5385 elif [ "$guest_agent" != yes ]; then
5386 guest_agent=no
5387 else
5388 error_exit "Guest agent is not supported on this platform"
5392 # Guest agent Window MSI package
5394 if test "$guest_agent" != yes; then
5395 if test "$guest_agent_msi" = yes; then
5396 error_exit "MSI guest agent package requires guest agent enabled"
5398 guest_agent_msi=no
5399 elif test "$mingw32" != "yes"; then
5400 if test "$guest_agent_msi" = "yes"; then
5401 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
5403 guest_agent_msi=no
5404 elif ! has wixl; then
5405 if test "$guest_agent_msi" = "yes"; then
5406 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
5408 guest_agent_msi=no
5409 else
5410 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
5411 # disabled explicitly
5412 if test "$guest_agent_msi" != "no"; then
5413 guest_agent_msi=yes
5417 if test "$guest_agent_msi" = "yes"; then
5418 if test "$guest_agent_with_vss" = "yes"; then
5419 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
5422 if test "$QEMU_GA_MANUFACTURER" = ""; then
5423 QEMU_GA_MANUFACTURER=QEMU
5426 if test "$QEMU_GA_DISTRO" = ""; then
5427 QEMU_GA_DISTRO=Linux
5430 if test "$QEMU_GA_VERSION" = ""; then
5431 QEMU_GA_VERSION=$(cat $source_path/VERSION)
5434 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
5436 case "$cpu" in
5437 x86_64)
5438 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5440 i386)
5441 QEMU_GA_MSI_ARCH="-D Arch=32"
5444 error_exit "CPU $cpu not supported for building installation package"
5446 esac
5449 # Mac OS X ships with a broken assembler
5450 roms=
5451 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5452 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5453 "$softmmu" = yes ; then
5454 # Different host OS linkers have different ideas about the name of the ELF
5455 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5456 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5457 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5458 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5459 ld_i386_emulation="$emu"
5460 roms="optionrom"
5461 break
5463 done
5465 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
5466 roms="$roms spapr-rtas"
5469 if test "$cpu" = "s390x" ; then
5470 roms="$roms s390-ccw"
5473 # Probe for the need for relocating the user-only binary.
5474 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5475 textseg_addr=
5476 case "$cpu" in
5477 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5478 # ??? Rationale for choosing this address
5479 textseg_addr=0x60000000
5481 mips)
5482 # A 256M aligned address, high in the address space, with enough
5483 # room for the code_gen_buffer above it before the stack.
5484 textseg_addr=0x60000000
5486 esac
5487 if [ -n "$textseg_addr" ]; then
5488 cat > $TMPC <<EOF
5489 int main(void) { return 0; }
5491 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5492 if ! compile_prog "" "$textseg_ldflags"; then
5493 # In case ld does not support -Ttext-segment, edit the default linker
5494 # script via sed to set the .text start addr. This is needed on FreeBSD
5495 # at least.
5496 if ! $ld --verbose >/dev/null 2>&1; then
5497 error_exit \
5498 "We need to link the QEMU user mode binaries at a" \
5499 "specific text address. Unfortunately your linker" \
5500 "doesn't support either the -Ttext-segment option or" \
5501 "printing the default linker script with --verbose." \
5502 "If you don't want the user mode binaries, pass the" \
5503 "--disable-user option to configure."
5506 $ld --verbose | sed \
5507 -e '1,/==================================================/d' \
5508 -e '/==================================================/,$d' \
5509 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5510 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5511 textseg_ldflags="-Wl,-T../config-host.ld"
5516 # Check that the C++ compiler exists and works with the C compiler.
5517 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
5518 if has $cxx; then
5519 cat > $TMPC <<EOF
5520 int c_function(void);
5521 int main(void) { return c_function(); }
5524 compile_object
5526 cat > $TMPCXX <<EOF
5527 extern "C" {
5528 int c_function(void);
5530 int c_function(void) { return 42; }
5533 update_cxxflags
5535 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
5536 # C++ compiler $cxx works ok with C compiler $cc
5538 else
5539 echo "C++ compiler $cxx does not work with C compiler $cc"
5540 echo "Disabling C++ specific optional code"
5541 cxx=
5543 else
5544 echo "No C++ compiler available; disabling C++ specific optional code"
5545 cxx=
5548 echo_version() {
5549 if test "$1" = "yes" ; then
5550 echo "($2)"
5554 # prepend pixman and ftd flags after all config tests are done
5555 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5556 libs_softmmu="$pixman_libs $libs_softmmu"
5558 echo "Install prefix $prefix"
5559 echo "BIOS directory $(eval echo $qemu_datadir)"
5560 echo "firmware path $(eval echo $firmwarepath)"
5561 echo "binary directory $(eval echo $bindir)"
5562 echo "library directory $(eval echo $libdir)"
5563 echo "module directory $(eval echo $qemu_moddir)"
5564 echo "libexec directory $(eval echo $libexecdir)"
5565 echo "include directory $(eval echo $includedir)"
5566 echo "config directory $(eval echo $sysconfdir)"
5567 if test "$mingw32" = "no" ; then
5568 echo "local state directory $(eval echo $local_statedir)"
5569 echo "Manual directory $(eval echo $mandir)"
5570 echo "ELF interp prefix $interp_prefix"
5571 else
5572 echo "local state directory queried at runtime"
5573 echo "Windows SDK $win_sdk"
5575 echo "Source path $source_path"
5576 echo "GIT binary $git"
5577 echo "GIT submodules $git_submodules"
5578 echo "C compiler $cc"
5579 echo "Host C compiler $host_cc"
5580 echo "C++ compiler $cxx"
5581 echo "Objective-C compiler $objcc"
5582 echo "ARFLAGS $ARFLAGS"
5583 echo "CFLAGS $CFLAGS"
5584 echo "QEMU_CFLAGS $QEMU_CFLAGS"
5585 echo "LDFLAGS $LDFLAGS"
5586 echo "make $make"
5587 echo "install $install"
5588 echo "python $python"
5589 if test "$slirp" = "yes" ; then
5590 echo "smbd $smbd"
5592 echo "module support $modules"
5593 echo "host CPU $cpu"
5594 echo "host big endian $bigendian"
5595 echo "target list $target_list"
5596 echo "gprof enabled $gprof"
5597 echo "sparse enabled $sparse"
5598 echo "strip binaries $strip_opt"
5599 echo "profiler $profiler"
5600 echo "static build $static"
5601 if test "$darwin" = "yes" ; then
5602 echo "Cocoa support $cocoa"
5604 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5605 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
5606 echo "GTK GL support $gtk_gl"
5607 echo "VTE support $vte $(echo_version $vte $vteversion)"
5608 echo "TLS priority $tls_priority"
5609 echo "GNUTLS support $gnutls"
5610 echo "GNUTLS rnd $gnutls_rnd"
5611 echo "libgcrypt $gcrypt"
5612 echo "libgcrypt kdf $gcrypt_kdf"
5613 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
5614 echo "nettle kdf $nettle_kdf"
5615 echo "libtasn1 $tasn1"
5616 echo "curses support $curses"
5617 echo "virgl support $virglrenderer"
5618 echo "curl support $curl"
5619 echo "mingw32 support $mingw32"
5620 echo "Audio drivers $audio_drv_list"
5621 echo "Block whitelist (rw) $block_drv_rw_whitelist"
5622 echo "Block whitelist (ro) $block_drv_ro_whitelist"
5623 echo "VirtFS support $virtfs"
5624 echo "Multipath support $mpath"
5625 echo "VNC support $vnc"
5626 if test "$vnc" = "yes" ; then
5627 echo "VNC SASL support $vnc_sasl"
5628 echo "VNC JPEG support $vnc_jpeg"
5629 echo "VNC PNG support $vnc_png"
5631 if test -n "$sparc_cpu"; then
5632 echo "Target Sparc Arch $sparc_cpu"
5634 echo "xen support $xen"
5635 if test "$xen" = "yes" ; then
5636 echo "xen ctrl version $xen_ctrl_version"
5637 echo "pv dom build $xen_pv_domain_build"
5639 echo "brlapi support $brlapi"
5640 echo "bluez support $bluez"
5641 echo "Documentation $docs"
5642 echo "PIE $pie"
5643 echo "vde support $vde"
5644 echo "netmap support $netmap"
5645 echo "Linux AIO support $linux_aio"
5646 echo "ATTR/XATTR support $attr"
5647 echo "Install blobs $blobs"
5648 echo "KVM support $kvm"
5649 echo "HAX support $hax"
5650 echo "HVF support $hvf"
5651 echo "TCG support $tcg"
5652 if test "$tcg" = "yes" ; then
5653 echo "TCG debug enabled $debug_tcg"
5654 echo "TCG interpreter $tcg_interpreter"
5656 echo "malloc trim support $malloc_trim"
5657 echo "RDMA support $rdma"
5658 echo "fdt support $fdt"
5659 echo "preadv support $preadv"
5660 echo "fdatasync $fdatasync"
5661 echo "madvise $madvise"
5662 echo "posix_madvise $posix_madvise"
5663 echo "libcap-ng support $cap_ng"
5664 echo "vhost-net support $vhost_net"
5665 echo "vhost-scsi support $vhost_scsi"
5666 echo "vhost-vsock support $vhost_vsock"
5667 echo "vhost-user support $vhost_user"
5668 echo "Trace backends $trace_backends"
5669 if have_backend "simple"; then
5670 echo "Trace output file $trace_file-<pid>"
5672 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5673 echo "rbd support $rbd"
5674 echo "xfsctl support $xfs"
5675 echo "smartcard support $smartcard"
5676 echo "libusb $libusb"
5677 echo "usb net redir $usb_redir"
5678 echo "OpenGL support $opengl"
5679 echo "OpenGL dmabufs $opengl_dmabuf"
5680 echo "libiscsi support $libiscsi"
5681 echo "libnfs support $libnfs"
5682 echo "build guest agent $guest_agent"
5683 echo "QGA VSS support $guest_agent_with_vss"
5684 echo "QGA w32 disk info $guest_agent_ntddscsi"
5685 echo "QGA MSI support $guest_agent_msi"
5686 echo "seccomp support $seccomp"
5687 echo "coroutine backend $coroutine"
5688 echo "coroutine pool $coroutine_pool"
5689 echo "debug stack usage $debug_stack_usage"
5690 echo "crypto afalg $crypto_afalg"
5691 echo "GlusterFS support $glusterfs"
5692 echo "gcov $gcov_tool"
5693 echo "gcov enabled $gcov"
5694 echo "TPM support $tpm"
5695 echo "libssh2 support $libssh2"
5696 echo "TPM passthrough $tpm_passthrough"
5697 echo "TPM emulator $tpm_emulator"
5698 echo "QOM debugging $qom_cast_debug"
5699 echo "Live block migration $live_block_migration"
5700 echo "lzo support $lzo"
5701 echo "snappy support $snappy"
5702 echo "bzip2 support $bzip2"
5703 echo "NUMA host support $numa"
5704 echo "libxml2 $libxml2"
5705 echo "tcmalloc support $tcmalloc"
5706 echo "jemalloc support $jemalloc"
5707 echo "avx2 optimization $avx2_opt"
5708 echo "replication support $replication"
5709 echo "VxHS block device $vxhs"
5710 echo "capstone $capstone"
5712 if test "$sdl_too_old" = "yes"; then
5713 echo "-> Your SDL version is too old - please upgrade to have SDL support"
5716 if test "$gtkabi" = "2.0"; then
5717 echo
5718 echo "WARNING: Use of GTK 2.0 is deprecated and will be removed in"
5719 echo "WARNING: future releases. Please switch to using GTK 3.0"
5722 if test "$sdlabi" = "1.2"; then
5723 echo
5724 echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
5725 echo "WARNING: future releases. Please switch to using SDL 2.0"
5728 if test "$supported_cpu" = "no"; then
5729 echo
5730 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5731 echo
5732 echo "CPU host architecture $cpu support is not currently maintained."
5733 echo "The QEMU project intends to remove support for this host CPU in"
5734 echo "a future release if nobody volunteers to maintain it and to"
5735 echo "provide a build host for our continuous integration setup."
5736 echo "configure has succeeded and you can continue to build, but"
5737 echo "if you care about QEMU on this platform you should contact"
5738 echo "us upstream at qemu-devel@nongnu.org."
5741 if test "$supported_os" = "no"; then
5742 echo
5743 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5744 echo
5745 echo "Host OS $targetos support is not currently maintained."
5746 echo "The QEMU project intends to remove support for this host OS in"
5747 echo "a future release if nobody volunteers to maintain it and to"
5748 echo "provide a build host for our continuous integration setup."
5749 echo "configure has succeeded and you can continue to build, but"
5750 echo "if you care about QEMU on this platform you should contact"
5751 echo "us upstream at qemu-devel@nongnu.org."
5754 config_host_mak="config-host.mak"
5756 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
5758 echo "# Automatically generated by configure - do not modify" > $config_host_mak
5759 echo >> $config_host_mak
5761 echo all: >> $config_host_mak
5762 echo "prefix=$prefix" >> $config_host_mak
5763 echo "bindir=$bindir" >> $config_host_mak
5764 echo "libdir=$libdir" >> $config_host_mak
5765 echo "libexecdir=$libexecdir" >> $config_host_mak
5766 echo "includedir=$includedir" >> $config_host_mak
5767 echo "mandir=$mandir" >> $config_host_mak
5768 echo "sysconfdir=$sysconfdir" >> $config_host_mak
5769 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
5770 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
5771 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
5772 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
5773 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5774 if test "$mingw32" = "no" ; then
5775 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
5777 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
5778 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
5779 echo "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5780 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5781 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
5782 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
5783 echo "GIT=$git" >> $config_host_mak
5784 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5785 echo "GIT_UPDATE=$git_update" >> $config_host_mak
5787 echo "ARCH=$ARCH" >> $config_host_mak
5789 if test "$debug_tcg" = "yes" ; then
5790 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5792 if test "$strip_opt" = "yes" ; then
5793 echo "STRIP=${strip}" >> $config_host_mak
5795 if test "$bigendian" = "yes" ; then
5796 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
5798 if test "$mingw32" = "yes" ; then
5799 echo "CONFIG_WIN32=y" >> $config_host_mak
5800 rc_version=$(cat $source_path/VERSION)
5801 version_major=${rc_version%%.*}
5802 rc_version=${rc_version#*.}
5803 version_minor=${rc_version%%.*}
5804 rc_version=${rc_version#*.}
5805 version_subminor=${rc_version%%.*}
5806 version_micro=0
5807 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5808 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5809 if test "$guest_agent_with_vss" = "yes" ; then
5810 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5811 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5812 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5814 if test "$guest_agent_ntddscsi" = "yes" ; then
5815 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
5817 if test "$guest_agent_msi" = "yes"; then
5818 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
5819 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
5820 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
5821 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
5822 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
5823 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
5824 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5826 else
5827 echo "CONFIG_POSIX=y" >> $config_host_mak
5830 if test "$linux" = "yes" ; then
5831 echo "CONFIG_LINUX=y" >> $config_host_mak
5834 if test "$darwin" = "yes" ; then
5835 echo "CONFIG_DARWIN=y" >> $config_host_mak
5838 if test "$solaris" = "yes" ; then
5839 echo "CONFIG_SOLARIS=y" >> $config_host_mak
5841 if test "$haiku" = "yes" ; then
5842 echo "CONFIG_HAIKU=y" >> $config_host_mak
5844 if test "$static" = "yes" ; then
5845 echo "CONFIG_STATIC=y" >> $config_host_mak
5847 if test "$profiler" = "yes" ; then
5848 echo "CONFIG_PROFILER=y" >> $config_host_mak
5850 if test "$slirp" = "yes" ; then
5851 echo "CONFIG_SLIRP=y" >> $config_host_mak
5852 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5854 if test "$vde" = "yes" ; then
5855 echo "CONFIG_VDE=y" >> $config_host_mak
5856 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
5858 if test "$netmap" = "yes" ; then
5859 echo "CONFIG_NETMAP=y" >> $config_host_mak
5861 if test "$l2tpv3" = "yes" ; then
5862 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5864 if test "$cap_ng" = "yes" ; then
5865 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5867 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
5868 for drv in $audio_drv_list; do
5869 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5870 echo "$def=y" >> $config_host_mak
5871 done
5872 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5873 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5874 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5875 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5876 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
5877 if test "$audio_pt_int" = "yes" ; then
5878 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5880 if test "$audio_win_int" = "yes" ; then
5881 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5883 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5884 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5885 if test "$vnc" = "yes" ; then
5886 echo "CONFIG_VNC=y" >> $config_host_mak
5888 if test "$vnc_sasl" = "yes" ; then
5889 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
5891 if test "$vnc_jpeg" = "yes" ; then
5892 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
5894 if test "$vnc_png" = "yes" ; then
5895 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5897 if test "$xkbcommon" = "yes" ; then
5898 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
5899 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
5901 if test "$fnmatch" = "yes" ; then
5902 echo "CONFIG_FNMATCH=y" >> $config_host_mak
5904 if test "$xfs" = "yes" ; then
5905 echo "CONFIG_XFS=y" >> $config_host_mak
5907 qemu_version=$(head $source_path/VERSION)
5908 echo "VERSION=$qemu_version" >>$config_host_mak
5909 echo "PKGVERSION=$pkgversion" >>$config_host_mak
5910 echo "SRC_PATH=$source_path" >> $config_host_mak
5911 echo "TARGET_DIRS=$target_list" >> $config_host_mak
5912 if [ "$docs" = "yes" ] ; then
5913 echo "BUILD_DOCS=yes" >> $config_host_mak
5915 if test "$modules" = "yes"; then
5916 # $shacmd can generate a hash started with digit, which the compiler doesn't
5917 # like as an symbol. So prefix it with an underscore
5918 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
5919 echo "CONFIG_MODULES=y" >> $config_host_mak
5921 if test "$sdl" = "yes" ; then
5922 echo "CONFIG_SDL=y" >> $config_host_mak
5923 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
5924 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
5925 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
5927 if test "$cocoa" = "yes" ; then
5928 echo "CONFIG_COCOA=y" >> $config_host_mak
5930 if test "$curses" = "yes" ; then
5931 echo "CONFIG_CURSES=y" >> $config_host_mak
5933 if test "$pipe2" = "yes" ; then
5934 echo "CONFIG_PIPE2=y" >> $config_host_mak
5936 if test "$accept4" = "yes" ; then
5937 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5939 if test "$splice" = "yes" ; then
5940 echo "CONFIG_SPLICE=y" >> $config_host_mak
5942 if test "$eventfd" = "yes" ; then
5943 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5945 if test "$memfd" = "yes" ; then
5946 echo "CONFIG_MEMFD=y" >> $config_host_mak
5948 if test "$fallocate" = "yes" ; then
5949 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5951 if test "$fallocate_punch_hole" = "yes" ; then
5952 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5954 if test "$fallocate_zero_range" = "yes" ; then
5955 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5957 if test "$posix_fallocate" = "yes" ; then
5958 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5960 if test "$sync_file_range" = "yes" ; then
5961 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5963 if test "$fiemap" = "yes" ; then
5964 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5966 if test "$dup3" = "yes" ; then
5967 echo "CONFIG_DUP3=y" >> $config_host_mak
5969 if test "$ppoll" = "yes" ; then
5970 echo "CONFIG_PPOLL=y" >> $config_host_mak
5972 if test "$prctl_pr_set_timerslack" = "yes" ; then
5973 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5975 if test "$epoll" = "yes" ; then
5976 echo "CONFIG_EPOLL=y" >> $config_host_mak
5978 if test "$epoll_create1" = "yes" ; then
5979 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5981 if test "$sendfile" = "yes" ; then
5982 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5984 if test "$timerfd" = "yes" ; then
5985 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5987 if test "$setns" = "yes" ; then
5988 echo "CONFIG_SETNS=y" >> $config_host_mak
5990 if test "$clock_adjtime" = "yes" ; then
5991 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
5993 if test "$syncfs" = "yes" ; then
5994 echo "CONFIG_SYNCFS=y" >> $config_host_mak
5996 if test "$inotify" = "yes" ; then
5997 echo "CONFIG_INOTIFY=y" >> $config_host_mak
5999 if test "$inotify1" = "yes" ; then
6000 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6002 if test "$sem_timedwait" = "yes" ; then
6003 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6005 if test "$byteswap_h" = "yes" ; then
6006 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
6008 if test "$bswap_h" = "yes" ; then
6009 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
6011 if test "$curl" = "yes" ; then
6012 echo "CONFIG_CURL=m" >> $config_host_mak
6013 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
6014 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6016 if test "$brlapi" = "yes" ; then
6017 echo "CONFIG_BRLAPI=y" >> $config_host_mak
6018 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
6020 if test "$bluez" = "yes" ; then
6021 echo "CONFIG_BLUEZ=y" >> $config_host_mak
6022 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
6024 if test "$glib_subprocess" = "yes" ; then
6025 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
6027 if test "$gtk" = "yes" ; then
6028 echo "CONFIG_GTK=y" >> $config_host_mak
6029 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
6030 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6031 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6032 if test "$gtk_gl" = "yes" ; then
6033 echo "CONFIG_GTK_GL=y" >> $config_host_mak
6036 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6037 if test "$gnutls" = "yes" ; then
6038 echo "CONFIG_GNUTLS=y" >> $config_host_mak
6040 if test "$gnutls_rnd" = "yes" ; then
6041 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
6043 if test "$gcrypt" = "yes" ; then
6044 echo "CONFIG_GCRYPT=y" >> $config_host_mak
6045 if test "$gcrypt_hmac" = "yes" ; then
6046 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
6048 if test "$gcrypt_kdf" = "yes" ; then
6049 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
6052 if test "$nettle" = "yes" ; then
6053 echo "CONFIG_NETTLE=y" >> $config_host_mak
6054 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6055 if test "$nettle_kdf" = "yes" ; then
6056 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
6059 if test "$tasn1" = "yes" ; then
6060 echo "CONFIG_TASN1=y" >> $config_host_mak
6062 if test "$have_ifaddrs_h" = "yes" ; then
6063 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6065 if test "$have_broken_size_max" = "yes" ; then
6066 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
6069 # Work around a system header bug with some kernel/XFS header
6070 # versions where they both try to define 'struct fsxattr':
6071 # xfs headers will not try to redefine structs from linux headers
6072 # if this macro is set.
6073 if test "$have_fsxattr" = "yes" ; then
6074 echo "HAVE_FSXATTR=y" >> $config_host_mak
6076 if test "$vte" = "yes" ; then
6077 echo "CONFIG_VTE=y" >> $config_host_mak
6078 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6080 if test "$virglrenderer" = "yes" ; then
6081 echo "CONFIG_VIRGL=y" >> $config_host_mak
6082 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
6083 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
6085 if test "$xen" = "yes" ; then
6086 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6087 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6088 if test "$xen_pv_domain_build" = "yes" ; then
6089 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
6092 if test "$linux_aio" = "yes" ; then
6093 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
6095 if test "$attr" = "yes" ; then
6096 echo "CONFIG_ATTR=y" >> $config_host_mak
6098 if test "$libattr" = "yes" ; then
6099 echo "CONFIG_LIBATTR=y" >> $config_host_mak
6101 if test "$virtfs" = "yes" ; then
6102 echo "CONFIG_VIRTFS=y" >> $config_host_mak
6104 if test "$mpath" = "yes" ; then
6105 echo "CONFIG_MPATH=y" >> $config_host_mak
6107 if test "$vhost_scsi" = "yes" ; then
6108 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
6110 if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
6111 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
6113 if test "$vhost_vsock" = "yes" ; then
6114 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6116 if test "$vhost_user" = "yes" ; then
6117 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6119 if test "$blobs" = "yes" ; then
6120 echo "INSTALL_BLOBS=yes" >> $config_host_mak
6122 if test "$iovec" = "yes" ; then
6123 echo "CONFIG_IOVEC=y" >> $config_host_mak
6125 if test "$preadv" = "yes" ; then
6126 echo "CONFIG_PREADV=y" >> $config_host_mak
6128 if test "$fdt" = "yes" ; then
6129 echo "CONFIG_FDT=y" >> $config_host_mak
6131 if test "$signalfd" = "yes" ; then
6132 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6134 if test "$tcg" = "yes"; then
6135 echo "CONFIG_TCG=y" >> $config_host_mak
6136 if test "$tcg_interpreter" = "yes" ; then
6137 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
6140 if test "$fdatasync" = "yes" ; then
6141 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
6143 if test "$madvise" = "yes" ; then
6144 echo "CONFIG_MADVISE=y" >> $config_host_mak
6146 if test "$posix_madvise" = "yes" ; then
6147 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6150 if test "$spice" = "yes" ; then
6151 echo "CONFIG_SPICE=y" >> $config_host_mak
6154 if test "$smartcard" = "yes" ; then
6155 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
6156 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
6157 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6160 if test "$libusb" = "yes" ; then
6161 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6162 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6163 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
6166 if test "$usb_redir" = "yes" ; then
6167 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6168 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6169 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
6172 if test "$opengl" = "yes" ; then
6173 echo "CONFIG_OPENGL=y" >> $config_host_mak
6174 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6175 if test "$opengl_dmabuf" = "yes" ; then
6176 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6180 if test "$malloc_trim" = "yes" ; then
6181 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
6184 if test "$avx2_opt" = "yes" ; then
6185 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
6188 if test "$lzo" = "yes" ; then
6189 echo "CONFIG_LZO=y" >> $config_host_mak
6192 if test "$snappy" = "yes" ; then
6193 echo "CONFIG_SNAPPY=y" >> $config_host_mak
6196 if test "$bzip2" = "yes" ; then
6197 echo "CONFIG_BZIP2=y" >> $config_host_mak
6198 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
6201 if test "$libiscsi" = "yes" ; then
6202 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6203 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
6204 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6207 if test "$libnfs" = "yes" ; then
6208 echo "CONFIG_LIBNFS=m" >> $config_host_mak
6209 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6212 if test "$seccomp" = "yes"; then
6213 echo "CONFIG_SECCOMP=y" >> $config_host_mak
6214 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6215 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6218 # XXX: suppress that
6219 if [ "$bsd" = "yes" ] ; then
6220 echo "CONFIG_BSD=y" >> $config_host_mak
6223 if test "$localtime_r" = "yes" ; then
6224 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
6226 if test "$qom_cast_debug" = "yes" ; then
6227 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
6229 if test "$rbd" = "yes" ; then
6230 echo "CONFIG_RBD=m" >> $config_host_mak
6231 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
6232 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6235 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
6236 if test "$coroutine_pool" = "yes" ; then
6237 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
6238 else
6239 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
6242 if test "$debug_stack_usage" = "yes" ; then
6243 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
6246 if test "$crypto_afalg" = "yes" ; then
6247 echo "CONFIG_AF_ALG=y" >> $config_host_mak
6250 if test "$open_by_handle_at" = "yes" ; then
6251 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6254 if test "$linux_magic_h" = "yes" ; then
6255 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6258 if test "$pragma_diagnostic_available" = "yes" ; then
6259 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
6262 if test "$valgrind_h" = "yes" ; then
6263 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
6266 if test "$have_asan_iface_fiber" = "yes" ; then
6267 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6270 if test "$has_environ" = "yes" ; then
6271 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
6274 if test "$cpuid_h" = "yes" ; then
6275 echo "CONFIG_CPUID_H=y" >> $config_host_mak
6278 if test "$int128" = "yes" ; then
6279 echo "CONFIG_INT128=y" >> $config_host_mak
6282 if test "$atomic128" = "yes" ; then
6283 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
6286 if test "$atomic64" = "yes" ; then
6287 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6290 if test "$getauxval" = "yes" ; then
6291 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
6294 if test "$glusterfs" = "yes" ; then
6295 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6296 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
6297 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6300 if test "$glusterfs_xlator_opt" = "yes" ; then
6301 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6304 if test "$glusterfs_discard" = "yes" ; then
6305 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
6308 if test "$glusterfs_fallocate" = "yes" ; then
6309 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6312 if test "$glusterfs_zerofill" = "yes" ; then
6313 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
6316 if test "$libssh2" = "yes" ; then
6317 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6318 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
6319 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
6322 if test "$live_block_migration" = "yes" ; then
6323 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6326 if test "$tpm" = "yes"; then
6327 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6328 # TPM passthrough support?
6329 if test "$tpm_passthrough" = "yes"; then
6330 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
6332 # TPM emulator support?
6333 if test "$tpm_emulator" = "yes"; then
6334 echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6338 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
6339 if have_backend "nop"; then
6340 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
6342 if have_backend "simple"; then
6343 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
6344 # Set the appropriate trace file.
6345 trace_file="\"$trace_file-\" FMT_pid"
6347 if have_backend "log"; then
6348 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6350 if have_backend "ust"; then
6351 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6353 if have_backend "dtrace"; then
6354 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
6355 if test "$trace_backend_stap" = "yes" ; then
6356 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
6359 if have_backend "ftrace"; then
6360 if test "$linux" = "yes" ; then
6361 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6362 else
6363 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6366 if have_backend "syslog"; then
6367 if test "$posix_syslog" = "yes" ; then
6368 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
6369 else
6370 feature_not_found "syslog(trace backend)" "syslog not available"
6373 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
6375 if test "$rdma" = "yes" ; then
6376 echo "CONFIG_RDMA=y" >> $config_host_mak
6377 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
6380 if test "$have_rtnetlink" = "yes" ; then
6381 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6384 if test "$libxml2" = "yes" ; then
6385 echo "CONFIG_LIBXML2=y" >> $config_host_mak
6386 echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6387 echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6390 if test "$replication" = "yes" ; then
6391 echo "CONFIG_REPLICATION=y" >> $config_host_mak
6394 if test "$have_af_vsock" = "yes" ; then
6395 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
6398 if test "$have_sysmacros" = "yes" ; then
6399 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
6402 if test "$have_static_assert" = "yes" ; then
6403 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
6406 if test "$have_utmpx" = "yes" ; then
6407 echo "HAVE_UTMPX=y" >> $config_host_mak
6410 if test "$ivshmem" = "yes" ; then
6411 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6413 if test "$capstone" != "no" ; then
6414 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
6417 # Hold two types of flag:
6418 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
6419 # a thread we have a handle to
6420 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
6421 # platform
6422 if test "$pthread_setname_np" = "yes" ; then
6423 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6424 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
6427 if test "$vxhs" = "yes" ; then
6428 echo "CONFIG_VXHS=y" >> $config_host_mak
6429 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6432 if test "$tcg_interpreter" = "yes"; then
6433 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
6434 elif test "$ARCH" = "sparc64" ; then
6435 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
6436 elif test "$ARCH" = "s390x" ; then
6437 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6438 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
6439 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
6440 elif test "$ARCH" = "ppc64" ; then
6441 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
6442 else
6443 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
6445 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
6447 echo "TOOLS=$tools" >> $config_host_mak
6448 echo "ROMS=$roms" >> $config_host_mak
6449 echo "MAKE=$make" >> $config_host_mak
6450 echo "INSTALL=$install" >> $config_host_mak
6451 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
6452 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
6453 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
6454 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6455 echo "PYTHON=$python" >> $config_host_mak
6456 echo "CC=$cc" >> $config_host_mak
6457 if $iasl -h > /dev/null 2>&1; then
6458 echo "IASL=$iasl" >> $config_host_mak
6460 echo "CC_I386=$cc_i386" >> $config_host_mak
6461 echo "HOST_CC=$host_cc" >> $config_host_mak
6462 echo "CXX=$cxx" >> $config_host_mak
6463 echo "OBJCC=$objcc" >> $config_host_mak
6464 echo "AR=$ar" >> $config_host_mak
6465 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
6466 echo "AS=$as" >> $config_host_mak
6467 echo "CCAS=$ccas" >> $config_host_mak
6468 echo "CPP=$cpp" >> $config_host_mak
6469 echo "OBJCOPY=$objcopy" >> $config_host_mak
6470 echo "LD=$ld" >> $config_host_mak
6471 echo "RANLIB=$ranlib" >> $config_host_mak
6472 echo "NM=$nm" >> $config_host_mak
6473 echo "WINDRES=$windres" >> $config_host_mak
6474 echo "CFLAGS=$CFLAGS" >> $config_host_mak
6475 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6476 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
6477 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6478 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6479 if test "$sparse" = "yes" ; then
6480 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
6481 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
6482 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
6483 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
6484 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6486 if test "$cross_prefix" != ""; then
6487 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
6488 else
6489 echo "AUTOCONF_HOST := " >> $config_host_mak
6491 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
6492 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
6493 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6494 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
6495 echo "LIBS+=$LIBS" >> $config_host_mak
6496 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6497 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6498 echo "EXESUF=$EXESUF" >> $config_host_mak
6499 echo "DSOSUF=$DSOSUF" >> $config_host_mak
6500 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6501 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
6502 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
6503 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
6504 echo "POD2MAN=$POD2MAN" >> $config_host_mak
6505 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
6506 if test "$gcov" = "yes" ; then
6507 echo "CONFIG_GCOV=y" >> $config_host_mak
6508 echo "GCOV=$gcov_tool" >> $config_host_mak
6511 # use included Linux headers
6512 if test "$linux" = "yes" ; then
6513 mkdir -p linux-headers
6514 case "$cpu" in
6515 i386|x86_64|x32)
6516 linux_arch=x86
6518 ppcemb|ppc|ppc64)
6519 linux_arch=powerpc
6521 s390x)
6522 linux_arch=s390
6524 aarch64)
6525 linux_arch=arm64
6527 mips64)
6528 linux_arch=mips
6531 # For most CPUs the kernel architecture name and QEMU CPU name match.
6532 linux_arch="$cpu"
6534 esac
6535 # For non-KVM architectures we will not have asm headers
6536 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
6537 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
6541 for target in $target_list; do
6542 target_dir="$target"
6543 config_target_mak=$target_dir/config-target.mak
6544 target_name=$(echo $target | cut -d '-' -f 1)
6545 target_bigendian="no"
6547 case "$target_name" in
6548 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6549 target_bigendian=yes
6551 esac
6552 target_softmmu="no"
6553 target_user_only="no"
6554 target_linux_user="no"
6555 target_bsd_user="no"
6556 case "$target" in
6557 ${target_name}-softmmu)
6558 target_softmmu="yes"
6560 ${target_name}-linux-user)
6561 target_user_only="yes"
6562 target_linux_user="yes"
6564 ${target_name}-bsd-user)
6565 target_user_only="yes"
6566 target_bsd_user="yes"
6569 error_exit "Target '$target' not recognised"
6570 exit 1
6572 esac
6574 mkdir -p $target_dir
6575 echo "# Automatically generated by configure - do not modify" > $config_target_mak
6577 bflt="no"
6578 mttcg="no"
6579 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
6580 gdb_xml_files=""
6582 TARGET_ARCH="$target_name"
6583 TARGET_BASE_ARCH=""
6584 TARGET_ABI_DIR=""
6586 case "$target_name" in
6587 i386)
6588 gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
6590 x86_64)
6591 TARGET_BASE_ARCH=i386
6592 gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
6594 alpha)
6595 mttcg="yes"
6597 arm|armeb)
6598 TARGET_ARCH=arm
6599 bflt="yes"
6600 mttcg="yes"
6601 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6603 aarch64|aarch64_be)
6604 TARGET_ARCH=aarch64
6605 TARGET_BASE_ARCH=arm
6606 bflt="yes"
6607 mttcg="yes"
6608 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6610 cris)
6612 hppa)
6613 mttcg="yes"
6615 lm32)
6617 m68k)
6618 bflt="yes"
6619 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
6621 microblaze|microblazeel)
6622 TARGET_ARCH=microblaze
6623 bflt="yes"
6625 mips|mipsel)
6626 TARGET_ARCH=mips
6627 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
6629 mipsn32|mipsn32el)
6630 TARGET_ARCH=mips64
6631 TARGET_BASE_ARCH=mips
6632 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6633 echo "TARGET_ABI32=y" >> $config_target_mak
6635 mips64|mips64el)
6636 TARGET_ARCH=mips64
6637 TARGET_BASE_ARCH=mips
6638 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
6640 moxie)
6642 nios2)
6644 or1k)
6645 TARGET_ARCH=openrisc
6646 TARGET_BASE_ARCH=openrisc
6648 ppc)
6649 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6651 ppcemb)
6652 TARGET_BASE_ARCH=ppc
6653 TARGET_ABI_DIR=ppc
6654 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6656 ppc64)
6657 TARGET_BASE_ARCH=ppc
6658 TARGET_ABI_DIR=ppc
6659 mttcg=yes
6660 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6662 ppc64le)
6663 TARGET_ARCH=ppc64
6664 TARGET_BASE_ARCH=ppc
6665 TARGET_ABI_DIR=ppc
6666 mttcg=yes
6667 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6669 ppc64abi32)
6670 TARGET_ARCH=ppc64
6671 TARGET_BASE_ARCH=ppc
6672 TARGET_ABI_DIR=ppc
6673 echo "TARGET_ABI32=y" >> $config_target_mak
6674 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6676 sh4|sh4eb)
6677 TARGET_ARCH=sh4
6678 bflt="yes"
6680 sparc)
6682 sparc64)
6683 TARGET_BASE_ARCH=sparc
6685 sparc32plus)
6686 TARGET_ARCH=sparc64
6687 TARGET_BASE_ARCH=sparc
6688 TARGET_ABI_DIR=sparc
6689 echo "TARGET_ABI32=y" >> $config_target_mak
6691 s390x)
6692 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
6694 tilegx)
6696 tricore)
6698 unicore32)
6700 xtensa|xtensaeb)
6701 TARGET_ARCH=xtensa
6704 error_exit "Unsupported target CPU"
6706 esac
6707 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6708 if [ "$TARGET_BASE_ARCH" = "" ]; then
6709 TARGET_BASE_ARCH=$TARGET_ARCH
6712 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
6714 upper() {
6715 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
6718 target_arch_name="$(upper $TARGET_ARCH)"
6719 echo "TARGET_$target_arch_name=y" >> $config_target_mak
6720 echo "TARGET_NAME=$target_name" >> $config_target_mak
6721 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6722 if [ "$TARGET_ABI_DIR" = "" ]; then
6723 TARGET_ABI_DIR=$TARGET_ARCH
6725 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6726 if [ "$HOST_VARIANT_DIR" != "" ]; then
6727 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6730 if supported_xen_target $target; then
6731 echo "CONFIG_XEN=y" >> $config_target_mak
6732 if test "$xen_pci_passthrough" = yes; then
6733 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6736 if supported_kvm_target $target; then
6737 echo "CONFIG_KVM=y" >> $config_target_mak
6738 if test "$vhost_net" = "yes" ; then
6739 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6740 if test "$vhost_user" = "yes" ; then
6741 echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6745 if supported_hax_target $target; then
6746 echo "CONFIG_HAX=y" >> $config_target_mak
6748 if supported_hvf_target $target; then
6749 echo "CONFIG_HVF=y" >> $config_target_mak
6751 if test "$target_bigendian" = "yes" ; then
6752 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
6754 if test "$target_softmmu" = "yes" ; then
6755 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6756 if test "$mttcg" = "yes" ; then
6757 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6760 if test "$target_user_only" = "yes" ; then
6761 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6762 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6764 if test "$target_linux_user" = "yes" ; then
6765 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6767 list=""
6768 if test ! -z "$gdb_xml_files" ; then
6769 for x in $gdb_xml_files; do
6770 list="$list $source_path/gdb-xml/$x"
6771 done
6772 echo "TARGET_XML_FILES=$list" >> $config_target_mak
6775 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
6776 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6778 if test "$target_bsd_user" = "yes" ; then
6779 echo "CONFIG_BSD_USER=y" >> $config_target_mak
6782 # generate QEMU_CFLAGS/LDFLAGS for targets
6784 cflags=""
6785 ldflags=""
6787 disas_config() {
6788 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6789 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6792 for i in $ARCH $TARGET_BASE_ARCH ; do
6793 case "$i" in
6794 alpha)
6795 disas_config "ALPHA"
6797 aarch64)
6798 if test -n "${cxx}"; then
6799 disas_config "ARM_A64"
6802 arm)
6803 disas_config "ARM"
6804 if test -n "${cxx}"; then
6805 disas_config "ARM_A64"
6808 cris)
6809 disas_config "CRIS"
6811 hppa)
6812 disas_config "HPPA"
6814 i386|x86_64|x32)
6815 disas_config "I386"
6817 lm32)
6818 disas_config "LM32"
6820 m68k)
6821 disas_config "M68K"
6823 microblaze*)
6824 disas_config "MICROBLAZE"
6826 mips*)
6827 disas_config "MIPS"
6829 moxie*)
6830 disas_config "MOXIE"
6832 nios2)
6833 disas_config "NIOS2"
6835 or1k)
6836 disas_config "OPENRISC"
6838 ppc*)
6839 disas_config "PPC"
6841 s390*)
6842 disas_config "S390"
6844 sh4)
6845 disas_config "SH4"
6847 sparc*)
6848 disas_config "SPARC"
6850 xtensa*)
6851 disas_config "XTENSA"
6853 esac
6854 done
6855 if test "$tcg_interpreter" = "yes" ; then
6856 disas_config "TCI"
6859 case "$ARCH" in
6860 alpha)
6861 # Ensure there's only a single GP
6862 cflags="-msmall-data $cflags"
6864 esac
6866 if test "$gprof" = "yes" ; then
6867 echo "TARGET_GPROF=yes" >> $config_target_mak
6868 if test "$target_linux_user" = "yes" ; then
6869 cflags="-p $cflags"
6870 ldflags="-p $ldflags"
6872 if test "$target_softmmu" = "yes" ; then
6873 ldflags="-p $ldflags"
6874 echo "GPROF_CFLAGS=-p" >> $config_target_mak
6878 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6879 ldflags="$ldflags $textseg_ldflags"
6882 # Newer kernels on s390 check for an S390_PGSTE program header and
6883 # enable the pgste page table extensions in that case. This makes
6884 # the vm.allocate_pgste sysctl unnecessary. We enable this program
6885 # header if
6886 # - we build on s390x
6887 # - we build the system emulation for s390x (qemu-system-s390x)
6888 # - KVM is enabled
6889 # - the linker supports --s390-pgste
6890 if test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes" -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6891 if ld_has --s390-pgste ; then
6892 ldflags="-Wl,--s390-pgste $ldflags"
6896 echo "LDFLAGS+=$ldflags" >> $config_target_mak
6897 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6899 done # for target in $targets
6901 if [ "$dtc_internal" = "yes" ]; then
6902 echo "config-host.h: subdir-dtc" >> $config_host_mak
6904 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
6905 echo "config-host.h: subdir-capstone" >> $config_host_mak
6907 if test -n "$LIBCAPSTONE"; then
6908 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
6911 if test "$numa" = "yes"; then
6912 echo "CONFIG_NUMA=y" >> $config_host_mak
6915 if test "$ccache_cpp2" = "yes"; then
6916 echo "export CCACHE_CPP2=y" >> $config_host_mak
6919 # build tree in object directory in case the source is not in the current directory
6920 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
6921 DIRS="$DIRS docs docs/interop fsdev scsi"
6922 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
6923 DIRS="$DIRS roms/seabios roms/vgabios"
6924 DIRS="$DIRS qapi-generated"
6925 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6926 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6927 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6928 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6929 FILES="$FILES pc-bios/spapr-rtas/Makefile"
6930 FILES="$FILES pc-bios/s390-ccw/Makefile"
6931 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
6932 FILES="$FILES pc-bios/qemu-icon.bmp"
6933 FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6934 for bios_file in \
6935 $source_path/pc-bios/*.bin \
6936 $source_path/pc-bios/*.lid \
6937 $source_path/pc-bios/*.aml \
6938 $source_path/pc-bios/*.rom \
6939 $source_path/pc-bios/*.dtb \
6940 $source_path/pc-bios/*.img \
6941 $source_path/pc-bios/openbios-* \
6942 $source_path/pc-bios/u-boot.* \
6943 $source_path/pc-bios/palcode-*
6945 FILES="$FILES pc-bios/$(basename $bios_file)"
6946 done
6947 for test_file in $(find $source_path/tests/acpi-test-data -type f)
6949 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6950 done
6951 mkdir -p $DIRS
6952 for f in $FILES ; do
6953 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6954 symlink "$source_path/$f" "$f"
6956 done
6958 # temporary config to build submodules
6959 for rom in seabios vgabios ; do
6960 config_mak=roms/$rom/config.mak
6961 echo "# Automatically generated by configure - do not modify" > $config_mak
6962 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6963 echo "AS=$as" >> $config_mak
6964 echo "CCAS=$ccas" >> $config_mak
6965 echo "CC=$cc" >> $config_mak
6966 echo "BCC=bcc" >> $config_mak
6967 echo "CPP=$cpp" >> $config_mak
6968 echo "OBJCOPY=objcopy" >> $config_mak
6969 echo "IASL=$iasl" >> $config_mak
6970 echo "LD=$ld" >> $config_mak
6971 echo "RANLIB=$ranlib" >> $config_mak
6972 done
6974 # set up tests data directory
6975 if [ ! -e tests/data ]; then
6976 symlink "$source_path/tests/data" tests/data
6979 # set up qemu-iotests in this build directory
6980 iotests_common_env="tests/qemu-iotests/common.env"
6981 iotests_check="tests/qemu-iotests/check"
6983 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
6984 echo >> "$iotests_common_env"
6985 echo "export PYTHON='$python'" >> "$iotests_common_env"
6987 if [ ! -e "$iotests_check" ]; then
6988 symlink "$source_path/$iotests_check" "$iotests_check"
6991 # Save the configure command line for later reuse.
6992 cat <<EOD >config.status
6993 #!/bin/sh
6994 # Generated by configure.
6995 # Run this file to recreate the current configuration.
6996 # Compiler output produced by configure, useful for debugging
6997 # configure, is in config.log if it exists.
6999 printf "exec" >>config.status
7000 printf " '%s'" "$0" "$@" >>config.status
7001 echo ' "$@"' >>config.status
7002 chmod +x config.status
7004 rm -r "$TMPDIR1"