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