master
text 2,031 lines 60.1 KB
Raw
1 #!/bin/sh
2 #
3 # qemu configure script (c) 2003 Fabrice Bellard
4 #
5
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
9
10 # Don't allow CCACHE, if present, to use cached results of compile tests!
11 export CCACHE_RECACHE=yes
12
13 # make source path absolute
14 source_path=$(cd "$(dirname -- "$0")"; pwd)
15
16 if test "$PWD" -ef "$source_path"
17 then
18 echo "Using './build' as the directory for build output"
19
20 MARKER=build/auto-created-by-configure
21
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
30 fi
31 fi
32
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
38 fi
39
40 cat > GNUmakefile <<'EOF'
41 # This file is auto-generated by configure to support in-source tree
42 # 'make' command invocation
43
44 build:
45 @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
46 @$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
47 @if test "$(MAKECMDGOALS)" = "distclean" && \
48 test -e build/auto-created-by-configure ; \
49 then \
50 rm -rf build GNUmakefile ; \
51 fi
52 %: build
53 @
54 .PHONY: build
55 GNUmakefile: ;
56
57 EOF
58 cd build
59 exec "$source_path/configure" "$@"
60 fi
61
62 # Temporary directory used for files created while
63 # configure runs. Since it is in the build directory
64 # we can safely blow away any previous version of it
65 # (and we need not jump through hoops to try to delete
66 # it when configure exits.)
67 TMPDIR1="config-temp"
68 rm -rf "${TMPDIR1}"
69 if ! mkdir -p "${TMPDIR1}"; then
70 echo "ERROR: failed to create temporary directory"
71 exit 1
72 fi
73
74 TMPB="qemu-conf"
75 TMPC="${TMPDIR1}/${TMPB}.c"
76 TMPO="${TMPDIR1}/${TMPB}.o"
77 TMPE="${TMPDIR1}/${TMPB}.exe"
78
79 rm -f config.log
80
81 # Print a helpful header at the top of config.log
82 echo "# QEMU configure log $(date)" >> config.log
83 printf "# Configured with:" >> config.log
84 # repeat the invocation to log and stdout for CI
85 invoke=$(printf " '%s'" "$0" "$@")
86 test -n "$GITLAB_CI" && echo "configuring with: $invoke"
87 { echo "$invoke"; echo; echo "#"; } >> config.log
88
89 quote_sh() {
90 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
91 }
92
93 error_exit() {
94 (echo
95 echo "ERROR: $1"
96 while test -n "$2"; do
97 echo " $2"
98 shift
99 done
100 echo) >&2
101 exit 1
102 }
103
104 do_compiler() {
105 # Run the compiler, capturing its output to the log. First argument
106 # is compiler binary to execute.
107 compiler="$1"
108 shift
109 if test -n "$BASH_VERSION"; then eval '
110 echo >>config.log "
111 funcs: ${FUNCNAME[*]}
112 lines: ${BASH_LINENO[*]}"
113 '; fi
114 echo $compiler "$@" >> config.log
115 $compiler "$@" >> config.log 2>&1 || return $?
116 }
117
118 do_cc() {
119 do_compiler "$cc" $CPU_CFLAGS "$@"
120 }
121
122 compile_object() {
123 local_cflags="$1"
124 do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC
125 }
126
127 compile_prog() {
128 local_cflags="$1"
129 local_ldflags="$2"
130 do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -o $TMPE $TMPC \
131 $LDFLAGS $EXTRA_LDFLAGS $local_ldflags
132 }
133
134 # symbolically link $1 to $2. Portable version of "ln -sf".
135 symlink() {
136 rm -rf "$2"
137 mkdir -p "$(dirname "$2")"
138 ln -s "$1" "$2"
139 }
140
141 # check whether a command is available to this shell (may be either an
142 # executable or a builtin)
143 has() {
144 type "$1" >/dev/null 2>&1
145 }
146
147 version_ge () {
148 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
149 local_ver2=$(echo "$2" | tr . ' ')
150 while true; do
151 set x $local_ver1
152 local_first=${2-0}
153 # 'shift 2' if $2 is set, or 'shift' if $2 is not set
154 shift ${2:+2}
155 local_ver1=$*
156 set x $local_ver2
157 # the second argument finished, the first must be greater or equal
158 test $# = 1 && return 0
159 test $local_first -lt $2 && return 1
160 test $local_first -gt $2 && return 0
161 shift ${2:+2}
162 local_ver2=$*
163 done
164 }
165
166 if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
167 then
168 error_exit "main directory cannot contain spaces nor colons"
169 fi
170
171 # parse CC options first; some compiler tests are used to establish
172 # some defaults, based on the host environment
173
174 # default parameters
175 container_command=""
176 cpu=""
177 cross_compile="no"
178 cross_prefix=""
179 host_cc="cc"
180 EXTRA_CFLAGS=""
181 EXTRA_CXXFLAGS=""
182 EXTRA_OBJCFLAGS=""
183 EXTRA_LDFLAGS=""
184
185 # The value is propagated to Emscripten's "-sMEMORY64" flag.
186 # https://emscripten.org/docs/tools_reference/settings_reference.html#memory64
187 wasm64_memory64=1
188
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
196 #
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=""
201
202 for opt do
203 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
204 case "$opt" in
205 --cross-prefix=*) cross_prefix="$optarg"
206 cross_compile="yes"
207 ;;
208 --cc=*) CC="$optarg"
209 ;;
210 --cxx=*) CXX="$optarg"
211 ;;
212 --objcc=*) objcc="$optarg"
213 ;;
214 --rustc=*) RUSTC="$optarg"
215 ;;
216 --rustdoc=*) RUSTDOC="$optarg"
217 ;;
218 --cpu=*) cpu="$optarg"
219 ;;
220 --extra-cflags=*)
221 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
222 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
223 EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
224 ;;
225 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
226 ;;
227 --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg"
228 ;;
229 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
230 ;;
231 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
232 ;;
233 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
234 eval "cross_cc_cflags_${cc_arch}=\$optarg"
235 ;;
236 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
237 eval "cross_cc_${cc_arch}=\$optarg"
238 ;;
239 --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option"
240 ;;
241 --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*}
242 eval "cross_prefix_${cc_arch}=\$optarg"
243 ;;
244 --without-default-features) default_feature="no"
245 ;;
246 --wasm64-32bit-address-limit) wasm64_memory64="2"
247 ;;
248 esac
249 done
250
251 git_submodules_action="update"
252 docs="auto"
253 EXESUF=""
254 system="yes"
255 linux_user=""
256 bsd_user=""
257 plugins="$default_feature"
258 subdirs=""
259 ninja=""
260 python=
261 download="enabled"
262 skip_meson=no
263 use_containers="yes"
264 rust="disabled"
265 rust_target_triple=""
266 gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
267 gdb_arches=""
268
269 # Don't accept a target_list environment variable.
270 unset target_list
271 unset target_list_exclude
272
273 # The following Meson options are handled manually (still they
274 # are included in the automatically generated help message)
275 # because they automatically enable/disable other options
276 tcg="auto"
277 cfi="false"
278
279 # Meson has PIE as a boolean rather than enabled/disabled/auto,
280 # and we also need to check for -static-pie before Meson runs
281 # which requires knowing whether --static is enabled.
282 pie=""
283 static="no"
284
285 # Preferred compiler:
286 # ${CC} (if set)
287 # ${cross_prefix}gcc (if cross-prefix specified)
288 # system compiler
289 if test -z "${CC}${cross_prefix}"; then
290 cc="cc"
291 else
292 cc="${CC-${cross_prefix}gcc}"
293 fi
294
295 if test -z "${CXX}${cross_prefix}"; then
296 cxx="c++"
297 else
298 cxx="${CXX-${cross_prefix}g++}"
299 fi
300
301 # Preferred ObjC compiler:
302 # $objcc (if set, i.e. via --objcc option)
303 # ${cross_prefix}clang (if cross-prefix specified)
304 # clang (if available)
305 # $cc
306 if test -z "${objcc}${cross_prefix}"; then
307 if has clang; then
308 objcc=clang
309 else
310 objcc="$cc"
311 fi
312 else
313 objcc="${objcc-${cross_prefix}clang}"
314 fi
315
316 ar="${AR-${cross_prefix}ar}"
317 as="${AS-${cross_prefix}as}"
318 ccas="${CCAS-$cc}"
319 dlltool="${DLLTOOL-${cross_prefix}dlltool}"
320 objcopy="${OBJCOPY-${cross_prefix}objcopy}"
321 ld="${LD-${cross_prefix}ld}"
322 ranlib="${RANLIB-${cross_prefix}ranlib}"
323 nm="${NM-${cross_prefix}nm}"
324 readelf="${READELF-${cross_prefix}readelf}"
325 strip="${STRIP-${cross_prefix}strip}"
326 widl="${WIDL-${cross_prefix}widl}"
327 windres="${WINDRES-${cross_prefix}windres}"
328 windmc="${WINDMC-${cross_prefix}windmc}"
329 pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
330 sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
331
332 rustc="${RUSTC-rustc}"
333 rustdoc="${RUSTDOC-rustdoc}"
334
335 check_define() {
336 cat > $TMPC <<EOF
337 #if !defined($1)
338 #error $1 not defined
339 #endif
340 int main(void) { return 0; }
341 EOF
342 compile_object
343 }
344
345 write_c_skeleton() {
346 cat > $TMPC <<EOF
347 int main(void) { return 0; }
348 EOF
349 }
350
351 if check_define __linux__ ; then
352 host_os=linux
353 elif check_define _WIN32 ; then
354 host_os=windows
355 elif check_define __OpenBSD__ ; then
356 host_os=openbsd
357 elif check_define __sun__ ; then
358 host_os=sunos
359 elif check_define __HAIKU__ ; then
360 host_os=haiku
361 elif check_define __FreeBSD__ ; then
362 host_os=freebsd
363 elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
364 host_os=gnu/kfreebsd
365 elif check_define __DragonFly__ ; then
366 host_os=dragonfly
367 elif check_define __NetBSD__; then
368 host_os=netbsd
369 elif check_define __APPLE__; then
370 host_os=darwin
371 elif check_define EMSCRIPTEN ; then
372 host_os=emscripten
373 cross_compile="yes"
374 elif check_define __GNU__; then
375 host_os=gnu
376 else
377 # This is a fatal error, but don't report it yet, because we
378 # might be going to just print the --help text, or it might
379 # be the result of a missing compiler.
380 host_os=bogus
381 fi
382
383 if test ! -z "$cpu" ; then
384 # command line argument
385 :
386 elif check_define __x86_64__ ; then
387 if check_define __ILP32__ ; then
388 cpu="x32"
389 else
390 cpu="x86_64"
391 fi
392 elif check_define __sparc__ ; then
393 if check_define __arch64__ ; then
394 cpu="sparc64"
395 else
396 cpu="sparc"
397 fi
398 elif check_define _ARCH_PPC64 ; then
399 if check_define _LITTLE_ENDIAN ; then
400 cpu="ppc64le"
401 else
402 cpu="ppc64"
403 fi
404 elif check_define __s390x__ ; then
405 cpu="s390x"
406 elif check_define __riscv && check_define _LP64 ; then
407 cpu="riscv64"
408 elif check_define __aarch64__ ; then
409 cpu="aarch64"
410 elif check_define __loongarch64 ; then
411 cpu="loongarch64"
412 elif check_define EMSCRIPTEN ; then
413 error_exit "wasm64 must be specified to the cpu flag"
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 if test "$host_os" != "bogus"; then
419 echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
420 fi
421 fi
422
423 # Normalise host CPU name to the values used by Meson cross files and in source
424 # directories, and set multilib cflags. The canonicalization isn't really
425 # necessary, because the architectures that we check for should not hit the
426 # 'uname -m' case, but better safe than sorry in case --cpu= is used.
427 #
428 # Note that this case should only have supported host CPUs, not guests.
429 # Please keep it sorted and synchronized with meson.build's host_arch.
430 host_arch=
431 linux_arch=
432 raw_cpu=$cpu
433 case "$cpu" in
434 aarch64)
435 host_arch=aarch64
436 linux_arch=arm64
437 ;;
438
439 loongarch*)
440 cpu=loongarch64
441 host_arch=loongarch64
442 linux_arch=loongarch
443 ;;
444
445 ppc64)
446 host_arch=ppc64
447 linux_arch=powerpc
448 CPU_CFLAGS="-m64 -mbig-endian"
449 ;;
450 ppc64le)
451 cpu=ppc64
452 host_arch=ppc64
453 linux_arch=powerpc
454 CPU_CFLAGS="-m64 -mlittle-endian"
455 ;;
456
457 riscv64)
458 host_arch=riscv64
459 linux_arch=riscv
460 ;;
461
462 s390x)
463 host_arch=s390x
464 linux_arch=s390
465 CPU_CFLAGS="-m64"
466 ;;
467
468 sparc|sun4[cdmuv])
469 cpu=sparc
470 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
471 ;;
472 sparc64)
473 host_arch=sparc64
474 CPU_CFLAGS="-m64 -mcpu=ultrasparc"
475 ;;
476
477 x32)
478 cpu="x86_64"
479 host_arch=x86_64
480 linux_arch=x86
481 CPU_CFLAGS="-mx32"
482 ;;
483 x86_64|amd64)
484 cpu="x86_64"
485 host_arch=x86_64
486 linux_arch=x86
487 CPU_CFLAGS="-m64"
488 ;;
489 wasm64)
490 CPU_CFLAGS="-m64 -sMEMORY64=$wasm64_memory64"
491 ;;
492 esac
493
494 if test -n "$host_arch" && {
495 ! test -d "$source_path/linux-user/include/host/$host_arch" ||
496 ! test -d "$source_path/common-user/host/$host_arch"; }; then
497 error_exit "linux-user/include/host/$host_arch does not exist." \
498 "This is a bug in the configure script, please report it."
499 fi
500 if test -n "$linux_arch" && ! test -d "$source_path/linux-headers/asm-$linux_arch"; then
501 error_exit "linux-headers/asm-$linux_arch does not exist." \
502 "This is a bug in the configure script, please report it."
503 fi
504
505 check_py_version() {
506 # We require python >= 3.9.
507 # NB: a True python conditional creates a non-zero return code (Failure)
508 "$1" -c 'import sys; sys.exit(sys.version_info < (3,9))'
509 }
510
511 first_python=
512 if test -z "${PYTHON}"; then
513 # A bare 'python' is traditionally python 2.x, but some distros
514 # have it as python 3.x, so check in both places.
515 for binary in python3 python python3.14 python3.13 python3.12 \
516 python3.11 python3.10 python3.9 ; do
517 if has "$binary"; then
518 python=$(command -v "$binary")
519 if check_py_version "$python"; then
520 # This one is good.
521 first_python=
522 break
523 else
524 first_python=$python
525 fi
526 fi
527 done
528 else
529 # Same as above, but only check the environment variable.
530 has "${PYTHON}" || error_exit "The PYTHON environment variable does not point to an executable"
531 python=$(command -v "$PYTHON")
532 if check_py_version "$python"; then
533 # This one is good.
534 first_python=
535 else
536 first_python=$first_python
537 fi
538 fi
539
540 # Check for ancillary tools used in testing
541 genisoimage=
542 for binary in genisoimage mkisofs
543 do
544 if has $binary
545 then
546 genisoimage=$(command -v "$binary")
547 break
548 fi
549 done
550
551 if test "$host_os" = "windows" ; then
552 EXESUF=".exe"
553 fi
554
555 meson_option_build_array() {
556 printf '['
557 (if test "$host_os" = windows; then
558 IFS=\;
559 else
560 IFS=:
561 fi
562 for e in $1; do
563 printf '"""'
564 # backslash escape any '\' and '"' characters
565 printf "%s" "$e" | sed -e 's/\([\"]\)/\\\1/g'
566 printf '""",'
567 done)
568 printf ']\n'
569 }
570
571 . "$source_path/scripts/meson-buildoptions.sh"
572
573 meson_options=
574 meson_option_add() {
575 local arg
576 for arg; do
577 meson_options="$meson_options $(quote_sh "$arg")"
578 done
579 }
580 meson_option_parse() {
581 meson_options="$meson_options $(_meson_option_parse "$@")"
582 if test $? -eq 1; then
583 echo "ERROR: unknown option $1"
584 echo "Try '$0 --help' for more information"
585 exit 1
586 fi
587 }
588 has_meson_option() {
589 test "${meson_options#*"$1"}" != "$meson_options"
590 }
591
592 meson_add_machine_file() {
593 if test "$cross_compile" = "yes"; then
594 meson_option_add --cross-file "$1"
595 else
596 meson_option_add --native-file "$1"
597 fi
598 }
599
600 for opt do
601 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
602 case "$opt" in
603 --help|-h) show_help=yes
604 ;;
605 --version|-V) exec cat "$source_path/VERSION"
606 ;;
607 --cross-prefix=*)
608 ;;
609 --cc=*)
610 ;;
611 --host-cc=*) host_cc="$optarg"
612 ;;
613 --cxx=*)
614 ;;
615 --objcc=*)
616 ;;
617 --rustc=*)
618 ;;
619 --rustdoc=*)
620 ;;
621 --make=*)
622 ;;
623 --install=*)
624 ;;
625 --python=*) python="$optarg"
626 ;;
627 --skip-meson) skip_meson=yes
628 ;;
629 --ninja=*) ninja="$optarg"
630 ;;
631 --extra-cflags=*)
632 ;;
633 --extra-cxxflags=*)
634 ;;
635 --extra-objcflags=*)
636 ;;
637 --extra-ldflags=*)
638 ;;
639 --cross-cc-*)
640 ;;
641 --cross-prefix-*)
642 ;;
643 --enable-docs) docs=enabled
644 ;;
645 --disable-docs) docs=disabled
646 ;;
647 --cpu=*)
648 ;;
649 --target-list=*) target_list="$optarg"
650 if test "$target_list_exclude"; then
651 error_exit "Can't mix --target-list with --target-list-exclude"
652 fi
653 ;;
654 --target-list-exclude=*) target_list_exclude="$optarg"
655 if test "$target_list"; then
656 error_exit "Can't mix --target-list-exclude with --target-list"
657 fi
658 ;;
659 --with-default-devices) meson_option_add -Ddefault_devices=true
660 ;;
661 --without-default-devices) meson_option_add -Ddefault_devices=false
662 ;;
663 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
664 ;;
665 --with-devices-*) device_arch=${opt#--with-devices-};
666 device_arch=${device_arch%%=*}
667 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
668 if test -f "$cf"; then
669 device_archs="$device_archs $device_arch"
670 eval "devices_${device_arch}=\$optarg"
671 else
672 error_exit "File $cf does not exist"
673 fi
674 ;;
675 --without-default-features) # processed above
676 ;;
677 --static) static="yes"
678 ;;
679 --host=*|--build=*|\
680 --disable-dependency-tracking|\
681 --sbindir=*|--sharedstatedir=*|\
682 --oldincludedir=*|--datarootdir=*|--infodir=*|\
683 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
684 # These switches are silently ignored, for compatibility with
685 # autoconf-generated configure scripts. This allows QEMU's
686 # configure to be used by RPM and similar macros that set
687 # lots of directory switches by default.
688 ;;
689 --enable-debug)
690 # Enable debugging options that aren't excessively noisy
691 meson_option_parse --enable-debug-tcg ""
692 meson_option_parse --enable-debug-graph-lock ""
693 meson_option_parse --enable-debug-mutex ""
694 meson_option_add -Doptimization=0
695 ;;
696 --disable-tcg) tcg="disabled"
697 ;;
698 --enable-tcg) tcg="enabled"
699 ;;
700 --disable-system) system="no"
701 ;;
702 --enable-system) system="yes"
703 ;;
704 --disable-user)
705 linux_user="no" ;
706 bsd_user="no" ;
707 ;;
708 --enable-user) ;;
709 --disable-linux-user) linux_user="no"
710 ;;
711 --enable-linux-user) linux_user="yes"
712 ;;
713 --disable-bsd-user) bsd_user="no"
714 ;;
715 --enable-bsd-user) bsd_user="yes"
716 ;;
717 --enable-pie) pie="yes"
718 ;;
719 --disable-pie) pie="no"
720 ;;
721 --enable-cfi) cfi=true
722 ;;
723 --disable-cfi) cfi=false
724 ;;
725 --disable-download) download="disabled"; git_submodules_action=validate;
726 ;;
727 --enable-download) download="enabled"; git_submodules_action=update;
728 ;;
729 --enable-plugins) plugins="yes"
730 ;;
731 --disable-plugins) plugins="no"
732 ;;
733 --enable-containers) use_containers="yes"
734 ;;
735 --disable-containers) use_containers="no"
736 ;;
737 --container-command=*) container_command="$optarg"
738 ;;
739 --rust-target-triple=*) rust_target_triple="$optarg"
740 ;;
741 --gdb=*) gdb_bin="$optarg"
742 ;;
743 --enable-rust) rust=enabled
744 ;;
745 --disable-rust) rust=disabled
746 ;;
747 --wasm64-32bit-address-limit)
748 ;;
749 # everything else has the same name in configure and meson
750 --*) meson_option_parse "$opt" "$optarg"
751 ;;
752 # Pass through -Dxxxx options to meson
753 -D*) meson_option_add "$opt"
754 ;;
755 esac
756 done
757
758 if ! test -e "$source_path/.git"
759 then
760 git_submodules_action="validate"
761 fi
762
763 if ! test -f "$source_path/subprojects/keycodemapdb/README" \
764 && test "$download" = disabled
765 then
766 echo
767 echo "ERROR: missing subprojects"
768 echo
769 if test -e "$source_path/.git"; then
770 echo "--disable-download specified but subprojects were not"
771 echo 'checked out. Please invoke "meson subprojects download"'
772 echo "before configuring QEMU, or remove --disable-download"
773 echo "from the command line."
774 else
775 echo "This is not a GIT checkout but subproject content appears to"
776 echo "be missing. Do not use 'git archive' or GitHub download links"
777 echo "to acquire QEMU source archives. Non-GIT builds are only"
778 echo "supported with source archives linked from:"
779 echo
780 echo " https://www.qemu.org/download/#source"
781 echo
782 echo "Developers working with GIT can use scripts/archive-source.sh"
783 echo "if they need to create valid source archives."
784 fi
785 echo
786 exit 1
787 fi
788
789 default_target_list=""
790 mak_wilds=""
791
792 if [ -n "$host_arch" ] && [ -d "$source_path/common-user/host/$host_arch" ]; then
793 if [ "$linux_user" != no ]; then
794 if [ "$host_os" = linux ]; then
795 linux_user=yes
796 elif [ "$linux_user" = yes ]; then
797 error_exit "linux-user not supported on this architecture"
798 fi
799 if [ "$linux_user" = "yes" ]; then
800 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
801 fi
802 fi
803 if [ "$bsd_user" != no ]; then
804 if [ "$bsd_user" = "" ]; then
805 test $host_os = freebsd && bsd_user=yes
806 fi
807 if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$host_os" ]; then
808 error_exit "bsd-user not supported on this host OS"
809 fi
810 if [ "$bsd_user" = "yes" ]; then
811 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
812 fi
813 fi
814 else
815 if [ "$linux_user" = yes ] || [ "$bsd_user" = yes ]; then
816 error_exit "user mode emulation not supported on this architecture"
817 fi
818 fi
819 if [ "$system" = "yes" ]; then
820 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
821 fi
822
823 for config in $mak_wilds; do
824 target="$(basename "$config" .mak)"
825 if echo "$target_list_exclude" | grep -vq "$target"; then
826 default_target_list="${default_target_list} $target"
827 fi
828 done
829
830 if test x"$show_help" = x"yes" ; then
831 cat << EOF
832
833 Usage: configure [options]
834 Options: [defaults in brackets after descriptions]
835
836 Standard options:
837 --help print this message
838 --target-list=LIST set target list (default: build all)
839 $(echo Available targets: $default_target_list | \
840 fold -s -w 53 | sed -e 's/^/ /')
841 --target-list-exclude=LIST exclude a set of targets from the default target-list
842
843 Advanced options (experts only):
844 -Dmesonoptname=val passthrough option to meson unmodified
845 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
846 --cc=CC use C compiler CC [$cc]
847 --host-cc=CC when cross compiling, use C compiler CC for code run
848 at build time [$host_cc]
849 --cxx=CXX use C++ compiler CXX [$cxx]
850 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
851 --rustc=RUSTC use Rust compiler RUSTC [$rustc]
852 --rustdoc=RUSTDOC use rustdoc binary RUSTDOC [$rustdoc]
853 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS
854 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
855 --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
856 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS
857 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases
858 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests
859 --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases
860 --python=PYTHON use specified python [$python]
861 --ninja=NINJA use specified ninja [$ninja]
862 --static enable static build [$static]
863 --rust-target-triple=TRIPLE compilation target for Rust code [autodetect]
864 --without-default-features default all --enable-* options to "disabled"
865 --without-default-devices do not include any device that is not needed to
866 start the emulator (only use if you are including
867 desired devices in configs/devices/)
868 --with-devices-ARCH=NAME override default configs/devices
869 --enable-debug enable common debug build options
870 --cpu=CPU Build for host CPU [$cpu]
871 --disable-containers don't use containers for cross-building
872 --container-command=CMD which container command to use [autodetect]
873 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
874 --wasm64-32bit-address-limit Restrict wasm64 address space to 32-bit (default
875 is to use the whole 64-bit range).
876 EOF
877 meson_options_help
878 cat << EOF
879 system all system emulation targets
880 user supported user emulation targets
881 linux-user all linux usermode emulation targets
882 bsd-user all BSD usermode emulation targets
883 pie Position Independent Executables
884
885 NOTE: The object files are built at the place where configure is launched
886 EOF
887 exit 0
888 fi
889
890 # Now that we are sure that the user did not only want to print the --help
891 # information, we should double-check that the C compiler really works:
892 write_c_skeleton
893 if ! compile_object ; then
894 error_exit "C compiler \"$cc\" either does not exist or does not work."
895 fi
896
897 # Remove old dependency files to make sure that they get properly regenerated
898 rm -f ./*/config-devices.mak.d
899
900 if test -z "$python"
901 then
902 # If first_python is set, there was a binary somewhere even though
903 # it was not suitable. Use it for the error message.
904 if test -n "$first_python"; then
905 error_exit "Cannot use '$first_python', Python >= 3.9 is required." \
906 "Use --python=/path/to/python to specify a supported Python."
907 else
908 error_exit "Python not found. Use --python=/path/to/python"
909 fi
910 fi
911
912 if ! check_py_version "$python"; then
913 error_exit "Cannot use '$python', Python >= 3.9 is required." \
914 "Use --python=/path/to/python to specify a supported Python." \
915 "Maybe try:" \
916 " CentOS: dnf install python3.12"
917 fi
918
919 # Resolve PATH
920 python="$(command -v "$python")"
921
922 # Create a Python virtual environment using our configured python.
923 # The stdout of this script will be the location of a symlink that
924 # points to the configured Python.
925 # Entry point scripts for pip, meson, and sphinx are generated if those
926 # packages are present.
927
928 # Defaults assumed for now:
929 # - venv is cleared if it exists already;
930 # - venv is allowed to use system packages;
931 # - all setup can be performed offline;
932 # - missing packages may be fetched from PyPI,
933 # unless --disable-download is passed.
934 # - pip is not installed into the venv when possible,
935 # but ensurepip is called as a fallback when necessary.
936
937 echo "python determined to be '$python'"
938 echo "python version: $($python --version)"
939
940 python="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)"
941 if test "$?" -ne 0 ; then
942 error_exit "python venv creation failed"
943 fi
944
945 # Suppress writing compiled files
946 python="$python -B"
947 mkvenv="$python ${source_path}/python/scripts/mkvenv.py"
948
949 # Finish preparing the virtual environment using vendored .whl files.
950 # Even if PyPI is allowed, we disallow it here to force installation
951 # from our preferred vendored versions.
952
953 $mkvenv ensuregroup --dir "${source_path}/python/wheels" \
954 ${source_path}/pythondeps.toml meson || exit 1
955
956 # At this point, we expect Meson to be installed and available.
957 # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
958 # We ignore PATH completely here: we want to use the venv's Meson
959 # *exclusively*.
960
961 # for msys2
962 get_pwd() {
963 if pwd -W >/dev/null 2>&1; then
964 pwd -W
965 else
966 pwd
967 fi
968 }
969
970 meson="$(cd pyvenv/bin; get_pwd)/meson"
971 if [ -f "$meson$EXESUF" ]; then
972 meson="$meson$EXESUF"
973 fi
974
975 # On Haiku, meson might show up in a "non-packaged" subfolder instead, see
976 # https://github.com/haiku/haiku/blob/r1beta5/docs/user/storage/storageintro.dox
977 if test "$host_os" = "haiku" && test ! -e "$meson" ; then
978 meson="$(cd pyvenv/non-packaged/bin; get_pwd)/meson"
979 fi
980
981 mkvenv_online_flag=""
982 if test "$download" = "enabled" ; then
983 mkvenv_online_flag=" --online"
984 fi
985
986 # Unconditionally install our tooling group. PyPI is allowed if enabled here.
987
988 $mkvenv ensuregroup $mkvenv_online_flag \
989 --dir "${source_path}/python/wheels" \
990 ${source_path}/pythondeps.toml tooling || exit 1
991
992 # Conditionally ensure Sphinx is installed.
993
994 if test "$docs" != "disabled" ; then
995 if ! $mkvenv ensuregroup \
996 $(test "$docs" = "enabled" && echo "$mkvenv_online_flag") \
997 ${source_path}/pythondeps.toml docs;
998 then
999 if test "$docs" = "enabled" ; then
1000 exit 1
1001 fi
1002 echo "Sphinx not found/usable, disabling docs."
1003 docs=disabled
1004 else
1005 docs=enabled
1006 fi
1007 fi
1008
1009 # Probe for ninja
1010
1011 if test -z "$ninja"; then
1012 for c in ninja ninja-build samu; do
1013 if has $c; then
1014 ninja=$(command -v "$c")
1015 break
1016 fi
1017 done
1018 if test -z "$ninja"; then
1019 error_exit "Cannot find Ninja"
1020 fi
1021 fi
1022
1023 if test "$host_os" = "bogus"; then
1024 # Now that we know that we're not printing the help and that
1025 # the compiler works (so the results of the check_defines we used
1026 # to identify the OS are reliable), if we didn't recognize the
1027 # host OS we should stop now.
1028 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1029 fi
1030
1031 # test for any invalid configuration combinations
1032 if test "$host_os" = "windows" && ! has "$dlltool"; then
1033 if test "$plugins" = "yes"; then
1034 error_exit "TCG plugins requires dlltool to build on Windows platforms"
1035 fi
1036 plugins="no"
1037 fi
1038 if test "$tcg" = "disabled" ; then
1039 if test "$plugins" = "yes"; then
1040 error_exit "Can't enable plugins on non-TCG builds"
1041 fi
1042 plugins="no"
1043 fi
1044 if test "$static" = "yes" ; then
1045 if test "$plugins" = "yes"; then
1046 error_exit "static and plugins are mutually incompatible"
1047 fi
1048 plugins="no"
1049 fi
1050 if test "$plugins" != "no"; then
1051 if has_meson_option "-Dtcg_interpreter=true"; then
1052 plugins="no"
1053 else
1054 plugins=yes
1055 fi
1056 fi
1057
1058 cat > $TMPC << EOF
1059
1060 #ifdef __linux__
1061 # define THREAD __thread
1062 #else
1063 # define THREAD
1064 #endif
1065 static THREAD int tls_var;
1066 int main(void) { return tls_var; }
1067 EOF
1068
1069 if test "$host_os" = windows ; then
1070 if test "$pie" = "yes"; then
1071 error_exit "PIE not available due to missing OS support"
1072 fi
1073 pie=no
1074 fi
1075
1076 if test "$pie" != "no"; then
1077 if test "$static" = "yes"; then
1078 pie_ldflags=-static-pie
1079 else
1080 pie_ldflags=-pie
1081 fi
1082 if compile_prog "-Werror -fPIE -DPIE" "$pie_ldflags"; then
1083 pie="yes"
1084 elif test "$pie" = "yes"; then
1085 error_exit "-static-pie not available due to missing toolchain support"
1086 else
1087 echo "Disabling PIE due to missing toolchain support"
1088 pie="no"
1089 fi
1090 fi
1091
1092 ##########################################
1093
1094 if test -z "${target_list+xxx}" ; then
1095 default_targets=yes
1096 for target in $default_target_list; do
1097 target_list="$target_list $target"
1098 done
1099 target_list="${target_list# }"
1100 else
1101 default_targets=no
1102 target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1103 for target in $target_list; do
1104 # Check that we recognised the target name; this allows a more
1105 # friendly error message than if we let it fall through.
1106 case " $default_target_list " in
1107 *" $target "*)
1108 ;;
1109 *)
1110 error_exit "Unknown target name '$target'"
1111 ;;
1112 esac
1113 done
1114 fi
1115
1116 if test "$tcg" = "auto"; then
1117 if test -z "$target_list"; then
1118 tcg="disabled"
1119 else
1120 tcg="enabled"
1121 fi
1122 fi
1123
1124 #########################################
1125 # gdb test
1126
1127 if test -n "$gdb_bin"; then
1128 gdb_version_string=$($gdb_bin --version | head -n 1)
1129 # Extract last field in the version string
1130 gdb_version=${gdb_version_string##* }
1131 if version_ge $gdb_version 9.1; then
1132 gdb_arches=$($python "$source_path/scripts/probe-gdb-support.py" $gdb_bin)
1133 else
1134 gdb_bin=""
1135 fi
1136 fi
1137
1138 ##########################################
1139 # big/little endian test
1140 cat > $TMPC << EOF
1141 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1142 # error LITTLE
1143 #endif
1144 int main(void) { return 0; }
1145 EOF
1146
1147 if ! compile_prog ; then
1148 bigendian="no"
1149 else
1150 cat > $TMPC << EOF
1151 #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
1152 # error BIG
1153 #endif
1154 int main(void) { return 0; }
1155 EOF
1156
1157 if ! compile_prog ; then
1158 bigendian="yes"
1159 else
1160 echo big/little test failed
1161 exit 1
1162 fi
1163 fi
1164
1165 ##########################################
1166 # detect rust triple
1167
1168 meson_version=$($meson --version)
1169 if test "$rust" != disabled && ! version_ge "$meson_version" 1.12.0; then
1170 if test "$rust" = enabled; then
1171 $mkvenv ensuregroup --dir "${source_path}/python/wheels" \
1172 ${source_path}/pythondeps.toml meson-rust || exit 1
1173 else
1174 echo "Rust needs Meson 1.12.0, disabling" 2>&1
1175 rust=disabled
1176 fi
1177 fi
1178 if test "$rust" != disabled && has "$rustc" && $rustc -vV > "${TMPDIR1}/${TMPB}.out"; then
1179 rust_host_triple=$(sed -n 's/^host: //p' "${TMPDIR1}/${TMPB}.out")
1180 else
1181 if test "$rust" = enabled; then
1182 error_exit "could not execute rustc binary \"$rustc\""
1183 fi
1184 rust=disabled
1185 fi
1186 if test "$rust" != disabled && test -z "$rust_target_triple"; then
1187 # arch and os generally matches between meson and rust
1188 rust_arch=$host_arch
1189 # default to host vendor
1190 rust_vendor=$(echo "$rust_host_triple" | cut -d'-' -f2)
1191 rust_os=$host_os
1192 rust_osvariant=
1193
1194 # tweak rust_os if needed; also, machine and variant depend on the OS
1195 android=no
1196 case "$host_os" in
1197 darwin)
1198 # e.g. aarch64-apple-darwin
1199 rust_vendor=apple
1200 ;;
1201
1202 linux)
1203 # detect android/glibc/musl
1204 if check_define __ANDROID__; then
1205 rust_osvariant=android
1206 android=yes
1207 else
1208 cat > $TMPC << EOF
1209 #define _GNU_SOURCE
1210 #include <features.h>
1211 #ifndef __USE_GNU
1212 error using musl
1213 #endif
1214 EOF
1215 if compile_object; then
1216 rust_osvariant=gnu
1217 else
1218 rust_osvariant=musl
1219 fi
1220 fi
1221
1222 case "$cpu" in
1223 arm)
1224 # e.g. arm-unknown-linux-gnueabi, arm-unknown-linux-gnueabihf
1225 write_c_skeleton
1226 compile_object
1227 if $READELF -A $TMPO | grep Tag_API_VFP_args: > /dev/null; then
1228 rust_osvariant=${rust_osvariant}eabihf
1229 else
1230 rust_osvariant=${rust_osvariant}eabi
1231 fi
1232 ;;
1233 esac
1234 ;;
1235
1236 netbsd)
1237 # e.g. arm-unknown-netbsd-eabihf
1238 test "$host_arch" = arm && rust_osvariant=eabihf
1239 ;;
1240
1241 sunos)
1242 rust_vendor=pc
1243 rust_os=solaris
1244 ;;
1245
1246 windows)
1247 # e.g. aarch64-pc-windows-gnullvm, x86_64-pc-windows-gnu (MSVC not supported)
1248 rust_vendor=pc
1249 if test "$host_arch" = aarch64; then
1250 rust_osvariant=gnullvm
1251 else
1252 rust_osvariant=gnu
1253 fi
1254 ;;
1255 esac
1256
1257 # now tweak the architecture part, possibly based on pre-canonicalization --cpu
1258 case "$host_arch" in
1259 arm)
1260 # preserve ISA version (armv7 etc.) from $raw_cpu if passed via --cpu
1261 rust_arch=$raw_cpu
1262 test "$rust_arch" = arm && test "$rust_os" != linux && rust_arch=armv7
1263 ;;
1264
1265 riscv64)
1266 # e.g. riscv64gc-unknown-linux-gnu, but riscv64-linux-android
1267 test "$android" = no && rust_arch=${rust_arch}gc
1268 ;;
1269
1270 sparc64)
1271 if test "$rust_os" = solaris; then
1272 rust_arch=sparcv9
1273 rust_vendor=sun
1274 fi
1275 ;;
1276
1277 x86_64)
1278 # e.g. x86_64-unknown-linux-gnux32
1279 test "$raw_cpu" = x32 && rust_osvariant=${rust_osvariant}x32
1280 ;;
1281 esac
1282
1283 if test "$android" = yes; then
1284 # e.g. aarch64-linux-android
1285 rust_target_triple=$rust_arch-$rust_os-$rust_osvariant
1286 else
1287 rust_target_triple=$rust_arch-$rust_vendor-$rust_os${rust_osvariant:+-$rust_osvariant}
1288 fi
1289 fi
1290
1291 ##########################################
1292 # functions to probe cross compilers
1293
1294 if test "$container_command" = ""; then
1295 container_command=$($python "$source_path"/tests/docker/docker.py probe)
1296 test "$container_command" = "no" && container_command=""
1297 fi
1298 if test $use_containers = "yes" && test "$container_command" != ""; then
1299 docker_py="$python $source_path/tests/docker/docker.py --command $container_command"
1300 fi
1301
1302 # cross compilers defaults, can be overridden with --cross-cc-ARCH
1303 : ${cross_prefix_aarch64="aarch64-linux-gnu-"}
1304 : ${cross_prefix_aarch64_be="$cross_prefix_aarch64"}
1305 : ${cross_prefix_alpha="alpha-linux-gnu-"}
1306 : ${cross_prefix_arm="arm-linux-gnueabihf-"}
1307 : ${cross_prefix_armeb="$cross_prefix_arm"}
1308 : ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"}
1309 : ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"}
1310 : ${cross_prefix_hppa="hppa-linux-gnu-"}
1311 : ${cross_prefix_i386="i686-linux-gnu-"}
1312 : ${cross_prefix_m68k="m68k-linux-gnu-"}
1313 : ${cross_prefix_microblaze="microblaze-linux-musl-"}
1314 : ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"}
1315 : ${cross_prefix_mips64="mips64-linux-gnuabi64-"}
1316 : ${cross_prefix_mipsel="mipsel-linux-gnu-"}
1317 : ${cross_prefix_mips="mips-linux-gnu-"}
1318 : ${cross_prefix_ppc="powerpc-linux-gnu-"}
1319 : ${cross_prefix_ppc64="powerpc64-linux-gnu-"}
1320 : ${cross_prefix_ppc64le="$cross_prefix_ppc64"}
1321 : ${cross_prefix_riscv64="riscv64-linux-gnu-"}
1322 : ${cross_prefix_s390x="s390x-linux-gnu-"}
1323 : ${cross_prefix_sh4="sh4-linux-gnu-"}
1324 : ${cross_prefix_sparc64="sparc64-linux-gnu-"}
1325 : ${cross_prefix_sparc="$cross_prefix_sparc64"}
1326 : ${cross_prefix_tricore="tricore-"}
1327 : ${cross_prefix_x86_64="x86_64-linux-gnu-"}
1328
1329 : ${cross_cc_aarch64_be="$cross_cc_aarch64"}
1330 : ${cross_cc_cflags_aarch64_be="-mbig-endian"}
1331 : ${cross_cc_armeb="$cross_cc_arm"}
1332 : ${cross_cc_cflags_armeb="-mbig-endian"}
1333 : ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"}
1334 : ${cross_cc_cflags_hexagon="-mv73 -O2 -static"}
1335 : ${cross_cc_cflags_i386="-m32"}
1336 : ${cross_cc_cflags_ppc="-m32 -mbig-endian"}
1337 : ${cross_cc_cflags_ppc64="-m64 -mbig-endian"}
1338 : ${cross_cc_ppc64le="$cross_cc_ppc64"}
1339 : ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"}
1340 : ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"}
1341 : ${cross_cc_sparc="$cross_cc_sparc64"}
1342 : ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"}
1343 : ${cross_cc_cflags_x86_64="-m64 -mcx16"}
1344
1345 compute_target_variable() {
1346 eval "$2="
1347 if eval test -n "\"\${cross_prefix_$1}\""; then
1348 if eval has "\"\${cross_prefix_$1}\$3\""; then
1349 eval "$2=\"\${cross_prefix_$1}\$3\""
1350 fi
1351 fi
1352 }
1353
1354 have_target() {
1355 for i; do
1356 case " $target_list " in
1357 *" $i "*) return 0;;
1358 *) ;;
1359 esac
1360 done
1361 return 1
1362 }
1363
1364 # probe_target_compiler TARGET
1365 #
1366 # Look for a compiler for the given target, either native or cross.
1367 # Set variables target_* if a compiler is found, and container_cross_*
1368 # if a Docker-based cross-compiler image is known for the target.
1369 # Set got_cross_cc to yes/no depending on whether a non-container-based
1370 # compiler was found.
1371 #
1372 # If TARGET is a user-mode emulation target, also set build_static to
1373 # "y" if static linking is possible.
1374 #
1375 probe_target_compiler() {
1376 # reset all output variables
1377 got_cross_cc=no
1378 container_image=
1379 container_hosts=
1380 container_cross_prefix=
1381 container_cross_cc=
1382 container_cross_ar=
1383 container_cross_as=
1384 container_cross_ld=
1385 container_cross_nm=
1386 container_cross_objcopy=
1387 container_cross_ranlib=
1388 container_cross_strip=
1389
1390 target_arch=${1%%-*}
1391 case $target_arch in
1392 aarch64) container_hosts="x86_64 aarch64" ;;
1393 aarch64_be) container_hosts="x86_64 aarch64" ;;
1394 alpha) container_hosts=x86_64 ;;
1395 arm) container_hosts="x86_64 aarch64" ;;
1396 hexagon) container_hosts=x86_64 ;;
1397 hppa) container_hosts=x86_64 ;;
1398 i386) container_hosts=x86_64 ;;
1399 loongarch64) container_hosts=x86_64 ;;
1400 m68k) container_hosts=x86_64 ;;
1401 microblaze) container_hosts=x86_64 ;;
1402 mips64el) container_hosts=x86_64 ;;
1403 mips64) container_hosts=x86_64 ;;
1404 mipsel) container_hosts=x86_64 ;;
1405 mips) container_hosts=x86_64 ;;
1406 ppc) container_hosts=x86_64 ;;
1407 ppc64|ppc64le) container_hosts=x86_64 ;;
1408 riscv64) container_hosts=x86_64 ;;
1409 s390x) container_hosts=x86_64 ;;
1410 sh4) container_hosts=x86_64 ;;
1411 sparc64) container_hosts=x86_64 ;;
1412 tricore) container_hosts=x86_64 ;;
1413 x86_64) container_hosts="aarch64 ppc64le x86_64" ;;
1414 xtensa*) container_hosts=x86_64 ;;
1415 esac
1416
1417 for host in $container_hosts; do
1418 test "$container_command" != "" || continue
1419 test "$host" = "$cpu" || continue
1420 case $target_arch in
1421 # debian-all-test-cross architectures
1422
1423 aarch64_be)
1424 container_image=debian-all-test-cross
1425 container_cross_prefix=aarch64-linux-gnu-
1426 ;;
1427 alpha|hppa|m68k|mips|mipsel|riscv64|sh4|sparc64)
1428 container_image=debian-all-test-cross
1429 ;;
1430 mips64)
1431 container_image=debian-all-test-cross
1432 container_cross_prefix=mips64-linux-gnuabi64-
1433 ;;
1434 ppc|ppc64|ppc64le)
1435 container_image=debian-all-test-cross
1436 container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu-
1437 ;;
1438
1439 # architectures with individual containers
1440
1441 aarch64)
1442 # We don't have any bigendian build tools so we only use this for AArch64
1443 container_image=debian-arm64-cross
1444 ;;
1445 arm)
1446 # We don't have any bigendian build tools so we only use this for ARM
1447 container_image=debian-armhf-cross
1448 container_cross_prefix=arm-linux-gnueabihf-
1449 ;;
1450 hexagon)
1451 container_cross_prefix=hexagon-unknown-linux-musl-
1452 container_cross_cc=${container_cross_prefix}clang
1453 ;;
1454 i386)
1455 container_image=debian-i686-cross
1456 container_cross_prefix=i686-linux-gnu-
1457 ;;
1458 loongarch64)
1459 container_image=debian-loongarch-cross
1460 container_cross_prefix=loongarch64-unknown-linux-gnu-
1461 ;;
1462 microblaze)
1463 container_cross_prefix=microblaze-linux-musl-
1464 ;;
1465 mips64el)
1466 container_image=debian-all-test-cross
1467 container_cross_prefix=mips64el-linux-gnuabi64-
1468 ;;
1469 tricore)
1470 container_image=debian-tricore-cross
1471 container_cross_prefix=tricore-
1472 ;;
1473 x86_64)
1474 container_image=debian-amd64-cross
1475 ;;
1476 xtensa*)
1477 container_image=debian-xtensa-cross
1478
1479 # default to the dc232b cpu
1480 container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf-
1481 ;;
1482 esac
1483 # Debian and GNU architecture names usually match
1484 : ${container_image:=debian-$target_arch-cross}
1485 : ${container_cross_prefix:=$target_arch-linux-gnu-}
1486 : ${container_cross_cc:=${container_cross_prefix}gcc}
1487 : ${container_cross_ar:=${container_cross_prefix}ar}
1488 : ${container_cross_as:=${container_cross_prefix}as}
1489 : ${container_cross_ld:=${container_cross_prefix}ld}
1490 : ${container_cross_nm:=${container_cross_prefix}nm}
1491 : ${container_cross_objcopy:=${container_cross_prefix}objcopy}
1492 : ${container_cross_ranlib:=${container_cross_prefix}ranlib}
1493 : ${container_cross_strip:=${container_cross_prefix}strip}
1494 done
1495
1496 try=cross
1497 # For softmmu/roms also look for a bi-endian or multilib-enabled host compiler
1498 if [ "${1%softmmu}" != "$1" ] || test "$target_arch" = "$cpu"; then
1499 case "$target_arch:$cpu" in
1500 aarch64_be:aarch64 | \
1501 armeb:arm | \
1502 i386:x86_64 | \
1503 ppc*:ppc64 | \
1504 sparc:sparc64 | \
1505 "$cpu:$cpu")
1506 try='native cross' ;;
1507 esac
1508 fi
1509 eval "target_cflags=\${cross_cc_cflags_$target_arch}"
1510 for thistry in $try; do
1511 case $thistry in
1512 native)
1513 target_cc=$cc
1514 target_ccas=$ccas
1515 target_ar=$ar
1516 target_as=$as
1517 target_ld=$ld
1518 target_nm=$nm
1519 target_objcopy=$objcopy
1520 target_ranlib=$ranlib
1521 target_strip=$strip
1522 ;;
1523 cross)
1524 target_cc=
1525 if eval test -n "\"\${cross_cc_$target_arch}\""; then
1526 if eval has "\"\${cross_cc_$target_arch}\""; then
1527 eval "target_cc=\"\${cross_cc_$target_arch}\""
1528 fi
1529 else
1530 compute_target_variable $target_arch target_cc gcc
1531 fi
1532 target_ccas=$target_cc
1533 compute_target_variable $target_arch target_ar ar
1534 compute_target_variable $target_arch target_as as
1535 compute_target_variable $target_arch target_ld ld
1536 compute_target_variable $target_arch target_nm nm
1537 compute_target_variable $target_arch target_objcopy objcopy
1538 compute_target_variable $target_arch target_ranlib ranlib
1539 compute_target_variable $target_arch target_strip strip
1540 ;;
1541 esac
1542
1543 if test -n "$target_cc"; then
1544 case $target_arch in
1545 i386|x86_64)
1546 if $target_cc --version | grep -qi "clang"; then
1547 continue
1548 fi
1549 ;;
1550 esac
1551 elif test -n "$target_as" && test -n "$target_ld"; then
1552 # Special handling for assembler only targets
1553 case $target in
1554 tricore-softmmu)
1555 build_static=
1556 got_cross_cc=yes
1557 break
1558 ;;
1559 *)
1560 continue
1561 ;;
1562 esac
1563 else
1564 continue
1565 fi
1566
1567 write_c_skeleton
1568 case $1 in
1569 *-softmmu)
1570 if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC &&
1571 do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then
1572 got_cross_cc=yes
1573 break
1574 fi
1575 ;;
1576 *)
1577 if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then
1578 build_static=y
1579 got_cross_cc=yes
1580 break
1581 fi
1582 if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then
1583 build_static=
1584 got_cross_cc=yes
1585 break
1586 fi
1587 ;;
1588 esac
1589 done
1590 if test $got_cross_cc != yes; then
1591 build_static=
1592 target_cc=
1593 target_ccas=
1594 target_ar=
1595 target_as=
1596 target_ld=
1597 target_nm=
1598 target_objcopy=
1599 target_ranlib=
1600 target_strip=
1601 fi
1602 test -n "$target_cc"
1603 }
1604
1605 write_target_makefile() {
1606 echo "PYTHON=$python"
1607 echo "EXTRA_CFLAGS=$target_cflags"
1608 if test -z "$target_cc" && test -z "$target_as"; then
1609 test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?"
1610 echo "$1: docker-image-$container_image" >> Makefile.prereqs
1611 if test -n "$container_cross_cc"; then
1612 echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1613 echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --"
1614 fi
1615 echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --"
1616 echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --"
1617 echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --"
1618 echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --"
1619 echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --"
1620 echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --"
1621 echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --"
1622 else
1623 if test -n "$target_cc"; then
1624 echo "CC=$target_cc"
1625 echo "CCAS=$target_ccas"
1626 fi
1627 if test -n "$target_ar"; then
1628 echo "AR=$target_ar"
1629 fi
1630 if test -n "$target_as"; then
1631 echo "AS=$target_as"
1632 fi
1633 if test -n "$target_ld"; then
1634 echo "LD=$target_ld"
1635 fi
1636 if test -n "$target_nm"; then
1637 echo "NM=$target_nm"
1638 fi
1639 if test -n "$target_objcopy"; then
1640 echo "OBJCOPY=$target_objcopy"
1641 fi
1642 if test -n "$target_ranlib"; then
1643 echo "RANLIB=$target_ranlib"
1644 fi
1645 if test -n "$target_strip"; then
1646 echo "STRIP=$target_strip"
1647 fi
1648 fi
1649 }
1650
1651 #######################################
1652 # cross-compiled firmware targets
1653
1654 # Set up build tree symlinks that point back into the source tree
1655 # (these can be both files and directories).
1656 # Caution: avoid adding files or directories here using wildcards. This
1657 # will result in problems later if a new file matching the wildcard is
1658 # added to the source tree -- nothing will cause configure to be rerun
1659 # so the build tree will be missing the link back to the new file, and
1660 # tests might fail. Prefer to keep the relevant files in their own
1661 # directory and symlink the directory instead.
1662 LINKS="Makefile"
1663 LINKS="$LINKS docs/config"
1664 LINKS="$LINKS pc-bios/optionrom/Makefile"
1665 LINKS="$LINKS pc-bios/s390-ccw/Makefile"
1666 LINKS="$LINKS pc-bios/vof/Makefile"
1667 LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
1668 LINKS="$LINKS tests/data"
1669 LINKS="$LINKS tests/qemu-iotests/check tests/qemu-iotests/Makefile"
1670 LINKS="$LINKS python"
1671 for f in $LINKS ; do
1672 if [ -e "$source_path/$f" ]; then
1673 symlink "$source_path/$f" "$f"
1674 fi
1675 done
1676
1677 # use included Linux headers for KVM architectures
1678 if test "$host_os" = "linux" && test -n "$linux_arch"; then
1679 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
1680 fi
1681
1682 echo "# Automatically generated by configure - do not modify" > Makefile.prereqs
1683
1684 # Mac OS X ships with a broken assembler
1685 if have_target i386-softmmu x86_64-softmmu && \
1686 test "$host_os" != "darwin" && test "$host_os" != "sunos" && \
1687 test "$host_os" != "haiku" && \
1688 probe_target_compiler i386-softmmu; then
1689 subdirs="$subdirs pc-bios/optionrom"
1690 config_mak=pc-bios/optionrom/config.mak
1691 echo "# Automatically generated by configure - do not modify" > $config_mak
1692 echo "TOPSRC_DIR=$source_path" >> $config_mak
1693 write_target_makefile >> $config_mak
1694 fi
1695
1696 if have_target ppc-softmmu ppc64-softmmu && \
1697 probe_target_compiler ppc-softmmu; then
1698 subdirs="$subdirs pc-bios/vof"
1699 config_mak=pc-bios/vof/config.mak
1700 echo "# Automatically generated by configure - do not modify" > $config_mak
1701 echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak
1702 write_target_makefile >> $config_mak
1703 fi
1704
1705 # Only build s390-ccw bios if the compiler has -march=z900 or -march=z10
1706 # (which is the lowest architecture level that Clang supports)
1707 if have_target s390x-softmmu && probe_target_compiler s390x-softmmu && \
1708 GIT=git "$source_path/scripts/git-submodule.sh" "$git_submodules_action" roms/SLOF >> config.log 2>&1; then
1709 write_c_skeleton
1710 do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC
1711 has_z900=$?
1712 if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then
1713 if [ $has_z900 != 0 ]; then
1714 echo "WARNING: Your compiler does not support the z900!"
1715 echo " The s390-ccw bios will only work with guest CPUs >= z10."
1716 fi
1717 subdirs="$subdirs pc-bios/s390-ccw"
1718 config_mak=pc-bios/s390-ccw/config-host.mak
1719 echo "# Automatically generated by configure - do not modify" > $config_mak
1720 echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak
1721 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_mak
1722 write_target_makefile >> $config_mak
1723 fi
1724 fi
1725
1726 #######################################
1727 # generate config-host.mak
1728
1729 config_host_mak="config-host.mak"
1730
1731 echo "# Automatically generated by configure - do not modify" > $config_host_mak
1732 echo >> $config_host_mak
1733
1734 echo all: >> $config_host_mak
1735
1736 echo "SRC_PATH=$source_path" >> $config_host_mak
1737 echo "TARGET_DIRS=$target_list" >> $config_host_mak
1738 echo "GDB=$gdb_bin" >> $config_host_mak
1739 if test "$container_command" != ""; then
1740 echo "CONTAINER_COMMAND=$container_command" >> $config_host_mak
1741 fi
1742 echo "SUBDIRS=$subdirs" >> $config_host_mak
1743 echo "PYTHON=$python" >> $config_host_mak
1744 echo "MKVENV_ENSUREGROUP=$mkvenv ensuregroup $mkvenv_online_flag" >> $config_host_mak
1745 echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
1746 echo "MESON=$meson" >> $config_host_mak
1747 echo "NINJA=$ninja" >> $config_host_mak
1748 echo "EXESUF=$EXESUF" >> $config_host_mak
1749 if test "$default_targets" = "yes"; then
1750 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
1751 fi
1752
1753 # tests/tcg configuration
1754 mkdir -p tests/tcg
1755 echo "# Automatically generated by configure - do not modify" > tests/tcg/$config_host_mak
1756 echo "SRC_PATH=$source_path" >> tests/tcg/$config_host_mak
1757 if test "$plugins" = "yes" ; then
1758 echo "CONFIG_PLUGIN=y" >> tests/tcg/$config_host_mak
1759 fi
1760 echo "PYTHON=$python" >> tests/tcg/$config_host_mak
1761
1762 tcg_tests_with_compilers=
1763 for target in $target_list; do
1764 arch=${target%%-*}
1765
1766 case $target in
1767 xtensa*-linux-user)
1768 # the toolchain is not complete with headers, only build system tests
1769 continue
1770 ;;
1771 *-softmmu)
1772 test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue
1773 qemu="qemu-system-$arch"
1774 ;;
1775 *-linux-user|*-bsd-user)
1776 qemu="qemu-$arch"
1777 ;;
1778 esac
1779
1780 if probe_target_compiler $target || test -n "$container_image"; then
1781 test -n "$container_image" && build_static=y
1782 mkdir -p "tests/tcg/$target"
1783 config_target_mak=tests/tcg/$target/config-target.mak
1784 ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile"
1785 echo "# Automatically generated by configure - do not modify" > "$config_target_mak"
1786 echo "TARGET_NAME=$arch" >> "$config_target_mak"
1787 echo "TARGET=$target" >> "$config_target_mak"
1788 write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak"
1789 echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
1790 echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
1791
1792 # will GDB work with these binaries?
1793 if test "${gdb_arches#*$arch}" != "$gdb_arches"; then
1794 echo "GDB=$gdb_bin" >> $config_target_mak
1795 fi
1796
1797 if test "${gdb_arches#*$arch}" != "$gdb_arches" && version_ge $gdb_version 14.1; then
1798 echo "GDB_HAS_SME_TILES=y" >> $config_target_mak
1799 else
1800 echo "GDB_HAS_SME_TILES=n" >> $config_target_mak
1801 fi
1802
1803 if test "${gdb_arches#*aarch64}" != "$gdb_arches" && version_ge $gdb_version 15.1; then
1804 echo "GDB_HAS_MTE=y" >> $config_target_mak
1805 fi
1806
1807 if test "${gdb_arches#*aarch64}" != "$gdb_arches" && version_ge $gdb_version 16.0; then
1808 # GDB has to support MTE in baremetal to allow debugging MTE in QEMU system mode
1809 echo "GDB_SUPPORTS_MTE_IN_BAREMETAL=y" >> $config_target_mak
1810 fi
1811
1812 echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs
1813 tcg_tests_with_compilers="$tcg_tests_with_compilers $target"
1814 fi
1815 done
1816
1817 if test "$tcg" = "enabled"; then
1818 echo "TCG_TESTS_WITH_COMPILERS=$tcg_tests_with_compilers" >> $config_host_mak
1819 fi
1820
1821 if test "$skip_meson" = no; then
1822 cross="config-meson.cross.new"
1823 meson_quote() {
1824 test $# = 0 && return
1825 echo "'$(echo $* | sed "s/ /','/g")'"
1826 }
1827
1828 echo "# Automatically generated by configure - do not modify" > $cross
1829 echo "[properties]" >> $cross
1830
1831 # unroll any custom device configs
1832 for a in $device_archs; do
1833 eval "c=\$devices_${a}"
1834 echo "${a}-softmmu = '$c'" >> $cross
1835 done
1836 if test "$rust" != disabled; then
1837 if test "$cross_compile" = "yes"; then
1838 . "$source_path/scripts/rust-to-clang-target.sh"
1839 clang_target=$(rust_to_clang_target "$rust_target_triple")
1840 echo "bindgen_clang_arguments = [$(meson_quote --target="$clang_target")]" >> $cross
1841 fi
1842 fi
1843
1844 echo "[built-in options]" >> $cross
1845 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
1846 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
1847 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross
1848 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
1849 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
1850 test -n "$objcc" && echo "objc_link_args = [$(meson_quote $OBJCFLAGS $LDFLAGS $EXTRA_OBJCFLAGS $EXTRA_LDFLAGS)]" >> $cross
1851
1852 # Only enable by default for git builds and on select OSes
1853 echo "# environment defaults, can still be overridden on " >> $cross
1854 echo "# the command line" >> $cross
1855 if test -e "$source_path/.git" && \
1856 { test "$host_os" = linux || test "$host_os" = "windows"; }; then
1857 echo 'werror = true' >> $cross
1858 fi
1859 echo "[project options]" >> $cross
1860 if test "$SMBD" != ''; then
1861 echo "smbd = $(meson_quote "$SMBD")" >> $cross
1862 fi
1863 if test "${QEMU_GA_MANUFACTURER}" != ''; then
1864 echo "qemu_ga_manufacturer = $(meson_quote "${QEMU_GA_MANUFACTURER}")" >> $cross
1865 fi
1866 if test "${QEMU_GA_DISTRO}" != ''; then
1867 echo "qemu_ga_distro = $(meson_quote "${QEMU_GA_DISTRO}")" >> $cross
1868 fi
1869 if test "${QEMU_GA_VERSION}" != ''; then
1870 echo "qemu_ga_version = $(meson_quote "${QEMU_GA_VERSION}")" >> $cross
1871 fi
1872
1873 echo >> $cross
1874 echo "[binaries]" >> $cross
1875 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
1876 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
1877 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
1878 if test "$rust" != disabled; then
1879 if test "$rust_host_triple" != "$rust_target_triple"; then
1880 echo "rust = [$(meson_quote $rustc --target "$rust_target_triple")]" >> $cross
1881 echo "rustdoc = [$(meson_quote $rustdoc --target "$rust_target_triple")]" >> $cross
1882 else
1883 echo "rust = [$(meson_quote $rustc)]" >> $cross
1884 echo "rustdoc = [$(meson_quote $rustdoc)]" >> $cross
1885 fi
1886 fi
1887 echo "ar = [$(meson_quote $ar)]" >> $cross
1888 echo "dlltool = [$(meson_quote $dlltool)]" >> $cross
1889 echo "nm = [$(meson_quote $nm)]" >> $cross
1890 echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross
1891 echo "pkg-config = [$(meson_quote $pkg_config)]" >> $cross
1892 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
1893 echo "readelf = [$(meson_quote $readelf)]" >> $cross
1894 if has $sdl2_config; then
1895 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
1896 fi
1897 echo "strip = [$(meson_quote $strip)]" >> $cross
1898 echo "widl = [$(meson_quote $widl)]" >> $cross
1899 echo "windres = [$(meson_quote $windres)]" >> $cross
1900 echo "windmc = [$(meson_quote $windmc)]" >> $cross
1901 if test "$cross_compile" = "yes"; then
1902 echo "[host_machine]" >> $cross
1903 echo "system = '$host_os'" >> $cross
1904 echo "cpu_family = '$cpu'" >> $cross
1905 echo "cpu = '$cpu'" >> $cross
1906 if test "$bigendian" = "yes" ; then
1907 echo "endian = 'big'" >> $cross
1908 else
1909 echo "endian = 'little'" >> $cross
1910 fi
1911
1912 native="config-meson.native.new"
1913 echo "# Automatically generated by configure - do not modify" > $native
1914 echo "[binaries]" >> $native
1915 echo "c = [$(meson_quote $host_cc)]" >> $native
1916 if test "$rust" != disabled; then
1917 echo "rust = [$(meson_quote $rustc)]" >> $native
1918 fi
1919 mv $native config-meson.native
1920 meson_option_add --native-file
1921 meson_option_add config-meson.native
1922 fi
1923 mv $cross config-meson.cross
1924 meson_add_machine_file config-meson.cross
1925 if test -f "$source_path/configs/meson/$host_os.txt"; then
1926 meson_add_machine_file $source_path/configs/meson/$host_os.txt
1927 fi
1928
1929 rm -rf meson-private meson-info meson-logs
1930
1931 test "$download" = "disabled" && meson_option_add "--wrap-mode=nodownload"
1932 test "$default_feature" = no && meson_option_add -Dauto_features=disabled
1933 test "$static" = yes && meson_option_add -Dprefer_static=true
1934 test "$pie" = no && meson_option_add -Db_pie=false
1935
1936 # QEMU options
1937 test "$rust" != "disabled" && meson_option_add "-Drust=$rust"
1938 test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi"
1939 test "$docs" != auto && meson_option_add "-Ddocs=$docs"
1940 test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
1941 test "$plugins" = yes && meson_option_add "-Dplugins=true"
1942 test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg"
1943 test -n "$gdb_bin" && meson_option_add "-Dgdb=$gdb_bin"
1944
1945 run_meson() {
1946 NINJA=$ninja $meson setup "$@" "$PWD" "$source_path"
1947 }
1948 eval run_meson $meson_options
1949 if test "$?" -ne 0 ; then
1950 error_exit "meson setup failed"
1951 fi
1952 echo "$meson" > build.ninja.stamp
1953 else
1954 if test -f meson-private/cmd_line.txt; then
1955 # Adjust old command line options that were removed
1956 # sed -i is not portable
1957 perl -i -ne '
1958 /^sphinx_build/ && next;
1959 print;' meson-private/cmd_line.txt
1960 fi
1961 fi
1962
1963 # Save the configure command line for later reuse.
1964 cat <<EOD >config.status
1965 #!/bin/sh
1966 # Generated by configure.
1967 # Run this file to recreate the current configuration.
1968 # Compiler output produced by configure, useful for debugging
1969 # configure, is in config.log if it exists.
1970 EOD
1971
1972 preserve_env() {
1973 envname=$1
1974
1975 eval envval=\$$envname
1976
1977 if test -n "$envval"
1978 then
1979 echo "$envname='$envval'" >> config.status
1980 echo "export $envname" >> config.status
1981 else
1982 echo "unset $envname" >> config.status
1983 fi
1984 }
1985
1986 # Preserve various env variables that influence what
1987 # features/build target configure will detect
1988 preserve_env AR
1989 preserve_env AS
1990 preserve_env CC
1991 preserve_env CFLAGS
1992 preserve_env CXX
1993 preserve_env CXXFLAGS
1994 preserve_env DLLTOOL
1995 preserve_env LD
1996 preserve_env LDFLAGS
1997 preserve_env LD_LIBRARY_PATH
1998 preserve_env NM
1999 preserve_env OBJCFLAGS
2000 preserve_env OBJCOPY
2001 preserve_env PATH
2002 preserve_env PKG_CONFIG
2003 preserve_env PKG_CONFIG_LIBDIR
2004 preserve_env PKG_CONFIG_PATH
2005 preserve_env PYTHON
2006 preserve_env QEMU_GA_MANUFACTURER
2007 preserve_env QEMU_GA_DISTRO
2008 preserve_env QEMU_GA_VERSION
2009 preserve_env SDL2_CONFIG
2010 preserve_env SMBD
2011 preserve_env STRIP
2012 preserve_env WIDL
2013 preserve_env WINDRES
2014 preserve_env WINDMC
2015
2016 printf "exec" >>config.status
2017 for i in "$0" "$@"; do
2018 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
2019 done
2020 echo ' "$@"' >>config.status
2021 chmod +x config.status
2022
2023 rm -r "$TMPDIR1"
2024
2025 if test "$rust" != disabled; then
2026 echo
2027 echo 'INFO: Rust bindings generation with `bindgen` might fail in some cases where'
2028 echo 'the detected `libclang` does not match the expected `clang` version/target. In'
2029 echo 'this case you must pass the path to `clang` and `libclang` to your build'
2030 echo 'command invocation using the environment variables CLANG_PATH and LIBCLANG_PATH'
2031 fi