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
=""
251 gdb_bin
=$
(command -v "gdb-multiarch" ||
command -v "gdb")
253 if test -e "$source_path/.git"
255 git_submodules_action
="update"
257 git_submodules_action
="ignore"
260 git_submodules
="ui/keycodemapdb"
263 # Don't accept a target_list environment variable.
265 unset target_list_exclude
267 # Default value for a variable defining feature "foo".
268 # * foo="no" feature will only be used if --enable-foo arg is given
269 # * foo="" feature will be searched for, and if found, will be used
270 # unless --disable-foo is given
271 # * foo="yes" this value will only be set by --enable-foo flag.
272 # feature will searched for,
273 # if not found, configure exits with error
275 # Always add --enable-foo and --disable-foo command line args.
276 # Distributions want to ensure that several features are compiled in, and it
277 # is impossible without a --enable-foo that exits if a feature is not found.
280 # parse CC options second
282 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
284 --without-default-features)
295 xen_ctrl_version
="$default_feature"
296 vhost_kernel
="$default_feature"
297 vhost_net
="$default_feature"
298 vhost_crypto
="$default_feature"
299 vhost_scsi
="$default_feature"
300 vhost_vsock
="$default_feature"
302 vhost_user_fs
="$default_feature"
303 vhost_vdpa
="$default_feature"
323 tls_priority
="NORMAL"
324 plugins
="$default_feature"
328 gio
="$default_feature"
331 # The following Meson options are handled manually (still they
332 # are included in the automatically generated help message)
334 # 1. Track which submodules are needed
335 if test "$default_feature" = no
; then
344 # 2. Support --with/--without option
345 default_devices
="true"
347 # 3. Automatically enable/disable other options
351 # 4. Detection partly done in configure
352 xen
=${default_feature:+disabled}
354 # parse CC options second
356 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
358 --cross-prefix=*) cross_prefix
="$optarg"
363 --cxx=*) CXX
="$optarg"
365 --cpu=*) cpu
="$optarg"
368 EXTRA_CFLAGS
="$EXTRA_CFLAGS $optarg"
369 EXTRA_CXXFLAGS
="$EXTRA_CXXFLAGS $optarg"
370 EXTRA_OBJCFLAGS
="$EXTRA_OBJCFLAGS $optarg"
372 --extra-cxxflags=*) EXTRA_CXXFLAGS
="$EXTRA_CXXFLAGS $optarg"
374 --extra-objcflags=*) EXTRA_OBJCFLAGS
="$EXTRA_OBJCFLAGS $optarg"
376 --extra-ldflags=*) EXTRA_LDFLAGS
="$EXTRA_LDFLAGS $optarg"
378 --cross-cc-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --cross-cc-FOO option"
380 --cross-cc-cflags-*) cc_arch
=${opt#--cross-cc-cflags-}; cc_arch
=${cc_arch%%=*}
381 eval "cross_cc_cflags_${cc_arch}=\$optarg"
382 cross_cc_vars
="$cross_cc_vars cross_cc_cflags_${cc_arch}"
384 --cross-cc-*) cc_arch
=${opt#--cross-cc-}; cc_arch
=${cc_arch%%=*}
385 eval "cross_cc_${cc_arch}=\$optarg"
386 cross_cc_vars
="$cross_cc_vars cross_cc_${cc_arch}"
391 # Using uname is really, really broken. Once we have the right set of checks
392 # we can eliminate its usage altogether.
394 # Preferred compiler:
396 # ${cross_prefix}gcc (if cross-prefix specified)
398 if test -z "${CC}${cross_prefix}"; then
401 cc
="${CC-${cross_prefix}gcc}"
404 if test -z "${CXX}${cross_prefix}"; then
407 cxx
="${CXX-${cross_prefix}g++}"
410 ar="${AR-${cross_prefix}ar}"
411 as
="${AS-${cross_prefix}as}"
414 objcopy
="${OBJCOPY-${cross_prefix}objcopy}"
415 ld
="${LD-${cross_prefix}ld}"
416 ranlib
="${RANLIB-${cross_prefix}ranlib}"
417 nm
="${NM-${cross_prefix}nm}"
419 strip
="${STRIP-${cross_prefix}strip}"
420 windres
="${WINDRES-${cross_prefix}windres}"
421 pkg_config_exe
="${PKG_CONFIG-${cross_prefix}pkg-config}"
423 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
425 pkg_config
=query_pkg_config
426 sdl2_config
="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
428 # default flags for all hosts
429 # We use -fwrapv to tell the compiler that we require a C dialect where
430 # left shift of signed integers is well defined and has the expected
431 # 2s-complement style results. (Both clang and gcc agree that it
432 # provides these semantics.)
433 QEMU_CFLAGS
="-fno-strict-aliasing -fno-common -fwrapv"
434 QEMU_CFLAGS
="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
435 QEMU_CFLAGS
="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
436 QEMU_CFLAGS
="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
440 # Flags that are needed during configure but later taken care of by Meson
441 CONFIGURE_CFLAGS
="-std=gnu11 -Wall"
448 #error $1 not defined
450 int main(void) { return 0; }
458 int main(void) { return 0; }
465 int main(void) { return 0; }
469 if check_define __linux__
; then
471 elif check_define _WIN32
; then
473 elif check_define __OpenBSD__
; then
475 elif check_define __sun__
; then
477 elif check_define __HAIKU__
; then
479 elif check_define __FreeBSD__
; then
481 elif check_define __FreeBSD_kernel__
&& check_define __GLIBC__
; then
482 targetos
=gnu
/kfreebsd
483 elif check_define __DragonFly__
; then
485 elif check_define __NetBSD__
; then
487 elif check_define __APPLE__
; then
490 # This is a fatal error, but don't report it yet, because we
491 # might be going to just print the --help text, or it might
492 # be the result of a missing compiler.
514 # needed for kinfo_getvmmap(3) in libutil.h
531 # Disable attempts to use ObjectiveC features in os/object.h since they
532 # won't work when we're compiling with gcc as a C compiler.
533 QEMU_CFLAGS
="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
538 # needed for CMSG_ macros in sys/socket.h
539 QEMU_CFLAGS
="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
540 # needed for TIOCWIN* defines in termios.h
541 QEMU_CFLAGS
="-D__EXTENSIONS__ $QEMU_CFLAGS"
542 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
543 # Note that this check is broken for cross-compilation: if you're
544 # cross-compiling to one of these OSes then you'll need to specify
545 # the correct CPU with the --cpu option.
546 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
552 QEMU_CFLAGS
="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
556 vhost_user
=${default_feature:-yes}
560 if test ! -z "$cpu" ; then
561 # command line argument
563 elif check_define __i386__
; then
565 elif check_define __x86_64__
; then
566 if check_define __ILP32__
; then
571 elif check_define __sparc__
; then
572 if check_define __arch64__
; then
577 elif check_define _ARCH_PPC
; then
578 if check_define _ARCH_PPC64
; then
579 if check_define _LITTLE_ENDIAN
; then
587 elif check_define __mips__
; then
589 elif check_define __s390__
; then
590 if check_define __s390x__
; then
595 elif check_define __riscv
; then
597 elif check_define __arm__
; then
599 elif check_define __aarch64__
; then
601 elif check_define __loongarch64
; then
607 # Normalise host CPU name, set multilib cflags
608 # Note that this case should only have supported host CPUs, not guests.
613 i386|i486|i586|i686|i86pc|BePC
)
618 CPU_CFLAGS
="-mx32" ;;
621 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
622 # If we truly care, we should simply detect this case at
623 # runtime and generate the fallback to serial emulation.
624 CPU_CFLAGS
="-m64 -mcx16" ;;
632 CPU_CFLAGS
="-m64 -mbig-endian" ;;
635 CPU_CFLAGS
="-m64 -mlittle-endian" ;;
644 CPU_CFLAGS
="-m32 -mv8plus -mcpu=ultrasparc" ;;
646 CPU_CFLAGS
="-m64 -mcpu=ultrasparc" ;;
649 : ${make=${MAKE-make}}
651 # We prefer python 3.x. A bare 'python' is traditionally
652 # python 2.x, but some distros have it as python 3.x, so
656 for binary
in "${PYTHON-python3}" python
660 python
=$
(command -v "$binary")
666 # Check for ancillary tools used in testing
668 for binary
in genisoimage mkisofs
672 genisoimage
=$
(command -v "$binary")
677 # Default objcc to clang if available, otherwise use CC
684 if test "$mingw32" = "yes" ; then
686 # MinGW needs -mthreads for TLS and macro _MT.
687 CONFIGURE_CFLAGS
="-mthreads $CONFIGURE_CFLAGS"
695 .
$source_path/scripts
/meson-buildoptions.sh
698 meson_option_parse
() {
699 meson_options
="$meson_options $(_meson_option_parse "$@
")"
700 if test $?
-eq 1; then
701 echo "ERROR: unknown option $1"
702 echo "Try '$0 --help' for more information"
708 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
710 --help|
-h) show_help
=yes
712 --version|
-V) exec cat $source_path/VERSION
714 --prefix=*) prefix
="$optarg"
716 --interp-prefix=*) interp_prefix
="$optarg"
722 --host-cc=*) host_cc
="$optarg"
726 --iasl=*) iasl
="$optarg"
728 --objcc=*) objcc
="$optarg"
730 --make=*) make="$optarg"
734 --python=*) python
="$optarg" ; explicit_python
=yes
736 --sphinx-build=*) sphinx_build
="$optarg"
738 --skip-meson) skip_meson
=yes
740 --meson=*) meson
="$optarg"
742 --ninja=*) ninja
="$optarg"
744 --smbd=*) smbd
="$optarg"
756 --enable-debug-info) debug_info
="yes"
758 --disable-debug-info) debug_info
="no"
766 --disable-module-upgrades) module_upgrades
="no"
768 --enable-module-upgrades) module_upgrades
="yes"
772 --target-list=*) target_list
="$optarg"
773 if test "$target_list_exclude"; then
774 error_exit
"Can't mix --target-list with --target-list-exclude"
777 --target-list-exclude=*) target_list_exclude
="$optarg"
778 if test "$target_list"; then
779 error_exit
"Can't mix --target-list-exclude with --target-list"
782 --with-trace-file=*) trace_file
="$optarg"
784 --with-default-devices) default_devices
="true"
786 --without-default-devices) default_devices
="false"
788 --with-devices-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --with-devices-FOO option"
790 --with-devices-*) device_arch
=${opt#--with-devices-};
791 device_arch
=${device_arch%%=*}
792 cf
=$source_path/configs
/devices
/$device_arch-softmmu/$optarg.mak
793 if test -f "$cf"; then
794 device_archs
="$device_archs $device_arch"
795 eval "devices_${device_arch}=\$optarg"
797 error_exit
"File $cf does not exist"
800 --without-default-features) # processed above
802 --enable-gcov) gcov
="yes"
806 QEMU_PKG_CONFIG_FLAGS
="--static $QEMU_PKG_CONFIG_FLAGS"
808 --mandir=*) mandir
="$optarg"
810 --bindir=*) bindir
="$optarg"
812 --libdir=*) libdir
="$optarg"
814 --libexecdir=*) libexecdir
="$optarg"
816 --includedir=*) includedir
="$optarg"
818 --datadir=*) datadir
="$optarg"
820 --with-suffix=*) qemu_suffix
="$optarg"
822 --docdir=*) docdir
="$optarg"
824 --localedir=*) localedir
="$optarg"
826 --sysconfdir=*) sysconfdir
="$optarg"
828 --localstatedir=*) local_statedir
="$optarg"
830 --firmwarepath=*) firmwarepath
="$optarg"
833 --disable-dependency-tracking|\
834 --sbindir=*|
--sharedstatedir=*|\
835 --oldincludedir=*|
--datarootdir=*|
--infodir=*|\
836 --htmldir=*|
--dvidir=*|
--pdfdir=*|
--psdir=*)
837 # These switches are silently ignored, for compatibility with
838 # autoconf-generated configure scripts. This allows QEMU's
839 # configure to be used by RPM and similar macros that set
840 # lots of directory switches by default.
842 --audio-drv-list=*) audio_drv_list
="$optarg"
844 --block-drv-rw-whitelist=*|
--block-drv-whitelist=*) block_drv_rw_whitelist
=$
(echo "$optarg" |
sed -e 's/,/ /g')
846 --block-drv-ro-whitelist=*) block_drv_ro_whitelist
=$
(echo "$optarg" |
sed -e 's/,/ /g')
848 --enable-debug-tcg) debug_tcg
="yes"
850 --disable-debug-tcg) debug_tcg
="no"
853 # Enable debugging options that aren't excessively noisy
855 meson_option_parse
--enable-debug-mutex ""
859 --enable-sanitizers) sanitizers
="yes"
861 --disable-sanitizers) sanitizers
="no"
863 --enable-tsan) tsan
="yes"
865 --disable-tsan) tsan
="no"
867 --disable-slirp) slirp
="disabled"
869 --enable-slirp) slirp
="enabled"
871 --enable-slirp=git
) slirp
="internal"
873 --enable-slirp=*) slirp
="$optarg"
875 --disable-xen) xen
="disabled"
877 --enable-xen) xen
="enabled"
879 --disable-tcg) tcg
="disabled"
882 --enable-tcg) tcg
="enabled"
884 --disable-system) softmmu
="no"
886 --enable-system) softmmu
="yes"
893 --disable-linux-user) linux_user
="no"
895 --enable-linux-user) linux_user
="yes"
897 --disable-bsd-user) bsd_user
="no"
899 --enable-bsd-user) bsd_user
="yes"
901 --enable-pie) pie
="yes"
903 --disable-pie) pie
="no"
905 --enable-werror) werror
="yes"
907 --disable-werror) werror
="no"
909 --enable-lto) lto
="true"
911 --disable-lto) lto
="false"
913 --enable-stack-protector) stack_protector
="yes"
915 --disable-stack-protector) stack_protector
="no"
917 --enable-safe-stack) safe_stack
="yes"
919 --disable-safe-stack) safe_stack
="no"
925 --disable-cfi) cfi
="false"
927 --disable-fdt) fdt
="disabled"
929 --enable-fdt) fdt
="enabled"
931 --enable-fdt=git
) fdt
="internal"
933 --enable-fdt=*) fdt
="$optarg"
935 --with-pkgversion=*) pkgversion
="$optarg"
937 --with-coroutine=*) coroutine
="$optarg"
939 --disable-vhost-net) vhost_net
="no"
941 --enable-vhost-net) vhost_net
="yes"
943 --disable-vhost-crypto) vhost_crypto
="no"
945 --enable-vhost-crypto) vhost_crypto
="yes"
947 --disable-vhost-scsi) vhost_scsi
="no"
949 --enable-vhost-scsi) vhost_scsi
="yes"
951 --disable-vhost-vsock) vhost_vsock
="no"
953 --enable-vhost-vsock) vhost_vsock
="yes"
955 --disable-vhost-user-fs) vhost_user_fs
="no"
957 --enable-vhost-user-fs) vhost_user_fs
="yes"
961 --disable-virtio-blk-data-plane|
--enable-virtio-blk-data-plane)
962 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
964 --enable-vhdx|
--disable-vhdx)
965 echo "$0: $opt is obsolete, VHDX driver is always built" >&2
967 --enable-uuid|
--disable-uuid)
968 echo "$0: $opt is obsolete, UUID support is always built" >&2
970 --tls-priority=*) tls_priority
="$optarg"
972 --disable-vhost-user) vhost_user
="no"
974 --enable-vhost-user) vhost_user
="yes"
976 --disable-vhost-vdpa) vhost_vdpa
="no"
978 --enable-vhost-vdpa) vhost_vdpa
="yes"
980 --disable-vhost-kernel) vhost_kernel
="no"
982 --enable-vhost-kernel) vhost_kernel
="yes"
984 --disable-capstone) capstone
="disabled"
986 --enable-capstone) capstone
="enabled"
988 --enable-capstone=git
) capstone
="internal"
990 --enable-capstone=*) capstone
="$optarg"
992 --with-git=*) git
="$optarg"
994 --with-git-submodules=*)
995 git_submodules_action
="$optarg"
997 --enable-plugins) if test "$mingw32" = "yes"; then
998 error_exit
"TCG plugins not currently supported on Windows platforms"
1003 --disable-plugins) plugins
="no"
1005 --enable-containers) use_containers
="yes"
1007 --disable-containers) use_containers
="no"
1009 --gdb=*) gdb_bin
="$optarg"
1011 --enable-gio) gio
=yes
1013 --disable-gio) gio
=no
1015 # backwards compatibility options
1016 --enable-trace-backend=*) meson_option_parse
"--enable-trace-backends=$optarg" "$optarg"
1018 --disable-blobs) meson_option_parse
--disable-install-blobs ""
1020 --enable-tcmalloc) meson_option_parse
--enable-malloc=tcmalloc tcmalloc
1022 --enable-jemalloc) meson_option_parse
--enable-malloc=jemalloc jemalloc
1024 # everything else has the same name in configure and meson
1025 --enable-* |
--disable-*) meson_option_parse
"$opt" "$optarg"
1028 echo "ERROR: unknown option $opt"
1029 echo "Try '$0 --help' for more information"
1035 # test for any invalid configuration combinations
1036 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1037 error_exit
"Can't enable plugins on non-TCG builds"
1040 case $git_submodules_action in
1042 if test ! -e "$source_path/.git"; then
1043 echo "ERROR: cannot $git_submodules_action git submodules without .git"
1048 if ! test -f "$source_path/ui/keycodemapdb/README"
1051 echo "ERROR: missing GIT submodules"
1053 if test -e "$source_path/.git"; then
1054 echo "--with-git-submodules=ignore specified but submodules were not"
1055 echo "checked out. Please initialize and update submodules."
1057 echo "This is not a GIT checkout but module content appears to"
1058 echo "be missing. Do not use 'git archive' or GitHub download links"
1059 echo "to acquire QEMU source archives. Non-GIT builds are only"
1060 echo "supported with source archives linked from:"
1062 echo " https://www.qemu.org/download/#source"
1064 echo "Developers working with GIT can use scripts/archive-source.sh"
1065 echo "if they need to create valid source archives."
1072 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1077 libdir
="${libdir:-$prefix/lib}"
1078 libexecdir
="${libexecdir:-$prefix/libexec}"
1079 includedir
="${includedir:-$prefix/include}"
1081 if test "$mingw32" = "yes" ; then
1082 bindir
="${bindir:-$prefix}"
1084 bindir
="${bindir:-$prefix/bin}"
1086 mandir
="${mandir:-$prefix/share/man}"
1087 datadir
="${datadir:-$prefix/share}"
1088 docdir
="${docdir:-$prefix/share/doc}"
1089 sysconfdir
="${sysconfdir:-$prefix/etc}"
1090 local_statedir
="${local_statedir:-$prefix/var}"
1091 firmwarepath
="${firmwarepath:-$datadir/qemu-firmware}"
1092 localedir
="${localedir:-$datadir/locale}"
1094 if eval test -z "\${cross_cc_$cpu}"; then
1095 eval "cross_cc_${cpu}=\$cc"
1096 cross_cc_vars
="$cross_cc_vars cross_cc_${cpu}"
1099 default_target_list
=""
1102 if [ "$linux_user" != no
]; then
1103 if [ "$targetos" = linux
] && [ -d $source_path/linux-user
/include
/host
/$cpu ]; then
1105 elif [ "$linux_user" = yes ]; then
1106 error_exit
"linux-user not supported on this architecture"
1109 if [ "$bsd_user" != no
]; then
1110 if [ "$bsd_user" = "" ]; then
1111 test $targetos = freebsd
&& bsd_user
=yes
1113 if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user
/$targetos ]; then
1114 error_exit
"bsd-user not supported on this host OS"
1117 if [ "$softmmu" = "yes" ]; then
1118 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
1120 if [ "$linux_user" = "yes" ]; then
1121 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
1123 if [ "$bsd_user" = "yes" ]; then
1124 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
1127 for config
in $mak_wilds; do
1128 target
="$(basename "$config" .mak)"
1129 if echo "$target_list_exclude" |
grep -vq "$target"; then
1130 default_target_list
="${default_target_list} $target"
1134 if test x
"$show_help" = x
"yes" ; then
1137 Usage: configure [options]
1138 Options: [defaults in brackets after descriptions]
1141 --help print this message
1142 --prefix=PREFIX install in PREFIX [$prefix]
1143 --interp-prefix=PREFIX where to find shared libraries, etc.
1144 use %M for cpu name [$interp_prefix]
1145 --target-list=LIST set target list (default: build all)
1146 $(echo Available targets: $default_target_list | \
1147 fold -s -w 53 | sed -e 's/^/ /')
1148 --target-list-exclude=LIST exclude a set of targets from the default target-list
1150 Advanced options (experts only):
1151 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
1152 --cc=CC use C compiler CC [$cc]
1153 --iasl=IASL use ACPI compiler IASL [$iasl]
1154 --host-cc=CC use C compiler CC [$host_cc] for code run at
1156 --cxx=CXX use C++ compiler CXX [$cxx]
1157 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
1158 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
1159 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
1160 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
1161 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
1162 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
1163 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
1164 --make=MAKE use specified make [$make]
1165 --python=PYTHON use specified python [$python]
1166 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
1167 --meson=MESON use specified meson [$meson]
1168 --ninja=NINJA use specified ninja [$ninja]
1169 --smbd=SMBD use specified smbd [$smbd]
1170 --with-git=GIT use specified git [$git]
1171 --with-git-submodules=update update git submodules (default if .git dir exists)
1172 --with-git-submodules=validate fail if git submodules are not up to date
1173 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
1174 --static enable static build [$static]
1175 --mandir=PATH install man pages in PATH
1176 --datadir=PATH install firmware in PATH/$qemu_suffix
1177 --localedir=PATH install translation in PATH/$qemu_suffix
1178 --docdir=PATH install documentation in PATH/$qemu_suffix
1179 --bindir=PATH install binaries in PATH
1180 --libdir=PATH install libraries in PATH
1181 --libexecdir=PATH install helper binaries in PATH
1182 --sysconfdir=PATH install config in PATH/$qemu_suffix
1183 --localstatedir=PATH install local state in PATH (set at runtime on win32)
1184 --firmwarepath=PATH search PATH for firmware files
1185 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
1186 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1187 --with-pkgversion=VERS use specified string as sub-version of the package
1188 --without-default-features default all --enable-* options to "disabled"
1189 --without-default-devices do not include any device that is not needed to
1190 start the emulator (only use if you are including
1191 desired devices in configs/devices/)
1192 --with-devices-ARCH=NAME override default configs/devices
1193 --enable-debug enable common debug build options
1194 --enable-sanitizers enable default sanitizers
1195 --enable-tsan enable thread sanitizer
1196 --disable-werror disable compilation abort on warning
1197 --disable-stack-protector disable compiler-provided stack protection
1198 --audio-drv-list=LIST set audio drivers to try if -audiodev is not used
1199 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L
1200 --block-drv-rw-whitelist=L
1201 set block driver read-write whitelist
1202 (by default affects only QEMU, not tools like qemu-img)
1203 --block-drv-ro-whitelist=L
1204 set block driver read-only whitelist
1205 (by default affects only QEMU, not tools like qemu-img)
1206 --with-trace-file=NAME Full PATH,NAME of file to store traces
1208 --cpu=CPU Build for host CPU [$cpu]
1209 --with-coroutine=BACKEND coroutine backend. Supported options:
1210 ucontext, sigaltstack, windows
1211 --enable-gcov enable test coverage analysis with gcov
1212 --tls-priority default TLS protocol/cipher priority string
1214 enable plugins via shared library loading
1215 --disable-containers don't use containers for cross-building
1216 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1220 system all system emulation targets
1221 user supported user emulation targets
1222 linux-user all linux usermode emulation targets
1223 bsd-user all BSD usermode emulation targets
1224 pie Position Independent Executables
1225 modules modules support (non-Windows)
1226 module-upgrades try to load modules from alternate paths for upgrades
1227 debug-tcg TCG debugging (default is disabled)
1228 debug-info debugging information
1229 lto Enable Link-Time Optimization.
1230 safe-stack SafeStack Stack Smash Protection. Depends on
1231 clang/llvm >= 3.7 and requires coroutine backend ucontext.
1232 vhost-net vhost-net kernel acceleration support
1233 vhost-vsock virtio sockets device support
1234 vhost-scsi vhost-scsi kernel target support
1235 vhost-crypto vhost-user-crypto backend support
1236 vhost-kernel vhost kernel backend support
1237 vhost-user vhost-user backend support
1238 vhost-vdpa vhost-vdpa kernel backend support
1241 NOTE: The object files are built at the place where configure is launched
1246 # Remove old dependency files to make sure that they get properly regenerated
1247 rm -f */config-devices.mak.d
1249 if test -z "$python"
1251 error_exit
"Python not found. Use --python=/path/to/python"
1255 error_exit
"GNU make ($make) not found"
1258 # Note that if the Python conditional here evaluates True we will exit
1259 # with status 1 which is a shell 'false' value.
1260 if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
1261 error_exit
"Cannot use '$python', Python >= 3.6 is required." \
1262 "Use --python=/path/to/python to specify a supported Python."
1265 # Preserve python version since some functionality is dependent on it
1266 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
)
1268 # Suppress writing compiled files
1271 if test -z "$meson"; then
1272 if test "$explicit_python" = no
&& has meson
&& version_ge
"$(meson --version)" 0.59.3; then
1274 elif test $git_submodules_action != 'ignore' ; then
1276 elif test -e "${source_path}/meson/meson.py" ; then
1279 if test "$explicit_python" = yes; then
1280 error_exit
"--python requires using QEMU's embedded Meson distribution, but it was not found."
1282 error_exit
"Meson not found. Use --meson=/path/to/meson"
1286 # Meson uses its own Python interpreter to invoke other Python scripts,
1287 # but the user wants to use the one they specified with --python.
1289 # We do not want to override the distro Python interpreter (and sometimes
1290 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
1291 # just require --meson=git|internal together with --python.
1292 if test "$explicit_python" = yes; then
1295 *) error_exit
"--python requires using QEMU's embedded Meson distribution." ;;
1300 if test "$meson" = git
; then
1301 git_submodules
="${git_submodules} meson"
1306 meson
="$python ${source_path}/meson/meson.py"
1308 *) meson
=$
(command -v "$meson") ;;
1313 if test -z "$ninja"; then
1314 for c
in ninja ninja-build samu
; do
1316 ninja
=$
(command -v "$c")
1320 if test -z "$ninja"; then
1321 error_exit
"Cannot find Ninja"
1325 # Check that the C compiler works. Doing this here before testing
1326 # the host CPU ensures that we had a valid CC to autodetect the
1327 # $cpu var (and we should bail right here if that's not the case).
1328 # It also allows the help message to be printed without a CC.
1330 if compile_object
; then
1331 : C compiler works ok
1333 error_exit
"\"$cc\" either does not exist or does not work"
1335 if ! compile_prog
; then
1336 error_exit
"\"$cc\" cannot build an executable (is your linker broken?)"
1339 # Consult white-list to determine whether to enable werror
1340 # by default. Only enable by default for git builds
1341 if test -z "$werror" ; then
1342 if test "$git_submodules_action" != "ignore" && \
1343 { test "$linux" = "yes" ||
test "$mingw32" = "yes"; }; then
1350 if test "$targetos" = "bogus"; then
1351 # Now that we know that we're not printing the help and that
1352 # the compiler works (so the results of the check_defines we used
1353 # to identify the OS are reliable), if we didn't recognize the
1354 # host OS we should stop now.
1355 error_exit
"Unrecognized host OS (uname -s reports '$(uname -s)')"
1358 # Check whether the compiler matches our minimum requirements:
1360 #if defined(__clang_major__) && defined(__clang_minor__)
1361 # ifdef __apple_build_version__
1362 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1363 # error You need at least XCode Clang v10.0 to compile QEMU
1366 # if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
1367 # error You need at least Clang v6.0 to compile QEMU
1370 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1371 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1372 # error You need at least GCC v7.4.0 to compile QEMU
1375 # error You either need GCC or Clang to compiler QEMU
1377 int main (void) { return 0; }
1379 if ! compile_prog
"" "" ; then
1380 error_exit
"You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1383 # Accumulate -Wfoo and -Wno-bar separately.
1384 # We will list all of the enable flags first, and the disable flags second.
1385 # Note that we do not add -Werror, because that would enable it for all
1386 # configure tests. If a configure test failed due to -Werror this would
1387 # just silently disable some features, so it's too error prone.
1390 add_to warn_flags
-Wold-style-declaration
1391 add_to warn_flags
-Wold-style-definition
1392 add_to warn_flags
-Wtype-limits
1393 add_to warn_flags
-Wformat-security
1394 add_to warn_flags
-Wformat-y2k
1395 add_to warn_flags
-Winit-self
1396 add_to warn_flags
-Wignored-qualifiers
1397 add_to warn_flags
-Wempty-body
1398 add_to warn_flags
-Wnested-externs
1399 add_to warn_flags
-Wendif-labels
1400 add_to warn_flags
-Wexpansion-to-defined
1401 add_to warn_flags
-Wimplicit-fallthrough=2
1404 add_to nowarn_flags
-Wno-initializer-overrides
1405 add_to nowarn_flags
-Wno-missing-include-dirs
1406 add_to nowarn_flags
-Wno-shift-negative-value
1407 add_to nowarn_flags
-Wno-string-plus-int
1408 add_to nowarn_flags
-Wno-typedef-redefinition
1409 add_to nowarn_flags
-Wno-tautological-type-limit-compare
1410 add_to nowarn_flags
-Wno-psabi
1412 gcc_flags
="$warn_flags $nowarn_flags"
1414 cc_has_warning_flag
() {
1417 # Use the positive sense of the flag when testing for -Wno-wombat
1418 # support (gcc will happily accept the -Wno- form of unknown
1420 optflag
="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1421 compile_prog
"-Werror $optflag" ""
1424 objcc_has_warning_flag
() {
1426 int main(void) { return 0; }
1429 # Use the positive sense of the flag when testing for -Wno-wombat
1430 # support (gcc will happily accept the -Wno- form of unknown
1432 optflag
="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1433 do_objc
-Werror $optflag \
1434 $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
1435 -o $TMPE $TMPM $QEMU_LDFLAGS
1438 for flag
in $gcc_flags; do
1439 if cc_has_warning_flag
$flag ; then
1440 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1442 if objcc_has_warning_flag
$flag ; then
1443 QEMU_OBJCFLAGS
="$QEMU_OBJCFLAGS $flag"
1447 if test "$stack_protector" != "no"; then
1449 int main(int argc, char *argv[])
1451 char arr[64], *p = arr, *c = argv[0];
1458 gcc_flags
="-fstack-protector-strong -fstack-protector-all"
1460 for flag
in $gcc_flags; do
1461 # We need to check both a compile and a link, since some compiler
1462 # setups fail only on a .c->.o compile and some only at link time
1463 if compile_object
"-Werror $flag" &&
1464 compile_prog
"-Werror $flag" ""; then
1465 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1466 QEMU_LDFLAGS
="$QEMU_LDFLAGS $flag"
1471 if test "$stack_protector" = yes; then
1472 if test $sp_on = 0; then
1473 error_exit
"Stack protector not supported"
1478 # Disable -Wmissing-braces on older compilers that warn even for
1479 # the "universal" C zero initializer {0}.
1485 if compile_object
"-Werror" "" ; then
1488 QEMU_CFLAGS
="$QEMU_CFLAGS -Wno-missing-braces"
1491 # Our module code doesn't support Windows
1492 if test "$modules" = "yes" && test "$mingw32" = "yes" ; then
1493 error_exit
"Modules are not available for Windows"
1496 # module_upgrades is only reasonable if modules are enabled
1497 if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1498 error_exit
"Can't enable module-upgrades as Modules are not enabled"
1501 # Static linking is not possible with plugins, modules or PIE
1502 if test "$static" = "yes" ; then
1503 if test "$modules" = "yes" ; then
1504 error_exit
"static and modules are mutually incompatible"
1506 if test "$plugins" = "yes"; then
1507 error_exit
"static and plugins are mutually incompatible"
1512 test "$plugins" = "" && plugins
=yes
1517 # define THREAD __thread
1521 static THREAD int tls_var;
1522 int main(void) { return tls_var; }
1525 # Check we support -fno-pie and -no-pie first; we will need the former for
1526 # building ROMs, and both for everything if --disable-pie is passed.
1527 if compile_prog
"-Werror -fno-pie" "-no-pie"; then
1528 CFLAGS_NOPIE
="-fno-pie"
1529 LDFLAGS_NOPIE
="-no-pie"
1532 if test "$static" = "yes"; then
1533 if test "$pie" != "no" && compile_prog
"-Werror -fPIE -DPIE" "-static-pie"; then
1534 CONFIGURE_CFLAGS
="-fPIE -DPIE $CONFIGURE_CFLAGS"
1535 QEMU_LDFLAGS
="-static-pie $QEMU_LDFLAGS"
1537 elif test "$pie" = "yes"; then
1538 error_exit
"-static-pie not available due to missing toolchain support"
1540 QEMU_LDFLAGS
="-static $QEMU_LDFLAGS"
1543 elif test "$pie" = "no"; then
1544 CONFIGURE_CFLAGS
="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1545 CONFIGURE_LDFLAGS
="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
1546 elif compile_prog
"-Werror -fPIE -DPIE" "-pie"; then
1547 CONFIGURE_CFLAGS
="-fPIE -DPIE $CONFIGURE_CFLAGS"
1548 CONFIGURE_LDFLAGS
="-pie $CONFIGURE_LDFLAGS"
1550 elif test "$pie" = "yes"; then
1551 error_exit
"PIE not available due to missing toolchain support"
1553 echo "Disabling PIE due to missing toolchain support"
1557 # Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1558 # The combination is known as "full relro", because .got.plt is read-only too.
1559 if compile_prog
"" "-Wl,-z,relro -Wl,-z,now" ; then
1560 QEMU_LDFLAGS
="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1563 ##########################################
1564 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1565 # use i686 as default anyway, but for those that don't, an explicit
1566 # specification is necessary
1568 if test "$cpu" = "i386"; then
1570 static int sfaa(int *ptr)
1572 return __sync_fetch_and_and(ptr, 0);
1578 val = __sync_val_compare_and_swap(&val, 0, 1);
1583 if ! compile_prog
"" "" ; then
1584 QEMU_CFLAGS
="-march=i486 $QEMU_CFLAGS"
1588 if test "$tcg" = "enabled"; then
1589 git_submodules
="$git_submodules tests/fp/berkeley-testfloat-3"
1590 git_submodules
="$git_submodules tests/fp/berkeley-softfloat-3"
1593 if test -z "${target_list+xxx}" ; then
1595 for target
in $default_target_list; do
1596 target_list
="$target_list $target"
1598 target_list
="${target_list# }"
1601 target_list
=$
(echo "$target_list" |
sed -e 's/,/ /g')
1602 for target
in $target_list; do
1603 # Check that we recognised the target name; this allows a more
1604 # friendly error message than if we let it fall through.
1605 case " $default_target_list " in
1609 error_exit
"Unknown target name '$target'"
1615 # see if system emulation was really requested
1616 case " $target_list " in
1617 *"-softmmu "*) softmmu
=yes
1623 feature_not_found
() {
1627 error_exit
"User requested feature $feature" \
1628 "configure was not able to find it." \
1633 # big/little endian test
1636 short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
1637 short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1638 int main(int argc, char *argv[])
1640 return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
1644 if compile_prog
; then
1645 if strings -a $TMPE |
grep -q BiGeNdIaN
; then
1647 elif strings -a $TMPE |
grep -q LiTtLeEnDiAn
; then
1650 echo big
/little
test failed
1654 echo big
/little
test failed
1658 #########################################
1659 # vhost interdependencies and host support
1662 if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
1663 error_exit
"vhost-user is not available on Windows"
1665 test "$vhost_vdpa" = "" && vhost_vdpa
=$linux
1666 if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1667 error_exit
"vhost-vdpa is only available on Linux"
1669 test "$vhost_kernel" = "" && vhost_kernel
=$linux
1670 if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1671 error_exit
"vhost-kernel is only available on Linux"
1674 # vhost-kernel devices
1675 test "$vhost_scsi" = "" && vhost_scsi
=$vhost_kernel
1676 if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1677 error_exit
"--enable-vhost-scsi requires --enable-vhost-kernel"
1679 test "$vhost_vsock" = "" && vhost_vsock
=$vhost_kernel
1680 if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1681 error_exit
"--enable-vhost-vsock requires --enable-vhost-kernel"
1684 # vhost-user backends
1685 test "$vhost_net_user" = "" && vhost_net_user
=$vhost_user
1686 if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1687 error_exit
"--enable-vhost-net-user requires --enable-vhost-user"
1689 test "$vhost_crypto" = "" && vhost_crypto
=$vhost_user
1690 if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1691 error_exit
"--enable-vhost-crypto requires --enable-vhost-user"
1693 test "$vhost_user_fs" = "" && vhost_user_fs
=$vhost_user
1694 if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
1695 error_exit
"--enable-vhost-user-fs requires --enable-vhost-user"
1697 #vhost-vdpa backends
1698 test "$vhost_net_vdpa" = "" && vhost_net_vdpa
=$vhost_vdpa
1699 if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1700 error_exit
"--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1703 # OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1704 if test "$vhost_net" = ""; then
1705 test "$vhost_net_user" = "yes" && vhost_net
=yes
1706 test "$vhost_net_vdpa" = "yes" && vhost_net
=yes
1707 test "$vhost_kernel" = "yes" && vhost_net
=yes
1710 ##########################################
1713 if ! has
"$pkg_config_exe"; then
1714 error_exit
"pkg-config binary '$pkg_config_exe' not found"
1717 ##########################################
1720 if test "$xen" != "disabled" ; then
1721 # Check whether Xen library path is specified via --extra-ldflags to avoid
1722 # overriding this setting with pkg-config output. If not, try pkg-config
1723 # to obtain all needed flags.
1725 if ! echo $EXTRA_LDFLAGS |
grep tools
/libxc
> /dev
/null
&& \
1726 $pkg_config --exists xencontrol
; then
1727 xen_ctrl_version
="$(printf '%d%02d%02d' \
1728 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
1730 xen_pc
="xencontrol xenstore xenforeignmemory xengnttab"
1731 xen_pc
="$xen_pc xenevtchn xendevicemodel"
1732 if $pkg_config --exists xentoolcore
; then
1733 xen_pc
="$xen_pc xentoolcore"
1735 xen_cflags
="$($pkg_config --cflags $xen_pc)"
1736 xen_libs
="$($pkg_config --libs $xen_pc)"
1739 xen_libs
="-lxenstore -lxenctrl"
1740 xen_stable_libs
="-lxenforeignmemory -lxengnttab -lxenevtchn"
1742 # First we test whether Xen headers and libraries are available.
1743 # If no, we are done and there is no Xen support.
1744 # If yes, more tests are run to detect the Xen version.
1748 #include <xenctrl.h>
1753 if ! compile_prog
"" "$xen_libs" ; then
1755 if test "$xen" = "enabled" ; then
1756 feature_not_found
"xen" "Install xen devel"
1762 cat > $TMPC <<EOF &&
1763 #undef XC_WANT_COMPAT_DEVICEMODEL_API
1764 #define __XEN_TOOLS__
1765 #include <xendevicemodel.h>
1766 #include <xenforeignmemory.h>
1768 xendevicemodel_handle *xd;
1769 xenforeignmemory_handle *xfmem;
1771 xd = xendevicemodel_open(0, 0);
1772 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
1774 xfmem = xenforeignmemory_open(0, 0);
1775 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
1780 compile_prog
"" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1782 xen_stable_libs
="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1783 xen_ctrl_version
=41100
1786 cat > $TMPC <<EOF &&
1787 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1788 #include <xenforeignmemory.h>
1789 #include <xentoolcore.h>
1791 xenforeignmemory_handle *xfmem;
1793 xfmem = xenforeignmemory_open(0, 0);
1794 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
1795 xentoolcore_restrict_all(0);
1800 compile_prog
"" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
1802 xen_stable_libs
="-lxendevicemodel $xen_stable_libs -lxentoolcore"
1803 xen_ctrl_version
=41000
1806 cat > $TMPC <<EOF &&
1807 #undef XC_WANT_COMPAT_DEVICEMODEL_API
1808 #define __XEN_TOOLS__
1809 #include <xendevicemodel.h>
1811 xendevicemodel_handle *xd;
1813 xd = xendevicemodel_open(0, 0);
1814 xendevicemodel_close(xd);
1819 compile_prog
"" "$xen_libs -lxendevicemodel $xen_stable_libs"
1821 xen_stable_libs
="-lxendevicemodel $xen_stable_libs"
1822 xen_ctrl_version
=40900
1825 cat > $TMPC <<EOF &&
1827 * If we have stable libs the we don't want the libxc compat
1828 * layers, regardless of what CFLAGS we may have been given.
1830 * Also, check if xengnttab_grant_copy_segment_t is defined and
1831 * grant copy operation is implemented.
1833 #undef XC_WANT_COMPAT_EVTCHN_API
1834 #undef XC_WANT_COMPAT_GNTTAB_API
1835 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1836 #include <xenctrl.h>
1837 #include <xenstore.h>
1838 #include <xenevtchn.h>
1839 #include <xengnttab.h>
1840 #include <xenforeignmemory.h>
1842 #include <xen/hvm/hvm_info_table.h>
1843 #if !defined(HVM_MAX_VCPUS)
1844 # error HVM_MAX_VCPUS not defined
1847 xc_interface *xc = NULL;
1848 xenforeignmemory_handle *xfmem;
1849 xenevtchn_handle *xe;
1850 xengnttab_handle *xg;
1851 xengnttab_grant_copy_segment_t* seg = NULL;
1855 xc = xc_interface_open(0, 0, 0);
1856 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1857 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1858 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1859 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1861 xfmem = xenforeignmemory_open(0, 0);
1862 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1864 xe = xenevtchn_open(0, 0);
1867 xg = xengnttab_open(0, 0);
1868 xengnttab_grant_copy(xg, 0, seg);
1873 compile_prog
"" "$xen_libs $xen_stable_libs"
1875 xen_ctrl_version
=40800
1878 cat > $TMPC <<EOF &&
1880 * If we have stable libs the we don't want the libxc compat
1881 * layers, regardless of what CFLAGS we may have been given.
1883 #undef XC_WANT_COMPAT_EVTCHN_API
1884 #undef XC_WANT_COMPAT_GNTTAB_API
1885 #undef XC_WANT_COMPAT_MAP_FOREIGN_API
1886 #include <xenctrl.h>
1887 #include <xenstore.h>
1888 #include <xenevtchn.h>
1889 #include <xengnttab.h>
1890 #include <xenforeignmemory.h>
1892 #include <xen/hvm/hvm_info_table.h>
1893 #if !defined(HVM_MAX_VCPUS)
1894 # error HVM_MAX_VCPUS not defined
1897 xc_interface *xc = NULL;
1898 xenforeignmemory_handle *xfmem;
1899 xenevtchn_handle *xe;
1900 xengnttab_handle *xg;
1904 xc = xc_interface_open(0, 0, 0);
1905 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1906 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1907 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1908 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1910 xfmem = xenforeignmemory_open(0, 0);
1911 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
1913 xe = xenevtchn_open(0, 0);
1916 xg = xengnttab_open(0, 0);
1917 xengnttab_map_grant_ref(xg, 0, 0, 0);
1922 compile_prog
"" "$xen_libs $xen_stable_libs"
1924 xen_ctrl_version
=40701
1929 cat > $TMPC <<EOF &&
1930 #include <xenctrl.h>
1931 #include <xenstore.h>
1933 #include <xen/hvm/hvm_info_table.h>
1934 #if !defined(HVM_MAX_VCPUS)
1935 # error HVM_MAX_VCPUS not defined
1940 xc = xc_interface_open(0, 0, 0);
1941 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1942 xc_gnttab_open(NULL, 0);
1943 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1944 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1945 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
1946 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
1950 compile_prog
"" "$xen_libs"
1952 xen_ctrl_version
=40600
1957 cat > $TMPC <<EOF &&
1958 #include <xenctrl.h>
1959 #include <xenstore.h>
1961 #include <xen/hvm/hvm_info_table.h>
1962 #if !defined(HVM_MAX_VCPUS)
1963 # error HVM_MAX_VCPUS not defined
1968 xc = xc_interface_open(0, 0, 0);
1969 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1970 xc_gnttab_open(NULL, 0);
1971 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1972 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
1973 xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
1977 compile_prog
"" "$xen_libs"
1979 xen_ctrl_version
=40500
1983 cat > $TMPC <<EOF &&
1984 #include <xenctrl.h>
1985 #include <xenstore.h>
1987 #include <xen/hvm/hvm_info_table.h>
1988 #if !defined(HVM_MAX_VCPUS)
1989 # error HVM_MAX_VCPUS not defined
1994 xc = xc_interface_open(0, 0, 0);
1995 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
1996 xc_gnttab_open(NULL, 0);
1997 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
1998 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2002 compile_prog
"" "$xen_libs"
2004 xen_ctrl_version
=40200
2008 if test "$xen" = "enabled" ; then
2009 feature_not_found
"xen (unsupported version)" \
2010 "Install a supported xen (xen 4.2 or newer)"
2015 if test "$xen" = enabled
; then
2016 if test $xen_ctrl_version -ge 40701 ; then
2017 xen_libs
="$xen_libs $xen_stable_libs "
2023 ##########################################
2024 # glib support probe
2027 glib_modules
=gthread-2.0
2028 if test "$modules" = yes; then
2029 glib_modules
="$glib_modules gmodule-export-2.0"
2030 elif test "$plugins" = "yes"; then
2031 glib_modules
="$glib_modules gmodule-no-export-2.0"
2034 for i
in $glib_modules; do
2035 if $pkg_config --atleast-version=$glib_req_ver $i; then
2036 glib_cflags
=$
($pkg_config --cflags $i)
2037 glib_libs
=$
($pkg_config --libs $i)
2039 error_exit
"glib-$glib_req_ver $i is required to compile QEMU"
2043 # This workaround is required due to a bug in pkg-config file for glib as it
2044 # doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2046 if test "$static" = yes && test "$mingw32" = yes; then
2047 glib_cflags
="-DGLIB_STATIC_COMPILATION $glib_cflags"
2050 if ! test "$gio" = "no"; then
2052 if $pkg_config --atleast-version=$glib_req_ver gio-2.0
; then
2053 gio_cflags
=$
($pkg_config --cflags gio-2.0
)
2054 gio_libs
=$
($pkg_config --libs gio-2.0
)
2055 gdbus_codegen
=$
($pkg_config --variable=gdbus_codegen gio-2.0
)
2056 if ! has
"$gdbus_codegen"; then
2059 # Check that the libraries actually work -- Ubuntu 18.04 ships
2060 # with pkg-config --static --libs data for gio-2.0 that is missing
2061 # -lblkid and will give a link error.
2063 #include <gio/gio.h>
2066 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
2070 if compile_prog
"$gio_cflags" "$gio_libs" ; then
2076 if test "$pass" = "yes" &&
2077 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0
; then
2078 gio_cflags
="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
2079 gio_libs
="$gio_libs $($pkg_config --libs gio-unix-2.0)"
2083 if test "$pass" = "no"; then
2084 if test "$gio" = "yes"; then
2085 feature_not_found
"gio" "Install libgio >= 2.0"
2094 # Sanity check that the current size_t matches the
2095 # size that glib thinks it should be. This catches
2096 # problems on multi-arch where people try to build
2097 # 32-bit QEMU while pointing at 64-bit glib headers
2102 #define QEMU_BUILD_BUG_ON(x) \
2103 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2106 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2111 if ! compile_prog
"$glib_cflags" "$glib_libs" ; then
2112 error_exit
"sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2113 "You probably need to set PKG_CONFIG_LIBDIR"\
2114 "to point to the right pkg-config files for your"\
2118 # Silence clang warnings triggered by glib < 2.57.2
2121 typedef struct Foo {
2124 static void foo_free(Foo *f)
2128 G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free)
2129 int main(void) { return 0; }
2131 if ! compile_prog
"$glib_cflags -Werror" "$glib_libs" ; then
2132 if cc_has_warning_flag
"-Wno-unused-function"; then
2133 glib_cflags
="$glib_cflags -Wno-unused-function"
2134 CONFIGURE_CFLAGS
="$CONFIGURE_CFLAGS -Wno-unused-function"
2138 ##########################################
2139 # SHA command probe for modules
2140 if test "$modules" = yes; then
2141 shacmd_probe
="sha1sum sha1 shasum"
2142 for c
in $shacmd_probe; do
2148 if test "$shacmd" = ""; then
2149 error_exit
"one of the checksum commands is required to enable modules: $shacmd_probe"
2153 ##########################################
2157 auto | enabled | internal
)
2158 # Simpler to always update submodule, even if not needed.
2159 git_submodules
="${git_submodules} dtc"
2163 ##########################################
2167 auto | enabled | internal
)
2168 # Simpler to always update submodule, even if not needed.
2169 git_submodules
="${git_submodules} capstone"
2173 ##########################################
2174 # check and set a backend for coroutine
2176 # We prefer ucontext, but it's not always possible. The fallback
2177 # is sigcontext. On Windows the only valid backend is the Windows
2181 if test "$darwin" != "yes"; then
2183 #include <ucontext.h>
2184 #ifdef __stub_makecontext
2185 #error Ignoring glibc stub makecontext which will always fail
2187 int main(void) { makecontext(0, 0, 0); return 0; }
2189 if compile_prog
"" "" ; then
2194 if test "$coroutine" = ""; then
2195 if test "$mingw32" = "yes"; then
2197 elif test "$ucontext_works" = "yes"; then
2200 coroutine
=sigaltstack
2205 if test "$mingw32" != "yes"; then
2206 error_exit
"'windows' coroutine backend only valid for Windows"
2208 # Unfortunately the user visible backend name doesn't match the
2209 # coroutine-*.c filename for this case, so we have to adjust it here.
2213 if test "$ucontext_works" != "yes"; then
2214 feature_not_found
"ucontext"
2218 if test "$mingw32" = "yes"; then
2219 error_exit
"only the 'windows' coroutine backend is valid for Windows"
2223 error_exit
"unknown coroutine backend $coroutine"
2228 ##################################################
2232 if test "$safe_stack" = "yes"; then
2234 int main(int argc, char *argv[])
2236 #if ! __has_feature(safe_stack)
2237 #error SafeStack Disabled
2242 flag
="-fsanitize=safe-stack"
2243 # Check that safe-stack is supported and enabled.
2244 if compile_prog
"-Werror $flag" "$flag"; then
2245 # Flag needed both at compilation and at linking
2246 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
2247 QEMU_LDFLAGS
="$QEMU_LDFLAGS $flag"
2249 error_exit
"SafeStack not supported by your compiler"
2251 if test "$coroutine" != "ucontext"; then
2252 error_exit
"SafeStack is only supported by the coroutine backend ucontext"
2256 int main(int argc, char *argv[])
2258 #if defined(__has_feature)
2259 #if __has_feature(safe_stack)
2260 #error SafeStack Enabled
2266 if test "$safe_stack" = "no"; then
2267 # Make sure that safe-stack is disabled
2268 if ! compile_prog
"-Werror" ""; then
2269 # SafeStack was already enabled, try to explicitly remove the feature
2270 flag
="-fno-sanitize=safe-stack"
2271 if ! compile_prog
"-Werror $flag" "$flag"; then
2272 error_exit
"Configure cannot disable SafeStack"
2274 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
2275 QEMU_LDFLAGS
="$QEMU_LDFLAGS $flag"
2277 else # "$safe_stack" = ""
2278 # Set safe_stack to yes or no based on pre-existing flags
2279 if compile_prog
"-Werror" ""; then
2283 if test "$coroutine" != "ucontext"; then
2284 error_exit
"SafeStack is only supported by the coroutine backend ucontext"
2290 ########################################
2291 # check if ccache is interfering with
2292 # semantic analysis of macros
2297 static const int Z = 1;
2298 #define fn() ({ Z; })
2299 #define TAUT(X) ((X) == Z)
2300 #define PAREN(X, Y) (X == Y)
2302 int main(int argc, char *argv[])
2308 if (PAREN(x, y)) return 0;
2309 if (TAUT(Z)) return 0;
2314 if ! compile_object
"-Werror"; then
2318 #################################################
2319 # clang does not support glibc + FORTIFY_SOURCE.
2321 if test "$fortify_source" != "no"; then
2322 if echo |
$cc -dM -E - |
grep __clang__
> /dev
/null
2>&1 ; then
2323 fortify_source
="no";
2324 elif test -n "$cxx" && has
$cxx &&
2325 echo |
$cxx -dM -E - |
grep __clang__
>/dev
/null
2>&1 ; then
2326 fortify_source
="no";
2328 fortify_source
="yes"
2332 ##########################################
2333 # checks for sanitizers
2337 have_asan_iface_h
=no
2338 have_asan_iface_fiber
=no
2340 if test "$sanitizers" = "yes" ; then
2342 if compile_prog
"$CPU_CFLAGS -Werror -fsanitize=address" ""; then
2346 # we could use a simple skeleton for flags checks, but this also
2347 # detect the static linking issue of ubsan, see also:
2348 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
2352 void *tmp = malloc(10);
2354 return *(int *)(tmp + 2);
2359 if compile_prog
"$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
2363 if check_include
"sanitizer/asan_interface.h" ; then
2364 have_asan_iface_h
=yes
2368 #include <sanitizer/asan_interface.h>
2370 __sanitizer_start_switch_fiber(0, 0, 0);
2374 if compile_prog
"$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
2375 have_asan_iface_fiber
=yes
2379 # Thread sanitizer is, for now, much noisier than the other sanitizers;
2380 # keep it separate until that is not the case.
2381 if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
2382 error_exit
"TSAN is not supported with other sanitiziers."
2385 have_tsan_iface_fiber
=no
2386 if test "$tsan" = "yes" ; then
2388 if compile_prog
"$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
2392 #include <sanitizer/tsan_interface.h>
2394 __tsan_create_fiber(0);
2398 if compile_prog
"$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
2399 have_tsan_iface_fiber
=yes
2403 ##########################################
2407 auto | enabled | internal
)
2408 # Simpler to always update submodule, even if not needed.
2409 git_submodules
="${git_submodules} slirp"
2413 ##########################################
2415 # After here, no more $cc or $ld runs
2419 if test "$fortify_source" = "yes" ; then
2420 QEMU_CFLAGS
="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
2426 # Ensure there's only a single GP
2427 QEMU_CFLAGS
="-msmall-data $QEMU_CFLAGS"
2431 if test "$have_asan" = "yes"; then
2432 QEMU_CFLAGS
="-fsanitize=address $QEMU_CFLAGS"
2433 QEMU_LDFLAGS
="-fsanitize=address $QEMU_LDFLAGS"
2434 if test "$have_asan_iface_h" = "no" ; then
2435 echo "ASAN build enabled, but ASAN header missing." \
2436 "Without code annotation, the report may be inferior."
2437 elif test "$have_asan_iface_fiber" = "no" ; then
2438 echo "ASAN build enabled, but ASAN header is too old." \
2439 "Without code annotation, the report may be inferior."
2442 if test "$have_tsan" = "yes" ; then
2443 if test "$have_tsan_iface_fiber" = "yes" ; then
2444 QEMU_CFLAGS
="-fsanitize=thread $QEMU_CFLAGS"
2445 QEMU_LDFLAGS
="-fsanitize=thread $QEMU_LDFLAGS"
2447 error_exit
"Cannot enable TSAN due to missing fiber annotation interface."
2449 elif test "$tsan" = "yes" ; then
2450 error_exit
"Cannot enable TSAN due to missing sanitize thread interface."
2452 if test "$have_ubsan" = "yes"; then
2453 QEMU_CFLAGS
="-fsanitize=undefined $QEMU_CFLAGS"
2454 QEMU_LDFLAGS
="-fsanitize=undefined $QEMU_LDFLAGS"
2457 ##########################################
2459 # Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
2460 if test "$solaris" = "no" && test "$tsan" = "no"; then
2461 if $ld --version 2>/dev
/null |
grep "GNU ld" >/dev
/null
2>/dev
/null
; then
2462 QEMU_LDFLAGS
="-Wl,--warn-common $QEMU_LDFLAGS"
2466 # Use ASLR, no-SEH and DEP if available
2467 if test "$mingw32" = "yes" ; then
2468 flags
="--no-seh --nxcompat"
2470 # Disable ASLR for debug builds to allow debugging with gdb
2471 if test "$debug" = "no" ; then
2472 flags
="--dynamicbase $flags"
2475 for flag
in $flags; do
2476 if ld_has
$flag ; then
2477 QEMU_LDFLAGS
="-Wl,$flag $QEMU_LDFLAGS"
2482 # Guest agent Windows MSI package
2484 if test "$QEMU_GA_MANUFACTURER" = ""; then
2485 QEMU_GA_MANUFACTURER
=QEMU
2487 if test "$QEMU_GA_DISTRO" = ""; then
2488 QEMU_GA_DISTRO
=Linux
2490 if test "$QEMU_GA_VERSION" = ""; then
2491 QEMU_GA_VERSION
=$
(cat $source_path/VERSION
)
2494 QEMU_GA_MSI_MINGW_BIN_PATH
="$($pkg_config --variable=prefix glib-2.0)/bin"
2496 # Mac OS X ships with a broken assembler
2498 if { test "$cpu" = "i386" ||
test "$cpu" = "x86_64"; } && \
2499 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
2500 test "$targetos" != "haiku" && test "$softmmu" = yes ; then
2501 # Different host OS linkers have different ideas about the name of the ELF
2502 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
2503 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
2504 for emu
in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe
; do
2505 if "$ld" -verbose 2>&1 |
grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
2506 ld_i386_emulation
="$emu"
2513 # Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
2514 # or -march=z10 (which is the lowest architecture level that Clang supports)
2515 if test "$cpu" = "s390x" ; then
2517 compile_prog
"-march=z900" ""
2519 if [ $has_z900 = 0 ] || compile_object
"-march=z10 -msoft-float -Werror"; then
2520 if [ $has_z900 != 0 ]; then
2521 echo "WARNING: Your compiler does not support the z900!"
2522 echo " The s390-ccw bios will only work with guest CPUs >= z10."
2524 roms
="$roms s390-ccw"
2525 # SLOF is required for building the s390-ccw firmware on s390x,
2526 # since it is using the libnet code from SLOF for network booting.
2527 git_submodules
="${git_submodules} roms/SLOF"
2531 # Check that the C++ compiler exists and works with the C compiler.
2532 # All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added.
2535 int c_function(void);
2536 int main(void) { return c_function(); }
2543 int c_function(void);
2545 int c_function(void) { return 42; }
2550 if do_cxx
$CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
2551 # C++ compiler $cxx works ok with C compiler $cc
2554 echo "C++ compiler $cxx does not work with C compiler $cc"
2555 echo "Disabling C++ specific optional code"
2559 echo "No C++ compiler available; disabling C++ specific optional code"
2563 if !(GIT
="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
2567 config_host_mak
="config-host.mak"
2569 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2570 echo >> $config_host_mak
2572 echo all
: >> $config_host_mak
2573 echo "GIT=$git" >> $config_host_mak
2574 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
2575 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
2577 if test "$debug_tcg" = "yes" ; then
2578 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2580 if test "$mingw32" = "yes" ; then
2581 echo "CONFIG_WIN32=y" >> $config_host_mak
2582 echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak
2583 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
2584 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
2585 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
2587 echo "CONFIG_POSIX=y" >> $config_host_mak
2590 if test "$linux" = "yes" ; then
2591 echo "CONFIG_LINUX=y" >> $config_host_mak
2594 if test "$darwin" = "yes" ; then
2595 echo "CONFIG_DARWIN=y" >> $config_host_mak
2598 if test "$solaris" = "yes" ; then
2599 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2601 if test "$static" = "yes" ; then
2602 echo "CONFIG_STATIC=y" >> $config_host_mak
2604 echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
2605 echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
2606 qemu_version
=$
(head $source_path/VERSION
)
2607 echo "PKGVERSION=$pkgversion" >>$config_host_mak
2608 echo "SRC_PATH=$source_path" >> $config_host_mak
2609 echo "TARGET_DIRS=$target_list" >> $config_host_mak
2610 if test "$modules" = "yes"; then
2611 # $shacmd can generate a hash started with digit, which the compiler doesn't
2612 # like as an symbol. So prefix it with an underscore
2613 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
2614 echo "CONFIG_MODULES=y" >> $config_host_mak
2616 if test "$module_upgrades" = "yes"; then
2617 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
2619 if test "$gio" = "yes" ; then
2620 echo "CONFIG_GIO=y" >> $config_host_mak
2621 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
2622 echo "GIO_LIBS=$gio_libs" >> $config_host_mak
2624 if test "$gdbus_codegen" != "" ; then
2625 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
2627 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
2629 if test "$xen" = "enabled" ; then
2630 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
2631 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
2632 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
2633 echo "XEN_LIBS=$xen_libs" >> $config_host_mak
2635 if test "$vhost_scsi" = "yes" ; then
2636 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
2638 if test "$vhost_net" = "yes" ; then
2639 echo "CONFIG_VHOST_NET=y" >> $config_host_mak
2641 if test "$vhost_net_user" = "yes" ; then
2642 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
2644 if test "$vhost_net_vdpa" = "yes" ; then
2645 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
2647 if test "$vhost_crypto" = "yes" ; then
2648 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
2650 if test "$vhost_vsock" = "yes" ; then
2651 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
2652 if test "$vhost_user" = "yes" ; then
2653 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
2656 if test "$vhost_kernel" = "yes" ; then
2657 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
2659 if test "$vhost_user" = "yes" ; then
2660 echo "CONFIG_VHOST_USER=y" >> $config_host_mak
2662 if test "$vhost_vdpa" = "yes" ; then
2663 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
2665 if test "$vhost_user_fs" = "yes" ; then
2666 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
2669 # XXX: suppress that
2670 if [ "$bsd" = "yes" ] ; then
2671 echo "CONFIG_BSD=y" >> $config_host_mak
2674 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
2676 if test "$have_asan_iface_fiber" = "yes" ; then
2677 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
2680 if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
2681 echo "CONFIG_TSAN=y" >> $config_host_mak
2684 if test "$plugins" = "yes" ; then
2685 echo "CONFIG_PLUGIN=y" >> $config_host_mak
2688 if test -n "$gdb_bin"; then
2689 gdb_version
=$
($gdb_bin --version |
head -n 1)
2690 if version_ge
${gdb_version##* } 9.1; then
2691 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2695 echo "ROMS=$roms" >> $config_host_mak
2696 echo "MAKE=$make" >> $config_host_mak
2697 echo "PYTHON=$python" >> $config_host_mak
2698 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
2699 echo "MESON=$meson" >> $config_host_mak
2700 echo "NINJA=$ninja" >> $config_host_mak
2701 echo "CC=$cc" >> $config_host_mak
2702 echo "AR=$ar" >> $config_host_mak
2703 echo "AS=$as" >> $config_host_mak
2704 echo "CCAS=$ccas" >> $config_host_mak
2705 echo "CPP=$cpp" >> $config_host_mak
2706 echo "OBJCOPY=$objcopy" >> $config_host_mak
2707 echo "LD=$ld" >> $config_host_mak
2708 echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
2709 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2710 echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
2711 echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
2712 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
2713 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
2714 echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
2715 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
2716 echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
2717 echo "STRIP=$strip" >> $config_host_mak
2718 echo "EXESUF=$EXESUF" >> $config_host_mak
2720 # use included Linux headers
2721 if test "$linux" = "yes" ; then
2722 mkdir
-p linux-headers
2737 linux_arch
=loongarch
2743 # For most CPUs the kernel architecture name and QEMU CPU name match.
2747 # For non-KVM architectures we will not have asm headers
2748 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
2749 symlink
"$source_path/linux-headers/asm-$linux_arch" linux-headers
/asm
2753 for target
in $target_list; do
2754 target_dir
="$target"
2755 target_name
=$
(echo $target | cut
-d '-' -f 1)$EXESUF
2756 mkdir
-p $target_dir
2758 *-user) symlink
"../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
2759 *) symlink
"../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
2763 echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" |
sed 's/%M/@0@/' >> $config_host_mak
2764 if test "$default_targets" = "yes"; then
2765 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
2768 if test "$ccache_cpp2" = "yes"; then
2769 echo "export CCACHE_CPP2=y" >> $config_host_mak
2772 if test "$safe_stack" = "yes"; then
2773 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
2776 # If we're using a separate build tree, set it up now.
2777 # LINKS are things to symlink back into the source tree
2778 # (these can be both files and directories).
2779 # Caution: do not add files or directories here using wildcards. This
2780 # will result in problems later if a new file matching the wildcard is
2781 # added to the source tree -- nothing will cause configure to be rerun
2782 # so the build tree will be missing the link back to the new file, and
2783 # tests might fail. Prefer to keep the relevant files in their own
2784 # directory and symlink the directory instead.
2786 LINKS
="$LINKS tests/tcg/Makefile.target"
2787 LINKS
="$LINKS pc-bios/optionrom/Makefile"
2788 LINKS
="$LINKS pc-bios/s390-ccw/Makefile"
2789 LINKS
="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
2790 LINKS
="$LINKS tests/avocado tests/data"
2791 LINKS
="$LINKS tests/qemu-iotests/check"
2792 LINKS
="$LINKS python"
2793 LINKS
="$LINKS contrib/plugins/Makefile "
2795 $source_path/pc-bios
/*.bin \
2796 $source_path/pc-bios
/*.elf \
2797 $source_path/pc-bios
/*.lid \
2798 $source_path/pc-bios
/*.rom \
2799 $source_path/pc-bios
/*.dtb \
2800 $source_path/pc-bios
/*.img \
2801 $source_path/pc-bios
/openbios-
* \
2802 $source_path/pc-bios
/u-boot.
* \
2803 $source_path/pc-bios
/palcode-
* \
2804 $source_path/pc-bios
/qemu_vga.ndrv
2807 LINKS
="$LINKS pc-bios/$(basename $bios_file)"
2809 for f
in $LINKS ; do
2810 if [ -e "$source_path/$f" ]; then
2811 mkdir
-p `dirname ./$f`
2812 symlink
"$source_path/$f" "$f"
2816 (for i
in $cross_cc_vars; do
2819 export target_list source_path use_containers cpu host_cc
2820 $source_path/tests
/tcg
/configure.sh
)
2822 config_mak
=pc-bios
/optionrom
/config.mak
2823 echo "# Automatically generated by configure - do not modify" > $config_mak
2824 echo "TOPSRC_DIR=$source_path" >> $config_mak
2826 if test "$skip_meson" = no
; then
2827 cross
="config-meson.cross.new"
2829 test $# = 0 && return
2830 echo "'$(echo $* | sed "s
/ /','/g
")'"
2833 echo "# Automatically generated by configure - do not modify" > $cross
2834 echo "[properties]" >> $cross
2836 # unroll any custom device configs
2837 for a
in $device_archs; do
2838 eval "c=\$devices_${a}"
2839 echo "${a}-softmmu = '$c'" >> $cross
2842 test -z "$cxx" && echo "link_language = 'c'" >> $cross
2843 echo "[built-in options]" >> $cross
2844 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
2845 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
2846 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
2847 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
2848 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
2849 echo "[binaries]" >> $cross
2850 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
2851 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
2852 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
2853 echo "ar = [$(meson_quote $ar)]" >> $cross
2854 echo "nm = [$(meson_quote $nm)]" >> $cross
2855 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
2856 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
2857 if has
$sdl2_config; then
2858 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
2860 echo "strip = [$(meson_quote $strip)]" >> $cross
2861 echo "windres = [$(meson_quote $windres)]" >> $cross
2862 if test "$cross_compile" = "yes"; then
2863 cross_arg
="--cross-file config-meson.cross"
2864 echo "[host_machine]" >> $cross
2865 echo "system = '$targetos'" >> $cross
2868 echo "cpu_family = 'x86'" >> $cross
2871 echo "cpu_family = '$cpu'" >> $cross
2874 echo "cpu = '$cpu'" >> $cross
2875 if test "$bigendian" = "yes" ; then
2876 echo "endian = 'big'" >> $cross
2878 echo "endian = 'little'" >> $cross
2881 cross_arg
="--native-file config-meson.cross"
2883 mv $cross config-meson.cross
2885 rm -rf meson-private meson-info meson-logs
2887 NINJA
=$ninja $meson setup \
2888 --prefix "$prefix" \
2889 --libdir "$libdir" \
2890 --libexecdir "$libexecdir" \
2891 --bindir "$bindir" \
2892 --includedir "$includedir" \
2893 --datadir "$datadir" \
2894 --mandir "$mandir" \
2895 --sysconfdir "$sysconfdir" \
2896 --localedir "$localedir" \
2897 --localstatedir "$local_statedir" \
2898 -Daudio_drv_list=$audio_drv_list \
2899 -Ddefault_devices=$default_devices \
2900 -Ddocdir="$docdir" \
2901 -Diasl="$($iasl -h >/dev/null 2>&1 && printf %s "$iasl")" \
2902 -Dqemu_firmwarepath="$firmwarepath" \
2903 -Dqemu_suffix="$qemu_suffix" \
2905 -Dsphinx_build="$sphinx_build" \
2906 -Dtrace_file="$trace_file" \
2907 -Doptimization=$
(if test "$debug" = yes; then echo 0; else echo 2; fi) \
2908 -Ddebug=$
(if test "$debug_info" = yes; then echo true
; else echo false
; fi) \
2909 -Dwerror=$
(if test "$werror" = yes; then echo true
; else echo false
; fi) \
2910 -Db_pie=$
(if test "$pie" = yes; then echo true
; else echo false
; fi) \
2911 -Db_coverage=$
(if test "$gcov" = yes; then echo true
; else echo false
; fi) \
2912 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
2913 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
2914 $
(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
2915 $
(if test "$default_feature" = no
; then echo "-Dauto_features=disabled"; fi) \
2916 "$@" $cross_arg "$PWD" "$source_path"
2918 eval run_meson
$meson_options
2919 if test "$?" -ne 0 ; then
2920 error_exit
"meson setup failed"
2923 if test -f meson-private
/cmd_line.txt
; then
2924 # Adjust old command line options whose type was changed
2925 # Avoids having to use "setup --wipe" when Meson is upgraded
2927 s/^gettext = true$/gettext = auto/;
2928 s/^gettext = false$/gettext = disabled/;
2929 /^b_staticpic/ && next;
2930 print;' meson-private
/cmd_line.txt
2934 # Save the configure command line for later reuse.
2935 cat <<EOD >config.status
2937 # Generated by configure.
2938 # Run this file to recreate the current configuration.
2939 # Compiler output produced by configure, useful for debugging
2940 # configure, is in config.log if it exists.
2946 eval envval
=\$
$envname
2948 if test -n "$envval"
2950 echo "$envname='$envval'" >> config.status
2951 echo "export $envname" >> config.status
2953 echo "unset $envname" >> config.status
2957 # Preserve various env variables that influence what
2958 # features/build target configure will detect
2965 preserve_env CXXFLAGS
2966 preserve_env INSTALL
2968 preserve_env LDFLAGS
2969 preserve_env LD_LIBRARY_PATH
2970 preserve_env LIBTOOL
2973 preserve_env OBJCOPY
2975 preserve_env PKG_CONFIG
2976 preserve_env PKG_CONFIG_LIBDIR
2977 preserve_env PKG_CONFIG_PATH
2979 preserve_env SDL2_CONFIG
2982 preserve_env WINDRES
2984 printf "exec" >>config.status
2985 for i
in "$0" "$@"; do
2986 test "$i" = --skip-meson ||
printf " %s" "$(quote_sh "$i")" >>config.status
2988 echo ' "$@"' >>config.status
2989 chmod +x config.status