e1000e: Notify only new interrupts
[qemu/kevin.git] / configure
blob80ca1c922151ed0ac42ecc96d6540767020489d4
1 #!/bin/sh
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"
18 then
19 echo "Using './build' as the directory for build output"
21 MARKER=build/auto-created-by-configure
23 if test -e build
24 then
25 if test -f $MARKER
26 then
27 rm -rf build
28 else
29 echo "ERROR: ./build dir already exists and was not previously created by configure"
30 exit 1
34 if ! mkdir build || ! touch $MARKER
35 then
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."
38 exit 1
41 cat > GNUmakefile <<'EOF'
42 # This file is auto-generated by configure to support in-source tree
43 # 'make' command invocation
45 ifeq ($(MAKECMDGOALS),)
46 recurse: all
47 endif
49 .NOTPARALLEL: %
50 %: force
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 ; \
55 then \
56 rm -rf build GNUmakefile ; \
58 force: ;
59 .PHONY: force
60 GNUmakefile: ;
62 EOF
63 cd build
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.)
72 TMPDIR1="config-temp"
73 rm -rf "${TMPDIR1}"
74 if ! mkdir -p "${TMPDIR1}"; then
75 echo "ERROR: failed to create temporary directory"
76 exit 1
79 TMPB="qemu-conf"
80 TMPC="${TMPDIR1}/${TMPB}.c"
81 TMPO="${TMPDIR1}/${TMPB}.o"
82 TMPE="${TMPDIR1}/${TMPB}.exe"
84 rm -f config.log
86 # Print a helpful header at the top of config.log
87 echo "# QEMU configure log $(date)" >> config.log
88 printf "# Configured with:" >> config.log
89 # repeat the invocation to log and stdout for CI
90 invoke=$(printf " '%s'" "$0" "$@")
91 test -n "$GITLAB_CI" && echo "configuring with: $invoke"
92 { echo "$invoke"; echo; echo "#"; } >> config.log
94 quote_sh() {
95 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
98 print_error() {
99 (echo
100 echo "ERROR: $1"
101 while test -n "$2"; do
102 echo " $2"
103 shift
104 done
105 echo) >&2
108 error_exit() {
109 print_error "$@"
110 exit 1
113 do_compiler() {
114 # Run the compiler, capturing its output to the log. First argument
115 # is compiler binary to execute.
116 compiler="$1"
117 shift
118 if test -n "$BASH_VERSION"; then eval '
119 echo >>config.log "
120 funcs: ${FUNCNAME[*]}
121 lines: ${BASH_LINENO[*]}"
122 '; fi
123 echo $compiler "$@" >> config.log
124 $compiler "$@" >> config.log 2>&1 || return $?
127 do_cc() {
128 do_compiler "$cc" $CPU_CFLAGS "$@"
131 compile_object() {
132 local_cflags="$1"
133 do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC
136 compile_prog() {
137 local_cflags="$1"
138 local_ldflags="$2"
139 do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -o $TMPE $TMPC \
140 $LDFLAGS $EXTRA_LDFLAGS $local_ldflags
143 # symbolically link $1 to $2. Portable version of "ln -sf".
144 symlink() {
145 rm -rf "$2"
146 mkdir -p "$(dirname "$2")"
147 ln -s "$1" "$2"
150 # check whether a command is available to this shell (may be either an
151 # executable or a builtin)
152 has() {
153 type "$1" >/dev/null 2>&1
156 version_ge () {
157 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
158 local_ver2=$(echo "$2" | tr . ' ')
159 while true; do
160 set x $local_ver1
161 local_first=${2-0}
162 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
163 shift ${2:+2}
164 local_ver1=$*
165 set x $local_ver2
166 # the second argument finished, the first must be greater or equal
167 test $# = 1 && return 0
168 test $local_first -lt $2 && return 1
169 test $local_first -gt $2 && return 0
170 shift ${2:+2}
171 local_ver2=$*
172 done
175 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
176 then
177 error_exit "main directory cannot contain spaces nor colons"
180 # parse CC options first; some compiler tests are used to establish
181 # some defaults, based on the host environment
183 # default parameters
184 cpu=""
185 cross_compile="no"
186 cross_prefix=""
187 host_cc="cc"
188 EXTRA_CFLAGS=""
189 EXTRA_CXXFLAGS=""
190 EXTRA_OBJCFLAGS=""
191 EXTRA_LDFLAGS=""
193 # Default value for a variable defining feature "foo".
194 # * foo="no" feature will only be used if --enable-foo arg is given
195 # * foo="" feature will be searched for, and if found, will be used
196 # unless --disable-foo is given
197 # * foo="yes" this value will only be set by --enable-foo flag.
198 # feature will searched for,
199 # if not found, configure exits with error
201 # Always add --enable-foo and --disable-foo command line args.
202 # Distributions want to ensure that several features are compiled in, and it
203 # is impossible without a --enable-foo that exits if a feature is not found.
204 default_feature=""
206 for opt do
207 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
208 case "$opt" in
209 --cross-prefix=*) cross_prefix="$optarg"
210 cross_compile="yes"
212 --cc=*) CC="$optarg"
214 --cxx=*) CXX="$optarg"
216 --objcc=*) objcc="$optarg"
218 --cpu=*) cpu="$optarg"
220 --extra-cflags=*)
221 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
222 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
223 EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
225 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
227 --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
229 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
231 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
233 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
234 eval "cross_cc_cflags_${cc_arch}=\$optarg"
236 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
237 eval "cross_cc_${cc_arch}=\$optarg"
239 --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option"
241 --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*}
242 eval "cross_prefix_${cc_arch}=\$optarg"
244 --without-default-features) default_feature="no"
246 esac
247 done
250 if test -e "$source_path/.git"
251 then
252 git_submodules_action="update"
253 else
254 git_submodules_action="ignore"
257 git_submodules="ui/keycodemapdb"
258 git="git"
259 debug_tcg="no"
260 docs="auto"
261 EXESUF=""
262 prefix="/usr/local"
263 qemu_suffix="qemu"
264 softmmu="yes"
265 linux_user=""
266 bsd_user=""
267 plugins="$default_feature"
268 ninja=""
269 python=
270 pypi="enabled"
271 bindir="bin"
272 skip_meson=no
273 vfio_user_server="disabled"
274 use_containers="yes"
275 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
276 gdb_arches=""
277 werror=""
279 # Don't accept a target_list environment variable.
280 unset target_list
281 unset target_list_exclude
283 # The following Meson options are handled manually (still they
284 # are included in the automatically generated help message)
286 # 1. Track which submodules are needed
287 fdt="auto"
289 # 2. Automatically enable/disable other options
290 tcg="auto"
291 cfi="false"
293 # 3. Need to check for -static-pie before Meson runs. Also,
294 # Meson has PIE as a boolean rather than enabled/disabled/auto.
295 pie=""
296 static="no"
298 # Preferred compiler:
299 # ${CC} (if set)
300 # ${cross_prefix}gcc (if cross-prefix specified)
301 # system compiler
302 if test -z "${CC}${cross_prefix}"; then
303 cc="$host_cc"
304 else
305 cc="${CC-${cross_prefix}gcc}"
308 if test -z "${CXX}${cross_prefix}"; then
309 cxx="c++"
310 else
311 cxx="${CXX-${cross_prefix}g++}"
314 # Preferred ObjC compiler:
315 # $objcc (if set, i.e. via --objcc option)
316 # ${cross_prefix}clang (if cross-prefix specified)
317 # clang (if available)
318 # $cc
319 if test -z "${objcc}${cross_prefix}"; then
320 if has clang; then
321 objcc=clang
322 else
323 objcc="$cc"
325 else
326 objcc="${objcc-${cross_prefix}clang}"
329 ar="${AR-${cross_prefix}ar}"
330 as="${AS-${cross_prefix}as}"
331 ccas="${CCAS-$cc}"
332 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
333 ld="${LD-${cross_prefix}ld}"
334 ranlib="${RANLIB-${cross_prefix}ranlib}"
335 nm="${NM-${cross_prefix}nm}"
336 smbd="$SMBD"
337 strip="${STRIP-${cross_prefix}strip}"
338 widl="${WIDL-${cross_prefix}widl}"
339 windres="${WINDRES-${cross_prefix}windres}"
340 windmc="${WINDMC-${cross_prefix}windmc}"
341 pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
342 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
344 check_define() {
345 cat > $TMPC <<EOF
346 #if !defined($1)
347 #error $1 not defined
348 #endif
349 int main(void) { return 0; }
351 compile_object
354 write_c_skeleton() {
355 cat > $TMPC <<EOF
356 int main(void) { return 0; }
360 if check_define __linux__ ; then
361 targetos=linux
362 elif check_define _WIN32 ; then
363 targetos=windows
364 elif check_define __OpenBSD__ ; then
365 targetos=openbsd
366 elif check_define __sun__ ; then
367 targetos=sunos
368 elif check_define __HAIKU__ ; then
369 targetos=haiku
370 elif check_define __FreeBSD__ ; then
371 targetos=freebsd
372 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
373 targetos=gnu/kfreebsd
374 elif check_define __DragonFly__ ; then
375 targetos=dragonfly
376 elif check_define __NetBSD__; then
377 targetos=netbsd
378 elif check_define __APPLE__; then
379 targetos=darwin
380 else
381 # This is a fatal error, but don't report it yet, because we
382 # might be going to just print the --help text, or it might
383 # be the result of a missing compiler.
384 targetos=bogus
387 # OS specific
389 mingw32="no"
390 bsd="no"
391 linux="no"
392 solaris="no"
393 case $targetos in
394 windows)
395 mingw32="yes"
396 plugins="no"
397 pie="no"
399 gnu/kfreebsd)
400 bsd="yes"
402 freebsd)
403 bsd="yes"
404 make="${MAKE-gmake}"
405 # needed for kinfo_getvmmap(3) in libutil.h
407 dragonfly)
408 bsd="yes"
409 make="${MAKE-gmake}"
411 netbsd)
412 bsd="yes"
413 make="${MAKE-gmake}"
415 openbsd)
416 bsd="yes"
417 make="${MAKE-gmake}"
419 darwin)
420 bsd="yes"
421 darwin="yes"
423 sunos)
424 solaris="yes"
425 make="${MAKE-gmake}"
427 haiku)
428 pie="no"
430 linux)
431 linux="yes"
433 esac
435 if test ! -z "$cpu" ; then
436 # command line argument
438 elif check_define __i386__ ; then
439 cpu="i386"
440 elif check_define __x86_64__ ; then
441 if check_define __ILP32__ ; then
442 cpu="x32"
443 else
444 cpu="x86_64"
446 elif check_define __sparc__ ; then
447 if check_define __arch64__ ; then
448 cpu="sparc64"
449 else
450 cpu="sparc"
452 elif check_define _ARCH_PPC ; then
453 if check_define _ARCH_PPC64 ; then
454 if check_define _LITTLE_ENDIAN ; then
455 cpu="ppc64le"
456 else
457 cpu="ppc64"
459 else
460 cpu="ppc"
462 elif check_define __mips__ ; then
463 cpu="mips"
464 elif check_define __s390__ ; then
465 if check_define __s390x__ ; then
466 cpu="s390x"
467 else
468 cpu="s390"
470 elif check_define __riscv ; then
471 cpu="riscv"
472 elif check_define __arm__ ; then
473 cpu="arm"
474 elif check_define __aarch64__ ; then
475 cpu="aarch64"
476 elif check_define __loongarch64 ; then
477 cpu="loongarch64"
478 else
479 # Using uname is really broken, but it is just a fallback for architectures
480 # that are going to use TCI anyway
481 cpu=$(uname -m)
482 echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
485 # Normalise host CPU name and set multilib cflags. The canonicalization
486 # isn't really necessary, because the architectures that we check for
487 # should not hit the 'uname -m' case, but better safe than sorry.
488 # Note that this case should only have supported host CPUs, not guests.
489 case "$cpu" in
490 armv*b|armv*l|arm)
491 cpu="arm" ;;
493 i386|i486|i586|i686)
494 cpu="i386"
495 CPU_CFLAGS="-m32" ;;
496 x32)
497 cpu="x86_64"
498 CPU_CFLAGS="-mx32" ;;
499 x86_64|amd64)
500 cpu="x86_64"
501 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
502 # If we truly care, we should simply detect this case at
503 # runtime and generate the fallback to serial emulation.
504 CPU_CFLAGS="-m64 -mcx16" ;;
506 mips*)
507 cpu="mips" ;;
509 ppc)
510 CPU_CFLAGS="-m32" ;;
511 ppc64)
512 CPU_CFLAGS="-m64 -mbig-endian" ;;
513 ppc64le)
514 cpu="ppc64"
515 CPU_CFLAGS="-m64 -mlittle-endian" ;;
517 s390)
518 CPU_CFLAGS="-m31" ;;
519 s390x)
520 CPU_CFLAGS="-m64" ;;
522 sparc|sun4[cdmuv])
523 cpu="sparc"
524 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
525 sparc64)
526 CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
527 esac
529 : ${make=${MAKE-make}}
532 check_py_version() {
533 # We require python >= 3.7.
534 # NB: a True python conditional creates a non-zero return code (Failure)
535 "$1" -c 'import sys; sys.exit(sys.version_info < (3,7))'
538 first_python=
539 if test -z "${PYTHON}"; then
540 # A bare 'python' is traditionally python 2.x, but some distros
541 # have it as python 3.x, so check in both places.
542 for binary in python3 python python3.11 python3.10 python3.9 python3.8 python3.7; do
543 if has "$binary"; then
544 python=$(command -v "$binary")
545 if check_py_version "$python"; then
546 # This one is good.
547 first_python=
548 break
549 else
550 first_python=$python
553 done
554 else
555 # Same as above, but only check the environment variable.
556 has "${PYTHON}" || error_exit "The PYTHON environment variable does not point to an executable"
557 python=$(command -v "$PYTHON")
558 if check_py_version "$python"; then
559 # This one is good.
560 first_python=
561 else
562 first_python=$first_python
566 # Check for ancillary tools used in testing
567 genisoimage=
568 for binary in genisoimage mkisofs
570 if has $binary
571 then
572 genisoimage=$(command -v "$binary")
573 break
575 done
577 if test "$mingw32" = "yes" ; then
578 EXESUF=".exe"
579 prefix="/qemu"
580 bindir=""
581 qemu_suffix=""
584 meson_option_build_array() {
585 printf '['
586 (if test "$targetos" = windows; then
587 IFS=\;
588 else
589 IFS=:
591 for e in $1; do
592 printf '"""'
593 # backslash escape any '\' and '"' characters
594 printf "%s" "$e" | sed -e 's/\([\"]\)/\\\1/g'
595 printf '""",'
596 done)
597 printf ']\n'
600 . "$source_path/scripts/meson-buildoptions.sh"
602 meson_options=
603 meson_option_add() {
604 meson_options="$meson_options $(quote_sh "$1")"
606 meson_option_parse() {
607 meson_options="$meson_options $(_meson_option_parse "$@")"
608 if test $? -eq 1; then
609 echo "ERROR: unknown option $1"
610 echo "Try '$0 --help' for more information"
611 exit 1
615 for opt do
616 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
617 case "$opt" in
618 --help|-h) show_help=yes
620 --version|-V) exec cat "$source_path/VERSION"
622 --prefix=*) prefix="$optarg"
624 --cross-prefix=*)
626 --cc=*)
628 --host-cc=*) host_cc="$optarg"
630 --cxx=*)
632 --objcc=*)
634 --make=*) make="$optarg"
636 --install=*)
638 --python=*) python="$optarg"
640 --skip-meson) skip_meson=yes
642 --ninja=*) ninja="$optarg"
644 --smbd=*) smbd="$optarg"
646 --extra-cflags=*)
648 --extra-cxxflags=*)
650 --extra-objcflags=*)
652 --extra-ldflags=*)
654 --cross-cc-*)
656 --cross-prefix-*)
658 --enable-docs) docs=enabled
660 --disable-docs) docs=disabled
662 --cpu=*)
664 --target-list=*) target_list="$optarg"
665 if test "$target_list_exclude"; then
666 error_exit "Can't mix --target-list with --target-list-exclude"
669 --target-list-exclude=*) target_list_exclude="$optarg"
670 if test "$target_list"; then
671 error_exit "Can't mix --target-list-exclude with --target-list"
674 --with-default-devices) meson_option_add -Ddefault_devices=true
676 --without-default-devices) meson_option_add -Ddefault_devices=false
678 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
680 --with-devices-*) device_arch=${opt#--with-devices-};
681 device_arch=${device_arch%%=*}
682 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
683 if test -f "$cf"; then
684 device_archs="$device_archs $device_arch"
685 eval "devices_${device_arch}=\$optarg"
686 else
687 error_exit "File $cf does not exist"
690 --without-default-features) # processed above
692 --static) static="yes"
694 --bindir=*) bindir="$optarg"
696 --with-suffix=*) qemu_suffix="$optarg"
698 --host=*|--build=*|\
699 --disable-dependency-tracking|\
700 --sbindir=*|--sharedstatedir=*|\
701 --oldincludedir=*|--datarootdir=*|--infodir=*|\
702 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
703 # These switches are silently ignored, for compatibility with
704 # autoconf-generated configure scripts. This allows QEMU's
705 # configure to be used by RPM and similar macros that set
706 # lots of directory switches by default.
708 --enable-debug-tcg) debug_tcg="yes"
710 --disable-debug-tcg) debug_tcg="no"
712 --enable-debug)
713 # Enable debugging options that aren't excessively noisy
714 debug_tcg="yes"
715 meson_option_parse --enable-debug-graph-lock ""
716 meson_option_parse --enable-debug-mutex ""
717 meson_option_add -Doptimization=0
719 --disable-tcg) tcg="disabled"
720 plugins="no"
722 --enable-tcg) tcg="enabled"
724 --disable-system) softmmu="no"
726 --enable-system) softmmu="yes"
728 --disable-user)
729 linux_user="no" ;
730 bsd_user="no" ;
732 --enable-user) ;;
733 --disable-linux-user) linux_user="no"
735 --enable-linux-user) linux_user="yes"
737 --disable-bsd-user) bsd_user="no"
739 --enable-bsd-user) bsd_user="yes"
741 --enable-pie) pie="yes"
743 --disable-pie) pie="no"
745 --enable-werror) werror="yes"
747 --disable-werror) werror="no"
749 --enable-cfi)
750 cfi="true";
751 meson_option_add -Db_lto=true
753 --disable-cfi) cfi="false"
755 --disable-fdt) fdt="disabled"
757 --enable-fdt) fdt="enabled"
759 --enable-fdt=git) fdt="internal"
761 --enable-fdt=*) fdt="$optarg"
763 --with-git=*) git="$optarg"
765 --with-git-submodules=*)
766 git_submodules_action="$optarg"
768 --disable-pypi) pypi="disabled"
770 --enable-pypi) pypi="enabled"
772 --enable-plugins) if test "$mingw32" = "yes"; then
773 error_exit "TCG plugins not currently supported on Windows platforms"
774 else
775 plugins="yes"
778 --disable-plugins) plugins="no"
780 --enable-containers) use_containers="yes"
782 --disable-containers) use_containers="no"
784 --gdb=*) gdb_bin="$optarg"
786 --enable-vfio-user-server) vfio_user_server="enabled"
788 --disable-vfio-user-server) vfio_user_server="disabled"
790 # everything else has the same name in configure and meson
791 --*) meson_option_parse "$opt" "$optarg"
793 esac
794 done
796 # test for any invalid configuration combinations
797 if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
798 error_exit "Can't enable plugins on non-TCG builds"
801 case $git_submodules_action in
802 update|validate)
803 if test ! -e "$source_path/.git"; then
804 echo "ERROR: cannot $git_submodules_action git submodules without .git"
805 exit 1
808 ignore)
809 if ! test -f "$source_path/ui/keycodemapdb/README"
810 then
811 echo
812 echo "ERROR: missing GIT submodules"
813 echo
814 if test -e "$source_path/.git"; then
815 echo "--with-git-submodules=ignore specified but submodules were not"
816 echo "checked out. Please initialize and update submodules."
817 else
818 echo "This is not a GIT checkout but module content appears to"
819 echo "be missing. Do not use 'git archive' or GitHub download links"
820 echo "to acquire QEMU source archives. Non-GIT builds are only"
821 echo "supported with source archives linked from:"
822 echo
823 echo " https://www.qemu.org/download/#source"
824 echo
825 echo "Developers working with GIT can use scripts/archive-source.sh"
826 echo "if they need to create valid source archives."
828 echo
829 exit 1
833 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
834 exit 1
836 esac
838 default_target_list=""
839 mak_wilds=""
841 if [ "$linux_user" != no ]; then
842 if [ "$targetos" = linux ] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then
843 linux_user=yes
844 elif [ "$linux_user" = yes ]; then
845 error_exit "linux-user not supported on this architecture"
848 if [ "$bsd_user" != no ]; then
849 if [ "$bsd_user" = "" ]; then
850 test $targetos = freebsd && bsd_user=yes
852 if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
853 error_exit "bsd-user not supported on this host OS"
856 if [ "$softmmu" = "yes" ]; then
857 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
859 if [ "$linux_user" = "yes" ]; then
860 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
862 if [ "$bsd_user" = "yes" ]; then
863 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
866 for config in $mak_wilds; do
867 target="$(basename "$config" .mak)"
868 if echo "$target_list_exclude" | grep -vq "$target"; then
869 default_target_list="${default_target_list} $target"
871 done
873 if test x"$show_help" = x"yes" ; then
874 cat << EOF
876 Usage: configure [options]
877 Options: [defaults in brackets after descriptions]
879 Standard options:
880 --help print this message
881 --prefix=PREFIX install in PREFIX [$prefix]
882 --target-list=LIST set target list (default: build all)
883 $(echo Available targets: $default_target_list | \
884 fold -s -w 53 | sed -e 's/^/ /')
885 --target-list-exclude=LIST exclude a set of targets from the default target-list
887 Advanced options (experts only):
888 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
889 --cc=CC use C compiler CC [$cc]
890 --host-cc=CC use C compiler CC [$host_cc] for code run at
891 build time
892 --cxx=CXX use C++ compiler CXX [$cxx]
893 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
894 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
895 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
896 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
897 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
898 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
899 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
900 --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
901 --make=MAKE use specified make [$make]
902 --python=PYTHON use specified python [$python]
903 --ninja=NINJA use specified ninja [$ninja]
904 --smbd=SMBD use specified smbd [$smbd]
905 --with-git=GIT use specified git [$git]
906 --with-git-submodules=update update git submodules (default if .git dir exists)
907 --with-git-submodules=validate fail if git submodules are not up to date
908 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
909 --static enable static build [$static]
910 --bindir=PATH install binaries in PATH
911 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
912 --without-default-features default all --enable-* options to "disabled"
913 --without-default-devices do not include any device that is not needed to
914 start the emulator (only use if you are including
915 desired devices in configs/devices/)
916 --with-devices-ARCH=NAME override default configs/devices
917 --enable-debug enable common debug build options
918 --disable-werror disable compilation abort on warning
919 --cpu=CPU Build for host CPU [$cpu]
920 --enable-plugins
921 enable plugins via shared library loading
922 --disable-containers don't use containers for cross-building
923 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
925 meson_options_help
926 cat << EOF
927 system all system emulation targets
928 user supported user emulation targets
929 linux-user all linux usermode emulation targets
930 bsd-user all BSD usermode emulation targets
931 pie Position Independent Executables
932 debug-tcg TCG debugging (default is disabled)
934 NOTE: The object files are built at the place where configure is launched
936 exit 0
939 # Remove old dependency files to make sure that they get properly regenerated
940 rm -f ./*/config-devices.mak.d
942 if test -z "$python"
943 then
944 # If first_python is set, there was a binary somewhere even though
945 # it was not suitable. Use it for the error message.
946 if test -n "$first_python"; then
947 error_exit "Cannot use '$first_python', Python >= 3.7 is required." \
948 "Use --python=/path/to/python to specify a supported Python."
949 else
950 error_exit "Python not found. Use --python=/path/to/python"
954 if ! has "$make"
955 then
956 error_exit "GNU make ($make) not found"
959 if ! check_py_version "$python"; then
960 error_exit "Cannot use '$python', Python >= 3.7 is required." \
961 "Use --python=/path/to/python to specify a supported Python." \
962 "Maybe try:" \
963 " openSUSE Leap 15.3+: zypper install python39" \
964 " CentOS 8: dnf install python38"
967 # Resolve PATH
968 python="$(command -v "$python")"
970 # Create a Python virtual environment using our configured python.
971 # The stdout of this script will be the location of a symlink that
972 # points to the configured Python.
973 # Entry point scripts for pip, meson, and sphinx are generated if those
974 # packages are present.
976 # Defaults assumed for now:
977 # - venv is cleared if it exists already;
978 # - venv is allowed to use system packages;
979 # - all setup can be performed offline;
980 # - missing packages may be fetched from PyPI,
981 # unless --disable-pypi is passed.
982 # - pip is not installed into the venv when possible,
983 # but ensurepip is called as a fallback when necessary.
985 echo "python determined to be '$python'"
986 echo "python version: $($python --version)"
988 python="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)"
989 if test "$?" -ne 0 ; then
990 error_exit "python venv creation failed"
993 # Suppress writing compiled files
994 python="$python -B"
995 mkvenv="$python ${source_path}/python/scripts/mkvenv.py"
997 mkvenv_flags=""
998 if test "$pypi" = "enabled" ; then
999 mkvenv_flags="--online"
1002 if ! $mkvenv ensure \
1003 $mkvenv_flags \
1004 --dir "${source_path}/python/wheels" \
1005 --diagnose "meson" \
1006 "meson>=0.63.0" ;
1007 then
1008 exit 1
1011 # At this point, we expect Meson to be installed and available.
1012 # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
1013 # We ignore PATH completely here: we want to use the venv's Meson
1014 # *exclusively*.
1016 meson="$(cd pyvenv/bin; pwd)/meson"
1018 # Conditionally ensure Sphinx is installed.
1020 mkvenv_flags=""
1021 if test "$pypi" = "enabled" -a "$docs" = "enabled" ; then
1022 mkvenv_flags="--online"
1025 if test "$docs" != "disabled" ; then
1026 if ! $mkvenv ensure \
1027 $mkvenv_flags \
1028 --diagnose "sphinx-build" \
1029 "sphinx>=1.6.0" "sphinx-rtd-theme>=0.5.0";
1030 then
1031 if test "$docs" = "enabled" ; then
1032 exit 1
1034 echo "Sphinx not found/usable, disabling docs."
1035 docs=disabled
1036 else
1037 docs=enabled
1041 # Probe for ninja
1043 if test -z "$ninja"; then
1044 for c in ninja ninja-build samu; do
1045 if has $c; then
1046 ninja=$(command -v "$c")
1047 break
1049 done
1050 if test -z "$ninja"; then
1051 error_exit "Cannot find Ninja"
1055 # Consult white-list to determine whether to enable werror
1056 # by default. Only enable by default for git builds
1057 if test -z "$werror" ; then
1058 if test "$git_submodules_action" != "ignore" && \
1059 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
1060 werror="yes"
1061 else
1062 werror="no"
1066 if test "$targetos" = "bogus"; then
1067 # Now that we know that we're not printing the help and that
1068 # the compiler works (so the results of the check_defines we used
1069 # to identify the OS are reliable), if we didn't recognize the
1070 # host OS we should stop now.
1071 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1074 if test "$static" = "yes" ; then
1075 if test "$plugins" = "yes"; then
1076 error_exit "static and plugins are mutually incompatible"
1077 else
1078 plugins="no"
1081 test "$plugins" = "" && plugins=yes
1083 cat > $TMPC << EOF
1085 #ifdef __linux__
1086 # define THREAD __thread
1087 #else
1088 # define THREAD
1089 #endif
1090 static THREAD int tls_var;
1091 int main(void) { return tls_var; }
1094 if test "$static" = "yes"; then
1095 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
1096 pie="yes"
1097 elif test "$pie" = "yes"; then
1098 error_exit "-static-pie not available due to missing toolchain support"
1099 else
1100 pie="no"
1102 elif test "$pie" != "no"; then
1103 if compile_prog "-Werror -fPIE -DPIE" "-pie"; then
1104 pie="yes"
1105 elif test "$pie" = "yes"; then
1106 error_exit "PIE not available due to missing toolchain support"
1107 else
1108 echo "Disabling PIE due to missing toolchain support"
1109 pie="no"
1113 ##########################################
1115 if test -z "${target_list+xxx}" ; then
1116 default_targets=yes
1117 for target in $default_target_list; do
1118 target_list="$target_list $target"
1119 done
1120 target_list="${target_list# }"
1121 else
1122 default_targets=no
1123 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1124 for target in $target_list; do
1125 # Check that we recognised the target name; this allows a more
1126 # friendly error message than if we let it fall through.
1127 case " $default_target_list " in
1128 *" $target "*)
1131 error_exit "Unknown target name '$target'"
1133 esac
1134 done
1137 # see if system emulation was really requested
1138 case " $target_list " in
1139 *"-softmmu "*) softmmu=yes
1141 *) softmmu=no
1143 esac
1145 if test "$tcg" = "auto"; then
1146 if test -z "$target_list"; then
1147 tcg="disabled"
1148 else
1149 tcg="enabled"
1153 if test "$tcg" = "enabled"; then
1154 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
1155 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
1158 ##########################################
1159 # big/little endian test
1160 cat > $TMPC << EOF
1161 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1162 # error LITTLE
1163 #endif
1164 int main(void) { return 0; }
1167 if ! compile_prog ; then
1168 bigendian="no"
1169 else
1170 cat > $TMPC << EOF
1171 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1172 # error BIG
1173 #endif
1174 int main(void) { return 0; }
1177 if ! compile_prog ; then
1178 bigendian="yes"
1179 else
1180 echo big/little test failed
1181 exit 1
1185 ##########################################
1186 # fdt probe
1188 case "$fdt" in
1189 auto | enabled | internal)
1190 # Simpler to always update submodule, even if not needed.
1191 git_submodules="${git_submodules} dtc"
1193 esac
1195 ########################################
1196 # check if ccache is interfering with
1197 # semantic analysis of macros
1199 unset CCACHE_CPP2
1200 ccache_cpp2=no
1201 cat > $TMPC << EOF
1202 static const int Z = 1;
1203 #define fn() ({ Z; })
1204 #define TAUT(X) ((X) == Z)
1205 #define PAREN(X, Y) (X == Y)
1206 #define ID(X) (X)
1207 int main(void)
1209 int x = 0, y = 0;
1210 x = ID(x);
1211 x = fn();
1212 fn();
1213 if (PAREN(x, y)) return 0;
1214 if (TAUT(Z)) return 0;
1215 return 0;
1219 if ! compile_object "-Werror"; then
1220 ccache_cpp2=yes
1223 ##########################################
1224 # functions to probe cross compilers
1226 container="no"
1227 runc=""
1228 if test $use_containers = "yes" && (has "docker" || has "podman"); then
1229 case $($python "$source_path"/tests/docker/docker.py probe) in
1230 *docker) container=docker ;;
1231 podman) container=podman ;;
1232 no) container=no ;;
1233 esac
1234 if test "$container" != "no"; then
1235 docker_py="$python $source_path/tests/docker/docker.py --engine $container"
1236 runc=$($python "$source_path"/tests/docker/docker.py probe)
1240 # cross compilers defaults, can be overridden with --cross-cc-ARCH
1241 : ${cross_prefix_aarch64="aarch64-linux-gnu-"}
1242 : ${cross_prefix_aarch64_be="$cross_prefix_aarch64"}
1243 : ${cross_prefix_alpha="alpha-linux-gnu-"}
1244 : ${cross_prefix_arm="arm-linux-gnueabihf-"}
1245 : ${cross_prefix_armeb="$cross_prefix_arm"}
1246 : ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"}
1247 : ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"}
1248 : ${cross_prefix_hppa="hppa-linux-gnu-"}
1249 : ${cross_prefix_i386="i686-linux-gnu-"}
1250 : ${cross_prefix_m68k="m68k-linux-gnu-"}
1251 : ${cross_prefix_microblaze="microblaze-linux-musl-"}
1252 : ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"}
1253 : ${cross_prefix_mips64="mips64-linux-gnuabi64-"}
1254 : ${cross_prefix_mipsel="mipsel-linux-gnu-"}
1255 : ${cross_prefix_mips="mips-linux-gnu-"}
1256 : ${cross_prefix_nios2="nios2-linux-gnu-"}
1257 : ${cross_prefix_ppc="powerpc-linux-gnu-"}
1258 : ${cross_prefix_ppc64="powerpc64-linux-gnu-"}
1259 : ${cross_prefix_ppc64le="$cross_prefix_ppc64"}
1260 : ${cross_prefix_riscv64="riscv64-linux-gnu-"}
1261 : ${cross_prefix_s390x="s390x-linux-gnu-"}
1262 : ${cross_prefix_sh4="sh4-linux-gnu-"}
1263 : ${cross_prefix_sparc64="sparc64-linux-gnu-"}
1264 : ${cross_prefix_sparc="$cross_prefix_sparc64"}
1265 : ${cross_prefix_x86_64="x86_64-linux-gnu-"}
1267 : ${cross_cc_aarch64_be="$cross_cc_aarch64"}
1268 : ${cross_cc_cflags_aarch64_be="-mbig-endian"}
1269 : ${cross_cc_armeb="$cross_cc_arm"}
1270 : ${cross_cc_cflags_armeb="-mbig-endian"}
1271 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
1272 : ${cross_cc_cflags_hexagon="-mv73 -O2 -static"}
1273 : ${cross_cc_cflags_i386="-m32"}
1274 : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
1275 : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
1276 : ${cross_cc_ppc64le="$cross_cc_ppc64"}
1277 : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
1278 : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
1279 : ${cross_cc_sparc="$cross_cc_sparc64"}
1280 : ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
1281 : ${cross_cc_cflags_x86_64="-m64"}
1283 compute_target_variable() {
1284 eval "$2="
1285 if eval test -n "\"\${cross_prefix_$1}\""; then
1286 if eval has "\"\${cross_prefix_$1}\$3\""; then
1287 eval "$2=\"\${cross_prefix_$1}\$3\""
1292 have_target() {
1293 for i; do
1294 case " $target_list " in
1295 *" $i "*) return 0;;
1296 *) ;;
1297 esac
1298 done
1299 return 1
1302 # probe_target_compiler TARGET
1304 # Look for a compiler for the given target, either native or cross.
1305 # Set variables target_* if a compiler is found, and container_cross_*
1306 # if a Docker-based cross-compiler image is known for the target.
1307 # Set got_cross_cc to yes/no depending on whether a non-container-based
1308 # compiler was found.
1310 # If TARGET is a user-mode emulation target, also set build_static to
1311 # "y" if static linking is possible.
1313 probe_target_compiler() {
1314 # reset all output variables
1315 got_cross_cc=no
1316 container_image=
1317 container_hosts=
1318 container_cross_cc=
1319 container_cross_ar=
1320 container_cross_as=
1321 container_cross_ld=
1322 container_cross_nm=
1323 container_cross_objcopy=
1324 container_cross_ranlib=
1325 container_cross_strip=
1327 target_arch=${1%%-*}
1328 case $target_arch in
1329 aarch64) container_hosts="x86_64 aarch64" ;;
1330 alpha) container_hosts=x86_64 ;;
1331 arm) container_hosts="x86_64 aarch64" ;;
1332 cris) container_hosts=x86_64 ;;
1333 hexagon) container_hosts=x86_64 ;;
1334 hppa) container_hosts=x86_64 ;;
1335 i386) container_hosts=x86_64 ;;
1336 loongarch64) container_hosts=x86_64 ;;
1337 m68k) container_hosts=x86_64 ;;
1338 microblaze) container_hosts=x86_64 ;;
1339 mips64el) container_hosts=x86_64 ;;
1340 mips64) container_hosts=x86_64 ;;
1341 mipsel) container_hosts=x86_64 ;;
1342 mips) container_hosts=x86_64 ;;
1343 nios2) container_hosts=x86_64 ;;
1344 ppc) container_hosts=x86_64 ;;
1345 ppc64|ppc64le) container_hosts=x86_64 ;;
1346 riscv64) container_hosts=x86_64 ;;
1347 s390x) container_hosts=x86_64 ;;
1348 sh4) container_hosts=x86_64 ;;
1349 sparc64) container_hosts=x86_64 ;;
1350 tricore) container_hosts=x86_64 ;;
1351 x86_64) container_hosts="aarch64 ppc64el x86_64" ;;
1352 xtensa*) container_hosts=x86_64 ;;
1353 esac
1355 for host in $container_hosts; do
1356 test "$container" != no || continue
1357 test "$host" = "$cpu" || continue
1358 case $target_arch in
1359 aarch64)
1360 # We don't have any bigendian build tools so we only use this for AArch64
1361 container_image=debian-arm64-cross
1362 container_cross_prefix=aarch64-linux-gnu-
1363 container_cross_cc=${container_cross_prefix}gcc-10
1365 alpha)
1366 container_image=debian-alpha-cross
1367 container_cross_prefix=alpha-linux-gnu-
1369 arm)
1370 # We don't have any bigendian build tools so we only use this for ARM
1371 container_image=debian-armhf-cross
1372 container_cross_prefix=arm-linux-gnueabihf-
1374 cris)
1375 container_image=fedora-cris-cross
1376 container_cross_prefix=cris-linux-gnu-
1378 hexagon)
1379 container_image=debian-hexagon-cross
1380 container_cross_prefix=hexagon-unknown-linux-musl-
1381 container_cross_cc=${container_cross_prefix}clang
1383 hppa)
1384 container_image=debian-hppa-cross
1385 container_cross_prefix=hppa-linux-gnu-
1387 i386)
1388 container_image=fedora-i386-cross
1389 container_cross_prefix=
1391 loongarch64)
1392 container_image=debian-loongarch-cross
1393 container_cross_prefix=loongarch64-unknown-linux-gnu-
1395 m68k)
1396 container_image=debian-m68k-cross
1397 container_cross_prefix=m68k-linux-gnu-
1399 microblaze)
1400 container_image=debian-microblaze-cross
1401 container_cross_prefix=microblaze-linux-musl-
1403 mips64el)
1404 container_image=debian-mips64el-cross
1405 container_cross_prefix=mips64el-linux-gnuabi64-
1407 mips64)
1408 container_image=debian-mips64-cross
1409 container_cross_prefix=mips64-linux-gnuabi64-
1411 mipsel)
1412 container_image=debian-mipsel-cross
1413 container_cross_prefix=mipsel-linux-gnu-
1415 mips)
1416 container_image=debian-mips-cross
1417 container_cross_prefix=mips-linux-gnu-
1419 nios2)
1420 container_image=debian-nios2-cross
1421 container_cross_prefix=nios2-linux-gnu-
1423 ppc)
1424 container_image=debian-powerpc-test-cross
1425 container_cross_prefix=powerpc-linux-gnu-
1426 container_cross_cc=${container_cross_prefix}gcc-10
1428 ppc64|ppc64le)
1429 container_image=debian-powerpc-test-cross
1430 container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu-
1431 container_cross_cc=${container_cross_prefix}gcc-10
1433 riscv64)
1434 container_image=debian-riscv64-test-cross
1435 container_cross_prefix=riscv64-linux-gnu-
1437 s390x)
1438 container_image=debian-s390x-cross
1439 container_cross_prefix=s390x-linux-gnu-
1441 sh4)
1442 container_image=debian-sh4-cross
1443 container_cross_prefix=sh4-linux-gnu-
1445 sparc64)
1446 container_image=debian-sparc64-cross
1447 container_cross_prefix=sparc64-linux-gnu-
1449 tricore)
1450 container_image=debian-tricore-cross
1451 container_cross_prefix=tricore-
1452 container_cross_as=tricore-as
1453 container_cross_ld=tricore-ld
1454 break
1456 x86_64)
1457 container_image=debian-amd64-cross
1458 container_cross_prefix=x86_64-linux-gnu-
1460 xtensa*)
1461 container_hosts=x86_64
1462 container_image=debian-xtensa-cross
1464 # default to the dc232b cpu
1465 container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-
1467 esac
1468 : ${container_cross_cc:=${container_cross_prefix}gcc}
1469 : ${container_cross_ar:=${container_cross_prefix}ar}
1470 : ${container_cross_as:=${container_cross_prefix}as}
1471 : ${container_cross_ld:=${container_cross_prefix}ld}
1472 : ${container_cross_nm:=${container_cross_prefix}nm}
1473 : ${container_cross_objcopy:=${container_cross_prefix}objcopy}
1474 : ${container_cross_ranlib:=${container_cross_prefix}ranlib}
1475 : ${container_cross_strip:=${container_cross_prefix}strip}
1476 done
1478 try=cross
1479 case "$target_arch:$cpu" in
1480 aarch64_be:aarch64 | \
1481 armeb:arm | \
1482 i386:x86_64 | \
1483 mips*:mips64 | \
1484 ppc*:ppc64 | \
1485 sparc:sparc64 | \
1486 "$cpu:$cpu")
1487 try='native cross' ;;
1488 esac
1489 eval "target_cflags=\${cross_cc_cflags_$target_arch}"
1490 for thistry in $try; do
1491 case $thistry in
1492 native)
1493 target_cc=$cc
1494 target_ccas=$ccas
1495 target_ar=$ar
1496 target_as=$as
1497 target_ld=$ld
1498 target_nm=$nm
1499 target_objcopy=$objcopy
1500 target_ranlib=$ranlib
1501 target_strip=$strip
1503 cross)
1504 target_cc=
1505 if eval test -n "\"\${cross_cc_$target_arch}\""; then
1506 if eval has "\"\${cross_cc_$target_arch}\""; then
1507 eval "target_cc=\"\${cross_cc_$target_arch}\""
1509 else
1510 compute_target_variable $target_arch target_cc gcc
1512 target_ccas=$target_cc
1513 compute_target_variable $target_arch target_ar ar
1514 compute_target_variable $target_arch target_as as
1515 compute_target_variable $target_arch target_ld ld
1516 compute_target_variable $target_arch target_nm nm
1517 compute_target_variable $target_arch target_objcopy objcopy
1518 compute_target_variable $target_arch target_ranlib ranlib
1519 compute_target_variable $target_arch target_strip strip
1521 esac
1523 if test -n "$target_cc"; then
1524 case $target_arch in
1525 i386|x86_64)
1526 if $target_cc --version | grep -qi "clang"; then
1527 continue
1530 esac
1531 elif test -n "$target_as" && test -n "$target_ld"; then
1532 # Special handling for assembler only targets
1533 case $target in
1534 tricore-softmmu)
1535 build_static=
1536 got_cross_cc=yes
1537 break
1540 continue
1542 esac
1543 else
1544 continue
1547 write_c_skeleton
1548 case $1 in
1549 *-softmmu)
1550 if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC &&
1551 do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
1552 got_cross_cc=yes
1553 break
1557 if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then
1558 build_static=y
1559 got_cross_cc=yes
1560 break
1562 if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then
1563 build_static=
1564 got_cross_cc=yes
1565 break
1568 esac
1569 done
1570 if test $got_cross_cc != yes; then
1571 build_static=
1572 target_cc=
1573 target_ccas=
1574 target_ar=
1575 target_as=
1576 target_ld=
1577 target_nm=
1578 target_objcopy=
1579 target_ranlib=
1580 target_strip=
1582 test -n "$target_cc"
1585 write_target_makefile() {
1586 echo "EXTRA_CFLAGS=$target_cflags"
1587 if test -z "$target_cc" && test -z "$target_as"; then
1588 test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?"
1589 echo "$1: docker-image-$container_image" >> Makefile.prereqs
1590 if test -n "$container_cross_cc"; then
1591 echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1592 echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1594 echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --"
1595 echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --"
1596 echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --"
1597 echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --"
1598 echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --"
1599 echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --"
1600 echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --"
1601 else
1602 if test -n "$target_cc"; then
1603 echo "CC=$target_cc"
1604 echo "CCAS=$target_ccas"
1606 if test -n "$target_ar"; then
1607 echo "AR=$target_ar"
1609 if test -n "$target_as"; then
1610 echo "AS=$target_as"
1612 if test -n "$target_ld"; then
1613 echo "LD=$target_ld"
1615 if test -n "$target_nm"; then
1616 echo "NM=$target_nm"
1618 if test -n "$target_objcopy"; then
1619 echo "OBJCOPY=$target_objcopy"
1621 if test -n "$target_ranlib"; then
1622 echo "RANLIB=$target_ranlib"
1624 if test -n "$target_strip"; then
1625 echo "STRIP=$target_strip"
1630 ##########################################
1631 # check for vfio_user_server
1633 case "$vfio_user_server" in
1634 enabled )
1635 if test "$git_submodules_action" != "ignore"; then
1636 git_submodules="${git_submodules} subprojects/libvfio-user"
1639 esac
1641 #######################################
1642 # cross-compiled firmware targets
1644 # Set up build tree symlinks that point back into the source tree
1645 # (these can be both files and directories).
1646 # Caution: avoid adding files or directories here using wildcards. This
1647 # will result in problems later if a new file matching the wildcard is
1648 # added to the source tree -- nothing will cause configure to be rerun
1649 # so the build tree will be missing the link back to the new file, and
1650 # tests might fail. Prefer to keep the relevant files in their own
1651 # directory and symlink the directory instead.
1652 LINKS="Makefile"
1653 LINKS="$LINKS docs/config"
1654 LINKS="$LINKS pc-bios/optionrom/Makefile"
1655 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
1656 LINKS="$LINKS pc-bios/vof/Makefile"
1657 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
1658 LINKS="$LINKS tests/avocado tests/data"
1659 LINKS="$LINKS tests/qemu-iotests/check"
1660 LINKS="$LINKS python"
1661 LINKS="$LINKS contrib/plugins/Makefile "
1662 for f in $LINKS ; do
1663 if [ -e "$source_path/$f" ]; then
1664 symlink "$source_path/$f" "$f"
1666 done
1668 echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
1670 # Mac OS X ships with a broken assembler
1671 roms=
1672 if have_target i386-softmmu x86_64-softmmu && \
1673 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
1674 test "$targetos" != "haiku" && \
1675 probe_target_compiler i386-softmmu; then
1676 roms="pc-bios/optionrom"
1677 config_mak=pc-bios/optionrom/config.mak
1678 echo "# Automatically generated by configure - do not modify" > $config_mak
1679 echo "TOPSRC_DIR=$source_path" >> $config_mak
1680 write_target_makefile >> $config_mak
1683 if have_target ppc-softmmu ppc64-softmmu && \
1684 probe_target_compiler ppc-softmmu; then
1685 roms="$roms pc-bios/vof"
1686 config_mak=pc-bios/vof/config.mak
1687 echo "# Automatically generated by configure - do not modify" > $config_mak
1688 echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
1689 write_target_makefile >> $config_mak
1692 # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
1693 # (which is the lowest architecture level that Clang supports)
1694 if have_target s390x-softmmu && probe_target_compiler s390x-softmmu; then
1695 write_c_skeleton
1696 do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC
1697 has_z900=$?
1698 if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then
1699 if [ $has_z900 != 0 ]; then
1700 echo "WARNING: Your compiler does not support the z900!"
1701 echo " The s390-ccw bios will only work with guest CPUs >= z10."
1703 roms="$roms pc-bios/s390-ccw"
1704 config_mak=pc-bios/s390-ccw/config-host.mak
1705 echo "# Automatically generated by configure - do not modify" > $config_mak
1706 echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
1707 write_target_makefile >> $config_mak
1708 # SLOF is required for building the s390-ccw firmware on s390x,
1709 # since it is using the libnet code from SLOF for network booting.
1710 git_submodules="${git_submodules} roms/SLOF"
1714 #######################################
1715 # generate config-host.mak
1717 if ! (GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
1718 exit 1
1721 config_host_mak="config-host.mak"
1723 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1724 echo >> $config_host_mak
1726 echo all: >> $config_host_mak
1727 echo "GIT=$git" >> $config_host_mak
1728 echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
1729 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
1731 if test "$debug_tcg" = "yes" ; then
1732 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
1734 if test "$mingw32" = "yes" ; then
1735 echo "CONFIG_WIN32=y" >> $config_host_mak
1736 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER-QEMU}" >> $config_host_mak
1737 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO-Linux}" >> $config_host_mak
1738 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION-$(cat "$source_path"/VERSION)}" >> $config_host_mak
1739 else
1740 echo "CONFIG_POSIX=y" >> $config_host_mak
1743 if test "$linux" = "yes" ; then
1744 echo "CONFIG_LINUX=y" >> $config_host_mak
1747 if test "$darwin" = "yes" ; then
1748 echo "CONFIG_DARWIN=y" >> $config_host_mak
1751 if test "$solaris" = "yes" ; then
1752 echo "CONFIG_SOLARIS=y" >> $config_host_mak
1754 echo "SRC_PATH=$source_path" >> $config_host_mak
1755 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1757 # XXX: suppress that
1758 if [ "$bsd" = "yes" ] ; then
1759 echo "CONFIG_BSD=y" >> $config_host_mak
1762 if test "$plugins" = "yes" ; then
1763 echo "CONFIG_PLUGIN=y" >> $config_host_mak
1766 if test -n "$gdb_bin"; then
1767 gdb_version=$($gdb_bin --version | head -n 1)
1768 if version_ge ${gdb_version##* } 9.1; then
1769 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
1770 gdb_arches=$($python "$source_path/scripts/probe-gdb-support.py" $gdb_bin)
1771 else
1772 gdb_bin=""
1776 if test "$container" != no; then
1777 echo "ENGINE=$container" >> $config_host_mak
1778 echo "RUNC=$runc" >> $config_host_mak
1780 echo "ROMS=$roms" >> $config_host_mak
1781 echo "MAKE=$make" >> $config_host_mak
1782 echo "PYTHON=$python" >> $config_host_mak
1783 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
1784 echo "MESON=$meson" >> $config_host_mak
1785 echo "NINJA=$ninja" >> $config_host_mak
1786 echo "PKG_CONFIG=${pkg_config}" >> $config_host_mak
1787 echo "CC=$cc" >> $config_host_mak
1788 echo "EXESUF=$EXESUF" >> $config_host_mak
1790 # use included Linux headers
1791 if test "$linux" = "yes" ; then
1792 mkdir -p linux-headers
1793 case "$cpu" in
1794 i386|x86_64)
1795 linux_arch=x86
1797 ppc|ppc64)
1798 linux_arch=powerpc
1800 s390x)
1801 linux_arch=s390
1803 aarch64)
1804 linux_arch=arm64
1806 loongarch*)
1807 linux_arch=loongarch
1809 mips64)
1810 linux_arch=mips
1813 # For most CPUs the kernel architecture name and QEMU CPU name match.
1814 linux_arch="$cpu"
1816 esac
1817 # For non-KVM architectures we will not have asm headers
1818 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
1819 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
1823 for target in $target_list; do
1824 target_dir="$target"
1825 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
1826 mkdir -p "$target_dir"
1827 case $target in
1828 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
1829 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
1830 esac
1831 done
1833 if test "$default_targets" = "yes"; then
1834 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
1837 if test "$ccache_cpp2" = "yes"; then
1838 echo "export CCACHE_CPP2=y" >> $config_host_mak
1841 # tests/tcg configuration
1842 (config_host_mak=tests/tcg/config-host.mak
1843 mkdir -p tests/tcg
1844 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1845 echo "SRC_PATH=$source_path" >> $config_host_mak
1846 echo "HOST_CC=$host_cc" >> $config_host_mak
1848 # versioned checked in the main config_host.mak above
1849 if test -n "$gdb_bin"; then
1850 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
1852 if test "$plugins" = "yes" ; then
1853 echo "CONFIG_PLUGIN=y" >> $config_host_mak
1856 tcg_tests_targets=
1857 for target in $target_list; do
1858 arch=${target%%-*}
1860 case $target in
1861 xtensa*-linux-user)
1862 # the toolchain is not complete with headers, only build softmmu tests
1863 continue
1865 *-softmmu)
1866 test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue
1867 qemu="qemu-system-$arch"
1869 *-linux-user|*-bsd-user)
1870 qemu="qemu-$arch"
1872 esac
1874 if probe_target_compiler $target || test -n "$container_image"; then
1875 test -n "$container_image" && build_static=y
1876 mkdir -p "tests/tcg/$target"
1877 config_target_mak=tests/tcg/$target/config-target.mak
1878 ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile"
1879 echo "# Automatically generated by configure - do not modify" > "$config_target_mak"
1880 echo "TARGET_NAME=$arch" >> "$config_target_mak"
1881 echo "TARGET=$target" >> "$config_target_mak"
1882 write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak"
1883 echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
1884 echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
1886 # will GDB work with these binaries?
1887 if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
1888 echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak"
1891 echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
1892 tcg_tests_targets="$tcg_tests_targets $target"
1894 done
1896 if test "$tcg" = "enabled"; then
1897 echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
1901 if test "$skip_meson" = no; then
1902 cross="config-meson.cross.new"
1903 meson_quote() {
1904 test $# = 0 && return
1905 echo "'$(echo $* | sed "s/ /','/g")'"
1908 echo "# Automatically generated by configure - do not modify" > $cross
1909 echo "[properties]" >> $cross
1911 # unroll any custom device configs
1912 for a in $device_archs; do
1913 eval "c=\$devices_${a}"
1914 echo "${a}-softmmu = '$c'" >> $cross
1915 done
1917 echo "[built-in options]" >> $cross
1918 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
1919 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
1920 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
1921 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
1922 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
1923 echo "[binaries]" >> $cross
1924 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
1925 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
1926 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
1927 echo "ar = [$(meson_quote $ar)]" >> $cross
1928 echo "nm = [$(meson_quote $nm)]" >> $cross
1929 echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
1930 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
1931 if has $sdl2_config; then
1932 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
1934 echo "strip = [$(meson_quote $strip)]" >> $cross
1935 echo "widl = [$(meson_quote $widl)]" >> $cross
1936 echo "windres = [$(meson_quote $windres)]" >> $cross
1937 echo "windmc = [$(meson_quote $windmc)]" >> $cross
1938 if test "$cross_compile" = "yes"; then
1939 cross_arg="--cross-file config-meson.cross"
1940 echo "[host_machine]" >> $cross
1941 echo "system = '$targetos'" >> $cross
1942 case "$cpu" in
1943 i386)
1944 echo "cpu_family = 'x86'" >> $cross
1947 echo "cpu_family = '$cpu'" >> $cross
1949 esac
1950 echo "cpu = '$cpu'" >> $cross
1951 if test "$bigendian" = "yes" ; then
1952 echo "endian = 'big'" >> $cross
1953 else
1954 echo "endian = 'little'" >> $cross
1956 else
1957 cross_arg="--native-file config-meson.cross"
1959 mv $cross config-meson.cross
1961 rm -rf meson-private meson-info meson-logs
1963 # Prevent meson from automatically downloading wrapped subprojects when missing.
1964 # You can use 'meson subprojects download' before running configure.
1965 meson_option_add "--wrap-mode=nodownload"
1967 # Built-in options
1968 test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir"
1969 test "$default_feature" = no && meson_option_add -Dauto_features=disabled
1970 test "$static" = yes && meson_option_add -Dprefer_static=true
1971 test "$pie" = no && meson_option_add -Db_pie=false
1972 test "$werror" = yes && meson_option_add -Dwerror=true
1974 # QEMU options
1975 test "$cfi" != false && meson_option_add "-Dcfi=$cfi"
1976 test "$docs" != auto && meson_option_add "-Ddocs=$docs"
1977 test "$fdt" != auto && meson_option_add "-Dfdt=$fdt"
1978 test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
1979 test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix"
1980 test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd"
1981 test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg"
1982 test "$vfio_user_server" != auto && meson_option_add "-Dvfio_user_server=$vfio_user_server"
1983 run_meson() {
1984 NINJA=$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path"
1986 eval run_meson $meson_options
1987 if test "$?" -ne 0 ; then
1988 error_exit "meson setup failed"
1990 else
1991 if test -f meson-private/cmd_line.txt; then
1992 # Adjust old command line options that were removed
1993 # sed -i is not portable
1994 perl -i -ne '
1995 /^sphinx_build/ && next;
1996 print;' meson-private/cmd_line.txt
2000 # Save the configure command line for later reuse.
2001 cat <<EOD >config.status
2002 #!/bin/sh
2003 # Generated by configure.
2004 # Run this file to recreate the current configuration.
2005 # Compiler output produced by configure, useful for debugging
2006 # configure, is in config.log if it exists.
2009 preserve_env() {
2010 envname=$1
2012 eval envval=\$$envname
2014 if test -n "$envval"
2015 then
2016 echo "$envname='$envval'" >> config.status
2017 echo "export $envname" >> config.status
2018 else
2019 echo "unset $envname" >> config.status
2023 # Preserve various env variables that influence what
2024 # features/build target configure will detect
2025 preserve_env AR
2026 preserve_env AS
2027 preserve_env CC
2028 preserve_env CFLAGS
2029 preserve_env CXX
2030 preserve_env CXXFLAGS
2031 preserve_env LD
2032 preserve_env LDFLAGS
2033 preserve_env LD_LIBRARY_PATH
2034 preserve_env MAKE
2035 preserve_env NM
2036 preserve_env OBJCFLAGS
2037 preserve_env OBJCOPY
2038 preserve_env PATH
2039 preserve_env PKG_CONFIG
2040 preserve_env PKG_CONFIG_LIBDIR
2041 preserve_env PKG_CONFIG_PATH
2042 preserve_env PYTHON
2043 preserve_env QEMU_GA_MANUFACTURER
2044 preserve_env QEMU_GA_DISTRO
2045 preserve_env QEMU_GA_VERSION
2046 preserve_env SDL2_CONFIG
2047 preserve_env SMBD
2048 preserve_env STRIP
2049 preserve_env WIDL
2050 preserve_env WINDRES
2051 preserve_env WINDMC
2053 printf "exec" >>config.status
2054 for i in "$0" "$@"; do
2055 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
2056 done
2057 echo ' "$@"' >>config.status
2058 chmod +x config.status
2060 rm -r "$TMPDIR1"