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 # make source path absolute
15 source_path=$(cd "$(dirname -- "$0")"; pwd)
17 if test "$PWD" = "$source_path"
19 echo "Using './build' as the directory for build output"
21 MARKER=build/auto-created-by-configure
29 echo "ERROR: ./build dir already exists and was not previously created by configure"
37 cat > GNUmakefile <<'EOF'
38 # This file is auto-generated by configure to support in-source tree
39 # 'make' command invocation
41 ifeq ($(MAKECMDGOALS),)
47 @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48 @$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49 @if test "$(MAKECMDGOALS)" = "distclean" && \
50 test -e build/auto-created-by-configure ; \
52 rm -rf build GNUmakefile ; \
60 exec $source_path/configure "$@"
63 # Temporary directory used for files created while
64 # configure runs. Since it is in the build directory
65 # we can safely blow away any previous version of it
66 # (and we need not jump through hoops to try to delete
67 # it when configure exits.)
72 echo "ERROR: failed to create temporary directory"
77 TMPC="${TMPDIR1}/${TMPB}.c"
78 TMPO="${TMPDIR1}/${TMPB}.o"
79 TMPCXX="${TMPDIR1}/${TMPB}.cxx"
80 TMPM="${TMPDIR1}/${TMPB}.m"
81 TMPE="${TMPDIR1}/${TMPB}.exe"
85 # Print a helpful header at the top of config.log
86 echo "# QEMU configure log $(date)" >> config.log
87 printf "# Configured with:" >> config.log
88 printf " '%s'" "$0" "$@" >> config.log
90 echo "#" >> config.log
93 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
99 while test -n "$2"; do
112 # Run the compiler, capturing its output to the log. First argument
113 # is compiler binary to execute.
116 if test -n "$BASH_VERSION"; then eval '
118 funcs: ${FUNCNAME[*]}
119 lines: ${BASH_LINENO[*]}"
121 echo $compiler "$@" >> config.log
122 $compiler "$@" >> config.log 2>&1 || return $?
123 # Test passed. If this is an --enable-werror build, rerun
124 # the test with -Werror and bail out if it fails. This
125 # makes warning-generating-errors in configure test code
126 # obvious to developers.
127 if test "$werror" != "yes"; then
130 # Don't bother rerunning the compile if we were already using -Werror
136 echo $compiler -Werror "$@" >> config.log
137 $compiler -Werror "$@" >> config.log 2>&1 && return $?
138 error_exit "configure test passed without -Werror but failed with -Werror." \
139 "This is probably a bug in the configure script. The failing command" \
140 "will be at the bottom of config.log." \
141 "You can run configure with --disable-werror to bypass this check."
145 do_compiler "$cc" $CPU_CFLAGS "$@"
149 do_compiler "$cxx" $CPU_CFLAGS "$@"
153 do_compiler "$objcc" $CPU_CFLAGS "$@"
156 # Append $2 to the variable named $1, with space separation
158 eval $1=\${$1:+\"\$$1 \"}\$2
162 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
163 # options which some versions of GCC's C++ compiler complain about
164 # because they only make sense for C programs.
165 QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
166 CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
167 for arg in $QEMU_CFLAGS; do
169 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
170 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
173 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
181 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
187 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
188 $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
191 # symbolically link $1 to $2. Portable version of "ln -sf".
194 mkdir -p "$(dirname "$2")"
198 # check whether a command is available to this shell (may be either an
199 # executable or a builtin)
201 type "$1" >/dev/null 2>&1
205 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
206 local_ver2=$(echo "$2" | tr . ' ')
210 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
214 # the second argument finished, the first must be greater or equal
215 test $# = 1 && return 0
216 test $local_first -lt $2 && return 1
217 test $local_first -gt $2 && return 0
224 eval test -z '"${1#'"$2"'}"'
228 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
231 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
233 error_exit "main directory cannot contain spaces nor colons"
239 interp_prefix="/usr/gnemul/qemu-%M"
243 audio_drv_list="default"
244 block_drv_rw_whitelist=""
245 block_drv_ro_whitelist=""
252 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
254 if test -e "$source_path/.git"
256 git_submodules_action="update"
258 git_submodules_action="ignore"
261 git_submodules="ui/keycodemapdb"
264 # Don't accept a target_list environment variable.
266 unset target_list_exclude
268 # Default value for a variable defining feature "foo".
269 # * foo="no" feature will only be used if --enable-foo arg is given
270 # * foo="" feature will be searched for, and if found, will be used
271 # unless --disable-foo is given
272 # * foo="yes" this value will only be set by --enable-foo flag.
273 # feature will searched for,
274 # if not found, configure exits with error
276 # Always add --enable-foo and --disable-foo command line args.
277 # Distributions want to ensure that several features are compiled in, and it
278 # is impossible without a --enable-foo that exits if a feature is not found.
281 # parse CC options second
283 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
285 --without-default-features)
296 xen_ctrl_version="$default_feature"
297 vhost_kernel="$default_feature"
298 vhost_net="$default_feature"
299 vhost_crypto="$default_feature"
300 vhost_scsi="$default_feature"
301 vhost_vsock="$default_feature"
303 vhost_user_fs="$default_feature"
304 vhost_vdpa="$default_feature"
305 rdma="$default_feature"
306 pvrdma="$default_feature"
324 opengl="$default_feature"
326 tls_priority="NORMAL"
327 plugins="$default_feature"
328 secret_keyring="$default_feature"
332 gio="$default_feature"
335 # The following Meson options are handled manually (still they
336 # are included in the automatically generated help message)
338 # 1. Track which submodules are needed
339 if test "$default_feature" = no ; then
348 # 2. Support --with/--without option
349 default_devices="true"
351 # 3. Automatically enable/disable other options
355 # 4. Detection partly done in configure
356 xen=${default_feature:+disabled}
358 # parse CC options second
360 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
362 --cross-prefix=*) cross_prefix="$optarg"
367 --cxx=*) CXX="$optarg"
369 --cpu=*) cpu="$optarg"
372 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
373 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
374 EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
376 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
378 --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
380 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
382 --enable-debug-info) debug_info="yes"
384 --disable-debug-info) debug_info="no"
386 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
388 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
389 eval "cross_cc_cflags_${cc_arch}=\$optarg"
390 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
392 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
393 eval "cross_cc_${cc_arch}=\$optarg"
394 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
399 # Using uname is really, really broken. Once we have the right set of checks
400 # we can eliminate its usage altogether.
402 # Preferred compiler:
404 # ${cross_prefix}gcc (if cross-prefix specified)
406 if test -z "${CC}${cross_prefix}"; then
409 cc="${CC-${cross_prefix}gcc}"
412 if test -z "${CXX}${cross_prefix}"; then
415 cxx="${CXX-${cross_prefix}g++}"
418 ar="${AR-${cross_prefix}ar}"
419 as="${AS-${cross_prefix}as}"
422 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
423 ld="${LD-${cross_prefix}ld}"
424 ranlib="${RANLIB-${cross_prefix}ranlib}"
425 nm="${NM-${cross_prefix}nm}"
427 strip="${STRIP-${cross_prefix}strip}"
428 windres="${WINDRES-${cross_prefix}windres}"
429 pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
431 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
433 pkg_config=query_pkg_config
434 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
436 # default flags for all hosts
437 # We use -fwrapv to tell the compiler that we require a C dialect where
438 # left shift of signed integers is well defined and has the expected
439 # 2s-complement style results. (Both clang and gcc agree that it
440 # provides these semantics.)
441 QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
442 QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
443 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
444 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
448 # Flags that are needed during configure but later taken care of by Meson
449 CONFIGURE_CFLAGS="-std=gnu11 -Wall"
456 #error $1 not defined
458 int main(void) { return 0; }
466 int main(void) { return 0; }
473 int main(void) { return 0; }
477 if check_define __linux__ ; then
479 elif check_define _WIN32 ; then
481 elif check_define __OpenBSD__ ; then
483 elif check_define __sun__ ; then
485 elif check_define __HAIKU__ ; then
487 elif check_define __FreeBSD__ ; then
489 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
490 targetos=gnu/kfreebsd
491 elif check_define __DragonFly__ ; then
493 elif check_define __NetBSD__; then
495 elif check_define __APPLE__; then
498 # This is a fatal error, but don't report it yet, because we
499 # might be going to just print the --help text, or it might
500 # be the result of a missing compiler.
522 # needed for kinfo_getvmmap(3) in libutil.h
539 # Disable attempts to use ObjectiveC features in os/object.h since they
540 # won't work when we're compiling with gcc as a C compiler.
541 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
546 # needed for CMSG_ macros in sys/socket.h
547 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
548 # needed for TIOCWIN* defines in termios.h
549 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
550 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
551 # Note that this check is broken for cross-compilation: if you're
552 # cross-compiling to one of these OSes then you'll need to specify
553 # the correct CPU with the --cpu option.
554 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
560 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
564 vhost_user=${default_feature:-yes}
568 if test ! -z "$cpu" ; then
569 # command line argument
571 elif check_define __i386__ ; then
573 elif check_define __x86_64__ ; then
574 if check_define __ILP32__ ; then
579 elif check_define __sparc__ ; then
580 if check_define __arch64__ ; then
585 elif check_define _ARCH_PPC ; then
586 if check_define _ARCH_PPC64 ; then
587 if check_define _LITTLE_ENDIAN ; then
595 elif check_define __mips__ ; then
597 elif check_define __s390__ ; then
598 if check_define __s390x__ ; then
603 elif check_define __riscv ; then
605 elif check_define __arm__ ; then
607 elif check_define __aarch64__ ; then
609 elif check_define __loongarch64 ; then
615 # Normalise host CPU name, set multilib cflags
616 # Note that this case should only have supported host CPUs, not guests.
621 i386|i486|i586|i686|i86pc|BePC)
626 CPU_CFLAGS="-mx32" ;;
629 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
630 # If we truly care, we should simply detect this case at
631 # runtime and generate the fallback to serial emulation.
632 CPU_CFLAGS="-m64 -mcx16" ;;
640 CPU_CFLAGS="-m64 -mbig-endian" ;;
643 CPU_CFLAGS="-m64 -mlittle-endian" ;;
652 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
654 CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
657 : ${make=${MAKE-make}}
659 # We prefer python 3.x. A bare 'python' is traditionally
660 # python 2.x, but some distros have it as python 3.x, so
664 for binary in "${PYTHON-python3}" python
668 python=$(command -v "$binary")
674 # Check for ancillary tools used in testing
676 for binary in genisoimage mkisofs
680 genisoimage=$(command -v "$binary")
685 # Default objcc to clang if available, otherwise use CC
692 if test "$mingw32" = "yes" ; then
694 # MinGW needs -mthreads for TLS and macro _MT.
695 CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
703 . $source_path/scripts/meson-buildoptions.sh
706 meson_option_parse() {
707 meson_options="$meson_options $(_meson_option_parse "$@")"
708 if test $? -eq 1; then
709 echo "ERROR: unknown option $1"
710 echo "Try '$0 --help' for more information"
716 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
718 --help|-h) show_help=yes
720 --version|-V) exec cat $source_path/VERSION
722 --prefix=*) prefix="$optarg"
724 --interp-prefix=*) interp_prefix="$optarg"
730 --host-cc=*) host_cc="$optarg"
734 --iasl=*) iasl="$optarg"
736 --objcc=*) objcc="$optarg"
738 --make=*) make="$optarg"
742 --python=*) python="$optarg" ; explicit_python=yes
744 --sphinx-build=*) sphinx_build="$optarg"
746 --skip-meson) skip_meson=yes
748 --meson=*) meson="$optarg"
750 --ninja=*) ninja="$optarg"
752 --smbd=*) smbd="$optarg"
764 --disable-debug-info)
774 --disable-module-upgrades) module_upgrades="no"
776 --enable-module-upgrades) module_upgrades="yes"
780 --target-list=*) target_list="$optarg"
781 if test "$target_list_exclude"; then
782 error_exit "Can't mix --target-list with --target-list-exclude"
785 --target-list-exclude=*) target_list_exclude="$optarg"
786 if test "$target_list"; then
787 error_exit "Can't mix --target-list-exclude with --target-list"
790 --with-trace-file=*) trace_file="$optarg"
792 --with-default-devices) default_devices="true"
794 --without-default-devices) default_devices="false"
796 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
798 --with-devices-*) device_arch=${opt#--with-devices-};
799 device_arch=${device_arch%%=*}
800 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
801 if test -f "$cf"; then
802 device_archs="$device_archs $device_arch"
803 eval "devices_${device_arch}=\$optarg"
805 error_exit "File $cf does not exist"
808 --without-default-features) # processed above
810 --enable-gcov) gcov="yes"
814 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
816 --mandir=*) mandir="$optarg"
818 --bindir=*) bindir="$optarg"
820 --libdir=*) libdir="$optarg"
822 --libexecdir=*) libexecdir="$optarg"
824 --includedir=*) includedir="$optarg"
826 --datadir=*) datadir="$optarg"
828 --with-suffix=*) qemu_suffix="$optarg"
830 --docdir=*) docdir="$optarg"
832 --localedir=*) localedir="$optarg"
834 --sysconfdir=*) sysconfdir="$optarg"
836 --localstatedir=*) local_statedir="$optarg"
838 --firmwarepath=*) firmwarepath="$optarg"
841 --disable-dependency-tracking|\
842 --sbindir=*|--sharedstatedir=*|\
843 --oldincludedir=*|--datarootdir=*|--infodir=*|\
844 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
845 # These switches are silently ignored, for compatibility with
846 # autoconf-generated configure scripts. This allows QEMU's
847 # configure to be used by RPM and similar macros that set
848 # lots of directory switches by default.
850 --audio-drv-list=*) audio_drv_list="$optarg"
852 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
854 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
856 --enable-debug-tcg) debug_tcg="yes"
858 --disable-debug-tcg) debug_tcg="no"
861 # Enable debugging options that aren't excessively noisy
863 meson_option_parse --enable-debug-mutex ""
867 --enable-sanitizers) sanitizers="yes"
869 --disable-sanitizers) sanitizers="no"
871 --enable-tsan) tsan="yes"
873 --disable-tsan) tsan="no"
875 --disable-slirp) slirp="disabled"
877 --enable-slirp) slirp="enabled"
879 --enable-slirp=git) slirp="internal"
881 --enable-slirp=*) slirp="$optarg"
883 --disable-xen) xen="disabled"
885 --enable-xen) xen="enabled"
887 --disable-tcg) tcg="disabled"
890 --enable-tcg) tcg="enabled"
892 --disable-system) softmmu="no"
894 --enable-system) softmmu="yes"
901 --disable-linux-user) linux_user="no"
903 --enable-linux-user) linux_user="yes"
905 --disable-bsd-user) bsd_user="no"
907 --enable-bsd-user) bsd_user="yes"
909 --enable-pie) pie="yes"
911 --disable-pie) pie="no"
913 --enable-werror) werror="yes"
915 --disable-werror) werror="no"
917 --enable-lto) lto="true"
919 --disable-lto) lto="false"
921 --enable-stack-protector) stack_protector="yes"
923 --disable-stack-protector) stack_protector="no"
925 --enable-safe-stack) safe_stack="yes"
927 --disable-safe-stack) safe_stack="no"
933 --disable-cfi) cfi="false"
935 --disable-fdt) fdt="disabled"
937 --enable-fdt) fdt="enabled"
939 --enable-fdt=git) fdt="internal"
941 --enable-fdt=*) fdt="$optarg"
943 --with-pkgversion=*) pkgversion="$optarg"
945 --with-coroutine=*) coroutine="$optarg"
947 --disable-vhost-net) vhost_net="no"
949 --enable-vhost-net) vhost_net="yes"
951 --disable-vhost-crypto) vhost_crypto="no"
953 --enable-vhost-crypto) vhost_crypto="yes"
955 --disable-vhost-scsi) vhost_scsi="no"
957 --enable-vhost-scsi) vhost_scsi="yes"
959 --disable-vhost-vsock) vhost_vsock="no"
961 --enable-vhost-vsock) vhost_vsock="yes"
963 --disable-vhost-user-fs) vhost_user_fs="no"
965 --enable-vhost-user-fs) vhost_user_fs="yes"
967 --disable-opengl) opengl="no"
969 --enable-opengl) opengl="yes"
973 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
974 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
976 --enable-vhdx|--disable-vhdx)
977 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
979 --enable-uuid|--disable-uuid)
980 echo "$0: $opt is obsolete, UUID support is always built" >&2
982 --tls-priority=*) tls_priority="$optarg"
984 --enable-rdma) rdma="yes"
986 --disable-rdma) rdma="no"
988 --enable-pvrdma) pvrdma="yes"
990 --disable-pvrdma) pvrdma="no"
992 --disable-vhost-user) vhost_user="no"
994 --enable-vhost-user) vhost_user="yes"
996 --disable-vhost-vdpa) vhost_vdpa="no"
998 --enable-vhost-vdpa) vhost_vdpa="yes"
1000 --disable-vhost-kernel) vhost_kernel="no"
1002 --enable-vhost-kernel) vhost_kernel="yes"
1004 --disable-capstone) capstone="disabled"
1006 --enable-capstone) capstone="enabled"
1008 --enable-capstone=git) capstone="internal"
1010 --enable-capstone=*) capstone="$optarg"
1012 --with-git=*) git="$optarg"
1014 --with-git-submodules=*)
1015 git_submodules_action="$optarg"
1017 --enable-plugins) if test "$mingw32" = "yes"; then
1018 error_exit "TCG plugins not currently supported on Windows platforms"
1023 --disable-plugins) plugins="no"
1025 --enable-containers) use_containers="yes"
1027 --disable-containers) use_containers="no"
1029 --gdb=*) gdb_bin="$optarg"
1031 --enable-keyring) secret_keyring="yes"
1033 --disable-keyring) secret_keyring="no"
1035 --enable-gio) gio=yes
1037 --disable-gio) gio=no
1039 # backwards compatibility options
1040 --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
1042 --disable-blobs) meson_option_parse --disable-install-blobs ""
1044 --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
1046 --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
1048 # everything else has the same name in configure and meson
1049 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
1052 echo "ERROR: unknown option $opt"
1053 echo "Try '$0 --help' for more information"
1059 # test for any invalid configuration combinations
1060 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1061 error_exit "Can't enable plugins on non-TCG builds"
1064 case $git_submodules_action in
1066 if test ! -e "$source_path/.git"; then
1067 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1072 if ! test -f "$source_path/ui/keycodemapdb/README"
1075 echo "ERROR: missing GIT submodules"
1077 if test -e "$source_path/.git"; then
1078 echo "--with-git-submodules=ignore specified but submodules were not"
1079 echo "checked out. Please initialize and update submodules."
1081 echo "This is not a GIT checkout but module content appears to"
1082 echo "be missing. Do not use 'git archive' or GitHub download links"
1083 echo "to acquire QEMU source archives. Non-GIT builds are only"
1084 echo "supported with source archives linked from:"
1086 echo " https://www.qemu.org/download/#source"
1088 echo "Developers working with GIT can use scripts/archive-source.sh"
1089 echo "if they need to create valid source archives."
1096 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1101 libdir="${libdir:-$prefix/lib}"
1102 libexecdir="${libexecdir:-$prefix/libexec}"
1103 includedir="${includedir:-$prefix/include}"
1105 if test "$mingw32" = "yes" ; then
1106 bindir="${bindir:-$prefix}"
1108 bindir="${bindir:-$prefix/bin}"
1110 mandir="${mandir:-$prefix/share/man}"
1111 datadir="${datadir:-$prefix/share}"
1112 docdir="${docdir:-$prefix/share/doc}"
1113 sysconfdir="${sysconfdir:-$prefix/etc}"
1114 local_statedir="${local_statedir:-$prefix/var}"
1115 firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
1116 localedir="${localedir:-$datadir/locale}"
1118 if eval test -z "\${cross_cc_$cpu}"; then
1119 eval "cross_cc_${cpu}=\$cc"
1120 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
1123 default_target_list=""
1126 if [ "$linux_user" != no ]; then
1127 if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then
1129 elif [ "$linux_user" = yes ]; then
1130 error_exit "linux-user not supported on this architecture"
1133 if [ "$bsd_user" != no ]; then
1134 if [ "$bsd_user" = "" ]; then
1135 test $targetos = freebsd && bsd_user=yes
1137 if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
1138 error_exit "bsd-user not supported on this host OS"
1141 if [ "$softmmu" = "yes" ]; then
1142 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
1144 if [ "$linux_user" = "yes" ]; then
1145 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
1147 if [ "$bsd_user" = "yes" ]; then
1148 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
1151 for config in $mak_wilds; do
1152 target="$(basename "$config" .mak)"
1153 if echo "$target_list_exclude" | grep -vq "$target"; then
1154 default_target_list="${default_target_list} $target"
1158 if test x"$show_help" = x"yes" ; then
1161 Usage: configure [options]
1162 Options: [defaults in brackets after descriptions]
1165 --help print this message
1166 --prefix=PREFIX install in PREFIX [$prefix]
1167 --interp-prefix=PREFIX where to find shared libraries, etc.
1168 use %M for cpu name [$interp_prefix]
1169 --target-list=LIST set target list (default: build all)
1170 $(echo Available targets: $default_target_list | \
1171 fold -s -w 53 | sed -e 's/^/ /')
1172 --target-list-exclude=LIST exclude a set of targets from the default target-list
1174 Advanced options (experts only):
1175 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
1176 --cc=CC use C compiler CC [$cc]
1177 --iasl=IASL use ACPI compiler IASL [$iasl]
1178 --host-cc=CC use C compiler CC [$host_cc] for code run at
1180 --cxx=CXX use C++ compiler CXX [$cxx]
1181 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1182 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
1183 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
1184 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
1185 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1186 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1187 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
1188 --make=MAKE use specified make [$make]
1189 --python=PYTHON use specified python [$python]
1190 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
1191 --meson=MESON use specified meson [$meson]
1192 --ninja=NINJA use specified ninja [$ninja]
1193 --smbd=SMBD use specified smbd [$smbd]
1194 --with-git=GIT use specified git [$git]
1195 --with-git-submodules=update update git submodules (default if .git dir exists)
1196 --with-git-submodules=validate fail if git submodules are not up to date
1197 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
1198 --static enable static build [$static]
1199 --mandir=PATH install man pages in PATH
1200 --datadir=PATH install firmware in PATH/$qemu_suffix
1201 --localedir=PATH install translation in PATH/$qemu_suffix
1202 --docdir=PATH install documentation in PATH/$qemu_suffix
1203 --bindir=PATH install binaries in PATH
1204 --libdir=PATH install libraries in PATH
1205 --libexecdir=PATH install helper binaries in PATH
1206 --sysconfdir=PATH install config in PATH/$qemu_suffix
1207 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1208 --firmwarepath=PATH search PATH for firmware files
1209 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
1210 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1211 --with-pkgversion=VERS use specified string as sub-version of the package
1212 --without-default-features default all --enable-* options to "disabled"
1213 --without-default-devices do not include any device that is not needed to
1214 start the emulator (only use if you are including
1215 desired devices in configs/devices/)
1216 --with-devices-ARCH=NAME override default configs/devices
1217 --enable-debug enable common debug build options
1218 --enable-sanitizers enable default sanitizers
1219 --enable-tsan enable thread sanitizer
1220 --disable-werror disable compilation abort on warning
1221 --disable-stack-protector disable compiler-provided stack protection
1222 --audio-drv-list=LIST set audio drivers to try if -audiodev is not used
1223 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1224 --block-drv-rw-whitelist=L
1225 set block driver read-write whitelist
1226 (by default affects only QEMU, not tools like qemu-img)
1227 --block-drv-ro-whitelist=L
1228 set block driver read-only whitelist
1229 (by default affects only QEMU, not tools like qemu-img)
1230 --with-trace-file=NAME Full PATH,NAME of file to store traces
1232 --cpu=CPU Build for host CPU [$cpu]
1233 --with-coroutine=BACKEND coroutine backend. Supported options:
1234 ucontext, sigaltstack, windows
1235 --enable-gcov enable test coverage analysis with gcov
1236 --tls-priority default TLS protocol/cipher priority string
1238 enable plugins via shared library loading
1239 --disable-containers don't use containers for cross-building
1240 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1244 system all system emulation targets
1245 user supported user emulation targets
1246 linux-user all linux usermode emulation targets
1247 bsd-user all BSD usermode emulation targets
1248 pie Position Independent Executables
1249 modules modules support (non-Windows)
1250 module-upgrades try to load modules from alternate paths for upgrades
1251 debug-tcg TCG debugging (default is disabled)
1252 debug-info debugging information
1253 lto Enable Link-Time Optimization.
1254 safe-stack SafeStack Stack Smash Protection. Depends on
1255 clang/llvm >= 3.7 and requires coroutine backend ucontext.
1256 rdma Enable RDMA-based migration
1257 pvrdma Enable PVRDMA support
1258 vhost-net vhost-net kernel acceleration support
1259 vhost-vsock virtio sockets device support
1260 vhost-scsi vhost-scsi kernel target support
1261 vhost-crypto vhost-user-crypto backend support
1262 vhost-kernel vhost kernel backend support
1263 vhost-user vhost-user backend support
1264 vhost-vdpa vhost-vdpa kernel backend support
1265 opengl opengl support
1268 NOTE: The object files are built at the place where configure is launched
1273 # Remove old dependency files to make sure that they get properly regenerated
1274 rm -f */config-devices.mak.d
1276 if test -z "$python"
1278 error_exit "Python not found. Use --python=/path/to/python"
1282 error_exit "GNU make ($make) not found"
1285 # Note that if the Python conditional here evaluates True we will exit
1286 # with status 1 which is a shell 'false' value.
1287 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1288 error_exit "Cannot use '$python', Python >= 3.6 is required." \
1289 "Use --python=/path/to/python to specify a supported Python."
1292 # Preserve python version since some functionality is dependent on it
1293 python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
1295 # Suppress writing compiled files
1298 if test -z "$meson"; then
1299 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
1301 elif test $git_submodules_action != 'ignore' ; then
1303 elif test -e "${source_path}/meson/meson.py" ; then
1306 if test "$explicit_python" = yes; then
1307 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
1309 error_exit "Meson not found. Use --meson=/path/to/meson"
1313 # Meson uses its own Python interpreter to invoke other Python scripts,
1314 # but the user wants to use the one they specified with --python.
1316 # We do not want to override the distro Python interpreter (and sometimes
1317 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1318 # just require --meson=git|internal together with --python.
1319 if test "$explicit_python" = yes; then
1322 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
1327 if test "$meson" = git; then
1328 git_submodules="${git_submodules} meson"
1333 meson="$python ${source_path}/meson/meson.py"
1335 *) meson=$(command -v "$meson") ;;
1340 if test -z "$ninja"; then
1341 for c in ninja ninja-build samu; do
1343 ninja=$(command -v "$c")
1347 if test -z "$ninja"; then
1348 error_exit "Cannot find Ninja"
1352 # Check that the C compiler works. Doing this here before testing
1353 # the host CPU ensures that we had a valid CC to autodetect the
1354 # $cpu var (and we should bail right here if that's not the case).
1355 # It also allows the help message to be printed without a CC.
1357 if compile_object ; then
1358 : C compiler works ok
1360 error_exit "\"$cc\" either does not exist or does not work"
1362 if ! compile_prog ; then
1363 error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
1366 # Consult white-list to determine whether to enable werror
1367 # by default. Only enable by default for git builds
1368 if test -z "$werror" ; then
1369 if test "$git_submodules_action" != "ignore" && \
1370 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1377 if test "$targetos" = "bogus"; then
1378 # Now that we know that we're not printing the help and that
1379 # the compiler works (so the results of the check_defines we used
1380 # to identify the OS are reliable), if we didn't recognize the
1381 # host OS we should stop now.
1382 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1385 # Check whether the compiler matches our minimum requirements:
1387 #if defined(__clang_major__) && defined(__clang_minor__)
1388 # ifdef __apple_build_version__
1389 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1390 # error You need at least XCode Clang v10.0 to compile QEMU
1393 # if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1394 # error You need at least Clang v6.0 to compile QEMU
1397 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1398 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1399 # error You need at least GCC v7.4.0 to compile QEMU
1402 # error You either need GCC or Clang to compiler QEMU
1404 int main (void) { return 0; }
1406 if ! compile_prog "" "" ; then
1407 error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1410 # Accumulate -Wfoo and -Wno-bar separately.
1411 # We will list all of the enable flags first, and the disable flags second.
1412 # Note that we do not add -Werror, because that would enable it for all
1413 # configure tests. If a configure test failed due to -Werror this would
1414 # just silently disable some features, so it's too error prone.
1417 add_to warn_flags -Wold-style-declaration
1418 add_to warn_flags -Wold-style-definition
1419 add_to warn_flags -Wtype-limits
1420 add_to warn_flags -Wformat-security
1421 add_to warn_flags -Wformat-y2k
1422 add_to warn_flags -Winit-self
1423 add_to warn_flags -Wignored-qualifiers
1424 add_to warn_flags -Wempty-body
1425 add_to warn_flags -Wnested-externs
1426 add_to warn_flags -Wendif-labels
1427 add_to warn_flags -Wexpansion-to-defined
1428 add_to warn_flags -Wimplicit-fallthrough=2
1431 add_to nowarn_flags -Wno-initializer-overrides
1432 add_to nowarn_flags -Wno-missing-include-dirs
1433 add_to nowarn_flags -Wno-shift-negative-value
1434 add_to nowarn_flags -Wno-string-plus-int
1435 add_to nowarn_flags -Wno-typedef-redefinition
1436 add_to nowarn_flags -Wno-tautological-type-limit-compare
1437 add_to nowarn_flags -Wno-psabi
1439 gcc_flags="$warn_flags $nowarn_flags"
1441 cc_has_warning_flag() {
1444 # Use the positive sense of the flag when testing for -Wno-wombat
1445 # support (gcc will happily accept the -Wno- form of unknown
1447 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1448 compile_prog "-Werror $optflag" ""
1451 objcc_has_warning_flag() {
1453 int main(void) { return 0; }
1456 # Use the positive sense of the flag when testing for -Wno-wombat
1457 # support (gcc will happily accept the -Wno- form of unknown
1459 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1460 do_objc -Werror $optflag \
1461 $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
1462 -o $TMPE $TMPM $QEMU_LDFLAGS
1465 for flag in $gcc_flags; do
1466 if cc_has_warning_flag $flag ; then
1467 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1469 if objcc_has_warning_flag $flag ; then
1470 QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag"
1474 if test "$stack_protector" != "no"; then
1476 int main(int argc, char *argv[])
1478 char arr[64], *p = arr, *c = argv[0];
1485 gcc_flags="-fstack-protector-strong -fstack-protector-all"
1487 for flag in $gcc_flags; do
1488 # We need to check both a compile and a link, since some compiler
1489 # setups fail only on a .c->.o compile and some only at link time
1490 if compile_object "-Werror $flag" &&
1491 compile_prog "-Werror $flag" ""; then
1492 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1493 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
1498 if test "$stack_protector" = yes; then
1499 if test $sp_on = 0; then
1500 error_exit "Stack protector not supported"
1505 # Disable -Wmissing-braces on older compilers that warn even for
1506 # the "universal" C zero initializer {0}.
1512 if compile_object "-Werror" "" ; then
1515 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
1518 # Our module code doesn't support Windows
1519 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1520 error_exit "Modules are not available for Windows"
1523 # module_upgrades is only reasonable if modules are enabled
1524 if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1525 error_exit "Can't enable module-upgrades as Modules are not enabled"
1528 # Static linking is not possible with plugins, modules or PIE
1529 if test "$static" = "yes" ; then
1530 if test "$modules" = "yes" ; then
1531 error_exit "static and modules are mutually incompatible"
1533 if test "$plugins" = "yes"; then
1534 error_exit "static and plugins are mutually incompatible"
1539 test "$plugins" = "" && plugins=yes
1544 # define THREAD __thread
1548 static THREAD int tls_var;
1549 int main(void) { return tls_var; }
1552 # Check we support -fno-pie and -no-pie first; we will need the former for
1553 # building ROMs, and both for everything if --disable-pie is passed.
1554 if compile_prog "-Werror -fno-pie" "-no-pie"; then
1555 CFLAGS_NOPIE="-fno-pie"
1556 LDFLAGS_NOPIE="-no-pie"
1559 if test "$static" = "yes"; then
1560 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
1561 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1562 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
1564 elif test "$pie" = "yes"; then
1565 error_exit "-static-pie not available due to missing toolchain support"
1567 QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
1570 elif test "$pie" = "no"; then
1571 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1572 CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
1573 elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
1574 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
1575 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
1577 elif test "$pie" = "yes"; then
1578 error_exit "PIE not available due to missing toolchain support"
1580 echo "Disabling PIE due to missing toolchain support"
1584 # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1585 # The combination is known as "full relro", because .got.plt is read-only too.
1586 if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1587 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1590 ##########################################
1591 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1592 # use i686 as default anyway, but for those that don't, an explicit
1593 # specification is necessary
1595 if test "$cpu" = "i386"; then
1597 static int sfaa(int *ptr)
1599 return __sync_fetch_and_and(ptr, 0);
1605 val = __sync_val_compare_and_swap(&val, 0, 1);
1610 if ! compile_prog "" "" ; then
1611 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
1615 if test "$tcg" = "enabled"; then
1616 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1617 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1620 if test -z "${target_list+xxx}" ; then
1622 for target in $default_target_list; do
1623 target_list="$target_list $target"
1625 target_list="${target_list# }"
1628 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1629 for target in $target_list; do
1630 # Check that we recognised the target name; this allows a more
1631 # friendly error message than if we let it fall through.
1632 case " $default_target_list " in
1636 error_exit "Unknown target name '$target'"
1642 # see if system emulation was really requested
1643 case " $target_list " in
1644 *"-softmmu "*) softmmu=yes
1650 feature_not_found() {
1654 error_exit "User requested feature $feature" \
1655 "configure was not able to find it." \
1660 # big/little endian test
1663 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1664 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1665 int main(int argc, char *argv[])
1667 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
1671 if compile_prog ; then
1672 if strings -a $TMPE | grep -q BiGeNdIaN ; then
1674 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
1677 echo big/little test failed
1681 echo big/little test failed
1685 #########################################
1686 # vhost interdependencies and host support
1689 if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
1690 error_exit "vhost-user is not available on Windows"
1692 test "$vhost_vdpa" = "" && vhost_vdpa=$linux
1693 if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1694 error_exit "vhost-vdpa is only available on Linux"
1696 test "$vhost_kernel" = "" && vhost_kernel=$linux
1697 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1698 error_exit "vhost-kernel is only available on Linux"
1701 # vhost-kernel devices
1702 test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1703 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1704 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1706 test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1707 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1708 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1711 # vhost-user backends
1712 test "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1713 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1714 error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1716 test "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1717 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1718 error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1720 test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
1721 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1722 error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
1724 #vhost-vdpa backends
1725 test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1726 if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1727 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1730 # OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1731 if test "$vhost_net" = ""; then
1732 test "$vhost_net_user" = "yes" && vhost_net=yes
1733 test "$vhost_net_vdpa" = "yes" && vhost_net=yes
1734 test "$vhost_kernel" = "yes" && vhost_net=yes
1737 ##########################################
1740 if ! has "$pkg_config_exe"; then
1741 error_exit "pkg-config binary '$pkg_config_exe' not found"
1744 ##########################################
1747 if test "$xen" != "disabled" ; then
1748 # Check whether Xen library path is specified via --extra-ldflags to avoid
1749 # overriding this setting with pkg-config output. If not, try pkg-config
1750 # to obtain all needed flags.
1752 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
1753 $pkg_config --exists xencontrol ; then
1754 xen_ctrl_version="$(printf '%d%02d%02d' \
1755 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
1757 xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
1758 xen_pc="$xen_pc xenevtchn xendevicemodel"
1759 if $pkg_config --exists xentoolcore; then
1760 xen_pc="$xen_pc xentoolcore"
1762 xen_cflags="$($pkg_config --cflags $xen_pc)"
1763 xen_libs="$($pkg_config --libs $xen_pc)"
1766 xen_libs="-lxenstore -lxenctrl"
1767 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1769 # First we test whether Xen headers and libraries are available.
1770 # If no, we are done and there is no Xen support.
1771 # If yes, more tests are run to detect the Xen version.
1775 #include <xenctrl.h>
1780 if ! compile_prog "" "$xen_libs" ; then
1782 if test "$xen" = "enabled" ; then
1783 feature_not_found "xen" "Install xen devel"
1789 cat > $TMPC <<EOF &&
1790 #undef XC_WANT_COMPAT_DEVICEMODEL_API
1791 #define __XEN_TOOLS__
1792 #include <xendevicemodel.h>
1793 #include <xenforeignmemory.h>
1795 xendevicemodel_handle *xd;
1796 xenforeignmemory_handle *xfmem;
1798 xd = xendevicemodel_open(0, 0);
1799 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
1801 xfmem = xenforeignmemory_open(0, 0);
1802 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
1807 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1809 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1810 xen_ctrl_version=41100
1813 cat > $TMPC <<EOF &&
1814 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1815 #include <xenforeignmemory.h>
1816 #include <xentoolcore.h>
1818 xenforeignmemory_handle *xfmem;
1820 xfmem = xenforeignmemory_open(0, 0);
1821 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
1822 xentoolcore_restrict_all(0);
1827 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1829 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1830 xen_ctrl_version=41000
1833 cat > $TMPC <<EOF &&
1834 #undef XC_WANT_COMPAT_DEVICEMODEL_API
1835 #define __XEN_TOOLS__
1836 #include <xendevicemodel.h>
1838 xendevicemodel_handle *xd;
1840 xd = xendevicemodel_open(0, 0);
1841 xendevicemodel_close(xd);
1846 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
1848 xen_stable_libs="-lxendevicemodel $xen_stable_libs"
1849 xen_ctrl_version=40900
1852 cat > $TMPC <<EOF &&
1854 * If we have stable libs the we don't want the libxc compat
1855 * layers, regardless of what CFLAGS we may have been given.
1857 * Also, check if xengnttab_grant_copy_segment_t is defined and
1858 * grant copy operation is implemented.
1860 #undef XC_WANT_COMPAT_EVTCHN_API
1861 #undef XC_WANT_COMPAT_GNTTAB_API
1862 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1863 #include <xenctrl.h>
1864 #include <xenstore.h>
1865 #include <xenevtchn.h>
1866 #include <xengnttab.h>
1867 #include <xenforeignmemory.h>
1869 #include <xen/hvm/hvm_info_table.h>
1870 #if !defined(HVM_MAX_VCPUS)
1871 # error HVM_MAX_VCPUS not defined
1874 xc_interface *xc = NULL;
1875 xenforeignmemory_handle *xfmem;
1876 xenevtchn_handle *xe;
1877 xengnttab_handle *xg;
1878 xengnttab_grant_copy_segment_t* seg = NULL;
1882 xc = xc_interface_open(0, 0, 0);
1883 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1884 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1885 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1886 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1888 xfmem = xenforeignmemory_open(0, 0);
1889 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1891 xe = xenevtchn_open(0, 0);
1894 xg = xengnttab_open(0, 0);
1895 xengnttab_grant_copy(xg, 0, seg);
1900 compile_prog "" "$xen_libs $xen_stable_libs"
1902 xen_ctrl_version=40800
1905 cat > $TMPC <<EOF &&
1907 * If we have stable libs the we don't want the libxc compat
1908 * layers, regardless of what CFLAGS we may have been given.
1910 #undef XC_WANT_COMPAT_EVTCHN_API
1911 #undef XC_WANT_COMPAT_GNTTAB_API
1912 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1913 #include <xenctrl.h>
1914 #include <xenstore.h>
1915 #include <xenevtchn.h>
1916 #include <xengnttab.h>
1917 #include <xenforeignmemory.h>
1919 #include <xen/hvm/hvm_info_table.h>
1920 #if !defined(HVM_MAX_VCPUS)
1921 # error HVM_MAX_VCPUS not defined
1924 xc_interface *xc = NULL;
1925 xenforeignmemory_handle *xfmem;
1926 xenevtchn_handle *xe;
1927 xengnttab_handle *xg;
1931 xc = xc_interface_open(0, 0, 0);
1932 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1933 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1934 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1935 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1937 xfmem = xenforeignmemory_open(0, 0);
1938 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1940 xe = xenevtchn_open(0, 0);
1943 xg = xengnttab_open(0, 0);
1944 xengnttab_map_grant_ref(xg, 0, 0, 0);
1949 compile_prog "" "$xen_libs $xen_stable_libs"
1951 xen_ctrl_version=40701
1956 cat > $TMPC <<EOF &&
1957 #include <xenctrl.h>
1958 #include <xenstore.h>
1960 #include <xen/hvm/hvm_info_table.h>
1961 #if !defined(HVM_MAX_VCPUS)
1962 # error HVM_MAX_VCPUS not defined
1967 xc = xc_interface_open(0, 0, 0);
1968 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1969 xc_gnttab_open(NULL, 0);
1970 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1971 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1972 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1973 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
1977 compile_prog "" "$xen_libs"
1979 xen_ctrl_version=40600
1984 cat > $TMPC <<EOF &&
1985 #include <xenctrl.h>
1986 #include <xenstore.h>
1988 #include <xen/hvm/hvm_info_table.h>
1989 #if !defined(HVM_MAX_VCPUS)
1990 # error HVM_MAX_VCPUS not defined
1995 xc = xc_interface_open(0, 0, 0);
1996 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1997 xc_gnttab_open(NULL, 0);
1998 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1999 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2000 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
2004 compile_prog "" "$xen_libs"
2006 xen_ctrl_version=40500
2010 cat > $TMPC <<EOF &&
2011 #include <xenctrl.h>
2012 #include <xenstore.h>
2014 #include <xen/hvm/hvm_info_table.h>
2015 #if !defined(HVM_MAX_VCPUS)
2016 # error HVM_MAX_VCPUS not defined
2021 xc = xc_interface_open(0, 0, 0);
2022 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2023 xc_gnttab_open(NULL, 0);
2024 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2025 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2029 compile_prog "" "$xen_libs"
2031 xen_ctrl_version=40200
2035 if test "$xen" = "enabled" ; then
2036 feature_not_found "xen (unsupported version)" \
2037 "Install a supported xen (xen 4.2 or newer)"
2042 if test "$xen" = enabled; then
2043 if test $xen_ctrl_version -ge 40701 ; then
2044 xen_libs="$xen_libs $xen_stable_libs "
2050 ##########################################
2051 # RDMA needs OpenFabrics libraries
2052 if test "$rdma" != "no" ; then
2054 #include <rdma/rdma_cma.h>
2055 int main(void) { return 0; }
2057 rdma_libs="-lrdmacm -libverbs -libumad"
2058 if compile_prog "" "$rdma_libs" ; then
2061 if test "$rdma" = "yes" ; then
2063 " OpenFabrics librdmacm/libibverbs/libibumad not present." \
2065 " (1) Fast: Install infiniband packages (devel) from your distro." \
2066 " (2) Cleanest: Install libraries from www.openfabrics.org" \
2067 " (3) Also: Install softiwarp if you don't have RDMA hardware"
2073 ##########################################
2076 cat > $TMPC <<EOF &&
2077 #include <sys/mman.h>
2084 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
2090 if test "$rdma" = "yes" ; then
2093 if compile_prog "" ""; then
2100 if ! compile_prog "" ""; then
2101 error_exit "PVRDMA is not supported since mremap is not implemented"
2110 if test "$pvrdma" = "yes" ; then
2111 error_exit "PVRDMA requires rdma suppport"
2116 # Let's see if enhanced reg_mr is supported
2117 if test "$pvrdma" = "yes" ; then
2119 cat > $TMPC <<EOF &&
2120 #include <infiniband/verbs.h>
2126 struct ibv_pd *pd = NULL;
2132 mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2139 if ! compile_prog "" "-libverbs"; then
2140 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2144 ##########################################
2145 # glib support probe
2148 glib_modules=gthread-2.0
2149 if test "$modules" = yes; then
2150 glib_modules="$glib_modules gmodule-export-2.0"
2151 elif test "$plugins" = "yes"; then
2152 glib_modules="$glib_modules gmodule-no-export-2.0"
2155 for i in $glib_modules; do
2156 if $pkg_config --atleast-version=$glib_req_ver $i; then
2157 glib_cflags=$($pkg_config --cflags $i)
2158 glib_libs=$($pkg_config --libs $i)
2160 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2164 # This workaround is required due to a bug in pkg-config file for glib as it
2165 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2167 if test "$static" = yes && test "$mingw32" = yes; then
2168 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2171 if ! test "$gio" = "no"; then
2173 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2174 gio_cflags=$($pkg_config --cflags gio-2.0)
2175 gio_libs=$($pkg_config --libs gio-2.0)
2176 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
2177 if ! has "$gdbus_codegen"; then
2180 # Check that the libraries actually work -- Ubuntu 18.04 ships
2181 # with pkg-config --static --libs data for gio-2.0 that is missing
2182 # -lblkid and will give a link error.
2184 #include <gio/gio.h>
2187 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2191 if compile_prog "$gio_cflags" "$gio_libs" ; then
2197 if test "$pass" = "yes" &&
2198 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
2199 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2200 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2204 if test "$pass" = "no"; then
2205 if test "$gio" = "yes"; then
2206 feature_not_found "gio" "Install libgio >= 2.0"
2215 # Sanity check that the current size_t matches the
2216 # size that glib thinks it should be. This catches
2217 # problems on multi-arch where people try to build
2218 # 32-bit QEMU while pointing at 64-bit glib headers
2223 #define QEMU_BUILD_BUG_ON(x) \
2224 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2227 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2232 if ! compile_prog "$glib_cflags" "$glib_libs" ; then
2233 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2234 "You probably need to set PKG_CONFIG_LIBDIR"\
2235 "to point to the right pkg-config files for your"\
2239 # Silence clang warnings triggered by glib < 2.57.2
2242 typedef struct Foo {
2245 static void foo_free(Foo *f)
2249 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free)
2250 int main(void) { return 0; }
2252 if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
2253 if cc_has_warning_flag "-Wno-unused-function"; then
2254 glib_cflags="$glib_cflags -Wno-unused-function"
2255 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
2259 ##########################################
2260 # SHA command probe for modules
2261 if test "$modules" = yes; then
2262 shacmd_probe="sha1sum sha1 shasum"
2263 for c in $shacmd_probe; do
2269 if test "$shacmd" = ""; then
2270 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2274 ##########################################
2278 auto | enabled | internal)
2279 # Simpler to always update submodule, even if not needed.
2280 git_submodules="${git_submodules} dtc"
2284 ##########################################
2285 # opengl probe (for sdl2, gtk)
2287 if test "$opengl" != "no" ; then
2289 if $pkg_config epoxy; then
2291 #include <epoxy/egl.h>
2292 int main(void) { return 0; }
2294 if compile_prog "" "" ; then
2299 if test "$epoxy" = "yes" ; then
2300 opengl_cflags="$($pkg_config --cflags epoxy)"
2301 opengl_libs="$($pkg_config --libs epoxy)"
2304 if test "$opengl" = "yes" ; then
2305 feature_not_found "opengl" "Please install epoxy with EGL"
2315 if test "$linux_user" = "yes"; then
2317 #include <linux/usbdevice_fs.h>
2319 #ifndef USBDEVFS_GET_CAPABILITIES
2320 #error "USBDEVFS_GET_CAPABILITIES undefined"
2323 #ifndef USBDEVFS_DISCONNECT_CLAIM
2324 #error "USBDEVFS_DISCONNECT_CLAIM undefined"
2332 if compile_prog "" ""; then
2337 ##########################################
2341 auto | enabled | internal)
2342 # Simpler to always update submodule, even if not needed.
2343 git_submodules="${git_submodules} capstone"
2347 ##########################################
2348 # check and set a backend for coroutine
2350 # We prefer ucontext, but it's not always possible. The fallback
2351 # is sigcontext. On Windows the only valid backend is the Windows
2355 if test "$darwin" != "yes"; then
2357 #include <ucontext.h>
2358 #ifdef __stub_makecontext
2359 #error Ignoring glibc stub makecontext which will always fail
2361 int main(void) { makecontext(0, 0, 0); return 0; }
2363 if compile_prog "" "" ; then
2368 if test "$coroutine" = ""; then
2369 if test "$mingw32" = "yes"; then
2371 elif test "$ucontext_works" = "yes"; then
2374 coroutine=sigaltstack
2379 if test "$mingw32" != "yes"; then
2380 error_exit "'windows' coroutine backend only valid for Windows"
2382 # Unfortunately the user visible backend name doesn't match the
2383 # coroutine-*.c filename for this case, so we have to adjust it here.
2387 if test "$ucontext_works" != "yes"; then
2388 feature_not_found "ucontext"
2392 if test "$mingw32" = "yes"; then
2393 error_exit "only the 'windows' coroutine backend is valid for Windows"
2397 error_exit "unknown coroutine backend $coroutine"
2402 ##################################################
2406 if test "$safe_stack" = "yes"; then
2408 int main(int argc, char *argv[])
2410 #if ! __has_feature(safe_stack)
2411 #error SafeStack Disabled
2416 flag="-fsanitize=safe-stack"
2417 # Check that safe-stack is supported and enabled.
2418 if compile_prog "-Werror $flag" "$flag"; then
2419 # Flag needed both at compilation and at linking
2420 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2421 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2423 error_exit "SafeStack not supported by your compiler"
2425 if test "$coroutine" != "ucontext"; then
2426 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2430 int main(int argc, char *argv[])
2432 #if defined(__has_feature)
2433 #if __has_feature(safe_stack)
2434 #error SafeStack Enabled
2440 if test "$safe_stack" = "no"; then
2441 # Make sure that safe-stack is disabled
2442 if ! compile_prog "-Werror" ""; then
2443 # SafeStack was already enabled, try to explicitly remove the feature
2444 flag="-fno-sanitize=safe-stack"
2445 if ! compile_prog "-Werror $flag" "$flag"; then
2446 error_exit "Configure cannot disable SafeStack"
2448 QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2449 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
2451 else # "$safe_stack" = ""
2452 # Set safe_stack to yes or no based on pre-existing flags
2453 if compile_prog "-Werror" ""; then
2457 if test "$coroutine" != "ucontext"; then
2458 error_exit "SafeStack is only supported by the coroutine backend ucontext"
2464 ########################################
2465 # check if ccache is interfering with
2466 # semantic analysis of macros
2471 static const int Z = 1;
2472 #define fn() ({ Z; })
2473 #define TAUT(X) ((X) == Z)
2474 #define PAREN(X, Y) (X == Y)
2476 int main(int argc, char *argv[])
2482 if (PAREN(x, y)) return 0;
2483 if (TAUT(Z)) return 0;
2488 if ! compile_object "-Werror"; then
2492 #################################################
2493 # clang does not support glibc + FORTIFY_SOURCE.
2495 if test "$fortify_source" != "no"; then
2496 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
2497 fortify_source="no";
2498 elif test -n "$cxx" && has $cxx &&
2499 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
2500 fortify_source="no";
2502 fortify_source="yes"
2506 ##########################################
2507 # checks for sanitizers
2511 have_asan_iface_h=no
2512 have_asan_iface_fiber=no
2514 if test "$sanitizers" = "yes" ; then
2516 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
2520 # we could use a simple skeleton for flags checks, but this also
2521 # detect the static linking issue of ubsan, see also:
2522 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
2526 void *tmp = malloc(10);
2528 return *(int *)(tmp + 2);
2533 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
2537 if check_include "sanitizer/asan_interface.h" ; then
2538 have_asan_iface_h=yes
2542 #include <sanitizer/asan_interface.h>
2544 __sanitizer_start_switch_fiber(0, 0, 0);
2548 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
2549 have_asan_iface_fiber=yes
2553 # Thread sanitizer is, for now, much noisier than the other sanitizers;
2554 # keep it separate until that is not the case.
2555 if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
2556 error_exit "TSAN is not supported with other sanitiziers."
2559 have_tsan_iface_fiber=no
2560 if test "$tsan" = "yes" ; then
2562 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
2566 #include <sanitizer/tsan_interface.h>
2568 __tsan_create_fiber(0);
2572 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
2573 have_tsan_iface_fiber=yes
2577 ##########################################
2581 auto | enabled | internal)
2582 # Simpler to always update submodule, even if not needed.
2583 git_submodules="${git_submodules} slirp"
2587 ##########################################
2588 # check for usable __NR_keyctl syscall
2590 if test "$linux" = "yes" ; then
2595 #include <asm/unistd.h>
2596 #include <linux/keyctl.h>
2599 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
2602 if compile_prog "" "" ; then
2606 if test "$secret_keyring" != "no"
2608 if test "$have_keyring" = "yes"
2612 if test "$secret_keyring" = "yes"
2614 error_exit "syscall __NR_keyctl requested, \
2615 but not implemented on your system"
2622 ##########################################
2624 # After here, no more $cc or $ld runs
2628 if test "$fortify_source" = "yes" ; then
2629 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
2635 # Ensure there's only a single GP
2636 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
2640 if test "$have_asan" = "yes"; then
2641 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
2642 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
2643 if test "$have_asan_iface_h" = "no" ; then
2644 echo "ASAN build enabled, but ASAN header missing." \
2645 "Without code annotation, the report may be inferior."
2646 elif test "$have_asan_iface_fiber" = "no" ; then
2647 echo "ASAN build enabled, but ASAN header is too old." \
2648 "Without code annotation, the report may be inferior."
2651 if test "$have_tsan" = "yes" ; then
2652 if test "$have_tsan_iface_fiber" = "yes" ; then
2653 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
2654 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
2656 error_exit "Cannot enable TSAN due to missing fiber annotation interface."
2658 elif test "$tsan" = "yes" ; then
2659 error_exit "Cannot enable TSAN due to missing sanitize thread interface."
2661 if test "$have_ubsan" = "yes"; then
2662 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
2663 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
2666 ##########################################
2668 # Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
2669 if test "$solaris" = "no" && test "$tsan" = "no"; then
2670 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
2671 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
2675 # Use ASLR, no-SEH and DEP if available
2676 if test "$mingw32" = "yes" ; then
2677 flags="--no-seh --nxcompat"
2679 # Disable ASLR for debug builds to allow debugging with gdb
2680 if test "$debug" = "no" ; then
2681 flags="--dynamicbase $flags"
2684 for flag in $flags; do
2685 if ld_has $flag ; then
2686 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
2691 # Guest agent Windows MSI package
2693 if test "$QEMU_GA_MANUFACTURER" = ""; then
2694 QEMU_GA_MANUFACTURER=QEMU
2696 if test "$QEMU_GA_DISTRO" = ""; then
2697 QEMU_GA_DISTRO=Linux
2699 if test "$QEMU_GA_VERSION" = ""; then
2700 QEMU_GA_VERSION=$(cat $source_path/VERSION)
2703 QEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
2705 # Mac OS X ships with a broken assembler
2707 if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
2708 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
2709 test "$targetos" != "haiku" && test "$softmmu" = yes ; then
2710 # Different host OS linkers have different ideas about the name of the ELF
2711 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
2712 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
2713 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
2714 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
2715 ld_i386_emulation="$emu"
2722 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
2723 # or -march=z10 (which is the lowest architecture level that Clang supports)
2724 if test "$cpu" = "s390x" ; then
2726 compile_prog "-march=z900" ""
2728 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
2729 if [ $has_z900 != 0 ]; then
2730 echo "WARNING: Your compiler does not support the z900!"
2731 echo " The s390-ccw bios will only work with guest CPUs >= z10."
2733 roms="$roms s390-ccw"
2734 # SLOF is required for building the s390-ccw firmware on s390x,
2735 # since it is using the libnet code from SLOF for network booting.
2736 git_submodules="${git_submodules} roms/SLOF"
2740 # Check that the C++ compiler exists and works with the C compiler.
2741 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
2744 int c_function(void);
2745 int main(void) { return c_function(); }
2752 int c_function(void);
2754 int c_function(void) { return 42; }
2759 if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
2760 # C++ compiler $cxx works ok with C compiler $cc
2763 echo "C++ compiler $cxx does not work with C compiler $cc"
2764 echo "Disabling C++ specific optional code"
2768 echo "No C++ compiler available; disabling C++ specific optional code"
2772 if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
2776 config_host_mak="config-host.mak"
2778 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2779 echo >> $config_host_mak
2781 echo all: >> $config_host_mak
2782 echo "GIT=$git" >> $config_host_mak
2783 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
2784 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
2786 if test "$debug_tcg" = "yes" ; then
2787 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2789 if test "$mingw32" = "yes" ; then
2790 echo "CONFIG_WIN32=y" >> $config_host_mak
2791 echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak
2792 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
2793 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
2794 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
2796 echo "CONFIG_POSIX=y" >> $config_host_mak
2799 if test "$linux" = "yes" ; then
2800 echo "CONFIG_LINUX=y" >> $config_host_mak
2803 if test "$darwin" = "yes" ; then
2804 echo "CONFIG_DARWIN=y" >> $config_host_mak
2807 if test "$solaris" = "yes" ; then
2808 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2810 if test "$static" = "yes" ; then
2811 echo "CONFIG_STATIC=y" >> $config_host_mak
2813 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
2814 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
2815 qemu_version=$(head $source_path/VERSION)
2816 echo "PKGVERSION=$pkgversion" >>$config_host_mak
2817 echo "SRC_PATH=$source_path" >> $config_host_mak
2818 echo "TARGET_DIRS=$target_list" >> $config_host_mak
2819 if test "$modules" = "yes"; then
2820 # $shacmd can generate a hash started with digit, which the compiler doesn't
2821 # like as an symbol. So prefix it with an underscore
2822 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
2823 echo "CONFIG_MODULES=y" >> $config_host_mak
2825 if test "$module_upgrades" = "yes"; then
2826 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
2828 if test "$have_usbfs" = "yes" ; then
2829 echo "CONFIG_USBFS=y" >> $config_host_mak
2831 if test "$gio" = "yes" ; then
2832 echo "CONFIG_GIO=y" >> $config_host_mak
2833 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
2834 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
2836 if test "$gdbus_codegen" != "" ; then
2837 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
2839 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
2841 if test "$xen" = "enabled" ; then
2842 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
2843 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
2844 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
2845 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
2847 if test "$vhost_scsi" = "yes" ; then
2848 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
2850 if test "$vhost_net" = "yes" ; then
2851 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
2853 if test "$vhost_net_user" = "yes" ; then
2854 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
2856 if test "$vhost_net_vdpa" = "yes" ; then
2857 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
2859 if test "$vhost_crypto" = "yes" ; then
2860 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
2862 if test "$vhost_vsock" = "yes" ; then
2863 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
2864 if test "$vhost_user" = "yes" ; then
2865 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
2868 if test "$vhost_kernel" = "yes" ; then
2869 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
2871 if test "$vhost_user" = "yes" ; then
2872 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
2874 if test "$vhost_vdpa" = "yes" ; then
2875 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
2877 if test "$vhost_user_fs" = "yes" ; then
2878 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
2881 if test "$opengl" = "yes" ; then
2882 echo "CONFIG_OPENGL=y" >> $config_host_mak
2883 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
2884 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
2887 # XXX: suppress that
2888 if [ "$bsd" = "yes" ] ; then
2889 echo "CONFIG_BSD=y" >> $config_host_mak
2892 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
2894 if test "$have_asan_iface_fiber" = "yes" ; then
2895 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
2898 if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
2899 echo "CONFIG_TSAN=y" >> $config_host_mak
2902 if test "$rdma" = "yes" ; then
2903 echo "CONFIG_RDMA=y" >> $config_host_mak
2904 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
2907 if test "$pvrdma" = "yes" ; then
2908 echo "CONFIG_PVRDMA=y" >> $config_host_mak
2911 if test "$plugins" = "yes" ; then
2912 echo "CONFIG_PLUGIN=y" >> $config_host_mak
2915 if test -n "$gdb_bin"; then
2916 gdb_version=$($gdb_bin --version | head -n 1)
2917 if version_ge ${gdb_version##* } 9.1; then
2918 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2922 if test "$secret_keyring" = "yes" ; then
2923 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
2926 echo "ROMS=$roms" >> $config_host_mak
2927 echo "MAKE=$make" >> $config_host_mak
2928 echo "PYTHON=$python" >> $config_host_mak
2929 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
2930 echo "MESON=$meson" >> $config_host_mak
2931 echo "NINJA=$ninja" >> $config_host_mak
2932 echo "CC=$cc" >> $config_host_mak
2933 echo "AR=$ar" >> $config_host_mak
2934 echo "AS=$as" >> $config_host_mak
2935 echo "CCAS=$ccas" >> $config_host_mak
2936 echo "CPP=$cpp" >> $config_host_mak
2937 echo "OBJCOPY=$objcopy" >> $config_host_mak
2938 echo "LD=$ld" >> $config_host_mak
2939 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
2940 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2941 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
2942 echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
2943 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
2944 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
2945 echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
2946 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
2947 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
2948 echo "STRIP=$strip" >> $config_host_mak
2949 echo "EXESUF=$EXESUF" >> $config_host_mak
2951 # use included Linux headers
2952 if test "$linux" = "yes" ; then
2953 mkdir -p linux-headers
2968 linux_arch=loongarch
2974 # For most CPUs the kernel architecture name and QEMU CPU name match.
2978 # For non-KVM architectures we will not have asm headers
2979 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
2980 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
2984 for target in $target_list; do
2985 target_dir="$target"
2986 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
2987 mkdir -p $target_dir
2989 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
2990 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
2994 echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
2995 if test "$default_targets" = "yes"; then
2996 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
2999 if test "$ccache_cpp2" = "yes"; then
3000 echo "export CCACHE_CPP2=y" >> $config_host_mak
3003 if test "$safe_stack" = "yes"; then
3004 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
3007 # If we're using a separate build tree, set it up now.
3008 # LINKS are things to symlink back into the source tree
3009 # (these can be both files and directories).
3010 # Caution: do not add files or directories here using wildcards. This
3011 # will result in problems later if a new file matching the wildcard is
3012 # added to the source tree -- nothing will cause configure to be rerun
3013 # so the build tree will be missing the link back to the new file, and
3014 # tests might fail. Prefer to keep the relevant files in their own
3015 # directory and symlink the directory instead.
3017 LINKS="$LINKS tests/tcg/Makefile.target"
3018 LINKS="$LINKS pc-bios/optionrom/Makefile"
3019 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
3020 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
3021 LINKS="$LINKS tests/avocado tests/data"
3022 LINKS="$LINKS tests/qemu-iotests/check"
3023 LINKS="$LINKS python"
3024 LINKS="$LINKS contrib/plugins/Makefile "
3026 $source_path/pc-bios/*.bin \
3027 $source_path/pc-bios/*.elf \
3028 $source_path/pc-bios/*.lid \
3029 $source_path/pc-bios/*.rom \
3030 $source_path/pc-bios/*.dtb \
3031 $source_path/pc-bios/*.img \
3032 $source_path/pc-bios/openbios-* \
3033 $source_path/pc-bios/u-boot.* \
3034 $source_path/pc-bios/palcode-* \
3035 $source_path/pc-bios/qemu_vga.ndrv
3038 LINKS="$LINKS pc-bios/$(basename $bios_file)"
3040 for f in $LINKS ; do
3041 if [ -e "$source_path/$f" ]; then
3042 mkdir -p `dirname ./$f`
3043 symlink "$source_path/$f" "$f"
3047 (for i in $cross_cc_vars; do
3050 export target_list source_path use_containers cpu host_cc
3051 $source_path/tests/tcg/configure.sh)
3053 config_mak=pc-bios/optionrom/config.mak
3054 echo "# Automatically generated by configure - do not modify" > $config_mak
3055 echo "TOPSRC_DIR=$source_path" >> $config_mak
3057 if test "$skip_meson" = no; then
3058 cross="config-meson.cross.new"
3060 test $# = 0 && return
3061 echo "'$(echo $* | sed "s/ /','/g")'"
3064 echo "# Automatically generated by configure - do not modify" > $cross
3065 echo "[properties]" >> $cross
3067 # unroll any custom device configs
3068 for a in $device_archs; do
3069 eval "c=\$devices_${a}"
3070 echo "${a}-softmmu = '$c'" >> $cross
3073 test -z "$cxx" && echo "link_language = 'c'" >> $cross
3074 echo "[built-in options]" >> $cross
3075 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
3076 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
3077 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
3078 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
3079 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
3080 echo "[binaries]" >> $cross
3081 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
3082 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
3083 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
3084 echo "ar = [$(meson_quote $ar)]" >> $cross
3085 echo "nm = [$(meson_quote $nm)]" >> $cross
3086 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
3087 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3088 if has $sdl2_config; then
3089 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3091 echo "strip = [$(meson_quote $strip)]" >> $cross
3092 echo "windres = [$(meson_quote $windres)]" >> $cross
3093 if test "$cross_compile" = "yes"; then
3094 cross_arg="--cross-file config-meson.cross"
3095 echo "[host_machine]" >> $cross
3096 echo "system = '$targetos'" >> $cross
3099 echo "cpu_family = 'x86'" >> $cross
3102 echo "cpu_family = '$cpu'" >> $cross
3105 echo "cpu = '$cpu'" >> $cross
3106 if test "$bigendian" = "yes" ; then
3107 echo "endian = 'big'" >> $cross
3109 echo "endian = 'little'" >> $cross
3112 cross_arg="--native-file config-meson.cross"
3114 mv $cross config-meson.cross
3116 rm -rf meson-private meson-info meson-logs
3118 NINJA=$ninja $meson setup \
3119 --prefix "$prefix" \
3120 --libdir "$libdir" \
3121 --libexecdir "$libexecdir" \
3122 --bindir "$bindir" \
3123 --includedir "$includedir" \
3124 --datadir "$datadir" \
3125 --mandir "$mandir" \
3126 --sysconfdir "$sysconfdir" \
3127 --localedir "$localedir" \
3128 --localstatedir "$local_statedir" \
3129 -Daudio_drv_list=$audio_drv_list \
3130 -Ddefault_devices=$default_devices \
3131 -Ddocdir="$docdir" \
3132 -Diasl="$($iasl -h >/dev/null 2>&1 && printf %s "$iasl")" \
3133 -Dqemu_firmwarepath="$firmwarepath" \
3134 -Dqemu_suffix="$qemu_suffix" \
3136 -Dsphinx_build="$sphinx_build" \
3137 -Dtrace_file="$trace_file" \
3138 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
3139 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
3140 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
3141 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
3142 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
3143 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
3144 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
3145 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
3146 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
3147 "$@" $cross_arg "$PWD" "$source_path"
3149 eval run_meson $meson_options
3150 if test "$?" -ne 0 ; then
3151 error_exit "meson setup failed"
3154 if test -f meson-private/cmd_line.txt; then
3155 # Adjust old command line options whose type was changed
3156 # Avoids having to use "setup --wipe" when Meson is upgraded
3158 s/^gettext = true$/gettext = auto/;
3159 s/^gettext = false$/gettext = disabled/;
3160 /^b_staticpic/ && next;
3161 print;' meson-private/cmd_line.txt
3165 # Save the configure command line for later reuse.
3166 cat <<EOD >config.status
3168 # Generated by configure.
3169 # Run this file to recreate the current configuration.
3170 # Compiler output produced by configure, useful for debugging
3171 # configure, is in config.log if it exists.
3177 eval envval=\$$envname
3179 if test -n "$envval"
3181 echo "$envname='$envval'" >> config.status
3182 echo "export $envname" >> config.status
3184 echo "unset $envname" >> config.status
3188 # Preserve various env variables that influence what
3189 # features/build target configure will detect
3196 preserve_env CXXFLAGS
3197 preserve_env INSTALL
3199 preserve_env LDFLAGS
3200 preserve_env LD_LIBRARY_PATH
3201 preserve_env LIBTOOL
3204 preserve_env OBJCOPY
3206 preserve_env PKG_CONFIG
3207 preserve_env PKG_CONFIG_LIBDIR
3208 preserve_env PKG_CONFIG_PATH
3210 preserve_env SDL2_CONFIG
3213 preserve_env WINDRES
3215 printf "exec" >>config.status
3216 for i in "$0" "$@"; do
3217 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
3219 echo ' "$@"' >>config.status
3220 chmod +x config.status