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"
231 gdb_bin
=$
(command -v "gdb-multiarch" ||
command -v "gdb")
234 if test -e "$source_path/.git"
236 git_submodules_action
="update"
238 git_submodules_action
="ignore"
241 git_submodules
="ui/keycodemapdb"
244 # Don't accept a target_list environment variable.
246 unset target_list_exclude
248 # Default value for a variable defining feature "foo".
249 # * foo="no" feature will only be used if --enable-foo arg is given
250 # * foo="" feature will be searched for, and if found, will be used
251 # unless --disable-foo is given
252 # * foo="yes" this value will only be set by --enable-foo flag.
253 # feature will searched for,
254 # if not found, configure exits with error
256 # Always add --enable-foo and --disable-foo command line args.
257 # Distributions want to ensure that several features are compiled in, and it
258 # is impossible without a --enable-foo that exits if a feature is not found.
261 # parse CC options second
263 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
265 --without-default-features)
286 plugins
="$default_feature"
290 vfio_user_server
="disabled"
292 # The following Meson options are handled manually (still they
293 # are included in the automatically generated help message)
295 # 1. Track which submodules are needed
298 # 2. Automatically enable/disable other options
302 # parse CC options second
304 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
306 --cross-prefix=*) cross_prefix
="$optarg"
311 --cxx=*) CXX
="$optarg"
313 --objcc=*) objcc
="$optarg"
315 --cpu=*) cpu
="$optarg"
318 EXTRA_CFLAGS
="$EXTRA_CFLAGS $optarg"
319 EXTRA_CXXFLAGS
="$EXTRA_CXXFLAGS $optarg"
320 EXTRA_OBJCFLAGS
="$EXTRA_OBJCFLAGS $optarg"
322 --extra-cxxflags=*) EXTRA_CXXFLAGS
="$EXTRA_CXXFLAGS $optarg"
324 --extra-objcflags=*) EXTRA_OBJCFLAGS
="$EXTRA_OBJCFLAGS $optarg"
326 --extra-ldflags=*) EXTRA_LDFLAGS
="$EXTRA_LDFLAGS $optarg"
328 --cross-cc-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --cross-cc-FOO option"
330 --cross-cc-cflags-*) cc_arch
=${opt#--cross-cc-cflags-}; cc_arch
=${cc_arch%%=*}
331 eval "cross_cc_cflags_${cc_arch}=\$optarg"
333 --cross-cc-*) cc_arch
=${opt#--cross-cc-}; cc_arch
=${cc_arch%%=*}
334 eval "cross_cc_${cc_arch}=\$optarg"
336 --cross-prefix-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --cross-prefix-FOO option"
338 --cross-prefix-*) cc_arch
=${opt#--cross-prefix-}; cc_arch
=${cc_arch%%=*}
339 eval "cross_prefix_${cc_arch}=\$optarg"
344 # Preferred compiler:
346 # ${cross_prefix}gcc (if cross-prefix specified)
348 if test -z "${CC}${cross_prefix}"; then
351 cc
="${CC-${cross_prefix}gcc}"
354 if test -z "${CXX}${cross_prefix}"; then
357 cxx
="${CXX-${cross_prefix}g++}"
360 # Preferred ObjC compiler:
361 # $objcc (if set, i.e. via --objcc option)
362 # ${cross_prefix}clang (if cross-prefix specified)
363 # clang (if available)
365 if test -z "${objcc}${cross_prefix}"; then
372 objcc
="${objcc-${cross_prefix}clang}"
375 ar="${AR-${cross_prefix}ar}"
376 as
="${AS-${cross_prefix}as}"
378 objcopy
="${OBJCOPY-${cross_prefix}objcopy}"
379 ld
="${LD-${cross_prefix}ld}"
380 ranlib
="${RANLIB-${cross_prefix}ranlib}"
381 nm
="${NM-${cross_prefix}nm}"
383 strip
="${STRIP-${cross_prefix}strip}"
384 widl
="${WIDL-${cross_prefix}widl}"
385 windres
="${WINDRES-${cross_prefix}windres}"
386 windmc
="${WINDMC-${cross_prefix}windmc}"
387 pkg_config
="${PKG_CONFIG-${cross_prefix}pkg-config}"
388 sdl2_config
="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
390 # default flags for all hosts
391 # We use -fwrapv to tell the compiler that we require a C dialect where
392 # left shift of signed integers is well defined and has the expected
393 # 2s-complement style results. (Both clang and gcc agree that it
394 # provides these semantics.)
395 QEMU_CFLAGS
="-fno-strict-aliasing -fno-common -fwrapv"
396 QEMU_CFLAGS
="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
400 # Flags that are needed during configure but later taken care of by Meson
401 CONFIGURE_CFLAGS
="-std=gnu11 -Wall"
408 #error $1 not defined
410 int main(void) { return 0; }
417 int main(void) { return 0; }
421 if check_define __linux__
; then
423 elif check_define _WIN32
; then
425 elif check_define __OpenBSD__
; then
427 elif check_define __sun__
; then
429 elif check_define __HAIKU__
; then
431 elif check_define __FreeBSD__
; then
433 elif check_define __FreeBSD_kernel__
&& check_define __GLIBC__
; then
434 targetos
=gnu
/kfreebsd
435 elif check_define __DragonFly__
; then
437 elif check_define __NetBSD__
; then
439 elif check_define __APPLE__
; then
442 # This is a fatal error, but don't report it yet, because we
443 # might be going to just print the --help text, or it might
444 # be the result of a missing compiler.
466 # needed for kinfo_getvmmap(3) in libutil.h
483 # Disable attempts to use ObjectiveC features in os/object.h since they
484 # won't work when we're compiling with gcc as a C compiler.
485 QEMU_CFLAGS
="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
490 # needed for CMSG_ macros in sys/socket.h
491 QEMU_CFLAGS
="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
492 # needed for TIOCWIN* defines in termios.h
493 QEMU_CFLAGS
="-D__EXTENSIONS__ $QEMU_CFLAGS"
497 QEMU_CFLAGS
="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
504 if test ! -z "$cpu" ; then
505 # command line argument
507 elif check_define __i386__
; then
509 elif check_define __x86_64__
; then
510 if check_define __ILP32__
; then
515 elif check_define __sparc__
; then
516 if check_define __arch64__
; then
521 elif check_define _ARCH_PPC
; then
522 if check_define _ARCH_PPC64
; then
523 if check_define _LITTLE_ENDIAN
; then
531 elif check_define __mips__
; then
533 elif check_define __s390__
; then
534 if check_define __s390x__
; then
539 elif check_define __riscv
; then
541 elif check_define __arm__
; then
543 elif check_define __aarch64__
; then
545 elif check_define __loongarch64
; then
548 # Using uname is really broken, but it is just a fallback for architectures
549 # that are going to use TCI anyway
551 echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
554 # Normalise host CPU name and set multilib cflags. The canonicalization
555 # isn't really necessary, because the architectures that we check for
556 # should not hit the 'uname -m' case, but better safe than sorry.
557 # Note that this case should only have supported host CPUs, not guests.
567 CPU_CFLAGS
="-mx32" ;;
570 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
571 # If we truly care, we should simply detect this case at
572 # runtime and generate the fallback to serial emulation.
573 CPU_CFLAGS
="-m64 -mcx16" ;;
581 CPU_CFLAGS
="-m64 -mbig-endian" ;;
584 CPU_CFLAGS
="-m64 -mlittle-endian" ;;
593 CPU_CFLAGS
="-m32 -mv8plus -mcpu=ultrasparc" ;;
595 CPU_CFLAGS
="-m64 -mcpu=ultrasparc" ;;
598 : ${make=${MAKE-make}}
602 # We require python >= 3.7.
603 # NB: a True python conditional creates a non-zero return code (Failure)
604 "$1" -c 'import sys; sys.exit(sys.version_info < (3,7))'
610 if test -z "${PYTHON}"; then
611 # A bare 'python' is traditionally python 2.x, but some distros
612 # have it as python 3.x, so check in both places.
613 for binary
in python3 python python3.11 python3.10 python3.9 python3.8 python3.7
; do
614 if has
"$binary"; then
615 python
=$
(command -v "$binary")
616 if check_py_version
"$python"; then
626 # Same as above, but only check the environment variable.
627 has
"${PYTHON}" || error_exit
"The PYTHON environment variable does not point to an executable"
628 python
=$
(command -v "$PYTHON")
629 if check_py_version
"$python"; then
633 first_python
=$first_python
637 # Check for ancillary tools used in testing
639 for binary
in genisoimage mkisofs
643 genisoimage
=$
(command -v "$binary")
648 if test "$mingw32" = "yes" ; then
650 # MinGW needs -mthreads for TLS and macro _MT.
651 CONFIGURE_CFLAGS
="-mthreads $CONFIGURE_CFLAGS"
659 meson_option_build_array
() {
661 (if test "$targetos" = windows
; then
668 # backslash escape any '\' and '"' characters
669 printf "%s" "$e" |
sed -e 's/\([\"]\)/\\\1/g'
675 .
"$source_path/scripts/meson-buildoptions.sh"
679 meson_options
="$meson_options $(quote_sh "$1")"
681 meson_option_parse
() {
682 meson_options
="$meson_options $(_meson_option_parse "$@
")"
683 if test $?
-eq 1; then
684 echo "ERROR: unknown option $1"
685 echo "Try '$0 --help' for more information"
691 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
693 --help|
-h) show_help
=yes
695 --version|
-V) exec cat "$source_path/VERSION"
697 --prefix=*) prefix
="$optarg"
703 --host-cc=*) host_cc
="$optarg"
709 --make=*) make="$optarg"
713 --python=*) python
="$optarg"
715 --skip-meson) skip_meson
=yes
717 --ninja=*) ninja
="$optarg"
719 --smbd=*) smbd
="$optarg"
733 --enable-debug-info) meson_option_add
-Ddebug=true
735 --disable-debug-info) meson_option_add
-Ddebug=false
737 --enable-docs) docs
=enabled
739 --disable-docs) docs
=disabled
743 --target-list=*) target_list
="$optarg"
744 if test "$target_list_exclude"; then
745 error_exit
"Can't mix --target-list with --target-list-exclude"
748 --target-list-exclude=*) target_list_exclude
="$optarg"
749 if test "$target_list"; then
750 error_exit
"Can't mix --target-list-exclude with --target-list"
753 --with-default-devices) meson_option_add
-Ddefault_devices=true
755 --without-default-devices) meson_option_add
-Ddefault_devices=false
757 --with-devices-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --with-devices-FOO option"
759 --with-devices-*) device_arch
=${opt#--with-devices-};
760 device_arch
=${device_arch%%=*}
761 cf
=$source_path/configs
/devices
/$device_arch-softmmu/$optarg.mak
762 if test -f "$cf"; then
763 device_archs
="$device_archs $device_arch"
764 eval "devices_${device_arch}=\$optarg"
766 error_exit
"File $cf does not exist"
769 --without-default-features) # processed above
771 --static) static
="yes"
773 --bindir=*) bindir
="$optarg"
775 --with-suffix=*) qemu_suffix
="$optarg"
778 --disable-dependency-tracking|\
779 --sbindir=*|
--sharedstatedir=*|\
780 --oldincludedir=*|
--datarootdir=*|
--infodir=*|\
781 --htmldir=*|
--dvidir=*|
--pdfdir=*|
--psdir=*)
782 # These switches are silently ignored, for compatibility with
783 # autoconf-generated configure scripts. This allows QEMU's
784 # configure to be used by RPM and similar macros that set
785 # lots of directory switches by default.
787 --enable-debug-tcg) debug_tcg
="yes"
789 --disable-debug-tcg) debug_tcg
="no"
792 # Enable debugging options that aren't excessively noisy
794 meson_option_parse
--enable-debug-graph-lock ""
795 meson_option_parse
--enable-debug-mutex ""
796 meson_option_add
-Doptimization=0
798 --disable-tcg) tcg
="disabled"
801 --enable-tcg) tcg
="enabled"
803 --disable-system) softmmu
="no"
805 --enable-system) softmmu
="yes"
812 --disable-linux-user) linux_user
="no"
814 --enable-linux-user) linux_user
="yes"
816 --disable-bsd-user) bsd_user
="no"
818 --enable-bsd-user) bsd_user
="yes"
820 --enable-pie) pie
="yes"
822 --disable-pie) pie
="no"
824 --enable-werror) werror
="yes"
826 --disable-werror) werror
="no"
828 --enable-stack-protector) stack_protector
="yes"
830 --disable-stack-protector) stack_protector
="no"
834 meson_option_add
-Db_lto=true
836 --disable-cfi) cfi
="false"
838 --disable-fdt) fdt
="disabled"
840 --enable-fdt) fdt
="enabled"
842 --enable-fdt=git
) fdt
="internal"
844 --enable-fdt=*) fdt
="$optarg"
846 --with-coroutine=*) coroutine
="$optarg"
848 --with-git=*) git
="$optarg"
850 --with-git-submodules=*)
851 git_submodules_action
="$optarg"
853 --disable-pypi) pypi
="disabled"
855 --enable-pypi) pypi
="enabled"
857 --enable-plugins) if test "$mingw32" = "yes"; then
858 error_exit
"TCG plugins not currently supported on Windows platforms"
863 --disable-plugins) plugins
="no"
865 --enable-containers) use_containers
="yes"
867 --disable-containers) use_containers
="no"
869 --gdb=*) gdb_bin
="$optarg"
871 --enable-vfio-user-server) vfio_user_server
="enabled"
873 --disable-vfio-user-server) vfio_user_server
="disabled"
875 # everything else has the same name in configure and meson
876 --*) meson_option_parse
"$opt" "$optarg"
881 # test for any invalid configuration combinations
882 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
883 error_exit
"Can't enable plugins on non-TCG builds"
886 case $git_submodules_action in
888 if test ! -e "$source_path/.git"; then
889 echo "ERROR: cannot $git_submodules_action git submodules without .git"
894 if ! test -f "$source_path/ui/keycodemapdb/README"
897 echo "ERROR: missing GIT submodules"
899 if test -e "$source_path/.git"; then
900 echo "--with-git-submodules=ignore specified but submodules were not"
901 echo "checked out. Please initialize and update submodules."
903 echo "This is not a GIT checkout but module content appears to"
904 echo "be missing. Do not use 'git archive' or GitHub download links"
905 echo "to acquire QEMU source archives. Non-GIT builds are only"
906 echo "supported with source archives linked from:"
908 echo " https://www.qemu.org/download/#source"
910 echo "Developers working with GIT can use scripts/archive-source.sh"
911 echo "if they need to create valid source archives."
918 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
923 default_target_list
=""
926 if [ "$linux_user" != no
]; then
927 if [ "$targetos" = linux
] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then
929 elif [ "$linux_user" = yes ]; then
930 error_exit
"linux-user not supported on this architecture"
933 if [ "$bsd_user" != no
]; then
934 if [ "$bsd_user" = "" ]; then
935 test $targetos = freebsd
&& bsd_user
=yes
937 if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
938 error_exit
"bsd-user not supported on this host OS"
941 if [ "$softmmu" = "yes" ]; then
942 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
944 if [ "$linux_user" = "yes" ]; then
945 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
947 if [ "$bsd_user" = "yes" ]; then
948 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
951 for config
in $mak_wilds; do
952 target
="$(basename "$config" .mak)"
953 if echo "$target_list_exclude" |
grep -vq "$target"; then
954 default_target_list
="${default_target_list} $target"
958 if test x
"$show_help" = x
"yes" ; then
961 Usage: configure [options]
962 Options: [defaults in brackets after descriptions]
965 --help print this message
966 --prefix=PREFIX install in PREFIX [$prefix]
967 --target-list=LIST set target list (default: build all)
968 $(echo Available targets: $default_target_list | \
969 fold -s -w 53 | sed -e 's/^/ /')
970 --target-list-exclude=LIST exclude a set of targets from the default target-list
972 Advanced options (experts only):
973 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
974 --cc=CC use C compiler CC [$cc]
975 --host-cc=CC use C compiler CC [$host_cc] for code run at
977 --cxx=CXX use C++ compiler CXX [$cxx]
978 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
979 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
980 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
981 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
982 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
983 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
984 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
985 --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
986 --make=MAKE use specified make [$make]
987 --python=PYTHON use specified python [$python]
988 --ninja=NINJA use specified ninja [$ninja]
989 --smbd=SMBD use specified smbd [$smbd]
990 --with-git=GIT use specified git [$git]
991 --with-git-submodules=update update git submodules (default if .git dir exists)
992 --with-git-submodules=validate fail if git submodules are not up to date
993 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
994 --static enable static build [$static]
995 --bindir=PATH install binaries in PATH
996 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
997 --without-default-features default all --enable-* options to "disabled"
998 --without-default-devices do not include any device that is not needed to
999 start the emulator (only use if you are including
1000 desired devices in configs/devices/)
1001 --with-devices-ARCH=NAME override default configs/devices
1002 --enable-debug enable common debug build options
1003 --disable-werror disable compilation abort on warning
1004 --disable-stack-protector disable compiler-provided stack protection
1005 --cpu=CPU Build for host CPU [$cpu]
1006 --with-coroutine=BACKEND coroutine backend. Supported options:
1007 ucontext, sigaltstack, windows
1009 enable plugins via shared library loading
1010 --disable-containers don't use containers for cross-building
1011 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1015 system all system emulation targets
1016 user supported user emulation targets
1017 linux-user all linux usermode emulation targets
1018 bsd-user all BSD usermode emulation targets
1019 pie Position Independent Executables
1020 debug-tcg TCG debugging (default is disabled)
1021 debug-info debugging information
1023 NOTE: The object files are built at the place where configure is launched
1028 # Remove old dependency files to make sure that they get properly regenerated
1029 rm -f .
/*/config-devices.mak.d
1031 if test -z "$python"
1033 # If first_python is set, there was a binary somewhere even though
1034 # it was not suitable. Use it for the error message.
1035 if test -n "$first_python"; then
1036 error_exit
"Cannot use '$first_python', Python >= 3.7 is required." \
1037 "Use --python=/path/to/python to specify a supported Python."
1039 error_exit
"Python not found. Use --python=/path/to/python"
1045 error_exit
"GNU make ($make) not found"
1048 if ! check_py_version
"$python"; then
1049 error_exit
"Cannot use '$python', Python >= 3.7 is required." \
1050 "Use --python=/path/to/python to specify a supported Python." \
1052 " openSUSE Leap 15.3+: zypper install python39" \
1053 " CentOS 8: dnf install python38"
1057 python
="$(command -v "$python")"
1059 # Create a Python virtual environment using our configured python.
1060 # The stdout of this script will be the location of a symlink that
1061 # points to the configured Python.
1062 # Entry point scripts for pip, meson, and sphinx are generated if those
1063 # packages are present.
1065 # Defaults assumed for now:
1066 # - venv is cleared if it exists already;
1067 # - venv is allowed to use system packages;
1068 # - all setup can be performed offline;
1069 # - missing packages may be fetched from PyPI,
1070 # unless --disable-pypi is passed.
1071 # - pip is not installed into the venv when possible,
1072 # but ensurepip is called as a fallback when necessary.
1074 echo "python determined to be '$python'"
1075 echo "python version: $($python --version)"
1077 python
="$($python -B "${source_path}/python
/scripts
/mkvenv.py
" create pyvenv)"
1078 if test "$?" -ne 0 ; then
1079 error_exit
"python venv creation failed"
1082 # Suppress writing compiled files
1084 mkvenv
="$python ${source_path}/python/scripts/mkvenv.py"
1087 if test "$pypi" = "enabled" ; then
1088 mkvenv_flags
="--online"
1091 if ! $mkvenv ensure \
1093 --dir "${source_path}/python/wheels" \
1094 --diagnose "meson" \
1100 # At this point, we expect Meson to be installed and available.
1101 # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
1102 # We ignore PATH completely here: we want to use the venv's Meson
1105 meson
="$(cd pyvenv/bin; pwd)/meson"
1107 # Conditionally ensure Sphinx is installed.
1110 if test "$pypi" = "enabled" -a "$docs" = "enabled" ; then
1111 mkvenv_flags
="--online"
1114 if test "$docs" != "disabled" ; then
1115 if ! $mkvenv ensure \
1117 --diagnose "sphinx-build" \
1118 "sphinx>=1.6.0" "sphinx-rtd-theme>=0.5.0";
1120 if test "$docs" = "enabled" ; then
1123 echo "Sphinx not found/usable, disabling docs."
1132 if test -z "$ninja"; then
1133 for c
in ninja ninja-build samu
; do
1135 ninja
=$
(command -v "$c")
1139 if test -z "$ninja"; then
1140 error_exit
"Cannot find Ninja"
1144 # Check that the C compiler works. Doing this here before testing
1145 # the host CPU ensures that we had a valid CC to autodetect the
1146 # $cpu var (and we should bail right here if that's not the case).
1147 # It also allows the help message to be printed without a CC.
1149 if compile_object
; then
1150 : C compiler works ok
1152 error_exit
"\"$cc\" either does not exist or does not work"
1154 if ! compile_prog
; then
1155 error_exit
"\"$cc\" cannot build an executable (is your linker broken?)"
1158 # Consult white-list to determine whether to enable werror
1159 # by default. Only enable by default for git builds
1160 if test -z "$werror" ; then
1161 if test "$git_submodules_action" != "ignore" && \
1162 { test "$linux" = "yes" ||
test "$mingw32" = "yes"; }; then
1169 if test "$targetos" = "bogus"; then
1170 # Now that we know that we're not printing the help and that
1171 # the compiler works (so the results of the check_defines we used
1172 # to identify the OS are reliable), if we didn't recognize the
1173 # host OS we should stop now.
1174 error_exit
"Unrecognized host OS (uname -s reports '$(uname -s)')"
1177 # Check whether the compiler matches our minimum requirements:
1179 #if defined(__clang_major__) && defined(__clang_minor__)
1180 # ifdef __apple_build_version__
1181 # if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0)
1182 # error You need at least XCode Clang v12.0 to compile QEMU
1185 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1186 # error You need at least Clang v10.0 to compile QEMU
1189 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1190 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1191 # error You need at least GCC v7.4.0 to compile QEMU
1194 # error You either need GCC or Clang to compiler QEMU
1196 int main (void) { return 0; }
1198 if ! compile_prog
"" "" ; then
1199 error_exit
"You need at least GCC v7.4 or Clang v10.0 (or XCode Clang v12.0)"
1202 # Accumulate -Wfoo and -Wno-bar separately.
1203 # We will list all of the enable flags first, and the disable flags second.
1204 # Note that we do not add -Werror, because that would enable it for all
1205 # configure tests. If a configure test failed due to -Werror this would
1206 # just silently disable some features, so it's too error prone.
1209 add_to warn_flags
-Wundef
1210 add_to warn_flags
-Wwrite-strings
1211 add_to warn_flags
-Wmissing-prototypes
1212 add_to warn_flags
-Wstrict-prototypes
1213 add_to warn_flags
-Wredundant-decls
1214 add_to warn_flags
-Wold-style-declaration
1215 add_to warn_flags
-Wold-style-definition
1216 add_to warn_flags
-Wtype-limits
1217 add_to warn_flags
-Wformat-security
1218 add_to warn_flags
-Wformat-y2k
1219 add_to warn_flags
-Winit-self
1220 add_to warn_flags
-Wignored-qualifiers
1221 add_to warn_flags
-Wempty-body
1222 add_to warn_flags
-Wnested-externs
1223 add_to warn_flags
-Wendif-labels
1224 add_to warn_flags
-Wexpansion-to-defined
1225 add_to warn_flags
-Wimplicit-fallthrough=2
1226 add_to warn_flags
-Wmissing-format-attribute
1228 if test "$targetos" != "darwin"; then
1229 add_to warn_flags
-Wthread-safety
1233 add_to nowarn_flags
-Wno-initializer-overrides
1234 add_to nowarn_flags
-Wno-missing-include-dirs
1235 add_to nowarn_flags
-Wno-shift-negative-value
1236 add_to nowarn_flags
-Wno-string-plus-int
1237 add_to nowarn_flags
-Wno-typedef-redefinition
1238 add_to nowarn_flags
-Wno-tautological-type-limit-compare
1239 add_to nowarn_flags
-Wno-psabi
1240 add_to nowarn_flags
-Wno-gnu-variable-sized-type-not-at-end
1242 gcc_flags
="$warn_flags $nowarn_flags"
1244 cc_has_warning_flag
() {
1247 # Use the positive sense of the flag when testing for -Wno-wombat
1248 # support (gcc will happily accept the -Wno- form of unknown
1250 optflag
="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1251 compile_prog
"-Werror $optflag" ""
1254 objcc_has_warning_flag
() {
1256 int main(void) { return 0; }
1259 # Use the positive sense of the flag when testing for -Wno-wombat
1260 # support (gcc will happily accept the -Wno- form of unknown
1262 optflag
="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1263 do_objc
-Werror $optflag \
1264 $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
1265 -o $TMPE $TMPM $QEMU_LDFLAGS
1268 for flag
in $gcc_flags; do
1269 if cc_has_warning_flag
$flag ; then
1270 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1272 if objcc_has_warning_flag
$flag ; then
1273 QEMU_OBJCFLAGS
="$QEMU_OBJCFLAGS $flag"
1277 if test "$stack_protector" != "no"; then
1279 int main(int argc, char *argv[])
1281 char arr[64], *p = arr, *c = argv[argc - 1];
1288 gcc_flags
="-fstack-protector-strong -fstack-protector-all"
1290 for flag
in $gcc_flags; do
1291 # We need to check both a compile and a link, since some compiler
1292 # setups fail only on a .c->.o compile and some only at link time
1293 if compile_object
"-Werror $flag" &&
1294 compile_prog
"-Werror $flag" ""; then
1295 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1296 QEMU_LDFLAGS
="$QEMU_LDFLAGS $flag"
1301 if test "$stack_protector" = yes; then
1302 if test $sp_on = 0; then
1303 error_exit
"Stack protector not supported"
1308 if test "$static" = "yes" ; then
1309 if test "$plugins" = "yes"; then
1310 error_exit
"static and plugins are mutually incompatible"
1315 test "$plugins" = "" && plugins
=yes
1320 # define THREAD __thread
1324 static THREAD int tls_var;
1325 int main(void) { return tls_var; }
1328 # Meson currently only handles pie as a boolean for now so if we have
1329 # explicitly disabled PIE we need to extend our cflags because it wont.
1330 if test "$static" = "yes"; then
1331 if test "$pie" != "no" && compile_prog
"-Werror -fPIE -DPIE" "-static-pie"; then
1332 CONFIGURE_CFLAGS
="-fPIE -DPIE $CONFIGURE_CFLAGS"
1334 elif test "$pie" = "yes"; then
1335 error_exit
"-static-pie not available due to missing toolchain support"
1338 QEMU_CFLAGS
="-fno-pie $QEMU_CFLAGS"
1340 elif test "$pie" = "no"; then
1341 if compile_prog
"-Werror -fno-pie" "-no-pie"; then
1342 CONFIGURE_CFLAGS
="-fno-pie $CONFIGURE_CFLAGS"
1343 CONFIGURE_LDFLAGS
="-no-pie $CONFIGURE_LDFLAGS"
1344 QEMU_CFLAGS
="-fno-pie -no-pie $QEMU_CFLAGS"
1346 elif compile_prog
"-Werror -fPIE -DPIE" "-pie"; then
1347 CONFIGURE_CFLAGS
="-fPIE -DPIE $CONFIGURE_CFLAGS"
1348 CONFIGURE_LDFLAGS
="-pie $CONFIGURE_LDFLAGS"
1350 elif test "$pie" = "yes"; then
1351 error_exit
"PIE not available due to missing toolchain support"
1353 echo "Disabling PIE due to missing toolchain support"
1357 ##########################################
1358 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1359 # use i686 as default anyway, but for those that don't, an explicit
1360 # specification is necessary
1362 if test "$cpu" = "i386"; then
1364 static int sfaa(int *ptr)
1366 return __sync_fetch_and_and(ptr, 0);
1372 val = __sync_val_compare_and_swap(&val, 0, 1);
1377 if ! compile_prog
"" "" ; then
1378 QEMU_CFLAGS
="-march=i486 $QEMU_CFLAGS"
1382 if test -z "${target_list+xxx}" ; then
1384 for target
in $default_target_list; do
1385 target_list
="$target_list $target"
1387 target_list
="${target_list# }"
1390 target_list
=$
(echo "$target_list" |
sed -e 's/,/ /g')
1391 for target
in $target_list; do
1392 # Check that we recognised the target name; this allows a more
1393 # friendly error message than if we let it fall through.
1394 case " $default_target_list " in
1398 error_exit
"Unknown target name '$target'"
1404 # see if system emulation was really requested
1405 case " $target_list " in
1406 *"-softmmu "*) softmmu
=yes
1412 if test "$tcg" = "auto"; then
1413 if test -z "$target_list"; then
1420 if test "$tcg" = "enabled"; then
1421 git_submodules
="$git_submodules tests/fp/berkeley-testfloat-3"
1422 git_submodules
="$git_submodules tests/fp/berkeley-softfloat-3"
1425 ##########################################
1426 # big/little endian test
1428 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1431 int main(void) { return 0; }
1434 if ! compile_prog
; then
1438 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1441 int main(void) { return 0; }
1444 if ! compile_prog
; then
1447 echo big
/little
test failed
1452 ##########################################
1456 auto | enabled | internal
)
1457 # Simpler to always update submodule, even if not needed.
1458 git_submodules
="${git_submodules} dtc"
1462 ##########################################
1463 # check and set a backend for coroutine
1465 # We prefer ucontext, but it's not always possible. The fallback
1466 # is sigcontext. On Windows the only valid backend is the Windows
1470 if test "$darwin" != "yes"; then
1472 #include <ucontext.h>
1473 #ifdef __stub_makecontext
1474 #error Ignoring glibc stub makecontext which will always fail
1476 int main(void) { makecontext(0, 0, 0); return 0; }
1478 if compile_prog
"" "" ; then
1483 if test "$coroutine" = ""; then
1484 if test "$mingw32" = "yes"; then
1486 elif test "$ucontext_works" = "yes"; then
1489 coroutine
=sigaltstack
1494 if test "$mingw32" != "yes"; then
1495 error_exit
"'windows' coroutine backend only valid for Windows"
1497 # Unfortunately the user visible backend name doesn't match the
1498 # coroutine-*.c filename for this case, so we have to adjust it here.
1502 if test "$ucontext_works" != "yes"; then
1503 error_exit
"'ucontext' backend requested but makecontext not available"
1507 if test "$mingw32" = "yes"; then
1508 error_exit
"only the 'windows' coroutine backend is valid for Windows"
1512 error_exit
"unknown coroutine backend $coroutine"
1517 ########################################
1518 # check if ccache is interfering with
1519 # semantic analysis of macros
1524 static const int Z = 1;
1525 #define fn() ({ Z; })
1526 #define TAUT(X) ((X) == Z)
1527 #define PAREN(X, Y) (X == Y)
1535 if (PAREN(x, y)) return 0;
1536 if (TAUT(Z)) return 0;
1541 if ! compile_object
"-Werror"; then
1545 ##########################################
1546 # functions to probe cross compilers
1550 if test $use_containers = "yes" && (has
"docker" || has
"podman"); then
1551 case $
($python "$source_path"/tests
/docker
/docker.py probe
) in
1552 *docker
) container
=docker
;;
1553 podman
) container
=podman
;;
1556 if test "$container" != "no"; then
1557 docker_py
="$python $source_path/tests/docker/docker.py --engine $container"
1558 runc
=$
($python "$source_path"/tests
/docker
/docker.py probe
)
1562 # cross compilers defaults, can be overridden with --cross-cc-ARCH
1563 : ${cross_prefix_aarch64="aarch64-linux-gnu-"}
1564 : ${cross_prefix_aarch64_be="$cross_prefix_aarch64"}
1565 : ${cross_prefix_alpha="alpha-linux-gnu-"}
1566 : ${cross_prefix_arm="arm-linux-gnueabihf-"}
1567 : ${cross_prefix_armeb="$cross_prefix_arm"}
1568 : ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"}
1569 : ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"}
1570 : ${cross_prefix_hppa="hppa-linux-gnu-"}
1571 : ${cross_prefix_i386="i686-linux-gnu-"}
1572 : ${cross_prefix_m68k="m68k-linux-gnu-"}
1573 : ${cross_prefix_microblaze="microblaze-linux-musl-"}
1574 : ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"}
1575 : ${cross_prefix_mips64="mips64-linux-gnuabi64-"}
1576 : ${cross_prefix_mipsel="mipsel-linux-gnu-"}
1577 : ${cross_prefix_mips="mips-linux-gnu-"}
1578 : ${cross_prefix_nios2="nios2-linux-gnu-"}
1579 : ${cross_prefix_ppc="powerpc-linux-gnu-"}
1580 : ${cross_prefix_ppc64="powerpc64-linux-gnu-"}
1581 : ${cross_prefix_ppc64le="$cross_prefix_ppc64"}
1582 : ${cross_prefix_riscv64="riscv64-linux-gnu-"}
1583 : ${cross_prefix_s390x="s390x-linux-gnu-"}
1584 : ${cross_prefix_sh4="sh4-linux-gnu-"}
1585 : ${cross_prefix_sparc64="sparc64-linux-gnu-"}
1586 : ${cross_prefix_sparc="$cross_prefix_sparc64"}
1587 : ${cross_prefix_x86_64="x86_64-linux-gnu-"}
1589 : ${cross_cc_aarch64_be="$cross_cc_aarch64"}
1590 : ${cross_cc_cflags_aarch64_be="-mbig-endian"}
1591 : ${cross_cc_armeb="$cross_cc_arm"}
1592 : ${cross_cc_cflags_armeb="-mbig-endian"}
1593 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
1594 : ${cross_cc_cflags_hexagon="-mv67 -O2 -static"}
1595 : ${cross_cc_cflags_i386="-m32"}
1596 : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
1597 : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
1598 : ${cross_cc_ppc64le="$cross_cc_ppc64"}
1599 : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
1600 : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
1601 : ${cross_cc_sparc="$cross_cc_sparc64"}
1602 : ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
1603 : ${cross_cc_cflags_x86_64="-m64"}
1605 compute_target_variable
() {
1607 if eval test -n "\"\${cross_prefix_$1}\""; then
1608 if eval has
"\"\${cross_prefix_$1}\$3\""; then
1609 eval "$2=\"\${cross_prefix_$1}\$3\""
1616 case " $target_list " in
1617 *" $i "*) return 0;;
1624 # probe_target_compiler TARGET
1626 # Look for a compiler for the given target, either native or cross.
1627 # Set variables target_* if a compiler is found, and container_cross_*
1628 # if a Docker-based cross-compiler image is known for the target.
1629 # Set got_cross_cc to yes/no depending on whether a non-container-based
1630 # compiler was found.
1632 # If TARGET is a user-mode emulation target, also set build_static to
1633 # "y" if static linking is possible.
1635 probe_target_compiler
() {
1636 # reset all output variables
1645 container_cross_objcopy
=
1646 container_cross_ranlib
=
1647 container_cross_strip
=
1649 # We shall skip configuring the target compiler if the user didn't
1650 # bother enabling an appropriate guest. This avoids building
1651 # extraneous firmware images and tests.
1652 if test "${target_list#*$1}" = "$1"; then
1656 target_arch
=${1%%-*}
1657 case $target_arch in
1658 aarch64
) container_hosts
="x86_64 aarch64" ;;
1659 alpha
) container_hosts
=x86_64
;;
1660 arm
) container_hosts
="x86_64 aarch64" ;;
1661 cris
) container_hosts
=x86_64
;;
1662 hexagon
) container_hosts
=x86_64
;;
1663 hppa
) container_hosts
=x86_64
;;
1664 i386
) container_hosts
=x86_64
;;
1665 loongarch64
) container_hosts
=x86_64
;;
1666 m68k
) container_hosts
=x86_64
;;
1667 microblaze
) container_hosts
=x86_64
;;
1668 mips64el
) container_hosts
=x86_64
;;
1669 mips64
) container_hosts
=x86_64
;;
1670 mipsel
) container_hosts
=x86_64
;;
1671 mips
) container_hosts
=x86_64
;;
1672 nios2
) container_hosts
=x86_64
;;
1673 ppc
) container_hosts
=x86_64
;;
1674 ppc64|ppc64le
) container_hosts
=x86_64
;;
1675 riscv64
) container_hosts
=x86_64
;;
1676 s390x
) container_hosts
=x86_64
;;
1677 sh4
) container_hosts
=x86_64
;;
1678 sparc64
) container_hosts
=x86_64
;;
1679 tricore
) container_hosts
=x86_64
;;
1680 x86_64
) container_hosts
="aarch64 ppc64el x86_64" ;;
1681 xtensa
*) container_hosts
=x86_64
;;
1684 for host in $container_hosts; do
1685 test "$container" != no ||
continue
1686 test "$host" = "$cpu" ||
continue
1687 case $target_arch in
1689 # We don't have any bigendian build tools so we only use this for AArch64
1690 container_image
=debian-arm64-cross
1691 container_cross_prefix
=aarch64-linux-gnu-
1692 container_cross_cc
=${container_cross_prefix}gcc-10
1695 container_image
=debian-alpha-cross
1696 container_cross_prefix
=alpha-linux-gnu-
1699 # We don't have any bigendian build tools so we only use this for ARM
1700 container_image
=debian-armhf-cross
1701 container_cross_prefix
=arm-linux-gnueabihf-
1704 container_image
=fedora-cris-cross
1705 container_cross_prefix
=cris-linux-gnu-
1708 container_image
=debian-hexagon-cross
1709 container_cross_prefix
=hexagon-unknown-linux-musl-
1710 container_cross_cc
=${container_cross_prefix}clang
1713 container_image
=debian-hppa-cross
1714 container_cross_prefix
=hppa-linux-gnu-
1717 container_image
=fedora-i386-cross
1718 container_cross_prefix
=
1721 container_image
=debian-loongarch-cross
1722 container_cross_prefix
=loongarch64-unknown-linux-gnu-
1725 container_image
=debian-m68k-cross
1726 container_cross_prefix
=m68k-linux-gnu-
1729 container_image
=debian-microblaze-cross
1730 container_cross_prefix
=microblaze-linux-musl-
1733 container_image
=debian-mips64el-cross
1734 container_cross_prefix
=mips64el-linux-gnuabi64-
1737 container_image
=debian-mips64-cross
1738 container_cross_prefix
=mips64-linux-gnuabi64-
1741 container_image
=debian-mipsel-cross
1742 container_cross_prefix
=mipsel-linux-gnu-
1745 container_image
=debian-mips-cross
1746 container_cross_prefix
=mips-linux-gnu-
1749 container_image
=debian-nios2-cross
1750 container_cross_prefix
=nios2-linux-gnu-
1753 container_image
=debian-powerpc-test-cross
1754 container_cross_prefix
=powerpc-linux-gnu-
1755 container_cross_cc
=${container_cross_prefix}gcc-10
1758 container_image
=debian-powerpc-test-cross
1759 container_cross_prefix
=powerpc
${target_arch#ppc}-linux-gnu-
1760 container_cross_cc
=${container_cross_prefix}gcc-10
1763 container_image
=debian-riscv64-test-cross
1764 container_cross_prefix
=riscv64-linux-gnu-
1767 container_image
=debian-s390x-cross
1768 container_cross_prefix
=s390x-linux-gnu-
1771 container_image
=debian-sh4-cross
1772 container_cross_prefix
=sh4-linux-gnu-
1775 container_image
=debian-sparc64-cross
1776 container_cross_prefix
=sparc64-linux-gnu-
1779 container_image
=debian-tricore-cross
1780 container_cross_prefix
=tricore-
1781 container_cross_as
=tricore-as
1782 container_cross_ld
=tricore-ld
1786 container_image
=debian-amd64-cross
1787 container_cross_prefix
=x86_64-linux-gnu-
1790 container_hosts
=x86_64
1791 container_image
=debian-xtensa-cross
1793 # default to the dc232b cpu
1794 container_cross_prefix
=/opt
/2020.07/xtensa-dc232b-elf
/bin
/xtensa-dc232b-elf-
1797 : ${container_cross_cc:=${container_cross_prefix}gcc}
1798 : ${container_cross_ar:=${container_cross_prefix}ar}
1799 : ${container_cross_as:=${container_cross_prefix}as}
1800 : ${container_cross_ld:=${container_cross_prefix}ld}
1801 : ${container_cross_nm:=${container_cross_prefix}nm}
1802 : ${container_cross_objcopy:=${container_cross_prefix}objcopy}
1803 : ${container_cross_ranlib:=${container_cross_prefix}ranlib}
1804 : ${container_cross_strip:=${container_cross_prefix}strip}
1808 case "$target_arch:$cpu" in
1809 aarch64_be
:aarch64 | \
1816 try
='native cross' ;;
1818 eval "target_cflags=\${cross_cc_cflags_$target_arch}"
1819 for thistry
in $try; do
1828 target_objcopy
=$objcopy
1829 target_ranlib
=$ranlib
1834 if eval test -n "\"\${cross_cc_$target_arch}\""; then
1835 if eval has
"\"\${cross_cc_$target_arch}\""; then
1836 eval "target_cc=\"\${cross_cc_$target_arch}\""
1839 compute_target_variable
$target_arch target_cc gcc
1841 target_ccas
=$target_cc
1842 compute_target_variable
$target_arch target_ar
ar
1843 compute_target_variable
$target_arch target_as as
1844 compute_target_variable
$target_arch target_ld ld
1845 compute_target_variable
$target_arch target_nm nm
1846 compute_target_variable
$target_arch target_objcopy objcopy
1847 compute_target_variable
$target_arch target_ranlib ranlib
1848 compute_target_variable
$target_arch target_strip strip
1852 if test -n "$target_cc"; then
1853 case $target_arch in
1855 if $target_cc --version |
grep -qi "clang"; then
1860 elif test -n "$target_as" && test -n "$target_ld"; then
1861 # Special handling for assembler only targets
1879 if do_compiler
"$target_cc" $target_cflags -o $TMPO -c $TMPC &&
1880 do_compiler
"$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
1886 if do_compiler
"$target_cc" $target_cflags -o $TMPE $TMPC -static ; then
1891 if do_compiler
"$target_cc" $target_cflags -o $TMPE $TMPC ; then
1899 if test $got_cross_cc != yes; then
1911 test -n "$target_cc"
1914 write_target_makefile
() {
1915 echo "EXTRA_CFLAGS=$target_cflags"
1916 if test -z "$target_cc" && test -z "$target_as"; then
1917 test -z "$container_image" && error_exit
"Internal error: could not find cross compiler for $1?"
1918 echo "$1: docker-image-$container_image" >> Makefile.prereqs
1919 if test -n "$container_cross_cc"; then
1920 echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1921 echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1923 echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --"
1924 echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --"
1925 echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --"
1926 echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --"
1927 echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --"
1928 echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --"
1929 echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --"
1931 if test -n "$target_cc"; then
1932 echo "CC=$target_cc"
1933 echo "CCAS=$target_ccas"
1935 if test -n "$target_ar"; then
1936 echo "AR=$target_ar"
1938 if test -n "$target_as"; then
1939 echo "AS=$target_as"
1941 if test -n "$target_ld"; then
1942 echo "LD=$target_ld"
1944 if test -n "$target_nm"; then
1945 echo "NM=$target_nm"
1947 if test -n "$target_objcopy"; then
1948 echo "OBJCOPY=$target_objcopy"
1950 if test -n "$target_ranlib"; then
1951 echo "RANLIB=$target_ranlib"
1953 if test -n "$target_strip"; then
1954 echo "STRIP=$target_strip"
1959 ##########################################
1960 # check for vfio_user_server
1962 case "$vfio_user_server" in
1964 if test "$git_submodules_action" != "ignore"; then
1965 git_submodules
="${git_submodules} subprojects/libvfio-user"
1970 #######################################
1971 # cross-compiled firmware targets
1973 # Set up build tree symlinks that point back into the source tree
1974 # (these can be both files and directories).
1975 # Caution: avoid adding files or directories here using wildcards. This
1976 # will result in problems later if a new file matching the wildcard is
1977 # added to the source tree -- nothing will cause configure to be rerun
1978 # so the build tree will be missing the link back to the new file, and
1979 # tests might fail. Prefer to keep the relevant files in their own
1980 # directory and symlink the directory instead.
1982 LINKS
="$LINKS docs/config"
1983 LINKS
="$LINKS pc-bios/optionrom/Makefile"
1984 LINKS
="$LINKS pc-bios/s390-ccw/Makefile"
1985 LINKS
="$LINKS pc-bios/vof/Makefile"
1986 LINKS
="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
1987 LINKS
="$LINKS tests/avocado tests/data"
1988 LINKS
="$LINKS tests/qemu-iotests/check"
1989 LINKS
="$LINKS python"
1990 LINKS
="$LINKS contrib/plugins/Makefile "
1991 for f
in $LINKS ; do
1992 if [ -e "$source_path/$f" ]; then
1993 mkdir
-p "$(dirname ./"$f")"
1994 symlink
"$source_path/$f" "$f"
1998 echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
2000 # Mac OS X ships with a broken assembler
2002 if have_target i386-softmmu x86_64-softmmu
&& \
2003 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
2004 test "$targetos" != "haiku" && \
2005 probe_target_compiler i386-softmmu
; then
2006 roms
="pc-bios/optionrom"
2007 config_mak
=pc-bios
/optionrom
/config.mak
2008 echo "# Automatically generated by configure - do not modify" > $config_mak
2009 echo "TOPSRC_DIR=$source_path" >> $config_mak
2010 write_target_makefile
>> $config_mak
2013 if have_target ppc-softmmu ppc64-softmmu
&& \
2014 probe_target_compiler ppc-softmmu
; then
2015 roms
="$roms pc-bios/vof"
2016 config_mak
=pc-bios
/vof
/config.mak
2017 echo "# Automatically generated by configure - do not modify" > $config_mak
2018 echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
2019 write_target_makefile
>> $config_mak
2022 # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
2023 # (which is the lowest architecture level that Clang supports)
2024 if have_target s390x-softmmu
&& probe_target_compiler s390x-softmmu
; then
2026 do_compiler
"$target_cc" $target_cc_cflags -march=z900
-o $TMPO -c $TMPC
2028 if [ $has_z900 = 0 ] || do_compiler
"$target_cc" $target_cc_cflags -march=z10
-msoft-float -Werror -o $TMPO -c $TMPC; then
2029 if [ $has_z900 != 0 ]; then
2030 echo "WARNING: Your compiler does not support the z900!"
2031 echo " The s390-ccw bios will only work with guest CPUs >= z10."
2033 roms
="$roms pc-bios/s390-ccw"
2034 config_mak
=pc-bios
/s390-ccw
/config-host.mak
2035 echo "# Automatically generated by configure - do not modify" > $config_mak
2036 echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
2037 write_target_makefile
>> $config_mak
2038 # SLOF is required for building the s390-ccw firmware on s390x,
2039 # since it is using the libnet code from SLOF for network booting.
2040 git_submodules
="${git_submodules} roms/SLOF"
2044 #######################################
2045 # generate config-host.mak
2047 if ! (GIT
="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
2051 config_host_mak
="config-host.mak"
2053 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2054 echo >> $config_host_mak
2056 echo all
: >> $config_host_mak
2057 echo "GIT=$git" >> $config_host_mak
2058 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
2059 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
2061 if test "$debug_tcg" = "yes" ; then
2062 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2064 if test "$mingw32" = "yes" ; then
2065 echo "CONFIG_WIN32=y" >> $config_host_mak
2066 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER-QEMU}" >> $config_host_mak
2067 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO-Linux}" >> $config_host_mak
2068 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION-$(cat "$source_path"/VERSION)}" >> $config_host_mak
2070 echo "CONFIG_POSIX=y" >> $config_host_mak
2073 if test "$linux" = "yes" ; then
2074 echo "CONFIG_LINUX=y" >> $config_host_mak
2077 if test "$darwin" = "yes" ; then
2078 echo "CONFIG_DARWIN=y" >> $config_host_mak
2081 if test "$solaris" = "yes" ; then
2082 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2084 echo "SRC_PATH=$source_path" >> $config_host_mak
2085 echo "TARGET_DIRS=$target_list" >> $config_host_mak
2087 # XXX: suppress that
2088 if [ "$bsd" = "yes" ] ; then
2089 echo "CONFIG_BSD=y" >> $config_host_mak
2092 echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
2094 if test "$plugins" = "yes" ; then
2095 echo "CONFIG_PLUGIN=y" >> $config_host_mak
2098 if test -n "$gdb_bin"; then
2099 gdb_version
=$
($gdb_bin --version |
head -n 1)
2100 if version_ge
${gdb_version##* } 9.1; then
2101 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2102 gdb_arches
=$
("$source_path/scripts/probe-gdb-support.py" $gdb_bin)
2108 if test "$container" != no
; then
2109 echo "ENGINE=$container" >> $config_host_mak
2110 echo "RUNC=$runc" >> $config_host_mak
2112 echo "ROMS=$roms" >> $config_host_mak
2113 echo "MAKE=$make" >> $config_host_mak
2114 echo "PYTHON=$python" >> $config_host_mak
2115 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
2116 echo "MESON=$meson" >> $config_host_mak
2117 echo "NINJA=$ninja" >> $config_host_mak
2118 echo "PKG_CONFIG=${pkg_config}" >> $config_host_mak
2119 echo "CC=$cc" >> $config_host_mak
2120 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2121 echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
2122 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
2123 echo "EXESUF=$EXESUF" >> $config_host_mak
2125 # use included Linux headers
2126 if test "$linux" = "yes" ; then
2127 mkdir
-p linux-headers
2142 linux_arch
=loongarch
2148 # For most CPUs the kernel architecture name and QEMU CPU name match.
2152 # For non-KVM architectures we will not have asm headers
2153 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
2154 symlink
"$source_path/linux-headers/asm-$linux_arch" linux-headers
/asm
2158 for target
in $target_list; do
2159 target_dir
="$target"
2160 target_name
=$
(echo $target | cut
-d '-' -f 1)$EXESUF
2161 mkdir
-p "$target_dir"
2163 *-user) symlink
"../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
2164 *) symlink
"../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
2168 if test "$default_targets" = "yes"; then
2169 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
2172 if test "$ccache_cpp2" = "yes"; then
2173 echo "export CCACHE_CPP2=y" >> $config_host_mak
2176 # tests/tcg configuration
2177 (config_host_mak
=tests
/tcg
/config-host.mak
2179 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2180 echo "SRC_PATH=$source_path" >> $config_host_mak
2181 echo "HOST_CC=$host_cc" >> $config_host_mak
2183 # versioned checked in the main config_host.mak above
2184 if test -n "$gdb_bin"; then
2185 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2187 if test "$plugins" = "yes" ; then
2188 echo "CONFIG_PLUGIN=y" >> $config_host_mak
2192 for target
in $target_list; do
2197 # the toolchain is not complete with headers, only build softmmu tests
2201 test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" ||
continue
2202 qemu
="qemu-system-$arch"
2204 *-linux-user|
*-bsd-user)
2209 if probe_target_compiler
$target ||
test -n "$container_image"; then
2210 test -n "$container_image" && build_static
=y
2211 mkdir
-p "tests/tcg/$target"
2212 config_target_mak
=tests
/tcg
/$target/config-target.mak
2213 ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile"
2214 echo "# Automatically generated by configure - do not modify" > "$config_target_mak"
2215 echo "TARGET_NAME=$arch" >> "$config_target_mak"
2216 echo "TARGET=$target" >> "$config_target_mak"
2217 write_target_makefile
"build-tcg-tests-$target" >> "$config_target_mak"
2218 echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
2219 echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
2221 # will GDB work with these binaries?
2222 if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
2223 echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak"
2226 echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
2227 tcg_tests_targets
="$tcg_tests_targets $target"
2231 if test "$tcg" = "enabled"; then
2232 echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
2236 if test "$skip_meson" = no
; then
2237 cross
="config-meson.cross.new"
2239 test $# = 0 && return
2240 echo "'$(echo $* | sed "s
/ /','/g
")'"
2243 echo "# Automatically generated by configure - do not modify" > $cross
2244 echo "[properties]" >> $cross
2246 # unroll any custom device configs
2247 for a
in $device_archs; do
2248 eval "c=\$devices_${a}"
2249 echo "${a}-softmmu = '$c'" >> $cross
2252 echo "[built-in options]" >> $cross
2253 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
2254 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
2255 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
2256 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
2257 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
2258 echo "[binaries]" >> $cross
2259 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
2260 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
2261 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
2262 echo "ar = [$(meson_quote $ar)]" >> $cross
2263 echo "nm = [$(meson_quote $nm)]" >> $cross
2264 echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
2265 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
2266 if has
$sdl2_config; then
2267 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
2269 echo "strip = [$(meson_quote $strip)]" >> $cross
2270 echo "widl = [$(meson_quote $widl)]" >> $cross
2271 echo "windres = [$(meson_quote $windres)]" >> $cross
2272 echo "windmc = [$(meson_quote $windmc)]" >> $cross
2273 if test "$cross_compile" = "yes"; then
2274 cross_arg
="--cross-file config-meson.cross"
2275 echo "[host_machine]" >> $cross
2276 echo "system = '$targetos'" >> $cross
2279 echo "cpu_family = 'x86'" >> $cross
2282 echo "cpu_family = '$cpu'" >> $cross
2285 echo "cpu = '$cpu'" >> $cross
2286 if test "$bigendian" = "yes" ; then
2287 echo "endian = 'big'" >> $cross
2289 echo "endian = 'little'" >> $cross
2292 cross_arg
="--native-file config-meson.cross"
2294 mv $cross config-meson.cross
2296 rm -rf meson-private meson-info meson-logs
2298 # Prevent meson from automatically downloading wrapped subprojects when missing.
2299 # You can use 'meson subprojects download' before running configure.
2300 meson_option_add
"--wrap-mode=nodownload"
2303 test "$bindir" != "bin" && meson_option_add
"-Dbindir=$bindir"
2304 test "$default_feature" = no
&& meson_option_add
-Dauto_features=disabled
2305 test "$static" = yes && meson_option_add
-Dprefer_static=true
2306 test "$pie" = no
&& meson_option_add
-Db_pie=false
2307 test "$werror" = yes && meson_option_add
-Dwerror=true
2310 test "$cfi" != false
&& meson_option_add
"-Dcfi=$cfi"
2311 test "$docs" != auto
&& meson_option_add
"-Ddocs=$docs"
2312 test "$fdt" != auto
&& meson_option_add
"-Dfdt=$fdt"
2313 test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add
"-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
2314 test "$qemu_suffix" != qemu
&& meson_option_add
"-Dqemu_suffix=$qemu_suffix"
2315 test "$smbd" != '' && meson_option_add
"-Dsmbd=$smbd"
2316 test "$tcg" != enabled
&& meson_option_add
"-Dtcg=$tcg"
2317 test "$vfio_user_server" != auto
&& meson_option_add
"-Dvfio_user_server=$vfio_user_server"
2319 NINJA
=$ninja $meson setup
--prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path"
2321 eval run_meson
$meson_options
2322 if test "$?" -ne 0 ; then
2323 error_exit
"meson setup failed"
2327 # Save the configure command line for later reuse.
2328 cat <<EOD >config.status
2330 # Generated by configure.
2331 # Run this file to recreate the current configuration.
2332 # Compiler output produced by configure, useful for debugging
2333 # configure, is in config.log if it exists.
2339 eval envval
=\$
$envname
2341 if test -n "$envval"
2343 echo "$envname='$envval'" >> config.status
2344 echo "export $envname" >> config.status
2346 echo "unset $envname" >> config.status
2350 # Preserve various env variables that influence what
2351 # features/build target configure will detect
2357 preserve_env CXXFLAGS
2359 preserve_env LDFLAGS
2360 preserve_env LD_LIBRARY_PATH
2363 preserve_env OBJCFLAGS
2364 preserve_env OBJCOPY
2366 preserve_env PKG_CONFIG
2367 preserve_env PKG_CONFIG_LIBDIR
2368 preserve_env PKG_CONFIG_PATH
2370 preserve_env QEMU_GA_MANUFACTURER
2371 preserve_env QEMU_GA_DISTRO
2372 preserve_env QEMU_GA_VERSION
2373 preserve_env SDL2_CONFIG
2377 preserve_env WINDRES
2380 printf "exec" >>config.status
2381 for i
in "$0" "$@"; do
2382 test "$i" = --skip-meson ||
printf " %s" "$(quote_sh "$i")" >>config.status
2384 echo ' "$@"' >>config.status
2385 chmod +x config.status