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)
285 plugins
="$default_feature"
289 vfio_user_server
="disabled"
291 # The following Meson options are handled manually (still they
292 # are included in the automatically generated help message)
294 # 1. Track which submodules are needed
297 # 2. Automatically enable/disable other options
301 # parse CC options second
303 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
305 --cross-prefix=*) cross_prefix
="$optarg"
310 --cxx=*) CXX
="$optarg"
312 --objcc=*) objcc
="$optarg"
314 --cpu=*) cpu
="$optarg"
317 EXTRA_CFLAGS
="$EXTRA_CFLAGS $optarg"
318 EXTRA_CXXFLAGS
="$EXTRA_CXXFLAGS $optarg"
319 EXTRA_OBJCFLAGS
="$EXTRA_OBJCFLAGS $optarg"
321 --extra-cxxflags=*) EXTRA_CXXFLAGS
="$EXTRA_CXXFLAGS $optarg"
323 --extra-objcflags=*) EXTRA_OBJCFLAGS
="$EXTRA_OBJCFLAGS $optarg"
325 --extra-ldflags=*) EXTRA_LDFLAGS
="$EXTRA_LDFLAGS $optarg"
327 --cross-cc-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --cross-cc-FOO option"
329 --cross-cc-cflags-*) cc_arch
=${opt#--cross-cc-cflags-}; cc_arch
=${cc_arch%%=*}
330 eval "cross_cc_cflags_${cc_arch}=\$optarg"
332 --cross-cc-*) cc_arch
=${opt#--cross-cc-}; cc_arch
=${cc_arch%%=*}
333 eval "cross_cc_${cc_arch}=\$optarg"
335 --cross-prefix-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --cross-prefix-FOO option"
337 --cross-prefix-*) cc_arch
=${opt#--cross-prefix-}; cc_arch
=${cc_arch%%=*}
338 eval "cross_prefix_${cc_arch}=\$optarg"
343 # Preferred compiler:
345 # ${cross_prefix}gcc (if cross-prefix specified)
347 if test -z "${CC}${cross_prefix}"; then
350 cc
="${CC-${cross_prefix}gcc}"
353 if test -z "${CXX}${cross_prefix}"; then
356 cxx
="${CXX-${cross_prefix}g++}"
359 # Preferred ObjC compiler:
360 # $objcc (if set, i.e. via --objcc option)
361 # ${cross_prefix}clang (if cross-prefix specified)
362 # clang (if available)
364 if test -z "${objcc}${cross_prefix}"; then
371 objcc
="${objcc-${cross_prefix}clang}"
374 ar="${AR-${cross_prefix}ar}"
375 as
="${AS-${cross_prefix}as}"
377 objcopy
="${OBJCOPY-${cross_prefix}objcopy}"
378 ld
="${LD-${cross_prefix}ld}"
379 ranlib
="${RANLIB-${cross_prefix}ranlib}"
380 nm
="${NM-${cross_prefix}nm}"
382 strip
="${STRIP-${cross_prefix}strip}"
383 widl
="${WIDL-${cross_prefix}widl}"
384 windres
="${WINDRES-${cross_prefix}windres}"
385 windmc
="${WINDMC-${cross_prefix}windmc}"
386 pkg_config
="${PKG_CONFIG-${cross_prefix}pkg-config}"
387 sdl2_config
="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
389 # default flags for all hosts
390 # We use -fwrapv to tell the compiler that we require a C dialect where
391 # left shift of signed integers is well defined and has the expected
392 # 2s-complement style results. (Both clang and gcc agree that it
393 # provides these semantics.)
394 QEMU_CFLAGS
="-fno-strict-aliasing -fno-common -fwrapv"
395 QEMU_CFLAGS
="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
399 # Flags that are needed during configure but later taken care of by Meson
400 CONFIGURE_CFLAGS
="-std=gnu11 -Wall"
407 #error $1 not defined
409 int main(void) { return 0; }
416 int main(void) { return 0; }
420 if check_define __linux__
; then
422 elif check_define _WIN32
; then
424 elif check_define __OpenBSD__
; then
426 elif check_define __sun__
; then
428 elif check_define __HAIKU__
; then
430 elif check_define __FreeBSD__
; then
432 elif check_define __FreeBSD_kernel__
&& check_define __GLIBC__
; then
433 targetos
=gnu
/kfreebsd
434 elif check_define __DragonFly__
; then
436 elif check_define __NetBSD__
; then
438 elif check_define __APPLE__
; then
441 # This is a fatal error, but don't report it yet, because we
442 # might be going to just print the --help text, or it might
443 # be the result of a missing compiler.
465 # needed for kinfo_getvmmap(3) in libutil.h
482 # Disable attempts to use ObjectiveC features in os/object.h since they
483 # won't work when we're compiling with gcc as a C compiler.
484 QEMU_CFLAGS
="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
489 # needed for CMSG_ macros in sys/socket.h
490 QEMU_CFLAGS
="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
491 # needed for TIOCWIN* defines in termios.h
492 QEMU_CFLAGS
="-D__EXTENSIONS__ $QEMU_CFLAGS"
496 QEMU_CFLAGS
="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
503 if test ! -z "$cpu" ; then
504 # command line argument
506 elif check_define __i386__
; then
508 elif check_define __x86_64__
; then
509 if check_define __ILP32__
; then
514 elif check_define __sparc__
; then
515 if check_define __arch64__
; then
520 elif check_define _ARCH_PPC
; then
521 if check_define _ARCH_PPC64
; then
522 if check_define _LITTLE_ENDIAN
; then
530 elif check_define __mips__
; then
532 elif check_define __s390__
; then
533 if check_define __s390x__
; then
538 elif check_define __riscv
; then
540 elif check_define __arm__
; then
542 elif check_define __aarch64__
; then
544 elif check_define __loongarch64
; then
547 # Using uname is really broken, but it is just a fallback for architectures
548 # that are going to use TCI anyway
550 echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
553 # Normalise host CPU name and set multilib cflags. The canonicalization
554 # isn't really necessary, because the architectures that we check for
555 # should not hit the 'uname -m' case, but better safe than sorry.
556 # Note that this case should only have supported host CPUs, not guests.
566 CPU_CFLAGS
="-mx32" ;;
569 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
570 # If we truly care, we should simply detect this case at
571 # runtime and generate the fallback to serial emulation.
572 CPU_CFLAGS
="-m64 -mcx16" ;;
580 CPU_CFLAGS
="-m64 -mbig-endian" ;;
583 CPU_CFLAGS
="-m64 -mlittle-endian" ;;
592 CPU_CFLAGS
="-m32 -mv8plus -mcpu=ultrasparc" ;;
594 CPU_CFLAGS
="-m64 -mcpu=ultrasparc" ;;
597 : ${make=${MAKE-make}}
601 # We require python >= 3.7.
602 # NB: a True python conditional creates a non-zero return code (Failure)
603 "$1" -c 'import sys; sys.exit(sys.version_info < (3,7))'
609 if test -z "${PYTHON}"; then
610 # A bare 'python' is traditionally python 2.x, but some distros
611 # have it as python 3.x, so check in both places.
612 for binary
in python3 python python3.11 python3.10 python3.9 python3.8 python3.7
; do
613 if has
"$binary"; then
614 python
=$
(command -v "$binary")
615 if check_py_version
"$python"; then
625 # Same as above, but only check the environment variable.
626 has
"${PYTHON}" || error_exit
"The PYTHON environment variable does not point to an executable"
627 python
=$
(command -v "$PYTHON")
628 if check_py_version
"$python"; then
632 first_python
=$first_python
636 # Check for ancillary tools used in testing
638 for binary
in genisoimage mkisofs
642 genisoimage
=$
(command -v "$binary")
647 if test "$mingw32" = "yes" ; then
649 # MinGW needs -mthreads for TLS and macro _MT.
650 CONFIGURE_CFLAGS
="-mthreads $CONFIGURE_CFLAGS"
658 meson_option_build_array
() {
660 (if test "$targetos" = windows
; then
667 # backslash escape any '\' and '"' characters
668 printf "%s" "$e" |
sed -e 's/\([\"]\)/\\\1/g'
674 .
"$source_path/scripts/meson-buildoptions.sh"
678 meson_options
="$meson_options $(quote_sh "$1")"
680 meson_option_parse
() {
681 meson_options
="$meson_options $(_meson_option_parse "$@
")"
682 if test $?
-eq 1; then
683 echo "ERROR: unknown option $1"
684 echo "Try '$0 --help' for more information"
690 optarg
=$
(expr "x$opt" : 'x[^=]*=\(.*\)')
692 --help|
-h) show_help
=yes
694 --version|
-V) exec cat "$source_path/VERSION"
696 --prefix=*) prefix
="$optarg"
702 --host-cc=*) host_cc
="$optarg"
708 --make=*) make="$optarg"
712 --python=*) python
="$optarg"
714 --skip-meson) skip_meson
=yes
716 --ninja=*) ninja
="$optarg"
718 --smbd=*) smbd
="$optarg"
732 --enable-debug-info) meson_option_add
-Ddebug=true
734 --disable-debug-info) meson_option_add
-Ddebug=false
736 --enable-docs) docs
=enabled
738 --disable-docs) docs
=disabled
742 --target-list=*) target_list
="$optarg"
743 if test "$target_list_exclude"; then
744 error_exit
"Can't mix --target-list with --target-list-exclude"
747 --target-list-exclude=*) target_list_exclude
="$optarg"
748 if test "$target_list"; then
749 error_exit
"Can't mix --target-list-exclude with --target-list"
752 --with-default-devices) meson_option_add
-Ddefault_devices=true
754 --without-default-devices) meson_option_add
-Ddefault_devices=false
756 --with-devices-*[!a-zA-Z0-9_-
]*=*) error_exit
"Passed bad --with-devices-FOO option"
758 --with-devices-*) device_arch
=${opt#--with-devices-};
759 device_arch
=${device_arch%%=*}
760 cf
=$source_path/configs
/devices
/$device_arch-softmmu/$optarg.mak
761 if test -f "$cf"; then
762 device_archs
="$device_archs $device_arch"
763 eval "devices_${device_arch}=\$optarg"
765 error_exit
"File $cf does not exist"
768 --without-default-features) # processed above
770 --static) static
="yes"
772 --bindir=*) bindir
="$optarg"
774 --with-suffix=*) qemu_suffix
="$optarg"
777 --disable-dependency-tracking|\
778 --sbindir=*|
--sharedstatedir=*|\
779 --oldincludedir=*|
--datarootdir=*|
--infodir=*|\
780 --htmldir=*|
--dvidir=*|
--pdfdir=*|
--psdir=*)
781 # These switches are silently ignored, for compatibility with
782 # autoconf-generated configure scripts. This allows QEMU's
783 # configure to be used by RPM and similar macros that set
784 # lots of directory switches by default.
786 --enable-debug-tcg) debug_tcg
="yes"
788 --disable-debug-tcg) debug_tcg
="no"
791 # Enable debugging options that aren't excessively noisy
793 meson_option_parse
--enable-debug-graph-lock ""
794 meson_option_parse
--enable-debug-mutex ""
795 meson_option_add
-Doptimization=0
797 --disable-tcg) tcg
="disabled"
800 --enable-tcg) tcg
="enabled"
802 --disable-system) softmmu
="no"
804 --enable-system) softmmu
="yes"
811 --disable-linux-user) linux_user
="no"
813 --enable-linux-user) linux_user
="yes"
815 --disable-bsd-user) bsd_user
="no"
817 --enable-bsd-user) bsd_user
="yes"
819 --enable-pie) pie
="yes"
821 --disable-pie) pie
="no"
823 --enable-werror) werror
="yes"
825 --disable-werror) werror
="no"
827 --enable-stack-protector) stack_protector
="yes"
829 --disable-stack-protector) stack_protector
="no"
833 meson_option_add
-Db_lto=true
835 --disable-cfi) cfi
="false"
837 --disable-fdt) fdt
="disabled"
839 --enable-fdt) fdt
="enabled"
841 --enable-fdt=git
) fdt
="internal"
843 --enable-fdt=*) fdt
="$optarg"
845 --with-git=*) git
="$optarg"
847 --with-git-submodules=*)
848 git_submodules_action
="$optarg"
850 --disable-pypi) pypi
="disabled"
852 --enable-pypi) pypi
="enabled"
854 --enable-plugins) if test "$mingw32" = "yes"; then
855 error_exit
"TCG plugins not currently supported on Windows platforms"
860 --disable-plugins) plugins
="no"
862 --enable-containers) use_containers
="yes"
864 --disable-containers) use_containers
="no"
866 --gdb=*) gdb_bin
="$optarg"
868 --enable-vfio-user-server) vfio_user_server
="enabled"
870 --disable-vfio-user-server) vfio_user_server
="disabled"
872 # everything else has the same name in configure and meson
873 --*) meson_option_parse
"$opt" "$optarg"
878 # test for any invalid configuration combinations
879 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
880 error_exit
"Can't enable plugins on non-TCG builds"
883 case $git_submodules_action in
885 if test ! -e "$source_path/.git"; then
886 echo "ERROR: cannot $git_submodules_action git submodules without .git"
891 if ! test -f "$source_path/ui/keycodemapdb/README"
894 echo "ERROR: missing GIT submodules"
896 if test -e "$source_path/.git"; then
897 echo "--with-git-submodules=ignore specified but submodules were not"
898 echo "checked out. Please initialize and update submodules."
900 echo "This is not a GIT checkout but module content appears to"
901 echo "be missing. Do not use 'git archive' or GitHub download links"
902 echo "to acquire QEMU source archives. Non-GIT builds are only"
903 echo "supported with source archives linked from:"
905 echo " https://www.qemu.org/download/#source"
907 echo "Developers working with GIT can use scripts/archive-source.sh"
908 echo "if they need to create valid source archives."
915 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
920 default_target_list
=""
923 if [ "$linux_user" != no
]; then
924 if [ "$targetos" = linux
] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then
926 elif [ "$linux_user" = yes ]; then
927 error_exit
"linux-user not supported on this architecture"
930 if [ "$bsd_user" != no
]; then
931 if [ "$bsd_user" = "" ]; then
932 test $targetos = freebsd
&& bsd_user
=yes
934 if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
935 error_exit
"bsd-user not supported on this host OS"
938 if [ "$softmmu" = "yes" ]; then
939 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
941 if [ "$linux_user" = "yes" ]; then
942 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
944 if [ "$bsd_user" = "yes" ]; then
945 mak_wilds
="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
948 for config
in $mak_wilds; do
949 target
="$(basename "$config" .mak)"
950 if echo "$target_list_exclude" |
grep -vq "$target"; then
951 default_target_list
="${default_target_list} $target"
955 if test x
"$show_help" = x
"yes" ; then
958 Usage: configure [options]
959 Options: [defaults in brackets after descriptions]
962 --help print this message
963 --prefix=PREFIX install in PREFIX [$prefix]
964 --target-list=LIST set target list (default: build all)
965 $(echo Available targets: $default_target_list | \
966 fold -s -w 53 | sed -e 's/^/ /')
967 --target-list-exclude=LIST exclude a set of targets from the default target-list
969 Advanced options (experts only):
970 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
971 --cc=CC use C compiler CC [$cc]
972 --host-cc=CC use C compiler CC [$host_cc] for code run at
974 --cxx=CXX use C++ compiler CXX [$cxx]
975 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
976 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
977 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
978 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
979 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
980 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
981 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
982 --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
983 --make=MAKE use specified make [$make]
984 --python=PYTHON use specified python [$python]
985 --ninja=NINJA use specified ninja [$ninja]
986 --smbd=SMBD use specified smbd [$smbd]
987 --with-git=GIT use specified git [$git]
988 --with-git-submodules=update update git submodules (default if .git dir exists)
989 --with-git-submodules=validate fail if git submodules are not up to date
990 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
991 --static enable static build [$static]
992 --bindir=PATH install binaries in PATH
993 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
994 --without-default-features default all --enable-* options to "disabled"
995 --without-default-devices do not include any device that is not needed to
996 start the emulator (only use if you are including
997 desired devices in configs/devices/)
998 --with-devices-ARCH=NAME override default configs/devices
999 --enable-debug enable common debug build options
1000 --disable-werror disable compilation abort on warning
1001 --disable-stack-protector disable compiler-provided stack protection
1002 --cpu=CPU Build for host CPU [$cpu]
1004 enable plugins via shared library loading
1005 --disable-containers don't use containers for cross-building
1006 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
1010 system all system emulation targets
1011 user supported user emulation targets
1012 linux-user all linux usermode emulation targets
1013 bsd-user all BSD usermode emulation targets
1014 pie Position Independent Executables
1015 debug-tcg TCG debugging (default is disabled)
1016 debug-info debugging information
1018 NOTE: The object files are built at the place where configure is launched
1023 # Remove old dependency files to make sure that they get properly regenerated
1024 rm -f .
/*/config-devices.mak.d
1026 if test -z "$python"
1028 # If first_python is set, there was a binary somewhere even though
1029 # it was not suitable. Use it for the error message.
1030 if test -n "$first_python"; then
1031 error_exit
"Cannot use '$first_python', Python >= 3.7 is required." \
1032 "Use --python=/path/to/python to specify a supported Python."
1034 error_exit
"Python not found. Use --python=/path/to/python"
1040 error_exit
"GNU make ($make) not found"
1043 if ! check_py_version
"$python"; then
1044 error_exit
"Cannot use '$python', Python >= 3.7 is required." \
1045 "Use --python=/path/to/python to specify a supported Python." \
1047 " openSUSE Leap 15.3+: zypper install python39" \
1048 " CentOS 8: dnf install python38"
1052 python
="$(command -v "$python")"
1054 # Create a Python virtual environment using our configured python.
1055 # The stdout of this script will be the location of a symlink that
1056 # points to the configured Python.
1057 # Entry point scripts for pip, meson, and sphinx are generated if those
1058 # packages are present.
1060 # Defaults assumed for now:
1061 # - venv is cleared if it exists already;
1062 # - venv is allowed to use system packages;
1063 # - all setup can be performed offline;
1064 # - missing packages may be fetched from PyPI,
1065 # unless --disable-pypi is passed.
1066 # - pip is not installed into the venv when possible,
1067 # but ensurepip is called as a fallback when necessary.
1069 echo "python determined to be '$python'"
1070 echo "python version: $($python --version)"
1072 python
="$($python -B "${source_path}/python
/scripts
/mkvenv.py
" create pyvenv)"
1073 if test "$?" -ne 0 ; then
1074 error_exit
"python venv creation failed"
1077 # Suppress writing compiled files
1079 mkvenv
="$python ${source_path}/python/scripts/mkvenv.py"
1082 if test "$pypi" = "enabled" ; then
1083 mkvenv_flags
="--online"
1086 if ! $mkvenv ensure \
1088 --dir "${source_path}/python/wheels" \
1089 --diagnose "meson" \
1095 # At this point, we expect Meson to be installed and available.
1096 # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
1097 # We ignore PATH completely here: we want to use the venv's Meson
1100 meson
="$(cd pyvenv/bin; pwd)/meson"
1102 # Conditionally ensure Sphinx is installed.
1105 if test "$pypi" = "enabled" -a "$docs" = "enabled" ; then
1106 mkvenv_flags
="--online"
1109 if test "$docs" != "disabled" ; then
1110 if ! $mkvenv ensure \
1112 --diagnose "sphinx-build" \
1113 "sphinx>=1.6.0" "sphinx-rtd-theme>=0.5.0";
1115 if test "$docs" = "enabled" ; then
1118 echo "Sphinx not found/usable, disabling docs."
1127 if test -z "$ninja"; then
1128 for c
in ninja ninja-build samu
; do
1130 ninja
=$
(command -v "$c")
1134 if test -z "$ninja"; then
1135 error_exit
"Cannot find Ninja"
1139 # Check that the C compiler works. Doing this here before testing
1140 # the host CPU ensures that we had a valid CC to autodetect the
1141 # $cpu var (and we should bail right here if that's not the case).
1142 # It also allows the help message to be printed without a CC.
1144 if compile_object
; then
1145 : C compiler works ok
1147 error_exit
"\"$cc\" either does not exist or does not work"
1149 if ! compile_prog
; then
1150 error_exit
"\"$cc\" cannot build an executable (is your linker broken?)"
1153 # Consult white-list to determine whether to enable werror
1154 # by default. Only enable by default for git builds
1155 if test -z "$werror" ; then
1156 if test "$git_submodules_action" != "ignore" && \
1157 { test "$linux" = "yes" ||
test "$mingw32" = "yes"; }; then
1164 if test "$targetos" = "bogus"; then
1165 # Now that we know that we're not printing the help and that
1166 # the compiler works (so the results of the check_defines we used
1167 # to identify the OS are reliable), if we didn't recognize the
1168 # host OS we should stop now.
1169 error_exit
"Unrecognized host OS (uname -s reports '$(uname -s)')"
1172 # Check whether the compiler matches our minimum requirements:
1174 #if defined(__clang_major__) && defined(__clang_minor__)
1175 # ifdef __apple_build_version__
1176 # if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0)
1177 # error You need at least XCode Clang v12.0 to compile QEMU
1180 # if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
1181 # error You need at least Clang v10.0 to compile QEMU
1184 #elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1185 # if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
1186 # error You need at least GCC v7.4.0 to compile QEMU
1189 # error You either need GCC or Clang to compiler QEMU
1191 int main (void) { return 0; }
1193 if ! compile_prog
"" "" ; then
1194 error_exit
"You need at least GCC v7.4 or Clang v10.0 (or XCode Clang v12.0)"
1197 # Accumulate -Wfoo and -Wno-bar separately.
1198 # We will list all of the enable flags first, and the disable flags second.
1199 # Note that we do not add -Werror, because that would enable it for all
1200 # configure tests. If a configure test failed due to -Werror this would
1201 # just silently disable some features, so it's too error prone.
1204 add_to warn_flags
-Wundef
1205 add_to warn_flags
-Wwrite-strings
1206 add_to warn_flags
-Wmissing-prototypes
1207 add_to warn_flags
-Wstrict-prototypes
1208 add_to warn_flags
-Wredundant-decls
1209 add_to warn_flags
-Wold-style-declaration
1210 add_to warn_flags
-Wold-style-definition
1211 add_to warn_flags
-Wtype-limits
1212 add_to warn_flags
-Wformat-security
1213 add_to warn_flags
-Wformat-y2k
1214 add_to warn_flags
-Winit-self
1215 add_to warn_flags
-Wignored-qualifiers
1216 add_to warn_flags
-Wempty-body
1217 add_to warn_flags
-Wnested-externs
1218 add_to warn_flags
-Wendif-labels
1219 add_to warn_flags
-Wexpansion-to-defined
1220 add_to warn_flags
-Wimplicit-fallthrough=2
1221 add_to warn_flags
-Wmissing-format-attribute
1223 if test "$targetos" != "darwin"; then
1224 add_to warn_flags
-Wthread-safety
1228 add_to nowarn_flags
-Wno-initializer-overrides
1229 add_to nowarn_flags
-Wno-missing-include-dirs
1230 add_to nowarn_flags
-Wno-shift-negative-value
1231 add_to nowarn_flags
-Wno-string-plus-int
1232 add_to nowarn_flags
-Wno-typedef-redefinition
1233 add_to nowarn_flags
-Wno-tautological-type-limit-compare
1234 add_to nowarn_flags
-Wno-psabi
1235 add_to nowarn_flags
-Wno-gnu-variable-sized-type-not-at-end
1237 gcc_flags
="$warn_flags $nowarn_flags"
1239 cc_has_warning_flag
() {
1242 # Use the positive sense of the flag when testing for -Wno-wombat
1243 # support (gcc will happily accept the -Wno- form of unknown
1245 optflag
="$(echo $1 | sed -e 's/^-Wno-/-W/')"
1246 compile_prog
"-Werror $optflag" ""
1249 objcc_has_warning_flag
() {
1251 int main(void) { return 0; }
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 do_objc
-Werror $optflag \
1259 $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \
1260 -o $TMPE $TMPM $QEMU_LDFLAGS
1263 for flag
in $gcc_flags; do
1264 if cc_has_warning_flag
$flag ; then
1265 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1267 if objcc_has_warning_flag
$flag ; then
1268 QEMU_OBJCFLAGS
="$QEMU_OBJCFLAGS $flag"
1272 if test "$stack_protector" != "no"; then
1274 int main(int argc, char *argv[])
1276 char arr[64], *p = arr, *c = argv[argc - 1];
1283 gcc_flags
="-fstack-protector-strong -fstack-protector-all"
1285 for flag
in $gcc_flags; do
1286 # We need to check both a compile and a link, since some compiler
1287 # setups fail only on a .c->.o compile and some only at link time
1288 if compile_object
"-Werror $flag" &&
1289 compile_prog
"-Werror $flag" ""; then
1290 QEMU_CFLAGS
="$QEMU_CFLAGS $flag"
1291 QEMU_LDFLAGS
="$QEMU_LDFLAGS $flag"
1296 if test "$stack_protector" = yes; then
1297 if test $sp_on = 0; then
1298 error_exit
"Stack protector not supported"
1303 if test "$static" = "yes" ; then
1304 if test "$plugins" = "yes"; then
1305 error_exit
"static and plugins are mutually incompatible"
1310 test "$plugins" = "" && plugins
=yes
1315 # define THREAD __thread
1319 static THREAD int tls_var;
1320 int main(void) { return tls_var; }
1323 # Meson currently only handles pie as a boolean for now so if we have
1324 # explicitly disabled PIE we need to extend our cflags because it wont.
1325 if test "$static" = "yes"; then
1326 if test "$pie" != "no" && compile_prog
"-Werror -fPIE -DPIE" "-static-pie"; then
1327 CONFIGURE_CFLAGS
="-fPIE -DPIE $CONFIGURE_CFLAGS"
1329 elif test "$pie" = "yes"; then
1330 error_exit
"-static-pie not available due to missing toolchain support"
1333 QEMU_CFLAGS
="-fno-pie $QEMU_CFLAGS"
1335 elif test "$pie" = "no"; then
1336 if compile_prog
"-Werror -fno-pie" "-no-pie"; then
1337 CONFIGURE_CFLAGS
="-fno-pie $CONFIGURE_CFLAGS"
1338 CONFIGURE_LDFLAGS
="-no-pie $CONFIGURE_LDFLAGS"
1339 QEMU_CFLAGS
="-fno-pie -no-pie $QEMU_CFLAGS"
1341 elif compile_prog
"-Werror -fPIE -DPIE" "-pie"; then
1342 CONFIGURE_CFLAGS
="-fPIE -DPIE $CONFIGURE_CFLAGS"
1343 CONFIGURE_LDFLAGS
="-pie $CONFIGURE_LDFLAGS"
1345 elif test "$pie" = "yes"; then
1346 error_exit
"PIE not available due to missing toolchain support"
1348 echo "Disabling PIE due to missing toolchain support"
1352 ##########################################
1353 # __sync_fetch_and_and requires at least -march=i486. Many toolchains
1354 # use i686 as default anyway, but for those that don't, an explicit
1355 # specification is necessary
1357 if test "$cpu" = "i386"; then
1359 static int sfaa(int *ptr)
1361 return __sync_fetch_and_and(ptr, 0);
1367 val = __sync_val_compare_and_swap(&val, 0, 1);
1372 if ! compile_prog
"" "" ; then
1373 QEMU_CFLAGS
="-march=i486 $QEMU_CFLAGS"
1377 if test -z "${target_list+xxx}" ; then
1379 for target
in $default_target_list; do
1380 target_list
="$target_list $target"
1382 target_list
="${target_list# }"
1385 target_list
=$
(echo "$target_list" |
sed -e 's/,/ /g')
1386 for target
in $target_list; do
1387 # Check that we recognised the target name; this allows a more
1388 # friendly error message than if we let it fall through.
1389 case " $default_target_list " in
1393 error_exit
"Unknown target name '$target'"
1399 # see if system emulation was really requested
1400 case " $target_list " in
1401 *"-softmmu "*) softmmu
=yes
1407 if test "$tcg" = "auto"; then
1408 if test -z "$target_list"; then
1415 if test "$tcg" = "enabled"; then
1416 git_submodules
="$git_submodules tests/fp/berkeley-testfloat-3"
1417 git_submodules
="$git_submodules tests/fp/berkeley-softfloat-3"
1420 ##########################################
1421 # big/little endian test
1423 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1426 int main(void) { return 0; }
1429 if ! compile_prog
; then
1433 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1436 int main(void) { return 0; }
1439 if ! compile_prog
; then
1442 echo big
/little
test failed
1447 ##########################################
1451 auto | enabled | internal
)
1452 # Simpler to always update submodule, even if not needed.
1453 git_submodules
="${git_submodules} dtc"
1457 ########################################
1458 # check if ccache is interfering with
1459 # semantic analysis of macros
1464 static const int Z = 1;
1465 #define fn() ({ Z; })
1466 #define TAUT(X) ((X) == Z)
1467 #define PAREN(X, Y) (X == Y)
1475 if (PAREN(x, y)) return 0;
1476 if (TAUT(Z)) return 0;
1481 if ! compile_object
"-Werror"; then
1485 ##########################################
1486 # functions to probe cross compilers
1490 if test $use_containers = "yes" && (has
"docker" || has
"podman"); then
1491 case $
($python "$source_path"/tests
/docker
/docker.py probe
) in
1492 *docker
) container
=docker
;;
1493 podman
) container
=podman
;;
1496 if test "$container" != "no"; then
1497 docker_py
="$python $source_path/tests/docker/docker.py --engine $container"
1498 runc
=$
($python "$source_path"/tests
/docker
/docker.py probe
)
1502 # cross compilers defaults, can be overridden with --cross-cc-ARCH
1503 : ${cross_prefix_aarch64="aarch64-linux-gnu-"}
1504 : ${cross_prefix_aarch64_be="$cross_prefix_aarch64"}
1505 : ${cross_prefix_alpha="alpha-linux-gnu-"}
1506 : ${cross_prefix_arm="arm-linux-gnueabihf-"}
1507 : ${cross_prefix_armeb="$cross_prefix_arm"}
1508 : ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"}
1509 : ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"}
1510 : ${cross_prefix_hppa="hppa-linux-gnu-"}
1511 : ${cross_prefix_i386="i686-linux-gnu-"}
1512 : ${cross_prefix_m68k="m68k-linux-gnu-"}
1513 : ${cross_prefix_microblaze="microblaze-linux-musl-"}
1514 : ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"}
1515 : ${cross_prefix_mips64="mips64-linux-gnuabi64-"}
1516 : ${cross_prefix_mipsel="mipsel-linux-gnu-"}
1517 : ${cross_prefix_mips="mips-linux-gnu-"}
1518 : ${cross_prefix_nios2="nios2-linux-gnu-"}
1519 : ${cross_prefix_ppc="powerpc-linux-gnu-"}
1520 : ${cross_prefix_ppc64="powerpc64-linux-gnu-"}
1521 : ${cross_prefix_ppc64le="$cross_prefix_ppc64"}
1522 : ${cross_prefix_riscv64="riscv64-linux-gnu-"}
1523 : ${cross_prefix_s390x="s390x-linux-gnu-"}
1524 : ${cross_prefix_sh4="sh4-linux-gnu-"}
1525 : ${cross_prefix_sparc64="sparc64-linux-gnu-"}
1526 : ${cross_prefix_sparc="$cross_prefix_sparc64"}
1527 : ${cross_prefix_x86_64="x86_64-linux-gnu-"}
1529 : ${cross_cc_aarch64_be="$cross_cc_aarch64"}
1530 : ${cross_cc_cflags_aarch64_be="-mbig-endian"}
1531 : ${cross_cc_armeb="$cross_cc_arm"}
1532 : ${cross_cc_cflags_armeb="-mbig-endian"}
1533 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
1534 : ${cross_cc_cflags_hexagon="-mv67 -O2 -static"}
1535 : ${cross_cc_cflags_i386="-m32"}
1536 : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
1537 : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
1538 : ${cross_cc_ppc64le="$cross_cc_ppc64"}
1539 : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
1540 : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
1541 : ${cross_cc_sparc="$cross_cc_sparc64"}
1542 : ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
1543 : ${cross_cc_cflags_x86_64="-m64"}
1545 compute_target_variable
() {
1547 if eval test -n "\"\${cross_prefix_$1}\""; then
1548 if eval has
"\"\${cross_prefix_$1}\$3\""; then
1549 eval "$2=\"\${cross_prefix_$1}\$3\""
1556 case " $target_list " in
1557 *" $i "*) return 0;;
1564 # probe_target_compiler TARGET
1566 # Look for a compiler for the given target, either native or cross.
1567 # Set variables target_* if a compiler is found, and container_cross_*
1568 # if a Docker-based cross-compiler image is known for the target.
1569 # Set got_cross_cc to yes/no depending on whether a non-container-based
1570 # compiler was found.
1572 # If TARGET is a user-mode emulation target, also set build_static to
1573 # "y" if static linking is possible.
1575 probe_target_compiler
() {
1576 # reset all output variables
1585 container_cross_objcopy
=
1586 container_cross_ranlib
=
1587 container_cross_strip
=
1589 # We shall skip configuring the target compiler if the user didn't
1590 # bother enabling an appropriate guest. This avoids building
1591 # extraneous firmware images and tests.
1592 if test "${target_list#*$1}" = "$1"; then
1596 target_arch
=${1%%-*}
1597 case $target_arch in
1598 aarch64
) container_hosts
="x86_64 aarch64" ;;
1599 alpha
) container_hosts
=x86_64
;;
1600 arm
) container_hosts
="x86_64 aarch64" ;;
1601 cris
) container_hosts
=x86_64
;;
1602 hexagon
) container_hosts
=x86_64
;;
1603 hppa
) container_hosts
=x86_64
;;
1604 i386
) container_hosts
=x86_64
;;
1605 loongarch64
) container_hosts
=x86_64
;;
1606 m68k
) container_hosts
=x86_64
;;
1607 microblaze
) container_hosts
=x86_64
;;
1608 mips64el
) container_hosts
=x86_64
;;
1609 mips64
) container_hosts
=x86_64
;;
1610 mipsel
) container_hosts
=x86_64
;;
1611 mips
) container_hosts
=x86_64
;;
1612 nios2
) container_hosts
=x86_64
;;
1613 ppc
) container_hosts
=x86_64
;;
1614 ppc64|ppc64le
) container_hosts
=x86_64
;;
1615 riscv64
) container_hosts
=x86_64
;;
1616 s390x
) container_hosts
=x86_64
;;
1617 sh4
) container_hosts
=x86_64
;;
1618 sparc64
) container_hosts
=x86_64
;;
1619 tricore
) container_hosts
=x86_64
;;
1620 x86_64
) container_hosts
="aarch64 ppc64el x86_64" ;;
1621 xtensa
*) container_hosts
=x86_64
;;
1624 for host in $container_hosts; do
1625 test "$container" != no ||
continue
1626 test "$host" = "$cpu" ||
continue
1627 case $target_arch in
1629 # We don't have any bigendian build tools so we only use this for AArch64
1630 container_image
=debian-arm64-cross
1631 container_cross_prefix
=aarch64-linux-gnu-
1632 container_cross_cc
=${container_cross_prefix}gcc-10
1635 container_image
=debian-alpha-cross
1636 container_cross_prefix
=alpha-linux-gnu-
1639 # We don't have any bigendian build tools so we only use this for ARM
1640 container_image
=debian-armhf-cross
1641 container_cross_prefix
=arm-linux-gnueabihf-
1644 container_image
=fedora-cris-cross
1645 container_cross_prefix
=cris-linux-gnu-
1648 container_image
=debian-hexagon-cross
1649 container_cross_prefix
=hexagon-unknown-linux-musl-
1650 container_cross_cc
=${container_cross_prefix}clang
1653 container_image
=debian-hppa-cross
1654 container_cross_prefix
=hppa-linux-gnu-
1657 container_image
=fedora-i386-cross
1658 container_cross_prefix
=
1661 container_image
=debian-loongarch-cross
1662 container_cross_prefix
=loongarch64-unknown-linux-gnu-
1665 container_image
=debian-m68k-cross
1666 container_cross_prefix
=m68k-linux-gnu-
1669 container_image
=debian-microblaze-cross
1670 container_cross_prefix
=microblaze-linux-musl-
1673 container_image
=debian-mips64el-cross
1674 container_cross_prefix
=mips64el-linux-gnuabi64-
1677 container_image
=debian-mips64-cross
1678 container_cross_prefix
=mips64-linux-gnuabi64-
1681 container_image
=debian-mipsel-cross
1682 container_cross_prefix
=mipsel-linux-gnu-
1685 container_image
=debian-mips-cross
1686 container_cross_prefix
=mips-linux-gnu-
1689 container_image
=debian-nios2-cross
1690 container_cross_prefix
=nios2-linux-gnu-
1693 container_image
=debian-powerpc-test-cross
1694 container_cross_prefix
=powerpc-linux-gnu-
1695 container_cross_cc
=${container_cross_prefix}gcc-10
1698 container_image
=debian-powerpc-test-cross
1699 container_cross_prefix
=powerpc
${target_arch#ppc}-linux-gnu-
1700 container_cross_cc
=${container_cross_prefix}gcc-10
1703 container_image
=debian-riscv64-test-cross
1704 container_cross_prefix
=riscv64-linux-gnu-
1707 container_image
=debian-s390x-cross
1708 container_cross_prefix
=s390x-linux-gnu-
1711 container_image
=debian-sh4-cross
1712 container_cross_prefix
=sh4-linux-gnu-
1715 container_image
=debian-sparc64-cross
1716 container_cross_prefix
=sparc64-linux-gnu-
1719 container_image
=debian-tricore-cross
1720 container_cross_prefix
=tricore-
1721 container_cross_as
=tricore-as
1722 container_cross_ld
=tricore-ld
1726 container_image
=debian-amd64-cross
1727 container_cross_prefix
=x86_64-linux-gnu-
1730 container_hosts
=x86_64
1731 container_image
=debian-xtensa-cross
1733 # default to the dc232b cpu
1734 container_cross_prefix
=/opt
/2020.07/xtensa-dc232b-elf
/bin
/xtensa-dc232b-elf-
1737 : ${container_cross_cc:=${container_cross_prefix}gcc}
1738 : ${container_cross_ar:=${container_cross_prefix}ar}
1739 : ${container_cross_as:=${container_cross_prefix}as}
1740 : ${container_cross_ld:=${container_cross_prefix}ld}
1741 : ${container_cross_nm:=${container_cross_prefix}nm}
1742 : ${container_cross_objcopy:=${container_cross_prefix}objcopy}
1743 : ${container_cross_ranlib:=${container_cross_prefix}ranlib}
1744 : ${container_cross_strip:=${container_cross_prefix}strip}
1748 case "$target_arch:$cpu" in
1749 aarch64_be
:aarch64 | \
1756 try
='native cross' ;;
1758 eval "target_cflags=\${cross_cc_cflags_$target_arch}"
1759 for thistry
in $try; do
1768 target_objcopy
=$objcopy
1769 target_ranlib
=$ranlib
1774 if eval test -n "\"\${cross_cc_$target_arch}\""; then
1775 if eval has
"\"\${cross_cc_$target_arch}\""; then
1776 eval "target_cc=\"\${cross_cc_$target_arch}\""
1779 compute_target_variable
$target_arch target_cc gcc
1781 target_ccas
=$target_cc
1782 compute_target_variable
$target_arch target_ar
ar
1783 compute_target_variable
$target_arch target_as as
1784 compute_target_variable
$target_arch target_ld ld
1785 compute_target_variable
$target_arch target_nm nm
1786 compute_target_variable
$target_arch target_objcopy objcopy
1787 compute_target_variable
$target_arch target_ranlib ranlib
1788 compute_target_variable
$target_arch target_strip strip
1792 if test -n "$target_cc"; then
1793 case $target_arch in
1795 if $target_cc --version |
grep -qi "clang"; then
1800 elif test -n "$target_as" && test -n "$target_ld"; then
1801 # Special handling for assembler only targets
1819 if do_compiler
"$target_cc" $target_cflags -o $TMPO -c $TMPC &&
1820 do_compiler
"$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
1826 if do_compiler
"$target_cc" $target_cflags -o $TMPE $TMPC -static ; then
1831 if do_compiler
"$target_cc" $target_cflags -o $TMPE $TMPC ; then
1839 if test $got_cross_cc != yes; then
1851 test -n "$target_cc"
1854 write_target_makefile
() {
1855 echo "EXTRA_CFLAGS=$target_cflags"
1856 if test -z "$target_cc" && test -z "$target_as"; then
1857 test -z "$container_image" && error_exit
"Internal error: could not find cross compiler for $1?"
1858 echo "$1: docker-image-$container_image" >> Makefile.prereqs
1859 if test -n "$container_cross_cc"; then
1860 echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1861 echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1863 echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --"
1864 echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --"
1865 echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --"
1866 echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --"
1867 echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --"
1868 echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --"
1869 echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --"
1871 if test -n "$target_cc"; then
1872 echo "CC=$target_cc"
1873 echo "CCAS=$target_ccas"
1875 if test -n "$target_ar"; then
1876 echo "AR=$target_ar"
1878 if test -n "$target_as"; then
1879 echo "AS=$target_as"
1881 if test -n "$target_ld"; then
1882 echo "LD=$target_ld"
1884 if test -n "$target_nm"; then
1885 echo "NM=$target_nm"
1887 if test -n "$target_objcopy"; then
1888 echo "OBJCOPY=$target_objcopy"
1890 if test -n "$target_ranlib"; then
1891 echo "RANLIB=$target_ranlib"
1893 if test -n "$target_strip"; then
1894 echo "STRIP=$target_strip"
1899 ##########################################
1900 # check for vfio_user_server
1902 case "$vfio_user_server" in
1904 if test "$git_submodules_action" != "ignore"; then
1905 git_submodules
="${git_submodules} subprojects/libvfio-user"
1910 #######################################
1911 # cross-compiled firmware targets
1913 # Set up build tree symlinks that point back into the source tree
1914 # (these can be both files and directories).
1915 # Caution: avoid adding files or directories here using wildcards. This
1916 # will result in problems later if a new file matching the wildcard is
1917 # added to the source tree -- nothing will cause configure to be rerun
1918 # so the build tree will be missing the link back to the new file, and
1919 # tests might fail. Prefer to keep the relevant files in their own
1920 # directory and symlink the directory instead.
1922 LINKS
="$LINKS docs/config"
1923 LINKS
="$LINKS pc-bios/optionrom/Makefile"
1924 LINKS
="$LINKS pc-bios/s390-ccw/Makefile"
1925 LINKS
="$LINKS pc-bios/vof/Makefile"
1926 LINKS
="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
1927 LINKS
="$LINKS tests/avocado tests/data"
1928 LINKS
="$LINKS tests/qemu-iotests/check"
1929 LINKS
="$LINKS python"
1930 LINKS
="$LINKS contrib/plugins/Makefile "
1931 for f
in $LINKS ; do
1932 if [ -e "$source_path/$f" ]; then
1933 mkdir
-p "$(dirname ./"$f")"
1934 symlink
"$source_path/$f" "$f"
1938 echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
1940 # Mac OS X ships with a broken assembler
1942 if have_target i386-softmmu x86_64-softmmu
&& \
1943 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
1944 test "$targetos" != "haiku" && \
1945 probe_target_compiler i386-softmmu
; then
1946 roms
="pc-bios/optionrom"
1947 config_mak
=pc-bios
/optionrom
/config.mak
1948 echo "# Automatically generated by configure - do not modify" > $config_mak
1949 echo "TOPSRC_DIR=$source_path" >> $config_mak
1950 write_target_makefile
>> $config_mak
1953 if have_target ppc-softmmu ppc64-softmmu
&& \
1954 probe_target_compiler ppc-softmmu
; then
1955 roms
="$roms pc-bios/vof"
1956 config_mak
=pc-bios
/vof
/config.mak
1957 echo "# Automatically generated by configure - do not modify" > $config_mak
1958 echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
1959 write_target_makefile
>> $config_mak
1962 # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
1963 # (which is the lowest architecture level that Clang supports)
1964 if have_target s390x-softmmu
&& probe_target_compiler s390x-softmmu
; then
1966 do_compiler
"$target_cc" $target_cc_cflags -march=z900
-o $TMPO -c $TMPC
1968 if [ $has_z900 = 0 ] || do_compiler
"$target_cc" $target_cc_cflags -march=z10
-msoft-float -Werror -o $TMPO -c $TMPC; then
1969 if [ $has_z900 != 0 ]; then
1970 echo "WARNING: Your compiler does not support the z900!"
1971 echo " The s390-ccw bios will only work with guest CPUs >= z10."
1973 roms
="$roms pc-bios/s390-ccw"
1974 config_mak
=pc-bios
/s390-ccw
/config-host.mak
1975 echo "# Automatically generated by configure - do not modify" > $config_mak
1976 echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
1977 write_target_makefile
>> $config_mak
1978 # SLOF is required for building the s390-ccw firmware on s390x,
1979 # since it is using the libnet code from SLOF for network booting.
1980 git_submodules
="${git_submodules} roms/SLOF"
1984 #######################################
1985 # generate config-host.mak
1987 if ! (GIT
="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
1991 config_host_mak
="config-host.mak"
1993 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1994 echo >> $config_host_mak
1996 echo all
: >> $config_host_mak
1997 echo "GIT=$git" >> $config_host_mak
1998 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
1999 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
2001 if test "$debug_tcg" = "yes" ; then
2002 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
2004 if test "$mingw32" = "yes" ; then
2005 echo "CONFIG_WIN32=y" >> $config_host_mak
2006 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER-QEMU}" >> $config_host_mak
2007 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO-Linux}" >> $config_host_mak
2008 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION-$(cat "$source_path"/VERSION)}" >> $config_host_mak
2010 echo "CONFIG_POSIX=y" >> $config_host_mak
2013 if test "$linux" = "yes" ; then
2014 echo "CONFIG_LINUX=y" >> $config_host_mak
2017 if test "$darwin" = "yes" ; then
2018 echo "CONFIG_DARWIN=y" >> $config_host_mak
2021 if test "$solaris" = "yes" ; then
2022 echo "CONFIG_SOLARIS=y" >> $config_host_mak
2024 echo "SRC_PATH=$source_path" >> $config_host_mak
2025 echo "TARGET_DIRS=$target_list" >> $config_host_mak
2027 # XXX: suppress that
2028 if [ "$bsd" = "yes" ] ; then
2029 echo "CONFIG_BSD=y" >> $config_host_mak
2032 if test "$plugins" = "yes" ; then
2033 echo "CONFIG_PLUGIN=y" >> $config_host_mak
2036 if test -n "$gdb_bin"; then
2037 gdb_version
=$
($gdb_bin --version |
head -n 1)
2038 if version_ge
${gdb_version##* } 9.1; then
2039 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2040 gdb_arches
=$
("$source_path/scripts/probe-gdb-support.py" $gdb_bin)
2046 if test "$container" != no
; then
2047 echo "ENGINE=$container" >> $config_host_mak
2048 echo "RUNC=$runc" >> $config_host_mak
2050 echo "ROMS=$roms" >> $config_host_mak
2051 echo "MAKE=$make" >> $config_host_mak
2052 echo "PYTHON=$python" >> $config_host_mak
2053 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
2054 echo "MESON=$meson" >> $config_host_mak
2055 echo "NINJA=$ninja" >> $config_host_mak
2056 echo "PKG_CONFIG=${pkg_config}" >> $config_host_mak
2057 echo "CC=$cc" >> $config_host_mak
2058 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
2059 echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
2060 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
2061 echo "EXESUF=$EXESUF" >> $config_host_mak
2063 # use included Linux headers
2064 if test "$linux" = "yes" ; then
2065 mkdir
-p linux-headers
2080 linux_arch
=loongarch
2086 # For most CPUs the kernel architecture name and QEMU CPU name match.
2090 # For non-KVM architectures we will not have asm headers
2091 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
2092 symlink
"$source_path/linux-headers/asm-$linux_arch" linux-headers
/asm
2096 for target
in $target_list; do
2097 target_dir
="$target"
2098 target_name
=$
(echo $target | cut
-d '-' -f 1)$EXESUF
2099 mkdir
-p "$target_dir"
2101 *-user) symlink
"../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
2102 *) symlink
"../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
2106 if test "$default_targets" = "yes"; then
2107 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
2110 if test "$ccache_cpp2" = "yes"; then
2111 echo "export CCACHE_CPP2=y" >> $config_host_mak
2114 # tests/tcg configuration
2115 (config_host_mak
=tests
/tcg
/config-host.mak
2117 echo "# Automatically generated by configure - do not modify" > $config_host_mak
2118 echo "SRC_PATH=$source_path" >> $config_host_mak
2119 echo "HOST_CC=$host_cc" >> $config_host_mak
2121 # versioned checked in the main config_host.mak above
2122 if test -n "$gdb_bin"; then
2123 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
2125 if test "$plugins" = "yes" ; then
2126 echo "CONFIG_PLUGIN=y" >> $config_host_mak
2130 for target
in $target_list; do
2135 # the toolchain is not complete with headers, only build softmmu tests
2139 test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" ||
continue
2140 qemu
="qemu-system-$arch"
2142 *-linux-user|
*-bsd-user)
2147 if probe_target_compiler
$target ||
test -n "$container_image"; then
2148 test -n "$container_image" && build_static
=y
2149 mkdir
-p "tests/tcg/$target"
2150 config_target_mak
=tests
/tcg
/$target/config-target.mak
2151 ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile"
2152 echo "# Automatically generated by configure - do not modify" > "$config_target_mak"
2153 echo "TARGET_NAME=$arch" >> "$config_target_mak"
2154 echo "TARGET=$target" >> "$config_target_mak"
2155 write_target_makefile
"build-tcg-tests-$target" >> "$config_target_mak"
2156 echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
2157 echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
2159 # will GDB work with these binaries?
2160 if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
2161 echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak"
2164 echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
2165 tcg_tests_targets
="$tcg_tests_targets $target"
2169 if test "$tcg" = "enabled"; then
2170 echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
2174 if test "$skip_meson" = no
; then
2175 cross
="config-meson.cross.new"
2177 test $# = 0 && return
2178 echo "'$(echo $* | sed "s
/ /','/g
")'"
2181 echo "# Automatically generated by configure - do not modify" > $cross
2182 echo "[properties]" >> $cross
2184 # unroll any custom device configs
2185 for a
in $device_archs; do
2186 eval "c=\$devices_${a}"
2187 echo "${a}-softmmu = '$c'" >> $cross
2190 echo "[built-in options]" >> $cross
2191 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
2192 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
2193 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
2194 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
2195 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
2196 echo "[binaries]" >> $cross
2197 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
2198 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
2199 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
2200 echo "ar = [$(meson_quote $ar)]" >> $cross
2201 echo "nm = [$(meson_quote $nm)]" >> $cross
2202 echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
2203 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
2204 if has
$sdl2_config; then
2205 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
2207 echo "strip = [$(meson_quote $strip)]" >> $cross
2208 echo "widl = [$(meson_quote $widl)]" >> $cross
2209 echo "windres = [$(meson_quote $windres)]" >> $cross
2210 echo "windmc = [$(meson_quote $windmc)]" >> $cross
2211 if test "$cross_compile" = "yes"; then
2212 cross_arg
="--cross-file config-meson.cross"
2213 echo "[host_machine]" >> $cross
2214 echo "system = '$targetos'" >> $cross
2217 echo "cpu_family = 'x86'" >> $cross
2220 echo "cpu_family = '$cpu'" >> $cross
2223 echo "cpu = '$cpu'" >> $cross
2224 if test "$bigendian" = "yes" ; then
2225 echo "endian = 'big'" >> $cross
2227 echo "endian = 'little'" >> $cross
2230 cross_arg
="--native-file config-meson.cross"
2232 mv $cross config-meson.cross
2234 rm -rf meson-private meson-info meson-logs
2236 # Prevent meson from automatically downloading wrapped subprojects when missing.
2237 # You can use 'meson subprojects download' before running configure.
2238 meson_option_add
"--wrap-mode=nodownload"
2241 test "$bindir" != "bin" && meson_option_add
"-Dbindir=$bindir"
2242 test "$default_feature" = no
&& meson_option_add
-Dauto_features=disabled
2243 test "$static" = yes && meson_option_add
-Dprefer_static=true
2244 test "$pie" = no
&& meson_option_add
-Db_pie=false
2245 test "$werror" = yes && meson_option_add
-Dwerror=true
2248 test "$cfi" != false
&& meson_option_add
"-Dcfi=$cfi"
2249 test "$docs" != auto
&& meson_option_add
"-Ddocs=$docs"
2250 test "$fdt" != auto
&& meson_option_add
"-Dfdt=$fdt"
2251 test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add
"-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
2252 test "$qemu_suffix" != qemu
&& meson_option_add
"-Dqemu_suffix=$qemu_suffix"
2253 test "$smbd" != '' && meson_option_add
"-Dsmbd=$smbd"
2254 test "$tcg" != enabled
&& meson_option_add
"-Dtcg=$tcg"
2255 test "$vfio_user_server" != auto
&& meson_option_add
"-Dvfio_user_server=$vfio_user_server"
2257 NINJA
=$ninja $meson setup
--prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path"
2259 eval run_meson
$meson_options
2260 if test "$?" -ne 0 ; then
2261 error_exit
"meson setup failed"
2265 # Save the configure command line for later reuse.
2266 cat <<EOD >config.status
2268 # Generated by configure.
2269 # Run this file to recreate the current configuration.
2270 # Compiler output produced by configure, useful for debugging
2271 # configure, is in config.log if it exists.
2277 eval envval
=\$
$envname
2279 if test -n "$envval"
2281 echo "$envname='$envval'" >> config.status
2282 echo "export $envname" >> config.status
2284 echo "unset $envname" >> config.status
2288 # Preserve various env variables that influence what
2289 # features/build target configure will detect
2295 preserve_env CXXFLAGS
2297 preserve_env LDFLAGS
2298 preserve_env LD_LIBRARY_PATH
2301 preserve_env OBJCFLAGS
2302 preserve_env OBJCOPY
2304 preserve_env PKG_CONFIG
2305 preserve_env PKG_CONFIG_LIBDIR
2306 preserve_env PKG_CONFIG_PATH
2308 preserve_env QEMU_GA_MANUFACTURER
2309 preserve_env QEMU_GA_DISTRO
2310 preserve_env QEMU_GA_VERSION
2311 preserve_env SDL2_CONFIG
2315 preserve_env WINDRES
2318 printf "exec" >>config.status
2319 for i
in "$0" "$@"; do
2320 test "$i" = --skip-meson ||
printf " %s" "$(quote_sh "$i")" >>config.status
2322 echo ' "$@"' >>config.status
2323 chmod +x config.status