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"
34 if ! mkdir build ||
! touch $MARKER
36 echo "ERROR: Could not create ./build directory. Check the permissions on"
37 echo "your source directory, or try doing an out-of-tree build."
41 cat > GNUmakefile
<<'EOF'
42 # This file is auto-generated by configure to support in-source tree
43 # 'make' command invocation
45 ifeq ($(MAKECMDGOALS),)
51 @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
52 @$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
53 @if test "$(MAKECMDGOALS)" = "distclean" && \
54 test -e build/auto-created-by-configure ; \
56 rm -rf build GNUmakefile ; \
64 exec "$source_path/configure" "$@"
67 # Temporary directory used for files created while
68 # configure runs. Since it is in the build directory
69 # we can safely blow away any previous version of it
70 # (and we need not jump through hoops to try to delete
71 # it when configure exits.)
74 if ! mkdir
-p "${TMPDIR1}"; then
75 echo "ERROR: failed to create temporary directory"
80 TMPC
="${TMPDIR1}/${TMPB}.c"
81 TMPO
="${TMPDIR1}/${TMPB}.o"
82 TMPM
="${TMPDIR1}/${TMPB}.m"
83 TMPE
="${TMPDIR1}/${TMPB}.exe"
87 # Print a helpful header at the top of config.log
88 echo "# QEMU configure log $(date)" >> config.log
89 printf "# Configured with:" >> config.log
90 # repeat the invocation to log and stdout for CI
91 invoke
=$
(printf " '%s'" "$0" "$@")
92 test -n "$GITLAB_CI" && echo "configuring with: $invoke"
93 { echo "$invoke"; echo; echo "#"; } >> config.log
96 printf "%s" "$1" |
sed "s,','\\\\'',g; s,.*,'&',"
102 while test -n "$2"; do
115 # Run the compiler, capturing its output to the log. First argument
116 # is compiler binary to execute.
119 if test -n "$BASH_VERSION"; then eval '
121 funcs: ${FUNCNAME[*]}
122 lines: ${BASH_LINENO[*]}"
124 echo $compiler "$@" >> config.log
125 $compiler "$@" >> config.log
2>&1 ||
return $?
128 do_compiler_werror
() {
129 # Run the compiler, capturing its output to the log. First argument
130 # is compiler binary to execute.
133 if test -n "$BASH_VERSION"; then eval '
135 funcs: ${FUNCNAME[*]}
136 lines: ${BASH_LINENO[*]}"
138 echo $compiler "$@" >> config.log
139 $compiler "$@" >> config.log
2>&1 ||
return $?
140 # Test passed. If this is an --enable-werror build, rerun
141 # the test with -Werror and bail out if it fails. This
142 # makes warning-generating-errors in configure test code
143 # obvious to developers.
144 if test "$werror" != "yes"; then
147 # Don't bother rerunning the compile if we were already using -Werror
153 echo $compiler -Werror "$@" >> config.log
154 $compiler -Werror "$@" >> config.log
2>&1 && return $?
155 error_exit
"configure test passed without -Werror but failed with -Werror." \
156 "This is probably a bug in the configure script. The failing command" \
157 "will be at the bottom of config.log." \
158 "You can run configure with --disable-werror to bypass this check."
162 do_compiler_werror
"$cc" $CPU_CFLAGS "$@"
166 do_compiler_werror
"$objcc" $CPU_CFLAGS "$@"
169 # Append $2 to the variable named $1, with space separation
171 eval $1=\
${$1:+\"\$$1 \"}\
$2
176 do_cc
$CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
182 do_cc
$CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
183 $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
186 # symbolically link $1 to $2. Portable version of "ln -sf".
189 mkdir
-p "$(dirname "$2")"
193 # check whether a command is available to this shell (may be either an
194 # executable or a builtin)
196 type "$1" >/dev
/null
2>&1
200 local_ver1
=$
(expr "$1" : '\([0-9.]*\)' |
tr .
' ')
201 local_ver2
=$
(echo "$2" |
tr .
' ')
205 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
209 # the second argument finished, the first must be greater or equal
210 test $# = 1 && return 0
211 test $local_first -lt $2 && return 1
212 test $local_first -gt $2 && return 0
218 if printf %s
\\n
"$source_path" "$PWD" |
grep -q "[[:space:]:]";
220 error_exit
"main directory cannot contain spaces nor colons"
232 gdb_bin
=$
(command -v "gdb-multiarch" ||
command -v "gdb")
235 if test -e "$source_path/.git"
237 git_submodules_action
="update"
239 git_submodules_action
="ignore"
242 git_submodules
="ui/keycodemapdb"
245 # Don't accept a target_list environment variable.
247 unset target_list_exclude
249 # Default value for a variable defining feature "foo".
250 # * foo="no" feature will only be used if --enable-foo arg is given
251 # * foo="" feature will be searched for, and if found, will be used
252 # unless --disable-foo is given
253 # * foo="yes" this value will only be set by --enable-foo flag.
254 # feature will searched for,
255 # if not found, configure exits with error
257 # Always add --enable-foo and --disable-foo command line args.
258 # Distributions want to ensure that several features are compiled in, and it
259 # is impossible without a --enable-foo that exits if a feature is not found.
262 # parse CC options second
264 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
266 --without-default-features)
287 plugins
="$default_feature"
291 vfio_user_server
="disabled"
293 # The following Meson options are handled manually (still they
294 # are included in the automatically generated help message)
296 # 1. Track which submodules are needed
299 # 2. Automatically enable/disable other options
303 # parse CC options second
305 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
307 --cross-prefix=*) cross_prefix
="$optarg"
312 --cxx=*) CXX
="$optarg"
314 --objcc=*) objcc
="$optarg"
316 --cpu=*) cpu
="$optarg"
319 EXTRA_CFLAGS
="$EXTRA_CFLAGS $optarg"
320 EXTRA_CXXFLAGS
="$EXTRA_CXXFLAGS $optarg"
321 EXTRA_OBJCFLAGS
="$EXTRA_OBJCFLAGS $optarg"
323 --extra-cxxflags=*) EXTRA_CXXFLAGS
="$EXTRA_CXXFLAGS $optarg"
325 --extra-objcflags=*) EXTRA_OBJCFLAGS
="$EXTRA_OBJCFLAGS $optarg"
327 --extra-ldflags=*) EXTRA_LDFLAGS
="$EXTRA_LDFLAGS $optarg"
329 --cross-cc-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --cross-cc-FOO option"
331 --cross-cc-cflags-*) cc_arch
=${opt#--cross-cc-cflags-}; cc_arch
=${cc_arch%%=*}
332 eval "cross_cc_cflags_${cc_arch}=\$optarg"
334 --cross-cc-*) cc_arch
=${opt#--cross-cc-}; cc_arch
=${cc_arch%%=*}
335 eval "cross_cc_${cc_arch}=\$optarg"
337 --cross-prefix-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --cross-prefix-FOO option"
339 --cross-prefix-*) cc_arch
=${opt#--cross-prefix-}; cc_arch
=${cc_arch%%=*}
340 eval "cross_prefix_${cc_arch}=\$optarg"
345 # Preferred compiler:
347 # ${cross_prefix}gcc (if cross-prefix specified)
349 if test -z "${CC}${cross_prefix}"; then
352 cc
="${CC-${cross_prefix}gcc}"
355 if test -z "${CXX}${cross_prefix}"; then
358 cxx
="${CXX-${cross_prefix}g++}"
361 # Preferred ObjC compiler:
362 # $objcc (if set, i.e. via --objcc option)
363 # ${cross_prefix}clang (if cross-prefix specified)
364 # clang (if available)
366 if test -z "${objcc}${cross_prefix}"; then
373 objcc
="${objcc-${cross_prefix}clang}"
376 ar="${AR-${cross_prefix}ar}"
377 as
="${AS-${cross_prefix}as}"
379 objcopy
="${OBJCOPY-${cross_prefix}objcopy}"
380 ld
="${LD-${cross_prefix}ld}"
381 ranlib
="${RANLIB-${cross_prefix}ranlib}"
382 nm
="${NM-${cross_prefix}nm}"
384 strip
="${STRIP-${cross_prefix}strip}"
385 widl
="${WIDL-${cross_prefix}widl}"
386 windres
="${WINDRES-${cross_prefix}windres}"
387 windmc
="${WINDMC-${cross_prefix}windmc}"
388 pkg_config
="${PKG_CONFIG-${cross_prefix}pkg-config}"
389 sdl2_config
="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
391 # default flags for all hosts
392 # We use -fwrapv to tell the compiler that we require a C dialect where
393 # left shift of signed integers is well defined and has the expected
394 # 2s-complement style results. (Both clang and gcc agree that it
395 # provides these semantics.)
396 QEMU_CFLAGS
="-fno-strict-aliasing -fno-common -fwrapv"
397 QEMU_CFLAGS
="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
401 # Flags that are needed during configure but later taken care of by Meson
402 CONFIGURE_CFLAGS
="-std=gnu11 -Wall"
409 #error $1 not defined
411 int main(void) { return 0; }
418 int main(void) { return 0; }
422 if check_define __linux__
; then
424 elif check_define _WIN32
; then
426 elif check_define __OpenBSD__
; then
428 elif check_define __sun__
; then
430 elif check_define __HAIKU__
; then
432 elif check_define __FreeBSD__
; then
434 elif check_define __FreeBSD_kernel__
&& check_define __GLIBC__
; then
435 targetos
=gnu
/kfreebsd
436 elif check_define __DragonFly__
; then
438 elif check_define __NetBSD__
; then
440 elif check_define __APPLE__
; then
443 # This is a fatal error, but don't report it yet, because we
444 # might be going to just print the --help text, or it might
445 # be the result of a missing compiler.
467 # needed for kinfo_getvmmap(3) in libutil.h
484 # Disable attempts to use ObjectiveC features in os/object.h since they
485 # won't work when we're compiling with gcc as a C compiler.
486 QEMU_CFLAGS
="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
491 # needed for CMSG_ macros in sys/socket.h
492 QEMU_CFLAGS
="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
493 # needed for TIOCWIN* defines in termios.h
494 QEMU_CFLAGS
="-D__EXTENSIONS__ $QEMU_CFLAGS"
498 QEMU_CFLAGS
="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
505 if test ! -z "$cpu" ; then
506 # command line argument
508 elif check_define __i386__
; then
510 elif check_define __x86_64__
; then
511 if check_define __ILP32__
; then
516 elif check_define __sparc__
; then
517 if check_define __arch64__
; then
522 elif check_define _ARCH_PPC
; then
523 if check_define _ARCH_PPC64
; then
524 if check_define _LITTLE_ENDIAN
; then
532 elif check_define __mips__
; then
534 elif check_define __s390__
; then
535 if check_define __s390x__
; then
540 elif check_define __riscv
; then
542 elif check_define __arm__
; then
544 elif check_define __aarch64__
; then
546 elif check_define __loongarch64
; then
549 # Using uname is really broken, but it is just a fallback for architectures
550 # that are going to use TCI anyway
552 echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
555 # Normalise host CPU name and set multilib cflags. The canonicalization
556 # isn't really necessary, because the architectures that we check for
557 # should not hit the 'uname -m' case, but better safe than sorry.
558 # Note that this case should only have supported host CPUs, not guests.
568 CPU_CFLAGS
="-mx32" ;;
571 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
572 # If we truly care, we should simply detect this case at
573 # runtime and generate the fallback to serial emulation.
574 CPU_CFLAGS
="-m64 -mcx16" ;;
582 CPU_CFLAGS
="-m64 -mbig-endian" ;;
585 CPU_CFLAGS
="-m64 -mlittle-endian" ;;
594 CPU_CFLAGS
="-m32 -mv8plus -mcpu=ultrasparc" ;;
596 CPU_CFLAGS
="-m64 -mcpu=ultrasparc" ;;
599 : ${make=${MAKE-make}}
603 # We require python >= 3.7.
604 # NB: a True python conditional creates a non-zero return code (Failure)
605 "$1" -c 'import sys; sys.exit(sys.version_info < (3,7))'
611 if test -z "${PYTHON}"; then
612 # A bare 'python' is traditionally python 2.x, but some distros
613 # have it as python 3.x, so check in both places.
614 for binary
in python3 python python3.11 python3.10 python3.9 python3.8 python3.7
; do
615 if has
"$binary"; then
616 python
=$
(command -v "$binary")
617 if check_py_version
"$python"; then
627 # Same as above, but only check the environment variable.
628 has
"${PYTHON}" || error_exit
"The PYTHON environment variable does not point to an executable"
629 python
=$
(command -v "$PYTHON")
630 if check_py_version
"$python"; then
634 first_python
=$first_python
638 # Check for ancillary tools used in testing
640 for binary
in genisoimage mkisofs
644 genisoimage
=$
(command -v "$binary")
649 if test "$mingw32" = "yes" ; then
651 # MinGW needs -mthreads for TLS and macro _MT.
652 CONFIGURE_CFLAGS
="-mthreads $CONFIGURE_CFLAGS"
660 meson_option_build_array
() {
662 (if test "$targetos" = windows
; then
669 # backslash escape any '\' and '"' characters
670 printf "%s" "$e" |
sed -e 's/\([\"]\)/\\\1/g'
676 .
"$source_path/scripts/meson-buildoptions.sh"
680 meson_options
="$meson_options $(quote_sh "$1")"
682 meson_option_parse
() {
683 meson_options
="$meson_options $(_meson_option_parse "$@
")"
684 if test $?
-eq 1; then
685 echo "ERROR: unknown option $1"
686 echo "Try '$0 --help' for more information"
692 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
694 --help|
-h) show_help
=yes
696 --version|
-V) exec cat "$source_path/VERSION"
698 --prefix=*) prefix
="$optarg"
704 --host-cc=*) host_cc
="$optarg"
710 --make=*) make="$optarg"
714 --python=*) python
="$optarg"
716 --skip-meson) skip_meson
=yes
718 --ninja=*) ninja
="$optarg"
720 --smbd=*) smbd
="$optarg"
734 --enable-debug-info) meson_option_add
-Ddebug=true
736 --disable-debug-info) meson_option_add
-Ddebug=false
738 --enable-docs) docs
=enabled
740 --disable-docs) docs
=disabled
744 --target-list=*) target_list
="$optarg"
745 if test "$target_list_exclude"; then
746 error_exit
"Can't mix --target-list with --target-list-exclude"
749 --target-list-exclude=*) target_list_exclude
="$optarg"
750 if test "$target_list"; then
751 error_exit
"Can't mix --target-list-exclude with --target-list"
754 --with-default-devices) meson_option_add
-Ddefault_devices=true
756 --without-default-devices) meson_option_add
-Ddefault_devices=false
758 --with-devices-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --with-devices-FOO option"
760 --with-devices-*) device_arch
=${opt#--with-devices-};
761 device_arch
=${device_arch%%=*}
762 cf
=$source_path/configs
/devices
/$device_arch-softmmu/$optarg.mak
763 if test -f "$cf"; then
764 device_archs
="$device_archs $device_arch"
765 eval "devices_${device_arch}=\$optarg"
767 error_exit
"File $cf does not exist"
770 --without-default-features) # processed above
772 --static) static
="yes"
774 --bindir=*) bindir
="$optarg"
776 --with-suffix=*) qemu_suffix
="$optarg"
779 --disable-dependency-tracking|\
780 --sbindir=*|
--sharedstatedir=*|\
781 --oldincludedir=*|
--datarootdir=*|
--infodir=*|\
782 --htmldir=*|
--dvidir=*|
--pdfdir=*|
--psdir=*)
783 # These switches are silently ignored, for compatibility with
784 # autoconf-generated configure scripts. This allows QEMU's
785 # configure to be used by RPM and similar macros that set
786 # lots of directory switches by default.
788 --enable-debug-tcg) debug_tcg
="yes"
790 --disable-debug-tcg) debug_tcg
="no"
793 # Enable debugging options that aren't excessively noisy
795 meson_option_parse
--enable-debug-graph-lock ""
796 meson_option_parse
--enable-debug-mutex ""
797 meson_option_add
-Doptimization=0
799 --disable-tcg) tcg
="disabled"
802 --enable-tcg) tcg
="enabled"
804 --disable-system) softmmu
="no"
806 --enable-system) softmmu
="yes"
813 --disable-linux-user) linux_user
="no"
815 --enable-linux-user) linux_user
="yes"
817 --disable-bsd-user) bsd_user
="no"
819 --enable-bsd-user) bsd_user
="yes"
821 --enable-pie) pie
="yes"
823 --disable-pie) pie
="no"
825 --enable-werror) werror
="yes"
827 --disable-werror) werror
="no"
829 --enable-stack-protector) stack_protector
="yes"
831 --disable-stack-protector) stack_protector
="no"
833 --enable-safe-stack) safe_stack
="yes"
835 --disable-safe-stack) safe_stack
="no"
839 meson_option_add
-Db_lto=true
841 --disable-cfi) cfi
="false"
843 --disable-fdt) fdt
="disabled"
845 --enable-fdt) fdt
="enabled"
847 --enable-fdt=git
) fdt
="internal"
849 --enable-fdt=*) fdt
="$optarg"
851 --with-coroutine=*) coroutine
="$optarg"
853 --with-git=*) git
="$optarg"
855 --with-git-submodules=*)
856 git_submodules_action
="$optarg"
858 --disable-pypi) pypi
="disabled"
860 --enable-pypi) pypi
="enabled"
862 --enable-plugins) if test "$mingw32" = "yes"; then
863 error_exit
"TCG plugins not currently supported on Windows platforms"
868 --disable-plugins) plugins
="no"
870 --enable-containers) use_containers
="yes"
872 --disable-containers) use_containers
="no"
874 --gdb=*) gdb_bin
="$optarg"
876 --enable-vfio-user-server) vfio_user_server
="enabled"
878 --disable-vfio-user-server) vfio_user_server
="disabled"
880 # everything else has the same name in configure and meson
881 --*) meson_option_parse
"$opt" "$optarg"
886 # test for any invalid configuration combinations
887 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
888 error_exit
"Can't enable plugins on non-TCG builds"
891 case $git_submodules_action in
893 if test ! -e "$source_path/.git"; then
894 echo "ERROR: cannot $git_submodules_action git submodules without .git"
899 if ! test -f "$source_path/ui/keycodemapdb/README"
902 echo "ERROR: missing GIT submodules"
904 if test -e "$source_path/.git"; then
905 echo "--with-git-submodules=ignore specified but submodules were not"
906 echo "checked out. Please initialize and update submodules."
908 echo "This is not a GIT checkout but module content appears to"
909 echo "be missing. Do not use 'git archive' or GitHub download links"
910 echo "to acquire QEMU source archives. Non-GIT builds are only"
911 echo "supported with source archives linked from:"
913 echo " https://www.qemu.org/download/#source"
915 echo "Developers working with GIT can use scripts/archive-source.sh"
916 echo "if they need to create valid source archives."
923 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
928 default_target_list
=""
931 if [ "$linux_user" != no
]; then
932 if [ "$targetos" = linux
] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then
934 elif [ "$linux_user" = yes ]; then
935 error_exit
"linux-user not supported on this architecture"
938 if [ "$bsd_user" != no
]; then
939 if [ "$bsd_user" = "" ]; then
940 test $targetos = freebsd
&& bsd_user
=yes
942 if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
943 error_exit
"bsd-user not supported on this host OS"
946 if [ "$softmmu" = "yes" ]; then
947 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
949 if [ "$linux_user" = "yes" ]; then
950 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
952 if [ "$bsd_user" = "yes" ]; then
953 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
956 for config
in $mak_wilds; do
957 target
="$(basename "$config" .mak)"
958 if echo "$target_list_exclude" |
grep -vq "$target"; then
959 default_target_list
="${default_target_list} $target"
963 if test x
"$show_help" = x
"yes" ; then
966 Usage: configure [options]
967 Options: [defaults in brackets after descriptions]
970 --help print this message
971 --prefix=PREFIX install in PREFIX [$prefix]
972 --target-list=LIST set target list (default: build all)
973 $(echo Available targets: $default_target_list | \
974 fold -s -w 53 | sed -e 's/^/ /')
975 --target-list-exclude=LIST exclude a set of targets from the default target-list
977 Advanced options (experts only):
978 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
979 --cc=CC use C compiler CC [$cc]
980 --host-cc=CC use C compiler CC [$host_cc] for code run at
982 --cxx=CXX use C++ compiler CXX [$cxx]
983 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
984 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
985 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
986 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
987 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
988 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
989 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
990 --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
991 --make=MAKE use specified make [$make]
992 --python=PYTHON use specified python [$python]
993 --ninja=NINJA use specified ninja [$ninja]
994 --smbd=SMBD use specified smbd [$smbd]
995 --with-git=GIT use specified git [$git]
996 --with-git-submodules=update update git submodules (default if .git dir exists)
997 --with-git-submodules=validate fail if git submodules are not up to date
998 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
999 --static enable static build [$static]
1000 --bindir=PATH install binaries in PATH
1001 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1002 --without-default-features default all --enable-* options to "disabled"
1003 --without-default-devices do not include any device that is not needed to
1004 start the emulator (only use if you are including
1005 desired devices in configs/devices/)
1006 --with-devices-ARCH=NAME override default configs/devices
1007 --enable-debug enable common debug build options
1008 --disable-werror disable compilation abort on warning
1009 --disable-stack-protector disable compiler-provided stack protection
1010 --cpu=CPU Build for host CPU [$cpu]
1011 --with-coroutine=BACKEND coroutine backend. Supported options:
1012 ucontext, sigaltstack, windows
1014 enable plugins via shared library loading
1015 --disable-containers don't use containers for cross-building
1016 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1020 system all system emulation targets
1021 user supported user emulation targets
1022 linux-user all linux usermode emulation targets
1023 bsd-user all BSD usermode emulation targets
1024 pie Position Independent Executables
1025 debug-tcg TCG debugging (default is disabled)
1026 debug-info debugging information
1027 safe-stack SafeStack Stack Smash Protection. Depends on
1028 clang/llvm and requires coroutine backend ucontext.
1030 NOTE: The object files are built at the place where configure is launched
1035 # Remove old dependency files to make sure that they get properly regenerated
1036 rm -f .
/*/config-devices.mak.d
1038 if test -z "$python"
1040 # If first_python is set, there was a binary somewhere even though
1041 # it was not suitable. Use it for the error message.
1042 if test -n "$first_python"; then
1043 error_exit
"Cannot use '$first_python', Python >= 3.7 is required." \
1044 "Use --python=/path/to/python to specify a supported Python."
1046 error_exit
"Python not found. Use --python=/path/to/python"
1052 error_exit
"GNU make ($make) not found"
1055 if ! check_py_version
"$python"; then
1056 error_exit
"Cannot use '$python', Python >= 3.7 is required." \
1057 "Use --python=/path/to/python to specify a supported Python." \
1059 " openSUSE Leap 15.3+: zypper install python39" \
1060 " CentOS 8: dnf install python38"
1064 python
="$(command -v "$python")"
1066 # Create a Python virtual environment using our configured python.
1067 # The stdout of this script will be the location of a symlink that
1068 # points to the configured Python.
1069 # Entry point scripts for pip, meson, and sphinx are generated if those
1070 # packages are present.
1072 # Defaults assumed for now:
1073 # - venv is cleared if it exists already;
1074 # - venv is allowed to use system packages;
1075 # - all setup can be performed offline;
1076 # - missing packages may be fetched from PyPI,
1077 # unless --disable-pypi is passed.
1078 # - pip is not installed into the venv when possible,
1079 # but ensurepip is called as a fallback when necessary.
1081 echo "python determined to be '$python'"
1082 echo "python version: $($python --version)"
1084 python
="$($python -B "${source_path}/python
/scripts
/mkvenv.py
" create pyvenv)"
1085 if test "$?" -ne 0 ; then
1086 error_exit
"python venv creation failed"
1089 # Suppress writing compiled files
1091 mkvenv
="$python ${source_path}/python/scripts/mkvenv.py"
1094 if test "$pypi" = "enabled" ; then
1095 mkvenv_flags
="--online"
1098 if ! $mkvenv ensure \
1100 --dir "${source_path}/python/wheels" \
1101 --diagnose "meson" \
1107 # At this point, we expect Meson to be installed and available.
1108 # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
1109 # We ignore PATH completely here: we want to use the venv's Meson
1112 meson
="$(cd pyvenv/bin; pwd)/meson"
1114 # Conditionally ensure Sphinx is installed.
1117 if test "$pypi" = "enabled" -a "$docs" = "enabled" ; then
1118 mkvenv_flags
="--online"
1121 if test "$docs" != "disabled" ; then
1122 if ! $mkvenv ensure \
1124 --diagnose "sphinx-build" \
1125 "sphinx>=1.6.0" "sphinx-rtd-theme>=0.5.0";
1127 if test "$docs" = "enabled" ; then
1130 echo "Sphinx not found/usable, disabling docs."
1139 if test -z "$ninja"; then
1140 for c
in ninja ninja-build samu
; do
1142 ninja
=$
(command -v "$c")
1146 if test -z "$ninja"; then
1147 error_exit
"Cannot find Ninja"
1151 # Check that the C compiler works. Doing this here before testing
1152 # the host CPU ensures that we had a valid CC to autodetect the
1153 # $cpu var (and we should bail right here if that's not the case).
1154 # It also allows the help message to be printed without a CC.
1156 if compile_object
; then
1157 : C compiler works ok
1159 error_exit
"\"$cc\" either does not exist or does not work"
1161 if ! compile_prog
; then
1162 error_exit
"\"$cc\" cannot build an executable (is your linker broken?)"
1165 # Consult white-list to determine whether to enable werror
1166 # by default. Only enable by default for git builds
1167 if test -z "$werror" ; then
1168 if test "$git_submodules_action" != "ignore" && \
1169 { test "$linux" = "yes" ||
test "$mingw32" = "yes"; }; then
1176 if test "$targetos" = "bogus"; then
1177 # Now that we know that we're not printing the help and that
1178 # the compiler works (so the results of the check_defines we used
1179 # to identify the OS are reliable), if we didn't recognize the
1180 # host OS we should stop now.
1181 error_exit
"Unrecognized host OS (uname -s reports '$(uname -s)')"
1184 # Check whether the compiler matches our minimum requirements:
1186 #if defined(__clang_major__) && defined(__clang_minor__)
1187 # ifdef __apple_build_version__
1188 # if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0)
1189 # error You need at least XCode Clang v12.0 to compile QEMU
1192 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1193 # error You need at least Clang v10.0 to compile QEMU
1196 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1197 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1198 # error You need at least GCC v7.4.0 to compile QEMU
1201 # error You either need GCC or Clang to compiler QEMU
1203 int main (void) { return 0; }
1205 if ! compile_prog
"" "" ; then
1206 error_exit
"You need at least GCC v7.4 or Clang v10.0 (or XCode Clang v12.0)"
1209 # Accumulate -Wfoo and -Wno-bar separately.
1210 # We will list all of the enable flags first, and the disable flags second.
1211 # Note that we do not add -Werror, because that would enable it for all
1212 # configure tests. If a configure test failed due to -Werror this would
1213 # just silently disable some features, so it's too error prone.
1216 add_to warn_flags
-Wundef
1217 add_to warn_flags
-Wwrite-strings
1218 add_to warn_flags
-Wmissing-prototypes
1219 add_to warn_flags
-Wstrict-prototypes
1220 add_to warn_flags
-Wredundant-decls
1221 add_to warn_flags
-Wold-style-declaration
1222 add_to warn_flags
-Wold-style-definition
1223 add_to warn_flags
-Wtype-limits
1224 add_to warn_flags
-Wformat-security
1225 add_to warn_flags
-Wformat-y2k
1226 add_to warn_flags
-Winit-self
1227 add_to warn_flags
-Wignored-qualifiers
1228 add_to warn_flags
-Wempty-body
1229 add_to warn_flags
-Wnested-externs
1230 add_to warn_flags
-Wendif-labels
1231 add_to warn_flags
-Wexpansion-to-defined
1232 add_to warn_flags
-Wimplicit-fallthrough=2
1233 add_to warn_flags
-Wmissing-format-attribute
1235 if test "$targetos" != "darwin"; then
1236 add_to warn_flags
-Wthread-safety
1240 add_to nowarn_flags
-Wno-initializer-overrides
1241 add_to nowarn_flags
-Wno-missing-include-dirs
1242 add_to nowarn_flags
-Wno-shift-negative-value
1243 add_to nowarn_flags
-Wno-string-plus-int
1244 add_to nowarn_flags
-Wno-typedef-redefinition
1245 add_to nowarn_flags
-Wno-tautological-type-limit-compare
1246 add_to nowarn_flags
-Wno-psabi
1247 add_to nowarn_flags
-Wno-gnu-variable-sized-type-not-at-end
1249 gcc_flags
="$warn_flags $nowarn_flags"
1251 cc_has_warning_flag
() {
1254 # Use the positive sense of the flag when testing for -Wno-wombat
1255 # support (gcc will happily accept the -Wno- form of unknown
1257 optflag
="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1258 compile_prog
"-Werror $optflag" ""
1261 objcc_has_warning_flag
() {
1263 int main(void) { return 0; }
1266 # Use the positive sense of the flag when testing for -Wno-wombat
1267 # support (gcc will happily accept the -Wno- form of unknown
1269 optflag
="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1270 do_objc
-Werror $optflag \
1271 $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
1272 -o $TMPE $TMPM $QEMU_LDFLAGS
1275 for flag
in $gcc_flags; do
1276 if cc_has_warning_flag
$flag ; then
1277 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1279 if objcc_has_warning_flag
$flag ; then
1280 QEMU_OBJCFLAGS
="$QEMU_OBJCFLAGS $flag"
1284 if test "$stack_protector" != "no"; then
1286 int main(int argc, char *argv[])
1288 char arr[64], *p = arr, *c = argv[argc - 1];
1295 gcc_flags
="-fstack-protector-strong -fstack-protector-all"
1297 for flag
in $gcc_flags; do
1298 # We need to check both a compile and a link, since some compiler
1299 # setups fail only on a .c->.o compile and some only at link time
1300 if compile_object
"-Werror $flag" &&
1301 compile_prog
"-Werror $flag" ""; then
1302 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1303 QEMU_LDFLAGS
="$QEMU_LDFLAGS $flag"
1308 if test "$stack_protector" = yes; then
1309 if test $sp_on = 0; then
1310 error_exit
"Stack protector not supported"
1315 if test "$static" = "yes" ; then
1316 if test "$plugins" = "yes"; then
1317 error_exit
"static and plugins are mutually incompatible"
1322 test "$plugins" = "" && plugins
=yes
1327 # define THREAD __thread
1331 static THREAD int tls_var;
1332 int main(void) { return tls_var; }
1335 # Meson currently only handles pie as a boolean for now so if we have
1336 # explicitly disabled PIE we need to extend our cflags because it wont.
1337 if test "$static" = "yes"; then
1338 if test "$pie" != "no" && compile_prog
"-Werror -fPIE -DPIE" "-static-pie"; then
1339 CONFIGURE_CFLAGS
="-fPIE -DPIE $CONFIGURE_CFLAGS"
1341 elif test "$pie" = "yes"; then
1342 error_exit
"-static-pie not available due to missing toolchain support"
1345 QEMU_CFLAGS
="-fno-pie $QEMU_CFLAGS"
1347 elif test "$pie" = "no"; then
1348 if compile_prog
"-Werror -fno-pie" "-no-pie"; then
1349 CONFIGURE_CFLAGS
="-fno-pie $CONFIGURE_CFLAGS"
1350 CONFIGURE_LDFLAGS
="-no-pie $CONFIGURE_LDFLAGS"
1351 QEMU_CFLAGS
="-fno-pie -no-pie $QEMU_CFLAGS"
1353 elif compile_prog
"-Werror -fPIE -DPIE" "-pie"; then
1354 CONFIGURE_CFLAGS
="-fPIE -DPIE $CONFIGURE_CFLAGS"
1355 CONFIGURE_LDFLAGS
="-pie $CONFIGURE_LDFLAGS"
1357 elif test "$pie" = "yes"; then
1358 error_exit
"PIE not available due to missing toolchain support"
1360 echo "Disabling PIE due to missing toolchain support"
1364 ##########################################
1365 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1366 # use i686 as default anyway, but for those that don't, an explicit
1367 # specification is necessary
1369 if test "$cpu" = "i386"; then
1371 static int sfaa(int *ptr)
1373 return __sync_fetch_and_and(ptr, 0);
1379 val = __sync_val_compare_and_swap(&val, 0, 1);
1384 if ! compile_prog
"" "" ; then
1385 QEMU_CFLAGS
="-march=i486 $QEMU_CFLAGS"
1389 if test -z "${target_list+xxx}" ; then
1391 for target
in $default_target_list; do
1392 target_list
="$target_list $target"
1394 target_list
="${target_list# }"
1397 target_list
=$
(echo "$target_list" |
sed -e 's/,/ /g')
1398 for target
in $target_list; do
1399 # Check that we recognised the target name; this allows a more
1400 # friendly error message than if we let it fall through.
1401 case " $default_target_list " in
1405 error_exit
"Unknown target name '$target'"
1411 # see if system emulation was really requested
1412 case " $target_list " in
1413 *"-softmmu "*) softmmu
=yes
1419 if test "$tcg" = "auto"; then
1420 if test -z "$target_list"; then
1427 if test "$tcg" = "enabled"; then
1428 git_submodules
="$git_submodules tests/fp/berkeley-testfloat-3"
1429 git_submodules
="$git_submodules tests/fp/berkeley-softfloat-3"
1432 ##########################################
1433 # big/little endian test
1435 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1438 int main(void) { return 0; }
1441 if ! compile_prog
; then
1445 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1448 int main(void) { return 0; }
1451 if ! compile_prog
; then
1454 echo big
/little
test failed
1459 ##########################################
1463 auto | enabled | internal
)
1464 # Simpler to always update submodule, even if not needed.
1465 git_submodules
="${git_submodules} dtc"
1469 ##########################################
1470 # check and set a backend for coroutine
1472 # We prefer ucontext, but it's not always possible. The fallback
1473 # is sigcontext. On Windows the only valid backend is the Windows
1477 if test "$darwin" != "yes"; then
1479 #include <ucontext.h>
1480 #ifdef __stub_makecontext
1481 #error Ignoring glibc stub makecontext which will always fail
1483 int main(void) { makecontext(0, 0, 0); return 0; }
1485 if compile_prog
"" "" ; then
1490 if test "$coroutine" = ""; then
1491 if test "$mingw32" = "yes"; then
1493 elif test "$ucontext_works" = "yes"; then
1496 coroutine
=sigaltstack
1501 if test "$mingw32" != "yes"; then
1502 error_exit
"'windows' coroutine backend only valid for Windows"
1504 # Unfortunately the user visible backend name doesn't match the
1505 # coroutine-*.c filename for this case, so we have to adjust it here.
1509 if test "$ucontext_works" != "yes"; then
1510 error_exit
"'ucontext' backend requested but makecontext not available"
1514 if test "$mingw32" = "yes"; then
1515 error_exit
"only the 'windows' coroutine backend is valid for Windows"
1519 error_exit
"unknown coroutine backend $coroutine"
1524 ##################################################
1528 if test "$safe_stack" = "yes"; then
1532 #if ! __has_feature(safe_stack)
1533 #error SafeStack Disabled
1538 flag
="-fsanitize=safe-stack"
1539 # Check that safe-stack is supported and enabled.
1540 if compile_prog
"-Werror $flag" "$flag"; then
1541 # Flag needed both at compilation and at linking
1542 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1543 QEMU_LDFLAGS
="$QEMU_LDFLAGS $flag"
1545 error_exit
"SafeStack not supported by your compiler"
1547 if test "$coroutine" != "ucontext"; then
1548 error_exit
"SafeStack is only supported by the coroutine backend ucontext"
1554 #if defined(__has_feature)
1555 #if __has_feature(safe_stack)
1556 #error SafeStack Enabled
1562 if test "$safe_stack" = "no"; then
1563 # Make sure that safe-stack is disabled
1564 if ! compile_prog
"-Werror" ""; then
1565 # SafeStack was already enabled, try to explicitly remove the feature
1566 flag
="-fno-sanitize=safe-stack"
1567 if ! compile_prog
"-Werror $flag" "$flag"; then
1568 error_exit
"Configure cannot disable SafeStack"
1570 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1571 QEMU_LDFLAGS
="$QEMU_LDFLAGS $flag"
1573 else # "$safe_stack" = ""
1574 # Set safe_stack to yes or no based on pre-existing flags
1575 if compile_prog
"-Werror" ""; then
1579 if test "$coroutine" != "ucontext"; then
1580 error_exit
"SafeStack is only supported by the coroutine backend ucontext"
1586 ########################################
1587 # check if ccache is interfering with
1588 # semantic analysis of macros
1593 static const int Z = 1;
1594 #define fn() ({ Z; })
1595 #define TAUT(X) ((X) == Z)
1596 #define PAREN(X, Y) (X == Y)
1604 if (PAREN(x, y)) return 0;
1605 if (TAUT(Z)) return 0;
1610 if ! compile_object
"-Werror"; then
1614 ##########################################
1615 # functions to probe cross compilers
1619 if test $use_containers = "yes" && (has
"docker" || has
"podman"); then
1620 case $
($python "$source_path"/tests
/docker
/docker.py probe
) in
1621 *docker
) container
=docker
;;
1622 podman
) container
=podman
;;
1625 if test "$container" != "no"; then
1626 docker_py
="$python $source_path/tests/docker/docker.py --engine $container"
1627 runc
=$
($python "$source_path"/tests
/docker
/docker.py probe
)
1631 # cross compilers defaults, can be overridden with --cross-cc-ARCH
1632 : ${cross_prefix_aarch64="aarch64-linux-gnu-"}
1633 : ${cross_prefix_aarch64_be="$cross_prefix_aarch64"}
1634 : ${cross_prefix_alpha="alpha-linux-gnu-"}
1635 : ${cross_prefix_arm="arm-linux-gnueabihf-"}
1636 : ${cross_prefix_armeb="$cross_prefix_arm"}
1637 : ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"}
1638 : ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"}
1639 : ${cross_prefix_hppa="hppa-linux-gnu-"}
1640 : ${cross_prefix_i386="i686-linux-gnu-"}
1641 : ${cross_prefix_m68k="m68k-linux-gnu-"}
1642 : ${cross_prefix_microblaze="microblaze-linux-musl-"}
1643 : ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"}
1644 : ${cross_prefix_mips64="mips64-linux-gnuabi64-"}
1645 : ${cross_prefix_mipsel="mipsel-linux-gnu-"}
1646 : ${cross_prefix_mips="mips-linux-gnu-"}
1647 : ${cross_prefix_nios2="nios2-linux-gnu-"}
1648 : ${cross_prefix_ppc="powerpc-linux-gnu-"}
1649 : ${cross_prefix_ppc64="powerpc64-linux-gnu-"}
1650 : ${cross_prefix_ppc64le="$cross_prefix_ppc64"}
1651 : ${cross_prefix_riscv64="riscv64-linux-gnu-"}
1652 : ${cross_prefix_s390x="s390x-linux-gnu-"}
1653 : ${cross_prefix_sh4="sh4-linux-gnu-"}
1654 : ${cross_prefix_sparc64="sparc64-linux-gnu-"}
1655 : ${cross_prefix_sparc="$cross_prefix_sparc64"}
1656 : ${cross_prefix_x86_64="x86_64-linux-gnu-"}
1658 : ${cross_cc_aarch64_be="$cross_cc_aarch64"}
1659 : ${cross_cc_cflags_aarch64_be="-mbig-endian"}
1660 : ${cross_cc_armeb="$cross_cc_arm"}
1661 : ${cross_cc_cflags_armeb="-mbig-endian"}
1662 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
1663 : ${cross_cc_cflags_hexagon="-mv67 -O2 -static"}
1664 : ${cross_cc_cflags_i386="-m32"}
1665 : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
1666 : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
1667 : ${cross_cc_ppc64le="$cross_cc_ppc64"}
1668 : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
1669 : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
1670 : ${cross_cc_sparc="$cross_cc_sparc64"}
1671 : ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
1672 : ${cross_cc_cflags_x86_64="-m64"}
1674 compute_target_variable
() {
1676 if eval test -n "\"\${cross_prefix_$1}\""; then
1677 if eval has
"\"\${cross_prefix_$1}\$3\""; then
1678 eval "$2=\"\${cross_prefix_$1}\$3\""
1685 case " $target_list " in
1686 *" $i "*) return 0;;
1693 # probe_target_compiler TARGET
1695 # Look for a compiler for the given target, either native or cross.
1696 # Set variables target_* if a compiler is found, and container_cross_*
1697 # if a Docker-based cross-compiler image is known for the target.
1698 # Set got_cross_cc to yes/no depending on whether a non-container-based
1699 # compiler was found.
1701 # If TARGET is a user-mode emulation target, also set build_static to
1702 # "y" if static linking is possible.
1704 probe_target_compiler
() {
1705 # reset all output variables
1714 container_cross_objcopy
=
1715 container_cross_ranlib
=
1716 container_cross_strip
=
1718 # We shall skip configuring the target compiler if the user didn't
1719 # bother enabling an appropriate guest. This avoids building
1720 # extraneous firmware images and tests.
1721 if test "${target_list#*$1}" = "$1"; then
1725 target_arch
=${1%%-*}
1726 case $target_arch in
1727 aarch64
) container_hosts
="x86_64 aarch64" ;;
1728 alpha
) container_hosts
=x86_64
;;
1729 arm
) container_hosts
="x86_64 aarch64" ;;
1730 cris
) container_hosts
=x86_64
;;
1731 hexagon
) container_hosts
=x86_64
;;
1732 hppa
) container_hosts
=x86_64
;;
1733 i386
) container_hosts
=x86_64
;;
1734 loongarch64
) container_hosts
=x86_64
;;
1735 m68k
) container_hosts
=x86_64
;;
1736 microblaze
) container_hosts
=x86_64
;;
1737 mips64el
) container_hosts
=x86_64
;;
1738 mips64
) container_hosts
=x86_64
;;
1739 mipsel
) container_hosts
=x86_64
;;
1740 mips
) container_hosts
=x86_64
;;
1741 nios2
) container_hosts
=x86_64
;;
1742 ppc
) container_hosts
=x86_64
;;
1743 ppc64|ppc64le
) container_hosts
=x86_64
;;
1744 riscv64
) container_hosts
=x86_64
;;
1745 s390x
) container_hosts
=x86_64
;;
1746 sh4
) container_hosts
=x86_64
;;
1747 sparc64
) container_hosts
=x86_64
;;
1748 tricore
) container_hosts
=x86_64
;;
1749 x86_64
) container_hosts
="aarch64 ppc64el x86_64" ;;
1750 xtensa
*) container_hosts
=x86_64
;;
1753 for host in $container_hosts; do
1754 test "$container" != no ||
continue
1755 test "$host" = "$cpu" ||
continue
1756 case $target_arch in
1758 # We don't have any bigendian build tools so we only use this for AArch64
1759 container_image
=debian-arm64-cross
1760 container_cross_prefix
=aarch64-linux-gnu-
1761 container_cross_cc
=${container_cross_prefix}gcc-10
1764 container_image
=debian-alpha-cross
1765 container_cross_prefix
=alpha-linux-gnu-
1768 # We don't have any bigendian build tools so we only use this for ARM
1769 container_image
=debian-armhf-cross
1770 container_cross_prefix
=arm-linux-gnueabihf-
1773 container_image
=fedora-cris-cross
1774 container_cross_prefix
=cris-linux-gnu-
1777 container_image
=debian-hexagon-cross
1778 container_cross_prefix
=hexagon-unknown-linux-musl-
1779 container_cross_cc
=${container_cross_prefix}clang
1782 container_image
=debian-hppa-cross
1783 container_cross_prefix
=hppa-linux-gnu-
1786 container_image
=fedora-i386-cross
1787 container_cross_prefix
=
1790 container_image
=debian-loongarch-cross
1791 container_cross_prefix
=loongarch64-unknown-linux-gnu-
1794 container_image
=debian-m68k-cross
1795 container_cross_prefix
=m68k-linux-gnu-
1798 container_image
=debian-microblaze-cross
1799 container_cross_prefix
=microblaze-linux-musl-
1802 container_image
=debian-mips64el-cross
1803 container_cross_prefix
=mips64el-linux-gnuabi64-
1806 container_image
=debian-mips64-cross
1807 container_cross_prefix
=mips64-linux-gnuabi64-
1810 container_image
=debian-mipsel-cross
1811 container_cross_prefix
=mipsel-linux-gnu-
1814 container_image
=debian-mips-cross
1815 container_cross_prefix
=mips-linux-gnu-
1818 container_image
=debian-nios2-cross
1819 container_cross_prefix
=nios2-linux-gnu-
1822 container_image
=debian-powerpc-test-cross
1823 container_cross_prefix
=powerpc-linux-gnu-
1824 container_cross_cc
=${container_cross_prefix}gcc-10
1827 container_image
=debian-powerpc-test-cross
1828 container_cross_prefix
=powerpc
${target_arch#ppc}-linux-gnu-
1829 container_cross_cc
=${container_cross_prefix}gcc-10
1832 container_image
=debian-riscv64-test-cross
1833 container_cross_prefix
=riscv64-linux-gnu-
1836 container_image
=debian-s390x-cross
1837 container_cross_prefix
=s390x-linux-gnu-
1840 container_image
=debian-sh4-cross
1841 container_cross_prefix
=sh4-linux-gnu-
1844 container_image
=debian-sparc64-cross
1845 container_cross_prefix
=sparc64-linux-gnu-
1848 container_image
=debian-tricore-cross
1849 container_cross_prefix
=tricore-
1850 container_cross_as
=tricore-as
1851 container_cross_ld
=tricore-ld
1855 container_image
=debian-amd64-cross
1856 container_cross_prefix
=x86_64-linux-gnu-
1859 container_hosts
=x86_64
1860 container_image
=debian-xtensa-cross
1862 # default to the dc232b cpu
1863 container_cross_prefix
=/opt
/2020.07/xtensa-dc232b-elf
/bin
/xtensa-dc232b-elf-
1866 : ${container_cross_cc:=${container_cross_prefix}gcc}
1867 : ${container_cross_ar:=${container_cross_prefix}ar}
1868 : ${container_cross_as:=${container_cross_prefix}as}
1869 : ${container_cross_ld:=${container_cross_prefix}ld}
1870 : ${container_cross_nm:=${container_cross_prefix}nm}
1871 : ${container_cross_objcopy:=${container_cross_prefix}objcopy}
1872 : ${container_cross_ranlib:=${container_cross_prefix}ranlib}
1873 : ${container_cross_strip:=${container_cross_prefix}strip}
1877 case "$target_arch:$cpu" in
1878 aarch64_be
:aarch64 | \
1885 try
='native cross' ;;
1887 eval "target_cflags=\${cross_cc_cflags_$target_arch}"
1888 for thistry
in $try; do
1897 target_objcopy
=$objcopy
1898 target_ranlib
=$ranlib
1903 if eval test -n "\"\${cross_cc_$target_arch}\""; then
1904 if eval has
"\"\${cross_cc_$target_arch}\""; then
1905 eval "target_cc=\"\${cross_cc_$target_arch}\""
1908 compute_target_variable
$target_arch target_cc gcc
1910 target_ccas
=$target_cc
1911 compute_target_variable
$target_arch target_ar
ar
1912 compute_target_variable
$target_arch target_as as
1913 compute_target_variable
$target_arch target_ld ld
1914 compute_target_variable
$target_arch target_nm nm
1915 compute_target_variable
$target_arch target_objcopy objcopy
1916 compute_target_variable
$target_arch target_ranlib ranlib
1917 compute_target_variable
$target_arch target_strip strip
1921 if test -n "$target_cc"; then
1922 case $target_arch in
1924 if $target_cc --version |
grep -qi "clang"; then
1929 elif test -n "$target_as" && test -n "$target_ld"; then
1930 # Special handling for assembler only targets
1948 if do_compiler
"$target_cc" $target_cflags -o $TMPO -c $TMPC &&
1949 do_compiler
"$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
1955 if do_compiler
"$target_cc" $target_cflags -o $TMPE $TMPC -static ; then
1960 if do_compiler
"$target_cc" $target_cflags -o $TMPE $TMPC ; then
1968 if test $got_cross_cc != yes; then
1980 test -n "$target_cc"
1983 write_target_makefile
() {
1984 echo "EXTRA_CFLAGS=$target_cflags"
1985 if test -z "$target_cc" && test -z "$target_as"; then
1986 test -z "$container_image" && error_exit
"Internal error: could not find cross compiler for $1?"
1987 echo "$1: docker-image-$container_image" >> Makefile.prereqs
1988 if test -n "$container_cross_cc"; then
1989 echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1990 echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1992 echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --"
1993 echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --"
1994 echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --"
1995 echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --"
1996 echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --"
1997 echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --"
1998 echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --"
2000 if test -n "$target_cc"; then
2001 echo "CC=$target_cc"
2002 echo "CCAS=$target_ccas"
2004 if test -n "$target_ar"; then
2005 echo "AR=$target_ar"
2007 if test -n "$target_as"; then
2008 echo "AS=$target_as"
2010 if test -n "$target_ld"; then
2011 echo "LD=$target_ld"
2013 if test -n "$target_nm"; then
2014 echo "NM=$target_nm"
2016 if test -n "$target_objcopy"; then
2017 echo "OBJCOPY=$target_objcopy"
2019 if test -n "$target_ranlib"; then
2020 echo "RANLIB=$target_ranlib"
2022 if test -n "$target_strip"; then
2023 echo "STRIP=$target_strip"
2028 ##########################################
2029 # check for vfio_user_server
2031 case "$vfio_user_server" in
2033 if test "$git_submodules_action" != "ignore"; then
2034 git_submodules
="${git_submodules} subprojects/libvfio-user"
2039 #######################################
2040 # cross-compiled firmware targets
2042 # Set up build tree symlinks that point back into the source tree
2043 # (these can be both files and directories).
2044 # Caution: avoid adding files or directories here using wildcards. This
2045 # will result in problems later if a new file matching the wildcard is
2046 # added to the source tree -- nothing will cause configure to be rerun
2047 # so the build tree will be missing the link back to the new file, and
2048 # tests might fail. Prefer to keep the relevant files in their own
2049 # directory and symlink the directory instead.
2051 LINKS
="$LINKS docs/config"
2052 LINKS
="$LINKS pc-bios/optionrom/Makefile"
2053 LINKS
="$LINKS pc-bios/s390-ccw/Makefile"
2054 LINKS
="$LINKS pc-bios/vof/Makefile"
2055 LINKS
="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
2056 LINKS
="$LINKS tests/avocado tests/data"
2057 LINKS
="$LINKS tests/qemu-iotests/check"
2058 LINKS
="$LINKS python"
2059 LINKS
="$LINKS contrib/plugins/Makefile "
2060 for f
in $LINKS ; do
2061 if [ -e "$source_path/$f" ]; then
2062 mkdir
-p "$(dirname ./"$f")"
2063 symlink
"$source_path/$f" "$f"
2067 echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
2069 # Mac OS X ships with a broken assembler
2071 if have_target i386-softmmu x86_64-softmmu
&& \
2072 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
2073 test "$targetos" != "haiku" && \
2074 probe_target_compiler i386-softmmu
; then
2075 roms
="pc-bios/optionrom"
2076 config_mak
=pc-bios
/optionrom
/config.mak
2077 echo "# Automatically generated by configure - do not modify" > $config_mak
2078 echo "TOPSRC_DIR=$source_path" >> $config_mak
2079 write_target_makefile
>> $config_mak
2082 if have_target ppc-softmmu ppc64-softmmu
&& \
2083 probe_target_compiler ppc-softmmu
; then
2084 roms
="$roms pc-bios/vof"
2085 config_mak
=pc-bios
/vof
/config.mak
2086 echo "# Automatically generated by configure - do not modify" > $config_mak
2087 echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
2088 write_target_makefile
>> $config_mak
2091 # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
2092 # (which is the lowest architecture level that Clang supports)
2093 if have_target s390x-softmmu
&& probe_target_compiler s390x-softmmu
; then
2095 do_compiler
"$target_cc" $target_cc_cflags -march=z900
-o $TMPO -c $TMPC
2097 if [ $has_z900 = 0 ] || do_compiler
"$target_cc" $target_cc_cflags -march=z10
-msoft-float -Werror -o $TMPO -c $TMPC; then
2098 if [ $has_z900 != 0 ]; then
2099 echo "WARNING: Your compiler does not support the z900!"
2100 echo " The s390-ccw bios will only work with guest CPUs >= z10."
2102 roms
="$roms pc-bios/s390-ccw"
2103 config_mak
=pc-bios
/s390-ccw
/config-host.mak
2104 echo "# Automatically generated by configure - do not modify" > $config_mak
2105 echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
2106 write_target_makefile
>> $config_mak
2107 # SLOF is required for building the s390-ccw firmware on s390x,
2108 # since it is using the libnet code from SLOF for network booting.
2109 git_submodules
="${git_submodules} roms/SLOF"
2113 #######################################
2114 # generate config-host.mak
2116 if ! (GIT
="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
2120 config_host_mak
="config-host.mak"
2122 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2123 echo >> $config_host_mak
2125 echo all
: >> $config_host_mak
2126 echo "GIT=$git" >> $config_host_mak
2127 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
2128 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
2130 if test "$debug_tcg" = "yes" ; then
2131 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2133 if test "$mingw32" = "yes" ; then
2134 echo "CONFIG_WIN32=y" >> $config_host_mak
2135 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER-QEMU}" >> $config_host_mak
2136 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO-Linux}" >> $config_host_mak
2137 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION-$(cat "$source_path"/VERSION)}" >> $config_host_mak
2139 echo "CONFIG_POSIX=y" >> $config_host_mak
2142 if test "$linux" = "yes" ; then
2143 echo "CONFIG_LINUX=y" >> $config_host_mak
2146 if test "$darwin" = "yes" ; then
2147 echo "CONFIG_DARWIN=y" >> $config_host_mak
2150 if test "$solaris" = "yes" ; then
2151 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2153 echo "SRC_PATH=$source_path" >> $config_host_mak
2154 echo "TARGET_DIRS=$target_list" >> $config_host_mak
2156 # XXX: suppress that
2157 if [ "$bsd" = "yes" ] ; then
2158 echo "CONFIG_BSD=y" >> $config_host_mak
2161 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
2163 if test "$plugins" = "yes" ; then
2164 echo "CONFIG_PLUGIN=y" >> $config_host_mak
2167 if test -n "$gdb_bin"; then
2168 gdb_version
=$
($gdb_bin --version |
head -n 1)
2169 if version_ge
${gdb_version##* } 9.1; then
2170 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2171 gdb_arches
=$
("$source_path/scripts/probe-gdb-support.py" $gdb_bin)
2177 if test "$container" != no
; then
2178 echo "ENGINE=$container" >> $config_host_mak
2179 echo "RUNC=$runc" >> $config_host_mak
2181 echo "ROMS=$roms" >> $config_host_mak
2182 echo "MAKE=$make" >> $config_host_mak
2183 echo "PYTHON=$python" >> $config_host_mak
2184 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
2185 echo "MESON=$meson" >> $config_host_mak
2186 echo "NINJA=$ninja" >> $config_host_mak
2187 echo "PKG_CONFIG=${pkg_config}" >> $config_host_mak
2188 echo "CC=$cc" >> $config_host_mak
2189 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2190 echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
2191 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
2192 echo "EXESUF=$EXESUF" >> $config_host_mak
2194 # use included Linux headers
2195 if test "$linux" = "yes" ; then
2196 mkdir
-p linux-headers
2211 linux_arch
=loongarch
2217 # For most CPUs the kernel architecture name and QEMU CPU name match.
2221 # For non-KVM architectures we will not have asm headers
2222 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
2223 symlink
"$source_path/linux-headers/asm-$linux_arch" linux-headers
/asm
2227 for target
in $target_list; do
2228 target_dir
="$target"
2229 target_name
=$
(echo $target | cut
-d '-' -f 1)$EXESUF
2230 mkdir
-p "$target_dir"
2232 *-user) symlink
"../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
2233 *) symlink
"../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
2237 if test "$default_targets" = "yes"; then
2238 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
2241 if test "$ccache_cpp2" = "yes"; then
2242 echo "export CCACHE_CPP2=y" >> $config_host_mak
2245 if test "$safe_stack" = "yes"; then
2246 echo "CONFIG_SAFESTACK=y" >> $config_host_mak
2249 # tests/tcg configuration
2250 (config_host_mak
=tests
/tcg
/config-host.mak
2252 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2253 echo "SRC_PATH=$source_path" >> $config_host_mak
2254 echo "HOST_CC=$host_cc" >> $config_host_mak
2256 # versioned checked in the main config_host.mak above
2257 if test -n "$gdb_bin"; then
2258 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2260 if test "$plugins" = "yes" ; then
2261 echo "CONFIG_PLUGIN=y" >> $config_host_mak
2265 for target
in $target_list; do
2270 # the toolchain is not complete with headers, only build softmmu tests
2274 test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" ||
continue
2275 qemu
="qemu-system-$arch"
2277 *-linux-user|
*-bsd-user)
2282 if probe_target_compiler
$target ||
test -n "$container_image"; then
2283 test -n "$container_image" && build_static
=y
2284 mkdir
-p "tests/tcg/$target"
2285 config_target_mak
=tests
/tcg
/$target/config-target.mak
2286 ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile"
2287 echo "# Automatically generated by configure - do not modify" > "$config_target_mak"
2288 echo "TARGET_NAME=$arch" >> "$config_target_mak"
2289 echo "TARGET=$target" >> "$config_target_mak"
2290 write_target_makefile
"build-tcg-tests-$target" >> "$config_target_mak"
2291 echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
2292 echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
2294 # will GDB work with these binaries?
2295 if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
2296 echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak"
2299 echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
2300 tcg_tests_targets
="$tcg_tests_targets $target"
2304 if test "$tcg" = "enabled"; then
2305 echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
2309 if test "$skip_meson" = no
; then
2310 cross
="config-meson.cross.new"
2312 test $# = 0 && return
2313 echo "'$(echo $* | sed "s
/ /','/g
")'"
2316 echo "# Automatically generated by configure - do not modify" > $cross
2317 echo "[properties]" >> $cross
2319 # unroll any custom device configs
2320 for a
in $device_archs; do
2321 eval "c=\$devices_${a}"
2322 echo "${a}-softmmu = '$c'" >> $cross
2325 echo "[built-in options]" >> $cross
2326 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
2327 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
2328 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
2329 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
2330 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
2331 echo "[binaries]" >> $cross
2332 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
2333 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
2334 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
2335 echo "ar = [$(meson_quote $ar)]" >> $cross
2336 echo "nm = [$(meson_quote $nm)]" >> $cross
2337 echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
2338 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
2339 if has
$sdl2_config; then
2340 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
2342 echo "strip = [$(meson_quote $strip)]" >> $cross
2343 echo "widl = [$(meson_quote $widl)]" >> $cross
2344 echo "windres = [$(meson_quote $windres)]" >> $cross
2345 echo "windmc = [$(meson_quote $windmc)]" >> $cross
2346 if test "$cross_compile" = "yes"; then
2347 cross_arg
="--cross-file config-meson.cross"
2348 echo "[host_machine]" >> $cross
2349 echo "system = '$targetos'" >> $cross
2352 echo "cpu_family = 'x86'" >> $cross
2355 echo "cpu_family = '$cpu'" >> $cross
2358 echo "cpu = '$cpu'" >> $cross
2359 if test "$bigendian" = "yes" ; then
2360 echo "endian = 'big'" >> $cross
2362 echo "endian = 'little'" >> $cross
2365 cross_arg
="--native-file config-meson.cross"
2367 mv $cross config-meson.cross
2369 rm -rf meson-private meson-info meson-logs
2371 # Prevent meson from automatically downloading wrapped subprojects when missing.
2372 # You can use 'meson subprojects download' before running configure.
2373 meson_option_add
"--wrap-mode=nodownload"
2376 test "$bindir" != "bin" && meson_option_add
"-Dbindir=$bindir"
2377 test "$default_feature" = no
&& meson_option_add
-Dauto_features=disabled
2378 test "$static" = yes && meson_option_add
-Dprefer_static=true
2379 test "$pie" = no
&& meson_option_add
-Db_pie=false
2380 test "$werror" = yes && meson_option_add
-Dwerror=true
2383 test "$cfi" != false
&& meson_option_add
"-Dcfi=$cfi"
2384 test "$docs" != auto
&& meson_option_add
"-Ddocs=$docs"
2385 test "$fdt" != auto
&& meson_option_add
"-Dfdt=$fdt"
2386 test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add
"-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
2387 test "$qemu_suffix" != qemu
&& meson_option_add
"-Dqemu_suffix=$qemu_suffix"
2388 test "$smbd" != '' && meson_option_add
"-Dsmbd=$smbd"
2389 test "$tcg" != enabled
&& meson_option_add
"-Dtcg=$tcg"
2390 test "$vfio_user_server" != auto
&& meson_option_add
"-Dvfio_user_server=$vfio_user_server"
2392 NINJA
=$ninja $meson setup
--prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path"
2394 eval run_meson
$meson_options
2395 if test "$?" -ne 0 ; then
2396 error_exit
"meson setup failed"
2400 # Save the configure command line for later reuse.
2401 cat <<EOD >config.status
2403 # Generated by configure.
2404 # Run this file to recreate the current configuration.
2405 # Compiler output produced by configure, useful for debugging
2406 # configure, is in config.log if it exists.
2412 eval envval
=\$
$envname
2414 if test -n "$envval"
2416 echo "$envname='$envval'" >> config.status
2417 echo "export $envname" >> config.status
2419 echo "unset $envname" >> config.status
2423 # Preserve various env variables that influence what
2424 # features/build target configure will detect
2430 preserve_env CXXFLAGS
2432 preserve_env LDFLAGS
2433 preserve_env LD_LIBRARY_PATH
2436 preserve_env OBJCFLAGS
2437 preserve_env OBJCOPY
2439 preserve_env PKG_CONFIG
2440 preserve_env PKG_CONFIG_LIBDIR
2441 preserve_env PKG_CONFIG_PATH
2443 preserve_env QEMU_GA_MANUFACTURER
2444 preserve_env QEMU_GA_DISTRO
2445 preserve_env QEMU_GA_VERSION
2446 preserve_env SDL2_CONFIG
2450 preserve_env WINDRES
2453 printf "exec" >>config.status
2454 for i
in "$0" "$@"; do
2455 test "$i" = --skip-meson ||
printf " %s" "$(quote_sh "$i")" >>config.status
2457 echo ' "$@"' >>config.status
2458 chmod +x config.status