Merge remote-tracking branch 'qemu/master'
[qemu/ar7.git] / configure
blob486387fa328e40af8612e646ddbe549e31c97c56
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_target() {
216 case "$1" in
217 *-softmmu)
219 *-linux-user)
220 if test "$linux" != "yes"; then
221 print_error "Target '$target' is only available on a Linux host"
222 return 1
225 *-bsd-user)
226 if test "$bsd" != "yes"; then
227 print_error "Target '$target' is only available on a BSD host"
228 return 1
232 print_error "Invalid target name '$target'"
233 return 1
235 esac
236 test "$tcg" = "yes" && return 0
237 supported_kvm_target "$1" && return 0
238 supported_xen_target "$1" && return 0
239 supported_hax_target "$1" && return 0
240 print_error "TCG disabled, but hardware accelerator not available for '$target'"
241 return 1
245 ld_has() {
246 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
249 # default parameters
250 source_path=$(dirname "$0")
251 cpu=""
252 iasl="iasl"
253 interp_prefix="/usr/gnemul/qemu-%M"
254 static="no"
255 cross_prefix=""
256 audio_drv_list=""
257 block_drv_rw_whitelist=""
258 block_drv_ro_whitelist=""
259 host_cc="cc"
260 libs_softmmu=""
261 libs_tools=""
262 audio_pt_int=""
263 audio_win_int=""
264 cc_i386=i386-pc-linux-gnu-gcc
265 libs_qga=""
266 debug_info="yes"
267 stack_protector=""
269 if test -e "$source_path/.git"
270 then
271 git_update=yes
272 git_submodules="ui/keycodemapdb"
273 else
274 git_update=no
275 git_submodules=""
277 git="git"
279 # Don't accept a target_list environment variable.
280 unset target_list
282 # Default value for a variable defining feature "foo".
283 # * foo="no" feature will only be used if --enable-foo arg is given
284 # * foo="" feature will be searched for, and if found, will be used
285 # unless --disable-foo is given
286 # * foo="yes" this value will only be set by --enable-foo flag.
287 # feature will searched for,
288 # if not found, configure exits with error
290 # Always add --enable-foo and --disable-foo command line args.
291 # Distributions want to ensure that several features are compiled in, and it
292 # is impossible without a --enable-foo that exits if a feature is not found.
294 bluez=""
295 brlapi=""
296 curl=""
297 curses=""
298 docs=""
299 fdt=""
300 netmap="no"
301 sdl=""
302 sdlabi=""
303 virtfs=""
304 mpath=""
305 vnc="yes"
306 sparse="no"
307 vde=""
308 vnc_sasl=""
309 vnc_jpeg=""
310 vnc_png=""
311 xkbcommon=""
312 xen=""
313 xen_ctrl_version=""
314 xen_pv_domain_build="no"
315 xen_pci_passthrough=""
316 linux_aio=""
317 cap_ng=""
318 attr=""
319 libattr=""
320 xfs=""
321 tcg="yes"
323 vhost_net="no"
324 vhost_scsi="no"
325 vhost_vsock="no"
326 vhost_user=""
327 kvm="no"
328 hax="no"
329 rdma=""
330 gprof="no"
331 debug_tcg="no"
332 debug="no"
333 fortify_source=""
334 strip_opt="yes"
335 tcg_interpreter="no"
336 bigendian="no"
337 mingw32="no"
338 gcov="no"
339 gcov_tool="gcov"
340 EXESUF=""
341 DSOSUF=".so"
342 LDFLAGS_SHARED="-shared"
343 modules="no"
344 prefix="/usr/local"
345 mandir="\${prefix}/share/man"
346 datadir="\${prefix}/share"
347 firmwarepath="\${prefix}/share/qemu-firmware"
348 qemu_docdir="\${prefix}/share/doc/qemu"
349 bindir="\${prefix}/bin"
350 libdir="\${prefix}/lib"
351 libexecdir="\${prefix}/libexec"
352 includedir="\${prefix}/include"
353 sysconfdir="\${prefix}/etc"
354 local_statedir="\${prefix}/var"
355 confsuffix="/qemu"
356 slirp="yes"
357 oss_lib=""
358 bsd="no"
359 haiku="no"
360 linux="no"
361 solaris="no"
362 profiler="no"
363 cocoa="no"
364 softmmu="yes"
365 linux_user="no"
366 bsd_user="no"
367 blobs="yes"
368 pkgversion=""
369 pie=""
370 qom_cast_debug="yes"
371 trace_backends="log"
372 trace_file="trace"
373 spice=""
374 rbd=""
375 smartcard=""
376 libusb=""
377 usb_redir=""
378 opengl=""
379 opengl_dmabuf="no"
380 cpuid_h="no"
381 avx2_opt="no"
382 zlib="yes"
383 capstone=""
384 lzo=""
385 snappy=""
386 bzip2=""
387 guest_agent=""
388 guest_agent_with_vss="no"
389 guest_agent_ntddscsi="no"
390 guest_agent_msi=""
391 vss_win32_sdk=""
392 win_sdk="no"
393 want_tools="yes"
394 libiscsi=""
395 libnfs=""
396 coroutine=""
397 coroutine_pool=""
398 debug_stack_usage="no"
399 crypto_afalg="no"
400 seccomp=""
401 glusterfs=""
402 glusterfs_xlator_opt="no"
403 glusterfs_discard="no"
404 glusterfs_fallocate="no"
405 glusterfs_zerofill="no"
406 gtk=""
407 gtkabi=""
408 gtk_gl="no"
409 tls_priority="NORMAL"
410 gnutls=""
411 gnutls_rnd=""
412 nettle=""
413 nettle_kdf="no"
414 gcrypt=""
415 gcrypt_hmac="no"
416 gcrypt_kdf="no"
417 vte=""
418 virglrenderer=""
419 tpm="yes"
420 libssh2=""
421 live_block_migration="yes"
422 numa=""
423 tcmalloc="no"
424 jemalloc="no"
425 replication="yes"
426 vxhs=""
428 supported_cpu="no"
429 supported_os="no"
430 bogus_os="no"
431 malloc_trim=""
433 # parse CC options first
434 for opt do
435 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
436 case "$opt" in
437 --cross-prefix=*) cross_prefix="$optarg"
439 --cc=*) CC="$optarg"
441 --cxx=*) CXX="$optarg"
443 --source-path=*) source_path="$optarg"
445 --cpu=*) cpu="$optarg"
447 --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
448 EXTRA_CFLAGS="$optarg"
450 --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
451 EXTRA_CXXFLAGS="$optarg"
453 --extra-ldflags=*) LDFLAGS="$LDFLAGS $optarg"
454 EXTRA_LDFLAGS="$optarg"
456 --enable-debug-info) debug_info="yes"
458 --disable-debug-info) debug_info="no"
460 esac
461 done
462 # OS specific
463 # Using uname is really, really broken. Once we have the right set of checks
464 # we can eliminate its usage altogether.
466 # Preferred compiler:
467 # ${CC} (if set)
468 # ${cross_prefix}gcc (if cross-prefix specified)
469 # system compiler
470 if test -z "${CC}${cross_prefix}"; then
471 cc="$host_cc"
472 else
473 cc="${CC-${cross_prefix}gcc}"
476 if test -z "${CXX}${cross_prefix}"; then
477 cxx="c++"
478 else
479 cxx="${CXX-${cross_prefix}g++}"
482 ar="${AR-${cross_prefix}ar}"
483 as="${AS-${cross_prefix}as}"
484 ccas="${CCAS-$cc}"
485 cpp="${CPP-$cc -E}"
486 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
487 ld="${LD-${cross_prefix}ld}"
488 ranlib="${RANLIB-${cross_prefix}ranlib}"
489 nm="${NM-${cross_prefix}nm}"
490 strip="${STRIP-${cross_prefix}strip}"
491 windres="${WINDRES-${cross_prefix}windres}"
492 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
493 query_pkg_config() {
494 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
496 pkg_config=query_pkg_config
497 sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
498 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
500 # If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
501 ARFLAGS="${ARFLAGS-rv}"
503 # default flags for all hosts
504 # We use -fwrapv to tell the compiler that we require a C dialect where
505 # left shift of signed integers is well defined and has the expected
506 # 2s-complement style results. (Both clang and gcc agree that it
507 # provides these semantics.)
508 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
509 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
510 QEMU_CFLAGS="-Wmissing-format-attribute $QEMU_CFLAGS"
511 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
512 QEMU_CFLAGS="-Wno-unused-parameter $QEMU_CFLAGS"
513 QEMU_CFLAGS="-Wno-missing-field-initializers $QEMU_CFLAGS"
514 QEMU_CFLAGS="-Wno-sign-compare $QEMU_CFLAGS"
515 QEMU_CFLAGS="-Wno-override-init $QEMU_CFLAGS"
516 QEMU_CFLAGS="-Wno-error=format $QEMU_CFLAGS"
517 QEMU_CFLAGS="-Wno-error=format-extra-args $QEMU_CFLAGS"
518 QEMU_CFLAGS="-Wno-error=parentheses $QEMU_CFLAGS"
519 QEMU_CFLAGS="-Wextra $QEMU_CFLAGS"
520 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
521 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/accel/tcg -I\$(SRC_PATH)/include"
522 if test "$debug_info" = "yes"; then
523 CFLAGS="-g $CFLAGS"
524 LDFLAGS="-g $LDFLAGS"
527 # make source path absolute
528 source_path=$(cd "$source_path"; pwd)
530 cc_macros=$($cc $QEMU_CFLAGS -E -dD - </dev/null)
532 # running configure in the source tree?
533 # we know that's the case if configure is there.
534 if test -f "./configure"; then
535 pwd_is_source_path="y"
536 else
537 pwd_is_source_path="n"
540 check_define() {
541 rm -f $TMPC
542 cat > $TMPC <<EOF
543 #if !defined($1)
544 #error $1 not defined
545 #endif
546 int main(void) { return 0; }
548 compile_object
551 check_include() {
552 cat > $TMPC <<EOF
553 #include <$1>
554 int main(void) { return 0; }
556 compile_object
559 write_c_skeleton() {
560 cat > $TMPC <<EOF
561 int main(void) { return 0; }
565 if check_define __linux__ ; then
566 targetos="Linux"
567 elif check_define _WIN32 ; then
568 targetos='MINGW32'
569 elif check_define __OpenBSD__ ; then
570 targetos='OpenBSD'
571 elif check_define __sun__ ; then
572 targetos='SunOS'
573 elif check_define __HAIKU__ ; then
574 targetos='Haiku'
575 elif check_define __FreeBSD__ ; then
576 targetos='FreeBSD'
577 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
578 targetos='GNU/kFreeBSD'
579 elif check_define __DragonFly__ ; then
580 targetos='DragonFly'
581 elif check_define __NetBSD__; then
582 targetos='NetBSD'
583 elif check_define __APPLE__; then
584 targetos='Darwin'
585 else
586 # This is a fatal error, but don't report it yet, because we
587 # might be going to just print the --help text, or it might
588 # be the result of a missing compiler.
589 targetos='bogus'
590 bogus_os='yes'
593 # Some host OSes need non-standard checks for which CPU to use.
594 # Note that these checks are broken for cross-compilation: if you're
595 # cross-compiling to one of these OSes then you'll need to specify
596 # the correct CPU with the --cpu option.
597 case $targetos in
598 Darwin)
599 # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
600 # run 64-bit userspace code.
601 # If the user didn't specify a CPU explicitly and the kernel says this is
602 # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
603 if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
604 cpu="x86_64"
607 SunOS)
608 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
609 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
610 cpu="x86_64"
612 esac
614 if test ! -z "$cpu" ; then
615 # command line argument
617 elif check_define __i386__ ; then
618 cpu="i386"
619 elif check_define __x86_64__ ; then
620 if check_define __ILP32__ ; then
621 cpu="x32"
622 else
623 cpu="x86_64"
625 elif check_define __sparc__ ; then
626 if check_define __arch64__ ; then
627 cpu="sparc64"
628 else
629 cpu="sparc"
631 elif check_define _ARCH_PPC ; then
632 if check_define _ARCH_PPC64 ; then
633 cpu="ppc64"
634 else
635 cpu="ppc"
637 elif check_define __mips__ ; then
638 if check_define __mips64 ; then
639 cpu="mips64"
640 else
641 cpu="mips"
643 elif check_define __ia64__ ; then
644 cpu="ia64"
645 elif check_define __s390__ ; then
646 if check_define __s390x__ ; then
647 cpu="s390x"
648 else
649 cpu="s390"
651 elif check_define __arm__ ; then
652 cpu="arm"
653 elif check_define __aarch64__ ; then
654 cpu="aarch64"
655 else
656 cpu=$(uname -m)
659 ARCH=
660 # Normalise host CPU name and set ARCH.
661 # Note that this case should only have supported host CPUs, not guests.
662 case "$cpu" in
663 ppc|ppc64|s390|s390x|sparc64|x32)
664 cpu="$cpu"
665 supported_cpu="yes"
667 i386|i486|i586|i686|i86pc|BePC)
668 cpu="i386"
669 supported_cpu="yes"
671 x86_64|amd64)
672 cpu="x86_64"
673 supported_cpu="yes"
675 armv*b|armv*l|arm)
676 cpu="arm"
677 supported_cpu="yes"
679 aarch64)
680 cpu="aarch64"
681 supported_cpu="yes"
683 mips*)
684 cpu="mips"
685 if check_define __MIPSEL__ ; then
686 cpu="${cpu}el"
688 supported_cpu="yes"
690 sparc|sun4[cdmuv])
691 cpu="sparc"
692 supported_cpu="yes"
694 sh4)
695 cpu="sh4"
698 # This will result in either an error or falling back to TCI later
699 ARCH=unknown
701 esac
702 if test -z "$ARCH"; then
703 ARCH="$cpu"
706 # OS specific
708 # host *BSD for user mode
709 HOST_VARIANT_DIR=""
711 case $targetos in
712 MINGW32*)
713 mingw32="yes"
714 hax="yes"
715 audio_possible_drivers="dsound sdl"
716 if check_include dsound.h; then
717 audio_drv_list="dsound"
718 else
719 audio_drv_list=""
721 supported_os="yes"
723 GNU/kFreeBSD)
724 bsd="yes"
725 audio_drv_list="oss"
726 audio_possible_drivers="oss sdl pa"
728 FreeBSD)
729 bsd="yes"
730 make="${MAKE-gmake}"
731 audio_drv_list="oss"
732 audio_possible_drivers="oss sdl pa"
733 # needed for kinfo_getvmmap(3) in libutil.h
734 LIBS="-lutil $LIBS"
735 # needed for kinfo_getproc
736 libs_qga="-lutil $libs_qga"
737 netmap="" # enable netmap autodetect
738 HOST_VARIANT_DIR="freebsd"
739 supported_os="yes"
741 DragonFly)
742 bsd="yes"
743 make="${MAKE-gmake}"
744 audio_drv_list="oss"
745 audio_possible_drivers="oss sdl pa"
746 HOST_VARIANT_DIR="dragonfly"
748 NetBSD)
749 bsd="yes"
750 make="${MAKE-gmake}"
751 audio_drv_list="oss"
752 audio_possible_drivers="oss sdl"
753 oss_lib="-lossaudio"
754 HOST_VARIANT_DIR="netbsd"
755 supported_os="yes"
757 OpenBSD)
758 bsd="yes"
759 make="${MAKE-gmake}"
760 audio_drv_list="sdl"
761 audio_possible_drivers="sdl"
762 HOST_VARIANT_DIR="openbsd"
764 Darwin)
765 bsd="yes"
766 darwin="yes"
767 hax="yes"
768 LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
769 if [ "$cpu" = "x86_64" ] ; then
770 QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
771 LDFLAGS="-arch x86_64 $LDFLAGS"
773 cocoa="yes"
774 audio_drv_list="coreaudio"
775 audio_possible_drivers="coreaudio sdl"
776 LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS"
777 libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
778 # Disable attempts to use ObjectiveC features in os/object.h since they
779 # won't work when we're compiling with gcc as a C compiler.
780 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
781 HOST_VARIANT_DIR="darwin"
782 supported_os="yes"
784 SunOS)
785 solaris="yes"
786 make="${MAKE-gmake}"
787 install="${INSTALL-ginstall}"
788 smbd="${SMBD-/usr/sfw/sbin/smbd}"
789 if test -f /usr/include/sys/soundcard.h ; then
790 audio_drv_list="oss"
792 audio_possible_drivers="oss sdl"
793 # needed for CMSG_ macros in sys/socket.h
794 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
795 # needed for TIOCWIN* defines in termios.h
796 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
797 QEMU_CFLAGS="-std=gnu99 $QEMU_CFLAGS"
798 solarisnetlibs="-lsocket -lnsl -lresolv"
799 LIBS="$solarisnetlibs $LIBS"
800 libs_qga="$solarisnetlibs $libs_qga"
802 Haiku)
803 haiku="yes"
804 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
805 LIBS="-lposix_error_mapper -lnetwork $LIBS"
807 Linux)
808 audio_drv_list="oss"
809 audio_possible_drivers="oss alsa sdl pa"
810 linux="yes"
811 linux_user="yes"
812 kvm="yes"
813 vhost_net="yes"
814 vhost_scsi="yes"
815 vhost_vsock="yes"
816 QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
817 supported_os="yes"
819 esac
821 if [ "$bsd" = "yes" ] ; then
822 if [ "$darwin" != "yes" ] ; then
823 bsd_user="yes"
827 : ${make=${MAKE-make}}
828 : ${install=${INSTALL-install}}
829 : ${python=${PYTHON-python}}
830 : ${smbd=${SMBD-/usr/sbin/smbd}}
832 # Default objcc to clang if available, otherwise use CC
833 if has clang; then
834 objcc=clang
835 else
836 objcc="$cc"
839 if test "$mingw32" = "yes" ; then
840 EXESUF=".exe"
841 DSOSUF=".dll"
842 QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
843 # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
844 QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
845 # MinGW-w64 needs _POSIX defined.
846 QEMU_CFLAGS="-D_POSIX=1 $QEMU_CFLAGS"
847 # MinGW needs -mthreads for TLS and macro _MT.
848 QEMU_CFLAGS="-mthreads $QEMU_CFLAGS"
849 QEMU_CFLAGS="-I\$(SRC_PATH)/hosts/w32/include $QEMU_CFLAGS"
850 LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
851 write_c_skeleton;
852 if compile_prog "" "-liberty" ; then
853 LIBS="-liberty $LIBS"
855 prefix="c:/Program Files/QEMU"
856 mandir="\${prefix}"
857 datadir="\${prefix}"
858 qemu_docdir="\${prefix}"
859 bindir="\${prefix}"
860 sysconfdir="\${prefix}"
861 local_statedir=
862 confsuffix=""
863 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
866 werror=""
868 for opt do
869 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
870 case "$opt" in
871 --help|-h) show_help=yes
873 --version|-V) exec cat $source_path/VERSION
875 --prefix=*) prefix="$optarg"
877 --interp-prefix=*) interp_prefix="$optarg"
879 --source-path=*)
881 --cross-prefix=*)
883 --cc=*)
885 --host-cc=*) host_cc="$optarg"
887 --cxx=*)
889 --iasl=*) iasl="$optarg"
891 --objcc=*) objcc="$optarg"
893 --make=*) make="$optarg"
895 --install=*) install="$optarg"
897 --python=*) python="$optarg"
899 --gcov=*) gcov_tool="$optarg"
901 --smbd=*) smbd="$optarg"
903 --extra-cflags=*)
905 --extra-cxxflags=*)
907 --extra-ldflags=*)
909 --enable-debug-info)
911 --disable-debug-info)
913 --enable-modules)
914 modules="yes"
916 --disable-modules)
917 modules="no"
919 --cpu=*)
921 --target-list=*) target_list="$optarg"
923 --enable-trace-backends=*) trace_backends="$optarg"
925 # XXX: backwards compatibility
926 --enable-trace-backend=*) trace_backends="$optarg"
928 --with-trace-file=*) trace_file="$optarg"
930 --enable-gprof) gprof="yes"
932 --enable-gcov) gcov="yes"
934 --static)
935 static="yes"
936 LDFLAGS="-static $LDFLAGS"
937 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
939 --mandir=*) mandir="$optarg"
941 --bindir=*) bindir="$optarg"
943 --libdir=*) libdir="$optarg"
945 --libexecdir=*) libexecdir="$optarg"
947 --includedir=*) includedir="$optarg"
949 --datadir=*) datadir="$optarg"
951 --with-confsuffix=*) confsuffix="$optarg"
953 --docdir=*) qemu_docdir="$optarg"
955 --sysconfdir=*) sysconfdir="$optarg"
957 --localstatedir=*) local_statedir="$optarg"
959 --firmwarepath=*) firmwarepath="$optarg"
961 --sbindir=*|--sharedstatedir=*|\
962 --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
963 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
964 # These switches are silently ignored, for compatibility with
965 # autoconf-generated configure scripts. This allows QEMU's
966 # configure to be used by RPM and similar macros that set
967 # lots of directory switches by default.
969 --disable-sdl) sdl="no"
971 --enable-sdl) sdl="yes"
973 --with-sdlabi=*) sdlabi="$optarg"
975 --disable-qom-cast-debug) qom_cast_debug="no"
977 --enable-qom-cast-debug) qom_cast_debug="yes"
979 --disable-virtfs) virtfs="no"
981 --enable-virtfs) virtfs="yes"
983 --disable-mpath) mpath="no"
985 --enable-mpath) mpath="yes"
987 --disable-vnc) vnc="no"
989 --enable-vnc) vnc="yes"
991 --oss-lib=*) oss_lib="$optarg"
993 --audio-drv-list=*) audio_drv_list="$optarg"
995 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
997 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
999 --enable-debug-tcg) debug_tcg="yes"
1001 --disable-debug-tcg) debug_tcg="no"
1003 --enable-debug)
1004 # Enable debugging options that aren't excessively noisy
1005 debug_tcg="yes"
1006 debug="yes"
1007 strip_opt="no"
1008 fortify_source="no"
1010 --enable-sparse) sparse="yes"
1012 --disable-sparse) sparse="no"
1014 --disable-strip) strip_opt="no"
1016 --disable-vnc-sasl) vnc_sasl="no"
1018 --enable-vnc-sasl) vnc_sasl="yes"
1020 --disable-vnc-jpeg) vnc_jpeg="no"
1022 --enable-vnc-jpeg) vnc_jpeg="yes"
1024 --disable-vnc-png) vnc_png="no"
1026 --enable-vnc-png) vnc_png="yes"
1028 --disable-slirp) slirp="no"
1030 --disable-vde) vde="no"
1032 --enable-vde) vde="yes"
1034 --disable-netmap) netmap="no"
1036 --enable-netmap) netmap="yes"
1038 --disable-xen) xen="no"
1040 --enable-xen) xen="yes"
1042 --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1044 --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1046 --disable-xen-pv-domain-build) xen_pv_domain_build="no"
1048 --enable-xen-pv-domain-build) xen_pv_domain_build="yes"
1050 --disable-brlapi) brlapi="no"
1052 --enable-brlapi) brlapi="yes"
1054 --disable-bluez) bluez="no"
1056 --enable-bluez) bluez="yes"
1058 --disable-kvm) kvm="no"
1060 --enable-kvm) kvm="yes"
1062 --disable-hax) hax="no"
1064 --enable-hax) hax="yes"
1066 --disable-tcg-interpreter) tcg_interpreter="no"
1068 --enable-tcg-interpreter) tcg_interpreter="yes"
1070 --disable-cap-ng) cap_ng="no"
1072 --enable-cap-ng) cap_ng="yes"
1074 --disable-tcg) tcg="no"
1076 --enable-tcg) tcg="yes"
1078 --disable-malloc-trim) malloc_trim="no"
1080 --enable-malloc-trim) malloc_trim="yes"
1082 --disable-spice) spice="no"
1084 --enable-spice) spice="yes"
1086 --disable-libiscsi) libiscsi="no"
1088 --enable-libiscsi) libiscsi="yes"
1090 --disable-libnfs) libnfs="no"
1092 --enable-libnfs) libnfs="yes"
1094 --enable-profiler) profiler="yes"
1096 --disable-cocoa) cocoa="no"
1098 --enable-cocoa)
1099 cocoa="yes" ;
1100 audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
1102 --disable-system) softmmu="no"
1104 --enable-system) softmmu="yes"
1106 --disable-user)
1107 linux_user="no" ;
1108 bsd_user="no" ;
1110 --enable-user) ;;
1111 --disable-linux-user) linux_user="no"
1113 --enable-linux-user) linux_user="yes"
1115 --disable-bsd-user) bsd_user="no"
1117 --enable-bsd-user) bsd_user="yes"
1119 --enable-pie) pie="yes"
1121 --disable-pie) pie="no"
1123 --enable-werror) werror="yes"
1125 --disable-werror) werror="no"
1127 --enable-stack-protector) stack_protector="yes"
1129 --disable-stack-protector) stack_protector="no"
1131 --disable-curses) curses="no"
1133 --enable-curses) curses="yes"
1135 --disable-curl) curl="no"
1137 --enable-curl) curl="yes"
1139 --disable-fdt) fdt="no"
1141 --enable-fdt) fdt="yes"
1143 --disable-linux-aio) linux_aio="no"
1145 --enable-linux-aio) linux_aio="yes"
1147 --disable-attr) attr="no"
1149 --enable-attr) attr="yes"
1151 --disable-blobs) blobs="no"
1153 --with-pkgversion=*) pkgversion=" ($optarg)"
1155 --with-coroutine=*) coroutine="$optarg"
1157 --disable-coroutine-pool) coroutine_pool="no"
1159 --enable-coroutine-pool) coroutine_pool="yes"
1161 --enable-debug-stack-usage) debug_stack_usage="yes"
1163 --enable-crypto-afalg) crypto_afalg="yes"
1165 --disable-crypto-afalg) crypto_afalg="no"
1167 --disable-docs) docs="no"
1169 --enable-docs) docs="yes"
1171 --disable-vhost-net) vhost_net="no"
1173 --enable-vhost-net) vhost_net="yes"
1175 --disable-vhost-scsi) vhost_scsi="no"
1177 --enable-vhost-scsi) vhost_scsi="yes"
1179 --disable-vhost-vsock) vhost_vsock="no"
1181 --enable-vhost-vsock) vhost_vsock="yes"
1183 --disable-opengl) opengl="no"
1185 --enable-opengl) opengl="yes"
1187 --disable-rbd) rbd="no"
1189 --enable-rbd) rbd="yes"
1191 --disable-xfsctl) xfs="no"
1193 --enable-xfsctl) xfs="yes"
1195 --disable-smartcard) smartcard="no"
1197 --enable-smartcard) smartcard="yes"
1199 --disable-libusb) libusb="no"
1201 --enable-libusb) libusb="yes"
1203 --disable-usb-redir) usb_redir="no"
1205 --enable-usb-redir) usb_redir="yes"
1207 --disable-zlib-test) zlib="no"
1209 --disable-lzo) lzo="no"
1211 --enable-lzo) lzo="yes"
1213 --disable-snappy) snappy="no"
1215 --enable-snappy) snappy="yes"
1217 --disable-bzip2) bzip2="no"
1219 --enable-bzip2) bzip2="yes"
1221 --enable-guest-agent) guest_agent="yes"
1223 --disable-guest-agent) guest_agent="no"
1225 --enable-guest-agent-msi) guest_agent_msi="yes"
1227 --disable-guest-agent-msi) guest_agent_msi="no"
1229 --with-vss-sdk) vss_win32_sdk=""
1231 --with-vss-sdk=*) vss_win32_sdk="$optarg"
1233 --without-vss-sdk) vss_win32_sdk="no"
1235 --with-win-sdk) win_sdk=""
1237 --with-win-sdk=*) win_sdk="$optarg"
1239 --without-win-sdk) win_sdk="no"
1241 --enable-tools) want_tools="yes"
1243 --disable-tools) want_tools="no"
1245 --enable-seccomp) seccomp="yes"
1247 --disable-seccomp) seccomp="no"
1249 --disable-glusterfs) glusterfs="no"
1251 --enable-glusterfs) glusterfs="yes"
1253 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
1254 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1256 --enable-vhdx|--disable-vhdx)
1257 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1259 --enable-uuid|--disable-uuid)
1260 echo "$0: $opt is obsolete, UUID support is always built" >&2
1262 --disable-gtk) gtk="no"
1264 --enable-gtk) gtk="yes"
1266 --tls-priority=*) tls_priority="$optarg"
1268 --disable-gnutls) gnutls="no"
1270 --enable-gnutls) gnutls="yes"
1272 --disable-nettle) nettle="no"
1274 --enable-nettle) nettle="yes"
1276 --disable-gcrypt) gcrypt="no"
1278 --enable-gcrypt) gcrypt="yes"
1280 --enable-rdma) rdma="yes"
1282 --disable-rdma) rdma="no"
1284 --with-gtkabi=*) gtkabi="$optarg"
1286 --disable-vte) vte="no"
1288 --enable-vte) vte="yes"
1290 --disable-virglrenderer) virglrenderer="no"
1292 --enable-virglrenderer) virglrenderer="yes"
1294 --disable-tpm) tpm="no"
1296 --enable-tpm) tpm="yes"
1298 --disable-libssh2) libssh2="no"
1300 --enable-libssh2) libssh2="yes"
1302 --disable-live-block-migration) live_block_migration="no"
1304 --enable-live-block-migration) live_block_migration="yes"
1306 --disable-numa) numa="no"
1308 --enable-numa) numa="yes"
1310 --disable-tcmalloc) tcmalloc="no"
1312 --enable-tcmalloc) tcmalloc="yes"
1314 --disable-jemalloc) jemalloc="no"
1316 --enable-jemalloc) jemalloc="yes"
1318 --disable-replication) replication="no"
1320 --enable-replication) replication="yes"
1322 --disable-vxhs) vxhs="no"
1324 --enable-vxhs) vxhs="yes"
1326 --disable-vhost-user) vhost_user="no"
1328 --enable-vhost-user)
1329 vhost_user="yes"
1330 if test "$mingw32" = "yes"; then
1331 error_exit "vhost-user isn't available on win32"
1334 --disable-capstone) capstone="no"
1336 --enable-capstone) capstone="yes"
1338 --enable-capstone=git) capstone="git"
1340 --enable-capstone=system) capstone="system"
1342 --with-git=*) git="$optarg"
1344 --enable-git-update) git_update=yes
1346 --disable-git-update) git_update=no
1349 echo "ERROR: unknown option $opt"
1350 echo "Try '$0 --help' for more information"
1351 exit 1
1353 esac
1354 done
1356 if test "$vhost_user" = ""; then
1357 if test "$mingw32" = "yes"; then
1358 vhost_user="no"
1359 else
1360 vhost_user="yes"
1364 case "$cpu" in
1365 ppc)
1366 CPU_CFLAGS="-m32"
1367 LDFLAGS="-m32 $LDFLAGS"
1369 ppc64)
1370 CPU_CFLAGS="-m64"
1371 LDFLAGS="-m64 $LDFLAGS"
1373 sparc)
1374 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1375 LDFLAGS="-m32 -mv8plus $LDFLAGS"
1377 sparc64)
1378 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1379 LDFLAGS="-m64 $LDFLAGS"
1381 s390)
1382 CPU_CFLAGS="-m31"
1383 LDFLAGS="-m31 $LDFLAGS"
1385 s390x)
1386 CPU_CFLAGS="-m64"
1387 LDFLAGS="-m64 $LDFLAGS"
1389 i386)
1390 CPU_CFLAGS="-m32"
1391 LDFLAGS="-m32 $LDFLAGS"
1392 cc_i386='$(CC) -m32'
1394 x86_64)
1395 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
1396 # If we truly care, we should simply detect this case at
1397 # runtime and generate the fallback to serial emulation.
1398 CPU_CFLAGS="-m64 -mcx16"
1399 LDFLAGS="-m64 $LDFLAGS"
1400 cc_i386='$(CC) -m32'
1402 x32)
1403 CPU_CFLAGS="-mx32"
1404 LDFLAGS="-mx32 $LDFLAGS"
1405 cc_i386='$(CC) -m32'
1407 # No special flags required for other host CPUs
1408 esac
1410 QEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
1411 EXTRA_CFLAGS="$CPU_CFLAGS $EXTRA_CFLAGS"
1413 # For user-mode emulation the host arch has to be one we explicitly
1414 # support, even if we're using TCI.
1415 if [ "$ARCH" = "unknown" ]; then
1416 bsd_user="no"
1417 linux_user="no"
1420 default_target_list=""
1422 mak_wilds=""
1424 if [ "$softmmu" = "yes" ]; then
1425 mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
1427 if [ "$linux_user" = "yes" ]; then
1428 mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
1430 if [ "$bsd_user" = "yes" ]; then
1431 mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
1434 for config in $mak_wilds; do
1435 default_target_list="${default_target_list} $(basename "$config" .mak)"
1436 done
1438 # Enumerate public trace backends for --help output
1439 trace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1441 if test x"$show_help" = x"yes" ; then
1442 cat << EOF
1444 Usage: configure [options]
1445 Options: [defaults in brackets after descriptions]
1447 Standard options:
1448 --help print this message
1449 --prefix=PREFIX install in PREFIX [$prefix]
1450 --interp-prefix=PREFIX where to find shared libraries, etc.
1451 use %M for cpu name [$interp_prefix]
1452 --target-list=LIST set target list (default: build everything)
1453 $(echo Available targets: $default_target_list | \
1454 fold -s -w 53 | sed -e 's/^/ /')
1456 Advanced options (experts only):
1457 --source-path=PATH path of source code [$source_path]
1458 --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
1459 --cc=CC use C compiler CC [$cc]
1460 --iasl=IASL use ACPI compiler IASL [$iasl]
1461 --host-cc=CC use C compiler CC [$host_cc] for code run at
1462 build time
1463 --cxx=CXX use C++ compiler CXX [$cxx]
1464 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1465 --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS
1466 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
1467 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1468 --make=MAKE use specified make [$make]
1469 --install=INSTALL use specified install [$install]
1470 --python=PYTHON use specified python [$python]
1471 --smbd=SMBD use specified smbd [$smbd]
1472 --static enable static build [$static]
1473 --mandir=PATH install man pages in PATH
1474 --datadir=PATH install firmware in PATH$confsuffix
1475 --docdir=PATH install documentation in PATH$confsuffix
1476 --bindir=PATH install binaries in PATH
1477 --libdir=PATH install libraries in PATH
1478 --sysconfdir=PATH install config in PATH$confsuffix
1479 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1480 --firmwarepath=PATH search PATH for firmware files
1481 --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1482 --enable-debug enable common debug build options
1483 --disable-strip disable stripping binaries
1484 --disable-werror disable compilation abort on warning
1485 --disable-stack-protector disable compiler-provided stack protection
1486 --audio-drv-list=LIST set audio drivers list:
1487 Available drivers: $audio_possible_drivers
1488 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1489 --block-drv-rw-whitelist=L
1490 set block driver read-write whitelist
1491 (affects only QEMU, not qemu-img)
1492 --block-drv-ro-whitelist=L
1493 set block driver read-only whitelist
1494 (affects only QEMU, not qemu-img)
1495 --enable-trace-backends=B Set trace backend
1496 Available backends: $trace_backend_list
1497 --with-trace-file=NAME Full PATH,NAME of file to store traces
1498 Default:trace-<pid>
1499 --disable-slirp disable SLIRP userspace network connectivity
1500 --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
1501 --enable-malloc-trim enable libc malloc_trim() for memory optimization
1502 --oss-lib path to OSS library
1503 --cpu=CPU Build for host CPU [$cpu]
1504 --with-coroutine=BACKEND coroutine backend. Supported options:
1505 ucontext, sigaltstack, windows
1506 --enable-gcov enable test coverage analysis with gcov
1507 --gcov=GCOV use specified gcov [$gcov_tool]
1508 --disable-blobs disable installing provided firmware blobs
1509 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
1510 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb)
1511 --tls-priority default TLS protocol/cipher priority string
1512 --enable-gprof QEMU profiling with gprof
1513 --enable-profiler profiler support
1514 --enable-xen-pv-domain-build
1515 xen pv domain builder
1516 --enable-debug-stack-usage
1517 track the maximum stack usage of stacks created by qemu_alloc_stack
1519 Optional features, enabled with --enable-FEATURE and
1520 disabled with --disable-FEATURE, default is enabled if available:
1522 system all system emulation targets
1523 user supported user emulation targets
1524 linux-user all linux usermode emulation targets
1525 bsd-user all BSD usermode emulation targets
1526 docs build documentation
1527 guest-agent build the QEMU Guest Agent
1528 guest-agent-msi build guest agent Windows MSI installation package
1529 pie Position Independent Executables
1530 modules modules support
1531 debug-tcg TCG debugging (default is disabled)
1532 debug-info debugging information
1533 sparse sparse checker
1535 gnutls GNUTLS cryptography support
1536 nettle nettle cryptography support
1537 gcrypt libgcrypt cryptography support
1538 sdl SDL UI
1539 --with-sdlabi select preferred SDL ABI 1.2 or 2.0
1540 gtk gtk UI
1541 --with-gtkabi select preferred GTK ABI 2.0 or 3.0
1542 vte vte support for the gtk UI
1543 curses curses UI
1544 vnc VNC UI support
1545 vnc-sasl SASL encryption for VNC server
1546 vnc-jpeg JPEG lossy compression for VNC server
1547 vnc-png PNG compression for VNC server
1548 cocoa Cocoa UI (Mac OS X only)
1549 virtfs VirtFS
1550 mpath Multipath persistent reservation passthrough
1551 xen xen backend driver support
1552 xen-pci-passthrough
1553 brlapi BrlAPI (Braile)
1554 curl curl connectivity
1555 fdt fdt device tree
1556 bluez bluez stack connectivity
1557 kvm KVM acceleration support
1558 hax HAX acceleration support
1559 rdma RDMA-based migration support
1560 vde support for vde network
1561 netmap support for netmap network
1562 linux-aio Linux AIO support
1563 cap-ng libcap-ng support
1564 attr attr and xattr support
1565 vhost-net vhost-net acceleration support
1566 spice spice
1567 rbd rados block device (rbd)
1568 libiscsi iscsi support
1569 libnfs nfs support
1570 smartcard smartcard support (libcacard)
1571 libusb libusb (for usb passthrough)
1572 live-block-migration Block migration in the main migration stream
1573 usb-redir usb network redirection support
1574 lzo support of lzo compression library
1575 snappy support of snappy compression library
1576 bzip2 support of bzip2 compression library
1577 (for reading bzip2-compressed dmg images)
1578 seccomp seccomp support
1579 coroutine-pool coroutine freelist (better performance)
1580 glusterfs GlusterFS backend
1581 tpm TPM support
1582 libssh2 ssh block device support
1583 numa libnuma support
1584 tcmalloc tcmalloc support
1585 jemalloc jemalloc support
1586 replication replication support
1587 vhost-vsock virtio sockets device support
1588 opengl opengl support
1589 virglrenderer virgl rendering support
1590 xfsctl xfsctl support
1591 qom-cast-debug cast debugging support
1592 tools build qemu-io, qemu-nbd and qemu-image tools
1593 vxhs Veritas HyperScale vDisk backend support
1594 crypto-afalg Linux AF_ALG crypto backend driver
1595 vhost-user vhost-user support
1596 capstone capstone disassembler support
1598 NOTE: The object files are built at the place where configure is launched
1600 exit 0
1603 if ! has $python; then
1604 error_exit "Python not found. Use --python=/path/to/python"
1607 # Note that if the Python conditional here evaluates True we will exit
1608 # with status 1 which is a shell 'false' value.
1609 if ! $python -c 'import sys; sys.exit(sys.version_info < (2,6) or sys.version_info >= (3,))'; then
1610 error_exit "Cannot use '$python', Python 2.6 or later is required." \
1611 "Note that Python 3 or later is not yet supported." \
1612 "Use --python=/path/to/python to specify a supported Python."
1615 # Suppress writing compiled files
1616 python="$python -B"
1618 # Check that the C compiler works. Doing this here before testing
1619 # the host CPU ensures that we had a valid CC to autodetect the
1620 # $cpu var (and we should bail right here if that's not the case).
1621 # It also allows the help message to be printed without a CC.
1622 write_c_skeleton;
1623 if compile_object ; then
1624 : C compiler works ok
1625 else
1626 error_exit "\"$cc\" either does not exist or does not work"
1628 if ! compile_prog ; then
1629 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1632 # Now we have handled --enable-tcg-interpreter and know we're not just
1633 # printing the help message, bail out if the host CPU isn't supported.
1634 if test "$ARCH" = "unknown"; then
1635 if test "$tcg_interpreter" = "yes" ; then
1636 echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
1637 else
1638 error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
1642 # Consult white-list to determine whether to enable werror
1643 # by default. Only enable by default for git builds
1644 if test -z "$werror" ; then
1645 if test -d "$source_path/.git" -a \
1646 \( "$linux" = "yes" -o "$mingw32" = "yes" \) ; then
1647 werror="yes"
1648 else
1649 werror="no"
1653 if test "$bogus_os" = "yes"; then
1654 # Now that we know that we're not printing the help and that
1655 # the compiler works (so the results of the check_defines we used
1656 # to identify the OS are reliable), if we didn't recognize the
1657 # host OS we should stop now.
1658 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1661 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
1662 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
1663 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
1664 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
1665 gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
1666 gcc_flags="-Wno-string-plus-int $gcc_flags"
1667 # Note that we do not add -Werror to gcc_flags here, because that would
1668 # enable it for all configure tests. If a configure test failed due
1669 # to -Werror this would just silently disable some features,
1670 # so it's too error prone.
1672 cc_has_warning_flag() {
1673 write_c_skeleton;
1675 # Use the positive sense of the flag when testing for -Wno-wombat
1676 # support (gcc will happily accept the -Wno- form of unknown
1677 # warning options).
1678 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1679 compile_prog "-Werror $optflag" ""
1682 for flag in $gcc_flags; do
1683 if cc_has_warning_flag $flag ; then
1684 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1686 done
1688 if test "$mingw32" = "yes"; then
1689 stack_protector="no"
1691 if test "$stack_protector" != "no"; then
1692 cat > $TMPC << EOF
1693 int main(int argc, char *argv[])
1695 char arr[64], *p = arr, *c = argv[0];
1696 while (*c) {
1697 *p++ = *c++;
1699 return 0;
1702 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1703 sp_on=0
1704 for flag in $gcc_flags; do
1705 # We need to check both a compile and a link, since some compiler
1706 # setups fail only on a .c->.o compile and some only at link time
1707 if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC &&
1708 compile_prog "-Werror $flag" ""; then
1709 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1710 sp_on=1
1711 break
1713 done
1714 if test "$stack_protector" = yes; then
1715 if test $sp_on = 0; then
1716 error_exit "Stack protector not supported"
1721 # Disable -Wmissing-braces on older compilers that warn even for
1722 # the "universal" C zero initializer {0}.
1723 cat > $TMPC << EOF
1724 struct {
1725 int a[2];
1726 } x = {0};
1728 if compile_object "-Werror" "" ; then
1730 else
1731 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1734 # Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
1735 # large functions that use global variables. The bug is in all releases of
1736 # GCC, but it became particularly acute in 4.6.x and 4.7.x. It is fixed in
1737 # 4.7.3 and 4.8.0. We should be able to delete this at the end of 2013.
1738 cat > $TMPC << EOF
1739 #if __GNUC__ == 4 && (__GNUC_MINOR__ == 6 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ <= 2))
1740 int main(void) { return 0; }
1741 #else
1742 #error No bug in this compiler.
1743 #endif
1745 if compile_prog "-Werror -fno-gcse" "" ; then
1746 TRANSLATE_OPT_CFLAGS=-fno-gcse
1749 if test "$static" = "yes" ; then
1750 if test "$modules" = "yes" ; then
1751 error_exit "static and modules are mutually incompatible"
1753 if test "$pie" = "yes" ; then
1754 error_exit "static and pie are mutually incompatible"
1755 else
1756 pie="no"
1760 # Unconditional check for compiler __thread support
1761 cat > $TMPC << EOF
1762 static __thread int tls_var;
1763 int main(void) { return tls_var; }
1766 if ! compile_prog "-Werror" "" ; then
1767 error_exit "Your compiler does not support the __thread specifier for " \
1768 "Thread-Local Storage (TLS). Please upgrade to a version that does."
1771 if test "$pie" = ""; then
1772 case "$cpu-$targetos" in
1773 i386-Linux|x86_64-Linux|x32-Linux|i386-OpenBSD|x86_64-OpenBSD)
1776 pie="no"
1778 esac
1781 if test "$pie" != "no" ; then
1782 cat > $TMPC << EOF
1784 #ifdef __linux__
1785 # define THREAD __thread
1786 #else
1787 # define THREAD
1788 #endif
1790 static THREAD int tls_var;
1792 int main(void) { return tls_var; }
1795 if compile_prog "-fPIE -DPIE" "-pie"; then
1796 QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
1797 LDFLAGS="-pie $LDFLAGS"
1798 pie="yes"
1799 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1800 LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
1802 else
1803 if test "$pie" = "yes"; then
1804 error_exit "PIE not available due to missing toolchain support"
1805 else
1806 echo "Disabling PIE due to missing toolchain support"
1807 pie="no"
1811 if compile_prog "-Werror -fno-pie" "-nopie"; then
1812 CFLAGS_NOPIE="-fno-pie"
1813 LDFLAGS_NOPIE="-nopie"
1817 ##########################################
1818 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1819 # use i686 as default anyway, but for those that don't, an explicit
1820 # specification is necessary
1822 if test "$cpu" = "i386"; then
1823 cat > $TMPC << EOF
1824 static int sfaa(int *ptr)
1826 return __sync_fetch_and_and(ptr, 0);
1829 int main(void)
1831 int val = 42;
1832 val = __sync_val_compare_and_swap(&val, 0, 1);
1833 sfaa(&val);
1834 return val;
1837 if ! compile_prog "" "" ; then
1838 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1842 #########################################
1843 # Solaris specific configure tool chain decisions
1845 if test "$solaris" = "yes" ; then
1846 if has $install; then
1848 else
1849 error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
1850 "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
1851 "to get ginstall which is used by default (which lives in /opt/csw/bin)"
1853 if test "$(path_of $install)" = "/usr/sbin/install" ; then
1854 error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
1855 "try ginstall from the GNU fileutils available from www.blastwave.org" \
1856 "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
1858 if has ar; then
1860 else
1861 if test -f /usr/ccs/bin/ar ; then
1862 error_exit "No path includes ar" \
1863 "Add /usr/ccs/bin to your path and rerun configure"
1865 error_exit "No path includes ar"
1869 if test -z "${target_list+xxx}" ; then
1870 for target in $default_target_list; do
1871 supported_target $target 2>/dev/null && \
1872 target_list="$target_list $target"
1873 done
1874 target_list="${target_list# }"
1875 else
1876 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1877 for target in $target_list; do
1878 # Check that we recognised the target name; this allows a more
1879 # friendly error message than if we let it fall through.
1880 case " $default_target_list " in
1881 *" $target "*)
1884 error_exit "Unknown target name '$target'"
1886 esac
1887 supported_target $target || exit 1
1888 done
1891 # see if system emulation was really requested
1892 case " $target_list " in
1893 *"-softmmu "*) softmmu=yes
1895 *) softmmu=no
1897 esac
1899 feature_not_found() {
1900 feature=$1
1901 remedy=$2
1903 error_exit "User requested feature $feature" \
1904 "configure was not able to find it." \
1905 "$remedy"
1908 # ---
1909 # big/little endian test
1910 cat > $TMPC << EOF
1911 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1912 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1913 extern int foo(short *, short *);
1914 int main(int argc, char *argv[]) {
1915 return foo(big_endian, little_endian);
1919 if compile_object ; then
1920 if grep -q BiGeNdIaN $TMPO ; then
1921 bigendian="yes"
1922 elif grep -q LiTtLeEnDiAn $TMPO ; then
1923 bigendian="no"
1924 else
1925 echo big/little test failed
1927 else
1928 echo big/little test failed
1931 ##########################################
1932 # cocoa implies not SDL or GTK
1933 # (the cocoa UI code currently assumes it is always the active UI
1934 # and doesn't interact well with other UI frontend code)
1935 if test "$cocoa" = "yes"; then
1936 if test "$sdl" = "yes"; then
1937 error_exit "Cocoa and SDL UIs cannot both be enabled at once"
1939 if test "$gtk" = "yes"; then
1940 error_exit "Cocoa and GTK UIs cannot both be enabled at once"
1942 gtk=no
1943 sdl=no
1946 # Some versions of Mac OS X incorrectly define SIZE_MAX
1947 cat > $TMPC << EOF
1948 #include <stdint.h>
1949 #include <stdio.h>
1950 int main(int argc, char *argv[]) {
1951 return printf("%zu", SIZE_MAX);
1954 have_broken_size_max=no
1955 if ! compile_object -Werror ; then
1956 have_broken_size_max=yes
1959 ##########################################
1960 # L2TPV3 probe
1962 cat > $TMPC <<EOF
1963 #include <sys/socket.h>
1964 #include <linux/ip.h>
1965 int main(void) { return sizeof(struct mmsghdr); }
1967 if compile_prog "" "" ; then
1968 l2tpv3=yes
1969 else
1970 l2tpv3=no
1973 ##########################################
1974 # MinGW / Mingw-w64 localtime_r/gmtime_r check
1976 if test "$mingw32" = "yes"; then
1977 # Some versions of MinGW / Mingw-w64 lack localtime_r
1978 # and gmtime_r entirely.
1980 # Some versions of Mingw-w64 define a macro for
1981 # localtime_r/gmtime_r.
1983 # Some versions of Mingw-w64 will define functions
1984 # for localtime_r/gmtime_r, but only if you have
1985 # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
1986 # though, unistd.h and pthread.h both define
1987 # that for you.
1989 # So this #undef localtime_r and #include <unistd.h>
1990 # are not in fact redundant.
1991 cat > $TMPC << EOF
1992 #include <unistd.h>
1993 #include <time.h>
1994 #undef localtime_r
1995 int main(void) { localtime_r(NULL, NULL); return 0; }
1997 if compile_prog "" "" ; then
1998 localtime_r="yes"
1999 else
2000 localtime_r="no"
2004 ##########################################
2005 # pkg-config probe
2007 if ! has "$pkg_config_exe"; then
2008 error_exit "pkg-config binary '$pkg_config_exe' not found"
2011 ##########################################
2012 # NPTL probe
2014 if test "$linux_user" = "yes"; then
2015 cat > $TMPC <<EOF
2016 #include <sched.h>
2017 #include <linux/futex.h>
2018 int main(void) {
2019 #if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2020 #error bork
2021 #endif
2022 return 0;
2025 if ! compile_object ; then
2026 feature_not_found "nptl" "Install glibc and linux kernel headers."
2030 ##########################################
2031 # lzo check
2033 if test "$lzo" != "no" ; then
2034 cat > $TMPC << EOF
2035 #include <lzo/lzo1x.h>
2036 int main(void) { lzo_version(); return 0; }
2038 if compile_prog "" "-llzo2" ; then
2039 libs_softmmu="$libs_softmmu -llzo2"
2040 lzo="yes"
2041 else
2042 if test "$lzo" = "yes"; then
2043 feature_not_found "liblzo2" "Install liblzo2 devel"
2045 lzo="no"
2049 ##########################################
2050 # snappy check
2052 if test "$snappy" != "no" ; then
2053 cat > $TMPC << EOF
2054 #include <snappy-c.h>
2055 int main(void) { snappy_max_compressed_length(4096); return 0; }
2057 if compile_prog "" "-lsnappy" ; then
2058 libs_softmmu="$libs_softmmu -lsnappy"
2059 snappy="yes"
2060 else
2061 if test "$snappy" = "yes"; then
2062 feature_not_found "libsnappy" "Install libsnappy devel"
2064 snappy="no"
2068 ##########################################
2069 # bzip2 check
2071 if test "$bzip2" != "no" ; then
2072 cat > $TMPC << EOF
2073 #include <bzlib.h>
2074 int main(void) { BZ2_bzlibVersion(); return 0; }
2076 if compile_prog "" "-lbz2" ; then
2077 bzip2="yes"
2078 else
2079 if test "$bzip2" = "yes"; then
2080 feature_not_found "libbzip2" "Install libbzip2 devel"
2082 bzip2="no"
2086 ##########################################
2087 # libseccomp check
2089 if test "$seccomp" != "no" ; then
2090 case "$cpu" in
2091 i386|x86_64)
2092 libseccomp_minver="2.1.0"
2094 mips)
2095 libseccomp_minver="2.2.0"
2097 arm|aarch64)
2098 libseccomp_minver="2.2.3"
2100 ppc|ppc64|s390x)
2101 libseccomp_minver="2.3.0"
2104 libseccomp_minver=""
2106 esac
2108 if test "$libseccomp_minver" != "" &&
2109 $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2110 seccomp_cflags="$($pkg_config --cflags libseccomp)"
2111 seccomp_libs="$($pkg_config --libs libseccomp)"
2112 seccomp="yes"
2113 else
2114 if test "$seccomp" = "yes" ; then
2115 if test "$libseccomp_minver" != "" ; then
2116 feature_not_found "libseccomp" \
2117 "Install libseccomp devel >= $libseccomp_minver"
2118 else
2119 feature_not_found "libseccomp" \
2120 "libseccomp is not supported for host cpu $cpu"
2123 seccomp="no"
2126 ##########################################
2127 # xen probe
2129 if test "$xen" != "no" ; then
2130 # Check whether Xen library path is specified via --extra-ldflags to avoid
2131 # overriding this setting with pkg-config output. If not, try pkg-config
2132 # to obtain all needed flags.
2134 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2135 $pkg_config --exists xencontrol ; then
2136 xen_ctrl_version="$(printf '%d%02d%02d' \
2137 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2138 xen=yes
2139 xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2140 xen_pc="$xen_pc xenevtchn xendevicemodel"
2141 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2142 libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2143 LDFLAGS="$($pkg_config --libs $xen_pc) $LDFLAGS"
2144 else
2146 xen_libs="-lxenstore -lxenctrl -lxenguest"
2147 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2149 # First we test whether Xen headers and libraries are available.
2150 # If no, we are done and there is no Xen support.
2151 # If yes, more tests are run to detect the Xen version.
2153 # Xen (any)
2154 cat > $TMPC <<EOF
2155 #include <xenctrl.h>
2156 int main(void) {
2157 return 0;
2160 if ! compile_prog "" "$xen_libs" ; then
2161 # Xen not found
2162 if test "$xen" = "yes" ; then
2163 feature_not_found "xen" "Install xen devel"
2165 xen=no
2167 # Xen unstable
2168 elif
2169 cat > $TMPC <<EOF &&
2170 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2171 #include <xenforeignmemory.h>
2172 int main(void) {
2173 xenforeignmemory_handle *xfmem;
2175 xfmem = xenforeignmemory_open(0, 0);
2176 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
2178 return 0;
2181 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2182 then
2183 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2184 xen_ctrl_version=41000
2185 xen=yes
2186 elif
2187 cat > $TMPC <<EOF &&
2188 #undef XC_WANT_COMPAT_DEVICEMODEL_API
2189 #define __XEN_TOOLS__
2190 #include <xendevicemodel.h>
2191 int main(void) {
2192 xendevicemodel_handle *xd;
2194 xd = xendevicemodel_open(0, 0);
2195 xendevicemodel_close(xd);
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=40900
2204 xen=yes
2205 elif
2206 cat > $TMPC <<EOF &&
2208 * If we have stable libs the we don't want the libxc compat
2209 * layers, regardless of what CFLAGS we may have been given.
2211 * Also, check if xengnttab_grant_copy_segment_t is defined and
2212 * grant copy operation is implemented.
2214 #undef XC_WANT_COMPAT_EVTCHN_API
2215 #undef XC_WANT_COMPAT_GNTTAB_API
2216 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2217 #include <xenctrl.h>
2218 #include <xenstore.h>
2219 #include <xenevtchn.h>
2220 #include <xengnttab.h>
2221 #include <xenforeignmemory.h>
2222 #include <stdint.h>
2223 #include <xen/hvm/hvm_info_table.h>
2224 #if !defined(HVM_MAX_VCPUS)
2225 # error HVM_MAX_VCPUS not defined
2226 #endif
2227 int main(void) {
2228 xc_interface *xc = NULL;
2229 xenforeignmemory_handle *xfmem;
2230 xenevtchn_handle *xe;
2231 xengnttab_handle *xg;
2232 xen_domain_handle_t handle;
2233 xengnttab_grant_copy_segment_t* seg = NULL;
2235 xs_daemon_open();
2237 xc = xc_interface_open(0, 0, 0);
2238 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2239 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2240 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2241 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2242 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2244 xfmem = xenforeignmemory_open(0, 0);
2245 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2247 xe = xenevtchn_open(0, 0);
2248 xenevtchn_fd(xe);
2250 xg = xengnttab_open(0, 0);
2251 xengnttab_grant_copy(xg, 0, seg);
2253 return 0;
2256 compile_prog "" "$xen_libs $xen_stable_libs"
2257 then
2258 xen_ctrl_version=40800
2259 xen=yes
2260 elif
2261 cat > $TMPC <<EOF &&
2263 * If we have stable libs the we don't want the libxc compat
2264 * layers, regardless of what CFLAGS we may have been given.
2266 #undef XC_WANT_COMPAT_EVTCHN_API
2267 #undef XC_WANT_COMPAT_GNTTAB_API
2268 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
2269 #include <xenctrl.h>
2270 #include <xenstore.h>
2271 #include <xenevtchn.h>
2272 #include <xengnttab.h>
2273 #include <xenforeignmemory.h>
2274 #include <stdint.h>
2275 #include <xen/hvm/hvm_info_table.h>
2276 #if !defined(HVM_MAX_VCPUS)
2277 # error HVM_MAX_VCPUS not defined
2278 #endif
2279 int main(void) {
2280 xc_interface *xc = NULL;
2281 xenforeignmemory_handle *xfmem;
2282 xenevtchn_handle *xe;
2283 xengnttab_handle *xg;
2284 xen_domain_handle_t handle;
2286 xs_daemon_open();
2288 xc = xc_interface_open(0, 0, 0);
2289 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2290 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2291 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2292 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2293 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2295 xfmem = xenforeignmemory_open(0, 0);
2296 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2298 xe = xenevtchn_open(0, 0);
2299 xenevtchn_fd(xe);
2301 xg = xengnttab_open(0, 0);
2302 xengnttab_map_grant_ref(xg, 0, 0, 0);
2304 return 0;
2307 compile_prog "" "$xen_libs $xen_stable_libs"
2308 then
2309 xen_ctrl_version=40701
2310 xen=yes
2311 elif
2312 cat > $TMPC <<EOF &&
2313 #include <xenctrl.h>
2314 #include <stdint.h>
2315 int main(void) {
2316 xc_interface *xc = NULL;
2317 xen_domain_handle_t handle;
2318 xc_domain_create(xc, 0, handle, 0, NULL, NULL);
2319 return 0;
2322 compile_prog "" "$xen_libs"
2323 then
2324 xen_ctrl_version=40700
2325 xen=yes
2327 # Xen 4.6
2328 elif
2329 cat > $TMPC <<EOF &&
2330 #include <xenctrl.h>
2331 #include <xenstore.h>
2332 #include <stdint.h>
2333 #include <xen/hvm/hvm_info_table.h>
2334 #if !defined(HVM_MAX_VCPUS)
2335 # error HVM_MAX_VCPUS not defined
2336 #endif
2337 int main(void) {
2338 xc_interface *xc;
2339 xs_daemon_open();
2340 xc = xc_interface_open(0, 0, 0);
2341 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2342 xc_gnttab_open(NULL, 0);
2343 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2344 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2345 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2346 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2347 return 0;
2350 compile_prog "" "$xen_libs"
2351 then
2352 xen_ctrl_version=40600
2353 xen=yes
2355 # Xen 4.5
2356 elif
2357 cat > $TMPC <<EOF &&
2358 #include <xenctrl.h>
2359 #include <xenstore.h>
2360 #include <stdint.h>
2361 #include <xen/hvm/hvm_info_table.h>
2362 #if !defined(HVM_MAX_VCPUS)
2363 # error HVM_MAX_VCPUS not defined
2364 #endif
2365 int main(void) {
2366 xc_interface *xc;
2367 xs_daemon_open();
2368 xc = xc_interface_open(0, 0, 0);
2369 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2370 xc_gnttab_open(NULL, 0);
2371 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2372 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2373 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2374 return 0;
2377 compile_prog "" "$xen_libs"
2378 then
2379 xen_ctrl_version=40500
2380 xen=yes
2382 elif
2383 cat > $TMPC <<EOF &&
2384 #include <xenctrl.h>
2385 #include <xenstore.h>
2386 #include <stdint.h>
2387 #include <xen/hvm/hvm_info_table.h>
2388 #if !defined(HVM_MAX_VCPUS)
2389 # error HVM_MAX_VCPUS not defined
2390 #endif
2391 int main(void) {
2392 xc_interface *xc;
2393 xs_daemon_open();
2394 xc = xc_interface_open(0, 0, 0);
2395 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2396 xc_gnttab_open(NULL, 0);
2397 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2398 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2399 return 0;
2402 compile_prog "" "$xen_libs"
2403 then
2404 xen_ctrl_version=40200
2405 xen=yes
2407 else
2408 if test "$xen" = "yes" ; then
2409 feature_not_found "xen (unsupported version)" \
2410 "Install a supported xen (xen 4.2 or newer)"
2412 xen=no
2415 if test "$xen" = yes; then
2416 if test $xen_ctrl_version -ge 40701 ; then
2417 libs_softmmu="$xen_stable_libs $libs_softmmu"
2419 libs_softmmu="$xen_libs $libs_softmmu"
2424 if test "$xen_pci_passthrough" != "no"; then
2425 if test "$xen" = "yes" && test "$linux" = "yes"; then
2426 xen_pci_passthrough=yes
2427 else
2428 if test "$xen_pci_passthrough" = "yes"; then
2429 error_exit "User requested feature Xen PCI Passthrough" \
2430 " but this feature requires /sys from Linux"
2432 xen_pci_passthrough=no
2436 if test "$xen_pv_domain_build" = "yes" &&
2437 test "$xen" != "yes"; then
2438 error_exit "User requested Xen PV domain builder support" \
2439 "which requires Xen support."
2442 ##########################################
2443 # Sparse probe
2444 if test "$sparse" != "no" ; then
2445 if has cgcc; then
2446 sparse=yes
2447 else
2448 if test "$sparse" = "yes" ; then
2449 feature_not_found "sparse" "Install sparse binary"
2451 sparse=no
2455 ##########################################
2456 # X11 probe
2457 x11_cflags=
2458 x11_libs=-lX11
2459 if $pkg_config --exists "x11"; then
2460 x11_cflags=$($pkg_config --cflags x11)
2461 x11_libs=$($pkg_config --libs x11)
2464 ##########################################
2465 # GTK probe
2467 if test "$gtkabi" = ""; then
2468 # The GTK ABI was not specified explicitly, so try whether 3.0 is available.
2469 # Use 2.0 as a fallback if that is available.
2470 if $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
2471 gtkabi=3.0
2472 elif $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
2473 gtkabi=2.0
2474 else
2475 gtkabi=3.0
2479 if test "$gtk" != "no"; then
2480 gtkpackage="gtk+-$gtkabi"
2481 gtkx11package="gtk+-x11-$gtkabi"
2482 if test "$gtkabi" = "3.0" ; then
2483 gtkversion="3.0.0"
2484 else
2485 gtkversion="2.18.0"
2487 if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
2488 gtk_cflags=$($pkg_config --cflags $gtkpackage)
2489 gtk_libs=$($pkg_config --libs $gtkpackage)
2490 gtk_version=$($pkg_config --modversion $gtkpackage)
2491 if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
2492 gtk_cflags="$gtk_cflags $x11_cflags"
2493 gtk_libs="$gtk_libs $x11_libs"
2495 libs_softmmu="$gtk_libs $libs_softmmu"
2496 gtk="yes"
2497 elif test "$gtk" = "yes"; then
2498 feature_not_found "gtk" "Install gtk3-devel"
2499 else
2500 gtk="no"
2505 ##########################################
2506 # GNUTLS probe
2508 gnutls_works() {
2509 # Unfortunately some distros have bad pkg-config information for gnutls
2510 # such that it claims to exist but you get a compiler error if you try
2511 # to use the options returned by --libs. Specifically, Ubuntu for --static
2512 # builds doesn't work:
2513 # https://bugs.launchpad.net/ubuntu/+source/gnutls26/+bug/1478035
2515 # So sanity check the cflags/libs before assuming gnutls can be used.
2516 if ! $pkg_config --exists "gnutls"; then
2517 return 1
2520 write_c_skeleton
2521 compile_prog "$($pkg_config --cflags gnutls)" "$($pkg_config --libs gnutls)"
2524 gnutls_gcrypt=no
2525 gnutls_nettle=no
2526 if test "$gnutls" != "no"; then
2527 if gnutls_works; then
2528 gnutls_cflags=$($pkg_config --cflags gnutls)
2529 gnutls_libs=$($pkg_config --libs gnutls)
2530 libs_softmmu="$gnutls_libs $libs_softmmu"
2531 libs_tools="$gnutls_libs $libs_tools"
2532 QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
2533 gnutls="yes"
2535 # gnutls_rnd requires >= 2.11.0
2536 if $pkg_config --exists "gnutls >= 2.11.0"; then
2537 gnutls_rnd="yes"
2538 else
2539 gnutls_rnd="no"
2542 if $pkg_config --exists 'gnutls >= 3.0'; then
2543 gnutls_gcrypt=no
2544 gnutls_nettle=yes
2545 elif $pkg_config --exists 'gnutls >= 2.12'; then
2546 case $($pkg_config --libs --static gnutls) in
2547 *gcrypt*)
2548 gnutls_gcrypt=yes
2549 gnutls_nettle=no
2551 *nettle*)
2552 gnutls_gcrypt=no
2553 gnutls_nettle=yes
2556 gnutls_gcrypt=yes
2557 gnutls_nettle=no
2559 esac
2560 else
2561 gnutls_gcrypt=yes
2562 gnutls_nettle=no
2564 elif test "$gnutls" = "yes"; then
2565 feature_not_found "gnutls" "Install gnutls devel"
2566 else
2567 gnutls="no"
2568 gnutls_rnd="no"
2570 else
2571 gnutls_rnd="no"
2575 # If user didn't give a --disable/enable-gcrypt flag,
2576 # then mark as disabled if user requested nettle
2577 # explicitly, or if gnutls links to nettle
2578 if test -z "$gcrypt"
2579 then
2580 if test "$nettle" = "yes" || test "$gnutls_nettle" = "yes"
2581 then
2582 gcrypt="no"
2586 # If user didn't give a --disable/enable-nettle flag,
2587 # then mark as disabled if user requested gcrypt
2588 # explicitly, or if gnutls links to gcrypt
2589 if test -z "$nettle"
2590 then
2591 if test "$gcrypt" = "yes" || test "$gnutls_gcrypt" = "yes"
2592 then
2593 nettle="no"
2597 has_libgcrypt_config() {
2598 if ! has "libgcrypt-config"
2599 then
2600 return 1
2603 if test -n "$cross_prefix"
2604 then
2605 host=$(libgcrypt-config --host)
2606 if test "$host-" != $cross_prefix
2607 then
2608 return 1
2612 return 0
2615 if test "$gcrypt" != "no"; then
2616 if has_libgcrypt_config; then
2617 gcrypt_cflags=$(libgcrypt-config --cflags)
2618 gcrypt_libs=$(libgcrypt-config --libs)
2619 # Debian has remove -lgpg-error from libgcrypt-config
2620 # as it "spreads unnecessary dependencies" which in
2621 # turn breaks static builds...
2622 if test "$static" = "yes"
2623 then
2624 gcrypt_libs="$gcrypt_libs -lgpg-error"
2626 libs_softmmu="$gcrypt_libs $libs_softmmu"
2627 libs_tools="$gcrypt_libs $libs_tools"
2628 QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
2629 gcrypt="yes"
2630 if test -z "$nettle"; then
2631 nettle="no"
2634 cat > $TMPC << EOF
2635 #include <gcrypt.h>
2636 int main(void) {
2637 gcry_kdf_derive(NULL, 0, GCRY_KDF_PBKDF2,
2638 GCRY_MD_SHA256,
2639 NULL, 0, 0, 0, NULL);
2640 return 0;
2643 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2644 gcrypt_kdf=yes
2647 cat > $TMPC << EOF
2648 #include <gcrypt.h>
2649 int main(void) {
2650 gcry_mac_hd_t handle;
2651 gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
2652 GCRY_MAC_FLAG_SECURE, NULL);
2653 return 0;
2656 if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2657 gcrypt_hmac=yes
2659 else
2660 if test "$gcrypt" = "yes"; then
2661 feature_not_found "gcrypt" "Install gcrypt devel"
2662 else
2663 gcrypt="no"
2669 if test "$nettle" != "no"; then
2670 if $pkg_config --exists "nettle"; then
2671 nettle_cflags=$($pkg_config --cflags nettle)
2672 nettle_libs=$($pkg_config --libs nettle)
2673 nettle_version=$($pkg_config --modversion nettle)
2674 libs_softmmu="$nettle_libs $libs_softmmu"
2675 libs_tools="$nettle_libs $libs_tools"
2676 QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
2677 nettle="yes"
2679 cat > $TMPC << EOF
2680 #include <stddef.h>
2681 #include <nettle/pbkdf2.h>
2682 int main(void) {
2683 pbkdf2_hmac_sha256(8, NULL, 1000, 8, NULL, 8, NULL);
2684 return 0;
2687 if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2688 nettle_kdf=yes
2690 else
2691 if test "$nettle" = "yes"; then
2692 feature_not_found "nettle" "Install nettle devel"
2693 else
2694 nettle="no"
2699 if test "$gcrypt" = "yes" && test "$nettle" = "yes"
2700 then
2701 error_exit "Only one of gcrypt & nettle can be enabled"
2704 ##########################################
2705 # libtasn1 - only for the TLS creds/session test suite
2707 tasn1=yes
2708 tasn1_cflags=""
2709 tasn1_libs=""
2710 if $pkg_config --exists "libtasn1"; then
2711 tasn1_cflags=$($pkg_config --cflags libtasn1)
2712 tasn1_libs=$($pkg_config --libs libtasn1)
2713 else
2714 tasn1=no
2718 ##########################################
2719 # getifaddrs (for tests/test-io-channel-socket )
2721 have_ifaddrs_h=yes
2722 if ! check_include "ifaddrs.h" ; then
2723 have_ifaddrs_h=no
2726 ##########################################
2727 # VTE probe
2729 if test "$vte" != "no"; then
2730 if test "$gtkabi" = "3.0"; then
2731 vteminversion="0.32.0"
2732 if $pkg_config --exists "vte-2.91"; then
2733 vtepackage="vte-2.91"
2734 else
2735 vtepackage="vte-2.90"
2737 else
2738 vtepackage="vte"
2739 vteminversion="0.24.0"
2741 if $pkg_config --exists "$vtepackage >= $vteminversion"; then
2742 vte_cflags=$($pkg_config --cflags $vtepackage)
2743 vte_libs=$($pkg_config --libs $vtepackage)
2744 vteversion=$($pkg_config --modversion $vtepackage)
2745 libs_softmmu="$vte_libs $libs_softmmu"
2746 vte="yes"
2747 elif test "$vte" = "yes"; then
2748 if test "$gtkabi" = "3.0"; then
2749 feature_not_found "vte" "Install libvte-2.90/2.91 devel"
2750 else
2751 feature_not_found "vte" "Install libvte devel"
2753 else
2754 vte="no"
2758 ##########################################
2759 # SDL probe
2761 # Look for sdl configuration program (pkg-config or sdl-config). Try
2762 # sdl-config even without cross prefix, and favour pkg-config over sdl-config.
2764 if test "$sdlabi" = ""; then
2765 if $pkg_config --exists "sdl2"; then
2766 sdlabi=2.0
2767 elif $pkg_config --exists "sdl"; then
2768 sdlabi=1.2
2769 else
2770 sdlabi=2.0
2774 if test $sdlabi = "2.0"; then
2775 sdl_config=$sdl2_config
2776 sdlname=sdl2
2777 sdlconfigname=sdl2_config
2778 elif test $sdlabi = "1.2"; then
2779 sdlname=sdl
2780 sdlconfigname=sdl_config
2781 else
2782 error_exit "Unknown sdlabi $sdlabi, must be 1.2 or 2.0"
2785 if test "$(basename $sdl_config)" != $sdlconfigname && ! has ${sdl_config}; then
2786 sdl_config=$sdlconfigname
2789 if $pkg_config $sdlname --exists; then
2790 sdlconfig="$pkg_config $sdlname"
2791 sdlversion=$($sdlconfig --modversion 2>/dev/null)
2792 elif has ${sdl_config}; then
2793 sdlconfig="$sdl_config"
2794 sdlversion=$($sdlconfig --version)
2795 else
2796 if test "$sdl" = "yes" ; then
2797 feature_not_found "sdl" "Install SDL2-devel"
2799 sdl=no
2801 if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl-config; then
2802 echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
2805 sdl_too_old=no
2806 if test "$sdl" != "no" ; then
2807 cat > $TMPC << EOF
2808 #include <SDL.h>
2809 #undef main /* We don't want SDL to override our main() */
2810 int main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
2812 sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
2813 if test "$static" = "yes" ; then
2814 if $pkg_config $sdlname --exists; then
2815 sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null)
2816 else
2817 sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
2819 else
2820 sdl_libs=$($sdlconfig --libs 2>/dev/null)
2822 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2823 if test $(echo $sdlversion | sed 's/[^0-9]//g') -lt 121 ; then
2824 sdl_too_old=yes
2825 else
2826 sdl=yes
2829 # static link with sdl ? (note: sdl.pc's --static --libs is broken)
2830 if test "$sdl" = "yes" -a "$static" = "yes" ; then
2831 if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
2832 sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
2833 sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
2835 if compile_prog "$sdl_cflags" "$sdl_libs" ; then
2837 else
2838 sdl=no
2840 fi # static link
2841 else # sdl not found
2842 if test "$sdl" = "yes" ; then
2843 feature_not_found "sdl" "Install SDL devel"
2845 sdl=no
2846 fi # sdl compile test
2849 if test "$sdl" = "yes" ; then
2850 cat > $TMPC <<EOF
2851 #include <SDL.h>
2852 #if defined(SDL_VIDEO_DRIVER_X11)
2853 #include <X11/XKBlib.h>
2854 #else
2855 #error No x11 support
2856 #endif
2857 int main(void) { return 0; }
2859 if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
2860 sdl_cflags="$sdl_cflags $x11_cflags"
2861 sdl_libs="$sdl_libs $x11_libs"
2865 ##########################################
2866 # RDMA needs OpenFabrics libraries
2867 if test "$rdma" != "no" ; then
2868 cat > $TMPC <<EOF
2869 #include <rdma/rdma_cma.h>
2870 int main(void) { return 0; }
2872 rdma_libs="-lrdmacm -libverbs"
2873 if compile_prog "" "$rdma_libs" ; then
2874 rdma="yes"
2875 else
2876 if test "$rdma" = "yes" ; then
2877 error_exit \
2878 " OpenFabrics librdmacm/libibverbs not present." \
2879 " Your options:" \
2880 " (1) Fast: Install infiniband packages from your distro." \
2881 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2882 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2884 rdma="no"
2888 ##########################################
2889 # VNC SASL detection
2890 if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
2891 cat > $TMPC <<EOF
2892 #include <sasl/sasl.h>
2893 #include <stdio.h>
2894 int main(void) { sasl_server_init(NULL, "qemu"); return 0; }
2896 # Assuming Cyrus-SASL installed in /usr prefix
2897 vnc_sasl_cflags=""
2898 vnc_sasl_libs="-lsasl2"
2899 if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
2900 vnc_sasl=yes
2901 libs_softmmu="$vnc_sasl_libs $libs_softmmu"
2902 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
2903 else
2904 if test "$vnc_sasl" = "yes" ; then
2905 feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
2907 vnc_sasl=no
2911 ##########################################
2912 # VNC JPEG detection
2913 if test "$vnc" = "yes" -a "$vnc_jpeg" != "no" ; then
2914 if $pkg_config --exists libjpeg; then
2915 vnc_jpeg=yes
2916 libs_softmmu="$libs_softmmu $($pkg_config --libs libjpeg)"
2917 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags libjpeg)"
2918 else
2919 cat > $TMPC <<EOF
2920 #include <stdio.h>
2921 #include <jpeglib.h>
2922 int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
2924 vnc_jpeg_cflags=""
2925 vnc_jpeg_libs="-ljpeg"
2926 if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
2927 vnc_jpeg=yes
2928 libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
2929 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
2930 else
2931 if test "$vnc_jpeg" = "yes" ; then
2932 feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
2934 vnc_jpeg=no
2939 ##########################################
2940 # VNC PNG detection
2941 if test "$vnc" = "yes" -a "$vnc_png" != "no" ; then
2942 cat > $TMPC <<EOF
2943 //#include <stdio.h>
2944 #include <png.h>
2945 #include <stddef.h>
2946 int main(void) {
2947 png_structp png_ptr;
2948 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
2949 return png_ptr != 0;
2952 if $pkg_config libpng --exists; then
2953 vnc_png_cflags=$($pkg_config libpng --cflags)
2954 vnc_png_libs=$($pkg_config libpng --libs)
2955 else
2956 vnc_png_cflags=""
2957 vnc_png_libs="-lpng"
2959 if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
2960 vnc_png=yes
2961 libs_softmmu="$vnc_png_libs $libs_softmmu"
2962 QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
2963 else
2964 if test "$vnc_png" = "yes" ; then
2965 feature_not_found "vnc-png" "Install libpng devel"
2967 vnc_png=no
2971 ##########################################
2972 # xkbcommon probe
2973 if test "$xkbcommon" != "no" ; then
2974 if $pkg_config xkbcommon --exists; then
2975 xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
2976 xkbcommon_libs=$($pkg_config xkbcommon --libs)
2977 xkbcommon=yes
2978 else
2979 if test "$xkbcommon" = "yes" ; then
2980 feature_not_found "xkbcommon" "Install libxkbcommon-devel"
2982 xkbcommon=no
2986 ##########################################
2987 # fnmatch() probe, used for ACL routines
2988 fnmatch="no"
2989 cat > $TMPC << EOF
2990 #include <fnmatch.h>
2991 int main(void)
2993 fnmatch("foo", "foo", 0);
2994 return 0;
2997 if compile_prog "" "" ; then
2998 fnmatch="yes"
3001 ##########################################
3002 # xfsctl() probe, used for file-posix.c
3003 if test "$xfs" != "no" ; then
3004 cat > $TMPC << EOF
3005 #include <stddef.h> /* NULL */
3006 #include <xfs/xfs.h>
3007 int main(void)
3009 xfsctl(NULL, 0, 0, NULL);
3010 return 0;
3013 if compile_prog "" "" ; then
3014 xfs="yes"
3015 else
3016 if test "$xfs" = "yes" ; then
3017 feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3019 xfs=no
3023 ##########################################
3024 # vde libraries probe
3025 if test "$vde" != "no" ; then
3026 vde_libs="-lvdeplug"
3027 cat > $TMPC << EOF
3028 #include <stddef.h>
3029 #include <libvdeplug.h>
3030 int main(void)
3032 struct vde_open_args a = {0, 0, 0};
3033 char s[] = "";
3034 vde_open(s, s, &a);
3035 return 0;
3038 if compile_prog "" "$vde_libs" ; then
3039 vde=yes
3040 else
3041 if test "$vde" = "yes" ; then
3042 feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3044 vde=no
3048 ##########################################
3049 # netmap support probe
3050 # Apart from looking for netmap headers, we make sure that the host API version
3051 # supports the netmap backend (>=11). The upper bound (15) is meant to simulate
3052 # a minor/major version number. Minor new features will be marked with values up
3053 # to 15, and if something happens that requires a change to the backend we will
3054 # move above 15, submit the backend fixes and modify this two bounds.
3055 if test "$netmap" != "no" ; then
3056 cat > $TMPC << EOF
3057 #include <inttypes.h>
3058 #include <net/if.h>
3059 #include <net/netmap.h>
3060 #include <net/netmap_user.h>
3061 #if (NETMAP_API < 11) || (NETMAP_API > 15)
3062 #error
3063 #endif
3064 int main(void) { return 0; }
3066 if compile_prog "" "" ; then
3067 netmap=yes
3068 else
3069 if test "$netmap" = "yes" ; then
3070 feature_not_found "netmap"
3072 netmap=no
3076 ##########################################
3077 # libcap-ng library probe
3078 if test "$cap_ng" != "no" ; then
3079 cap_libs="-lcap-ng"
3080 cat > $TMPC << EOF
3081 #include <cap-ng.h>
3082 int main(void)
3084 capng_capability_to_name(CAPNG_EFFECTIVE);
3085 return 0;
3088 if compile_prog "" "$cap_libs" ; then
3089 cap_ng=yes
3090 libs_tools="$cap_libs $libs_tools"
3091 else
3092 if test "$cap_ng" = "yes" ; then
3093 feature_not_found "cap_ng" "Install libcap-ng devel"
3095 cap_ng=no
3099 ##########################################
3100 # Sound support libraries probe
3102 audio_drv_probe()
3104 drv=$1
3105 hdr=$2
3106 lib=$3
3107 exp=$4
3108 cfl=$5
3109 cat > $TMPC << EOF
3110 #include <$hdr>
3111 int main(void) { $exp }
3113 if compile_prog "$cfl" "$lib" ; then
3115 else
3116 error_exit "$drv check failed" \
3117 "Make sure to have the $drv libs and headers installed."
3121 audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3122 for drv in $audio_drv_list; do
3123 case $drv in
3124 alsa)
3125 audio_drv_probe $drv alsa/asoundlib.h -lasound \
3126 "return snd_pcm_close((snd_pcm_t *)0);"
3127 alsa_libs="-lasound"
3131 audio_drv_probe $drv pulse/pulseaudio.h "-lpulse" \
3132 "pa_context_set_source_output_volume(NULL, 0, NULL, NULL, NULL); return 0;"
3133 pulse_libs="-lpulse"
3134 audio_pt_int="yes"
3137 sdl)
3138 if test "$sdl" = "no"; then
3139 error_exit "sdl not found or disabled, can not use sdl audio driver"
3143 coreaudio)
3144 coreaudio_libs="-framework CoreAudio"
3147 dsound)
3148 dsound_libs="-lole32 -ldxguid"
3149 audio_win_int="yes"
3152 oss)
3153 oss_libs="$oss_lib"
3156 wav)
3157 # XXX: Probes for CoreAudio, DirectSound
3161 echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
3162 error_exit "Unknown driver '$drv' selected" \
3163 "Possible drivers are: $audio_possible_drivers"
3166 esac
3167 done
3169 ##########################################
3170 # BrlAPI probe
3172 if test "$brlapi" != "no" ; then
3173 brlapi_libs="-lbrlapi"
3174 cat > $TMPC << EOF
3175 #include <brlapi.h>
3176 #include <stddef.h>
3177 int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
3179 if compile_prog "" "$brlapi_libs" ; then
3180 brlapi=yes
3181 else
3182 if test "$brlapi" = "yes" ; then
3183 feature_not_found "brlapi" "Install brlapi devel"
3185 brlapi=no
3189 ##########################################
3190 # curses probe
3191 if test "$curses" != "no" ; then
3192 if test "$mingw32" = "yes" ; then
3193 curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
3194 curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3195 else
3196 curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
3197 curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3199 curses_found=no
3200 cat > $TMPC << EOF
3201 #include <locale.h>
3202 #include <curses.h>
3203 #include <wchar.h>
3204 int main(void) {
3205 wchar_t wch = L'w';
3206 setlocale(LC_ALL, "");
3207 resize_term(0, 0);
3208 addwstr(L"wide chars\n");
3209 addnwstr(&wch, 1);
3210 add_wch(WACS_DEGREE);
3211 return 0;
3214 IFS=:
3215 for curses_inc in $curses_inc_list; do
3216 # Make sure we get the wide character prototypes
3217 curses_inc="-DNCURSES_WIDECHAR $curses_inc"
3218 IFS=:
3219 for curses_lib in $curses_lib_list; do
3220 unset IFS
3221 if compile_prog "$curses_inc" "$curses_lib" ; then
3222 curses_found=yes
3223 QEMU_CFLAGS="$curses_inc $QEMU_CFLAGS"
3224 libs_softmmu="$curses_lib $libs_softmmu"
3225 break
3227 done
3228 if test "$curses_found" = yes ; then
3229 break
3231 done
3232 unset IFS
3233 if test "$curses_found" = "yes" ; then
3234 curses=yes
3235 else
3236 if test "$curses" = "yes" ; then
3237 feature_not_found "curses" "Install ncurses devel"
3239 curses=no
3243 ##########################################
3244 # curl probe
3245 if test "$curl" != "no" ; then
3246 if $pkg_config libcurl --exists; then
3247 curlconfig="$pkg_config libcurl"
3248 else
3249 curlconfig=curl-config
3251 cat > $TMPC << EOF
3252 #include <curl/curl.h>
3253 int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3255 curl_cflags=$($curlconfig --cflags 2>/dev/null)
3256 curl_libs=$($curlconfig --libs 2>/dev/null)
3257 if compile_prog "$curl_cflags" "$curl_libs" ; then
3258 curl=yes
3259 else
3260 if test "$curl" = "yes" ; then
3261 feature_not_found "curl" "Install libcurl devel"
3263 curl=no
3265 fi # test "$curl"
3267 ##########################################
3268 # bluez support probe
3269 if test "$bluez" != "no" ; then
3270 cat > $TMPC << EOF
3271 #include <bluetooth/bluetooth.h>
3272 int main(void) { return bt_error(0); }
3274 bluez_cflags=$($pkg_config --cflags bluez 2>/dev/null)
3275 bluez_libs=$($pkg_config --libs bluez 2>/dev/null)
3276 if compile_prog "$bluez_cflags" "$bluez_libs" ; then
3277 bluez=yes
3278 libs_softmmu="$bluez_libs $libs_softmmu"
3279 else
3280 if test "$bluez" = "yes" ; then
3281 feature_not_found "bluez" "Install bluez-libs/libbluetooth devel"
3283 bluez="no"
3287 ##########################################
3288 # glib support probe
3290 if test "$mingw32" = yes; then
3291 glib_req_ver=2.30
3292 else
3293 glib_req_ver=2.22
3295 glib_modules=gthread-2.0
3296 if test "$modules" = yes; then
3297 glib_modules="$glib_modules gmodule-2.0"
3300 # This workaround is required due to a bug in pkg-config file for glib as it
3301 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3303 if test "$static" = yes -a "$mingw32" = yes; then
3304 QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
3307 for i in $glib_modules; do
3308 if $pkg_config --atleast-version=$glib_req_ver $i; then
3309 glib_cflags=$($pkg_config --cflags $i)
3310 glib_libs=$($pkg_config --libs $i)
3311 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
3312 LIBS="$glib_libs $LIBS"
3313 libs_qga="$glib_libs $libs_qga"
3314 else
3315 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3317 done
3319 # Sanity check that the current size_t matches the
3320 # size that glib thinks it should be. This catches
3321 # problems on multi-arch where people try to build
3322 # 32-bit QEMU while pointing at 64-bit glib headers
3323 cat > $TMPC <<EOF
3324 #include <glib.h>
3325 #include <unistd.h>
3327 #define QEMU_BUILD_BUG_ON(x) \
3328 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3330 int main(void) {
3331 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3332 return 0;
3336 if ! compile_prog "$CFLAGS" "$LIBS" ; then
3337 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3338 "You probably need to set PKG_CONFIG_LIBDIR"\
3339 "to point to the right pkg-config files for your"\
3340 "build target"
3343 # g_test_trap_subprocess added in 2.38. Used by some tests.
3344 glib_subprocess=yes
3345 if ! $pkg_config --atleast-version=2.38 glib-2.0; then
3346 glib_subprocess=no
3349 # Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3350 cat > $TMPC << EOF
3351 #include <glib.h>
3352 int main(void) { return 0; }
3354 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3355 if cc_has_warning_flag "-Wno-unknown-attributes"; then
3356 glib_cflags="-Wno-unknown-attributes $glib_cflags"
3357 CFLAGS="-Wno-unknown-attributes $CFLAGS"
3361 #########################################
3362 # zlib check
3364 if test "$zlib" != "no" ; then
3365 if $pkg_config --exists zlib; then
3366 zlib_cflags=$($pkg_config --cflags zlib)
3367 zlib_libs=$($pkg_config --libs zlib)
3368 QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
3369 LIBS="$zlib_libs $LIBS"
3370 else
3371 cat > $TMPC << EOF
3372 #include <zlib.h>
3373 int main(void) { zlibVersion(); return 0; }
3375 if compile_prog "" "-lz" ; then
3376 LIBS="$LIBS -lz"
3377 else
3378 error_exit "zlib check failed" \
3379 "Make sure to have the zlib libs and headers installed."
3384 ##########################################
3385 # SHA command probe for modules
3386 if test "$modules" = yes; then
3387 shacmd_probe="sha1sum sha1 shasum"
3388 for c in $shacmd_probe; do
3389 if has $c; then
3390 shacmd="$c"
3391 break
3393 done
3394 if test "$shacmd" = ""; then
3395 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3399 ##########################################
3400 # pixman support probe
3402 if test "$want_tools" = "no" -a "$softmmu" = "no"; then
3403 pixman_cflags=
3404 pixman_libs=
3405 elif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
3406 pixman_cflags=$($pkg_config --cflags pixman-1)
3407 pixman_libs=$($pkg_config --libs pixman-1)
3408 else
3409 error_exit "pixman >= 0.21.8 not present." \
3410 "Please install the pixman devel package."
3413 ##########################################
3414 # libmpathpersist probe
3416 if test "$mpath" != "no" ; then
3417 cat > $TMPC <<EOF
3418 #include <libudev.h>
3419 #include <mpath_persist.h>
3420 unsigned mpath_mx_alloc_len = 1024;
3421 int logsink;
3422 static struct config *multipath_conf;
3423 extern struct udev *udev;
3424 extern struct config *get_multipath_config(void);
3425 extern void put_multipath_config(struct config *conf);
3426 struct udev *udev;
3427 struct config *get_multipath_config(void) { return multipath_conf; }
3428 void put_multipath_config(struct config *conf) { }
3430 int main(void) {
3431 udev = udev_new();
3432 multipath_conf = mpath_lib_init();
3433 return 0;
3436 if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3437 mpathpersist=yes
3438 else
3439 mpathpersist=no
3441 else
3442 mpathpersist=no
3445 ##########################################
3446 # libcap probe
3448 if test "$cap" != "no" ; then
3449 cat > $TMPC <<EOF
3450 #include <stdio.h>
3451 #include <sys/capability.h>
3452 int main(void) { cap_t caps; caps = cap_init(); return caps != NULL; }
3454 if compile_prog "" "-lcap" ; then
3455 cap=yes
3456 else
3457 cap=no
3461 ##########################################
3462 # pthread probe
3463 PTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
3465 pthread=no
3466 cat > $TMPC << EOF
3467 #include <pthread.h>
3468 static void *f(void *p) { return NULL; }
3469 int main(void) {
3470 pthread_t thread;
3471 pthread_create(&thread, 0, f, 0);
3472 return 0;
3475 if compile_prog "" "" ; then
3476 pthread=yes
3477 else
3478 for pthread_lib in $PTHREADLIBS_LIST; do
3479 if compile_prog "" "$pthread_lib" ; then
3480 pthread=yes
3481 found=no
3482 for lib_entry in $LIBS; do
3483 if test "$lib_entry" = "$pthread_lib"; then
3484 found=yes
3485 break
3487 done
3488 if test "$found" = "no"; then
3489 LIBS="$pthread_lib $LIBS"
3491 PTHREAD_LIB="$pthread_lib"
3492 break
3494 done
3497 if test "$mingw32" != yes -a "$pthread" = no; then
3498 error_exit "pthread check failed" \
3499 "Make sure to have the pthread libs and headers installed."
3502 # check for pthread_setname_np
3503 pthread_setname_np=no
3504 cat > $TMPC << EOF
3505 #include <pthread.h>
3507 static void *f(void *p) { return NULL; }
3508 int main(void)
3510 pthread_t thread;
3511 pthread_create(&thread, 0, f, 0);
3512 pthread_setname_np(thread, "QEMU");
3513 return 0;
3516 if compile_prog "" "$pthread_lib" ; then
3517 pthread_setname_np=yes
3520 ##########################################
3521 # rbd probe
3522 if test "$rbd" != "no" ; then
3523 cat > $TMPC <<EOF
3524 #include <stdio.h>
3525 #include <rbd/librbd.h>
3526 int main(void) {
3527 rados_t cluster;
3528 rados_create(&cluster, NULL);
3529 return 0;
3532 rbd_libs="-lrbd -lrados"
3533 if compile_prog "" "$rbd_libs" ; then
3534 rbd=yes
3535 else
3536 if test "$rbd" = "yes" ; then
3537 feature_not_found "rados block device" "Install librbd/ceph devel"
3539 rbd=no
3543 ##########################################
3544 # libssh2 probe
3545 min_libssh2_version=1.2.8
3546 if test "$libssh2" != "no" ; then
3547 if $pkg_config --atleast-version=$min_libssh2_version libssh2; then
3548 libssh2_cflags=$($pkg_config libssh2 --cflags)
3549 libssh2_libs=$($pkg_config libssh2 --libs)
3550 libssh2=yes
3551 else
3552 if test "$libssh2" = "yes" ; then
3553 error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2"
3555 libssh2=no
3559 ##########################################
3560 # libssh2_sftp_fsync probe
3562 if test "$libssh2" = "yes"; then
3563 cat > $TMPC <<EOF
3564 #include <stdio.h>
3565 #include <libssh2.h>
3566 #include <libssh2_sftp.h>
3567 int main(void) {
3568 LIBSSH2_SESSION *session;
3569 LIBSSH2_SFTP *sftp;
3570 LIBSSH2_SFTP_HANDLE *sftp_handle;
3571 session = libssh2_session_init ();
3572 sftp = libssh2_sftp_init (session);
3573 sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0);
3574 libssh2_sftp_fsync (sftp_handle);
3575 return 0;
3578 # libssh2_cflags/libssh2_libs defined in previous test.
3579 if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then
3580 QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS"
3584 ##########################################
3585 # linux-aio probe
3587 if test "$linux_aio" != "no" ; then
3588 cat > $TMPC <<EOF
3589 #include <libaio.h>
3590 #include <sys/eventfd.h>
3591 #include <stddef.h>
3592 int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
3594 if compile_prog "" "-laio" ; then
3595 linux_aio=yes
3596 else
3597 if test "$linux_aio" = "yes" ; then
3598 feature_not_found "linux AIO" "Install libaio devel"
3600 linux_aio=no
3604 ##########################################
3605 # TPM passthrough is only on x86 Linux
3607 if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64; then
3608 tpm_passthrough=$tpm
3609 else
3610 tpm_passthrough=no
3613 # TPM emulator is for all posix systems
3614 if test "$mingw32" != "yes"; then
3615 tpm_emulator=$tpm
3616 else
3617 tpm_emulator=no
3619 ##########################################
3620 # attr probe
3622 if test "$attr" != "no" ; then
3623 cat > $TMPC <<EOF
3624 #include <stdio.h>
3625 #include <sys/types.h>
3626 #ifdef CONFIG_LIBATTR
3627 #include <attr/xattr.h>
3628 #else
3629 #include <sys/xattr.h>
3630 #endif
3631 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3633 if compile_prog "" "" ; then
3634 attr=yes
3635 # Older distros have <attr/xattr.h>, and need -lattr:
3636 elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3637 attr=yes
3638 LIBS="-lattr $LIBS"
3639 libattr=yes
3640 else
3641 if test "$attr" = "yes" ; then
3642 feature_not_found "ATTR" "Install libc6 or libattr devel"
3644 attr=no
3648 ##########################################
3649 # iovec probe
3650 cat > $TMPC <<EOF
3651 #include <sys/types.h>
3652 #include <sys/uio.h>
3653 #include <unistd.h>
3654 int main(void) { return sizeof(struct iovec); }
3656 iovec=no
3657 if compile_prog "" "" ; then
3658 iovec=yes
3661 ##########################################
3662 # preadv probe
3663 cat > $TMPC <<EOF
3664 #include <sys/types.h>
3665 #include <sys/uio.h>
3666 #include <unistd.h>
3667 int main(void) { return preadv(0, 0, 0, 0); }
3669 preadv=no
3670 if compile_prog "" "" ; then
3671 preadv=yes
3674 ##########################################
3675 # fdt probe
3676 # fdt support is mandatory for at least some target architectures,
3677 # so insist on it if we're building those system emulators.
3678 fdt_required=no
3679 for target in $target_list; do
3680 case $target in
3681 aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu)
3682 fdt_required=yes
3684 esac
3685 done
3687 if test "$fdt_required" = "yes"; then
3688 if test "$fdt" = "no"; then
3689 error_exit "fdt disabled but some requested targets require it." \
3690 "You can turn off fdt only if you also disable all the system emulation" \
3691 "targets which need it (by specifying a cut down --target-list)."
3693 fdt=yes
3696 if test "$fdt" != "no" ; then
3697 fdt_libs="-lfdt"
3698 # explicitly check for libfdt_env.h as it is missing in some stable installs
3699 # and test for required functions to make sure we are on a version >= 1.4.2
3700 cat > $TMPC << EOF
3701 #include <libfdt.h>
3702 #include <libfdt_env.h>
3703 int main(void) { fdt_first_subnode(0, 0); return 0; }
3705 if compile_prog "" "$fdt_libs" ; then
3706 # system DTC is good - use it
3707 fdt=yes
3708 else
3709 # have GIT checkout, so activate dtc submodule
3710 if test -e "${source_path}/.git" ; then
3711 git_submodules="${git_submodules} dtc"
3713 if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
3714 fdt=yes
3715 dtc_internal="yes"
3716 mkdir -p dtc
3717 if [ "$pwd_is_source_path" != "y" ] ; then
3718 symlink "$source_path/dtc/Makefile" "dtc/Makefile"
3719 symlink "$source_path/dtc/scripts" "dtc/scripts"
3721 fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
3722 fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
3723 elif test "$fdt" = "yes" ; then
3724 # Not a git build & no libfdt found, prompt for system install
3725 error_exit "DTC (libfdt) version >= 1.4.2 not present." \
3726 "Please install the DTC (libfdt) devel package"
3727 else
3728 # don't have and don't want
3729 fdt_libs=
3730 fdt=no
3735 libs_softmmu="$libs_softmmu $fdt_libs"
3737 ##########################################
3738 # opengl probe (for sdl2, gtk, milkymist-tmu2)
3740 if test "$opengl" != "no" ; then
3741 opengl_pkgs="epoxy libdrm gbm"
3742 if $pkg_config $opengl_pkgs x11; then
3743 opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
3744 opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
3745 opengl=yes
3746 if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3747 gtk_gl="yes"
3749 QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
3750 else
3751 if test "$opengl" = "yes" ; then
3752 feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
3754 opengl_cflags=""
3755 opengl_libs=""
3756 opengl=no
3760 if test "$opengl" = "yes"; then
3761 cat > $TMPC << EOF
3762 #include <epoxy/egl.h>
3763 #ifndef EGL_MESA_image_dma_buf_export
3764 # error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3765 #endif
3766 int main(void) { return 0; }
3768 if compile_prog "" "" ; then
3769 opengl_dmabuf=yes
3774 ##########################################
3775 # glusterfs probe
3776 if test "$glusterfs" != "no" ; then
3777 if $pkg_config --atleast-version=3 glusterfs-api; then
3778 glusterfs="yes"
3779 glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
3780 glusterfs_libs=$($pkg_config --libs glusterfs-api)
3781 if $pkg_config --atleast-version=4 glusterfs-api; then
3782 glusterfs_xlator_opt="yes"
3784 if $pkg_config --atleast-version=5 glusterfs-api; then
3785 glusterfs_discard="yes"
3787 if $pkg_config --atleast-version=6 glusterfs-api; then
3788 glusterfs_fallocate="yes"
3789 glusterfs_zerofill="yes"
3791 else
3792 if test "$glusterfs" = "yes" ; then
3793 feature_not_found "GlusterFS backend support" \
3794 "Install glusterfs-api devel >= 3"
3796 glusterfs="no"
3800 # Check for inotify functions when we are building linux-user
3801 # emulator. This is done because older glibc versions don't
3802 # have syscall stubs for these implemented. In that case we
3803 # don't provide them even if kernel supports them.
3805 inotify=no
3806 cat > $TMPC << EOF
3807 #include <sys/inotify.h>
3810 main(void)
3812 /* try to start inotify */
3813 return inotify_init();
3816 if compile_prog "" "" ; then
3817 inotify=yes
3820 inotify1=no
3821 cat > $TMPC << EOF
3822 #include <sys/inotify.h>
3825 main(void)
3827 /* try to start inotify */
3828 return inotify_init1(0);
3831 if compile_prog "" "" ; then
3832 inotify1=yes
3835 # check if pipe2 is there
3836 pipe2=no
3837 cat > $TMPC << EOF
3838 #include <unistd.h>
3839 #include <fcntl.h>
3841 int main(void)
3843 int pipefd[2];
3844 return pipe2(pipefd, O_CLOEXEC);
3847 if compile_prog "" "" ; then
3848 pipe2=yes
3851 # check if accept4 is there
3852 accept4=no
3853 cat > $TMPC << EOF
3854 #include <sys/socket.h>
3855 #include <stddef.h>
3857 int main(void)
3859 accept4(0, NULL, NULL, SOCK_CLOEXEC);
3860 return 0;
3863 if compile_prog "" "" ; then
3864 accept4=yes
3867 # check if tee/splice is there. vmsplice was added same time.
3868 splice=no
3869 cat > $TMPC << EOF
3870 #include <unistd.h>
3871 #include <fcntl.h>
3872 #include <limits.h>
3874 int main(void)
3876 int len, fd = 0;
3877 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
3878 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
3879 return 0;
3882 if compile_prog "" "" ; then
3883 splice=yes
3886 ##########################################
3887 # libnuma probe
3889 if test "$numa" != "no" ; then
3890 cat > $TMPC << EOF
3891 #include <numa.h>
3892 int main(void) { return numa_available(); }
3895 if compile_prog "" "-lnuma" ; then
3896 numa=yes
3897 libs_softmmu="-lnuma $libs_softmmu"
3898 else
3899 if test "$numa" = "yes" ; then
3900 feature_not_found "numa" "install numactl devel"
3902 numa=no
3906 if test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
3907 echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
3908 exit 1
3911 # Even if malloc_trim() is available, these non-libc memory allocators
3912 # do not support it.
3913 if test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
3914 if test "$malloc_trim" = "yes" ; then
3915 echo "Disabling malloc_trim with non-libc memory allocator"
3917 malloc_trim="no"
3920 #######################################
3921 # malloc_trim
3923 if test "$malloc_trim" != "no" ; then
3924 cat > $TMPC << EOF
3925 #include <malloc.h>
3926 int main(void) { malloc_trim(0); return 0; }
3928 if compile_prog "" "" ; then
3929 malloc_trim="yes"
3930 else
3931 malloc_trim="no"
3935 ##########################################
3936 # tcmalloc probe
3938 if test "$tcmalloc" = "yes" ; then
3939 cat > $TMPC << EOF
3940 #include <stdlib.h>
3941 int main(void) { malloc(1); return 0; }
3944 if compile_prog "" "-ltcmalloc" ; then
3945 LIBS="-ltcmalloc $LIBS"
3946 else
3947 feature_not_found "tcmalloc" "install gperftools devel"
3951 ##########################################
3952 # jemalloc probe
3954 if test "$jemalloc" = "yes" ; then
3955 cat > $TMPC << EOF
3956 #include <stdlib.h>
3957 int main(void) { malloc(1); return 0; }
3960 if compile_prog "" "-ljemalloc" ; then
3961 LIBS="-ljemalloc $LIBS"
3962 else
3963 feature_not_found "jemalloc" "install jemalloc devel"
3967 ##########################################
3968 # signalfd probe
3969 signalfd="no"
3970 cat > $TMPC << EOF
3971 #include <unistd.h>
3972 #include <sys/syscall.h>
3973 #include <signal.h>
3974 int main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3977 if compile_prog "" "" ; then
3978 signalfd=yes
3981 # check if eventfd is supported
3982 eventfd=no
3983 cat > $TMPC << EOF
3984 #include <sys/eventfd.h>
3986 int main(void)
3988 return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3991 if compile_prog "" "" ; then
3992 eventfd=yes
3995 # check if memfd is supported
3996 memfd=no
3997 cat > $TMPC << EOF
3998 #include <sys/mman.h>
4000 int main(void)
4002 return memfd_create("foo", MFD_ALLOW_SEALING);
4005 if compile_prog "" "" ; then
4006 memfd=yes
4011 # check for fallocate
4012 fallocate=no
4013 cat > $TMPC << EOF
4014 #include <fcntl.h>
4016 int main(void)
4018 fallocate(0, 0, 0, 0);
4019 return 0;
4022 if compile_prog "" "" ; then
4023 fallocate=yes
4026 # check for fallocate hole punching
4027 fallocate_punch_hole=no
4028 cat > $TMPC << EOF
4029 #include <fcntl.h>
4030 #include <linux/falloc.h>
4032 int main(void)
4034 fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
4035 return 0;
4038 if compile_prog "" "" ; then
4039 fallocate_punch_hole=yes
4042 # check that fallocate supports range zeroing inside the file
4043 fallocate_zero_range=no
4044 cat > $TMPC << EOF
4045 #include <fcntl.h>
4046 #include <linux/falloc.h>
4048 int main(void)
4050 fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4051 return 0;
4054 if compile_prog "" "" ; then
4055 fallocate_zero_range=yes
4058 # check for posix_fallocate
4059 posix_fallocate=no
4060 cat > $TMPC << EOF
4061 #include <fcntl.h>
4063 int main(void)
4065 posix_fallocate(0, 0, 0);
4066 return 0;
4069 if compile_prog "" "" ; then
4070 posix_fallocate=yes
4073 # check for sync_file_range
4074 sync_file_range=no
4075 cat > $TMPC << EOF
4076 #include <fcntl.h>
4078 int main(void)
4080 sync_file_range(0, 0, 0, 0);
4081 return 0;
4084 if compile_prog "" "" ; then
4085 sync_file_range=yes
4088 # check for linux/fiemap.h and FS_IOC_FIEMAP
4089 fiemap=no
4090 cat > $TMPC << EOF
4091 #include <sys/ioctl.h>
4092 #include <linux/fs.h>
4093 #include <linux/fiemap.h>
4095 int main(void)
4097 ioctl(0, FS_IOC_FIEMAP, 0);
4098 return 0;
4101 if compile_prog "" "" ; then
4102 fiemap=yes
4105 # check for dup3
4106 dup3=no
4107 cat > $TMPC << EOF
4108 #include <unistd.h>
4110 int main(void)
4112 dup3(0, 0, 0);
4113 return 0;
4116 if compile_prog "" "" ; then
4117 dup3=yes
4120 # check for ppoll support
4121 ppoll=no
4122 cat > $TMPC << EOF
4123 #include <poll.h>
4125 int main(void)
4127 struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
4128 ppoll(&pfd, 1, 0, 0);
4129 return 0;
4132 if compile_prog "" "" ; then
4133 ppoll=yes
4136 # check for prctl(PR_SET_TIMERSLACK , ... ) support
4137 prctl_pr_set_timerslack=no
4138 cat > $TMPC << EOF
4139 #include <sys/prctl.h>
4141 int main(void)
4143 prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4144 return 0;
4147 if compile_prog "" "" ; then
4148 prctl_pr_set_timerslack=yes
4151 # check for epoll support
4152 epoll=no
4153 cat > $TMPC << EOF
4154 #include <sys/epoll.h>
4156 int main(void)
4158 epoll_create(0);
4159 return 0;
4162 if compile_prog "" "" ; then
4163 epoll=yes
4166 # epoll_create1 is a later addition
4167 # so we must check separately for its presence
4168 epoll_create1=no
4169 cat > $TMPC << EOF
4170 #include <sys/epoll.h>
4172 int main(void)
4174 /* Note that we use epoll_create1 as a value, not as
4175 * a function being called. This is necessary so that on
4176 * old SPARC glibc versions where the function was present in
4177 * the library but not declared in the header file we will
4178 * fail the configure check. (Otherwise we will get a compiler
4179 * warning but not an error, and will proceed to fail the
4180 * qemu compile where we compile with -Werror.)
4182 return (int)(uintptr_t)&epoll_create1;
4185 if compile_prog "" "" ; then
4186 epoll_create1=yes
4189 # check for sendfile support
4190 sendfile=no
4191 cat > $TMPC << EOF
4192 #include <sys/sendfile.h>
4194 int main(void)
4196 return sendfile(0, 0, 0, 0);
4199 if compile_prog "" "" ; then
4200 sendfile=yes
4203 # check for timerfd support (glibc 2.8 and newer)
4204 timerfd=no
4205 cat > $TMPC << EOF
4206 #include <sys/timerfd.h>
4208 int main(void)
4210 return(timerfd_create(CLOCK_REALTIME, 0));
4213 if compile_prog "" "" ; then
4214 timerfd=yes
4217 # check for setns and unshare support
4218 setns=no
4219 cat > $TMPC << EOF
4220 #include <sched.h>
4222 int main(void)
4224 int ret;
4225 ret = setns(0, 0);
4226 ret = unshare(0);
4227 return ret;
4230 if compile_prog "" "" ; then
4231 setns=yes
4234 # clock_adjtime probe
4235 clock_adjtime=no
4236 cat > $TMPC <<EOF
4237 #include <time.h>
4239 int main(void)
4241 return clock_adjtime(0, 0);
4244 clock_adjtime=no
4245 if compile_prog "" "" ; then
4246 clock_adjtime=yes
4249 # syncfs probe
4250 syncfs=no
4251 cat > $TMPC <<EOF
4252 #include <unistd.h>
4254 int main(void)
4256 return syncfs(0);
4259 syncfs=no
4260 if compile_prog "" "" ; then
4261 syncfs=yes
4264 # Check if tools are available to build documentation.
4265 if test "$docs" != "no" ; then
4266 if has makeinfo && has pod2man; then
4267 docs=yes
4268 else
4269 if test "$docs" = "yes" ; then
4270 feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
4272 docs=no
4276 if test "$want_tools" = ""; then
4277 if test $(expr "$target_list" : ".*softmmu.*") != 0; then
4278 want_tools=yes
4279 else
4280 want_tools=no
4284 # Search for bswap_32 function
4285 byteswap_h=no
4286 cat > $TMPC << EOF
4287 #include <byteswap.h>
4288 int main(void) { return bswap_32(0); }
4290 if compile_prog "" "" ; then
4291 byteswap_h=yes
4294 # Search for bswap32 function
4295 bswap_h=no
4296 cat > $TMPC << EOF
4297 #include <sys/endian.h>
4298 #include <sys/types.h>
4299 #include <machine/bswap.h>
4300 int main(void) { return bswap32(0); }
4302 if compile_prog "" "" ; then
4303 bswap_h=yes
4306 ##########################################
4307 # Do we have libiscsi >= 1.9.0
4308 if test "$libiscsi" != "no" ; then
4309 if $pkg_config --atleast-version=1.9.0 libiscsi; then
4310 libiscsi="yes"
4311 libiscsi_cflags=$($pkg_config --cflags libiscsi)
4312 libiscsi_libs=$($pkg_config --libs libiscsi)
4313 else
4314 if test "$libiscsi" = "yes" ; then
4315 feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4317 libiscsi="no"
4321 ##########################################
4322 # Do we need libm
4323 cat > $TMPC << EOF
4324 #include <math.h>
4325 int main(int argc, char **argv) { return isnan(sin((double)argc)); }
4327 if compile_prog "" "" ; then
4329 elif compile_prog "" "-lm" ; then
4330 LIBS="-lm $LIBS"
4331 libs_qga="-lm $libs_qga"
4332 else
4333 error_exit "libm check failed"
4336 ##########################################
4337 # Do we need librt
4338 # uClibc provides 2 versions of clock_gettime(), one with realtime
4339 # support and one without. This means that the clock_gettime() don't
4340 # need -lrt. We still need it for timer_create() so we check for this
4341 # function in addition.
4342 cat > $TMPC <<EOF
4343 #include <signal.h>
4344 #include <time.h>
4345 int main(void) {
4346 timer_create(CLOCK_REALTIME, NULL, NULL);
4347 return clock_gettime(CLOCK_REALTIME, NULL);
4351 if compile_prog "" "" ; then
4353 # we need pthread for static linking. use previous pthread test result
4354 elif compile_prog "" "$pthread_lib -lrt" ; then
4355 LIBS="$LIBS -lrt"
4356 libs_qga="$libs_qga -lrt"
4359 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
4360 "$haiku" != "yes" ; then
4361 libs_softmmu="-lutil $libs_softmmu"
4364 ##########################################
4365 # spice probe
4366 if test "$spice" != "no" ; then
4367 cat > $TMPC << EOF
4368 #include <spice.h>
4369 int main(void) { spice_server_new(); return 0; }
4371 spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4372 spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
4373 if $pkg_config --atleast-version=0.12.0 spice-server && \
4374 $pkg_config --atleast-version=0.12.3 spice-protocol && \
4375 compile_prog "$spice_cflags" "$spice_libs" ; then
4376 spice="yes"
4377 libs_softmmu="$libs_softmmu $spice_libs"
4378 QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
4379 spice_protocol_version=$($pkg_config --modversion spice-protocol)
4380 spice_server_version=$($pkg_config --modversion spice-server)
4381 else
4382 if test "$spice" = "yes" ; then
4383 feature_not_found "spice" \
4384 "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
4386 spice="no"
4390 # check for smartcard support
4391 if test "$smartcard" != "no"; then
4392 if $pkg_config libcacard; then
4393 libcacard_cflags=$($pkg_config --cflags libcacard)
4394 libcacard_libs=$($pkg_config --libs libcacard)
4395 smartcard="yes"
4396 else
4397 if test "$smartcard" = "yes"; then
4398 feature_not_found "smartcard" "Install libcacard devel"
4400 smartcard="no"
4404 # check for libusb
4405 if test "$libusb" != "no" ; then
4406 if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
4407 libusb="yes"
4408 libusb_cflags=$($pkg_config --cflags libusb-1.0)
4409 libusb_libs=$($pkg_config --libs libusb-1.0)
4410 else
4411 if test "$libusb" = "yes"; then
4412 feature_not_found "libusb" "Install libusb devel >= 1.0.13"
4414 libusb="no"
4418 # check for usbredirparser for usb network redirection support
4419 if test "$usb_redir" != "no" ; then
4420 if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
4421 usb_redir="yes"
4422 usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4423 usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
4424 else
4425 if test "$usb_redir" = "yes"; then
4426 feature_not_found "usb-redir" "Install usbredir devel"
4428 usb_redir="no"
4432 ##########################################
4433 # check if we have VSS SDK headers for win
4435 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$vss_win32_sdk" != "no" ; then
4436 case "$vss_win32_sdk" in
4437 "") vss_win32_include="-isystem $source_path" ;;
4438 *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4439 # handle path with spaces. So we symlink the headers into ".sdk/vss".
4440 vss_win32_include="-isystem $source_path/.sdk/vss"
4441 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4443 *) vss_win32_include="-isystem $vss_win32_sdk"
4444 esac
4445 cat > $TMPC << EOF
4446 #define __MIDL_user_allocate_free_DEFINED__
4447 #include <inc/win2003/vss.h>
4448 int main(void) { return VSS_CTX_BACKUP; }
4450 if compile_prog "$vss_win32_include" "" ; then
4451 guest_agent_with_vss="yes"
4452 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4453 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4454 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4455 else
4456 if test "$vss_win32_sdk" != "" ; then
4457 echo "ERROR: Please download and install Microsoft VSS SDK:"
4458 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4459 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4460 echo "ERROR: scripts/extract-vsssdk-headers setup.exe"
4461 echo "ERROR: The headers are extracted in the directory \`inc'."
4462 feature_not_found "VSS support"
4464 guest_agent_with_vss="no"
4468 ##########################################
4469 # lookup Windows platform SDK (if not specified)
4470 # The SDK is needed only to build .tlb (type library) file of guest agent
4471 # VSS provider from the source. It is usually unnecessary because the
4472 # pre-compiled .tlb file is included.
4474 if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss" = "yes" ; then
4475 if test -z "$win_sdk"; then
4476 programfiles="$PROGRAMFILES"
4477 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4478 if test -n "$programfiles"; then
4479 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4480 else
4481 feature_not_found "Windows SDK"
4483 elif test "$win_sdk" = "no"; then
4484 win_sdk=""
4488 ##########################################
4489 # check if mingw environment provides a recent ntddscsi.h
4490 if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
4491 cat > $TMPC << EOF
4492 #include <windows.h>
4493 #include <ntddscsi.h>
4494 int main(void) {
4495 #if !defined(IOCTL_SCSI_GET_ADDRESS)
4496 #error Missing required ioctl definitions
4497 #endif
4498 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
4499 return addr.Lun;
4502 if compile_prog "" "" ; then
4503 guest_agent_ntddscsi=yes
4504 libs_qga="-lsetupapi $libs_qga"
4508 ##########################################
4509 # virgl renderer probe
4511 if test "$virglrenderer" != "no" ; then
4512 cat > $TMPC << EOF
4513 #include <virglrenderer.h>
4514 int main(void) { virgl_renderer_poll(); return 0; }
4516 virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
4517 virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
4518 if $pkg_config virglrenderer >/dev/null 2>&1 && \
4519 compile_prog "$virgl_cflags" "$virgl_libs" ; then
4520 virglrenderer="yes"
4521 else
4522 if test "$virglrenderer" = "yes" ; then
4523 feature_not_found "virglrenderer"
4525 virglrenderer="no"
4529 ##########################################
4530 # capstone
4532 case "$capstone" in
4533 "" | yes)
4534 if $pkg_config capstone; then
4535 capstone=system
4536 elif test -e "${source_path}/.git" ; then
4537 capstone=git
4538 elif test -e "${source_path}/capstone/Makefile" ; then
4539 capstone=internal
4540 elif test -z "$capstone" ; then
4541 capstone=no
4542 else
4543 feature_not_found "capstone" "Install capstone devel or git submodule"
4547 system)
4548 if ! $pkg_config capstone; then
4549 feature_not_found "capstone" "Install capstone devel"
4552 esac
4554 case "$capstone" in
4555 git | internal)
4556 if test "$capstone" = git; then
4557 git_submodules="${git_submodules} capstone"
4559 mkdir -p capstone
4560 QEMU_CFLAGS="$QEMU_CFLAGS -I\$(SRC_PATH)/capstone/include"
4561 if test "$mingw32" = "yes"; then
4562 LIBCAPSTONE=capstone.lib
4563 else
4564 LIBCAPSTONE=libcapstone.a
4566 LIBS="-L\$(BUILD_DIR)/capstone -lcapstone $LIBS"
4569 system)
4570 QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
4571 LIBS="$($pkg_config --libs capstone) $LIBS"
4577 error_exit "Unknown state for capstone: $capstone"
4579 esac
4581 ##########################################
4582 # check if we have fdatasync
4584 fdatasync=no
4585 cat > $TMPC << EOF
4586 #include <unistd.h>
4587 int main(void) {
4588 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4589 return fdatasync(0);
4590 #else
4591 #error Not supported
4592 #endif
4595 if compile_prog "" "" ; then
4596 fdatasync=yes
4599 ##########################################
4600 # check if we have madvise
4602 madvise=no
4603 cat > $TMPC << EOF
4604 #include <sys/types.h>
4605 #include <sys/mman.h>
4606 #include <stddef.h>
4607 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4609 if compile_prog "" "" ; then
4610 madvise=yes
4613 ##########################################
4614 # check if we have posix_madvise
4616 posix_madvise=no
4617 cat > $TMPC << EOF
4618 #include <sys/mman.h>
4619 #include <stddef.h>
4620 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4622 if compile_prog "" "" ; then
4623 posix_madvise=yes
4626 ##########################################
4627 # check if we have posix_syslog
4629 posix_syslog=no
4630 cat > $TMPC << EOF
4631 #include <syslog.h>
4632 int main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
4634 if compile_prog "" "" ; then
4635 posix_syslog=yes
4638 ##########################################
4639 # check if we have sem_timedwait
4641 sem_timedwait=no
4642 cat > $TMPC << EOF
4643 #include <semaphore.h>
4644 int main(void) { return sem_timedwait(0, 0); }
4646 if compile_prog "" "" ; then
4647 sem_timedwait=yes
4650 ##########################################
4651 # check if trace backend exists
4653 $python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends > /dev/null 2> /dev/null
4654 if test "$?" -ne 0 ; then
4655 error_exit "invalid trace backends" \
4656 "Please choose supported trace backends."
4659 ##########################################
4660 # For 'ust' backend, test if ust headers are present
4661 if have_backend "ust"; then
4662 cat > $TMPC << EOF
4663 #include <lttng/tracepoint.h>
4664 int main(void) { return 0; }
4666 if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4667 if $pkg_config lttng-ust --exists; then
4668 lttng_ust_libs=$($pkg_config --libs lttng-ust)
4669 else
4670 lttng_ust_libs="-llttng-ust -ldl"
4672 if $pkg_config liburcu-bp --exists; then
4673 urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4674 else
4675 urcu_bp_libs="-lurcu-bp"
4678 LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
4679 libs_qga="$lttng_ust_libs $urcu_bp_libs $libs_qga"
4680 else
4681 error_exit "Trace backend 'ust' missing lttng-ust header files"
4685 ##########################################
4686 # For 'dtrace' backend, test if 'dtrace' command is present
4687 if have_backend "dtrace"; then
4688 if ! has 'dtrace' ; then
4689 error_exit "dtrace command is not found in PATH $PATH"
4691 trace_backend_stap="no"
4692 if has 'stap' ; then
4693 trace_backend_stap="yes"
4697 ##########################################
4698 # check and set a backend for coroutine
4700 # We prefer ucontext, but it's not always possible. The fallback
4701 # is sigcontext. On Windows the only valid backend is the Windows
4702 # specific one.
4704 ucontext_works=no
4705 if test "$darwin" != "yes"; then
4706 cat > $TMPC << EOF
4707 #include <ucontext.h>
4708 #ifdef __stub_makecontext
4709 #error Ignoring glibc stub makecontext which will always fail
4710 #endif
4711 int main(void) { makecontext(0, 0, 0); return 0; }
4713 if compile_prog "" "" ; then
4714 ucontext_works=yes
4718 if test "$coroutine" = ""; then
4719 if test "$mingw32" = "yes"; then
4720 coroutine=win32
4721 elif test "$ucontext_works" = "yes"; then
4722 coroutine=ucontext
4723 else
4724 coroutine=sigaltstack
4726 else
4727 case $coroutine in
4728 windows)
4729 if test "$mingw32" != "yes"; then
4730 error_exit "'windows' coroutine backend only valid for Windows"
4732 # Unfortunately the user visible backend name doesn't match the
4733 # coroutine-*.c filename for this case, so we have to adjust it here.
4734 coroutine=win32
4736 ucontext)
4737 if test "$ucontext_works" != "yes"; then
4738 feature_not_found "ucontext"
4741 sigaltstack)
4742 if test "$mingw32" = "yes"; then
4743 error_exit "only the 'windows' coroutine backend is valid for Windows"
4747 error_exit "unknown coroutine backend $coroutine"
4749 esac
4752 if test "$coroutine_pool" = ""; then
4753 if test "$coroutine" = "gthread" -o "$coroutine" = "win32"; then
4754 coroutine_pool=no
4755 else
4756 coroutine_pool=yes
4759 if test "$coroutine" = "gthread" -a "$coroutine_pool" = "yes"; then
4760 error_exit "'gthread' coroutine backend does not support pool (use --disable-coroutine-pool)"
4763 if test "$debug_stack_usage" = "yes"; then
4764 if test "$cpu" = "ia64" -o "$cpu" = "hppa"; then
4765 error_exit "stack usage debugging is not supported for $cpu"
4767 if test "$coroutine_pool" = "yes"; then
4768 echo "WARN: disabling coroutine pool for stack usage debugging"
4769 coroutine_pool=no
4774 ##########################################
4775 # check if we have open_by_handle_at
4777 open_by_handle_at=no
4778 cat > $TMPC << EOF
4779 #include <fcntl.h>
4780 #if !defined(AT_EMPTY_PATH)
4781 # error missing definition
4782 #else
4783 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4784 #endif
4786 if compile_prog "" "" ; then
4787 open_by_handle_at=yes
4790 ########################################
4791 # check if we have linux/magic.h
4793 linux_magic_h=no
4794 cat > $TMPC << EOF
4795 #include <linux/magic.h>
4796 int main(void) {
4797 return 0;
4800 if compile_prog "" "" ; then
4801 linux_magic_h=yes
4804 ########################################
4805 # check whether we can disable warning option with a pragma (this is needed
4806 # to silence warnings in the headers of some versions of external libraries).
4807 # This test has to be compiled with -Werror as otherwise an unknown pragma is
4808 # only a warning.
4810 # If we can't selectively disable warning in the code, disable -Werror so that
4811 # the build doesn't fail anyway.
4813 pragma_disable_unused_but_set=no
4814 cat > $TMPC << EOF
4815 #pragma GCC diagnostic push
4816 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
4817 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
4818 #pragma GCC diagnostic pop
4820 int main(void) {
4821 return 0;
4824 if compile_prog "-Werror" "" ; then
4825 pragma_diagnostic_available=yes
4828 ########################################
4829 # check if we have valgrind/valgrind.h
4831 valgrind_h=no
4832 cat > $TMPC << EOF
4833 #include <valgrind/valgrind.h>
4834 int main(void) {
4835 return 0;
4838 if compile_prog "" "" ; then
4839 valgrind_h=yes
4842 ########################################
4843 # check if environ is declared
4845 has_environ=no
4846 cat > $TMPC << EOF
4847 #include <unistd.h>
4848 int main(void) {
4849 environ = 0;
4850 return 0;
4853 if compile_prog "" "" ; then
4854 has_environ=yes
4857 ########################################
4858 # check if cpuid.h is usable.
4860 cat > $TMPC << EOF
4861 #include <cpuid.h>
4862 int main(void) {
4863 unsigned a, b, c, d;
4864 int max = __get_cpuid_max(0, 0);
4866 if (max >= 1) {
4867 __cpuid(1, a, b, c, d);
4870 if (max >= 7) {
4871 __cpuid_count(7, 0, a, b, c, d);
4874 return 0;
4877 if compile_prog "" "" ; then
4878 cpuid_h=yes
4881 ##########################################
4882 # avx2 optimization requirement check
4884 # There is no point enabling this if cpuid.h is not usable,
4885 # since we won't be able to select the new routines.
4887 if test $cpuid_h = yes; then
4888 cat > $TMPC << EOF
4889 #pragma GCC push_options
4890 #pragma GCC target("avx2")
4891 #include <cpuid.h>
4892 #include <immintrin.h>
4893 static int bar(void *a) {
4894 __m256i x = *(__m256i *)a;
4895 return _mm256_testz_si256(x, x);
4897 int main(int argc, char *argv[]) { return bar(argv[0]); }
4899 if compile_object "" ; then
4900 avx2_opt="yes"
4904 ########################################
4905 # check if __[u]int128_t is usable.
4907 int128=no
4908 cat > $TMPC << EOF
4909 #if defined(__clang_major__) && defined(__clang_minor__)
4910 # if ((__clang_major__ < 3) || (__clang_major__ == 3) && (__clang_minor__ < 2))
4911 # error __int128_t does not work in CLANG before 3.2
4912 # endif
4913 #endif
4914 __int128_t a;
4915 __uint128_t b;
4916 int main (void) {
4917 a = a + b;
4918 b = a * b;
4919 a = a * a;
4920 return 0;
4923 if compile_prog "" "" ; then
4924 int128=yes
4927 #########################################
4928 # See if 128-bit atomic operations are supported.
4930 atomic128=no
4931 if test "$int128" = "yes"; then
4932 cat > $TMPC << EOF
4933 int main(void)
4935 unsigned __int128 x = 0, y = 0;
4936 y = __atomic_load_16(&x, 0);
4937 __atomic_store_16(&x, y, 0);
4938 __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
4939 return 0;
4942 if compile_prog "" "" ; then
4943 atomic128=yes
4947 #########################################
4948 # See if 64-bit atomic operations are supported.
4949 # Note that without __atomic builtins, we can only
4950 # assume atomic loads/stores max at pointer size.
4952 cat > $TMPC << EOF
4953 #include <stdint.h>
4954 int main(void)
4956 uint64_t x = 0, y = 0;
4957 #ifdef __ATOMIC_RELAXED
4958 y = __atomic_load_8(&x, 0);
4959 __atomic_store_8(&x, y, 0);
4960 __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
4961 __atomic_exchange_8(&x, y, 0);
4962 __atomic_fetch_add_8(&x, y, 0);
4963 #else
4964 typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4965 __sync_lock_test_and_set(&x, y);
4966 __sync_val_compare_and_swap(&x, y, 0);
4967 __sync_fetch_and_add(&x, y);
4968 #endif
4969 return 0;
4972 if compile_prog "" "" ; then
4973 atomic64=yes
4976 ########################################
4977 # check if getauxval is available.
4979 getauxval=no
4980 cat > $TMPC << EOF
4981 #include <sys/auxv.h>
4982 int main(void) {
4983 return getauxval(AT_HWCAP) == 0;
4986 if compile_prog "" "" ; then
4987 getauxval=yes
4990 ########################################
4991 # check if ccache is interfering with
4992 # semantic analysis of macros
4994 unset CCACHE_CPP2
4995 ccache_cpp2=no
4996 cat > $TMPC << EOF
4997 static const int Z = 1;
4998 #define fn() ({ Z; })
4999 #define TAUT(X) ((X) == Z)
5000 #define PAREN(X, Y) (X == Y)
5001 #define ID(X) (X)
5002 int main(int argc, char *argv[])
5004 int x = 0, y = 0;
5005 x = ID(x);
5006 x = fn();
5007 fn();
5008 if (PAREN(x, y)) return 0;
5009 if (TAUT(Z)) return 0;
5010 return 0;
5014 if ! compile_object "-Werror"; then
5015 ccache_cpp2=yes
5018 #################################################
5019 # clang does not support glibc + FORTIFY_SOURCE.
5021 if test "$fortify_source" != "no"; then
5022 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5023 fortify_source="no";
5024 elif test -n "$cxx" && has $cxx &&
5025 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5026 fortify_source="no";
5027 else
5028 fortify_source="yes"
5032 ##########################################
5033 # check if struct fsxattr is available via linux/fs.h
5035 have_fsxattr=no
5036 cat > $TMPC << EOF
5037 #include <linux/fs.h>
5038 struct fsxattr foo;
5039 int main(void) {
5040 return 0;
5043 if compile_prog "" "" ; then
5044 have_fsxattr=yes
5047 ##########################################
5048 # check if rtnetlink.h exists and is useful
5049 have_rtnetlink=no
5050 cat > $TMPC << EOF
5051 #include <linux/rtnetlink.h>
5052 int main(void) {
5053 return IFLA_PROTO_DOWN;
5056 if compile_prog "" "" ; then
5057 have_rtnetlink=yes
5060 ##########################################
5061 # check for usable AF_VSOCK environment
5062 have_af_vsock=no
5063 cat > $TMPC << EOF
5064 #include <errno.h>
5065 #include <sys/types.h>
5066 #include <sys/socket.h>
5067 #if !defined(AF_VSOCK)
5068 # error missing AF_VSOCK flag
5069 #endif
5070 #include <linux/vm_sockets.h>
5071 int main(void) {
5072 int sock, ret;
5073 struct sockaddr_vm svm;
5074 socklen_t len = sizeof(svm);
5075 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
5076 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
5077 if ((ret == -1) && (errno == ENOTCONN)) {
5078 return 0;
5080 return -1;
5083 if compile_prog "" "" ; then
5084 have_af_vsock=yes
5087 ##########################################
5088 # check for usable AF_ALG environment
5089 hava_afalg=no
5090 cat > $TMPC << EOF
5091 #include <errno.h>
5092 #include <sys/types.h>
5093 #include <sys/socket.h>
5094 #include <linux/if_alg.h>
5095 int main(void) {
5096 int sock;
5097 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5098 return sock;
5101 if compile_prog "" "" ; then
5102 have_afalg=yes
5104 if test "$crypto_afalg" = "yes"
5105 then
5106 if test "$have_afalg" != "yes"
5107 then
5108 error_exit "AF_ALG requested but could not be detected"
5113 #################################################
5114 # Sparc implicitly links with --relax, which is
5115 # incompatible with -r, so --no-relax should be
5116 # given. It does no harm to give it on other
5117 # platforms too.
5119 # Note: the prototype is needed since QEMU_CFLAGS
5120 # contains -Wmissing-prototypes
5121 cat > $TMPC << EOF
5122 extern int foo(void);
5123 int foo(void) { return 0; }
5125 if ! compile_object ""; then
5126 error_exit "Failed to compile object file for LD_REL_FLAGS test"
5128 for i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
5129 if do_cc -nostdlib $i -o $TMPMO $TMPO; then
5130 LD_REL_FLAGS=$i
5131 break
5133 done
5134 if test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
5135 feature_not_found "modules" "Cannot find how to build relocatable objects"
5138 ##########################################
5139 # check for sysmacros.h
5141 have_sysmacros=no
5142 cat > $TMPC << EOF
5143 #include <sys/sysmacros.h>
5144 int main(void) {
5145 return makedev(0, 0);
5148 if compile_prog "" "" ; then
5149 have_sysmacros=yes
5152 ##########################################
5153 # Veritas HyperScale block driver VxHS
5154 # Check if libvxhs is installed
5156 if test "$vxhs" != "no" ; then
5157 cat > $TMPC <<EOF
5158 #include <stdint.h>
5159 #include <qnio/qnio_api.h>
5161 void *vxhs_callback;
5163 int main(void) {
5164 iio_init(QNIO_VERSION, vxhs_callback);
5165 return 0;
5168 vxhs_libs="-lvxhs -lssl"
5169 if compile_prog "" "$vxhs_libs" ; then
5170 vxhs=yes
5171 else
5172 if test "$vxhs" = "yes" ; then
5173 feature_not_found "vxhs block device" "Install libvxhs See github"
5175 vxhs=no
5179 ##########################################
5180 # check for _Static_assert()
5182 have_static_assert=no
5183 cat > $TMPC << EOF
5184 _Static_assert(1, "success");
5185 int main(void) {
5186 return 0;
5189 if compile_prog "" "" ; then
5190 have_static_assert=yes
5193 ##########################################
5194 # check for utmpx.h, it is missing e.g. on OpenBSD
5196 have_utmpx=no
5197 cat > $TMPC << EOF
5198 #include <utmpx.h>
5199 struct utmpx user_info;
5200 int main(void) {
5201 return 0;
5204 if compile_prog "" "" ; then
5205 have_utmpx=yes
5208 ##########################################
5209 # End of CC checks
5210 # After here, no more $cc or $ld runs
5212 if test "$gcov" = "yes" ; then
5213 CFLAGS="-fprofile-arcs -ftest-coverage -g $CFLAGS"
5214 LDFLAGS="-fprofile-arcs -ftest-coverage $LDFLAGS"
5215 elif test "$fortify_source" = "yes" ; then
5216 CFLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $CFLAGS"
5217 elif test "$debug" = "no"; then
5218 CFLAGS="-O2 $CFLAGS"
5221 ##########################################
5222 # Do we have libnfs
5223 if test "$libnfs" != "no" ; then
5224 if $pkg_config --atleast-version=1.9.3 libnfs; then
5225 libnfs="yes"
5226 libnfs_libs=$($pkg_config --libs libnfs)
5227 else
5228 if test "$libnfs" = "yes" ; then
5229 feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
5231 libnfs="no"
5235 # Now we've finished running tests it's OK to add -Werror to the compiler flags
5236 if test "$werror" = "yes"; then
5237 QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
5240 if test "$solaris" = "no" ; then
5241 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5242 LDFLAGS="-Wl,--warn-common $LDFLAGS"
5246 # test if pod2man has --utf8 option
5247 if pod2man --help | grep -q utf8; then
5248 POD2MAN="pod2man --utf8"
5249 else
5250 POD2MAN="pod2man"
5253 # Use large addresses, ASLR, no-SEH and DEP if available.
5254 if test "$mingw32" = "yes" ; then
5255 if test "$cpu" = i386; then
5256 LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
5258 for flag in --dynamicbase --no-seh --nxcompat; do
5259 if ld_has $flag ; then
5260 LDFLAGS="-Wl,$flag $LDFLAGS"
5262 done
5265 qemu_confdir=$sysconfdir$confsuffix
5266 qemu_moddir=$libdir$confsuffix
5267 qemu_datadir=$datadir$confsuffix
5268 qemu_localedir="$datadir/locale"
5270 # We can only support ivshmem if we have eventfd
5271 if [ "$eventfd" = "yes" ]; then
5272 ivshmem=yes
5275 tools=""
5276 tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools"
5277 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then
5278 tools="qemu-nbd\$(EXESUF) $tools"
5280 if [ "$ivshmem" = "yes" ]; then
5281 tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools"
5283 if test "$softmmu" = yes ; then
5284 if test "$linux" = yes; then
5285 if test "$virtfs" != no && test "$cap" = yes && test "$attr" = yes ; then
5286 virtfs=yes
5287 tools="$tools fsdev/virtfs-proxy-helper\$(EXESUF)"
5288 else
5289 if test "$virtfs" = yes; then
5290 error_exit "VirtFS requires libcap devel and libattr devel"
5292 virtfs=no
5294 if test "$mpath" != no && test "$mpathpersist" = yes ; then
5295 mpath=yes
5296 else
5297 if test "$mpath" = yes; then
5298 error_exit "Multipath requires libmpathpersist devel"
5300 mpath=no
5302 tools="$tools scsi/qemu-pr-helper\$(EXESUF)"
5303 else
5304 if test "$virtfs" = yes; then
5305 error_exit "VirtFS is supported only on Linux"
5307 virtfs=no
5308 if test "$mpath" = yes; then
5309 error_exit "Multipath is supported only on Linux"
5311 mpath=no
5313 if test "$xkbcommon" = "yes"; then
5314 tools="qemu-keymap\$(EXESUF) $tools"
5318 # Probe for guest agent support/options
5320 if [ "$guest_agent" != "no" ]; then
5321 if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5322 tools="qemu-ga $tools"
5323 guest_agent=yes
5324 elif [ "$guest_agent" != yes ]; then
5325 guest_agent=no
5326 else
5327 error_exit "Guest agent is not supported on this platform"
5331 # Guest agent Window MSI package
5333 if test "$guest_agent" != yes; then
5334 if test "$guest_agent_msi" = yes; then
5335 error_exit "MSI guest agent package requires guest agent enabled"
5337 guest_agent_msi=no
5338 elif test "$mingw32" != "yes"; then
5339 if test "$guest_agent_msi" = "yes"; then
5340 error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
5342 guest_agent_msi=no
5343 elif ! has wixl; then
5344 if test "$guest_agent_msi" = "yes"; then
5345 error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
5347 guest_agent_msi=no
5348 else
5349 # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
5350 # disabled explicitly
5351 if test "$guest_agent_msi" != "no"; then
5352 guest_agent_msi=yes
5356 if test "$guest_agent_msi" = "yes"; then
5357 if test "$guest_agent_with_vss" = "yes"; then
5358 QEMU_GA_MSI_WITH_VSS="-D InstallVss"
5361 if test "$QEMU_GA_MANUFACTURER" = ""; then
5362 QEMU_GA_MANUFACTURER=QEMU
5365 if test "$QEMU_GA_DISTRO" = ""; then
5366 QEMU_GA_DISTRO=Linux
5369 if test "$QEMU_GA_VERSION" = ""; then
5370 QEMU_GA_VERSION=$(cat $source_path/VERSION)
5373 QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
5375 case "$cpu" in
5376 x86_64)
5377 QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
5379 i386)
5380 QEMU_GA_MSI_ARCH="-D Arch=32"
5383 error_exit "CPU $cpu not supported for building installation package"
5385 esac
5388 # Mac OS X ships with a broken assembler
5389 roms=
5390 if test \( "$cpu" = "i386" -o "$cpu" = "x86_64" \) -a \
5391 "$targetos" != "Darwin" -a "$targetos" != "SunOS" -a \
5392 "$softmmu" = yes ; then
5393 # Different host OS linkers have different ideas about the name of the ELF
5394 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5395 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5396 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5397 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5398 ld_i386_emulation="$emu"
5399 roms="optionrom"
5400 break
5402 done
5404 if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
5405 roms="$roms spapr-rtas"
5408 if test "$cpu" = "s390x" ; then
5409 roms="$roms s390-ccw"
5412 # Probe for the need for relocating the user-only binary.
5413 if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ] ) && [ "$pie" = no ]; then
5414 textseg_addr=
5415 case "$cpu" in
5416 arm | i386 | ppc* | s390* | sparc* | x86_64 | x32)
5417 # ??? Rationale for choosing this address
5418 textseg_addr=0x60000000
5420 mips)
5421 # A 256M aligned address, high in the address space, with enough
5422 # room for the code_gen_buffer above it before the stack.
5423 textseg_addr=0x60000000
5425 esac
5426 if [ -n "$textseg_addr" ]; then
5427 cat > $TMPC <<EOF
5428 int main(void) { return 0; }
5430 textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
5431 if ! compile_prog "" "$textseg_ldflags"; then
5432 # In case ld does not support -Ttext-segment, edit the default linker
5433 # script via sed to set the .text start addr. This is needed on FreeBSD
5434 # at least.
5435 if ! $ld --verbose >/dev/null 2>&1; then
5436 error_exit \
5437 "We need to link the QEMU user mode binaries at a" \
5438 "specific text address. Unfortunately your linker" \
5439 "doesn't support either the -Ttext-segment option or" \
5440 "printing the default linker script with --verbose." \
5441 "If you don't want the user mode binaries, pass the" \
5442 "--disable-user option to configure."
5445 $ld --verbose | sed \
5446 -e '1,/==================================================/d' \
5447 -e '/==================================================/,$d' \
5448 -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
5449 -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
5450 textseg_ldflags="-Wl,-T../config-host.ld"
5455 # Check that the C++ compiler exists and works with the C compiler.
5456 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
5457 if has $cxx; then
5458 cat > $TMPC <<EOF
5459 int c_function(void);
5460 int main(void) { return c_function(); }
5463 compile_object
5465 cat > $TMPCXX <<EOF
5466 extern "C" {
5467 int c_function(void);
5469 int c_function(void) { return 42; }
5472 update_cxxflags
5474 if do_cxx $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $LDFLAGS; then
5475 # C++ compiler $cxx works ok with C compiler $cc
5477 else
5478 echo "C++ compiler $cxx does not work with C compiler $cc"
5479 echo "Disabling C++ specific optional code"
5480 cxx=
5482 else
5483 echo "No C++ compiler available; disabling C++ specific optional code"
5484 cxx=
5487 echo_version() {
5488 if test "$1" = "yes" ; then
5489 echo "($2)"
5493 # prepend pixman and ftd flags after all config tests are done
5494 QEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
5495 libs_softmmu="$pixman_libs $libs_softmmu"
5497 echo "Install prefix $prefix"
5498 echo "BIOS directory $(eval echo $qemu_datadir)"
5499 echo "firmware path $(eval echo $firmwarepath)"
5500 echo "binary directory $(eval echo $bindir)"
5501 echo "library directory $(eval echo $libdir)"
5502 echo "module directory $(eval echo $qemu_moddir)"
5503 echo "libexec directory $(eval echo $libexecdir)"
5504 echo "include directory $(eval echo $includedir)"
5505 echo "config directory $(eval echo $sysconfdir)"
5506 if test "$mingw32" = "no" ; then
5507 echo "local state directory $(eval echo $local_statedir)"
5508 echo "Manual directory $(eval echo $mandir)"
5509 echo "ELF interp prefix $interp_prefix"
5510 else
5511 echo "local state directory queried at runtime"
5512 echo "Windows SDK $win_sdk"
5514 echo "Source path $source_path"
5515 echo "GIT binary $git"
5516 echo "GIT submodules $git_submodules"
5517 echo "C compiler $cc"
5518 echo "Host C compiler $host_cc"
5519 echo "C++ compiler $cxx"
5520 echo "Objective-C compiler $objcc"
5521 echo "ARFLAGS $ARFLAGS"
5522 echo "CFLAGS $CFLAGS"
5523 echo "QEMU_CFLAGS $QEMU_CFLAGS"
5524 echo "LDFLAGS $LDFLAGS"
5525 echo "make $make"
5526 echo "install $install"
5527 echo "python $python"
5528 if test "$slirp" = "yes" ; then
5529 echo "smbd $smbd"
5531 echo "module support $modules"
5532 echo "host CPU $cpu"
5533 echo "host big endian $bigendian"
5534 echo "target list $target_list"
5535 echo "gprof enabled $gprof"
5536 echo "sparse enabled $sparse"
5537 echo "strip binaries $strip_opt"
5538 echo "profiler $profiler"
5539 echo "static build $static"
5540 if test "$darwin" = "yes" ; then
5541 echo "Cocoa support $cocoa"
5543 echo "SDL support $sdl $(echo_version $sdl $sdlversion)"
5544 echo "GTK support $gtk $(echo_version $gtk $gtk_version)"
5545 echo "GTK GL support $gtk_gl"
5546 echo "VTE support $vte $(echo_version $vte $vteversion)"
5547 echo "TLS priority $tls_priority"
5548 echo "GNUTLS support $gnutls"
5549 echo "GNUTLS rnd $gnutls_rnd"
5550 if test "$gcrypt" = "yes"; then
5551 echo "encryption libgcrypt"
5552 echo "libgcrypt kdf $gcrypt_kdf"
5553 elif test "$nettle" = "yes"; then
5554 echo "nettle $nettle $(echo_version $nettle $nettle_version)"
5555 else
5556 echo "encryption none"
5558 echo "nettle kdf $nettle_kdf"
5559 echo "libtasn1 $tasn1"
5560 echo "curses support $curses"
5561 echo "virgl support $virglrenderer"
5562 echo "curl support $curl"
5563 echo "mingw32 support $mingw32"
5564 echo "Audio drivers $audio_drv_list"
5565 echo "Block whitelist (rw) $block_drv_rw_whitelist"
5566 echo "Block whitelist (ro) $block_drv_ro_whitelist"
5567 echo "VirtFS support $virtfs"
5568 echo "Multipath support $mpath"
5569 echo "VNC support $vnc"
5570 if test "$vnc" = "yes" ; then
5571 echo "VNC SASL support $vnc_sasl"
5572 echo "VNC JPEG support $vnc_jpeg"
5573 echo "VNC PNG support $vnc_png"
5575 if test -n "$sparc_cpu"; then
5576 echo "Target Sparc Arch $sparc_cpu"
5578 echo "xen support $xen"
5579 if test "$xen" = "yes" ; then
5580 echo "xen ctrl version $xen_ctrl_version"
5581 echo "pv dom build $xen_pv_domain_build"
5583 echo "brlapi support $brlapi"
5584 echo "bluez support $bluez"
5585 echo "Documentation $docs"
5586 echo "Tools $tools"
5587 echo "PIE $pie"
5588 echo "vde support $vde"
5589 echo "netmap support $netmap"
5590 echo "Linux AIO support $linux_aio"
5591 echo "(X)ATTR support $attr"
5592 echo "Install blobs $blobs"
5593 echo "KVM support $kvm"
5594 echo "HAX support $hax"
5595 echo "TCG support $tcg"
5596 if test "$tcg" = "yes" ; then
5597 echo "TCG debug enabled $debug_tcg"
5598 echo "TCG interpreter $tcg_interpreter"
5600 echo "malloc trim support $malloc_trim"
5601 echo "RDMA support $rdma"
5602 echo "fdt support $fdt"
5603 echo "preadv support $preadv"
5604 echo "fdatasync $fdatasync"
5605 echo "madvise $madvise"
5606 echo "posix_madvise $posix_madvise"
5607 echo "libcap-ng support $cap_ng"
5608 echo "vhost-net support $vhost_net"
5609 echo "vhost-scsi support $vhost_scsi"
5610 echo "vhost-vsock support $vhost_vsock"
5611 echo "vhost-user support $vhost_user"
5612 echo "Trace backends $trace_backends"
5613 if have_backend "simple"; then
5614 echo "Trace output file $trace_file-<pid>"
5616 echo "spice support $spice $(echo_version $spice $spice_protocol_version/$spice_server_version)"
5617 echo "rbd support $rbd"
5618 echo "xfsctl support $xfs"
5619 echo "smartcard support $smartcard"
5620 echo "libusb $libusb"
5621 echo "usb net redir $usb_redir"
5622 echo "OpenGL support $opengl"
5623 echo "OpenGL dmabufs $opengl_dmabuf"
5624 echo "libiscsi support $libiscsi"
5625 echo "libnfs support $libnfs"
5626 echo "build guest agent $guest_agent"
5627 echo "QGA VSS support $guest_agent_with_vss"
5628 echo "QGA w32 disk info $guest_agent_ntddscsi"
5629 echo "QGA MSI support $guest_agent_msi"
5630 echo "seccomp support $seccomp"
5631 echo "coroutine backend $coroutine"
5632 echo "coroutine pool $coroutine_pool"
5633 echo "debug stack usage $debug_stack_usage"
5634 echo "crypto afalg $crypto_afalg"
5635 echo "GlusterFS support $glusterfs"
5636 echo "gcov $gcov_tool"
5637 echo "gcov enabled $gcov"
5638 echo "TPM support $tpm"
5639 echo "libssh2 support $libssh2"
5640 echo "TPM passthrough $tpm_passthrough"
5641 echo "TPM emulator $tpm_emulator"
5642 echo "QOM debugging $qom_cast_debug"
5643 echo "Live block migration $live_block_migration"
5644 echo "lzo support $lzo"
5645 echo "snappy support $snappy"
5646 echo "bzip2 support $bzip2"
5647 echo "NUMA host support $numa"
5648 echo "tcmalloc support $tcmalloc"
5649 echo "jemalloc support $jemalloc"
5650 echo "avx2 optimization $avx2_opt"
5651 echo "replication support $replication"
5652 echo "VxHS block device $vxhs"
5653 echo "capstone $capstone"
5655 if test "$sdl_too_old" = "yes"; then
5656 echo "-> Your SDL version is too old - please upgrade to have SDL support"
5659 if test "$supported_cpu" = "no"; then
5660 echo
5661 echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
5662 echo
5663 echo "CPU host architecture $cpu support is not currently maintained."
5664 echo "The QEMU project intends to remove support for this host CPU in"
5665 echo "a future release if nobody volunteers to maintain it and to"
5666 echo "provide a build host for our continuous integration setup."
5667 echo "configure has succeeded and you can continue to build, but"
5668 echo "if you care about QEMU on this platform you should contact"
5669 echo "us upstream at qemu-devel@nongnu.org."
5672 if test "$supported_os" = "no"; then
5673 echo
5674 echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
5675 echo
5676 echo "Host OS $targetos support is not currently maintained."
5677 echo "The QEMU project intends to remove support for this host OS in"
5678 echo "a future release if nobody volunteers to maintain it and to"
5679 echo "provide a build host for our continuous integration setup."
5680 echo "configure has succeeded and you can continue to build, but"
5681 echo "if you care about QEMU on this platform you should contact"
5682 echo "us upstream at qemu-devel@nongnu.org."
5685 config_host_mak="config-host.mak"
5687 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
5689 echo "# Automatically generated by configure - do not modify" > $config_host_mak
5690 echo >> $config_host_mak
5692 echo all: >> $config_host_mak
5693 echo "prefix=$prefix" >> $config_host_mak
5694 echo "bindir=$bindir" >> $config_host_mak
5695 echo "libdir=$libdir" >> $config_host_mak
5696 echo "libexecdir=$libexecdir" >> $config_host_mak
5697 echo "includedir=$includedir" >> $config_host_mak
5698 echo "mandir=$mandir" >> $config_host_mak
5699 echo "sysconfdir=$sysconfdir" >> $config_host_mak
5700 echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
5701 echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
5702 echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
5703 echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
5704 echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
5705 if test "$mingw32" = "no" ; then
5706 echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
5708 echo "qemu_helperdir=$libexecdir" >> $config_host_mak
5709 echo "extra_cflags=$EXTRA_CFLAGS" >> $config_host_mak
5710 echo "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
5711 echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
5712 echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
5713 echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
5714 echo "GIT=$git" >> $config_host_mak
5715 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5716 echo "GIT_UPDATE=$git_update" >> $config_host_mak
5718 echo "ARCH=$ARCH" >> $config_host_mak
5720 if test "$debug_tcg" = "yes" ; then
5721 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5723 if test "$strip_opt" = "yes" ; then
5724 echo "STRIP=${strip}" >> $config_host_mak
5726 if test "$bigendian" = "yes" ; then
5727 echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
5729 if test "$mingw32" = "yes" ; then
5730 echo "CONFIG_WIN32=y" >> $config_host_mak
5731 echo "CONFIG_INSTALLER=y" >> $config_host_mak
5732 rc_version=$(cat $source_path/VERSION)
5733 version_major=${rc_version%%.*}
5734 rc_version=${rc_version#*.}
5735 version_minor=${rc_version%%.*}
5736 rc_version=${rc_version#*.}
5737 version_subminor=${rc_version%%.*}
5738 version_micro=0
5739 echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5740 echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5741 if test "$guest_agent_with_vss" = "yes" ; then
5742 echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5743 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5744 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5746 if test "$guest_agent_ntddscsi" = "yes" ; then
5747 echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
5749 if test "$guest_agent_msi" = "yes"; then
5750 echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
5751 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
5752 echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
5753 echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
5754 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
5755 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
5756 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5758 else
5759 echo "CONFIG_POSIX=y" >> $config_host_mak
5762 if test "$linux" = "yes" ; then
5763 echo "CONFIG_LINUX=y" >> $config_host_mak
5766 if test "$darwin" = "yes" ; then
5767 echo "CONFIG_DARWIN=y" >> $config_host_mak
5770 if test "$solaris" = "yes" ; then
5771 echo "CONFIG_SOLARIS=y" >> $config_host_mak
5773 if test "$haiku" = "yes" ; then
5774 echo "CONFIG_HAIKU=y" >> $config_host_mak
5776 if test "$static" = "yes" ; then
5777 echo "CONFIG_STATIC=y" >> $config_host_mak
5779 if test "$profiler" = "yes" ; then
5780 echo "CONFIG_PROFILER=y" >> $config_host_mak
5782 if test "$slirp" = "yes" ; then
5783 echo "CONFIG_SLIRP=y" >> $config_host_mak
5784 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
5786 if test "$vde" = "yes" ; then
5787 echo "CONFIG_VDE=y" >> $config_host_mak
5788 echo "VDE_LIBS=$vde_libs" >> $config_host_mak
5790 if test "$netmap" = "yes" ; then
5791 echo "CONFIG_NETMAP=y" >> $config_host_mak
5793 if test "$l2tpv3" = "yes" ; then
5794 echo "CONFIG_L2TPV3=y" >> $config_host_mak
5796 if test "$cap_ng" = "yes" ; then
5797 echo "CONFIG_LIBCAP=y" >> $config_host_mak
5799 echo "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
5800 for drv in $audio_drv_list; do
5801 def=CONFIG_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5802 echo "$def=y" >> $config_host_mak
5803 done
5804 echo "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5805 echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5806 echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5807 echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5808 echo "OSS_LIBS=$oss_libs" >> $config_host_mak
5809 if test "$audio_pt_int" = "yes" ; then
5810 echo "CONFIG_AUDIO_PT_INT=y" >> $config_host_mak
5812 if test "$audio_win_int" = "yes" ; then
5813 echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5815 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5816 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5817 if test "$vnc" = "yes" ; then
5818 echo "CONFIG_VNC=y" >> $config_host_mak
5820 if test "$vnc_sasl" = "yes" ; then
5821 echo "CONFIG_VNC_SASL=y" >> $config_host_mak
5823 if test "$vnc_jpeg" = "yes" ; then
5824 echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
5826 if test "$vnc_png" = "yes" ; then
5827 echo "CONFIG_VNC_PNG=y" >> $config_host_mak
5829 if test "$xkbcommon" = "yes" ; then
5830 echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
5831 echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
5833 if test "$fnmatch" = "yes" ; then
5834 echo "CONFIG_FNMATCH=y" >> $config_host_mak
5836 if test "$xfs" = "yes" ; then
5837 echo "CONFIG_XFS=y" >> $config_host_mak
5839 qemu_version=$(head $source_path/VERSION)
5840 echo "VERSION=$qemu_version" >>$config_host_mak
5841 echo "PKGVERSION=$pkgversion" >>$config_host_mak
5842 echo "SRC_PATH=$source_path" >> $config_host_mak
5843 echo "TARGET_DIRS=$target_list" >> $config_host_mak
5844 if [ "$docs" = "yes" ] ; then
5845 echo "BUILD_DOCS=yes" >> $config_host_mak
5847 if [ "$want_tools" = "yes" ] ; then
5848 echo "BUILD_TOOLS=yes" >> $config_host_mak
5850 if test "$modules" = "yes"; then
5851 # $shacmd can generate a hash started with digit, which the compiler doesn't
5852 # like as an symbol. So prefix it with an underscore
5853 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
5854 echo "CONFIG_MODULES=y" >> $config_host_mak
5856 if test "$sdl" = "yes" ; then
5857 echo "CONFIG_SDL=y" >> $config_host_mak
5858 echo "CONFIG_SDLABI=$sdlabi" >> $config_host_mak
5859 echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
5860 echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
5862 if test "$cocoa" = "yes" ; then
5863 echo "CONFIG_COCOA=y" >> $config_host_mak
5865 if test "$curses" = "yes" ; then
5866 echo "CONFIG_CURSES=y" >> $config_host_mak
5868 if test "$pipe2" = "yes" ; then
5869 echo "CONFIG_PIPE2=y" >> $config_host_mak
5871 if test "$accept4" = "yes" ; then
5872 echo "CONFIG_ACCEPT4=y" >> $config_host_mak
5874 if test "$splice" = "yes" ; then
5875 echo "CONFIG_SPLICE=y" >> $config_host_mak
5877 if test "$eventfd" = "yes" ; then
5878 echo "CONFIG_EVENTFD=y" >> $config_host_mak
5880 if test "$memfd" = "yes" ; then
5881 echo "CONFIG_MEMFD=y" >> $config_host_mak
5883 if test "$fallocate" = "yes" ; then
5884 echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5886 if test "$fallocate_punch_hole" = "yes" ; then
5887 echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
5889 if test "$fallocate_zero_range" = "yes" ; then
5890 echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5892 if test "$posix_fallocate" = "yes" ; then
5893 echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5895 if test "$sync_file_range" = "yes" ; then
5896 echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5898 if test "$fiemap" = "yes" ; then
5899 echo "CONFIG_FIEMAP=y" >> $config_host_mak
5901 if test "$dup3" = "yes" ; then
5902 echo "CONFIG_DUP3=y" >> $config_host_mak
5904 if test "$ppoll" = "yes" ; then
5905 echo "CONFIG_PPOLL=y" >> $config_host_mak
5907 if test "$prctl_pr_set_timerslack" = "yes" ; then
5908 echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5910 if test "$epoll" = "yes" ; then
5911 echo "CONFIG_EPOLL=y" >> $config_host_mak
5913 if test "$epoll_create1" = "yes" ; then
5914 echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
5916 if test "$sendfile" = "yes" ; then
5917 echo "CONFIG_SENDFILE=y" >> $config_host_mak
5919 if test "$timerfd" = "yes" ; then
5920 echo "CONFIG_TIMERFD=y" >> $config_host_mak
5922 if test "$setns" = "yes" ; then
5923 echo "CONFIG_SETNS=y" >> $config_host_mak
5925 if test "$clock_adjtime" = "yes" ; then
5926 echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
5928 if test "$syncfs" = "yes" ; then
5929 echo "CONFIG_SYNCFS=y" >> $config_host_mak
5931 if test "$inotify" = "yes" ; then
5932 echo "CONFIG_INOTIFY=y" >> $config_host_mak
5934 if test "$inotify1" = "yes" ; then
5935 echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5937 if test "$sem_timedwait" = "yes" ; then
5938 echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5940 if test "$byteswap_h" = "yes" ; then
5941 echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
5943 if test "$bswap_h" = "yes" ; then
5944 echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
5946 if test "$curl" = "yes" ; then
5947 echo "CONFIG_CURL=m" >> $config_host_mak
5948 echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
5949 echo "CURL_LIBS=$curl_libs" >> $config_host_mak
5951 if test "$brlapi" = "yes" ; then
5952 echo "CONFIG_BRLAPI=y" >> $config_host_mak
5953 echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
5955 if test "$bluez" = "yes" ; then
5956 echo "CONFIG_BLUEZ=y" >> $config_host_mak
5957 echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
5959 if test "$glib_subprocess" = "yes" ; then
5960 echo "CONFIG_HAS_GLIB_SUBPROCESS_TESTS=y" >> $config_host_mak
5962 if test "$gtk" = "yes" ; then
5963 echo "CONFIG_GTK=y" >> $config_host_mak
5964 echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak
5965 echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
5966 echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
5967 if test "$gtk_gl" = "yes" ; then
5968 echo "CONFIG_GTK_GL=y" >> $config_host_mak
5971 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5972 if test "$gnutls" = "yes" ; then
5973 echo "CONFIG_GNUTLS=y" >> $config_host_mak
5975 if test "$gnutls_rnd" = "yes" ; then
5976 echo "CONFIG_GNUTLS_RND=y" >> $config_host_mak
5978 if test "$gcrypt" = "yes" ; then
5979 echo "CONFIG_GCRYPT=y" >> $config_host_mak
5980 if test "$gcrypt_hmac" = "yes" ; then
5981 echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
5983 if test "$gcrypt_kdf" = "yes" ; then
5984 echo "CONFIG_GCRYPT_KDF=y" >> $config_host_mak
5987 if test "$nettle" = "yes" ; then
5988 echo "CONFIG_NETTLE=y" >> $config_host_mak
5989 echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5990 if test "$nettle_kdf" = "yes" ; then
5991 echo "CONFIG_NETTLE_KDF=y" >> $config_host_mak
5994 if test "$tasn1" = "yes" ; then
5995 echo "CONFIG_TASN1=y" >> $config_host_mak
5997 if test "$have_ifaddrs_h" = "yes" ; then
5998 echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6000 if test "$have_broken_size_max" = "yes" ; then
6001 echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
6004 # Work around a system header bug with some kernel/XFS header
6005 # versions where they both try to define 'struct fsxattr':
6006 # xfs headers will not try to redefine structs from linux headers
6007 # if this macro is set.
6008 if test "$have_fsxattr" = "yes" ; then
6009 echo "HAVE_FSXATTR=y" >> $config_host_mak
6011 if test "$vte" = "yes" ; then
6012 echo "CONFIG_VTE=y" >> $config_host_mak
6013 echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6015 if test "$virglrenderer" = "yes" ; then
6016 echo "CONFIG_VIRGL=y" >> $config_host_mak
6017 echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
6018 echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
6020 if test "$xen" = "yes" ; then
6021 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6022 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6023 if test "$xen_pv_domain_build" = "yes" ; then
6024 echo "CONFIG_XEN_PV_DOMAIN_BUILD=y" >> $config_host_mak
6027 if test "$linux_aio" = "yes" ; then
6028 echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
6030 if test "$attr" = "yes" ; then
6031 echo "CONFIG_ATTR=y" >> $config_host_mak
6033 if test "$libattr" = "yes" ; then
6034 echo "CONFIG_LIBATTR=y" >> $config_host_mak
6036 if test "$virtfs" = "yes" ; then
6037 echo "CONFIG_VIRTFS=y" >> $config_host_mak
6039 if test "$mpath" = "yes" ; then
6040 echo "CONFIG_MPATH=y" >> $config_host_mak
6042 if test "$vhost_scsi" = "yes" ; then
6043 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
6045 if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
6046 echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
6048 if test "$vhost_vsock" = "yes" ; then
6049 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
6051 if test "$vhost_user" = "yes" ; then
6052 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6054 if test "$blobs" = "yes" ; then
6055 echo "INSTALL_BLOBS=yes" >> $config_host_mak
6057 if test "$iovec" = "yes" ; then
6058 echo "CONFIG_IOVEC=y" >> $config_host_mak
6060 if test "$preadv" = "yes" ; then
6061 echo "CONFIG_PREADV=y" >> $config_host_mak
6063 if test "$fdt" = "yes" ; then
6064 echo "CONFIG_FDT=y" >> $config_host_mak
6066 if test "$signalfd" = "yes" ; then
6067 echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6069 if test "$tcg" = "yes"; then
6070 echo "CONFIG_TCG=y" >> $config_host_mak
6071 if test "$tcg_interpreter" = "yes" ; then
6072 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
6075 if test "$fdatasync" = "yes" ; then
6076 echo "CONFIG_FDATASYNC=y" >> $config_host_mak
6078 if test "$madvise" = "yes" ; then
6079 echo "CONFIG_MADVISE=y" >> $config_host_mak
6081 if test "$posix_madvise" = "yes" ; then
6082 echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6085 if test "$spice" = "yes" ; then
6086 echo "CONFIG_SPICE=y" >> $config_host_mak
6089 if test "$smartcard" = "yes" ; then
6090 echo "CONFIG_SMARTCARD=y" >> $config_host_mak
6091 echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
6092 echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6095 if test "$libusb" = "yes" ; then
6096 echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6097 echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6098 echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
6101 if test "$usb_redir" = "yes" ; then
6102 echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6103 echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6104 echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
6107 if test "$opengl" = "yes" ; then
6108 echo "CONFIG_OPENGL=y" >> $config_host_mak
6109 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6110 if test "$opengl_dmabuf" = "yes" ; then
6111 echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6115 if test "$malloc_trim" = "yes" ; then
6116 echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
6119 if test "$avx2_opt" = "yes" ; then
6120 echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
6123 if test "$lzo" = "yes" ; then
6124 echo "CONFIG_LZO=y" >> $config_host_mak
6127 if test "$snappy" = "yes" ; then
6128 echo "CONFIG_SNAPPY=y" >> $config_host_mak
6131 if test "$bzip2" = "yes" ; then
6132 echo "CONFIG_BZIP2=y" >> $config_host_mak
6133 echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
6136 if test "$libiscsi" = "yes" ; then
6137 echo "CONFIG_LIBISCSI=m" >> $config_host_mak
6138 echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
6139 echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6142 if test "$libnfs" = "yes" ; then
6143 echo "CONFIG_LIBNFS=m" >> $config_host_mak
6144 echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
6147 if test "$seccomp" = "yes"; then
6148 echo "CONFIG_SECCOMP=y" >> $config_host_mak
6149 echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6150 echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6153 # XXX: suppress that
6154 if [ "$bsd" = "yes" ] ; then
6155 echo "CONFIG_BSD=y" >> $config_host_mak
6158 if test "$localtime_r" = "yes" ; then
6159 echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
6161 if test "$qom_cast_debug" = "yes" ; then
6162 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
6164 if test "$rbd" = "yes" ; then
6165 echo "CONFIG_RBD=m" >> $config_host_mak
6166 echo "RBD_CFLAGS=$rbd_cflags" >> $config_host_mak
6167 echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6170 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
6171 if test "$coroutine_pool" = "yes" ; then
6172 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
6173 else
6174 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
6177 if test "$debug_stack_usage" = "yes" ; then
6178 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
6181 if test "$crypto_afalg" = "yes" ; then
6182 echo "CONFIG_AF_ALG=y" >> $config_host_mak
6185 if test "$open_by_handle_at" = "yes" ; then
6186 echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6189 if test "$linux_magic_h" = "yes" ; then
6190 echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6193 if test "$pragma_diagnostic_available" = "yes" ; then
6194 echo "CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE=y" >> $config_host_mak
6197 if test "$valgrind_h" = "yes" ; then
6198 echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
6201 if test "$has_environ" = "yes" ; then
6202 echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
6205 if test "$cpuid_h" = "yes" ; then
6206 echo "CONFIG_CPUID_H=y" >> $config_host_mak
6209 if test "$int128" = "yes" ; then
6210 echo "CONFIG_INT128=y" >> $config_host_mak
6213 if test "$atomic128" = "yes" ; then
6214 echo "CONFIG_ATOMIC128=y" >> $config_host_mak
6217 if test "$atomic64" = "yes" ; then
6218 echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6221 if test "$getauxval" = "yes" ; then
6222 echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
6225 if test "$glusterfs" = "yes" ; then
6226 echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
6227 echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
6228 echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6231 if test "$glusterfs_xlator_opt" = "yes" ; then
6232 echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6235 if test "$glusterfs_discard" = "yes" ; then
6236 echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
6239 if test "$glusterfs_fallocate" = "yes" ; then
6240 echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6243 if test "$glusterfs_zerofill" = "yes" ; then
6244 echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
6247 if test "$libssh2" = "yes" ; then
6248 echo "CONFIG_LIBSSH2=m" >> $config_host_mak
6249 echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
6250 echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
6253 if test "$live_block_migration" = "yes" ; then
6254 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6257 if test "$tpm" = "yes"; then
6258 echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak
6259 # TPM passthrough support?
6260 if test "$tpm_passthrough" = "yes"; then
6261 echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
6263 # TPM emulator support?
6264 if test "$tpm_emulator" = "yes"; then
6265 echo "CONFIG_TPM_EMULATOR=y" >> $config_host_mak
6269 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
6270 if have_backend "nop"; then
6271 echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
6273 if have_backend "simple"; then
6274 echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
6275 # Set the appropriate trace file.
6276 trace_file="\"$trace_file-\" FMT_pid"
6278 if have_backend "log"; then
6279 echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
6281 if have_backend "ust"; then
6282 echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6284 if have_backend "dtrace"; then
6285 echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
6286 if test "$trace_backend_stap" = "yes" ; then
6287 echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
6290 if have_backend "ftrace"; then
6291 if test "$linux" = "yes" ; then
6292 echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6293 else
6294 feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6297 if have_backend "syslog"; then
6298 if test "$posix_syslog" = "yes" ; then
6299 echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
6300 else
6301 feature_not_found "syslog(trace backend)" "syslog not available"
6304 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
6306 if test "$rdma" = "yes" ; then
6307 echo "CONFIG_RDMA=y" >> $config_host_mak
6308 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
6311 if test "$have_rtnetlink" = "yes" ; then
6312 echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6315 if test "$replication" = "yes" ; then
6316 echo "CONFIG_REPLICATION=y" >> $config_host_mak
6319 if test "$have_af_vsock" = "yes" ; then
6320 echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
6323 if test "$have_sysmacros" = "yes" ; then
6324 echo "CONFIG_SYSMACROS=y" >> $config_host_mak
6327 if test "$have_static_assert" = "yes" ; then
6328 echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
6331 if test "$have_utmpx" = "yes" ; then
6332 echo "HAVE_UTMPX=y" >> $config_host_mak
6335 if test "$ivshmem" = "yes" ; then
6336 echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6338 if test "$capstone" != "no" ; then
6339 echo "CONFIG_CAPSTONE=y" >> $config_host_mak
6342 # Hold two types of flag:
6343 # CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
6344 # a thread we have a handle to
6345 # CONFIG_PTHREAD_SETNAME_NP - A way of doing it on a particular
6346 # platform
6347 if test "$pthread_setname_np" = "yes" ; then
6348 echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6349 echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
6352 if test "$vxhs" = "yes" ; then
6353 echo "CONFIG_VXHS=y" >> $config_host_mak
6354 echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
6357 if test "$tcg_interpreter" = "yes"; then
6358 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
6359 elif test "$ARCH" = "sparc64" ; then
6360 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/sparc $QEMU_INCLUDES"
6361 elif test "$ARCH" = "s390x" ; then
6362 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/s390 $QEMU_INCLUDES"
6363 elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then
6364 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES"
6365 elif test "$ARCH" = "ppc64" ; then
6366 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES"
6367 else
6368 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES"
6370 QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES"
6372 echo "TOOLS=$tools" >> $config_host_mak
6373 echo "ROMS=$roms" >> $config_host_mak
6374 echo "MAKE=$make" >> $config_host_mak
6375 echo "INSTALL=$install" >> $config_host_mak
6376 echo "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
6377 echo "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
6378 echo "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
6379 echo "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
6380 echo "PYTHON=$python" >> $config_host_mak
6381 echo "CC=$cc" >> $config_host_mak
6382 if $iasl -h > /dev/null 2>&1; then
6383 echo "IASL=$iasl" >> $config_host_mak
6385 echo "CC_I386=$cc_i386" >> $config_host_mak
6386 echo "HOST_CC=$host_cc" >> $config_host_mak
6387 echo "CXX=$cxx" >> $config_host_mak
6388 echo "OBJCC=$objcc" >> $config_host_mak
6389 echo "AR=$ar" >> $config_host_mak
6390 echo "ARFLAGS=$ARFLAGS" >> $config_host_mak
6391 echo "AS=$as" >> $config_host_mak
6392 echo "CCAS=$ccas" >> $config_host_mak
6393 echo "CPP=$cpp" >> $config_host_mak
6394 echo "OBJCOPY=$objcopy" >> $config_host_mak
6395 echo "LD=$ld" >> $config_host_mak
6396 echo "RANLIB=$ranlib" >> $config_host_mak
6397 echo "NM=$nm" >> $config_host_mak
6398 echo "WINDRES=$windres" >> $config_host_mak
6399 echo "CFLAGS=$CFLAGS" >> $config_host_mak
6400 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6401 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
6402 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6403 echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
6404 if test "$sparse" = "yes" ; then
6405 echo "CC := REAL_CC=\"\$(CC)\" cgcc" >> $config_host_mak
6406 echo "CPP := REAL_CC=\"\$(CPP)\" cgcc" >> $config_host_mak
6407 echo "CXX := REAL_CC=\"\$(CXX)\" cgcc" >> $config_host_mak
6408 echo "HOST_CC := REAL_CC=\"\$(HOST_CC)\" cgcc" >> $config_host_mak
6409 echo "QEMU_CFLAGS += -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
6411 if test "$cross_prefix" != ""; then
6412 echo "AUTOCONF_HOST := --host=${cross_prefix%-}" >> $config_host_mak
6413 else
6414 echo "AUTOCONF_HOST := " >> $config_host_mak
6416 echo "LDFLAGS=$LDFLAGS" >> $config_host_mak
6417 echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
6418 echo "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
6419 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
6420 echo "LIBS+=$LIBS" >> $config_host_mak
6421 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
6422 echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
6423 echo "EXESUF=$EXESUF" >> $config_host_mak
6424 echo "DSOSUF=$DSOSUF" >> $config_host_mak
6425 echo "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
6426 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
6427 echo "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
6428 echo "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
6429 echo "POD2MAN=$POD2MAN" >> $config_host_mak
6430 echo "TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS" >> $config_host_mak
6431 if test "$gcov" = "yes" ; then
6432 echo "CONFIG_GCOV=y" >> $config_host_mak
6433 echo "GCOV=$gcov_tool" >> $config_host_mak
6436 # use included Linux headers
6437 if test "$linux" = "yes" ; then
6438 mkdir -p linux-headers
6439 case "$cpu" in
6440 i386|x86_64|x32)
6441 linux_arch=x86
6443 ppcemb|ppc|ppc64)
6444 linux_arch=powerpc
6446 s390x)
6447 linux_arch=s390
6449 aarch64)
6450 linux_arch=arm64
6452 mips64)
6453 linux_arch=mips
6456 # For most CPUs the kernel architecture name and QEMU CPU name match.
6457 linux_arch="$cpu"
6459 esac
6460 # For non-KVM architectures we will not have asm headers
6461 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
6462 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
6466 for target in $target_list; do
6467 target_dir="$target"
6468 config_target_mak=$target_dir/config-target.mak
6469 target_name=$(echo $target | cut -d '-' -f 1)
6470 target_bigendian="no"
6472 case "$target_name" in
6473 armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
6474 target_bigendian=yes
6476 esac
6477 target_softmmu="no"
6478 target_user_only="no"
6479 target_linux_user="no"
6480 target_bsd_user="no"
6481 case "$target" in
6482 ${target_name}-softmmu)
6483 target_softmmu="yes"
6485 ${target_name}-linux-user)
6486 target_user_only="yes"
6487 target_linux_user="yes"
6489 ${target_name}-bsd-user)
6490 target_user_only="yes"
6491 target_bsd_user="yes"
6494 error_exit "Target '$target' not recognised"
6495 exit 1
6497 esac
6499 mkdir -p $target_dir
6500 echo "# Automatically generated by configure - do not modify" > $config_target_mak
6502 bflt="no"
6503 mttcg="no"
6504 interp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
6505 gdb_xml_files=""
6507 TARGET_ARCH="$target_name"
6508 TARGET_BASE_ARCH=""
6509 TARGET_ABI_DIR=""
6511 case "$target_name" in
6512 i386)
6513 gdb_xml_files="i386-32bit.xml i386-32bit-core.xml i386-32bit-sse.xml"
6515 x86_64)
6516 TARGET_BASE_ARCH=i386
6517 gdb_xml_files="i386-64bit.xml i386-64bit-core.xml i386-64bit-sse.xml"
6519 alpha)
6520 mttcg="yes"
6522 arm|armeb)
6523 TARGET_ARCH=arm
6524 bflt="yes"
6525 mttcg="yes"
6526 gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6528 aarch64)
6529 TARGET_BASE_ARCH=arm
6530 bflt="yes"
6531 mttcg="yes"
6532 gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
6534 cris)
6536 hppa)
6538 lm32)
6540 m68k)
6541 bflt="yes"
6542 gdb_xml_files="cf-core.xml cf-fp.xml m68k-fp.xml"
6544 microblaze|microblazeel)
6545 TARGET_ARCH=microblaze
6546 bflt="yes"
6548 mips|mipsel)
6549 TARGET_ARCH=mips
6550 echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
6552 mipsn32|mipsn32el)
6553 TARGET_ARCH=mips64
6554 TARGET_BASE_ARCH=mips
6555 echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
6556 echo "TARGET_ABI32=y" >> $config_target_mak
6558 mips64|mips64el)
6559 TARGET_ARCH=mips64
6560 TARGET_BASE_ARCH=mips
6561 echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
6563 moxie)
6565 nios2)
6567 or1k)
6568 TARGET_ARCH=openrisc
6569 TARGET_BASE_ARCH=openrisc
6571 ppc)
6572 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6574 ppcemb)
6575 TARGET_BASE_ARCH=ppc
6576 TARGET_ABI_DIR=ppc
6577 gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
6579 ppc64)
6580 TARGET_BASE_ARCH=ppc
6581 TARGET_ABI_DIR=ppc
6582 mttcg=yes
6583 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6585 ppc64le)
6586 TARGET_ARCH=ppc64
6587 TARGET_BASE_ARCH=ppc
6588 TARGET_ABI_DIR=ppc
6589 mttcg=yes
6590 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6592 ppc64abi32)
6593 TARGET_ARCH=ppc64
6594 TARGET_BASE_ARCH=ppc
6595 TARGET_ABI_DIR=ppc
6596 echo "TARGET_ABI32=y" >> $config_target_mak
6597 gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
6599 sh4|sh4eb)
6600 TARGET_ARCH=sh4
6601 bflt="yes"
6603 sparc)
6605 sparc64)
6606 TARGET_BASE_ARCH=sparc
6608 sparc32plus)
6609 TARGET_ARCH=sparc64
6610 TARGET_BASE_ARCH=sparc
6611 TARGET_ABI_DIR=sparc
6612 echo "TARGET_ABI32=y" >> $config_target_mak
6614 s390x)
6615 gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
6617 tilegx)
6619 tricore)
6621 unicore32)
6623 xtensa|xtensaeb)
6624 TARGET_ARCH=xtensa
6627 error_exit "Unsupported target CPU"
6629 esac
6630 # TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
6631 if [ "$TARGET_BASE_ARCH" = "" ]; then
6632 TARGET_BASE_ARCH=$TARGET_ARCH
6635 symlink "$source_path/Makefile.target" "$target_dir/Makefile"
6637 upper() {
6638 echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
6641 target_arch_name="$(upper $TARGET_ARCH)"
6642 echo "TARGET_$target_arch_name=y" >> $config_target_mak
6643 echo "TARGET_NAME=$target_name" >> $config_target_mak
6644 echo "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
6645 if [ "$TARGET_ABI_DIR" = "" ]; then
6646 TARGET_ABI_DIR=$TARGET_ARCH
6648 echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
6649 if [ "$HOST_VARIANT_DIR" != "" ]; then
6650 echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
6653 if supported_xen_target $target; then
6654 echo "CONFIG_XEN=y" >> $config_target_mak
6655 if test "$xen_pci_passthrough" = yes; then
6656 echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
6659 if supported_kvm_target $target; then
6660 echo "CONFIG_KVM=y" >> $config_target_mak
6661 if test "$vhost_net" = "yes" ; then
6662 echo "CONFIG_VHOST_NET=y" >> $config_target_mak
6663 if test "$vhost_user" = "yes" ; then
6664 echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
6668 if supported_hax_target $target; then
6669 echo "CONFIG_HAX=y" >> $config_target_mak
6671 if test "$target_bigendian" = "yes" ; then
6672 echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
6674 if test "$target_softmmu" = "yes" ; then
6675 echo "CONFIG_SOFTMMU=y" >> $config_target_mak
6676 if test "$mttcg" = "yes" ; then
6677 echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
6680 if test "$target_user_only" = "yes" ; then
6681 echo "CONFIG_USER_ONLY=y" >> $config_target_mak
6682 echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
6684 if test "$target_linux_user" = "yes" ; then
6685 echo "CONFIG_LINUX_USER=y" >> $config_target_mak
6687 list=""
6688 if test ! -z "$gdb_xml_files" ; then
6689 for x in $gdb_xml_files; do
6690 list="$list $source_path/gdb-xml/$x"
6691 done
6692 echo "TARGET_XML_FILES=$list" >> $config_target_mak
6695 if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
6696 echo "TARGET_HAS_BFLT=y" >> $config_target_mak
6698 if test "$target_bsd_user" = "yes" ; then
6699 echo "CONFIG_BSD_USER=y" >> $config_target_mak
6702 # generate QEMU_CFLAGS/LDFLAGS for targets
6704 cflags=""
6705 ldflags=""
6707 disas_config() {
6708 echo "CONFIG_${1}_DIS=y" >> $config_target_mak
6709 echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
6712 for i in $ARCH $TARGET_BASE_ARCH ; do
6713 case "$i" in
6714 alpha)
6715 disas_config "ALPHA"
6717 aarch64)
6718 if test -n "${cxx}"; then
6719 disas_config "ARM_A64"
6722 arm)
6723 disas_config "ARM"
6724 if test -n "${cxx}"; then
6725 disas_config "ARM_A64"
6728 cris)
6729 disas_config "CRIS"
6731 hppa)
6732 disas_config "HPPA"
6734 i386|x86_64|x32)
6735 disas_config "I386"
6737 lm32)
6738 disas_config "LM32"
6740 m68k)
6741 disas_config "M68K"
6743 microblaze*)
6744 disas_config "MICROBLAZE"
6746 mips*)
6747 disas_config "MIPS"
6749 moxie*)
6750 disas_config "MOXIE"
6752 nios2)
6753 disas_config "NIOS2"
6755 or1k)
6756 disas_config "OPENRISC"
6758 ppc*)
6759 disas_config "PPC"
6761 s390*)
6762 disas_config "S390"
6764 sh4)
6765 disas_config "SH4"
6767 sparc*)
6768 disas_config "SPARC"
6770 xtensa*)
6771 disas_config "XTENSA"
6773 esac
6774 done
6775 if test "$tcg_interpreter" = "yes" ; then
6776 disas_config "TCI"
6779 case "$ARCH" in
6780 alpha)
6781 # Ensure there's only a single GP
6782 cflags="-msmall-data $cflags"
6784 esac
6786 if test "$gprof" = "yes" ; then
6787 echo "TARGET_GPROF=yes" >> $config_target_mak
6788 if test "$target_linux_user" = "yes" ; then
6789 cflags="-p $cflags"
6790 ldflags="-p $ldflags"
6792 if test "$target_softmmu" = "yes" ; then
6793 ldflags="-p $ldflags"
6794 echo "GPROF_CFLAGS=-p" >> $config_target_mak
6798 if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
6799 ldflags="$ldflags $textseg_ldflags"
6802 # Newer kernels on s390 check for an S390_PGSTE program header and
6803 # enable the pgste page table extensions in that case. This makes
6804 # the vm.allocate_pgste sysctl unnecessary. We enable this program
6805 # header if
6806 # - we build on s390x
6807 # - we build the system emulation for s390x (qemu-system-s390x)
6808 # - KVM is enabled
6809 # - the linker supports --s390-pgste
6810 if test "$TARGET_ARCH" = "s390x" -a "$target_softmmu" = "yes" -a "$ARCH" = "s390x" -a "$kvm" = "yes"; then
6811 if ld_has --s390-pgste ; then
6812 ldflags="-Wl,--s390-pgste $ldflags"
6816 echo "LDFLAGS+=$ldflags" >> $config_target_mak
6817 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
6819 done # for target in $targets
6821 if [ "$dtc_internal" = "yes" ]; then
6822 echo "config-host.h: subdir-dtc" >> $config_host_mak
6824 if [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
6825 echo "config-host.h: subdir-capstone" >> $config_host_mak
6827 if test -n "$LIBCAPSTONE"; then
6828 echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
6831 if test "$numa" = "yes"; then
6832 echo "CONFIG_NUMA=y" >> $config_host_mak
6835 if test "$ccache_cpp2" = "yes"; then
6836 echo "export CCACHE_CPP2=y" >> $config_host_mak
6839 # build tree in object directory in case the source is not in the current directory
6840 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests tests/vm"
6841 DIRS="$DIRS docs docs/interop fsdev scsi"
6842 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
6843 DIRS="$DIRS roms/seabios roms/vgabios"
6844 DIRS="$DIRS qapi-generated"
6845 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
6846 FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
6847 FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile"
6848 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
6849 FILES="$FILES pc-bios/spapr-rtas/Makefile"
6850 FILES="$FILES pc-bios/s390-ccw/Makefile"
6851 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
6852 FILES="$FILES pc-bios/qemu-icon.bmp"
6853 FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
6854 for bios_file in \
6855 $source_path/pc-bios/*.bin \
6856 $source_path/pc-bios/*.lid \
6857 $source_path/pc-bios/*.aml \
6858 $source_path/pc-bios/*.rom \
6859 $source_path/pc-bios/*.dtb \
6860 $source_path/pc-bios/*.img \
6861 $source_path/pc-bios/openbios-* \
6862 $source_path/pc-bios/u-boot.* \
6863 $source_path/pc-bios/palcode-*
6865 FILES="$FILES pc-bios/$(basename $bios_file)"
6866 done
6867 for test_file in $(find $source_path/tests/acpi-test-data -type f)
6869 FILES="$FILES tests/acpi-test-data$(echo $test_file | sed -e 's/.*acpi-test-data//')"
6870 done
6871 mkdir -p $DIRS
6872 for f in $FILES ; do
6873 if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
6874 symlink "$source_path/$f" "$f"
6876 done
6878 # temporary config to build submodules
6879 for rom in seabios vgabios ; do
6880 config_mak=roms/$rom/config.mak
6881 echo "# Automatically generated by configure - do not modify" > $config_mak
6882 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6883 echo "AS=$as" >> $config_mak
6884 echo "CCAS=$ccas" >> $config_mak
6885 echo "CC=$cc" >> $config_mak
6886 echo "BCC=bcc" >> $config_mak
6887 echo "CPP=$cpp" >> $config_mak
6888 echo "OBJCOPY=objcopy" >> $config_mak
6889 echo "IASL=$iasl" >> $config_mak
6890 echo "LD=$ld" >> $config_mak
6891 echo "RANLIB=$ranlib" >> $config_mak
6892 done
6894 # set up tests data directory
6895 if [ ! -e tests/data ]; then
6896 symlink "$source_path/tests/data" tests/data
6899 # set up qemu-iotests in this build directory
6900 iotests_common_env="tests/qemu-iotests/common.env"
6901 iotests_check="tests/qemu-iotests/check"
6903 echo "# Automatically generated by configure - do not modify" > "$iotests_common_env"
6904 echo >> "$iotests_common_env"
6905 echo "export PYTHON='$python'" >> "$iotests_common_env"
6907 if [ ! -e "$iotests_check" ]; then
6908 symlink "$source_path/$iotests_check" "$iotests_check"
6911 # Save the configure command line for later reuse.
6912 cat <<EOD >config.status
6913 #!/bin/sh
6914 # Generated by configure.
6915 # Run this file to recreate the current configuration.
6916 # Compiler output produced by configure, useful for debugging
6917 # configure, is in config.log if it exists.
6919 printf "exec" >>config.status
6920 printf " '%s'" "$0" "$@" >>config.status
6921 echo ' "$@"' >>config.status
6922 chmod +x config.status
6924 rm -r "$TMPDIR1"