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. 8unset 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! 11export CCACHE_RECACHE=yes 12 13# make source path absolute 14source_path=$(cd "$(dirname -- "$0")"; pwd) 15 16if test "$PWD" = "$source_path" 17then 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 44ifeq ($(MAKECMDGOALS),) 45recurse: all 46endif 47 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 ; \ 56 fi 57force: ; 58.PHONY: force 59GNUmakefile: ; 60 61EOF 62 cd build 63 exec "$source_path/configure" "$@" 64fi 65 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.) 71TMPDIR1="config-temp" 72rm -rf "${TMPDIR1}" 73if ! mkdir -p "${TMPDIR1}"; then 74 echo "ERROR: failed to create temporary directory" 75 exit 1 76fi 77 78TMPB="qemu-conf" 79TMPC="${TMPDIR1}/${TMPB}.c" 80TMPO="${TMPDIR1}/${TMPB}.o" 81TMPE="${TMPDIR1}/${TMPB}.exe" 82 83rm -f config.log 84 85# Print a helpful header at the top of config.log 86echo "# QEMU configure log $(date)" >> config.log 87printf "# Configured with:" >> config.log 88# repeat the invocation to log and stdout for CI 89invoke=$(printf " '%s'" "$0" "$@") 90test -n "$GITLAB_CI" && echo "configuring with: $invoke" 91{ echo "$invoke"; echo; echo "#"; } >> config.log 92 93quote_sh() { 94 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," 95} 96 97error_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 106} 107 108do_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 " 115funcs: ${FUNCNAME[*]} 116lines: ${BASH_LINENO[*]}" 117 '; fi 118 echo $compiler "$@" >> config.log 119 $compiler "$@" >> config.log 2>&1 || return $? 120} 121 122do_cc() { 123 do_compiler "$cc" $CPU_CFLAGS "$@" 124} 125 126compile_object() { 127 local_cflags="$1" 128 do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC 129} 130 131compile_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 136} 137 138# symbolically link $1 to $2. Portable version of "ln -sf". 139symlink() { 140 rm -rf "$2" 141 mkdir -p "$(dirname "$2")" 142 ln -s "$1" "$2" 143} 144 145# check whether a command is available to this shell (may be either an 146# executable or a builtin) 147has() { 148 type "$1" >/dev/null 2>&1 149} 150 151version_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 168} 169 170if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; 171then 172 error_exit "main directory cannot contain spaces nor colons" 173fi 174 175# parse CC options first; some compiler tests are used to establish 176# some defaults, based on the host environment 177 178# default parameters 179container_engine="auto" 180cpu="" 181cross_compile="no" 182cross_prefix="" 183host_cc="cc" 184EXTRA_CFLAGS="" 185EXTRA_CXXFLAGS="" 186EXTRA_OBJCFLAGS="" 187EXTRA_LDFLAGS="" 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. 200default_feature="" 201 202for 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 --cpu=*) cpu="$optarg" 215 ;; 216 --extra-cflags=*) 217 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 218 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 219 EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 220 ;; 221 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 222 ;; 223 --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 224 ;; 225 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 226 ;; 227 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 228 ;; 229 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 230 eval "cross_cc_cflags_${cc_arch}=\$optarg" 231 ;; 232 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 233 eval "cross_cc_${cc_arch}=\$optarg" 234 ;; 235 --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option" 236 ;; 237 --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*} 238 eval "cross_prefix_${cc_arch}=\$optarg" 239 ;; 240 --without-default-features) default_feature="no" 241 ;; 242 esac 243done 244 245default_cflags='-O2 -g' 246git_submodules_action="update" 247docs="auto" 248EXESUF="" 249system="yes" 250linux_user="" 251bsd_user="" 252plugins="$default_feature" 253subdirs="" 254ninja="" 255python= 256download="enabled" 257skip_meson=no 258use_containers="yes" 259gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 260gdb_arches="" 261 262# Don't accept a target_list environment variable. 263unset target_list 264unset target_list_exclude 265 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 269tcg="auto" 270cfi="false" 271 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. 275pie="" 276static="no" 277 278# Preferred compiler: 279# ${CC} (if set) 280# ${cross_prefix}gcc (if cross-prefix specified) 281# system compiler 282if test -z "${CC}${cross_prefix}"; then 283 cc="cc" 284else 285 cc="${CC-${cross_prefix}gcc}" 286fi 287 288if test -z "${CXX}${cross_prefix}"; then 289 cxx="c++" 290else 291 cxx="${CXX-${cross_prefix}g++}" 292fi 293 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 299if test -z "${objcc}${cross_prefix}"; then 300 if has clang; then 301 objcc=clang 302 else 303 objcc="$cc" 304 fi 305else 306 objcc="${objcc-${cross_prefix}clang}" 307fi 308 309ar="${AR-${cross_prefix}ar}" 310as="${AS-${cross_prefix}as}" 311ccas="${CCAS-$cc}" 312dlltool="${DLLTOOL-${cross_prefix}dlltool}" 313objcopy="${OBJCOPY-${cross_prefix}objcopy}" 314ld="${LD-${cross_prefix}ld}" 315ranlib="${RANLIB-${cross_prefix}ranlib}" 316nm="${NM-${cross_prefix}nm}" 317strip="${STRIP-${cross_prefix}strip}" 318widl="${WIDL-${cross_prefix}widl}" 319windres="${WINDRES-${cross_prefix}windres}" 320windmc="${WINDMC-${cross_prefix}windmc}" 321pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}" 322sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 323 324check_define() { 325cat > $TMPC <<EOF 326#if !defined($1) 327#error $1 not defined 328#endif 329int main(void) { return 0; } 330EOF 331 compile_object 332} 333 334write_c_skeleton() { 335 cat > $TMPC <<EOF 336int main(void) { return 0; } 337EOF 338} 339 340if check_define __linux__ ; then 341 targetos=linux 342elif check_define _WIN32 ; then 343 targetos=windows 344elif check_define __OpenBSD__ ; then 345 targetos=openbsd 346elif check_define __sun__ ; then 347 targetos=sunos 348elif check_define __HAIKU__ ; then 349 targetos=haiku 350elif check_define __FreeBSD__ ; then 351 targetos=freebsd 352elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 353 targetos=gnu/kfreebsd 354elif check_define __DragonFly__ ; then 355 targetos=dragonfly 356elif check_define __NetBSD__; then 357 targetos=netbsd 358elif check_define __APPLE__; then 359 targetos=darwin 360else 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 365fi 366 367if test ! -z "$cpu" ; then 368 # command line argument 369 : 370elif check_define __i386__ ; then 371 cpu="i386" 372elif check_define __x86_64__ ; then 373 if check_define __ILP32__ ; then 374 cpu="x32" 375 else 376 cpu="x86_64" 377 fi 378elif check_define __sparc__ ; then 379 if check_define __arch64__ ; then 380 cpu="sparc64" 381 else 382 cpu="sparc" 383 fi 384elif 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" 390 fi 391 else 392 cpu="ppc" 393 fi 394elif check_define __mips__ ; then 395 cpu="mips" 396elif check_define __s390__ ; then 397 if check_define __s390x__ ; then 398 cpu="s390x" 399 else 400 cpu="s390" 401 fi 402elif check_define __riscv ; then 403 if check_define _LP64 ; then 404 cpu="riscv64" 405 else 406 cpu="riscv32" 407 fi 408elif check_define __arm__ ; then 409 cpu="arm" 410elif check_define __aarch64__ ; then 411 cpu="aarch64" 412elif check_define __loongarch64 ; then 413 cpu="loongarch64" 414else 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'" 419fi 420 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. 425# 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. 428host_arch= 429linux_arch= 430case "$cpu" in 431 aarch64) 432 host_arch=aarch64 433 linux_arch=arm64 434 ;; 435 436 armv*b|armv*l|arm) 437 cpu=arm 438 host_arch=arm 439 linux_arch=arm 440 ;; 441 442 i386|i486|i586|i686) 443 cpu="i386" 444 host_arch=i386 445 linux_arch=x86 446 CPU_CFLAGS="-m32" 447 ;; 448 449 loongarch*) 450 cpu=loongarch64 451 host_arch=loongarch64 452 ;; 453 454 mips64*) 455 cpu=mips64 456 host_arch=mips 457 linux_arch=mips 458 ;; 459 mips*) 460 cpu=mips 461 host_arch=mips 462 linux_arch=mips 463 ;; 464 465 ppc) 466 host_arch=ppc 467 linux_arch=powerpc 468 CPU_CFLAGS="-m32" 469 ;; 470 ppc64) 471 host_arch=ppc64 472 linux_arch=powerpc 473 CPU_CFLAGS="-m64 -mbig-endian" 474 ;; 475 ppc64le) 476 cpu=ppc64 477 host_arch=ppc64 478 linux_arch=powerpc 479 CPU_CFLAGS="-m64 -mlittle-endian" 480 ;; 481 482 riscv32 | riscv64) 483 host_arch=riscv 484 linux_arch=riscv 485 ;; 486 487 s390) 488 linux_arch=s390 489 CPU_CFLAGS="-m31" 490 ;; 491 s390x) 492 host_arch=s390x 493 linux_arch=s390 494 CPU_CFLAGS="-m64" 495 ;; 496 497 sparc|sun4[cdmuv]) 498 cpu=sparc 499 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" 500 ;; 501 sparc64) 502 host_arch=sparc64 503 CPU_CFLAGS="-m64 -mcpu=ultrasparc" 504 ;; 505 506 x32) 507 cpu="x86_64" 508 host_arch=x86_64 509 linux_arch=x86 510 CPU_CFLAGS="-mx32" 511 ;; 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" 520 ;; 521esac 522 523if 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." 528fi 529if 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." 532fi 533 534check_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))' 538} 539 540first_python= 541if 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 554 fi 555 fi 556 done 557else 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 566 fi 567fi 568 569# Check for ancillary tools used in testing 570genisoimage= 571for binary in genisoimage mkisofs 572do 573 if has $binary 574 then 575 genisoimage=$(command -v "$binary") 576 break 577 fi 578done 579 580if test "$targetos" = "windows" ; then 581 EXESUF=".exe" 582fi 583 584meson_option_build_array() { 585 printf '[' 586 (if test "$targetos" = windows; then 587 IFS=\; 588 else 589 IFS=: 590 fi 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' 598} 599 600. "$source_path/scripts/meson-buildoptions.sh" 601 602meson_options= 603meson_option_add() { 604 local arg 605 for arg; do 606 meson_options="$meson_options $(quote_sh "$arg")" 607 done 608} 609meson_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 615 fi 616} 617 618meson_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" 623 fi 624} 625 626for opt do 627 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 628 case "$opt" in 629 --help|-h) show_help=yes 630 ;; 631 --version|-V) exec cat "$source_path/VERSION" 632 ;; 633 --cross-prefix=*) 634 ;; 635 --cc=*) 636 ;; 637 --host-cc=*) host_cc="$optarg" 638 ;; 639 --cxx=*) 640 ;; 641 --objcc=*) 642 ;; 643 --make=*) 644 ;; 645 --install=*) 646 ;; 647 --python=*) python="$optarg" 648 ;; 649 --skip-meson) skip_meson=yes 650 ;; 651 --ninja=*) ninja="$optarg" 652 ;; 653 --extra-cflags=*) 654 ;; 655 --extra-cxxflags=*) 656 ;; 657 --extra-objcflags=*) 658 ;; 659 --extra-ldflags=*) 660 ;; 661 --cross-cc-*) 662 ;; 663 --cross-prefix-*) 664 ;; 665 --enable-docs) docs=enabled 666 ;; 667 --disable-docs) docs=disabled 668 ;; 669 --cpu=*) 670 ;; 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" 674 fi 675 ;; 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" 679 fi 680 ;; 681 --with-default-devices) meson_option_add -Ddefault_devices=true 682 ;; 683 --without-default-devices) meson_option_add -Ddefault_devices=false 684 ;; 685 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 686 ;; 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" 695 fi 696 ;; 697 --without-default-features) # processed above 698 ;; 699 --static) static="yes" 700 ;; 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. 710 ;; 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' 718 ;; 719 --disable-tcg) tcg="disabled" 720 ;; 721 --enable-tcg) tcg="enabled" 722 ;; 723 --disable-system) system="no" 724 ;; 725 --enable-system) system="yes" 726 ;; 727 --disable-user) 728 linux_user="no" ; 729 bsd_user="no" ; 730 ;; 731 --enable-user) ;; 732 --disable-linux-user) linux_user="no" 733 ;; 734 --enable-linux-user) linux_user="yes" 735 ;; 736 --disable-bsd-user) bsd_user="no" 737 ;; 738 --enable-bsd-user) bsd_user="yes" 739 ;; 740 --enable-pie) pie="yes" 741 ;; 742 --disable-pie) pie="no" 743 ;; 744 --enable-cfi) cfi=true 745 ;; 746 --disable-cfi) cfi=false 747 ;; 748 --disable-download) download="disabled"; git_submodules_action=validate; 749 ;; 750 --enable-download) download="enabled"; git_submodules_action=update; 751 ;; 752 --enable-plugins) plugins="yes" 753 ;; 754 --disable-plugins) plugins="no" 755 ;; 756 --enable-containers) use_containers="yes" 757 ;; 758 --disable-containers) use_containers="no" 759 ;; 760 --container-engine=*) container_engine="$optarg" 761 ;; 762 --gdb=*) gdb_bin="$optarg" 763 ;; 764 # everything else has the same name in configure and meson 765 --*) meson_option_parse "$opt" "$optarg" 766 ;; 767 # Pass through -Dxxxx options to meson 768 -D*) meson_options="$meson_options $opt" 769 ;; 770 esac 771done 772 773if ! test -e "$source_path/.git" 774then 775 git_submodules_action="validate" 776fi 777 778if ! test -f "$source_path/subprojects/keycodemapdb/README" \ 779 && test "$download" = disabled 780then 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." 799 fi 800 echo 801 exit 1 802fi 803 804default_target_list="" 805mak_wilds="" 806 807if [ -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" 813 fi 814 if [ "$linux_user" = "yes" ]; then 815 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 816 fi 817 fi 818 if [ "$bsd_user" != no ]; then 819 if [ "$bsd_user" = "" ]; then 820 test $targetos = freebsd && bsd_user=yes 821 fi 822 if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then 823 error_exit "bsd-user not supported on this host OS" 824 fi 825 if [ "$bsd_user" = "yes" ]; then 826 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 827 fi 828 fi 829else 830 if [ "$linux_user" = yes ] || [ "$bsd_user" = yes ]; then 831 error_exit "user mode emulation not supported on this architecture" 832 fi 833fi 834if [ "$system" = "yes" ]; then 835 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 836fi 837 838for 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" 842 fi 843done 844 845if test x"$show_help" = x"yes" ; then 846cat << EOF 847 848Usage: configure [options] 849Options: [defaults in brackets after descriptions] 850 851Standard 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 857 858Advanced 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] 886EOF 887 meson_options_help 888cat << 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 894 895NOTE: The object files are built at the place where configure is launched 896EOF 897exit 0 898fi 899 900# Remove old dependency files to make sure that they get properly regenerated 901rm -f ./*/config-devices.mak.d 902 903if test -z "$python" 904then 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" 912 fi 913fi 914 915if ! 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" 921fi 922 923# Resolve PATH 924python="$(command -v "$python")" 925 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. 931 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. 940 941echo "python determined to be '$python'" 942echo "python version: $($python --version)" 943 944python="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)" 945if test "$?" -ne 0 ; then 946 error_exit "python venv creation failed" 947fi 948 949# Suppress writing compiled files 950python="$python -B" 951mkvenv="$python ${source_path}/python/scripts/mkvenv.py" 952 953# Finish preparing the virtual environment using vendored .whl files 954 955if $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 958fi 959$mkvenv ensuregroup --dir "${source_path}/python/wheels" \ 960 ${source_path}/pythondeps.toml meson || exit 1 961 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*. 966 967meson="$(cd pyvenv/bin; pwd)/meson" 968 969# Conditionally ensure Sphinx is installed. 970 971mkvenv_flags="" 972if test "$download" = "enabled" -a "$docs" = "enabled" ; then 973 mkvenv_flags="--online" 974fi 975 976if 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 983 fi 984 echo "Sphinx not found/usable, disabling docs." 985 docs=disabled 986 else 987 docs=enabled 988 fi 989fi 990 991# Probe for ninja 992 993if 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 998 fi 999 done 1000 if test -z "$ninja"; then 1001 error_exit "Cannot find Ninja" 1002 fi 1003fi 1004 1005if 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)')" 1011fi 1012 1013# test for any invalid configuration combinations 1014if test "$targetos" = "windows" && ! has "$dlltool"; then 1015 if test "$plugins" = "yes"; then 1016 error_exit "TCG plugins requires dlltool to build on Windows platforms" 1017 fi 1018 plugins="no" 1019fi 1020if test "$tcg" = "disabled" ; then 1021 if test "$plugins" = "yes"; then 1022 error_exit "Can't enable plugins on non-TCG builds" 1023 fi 1024 plugins="no" 1025fi 1026if test "$static" = "yes" ; then 1027 if test "$plugins" = "yes"; then 1028 error_exit "static and plugins are mutually incompatible" 1029 fi 1030 plugins="no" 1031fi 1032if test "$plugins" != "no"; then 1033 plugins=yes 1034 subdirs="$subdirs contrib/plugins" 1035fi 1036 1037cat > $TMPC << EOF 1038 1039#ifdef __linux__ 1040# define THREAD __thread 1041#else 1042# define THREAD 1043#endif 1044static THREAD int tls_var; 1045int main(void) { return tls_var; } 1046EOF 1047 1048if test "$targetos" = windows || test "$targetos" = haiku; then 1049 if test "$pie" = "yes"; then 1050 error_exit "PIE not available due to missing OS support" 1051 fi 1052 pie=no 1053fi 1054 1055if test "$pie" != "no"; then 1056 if test "$static" = "yes"; then 1057 pie_ldflags=-static-pie 1058 else 1059 pie_ldflags=-pie 1060 fi 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" 1068 fi 1069fi 1070 1071########################################## 1072 1073if 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# }" 1079else 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 "*) 1087 ;; 1088 *) 1089 error_exit "Unknown target name '$target'" 1090 ;; 1091 esac 1092 done 1093fi 1094 1095if test "$tcg" = "auto"; then 1096 if test -z "$target_list"; then 1097 tcg="disabled" 1098 else 1099 tcg="enabled" 1100 fi 1101fi 1102 1103######################################### 1104# gdb test 1105 1106if 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="" 1112 fi 1113fi 1114 1115########################################## 1116# big/little endian test 1117cat > $TMPC << EOF 1118#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 1119# error LITTLE 1120#endif 1121int main(void) { return 0; } 1122EOF 1123 1124if ! compile_prog ; then 1125 bigendian="no" 1126else 1127 cat > $TMPC << EOF 1128#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 1129# error BIG 1130#endif 1131int main(void) { return 0; } 1132EOF 1133 1134 if ! compile_prog ; then 1135 bigendian="yes" 1136 else 1137 echo big/little test failed 1138 exit 1 1139 fi 1140fi 1141 1142########################################## 1143# functions to probe cross compilers 1144 1145container="no" 1146runc="" 1147if 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 1156 fi 1157fi 1158 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-"} 1186 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"} 1202 1203compute_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\"" 1208 fi 1209 fi 1210} 1211 1212have_target() { 1213 for i; do 1214 case " $target_list " in 1215 *" $i "*) return 0;; 1216 *) ;; 1217 esac 1218 done 1219 return 1 1220} 1221 1222# probe_target_compiler TARGET 1223# 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. 1229# 1230# If TARGET is a user-mode emulation target, also set build_static to 1231# "y" if static linking is possible. 1232# 1233probe_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= 1246 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 1274 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 1284 ;; 1285 alpha) 1286 container_image=debian-legacy-test-cross 1287 container_cross_prefix=alpha-linux-gnu- 1288 container_cross_cc=${container_cross_prefix}gcc 1289 ;; 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- 1294 ;; 1295 cris) 1296 container_image=fedora-cris-cross 1297 container_cross_prefix=cris-linux-gnu- 1298 ;; 1299 hexagon) 1300 container_image=debian-hexagon-cross 1301 container_cross_prefix=hexagon-unknown-linux-musl- 1302 container_cross_cc=${container_cross_prefix}clang 1303 ;; 1304 hppa) 1305 container_image=debian-all-test-cross 1306 container_cross_prefix=hppa-linux-gnu- 1307 container_cross_cc=${container_cross_prefix}gcc 1308 ;; 1309 i386) 1310 container_image=debian-i686-cross 1311 container_cross_prefix=i686-linux-gnu- 1312 ;; 1313 loongarch64) 1314 container_image=debian-loongarch-cross 1315 container_cross_prefix=loongarch64-unknown-linux-gnu- 1316 ;; 1317 m68k) 1318 container_image=debian-all-test-cross 1319 container_cross_prefix=m68k-linux-gnu- 1320 container_cross_cc=${container_cross_prefix}gcc 1321 ;; 1322 microblaze) 1323 container_image=debian-microblaze-cross 1324 container_cross_prefix=microblaze-linux-musl- 1325 ;; 1326 mips64el) 1327 container_image=debian-mips64el-cross 1328 container_cross_prefix=mips64el-linux-gnuabi64- 1329 ;; 1330 mips64) 1331 container_image=debian-all-test-cross 1332 container_cross_prefix=mips64-linux-gnuabi64- 1333 ;; 1334 mips) 1335 container_image=debian-all-test-cross 1336 container_cross_prefix=mips-linux-gnu- 1337 ;; 1338 nios2) 1339 container_image=debian-nios2-cross 1340 container_cross_prefix=nios2-linux-gnu- 1341 ;; 1342 ppc) 1343 container_image=debian-all-test-cross 1344 container_cross_prefix=powerpc-linux-gnu- 1345 container_cross_cc=${container_cross_prefix}gcc 1346 ;; 1347 ppc64|ppc64le) 1348 container_image=debian-all-test-cross 1349 container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu- 1350 ;; 1351 riscv64) 1352 container_image=debian-all-test-cross 1353 container_cross_prefix=riscv64-linux-gnu- 1354 ;; 1355 sh4) 1356 container_image=debian-legacy-test-cross 1357 container_cross_prefix=sh4-linux-gnu- 1358 ;; 1359 sparc64) 1360 container_image=debian-all-test-cross 1361 container_cross_prefix=sparc64-linux-gnu- 1362 ;; 1363 tricore) 1364 container_image=debian-tricore-cross 1365 container_cross_prefix=tricore- 1366 ;; 1367 x86_64) 1368 container_image=debian-amd64-cross 1369 container_cross_prefix=x86_64-linux-gnu- 1370 ;; 1371 xtensa*) 1372 container_image=debian-xtensa-cross 1373 1374 # default to the dc232b cpu 1375 container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf- 1376 ;; 1377 *) 1378 # Debian and GNU architecture names usually match 1379 container_image=debian-$target_arch-cross 1380 container_cross_prefix=$target_arch-linux-gnu- 1381 ;; 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 1392 1393 try=cross 1394 # For softmmu/roms we might be able to use the host compiler 1395 if [ "${1%softmmu}" != "$1" ]; then 1396 case "$target_arch:$cpu" in 1397 aarch64_be:aarch64 | \ 1398 armeb:arm | \ 1399 i386:x86_64 | \ 1400 mips*:mips64 | \ 1401 ppc*:ppc64 | \ 1402 sparc:sparc64 | \ 1403 "$cpu:$cpu") 1404 try='native cross' ;; 1405 esac 1406 fi 1407 eval "target_cflags=\${cross_cc_cflags_$target_arch}" 1408 for thistry in $try; do 1409 case $thistry in 1410 native) 1411 target_cc=$cc 1412 target_ccas=$ccas 1413 target_ar=$ar 1414 target_as=$as 1415 target_ld=$ld 1416 target_nm=$nm 1417 target_objcopy=$objcopy 1418 target_ranlib=$ranlib 1419 target_strip=$strip 1420 ;; 1421 cross) 1422 target_cc= 1423 if eval test -n "\"\${cross_cc_$target_arch}\""; then 1424 if eval has "\"\${cross_cc_$target_arch}\""; then 1425 eval "target_cc=\"\${cross_cc_$target_arch}\"" 1426 fi 1427 else 1428 compute_target_variable $target_arch target_cc gcc 1429 fi 1430 target_ccas=$target_cc 1431 compute_target_variable $target_arch target_ar ar 1432 compute_target_variable $target_arch target_as as 1433 compute_target_variable $target_arch target_ld ld 1434 compute_target_variable $target_arch target_nm nm 1435 compute_target_variable $target_arch target_objcopy objcopy 1436 compute_target_variable $target_arch target_ranlib ranlib 1437 compute_target_variable $target_arch target_strip strip 1438 ;; 1439 esac 1440 1441 if test -n "$target_cc"; then 1442 case $target_arch in 1443 i386|x86_64) 1444 if $target_cc --version | grep -qi "clang"; then 1445 continue 1446 fi 1447 ;; 1448 esac 1449 elif test -n "$target_as" && test -n "$target_ld"; then 1450 # Special handling for assembler only targets 1451 case $target in 1452 tricore-softmmu) 1453 build_static= 1454 got_cross_cc=yes 1455 break 1456 ;; 1457 *) 1458 continue 1459 ;; 1460 esac 1461 else 1462 continue 1463 fi 1464 1465 write_c_skeleton 1466 case $1 in 1467 *-softmmu) 1468 if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC && 1469 do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then 1470 got_cross_cc=yes 1471 break 1472 fi 1473 ;; 1474 *) 1475 if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then 1476 build_static=y 1477 got_cross_cc=yes 1478 break 1479 fi 1480 if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then 1481 build_static= 1482 got_cross_cc=yes 1483 break 1484 fi 1485 ;; 1486 esac 1487 done 1488 if test $got_cross_cc != yes; then 1489 build_static= 1490 target_cc= 1491 target_ccas= 1492 target_ar= 1493 target_as= 1494 target_ld= 1495 target_nm= 1496 target_objcopy= 1497 target_ranlib= 1498 target_strip= 1499 fi 1500 test -n "$target_cc" 1501} 1502 1503write_target_makefile() { 1504 echo "EXTRA_CFLAGS=$target_cflags" 1505 if test -z "$target_cc" && test -z "$target_as"; then 1506 test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?" 1507 echo "$1: docker-image-$container_image" >> Makefile.prereqs 1508 if test -n "$container_cross_cc"; then 1509 echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" 1510 echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" 1511 fi 1512 echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --" 1513 echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --" 1514 echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --" 1515 echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --" 1516 echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --" 1517 echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --" 1518 echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --" 1519 else 1520 if test -n "$target_cc"; then 1521 echo "CC=$target_cc" 1522 echo "CCAS=$target_ccas" 1523 fi 1524 if test -n "$target_ar"; then 1525 echo "AR=$target_ar" 1526 fi 1527 if test -n "$target_as"; then 1528 echo "AS=$target_as" 1529 fi 1530 if test -n "$target_ld"; then 1531 echo "LD=$target_ld" 1532 fi 1533 if test -n "$target_nm"; then 1534 echo "NM=$target_nm" 1535 fi 1536 if test -n "$target_objcopy"; then 1537 echo "OBJCOPY=$target_objcopy" 1538 fi 1539 if test -n "$target_ranlib"; then 1540 echo "RANLIB=$target_ranlib" 1541 fi 1542 if test -n "$target_strip"; then 1543 echo "STRIP=$target_strip" 1544 fi 1545 fi 1546} 1547 1548####################################### 1549# cross-compiled firmware targets 1550 1551# Set up build tree symlinks that point back into the source tree 1552# (these can be both files and directories). 1553# Caution: avoid adding files or directories here using wildcards. This 1554# will result in problems later if a new file matching the wildcard is 1555# added to the source tree -- nothing will cause configure to be rerun 1556# so the build tree will be missing the link back to the new file, and 1557# tests might fail. Prefer to keep the relevant files in their own 1558# directory and symlink the directory instead. 1559LINKS="Makefile" 1560LINKS="$LINKS docs/config" 1561LINKS="$LINKS pc-bios/optionrom/Makefile" 1562LINKS="$LINKS pc-bios/s390-ccw/Makefile" 1563LINKS="$LINKS pc-bios/vof/Makefile" 1564LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 1565LINKS="$LINKS tests/avocado tests/data" 1566LINKS="$LINKS tests/qemu-iotests/check" 1567LINKS="$LINKS python" 1568LINKS="$LINKS contrib/plugins/Makefile " 1569for f in $LINKS ; do 1570 if [ -e "$source_path/$f" ]; then 1571 symlink "$source_path/$f" "$f" 1572 fi 1573done 1574 1575echo "# Automatically generated by configure - do not modify" > Makefile.prereqs 1576 1577# Mac OS X ships with a broken assembler 1578if have_target i386-softmmu x86_64-softmmu && \ 1579 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 1580 test "$targetos" != "haiku" && \ 1581 probe_target_compiler i386-softmmu; then 1582 subdirs="$subdirs pc-bios/optionrom" 1583 config_mak=pc-bios/optionrom/config.mak 1584 echo "# Automatically generated by configure - do not modify" > $config_mak 1585 echo "TOPSRC_DIR=$source_path" >> $config_mak 1586 write_target_makefile >> $config_mak 1587fi 1588 1589if have_target ppc-softmmu ppc64-softmmu && \ 1590 probe_target_compiler ppc-softmmu; then 1591 subdirs="$subdirs pc-bios/vof" 1592 config_mak=pc-bios/vof/config.mak 1593 echo "# Automatically generated by configure - do not modify" > $config_mak 1594 echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak 1595 write_target_makefile >> $config_mak 1596fi 1597 1598# Only build s390-ccw bios if the compiler has -march=z900 or -march=z10 1599# (which is the lowest architecture level that Clang supports) 1600if have_target s390x-softmmu && probe_target_compiler s390x-softmmu && \ 1601 GIT=git "$source_path/scripts/git-submodule.sh" "$git_submodules_action" roms/SLOF >> config.log 2>&1; then 1602 write_c_skeleton 1603 do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC 1604 has_z900=$? 1605 if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then 1606 if [ $has_z900 != 0 ]; then 1607 echo "WARNING: Your compiler does not support the z900!" 1608 echo " The s390-ccw bios will only work with guest CPUs >= z10." 1609 fi 1610 subdirs="$subdirs pc-bios/s390-ccw" 1611 config_mak=pc-bios/s390-ccw/config-host.mak 1612 echo "# Automatically generated by configure - do not modify" > $config_mak 1613 echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak 1614 echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_mak 1615 write_target_makefile >> $config_mak 1616 fi 1617fi 1618 1619####################################### 1620# generate config-host.mak 1621 1622config_host_mak="config-host.mak" 1623 1624echo "# Automatically generated by configure - do not modify" > $config_host_mak 1625echo >> $config_host_mak 1626 1627echo all: >> $config_host_mak 1628 1629echo "SRC_PATH=$source_path" >> $config_host_mak 1630echo "TARGET_DIRS=$target_list" >> $config_host_mak 1631echo "GDB=$gdb_bin" >> $config_host_mak 1632if test "$container" != no; then 1633 echo "RUNC=$runc" >> $config_host_mak 1634fi 1635echo "SUBDIRS=$subdirs" >> $config_host_mak 1636echo "PYTHON=$python" >> $config_host_mak 1637echo "GENISOIMAGE=$genisoimage" >> $config_host_mak 1638echo "MESON=$meson" >> $config_host_mak 1639echo "NINJA=$ninja" >> $config_host_mak 1640echo "EXESUF=$EXESUF" >> $config_host_mak 1641 1642# use included Linux headers for KVM architectures 1643if test "$targetos" = "linux" && test -n "$linux_arch"; then 1644 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 1645fi 1646 1647for target in $target_list; do 1648 target_dir="$target" 1649 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 1650 case $target in 1651 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 1652 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 1653 esac 1654done 1655 1656if test "$default_targets" = "yes"; then 1657 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 1658fi 1659 1660# contrib/plugins configuration 1661echo "# Automatically generated by configure - do not modify" > contrib/plugins/$config_host_mak 1662echo "SRC_PATH=$source_path/contrib/plugins" >> contrib/plugins/$config_host_mak 1663echo "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak 1664echo "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak 1665echo "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config_host_mak 1666if test "$targetos" = windows; then 1667 echo "DLLTOOL=$dlltool" >> contrib/plugins/$config_host_mak 1668fi 1669if test "$targetos" = darwin; then 1670 echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak 1671fi 1672if test "$targetos" = windows; then 1673 echo "CONFIG_WIN32=y" >> contrib/plugins/$config_host_mak 1674fi 1675 1676# tests/tcg configuration 1677(config_host_mak=tests/tcg/config-host.mak 1678mkdir -p tests/tcg 1679echo "# Automatically generated by configure - do not modify" > $config_host_mak 1680echo "SRC_PATH=$source_path" >> $config_host_mak 1681 1682tcg_tests_targets= 1683for target in $target_list; do 1684 arch=${target%%-*} 1685 1686 case $target in 1687 xtensa*-linux-user) 1688 # the toolchain is not complete with headers, only build system tests 1689 continue 1690 ;; 1691 *-softmmu) 1692 test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue 1693 qemu="qemu-system-$arch" 1694 ;; 1695 *-linux-user|*-bsd-user) 1696 qemu="qemu-$arch" 1697 ;; 1698 esac 1699 1700 if probe_target_compiler $target || test -n "$container_image"; then 1701 test -n "$container_image" && build_static=y 1702 mkdir -p "tests/tcg/$target" 1703 config_target_mak=tests/tcg/$target/config-target.mak 1704 ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile" 1705 echo "# Automatically generated by configure - do not modify" > "$config_target_mak" 1706 echo "TARGET_NAME=$arch" >> "$config_target_mak" 1707 echo "TARGET=$target" >> "$config_target_mak" 1708 write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak" 1709 echo "BUILD_STATIC=$build_static" >> "$config_target_mak" 1710 echo "QEMU=$PWD/$qemu" >> "$config_target_mak" 1711 1712 # will GDB work with these binaries? 1713 if test "${gdb_arches#*$arch}" != "$gdb_arches"; then 1714 echo "GDB=$gdb_bin" >> $config_target_mak 1715 fi 1716 1717 echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs 1718 tcg_tests_targets="$tcg_tests_targets $target" 1719 fi 1720done 1721 1722if test "$tcg" = "enabled"; then 1723 echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak 1724fi 1725) 1726 1727if test "$skip_meson" = no; then 1728 cross="config-meson.cross.new" 1729 meson_quote() { 1730 test $# = 0 && return 1731 echo "'$(echo $* | sed "s/ /','/g")'" 1732 } 1733 1734 echo "# Automatically generated by configure - do not modify" > $cross 1735 echo "[properties]" >> $cross 1736 1737 # unroll any custom device configs 1738 for a in $device_archs; do 1739 eval "c=\$devices_${a}" 1740 echo "${a}-softmmu = '$c'" >> $cross 1741 done 1742 1743 echo "[built-in options]" >> $cross 1744 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 1745 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 1746 test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross 1747 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 1748 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 1749 1750 # Only enable by default for git builds and on select OSes 1751 echo "# environment defaults, can still be overridden on " >> $cross 1752 echo "# the command line" >> $cross 1753 if test -e "$source_path/.git" && \ 1754 { test "$targetos" = linux || test "$targetos" = "windows"; }; then 1755 echo 'werror = true' >> $cross 1756 fi 1757 echo "[project options]" >> $cross 1758 if test "$SMBD" != ''; then 1759 echo "smbd = $(meson_quote "$SMBD")" >> $cross 1760 fi 1761 if test "${QEMU_GA_MANUFACTURER}" != ''; then 1762 echo "qemu_ga_manufacturer = $(meson_quote "${QEMU_GA_MANUFACTURER}")" >> $cross 1763 fi 1764 if test "${QEMU_GA_DISTRO}" != ''; then 1765 echo "qemu_ga_distro = $(meson_quote "${QEMU_GA_DISTRO}")" >> $cross 1766 fi 1767 if test "${QEMU_GA_VERSION}" != ''; then 1768 echo "qemu_ga_version = $(meson_quote "${QEMU_GA_VERSION}")" >> $cross 1769 fi 1770 1771 echo >> $cross 1772 echo "[binaries]" >> $cross 1773 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 1774 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 1775 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 1776 echo "ar = [$(meson_quote $ar)]" >> $cross 1777 echo "dlltool = [$(meson_quote $dlltool)]" >> $cross 1778 echo "nm = [$(meson_quote $nm)]" >> $cross 1779 echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross 1780 echo "pkg-config = [$(meson_quote $pkg_config)]" >> $cross 1781 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 1782 if has $sdl2_config; then 1783 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 1784 fi 1785 echo "strip = [$(meson_quote $strip)]" >> $cross 1786 echo "widl = [$(meson_quote $widl)]" >> $cross 1787 echo "windres = [$(meson_quote $windres)]" >> $cross 1788 echo "windmc = [$(meson_quote $windmc)]" >> $cross 1789 if test "$cross_compile" = "yes"; then 1790 echo "[host_machine]" >> $cross 1791 echo "system = '$targetos'" >> $cross 1792 case "$cpu" in 1793 i386) 1794 echo "cpu_family = 'x86'" >> $cross 1795 ;; 1796 *) 1797 echo "cpu_family = '$cpu'" >> $cross 1798 ;; 1799 esac 1800 echo "cpu = '$cpu'" >> $cross 1801 if test "$bigendian" = "yes" ; then 1802 echo "endian = 'big'" >> $cross 1803 else 1804 echo "endian = 'little'" >> $cross 1805 fi 1806 1807 native="config-meson.native.new" 1808 echo "# Automatically generated by configure - do not modify" > $native 1809 echo "[binaries]" >> $native 1810 echo "c = [$(meson_quote $host_cc)]" >> $native 1811 mv $native config-meson.native 1812 meson_option_add --native-file 1813 meson_option_add config-meson.native 1814 fi 1815 mv $cross config-meson.cross 1816 meson_add_machine_file config-meson.cross 1817 if test -f "$source_path/configs/meson/$targetos.txt"; then 1818 meson_add_machine_file $source_path/configs/meson/$targetos.txt 1819 fi 1820 1821 rm -rf meson-private meson-info meson-logs 1822 1823 test "$download" = "disabled" && meson_option_add "--wrap-mode=nodownload" 1824 test "$default_feature" = no && meson_option_add -Dauto_features=disabled 1825 test "$static" = yes && meson_option_add -Dprefer_static=true 1826 test "$pie" = no && meson_option_add -Db_pie=false 1827 1828 # QEMU options 1829 test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi" 1830 test "$docs" != auto && meson_option_add "-Ddocs=$docs" 1831 test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE" 1832 test "$plugins" = yes && meson_option_add "-Dplugins=true" 1833 test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg" 1834 run_meson() { 1835 NINJA=$ninja $meson setup "$@" "$PWD" "$source_path" 1836 } 1837 eval run_meson $meson_options 1838 if test "$?" -ne 0 ; then 1839 error_exit "meson setup failed" 1840 fi 1841 echo "$meson" > build.ninja.stamp 1842else 1843 if test -f meson-private/cmd_line.txt; then 1844 # Adjust old command line options that were removed 1845 # sed -i is not portable 1846 perl -i -ne ' 1847 /^sphinx_build/ && next; 1848 print;' meson-private/cmd_line.txt 1849 fi 1850fi 1851 1852# Save the configure command line for later reuse. 1853cat <<EOD >config.status 1854#!/bin/sh 1855# Generated by configure. 1856# Run this file to recreate the current configuration. 1857# Compiler output produced by configure, useful for debugging 1858# configure, is in config.log if it exists. 1859EOD 1860 1861preserve_env() { 1862 envname=$1 1863 1864 eval envval=\$$envname 1865 1866 if test -n "$envval" 1867 then 1868 echo "$envname='$envval'" >> config.status 1869 echo "export $envname" >> config.status 1870 else 1871 echo "unset $envname" >> config.status 1872 fi 1873} 1874 1875# Preserve various env variables that influence what 1876# features/build target configure will detect 1877preserve_env AR 1878preserve_env AS 1879preserve_env CC 1880preserve_env CFLAGS 1881preserve_env CXX 1882preserve_env CXXFLAGS 1883preserve_env DLLTOOL 1884preserve_env LD 1885preserve_env LDFLAGS 1886preserve_env LD_LIBRARY_PATH 1887preserve_env NM 1888preserve_env OBJCFLAGS 1889preserve_env OBJCOPY 1890preserve_env PATH 1891preserve_env PKG_CONFIG 1892preserve_env PKG_CONFIG_LIBDIR 1893preserve_env PKG_CONFIG_PATH 1894preserve_env PYTHON 1895preserve_env QEMU_GA_MANUFACTURER 1896preserve_env QEMU_GA_DISTRO 1897preserve_env QEMU_GA_VERSION 1898preserve_env SDL2_CONFIG 1899preserve_env SMBD 1900preserve_env STRIP 1901preserve_env WIDL 1902preserve_env WINDRES 1903preserve_env WINDMC 1904 1905printf "exec" >>config.status 1906for i in "$0" "$@"; do 1907 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 1908done 1909echo ' "$@"' >>config.status 1910chmod +x config.status 1911 1912rm -r "$TMPDIR1" 1913