docs/system/arm/emulation.rst: spelling fix: Enhacements
[qemu/armbru.git] / configure
blobabcb199aa87d233fffb34166372b1e9c827df753
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. Unlike autoconf, we assume that unset exists.
8 unset CLICOLOR_FORCE GREP_OPTIONS BASH_ENV ENV MAIL MAILPATH CDPATH
10 # Don't allow CCACHE, if present, to use cached results of compile tests!
11 export CCACHE_RECACHE=yes
13 # make source path absolute
14 source_path=$(cd "$(dirname -- "$0")"; pwd)
16 if test "$PWD" = "$source_path"
17 then
18 echo "Using './build' as the directory for build output"
20 MARKER=build/auto-created-by-configure
22 if test -e build
23 then
24 if test -f $MARKER
25 then
26 rm -rf build
27 else
28 echo "ERROR: ./build dir already exists and was not previously created by configure"
29 exit 1
33 if ! mkdir build || ! touch $MARKER
34 then
35 echo "ERROR: Could not create ./build directory. Check the permissions on"
36 echo "your source directory, or try doing an out-of-tree build."
37 exit 1
40 cat > GNUmakefile <<'EOF'
41 # This file is auto-generated by configure to support in-source tree
42 # 'make' command invocation
44 ifeq ($(MAKECMDGOALS),)
45 recurse: all
46 endif
48 .NOTPARALLEL: %
49 %: force
50 @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
51 @$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
52 @if test "$(MAKECMDGOALS)" = "distclean" && \
53 test -e build/auto-created-by-configure ; \
54 then \
55 rm -rf build GNUmakefile ; \
57 force: ;
58 .PHONY: force
59 GNUmakefile: ;
61 EOF
62 cd build
63 exec "$source_path/configure" "$@"
66 # Temporary directory used for files created while
67 # configure runs. Since it is in the build directory
68 # we can safely blow away any previous version of it
69 # (and we need not jump through hoops to try to delete
70 # it when configure exits.)
71 TMPDIR1="config-temp"
72 rm -rf "${TMPDIR1}"
73 if ! mkdir -p "${TMPDIR1}"; then
74 echo "ERROR: failed to create temporary directory"
75 exit 1
78 TMPB="qemu-conf"
79 TMPC="${TMPDIR1}/${TMPB}.c"
80 TMPO="${TMPDIR1}/${TMPB}.o"
81 TMPE="${TMPDIR1}/${TMPB}.exe"
83 rm -f config.log
85 # Print a helpful header at the top of config.log
86 echo "# QEMU configure log $(date)" >> config.log
87 printf "# Configured with:" >> config.log
88 # repeat the invocation to log and stdout for CI
89 invoke=$(printf " '%s'" "$0" "$@")
90 test -n "$GITLAB_CI" && echo "configuring with: $invoke"
91 { echo "$invoke"; echo; echo "#"; } >> config.log
93 quote_sh() {
94 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
97 error_exit() {
98 (echo
99 echo "ERROR: $1"
100 while test -n "$2"; do
101 echo " $2"
102 shift
103 done
104 echo) >&2
105 exit 1
108 do_compiler() {
109 # Run the compiler, capturing its output to the log. First argument
110 # is compiler binary to execute.
111 compiler="$1"
112 shift
113 if test -n "$BASH_VERSION"; then eval '
114 echo >>config.log "
115 funcs: ${FUNCNAME[*]}
116 lines: ${BASH_LINENO[*]}"
117 '; fi
118 echo $compiler "$@" >> config.log
119 $compiler "$@" >> config.log 2>&1 || return $?
122 do_cc() {
123 do_compiler "$cc" $CPU_CFLAGS "$@"
126 compile_object() {
127 local_cflags="$1"
128 do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC
131 compile_prog() {
132 local_cflags="$1"
133 local_ldflags="$2"
134 do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -o $TMPE $TMPC \
135 $LDFLAGS $EXTRA_LDFLAGS $local_ldflags
138 # symbolically link $1 to $2. Portable version of "ln -sf".
139 symlink() {
140 rm -rf "$2"
141 mkdir -p "$(dirname "$2")"
142 ln -s "$1" "$2"
145 # check whether a command is available to this shell (may be either an
146 # executable or a builtin)
147 has() {
148 type "$1" >/dev/null 2>&1
151 version_ge () {
152 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
153 local_ver2=$(echo "$2" | tr . ' ')
154 while true; do
155 set x $local_ver1
156 local_first=${2-0}
157 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
158 shift ${2:+2}
159 local_ver1=$*
160 set x $local_ver2
161 # the second argument finished, the first must be greater or equal
162 test $# = 1 && return 0
163 test $local_first -lt $2 && return 1
164 test $local_first -gt $2 && return 0
165 shift ${2:+2}
166 local_ver2=$*
167 done
170 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
171 then
172 error_exit "main directory cannot contain spaces nor colons"
175 # parse CC options first; some compiler tests are used to establish
176 # some defaults, based on the host environment
178 # default parameters
179 container_engine="auto"
180 cpu=""
181 cross_compile="no"
182 cross_prefix=""
183 host_cc="cc"
184 EXTRA_CFLAGS=""
185 EXTRA_CXXFLAGS=""
186 EXTRA_OBJCFLAGS=""
187 EXTRA_LDFLAGS=""
189 # Default value for a variable defining feature "foo".
190 # * foo="no" feature will only be used if --enable-foo arg is given
191 # * foo="" feature will be searched for, and if found, will be used
192 # unless --disable-foo is given
193 # * foo="yes" this value will only be set by --enable-foo flag.
194 # feature will searched for,
195 # if not found, configure exits with error
197 # Always add --enable-foo and --disable-foo command line args.
198 # Distributions want to ensure that several features are compiled in, and it
199 # is impossible without a --enable-foo that exits if a feature is not found.
200 default_feature=""
202 for opt do
203 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
204 case "$opt" in
205 --cross-prefix=*) cross_prefix="$optarg"
206 cross_compile="yes"
208 --cc=*) CC="$optarg"
210 --cxx=*) CXX="$optarg"
212 --objcc=*) objcc="$optarg"
214 --cpu=*) cpu="$optarg"
216 --extra-cflags=*)
217 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
218 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
219 EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
221 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
223 --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
225 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
227 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
229 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
230 eval "cross_cc_cflags_${cc_arch}=\$optarg"
232 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
233 eval "cross_cc_${cc_arch}=\$optarg"
235 --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option"
237 --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*}
238 eval "cross_prefix_${cc_arch}=\$optarg"
240 --without-default-features) default_feature="no"
242 esac
243 done
245 default_cflags='-O2 -g'
246 git_submodules_action="update"
247 docs="auto"
248 EXESUF=""
249 system="yes"
250 linux_user=""
251 bsd_user=""
252 plugins="$default_feature"
253 subdirs=""
254 ninja=""
255 python=
256 download="enabled"
257 skip_meson=no
258 use_containers="yes"
259 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
260 gdb_arches=""
262 # Don't accept a target_list environment variable.
263 unset target_list
264 unset target_list_exclude
266 # The following Meson options are handled manually (still they
267 # are included in the automatically generated help message)
268 # because they automatically enable/disable other options
269 tcg="auto"
270 cfi="false"
272 # Meson has PIE as a boolean rather than enabled/disabled/auto,
273 # and we also need to check for -static-pie before Meson runs
274 # which requires knowing whether --static is enabled.
275 pie=""
276 static="no"
278 # Preferred compiler:
279 # ${CC} (if set)
280 # ${cross_prefix}gcc (if cross-prefix specified)
281 # system compiler
282 if test -z "${CC}${cross_prefix}"; then
283 cc="cc"
284 else
285 cc="${CC-${cross_prefix}gcc}"
288 if test -z "${CXX}${cross_prefix}"; then
289 cxx="c++"
290 else
291 cxx="${CXX-${cross_prefix}g++}"
294 # Preferred ObjC compiler:
295 # $objcc (if set, i.e. via --objcc option)
296 # ${cross_prefix}clang (if cross-prefix specified)
297 # clang (if available)
298 # $cc
299 if test -z "${objcc}${cross_prefix}"; then
300 if has clang; then
301 objcc=clang
302 else
303 objcc="$cc"
305 else
306 objcc="${objcc-${cross_prefix}clang}"
309 ar="${AR-${cross_prefix}ar}"
310 as="${AS-${cross_prefix}as}"
311 ccas="${CCAS-$cc}"
312 dlltool="${DLLTOOL-${cross_prefix}dlltool}"
313 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
314 ld="${LD-${cross_prefix}ld}"
315 ranlib="${RANLIB-${cross_prefix}ranlib}"
316 nm="${NM-${cross_prefix}nm}"
317 strip="${STRIP-${cross_prefix}strip}"
318 widl="${WIDL-${cross_prefix}widl}"
319 windres="${WINDRES-${cross_prefix}windres}"
320 windmc="${WINDMC-${cross_prefix}windmc}"
321 pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
322 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
324 check_define() {
325 cat > $TMPC <<EOF
326 #if !defined($1)
327 #error $1 not defined
328 #endif
329 int main(void) { return 0; }
331 compile_object
334 write_c_skeleton() {
335 cat > $TMPC <<EOF
336 int main(void) { return 0; }
340 if check_define __linux__ ; then
341 targetos=linux
342 elif check_define _WIN32 ; then
343 targetos=windows
344 elif check_define __OpenBSD__ ; then
345 targetos=openbsd
346 elif check_define __sun__ ; then
347 targetos=sunos
348 elif check_define __HAIKU__ ; then
349 targetos=haiku
350 elif check_define __FreeBSD__ ; then
351 targetos=freebsd
352 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
353 targetos=gnu/kfreebsd
354 elif check_define __DragonFly__ ; then
355 targetos=dragonfly
356 elif check_define __NetBSD__; then
357 targetos=netbsd
358 elif check_define __APPLE__; then
359 targetos=darwin
360 else
361 # This is a fatal error, but don't report it yet, because we
362 # might be going to just print the --help text, or it might
363 # be the result of a missing compiler.
364 targetos=bogus
367 if test ! -z "$cpu" ; then
368 # command line argument
370 elif check_define __i386__ ; then
371 cpu="i386"
372 elif check_define __x86_64__ ; then
373 if check_define __ILP32__ ; then
374 cpu="x32"
375 else
376 cpu="x86_64"
378 elif check_define __sparc__ ; then
379 if check_define __arch64__ ; then
380 cpu="sparc64"
381 else
382 cpu="sparc"
384 elif check_define _ARCH_PPC ; then
385 if check_define _ARCH_PPC64 ; then
386 if check_define _LITTLE_ENDIAN ; then
387 cpu="ppc64le"
388 else
389 cpu="ppc64"
391 else
392 cpu="ppc"
394 elif check_define __mips__ ; then
395 cpu="mips"
396 elif check_define __s390__ ; then
397 if check_define __s390x__ ; then
398 cpu="s390x"
399 else
400 cpu="s390"
402 elif check_define __riscv ; then
403 if check_define _LP64 ; then
404 cpu="riscv64"
405 else
406 cpu="riscv32"
408 elif check_define __arm__ ; then
409 cpu="arm"
410 elif check_define __aarch64__ ; then
411 cpu="aarch64"
412 elif check_define __loongarch64 ; then
413 cpu="loongarch64"
414 else
415 # Using uname is really broken, but it is just a fallback for architectures
416 # that are going to use TCI anyway
417 cpu=$(uname -m)
418 echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
421 # Normalise host CPU name to the values used by Meson cross files and in source
422 # directories, and set multilib cflags. The canonicalization isn't really
423 # necessary, because the architectures that we check for should not hit the
424 # 'uname -m' case, but better safe than sorry in case --cpu= is used.
426 # Note that this case should only have supported host CPUs, not guests.
427 # Please keep it sorted and synchronized with meson.build's host_arch.
428 host_arch=
429 linux_arch=
430 case "$cpu" in
431 aarch64)
432 host_arch=aarch64
433 linux_arch=arm64
436 armv*b|armv*l|arm)
437 cpu=arm
438 host_arch=arm
439 linux_arch=arm
442 i386|i486|i586|i686)
443 cpu="i386"
444 host_arch=i386
445 linux_arch=x86
446 CPU_CFLAGS="-m32"
449 loongarch*)
450 cpu=loongarch64
451 host_arch=loongarch64
454 mips64*)
455 cpu=mips64
456 host_arch=mips
457 linux_arch=mips
459 mips*)
460 cpu=mips
461 host_arch=mips
462 linux_arch=mips
465 ppc)
466 host_arch=ppc
467 linux_arch=powerpc
468 CPU_CFLAGS="-m32"
470 ppc64)
471 host_arch=ppc64
472 linux_arch=powerpc
473 CPU_CFLAGS="-m64 -mbig-endian"
475 ppc64le)
476 cpu=ppc64
477 host_arch=ppc64
478 linux_arch=powerpc
479 CPU_CFLAGS="-m64 -mlittle-endian"
482 riscv32 | riscv64)
483 host_arch=riscv
484 linux_arch=riscv
487 s390)
488 linux_arch=s390
489 CPU_CFLAGS="-m31"
491 s390x)
492 host_arch=s390x
493 linux_arch=s390
494 CPU_CFLAGS="-m64"
497 sparc|sun4[cdmuv])
498 cpu=sparc
499 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
501 sparc64)
502 host_arch=sparc64
503 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
506 x32)
507 cpu="x86_64"
508 host_arch=x86_64
509 linux_arch=x86
510 CPU_CFLAGS="-mx32"
512 x86_64|amd64)
513 cpu="x86_64"
514 host_arch=x86_64
515 linux_arch=x86
516 # ??? Only extremely old AMD cpus do not have cmpxchg16b.
517 # If we truly care, we should simply detect this case at
518 # runtime and generate the fallback to serial emulation.
519 CPU_CFLAGS="-m64 -mcx16"
521 esac
523 if test -n "$host_arch" && {
524 ! test -d "$source_path/linux-user/include/host/$host_arch" ||
525 ! test -d "$source_path/common-user/host/$host_arch"; }; then
526 error_exit "linux-user/include/host/$host_arch does not exist." \
527 "This is a bug in the configure script, please report it."
529 if test -n "$linux_arch" && ! test -d "$source_path/linux-headers/asm-$linux_arch"; then
530 error_exit "linux-headers/asm-$linux_arch does not exist." \
531 "This is a bug in the configure script, please report it."
534 check_py_version() {
535 # We require python >= 3.8.
536 # NB: a True python conditional creates a non-zero return code (Failure)
537 "$1" -c 'import sys; sys.exit(sys.version_info < (3,8))'
540 first_python=
541 if test -z "${PYTHON}"; then
542 # A bare 'python' is traditionally python 2.x, but some distros
543 # have it as python 3.x, so check in both places.
544 for binary in python3 python python3.12 python3.11 \
545 python3.10 python3.9 python3.8; do
546 if has "$binary"; then
547 python=$(command -v "$binary")
548 if check_py_version "$python"; then
549 # This one is good.
550 first_python=
551 break
552 else
553 first_python=$python
556 done
557 else
558 # Same as above, but only check the environment variable.
559 has "${PYTHON}" || error_exit "The PYTHON environment variable does not point to an executable"
560 python=$(command -v "$PYTHON")
561 if check_py_version "$python"; then
562 # This one is good.
563 first_python=
564 else
565 first_python=$first_python
569 # Check for ancillary tools used in testing
570 genisoimage=
571 for binary in genisoimage mkisofs
573 if has $binary
574 then
575 genisoimage=$(command -v "$binary")
576 break
578 done
580 if test "$targetos" = "windows" ; then
581 EXESUF=".exe"
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 local arg
605 for arg; do
606 meson_options="$meson_options $(quote_sh "$arg")"
607 done
609 meson_option_parse() {
610 meson_options="$meson_options $(_meson_option_parse "$@")"
611 if test $? -eq 1; then
612 echo "ERROR: unknown option $1"
613 echo "Try '$0 --help' for more information"
614 exit 1
618 meson_add_machine_file() {
619 if test "$cross_compile" = "yes"; then
620 meson_option_add --cross-file "$1"
621 else
622 meson_option_add --native-file "$1"
626 for opt do
627 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
628 case "$opt" in
629 --help|-h) show_help=yes
631 --version|-V) exec cat "$source_path/VERSION"
633 --cross-prefix=*)
635 --cc=*)
637 --host-cc=*) host_cc="$optarg"
639 --cxx=*)
641 --objcc=*)
643 --make=*)
645 --install=*)
647 --python=*) python="$optarg"
649 --skip-meson) skip_meson=yes
651 --ninja=*) ninja="$optarg"
653 --extra-cflags=*)
655 --extra-cxxflags=*)
657 --extra-objcflags=*)
659 --extra-ldflags=*)
661 --cross-cc-*)
663 --cross-prefix-*)
665 --enable-docs) docs=enabled
667 --disable-docs) docs=disabled
669 --cpu=*)
671 --target-list=*) target_list="$optarg"
672 if test "$target_list_exclude"; then
673 error_exit "Can't mix --target-list with --target-list-exclude"
676 --target-list-exclude=*) target_list_exclude="$optarg"
677 if test "$target_list"; then
678 error_exit "Can't mix --target-list-exclude with --target-list"
681 --with-default-devices) meson_option_add -Ddefault_devices=true
683 --without-default-devices) meson_option_add -Ddefault_devices=false
685 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
687 --with-devices-*) device_arch=${opt#--with-devices-};
688 device_arch=${device_arch%%=*}
689 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
690 if test -f "$cf"; then
691 device_archs="$device_archs $device_arch"
692 eval "devices_${device_arch}=\$optarg"
693 else
694 error_exit "File $cf does not exist"
697 --without-default-features) # processed above
699 --static) static="yes"
701 --host=*|--build=*|\
702 --disable-dependency-tracking|\
703 --sbindir=*|--sharedstatedir=*|\
704 --oldincludedir=*|--datarootdir=*|--infodir=*|\
705 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
706 # These switches are silently ignored, for compatibility with
707 # autoconf-generated configure scripts. This allows QEMU's
708 # configure to be used by RPM and similar macros that set
709 # lots of directory switches by default.
711 --enable-debug)
712 # Enable debugging options that aren't excessively noisy
713 meson_option_parse --enable-debug-tcg ""
714 meson_option_parse --enable-debug-graph-lock ""
715 meson_option_parse --enable-debug-mutex ""
716 meson_option_add -Doptimization=0
717 default_cflags='-O0 -g'
719 --disable-tcg) tcg="disabled"
721 --enable-tcg) tcg="enabled"
723 --disable-system) system="no"
725 --enable-system) system="yes"
727 --disable-user)
728 linux_user="no" ;
729 bsd_user="no" ;
731 --enable-user) ;;
732 --disable-linux-user) linux_user="no"
734 --enable-linux-user) linux_user="yes"
736 --disable-bsd-user) bsd_user="no"
738 --enable-bsd-user) bsd_user="yes"
740 --enable-pie) pie="yes"
742 --disable-pie) pie="no"
744 --enable-cfi) cfi=true
746 --disable-cfi) cfi=false
748 --disable-download) download="disabled"; git_submodules_action=validate;
750 --enable-download) download="enabled"; git_submodules_action=update;
752 --enable-plugins) plugins="yes"
754 --disable-plugins) plugins="no"
756 --enable-containers) use_containers="yes"
758 --disable-containers) use_containers="no"
760 --container-engine=*) container_engine="$optarg"
762 --gdb=*) gdb_bin="$optarg"
764 # everything else has the same name in configure and meson
765 --*) meson_option_parse "$opt" "$optarg"
767 # Pass through -Dxxxx options to meson
768 -D*) meson_options="$meson_options $opt"
770 esac
771 done
773 if ! test -e "$source_path/.git"
774 then
775 git_submodules_action="validate"
778 if ! test -f "$source_path/subprojects/keycodemapdb/README" \
779 && test "$download" = disabled
780 then
781 echo
782 echo "ERROR: missing subprojects"
783 echo
784 if test -e "$source_path/.git"; then
785 echo "--disable-download specified but subprojects were not"
786 echo 'checked out. Please invoke "meson subprojects download"'
787 echo "before configuring QEMU, or remove --disable-download"
788 echo "from the command line."
789 else
790 echo "This is not a GIT checkout but subproject content appears to"
791 echo "be missing. Do not use 'git archive' or GitHub download links"
792 echo "to acquire QEMU source archives. Non-GIT builds are only"
793 echo "supported with source archives linked from:"
794 echo
795 echo " https://www.qemu.org/download/#source"
796 echo
797 echo "Developers working with GIT can use scripts/archive-source.sh"
798 echo "if they need to create valid source archives."
800 echo
801 exit 1
804 default_target_list=""
805 mak_wilds=""
807 if [ -n "$host_arch" ] && [ -d "$source_path/common-user/host/$host_arch" ]; then
808 if [ "$linux_user" != no ]; then
809 if [ "$targetos" = linux ]; then
810 linux_user=yes
811 elif [ "$linux_user" = yes ]; then
812 error_exit "linux-user not supported on this architecture"
814 if [ "$linux_user" = "yes" ]; then
815 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
818 if [ "$bsd_user" != no ]; then
819 if [ "$bsd_user" = "" ]; then
820 test $targetos = freebsd && bsd_user=yes
822 if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
823 error_exit "bsd-user not supported on this host OS"
825 if [ "$bsd_user" = "yes" ]; then
826 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
829 else
830 if [ "$linux_user" = yes ] || [ "$bsd_user" = yes ]; then
831 error_exit "user mode emulation not supported on this architecture"
834 if [ "$system" = "yes" ]; then
835 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
838 for config in $mak_wilds; do
839 target="$(basename "$config" .mak)"
840 if echo "$target_list_exclude" | grep -vq "$target"; then
841 default_target_list="${default_target_list} $target"
843 done
845 if test x"$show_help" = x"yes" ; then
846 cat << EOF
848 Usage: configure [options]
849 Options: [defaults in brackets after descriptions]
851 Standard options:
852 --help print this message
853 --target-list=LIST set target list (default: build all)
854 $(echo Available targets: $default_target_list | \
855 fold -s -w 53 | sed -e 's/^/ /')
856 --target-list-exclude=LIST exclude a set of targets from the default target-list
858 Advanced options (experts only):
859 -Dmesonoptname=val passthrough option to meson unmodified
860 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
861 --cc=CC use C compiler CC [$cc]
862 --host-cc=CC when cross compiling, use C compiler CC for code run
863 at build time [$host_cc]
864 --cxx=CXX use C++ compiler CXX [$cxx]
865 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
866 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
867 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
868 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
869 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
870 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
871 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
872 --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
873 --python=PYTHON use specified python [$python]
874 --ninja=NINJA use specified ninja [$ninja]
875 --static enable static build [$static]
876 --without-default-features default all --enable-* options to "disabled"
877 --without-default-devices do not include any device that is not needed to
878 start the emulator (only use if you are including
879 desired devices in configs/devices/)
880 --with-devices-ARCH=NAME override default configs/devices
881 --enable-debug enable common debug build options
882 --cpu=CPU Build for host CPU [$cpu]
883 --disable-containers don't use containers for cross-building
884 --container-engine=TYPE which container engine to use [$container_engine]
885 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
887 meson_options_help
888 cat << EOF
889 system all system emulation targets
890 user supported user emulation targets
891 linux-user all linux usermode emulation targets
892 bsd-user all BSD usermode emulation targets
893 pie Position Independent Executables
895 NOTE: The object files are built at the place where configure is launched
897 exit 0
900 # Remove old dependency files to make sure that they get properly regenerated
901 rm -f ./*/config-devices.mak.d
903 if test -z "$python"
904 then
905 # If first_python is set, there was a binary somewhere even though
906 # it was not suitable. Use it for the error message.
907 if test -n "$first_python"; then
908 error_exit "Cannot use '$first_python', Python >= 3.8 is required." \
909 "Use --python=/path/to/python to specify a supported Python."
910 else
911 error_exit "Python not found. Use --python=/path/to/python"
915 if ! check_py_version "$python"; then
916 error_exit "Cannot use '$python', Python >= 3.8 is required." \
917 "Use --python=/path/to/python to specify a supported Python." \
918 "Maybe try:" \
919 " openSUSE Leap 15.3+: zypper install python39" \
920 " CentOS 8: dnf install python38"
923 # Resolve PATH
924 python="$(command -v "$python")"
926 # Create a Python virtual environment using our configured python.
927 # The stdout of this script will be the location of a symlink that
928 # points to the configured Python.
929 # Entry point scripts for pip, meson, and sphinx are generated if those
930 # packages are present.
932 # Defaults assumed for now:
933 # - venv is cleared if it exists already;
934 # - venv is allowed to use system packages;
935 # - all setup can be performed offline;
936 # - missing packages may be fetched from PyPI,
937 # unless --disable-download is passed.
938 # - pip is not installed into the venv when possible,
939 # but ensurepip is called as a fallback when necessary.
941 echo "python determined to be '$python'"
942 echo "python version: $($python --version)"
944 python="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)"
945 if test "$?" -ne 0 ; then
946 error_exit "python venv creation failed"
949 # Suppress writing compiled files
950 python="$python -B"
951 mkvenv="$python ${source_path}/python/scripts/mkvenv.py"
953 # Finish preparing the virtual environment using vendored .whl files
955 if $python -c 'import sys; sys.exit(sys.version_info >= (3,11))'; then
956 $mkvenv ensure --dir "${source_path}/python/wheels" \
957 'tomli>=1.2.0' || exit 1
959 $mkvenv ensuregroup --dir "${source_path}/python/wheels" \
960 ${source_path}/pythondeps.toml meson || exit 1
962 # At this point, we expect Meson to be installed and available.
963 # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
964 # We ignore PATH completely here: we want to use the venv's Meson
965 # *exclusively*.
967 meson="$(cd pyvenv/bin; pwd)/meson"
969 # Conditionally ensure Sphinx is installed.
971 mkvenv_flags=""
972 if test "$download" = "enabled" -a "$docs" = "enabled" ; then
973 mkvenv_flags="--online"
976 if test "$docs" != "disabled" ; then
977 if ! $mkvenv ensuregroup \
978 $mkvenv_flags \
979 ${source_path}/pythondeps.toml docs;
980 then
981 if test "$docs" = "enabled" ; then
982 exit 1
984 echo "Sphinx not found/usable, disabling docs."
985 docs=disabled
986 else
987 docs=enabled
991 # Probe for ninja
993 if test -z "$ninja"; then
994 for c in ninja ninja-build samu; do
995 if has $c; then
996 ninja=$(command -v "$c")
997 break
999 done
1000 if test -z "$ninja"; then
1001 error_exit "Cannot find Ninja"
1005 if test "$targetos" = "bogus"; then
1006 # Now that we know that we're not printing the help and that
1007 # the compiler works (so the results of the check_defines we used
1008 # to identify the OS are reliable), if we didn't recognize the
1009 # host OS we should stop now.
1010 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1013 # test for any invalid configuration combinations
1014 if test "$targetos" = "windows" && ! has "$dlltool"; then
1015 if test "$plugins" = "yes"; then
1016 error_exit "TCG plugins requires dlltool to build on Windows platforms"
1018 plugins="no"
1020 if test "$tcg" = "disabled" ; then
1021 if test "$plugins" = "yes"; then
1022 error_exit "Can't enable plugins on non-TCG builds"
1024 plugins="no"
1026 if test "$static" = "yes" ; then
1027 if test "$plugins" = "yes"; then
1028 error_exit "static and plugins are mutually incompatible"
1030 plugins="no"
1032 if test "$plugins" != "no"; then
1033 plugins=yes
1034 subdirs="$subdirs contrib/plugins"
1037 cat > $TMPC << EOF
1039 #ifdef __linux__
1040 # define THREAD __thread
1041 #else
1042 # define THREAD
1043 #endif
1044 static THREAD int tls_var;
1045 int main(void) { return tls_var; }
1048 if test "$targetos" = windows || test "$targetos" = haiku; then
1049 if test "$pie" = "yes"; then
1050 error_exit "PIE not available due to missing OS support"
1052 pie=no
1055 if test "$pie" != "no"; then
1056 if test "$static" = "yes"; then
1057 pie_ldflags=-static-pie
1058 else
1059 pie_ldflags=-pie
1061 if compile_prog "-Werror -fPIE -DPIE" "$pie_ldflags"; then
1062 pie="yes"
1063 elif test "$pie" = "yes"; then
1064 error_exit "-static-pie not available due to missing toolchain support"
1065 else
1066 echo "Disabling PIE due to missing toolchain support"
1067 pie="no"
1071 ##########################################
1073 if test -z "${target_list+xxx}" ; then
1074 default_targets=yes
1075 for target in $default_target_list; do
1076 target_list="$target_list $target"
1077 done
1078 target_list="${target_list# }"
1079 else
1080 default_targets=no
1081 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1082 for target in $target_list; do
1083 # Check that we recognised the target name; this allows a more
1084 # friendly error message than if we let it fall through.
1085 case " $default_target_list " in
1086 *" $target "*)
1089 error_exit "Unknown target name '$target'"
1091 esac
1092 done
1095 if test "$tcg" = "auto"; then
1096 if test -z "$target_list"; then
1097 tcg="disabled"
1098 else
1099 tcg="enabled"
1103 #########################################
1104 # gdb test
1106 if test -n "$gdb_bin"; then
1107 gdb_version=$($gdb_bin --version | head -n 1)
1108 if version_ge ${gdb_version##* } 9.1; then
1109 gdb_arches=$($python "$source_path/scripts/probe-gdb-support.py" $gdb_bin)
1110 else
1111 gdb_bin=""
1115 ##########################################
1116 # big/little endian test
1117 cat > $TMPC << EOF
1118 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1119 # error LITTLE
1120 #endif
1121 int main(void) { return 0; }
1124 if ! compile_prog ; then
1125 bigendian="no"
1126 else
1127 cat > $TMPC << EOF
1128 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1129 # error BIG
1130 #endif
1131 int main(void) { return 0; }
1134 if ! compile_prog ; then
1135 bigendian="yes"
1136 else
1137 echo big/little test failed
1138 exit 1
1142 ##########################################
1143 # functions to probe cross compilers
1145 container="no"
1146 runc=""
1147 if test $use_containers = "yes" && (has "docker" || has "podman"); then
1148 case $($python "$source_path"/tests/docker/docker.py --engine "$container_engine" probe) in
1149 *docker) container=docker ;;
1150 podman) container=podman ;;
1151 no) container=no ;;
1152 esac
1153 if test "$container" != "no"; then
1154 docker_py="$python $source_path/tests/docker/docker.py --engine $container"
1155 runc=$container
1159 # cross compilers defaults, can be overridden with --cross-cc-ARCH
1160 : ${cross_prefix_aarch64="aarch64-linux-gnu-"}
1161 : ${cross_prefix_aarch64_be="$cross_prefix_aarch64"}
1162 : ${cross_prefix_alpha="alpha-linux-gnu-"}
1163 : ${cross_prefix_arm="arm-linux-gnueabihf-"}
1164 : ${cross_prefix_armeb="$cross_prefix_arm"}
1165 : ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"}
1166 : ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"}
1167 : ${cross_prefix_hppa="hppa-linux-gnu-"}
1168 : ${cross_prefix_i386="i686-linux-gnu-"}
1169 : ${cross_prefix_m68k="m68k-linux-gnu-"}
1170 : ${cross_prefix_microblaze="microblaze-linux-musl-"}
1171 : ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"}
1172 : ${cross_prefix_mips64="mips64-linux-gnuabi64-"}
1173 : ${cross_prefix_mipsel="mipsel-linux-gnu-"}
1174 : ${cross_prefix_mips="mips-linux-gnu-"}
1175 : ${cross_prefix_nios2="nios2-linux-gnu-"}
1176 : ${cross_prefix_ppc="powerpc-linux-gnu-"}
1177 : ${cross_prefix_ppc64="powerpc64-linux-gnu-"}
1178 : ${cross_prefix_ppc64le="$cross_prefix_ppc64"}
1179 : ${cross_prefix_riscv64="riscv64-linux-gnu-"}
1180 : ${cross_prefix_s390x="s390x-linux-gnu-"}
1181 : ${cross_prefix_sh4="sh4-linux-gnu-"}
1182 : ${cross_prefix_sparc64="sparc64-linux-gnu-"}
1183 : ${cross_prefix_sparc="$cross_prefix_sparc64"}
1184 : ${cross_prefix_tricore="tricore-"}
1185 : ${cross_prefix_x86_64="x86_64-linux-gnu-"}
1187 : ${cross_cc_aarch64_be="$cross_cc_aarch64"}
1188 : ${cross_cc_cflags_aarch64_be="-mbig-endian"}
1189 : ${cross_cc_armeb="$cross_cc_arm"}
1190 : ${cross_cc_cflags_armeb="-mbig-endian"}
1191 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
1192 : ${cross_cc_cflags_hexagon="-mv73 -O2 -static"}
1193 : ${cross_cc_cflags_i386="-m32"}
1194 : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
1195 : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
1196 : ${cross_cc_ppc64le="$cross_cc_ppc64"}
1197 : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
1198 : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
1199 : ${cross_cc_sparc="$cross_cc_sparc64"}
1200 : ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
1201 : ${cross_cc_cflags_x86_64="-m64"}
1203 compute_target_variable() {
1204 eval "$2="
1205 if eval test -n "\"\${cross_prefix_$1}\""; then
1206 if eval has "\"\${cross_prefix_$1}\$3\""; then
1207 eval "$2=\"\${cross_prefix_$1}\$3\""
1212 have_target() {
1213 for i; do
1214 case " $target_list " in
1215 *" $i "*) return 0;;
1216 *) ;;
1217 esac
1218 done
1219 return 1
1222 # probe_target_compiler TARGET
1224 # Look for a compiler for the given target, either native or cross.
1225 # Set variables target_* if a compiler is found, and container_cross_*
1226 # if a Docker-based cross-compiler image is known for the target.
1227 # Set got_cross_cc to yes/no depending on whether a non-container-based
1228 # compiler was found.
1230 # If TARGET is a user-mode emulation target, also set build_static to
1231 # "y" if static linking is possible.
1233 probe_target_compiler() {
1234 # reset all output variables
1235 got_cross_cc=no
1236 container_image=
1237 container_hosts=
1238 container_cross_cc=
1239 container_cross_ar=
1240 container_cross_as=
1241 container_cross_ld=
1242 container_cross_nm=
1243 container_cross_objcopy=
1244 container_cross_ranlib=
1245 container_cross_strip=
1247 target_arch=${1%%-*}
1248 case $target_arch in
1249 aarch64) container_hosts="x86_64 aarch64" ;;
1250 alpha) container_hosts=x86_64 ;;
1251 arm) container_hosts="x86_64 aarch64" ;;
1252 cris) container_hosts=x86_64 ;;
1253 hexagon) container_hosts=x86_64 ;;
1254 hppa) container_hosts=x86_64 ;;
1255 i386) container_hosts=x86_64 ;;
1256 loongarch64) container_hosts=x86_64 ;;
1257 m68k) container_hosts=x86_64 ;;
1258 microblaze) container_hosts=x86_64 ;;
1259 mips64el) container_hosts=x86_64 ;;
1260 mips64) container_hosts=x86_64 ;;
1261 mipsel) container_hosts=x86_64 ;;
1262 mips) container_hosts=x86_64 ;;
1263 nios2) container_hosts=x86_64 ;;
1264 ppc) container_hosts=x86_64 ;;
1265 ppc64|ppc64le) container_hosts=x86_64 ;;
1266 riscv64) container_hosts=x86_64 ;;
1267 s390x) container_hosts=x86_64 ;;
1268 sh4) container_hosts=x86_64 ;;
1269 sparc64) container_hosts=x86_64 ;;
1270 tricore) container_hosts=x86_64 ;;
1271 x86_64) container_hosts="aarch64 ppc64le x86_64" ;;
1272 xtensa*) container_hosts=x86_64 ;;
1273 esac
1275 for host in $container_hosts; do
1276 test "$container" != no || continue
1277 test "$host" = "$cpu" || continue
1278 case $target_arch in
1279 aarch64)
1280 # We don't have any bigendian build tools so we only use this for AArch64
1281 container_image=debian-arm64-cross
1282 container_cross_prefix=aarch64-linux-gnu-
1283 container_cross_cc=${container_cross_prefix}gcc
1285 alpha)
1286 container_image=debian-legacy-test-cross
1287 container_cross_prefix=alpha-linux-gnu-
1288 container_cross_cc=${container_cross_prefix}gcc
1290 arm)
1291 # We don't have any bigendian build tools so we only use this for ARM
1292 container_image=debian-armhf-cross
1293 container_cross_prefix=arm-linux-gnueabihf-
1295 cris)
1296 container_image=fedora-cris-cross
1297 container_cross_prefix=cris-linux-gnu-
1299 hexagon)
1300 container_image=debian-hexagon-cross
1301 container_cross_prefix=hexagon-unknown-linux-musl-
1302 container_cross_cc=${container_cross_prefix}clang
1304 hppa)
1305 container_image=debian-all-test-cross
1306 container_cross_prefix=hppa-linux-gnu-
1307 container_cross_cc=${container_cross_prefix}gcc
1309 i386)
1310 container_image=fedora-i386-cross
1311 container_cross_prefix=
1313 loongarch64)
1314 container_image=debian-loongarch-cross
1315 container_cross_prefix=loongarch64-unknown-linux-gnu-
1317 m68k)
1318 container_image=debian-all-test-cross
1319 container_cross_prefix=m68k-linux-gnu-
1320 container_cross_cc=${container_cross_prefix}gcc
1322 microblaze)
1323 container_image=debian-microblaze-cross
1324 container_cross_prefix=microblaze-linux-musl-
1326 mips64el)
1327 container_image=debian-mips64el-cross
1328 container_cross_prefix=mips64el-linux-gnuabi64-
1330 mips64)
1331 container_image=debian-all-test-cross
1332 container_cross_prefix=mips64-linux-gnuabi64-
1334 mips)
1335 container_image=debian-all-test-cross
1336 container_cross_prefix=mips-linux-gnu-
1338 nios2)
1339 container_image=debian-nios2-cross
1340 container_cross_prefix=nios2-linux-gnu-
1342 ppc)
1343 container_image=debian-all-test-cross
1344 container_cross_prefix=powerpc-linux-gnu-
1345 container_cross_cc=${container_cross_prefix}gcc
1347 ppc64|ppc64le)
1348 container_image=debian-all-test-cross
1349 container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu-
1351 riscv64)
1352 container_image=debian-all-test-cross
1353 container_cross_prefix=riscv64-linux-gnu-
1355 sh4)
1356 container_image=debian-legacy-test-cross
1357 container_cross_prefix=sh4-linux-gnu-
1359 sparc64)
1360 container_image=debian-all-test-cross
1361 container_cross_prefix=sparc64-linux-gnu-
1363 tricore)
1364 container_image=debian-tricore-cross
1365 container_cross_prefix=tricore-
1367 x86_64)
1368 container_image=debian-amd64-cross
1369 container_cross_prefix=x86_64-linux-gnu-
1371 xtensa*)
1372 container_image=debian-xtensa-cross
1374 # default to the dc232b cpu
1375 container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-
1378 # Debian and GNU architecture names usually match
1379 container_image=debian-$target_arch-cross
1380 container_cross_prefix=$target_arch-linux-gnu-
1382 esac
1383 : ${container_cross_cc:=${container_cross_prefix}gcc}
1384 : ${container_cross_ar:=${container_cross_prefix}ar}
1385 : ${container_cross_as:=${container_cross_prefix}as}
1386 : ${container_cross_ld:=${container_cross_prefix}ld}
1387 : ${container_cross_nm:=${container_cross_prefix}nm}
1388 : ${container_cross_objcopy:=${container_cross_prefix}objcopy}
1389 : ${container_cross_ranlib:=${container_cross_prefix}ranlib}
1390 : ${container_cross_strip:=${container_cross_prefix}strip}
1391 done
1393 try=cross
1394 case "$target_arch:$cpu" in
1395 aarch64_be:aarch64 | \
1396 armeb:arm | \
1397 i386:x86_64 | \
1398 mips*:mips64 | \
1399 ppc*:ppc64 | \
1400 sparc:sparc64 | \
1401 "$cpu:$cpu")
1402 try='native cross' ;;
1403 esac
1404 eval "target_cflags=\${cross_cc_cflags_$target_arch}"
1405 for thistry in $try; do
1406 case $thistry in
1407 native)
1408 target_cc=$cc
1409 target_ccas=$ccas
1410 target_ar=$ar
1411 target_as=$as
1412 target_ld=$ld
1413 target_nm=$nm
1414 target_objcopy=$objcopy
1415 target_ranlib=$ranlib
1416 target_strip=$strip
1418 cross)
1419 target_cc=
1420 if eval test -n "\"\${cross_cc_$target_arch}\""; then
1421 if eval has "\"\${cross_cc_$target_arch}\""; then
1422 eval "target_cc=\"\${cross_cc_$target_arch}\""
1424 else
1425 compute_target_variable $target_arch target_cc gcc
1427 target_ccas=$target_cc
1428 compute_target_variable $target_arch target_ar ar
1429 compute_target_variable $target_arch target_as as
1430 compute_target_variable $target_arch target_ld ld
1431 compute_target_variable $target_arch target_nm nm
1432 compute_target_variable $target_arch target_objcopy objcopy
1433 compute_target_variable $target_arch target_ranlib ranlib
1434 compute_target_variable $target_arch target_strip strip
1436 esac
1438 if test -n "$target_cc"; then
1439 case $target_arch in
1440 i386|x86_64)
1441 if $target_cc --version | grep -qi "clang"; then
1442 continue
1445 esac
1446 elif test -n "$target_as" && test -n "$target_ld"; then
1447 # Special handling for assembler only targets
1448 case $target in
1449 tricore-softmmu)
1450 build_static=
1451 got_cross_cc=yes
1452 break
1455 continue
1457 esac
1458 else
1459 continue
1462 write_c_skeleton
1463 case $1 in
1464 *-softmmu)
1465 if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC &&
1466 do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
1467 got_cross_cc=yes
1468 break
1472 if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then
1473 build_static=y
1474 got_cross_cc=yes
1475 break
1477 if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then
1478 build_static=
1479 got_cross_cc=yes
1480 break
1483 esac
1484 done
1485 if test $got_cross_cc != yes; then
1486 build_static=
1487 target_cc=
1488 target_ccas=
1489 target_ar=
1490 target_as=
1491 target_ld=
1492 target_nm=
1493 target_objcopy=
1494 target_ranlib=
1495 target_strip=
1497 test -n "$target_cc"
1500 write_target_makefile() {
1501 echo "EXTRA_CFLAGS=$target_cflags"
1502 if test -z "$target_cc" && test -z "$target_as"; then
1503 test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?"
1504 echo "$1: docker-image-$container_image" >> Makefile.prereqs
1505 if test -n "$container_cross_cc"; then
1506 echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1507 echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1509 echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --"
1510 echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --"
1511 echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --"
1512 echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --"
1513 echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --"
1514 echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --"
1515 echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --"
1516 else
1517 if test -n "$target_cc"; then
1518 echo "CC=$target_cc"
1519 echo "CCAS=$target_ccas"
1521 if test -n "$target_ar"; then
1522 echo "AR=$target_ar"
1524 if test -n "$target_as"; then
1525 echo "AS=$target_as"
1527 if test -n "$target_ld"; then
1528 echo "LD=$target_ld"
1530 if test -n "$target_nm"; then
1531 echo "NM=$target_nm"
1533 if test -n "$target_objcopy"; then
1534 echo "OBJCOPY=$target_objcopy"
1536 if test -n "$target_ranlib"; then
1537 echo "RANLIB=$target_ranlib"
1539 if test -n "$target_strip"; then
1540 echo "STRIP=$target_strip"
1545 #######################################
1546 # cross-compiled firmware targets
1548 # Set up build tree symlinks that point back into the source tree
1549 # (these can be both files and directories).
1550 # Caution: avoid adding files or directories here using wildcards. This
1551 # will result in problems later if a new file matching the wildcard is
1552 # added to the source tree -- nothing will cause configure to be rerun
1553 # so the build tree will be missing the link back to the new file, and
1554 # tests might fail. Prefer to keep the relevant files in their own
1555 # directory and symlink the directory instead.
1556 LINKS="Makefile"
1557 LINKS="$LINKS docs/config"
1558 LINKS="$LINKS pc-bios/optionrom/Makefile"
1559 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
1560 LINKS="$LINKS pc-bios/vof/Makefile"
1561 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
1562 LINKS="$LINKS tests/avocado tests/data"
1563 LINKS="$LINKS tests/qemu-iotests/check"
1564 LINKS="$LINKS python"
1565 LINKS="$LINKS contrib/plugins/Makefile "
1566 for f in $LINKS ; do
1567 if [ -e "$source_path/$f" ]; then
1568 symlink "$source_path/$f" "$f"
1570 done
1572 echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
1574 # Mac OS X ships with a broken assembler
1575 if have_target i386-softmmu x86_64-softmmu && \
1576 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \
1577 test "$targetos" != "haiku" && \
1578 probe_target_compiler i386-softmmu; then
1579 subdirs="$subdirs pc-bios/optionrom"
1580 config_mak=pc-bios/optionrom/config.mak
1581 echo "# Automatically generated by configure - do not modify" > $config_mak
1582 echo "TOPSRC_DIR=$source_path" >> $config_mak
1583 write_target_makefile >> $config_mak
1586 if have_target ppc-softmmu ppc64-softmmu && \
1587 probe_target_compiler ppc-softmmu; then
1588 subdirs="$subdirs pc-bios/vof"
1589 config_mak=pc-bios/vof/config.mak
1590 echo "# Automatically generated by configure - do not modify" > $config_mak
1591 echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
1592 write_target_makefile >> $config_mak
1595 # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
1596 # (which is the lowest architecture level that Clang supports)
1597 if have_target s390x-softmmu && probe_target_compiler s390x-softmmu && \
1598 GIT=git "$source_path/scripts/git-submodule.sh" "$git_submodules_action" roms/SLOF >> config.log 2>&1; then
1599 write_c_skeleton
1600 do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC
1601 has_z900=$?
1602 if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then
1603 if [ $has_z900 != 0 ]; then
1604 echo "WARNING: Your compiler does not support the z900!"
1605 echo " The s390-ccw bios will only work with guest CPUs >= z10."
1607 subdirs="$subdirs pc-bios/s390-ccw"
1608 config_mak=pc-bios/s390-ccw/config-host.mak
1609 echo "# Automatically generated by configure - do not modify" > $config_mak
1610 echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
1611 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_mak
1612 write_target_makefile >> $config_mak
1616 #######################################
1617 # generate config-host.mak
1619 config_host_mak="config-host.mak"
1621 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1622 echo >> $config_host_mak
1624 echo all: >> $config_host_mak
1626 echo "SRC_PATH=$source_path" >> $config_host_mak
1627 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1628 echo "GDB=$gdb_bin" >> $config_host_mak
1629 if test "$container" != no; then
1630 echo "RUNC=$runc" >> $config_host_mak
1632 echo "SUBDIRS=$subdirs" >> $config_host_mak
1633 echo "PYTHON=$python" >> $config_host_mak
1634 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
1635 echo "MESON=$meson" >> $config_host_mak
1636 echo "NINJA=$ninja" >> $config_host_mak
1637 echo "EXESUF=$EXESUF" >> $config_host_mak
1639 # use included Linux headers for KVM architectures
1640 if test "$targetos" = "linux" && test -n "$linux_arch"; then
1641 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
1644 for target in $target_list; do
1645 target_dir="$target"
1646 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
1647 case $target in
1648 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
1649 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
1650 esac
1651 done
1653 if test "$default_targets" = "yes"; then
1654 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
1657 # contrib/plugins configuration
1658 echo "# Automatically generated by configure - do not modify" > contrib/plugins/$config_host_mak
1659 echo "SRC_PATH=$source_path/contrib/plugins" >> contrib/plugins/$config_host_mak
1660 echo "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak
1661 echo "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak
1662 echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config_host_mak
1663 if test "$targetos" = windows; then
1664 echo "DLLTOOL=$dlltool" >> contrib/plugins/$config_host_mak
1666 if test "$targetos" = darwin; then
1667 echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak
1669 if test "$targetos" = windows; then
1670 echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak
1673 # tests/tcg configuration
1674 (config_host_mak=tests/tcg/config-host.mak
1675 mkdir -p tests/tcg
1676 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1677 echo "SRC_PATH=$source_path" >> $config_host_mak
1679 tcg_tests_targets=
1680 for target in $target_list; do
1681 arch=${target%%-*}
1683 case $target in
1684 xtensa*-linux-user)
1685 # the toolchain is not complete with headers, only build system tests
1686 continue
1688 *-softmmu)
1689 test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue
1690 qemu="qemu-system-$arch"
1692 *-linux-user|*-bsd-user)
1693 qemu="qemu-$arch"
1695 esac
1697 if probe_target_compiler $target || test -n "$container_image"; then
1698 test -n "$container_image" && build_static=y
1699 mkdir -p "tests/tcg/$target"
1700 config_target_mak=tests/tcg/$target/config-target.mak
1701 ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile"
1702 echo "# Automatically generated by configure - do not modify" > "$config_target_mak"
1703 echo "TARGET_NAME=$arch" >> "$config_target_mak"
1704 echo "TARGET=$target" >> "$config_target_mak"
1705 write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak"
1706 echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
1707 echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
1709 # will GDB work with these binaries?
1710 if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
1711 echo "GDB=$gdb_bin" >> $config_target_mak
1714 echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
1715 tcg_tests_targets="$tcg_tests_targets $target"
1717 done
1719 if test "$tcg" = "enabled"; then
1720 echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak
1724 if test "$skip_meson" = no; then
1725 cross="config-meson.cross.new"
1726 meson_quote() {
1727 test $# = 0 && return
1728 echo "'$(echo $* | sed "s/ /','/g")'"
1731 echo "# Automatically generated by configure - do not modify" > $cross
1732 echo "[properties]" >> $cross
1734 # unroll any custom device configs
1735 for a in $device_archs; do
1736 eval "c=\$devices_${a}"
1737 echo "${a}-softmmu = '$c'" >> $cross
1738 done
1740 echo "[built-in options]" >> $cross
1741 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
1742 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
1743 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
1744 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
1745 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
1747 # Only enable by default for git builds and on select OSes
1748 echo "# environment defaults, can still be overridden on " >> $cross
1749 echo "# the command line" >> $cross
1750 if test -e "$source_path/.git" && \
1751 { test "$targetos" = linux || test "$targetos" = "windows"; }; then
1752 echo 'werror = true' >> $cross
1754 echo "[project options]" >> $cross
1755 if test "$SMBD" != ''; then
1756 echo "smbd = $(meson_quote "$SMBD")" >> $cross
1758 if test "${QEMU_GA_MANUFACTURER}" != ''; then
1759 echo "qemu_ga_manufacturer = $(meson_quote "${QEMU_GA_MANUFACTURER}")" >> $cross
1761 if test "${QEMU_GA_DISTRO}" != ''; then
1762 echo "qemu_ga_distro = $(meson_quote "${QEMU_GA_DISTRO}")" >> $cross
1764 if test "${QEMU_GA_VERSION}" != ''; then
1765 echo "qemu_ga_version = $(meson_quote "${QEMU_GA_VERSION}")" >> $cross
1768 echo >> $cross
1769 echo "[binaries]" >> $cross
1770 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
1771 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
1772 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
1773 echo "ar = [$(meson_quote $ar)]" >> $cross
1774 echo "dlltool = [$(meson_quote $dlltool)]" >> $cross
1775 echo "nm = [$(meson_quote $nm)]" >> $cross
1776 echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
1777 echo "pkg-config = [$(meson_quote $pkg_config)]" >> $cross
1778 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
1779 if has $sdl2_config; then
1780 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
1782 echo "strip = [$(meson_quote $strip)]" >> $cross
1783 echo "widl = [$(meson_quote $widl)]" >> $cross
1784 echo "windres = [$(meson_quote $windres)]" >> $cross
1785 echo "windmc = [$(meson_quote $windmc)]" >> $cross
1786 if test "$cross_compile" = "yes"; then
1787 echo "[host_machine]" >> $cross
1788 echo "system = '$targetos'" >> $cross
1789 case "$cpu" in
1790 i386)
1791 echo "cpu_family = 'x86'" >> $cross
1794 echo "cpu_family = '$cpu'" >> $cross
1796 esac
1797 echo "cpu = '$cpu'" >> $cross
1798 if test "$bigendian" = "yes" ; then
1799 echo "endian = 'big'" >> $cross
1800 else
1801 echo "endian = 'little'" >> $cross
1804 native="config-meson.native.new"
1805 echo "# Automatically generated by configure - do not modify" > $native
1806 echo "[binaries]" >> $native
1807 echo "c = [$(meson_quote $host_cc)]" >> $native
1808 mv $native config-meson.native
1809 meson_option_add --native-file
1810 meson_option_add config-meson.native
1812 mv $cross config-meson.cross
1813 meson_add_machine_file config-meson.cross
1814 if test -f "$source_path/configs/meson/$targetos.txt"; then
1815 meson_add_machine_file $source_path/configs/meson/$targetos.txt
1818 rm -rf meson-private meson-info meson-logs
1820 test "$download" = "disabled" && meson_option_add "--wrap-mode=nodownload"
1821 test "$default_feature" = no && meson_option_add -Dauto_features=disabled
1822 test "$static" = yes && meson_option_add -Dprefer_static=true
1823 test "$pie" = no && meson_option_add -Db_pie=false
1825 # QEMU options
1826 test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi"
1827 test "$docs" != auto && meson_option_add "-Ddocs=$docs"
1828 test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
1829 test "$plugins" = yes && meson_option_add "-Dplugins=true"
1830 test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg"
1831 run_meson() {
1832 NINJA=$ninja $meson setup "$@" "$PWD" "$source_path"
1834 eval run_meson $meson_options
1835 if test "$?" -ne 0 ; then
1836 error_exit "meson setup failed"
1838 echo "$meson" > build.ninja.stamp
1839 else
1840 if test -f meson-private/cmd_line.txt; then
1841 # Adjust old command line options that were removed
1842 # sed -i is not portable
1843 perl -i -ne '
1844 /^sphinx_build/ && next;
1845 print;' meson-private/cmd_line.txt
1849 # Save the configure command line for later reuse.
1850 cat <<EOD >config.status
1851 #!/bin/sh
1852 # Generated by configure.
1853 # Run this file to recreate the current configuration.
1854 # Compiler output produced by configure, useful for debugging
1855 # configure, is in config.log if it exists.
1858 preserve_env() {
1859 envname=$1
1861 eval envval=\$$envname
1863 if test -n "$envval"
1864 then
1865 echo "$envname='$envval'" >> config.status
1866 echo "export $envname" >> config.status
1867 else
1868 echo "unset $envname" >> config.status
1872 # Preserve various env variables that influence what
1873 # features/build target configure will detect
1874 preserve_env AR
1875 preserve_env AS
1876 preserve_env CC
1877 preserve_env CFLAGS
1878 preserve_env CXX
1879 preserve_env CXXFLAGS
1880 preserve_env DLLTOOL
1881 preserve_env LD
1882 preserve_env LDFLAGS
1883 preserve_env LD_LIBRARY_PATH
1884 preserve_env NM
1885 preserve_env OBJCFLAGS
1886 preserve_env OBJCOPY
1887 preserve_env PATH
1888 preserve_env PKG_CONFIG
1889 preserve_env PKG_CONFIG_LIBDIR
1890 preserve_env PKG_CONFIG_PATH
1891 preserve_env PYTHON
1892 preserve_env QEMU_GA_MANUFACTURER
1893 preserve_env QEMU_GA_DISTRO
1894 preserve_env QEMU_GA_VERSION
1895 preserve_env SDL2_CONFIG
1896 preserve_env SMBD
1897 preserve_env STRIP
1898 preserve_env WIDL
1899 preserve_env WINDRES
1900 preserve_env WINDMC
1902 printf "exec" >>config.status
1903 for i in "$0" "$@"; do
1904 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
1905 done
1906 echo ' "$@"' >>config.status
1907 chmod +x config.status
1909 rm -r "$TMPDIR1"