Merge remote-tracking branch 'qemu/master'
[qemu/ar7.git] / configure
blob5dc008d4c75c70c60001eb141d952642e9290b6d
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 -Wno-override-init|\
103 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
104 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
107 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
109 esac
110 done
113 compile_object() {
114 local_cflags="$1"
115 do_cc $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
118 compile_prog() {
119 local_cflags="$1"
120 local_ldflags="$2"
121 do_cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
124 # symbolically link $1 to $2. Portable version of "ln -sf".
125 symlink() {
126 rm -rf "$2"
127 mkdir -p "$(dirname "$2")"
128 ln -s "$1" "$2"
131 # check whether a command is available to this shell (may be either an
132 # executable or a builtin)
133 has() {
134 type "$1" >/dev/null 2>&1
137 # search for an executable in PATH
138 path_of() {
139 local_command="$1"
140 local_ifs="$IFS"
141 local_dir=""
143 # pathname has a dir component?
144 if [ "${local_command#*/}" != "$local_command" ]; then
145 if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
146 echo "$local_command"
147 return 0
150 if [ -z "$local_command" ]; then
151 return 1
154 IFS=:
155 for local_dir in $PATH; do
156 if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
157 echo "$local_dir/$local_command"
158 IFS="${local_ifs:-$(printf ' \t\n')}"
159 return 0
161 done
162 # not found
163 IFS="${local_ifs:-$(printf ' \t\n')}"
164 return 1
167 have_backend () {
168 echo "$trace_backends" | grep "$1" >/dev/null
171 glob() {
172 eval test -z '"${1#'"$2"'}"'
175 supported_hax_target() {
176 test "$hax" = "yes" || return 1
177 glob "$1" "*-softmmu" || return 1
178 case "${1%-softmmu}" in
179 i386|x86_64)
180 return 0
182 esac
183 return 1
186 supported_kvm_target() {
187 test "$kvm" = "yes" || return 1
188 glob "$1" "*-softmmu" || return 1
189 case "${1%-softmmu}:$cpu" in
190 arm:arm | aarch64:aarch64 | \
191 i386:i386 | i386:x86_64 | i386:x32 | \
192 x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
193 mips:mips | mipsel:mips | \
194 ppc:ppc | ppcemb:ppc | ppc64:ppc | \
195 ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
196 s390x:s390x)
197 return 0
199 esac
200 return 1
203 supported_xen_target() {
204 test "$xen" = "yes" || return 1
205 glob "$1" "*-softmmu" || return 1
206 # Only i386 and x86_64 provide the xenpv machine.
207 case "${1%-softmmu}" in
208 i386|x86_64)
209 return 0
211 esac
212 return 1
215 supported_hvf_target() {
216 test "$hvf" = "yes" || return 1
217 glob "$1" "*-softmmu" || return 1
218 case "${1%-softmmu}" in
219 x86_64)
220 return 0
222 esac
223 return 1
226 supported_target() {
227 case "$1" in
228 *-softmmu)
230 *-linux-user)
231 if test "$linux" != "yes"; then
232 print_error "Target '$target' is only available on a Linux host"
233 return 1
236 *-bsd-user)
237 if test "$bsd" != "yes"; then
238 print_error "Target '$target' is only available on a BSD host"
239 return 1
243 print_error "Invalid target name '$target'"
244 return 1
246 esac
247 test "$tcg" = "yes" && return 0
248 supported_kvm_target "$1" && return 0
249 supported_xen_target "$1" && return 0
250 supported_hax_target "$1" && return 0
251 supported_hvf_target "$1" && return 0
252 print_error "TCG disabled, but hardware accelerator not available for '$target'"
253 return 1
257 ld_has() {
258 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
261 # default parameters
262 source_path=$(dirname "$0")
263 cpu=""
264 iasl="iasl"
265 interp_prefix="/usr/gnemul/qemu-%M"
266 static="no"
267 cross_prefix=""
268 audio_drv_list=""
269 block_drv_rw_whitelist=""
270 block_drv_ro_whitelist=""
271 host_cc="cc"
272 libs_softmmu=""
273 libs_tools=""
274 audio_pt_int=""
275 audio_win_int=""
276 cc_i386=i386-pc-linux-gnu-gcc
277 libs_qga=""
278 debug_info="yes"
279 stack_protector=""
281 if test -e "$source_path/.git"
282 then
283 git_update=yes
284 git_submodules="ui/keycodemapdb"
285 else
286 git_update=no
287 git_submodules=""
289 git="git"
291 # Don't accept a target_list environment variable.
292 unset target_list
294 # Default value for a variable defining feature "foo".
295 # * foo="no" feature will only be used if --enable-foo arg is given
296 # * foo="" feature will be searched for, and if found, will be used
297 # unless --disable-foo is given
298 # * foo="yes" this value will only be set by --enable-foo flag.
299 # feature will searched for,
300 # if not found, configure exits with error
302 # Always add --enable-foo and --disable-foo command line args.
303 # Distributions want to ensure that several features are compiled in, and it
304 # is impossible without a --enable-foo that exits if a feature is not found.
306 bluez=""
307 brlapi=""
308 curl=""
309 curses=""
310 docs=""
311 fdt=""
312 netmap="no"
313 sdl=""
314 sdlabi=""
315 virtfs=""
316 mpath=""
317 vnc="yes"
318 sparse="no"
319 vde=""
320 vnc_sasl=""
321 vnc_jpeg=""
322 vnc_png=""
323 xkbcommon=""
324 xen=""
325 xen_ctrl_version=""
326 xen_pv_domain_build="no"
327 xen_pci_passthrough=""
328 linux_aio=""
329 cap_ng=""
330 attr=""
331 libattr=""
332 xfs=""
333 tcg="yes"
335 vhost_net="no"
336 vhost_scsi="no"
337 vhost_vsock="no"
338 vhost_user=""
339 kvm="no"
340 hax="no"
341 hvf="no"
342 rdma=""
343 gprof="no"
344 debug_tcg="no"
345 debug="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 haiku="no"
373 linux="no"
374 solaris="no"
375 profiler="no"
376 cocoa="no"
377 softmmu="yes"
378 linux_user="no"
379 bsd_user="no"
380 blobs="yes"
381 pkgversion=""
382 pie=""
383 qom_cast_debug="yes"
384 trace_backends="log"
385 trace_file="trace"
386 spice=""
387 rbd=""
388 smartcard=""
389 libusb=""
390 usb_redir=""
391 opengl=""
392 opengl_dmabuf="no"
393 cpuid_h="no"
394 avx2_opt="no"
395 zlib="yes"
396 capstone=""
397 lzo=""
398 snappy=""
399 bzip2=""
400 guest_agent=""
401 guest_agent_with_vss="no"
402 guest_agent_ntddscsi="no"
403 guest_agent_msi=""
404 vss_win32_sdk=""
405 win_sdk="no"
406 want_tools="yes"
407 libiscsi=""
408 libnfs=""
409 coroutine=""
410 coroutine_pool=""
411 debug_stack_usage="no"
412 crypto_afalg="no"
413 seccomp=""
414 glusterfs=""
415 glusterfs_xlator_opt="no"
416 glusterfs_discard="no"
417 glusterfs_fallocate="no"
418 glusterfs_zerofill="no"
419 gtk=""
420 gtkabi=""
421 gtk_gl="no"
422 tls_priority="NORMAL"
423 gnutls=""
424 gnutls_rnd=""
425 nettle=""
426 nettle_kdf="no"
427 gcrypt=""
428 gcrypt_hmac="no"
429 gcrypt_kdf="no"
430 vte=""
431 virglrenderer=""
432 tpm="yes"
433 libssh2=""
434 live_block_migration="yes"
435 numa=""
436 tcmalloc="no"
437 jemalloc="no"
438 replication="yes"
439 vxhs=""
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="-Wmissing-format-attribute $QEMU_CFLAGS"
524 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
525 QEMU_CFLAGS="-Wno-unused-parameter $QEMU_CFLAGS"
526 QEMU_CFLAGS="-Wno-missing-field-initializers $QEMU_CFLAGS"
527 QEMU_CFLAGS="-Wno-sign-compare $QEMU_CFLAGS"
528 QEMU_CFLAGS="-Wno-override-init $QEMU_CFLAGS"
529 QEMU_CFLAGS="-Wno-error=format $QEMU_CFLAGS"
530 QEMU_CFLAGS="-Wno-error=format-extra-args $QEMU_CFLAGS"
531 QEMU_CFLAGS="-Wno-error=parentheses $QEMU_CFLAGS"
532 QEMU_CFLAGS="-Wextra $QEMU_CFLAGS"
533 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
534 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
535 if test "$debug_info" = "yes"; then
536 CFLAGS="-g $CFLAGS"
537 LDFLAGS="-g $LDFLAGS"
540 # make source path absolute
541 source_path=$(cd "$source_path"; pwd)
543 cc_macros=$($cc $QEMU_CFLAGS -E -dD - </dev/null)
545 # running configure in the source tree?
546 # we know that's the case if configure is there.
547 if test -f "./configure"; then
548 pwd_is_source_path="y"
549 else
550 pwd_is_source_path="n"
553 check_define() {
554 rm -f $TMPC
555 cat > $TMPC <<EOF
556 #if !defined($1)
557 #error $1 not defined
558 #endif
559 int main(void) { return 0; }
561 compile_object
564 check_include() {
565 cat > $TMPC <<EOF
566 #include <$1>
567 int main(void) { return 0; }
569 compile_object
572 write_c_skeleton() {
573 cat > $TMPC <<EOF
574 int main(void) { return 0; }
578 if check_define __linux__ ; then
579 targetos="Linux"
580 elif check_define _WIN32 ; then
581 targetos='MINGW32'
582 elif check_define __OpenBSD__ ; then
583 targetos='OpenBSD'
584 elif check_define __sun__ ; then
585 targetos='SunOS'
586 elif check_define __HAIKU__ ; then
587 targetos='Haiku'
588 elif check_define __FreeBSD__ ; then
589 targetos='FreeBSD'
590 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
591 targetos='GNU/kFreeBSD'
592 elif check_define __DragonFly__ ; then
593 targetos='DragonFly'
594 elif check_define __NetBSD__; then
595 targetos='NetBSD'
596 elif check_define __APPLE__; then
597 targetos='Darwin'
598 else
599 # This is a fatal error, but don't report it yet, because we
600 # might be going to just print the --help text, or it might
601 # be the result of a missing compiler.
602 targetos='bogus'
603 bogus_os='yes'
606 # Some host OSes need non-standard checks for which CPU to use.
607 # Note that these checks are broken for cross-compilation: if you're
608 # cross-compiling to one of these OSes then you'll need to specify
609 # the correct CPU with the --cpu option.
610 case $targetos in
611 Darwin)
612 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
613 # run 64-bit userspace code.
614 # If the user didn't specify a CPU explicitly and the kernel says this is
615 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
616 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
617 cpu="x86_64"
620 SunOS)
621 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
622 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
623 cpu="x86_64"
625 esac
627 if test ! -z "$cpu" ; then
628 # command line argument
630 elif check_define __i386__ ; then
631 cpu="i386"
632 elif check_define __x86_64__ ; then
633 if check_define __ILP32__ ; then
634 cpu="x32"
635 else
636 cpu="x86_64"
638 elif check_define __sparc__ ; then
639 if check_define __arch64__ ; then
640 cpu="sparc64"
641 else
642 cpu="sparc"
644 elif check_define _ARCH_PPC ; then
645 if check_define _ARCH_PPC64 ; then
646 cpu="ppc64"
647 else
648 cpu="ppc"
650 elif check_define __mips__ ; then
651 if check_define __mips64 ; then
652 cpu="mips64"
653 else
654 cpu="mips"
656 elif check_define __ia64__ ; then
657 cpu="ia64"
658 elif check_define __s390__ ; then
659 if check_define __s390x__ ; then
660 cpu="s390x"
661 else
662 cpu="s390"
664 elif check_define __arm__ ; then
665 cpu="arm"
666 elif check_define __aarch64__ ; then
667 cpu="aarch64"
668 else
669 cpu=$(uname -m)
672 ARCH=
673 # Normalise host CPU name and set ARCH.
674 # Note that this case should only have supported host CPUs, not guests.
675 case "$cpu" in
676 ppc|ppc64|s390|s390x|sparc64|x32)
677 cpu="$cpu"
678 supported_cpu="yes"
680 i386|i486|i586|i686|i86pc|BePC)
681 cpu="i386"
682 supported_cpu="yes"
684 x86_64|amd64)
685 cpu="x86_64"
686 supported_cpu="yes"
688 armv*b|armv*l|arm)
689 cpu="arm"
690 supported_cpu="yes"
692 aarch64)
693 cpu="aarch64"
694 supported_cpu="yes"
696 mips*)
697 cpu="mips"
698 if check_define __MIPSEL__ ; then
699 cpu="${cpu}el"
701 supported_cpu="yes"
703 sparc|sun4[cdmuv])
704 cpu="sparc"
705 supported_cpu="yes"
707 sh4)
708 cpu="sh4"
711 # This will result in either an error or falling back to TCI later
712 ARCH=unknown
714 esac
715 if test -z "$ARCH"; then
716 ARCH="$cpu"
719 # OS specific
721 # host *BSD for user mode
722 HOST_VARIANT_DIR=""
724 case $targetos in
725 MINGW32*)
726 mingw32="yes"
727 hax="yes"
728 audio_possible_drivers="dsound sdl"
729 if check_include dsound.h; then
730 audio_drv_list="dsound"
731 else
732 audio_drv_list=""
734 supported_os="yes"
736 GNU/kFreeBSD)
737 bsd="yes"
738 audio_drv_list="oss"
739 audio_possible_drivers="oss sdl pa"
741 FreeBSD)
742 bsd="yes"
743 make="${MAKE-gmake}"
744 audio_drv_list="oss"
745 audio_possible_drivers="oss sdl pa"
746 # needed for kinfo_getvmmap(3) in libutil.h
747 LIBS="-lutil $LIBS"
748 # needed for kinfo_getproc
749 libs_qga="-lutil $libs_qga"
750 netmap="" # enable netmap autodetect
751 HOST_VARIANT_DIR="freebsd"
752 supported_os="yes"
754 DragonFly)
755 bsd="yes"
756 make="${MAKE-gmake}"
757 audio_drv_list="oss"
758 audio_possible_drivers="oss sdl pa"
759 HOST_VARIANT_DIR="dragonfly"
761 NetBSD)
762 bsd="yes"
763 make="${MAKE-gmake}"
764 audio_drv_list="oss"
765 audio_possible_drivers="oss sdl"
766 oss_lib="-lossaudio"
767 HOST_VARIANT_DIR="netbsd"
768 supported_os="yes"
770 OpenBSD)
771 bsd="yes"
772 make="${MAKE-gmake}"
773 audio_drv_list="sdl"
774 audio_possible_drivers="sdl"
775 HOST_VARIANT_DIR="openbsd"
777 Darwin)
778 bsd="yes"
779 darwin="yes"
780 hax="yes"
781 hvf="yes"
782 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
783 if [ "$cpu" = "x86_64" ] ; then
784 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
785 LDFLAGS="-arch x86_64 $LDFLAGS"
787 cocoa="yes"
788 audio_drv_list="coreaudio"
789 audio_possible_drivers="coreaudio sdl"
790 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
791 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
792 # Disable attempts to use ObjectiveC features in os/object.h since they
793 # won't work when we're compiling with gcc as a C compiler.
794 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
795 HOST_VARIANT_DIR="darwin"
796 supported_os="yes"
798 SunOS)
799 solaris="yes"
800 make="${MAKE-gmake}"
801 install="${INSTALL-ginstall}"
802 smbd="${SMBD-/usr/sfw/sbin/smbd}"
803 if test -f /usr/include/sys/soundcard.h ; then
804 audio_drv_list="oss"
806 audio_possible_drivers="oss sdl"
807 # needed for CMSG_ macros in sys/socket.h
808 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
809 # needed for TIOCWIN* defines in termios.h
810 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
811 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
812 solarisnetlibs="-lsocket -lnsl -lresolv"
813 LIBS="$solarisnetlibs $LIBS"
814 libs_qga="$solarisnetlibs $libs_qga"
816 Haiku)
817 haiku="yes"
818 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
819 LIBS="-lposix_error_mapper -lnetwork $LIBS"
821 Linux)
822 audio_drv_list="oss"
823 audio_possible_drivers="oss alsa sdl pa"
824 linux="yes"
825 linux_user="yes"
826 kvm="yes"
827 vhost_net="yes"
828 vhost_scsi="yes"
829 vhost_vsock="yes"
830 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
831 supported_os="yes"
833 esac
835 if [ "$bsd" = "yes" ] ; then
836 if [ "$darwin" != "yes" ] ; then
837 bsd_user="yes"
841 : ${make=${MAKE-make}}
842 : ${install=${INSTALL-install}}
843 : ${python=${PYTHON-python}}
844 : ${smbd=${SMBD-/usr/sbin/smbd}}
846 # Default objcc to clang if available, otherwise use CC
847 if has clang; then
848 objcc=clang
849 else
850 objcc="$cc"
853 if test "$mingw32" = "yes" ; then
854 EXESUF=".exe"
855 DSOSUF=".dll"
856 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
857 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
858 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
859 # MinGW-w64 needs _POSIX defined.
860 QEMU_CFLAGS="-D_POSIX=1 $QEMU_CFLAGS"
861 # MinGW needs -mthreads for TLS and macro _MT.
862 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
863 QEMU_CFLAGS="-I\$(SRC_PATH)/hosts/w32/include $QEMU_CFLAGS"
864 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
865 write_c_skeleton;
866 if compile_prog "" "-liberty" ; then
867 LIBS="-liberty $LIBS"
869 prefix="c:/Program Files/QEMU"
870 mandir="\${prefix}"
871 datadir="\${prefix}"
872 qemu_docdir="\${prefix}"
873 bindir="\${prefix}"
874 sysconfdir="\${prefix}"
875 local_statedir=
876 confsuffix=""
877 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
880 werror=""
882 for opt do
883 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
884 case "$opt" in
885 --help|-h) show_help=yes
887 --version|-V) exec cat $source_path/VERSION
889 --prefix=*) prefix="$optarg"
891 --interp-prefix=*) interp_prefix="$optarg"
893 --source-path=*)
895 --cross-prefix=*)
897 --cc=*)
899 --host-cc=*) host_cc="$optarg"
901 --cxx=*)
903 --iasl=*) iasl="$optarg"
905 --objcc=*) objcc="$optarg"
907 --make=*) make="$optarg"
909 --install=*) install="$optarg"
911 --python=*) python="$optarg"
913 --gcov=*) gcov_tool="$optarg"
915 --smbd=*) smbd="$optarg"
917 --extra-cflags=*)
919 --extra-cxxflags=*)
921 --extra-ldflags=*)
923 --enable-debug-info)
925 --disable-debug-info)
927 --enable-modules)
928 modules="yes"
930 --disable-modules)
931 modules="no"
933 --cpu=*)
935 --target-list=*) target_list="$optarg"
937 --enable-trace-backends=*) trace_backends="$optarg"
939 # XXX: backwards compatibility
940 --enable-trace-backend=*) trace_backends="$optarg"
942 --with-trace-file=*) trace_file="$optarg"
944 --enable-gprof) gprof="yes"
946 --enable-gcov) gcov="yes"
948 --static)
949 static="yes"
950 LDFLAGS="-static $LDFLAGS"
951 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
953 --mandir=*) mandir="$optarg"
955 --bindir=*) bindir="$optarg"
957 --libdir=*) libdir="$optarg"
959 --libexecdir=*) libexecdir="$optarg"
961 --includedir=*) includedir="$optarg"
963 --datadir=*) datadir="$optarg"
965 --with-confsuffix=*) confsuffix="$optarg"
967 --docdir=*) qemu_docdir="$optarg"
969 --sysconfdir=*) sysconfdir="$optarg"
971 --localstatedir=*) local_statedir="$optarg"
973 --firmwarepath=*) firmwarepath="$optarg"
975 --sbindir=*|--sharedstatedir=*|\
976 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
977 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
978 # These switches are silently ignored, for compatibility with
979 # autoconf-generated configure scripts. This allows QEMU's
980 # configure to be used by RPM and similar macros that set
981 # lots of directory switches by default.
983 --disable-sdl) sdl="no"
985 --enable-sdl) sdl="yes"
987 --with-sdlabi=*) sdlabi="$optarg"
989 --disable-qom-cast-debug) qom_cast_debug="no"
991 --enable-qom-cast-debug) qom_cast_debug="yes"
993 --disable-virtfs) virtfs="no"
995 --enable-virtfs) virtfs="yes"
997 --disable-mpath) mpath="no"
999 --enable-mpath) mpath="yes"
1001 --disable-vnc) vnc="no"
1003 --enable-vnc) vnc="yes"
1005 --oss-lib=*) oss_lib="$optarg"
1007 --audio-drv-list=*) audio_drv_list="$optarg"
1009 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1011 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1013 --enable-debug-tcg) debug_tcg="yes"
1015 --disable-debug-tcg) debug_tcg="no"
1017 --enable-debug)
1018 # Enable debugging options that aren't excessively noisy
1019 debug_tcg="yes"
1020 debug="yes"
1021 strip_opt="no"
1022 fortify_source="no"
1024 --enable-sparse) sparse="yes"
1026 --disable-sparse) sparse="no"
1028 --disable-strip) strip_opt="no"
1030 --disable-vnc-sasl) vnc_sasl="no"
1032 --enable-vnc-sasl) vnc_sasl="yes"
1034 --disable-vnc-jpeg) vnc_jpeg="no"
1036 --enable-vnc-jpeg) vnc_jpeg="yes"
1038 --disable-vnc-png) vnc_png="no"
1040 --enable-vnc-png) vnc_png="yes"
1042 --disable-slirp) slirp="no"
1044 --disable-vde) vde="no"
1046 --enable-vde) vde="yes"
1048 --disable-netmap) netmap="no"
1050 --enable-netmap) netmap="yes"
1052 --disable-xen) xen="no"
1054 --enable-xen) xen="yes"
1056 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1058 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1060 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
1062 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
1064 --disable-brlapi) brlapi="no"
1066 --enable-brlapi) brlapi="yes"
1068 --disable-bluez) bluez="no"
1070 --enable-bluez) bluez="yes"
1072 --disable-kvm) kvm="no"
1074 --enable-kvm) kvm="yes"
1076 --disable-hax) hax="no"
1078 --enable-hax) hax="yes"
1080 --disable-hvf) hvf="no"
1082 --enable-hvf) hvf="yes"
1084 --disable-tcg-interpreter) tcg_interpreter="no"
1086 --enable-tcg-interpreter) tcg_interpreter="yes"
1088 --disable-cap-ng) cap_ng="no"
1090 --enable-cap-ng) cap_ng="yes"
1092 --disable-tcg) tcg="no"
1094 --enable-tcg) tcg="yes"
1096 --disable-malloc-trim) malloc_trim="no"
1098 --enable-malloc-trim) malloc_trim="yes"
1100 --disable-spice) spice="no"
1102 --enable-spice) spice="yes"
1104 --disable-libiscsi) libiscsi="no"
1106 --enable-libiscsi) libiscsi="yes"
1108 --disable-libnfs) libnfs="no"
1110 --enable-libnfs) libnfs="yes"
1112 --enable-profiler) profiler="yes"
1114 --disable-cocoa) cocoa="no"
1116 --enable-cocoa)
1117 cocoa="yes" ;
1118 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1120 --disable-system) softmmu="no"
1122 --enable-system) softmmu="yes"
1124 --disable-user)
1125 linux_user="no" ;
1126 bsd_user="no" ;
1128 --enable-user) ;;
1129 --disable-linux-user) linux_user="no"
1131 --enable-linux-user) linux_user="yes"
1133 --disable-bsd-user) bsd_user="no"
1135 --enable-bsd-user) bsd_user="yes"
1137 --enable-pie) pie="yes"
1139 --disable-pie) pie="no"
1141 --enable-werror) werror="yes"
1143 --disable-werror) werror="no"
1145 --enable-stack-protector) stack_protector="yes"
1147 --disable-stack-protector) stack_protector="no"
1149 --disable-curses) curses="no"
1151 --enable-curses) curses="yes"
1153 --disable-curl) curl="no"
1155 --enable-curl) curl="yes"
1157 --disable-fdt) fdt="no"
1159 --enable-fdt) fdt="yes"
1161 --disable-linux-aio) linux_aio="no"
1163 --enable-linux-aio) linux_aio="yes"
1165 --disable-attr) attr="no"
1167 --enable-attr) attr="yes"
1169 --disable-blobs) blobs="no"
1171 --with-pkgversion=*) pkgversion=" ($optarg)"
1173 --with-coroutine=*) coroutine="$optarg"
1175 --disable-coroutine-pool) coroutine_pool="no"
1177 --enable-coroutine-pool) coroutine_pool="yes"
1179 --enable-debug-stack-usage) debug_stack_usage="yes"
1181 --enable-crypto-afalg) crypto_afalg="yes"
1183 --disable-crypto-afalg) crypto_afalg="no"
1185 --disable-docs) docs="no"
1187 --enable-docs) docs="yes"
1189 --disable-vhost-net) vhost_net="no"
1191 --enable-vhost-net) vhost_net="yes"
1193 --disable-vhost-scsi) vhost_scsi="no"
1195 --enable-vhost-scsi) vhost_scsi="yes"
1197 --disable-vhost-vsock) vhost_vsock="no"
1199 --enable-vhost-vsock) vhost_vsock="yes"
1201 --disable-opengl) opengl="no"
1203 --enable-opengl) opengl="yes"
1205 --disable-rbd) rbd="no"
1207 --enable-rbd) rbd="yes"
1209 --disable-xfsctl) xfs="no"
1211 --enable-xfsctl) xfs="yes"
1213 --disable-smartcard) smartcard="no"
1215 --enable-smartcard) smartcard="yes"
1217 --disable-libusb) libusb="no"
1219 --enable-libusb) libusb="yes"
1221 --disable-usb-redir) usb_redir="no"
1223 --enable-usb-redir) usb_redir="yes"
1225 --disable-zlib-test) zlib="no"
1227 --disable-lzo) lzo="no"
1229 --enable-lzo) lzo="yes"
1231 --disable-snappy) snappy="no"
1233 --enable-snappy) snappy="yes"
1235 --disable-bzip2) bzip2="no"
1237 --enable-bzip2) bzip2="yes"
1239 --enable-guest-agent) guest_agent="yes"
1241 --disable-guest-agent) guest_agent="no"
1243 --enable-guest-agent-msi) guest_agent_msi="yes"
1245 --disable-guest-agent-msi) guest_agent_msi="no"
1247 --with-vss-sdk) vss_win32_sdk=""
1249 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1251 --without-vss-sdk) vss_win32_sdk="no"
1253 --with-win-sdk) win_sdk=""
1255 --with-win-sdk=*) win_sdk="$optarg"
1257 --without-win-sdk) win_sdk="no"
1259 --enable-tools) want_tools="yes"
1261 --disable-tools) want_tools="no"
1263 --enable-seccomp) seccomp="yes"
1265 --disable-seccomp) seccomp="no"
1267 --disable-glusterfs) glusterfs="no"
1269 --enable-glusterfs) glusterfs="yes"
1271 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1272 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1274 --enable-vhdx|--disable-vhdx)
1275 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1277 --enable-uuid|--disable-uuid)
1278 echo "$0: $opt is obsolete, UUID support is always built" >&2
1280 --disable-gtk) gtk="no"
1282 --enable-gtk) gtk="yes"
1284 --tls-priority=*) tls_priority="$optarg"
1286 --disable-gnutls) gnutls="no"
1288 --enable-gnutls) gnutls="yes"
1290 --disable-nettle) nettle="no"
1292 --enable-nettle) nettle="yes"
1294 --disable-gcrypt) gcrypt="no"
1296 --enable-gcrypt) gcrypt="yes"
1298 --enable-rdma) rdma="yes"
1300 --disable-rdma) rdma="no"
1302 --with-gtkabi=*) gtkabi="$optarg"
1304 --disable-vte) vte="no"
1306 --enable-vte) vte="yes"
1308 --disable-virglrenderer) virglrenderer="no"
1310 --enable-virglrenderer) virglrenderer="yes"
1312 --disable-tpm) tpm="no"
1314 --enable-tpm) tpm="yes"
1316 --disable-libssh2) libssh2="no"
1318 --enable-libssh2) libssh2="yes"
1320 --disable-live-block-migration) live_block_migration="no"
1322 --enable-live-block-migration) live_block_migration="yes"
1324 --disable-numa) numa="no"
1326 --enable-numa) numa="yes"
1328 --disable-tcmalloc) tcmalloc="no"
1330 --enable-tcmalloc) tcmalloc="yes"
1332 --disable-jemalloc) jemalloc="no"
1334 --enable-jemalloc) jemalloc="yes"
1336 --disable-replication) replication="no"
1338 --enable-replication) replication="yes"
1340 --disable-vxhs) vxhs="no"
1342 --enable-vxhs) vxhs="yes"
1344 --disable-vhost-user) vhost_user="no"
1346 --enable-vhost-user)
1347 vhost_user="yes"
1348 if test "$mingw32" = "yes"; then
1349 error_exit "vhost-user isn't available on win32"
1352 --disable-capstone) capstone="no"
1354 --enable-capstone) capstone="yes"
1356 --enable-capstone=git) capstone="git"
1358 --enable-capstone=system) capstone="system"
1360 --with-git=*) git="$optarg"
1362 --enable-git-update) git_update=yes
1364 --disable-git-update) git_update=no
1367 echo "ERROR: unknown option $opt"
1368 echo "Try '$0 --help' for more information"
1369 exit 1
1371 esac
1372 done
1374 if test "$vhost_user" = ""; then
1375 if test "$mingw32" = "yes"; then
1376 vhost_user="no"
1377 else
1378 vhost_user="yes"
1382 case "$cpu" in
1383 ppc)
1384 CPU_CFLAGS="-m32"
1385 LDFLAGS="-m32 $LDFLAGS"
1387 ppc64)
1388 CPU_CFLAGS="-m64"
1389 LDFLAGS="-m64 $LDFLAGS"
1391 sparc)
1392 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1393 LDFLAGS="-m32 -mv8plus $LDFLAGS"
1395 sparc64)
1396 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1397 LDFLAGS="-m64 $LDFLAGS"
1399 s390)
1400 CPU_CFLAGS="-m31"
1401 LDFLAGS="-m31 $LDFLAGS"
1403 s390x)
1404 CPU_CFLAGS="-m64"
1405 LDFLAGS="-m64 $LDFLAGS"
1407 i386)
1408 CPU_CFLAGS="-m32"
1409 LDFLAGS="-m32 $LDFLAGS"
1410 cc_i386='$(CC) -m32'
1412 x86_64)
1413 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1414 # If we truly care, we should simply detect this case at
1415 # runtime and generate the fallback to serial emulation.
1416 CPU_CFLAGS="-m64 -mcx16"
1417 LDFLAGS="-m64 $LDFLAGS"
1418 cc_i386='$(CC) -m32'
1420 x32)
1421 CPU_CFLAGS="-mx32"
1422 LDFLAGS="-mx32 $LDFLAGS"
1423 cc_i386='$(CC) -m32'
1425 # No special flags required for other host CPUs
1426 esac
1428 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1429 EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1431 # For user-mode emulation the host arch has to be one we explicitly
1432 # support, even if we're using TCI.
1433 if [ "$ARCH" = "unknown" ]; then
1434 bsd_user="no"
1435 linux_user="no"
1438 default_target_list=""
1440 mak_wilds=""
1442 if [ "$softmmu" = "yes" ]; then
1443 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1445 if [ "$linux_user" = "yes" ]; then
1446 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1448 if [ "$bsd_user" = "yes" ]; then
1449 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1452 for config in $mak_wilds; do
1453 default_target_list="${default_target_list} $(basename "$config" .mak)"
1454 done
1456 # Enumerate public trace backends for --help output
1457 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1459 if test x"$show_help" = x"yes" ; then
1460 cat << EOF
1462 Usage: configure [options]
1463 Options: [defaults in brackets after descriptions]
1465 Standard options:
1466 --help print this message
1467 --prefix=PREFIX install in PREFIX [$prefix]
1468 --interp-prefix=PREFIX where to find shared libraries, etc.
1469 use %M for cpu name [$interp_prefix]
1470 --target-list=LIST set target list (default: build everything)
1471 $(echo Available targets: $default_target_list | \
1472 fold -s -w 53 | sed -e 's/^/ /')
1474 Advanced options (experts only):
1475 --source-path=PATH path of source code [$source_path]
1476 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1477 --cc=CC use C compiler CC [$cc]
1478 --iasl=IASL use ACPI compiler IASL [$iasl]
1479 --host-cc=CC use C compiler CC [$host_cc] for code run at
1480 build time
1481 --cxx=CXX use C++ compiler CXX [$cxx]
1482 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1483 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1484 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1485 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1486 --make=MAKE use specified make [$make]
1487 --install=INSTALL use specified install [$install]
1488 --python=PYTHON use specified python [$python]
1489 --smbd=SMBD use specified smbd [$smbd]
1490 --static enable static build [$static]
1491 --mandir=PATH install man pages in PATH
1492 --datadir=PATH install firmware in PATH$confsuffix
1493 --docdir=PATH install documentation in PATH$confsuffix
1494 --bindir=PATH install binaries in PATH
1495 --libdir=PATH install libraries in PATH
1496 --sysconfdir=PATH install config in PATH$confsuffix
1497 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1498 --firmwarepath=PATH search PATH for firmware files
1499 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1500 --enable-debug enable common debug build options
1501 --disable-strip disable stripping binaries
1502 --disable-werror disable compilation abort on warning
1503 --disable-stack-protector disable compiler-provided stack protection
1504 --audio-drv-list=LIST set audio drivers list:
1505 Available drivers: $audio_possible_drivers
1506 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1507 --block-drv-rw-whitelist=L
1508 set block driver read-write whitelist
1509 (affects only QEMU, not qemu-img)
1510 --block-drv-ro-whitelist=L
1511 set block driver read-only whitelist
1512 (affects only QEMU, not qemu-img)
1513 --enable-trace-backends=B Set trace backend
1514 Available backends: $trace_backend_list
1515 --with-trace-file=NAME Full PATH,NAME of file to store traces
1516 Default:trace-<pid>
1517 --disable-slirp disable SLIRP userspace network connectivity
1518 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1519 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1520 --oss-lib path to OSS library
1521 --cpu=CPU Build for host CPU [$cpu]
1522 --with-coroutine=BACKEND coroutine backend. Supported options:
1523 ucontext, sigaltstack, windows
1524 --enable-gcov enable test coverage analysis with gcov
1525 --gcov=GCOV use specified gcov [$gcov_tool]
1526 --disable-blobs disable installing provided firmware blobs
1527 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1528 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1529 --tls-priority default TLS protocol/cipher priority string
1530 --enable-gprof QEMU profiling with gprof
1531 --enable-profiler profiler support
1532 --enable-xen-pv-domain-build
1533 xen pv domain builder
1534 --enable-debug-stack-usage
1535 track the maximum stack usage of stacks created by qemu_alloc_stack
1537 Optional features, enabled with --enable-FEATURE and
1538 disabled with --disable-FEATURE, default is enabled if available:
1540 system all system emulation targets
1541 user supported user emulation targets
1542 linux-user all linux usermode emulation targets
1543 bsd-user all BSD usermode emulation targets
1544 docs build documentation
1545 guest-agent build the QEMU Guest Agent
1546 guest-agent-msi build guest agent Windows MSI installation package
1547 pie Position Independent Executables
1548 modules modules support
1549 debug-tcg TCG debugging (default is disabled)
1550 debug-info debugging information
1551 sparse sparse checker
1553 gnutls GNUTLS cryptography support
1554 nettle nettle cryptography support
1555 gcrypt libgcrypt cryptography support
1556 sdl SDL UI
1557 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1558 gtk gtk UI
1559 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1560 vte vte support for the gtk UI
1561 curses curses UI
1562 vnc VNC UI support
1563 vnc-sasl SASL encryption for VNC server
1564 vnc-jpeg JPEG lossy compression for VNC server
1565 vnc-png PNG compression for VNC server
1566 cocoa Cocoa UI (Mac OS X only)
1567 virtfs VirtFS
1568 mpath Multipath persistent reservation passthrough
1569 xen xen backend driver support
1570 xen-pci-passthrough
1571 brlapi BrlAPI (Braile)
1572 curl curl connectivity
1573 fdt fdt device tree
1574 bluez bluez stack connectivity
1575 kvm KVM acceleration support
1576 hax HAX acceleration support
1577 hvf Hypervisor.framework acceleration support
1578 rdma RDMA-based migration support
1579 vde support for vde network
1580 netmap support for netmap network
1581 linux-aio Linux AIO support
1582 cap-ng libcap-ng support
1583 attr attr and xattr support
1584 vhost-net vhost-net acceleration support
1585 spice spice
1586 rbd rados block device (rbd)
1587 libiscsi iscsi support
1588 libnfs nfs support
1589 smartcard smartcard support (libcacard)
1590 libusb libusb (for usb passthrough)
1591 live-block-migration Block migration in the main migration stream
1592 usb-redir usb network redirection support
1593 lzo support of lzo compression library
1594 snappy support of snappy compression library
1595 bzip2 support of bzip2 compression library
1596 (for reading bzip2-compressed dmg images)
1597 seccomp seccomp support
1598 coroutine-pool coroutine freelist (better performance)
1599 glusterfs GlusterFS backend
1600 tpm TPM support
1601 libssh2 ssh block device support
1602 numa libnuma support
1603 tcmalloc tcmalloc support
1604 jemalloc jemalloc support
1605 replication replication support
1606 vhost-vsock virtio sockets device support
1607 opengl opengl support
1608 virglrenderer virgl rendering support
1609 xfsctl xfsctl support
1610 qom-cast-debug cast debugging support
1611 tools build qemu-io, qemu-nbd and qemu-image tools
1612 vxhs Veritas HyperScale vDisk backend support
1613 crypto-afalg Linux AF_ALG crypto backend driver
1614 vhost-user vhost-user support
1615 capstone capstone disassembler support
1617 NOTE: The object files are built at the place where configure is launched
1619 exit 0
1622 if ! has $python; then
1623 error_exit "Python not found. Use --python=/path/to/python"
1626 # Note that if the Python conditional here evaluates True we will exit
1627 # with status 1 which is a shell 'false' value.
1628 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1629 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1630 "Note that Python 3 or later is not yet supported." \
1631 "Use --python=/path/to/python to specify a supported Python."
1634 # Suppress writing compiled files
1635 python="$python -B"
1637 # Check that the C compiler works. Doing this here before testing
1638 # the host CPU ensures that we had a valid CC to autodetect the
1639 # $cpu var (and we should bail right here if that's not the case).
1640 # It also allows the help message to be printed without a CC.
1641 write_c_skeleton;
1642 if compile_object ; then
1643 : C compiler works ok
1644 else
1645 error_exit "\"$cc\" either does not exist or does not work"
1647 if ! compile_prog ; then
1648 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1651 # Now we have handled --enable-tcg-interpreter and know we're not just
1652 # printing the help message, bail out if the host CPU isn't supported.
1653 if test "$ARCH" = "unknown"; then
1654 if test "$tcg_interpreter" = "yes" ; then
1655 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1656 else
1657 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1661 # Consult white-list to determine whether to enable werror
1662 # by default. Only enable by default for git builds
1663 if test -z "$werror" ; then
1664 if test -d "$source_path/.git" -a \
1665 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1666 werror="yes"
1667 else
1668 werror="no"
1672 if test "$bogus_os" = "yes"; then
1673 # Now that we know that we're not printing the help and that
1674 # the compiler works (so the results of the check_defines we used
1675 # to identify the OS are reliable), if we didn't recognize the
1676 # host OS we should stop now.
1677 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1680 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1681 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1682 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1683 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1684 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1685 gcc_flags="-Wno-string-plus-int $gcc_flags"
1686 # Note that we do not add -Werror to gcc_flags here, because that would
1687 # enable it for all configure tests. If a configure test failed due
1688 # to -Werror this would just silently disable some features,
1689 # so it's too error prone.
1691 cc_has_warning_flag() {
1692 write_c_skeleton;
1694 # Use the positive sense of the flag when testing for -Wno-wombat
1695 # support (gcc will happily accept the -Wno- form of unknown
1696 # warning options).
1697 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1698 compile_prog "-Werror $optflag" ""
1701 for flag in $gcc_flags; do
1702 if cc_has_warning_flag $flag ; then
1703 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1705 done
1707 if test "$mingw32" = "yes"; then
1708 stack_protector="no"
1710 if test "$stack_protector" != "no"; then
1711 cat > $TMPC << EOF
1712 int main(int argc, char *argv[])
1714 char arr[64], *p = arr, *c = argv[0];
1715 while (*c) {
1716 *p++ = *c++;
1718 return 0;
1721 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1722 sp_on=0
1723 for flag in $gcc_flags; do
1724 # We need to check both a compile and a link, since some compiler
1725 # setups fail only on a .c->.o compile and some only at link time
1726 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1727 compile_prog "-Werror $flag" ""; then
1728 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1729 sp_on=1
1730 break
1732 done
1733 if test "$stack_protector" = yes; then
1734 if test $sp_on = 0; then
1735 error_exit "Stack protector not supported"
1740 # Disable -Wmissing-braces on older compilers that warn even for
1741 # the "universal" C zero initializer {0}.
1742 cat > $TMPC << EOF
1743 struct {
1744 int a[2];
1745 } x = {0};
1747 if compile_object "-Werror" "" ; then
1749 else
1750 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1753 # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1754 # large functions that use global variables. The bug is in all releases of
1755 # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1756 # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1757 cat > $TMPC << EOF
1758 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1759 int main(void) { return 0; }
1760 #else
1761 #error No bug in this compiler.
1762 #endif
1764 if compile_prog "-Werror -fno-gcse" "" ; then
1765 TRANSLATE_OPT_CFLAGS=-fno-gcse
1768 if test "$static" = "yes" ; then
1769 if test "$modules" = "yes" ; then
1770 error_exit "static and modules are mutually incompatible"
1772 if test "$pie" = "yes" ; then
1773 error_exit "static and pie are mutually incompatible"
1774 else
1775 pie="no"
1779 # Unconditional check for compiler __thread support
1780 cat > $TMPC << EOF
1781 static __thread int tls_var;
1782 int main(void) { return tls_var; }
1785 if ! compile_prog "-Werror" "" ; then
1786 error_exit "Your compiler does not support the __thread specifier for " \
1787 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1790 if test "$pie" = ""; then
1791 case "$cpu-$targetos" in
1792 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1795 pie="no"
1797 esac
1800 if test "$pie" != "no" ; then
1801 cat > $TMPC << EOF
1803 #ifdef __linux__
1804 # define THREAD __thread
1805 #else
1806 # define THREAD
1807 #endif
1809 static THREAD int tls_var;
1811 int main(void) { return tls_var; }
1814 if compile_prog "-fPIE -DPIE" "-pie"; then
1815 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1816 LDFLAGS="-pie $LDFLAGS"
1817 pie="yes"
1818 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1819 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1821 else
1822 if test "$pie" = "yes"; then
1823 error_exit "PIE not available due to missing toolchain support"
1824 else
1825 echo "Disabling PIE due to missing toolchain support"
1826 pie="no"
1830 if compile_prog "-Werror -fno-pie" "-nopie"; then
1831 CFLAGS_NOPIE="-fno-pie"
1832 LDFLAGS_NOPIE="-nopie"
1836 ##########################################
1837 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1838 # use i686 as default anyway, but for those that don't, an explicit
1839 # specification is necessary
1841 if test "$cpu" = "i386"; then
1842 cat > $TMPC << EOF
1843 static int sfaa(int *ptr)
1845 return __sync_fetch_and_and(ptr, 0);
1848 int main(void)
1850 int val = 42;
1851 val = __sync_val_compare_and_swap(&val, 0, 1);
1852 sfaa(&val);
1853 return val;
1856 if ! compile_prog "" "" ; then
1857 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1861 #########################################
1862 # Solaris specific configure tool chain decisions
1864 if test "$solaris" = "yes" ; then
1865 if has $install; then
1867 else
1868 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1869 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1870 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1872 if test "$(path_of $install)" = "/usr/sbin/install" ; then
1873 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1874 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1875 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1877 if has ar; then
1879 else
1880 if test -f /usr/ccs/bin/ar ; then
1881 error_exit "No path includes ar" \
1882 "Add /usr/ccs/bin to your path and rerun configure"
1884 error_exit "No path includes ar"
1888 if test -z "${target_list+xxx}" ; then
1889 for target in $default_target_list; do
1890 supported_target $target 2>/dev/null && \
1891 target_list="$target_list $target"
1892 done
1893 target_list="${target_list# }"
1894 else
1895 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1896 for target in $target_list; do
1897 # Check that we recognised the target name; this allows a more
1898 # friendly error message than if we let it fall through.
1899 case " $default_target_list " in
1900 *" $target "*)
1903 error_exit "Unknown target name '$target'"
1905 esac
1906 supported_target $target || exit 1
1907 done
1910 # see if system emulation was really requested
1911 case " $target_list " in
1912 *"-softmmu "*) softmmu=yes
1914 *) softmmu=no
1916 esac
1918 feature_not_found() {
1919 feature=$1
1920 remedy=$2
1922 error_exit "User requested feature $feature" \
1923 "configure was not able to find it." \
1924 "$remedy"
1927 # ---
1928 # big/little endian test
1929 cat > $TMPC << EOF
1930 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1931 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1932 extern int foo(short *, short *);
1933 int main(int argc, char *argv[]) {
1934 return foo(big_endian, little_endian);
1938 if compile_object ; then
1939 if grep -q BiGeNdIaN $TMPO ; then
1940 bigendian="yes"
1941 elif grep -q LiTtLeEnDiAn $TMPO ; then
1942 bigendian="no"
1943 else
1944 echo big/little test failed
1946 else
1947 echo big/little test failed
1950 ##########################################
1951 # cocoa implies not SDL or GTK
1952 # (the cocoa UI code currently assumes it is always the active UI
1953 # and doesn't interact well with other UI frontend code)
1954 if test "$cocoa" = "yes"; then
1955 if test "$sdl" = "yes"; then
1956 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1958 if test "$gtk" = "yes"; then
1959 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1961 gtk=no
1962 sdl=no
1965 # Some versions of Mac OS X incorrectly define SIZE_MAX
1966 cat > $TMPC << EOF
1967 #include <stdint.h>
1968 #include <stdio.h>
1969 int main(int argc, char *argv[]) {
1970 return printf("%zu", SIZE_MAX);
1973 have_broken_size_max=no
1974 if ! compile_object -Werror ; then
1975 have_broken_size_max=yes
1978 ##########################################
1979 # L2TPV3 probe
1981 cat > $TMPC <<EOF
1982 #include <sys/socket.h>
1983 #include <linux/ip.h>
1984 int main(void) { return sizeof(struct mmsghdr); }
1986 if compile_prog "" "" ; then
1987 l2tpv3=yes
1988 else
1989 l2tpv3=no
1992 ##########################################
1993 # MinGW / Mingw-w64 localtime_r/gmtime_r check
1995 if test "$mingw32" = "yes"; then
1996 # Some versions of MinGW / Mingw-w64 lack localtime_r
1997 # and gmtime_r entirely.
1999 # Some versions of Mingw-w64 define a macro for
2000 # localtime_r/gmtime_r.
2002 # Some versions of Mingw-w64 will define functions
2003 # for localtime_r/gmtime_r, but only if you have
2004 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
2005 # though, unistd.h and pthread.h both define
2006 # that for you.
2008 # So this #undef localtime_r and #include <unistd.h>
2009 # are not in fact redundant.
2010 cat > $TMPC << EOF
2011 #include <unistd.h>
2012 #include <time.h>
2013 #undef localtime_r
2014 int main(void) { localtime_r(NULL, NULL); return 0; }
2016 if compile_prog "" "" ; then
2017 localtime_r="yes"
2018 else
2019 localtime_r="no"
2023 ##########################################
2024 # pkg-config probe
2026 if ! has "$pkg_config_exe"; then
2027 error_exit "pkg-config binary '$pkg_config_exe' not found"
2030 ##########################################
2031 # NPTL probe
2033 if test "$linux_user" = "yes"; then
2034 cat > $TMPC <<EOF
2035 #include <sched.h>
2036 #include <linux/futex.h>
2037 int main(void) {
2038 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2039 #error bork
2040 #endif
2041 return 0;
2044 if ! compile_object ; then
2045 feature_not_found "nptl" "Install glibc and linux kernel headers."
2049 ##########################################
2050 # lzo check
2052 if test "$lzo" != "no" ; then
2053 cat > $TMPC << EOF
2054 #include <lzo/lzo1x.h>
2055 int main(void) { lzo_version(); return 0; }
2057 if compile_prog "" "-llzo2" ; then
2058 libs_softmmu="$libs_softmmu -llzo2"
2059 lzo="yes"
2060 else
2061 if test "$lzo" = "yes"; then
2062 feature_not_found "liblzo2" "Install liblzo2 devel"
2064 lzo="no"
2068 ##########################################
2069 # snappy check
2071 if test "$snappy" != "no" ; then
2072 cat > $TMPC << EOF
2073 #include <snappy-c.h>
2074 int main(void) { snappy_max_compressed_length(4096); return 0; }
2076 if compile_prog "" "-lsnappy" ; then
2077 libs_softmmu="$libs_softmmu -lsnappy"
2078 snappy="yes"
2079 else
2080 if test "$snappy" = "yes"; then
2081 feature_not_found "libsnappy" "Install libsnappy devel"
2083 snappy="no"
2087 ##########################################
2088 # bzip2 check
2090 if test "$bzip2" != "no" ; then
2091 cat > $TMPC << EOF
2092 #include <bzlib.h>
2093 int main(void) { BZ2_bzlibVersion(); return 0; }
2095 if compile_prog "" "-lbz2" ; then
2096 bzip2="yes"
2097 else
2098 if test "$bzip2" = "yes"; then
2099 feature_not_found "libbzip2" "Install libbzip2 devel"
2101 bzip2="no"
2105 ##########################################
2106 # libseccomp check
2108 if test "$seccomp" != "no" ; then
2109 case "$cpu" in
2110 i386|x86_64)
2111 libseccomp_minver="2.1.0"
2113 mips)
2114 libseccomp_minver="2.2.0"
2116 arm|aarch64)
2117 libseccomp_minver="2.2.3"
2119 ppc|ppc64|s390x)
2120 libseccomp_minver="2.3.0"
2123 libseccomp_minver=""
2125 esac
2127 if test "$libseccomp_minver" != "" &&
2128 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2129 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2130 seccomp_libs="$($pkg_config --libs libseccomp)"
2131 seccomp="yes"
2132 else
2133 if test "$seccomp" = "yes" ; then
2134 if test "$libseccomp_minver" != "" ; then
2135 feature_not_found "libseccomp" \
2136 "Install libseccomp devel >= $libseccomp_minver"
2137 else
2138 feature_not_found "libseccomp" \
2139 "libseccomp is not supported for host cpu $cpu"
2142 seccomp="no"
2145 ##########################################
2146 # xen probe
2148 if test "$xen" != "no" ; then
2149 # Check whether Xen library path is specified via --extra-ldflags to avoid
2150 # overriding this setting with pkg-config output. If not, try pkg-config
2151 # to obtain all needed flags.
2153 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2154 $pkg_config --exists xencontrol ; then
2155 xen_ctrl_version="$(printf '%d%02d%02d' \
2156 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2157 xen=yes
2158 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2159 xen_pc="$xen_pc xenevtchn xendevicemodel"
2160 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2161 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2162 LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2163 else
2165 xen_libs="-lxenstore -lxenctrl -lxenguest"
2166 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2168 # First we test whether Xen headers and libraries are available.
2169 # If no, we are done and there is no Xen support.
2170 # If yes, more tests are run to detect the Xen version.
2172 # Xen (any)
2173 cat > $TMPC <<EOF
2174 #include <xenctrl.h>
2175 int main(void) {
2176 return 0;
2179 if ! compile_prog "" "$xen_libs" ; then
2180 # Xen not found
2181 if test "$xen" = "yes" ; then
2182 feature_not_found "xen" "Install xen devel"
2184 xen=no
2186 # Xen unstable
2187 elif
2188 cat > $TMPC <<EOF &&
2189 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2190 #include <xenforeignmemory.h>
2191 int main(void) {
2192 xenforeignmemory_handle *xfmem;
2194 xfmem = xenforeignmemory_open(0, 0);
2195 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2197 return 0;
2200 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2201 then
2202 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2203 xen_ctrl_version=41000
2204 xen=yes
2205 elif
2206 cat > $TMPC <<EOF &&
2207 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2208 #define __XEN_TOOLS__
2209 #include <xendevicemodel.h>
2210 int main(void) {
2211 xendevicemodel_handle *xd;
2213 xd = xendevicemodel_open(0, 0);
2214 xendevicemodel_close(xd);
2216 return 0;
2219 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2220 then
2221 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2222 xen_ctrl_version=40900
2223 xen=yes
2224 elif
2225 cat > $TMPC <<EOF &&
2227 * If we have stable libs the we don't want the libxc compat
2228 * layers, regardless of what CFLAGS we may have been given.
2230 * Also, check if xengnttab_grant_copy_segment_t is defined and
2231 * grant copy operation is implemented.
2233 #undef XC_WANT_COMPAT_EVTCHN_API
2234 #undef XC_WANT_COMPAT_GNTTAB_API
2235 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2236 #include <xenctrl.h>
2237 #include <xenstore.h>
2238 #include <xenevtchn.h>
2239 #include <xengnttab.h>
2240 #include <xenforeignmemory.h>
2241 #include <stdint.h>
2242 #include <xen/hvm/hvm_info_table.h>
2243 #if !defined(HVM_MAX_VCPUS)
2244 # error HVM_MAX_VCPUS not defined
2245 #endif
2246 int main(void) {
2247 xc_interface *xc = NULL;
2248 xenforeignmemory_handle *xfmem;
2249 xenevtchn_handle *xe;
2250 xengnttab_handle *xg;
2251 xen_domain_handle_t handle;
2252 xengnttab_grant_copy_segment_t* seg = NULL;
2254 xs_daemon_open();
2256 xc = xc_interface_open(0, 0, 0);
2257 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2258 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2259 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2260 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2261 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2263 xfmem = xenforeignmemory_open(0, 0);
2264 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2266 xe = xenevtchn_open(0, 0);
2267 xenevtchn_fd(xe);
2269 xg = xengnttab_open(0, 0);
2270 xengnttab_grant_copy(xg, 0, seg);
2272 return 0;
2275 compile_prog "" "$xen_libs $xen_stable_libs"
2276 then
2277 xen_ctrl_version=40800
2278 xen=yes
2279 elif
2280 cat > $TMPC <<EOF &&
2282 * If we have stable libs the we don't want the libxc compat
2283 * layers, regardless of what CFLAGS we may have been given.
2285 #undef XC_WANT_COMPAT_EVTCHN_API
2286 #undef XC_WANT_COMPAT_GNTTAB_API
2287 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2288 #include <xenctrl.h>
2289 #include <xenstore.h>
2290 #include <xenevtchn.h>
2291 #include <xengnttab.h>
2292 #include <xenforeignmemory.h>
2293 #include <stdint.h>
2294 #include <xen/hvm/hvm_info_table.h>
2295 #if !defined(HVM_MAX_VCPUS)
2296 # error HVM_MAX_VCPUS not defined
2297 #endif
2298 int main(void) {
2299 xc_interface *xc = NULL;
2300 xenforeignmemory_handle *xfmem;
2301 xenevtchn_handle *xe;
2302 xengnttab_handle *xg;
2303 xen_domain_handle_t handle;
2305 xs_daemon_open();
2307 xc = xc_interface_open(0, 0, 0);
2308 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2309 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2310 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2311 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2312 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2314 xfmem = xenforeignmemory_open(0, 0);
2315 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2317 xe = xenevtchn_open(0, 0);
2318 xenevtchn_fd(xe);
2320 xg = xengnttab_open(0, 0);
2321 xengnttab_map_grant_ref(xg, 0, 0, 0);
2323 return 0;
2326 compile_prog "" "$xen_libs $xen_stable_libs"
2327 then
2328 xen_ctrl_version=40701
2329 xen=yes
2330 elif
2331 cat > $TMPC <<EOF &&
2332 #include <xenctrl.h>
2333 #include <stdint.h>
2334 int main(void) {
2335 xc_interface *xc = NULL;
2336 xen_domain_handle_t handle;
2337 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2338 return 0;
2341 compile_prog "" "$xen_libs"
2342 then
2343 xen_ctrl_version=40700
2344 xen=yes
2346 # Xen 4.6
2347 elif
2348 cat > $TMPC <<EOF &&
2349 #include <xenctrl.h>
2350 #include <xenstore.h>
2351 #include <stdint.h>
2352 #include <xen/hvm/hvm_info_table.h>
2353 #if !defined(HVM_MAX_VCPUS)
2354 # error HVM_MAX_VCPUS not defined
2355 #endif
2356 int main(void) {
2357 xc_interface *xc;
2358 xs_daemon_open();
2359 xc = xc_interface_open(0, 0, 0);
2360 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2361 xc_gnttab_open(NULL, 0);
2362 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2363 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2364 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2365 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2366 return 0;
2369 compile_prog "" "$xen_libs"
2370 then
2371 xen_ctrl_version=40600
2372 xen=yes
2374 # Xen 4.5
2375 elif
2376 cat > $TMPC <<EOF &&
2377 #include <xenctrl.h>
2378 #include <xenstore.h>
2379 #include <stdint.h>
2380 #include <xen/hvm/hvm_info_table.h>
2381 #if !defined(HVM_MAX_VCPUS)
2382 # error HVM_MAX_VCPUS not defined
2383 #endif
2384 int main(void) {
2385 xc_interface *xc;
2386 xs_daemon_open();
2387 xc = xc_interface_open(0, 0, 0);
2388 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2389 xc_gnttab_open(NULL, 0);
2390 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2391 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2392 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2393 return 0;
2396 compile_prog "" "$xen_libs"
2397 then
2398 xen_ctrl_version=40500
2399 xen=yes
2401 elif
2402 cat > $TMPC <<EOF &&
2403 #include <xenctrl.h>
2404 #include <xenstore.h>
2405 #include <stdint.h>
2406 #include <xen/hvm/hvm_info_table.h>
2407 #if !defined(HVM_MAX_VCPUS)
2408 # error HVM_MAX_VCPUS not defined
2409 #endif
2410 int main(void) {
2411 xc_interface *xc;
2412 xs_daemon_open();
2413 xc = xc_interface_open(0, 0, 0);
2414 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2415 xc_gnttab_open(NULL, 0);
2416 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2417 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2418 return 0;
2421 compile_prog "" "$xen_libs"
2422 then
2423 xen_ctrl_version=40200
2424 xen=yes
2426 else
2427 if test "$xen" = "yes" ; then
2428 feature_not_found "xen (unsupported version)" \
2429 "Install a supported xen (xen 4.2 or newer)"
2431 xen=no
2434 if test "$xen" = yes; then
2435 if test $xen_ctrl_version -ge 40701 ; then
2436 libs_softmmu="$xen_stable_libs $libs_softmmu"
2438 libs_softmmu="$xen_libs $libs_softmmu"
2443 if test "$xen_pci_passthrough" != "no"; then
2444 if test "$xen" = "yes" && test "$linux" = "yes"; then
2445 xen_pci_passthrough=yes
2446 else
2447 if test "$xen_pci_passthrough" = "yes"; then
2448 error_exit "User requested feature Xen PCI Passthrough" \
2449 " but this feature requires /sys from Linux"
2451 xen_pci_passthrough=no
2455 if test "$xen_pv_domain_build" = "yes" &&
2456 test "$xen" != "yes"; then
2457 error_exit "User requested Xen PV domain builder support" \
2458 "which requires Xen support."
2461 ##########################################
2462 # Sparse probe
2463 if test "$sparse" != "no" ; then
2464 if has cgcc; then
2465 sparse=yes
2466 else
2467 if test "$sparse" = "yes" ; then
2468 feature_not_found "sparse" "Install sparse binary"
2470 sparse=no
2474 ##########################################
2475 # X11 probe
2476 x11_cflags=
2477 x11_libs=-lX11
2478 if $pkg_config --exists "x11"; then
2479 x11_cflags=$($pkg_config --cflags x11)
2480 x11_libs=$($pkg_config --libs x11)
2483 ##########################################
2484 # GTK probe
2486 if test "$gtkabi" = ""; then
2487 # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
2488 # Use 2.0 as a fallback if that is available.
2489 if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2490 gtkabi=3.0
2491 elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2492 gtkabi=2.0
2493 else
2494 gtkabi=3.0
2498 if test "$gtk" != "no"; then
2499 gtkpackage="gtk+-$gtkabi"
2500 gtkx11package="gtk+-x11-$gtkabi"
2501 if test "$gtkabi" = "3.0" ; then
2502 gtkversion="3.0.0"
2503 else
2504 gtkversion="2.18.0"
2506 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2507 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2508 gtk_libs=$($pkg_config --libs $gtkpackage)
2509 gtk_version=$($pkg_config --modversion $gtkpackage)
2510 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2511 gtk_cflags="$gtk_cflags $x11_cflags"
2512 gtk_libs="$gtk_libs $x11_libs"
2514 libs_softmmu="$gtk_libs $libs_softmmu"
2515 gtk="yes"
2516 elif test "$gtk" = "yes"; then
2517 feature_not_found "gtk" "Install gtk3-devel"
2518 else
2519 gtk="no"
2524 ##########################################
2525 # GNUTLS probe
2527 gnutls_works() {
2528 # Unfortunately some distros have bad pkg-config information for gnutls
2529 # such that it claims to exist but you get a compiler error if you try
2530 # to use the options returned by --libs. Specifically, Ubuntu for --static
2531 # builds doesn't work:
2532 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2534 # So sanity check the cflags/libs before assuming gnutls can be used.
2535 if ! $pkg_config --exists "gnutls"; then
2536 return 1
2539 write_c_skeleton
2540 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2543 gnutls_gcrypt=no
2544 gnutls_nettle=no
2545 if test "$gnutls" != "no"; then
2546 if gnutls_works; then
2547 gnutls_cflags=$($pkg_config --cflags gnutls)
2548 gnutls_libs=$($pkg_config --libs gnutls)
2549 libs_softmmu="$gnutls_libs $libs_softmmu"
2550 libs_tools="$gnutls_libs $libs_tools"
2551 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2552 gnutls="yes"
2554 # gnutls_rnd requires >= 2.11.0
2555 if $pkg_config --exists "gnutls >= 2.11.0"; then
2556 gnutls_rnd="yes"
2557 else
2558 gnutls_rnd="no"
2561 if $pkg_config --exists 'gnutls >= 3.0'; then
2562 gnutls_gcrypt=no
2563 gnutls_nettle=yes
2564 elif $pkg_config --exists 'gnutls >= 2.12'; then
2565 case $($pkg_config --libs --static gnutls) in
2566 *gcrypt*)
2567 gnutls_gcrypt=yes
2568 gnutls_nettle=no
2570 *nettle*)
2571 gnutls_gcrypt=no
2572 gnutls_nettle=yes
2575 gnutls_gcrypt=yes
2576 gnutls_nettle=no
2578 esac
2579 else
2580 gnutls_gcrypt=yes
2581 gnutls_nettle=no
2583 elif test "$gnutls" = "yes"; then
2584 feature_not_found "gnutls" "Install gnutls devel"
2585 else
2586 gnutls="no"
2587 gnutls_rnd="no"
2589 else
2590 gnutls_rnd="no"
2594 # If user didn't give a --disable/enable-gcrypt flag,
2595 # then mark as disabled if user requested nettle
2596 # explicitly, or if gnutls links to nettle
2597 if test -z "$gcrypt"
2598 then
2599 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2600 then
2601 gcrypt="no"
2605 # If user didn't give a --disable/enable-nettle flag,
2606 # then mark as disabled if user requested gcrypt
2607 # explicitly, or if gnutls links to gcrypt
2608 if test -z "$nettle"
2609 then
2610 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2611 then
2612 nettle="no"
2616 has_libgcrypt_config() {
2617 if ! has "libgcrypt-config"
2618 then
2619 return 1
2622 if test -n "$cross_prefix"
2623 then
2624 host=$(libgcrypt-config --host)
2625 if test "$host-" != $cross_prefix
2626 then
2627 return 1
2631 return 0
2634 if test "$gcrypt" != "no"; then
2635 if has_libgcrypt_config; then
2636 gcrypt_cflags=$(libgcrypt-config --cflags)
2637 gcrypt_libs=$(libgcrypt-config --libs)
2638 # Debian has remove -lgpg-error from libgcrypt-config
2639 # as it "spreads unnecessary dependencies" which in
2640 # turn breaks static builds...
2641 if test "$static" = "yes"
2642 then
2643 gcrypt_libs="$gcrypt_libs -lgpg-error"
2645 libs_softmmu="$gcrypt_libs $libs_softmmu"
2646 libs_tools="$gcrypt_libs $libs_tools"
2647 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2648 gcrypt="yes"
2649 if test -z "$nettle"; then
2650 nettle="no"
2653 cat > $TMPC << EOF
2654 #include <gcrypt.h>
2655 int main(void) {
2656 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2657 GCRY_MD_SHA256,
2658 NULL, 0, 0, 0, NULL);
2659 return 0;
2662 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2663 gcrypt_kdf=yes
2666 cat > $TMPC << EOF
2667 #include <gcrypt.h>
2668 int main(void) {
2669 gcry_mac_hd_t handle;
2670 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2671 GCRY_MAC_FLAG_SECURE, NULL);
2672 return 0;
2675 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2676 gcrypt_hmac=yes
2678 else
2679 if test "$gcrypt" = "yes"; then
2680 feature_not_found "gcrypt" "Install gcrypt devel"
2681 else
2682 gcrypt="no"
2688 if test "$nettle" != "no"; then
2689 if $pkg_config --exists "nettle"; then
2690 nettle_cflags=$($pkg_config --cflags nettle)
2691 nettle_libs=$($pkg_config --libs nettle)
2692 nettle_version=$($pkg_config --modversion nettle)
2693 libs_softmmu="$nettle_libs $libs_softmmu"
2694 libs_tools="$nettle_libs $libs_tools"
2695 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2696 nettle="yes"
2698 cat > $TMPC << EOF
2699 #include <stddef.h>
2700 #include <nettle/pbkdf2.h>
2701 int main(void) {
2702 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2703 return 0;
2706 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2707 nettle_kdf=yes
2709 else
2710 if test "$nettle" = "yes"; then
2711 feature_not_found "nettle" "Install nettle devel"
2712 else
2713 nettle="no"
2718 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2719 then
2720 error_exit "Only one of gcrypt & nettle can be enabled"
2723 ##########################################
2724 # libtasn1 - only for the TLS creds/session test suite
2726 tasn1=yes
2727 tasn1_cflags=""
2728 tasn1_libs=""
2729 if $pkg_config --exists "libtasn1"; then
2730 tasn1_cflags=$($pkg_config --cflags libtasn1)
2731 tasn1_libs=$($pkg_config --libs libtasn1)
2732 else
2733 tasn1=no
2737 ##########################################
2738 # getifaddrs (for tests/test-io-channel-socket )
2740 have_ifaddrs_h=yes
2741 if ! check_include "ifaddrs.h" ; then
2742 have_ifaddrs_h=no
2745 ##########################################
2746 # VTE probe
2748 if test "$vte" != "no"; then
2749 if test "$gtkabi" = "3.0"; then
2750 vteminversion="0.32.0"
2751 if $pkg_config --exists "vte-2.91"; then
2752 vtepackage="vte-2.91"
2753 else
2754 vtepackage="vte-2.90"
2756 else
2757 vtepackage="vte"
2758 vteminversion="0.24.0"
2760 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2761 vte_cflags=$($pkg_config --cflags $vtepackage)
2762 vte_libs=$($pkg_config --libs $vtepackage)
2763 vteversion=$($pkg_config --modversion $vtepackage)
2764 libs_softmmu="$vte_libs $libs_softmmu"
2765 vte="yes"
2766 elif test "$vte" = "yes"; then
2767 if test "$gtkabi" = "3.0"; then
2768 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2769 else
2770 feature_not_found "vte" "Install libvte devel"
2772 else
2773 vte="no"
2777 ##########################################
2778 # SDL probe
2780 # Look for sdl configuration program (pkg-config or sdl-config). Try
2781 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2783 if test "$sdlabi" = ""; then
2784 if $pkg_config --exists "sdl2"; then
2785 sdlabi=2.0
2786 elif $pkg_config --exists "sdl"; then
2787 sdlabi=1.2
2788 else
2789 sdlabi=2.0
2793 if test $sdlabi = "2.0"; then
2794 sdl_config=$sdl2_config
2795 sdlname=sdl2
2796 sdlconfigname=sdl2_config
2797 elif test $sdlabi = "1.2"; then
2798 sdlname=sdl
2799 sdlconfigname=sdl_config
2800 else
2801 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2804 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2805 sdl_config=$sdlconfigname
2808 if $pkg_config $sdlname --exists; then
2809 sdlconfig="$pkg_config $sdlname"
2810 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2811 elif has ${sdl_config}; then
2812 sdlconfig="$sdl_config"
2813 sdlversion=$($sdlconfig --version)
2814 else
2815 if test "$sdl" = "yes" ; then
2816 feature_not_found "sdl" "Install SDL2-devel"
2818 sdl=no
2820 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2821 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2824 sdl_too_old=no
2825 if test "$sdl" != "no" ; then
2826 cat > $TMPC << EOF
2827 #include <SDL.h>
2828 #undef main /* We don't want SDL to override our main() */
2829 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2831 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2832 if test "$static" = "yes" ; then
2833 if $pkg_config $sdlname --exists; then
2834 sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
2835 else
2836 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2838 else
2839 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2841 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2842 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
2843 sdl_too_old=yes
2844 else
2845 sdl=yes
2848 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2849 if test "$sdl" = "yes" -a "$static" = "yes" ; then
2850 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2851 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2852 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2854 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2856 else
2857 sdl=no
2859 fi # static link
2860 else # sdl not found
2861 if test "$sdl" = "yes" ; then
2862 feature_not_found "sdl" "Install SDL devel"
2864 sdl=no
2865 fi # sdl compile test
2868 if test "$sdl" = "yes" ; then
2869 cat > $TMPC <<EOF
2870 #include <SDL.h>
2871 #if defined(SDL_VIDEO_DRIVER_X11)
2872 #include <X11/XKBlib.h>
2873 #else
2874 #error No x11 support
2875 #endif
2876 int main(void) { return 0; }
2878 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2879 sdl_cflags="$sdl_cflags $x11_cflags"
2880 sdl_libs="$sdl_libs $x11_libs"
2884 ##########################################
2885 # RDMA needs OpenFabrics libraries
2886 if test "$rdma" != "no" ; then
2887 cat > $TMPC <<EOF
2888 #include <rdma/rdma_cma.h>
2889 int main(void) { return 0; }
2891 rdma_libs="-lrdmacm -libverbs"
2892 if compile_prog "" "$rdma_libs" ; then
2893 rdma="yes"
2894 else
2895 if test "$rdma" = "yes" ; then
2896 error_exit \
2897 " OpenFabrics librdmacm/libibverbs not present." \
2898 " Your options:" \
2899 " (1) Fast: Install infiniband packages from your distro." \
2900 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2901 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2903 rdma="no"
2907 ##########################################
2908 # VNC SASL detection
2909 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
2910 cat > $TMPC <<EOF
2911 #include <sasl/sasl.h>
2912 #include <stdio.h>
2913 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2915 # Assuming Cyrus-SASL installed in /usr prefix
2916 vnc_sasl_cflags=""
2917 vnc_sasl_libs="-lsasl2"
2918 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2919 vnc_sasl=yes
2920 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2921 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
2922 else
2923 if test "$vnc_sasl" = "yes" ; then
2924 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2926 vnc_sasl=no
2930 ##########################################
2931 # VNC JPEG detection
2932 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2933 if $pkg_config --exists libjpeg; then
2934 vnc_jpeg=yes
2935 libs_softmmu="$libs_softmmu $($pkg_config --libs libjpeg)"
2936 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libjpeg)"
2937 else
2938 cat > $TMPC <<EOF
2939 #include <stdio.h>
2940 #include <jpeglib.h>
2941 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2943 vnc_jpeg_cflags=""
2944 vnc_jpeg_libs="-ljpeg"
2945 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2946 vnc_jpeg=yes
2947 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2948 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2949 else
2950 if test "$vnc_jpeg" = "yes" ; then
2951 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2953 vnc_jpeg=no
2958 ##########################################
2959 # VNC PNG detection
2960 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2961 cat > $TMPC <<EOF
2962 //#include <stdio.h>
2963 #include <png.h>
2964 #include <stddef.h>
2965 int main(void) {
2966 png_structp png_ptr;
2967 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
2968 return png_ptr != 0;
2971 if $pkg_config libpng --exists; then
2972 vnc_png_cflags=$($pkg_config libpng --cflags)
2973 vnc_png_libs=$($pkg_config libpng --libs)
2974 else
2975 vnc_png_cflags=""
2976 vnc_png_libs="-lpng"
2978 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2979 vnc_png=yes
2980 libs_softmmu="$vnc_png_libs $libs_softmmu"
2981 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2982 else
2983 if test "$vnc_png" = "yes" ; then
2984 feature_not_found "vnc-png" "Install libpng devel"
2986 vnc_png=no
2990 ##########################################
2991 # xkbcommon probe
2992 if test "$xkbcommon" != "no" ; then
2993 if $pkg_config xkbcommon --exists; then
2994 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
2995 xkbcommon_libs=$($pkg_config xkbcommon --libs)
2996 xkbcommon=yes
2997 else
2998 if test "$xkbcommon" = "yes" ; then
2999 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
3001 xkbcommon=no
3005 ##########################################
3006 # fnmatch() probe, used for ACL routines
3007 fnmatch="no"
3008 cat > $TMPC << EOF
3009 #include <fnmatch.h>
3010 int main(void)
3012 fnmatch("foo", "foo", 0);
3013 return 0;
3016 if compile_prog "" "" ; then
3017 fnmatch="yes"
3020 ##########################################
3021 # xfsctl() probe, used for file-posix.c
3022 if test "$xfs" != "no" ; then
3023 cat > $TMPC << EOF
3024 #include <stddef.h> /* NULL */
3025 #include <xfs/xfs.h>
3026 int main(void)
3028 xfsctl(NULL, 0, 0, NULL);
3029 return 0;
3032 if compile_prog "" "" ; then
3033 xfs="yes"
3034 else
3035 if test "$xfs" = "yes" ; then
3036 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3038 xfs=no
3042 ##########################################
3043 # vde libraries probe
3044 if test "$vde" != "no" ; then
3045 vde_libs="-lvdeplug"
3046 cat > $TMPC << EOF
3047 #include <stddef.h>
3048 #include <libvdeplug.h>
3049 int main(void)
3051 struct vde_open_args a = {0, 0, 0};
3052 char s[] = "";
3053 vde_open(s, s, &a);
3054 return 0;
3057 if compile_prog "" "$vde_libs" ; then
3058 vde=yes
3059 else
3060 if test "$vde" = "yes" ; then
3061 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3063 vde=no
3067 ##########################################
3068 # netmap support probe
3069 # Apart from looking for netmap headers, we make sure that the host API version
3070 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3071 # a minor/major version number. Minor new features will be marked with values up
3072 # to 15, and if something happens that requires a change to the backend we will
3073 # move above 15, submit the backend fixes and modify this two bounds.
3074 if test "$netmap" != "no" ; then
3075 cat > $TMPC << EOF
3076 #include <inttypes.h>
3077 #include <net/if.h>
3078 #include <net/netmap.h>
3079 #include <net/netmap_user.h>
3080 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3081 #error
3082 #endif
3083 int main(void) { return 0; }
3085 if compile_prog "" "" ; then
3086 netmap=yes
3087 else
3088 if test "$netmap" = "yes" ; then
3089 feature_not_found "netmap"
3091 netmap=no
3095 ##########################################
3096 # libcap-ng library probe
3097 if test "$cap_ng" != "no" ; then
3098 cap_libs="-lcap-ng"
3099 cat > $TMPC << EOF
3100 #include <cap-ng.h>
3101 int main(void)
3103 capng_capability_to_name(CAPNG_EFFECTIVE);
3104 return 0;
3107 if compile_prog "" "$cap_libs" ; then
3108 cap_ng=yes
3109 libs_tools="$cap_libs $libs_tools"
3110 else
3111 if test "$cap_ng" = "yes" ; then
3112 feature_not_found "cap_ng" "Install libcap-ng devel"
3114 cap_ng=no
3118 ##########################################
3119 # Sound support libraries probe
3121 audio_drv_probe()
3123 drv=$1
3124 hdr=$2
3125 lib=$3
3126 exp=$4
3127 cfl=$5
3128 cat > $TMPC << EOF
3129 #include <$hdr>
3130 int main(void) { $exp }
3132 if compile_prog "$cfl" "$lib" ; then
3134 else
3135 error_exit "$drv check failed" \
3136 "Make sure to have the $drv libs and headers installed."
3140 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3141 for drv in $audio_drv_list; do
3142 case $drv in
3143 alsa)
3144 audio_drv_probe $drv alsa/asoundlib.h -lasound \
3145 "return snd_pcm_close((snd_pcm_t *)0);"
3146 alsa_libs="-lasound"
3150 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3151 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3152 pulse_libs="-lpulse"
3153 audio_pt_int="yes"
3156 sdl)
3157 if test "$sdl" = "no"; then
3158 error_exit "sdl not found or disabled, can not use sdl audio driver"
3162 coreaudio)
3163 coreaudio_libs="-framework CoreAudio"
3166 dsound)
3167 dsound_libs="-lole32 -ldxguid"
3168 audio_win_int="yes"
3171 oss)
3172 oss_libs="$oss_lib"
3175 wav)
3176 # XXX: Probes for CoreAudio, DirectSound
3180 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3181 error_exit "Unknown driver '$drv' selected" \
3182 "Possible drivers are: $audio_possible_drivers"
3185 esac
3186 done
3188 ##########################################
3189 # BrlAPI probe
3191 if test "$brlapi" != "no" ; then
3192 brlapi_libs="-lbrlapi"
3193 cat > $TMPC << EOF
3194 #include <brlapi.h>
3195 #include <stddef.h>
3196 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3198 if compile_prog "" "$brlapi_libs" ; then
3199 brlapi=yes
3200 else
3201 if test "$brlapi" = "yes" ; then
3202 feature_not_found "brlapi" "Install brlapi devel"
3204 brlapi=no
3208 ##########################################
3209 # curses probe
3210 if test "$curses" != "no" ; then
3211 if test "$mingw32" = "yes" ; then
3212 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3213 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3214 else
3215 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3216 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3218 curses_found=no
3219 cat > $TMPC << EOF
3220 #include <locale.h>
3221 #include <curses.h>
3222 #include <wchar.h>
3223 int main(void) {
3224 wchar_t wch = L'w';
3225 setlocale(LC_ALL, "");
3226 resize_term(0, 0);
3227 addwstr(L"wide chars\n");
3228 addnwstr(&wch, 1);
3229 add_wch(WACS_DEGREE);
3230 return 0;
3233 IFS=:
3234 for curses_inc in $curses_inc_list; do
3235 # Make sure we get the wide character prototypes
3236 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3237 IFS=:
3238 for curses_lib in $curses_lib_list; do
3239 unset IFS
3240 if compile_prog "$curses_inc" "$curses_lib" ; then
3241 curses_found=yes
3242 QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
3243 libs_softmmu="$curses_lib $libs_softmmu"
3244 break
3246 done
3247 if test "$curses_found" = yes ; then
3248 break
3250 done
3251 unset IFS
3252 if test "$curses_found" = "yes" ; then
3253 curses=yes
3254 else
3255 if test "$curses" = "yes" ; then
3256 feature_not_found "curses" "Install ncurses devel"
3258 curses=no
3262 ##########################################
3263 # curl probe
3264 if test "$curl" != "no" ; then
3265 if $pkg_config libcurl --exists; then
3266 curlconfig="$pkg_config libcurl"
3267 else
3268 curlconfig=curl-config
3270 cat > $TMPC << EOF
3271 #include <curl/curl.h>
3272 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3274 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3275 curl_libs=$($curlconfig --libs 2>/dev/null)
3276 if compile_prog "$curl_cflags" "$curl_libs" ; then
3277 curl=yes
3278 else
3279 if test "$curl" = "yes" ; then
3280 feature_not_found "curl" "Install libcurl devel"
3282 curl=no
3284 fi # test "$curl"
3286 ##########################################
3287 # bluez support probe
3288 if test "$bluez" != "no" ; then
3289 cat > $TMPC << EOF
3290 #include <bluetooth/bluetooth.h>
3291 int main(void) { return bt_error(0); }
3293 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3294 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3295 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3296 bluez=yes
3297 libs_softmmu="$bluez_libs $libs_softmmu"
3298 else
3299 if test "$bluez" = "yes" ; then
3300 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3302 bluez="no"
3306 ##########################################
3307 # glib support probe
3309 if test "$mingw32" = yes; then
3310 glib_req_ver=2.30
3311 else
3312 glib_req_ver=2.22
3314 glib_modules=gthread-2.0
3315 if test "$modules" = yes; then
3316 glib_modules="$glib_modules gmodule-2.0"
3319 # This workaround is required due to a bug in pkg-config file for glib as it
3320 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3322 if test "$static" = yes -a "$mingw32" = yes; then
3323 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3326 for i in $glib_modules; do
3327 if $pkg_config --atleast-version=$glib_req_ver $i; then
3328 glib_cflags=$($pkg_config --cflags $i)
3329 glib_libs=$($pkg_config --libs $i)
3330 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3331 LIBS="$glib_libs $LIBS"
3332 libs_qga="$glib_libs $libs_qga"
3333 else
3334 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3336 done
3338 # Sanity check that the current size_t matches the
3339 # size that glib thinks it should be. This catches
3340 # problems on multi-arch where people try to build
3341 # 32-bit QEMU while pointing at 64-bit glib headers
3342 cat > $TMPC <<EOF
3343 #include <glib.h>
3344 #include <unistd.h>
3346 #define QEMU_BUILD_BUG_ON(x) \
3347 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3349 int main(void) {
3350 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3351 return 0;
3355 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3356 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3357 "You probably need to set PKG_CONFIG_LIBDIR"\
3358 "to point to the right pkg-config files for your"\
3359 "build target"
3362 # g_test_trap_subprocess added in 2.38. Used by some tests.
3363 glib_subprocess=yes
3364 if ! $pkg_config --atleast-version=2.38 glib-2.0; then
3365 glib_subprocess=no
3368 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3369 cat > $TMPC << EOF
3370 #include <glib.h>
3371 int main(void) { return 0; }
3373 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3374 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3375 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3376 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3380 #########################################
3381 # zlib check
3383 if test "$zlib" != "no" ; then
3384 if $pkg_config --exists zlib; then
3385 zlib_cflags=$($pkg_config --cflags zlib)
3386 zlib_libs=$($pkg_config --libs zlib)
3387 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3388 LIBS="$zlib_libs $LIBS"
3389 else
3390 cat > $TMPC << EOF
3391 #include <zlib.h>
3392 int main(void) { zlibVersion(); return 0; }
3394 if compile_prog "" "-lz" ; then
3395 LIBS="$LIBS -lz"
3396 else
3397 error_exit "zlib check failed" \
3398 "Make sure to have the zlib libs and headers installed."
3403 ##########################################
3404 # SHA command probe for modules
3405 if test "$modules" = yes; then
3406 shacmd_probe="sha1sum sha1 shasum"
3407 for c in $shacmd_probe; do
3408 if has $c; then
3409 shacmd="$c"
3410 break
3412 done
3413 if test "$shacmd" = ""; then
3414 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3418 ##########################################
3419 # pixman support probe
3421 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3422 pixman_cflags=
3423 pixman_libs=
3424 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3425 pixman_cflags=$($pkg_config --cflags pixman-1)
3426 pixman_libs=$($pkg_config --libs pixman-1)
3427 else
3428 error_exit "pixman >= 0.21.8 not present." \
3429 "Please install the pixman devel package."
3432 ##########################################
3433 # libmpathpersist probe
3435 if test "$mpath" != "no" ; then
3436 cat > $TMPC <<EOF
3437 #include <libudev.h>
3438 #include <mpath_persist.h>
3439 unsigned mpath_mx_alloc_len = 1024;
3440 int logsink;
3441 static struct config *multipath_conf;
3442 extern struct udev *udev;
3443 extern struct config *get_multipath_config(void);
3444 extern void put_multipath_config(struct config *conf);
3445 struct udev *udev;
3446 struct config *get_multipath_config(void) { return multipath_conf; }
3447 void put_multipath_config(struct config *conf) { }
3449 int main(void) {
3450 udev = udev_new();
3451 multipath_conf = mpath_lib_init();
3452 return 0;
3455 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3456 mpathpersist=yes
3457 else
3458 mpathpersist=no
3460 else
3461 mpathpersist=no
3464 ##########################################
3465 # libcap probe
3467 if test "$cap" != "no" ; then
3468 cat > $TMPC <<EOF
3469 #include <stdio.h>
3470 #include <sys/capability.h>
3471 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3473 if compile_prog "" "-lcap" ; then
3474 cap=yes
3475 else
3476 cap=no
3480 ##########################################
3481 # pthread probe
3482 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3484 pthread=no
3485 cat > $TMPC << EOF
3486 #include <pthread.h>
3487 static void *f(void *p) { return NULL; }
3488 int main(void) {
3489 pthread_t thread;
3490 pthread_create(&thread, 0, f, 0);
3491 return 0;
3494 if compile_prog "" "" ; then
3495 pthread=yes
3496 else
3497 for pthread_lib in $PTHREADLIBS_LIST; do
3498 if compile_prog "" "$pthread_lib" ; then
3499 pthread=yes
3500 found=no
3501 for lib_entry in $LIBS; do
3502 if test "$lib_entry" = "$pthread_lib"; then
3503 found=yes
3504 break
3506 done
3507 if test "$found" = "no"; then
3508 LIBS="$pthread_lib $LIBS"
3510 PTHREAD_LIB="$pthread_lib"
3511 break
3513 done
3516 if test "$mingw32" != yes -a "$pthread" = no; then
3517 error_exit "pthread check failed" \
3518 "Make sure to have the pthread libs and headers installed."
3521 # check for pthread_setname_np
3522 pthread_setname_np=no
3523 cat > $TMPC << EOF
3524 #include <pthread.h>
3526 static void *f(void *p) { return NULL; }
3527 int main(void)
3529 pthread_t thread;
3530 pthread_create(&thread, 0, f, 0);
3531 pthread_setname_np(thread, "QEMU");
3532 return 0;
3535 if compile_prog "" "$pthread_lib" ; then
3536 pthread_setname_np=yes
3539 ##########################################
3540 # rbd probe
3541 if test "$rbd" != "no" ; then
3542 cat > $TMPC <<EOF
3543 #include <stdio.h>
3544 #include <rbd/librbd.h>
3545 int main(void) {
3546 rados_t cluster;
3547 rados_create(&cluster, NULL);
3548 return 0;
3551 rbd_libs="-lrbd -lrados"
3552 if compile_prog "" "$rbd_libs" ; then
3553 rbd=yes
3554 else
3555 if test "$rbd" = "yes" ; then
3556 feature_not_found "rados block device" "Install librbd/ceph devel"
3558 rbd=no
3562 ##########################################
3563 # libssh2 probe
3564 min_libssh2_version=1.2.8
3565 if test "$libssh2" != "no" ; then
3566 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3567 libssh2_cflags=$($pkg_config libssh2 --cflags)
3568 libssh2_libs=$($pkg_config libssh2 --libs)
3569 libssh2=yes
3570 else
3571 if test "$libssh2" = "yes" ; then
3572 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3574 libssh2=no
3578 ##########################################
3579 # libssh2_sftp_fsync probe
3581 if test "$libssh2" = "yes"; then
3582 cat > $TMPC <<EOF
3583 #include <stdio.h>
3584 #include <libssh2.h>
3585 #include <libssh2_sftp.h>
3586 int main(void) {
3587 LIBSSH2_SESSION *session;
3588 LIBSSH2_SFTP *sftp;
3589 LIBSSH2_SFTP_HANDLE *sftp_handle;
3590 session = libssh2_session_init ();
3591 sftp = libssh2_sftp_init (session);
3592 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3593 libssh2_sftp_fsync (sftp_handle);
3594 return 0;
3597 # libssh2_cflags/libssh2_libs defined in previous test.
3598 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3599 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3603 ##########################################
3604 # linux-aio probe
3606 if test "$linux_aio" != "no" ; then
3607 cat > $TMPC <<EOF
3608 #include <libaio.h>
3609 #include <sys/eventfd.h>
3610 #include <stddef.h>
3611 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3613 if compile_prog "" "-laio" ; then
3614 linux_aio=yes
3615 else
3616 if test "$linux_aio" = "yes" ; then
3617 feature_not_found "linux AIO" "Install libaio devel"
3619 linux_aio=no
3623 ##########################################
3624 # TPM passthrough is only on x86 Linux
3626 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3627 tpm_passthrough=$tpm
3628 else
3629 tpm_passthrough=no
3632 # TPM emulator is for all posix systems
3633 if test "$mingw32" != "yes"; then
3634 tpm_emulator=$tpm
3635 else
3636 tpm_emulator=no
3638 ##########################################
3639 # attr probe
3641 if test "$attr" != "no" ; then
3642 cat > $TMPC <<EOF
3643 #include <stdio.h>
3644 #include <sys/types.h>
3645 #ifdef CONFIG_LIBATTR
3646 #include <attr/xattr.h>
3647 #else
3648 #include <sys/xattr.h>
3649 #endif
3650 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3652 if compile_prog "" "" ; then
3653 attr=yes
3654 # Older distros have <attr/xattr.h>, and need -lattr:
3655 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3656 attr=yes
3657 LIBS="-lattr $LIBS"
3658 libattr=yes
3659 else
3660 if test "$attr" = "yes" ; then
3661 feature_not_found "ATTR" "Install libc6 or libattr devel"
3663 attr=no
3667 ##########################################
3668 # iovec probe
3669 cat > $TMPC <<EOF
3670 #include <sys/types.h>
3671 #include <sys/uio.h>
3672 #include <unistd.h>
3673 int main(void) { return sizeof(struct iovec); }
3675 iovec=no
3676 if compile_prog "" "" ; then
3677 iovec=yes
3680 ##########################################
3681 # preadv probe
3682 cat > $TMPC <<EOF
3683 #include <sys/types.h>
3684 #include <sys/uio.h>
3685 #include <unistd.h>
3686 int main(void) { return preadv(0, 0, 0, 0); }
3688 preadv=no
3689 if compile_prog "" "" ; then
3690 preadv=yes
3693 ##########################################
3694 # fdt probe
3695 # fdt support is mandatory for at least some target architectures,
3696 # so insist on it if we're building those system emulators.
3697 fdt_required=no
3698 for target in $target_list; do
3699 case $target in
3700 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3701 fdt_required=yes
3703 esac
3704 done
3706 if test "$fdt_required" = "yes"; then
3707 if test "$fdt" = "no"; then
3708 error_exit "fdt disabled but some requested targets require it." \
3709 "You can turn off fdt only if you also disable all the system emulation" \
3710 "targets which need it (by specifying a cut down --target-list)."
3712 fdt=yes
3715 if test "$fdt" != "no" ; then
3716 fdt_libs="-lfdt"
3717 # explicitly check for libfdt_env.h as it is missing in some stable installs
3718 # and test for required functions to make sure we are on a version >= 1.4.2
3719 cat > $TMPC << EOF
3720 #include <libfdt.h>
3721 #include <libfdt_env.h>
3722 int main(void) { fdt_first_subnode(0, 0); return 0; }
3724 if compile_prog "" "$fdt_libs" ; then
3725 # system DTC is good - use it
3726 fdt=yes
3727 else
3728 # have GIT checkout, so activate dtc submodule
3729 if test -e "${source_path}/.git" ; then
3730 git_submodules="${git_submodules} dtc"
3732 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3733 fdt=yes
3734 dtc_internal="yes"
3735 mkdir -p dtc
3736 if [ "$pwd_is_source_path" != "y" ] ; then
3737 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3738 symlink "$source_path/dtc/scripts" "dtc/scripts"
3740 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3741 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3742 elif test "$fdt" = "yes" ; then
3743 # Not a git build & no libfdt found, prompt for system install
3744 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3745 "Please install the DTC (libfdt) devel package"
3746 else
3747 # don't have and don't want
3748 fdt_libs=
3749 fdt=no
3754 libs_softmmu="$libs_softmmu $fdt_libs"
3756 ##########################################
3757 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3759 if test "$opengl" != "no" ; then
3760 opengl_pkgs="epoxy libdrm gbm"
3761 if $pkg_config $opengl_pkgs x11; then
3762 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3763 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3764 opengl=yes
3765 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3766 gtk_gl="yes"
3768 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
3769 else
3770 if test "$opengl" = "yes" ; then
3771 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
3773 opengl_cflags=""
3774 opengl_libs=""
3775 opengl=no
3779 if test "$opengl" = "yes"; then
3780 cat > $TMPC << EOF
3781 #include <epoxy/egl.h>
3782 #ifndef EGL_MESA_image_dma_buf_export
3783 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3784 #endif
3785 int main(void) { return 0; }
3787 if compile_prog "" "" ; then
3788 opengl_dmabuf=yes
3793 ##########################################
3794 # glusterfs probe
3795 if test "$glusterfs" != "no" ; then
3796 if $pkg_config --atleast-version=3 glusterfs-api; then
3797 glusterfs="yes"
3798 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3799 glusterfs_libs=$($pkg_config --libs glusterfs-api)
3800 if $pkg_config --atleast-version=4 glusterfs-api; then
3801 glusterfs_xlator_opt="yes"
3803 if $pkg_config --atleast-version=5 glusterfs-api; then
3804 glusterfs_discard="yes"
3806 if $pkg_config --atleast-version=6 glusterfs-api; then
3807 glusterfs_fallocate="yes"
3808 glusterfs_zerofill="yes"
3810 else
3811 if test "$glusterfs" = "yes" ; then
3812 feature_not_found "GlusterFS backend support" \
3813 "Install glusterfs-api devel >= 3"
3815 glusterfs="no"
3819 # Check for inotify functions when we are building linux-user
3820 # emulator. This is done because older glibc versions don't
3821 # have syscall stubs for these implemented. In that case we
3822 # don't provide them even if kernel supports them.
3824 inotify=no
3825 cat > $TMPC << EOF
3826 #include <sys/inotify.h>
3829 main(void)
3831 /* try to start inotify */
3832 return inotify_init();
3835 if compile_prog "" "" ; then
3836 inotify=yes
3839 inotify1=no
3840 cat > $TMPC << EOF
3841 #include <sys/inotify.h>
3844 main(void)
3846 /* try to start inotify */
3847 return inotify_init1(0);
3850 if compile_prog "" "" ; then
3851 inotify1=yes
3854 # check if pipe2 is there
3855 pipe2=no
3856 cat > $TMPC << EOF
3857 #include <unistd.h>
3858 #include <fcntl.h>
3860 int main(void)
3862 int pipefd[2];
3863 return pipe2(pipefd, O_CLOEXEC);
3866 if compile_prog "" "" ; then
3867 pipe2=yes
3870 # check if accept4 is there
3871 accept4=no
3872 cat > $TMPC << EOF
3873 #include <sys/socket.h>
3874 #include <stddef.h>
3876 int main(void)
3878 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3879 return 0;
3882 if compile_prog "" "" ; then
3883 accept4=yes
3886 # check if tee/splice is there. vmsplice was added same time.
3887 splice=no
3888 cat > $TMPC << EOF
3889 #include <unistd.h>
3890 #include <fcntl.h>
3891 #include <limits.h>
3893 int main(void)
3895 int len, fd = 0;
3896 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3897 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3898 return 0;
3901 if compile_prog "" "" ; then
3902 splice=yes
3905 ##########################################
3906 # libnuma probe
3908 if test "$numa" != "no" ; then
3909 cat > $TMPC << EOF
3910 #include <numa.h>
3911 int main(void) { return numa_available(); }
3914 if compile_prog "" "-lnuma" ; then
3915 numa=yes
3916 libs_softmmu="-lnuma $libs_softmmu"
3917 else
3918 if test "$numa" = "yes" ; then
3919 feature_not_found "numa" "install numactl devel"
3921 numa=no
3925 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3926 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3927 exit 1
3930 # Even if malloc_trim() is available, these non-libc memory allocators
3931 # do not support it.
3932 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
3933 if test "$malloc_trim" = "yes" ; then
3934 echo "Disabling malloc_trim with non-libc memory allocator"
3936 malloc_trim="no"
3939 #######################################
3940 # malloc_trim
3942 if test "$malloc_trim" != "no" ; then
3943 cat > $TMPC << EOF
3944 #include <malloc.h>
3945 int main(void) { malloc_trim(0); return 0; }
3947 if compile_prog "" "" ; then
3948 malloc_trim="yes"
3949 else
3950 malloc_trim="no"
3954 ##########################################
3955 # tcmalloc probe
3957 if test "$tcmalloc" = "yes" ; then
3958 cat > $TMPC << EOF
3959 #include <stdlib.h>
3960 int main(void) { malloc(1); return 0; }
3963 if compile_prog "" "-ltcmalloc" ; then
3964 LIBS="-ltcmalloc $LIBS"
3965 else
3966 feature_not_found "tcmalloc" "install gperftools devel"
3970 ##########################################
3971 # jemalloc probe
3973 if test "$jemalloc" = "yes" ; then
3974 cat > $TMPC << EOF
3975 #include <stdlib.h>
3976 int main(void) { malloc(1); return 0; }
3979 if compile_prog "" "-ljemalloc" ; then
3980 LIBS="-ljemalloc $LIBS"
3981 else
3982 feature_not_found "jemalloc" "install jemalloc devel"
3986 ##########################################
3987 # signalfd probe
3988 signalfd="no"
3989 cat > $TMPC << EOF
3990 #include <unistd.h>
3991 #include <sys/syscall.h>
3992 #include <signal.h>
3993 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3996 if compile_prog "" "" ; then
3997 signalfd=yes
4000 # check if eventfd is supported
4001 eventfd=no
4002 cat > $TMPC << EOF
4003 #include <sys/eventfd.h>
4005 int main(void)
4007 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4010 if compile_prog "" "" ; then
4011 eventfd=yes
4014 # check if memfd is supported
4015 memfd=no
4016 cat > $TMPC << EOF
4017 #include <sys/mman.h>
4019 int main(void)
4021 return memfd_create("foo", MFD_ALLOW_SEALING);
4024 if compile_prog "" "" ; then
4025 memfd=yes
4030 # check for fallocate
4031 fallocate=no
4032 cat > $TMPC << EOF
4033 #include <fcntl.h>
4035 int main(void)
4037 fallocate(0, 0, 0, 0);
4038 return 0;
4041 if compile_prog "" "" ; then
4042 fallocate=yes
4045 # check for fallocate hole punching
4046 fallocate_punch_hole=no
4047 cat > $TMPC << EOF
4048 #include <fcntl.h>
4049 #include <linux/falloc.h>
4051 int main(void)
4053 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4054 return 0;
4057 if compile_prog "" "" ; then
4058 fallocate_punch_hole=yes
4061 # check that fallocate supports range zeroing inside the file
4062 fallocate_zero_range=no
4063 cat > $TMPC << EOF
4064 #include <fcntl.h>
4065 #include <linux/falloc.h>
4067 int main(void)
4069 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4070 return 0;
4073 if compile_prog "" "" ; then
4074 fallocate_zero_range=yes
4077 # check for posix_fallocate
4078 posix_fallocate=no
4079 cat > $TMPC << EOF
4080 #include <fcntl.h>
4082 int main(void)
4084 posix_fallocate(0, 0, 0);
4085 return 0;
4088 if compile_prog "" "" ; then
4089 posix_fallocate=yes
4092 # check for sync_file_range
4093 sync_file_range=no
4094 cat > $TMPC << EOF
4095 #include <fcntl.h>
4097 int main(void)
4099 sync_file_range(0, 0, 0, 0);
4100 return 0;
4103 if compile_prog "" "" ; then
4104 sync_file_range=yes
4107 # check for linux/fiemap.h and FS_IOC_FIEMAP
4108 fiemap=no
4109 cat > $TMPC << EOF
4110 #include <sys/ioctl.h>
4111 #include <linux/fs.h>
4112 #include <linux/fiemap.h>
4114 int main(void)
4116 ioctl(0, FS_IOC_FIEMAP, 0);
4117 return 0;
4120 if compile_prog "" "" ; then
4121 fiemap=yes
4124 # check for dup3
4125 dup3=no
4126 cat > $TMPC << EOF
4127 #include <unistd.h>
4129 int main(void)
4131 dup3(0, 0, 0);
4132 return 0;
4135 if compile_prog "" "" ; then
4136 dup3=yes
4139 # check for ppoll support
4140 ppoll=no
4141 cat > $TMPC << EOF
4142 #include <poll.h>
4144 int main(void)
4146 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4147 ppoll(&pfd, 1, 0, 0);
4148 return 0;
4151 if compile_prog "" "" ; then
4152 ppoll=yes
4155 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4156 prctl_pr_set_timerslack=no
4157 cat > $TMPC << EOF
4158 #include <sys/prctl.h>
4160 int main(void)
4162 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4163 return 0;
4166 if compile_prog "" "" ; then
4167 prctl_pr_set_timerslack=yes
4170 # check for epoll support
4171 epoll=no
4172 cat > $TMPC << EOF
4173 #include <sys/epoll.h>
4175 int main(void)
4177 epoll_create(0);
4178 return 0;
4181 if compile_prog "" "" ; then
4182 epoll=yes
4185 # epoll_create1 is a later addition
4186 # so we must check separately for its presence
4187 epoll_create1=no
4188 cat > $TMPC << EOF
4189 #include <sys/epoll.h>
4191 int main(void)
4193 /* Note that we use epoll_create1 as a value, not as
4194 * a function being called. This is necessary so that on
4195 * old SPARC glibc versions where the function was present in
4196 * the library but not declared in the header file we will
4197 * fail the configure check. (Otherwise we will get a compiler
4198 * warning but not an error, and will proceed to fail the
4199 * qemu compile where we compile with -Werror.)
4201 return (int)(uintptr_t)&epoll_create1;
4204 if compile_prog "" "" ; then
4205 epoll_create1=yes
4208 # check for sendfile support
4209 sendfile=no
4210 cat > $TMPC << EOF
4211 #include <sys/sendfile.h>
4213 int main(void)
4215 return sendfile(0, 0, 0, 0);
4218 if compile_prog "" "" ; then
4219 sendfile=yes
4222 # check for timerfd support (glibc 2.8 and newer)
4223 timerfd=no
4224 cat > $TMPC << EOF
4225 #include <sys/timerfd.h>
4227 int main(void)
4229 return(timerfd_create(CLOCK_REALTIME, 0));
4232 if compile_prog "" "" ; then
4233 timerfd=yes
4236 # check for setns and unshare support
4237 setns=no
4238 cat > $TMPC << EOF
4239 #include <sched.h>
4241 int main(void)
4243 int ret;
4244 ret = setns(0, 0);
4245 ret = unshare(0);
4246 return ret;
4249 if compile_prog "" "" ; then
4250 setns=yes
4253 # clock_adjtime probe
4254 clock_adjtime=no
4255 cat > $TMPC <<EOF
4256 #include <time.h>
4258 int main(void)
4260 return clock_adjtime(0, 0);
4263 clock_adjtime=no
4264 if compile_prog "" "" ; then
4265 clock_adjtime=yes
4268 # syncfs probe
4269 syncfs=no
4270 cat > $TMPC <<EOF
4271 #include <unistd.h>
4273 int main(void)
4275 return syncfs(0);
4278 syncfs=no
4279 if compile_prog "" "" ; then
4280 syncfs=yes
4283 # Check if tools are available to build documentation.
4284 if test "$docs" != "no" ; then
4285 if has makeinfo && has pod2man; then
4286 docs=yes
4287 else
4288 if test "$docs" = "yes" ; then
4289 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4291 docs=no
4295 if test "$want_tools" = ""; then
4296 if test $(expr "$target_list" : ".*softmmu.*") != 0; then
4297 want_tools=yes
4298 else
4299 want_tools=no
4303 # Search for bswap_32 function
4304 byteswap_h=no
4305 cat > $TMPC << EOF
4306 #include <byteswap.h>
4307 int main(void) { return bswap_32(0); }
4309 if compile_prog "" "" ; then
4310 byteswap_h=yes
4313 # Search for bswap32 function
4314 bswap_h=no
4315 cat > $TMPC << EOF
4316 #include <sys/endian.h>
4317 #include <sys/types.h>
4318 #include <machine/bswap.h>
4319 int main(void) { return bswap32(0); }
4321 if compile_prog "" "" ; then
4322 bswap_h=yes
4325 ##########################################
4326 # Do we have libiscsi >= 1.9.0
4327 if test "$libiscsi" != "no" ; then
4328 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4329 libiscsi="yes"
4330 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4331 libiscsi_libs=$($pkg_config --libs libiscsi)
4332 else
4333 if test "$libiscsi" = "yes" ; then
4334 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4336 libiscsi="no"
4340 ##########################################
4341 # Do we need libm
4342 cat > $TMPC << EOF
4343 #include <math.h>
4344 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4346 if compile_prog "" "" ; then
4348 elif compile_prog "" "-lm" ; then
4349 LIBS="-lm $LIBS"
4350 libs_qga="-lm $libs_qga"
4351 else
4352 error_exit "libm check failed"
4355 ##########################################
4356 # Do we need librt
4357 # uClibc provides 2 versions of clock_gettime(), one with realtime
4358 # support and one without. This means that the clock_gettime() don't
4359 # need -lrt. We still need it for timer_create() so we check for this
4360 # function in addition.
4361 cat > $TMPC <<EOF
4362 #include <signal.h>
4363 #include <time.h>
4364 int main(void) {
4365 timer_create(CLOCK_REALTIME, NULL, NULL);
4366 return clock_gettime(CLOCK_REALTIME, NULL);
4370 if compile_prog "" "" ; then
4372 # we need pthread for static linking. use previous pthread test result
4373 elif compile_prog "" "$pthread_lib -lrt" ; then
4374 LIBS="$LIBS -lrt"
4375 libs_qga="$libs_qga -lrt"
4378 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4379 "$haiku" != "yes" ; then
4380 libs_softmmu="-lutil $libs_softmmu"
4383 ##########################################
4384 # spice probe
4385 if test "$spice" != "no" ; then
4386 cat > $TMPC << EOF
4387 #include <spice.h>
4388 int main(void) { spice_server_new(); return 0; }
4390 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4391 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4392 if $pkg_config --atleast-version=0.12.0 spice-server && \
4393 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4394 compile_prog "$spice_cflags" "$spice_libs" ; then
4395 spice="yes"
4396 libs_softmmu="$libs_softmmu $spice_libs"
4397 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4398 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4399 spice_server_version=$($pkg_config --modversion spice-server)
4400 else
4401 if test "$spice" = "yes" ; then
4402 feature_not_found "spice" \
4403 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4405 spice="no"
4409 # check for smartcard support
4410 if test "$smartcard" != "no"; then
4411 if $pkg_config libcacard; then
4412 libcacard_cflags=$($pkg_config --cflags libcacard)
4413 libcacard_libs=$($pkg_config --libs libcacard)
4414 smartcard="yes"
4415 else
4416 if test "$smartcard" = "yes"; then
4417 feature_not_found "smartcard" "Install libcacard devel"
4419 smartcard="no"
4423 # check for libusb
4424 if test "$libusb" != "no" ; then
4425 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4426 libusb="yes"
4427 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4428 libusb_libs=$($pkg_config --libs libusb-1.0)
4429 else
4430 if test "$libusb" = "yes"; then
4431 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4433 libusb="no"
4437 # check for usbredirparser for usb network redirection support
4438 if test "$usb_redir" != "no" ; then
4439 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4440 usb_redir="yes"
4441 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4442 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4443 else
4444 if test "$usb_redir" = "yes"; then
4445 feature_not_found "usb-redir" "Install usbredir devel"
4447 usb_redir="no"
4451 ##########################################
4452 # check if we have VSS SDK headers for win
4454 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4455 case "$vss_win32_sdk" in
4456 "") vss_win32_include="-isystem $source_path" ;;
4457 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4458 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4459 vss_win32_include="-isystem $source_path/.sdk/vss"
4460 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4462 *) vss_win32_include="-isystem $vss_win32_sdk"
4463 esac
4464 cat > $TMPC << EOF
4465 #define __MIDL_user_allocate_free_DEFINED__
4466 #include <inc/win2003/vss.h>
4467 int main(void) { return VSS_CTX_BACKUP; }
4469 if compile_prog "$vss_win32_include" "" ; then
4470 guest_agent_with_vss="yes"
4471 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4472 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4473 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4474 else
4475 if test "$vss_win32_sdk" != "" ; then
4476 echo "ERROR: Please download and install Microsoft VSS SDK:"
4477 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4478 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4479 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4480 echo "ERROR: The headers are extracted in the directory \`inc'."
4481 feature_not_found "VSS support"
4483 guest_agent_with_vss="no"
4487 ##########################################
4488 # lookup Windows platform SDK (if not specified)
4489 # The SDK is needed only to build .tlb (type library) file of guest agent
4490 # VSS provider from the source. It is usually unnecessary because the
4491 # pre-compiled .tlb file is included.
4493 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4494 if test -z "$win_sdk"; then
4495 programfiles="$PROGRAMFILES"
4496 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4497 if test -n "$programfiles"; then
4498 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4499 else
4500 feature_not_found "Windows SDK"
4502 elif test "$win_sdk" = "no"; then
4503 win_sdk=""
4507 ##########################################
4508 # check if mingw environment provides a recent ntddscsi.h
4509 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4510 cat > $TMPC << EOF
4511 #include <windows.h>
4512 #include <ntddscsi.h>
4513 int main(void) {
4514 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4515 #error Missing required ioctl definitions
4516 #endif
4517 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4518 return addr.Lun;
4521 if compile_prog "" "" ; then
4522 guest_agent_ntddscsi=yes
4523 libs_qga="-lsetupapi $libs_qga"
4527 ##########################################
4528 # virgl renderer probe
4530 if test "$virglrenderer" != "no" ; then
4531 cat > $TMPC << EOF
4532 #include <virglrenderer.h>
4533 int main(void) { virgl_renderer_poll(); return 0; }
4535 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4536 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4537 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4538 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4539 virglrenderer="yes"
4540 else
4541 if test "$virglrenderer" = "yes" ; then
4542 feature_not_found "virglrenderer"
4544 virglrenderer="no"
4548 ##########################################
4549 # capstone
4551 case "$capstone" in
4552 "" | yes)
4553 if $pkg_config capstone; then
4554 capstone=system
4555 elif test -e "${source_path}/.git" ; then
4556 capstone=git
4557 elif test -e "${source_path}/capstone/Makefile" ; then
4558 capstone=internal
4559 elif test -z "$capstone" ; then
4560 capstone=no
4561 else
4562 feature_not_found "capstone" "Install capstone devel or git submodule"
4566 system)
4567 if ! $pkg_config capstone; then
4568 feature_not_found "capstone" "Install capstone devel"
4571 esac
4573 case "$capstone" in
4574 git | internal)
4575 if test "$capstone" = git; then
4576 git_submodules="${git_submodules} capstone"
4578 mkdir -p capstone
4579 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4580 if test "$mingw32" = "yes"; then
4581 LIBCAPSTONE=capstone.lib
4582 else
4583 LIBCAPSTONE=libcapstone.a
4585 LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4588 system)
4589 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
4590 LIBS="$($pkg_config --libs capstone) $LIBS"
4596 error_exit "Unknown state for capstone: $capstone"
4598 esac
4600 ##########################################
4601 # check if we have fdatasync
4603 fdatasync=no
4604 cat > $TMPC << EOF
4605 #include <unistd.h>
4606 int main(void) {
4607 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4608 return fdatasync(0);
4609 #else
4610 #error Not supported
4611 #endif
4614 if compile_prog "" "" ; then
4615 fdatasync=yes
4618 ##########################################
4619 # check if we have madvise
4621 madvise=no
4622 cat > $TMPC << EOF
4623 #include <sys/types.h>
4624 #include <sys/mman.h>
4625 #include <stddef.h>
4626 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4628 if compile_prog "" "" ; then
4629 madvise=yes
4632 ##########################################
4633 # check if we have posix_madvise
4635 posix_madvise=no
4636 cat > $TMPC << EOF
4637 #include <sys/mman.h>
4638 #include <stddef.h>
4639 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4641 if compile_prog "" "" ; then
4642 posix_madvise=yes
4645 ##########################################
4646 # check if we have posix_syslog
4648 posix_syslog=no
4649 cat > $TMPC << EOF
4650 #include <syslog.h>
4651 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4653 if compile_prog "" "" ; then
4654 posix_syslog=yes
4657 ##########################################
4658 # check if we have sem_timedwait
4660 sem_timedwait=no
4661 cat > $TMPC << EOF
4662 #include <semaphore.h>
4663 int main(void) { return sem_timedwait(0, 0); }
4665 if compile_prog "" "" ; then
4666 sem_timedwait=yes
4669 ##########################################
4670 # check if trace backend exists
4672 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4673 if test "$?" -ne 0 ; then
4674 error_exit "invalid trace backends" \
4675 "Please choose supported trace backends."
4678 ##########################################
4679 # For 'ust' backend, test if ust headers are present
4680 if have_backend "ust"; then
4681 cat > $TMPC << EOF
4682 #include <lttng/tracepoint.h>
4683 int main(void) { return 0; }
4685 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4686 if $pkg_config lttng-ust --exists; then
4687 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4688 else
4689 lttng_ust_libs="-llttng-ust -ldl"
4691 if $pkg_config liburcu-bp --exists; then
4692 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4693 else
4694 urcu_bp_libs="-lurcu-bp"
4697 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4698 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4699 else
4700 error_exit "Trace backend 'ust' missing lttng-ust header files"
4704 ##########################################
4705 # For 'dtrace' backend, test if 'dtrace' command is present
4706 if have_backend "dtrace"; then
4707 if ! has 'dtrace' ; then
4708 error_exit "dtrace command is not found in PATH $PATH"
4710 trace_backend_stap="no"
4711 if has 'stap' ; then
4712 trace_backend_stap="yes"
4716 ##########################################
4717 # check and set a backend for coroutine
4719 # We prefer ucontext, but it's not always possible. The fallback
4720 # is sigcontext. On Windows the only valid backend is the Windows
4721 # specific one.
4723 ucontext_works=no
4724 if test "$darwin" != "yes"; then
4725 cat > $TMPC << EOF
4726 #include <ucontext.h>
4727 #ifdef __stub_makecontext
4728 #error Ignoring glibc stub makecontext which will always fail
4729 #endif
4730 int main(void) { makecontext(0, 0, 0); return 0; }
4732 if compile_prog "" "" ; then
4733 ucontext_works=yes
4737 if test "$coroutine" = ""; then
4738 if test "$mingw32" = "yes"; then
4739 coroutine=win32
4740 elif test "$ucontext_works" = "yes"; then
4741 coroutine=ucontext
4742 else
4743 coroutine=sigaltstack
4745 else
4746 case $coroutine in
4747 windows)
4748 if test "$mingw32" != "yes"; then
4749 error_exit "'windows' coroutine backend only valid for Windows"
4751 # Unfortunately the user visible backend name doesn't match the
4752 # coroutine-*.c filename for this case, so we have to adjust it here.
4753 coroutine=win32
4755 ucontext)
4756 if test "$ucontext_works" != "yes"; then
4757 feature_not_found "ucontext"
4760 sigaltstack)
4761 if test "$mingw32" = "yes"; then
4762 error_exit "only the 'windows' coroutine backend is valid for Windows"
4766 error_exit "unknown coroutine backend $coroutine"
4768 esac
4771 if test "$coroutine_pool" = ""; then
4772 if test "$coroutine" = "gthread" -o "$coroutine" = "win32"; then
4773 coroutine_pool=no
4774 else
4775 coroutine_pool=yes
4778 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
4779 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
4782 if test "$debug_stack_usage" = "yes"; then
4783 if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
4784 error_exit "stack usage debugging is not supported for $cpu"
4786 if test "$coroutine_pool" = "yes"; then
4787 echo "WARN: disabling coroutine pool for stack usage debugging"
4788 coroutine_pool=no
4793 ##########################################
4794 # check if we have open_by_handle_at
4796 open_by_handle_at=no
4797 cat > $TMPC << EOF
4798 #include <fcntl.h>
4799 #if !defined(AT_EMPTY_PATH)
4800 # error missing definition
4801 #else
4802 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4803 #endif
4805 if compile_prog "" "" ; then
4806 open_by_handle_at=yes
4809 ########################################
4810 # check if we have linux/magic.h
4812 linux_magic_h=no
4813 cat > $TMPC << EOF
4814 #include <linux/magic.h>
4815 int main(void) {
4816 return 0;
4819 if compile_prog "" "" ; then
4820 linux_magic_h=yes
4823 ########################################
4824 # check whether we can disable warning option with a pragma (this is needed
4825 # to silence warnings in the headers of some versions of external libraries).
4826 # This test has to be compiled with -Werror as otherwise an unknown pragma is
4827 # only a warning.
4829 # If we can't selectively disable warning in the code, disable -Werror so that
4830 # the build doesn't fail anyway.
4832 pragma_disable_unused_but_set=no
4833 cat > $TMPC << EOF
4834 #pragma GCC diagnostic push
4835 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4836 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
4837 #pragma GCC diagnostic pop
4839 int main(void) {
4840 return 0;
4843 if compile_prog "-Werror" "" ; then
4844 pragma_diagnostic_available=yes
4847 ########################################
4848 # check if we have valgrind/valgrind.h
4850 valgrind_h=no
4851 cat > $TMPC << EOF
4852 #include <valgrind/valgrind.h>
4853 int main(void) {
4854 return 0;
4857 if compile_prog "" "" ; then
4858 valgrind_h=yes
4861 ########################################
4862 # check if environ is declared
4864 has_environ=no
4865 cat > $TMPC << EOF
4866 #include <unistd.h>
4867 int main(void) {
4868 environ = 0;
4869 return 0;
4872 if compile_prog "" "" ; then
4873 has_environ=yes
4876 ########################################
4877 # check if cpuid.h is usable.
4879 cat > $TMPC << EOF
4880 #include <cpuid.h>
4881 int main(void) {
4882 unsigned a, b, c, d;
4883 int max = __get_cpuid_max(0, 0);
4885 if (max >= 1) {
4886 __cpuid(1, a, b, c, d);
4889 if (max >= 7) {
4890 __cpuid_count(7, 0, a, b, c, d);
4893 return 0;
4896 if compile_prog "" "" ; then
4897 cpuid_h=yes
4900 ##########################################
4901 # avx2 optimization requirement check
4903 # There is no point enabling this if cpuid.h is not usable,
4904 # since we won't be able to select the new routines.
4906 if test $cpuid_h = yes; then
4907 cat > $TMPC << EOF
4908 #pragma GCC push_options
4909 #pragma GCC target("avx2")
4910 #include <cpuid.h>
4911 #include <immintrin.h>
4912 static int bar(void *a) {
4913 __m256i x = *(__m256i *)a;
4914 return _mm256_testz_si256(x, x);
4916 int main(int argc, char *argv[]) { return bar(argv[0]); }
4918 if compile_object "" ; then
4919 avx2_opt="yes"
4923 ########################################
4924 # check if __[u]int128_t is usable.
4926 int128=no
4927 cat > $TMPC << EOF
4928 #if defined(__clang_major__) && defined(__clang_minor__)
4929 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4930 # error __int128_t does not work in CLANG before 3.2
4931 # endif
4932 #endif
4933 __int128_t a;
4934 __uint128_t b;
4935 int main (void) {
4936 a = a + b;
4937 b = a * b;
4938 a = a * a;
4939 return 0;
4942 if compile_prog "" "" ; then
4943 int128=yes
4946 #########################################
4947 # See if 128-bit atomic operations are supported.
4949 atomic128=no
4950 if test "$int128" = "yes"; then
4951 cat > $TMPC << EOF
4952 int main(void)
4954 unsigned __int128 x = 0, y = 0;
4955 y = __atomic_load_16(&x, 0);
4956 __atomic_store_16(&x, y, 0);
4957 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
4958 return 0;
4961 if compile_prog "" "" ; then
4962 atomic128=yes
4966 #########################################
4967 # See if 64-bit atomic operations are supported.
4968 # Note that without __atomic builtins, we can only
4969 # assume atomic loads/stores max at pointer size.
4971 cat > $TMPC << EOF
4972 #include <stdint.h>
4973 int main(void)
4975 uint64_t x = 0, y = 0;
4976 #ifdef __ATOMIC_RELAXED
4977 y = __atomic_load_8(&x, 0);
4978 __atomic_store_8(&x, y, 0);
4979 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4980 __atomic_exchange_8(&x, y, 0);
4981 __atomic_fetch_add_8(&x, y, 0);
4982 #else
4983 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4984 __sync_lock_test_and_set(&x, y);
4985 __sync_val_compare_and_swap(&x, y, 0);
4986 __sync_fetch_and_add(&x, y);
4987 #endif
4988 return 0;
4991 if compile_prog "" "" ; then
4992 atomic64=yes
4995 ########################################
4996 # check if getauxval is available.
4998 getauxval=no
4999 cat > $TMPC << EOF
5000 #include <sys/auxv.h>
5001 int main(void) {
5002 return getauxval(AT_HWCAP) == 0;
5005 if compile_prog "" "" ; then
5006 getauxval=yes
5009 ########################################
5010 # check if ccache is interfering with
5011 # semantic analysis of macros
5013 unset CCACHE_CPP2
5014 ccache_cpp2=no
5015 cat > $TMPC << EOF
5016 static const int Z = 1;
5017 #define fn() ({ Z; })
5018 #define TAUT(X) ((X) == Z)
5019 #define PAREN(X, Y) (X == Y)
5020 #define ID(X) (X)
5021 int main(int argc, char *argv[])
5023 int x = 0, y = 0;
5024 x = ID(x);
5025 x = fn();
5026 fn();
5027 if (PAREN(x, y)) return 0;
5028 if (TAUT(Z)) return 0;
5029 return 0;
5033 if ! compile_object "-Werror"; then
5034 ccache_cpp2=yes
5037 #################################################
5038 # clang does not support glibc + FORTIFY_SOURCE.
5040 if test "$fortify_source" != "no"; then
5041 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5042 fortify_source="no";
5043 elif test -n "$cxx" && has $cxx &&
5044 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5045 fortify_source="no";
5046 else
5047 fortify_source="yes"
5051 ##########################################
5052 # check if struct fsxattr is available via linux/fs.h
5054 have_fsxattr=no
5055 cat > $TMPC << EOF
5056 #include <linux/fs.h>
5057 struct fsxattr foo;
5058 int main(void) {
5059 return 0;
5062 if compile_prog "" "" ; then
5063 have_fsxattr=yes
5066 ##########################################
5067 # check if rtnetlink.h exists and is useful
5068 have_rtnetlink=no
5069 cat > $TMPC << EOF
5070 #include <linux/rtnetlink.h>
5071 int main(void) {
5072 return IFLA_PROTO_DOWN;
5075 if compile_prog "" "" ; then
5076 have_rtnetlink=yes
5079 ##########################################
5080 # check for usable AF_VSOCK environment
5081 have_af_vsock=no
5082 cat > $TMPC << EOF
5083 #include <errno.h>
5084 #include <sys/types.h>
5085 #include <sys/socket.h>
5086 #if !defined(AF_VSOCK)
5087 # error missing AF_VSOCK flag
5088 #endif
5089 #include <linux/vm_sockets.h>
5090 int main(void) {
5091 int sock, ret;
5092 struct sockaddr_vm svm;
5093 socklen_t len = sizeof(svm);
5094 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
5095 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
5096 if ((ret == -1) && (errno == ENOTCONN)) {
5097 return 0;
5099 return -1;
5102 if compile_prog "" "" ; then
5103 have_af_vsock=yes
5106 ##########################################
5107 # check for usable AF_ALG environment
5108 hava_afalg=no
5109 cat > $TMPC << EOF
5110 #include <errno.h>
5111 #include <sys/types.h>
5112 #include <sys/socket.h>
5113 #include <linux/if_alg.h>
5114 int main(void) {
5115 int sock;
5116 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5117 return sock;
5120 if compile_prog "" "" ; then
5121 have_afalg=yes
5123 if test "$crypto_afalg" = "yes"
5124 then
5125 if test "$have_afalg" != "yes"
5126 then
5127 error_exit "AF_ALG requested but could not be detected"
5132 #################################################
5133 # Check to see if we have the Hypervisor framework
5134 if [ "$darwin" = "yes" ] ; then
5135 cat > $TMPC << EOF
5136 #include <Hypervisor/hv.h>
5137 int main() { return 0;}
5139 if ! compile_object ""; then
5140 hvf='no'
5141 else
5142 hvf='yes'
5143 LDFLAGS="-framework Hypervisor $LDFLAGS"
5147 #################################################
5148 # Sparc implicitly links with --relax, which is
5149 # incompatible with -r, so --no-relax should be
5150 # given. It does no harm to give it on other
5151 # platforms too.
5153 # Note: the prototype is needed since QEMU_CFLAGS
5154 # contains -Wmissing-prototypes
5155 cat > $TMPC << EOF
5156 extern int foo(void);
5157 int foo(void) { return 0; }
5159 if ! compile_object ""; then
5160 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5162 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5163 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5164 LD_REL_FLAGS=$i
5165 break
5167 done
5168 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5169 feature_not_found "modules" "Cannot find how to build relocatable objects"
5172 ##########################################
5173 # check for sysmacros.h
5175 have_sysmacros=no
5176 cat > $TMPC << EOF
5177 #include <sys/sysmacros.h>
5178 int main(void) {
5179 return makedev(0, 0);
5182 if compile_prog "" "" ; then
5183 have_sysmacros=yes
5186 ##########################################
5187 # Veritas HyperScale block driver VxHS
5188 # Check if libvxhs is installed
5190 if test "$vxhs" != "no" ; then
5191 cat > $TMPC <<EOF
5192 #include <stdint.h>
5193 #include <qnio/qnio_api.h>
5195 void *vxhs_callback;
5197 int main(void) {
5198 iio_init(QNIO_VERSION, vxhs_callback);
5199 return 0;
5202 vxhs_libs="-lvxhs -lssl"
5203 if compile_prog "" "$vxhs_libs" ; then
5204 vxhs=yes
5205 else
5206 if test "$vxhs" = "yes" ; then
5207 feature_not_found "vxhs block device" "Install libvxhs See github"
5209 vxhs=no
5213 ##########################################
5214 # check for _Static_assert()
5216 have_static_assert=no
5217 cat > $TMPC << EOF
5218 _Static_assert(1, "success");
5219 int main(void) {
5220 return 0;
5223 if compile_prog "" "" ; then
5224 have_static_assert=yes
5227 ##########################################
5228 # check for utmpx.h, it is missing e.g. on OpenBSD
5230 have_utmpx=no
5231 cat > $TMPC << EOF
5232 #include <utmpx.h>
5233 struct utmpx user_info;
5234 int main(void) {
5235 return 0;
5238 if compile_prog "" "" ; then
5239 have_utmpx=yes
5242 ##########################################
5243 # End of CC checks
5244 # After here, no more $cc or $ld runs
5246 if test "$gcov" = "yes" ; then
5247 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
5248 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5249 elif test "$fortify_source" = "yes" ; then
5250 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
5251 elif test "$debug" = "no"; then
5252 CFLAGS="-O2 $CFLAGS"
5255 ##########################################
5256 # Do we have libnfs
5257 if test "$libnfs" != "no" ; then
5258 if $pkg_config --atleast-version=1.9.3 libnfs; then
5259 libnfs="yes"
5260 libnfs_libs=$($pkg_config --libs libnfs)
5261 else
5262 if test "$libnfs" = "yes" ; then
5263 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
5265 libnfs="no"
5269 # Now we've finished running tests it's OK to add -Werror to the compiler flags
5270 if test "$werror" = "yes"; then
5271 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
5274 if test "$solaris" = "no" ; then
5275 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5276 LDFLAGS="-Wl,--warn-common $LDFLAGS"
5280 # test if pod2man has --utf8 option
5281 if pod2man --help | grep -q utf8; then
5282 POD2MAN="pod2man --utf8"
5283 else
5284 POD2MAN="pod2man"
5287 # Use large addresses, ASLR, no-SEH and DEP if available.
5288 if test "$mingw32" = "yes" ; then
5289 if test "$cpu" = i386; then
5290 LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
5292 for flag in --dynamicbase --no-seh --nxcompat; do
5293 if ld_has $flag ; then
5294 LDFLAGS="-Wl,$flag $LDFLAGS"
5296 done
5299 qemu_confdir=$sysconfdir$confsuffix
5300 qemu_moddir=$libdir$confsuffix
5301 qemu_datadir=$datadir$confsuffix
5302 qemu_localedir="$datadir/locale"
5304 # We can only support ivshmem if we have eventfd
5305 if [ "$eventfd" = "yes" ]; then
5306 ivshmem=yes
5309 tools=""
5310 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
5311 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
5312 tools="qemu-nbd\$(EXESUF) $tools"
5314 if [ "$ivshmem" = "yes" ]; then
5315 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
5317 if test "$softmmu" = yes ; then
5318 if test "$linux" = yes; then
5319 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5320 virtfs=yes
5321 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5322 else
5323 if test "$virtfs" = yes; then
5324 error_exit "VirtFS requires libcap devel and libattr devel"
5326 virtfs=no
5328 if test "$mpath" != no && test "$mpathpersist" = yes ; then
5329 mpath=yes
5330 else
5331 if test "$mpath" = yes; then
5332 error_exit "Multipath requires libmpathpersist devel"
5334 mpath=no
5336 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5337 else
5338 if test "$virtfs" = yes; then
5339 error_exit "VirtFS is supported only on Linux"
5341 virtfs=no
5342 if test "$mpath" = yes; then
5343 error_exit "Multipath is supported only on Linux"
5345 mpath=no
5347 if test "$xkbcommon" = "yes"; then
5348 tools="qemu-keymap\$(EXESUF) $tools"
5352 # Probe for guest agent support/options
5354 if [ "$guest_agent" != "no" ]; then
5355 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5356 tools="qemu-ga $tools"
5357 guest_agent=yes
5358 elif [ "$guest_agent" != yes ]; then
5359 guest_agent=no
5360 else
5361 error_exit "Guest agent is not supported on this platform"
5365 # Guest agent Window MSI package
5367 if test "$guest_agent" != yes; then
5368 if test "$guest_agent_msi" = yes; then
5369 error_exit "MSI guest agent package requires guest agent enabled"
5371 guest_agent_msi=no
5372 elif test "$mingw32" != "yes"; then
5373 if test "$guest_agent_msi" = "yes"; then
5374 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
5376 guest_agent_msi=no
5377 elif ! has wixl; then
5378 if test "$guest_agent_msi" = "yes"; then
5379 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
5381 guest_agent_msi=no
5382 else
5383 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
5384 # disabled explicitly
5385 if test "$guest_agent_msi" != "no"; then
5386 guest_agent_msi=yes
5390 if test "$guest_agent_msi" = "yes"; then
5391 if test "$guest_agent_with_vss" = "yes"; then
5392 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
5395 if test "$QEMU_GA_MANUFACTURER" = ""; then
5396 QEMU_GA_MANUFACTURER=QEMU
5399 if test "$QEMU_GA_DISTRO" = ""; then
5400 QEMU_GA_DISTRO=Linux
5403 if test "$QEMU_GA_VERSION" = ""; then
5404 QEMU_GA_VERSION=$(cat $source_path/VERSION)
5407 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
5409 case "$cpu" in
5410 x86_64)
5411 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5413 i386)
5414 QEMU_GA_MSI_ARCH="-D Arch=32"
5417 error_exit "CPU $cpu not supported for building installation package"
5419 esac
5422 # Mac OS X ships with a broken assembler
5423 roms=
5424 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5425 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5426 "$softmmu" = yes ; then
5427 # Different host OS linkers have different ideas about the name of the ELF
5428 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5429 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5430 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5431 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5432 ld_i386_emulation="$emu"
5433 roms="optionrom"
5434 break
5436 done
5438 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
5439 roms="$roms spapr-rtas"
5442 if test "$cpu" = "s390x" ; then
5443 roms="$roms s390-ccw"
5446 # Probe for the need for relocating the user-only binary.
5447 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5448 textseg_addr=
5449 case "$cpu" in
5450 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5451 # ??? Rationale for choosing this address
5452 textseg_addr=0x60000000
5454 mips)
5455 # A 256M aligned address, high in the address space, with enough
5456 # room for the code_gen_buffer above it before the stack.
5457 textseg_addr=0x60000000
5459 esac
5460 if [ -n "$textseg_addr" ]; then
5461 cat > $TMPC <<EOF
5462 int main(void) { return 0; }
5464 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5465 if ! compile_prog "" "$textseg_ldflags"; then
5466 # In case ld does not support -Ttext-segment, edit the default linker
5467 # script via sed to set the .text start addr. This is needed on FreeBSD
5468 # at least.
5469 if ! $ld --verbose >/dev/null 2>&1; then
5470 error_exit \
5471 "We need to link the QEMU user mode binaries at a" \
5472 "specific text address. Unfortunately your linker" \
5473 "doesn't support either the -Ttext-segment option or" \
5474 "printing the default linker script with --verbose." \
5475 "If you don't want the user mode binaries, pass the" \
5476 "--disable-user option to configure."
5479 $ld --verbose | sed \
5480 -e '1,/==================================================/d' \
5481 -e '/==================================================/,$d' \
5482 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5483 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5484 textseg_ldflags="-Wl,-T../config-host.ld"
5489 # Check that the C++ compiler exists and works with the C compiler.
5490 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
5491 if has $cxx; then
5492 cat > $TMPC <<EOF
5493 int c_function(void);
5494 int main(void) { return c_function(); }
5497 compile_object
5499 cat > $TMPCXX <<EOF
5500 extern "C" {
5501 int c_function(void);
5503 int c_function(void) { return 42; }
5506 update_cxxflags
5508 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
5509 # C++ compiler $cxx works ok with C compiler $cc
5511 else
5512 echo "C++ compiler $cxx does not work with C compiler $cc"
5513 echo "Disabling C++ specific optional code"
5514 cxx=
5516 else
5517 echo "No C++ compiler available; disabling C++ specific optional code"
5518 cxx=
5521 echo_version() {
5522 if test "$1" = "yes" ; then
5523 echo "($2)"
5527 # prepend pixman and ftd flags after all config tests are done
5528 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5529 libs_softmmu="$pixman_libs $libs_softmmu"
5531 echo "Install prefix $prefix"
5532 echo "BIOS directory $(eval echo $qemu_datadir)"
5533 echo "firmware path $(eval echo $firmwarepath)"
5534 echo "binary directory $(eval echo $bindir)"
5535 echo "library directory $(eval echo $libdir)"
5536 echo "module directory $(eval echo $qemu_moddir)"
5537 echo "libexec directory $(eval echo $libexecdir)"
5538 echo "include directory $(eval echo $includedir)"
5539 echo "config directory $(eval echo $sysconfdir)"
5540 if test "$mingw32" = "no" ; then
5541 echo "local state directory $(eval echo $local_statedir)"
5542 echo "Manual directory $(eval echo $mandir)"
5543 echo "ELF interp prefix $interp_prefix"
5544 else
5545 echo "local state directory queried at runtime"
5546 echo "Windows SDK $win_sdk"
5548 echo "Source path $source_path"
5549 echo "GIT binary $git"
5550 echo "GIT submodules $git_submodules"
5551 echo "C compiler $cc"
5552 echo "Host C compiler $host_cc"
5553 echo "C++ compiler $cxx"
5554 echo "Objective-C compiler $objcc"
5555 echo "ARFLAGS $ARFLAGS"
5556 echo "CFLAGS $CFLAGS"
5557 echo "QEMU_CFLAGS $QEMU_CFLAGS"
5558 echo "LDFLAGS $LDFLAGS"
5559 echo "make $make"
5560 echo "install $install"
5561 echo "python $python"
5562 if test "$slirp" = "yes" ; then
5563 echo "smbd $smbd"
5565 echo "module support $modules"
5566 echo "host CPU $cpu"
5567 echo "host big endian $bigendian"
5568 echo "target list $target_list"
5569 echo "gprof enabled $gprof"
5570 echo "sparse enabled $sparse"
5571 echo "strip binaries $strip_opt"
5572 echo "profiler $profiler"
5573 echo "static build $static"
5574 if test "$darwin" = "yes" ; then
5575 echo "Cocoa support $cocoa"
5577 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5578 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
5579 echo "GTK GL support $gtk_gl"
5580 echo "VTE support $vte $(echo_version $vte $vteversion)"
5581 echo "TLS priority $tls_priority"
5582 echo "GNUTLS support $gnutls"
5583 echo "GNUTLS rnd $gnutls_rnd"
5584 if test "$gcrypt" = "yes"; then
5585 echo "encryption libgcrypt"
5586 echo "libgcrypt kdf $gcrypt_kdf"
5587 elif test "$nettle" = "yes"; then
5588 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
5589 else
5590 echo "encryption none"
5592 echo "nettle kdf $nettle_kdf"
5593 echo "libtasn1 $tasn1"
5594 echo "curses support $curses"
5595 echo "virgl support $virglrenderer"
5596 echo "curl support $curl"
5597 echo "mingw32 support $mingw32"
5598 echo "Audio drivers $audio_drv_list"
5599 echo "Block whitelist (rw) $block_drv_rw_whitelist"
5600 echo "Block whitelist (ro) $block_drv_ro_whitelist"
5601 echo "VirtFS support $virtfs"
5602 echo "Multipath support $mpath"
5603 echo "VNC support $vnc"
5604 if test "$vnc" = "yes" ; then
5605 echo "VNC SASL support $vnc_sasl"
5606 echo "VNC JPEG support $vnc_jpeg"
5607 echo "VNC PNG support $vnc_png"
5609 if test -n "$sparc_cpu"; then
5610 echo "Target Sparc Arch $sparc_cpu"
5612 echo "xen support $xen"
5613 if test "$xen" = "yes" ; then
5614 echo "xen ctrl version $xen_ctrl_version"
5615 echo "pv dom build $xen_pv_domain_build"
5617 echo "brlapi support $brlapi"
5618 echo "bluez support $bluez"
5619 echo "Documentation $docs"
5620 echo "Tools $tools"
5621 echo "PIE $pie"
5622 echo "vde support $vde"
5623 echo "netmap support $netmap"
5624 echo "Linux AIO support $linux_aio"
5625 echo "(X)ATTR support $attr"
5626 echo "Install blobs $blobs"
5627 echo "KVM support $kvm"
5628 echo "HAX support $hax"
5629 echo "HVF support $hvf"
5630 echo "TCG support $tcg"
5631 if test "$tcg" = "yes" ; then
5632 echo "TCG debug enabled $debug_tcg"
5633 echo "TCG interpreter $tcg_interpreter"
5635 echo "malloc trim support $malloc_trim"
5636 echo "RDMA support $rdma"
5637 echo "fdt support $fdt"
5638 echo "preadv support $preadv"
5639 echo "fdatasync $fdatasync"
5640 echo "madvise $madvise"
5641 echo "posix_madvise $posix_madvise"
5642 echo "libcap-ng support $cap_ng"
5643 echo "vhost-net support $vhost_net"
5644 echo "vhost-scsi support $vhost_scsi"
5645 echo "vhost-vsock support $vhost_vsock"
5646 echo "vhost-user support $vhost_user"
5647 echo "Trace backends $trace_backends"
5648 if have_backend "simple"; then
5649 echo "Trace output file $trace_file-<pid>"
5651 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5652 echo "rbd support $rbd"
5653 echo "xfsctl support $xfs"
5654 echo "smartcard support $smartcard"
5655 echo "libusb $libusb"
5656 echo "usb net redir $usb_redir"
5657 echo "OpenGL support $opengl"
5658 echo "OpenGL dmabufs $opengl_dmabuf"
5659 echo "libiscsi support $libiscsi"
5660 echo "libnfs support $libnfs"
5661 echo "build guest agent $guest_agent"
5662 echo "QGA VSS support $guest_agent_with_vss"
5663 echo "QGA w32 disk info $guest_agent_ntddscsi"
5664 echo "QGA MSI support $guest_agent_msi"
5665 echo "seccomp support $seccomp"
5666 echo "coroutine backend $coroutine"
5667 echo "coroutine pool $coroutine_pool"
5668 echo "debug stack usage $debug_stack_usage"
5669 echo "crypto afalg $crypto_afalg"
5670 echo "GlusterFS support $glusterfs"
5671 echo "gcov $gcov_tool"
5672 echo "gcov enabled $gcov"
5673 echo "TPM support $tpm"
5674 echo "libssh2 support $libssh2"
5675 echo "TPM passthrough $tpm_passthrough"
5676 echo "TPM emulator $tpm_emulator"
5677 echo "QOM debugging $qom_cast_debug"
5678 echo "Live block migration $live_block_migration"
5679 echo "lzo support $lzo"
5680 echo "snappy support $snappy"
5681 echo "bzip2 support $bzip2"
5682 echo "NUMA host support $numa"
5683 echo "tcmalloc support $tcmalloc"
5684 echo "jemalloc support $jemalloc"
5685 echo "avx2 optimization $avx2_opt"
5686 echo "replication support $replication"
5687 echo "VxHS block device $vxhs"
5688 echo "capstone $capstone"
5690 if test "$sdl_too_old" = "yes"; then
5691 echo "-> Your SDL version is too old - please upgrade to have SDL support"
5694 if test "$supported_cpu" = "no"; then
5695 echo
5696 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5697 echo
5698 echo "CPU host architecture $cpu support is not currently maintained."
5699 echo "The QEMU project intends to remove support for this host CPU in"
5700 echo "a future release if nobody volunteers to maintain it and to"
5701 echo "provide a build host for our continuous integration setup."
5702 echo "configure has succeeded and you can continue to build, but"
5703 echo "if you care about QEMU on this platform you should contact"
5704 echo "us upstream at qemu-devel@nongnu.org."
5707 if test "$supported_os" = "no"; then
5708 echo
5709 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5710 echo
5711 echo "Host OS $targetos support is not currently maintained."
5712 echo "The QEMU project intends to remove support for this host OS in"
5713 echo "a future release if nobody volunteers to maintain it and to"
5714 echo "provide a build host for our continuous integration setup."
5715 echo "configure has succeeded and you can continue to build, but"
5716 echo "if you care about QEMU on this platform you should contact"
5717 echo "us upstream at qemu-devel@nongnu.org."
5720 config_host_mak="config-host.mak"
5722 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
5724 echo "# Automatically generated by configure - do not modify" > $config_host_mak
5725 echo >> $config_host_mak
5727 echo all: >> $config_host_mak
5728 echo "prefix=$prefix" >> $config_host_mak
5729 echo "bindir=$bindir" >> $config_host_mak
5730 echo "libdir=$libdir" >> $config_host_mak
5731 echo "libexecdir=$libexecdir" >> $config_host_mak
5732 echo "includedir=$includedir" >> $config_host_mak
5733 echo "mandir=$mandir" >> $config_host_mak
5734 echo "sysconfdir=$sysconfdir" >> $config_host_mak
5735 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
5736 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
5737 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
5738 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
5739 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5740 if test "$mingw32" = "no" ; then
5741 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
5743 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
5744 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
5745 echo "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5746 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5747 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
5748 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
5749 echo "GIT=$git" >> $config_host_mak
5750 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5751 echo "GIT_UPDATE=$git_update" >> $config_host_mak
5753 echo "ARCH=$ARCH" >> $config_host_mak
5755 if test "$debug_tcg" = "yes" ; then
5756 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5758 if test "$strip_opt" = "yes" ; then
5759 echo "STRIP=${strip}" >> $config_host_mak
5761 if test "$bigendian" = "yes" ; then
5762 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
5764 if test "$mingw32" = "yes" ; then
5765 echo "CONFIG_WIN32=y" >> $config_host_mak
5766 echo "CONFIG_INSTALLER=y" >> $config_host_mak
5767 rc_version=$(cat $source_path/VERSION)
5768 version_major=${rc_version%%.*}
5769 rc_version=${rc_version#*.}
5770 version_minor=${rc_version%%.*}
5771 rc_version=${rc_version#*.}
5772 version_subminor=${rc_version%%.*}
5773 version_micro=0
5774 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5775 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5776 if test "$guest_agent_with_vss" = "yes" ; then
5777 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5778 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5779 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5781 if test "$guest_agent_ntddscsi" = "yes" ; then
5782 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
5784 if test "$guest_agent_msi" = "yes"; then
5785 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
5786 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
5787 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
5788 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
5789 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
5790 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
5791 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5793 else
5794 echo "CONFIG_POSIX=y" >> $config_host_mak
5797 if test "$linux" = "yes" ; then
5798 echo "CONFIG_LINUX=y" >> $config_host_mak
5801 if test "$darwin" = "yes" ; then
5802 echo "CONFIG_DARWIN=y" >> $config_host_mak
5805 if test "$solaris" = "yes" ; then
5806 echo "CONFIG_SOLARIS=y" >> $config_host_mak
5808 if test "$haiku" = "yes" ; then
5809 echo "CONFIG_HAIKU=y" >> $config_host_mak
5811 if test "$static" = "yes" ; then
5812 echo "CONFIG_STATIC=y" >> $config_host_mak
5814 if test "$profiler" = "yes" ; then
5815 echo "CONFIG_PROFILER=y" >> $config_host_mak
5817 if test "$slirp" = "yes" ; then
5818 echo "CONFIG_SLIRP=y" >> $config_host_mak
5819 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5821 if test "$vde" = "yes" ; then
5822 echo "CONFIG_VDE=y" >> $config_host_mak
5823 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
5825 if test "$netmap" = "yes" ; then
5826 echo "CONFIG_NETMAP=y" >> $config_host_mak
5828 if test "$l2tpv3" = "yes" ; then
5829 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5831 if test "$cap_ng" = "yes" ; then
5832 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5834 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
5835 for drv in $audio_drv_list; do
5836 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5837 echo "$def=y" >> $config_host_mak
5838 done
5839 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5840 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5841 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5842 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5843 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
5844 if test "$audio_pt_int" = "yes" ; then
5845 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5847 if test "$audio_win_int" = "yes" ; then
5848 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5850 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5851 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5852 if test "$vnc" = "yes" ; then
5853 echo "CONFIG_VNC=y" >> $config_host_mak
5855 if test "$vnc_sasl" = "yes" ; then
5856 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
5858 if test "$vnc_jpeg" = "yes" ; then
5859 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
5861 if test "$vnc_png" = "yes" ; then
5862 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5864 if test "$xkbcommon" = "yes" ; then
5865 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
5866 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
5868 if test "$fnmatch" = "yes" ; then
5869 echo "CONFIG_FNMATCH=y" >> $config_host_mak
5871 if test "$xfs" = "yes" ; then
5872 echo "CONFIG_XFS=y" >> $config_host_mak
5874 qemu_version=$(head $source_path/VERSION)
5875 echo "VERSION=$qemu_version" >>$config_host_mak
5876 echo "PKGVERSION=$pkgversion" >>$config_host_mak
5877 echo "SRC_PATH=$source_path" >> $config_host_mak
5878 echo "TARGET_DIRS=$target_list" >> $config_host_mak
5879 if [ "$docs" = "yes" ] ; then
5880 echo "BUILD_DOCS=yes" >> $config_host_mak
5882 if [ "$want_tools" = "yes" ] ; then
5883 echo "BUILD_TOOLS=yes" >> $config_host_mak
5885 if test "$modules" = "yes"; then
5886 # $shacmd can generate a hash started with digit, which the compiler doesn't
5887 # like as an symbol. So prefix it with an underscore
5888 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
5889 echo "CONFIG_MODULES=y" >> $config_host_mak
5891 if test "$sdl" = "yes" ; then
5892 echo "CONFIG_SDL=y" >> $config_host_mak
5893 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
5894 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
5895 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
5897 if test "$cocoa" = "yes" ; then
5898 echo "CONFIG_COCOA=y" >> $config_host_mak
5900 if test "$curses" = "yes" ; then
5901 echo "CONFIG_CURSES=y" >> $config_host_mak
5903 if test "$pipe2" = "yes" ; then
5904 echo "CONFIG_PIPE2=y" >> $config_host_mak
5906 if test "$accept4" = "yes" ; then
5907 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5909 if test "$splice" = "yes" ; then
5910 echo "CONFIG_SPLICE=y" >> $config_host_mak
5912 if test "$eventfd" = "yes" ; then
5913 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5915 if test "$memfd" = "yes" ; then
5916 echo "CONFIG_MEMFD=y" >> $config_host_mak
5918 if test "$fallocate" = "yes" ; then
5919 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5921 if test "$fallocate_punch_hole" = "yes" ; then
5922 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5924 if test "$fallocate_zero_range" = "yes" ; then
5925 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5927 if test "$posix_fallocate" = "yes" ; then
5928 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5930 if test "$sync_file_range" = "yes" ; then
5931 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5933 if test "$fiemap" = "yes" ; then
5934 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5936 if test "$dup3" = "yes" ; then
5937 echo "CONFIG_DUP3=y" >> $config_host_mak
5939 if test "$ppoll" = "yes" ; then
5940 echo "CONFIG_PPOLL=y" >> $config_host_mak
5942 if test "$prctl_pr_set_timerslack" = "yes" ; then
5943 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5945 if test "$epoll" = "yes" ; then
5946 echo "CONFIG_EPOLL=y" >> $config_host_mak
5948 if test "$epoll_create1" = "yes" ; then
5949 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5951 if test "$sendfile" = "yes" ; then
5952 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5954 if test "$timerfd" = "yes" ; then
5955 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5957 if test "$setns" = "yes" ; then
5958 echo "CONFIG_SETNS=y" >> $config_host_mak
5960 if test "$clock_adjtime" = "yes" ; then
5961 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
5963 if test "$syncfs" = "yes" ; then
5964 echo "CONFIG_SYNCFS=y" >> $config_host_mak
5966 if test "$inotify" = "yes" ; then
5967 echo "CONFIG_INOTIFY=y" >> $config_host_mak
5969 if test "$inotify1" = "yes" ; then
5970 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5972 if test "$sem_timedwait" = "yes" ; then
5973 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5975 if test "$byteswap_h" = "yes" ; then
5976 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5978 if test "$bswap_h" = "yes" ; then
5979 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5981 if test "$curl" = "yes" ; then
5982 echo "CONFIG_CURL=m" >> $config_host_mak
5983 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
5984 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5986 if test "$brlapi" = "yes" ; then
5987 echo "CONFIG_BRLAPI=y" >> $config_host_mak
5988 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
5990 if test "$bluez" = "yes" ; then
5991 echo "CONFIG_BLUEZ=y" >> $config_host_mak
5992 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5994 if test "$glib_subprocess" = "yes" ; then
5995 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5997 if test "$gtk" = "yes" ; then
5998 echo "CONFIG_GTK=y" >> $config_host_mak
5999 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
6000 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6001 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6002 if test "$gtk_gl" = "yes" ; then
6003 echo "CONFIG_GTK_GL=y" >> $config_host_mak
6006 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6007 if test "$gnutls" = "yes" ; then
6008 echo "CONFIG_GNUTLS=y" >> $config_host_mak
6010 if test "$gnutls_rnd" = "yes" ; then
6011 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
6013 if test "$gcrypt" = "yes" ; then
6014 echo "CONFIG_GCRYPT=y" >> $config_host_mak
6015 if test "$gcrypt_hmac" = "yes" ; then
6016 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
6018 if test "$gcrypt_kdf" = "yes" ; then
6019 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
6022 if test "$nettle" = "yes" ; then
6023 echo "CONFIG_NETTLE=y" >> $config_host_mak
6024 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6025 if test "$nettle_kdf" = "yes" ; then
6026 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
6029 if test "$tasn1" = "yes" ; then
6030 echo "CONFIG_TASN1=y" >> $config_host_mak
6032 if test "$have_ifaddrs_h" = "yes" ; then
6033 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6035 if test "$have_broken_size_max" = "yes" ; then
6036 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
6039 # Work around a system header bug with some kernel/XFS header
6040 # versions where they both try to define 'struct fsxattr':
6041 # xfs headers will not try to redefine structs from linux headers
6042 # if this macro is set.
6043 if test "$have_fsxattr" = "yes" ; then
6044 echo "HAVE_FSXATTR=y" >> $config_host_mak
6046 if test "$vte" = "yes" ; then
6047 echo "CONFIG_VTE=y" >> $config_host_mak
6048 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6050 if test "$virglrenderer" = "yes" ; then
6051 echo "CONFIG_VIRGL=y" >> $config_host_mak
6052 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
6053 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
6055 if test "$xen" = "yes" ; then
6056 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6057 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6058 if test "$xen_pv_domain_build" = "yes" ; then
6059 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
6062 if test "$linux_aio" = "yes" ; then
6063 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
6065 if test "$attr" = "yes" ; then
6066 echo "CONFIG_ATTR=y" >> $config_host_mak
6068 if test "$libattr" = "yes" ; then
6069 echo "CONFIG_LIBATTR=y" >> $config_host_mak
6071 if test "$virtfs" = "yes" ; then
6072 echo "CONFIG_VIRTFS=y" >> $config_host_mak
6074 if test "$mpath" = "yes" ; then
6075 echo "CONFIG_MPATH=y" >> $config_host_mak
6077 if test "$vhost_scsi" = "yes" ; then
6078 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
6080 if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
6081 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
6083 if test "$vhost_vsock" = "yes" ; then
6084 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6086 if test "$vhost_user" = "yes" ; then
6087 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6089 if test "$blobs" = "yes" ; then
6090 echo "INSTALL_BLOBS=yes" >> $config_host_mak
6092 if test "$iovec" = "yes" ; then
6093 echo "CONFIG_IOVEC=y" >> $config_host_mak
6095 if test "$preadv" = "yes" ; then
6096 echo "CONFIG_PREADV=y" >> $config_host_mak
6098 if test "$fdt" = "yes" ; then
6099 echo "CONFIG_FDT=y" >> $config_host_mak
6101 if test "$signalfd" = "yes" ; then
6102 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6104 if test "$tcg" = "yes"; then
6105 echo "CONFIG_TCG=y" >> $config_host_mak
6106 if test "$tcg_interpreter" = "yes" ; then
6107 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
6110 if test "$fdatasync" = "yes" ; then
6111 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
6113 if test "$madvise" = "yes" ; then
6114 echo "CONFIG_MADVISE=y" >> $config_host_mak
6116 if test "$posix_madvise" = "yes" ; then
6117 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6120 if test "$spice" = "yes" ; then
6121 echo "CONFIG_SPICE=y" >> $config_host_mak
6124 if test "$smartcard" = "yes" ; then
6125 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
6126 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
6127 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6130 if test "$libusb" = "yes" ; then
6131 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6132 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6133 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
6136 if test "$usb_redir" = "yes" ; then
6137 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6138 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6139 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
6142 if test "$opengl" = "yes" ; then
6143 echo "CONFIG_OPENGL=y" >> $config_host_mak
6144 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6145 if test "$opengl_dmabuf" = "yes" ; then
6146 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6150 if test "$malloc_trim" = "yes" ; then
6151 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
6154 if test "$avx2_opt" = "yes" ; then
6155 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
6158 if test "$lzo" = "yes" ; then
6159 echo "CONFIG_LZO=y" >> $config_host_mak
6162 if test "$snappy" = "yes" ; then
6163 echo "CONFIG_SNAPPY=y" >> $config_host_mak
6166 if test "$bzip2" = "yes" ; then
6167 echo "CONFIG_BZIP2=y" >> $config_host_mak
6168 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
6171 if test "$libiscsi" = "yes" ; then
6172 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6173 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
6174 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6177 if test "$libnfs" = "yes" ; then
6178 echo "CONFIG_LIBNFS=m" >> $config_host_mak
6179 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6182 if test "$seccomp" = "yes"; then
6183 echo "CONFIG_SECCOMP=y" >> $config_host_mak
6184 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6185 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6188 # XXX: suppress that
6189 if [ "$bsd" = "yes" ] ; then
6190 echo "CONFIG_BSD=y" >> $config_host_mak
6193 if test "$localtime_r" = "yes" ; then
6194 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
6196 if test "$qom_cast_debug" = "yes" ; then
6197 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
6199 if test "$rbd" = "yes" ; then
6200 echo "CONFIG_RBD=m" >> $config_host_mak
6201 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
6202 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6205 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
6206 if test "$coroutine_pool" = "yes" ; then
6207 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
6208 else
6209 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
6212 if test "$debug_stack_usage" = "yes" ; then
6213 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
6216 if test "$crypto_afalg" = "yes" ; then
6217 echo "CONFIG_AF_ALG=y" >> $config_host_mak
6220 if test "$open_by_handle_at" = "yes" ; then
6221 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6224 if test "$linux_magic_h" = "yes" ; then
6225 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6228 if test "$pragma_diagnostic_available" = "yes" ; then
6229 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
6232 if test "$valgrind_h" = "yes" ; then
6233 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
6236 if test "$has_environ" = "yes" ; then
6237 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
6240 if test "$cpuid_h" = "yes" ; then
6241 echo "CONFIG_CPUID_H=y" >> $config_host_mak
6244 if test "$int128" = "yes" ; then
6245 echo "CONFIG_INT128=y" >> $config_host_mak
6248 if test "$atomic128" = "yes" ; then
6249 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
6252 if test "$atomic64" = "yes" ; then
6253 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6256 if test "$getauxval" = "yes" ; then
6257 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
6260 if test "$glusterfs" = "yes" ; then
6261 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6262 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
6263 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6266 if test "$glusterfs_xlator_opt" = "yes" ; then
6267 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6270 if test "$glusterfs_discard" = "yes" ; then
6271 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
6274 if test "$glusterfs_fallocate" = "yes" ; then
6275 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6278 if test "$glusterfs_zerofill" = "yes" ; then
6279 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
6282 if test "$libssh2" = "yes" ; then
6283 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6284 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
6285 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
6288 if test "$live_block_migration" = "yes" ; then
6289 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6292 if test "$tpm" = "yes"; then
6293 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6294 # TPM passthrough support?
6295 if test "$tpm_passthrough" = "yes"; then
6296 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
6298 # TPM emulator support?
6299 if test "$tpm_emulator" = "yes"; then
6300 echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6304 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
6305 if have_backend "nop"; then
6306 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
6308 if have_backend "simple"; then
6309 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
6310 # Set the appropriate trace file.
6311 trace_file="\"$trace_file-\" FMT_pid"
6313 if have_backend "log"; then
6314 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6316 if have_backend "ust"; then
6317 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6319 if have_backend "dtrace"; then
6320 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
6321 if test "$trace_backend_stap" = "yes" ; then
6322 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
6325 if have_backend "ftrace"; then
6326 if test "$linux" = "yes" ; then
6327 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6328 else
6329 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6332 if have_backend "syslog"; then
6333 if test "$posix_syslog" = "yes" ; then
6334 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
6335 else
6336 feature_not_found "syslog(trace backend)" "syslog not available"
6339 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
6341 if test "$rdma" = "yes" ; then
6342 echo "CONFIG_RDMA=y" >> $config_host_mak
6343 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
6346 if test "$have_rtnetlink" = "yes" ; then
6347 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6350 if test "$replication" = "yes" ; then
6351 echo "CONFIG_REPLICATION=y" >> $config_host_mak
6354 if test "$have_af_vsock" = "yes" ; then
6355 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
6358 if test "$have_sysmacros" = "yes" ; then
6359 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
6362 if test "$have_static_assert" = "yes" ; then
6363 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
6366 if test "$have_utmpx" = "yes" ; then
6367 echo "HAVE_UTMPX=y" >> $config_host_mak
6370 if test "$ivshmem" = "yes" ; then
6371 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6373 if test "$capstone" != "no" ; then
6374 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
6377 # Hold two types of flag:
6378 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
6379 # a thread we have a handle to
6380 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
6381 # platform
6382 if test "$pthread_setname_np" = "yes" ; then
6383 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6384 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
6387 if test "$vxhs" = "yes" ; then
6388 echo "CONFIG_VXHS=y" >> $config_host_mak
6389 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6392 if test "$tcg_interpreter" = "yes"; then
6393 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
6394 elif test "$ARCH" = "sparc64" ; then
6395 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
6396 elif test "$ARCH" = "s390x" ; then
6397 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6398 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
6399 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
6400 elif test "$ARCH" = "ppc64" ; then
6401 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
6402 else
6403 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
6405 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
6407 echo "TOOLS=$tools" >> $config_host_mak
6408 echo "ROMS=$roms" >> $config_host_mak
6409 echo "MAKE=$make" >> $config_host_mak
6410 echo "INSTALL=$install" >> $config_host_mak
6411 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
6412 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
6413 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
6414 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6415 echo "PYTHON=$python" >> $config_host_mak
6416 echo "CC=$cc" >> $config_host_mak
6417 if $iasl -h > /dev/null 2>&1; then
6418 echo "IASL=$iasl" >> $config_host_mak
6420 echo "CC_I386=$cc_i386" >> $config_host_mak
6421 echo "HOST_CC=$host_cc" >> $config_host_mak
6422 echo "CXX=$cxx" >> $config_host_mak
6423 echo "OBJCC=$objcc" >> $config_host_mak
6424 echo "AR=$ar" >> $config_host_mak
6425 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
6426 echo "AS=$as" >> $config_host_mak
6427 echo "CCAS=$ccas" >> $config_host_mak
6428 echo "CPP=$cpp" >> $config_host_mak
6429 echo "OBJCOPY=$objcopy" >> $config_host_mak
6430 echo "LD=$ld" >> $config_host_mak
6431 echo "RANLIB=$ranlib" >> $config_host_mak
6432 echo "NM=$nm" >> $config_host_mak
6433 echo "WINDRES=$windres" >> $config_host_mak
6434 echo "CFLAGS=$CFLAGS" >> $config_host_mak
6435 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6436 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
6437 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6438 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6439 if test "$sparse" = "yes" ; then
6440 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
6441 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
6442 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
6443 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
6444 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6446 if test "$cross_prefix" != ""; then
6447 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
6448 else
6449 echo "AUTOCONF_HOST := " >> $config_host_mak
6451 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
6452 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
6453 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6454 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
6455 echo "LIBS+=$LIBS" >> $config_host_mak
6456 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6457 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6458 echo "EXESUF=$EXESUF" >> $config_host_mak
6459 echo "DSOSUF=$DSOSUF" >> $config_host_mak
6460 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6461 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
6462 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
6463 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
6464 echo "POD2MAN=$POD2MAN" >> $config_host_mak
6465 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
6466 if test "$gcov" = "yes" ; then
6467 echo "CONFIG_GCOV=y" >> $config_host_mak
6468 echo "GCOV=$gcov_tool" >> $config_host_mak
6471 # use included Linux headers
6472 if test "$linux" = "yes" ; then
6473 mkdir -p linux-headers
6474 case "$cpu" in
6475 i386|x86_64|x32)
6476 linux_arch=x86
6478 ppcemb|ppc|ppc64)
6479 linux_arch=powerpc
6481 s390x)
6482 linux_arch=s390
6484 aarch64)
6485 linux_arch=arm64
6487 mips64)
6488 linux_arch=mips
6491 # For most CPUs the kernel architecture name and QEMU CPU name match.
6492 linux_arch="$cpu"
6494 esac
6495 # For non-KVM architectures we will not have asm headers
6496 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
6497 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
6501 for target in $target_list; do
6502 target_dir="$target"
6503 config_target_mak=$target_dir/config-target.mak
6504 target_name=$(echo $target | cut -d '-' -f 1)
6505 target_bigendian="no"
6507 case "$target_name" in
6508 armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6509 target_bigendian=yes
6511 esac
6512 target_softmmu="no"
6513 target_user_only="no"
6514 target_linux_user="no"
6515 target_bsd_user="no"
6516 case "$target" in
6517 ${target_name}-softmmu)
6518 target_softmmu="yes"
6520 ${target_name}-linux-user)
6521 target_user_only="yes"
6522 target_linux_user="yes"
6524 ${target_name}-bsd-user)
6525 target_user_only="yes"
6526 target_bsd_user="yes"
6529 error_exit "Target '$target' not recognised"
6530 exit 1
6532 esac
6534 mkdir -p $target_dir
6535 echo "# Automatically generated by configure - do not modify" > $config_target_mak
6537 bflt="no"
6538 mttcg="no"
6539 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
6540 gdb_xml_files=""
6542 TARGET_ARCH="$target_name"
6543 TARGET_BASE_ARCH=""
6544 TARGET_ABI_DIR=""
6546 case "$target_name" in
6547 i386)
6548 gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
6550 x86_64)
6551 TARGET_BASE_ARCH=i386
6552 gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
6554 alpha)
6555 mttcg="yes"
6557 arm|armeb)
6558 TARGET_ARCH=arm
6559 bflt="yes"
6560 mttcg="yes"
6561 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6563 aarch64|aarch64_be)
6564 TARGET_ARCH=aarch64
6565 TARGET_BASE_ARCH=arm
6566 bflt="yes"
6567 mttcg="yes"
6568 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6570 cris)
6572 hppa)
6574 lm32)
6576 m68k)
6577 bflt="yes"
6578 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
6580 microblaze|microblazeel)
6581 TARGET_ARCH=microblaze
6582 bflt="yes"
6584 mips|mipsel)
6585 TARGET_ARCH=mips
6586 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
6588 mipsn32|mipsn32el)
6589 TARGET_ARCH=mips64
6590 TARGET_BASE_ARCH=mips
6591 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6592 echo "TARGET_ABI32=y" >> $config_target_mak
6594 mips64|mips64el)
6595 TARGET_ARCH=mips64
6596 TARGET_BASE_ARCH=mips
6597 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
6599 moxie)
6601 nios2)
6603 or1k)
6604 TARGET_ARCH=openrisc
6605 TARGET_BASE_ARCH=openrisc
6607 ppc)
6608 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6610 ppcemb)
6611 TARGET_BASE_ARCH=ppc
6612 TARGET_ABI_DIR=ppc
6613 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6615 ppc64)
6616 TARGET_BASE_ARCH=ppc
6617 TARGET_ABI_DIR=ppc
6618 mttcg=yes
6619 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6621 ppc64le)
6622 TARGET_ARCH=ppc64
6623 TARGET_BASE_ARCH=ppc
6624 TARGET_ABI_DIR=ppc
6625 mttcg=yes
6626 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6628 ppc64abi32)
6629 TARGET_ARCH=ppc64
6630 TARGET_BASE_ARCH=ppc
6631 TARGET_ABI_DIR=ppc
6632 echo "TARGET_ABI32=y" >> $config_target_mak
6633 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6635 sh4|sh4eb)
6636 TARGET_ARCH=sh4
6637 bflt="yes"
6639 sparc)
6641 sparc64)
6642 TARGET_BASE_ARCH=sparc
6644 sparc32plus)
6645 TARGET_ARCH=sparc64
6646 TARGET_BASE_ARCH=sparc
6647 TARGET_ABI_DIR=sparc
6648 echo "TARGET_ABI32=y" >> $config_target_mak
6650 s390x)
6651 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
6653 tilegx)
6655 tricore)
6657 unicore32)
6659 xtensa|xtensaeb)
6660 TARGET_ARCH=xtensa
6663 error_exit "Unsupported target CPU"
6665 esac
6666 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6667 if [ "$TARGET_BASE_ARCH" = "" ]; then
6668 TARGET_BASE_ARCH=$TARGET_ARCH
6671 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
6673 upper() {
6674 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
6677 target_arch_name="$(upper $TARGET_ARCH)"
6678 echo "TARGET_$target_arch_name=y" >> $config_target_mak
6679 echo "TARGET_NAME=$target_name" >> $config_target_mak
6680 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6681 if [ "$TARGET_ABI_DIR" = "" ]; then
6682 TARGET_ABI_DIR=$TARGET_ARCH
6684 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6685 if [ "$HOST_VARIANT_DIR" != "" ]; then
6686 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6689 if supported_xen_target $target; then
6690 echo "CONFIG_XEN=y" >> $config_target_mak
6691 if test "$xen_pci_passthrough" = yes; then
6692 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6695 if supported_kvm_target $target; then
6696 echo "CONFIG_KVM=y" >> $config_target_mak
6697 if test "$vhost_net" = "yes" ; then
6698 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6699 if test "$vhost_user" = "yes" ; then
6700 echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6704 if supported_hax_target $target; then
6705 echo "CONFIG_HAX=y" >> $config_target_mak
6707 if supported_hvf_target $target; then
6708 echo "CONFIG_HVF=y" >> $config_target_mak
6710 if test "$target_bigendian" = "yes" ; then
6711 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
6713 if test "$target_softmmu" = "yes" ; then
6714 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6715 if test "$mttcg" = "yes" ; then
6716 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6719 if test "$target_user_only" = "yes" ; then
6720 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6721 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6723 if test "$target_linux_user" = "yes" ; then
6724 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6726 list=""
6727 if test ! -z "$gdb_xml_files" ; then
6728 for x in $gdb_xml_files; do
6729 list="$list $source_path/gdb-xml/$x"
6730 done
6731 echo "TARGET_XML_FILES=$list" >> $config_target_mak
6734 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
6735 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6737 if test "$target_bsd_user" = "yes" ; then
6738 echo "CONFIG_BSD_USER=y" >> $config_target_mak
6741 # generate QEMU_CFLAGS/LDFLAGS for targets
6743 cflags=""
6744 ldflags=""
6746 disas_config() {
6747 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6748 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6751 for i in $ARCH $TARGET_BASE_ARCH ; do
6752 case "$i" in
6753 alpha)
6754 disas_config "ALPHA"
6756 aarch64)
6757 if test -n "${cxx}"; then
6758 disas_config "ARM_A64"
6761 arm)
6762 disas_config "ARM"
6763 if test -n "${cxx}"; then
6764 disas_config "ARM_A64"
6767 cris)
6768 disas_config "CRIS"
6770 hppa)
6771 disas_config "HPPA"
6773 i386|x86_64|x32)
6774 disas_config "I386"
6776 lm32)
6777 disas_config "LM32"
6779 m68k)
6780 disas_config "M68K"
6782 microblaze*)
6783 disas_config "MICROBLAZE"
6785 mips*)
6786 disas_config "MIPS"
6788 moxie*)
6789 disas_config "MOXIE"
6791 nios2)
6792 disas_config "NIOS2"
6794 or1k)
6795 disas_config "OPENRISC"
6797 ppc*)
6798 disas_config "PPC"
6800 s390*)
6801 disas_config "S390"
6803 sh4)
6804 disas_config "SH4"
6806 sparc*)
6807 disas_config "SPARC"
6809 xtensa*)
6810 disas_config "XTENSA"
6812 esac
6813 done
6814 if test "$tcg_interpreter" = "yes" ; then
6815 disas_config "TCI"
6818 case "$ARCH" in
6819 alpha)
6820 # Ensure there's only a single GP
6821 cflags="-msmall-data $cflags"
6823 esac
6825 if test "$gprof" = "yes" ; then
6826 echo "TARGET_GPROF=yes" >> $config_target_mak
6827 if test "$target_linux_user" = "yes" ; then
6828 cflags="-p $cflags"
6829 ldflags="-p $ldflags"
6831 if test "$target_softmmu" = "yes" ; then
6832 ldflags="-p $ldflags"
6833 echo "GPROF_CFLAGS=-p" >> $config_target_mak
6837 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6838 ldflags="$ldflags $textseg_ldflags"
6841 # Newer kernels on s390 check for an S390_PGSTE program header and
6842 # enable the pgste page table extensions in that case. This makes
6843 # the vm.allocate_pgste sysctl unnecessary. We enable this program
6844 # header if
6845 # - we build on s390x
6846 # - we build the system emulation for s390x (qemu-system-s390x)
6847 # - KVM is enabled
6848 # - the linker supports --s390-pgste
6849 if test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes" -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6850 if ld_has --s390-pgste ; then
6851 ldflags="-Wl,--s390-pgste $ldflags"
6855 echo "LDFLAGS+=$ldflags" >> $config_target_mak
6856 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6858 done # for target in $targets
6860 if [ "$dtc_internal" = "yes" ]; then
6861 echo "config-host.h: subdir-dtc" >> $config_host_mak
6863 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
6864 echo "config-host.h: subdir-capstone" >> $config_host_mak
6866 if test -n "$LIBCAPSTONE"; then
6867 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
6870 if test "$numa" = "yes"; then
6871 echo "CONFIG_NUMA=y" >> $config_host_mak
6874 if test "$ccache_cpp2" = "yes"; then
6875 echo "export CCACHE_CPP2=y" >> $config_host_mak
6878 # build tree in object directory in case the source is not in the current directory
6879 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
6880 DIRS="$DIRS docs docs/interop fsdev scsi"
6881 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
6882 DIRS="$DIRS roms/seabios roms/vgabios"
6883 DIRS="$DIRS qapi-generated"
6884 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6885 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6886 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6887 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6888 FILES="$FILES pc-bios/spapr-rtas/Makefile"
6889 FILES="$FILES pc-bios/s390-ccw/Makefile"
6890 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
6891 FILES="$FILES pc-bios/qemu-icon.bmp"
6892 FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6893 for bios_file in \
6894 $source_path/pc-bios/*.bin \
6895 $source_path/pc-bios/*.lid \
6896 $source_path/pc-bios/*.aml \
6897 $source_path/pc-bios/*.rom \
6898 $source_path/pc-bios/*.dtb \
6899 $source_path/pc-bios/*.img \
6900 $source_path/pc-bios/openbios-* \
6901 $source_path/pc-bios/u-boot.* \
6902 $source_path/pc-bios/palcode-*
6904 FILES="$FILES pc-bios/$(basename $bios_file)"
6905 done
6906 for test_file in $(find $source_path/tests/acpi-test-data -type f)
6908 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6909 done
6910 mkdir -p $DIRS
6911 for f in $FILES ; do
6912 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6913 symlink "$source_path/$f" "$f"
6915 done
6917 # temporary config to build submodules
6918 for rom in seabios vgabios ; do
6919 config_mak=roms/$rom/config.mak
6920 echo "# Automatically generated by configure - do not modify" > $config_mak
6921 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6922 echo "AS=$as" >> $config_mak
6923 echo "CCAS=$ccas" >> $config_mak
6924 echo "CC=$cc" >> $config_mak
6925 echo "BCC=bcc" >> $config_mak
6926 echo "CPP=$cpp" >> $config_mak
6927 echo "OBJCOPY=objcopy" >> $config_mak
6928 echo "IASL=$iasl" >> $config_mak
6929 echo "LD=$ld" >> $config_mak
6930 echo "RANLIB=$ranlib" >> $config_mak
6931 done
6933 # set up tests data directory
6934 if [ ! -e tests/data ]; then
6935 symlink "$source_path/tests/data" tests/data
6938 # set up qemu-iotests in this build directory
6939 iotests_common_env="tests/qemu-iotests/common.env"
6940 iotests_check="tests/qemu-iotests/check"
6942 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
6943 echo >> "$iotests_common_env"
6944 echo "export PYTHON='$python'" >> "$iotests_common_env"
6946 if [ ! -e "$iotests_check" ]; then
6947 symlink "$source_path/$iotests_check" "$iotests_check"
6950 # Save the configure command line for later reuse.
6951 cat <<EOD >config.status
6952 #!/bin/sh
6953 # Generated by configure.
6954 # Run this file to recreate the current configuration.
6955 # Compiler output produced by configure, useful for debugging
6956 # configure, is in config.log if it exists.
6958 printf "exec" >>config.status
6959 printf " '%s'" "$0" "$@" >>config.status
6960 echo ' "$@"' >>config.status
6961 chmod +x config.status
6963 rm -r "$TMPDIR1"