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. 8CLICOLOR_FORCE= GREP_OPTIONS= 9unset CLICOLOR_FORCE GREP_OPTIONS 10 11# Don't allow CCACHE, if present, to use cached results of compile tests! 12export CCACHE_RECACHE=yes 13 14# make source path absolute 15source_path=$(cd "$(dirname -- "$0")"; pwd) 16 17if test "$PWD" = "$source_path" 18then 19 echo "Using './build' as the directory for build output" 20 21 MARKER=build/auto-created-by-configure 22 23 if test -e build 24 then 25 if test -f $MARKER 26 then 27 rm -rf build 28 else 29 echo "ERROR: ./build dir already exists and was not previously created by configure" 30 exit 1 31 fi 32 fi 33 34 mkdir build 35 touch $MARKER 36 37 cat > GNUmakefile <<'EOF' 38# This file is auto-generated by configure to support in-source tree 39# 'make' command invocation 40 41ifeq ($(MAKECMDGOALS),) 42recurse: all 43endif 44 45.NOTPARALLEL: % 46%: force 47 @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...' 48 @$(MAKE) -C build -f Makefile $(MAKECMDGOALS) 49 @if test "$(MAKECMDGOALS)" = "distclean" && \ 50 test -e build/auto-created-by-configure ; \ 51 then \ 52 rm -rf build GNUmakefile ; \ 53 fi 54force: ; 55.PHONY: force 56GNUmakefile: ; 57 58EOF 59 cd build 60 exec $source_path/configure "$@" 61fi 62 63# Temporary directory used for files created while 64# configure runs. Since it is in the build directory 65# we can safely blow away any previous version of it 66# (and we need not jump through hoops to try to delete 67# it when configure exits.) 68TMPDIR1="config-temp" 69rm -rf "${TMPDIR1}" 70mkdir -p "${TMPDIR1}" 71if [ $? -ne 0 ]; then 72 echo "ERROR: failed to create temporary directory" 73 exit 1 74fi 75 76TMPB="qemu-conf" 77TMPC="${TMPDIR1}/${TMPB}.c" 78TMPO="${TMPDIR1}/${TMPB}.o" 79TMPCXX="${TMPDIR1}/${TMPB}.cxx" 80TMPE="${TMPDIR1}/${TMPB}.exe" 81 82rm -f config.log 83 84# Print a helpful header at the top of config.log 85echo "# QEMU configure log $(date)" >> config.log 86printf "# Configured with:" >> config.log 87printf " '%s'" "$0" "$@" >> config.log 88echo >> config.log 89echo "#" >> config.log 90 91quote_sh() { 92 printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," 93} 94 95print_error() { 96 (echo 97 echo "ERROR: $1" 98 while test -n "$2"; do 99 echo " $2" 100 shift 101 done 102 echo) >&2 103} 104 105error_exit() { 106 print_error "$@" 107 exit 1 108} 109 110do_compiler() { 111 # Run the compiler, capturing its output to the log. First argument 112 # is compiler binary to execute. 113 compiler="$1" 114 shift 115 if test -n "$BASH_VERSION"; then eval ' 116 echo >>config.log " 117funcs: ${FUNCNAME[*]} 118lines: ${BASH_LINENO[*]}" 119 '; fi 120 echo $compiler "$@" >> config.log 121 $compiler "$@" >> config.log 2>&1 || return $? 122 # Test passed. If this is an --enable-werror build, rerun 123 # the test with -Werror and bail out if it fails. This 124 # makes warning-generating-errors in configure test code 125 # obvious to developers. 126 if test "$werror" != "yes"; then 127 return 0 128 fi 129 # Don't bother rerunning the compile if we were already using -Werror 130 case "$*" in 131 *-Werror*) 132 return 0 133 ;; 134 esac 135 echo $compiler -Werror "$@" >> config.log 136 $compiler -Werror "$@" >> config.log 2>&1 && return $? 137 error_exit "configure test passed without -Werror but failed with -Werror." \ 138 "This is probably a bug in the configure script. The failing command" \ 139 "will be at the bottom of config.log." \ 140 "You can run configure with --disable-werror to bypass this check." 141} 142 143do_cc() { 144 do_compiler "$cc" $CPU_CFLAGS "$@" 145} 146 147do_cxx() { 148 do_compiler "$cxx" $CPU_CFLAGS "$@" 149} 150 151# Append $2 to the variable named $1, with space separation 152add_to() { 153 eval $1=\${$1:+\"\$$1 \"}\$2 154} 155 156update_cxxflags() { 157 # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those 158 # options which some versions of GCC's C++ compiler complain about 159 # because they only make sense for C programs. 160 QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS" 161 CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/) 162 for arg in $QEMU_CFLAGS; do 163 case $arg in 164 -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ 165 -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) 166 ;; 167 *) 168 QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg 169 ;; 170 esac 171 done 172} 173 174compile_object() { 175 local_cflags="$1" 176 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC 177} 178 179compile_prog() { 180 local_cflags="$1" 181 local_ldflags="$2" 182 do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \ 183 $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags 184} 185 186# symbolically link $1 to $2. Portable version of "ln -sf". 187symlink() { 188 rm -rf "$2" 189 mkdir -p "$(dirname "$2")" 190 ln -s "$1" "$2" 191} 192 193# check whether a command is available to this shell (may be either an 194# executable or a builtin) 195has() { 196 type "$1" >/dev/null 2>&1 197} 198 199version_ge () { 200 local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') 201 local_ver2=$(echo "$2" | tr . ' ') 202 while true; do 203 set x $local_ver1 204 local_first=${2-0} 205 # 'shift 2' if $2 is set, or 'shift' if $2 is not set 206 shift ${2:+2} 207 local_ver1=$* 208 set x $local_ver2 209 # the second argument finished, the first must be greater or equal 210 test $# = 1 && return 0 211 test $local_first -lt $2 && return 1 212 test $local_first -gt $2 && return 0 213 shift ${2:+2} 214 local_ver2=$* 215 done 216} 217 218glob() { 219 eval test -z '"${1#'"$2"'}"' 220} 221 222ld_has() { 223 $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 224} 225 226if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; 227then 228 error_exit "main directory cannot contain spaces nor colons" 229fi 230 231# default parameters 232cpu="" 233iasl="iasl" 234interp_prefix="/usr/gnemul/qemu-%M" 235static="no" 236cross_compile="no" 237cross_prefix="" 238audio_drv_list="default" 239block_drv_rw_whitelist="" 240block_drv_ro_whitelist="" 241block_drv_whitelist_tools="no" 242host_cc="cc" 243libs_qga="" 244debug_info="yes" 245lto="false" 246stack_protector="" 247safe_stack="" 248use_containers="yes" 249gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 250 251if test -e "$source_path/.git" 252then 253 git_submodules_action="update" 254else 255 git_submodules_action="ignore" 256fi 257 258git_submodules="ui/keycodemapdb" 259git="git" 260 261# Don't accept a target_list environment variable. 262unset target_list 263unset target_list_exclude 264 265# Default value for a variable defining feature "foo". 266# * foo="no" feature will only be used if --enable-foo arg is given 267# * foo="" feature will be searched for, and if found, will be used 268# unless --disable-foo is given 269# * foo="yes" this value will only be set by --enable-foo flag. 270# feature will searched for, 271# if not found, configure exits with error 272# 273# Always add --enable-foo and --disable-foo command line args. 274# Distributions want to ensure that several features are compiled in, and it 275# is impossible without a --enable-foo that exits if a feature is not found. 276 277default_feature="" 278# parse CC options second 279for opt do 280 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 281 case "$opt" in 282 --without-default-features) 283 default_feature="no" 284 ;; 285 esac 286done 287 288EXTRA_CFLAGS="" 289EXTRA_CXXFLAGS="" 290EXTRA_LDFLAGS="" 291 292xen_ctrl_version="$default_feature" 293vhost_kernel="$default_feature" 294vhost_net="$default_feature" 295vhost_crypto="$default_feature" 296vhost_scsi="$default_feature" 297vhost_vsock="$default_feature" 298vhost_user="no" 299vhost_user_fs="$default_feature" 300vhost_vdpa="$default_feature" 301rdma="$default_feature" 302pvrdma="$default_feature" 303gprof="no" 304debug_tcg="no" 305debug="no" 306sanitizers="no" 307tsan="no" 308fortify_source="$default_feature" 309gcov="no" 310EXESUF="" 311modules="no" 312module_upgrades="no" 313prefix="/usr/local" 314qemu_suffix="qemu" 315profiler="no" 316softmmu="yes" 317linux_user="" 318bsd_user="" 319pkgversion="" 320pie="" 321qom_cast_debug="yes" 322trace_backends="log" 323trace_file="trace" 324opengl="$default_feature" 325guest_agent="$default_feature" 326vss_win32_sdk="$default_feature" 327win_sdk="no" 328want_tools="$default_feature" 329coroutine="" 330coroutine_pool="$default_feature" 331debug_stack_usage="no" 332tls_priority="NORMAL" 333live_block_migration=${default_feature:-yes} 334replication=${default_feature:-yes} 335bochs=${default_feature:-yes} 336cloop=${default_feature:-yes} 337dmg=${default_feature:-yes} 338qcow1=${default_feature:-yes} 339vdi=${default_feature:-yes} 340vvfat=${default_feature:-yes} 341qed=${default_feature:-yes} 342parallels=${default_feature:-yes} 343debug_mutex="no" 344plugins="$default_feature" 345rng_none="no" 346secret_keyring="$default_feature" 347meson="" 348meson_args="" 349ninja="" 350gio="$default_feature" 351skip_meson=no 352slirp_smbd="$default_feature" 353 354# The following Meson options are handled manually (still they 355# are included in the automatically generated help message) 356 357# 1. Track which submodules are needed 358capstone="auto" 359fdt="auto" 360slirp="auto" 361 362# 2. Support --with/--without option 363default_devices="true" 364 365# 3. Automatically enable/disable other options 366tcg="enabled" 367cfi="false" 368 369# 4. Detection partly done in configure 370xen=${default_feature:+disabled} 371 372# parse CC options second 373for opt do 374 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 375 case "$opt" in 376 --cross-prefix=*) cross_prefix="$optarg" 377 cross_compile="yes" 378 ;; 379 --cc=*) CC="$optarg" 380 ;; 381 --cxx=*) CXX="$optarg" 382 ;; 383 --cpu=*) cpu="$optarg" 384 ;; 385 --extra-cflags=*) 386 EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 387 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 388 ;; 389 --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 390 ;; 391 --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 392 ;; 393 --enable-debug-info) debug_info="yes" 394 ;; 395 --disable-debug-info) debug_info="no" 396 ;; 397 --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 398 ;; 399 --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 400 eval "cross_cc_cflags_${cc_arch}=\$optarg" 401 cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 402 ;; 403 --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 404 cc_archs="$cc_archs $cc_arch" 405 eval "cross_cc_${cc_arch}=\$optarg" 406 cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 407 ;; 408 esac 409done 410# OS specific 411# Using uname is really, really broken. Once we have the right set of checks 412# we can eliminate its usage altogether. 413 414# Preferred compiler: 415# ${CC} (if set) 416# ${cross_prefix}gcc (if cross-prefix specified) 417# system compiler 418if test -z "${CC}${cross_prefix}"; then 419 cc="$host_cc" 420else 421 cc="${CC-${cross_prefix}gcc}" 422fi 423 424if test -z "${CXX}${cross_prefix}"; then 425 cxx="c++" 426else 427 cxx="${CXX-${cross_prefix}g++}" 428fi 429 430ar="${AR-${cross_prefix}ar}" 431as="${AS-${cross_prefix}as}" 432ccas="${CCAS-$cc}" 433cpp="${CPP-$cc -E}" 434objcopy="${OBJCOPY-${cross_prefix}objcopy}" 435ld="${LD-${cross_prefix}ld}" 436ranlib="${RANLIB-${cross_prefix}ranlib}" 437nm="${NM-${cross_prefix}nm}" 438strip="${STRIP-${cross_prefix}strip}" 439windres="${WINDRES-${cross_prefix}windres}" 440pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 441query_pkg_config() { 442 "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 443} 444pkg_config=query_pkg_config 445sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 446 447# default flags for all hosts 448# We use -fwrapv to tell the compiler that we require a C dialect where 449# left shift of signed integers is well defined and has the expected 450# 2s-complement style results. (Both clang and gcc agree that it 451# provides these semantics.) 452QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 453QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 454QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 455QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 456 457QEMU_LDFLAGS= 458 459# Flags that are needed during configure but later taken care of by Meson 460CONFIGURE_CFLAGS="-std=gnu11 -Wall" 461CONFIGURE_LDFLAGS= 462 463 464check_define() { 465cat > $TMPC <<EOF 466#if !defined($1) 467#error $1 not defined 468#endif 469int main(void) { return 0; } 470EOF 471 compile_object 472} 473 474check_include() { 475cat > $TMPC <<EOF 476#include <$1> 477int main(void) { return 0; } 478EOF 479 compile_object 480} 481 482write_c_skeleton() { 483 cat > $TMPC <<EOF 484int main(void) { return 0; } 485EOF 486} 487 488if check_define __linux__ ; then 489 targetos=linux 490elif check_define _WIN32 ; then 491 targetos=windows 492elif check_define __OpenBSD__ ; then 493 targetos=openbsd 494elif check_define __sun__ ; then 495 targetos=sunos 496elif check_define __HAIKU__ ; then 497 targetos=haiku 498elif check_define __FreeBSD__ ; then 499 targetos=freebsd 500elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 501 targetos=gnu/kfreebsd 502elif check_define __DragonFly__ ; then 503 targetos=dragonfly 504elif check_define __NetBSD__; then 505 targetos=netbsd 506elif check_define __APPLE__; then 507 targetos=darwin 508else 509 # This is a fatal error, but don't report it yet, because we 510 # might be going to just print the --help text, or it might 511 # be the result of a missing compiler. 512 targetos=bogus 513fi 514 515# OS specific 516 517mingw32="no" 518bsd="no" 519linux="no" 520solaris="no" 521case $targetos in 522windows) 523 mingw32="yes" 524 plugins="no" 525 pie="no" 526;; 527gnu/kfreebsd) 528 bsd="yes" 529;; 530freebsd) 531 bsd="yes" 532 make="${MAKE-gmake}" 533 # needed for kinfo_getvmmap(3) in libutil.h 534;; 535dragonfly) 536 bsd="yes" 537 make="${MAKE-gmake}" 538;; 539netbsd) 540 bsd="yes" 541 make="${MAKE-gmake}" 542;; 543openbsd) 544 bsd="yes" 545 make="${MAKE-gmake}" 546;; 547darwin) 548 bsd="yes" 549 darwin="yes" 550 # Disable attempts to use ObjectiveC features in os/object.h since they 551 # won't work when we're compiling with gcc as a C compiler. 552 QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 553;; 554sunos) 555 solaris="yes" 556 make="${MAKE-gmake}" 557 smbd="${SMBD-/usr/sfw/sbin/smbd}" 558# needed for CMSG_ macros in sys/socket.h 559 QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 560# needed for TIOCWIN* defines in termios.h 561 QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 562 # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 563 # Note that this check is broken for cross-compilation: if you're 564 # cross-compiling to one of these OSes then you'll need to specify 565 # the correct CPU with the --cpu option. 566 if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 567 cpu="x86_64" 568 fi 569;; 570haiku) 571 pie="no" 572 QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 573;; 574linux) 575 linux="yes" 576 vhost_user=${default_feature:-yes} 577;; 578esac 579 580if test ! -z "$cpu" ; then 581 # command line argument 582 : 583elif check_define __i386__ ; then 584 cpu="i386" 585elif check_define __x86_64__ ; then 586 if check_define __ILP32__ ; then 587 cpu="x32" 588 else 589 cpu="x86_64" 590 fi 591elif check_define __sparc__ ; then 592 if check_define __arch64__ ; then 593 cpu="sparc64" 594 else 595 cpu="sparc" 596 fi 597elif check_define _ARCH_PPC ; then 598 if check_define _ARCH_PPC64 ; then 599 if check_define _LITTLE_ENDIAN ; then 600 cpu="ppc64le" 601 else 602 cpu="ppc64" 603 fi 604 else 605 cpu="ppc" 606 fi 607elif check_define __mips__ ; then 608 cpu="mips" 609elif check_define __s390__ ; then 610 if check_define __s390x__ ; then 611 cpu="s390x" 612 else 613 cpu="s390" 614 fi 615elif check_define __riscv ; then 616 cpu="riscv" 617elif check_define __arm__ ; then 618 cpu="arm" 619elif check_define __aarch64__ ; then 620 cpu="aarch64" 621elif check_define __loongarch64 ; then 622 cpu="loongarch64" 623else 624 cpu=$(uname -m) 625fi 626 627# Normalise host CPU name, set multilib cflags 628# Note that this case should only have supported host CPUs, not guests. 629case "$cpu" in 630 armv*b|armv*l|arm) 631 cpu="arm" ;; 632 633 i386|i486|i586|i686|i86pc|BePC) 634 cpu="i386" 635 CPU_CFLAGS="-m32" ;; 636 x32) 637 cpu="x86_64" 638 CPU_CFLAGS="-mx32" ;; 639 x86_64|amd64) 640 cpu="x86_64" 641 # ??? Only extremely old AMD cpus do not have cmpxchg16b. 642 # If we truly care, we should simply detect this case at 643 # runtime and generate the fallback to serial emulation. 644 CPU_CFLAGS="-m64 -mcx16" ;; 645 646 mips*) 647 cpu="mips" ;; 648 649 ppc) 650 CPU_CFLAGS="-m32" ;; 651 ppc64) 652 CPU_CFLAGS="-m64 -mbig" ;; 653 ppc64le) 654 cpu="ppc64" 655 CPU_CFLAGS="-m64 -mlittle" ;; 656 657 s390) 658 CPU_CFLAGS="-m31" ;; 659 s390x) 660 CPU_CFLAGS="-m64" ;; 661 662 sparc|sun4[cdmuv]) 663 cpu="sparc" 664 CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 665 sparc64) 666 CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 667esac 668 669: ${make=${MAKE-make}} 670 671# We prefer python 3.x. A bare 'python' is traditionally 672# python 2.x, but some distros have it as python 3.x, so 673# we check that too 674python= 675explicit_python=no 676for binary in "${PYTHON-python3}" python 677do 678 if has "$binary" 679 then 680 python=$(command -v "$binary") 681 break 682 fi 683done 684 685 686# Check for ancillary tools used in testing 687genisoimage= 688for binary in genisoimage mkisofs 689do 690 if has $binary 691 then 692 genisoimage=$(command -v "$binary") 693 break 694 fi 695done 696 697# Default objcc to clang if available, otherwise use CC 698if has clang; then 699 objcc=clang 700else 701 objcc="$cc" 702fi 703 704if test "$mingw32" = "yes" ; then 705 EXESUF=".exe" 706 # MinGW needs -mthreads for TLS and macro _MT. 707 CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 708 write_c_skeleton; 709 prefix="/qemu" 710 qemu_suffix="" 711 libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga" 712fi 713 714werror="" 715 716. $source_path/scripts/meson-buildoptions.sh 717 718meson_options= 719meson_option_parse() { 720 meson_options="$meson_options $(_meson_option_parse "$@")" 721 if test $? -eq 1; then 722 echo "ERROR: unknown option $1" 723 echo "Try '$0 --help' for more information" 724 exit 1 725 fi 726} 727 728for opt do 729 optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 730 case "$opt" in 731 --help|-h) show_help=yes 732 ;; 733 --version|-V) exec cat $source_path/VERSION 734 ;; 735 --prefix=*) prefix="$optarg" 736 ;; 737 --interp-prefix=*) interp_prefix="$optarg" 738 ;; 739 --cross-prefix=*) 740 ;; 741 --cc=*) 742 ;; 743 --host-cc=*) host_cc="$optarg" 744 ;; 745 --cxx=*) 746 ;; 747 --iasl=*) iasl="$optarg" 748 ;; 749 --objcc=*) objcc="$optarg" 750 ;; 751 --make=*) make="$optarg" 752 ;; 753 --install=*) 754 ;; 755 --python=*) python="$optarg" ; explicit_python=yes 756 ;; 757 --sphinx-build=*) sphinx_build="$optarg" 758 ;; 759 --skip-meson) skip_meson=yes 760 ;; 761 --meson=*) meson="$optarg" 762 ;; 763 --ninja=*) ninja="$optarg" 764 ;; 765 --smbd=*) smbd="$optarg" 766 ;; 767 --extra-cflags=*) 768 ;; 769 --extra-cxxflags=*) 770 ;; 771 --extra-ldflags=*) 772 ;; 773 --enable-debug-info) 774 ;; 775 --disable-debug-info) 776 ;; 777 --cross-cc-*) 778 ;; 779 --enable-modules) 780 modules="yes" 781 ;; 782 --disable-modules) 783 modules="no" 784 ;; 785 --disable-module-upgrades) module_upgrades="no" 786 ;; 787 --enable-module-upgrades) module_upgrades="yes" 788 ;; 789 --cpu=*) 790 ;; 791 --target-list=*) target_list="$optarg" 792 if test "$target_list_exclude"; then 793 error_exit "Can't mix --target-list with --target-list-exclude" 794 fi 795 ;; 796 --target-list-exclude=*) target_list_exclude="$optarg" 797 if test "$target_list"; then 798 error_exit "Can't mix --target-list-exclude with --target-list" 799 fi 800 ;; 801 --with-trace-file=*) trace_file="$optarg" 802 ;; 803 --with-default-devices) default_devices="true" 804 ;; 805 --without-default-devices) default_devices="false" 806 ;; 807 --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 808 ;; 809 --with-devices-*) device_arch=${opt#--with-devices-}; 810 device_arch=${device_arch%%=*} 811 cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 812 if test -f "$cf"; then 813 device_archs="$device_archs $device_arch" 814 eval "devices_${device_arch}=\$optarg" 815 else 816 error_exit "File $cf does not exist" 817 fi 818 ;; 819 --without-default-features) # processed above 820 ;; 821 --enable-gprof) gprof="yes" 822 ;; 823 --enable-gcov) gcov="yes" 824 ;; 825 --static) 826 static="yes" 827 QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 828 ;; 829 --mandir=*) mandir="$optarg" 830 ;; 831 --bindir=*) bindir="$optarg" 832 ;; 833 --libdir=*) libdir="$optarg" 834 ;; 835 --libexecdir=*) libexecdir="$optarg" 836 ;; 837 --includedir=*) includedir="$optarg" 838 ;; 839 --datadir=*) datadir="$optarg" 840 ;; 841 --with-suffix=*) qemu_suffix="$optarg" 842 ;; 843 --docdir=*) docdir="$optarg" 844 ;; 845 --localedir=*) localedir="$optarg" 846 ;; 847 --sysconfdir=*) sysconfdir="$optarg" 848 ;; 849 --localstatedir=*) local_statedir="$optarg" 850 ;; 851 --firmwarepath=*) firmwarepath="$optarg" 852 ;; 853 --host=*|--build=*|\ 854 --disable-dependency-tracking|\ 855 --sbindir=*|--sharedstatedir=*|\ 856 --oldincludedir=*|--datarootdir=*|--infodir=*|\ 857 --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 858 # These switches are silently ignored, for compatibility with 859 # autoconf-generated configure scripts. This allows QEMU's 860 # configure to be used by RPM and similar macros that set 861 # lots of directory switches by default. 862 ;; 863 --disable-qom-cast-debug) qom_cast_debug="no" 864 ;; 865 --enable-qom-cast-debug) qom_cast_debug="yes" 866 ;; 867 --audio-drv-list=*) audio_drv_list="$optarg" 868 ;; 869 --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 870 ;; 871 --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 872 ;; 873 --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes" 874 ;; 875 --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no" 876 ;; 877 --enable-debug-tcg) debug_tcg="yes" 878 ;; 879 --disable-debug-tcg) debug_tcg="no" 880 ;; 881 --enable-debug) 882 # Enable debugging options that aren't excessively noisy 883 debug_tcg="yes" 884 debug_mutex="yes" 885 debug="yes" 886 fortify_source="no" 887 ;; 888 --enable-sanitizers) sanitizers="yes" 889 ;; 890 --disable-sanitizers) sanitizers="no" 891 ;; 892 --enable-tsan) tsan="yes" 893 ;; 894 --disable-tsan) tsan="no" 895 ;; 896 --disable-slirp) slirp="disabled" 897 ;; 898 --enable-slirp) slirp="enabled" 899 ;; 900 --enable-slirp=git) slirp="internal" 901 ;; 902 --enable-slirp=*) slirp="$optarg" 903 ;; 904 --disable-xen) xen="disabled" 905 ;; 906 --enable-xen) xen="enabled" 907 ;; 908 --disable-tcg) tcg="disabled" 909 plugins="no" 910 ;; 911 --enable-tcg) tcg="enabled" 912 ;; 913 --enable-profiler) profiler="yes" 914 ;; 915 --disable-system) softmmu="no" 916 ;; 917 --enable-system) softmmu="yes" 918 ;; 919 --disable-user) 920 linux_user="no" ; 921 bsd_user="no" ; 922 ;; 923 --enable-user) ;; 924 --disable-linux-user) linux_user="no" 925 ;; 926 --enable-linux-user) linux_user="yes" 927 ;; 928 --disable-bsd-user) bsd_user="no" 929 ;; 930 --enable-bsd-user) bsd_user="yes" 931 ;; 932 --enable-pie) pie="yes" 933 ;; 934 --disable-pie) pie="no" 935 ;; 936 --enable-werror) werror="yes" 937 ;; 938 --disable-werror) werror="no" 939 ;; 940 --enable-lto) lto="true" 941 ;; 942 --disable-lto) lto="false" 943 ;; 944 --enable-stack-protector) stack_protector="yes" 945 ;; 946 --disable-stack-protector) stack_protector="no" 947 ;; 948 --enable-safe-stack) safe_stack="yes" 949 ;; 950 --disable-safe-stack) safe_stack="no" 951 ;; 952 --enable-cfi) 953 cfi="true"; 954 lto="true"; 955 ;; 956 --disable-cfi) cfi="false" 957 ;; 958 --disable-fdt) fdt="disabled" 959 ;; 960 --enable-fdt) fdt="enabled" 961 ;; 962 --enable-fdt=git) fdt="internal" 963 ;; 964 --enable-fdt=*) fdt="$optarg" 965 ;; 966 --with-pkgversion=*) pkgversion="$optarg" 967 ;; 968 --with-coroutine=*) coroutine="$optarg" 969 ;; 970 --disable-coroutine-pool) coroutine_pool="no" 971 ;; 972 --enable-coroutine-pool) coroutine_pool="yes" 973 ;; 974 --enable-debug-stack-usage) debug_stack_usage="yes" 975 ;; 976 --disable-vhost-net) vhost_net="no" 977 ;; 978 --enable-vhost-net) vhost_net="yes" 979 ;; 980 --disable-vhost-crypto) vhost_crypto="no" 981 ;; 982 --enable-vhost-crypto) vhost_crypto="yes" 983 ;; 984 --disable-vhost-scsi) vhost_scsi="no" 985 ;; 986 --enable-vhost-scsi) vhost_scsi="yes" 987 ;; 988 --disable-vhost-vsock) vhost_vsock="no" 989 ;; 990 --enable-vhost-vsock) vhost_vsock="yes" 991 ;; 992 --disable-vhost-user-fs) vhost_user_fs="no" 993 ;; 994 --enable-vhost-user-fs) vhost_user_fs="yes" 995 ;; 996 --disable-opengl) opengl="no" 997 ;; 998 --enable-opengl) opengl="yes" 999 ;; 1000 --disable-zlib-test) 1001 ;; 1002 --enable-guest-agent) guest_agent="yes" 1003 ;; 1004 --disable-guest-agent) guest_agent="no" 1005 ;; 1006 --with-vss-sdk) vss_win32_sdk="" 1007 ;; 1008 --with-vss-sdk=*) vss_win32_sdk="$optarg" 1009 ;; 1010 --without-vss-sdk) vss_win32_sdk="no" 1011 ;; 1012 --with-win-sdk) win_sdk="" 1013 ;; 1014 --with-win-sdk=*) win_sdk="$optarg" 1015 ;; 1016 --without-win-sdk) win_sdk="no" 1017 ;; 1018 --enable-tools) want_tools="yes" 1019 ;; 1020 --disable-tools) want_tools="no" 1021 ;; 1022 --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 1023 echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 1024 ;; 1025 --enable-vhdx|--disable-vhdx) 1026 echo "$0: $opt is obsolete, VHDX driver is always built" >&2 1027 ;; 1028 --enable-uuid|--disable-uuid) 1029 echo "$0: $opt is obsolete, UUID support is always built" >&2 1030 ;; 1031 --tls-priority=*) tls_priority="$optarg" 1032 ;; 1033 --enable-rdma) rdma="yes" 1034 ;; 1035 --disable-rdma) rdma="no" 1036 ;; 1037 --enable-pvrdma) pvrdma="yes" 1038 ;; 1039 --disable-pvrdma) pvrdma="no" 1040 ;; 1041 --disable-live-block-migration) live_block_migration="no" 1042 ;; 1043 --enable-live-block-migration) live_block_migration="yes" 1044 ;; 1045 --disable-replication) replication="no" 1046 ;; 1047 --enable-replication) replication="yes" 1048 ;; 1049 --disable-bochs) bochs="no" 1050 ;; 1051 --enable-bochs) bochs="yes" 1052 ;; 1053 --disable-cloop) cloop="no" 1054 ;; 1055 --enable-cloop) cloop="yes" 1056 ;; 1057 --disable-dmg) dmg="no" 1058 ;; 1059 --enable-dmg) dmg="yes" 1060 ;; 1061 --disable-qcow1) qcow1="no" 1062 ;; 1063 --enable-qcow1) qcow1="yes" 1064 ;; 1065 --disable-vdi) vdi="no" 1066 ;; 1067 --enable-vdi) vdi="yes" 1068 ;; 1069 --disable-vvfat) vvfat="no" 1070 ;; 1071 --enable-vvfat) vvfat="yes" 1072 ;; 1073 --disable-qed) qed="no" 1074 ;; 1075 --enable-qed) qed="yes" 1076 ;; 1077 --disable-parallels) parallels="no" 1078 ;; 1079 --enable-parallels) parallels="yes" 1080 ;; 1081 --disable-vhost-user) vhost_user="no" 1082 ;; 1083 --enable-vhost-user) vhost_user="yes" 1084 ;; 1085 --disable-vhost-vdpa) vhost_vdpa="no" 1086 ;; 1087 --enable-vhost-vdpa) vhost_vdpa="yes" 1088 ;; 1089 --disable-vhost-kernel) vhost_kernel="no" 1090 ;; 1091 --enable-vhost-kernel) vhost_kernel="yes" 1092 ;; 1093 --disable-capstone) capstone="disabled" 1094 ;; 1095 --enable-capstone) capstone="enabled" 1096 ;; 1097 --enable-capstone=git) capstone="internal" 1098 ;; 1099 --enable-capstone=*) capstone="$optarg" 1100 ;; 1101 --with-git=*) git="$optarg" 1102 ;; 1103 --with-git-submodules=*) 1104 git_submodules_action="$optarg" 1105 ;; 1106 --enable-debug-mutex) debug_mutex=yes 1107 ;; 1108 --disable-debug-mutex) debug_mutex=no 1109 ;; 1110 --enable-plugins) if test "$mingw32" = "yes"; then 1111 error_exit "TCG plugins not currently supported on Windows platforms" 1112 else 1113 plugins="yes" 1114 fi 1115 ;; 1116 --disable-plugins) plugins="no" 1117 ;; 1118 --enable-containers) use_containers="yes" 1119 ;; 1120 --disable-containers) use_containers="no" 1121 ;; 1122 --gdb=*) gdb_bin="$optarg" 1123 ;; 1124 --enable-rng-none) rng_none=yes 1125 ;; 1126 --disable-rng-none) rng_none=no 1127 ;; 1128 --enable-keyring) secret_keyring="yes" 1129 ;; 1130 --disable-keyring) secret_keyring="no" 1131 ;; 1132 --enable-gio) gio=yes 1133 ;; 1134 --disable-gio) gio=no 1135 ;; 1136 --enable-slirp-smbd) slirp_smbd=yes 1137 ;; 1138 --disable-slirp-smbd) slirp_smbd=no 1139 ;; 1140 # backwards compatibility options 1141 --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 1142 ;; 1143 --disable-blobs) meson_option_parse --disable-install-blobs "" 1144 ;; 1145 --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 1146 ;; 1147 --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 1148 ;; 1149 # everything else has the same name in configure and meson 1150 --enable-* | --disable-*) meson_option_parse "$opt" "$optarg" 1151 ;; 1152 *) 1153 echo "ERROR: unknown option $opt" 1154 echo "Try '$0 --help' for more information" 1155 exit 1 1156 ;; 1157 esac 1158done 1159 1160# test for any invalid configuration combinations 1161if test "$plugins" = "yes" -a "$tcg" = "disabled"; then 1162 error_exit "Can't enable plugins on non-TCG builds" 1163fi 1164 1165case $git_submodules_action in 1166 update|validate) 1167 if test ! -e "$source_path/.git"; then 1168 echo "ERROR: cannot $git_submodules_action git submodules without .git" 1169 exit 1 1170 fi 1171 ;; 1172 ignore) 1173 if ! test -f "$source_path/ui/keycodemapdb/README" 1174 then 1175 echo 1176 echo "ERROR: missing GIT submodules" 1177 echo 1178 if test -e "$source_path/.git"; then 1179 echo "--with-git-submodules=ignore specified but submodules were not" 1180 echo "checked out. Please initialize and update submodules." 1181 else 1182 echo "This is not a GIT checkout but module content appears to" 1183 echo "be missing. Do not use 'git archive' or GitHub download links" 1184 echo "to acquire QEMU source archives. Non-GIT builds are only" 1185 echo "supported with source archives linked from:" 1186 echo 1187 echo " https://www.qemu.org/download/#source" 1188 echo 1189 echo "Developers working with GIT can use scripts/archive-source.sh" 1190 echo "if they need to create valid source archives." 1191 fi 1192 echo 1193 exit 1 1194 fi 1195 ;; 1196 *) 1197 echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 1198 exit 1 1199 ;; 1200esac 1201 1202libdir="${libdir:-$prefix/lib}" 1203libexecdir="${libexecdir:-$prefix/libexec}" 1204includedir="${includedir:-$prefix/include}" 1205 1206if test "$mingw32" = "yes" ; then 1207 bindir="${bindir:-$prefix}" 1208else 1209 bindir="${bindir:-$prefix/bin}" 1210fi 1211mandir="${mandir:-$prefix/share/man}" 1212datadir="${datadir:-$prefix/share}" 1213docdir="${docdir:-$prefix/share/doc}" 1214sysconfdir="${sysconfdir:-$prefix/etc}" 1215local_statedir="${local_statedir:-$prefix/var}" 1216firmwarepath="${firmwarepath:-$datadir/qemu-firmware}" 1217localedir="${localedir:-$datadir/locale}" 1218 1219if eval test -z "\${cross_cc_$cpu}"; then 1220 eval "cross_cc_${cpu}=\$cc" 1221 cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 1222fi 1223 1224default_target_list="" 1225mak_wilds="" 1226 1227if [ "$linux_user" != no ]; then 1228 if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 1229 linux_user=yes 1230 elif [ "$linux_user" = yes ]; then 1231 error_exit "linux-user not supported on this architecture" 1232 fi 1233fi 1234if [ "$bsd_user" != no ]; then 1235 if [ "$bsd_user" = "" ]; then 1236 test $targetos = freebsd && bsd_user=yes 1237 fi 1238 if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 1239 error_exit "bsd-user not supported on this host OS" 1240 fi 1241fi 1242if [ "$softmmu" = "yes" ]; then 1243 mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 1244fi 1245if [ "$linux_user" = "yes" ]; then 1246 mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 1247fi 1248if [ "$bsd_user" = "yes" ]; then 1249 mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 1250fi 1251 1252for config in $mak_wilds; do 1253 target="$(basename "$config" .mak)" 1254 if echo "$target_list_exclude" | grep -vq "$target"; then 1255 default_target_list="${default_target_list} $target" 1256 fi 1257done 1258 1259if test x"$show_help" = x"yes" ; then 1260cat << EOF 1261 1262Usage: configure [options] 1263Options: [defaults in brackets after descriptions] 1264 1265Standard options: 1266 --help print this message 1267 --prefix=PREFIX install in PREFIX [$prefix] 1268 --interp-prefix=PREFIX where to find shared libraries, etc. 1269 use %M for cpu name [$interp_prefix] 1270 --target-list=LIST set target list (default: build all) 1271$(echo Available targets: $default_target_list | \ 1272 fold -s -w 53 | sed -e 's/^/ /') 1273 --target-list-exclude=LIST exclude a set of targets from the default target-list 1274 1275Advanced options (experts only): 1276 --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 1277 --cc=CC use C compiler CC [$cc] 1278 --iasl=IASL use ACPI compiler IASL [$iasl] 1279 --host-cc=CC use C compiler CC [$host_cc] for code run at 1280 build time 1281 --cxx=CXX use C++ compiler CXX [$cxx] 1282 --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1283 --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1284 --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 1285 --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1286 --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1287 --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 1288 --make=MAKE use specified make [$make] 1289 --python=PYTHON use specified python [$python] 1290 --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build] 1291 --meson=MESON use specified meson [$meson] 1292 --ninja=NINJA use specified ninja [$ninja] 1293 --smbd=SMBD use specified smbd [$smbd] 1294 --with-git=GIT use specified git [$git] 1295 --with-git-submodules=update update git submodules (default if .git dir exists) 1296 --with-git-submodules=validate fail if git submodules are not up to date 1297 --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 1298 --static enable static build [$static] 1299 --mandir=PATH install man pages in PATH 1300 --datadir=PATH install firmware in PATH/$qemu_suffix 1301 --localedir=PATH install translation in PATH/$qemu_suffix 1302 --docdir=PATH install documentation in PATH/$qemu_suffix 1303 --bindir=PATH install binaries in PATH 1304 --libdir=PATH install libraries in PATH 1305 --libexecdir=PATH install helper binaries in PATH 1306 --sysconfdir=PATH install config in PATH/$qemu_suffix 1307 --localstatedir=PATH install local state in PATH (set at runtime on win32) 1308 --firmwarepath=PATH search PATH for firmware files 1309 --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1310 --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1311 --with-pkgversion=VERS use specified string as sub-version of the package 1312 --without-default-features default all --enable-* options to "disabled" 1313 --without-default-devices do not include any device that is not needed to 1314 start the emulator (only use if you are including 1315 desired devices in configs/devices/) 1316 --with-devices-ARCH=NAME override default configs/devices 1317 --enable-debug enable common debug build options 1318 --enable-sanitizers enable default sanitizers 1319 --enable-tsan enable thread sanitizer 1320 --disable-werror disable compilation abort on warning 1321 --disable-stack-protector disable compiler-provided stack protection 1322 --audio-drv-list=LIST set audio drivers to try if -audiodev is not used 1323 --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L 1324 --block-drv-rw-whitelist=L 1325 set block driver read-write whitelist 1326 (by default affects only QEMU, not tools like qemu-img) 1327 --block-drv-ro-whitelist=L 1328 set block driver read-only whitelist 1329 (by default affects only QEMU, not tools like qemu-img) 1330 --enable-block-drv-whitelist-in-tools 1331 use block whitelist also in tools instead of only QEMU 1332 --with-trace-file=NAME Full PATH,NAME of file to store traces 1333 Default:trace-<pid> 1334 --cpu=CPU Build for host CPU [$cpu] 1335 --with-coroutine=BACKEND coroutine backend. Supported options: 1336 ucontext, sigaltstack, windows 1337 --enable-gcov enable test coverage analysis with gcov 1338 --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent 1339 --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb) 1340 --tls-priority default TLS protocol/cipher priority string 1341 --enable-gprof QEMU profiling with gprof 1342 --enable-profiler profiler support 1343 --enable-debug-stack-usage 1344 track the maximum stack usage of stacks created by qemu_alloc_stack 1345 --enable-plugins 1346 enable plugins via shared library loading 1347 --disable-containers don't use containers for cross-building 1348 --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 1349EOF 1350 meson_options_help 1351cat << EOF 1352 system all system emulation targets 1353 user supported user emulation targets 1354 linux-user all linux usermode emulation targets 1355 bsd-user all BSD usermode emulation targets 1356 guest-agent build the QEMU Guest Agent 1357 pie Position Independent Executables 1358 modules modules support (non-Windows) 1359 module-upgrades try to load modules from alternate paths for upgrades 1360 debug-tcg TCG debugging (default is disabled) 1361 debug-info debugging information 1362 lto Enable Link-Time Optimization. 1363 safe-stack SafeStack Stack Smash Protection. Depends on 1364 clang/llvm >= 3.7 and requires coroutine backend ucontext. 1365 rdma Enable RDMA-based migration 1366 pvrdma Enable PVRDMA support 1367 vhost-net vhost-net kernel acceleration support 1368 vhost-vsock virtio sockets device support 1369 vhost-scsi vhost-scsi kernel target support 1370 vhost-crypto vhost-user-crypto backend support 1371 vhost-kernel vhost kernel backend support 1372 vhost-user vhost-user backend support 1373 vhost-vdpa vhost-vdpa kernel backend support 1374 live-block-migration Block migration in the main migration stream 1375 coroutine-pool coroutine freelist (better performance) 1376 replication replication support 1377 opengl opengl support 1378 qom-cast-debug cast debugging support 1379 tools build qemu-io, qemu-nbd and qemu-img tools 1380 bochs bochs image format support 1381 cloop cloop image format support 1382 dmg dmg image format support 1383 qcow1 qcow v1 image format support 1384 vdi vdi image format support 1385 vvfat vvfat image format support 1386 qed qed image format support 1387 parallels parallels image format support 1388 debug-mutex mutex debugging support 1389 rng-none dummy RNG, avoid using /dev/(u)random and getrandom() 1390 gio libgio support 1391 slirp-smbd use smbd (at path --smbd=*) in slirp networking 1392 1393NOTE: The object files are built at the place where configure is launched 1394EOF 1395exit 0 1396fi 1397 1398# Remove old dependency files to make sure that they get properly regenerated 1399rm -f */config-devices.mak.d 1400 1401if test -z "$python" 1402then 1403 error_exit "Python not found. Use --python=/path/to/python" 1404fi 1405if ! has "$make" 1406then 1407 error_exit "GNU make ($make) not found" 1408fi 1409 1410# Note that if the Python conditional here evaluates True we will exit 1411# with status 1 which is a shell 'false' value. 1412if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 1413 error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1414 "Use --python=/path/to/python to specify a supported Python." 1415fi 1416 1417# Preserve python version since some functionality is dependent on it 1418python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null) 1419 1420# Suppress writing compiled files 1421python="$python -B" 1422 1423if test -z "$meson"; then 1424 if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 1425 meson=meson 1426 elif test $git_submodules_action != 'ignore' ; then 1427 meson=git 1428 elif test -e "${source_path}/meson/meson.py" ; then 1429 meson=internal 1430 else 1431 if test "$explicit_python" = yes; then 1432 error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 1433 else 1434 error_exit "Meson not found. Use --meson=/path/to/meson" 1435 fi 1436 fi 1437else 1438 # Meson uses its own Python interpreter to invoke other Python scripts, 1439 # but the user wants to use the one they specified with --python. 1440 # 1441 # We do not want to override the distro Python interpreter (and sometimes 1442 # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 1443 # just require --meson=git|internal together with --python. 1444 if test "$explicit_python" = yes; then 1445 case "$meson" in 1446 git | internal) ;; 1447 *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 1448 esac 1449 fi 1450fi 1451 1452if test "$meson" = git; then 1453 git_submodules="${git_submodules} meson" 1454fi 1455 1456case "$meson" in 1457 git | internal) 1458 meson="$python ${source_path}/meson/meson.py" 1459 ;; 1460 *) meson=$(command -v "$meson") ;; 1461esac 1462 1463# Probe for ninja 1464 1465if test -z "$ninja"; then 1466 for c in ninja ninja-build samu; do 1467 if has $c; then 1468 ninja=$(command -v "$c") 1469 break 1470 fi 1471 done 1472 if test -z "$ninja"; then 1473 error_exit "Cannot find Ninja" 1474 fi 1475fi 1476 1477# Check that the C compiler works. Doing this here before testing 1478# the host CPU ensures that we had a valid CC to autodetect the 1479# $cpu var (and we should bail right here if that's not the case). 1480# It also allows the help message to be printed without a CC. 1481write_c_skeleton; 1482if compile_object ; then 1483 : C compiler works ok 1484else 1485 error_exit "\"$cc\" either does not exist or does not work" 1486fi 1487if ! compile_prog ; then 1488 error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 1489fi 1490 1491# Consult white-list to determine whether to enable werror 1492# by default. Only enable by default for git builds 1493if test -z "$werror" ; then 1494 if test "$git_submodules_action" != "ignore" && \ 1495 { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 1496 werror="yes" 1497 else 1498 werror="no" 1499 fi 1500fi 1501 1502if test "$targetos" = "bogus"; then 1503 # Now that we know that we're not printing the help and that 1504 # the compiler works (so the results of the check_defines we used 1505 # to identify the OS are reliable), if we didn't recognize the 1506 # host OS we should stop now. 1507 error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1508fi 1509 1510# Check whether the compiler matches our minimum requirements: 1511cat > $TMPC << EOF 1512#if defined(__clang_major__) && defined(__clang_minor__) 1513# ifdef __apple_build_version__ 1514# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 1515# error You need at least XCode Clang v10.0 to compile QEMU 1516# endif 1517# else 1518# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 1519# error You need at least Clang v6.0 to compile QEMU 1520# endif 1521# endif 1522#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 1523# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 1524# error You need at least GCC v7.4.0 to compile QEMU 1525# endif 1526#else 1527# error You either need GCC or Clang to compiler QEMU 1528#endif 1529int main (void) { return 0; } 1530EOF 1531if ! compile_prog "" "" ; then 1532 error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1533fi 1534 1535# Accumulate -Wfoo and -Wno-bar separately. 1536# We will list all of the enable flags first, and the disable flags second. 1537# Note that we do not add -Werror, because that would enable it for all 1538# configure tests. If a configure test failed due to -Werror this would 1539# just silently disable some features, so it's too error prone. 1540 1541warn_flags= 1542add_to warn_flags -Wold-style-declaration 1543add_to warn_flags -Wold-style-definition 1544add_to warn_flags -Wtype-limits 1545add_to warn_flags -Wformat-security 1546add_to warn_flags -Wformat-y2k 1547add_to warn_flags -Winit-self 1548add_to warn_flags -Wignored-qualifiers 1549add_to warn_flags -Wempty-body 1550add_to warn_flags -Wnested-externs 1551add_to warn_flags -Wendif-labels 1552add_to warn_flags -Wexpansion-to-defined 1553add_to warn_flags -Wimplicit-fallthrough=2 1554 1555nowarn_flags= 1556add_to nowarn_flags -Wno-initializer-overrides 1557add_to nowarn_flags -Wno-missing-include-dirs 1558add_to nowarn_flags -Wno-shift-negative-value 1559add_to nowarn_flags -Wno-string-plus-int 1560add_to nowarn_flags -Wno-typedef-redefinition 1561add_to nowarn_flags -Wno-tautological-type-limit-compare 1562add_to nowarn_flags -Wno-psabi 1563 1564gcc_flags="$warn_flags $nowarn_flags" 1565 1566cc_has_warning_flag() { 1567 write_c_skeleton; 1568 1569 # Use the positive sense of the flag when testing for -Wno-wombat 1570 # support (gcc will happily accept the -Wno- form of unknown 1571 # warning options). 1572 optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 1573 compile_prog "-Werror $optflag" "" 1574} 1575 1576for flag in $gcc_flags; do 1577 if cc_has_warning_flag $flag ; then 1578 QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1579 fi 1580done 1581 1582if test "$stack_protector" != "no"; then 1583 cat > $TMPC << EOF 1584int main(int argc, char *argv[]) 1585{ 1586 char arr[64], *p = arr, *c = argv[0]; 1587 while (*c) { 1588 *p++ = *c++; 1589 } 1590 return 0; 1591} 1592EOF 1593 gcc_flags="-fstack-protector-strong -fstack-protector-all" 1594 sp_on=0 1595 for flag in $gcc_flags; do 1596 # We need to check both a compile and a link, since some compiler 1597 # setups fail only on a .c->.o compile and some only at link time 1598 if compile_object "-Werror $flag" && 1599 compile_prog "-Werror $flag" ""; then 1600 QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1601 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 1602 sp_on=1 1603 break 1604 fi 1605 done 1606 if test "$stack_protector" = yes; then 1607 if test $sp_on = 0; then 1608 error_exit "Stack protector not supported" 1609 fi 1610 fi 1611fi 1612 1613# Disable -Wmissing-braces on older compilers that warn even for 1614# the "universal" C zero initializer {0}. 1615cat > $TMPC << EOF 1616struct { 1617 int a[2]; 1618} x = {0}; 1619EOF 1620if compile_object "-Werror" "" ; then 1621 : 1622else 1623 QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 1624fi 1625 1626# Our module code doesn't support Windows 1627if test "$modules" = "yes" && test "$mingw32" = "yes" ; then 1628 error_exit "Modules are not available for Windows" 1629fi 1630 1631# module_upgrades is only reasonable if modules are enabled 1632if test "$modules" = "no" && test "$module_upgrades" = "yes" ; then 1633 error_exit "Can't enable module-upgrades as Modules are not enabled" 1634fi 1635 1636# Static linking is not possible with plugins, modules or PIE 1637if test "$static" = "yes" ; then 1638 if test "$modules" = "yes" ; then 1639 error_exit "static and modules are mutually incompatible" 1640 fi 1641 if test "$plugins" = "yes"; then 1642 error_exit "static and plugins are mutually incompatible" 1643 else 1644 plugins="no" 1645 fi 1646fi 1647test "$plugins" = "" && plugins=yes 1648 1649cat > $TMPC << EOF 1650 1651#ifdef __linux__ 1652# define THREAD __thread 1653#else 1654# define THREAD 1655#endif 1656static THREAD int tls_var; 1657int main(void) { return tls_var; } 1658EOF 1659 1660# Check we support -fno-pie and -no-pie first; we will need the former for 1661# building ROMs, and both for everything if --disable-pie is passed. 1662if compile_prog "-Werror -fno-pie" "-no-pie"; then 1663 CFLAGS_NOPIE="-fno-pie" 1664 LDFLAGS_NOPIE="-no-pie" 1665fi 1666 1667if test "$static" = "yes"; then 1668 if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 1669 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 1670 QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 1671 pie="yes" 1672 elif test "$pie" = "yes"; then 1673 error_exit "-static-pie not available due to missing toolchain support" 1674 else 1675 QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 1676 pie="no" 1677 fi 1678elif test "$pie" = "no"; then 1679 CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1680 CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1681elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 1682 CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 1683 CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 1684 pie="yes" 1685elif test "$pie" = "yes"; then 1686 error_exit "PIE not available due to missing toolchain support" 1687else 1688 echo "Disabling PIE due to missing toolchain support" 1689 pie="no" 1690fi 1691 1692# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1693# The combination is known as "full relro", because .got.plt is read-only too. 1694if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1695 QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1696fi 1697 1698########################################## 1699# __sync_fetch_and_and requires at least -march=i486. Many toolchains 1700# use i686 as default anyway, but for those that don't, an explicit 1701# specification is necessary 1702 1703if test "$cpu" = "i386"; then 1704 cat > $TMPC << EOF 1705static int sfaa(int *ptr) 1706{ 1707 return __sync_fetch_and_and(ptr, 0); 1708} 1709 1710int main(void) 1711{ 1712 int val = 42; 1713 val = __sync_val_compare_and_swap(&val, 0, 1); 1714 sfaa(&val); 1715 return val; 1716} 1717EOF 1718 if ! compile_prog "" "" ; then 1719 QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 1720 fi 1721fi 1722 1723if test "$tcg" = "enabled"; then 1724 git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 1725 git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 1726fi 1727 1728if test -z "${target_list+xxx}" ; then 1729 default_targets=yes 1730 for target in $default_target_list; do 1731 target_list="$target_list $target" 1732 done 1733 target_list="${target_list# }" 1734else 1735 default_targets=no 1736 target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1737 for target in $target_list; do 1738 # Check that we recognised the target name; this allows a more 1739 # friendly error message than if we let it fall through. 1740 case " $default_target_list " in 1741 *" $target "*) 1742 ;; 1743 *) 1744 error_exit "Unknown target name '$target'" 1745 ;; 1746 esac 1747 done 1748fi 1749 1750# see if system emulation was really requested 1751case " $target_list " in 1752 *"-softmmu "*) softmmu=yes 1753 ;; 1754 *) softmmu=no 1755 ;; 1756esac 1757 1758feature_not_found() { 1759 feature=$1 1760 remedy=$2 1761 1762 error_exit "User requested feature $feature" \ 1763 "configure was not able to find it." \ 1764 "$remedy" 1765} 1766 1767# --- 1768# big/little endian test 1769cat > $TMPC << EOF 1770#include <stdio.h> 1771short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 1772short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1773int main(int argc, char *argv[]) 1774{ 1775 return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 1776} 1777EOF 1778 1779if compile_prog ; then 1780 if strings -a $TMPE | grep -q BiGeNdIaN ; then 1781 bigendian="yes" 1782 elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 1783 bigendian="no" 1784 else 1785 echo big/little test failed 1786 exit 1 1787 fi 1788else 1789 echo big/little test failed 1790 exit 1 1791fi 1792 1793########################################## 1794# system tools 1795if test -z "$want_tools"; then 1796 if test "$softmmu" = "no"; then 1797 want_tools=no 1798 else 1799 want_tools=yes 1800 fi 1801fi 1802 1803######################################### 1804# vhost interdependencies and host support 1805 1806# vhost backends 1807if test "$vhost_user" = "yes" && test "$linux" != "yes"; then 1808 error_exit "vhost-user is only available on Linux" 1809fi 1810test "$vhost_vdpa" = "" && vhost_vdpa=$linux 1811if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then 1812 error_exit "vhost-vdpa is only available on Linux" 1813fi 1814test "$vhost_kernel" = "" && vhost_kernel=$linux 1815if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then 1816 error_exit "vhost-kernel is only available on Linux" 1817fi 1818 1819# vhost-kernel devices 1820test "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel 1821if test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then 1822 error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" 1823fi 1824test "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel 1825if test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then 1826 error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" 1827fi 1828 1829# vhost-user backends 1830test "$vhost_net_user" = "" && vhost_net_user=$vhost_user 1831if test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then 1832 error_exit "--enable-vhost-net-user requires --enable-vhost-user" 1833fi 1834test "$vhost_crypto" = "" && vhost_crypto=$vhost_user 1835if test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then 1836 error_exit "--enable-vhost-crypto requires --enable-vhost-user" 1837fi 1838test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user 1839if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then 1840 error_exit "--enable-vhost-user-fs requires --enable-vhost-user" 1841fi 1842#vhost-vdpa backends 1843test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa 1844if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then 1845 error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" 1846fi 1847 1848# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity 1849if test "$vhost_net" = ""; then 1850 test "$vhost_net_user" = "yes" && vhost_net=yes 1851 test "$vhost_net_vdpa" = "yes" && vhost_net=yes 1852 test "$vhost_kernel" = "yes" && vhost_net=yes 1853fi 1854 1855########################################## 1856# pkg-config probe 1857 1858if ! has "$pkg_config_exe"; then 1859 error_exit "pkg-config binary '$pkg_config_exe' not found" 1860fi 1861 1862########################################## 1863# xen probe 1864 1865if test "$xen" != "disabled" ; then 1866 # Check whether Xen library path is specified via --extra-ldflags to avoid 1867 # overriding this setting with pkg-config output. If not, try pkg-config 1868 # to obtain all needed flags. 1869 1870 if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ 1871 $pkg_config --exists xencontrol ; then 1872 xen_ctrl_version="$(printf '%d%02d%02d' \ 1873 $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" 1874 xen=enabled 1875 xen_pc="xencontrol xenstore xenforeignmemory xengnttab" 1876 xen_pc="$xen_pc xenevtchn xendevicemodel" 1877 if $pkg_config --exists xentoolcore; then 1878 xen_pc="$xen_pc xentoolcore" 1879 fi 1880 xen_cflags="$($pkg_config --cflags $xen_pc)" 1881 xen_libs="$($pkg_config --libs $xen_pc)" 1882 else 1883 1884 xen_libs="-lxenstore -lxenctrl" 1885 xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" 1886 1887 # First we test whether Xen headers and libraries are available. 1888 # If no, we are done and there is no Xen support. 1889 # If yes, more tests are run to detect the Xen version. 1890 1891 # Xen (any) 1892 cat > $TMPC <<EOF 1893#include <xenctrl.h> 1894int main(void) { 1895 return 0; 1896} 1897EOF 1898 if ! compile_prog "" "$xen_libs" ; then 1899 # Xen not found 1900 if test "$xen" = "enabled" ; then 1901 feature_not_found "xen" "Install xen devel" 1902 fi 1903 xen=disabled 1904 1905 # Xen unstable 1906 elif 1907 cat > $TMPC <<EOF && 1908#undef XC_WANT_COMPAT_DEVICEMODEL_API 1909#define __XEN_TOOLS__ 1910#include <xendevicemodel.h> 1911#include <xenforeignmemory.h> 1912int main(void) { 1913 xendevicemodel_handle *xd; 1914 xenforeignmemory_handle *xfmem; 1915 1916 xd = xendevicemodel_open(0, 0); 1917 xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); 1918 1919 xfmem = xenforeignmemory_open(0, 0); 1920 xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); 1921 1922 return 0; 1923} 1924EOF 1925 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 1926 then 1927 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 1928 xen_ctrl_version=41100 1929 xen=enabled 1930 elif 1931 cat > $TMPC <<EOF && 1932#undef XC_WANT_COMPAT_MAP_FOREIGN_API 1933#include <xenforeignmemory.h> 1934#include <xentoolcore.h> 1935int main(void) { 1936 xenforeignmemory_handle *xfmem; 1937 1938 xfmem = xenforeignmemory_open(0, 0); 1939 xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); 1940 xentoolcore_restrict_all(0); 1941 1942 return 0; 1943} 1944EOF 1945 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 1946 then 1947 xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 1948 xen_ctrl_version=41000 1949 xen=enabled 1950 elif 1951 cat > $TMPC <<EOF && 1952#undef XC_WANT_COMPAT_DEVICEMODEL_API 1953#define __XEN_TOOLS__ 1954#include <xendevicemodel.h> 1955int main(void) { 1956 xendevicemodel_handle *xd; 1957 1958 xd = xendevicemodel_open(0, 0); 1959 xendevicemodel_close(xd); 1960 1961 return 0; 1962} 1963EOF 1964 compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" 1965 then 1966 xen_stable_libs="-lxendevicemodel $xen_stable_libs" 1967 xen_ctrl_version=40900 1968 xen=enabled 1969 elif 1970 cat > $TMPC <<EOF && 1971/* 1972 * If we have stable libs the we don't want the libxc compat 1973 * layers, regardless of what CFLAGS we may have been given. 1974 * 1975 * Also, check if xengnttab_grant_copy_segment_t is defined and 1976 * grant copy operation is implemented. 1977 */ 1978#undef XC_WANT_COMPAT_EVTCHN_API 1979#undef XC_WANT_COMPAT_GNTTAB_API 1980#undef XC_WANT_COMPAT_MAP_FOREIGN_API 1981#include <xenctrl.h> 1982#include <xenstore.h> 1983#include <xenevtchn.h> 1984#include <xengnttab.h> 1985#include <xenforeignmemory.h> 1986#include <stdint.h> 1987#include <xen/hvm/hvm_info_table.h> 1988#if !defined(HVM_MAX_VCPUS) 1989# error HVM_MAX_VCPUS not defined 1990#endif 1991int main(void) { 1992 xc_interface *xc = NULL; 1993 xenforeignmemory_handle *xfmem; 1994 xenevtchn_handle *xe; 1995 xengnttab_handle *xg; 1996 xengnttab_grant_copy_segment_t* seg = NULL; 1997 1998 xs_daemon_open(); 1999 2000 xc = xc_interface_open(0, 0, 0); 2001 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2002 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2003 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 2004 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 2005 2006 xfmem = xenforeignmemory_open(0, 0); 2007 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 2008 2009 xe = xenevtchn_open(0, 0); 2010 xenevtchn_fd(xe); 2011 2012 xg = xengnttab_open(0, 0); 2013 xengnttab_grant_copy(xg, 0, seg); 2014 2015 return 0; 2016} 2017EOF 2018 compile_prog "" "$xen_libs $xen_stable_libs" 2019 then 2020 xen_ctrl_version=40800 2021 xen=enabled 2022 elif 2023 cat > $TMPC <<EOF && 2024/* 2025 * If we have stable libs the we don't want the libxc compat 2026 * layers, regardless of what CFLAGS we may have been given. 2027 */ 2028#undef XC_WANT_COMPAT_EVTCHN_API 2029#undef XC_WANT_COMPAT_GNTTAB_API 2030#undef XC_WANT_COMPAT_MAP_FOREIGN_API 2031#include <xenctrl.h> 2032#include <xenstore.h> 2033#include <xenevtchn.h> 2034#include <xengnttab.h> 2035#include <xenforeignmemory.h> 2036#include <stdint.h> 2037#include <xen/hvm/hvm_info_table.h> 2038#if !defined(HVM_MAX_VCPUS) 2039# error HVM_MAX_VCPUS not defined 2040#endif 2041int main(void) { 2042 xc_interface *xc = NULL; 2043 xenforeignmemory_handle *xfmem; 2044 xenevtchn_handle *xe; 2045 xengnttab_handle *xg; 2046 2047 xs_daemon_open(); 2048 2049 xc = xc_interface_open(0, 0, 0); 2050 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2051 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2052 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 2053 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 2054 2055 xfmem = xenforeignmemory_open(0, 0); 2056 xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 2057 2058 xe = xenevtchn_open(0, 0); 2059 xenevtchn_fd(xe); 2060 2061 xg = xengnttab_open(0, 0); 2062 xengnttab_map_grant_ref(xg, 0, 0, 0); 2063 2064 return 0; 2065} 2066EOF 2067 compile_prog "" "$xen_libs $xen_stable_libs" 2068 then 2069 xen_ctrl_version=40701 2070 xen=enabled 2071 2072 # Xen 4.6 2073 elif 2074 cat > $TMPC <<EOF && 2075#include <xenctrl.h> 2076#include <xenstore.h> 2077#include <stdint.h> 2078#include <xen/hvm/hvm_info_table.h> 2079#if !defined(HVM_MAX_VCPUS) 2080# error HVM_MAX_VCPUS not defined 2081#endif 2082int main(void) { 2083 xc_interface *xc; 2084 xs_daemon_open(); 2085 xc = xc_interface_open(0, 0, 0); 2086 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2087 xc_gnttab_open(NULL, 0); 2088 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2089 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 2090 xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 2091 xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); 2092 return 0; 2093} 2094EOF 2095 compile_prog "" "$xen_libs" 2096 then 2097 xen_ctrl_version=40600 2098 xen=enabled 2099 2100 # Xen 4.5 2101 elif 2102 cat > $TMPC <<EOF && 2103#include <xenctrl.h> 2104#include <xenstore.h> 2105#include <stdint.h> 2106#include <xen/hvm/hvm_info_table.h> 2107#if !defined(HVM_MAX_VCPUS) 2108# error HVM_MAX_VCPUS not defined 2109#endif 2110int main(void) { 2111 xc_interface *xc; 2112 xs_daemon_open(); 2113 xc = xc_interface_open(0, 0, 0); 2114 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2115 xc_gnttab_open(NULL, 0); 2116 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2117 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 2118 xc_hvm_create_ioreq_server(xc, 0, 0, NULL); 2119 return 0; 2120} 2121EOF 2122 compile_prog "" "$xen_libs" 2123 then 2124 xen_ctrl_version=40500 2125 xen=enabled 2126 2127 elif 2128 cat > $TMPC <<EOF && 2129#include <xenctrl.h> 2130#include <xenstore.h> 2131#include <stdint.h> 2132#include <xen/hvm/hvm_info_table.h> 2133#if !defined(HVM_MAX_VCPUS) 2134# error HVM_MAX_VCPUS not defined 2135#endif 2136int main(void) { 2137 xc_interface *xc; 2138 xs_daemon_open(); 2139 xc = xc_interface_open(0, 0, 0); 2140 xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2141 xc_gnttab_open(NULL, 0); 2142 xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2143 xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 2144 return 0; 2145} 2146EOF 2147 compile_prog "" "$xen_libs" 2148 then 2149 xen_ctrl_version=40200 2150 xen=enabled 2151 2152 else 2153 if test "$xen" = "enabled" ; then 2154 feature_not_found "xen (unsupported version)" \ 2155 "Install a supported xen (xen 4.2 or newer)" 2156 fi 2157 xen=disabled 2158 fi 2159 2160 if test "$xen" = enabled; then 2161 if test $xen_ctrl_version -ge 40701 ; then 2162 xen_libs="$xen_libs $xen_stable_libs " 2163 fi 2164 fi 2165 fi 2166fi 2167 2168########################################## 2169# RDMA needs OpenFabrics libraries 2170if test "$rdma" != "no" ; then 2171 cat > $TMPC <<EOF 2172#include <rdma/rdma_cma.h> 2173int main(void) { return 0; } 2174EOF 2175 rdma_libs="-lrdmacm -libverbs -libumad" 2176 if compile_prog "" "$rdma_libs" ; then 2177 rdma="yes" 2178 else 2179 if test "$rdma" = "yes" ; then 2180 error_exit \ 2181 " OpenFabrics librdmacm/libibverbs/libibumad not present." \ 2182 " Your options:" \ 2183 " (1) Fast: Install infiniband packages (devel) from your distro." \ 2184 " (2) Cleanest: Install libraries from www.openfabrics.org" \ 2185 " (3) Also: Install softiwarp if you don't have RDMA hardware" 2186 fi 2187 rdma="no" 2188 fi 2189fi 2190 2191########################################## 2192# PVRDMA detection 2193 2194cat > $TMPC <<EOF && 2195#include <sys/mman.h> 2196 2197int 2198main(void) 2199{ 2200 char buf = 0; 2201 void *addr = &buf; 2202 addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED); 2203 2204 return 0; 2205} 2206EOF 2207 2208if test "$rdma" = "yes" ; then 2209 case "$pvrdma" in 2210 "") 2211 if compile_prog "" ""; then 2212 pvrdma="yes" 2213 else 2214 pvrdma="no" 2215 fi 2216 ;; 2217 "yes") 2218 if ! compile_prog "" ""; then 2219 error_exit "PVRDMA is not supported since mremap is not implemented" 2220 fi 2221 pvrdma="yes" 2222 ;; 2223 "no") 2224 pvrdma="no" 2225 ;; 2226 esac 2227else 2228 if test "$pvrdma" = "yes" ; then 2229 error_exit "PVRDMA requires rdma suppport" 2230 fi 2231 pvrdma="no" 2232fi 2233 2234# Let's see if enhanced reg_mr is supported 2235if test "$pvrdma" = "yes" ; then 2236 2237cat > $TMPC <<EOF && 2238#include <infiniband/verbs.h> 2239 2240int 2241main(void) 2242{ 2243 struct ibv_mr *mr; 2244 struct ibv_pd *pd = NULL; 2245 size_t length = 10; 2246 uint64_t iova = 0; 2247 int access = 0; 2248 void *addr = NULL; 2249 2250 mr = ibv_reg_mr_iova(pd, addr, length, iova, access); 2251 2252 ibv_dereg_mr(mr); 2253 2254 return 0; 2255} 2256EOF 2257 if ! compile_prog "" "-libverbs"; then 2258 QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR" 2259 fi 2260fi 2261 2262########################################## 2263# glib support probe 2264 2265glib_req_ver=2.56 2266glib_modules=gthread-2.0 2267if test "$modules" = yes; then 2268 glib_modules="$glib_modules gmodule-export-2.0" 2269elif test "$plugins" = "yes"; then 2270 glib_modules="$glib_modules gmodule-no-export-2.0" 2271fi 2272 2273for i in $glib_modules; do 2274 if $pkg_config --atleast-version=$glib_req_ver $i; then 2275 glib_cflags=$($pkg_config --cflags $i) 2276 glib_libs=$($pkg_config --libs $i) 2277 else 2278 error_exit "glib-$glib_req_ver $i is required to compile QEMU" 2279 fi 2280done 2281 2282# This workaround is required due to a bug in pkg-config file for glib as it 2283# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 2284 2285if test "$static" = yes && test "$mingw32" = yes; then 2286 glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 2287fi 2288 2289if ! test "$gio" = "no"; then 2290 pass=no 2291 if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then 2292 gio_cflags=$($pkg_config --cflags gio-2.0) 2293 gio_libs=$($pkg_config --libs gio-2.0) 2294 gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) 2295 if ! has "$gdbus_codegen"; then 2296 gdbus_codegen= 2297 fi 2298 # Check that the libraries actually work -- Ubuntu 18.04 ships 2299 # with pkg-config --static --libs data for gio-2.0 that is missing 2300 # -lblkid and will give a link error. 2301 cat > $TMPC <<EOF 2302#include <gio/gio.h> 2303int main(void) 2304{ 2305 g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); 2306 return 0; 2307} 2308EOF 2309 if compile_prog "$gio_cflags" "$gio_libs" ; then 2310 pass=yes 2311 else 2312 pass=no 2313 fi 2314 2315 if test "$pass" = "yes" && 2316 $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then 2317 gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)" 2318 gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)" 2319 fi 2320 fi 2321 2322 if test "$pass" = "no"; then 2323 if test "$gio" = "yes"; then 2324 feature_not_found "gio" "Install libgio >= 2.0" 2325 else 2326 gio=no 2327 fi 2328 else 2329 gio=yes 2330 fi 2331fi 2332 2333# Sanity check that the current size_t matches the 2334# size that glib thinks it should be. This catches 2335# problems on multi-arch where people try to build 2336# 32-bit QEMU while pointing at 64-bit glib headers 2337cat > $TMPC <<EOF 2338#include <glib.h> 2339#include <unistd.h> 2340 2341#define QEMU_BUILD_BUG_ON(x) \ 2342 typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 2343 2344int main(void) { 2345 QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 2346 return 0; 2347} 2348EOF 2349 2350if ! compile_prog "$glib_cflags" "$glib_libs" ; then 2351 error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 2352 "You probably need to set PKG_CONFIG_LIBDIR"\ 2353 "to point to the right pkg-config files for your"\ 2354 "build target" 2355fi 2356 2357# Silence clang warnings triggered by glib < 2.57.2 2358cat > $TMPC << EOF 2359#include <glib.h> 2360typedef struct Foo { 2361 int i; 2362} Foo; 2363static void foo_free(Foo *f) 2364{ 2365 g_free(f); 2366} 2367G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free); 2368int main(void) { return 0; } 2369EOF 2370if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 2371 if cc_has_warning_flag "-Wno-unused-function"; then 2372 glib_cflags="$glib_cflags -Wno-unused-function" 2373 CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 2374 fi 2375fi 2376 2377########################################## 2378# SHA command probe for modules 2379if test "$modules" = yes; then 2380 shacmd_probe="sha1sum sha1 shasum" 2381 for c in $shacmd_probe; do 2382 if has $c; then 2383 shacmd="$c" 2384 break 2385 fi 2386 done 2387 if test "$shacmd" = ""; then 2388 error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" 2389 fi 2390fi 2391 2392########################################## 2393# fdt probe 2394 2395case "$fdt" in 2396 auto | enabled | internal) 2397 # Simpler to always update submodule, even if not needed. 2398 git_submodules="${git_submodules} dtc" 2399 ;; 2400esac 2401 2402########################################## 2403# opengl probe (for sdl2, gtk) 2404 2405if test "$opengl" != "no" ; then 2406 epoxy=no 2407 if $pkg_config epoxy; then 2408 cat > $TMPC << EOF 2409#include <epoxy/egl.h> 2410int main(void) { return 0; } 2411EOF 2412 if compile_prog "" "" ; then 2413 epoxy=yes 2414 fi 2415 fi 2416 2417 if test "$epoxy" = "yes" ; then 2418 opengl_cflags="$($pkg_config --cflags epoxy)" 2419 opengl_libs="$($pkg_config --libs epoxy)" 2420 opengl=yes 2421 else 2422 if test "$opengl" = "yes" ; then 2423 feature_not_found "opengl" "Please install epoxy with EGL" 2424 fi 2425 opengl_cflags="" 2426 opengl_libs="" 2427 opengl=no 2428 fi 2429fi 2430 2431# check for usbfs 2432have_usbfs=no 2433if test "$linux_user" = "yes"; then 2434 cat > $TMPC << EOF 2435#include <linux/usbdevice_fs.h> 2436 2437#ifndef USBDEVFS_GET_CAPABILITIES 2438#error "USBDEVFS_GET_CAPABILITIES undefined" 2439#endif 2440 2441#ifndef USBDEVFS_DISCONNECT_CLAIM 2442#error "USBDEVFS_DISCONNECT_CLAIM undefined" 2443#endif 2444 2445int main(void) 2446{ 2447 return 0; 2448} 2449EOF 2450 if compile_prog "" ""; then 2451 have_usbfs=yes 2452 fi 2453fi 2454 2455########################################## 2456# check if we have VSS SDK headers for win 2457 2458guest_agent_with_vss="no" 2459if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \ 2460 test "$vss_win32_sdk" != "no" ; then 2461 case "$vss_win32_sdk" in 2462 "") vss_win32_include="-isystem $source_path" ;; 2463 *\ *) # The SDK is installed in "Program Files" by default, but we cannot 2464 # handle path with spaces. So we symlink the headers into ".sdk/vss". 2465 vss_win32_include="-isystem $source_path/.sdk/vss" 2466 symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc" 2467 ;; 2468 *) vss_win32_include="-isystem $vss_win32_sdk" 2469 esac 2470 cat > $TMPC << EOF 2471#define __MIDL_user_allocate_free_DEFINED__ 2472#include <inc/win2003/vss.h> 2473int main(void) { return VSS_CTX_BACKUP; } 2474EOF 2475 if compile_prog "$vss_win32_include" "" ; then 2476 guest_agent_with_vss="yes" 2477 QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include" 2478 libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga" 2479 qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb" 2480 else 2481 if test "$vss_win32_sdk" != "" ; then 2482 echo "ERROR: Please download and install Microsoft VSS SDK:" 2483 echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490" 2484 echo "ERROR: On POSIX-systems, you can extract the SDK headers by:" 2485 echo "ERROR: scripts/extract-vsssdk-headers setup.exe" 2486 echo "ERROR: The headers are extracted in the directory \`inc'." 2487 feature_not_found "VSS support" 2488 fi 2489 fi 2490fi 2491 2492########################################## 2493# lookup Windows platform SDK (if not specified) 2494# The SDK is needed only to build .tlb (type library) file of guest agent 2495# VSS provider from the source. It is usually unnecessary because the 2496# pre-compiled .tlb file is included. 2497 2498if test "$mingw32" = "yes" && test "$guest_agent" != "no" && \ 2499 test "$guest_agent_with_vss" = "yes" ; then 2500 if test -z "$win_sdk"; then 2501 programfiles="$PROGRAMFILES" 2502 test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432" 2503 if test -n "$programfiles"; then 2504 win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null 2505 else 2506 feature_not_found "Windows SDK" 2507 fi 2508 elif test "$win_sdk" = "no"; then 2509 win_sdk="" 2510 fi 2511fi 2512 2513########################################## 2514# check if mingw environment provides a recent ntddscsi.h 2515guest_agent_ntddscsi="no" 2516if test "$mingw32" = "yes" && test "$guest_agent" != "no"; then 2517 cat > $TMPC << EOF 2518#include <windows.h> 2519#include <ntddscsi.h> 2520int main(void) { 2521#if !defined(IOCTL_SCSI_GET_ADDRESS) 2522#error Missing required ioctl definitions 2523#endif 2524 SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 }; 2525 return addr.Lun; 2526} 2527EOF 2528 if compile_prog "" "" ; then 2529 guest_agent_ntddscsi=yes 2530 libs_qga="-lsetupapi -lcfgmgr32 $libs_qga" 2531 fi 2532fi 2533 2534########################################## 2535# capstone 2536 2537case "$capstone" in 2538 auto | enabled | internal) 2539 # Simpler to always update submodule, even if not needed. 2540 git_submodules="${git_submodules} capstone" 2541 ;; 2542esac 2543 2544########################################## 2545# check and set a backend for coroutine 2546 2547# We prefer ucontext, but it's not always possible. The fallback 2548# is sigcontext. On Windows the only valid backend is the Windows 2549# specific one. 2550 2551ucontext_works=no 2552if test "$darwin" != "yes"; then 2553 cat > $TMPC << EOF 2554#include <ucontext.h> 2555#ifdef __stub_makecontext 2556#error Ignoring glibc stub makecontext which will always fail 2557#endif 2558int main(void) { makecontext(0, 0, 0); return 0; } 2559EOF 2560 if compile_prog "" "" ; then 2561 ucontext_works=yes 2562 fi 2563fi 2564 2565if test "$coroutine" = ""; then 2566 if test "$mingw32" = "yes"; then 2567 coroutine=win32 2568 elif test "$ucontext_works" = "yes"; then 2569 coroutine=ucontext 2570 else 2571 coroutine=sigaltstack 2572 fi 2573else 2574 case $coroutine in 2575 windows) 2576 if test "$mingw32" != "yes"; then 2577 error_exit "'windows' coroutine backend only valid for Windows" 2578 fi 2579 # Unfortunately the user visible backend name doesn't match the 2580 # coroutine-*.c filename for this case, so we have to adjust it here. 2581 coroutine=win32 2582 ;; 2583 ucontext) 2584 if test "$ucontext_works" != "yes"; then 2585 feature_not_found "ucontext" 2586 fi 2587 ;; 2588 sigaltstack) 2589 if test "$mingw32" = "yes"; then 2590 error_exit "only the 'windows' coroutine backend is valid for Windows" 2591 fi 2592 ;; 2593 *) 2594 error_exit "unknown coroutine backend $coroutine" 2595 ;; 2596 esac 2597fi 2598 2599if test "$coroutine_pool" = ""; then 2600 coroutine_pool=yes 2601fi 2602 2603if test "$debug_stack_usage" = "yes"; then 2604 if test "$coroutine_pool" = "yes"; then 2605 echo "WARN: disabling coroutine pool for stack usage debugging" 2606 coroutine_pool=no 2607 fi 2608fi 2609 2610################################################## 2611# SafeStack 2612 2613 2614if test "$safe_stack" = "yes"; then 2615cat > $TMPC << EOF 2616int main(int argc, char *argv[]) 2617{ 2618#if ! __has_feature(safe_stack) 2619#error SafeStack Disabled 2620#endif 2621 return 0; 2622} 2623EOF 2624 flag="-fsanitize=safe-stack" 2625 # Check that safe-stack is supported and enabled. 2626 if compile_prog "-Werror $flag" "$flag"; then 2627 # Flag needed both at compilation and at linking 2628 QEMU_CFLAGS="$QEMU_CFLAGS $flag" 2629 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 2630 else 2631 error_exit "SafeStack not supported by your compiler" 2632 fi 2633 if test "$coroutine" != "ucontext"; then 2634 error_exit "SafeStack is only supported by the coroutine backend ucontext" 2635 fi 2636else 2637cat > $TMPC << EOF 2638int main(int argc, char *argv[]) 2639{ 2640#if defined(__has_feature) 2641#if __has_feature(safe_stack) 2642#error SafeStack Enabled 2643#endif 2644#endif 2645 return 0; 2646} 2647EOF 2648if test "$safe_stack" = "no"; then 2649 # Make sure that safe-stack is disabled 2650 if ! compile_prog "-Werror" ""; then 2651 # SafeStack was already enabled, try to explicitly remove the feature 2652 flag="-fno-sanitize=safe-stack" 2653 if ! compile_prog "-Werror $flag" "$flag"; then 2654 error_exit "Configure cannot disable SafeStack" 2655 fi 2656 QEMU_CFLAGS="$QEMU_CFLAGS $flag" 2657 QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 2658 fi 2659else # "$safe_stack" = "" 2660 # Set safe_stack to yes or no based on pre-existing flags 2661 if compile_prog "-Werror" ""; then 2662 safe_stack="no" 2663 else 2664 safe_stack="yes" 2665 if test "$coroutine" != "ucontext"; then 2666 error_exit "SafeStack is only supported by the coroutine backend ucontext" 2667 fi 2668 fi 2669fi 2670fi 2671 2672######################################## 2673# check if __[u]int128_t is usable. 2674 2675int128=no 2676cat > $TMPC << EOF 2677__int128_t a; 2678__uint128_t b; 2679int main (void) { 2680 a = a + b; 2681 b = a * b; 2682 a = a * a; 2683 return 0; 2684} 2685EOF 2686if compile_prog "" "" ; then 2687 int128=yes 2688fi 2689 2690######################################### 2691# See if 128-bit atomic operations are supported. 2692 2693atomic128=no 2694if test "$int128" = "yes"; then 2695 cat > $TMPC << EOF 2696int main(void) 2697{ 2698 unsigned __int128 x = 0, y = 0; 2699 y = __atomic_load(&x, 0); 2700 __atomic_store(&x, y, 0); 2701 __atomic_compare_exchange(&x, &y, x, 0, 0, 0); 2702 return 0; 2703} 2704EOF 2705 if compile_prog "" "" ; then 2706 atomic128=yes 2707 fi 2708fi 2709 2710cmpxchg128=no 2711if test "$int128" = yes && test "$atomic128" = no; then 2712 cat > $TMPC << EOF 2713int main(void) 2714{ 2715 unsigned __int128 x = 0, y = 0; 2716 __sync_val_compare_and_swap_16(&x, y, x); 2717 return 0; 2718} 2719EOF 2720 if compile_prog "" "" ; then 2721 cmpxchg128=yes 2722 fi 2723fi 2724 2725######################################## 2726# check if ccache is interfering with 2727# semantic analysis of macros 2728 2729unset CCACHE_CPP2 2730ccache_cpp2=no 2731cat > $TMPC << EOF 2732static const int Z = 1; 2733#define fn() ({ Z; }) 2734#define TAUT(X) ((X) == Z) 2735#define PAREN(X, Y) (X == Y) 2736#define ID(X) (X) 2737int main(int argc, char *argv[]) 2738{ 2739 int x = 0, y = 0; 2740 x = ID(x); 2741 x = fn(); 2742 fn(); 2743 if (PAREN(x, y)) return 0; 2744 if (TAUT(Z)) return 0; 2745 return 0; 2746} 2747EOF 2748 2749if ! compile_object "-Werror"; then 2750 ccache_cpp2=yes 2751fi 2752 2753################################################# 2754# clang does not support glibc + FORTIFY_SOURCE. 2755 2756if test "$fortify_source" != "no"; then 2757 if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 2758 fortify_source="no"; 2759 elif test -n "$cxx" && has $cxx && 2760 echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 2761 fortify_source="no"; 2762 else 2763 fortify_source="yes" 2764 fi 2765fi 2766 2767########################################## 2768# checks for sanitizers 2769 2770have_asan=no 2771have_ubsan=no 2772have_asan_iface_h=no 2773have_asan_iface_fiber=no 2774 2775if test "$sanitizers" = "yes" ; then 2776 write_c_skeleton 2777 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 2778 have_asan=yes 2779 fi 2780 2781 # we could use a simple skeleton for flags checks, but this also 2782 # detect the static linking issue of ubsan, see also: 2783 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 2784 cat > $TMPC << EOF 2785#include <stdlib.h> 2786int main(void) { 2787 void *tmp = malloc(10); 2788 if (tmp != NULL) { 2789 return *(int *)(tmp + 2); 2790 } 2791 return 1; 2792} 2793EOF 2794 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 2795 have_ubsan=yes 2796 fi 2797 2798 if check_include "sanitizer/asan_interface.h" ; then 2799 have_asan_iface_h=yes 2800 fi 2801 2802 cat > $TMPC << EOF 2803#include <sanitizer/asan_interface.h> 2804int main(void) { 2805 __sanitizer_start_switch_fiber(0, 0, 0); 2806 return 0; 2807} 2808EOF 2809 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 2810 have_asan_iface_fiber=yes 2811 fi 2812fi 2813 2814# Thread sanitizer is, for now, much noisier than the other sanitizers; 2815# keep it separate until that is not the case. 2816if test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 2817 error_exit "TSAN is not supported with other sanitiziers." 2818fi 2819have_tsan=no 2820have_tsan_iface_fiber=no 2821if test "$tsan" = "yes" ; then 2822 write_c_skeleton 2823 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 2824 have_tsan=yes 2825 fi 2826 cat > $TMPC << EOF 2827#include <sanitizer/tsan_interface.h> 2828int main(void) { 2829 __tsan_create_fiber(0); 2830 return 0; 2831} 2832EOF 2833 if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 2834 have_tsan_iface_fiber=yes 2835 fi 2836fi 2837 2838########################################## 2839# check for slirp 2840 2841case "$slirp" in 2842 auto | enabled | internal) 2843 # Simpler to always update submodule, even if not needed. 2844 git_submodules="${git_submodules} slirp" 2845 ;; 2846esac 2847 2848# Check for slirp smbd dupport 2849: ${smbd=${SMBD-/usr/sbin/smbd}} 2850if test "$slirp_smbd" != "no" ; then 2851 if test "$mingw32" = "yes" ; then 2852 if test "$slirp_smbd" = "yes" ; then 2853 error_exit "Host smbd not supported on this platform." 2854 fi 2855 slirp_smbd=no 2856 else 2857 slirp_smbd=yes 2858 fi 2859fi 2860 2861########################################## 2862# check for usable __NR_keyctl syscall 2863 2864if test "$linux" = "yes" ; then 2865 2866 have_keyring=no 2867 cat > $TMPC << EOF 2868#include <errno.h> 2869#include <asm/unistd.h> 2870#include <linux/keyctl.h> 2871#include <unistd.h> 2872int main(void) { 2873 return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0); 2874} 2875EOF 2876 if compile_prog "" "" ; then 2877 have_keyring=yes 2878 fi 2879fi 2880if test "$secret_keyring" != "no" 2881then 2882 if test "$have_keyring" = "yes" 2883 then 2884 secret_keyring=yes 2885 else 2886 if test "$secret_keyring" = "yes" 2887 then 2888 error_exit "syscall __NR_keyctl requested, \ 2889but not implemented on your system" 2890 else 2891 secret_keyring=no 2892 fi 2893 fi 2894fi 2895 2896########################################## 2897# End of CC checks 2898# After here, no more $cc or $ld runs 2899 2900write_c_skeleton 2901 2902if test "$gcov" = "yes" ; then 2903 : 2904elif test "$fortify_source" = "yes" ; then 2905 QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 2906 debug=no 2907fi 2908 2909case "$ARCH" in 2910alpha) 2911 # Ensure there's only a single GP 2912 QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 2913;; 2914esac 2915 2916if test "$gprof" = "yes" ; then 2917 QEMU_CFLAGS="-p $QEMU_CFLAGS" 2918 QEMU_LDFLAGS="-p $QEMU_LDFLAGS" 2919fi 2920 2921if test "$have_asan" = "yes"; then 2922 QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 2923 QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 2924 if test "$have_asan_iface_h" = "no" ; then 2925 echo "ASAN build enabled, but ASAN header missing." \ 2926 "Without code annotation, the report may be inferior." 2927 elif test "$have_asan_iface_fiber" = "no" ; then 2928 echo "ASAN build enabled, but ASAN header is too old." \ 2929 "Without code annotation, the report may be inferior." 2930 fi 2931fi 2932if test "$have_tsan" = "yes" ; then 2933 if test "$have_tsan_iface_fiber" = "yes" ; then 2934 QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 2935 QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 2936 else 2937 error_exit "Cannot enable TSAN due to missing fiber annotation interface." 2938 fi 2939elif test "$tsan" = "yes" ; then 2940 error_exit "Cannot enable TSAN due to missing sanitize thread interface." 2941fi 2942if test "$have_ubsan" = "yes"; then 2943 QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 2944 QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 2945fi 2946 2947########################################## 2948 2949# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 2950if test "$solaris" = "no" && test "$tsan" = "no"; then 2951 if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 2952 QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 2953 fi 2954fi 2955 2956# Use ASLR, no-SEH and DEP if available 2957if test "$mingw32" = "yes" ; then 2958 flags="--no-seh --nxcompat" 2959 2960 # Disable ASLR for debug builds to allow debugging with gdb 2961 if test "$debug" = "no" ; then 2962 flags="--dynamicbase $flags" 2963 fi 2964 2965 for flag in $flags; do 2966 if ld_has $flag ; then 2967 QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS" 2968 fi 2969 done 2970fi 2971 2972# Probe for guest agent support/options 2973 2974if [ "$guest_agent" != "no" ]; then 2975 if [ "$softmmu" = no -a "$want_tools" = no ] ; then 2976 guest_agent=no 2977 elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then 2978 guest_agent=yes 2979 elif [ "$guest_agent" != yes ]; then 2980 guest_agent=no 2981 else 2982 error_exit "Guest agent is not supported on this platform" 2983 fi 2984fi 2985 2986# Guest agent Windows MSI package 2987 2988if test "$QEMU_GA_MANUFACTURER" = ""; then 2989 QEMU_GA_MANUFACTURER=QEMU 2990fi 2991if test "$QEMU_GA_DISTRO" = ""; then 2992 QEMU_GA_DISTRO=Linux 2993fi 2994if test "$QEMU_GA_VERSION" = ""; then 2995 QEMU_GA_VERSION=$(cat $source_path/VERSION) 2996fi 2997 2998QEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 2999 3000# Mac OS X ships with a broken assembler 3001roms= 3002if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 3003 test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 3004 test "$targetos" != "haiku" && test "$softmmu" = yes ; then 3005 # Different host OS linkers have different ideas about the name of the ELF 3006 # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 3007 # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 3008 for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 3009 if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 3010 ld_i386_emulation="$emu" 3011 roms="optionrom" 3012 break 3013 fi 3014 done 3015fi 3016 3017# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 3018# or -march=z10 (which is the lowest architecture level that Clang supports) 3019if test "$cpu" = "s390x" ; then 3020 write_c_skeleton 3021 compile_prog "-march=z900" "" 3022 has_z900=$? 3023 if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 3024 if [ $has_z900 != 0 ]; then 3025 echo "WARNING: Your compiler does not support the z900!" 3026 echo " The s390-ccw bios will only work with guest CPUs >= z10." 3027 fi 3028 roms="$roms s390-ccw" 3029 # SLOF is required for building the s390-ccw firmware on s390x, 3030 # since it is using the libnet code from SLOF for network booting. 3031 git_submodules="${git_submodules} roms/SLOF" 3032 fi 3033fi 3034 3035# Check that the C++ compiler exists and works with the C compiler. 3036# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added. 3037if has $cxx; then 3038 cat > $TMPC <<EOF 3039int c_function(void); 3040int main(void) { return c_function(); } 3041EOF 3042 3043 compile_object 3044 3045 cat > $TMPCXX <<EOF 3046extern "C" { 3047 int c_function(void); 3048} 3049int c_function(void) { return 42; } 3050EOF 3051 3052 update_cxxflags 3053 3054 if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 3055 # C++ compiler $cxx works ok with C compiler $cc 3056 : 3057 else 3058 echo "C++ compiler $cxx does not work with C compiler $cc" 3059 echo "Disabling C++ specific optional code" 3060 cxx= 3061 fi 3062else 3063 echo "No C++ compiler available; disabling C++ specific optional code" 3064 cxx= 3065fi 3066 3067if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 3068 exit 1 3069fi 3070 3071config_host_mak="config-host.mak" 3072 3073echo "# Automatically generated by configure - do not modify" > $config_host_mak 3074echo >> $config_host_mak 3075 3076echo all: >> $config_host_mak 3077echo "GIT=$git" >> $config_host_mak 3078echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 3079echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 3080 3081if test "$debug_tcg" = "yes" ; then 3082 echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 3083fi 3084if test "$mingw32" = "yes" ; then 3085 echo "CONFIG_WIN32=y" >> $config_host_mak 3086 if test "$guest_agent_with_vss" = "yes" ; then 3087 echo "CONFIG_QGA_VSS=y" >> $config_host_mak 3088 echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak 3089 echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak 3090 fi 3091 if test "$guest_agent_ntddscsi" = "yes" ; then 3092 echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak 3093 fi 3094 echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak 3095 echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 3096 echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 3097 echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 3098else 3099 echo "CONFIG_POSIX=y" >> $config_host_mak 3100fi 3101 3102if test "$linux" = "yes" ; then 3103 echo "CONFIG_LINUX=y" >> $config_host_mak 3104fi 3105 3106if test "$darwin" = "yes" ; then 3107 echo "CONFIG_DARWIN=y" >> $config_host_mak 3108fi 3109 3110if test "$solaris" = "yes" ; then 3111 echo "CONFIG_SOLARIS=y" >> $config_host_mak 3112fi 3113if test "$static" = "yes" ; then 3114 echo "CONFIG_STATIC=y" >> $config_host_mak 3115fi 3116if test "$profiler" = "yes" ; then 3117 echo "CONFIG_PROFILER=y" >> $config_host_mak 3118fi 3119if test "$want_tools" = "yes" ; then 3120 echo "CONFIG_TOOLS=y" >> $config_host_mak 3121fi 3122if test "$guest_agent" = "yes" ; then 3123 echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak 3124fi 3125if test "$slirp_smbd" = "yes" ; then 3126 echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak 3127 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak 3128fi 3129if test "$gprof" = "yes" ; then 3130 echo "CONFIG_GPROF=y" >> $config_host_mak 3131fi 3132echo "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak 3133echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak 3134if test "$block_drv_whitelist_tools" = "yes" ; then 3135 echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak 3136fi 3137qemu_version=$(head $source_path/VERSION) 3138echo "PKGVERSION=$pkgversion" >>$config_host_mak 3139echo "SRC_PATH=$source_path" >> $config_host_mak 3140echo "TARGET_DIRS=$target_list" >> $config_host_mak 3141if test "$modules" = "yes"; then 3142 # $shacmd can generate a hash started with digit, which the compiler doesn't 3143 # like as an symbol. So prefix it with an underscore 3144 echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak 3145 echo "CONFIG_MODULES=y" >> $config_host_mak 3146fi 3147if test "$module_upgrades" = "yes"; then 3148 echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak 3149fi 3150if test "$have_usbfs" = "yes" ; then 3151 echo "CONFIG_USBFS=y" >> $config_host_mak 3152fi 3153if test "$gio" = "yes" ; then 3154 echo "CONFIG_GIO=y" >> $config_host_mak 3155 echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak 3156 echo "GIO_LIBS=$gio_libs" >> $config_host_mak 3157fi 3158if test "$gdbus_codegen" != "" ; then 3159 echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak 3160fi 3161echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak 3162 3163if test "$xen" = "enabled" ; then 3164 echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak 3165 echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak 3166 echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak 3167 echo "XEN_LIBS=$xen_libs" >> $config_host_mak 3168fi 3169if test "$vhost_scsi" = "yes" ; then 3170 echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 3171fi 3172if test "$vhost_net" = "yes" ; then 3173 echo "CONFIG_VHOST_NET=y" >> $config_host_mak 3174fi 3175if test "$vhost_net_user" = "yes" ; then 3176 echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 3177fi 3178if test "$vhost_net_vdpa" = "yes" ; then 3179 echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak 3180fi 3181if test "$vhost_crypto" = "yes" ; then 3182 echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak 3183fi 3184if test "$vhost_vsock" = "yes" ; then 3185 echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak 3186 if test "$vhost_user" = "yes" ; then 3187 echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak 3188 fi 3189fi 3190if test "$vhost_kernel" = "yes" ; then 3191 echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak 3192fi 3193if test "$vhost_user" = "yes" ; then 3194 echo "CONFIG_VHOST_USER=y" >> $config_host_mak 3195fi 3196if test "$vhost_vdpa" = "yes" ; then 3197 echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak 3198fi 3199if test "$vhost_user_fs" = "yes" ; then 3200 echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak 3201fi 3202if test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then 3203 echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak 3204fi 3205 3206if test "$opengl" = "yes" ; then 3207 echo "CONFIG_OPENGL=y" >> $config_host_mak 3208 echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak 3209 echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak 3210fi 3211 3212# XXX: suppress that 3213if [ "$bsd" = "yes" ] ; then 3214 echo "CONFIG_BSD=y" >> $config_host_mak 3215fi 3216 3217if test "$qom_cast_debug" = "yes" ; then 3218 echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak 3219fi 3220 3221echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 3222if test "$coroutine_pool" = "yes" ; then 3223 echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak 3224else 3225 echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak 3226fi 3227 3228if test "$debug_stack_usage" = "yes" ; then 3229 echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak 3230fi 3231 3232if test "$have_asan_iface_fiber" = "yes" ; then 3233 echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 3234fi 3235 3236if test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 3237 echo "CONFIG_TSAN=y" >> $config_host_mak 3238fi 3239 3240if test "$int128" = "yes" ; then 3241 echo "CONFIG_INT128=y" >> $config_host_mak 3242fi 3243 3244if test "$atomic128" = "yes" ; then 3245 echo "CONFIG_ATOMIC128=y" >> $config_host_mak 3246fi 3247 3248if test "$cmpxchg128" = "yes" ; then 3249 echo "CONFIG_CMPXCHG128=y" >> $config_host_mak 3250fi 3251 3252if test "$live_block_migration" = "yes" ; then 3253 echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak 3254fi 3255 3256if test "$rdma" = "yes" ; then 3257 echo "CONFIG_RDMA=y" >> $config_host_mak 3258 echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak 3259fi 3260 3261if test "$pvrdma" = "yes" ; then 3262 echo "CONFIG_PVRDMA=y" >> $config_host_mak 3263fi 3264 3265if test "$replication" = "yes" ; then 3266 echo "CONFIG_REPLICATION=y" >> $config_host_mak 3267fi 3268 3269if test "$debug_mutex" = "yes" ; then 3270 echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak 3271fi 3272 3273if test "$bochs" = "yes" ; then 3274 echo "CONFIG_BOCHS=y" >> $config_host_mak 3275fi 3276if test "$cloop" = "yes" ; then 3277 echo "CONFIG_CLOOP=y" >> $config_host_mak 3278fi 3279if test "$dmg" = "yes" ; then 3280 echo "CONFIG_DMG=y" >> $config_host_mak 3281fi 3282if test "$qcow1" = "yes" ; then 3283 echo "CONFIG_QCOW1=y" >> $config_host_mak 3284fi 3285if test "$vdi" = "yes" ; then 3286 echo "CONFIG_VDI=y" >> $config_host_mak 3287fi 3288if test "$vvfat" = "yes" ; then 3289 echo "CONFIG_VVFAT=y" >> $config_host_mak 3290fi 3291if test "$qed" = "yes" ; then 3292 echo "CONFIG_QED=y" >> $config_host_mak 3293fi 3294if test "$parallels" = "yes" ; then 3295 echo "CONFIG_PARALLELS=y" >> $config_host_mak 3296fi 3297 3298if test "$plugins" = "yes" ; then 3299 echo "CONFIG_PLUGIN=y" >> $config_host_mak 3300fi 3301 3302if test -n "$gdb_bin"; then 3303 gdb_version=$($gdb_bin --version | head -n 1) 3304 if version_ge ${gdb_version##* } 9.1; then 3305 echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 3306 fi 3307fi 3308 3309if test "$secret_keyring" = "yes" ; then 3310 echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak 3311fi 3312 3313echo "ROMS=$roms" >> $config_host_mak 3314echo "MAKE=$make" >> $config_host_mak 3315echo "PYTHON=$python" >> $config_host_mak 3316echo "GENISOIMAGE=$genisoimage" >> $config_host_mak 3317echo "MESON=$meson" >> $config_host_mak 3318echo "NINJA=$ninja" >> $config_host_mak 3319echo "CC=$cc" >> $config_host_mak 3320echo "HOST_CC=$host_cc" >> $config_host_mak 3321if $iasl -h > /dev/null 2>&1; then 3322 echo "CONFIG_IASL=$iasl" >> $config_host_mak 3323fi 3324echo "AR=$ar" >> $config_host_mak 3325echo "AS=$as" >> $config_host_mak 3326echo "CCAS=$ccas" >> $config_host_mak 3327echo "CPP=$cpp" >> $config_host_mak 3328echo "OBJCOPY=$objcopy" >> $config_host_mak 3329echo "LD=$ld" >> $config_host_mak 3330echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak 3331echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 3332echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 3333echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 3334echo "GLIB_LIBS=$glib_libs" >> $config_host_mak 3335echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 3336echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 3337echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 3338echo "STRIP=$strip" >> $config_host_mak 3339echo "EXESUF=$EXESUF" >> $config_host_mak 3340echo "LIBS_QGA=$libs_qga" >> $config_host_mak 3341 3342if test "$rng_none" = "yes"; then 3343 echo "CONFIG_RNG_NONE=y" >> $config_host_mak 3344fi 3345 3346# use included Linux headers 3347if test "$linux" = "yes" ; then 3348 mkdir -p linux-headers 3349 case "$cpu" in 3350 i386|x86_64) 3351 linux_arch=x86 3352 ;; 3353 ppc|ppc64) 3354 linux_arch=powerpc 3355 ;; 3356 s390x) 3357 linux_arch=s390 3358 ;; 3359 aarch64) 3360 linux_arch=arm64 3361 ;; 3362 loongarch*) 3363 linux_arch=loongarch 3364 ;; 3365 mips64) 3366 linux_arch=mips 3367 ;; 3368 *) 3369 # For most CPUs the kernel architecture name and QEMU CPU name match. 3370 linux_arch="$cpu" 3371 ;; 3372 esac 3373 # For non-KVM architectures we will not have asm headers 3374 if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 3375 symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 3376 fi 3377fi 3378 3379for target in $target_list; do 3380 target_dir="$target" 3381 target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 3382 mkdir -p $target_dir 3383 case $target in 3384 *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 3385 *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 3386 esac 3387done 3388 3389echo "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak 3390if test "$default_targets" = "yes"; then 3391 echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 3392fi 3393 3394if test "$ccache_cpp2" = "yes"; then 3395 echo "export CCACHE_CPP2=y" >> $config_host_mak 3396fi 3397 3398if test "$safe_stack" = "yes"; then 3399 echo "CONFIG_SAFESTACK=y" >> $config_host_mak 3400fi 3401 3402# If we're using a separate build tree, set it up now. 3403# LINKS are things to symlink back into the source tree 3404# (these can be both files and directories). 3405# Caution: do not add files or directories here using wildcards. This 3406# will result in problems later if a new file matching the wildcard is 3407# added to the source tree -- nothing will cause configure to be rerun 3408# so the build tree will be missing the link back to the new file, and 3409# tests might fail. Prefer to keep the relevant files in their own 3410# directory and symlink the directory instead. 3411LINKS="Makefile" 3412LINKS="$LINKS tests/tcg/Makefile.target" 3413LINKS="$LINKS pc-bios/optionrom/Makefile" 3414LINKS="$LINKS pc-bios/s390-ccw/Makefile" 3415LINKS="$LINKS roms/seabios/Makefile" 3416LINKS="$LINKS pc-bios/qemu-icon.bmp" 3417LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 3418LINKS="$LINKS tests/avocado tests/data" 3419LINKS="$LINKS tests/qemu-iotests/check" 3420LINKS="$LINKS python" 3421LINKS="$LINKS contrib/plugins/Makefile " 3422for bios_file in \ 3423 $source_path/pc-bios/*.bin \ 3424 $source_path/pc-bios/*.elf \ 3425 $source_path/pc-bios/*.lid \ 3426 $source_path/pc-bios/*.rom \ 3427 $source_path/pc-bios/*.dtb \ 3428 $source_path/pc-bios/*.img \ 3429 $source_path/pc-bios/openbios-* \ 3430 $source_path/pc-bios/u-boot.* \ 3431 $source_path/pc-bios/palcode-* \ 3432 $source_path/pc-bios/qemu_vga.ndrv 3433 3434do 3435 LINKS="$LINKS pc-bios/$(basename $bios_file)" 3436done 3437for f in $LINKS ; do 3438 if [ -e "$source_path/$f" ]; then 3439 mkdir -p `dirname ./$f` 3440 symlink "$source_path/$f" "$f" 3441 fi 3442done 3443 3444(for i in $cross_cc_vars; do 3445 export $i 3446done 3447export target_list source_path use_containers cpu 3448$source_path/tests/tcg/configure.sh) 3449 3450# temporary config to build submodules 3451if test -f $source_path/roms/seabios/Makefile; then 3452 for rom in seabios; do 3453 config_mak=roms/$rom/config.mak 3454 echo "# Automatically generated by configure - do not modify" > $config_mak 3455 echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak 3456 echo "AS=$as" >> $config_mak 3457 echo "CCAS=$ccas" >> $config_mak 3458 echo "CC=$cc" >> $config_mak 3459 echo "BCC=bcc" >> $config_mak 3460 echo "CPP=$cpp" >> $config_mak 3461 echo "OBJCOPY=objcopy" >> $config_mak 3462 echo "IASL=$iasl" >> $config_mak 3463 echo "LD=$ld" >> $config_mak 3464 echo "RANLIB=$ranlib" >> $config_mak 3465 done 3466fi 3467 3468config_mak=pc-bios/optionrom/config.mak 3469echo "# Automatically generated by configure - do not modify" > $config_mak 3470echo "TOPSRC_DIR=$source_path" >> $config_mak 3471 3472if test "$skip_meson" = no; then 3473 cross="config-meson.cross.new" 3474 meson_quote() { 3475 test $# = 0 && return 3476 echo "'$(echo $* | sed "s/ /','/g")'" 3477 } 3478 3479 echo "# Automatically generated by configure - do not modify" > $cross 3480 echo "[properties]" >> $cross 3481 3482 # unroll any custom device configs 3483 for a in $device_archs; do 3484 eval "c=\$devices_${a}" 3485 echo "${a}-softmmu = '$c'" >> $cross 3486 done 3487 3488 test -z "$cxx" && echo "link_language = 'c'" >> $cross 3489 echo "[built-in options]" >> $cross 3490 echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 3491 echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 3492 echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 3493 echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 3494 echo "[binaries]" >> $cross 3495 echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 3496 test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 3497 test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 3498 echo "ar = [$(meson_quote $ar)]" >> $cross 3499 echo "nm = [$(meson_quote $nm)]" >> $cross 3500 echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 3501 echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 3502 if has $sdl2_config; then 3503 echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 3504 fi 3505 echo "strip = [$(meson_quote $strip)]" >> $cross 3506 echo "windres = [$(meson_quote $windres)]" >> $cross 3507 if test "$cross_compile" = "yes"; then 3508 cross_arg="--cross-file config-meson.cross" 3509 echo "[host_machine]" >> $cross 3510 echo "system = '$targetos'" >> $cross 3511 case "$cpu" in 3512 i386) 3513 echo "cpu_family = 'x86'" >> $cross 3514 ;; 3515 *) 3516 echo "cpu_family = '$cpu'" >> $cross 3517 ;; 3518 esac 3519 echo "cpu = '$cpu'" >> $cross 3520 if test "$bigendian" = "yes" ; then 3521 echo "endian = 'big'" >> $cross 3522 else 3523 echo "endian = 'little'" >> $cross 3524 fi 3525 else 3526 cross_arg="--native-file config-meson.cross" 3527 fi 3528 mv $cross config-meson.cross 3529 3530 rm -rf meson-private meson-info meson-logs 3531 run_meson() { 3532 NINJA=$ninja $meson setup \ 3533 --prefix "$prefix" \ 3534 --libdir "$libdir" \ 3535 --libexecdir "$libexecdir" \ 3536 --bindir "$bindir" \ 3537 --includedir "$includedir" \ 3538 --datadir "$datadir" \ 3539 --mandir "$mandir" \ 3540 --sysconfdir "$sysconfdir" \ 3541 --localedir "$localedir" \ 3542 --localstatedir "$local_statedir" \ 3543 -Daudio_drv_list=$audio_drv_list \ 3544 -Ddefault_devices=$default_devices \ 3545 -Ddocdir="$docdir" \ 3546 -Dqemu_firmwarepath="$firmwarepath" \ 3547 -Dqemu_suffix="$qemu_suffix" \ 3548 -Dsphinx_build="$sphinx_build" \ 3549 -Dtrace_file="$trace_file" \ 3550 -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ 3551 -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ 3552 -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ 3553 -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ 3554 -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ 3555 -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ 3556 -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ 3557 $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ 3558 $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ 3559 "$@" $cross_arg "$PWD" "$source_path" 3560 } 3561 eval run_meson $meson_options 3562 if test "$?" -ne 0 ; then 3563 error_exit "meson setup failed" 3564 fi 3565else 3566 if test -f meson-private/cmd_line.txt; then 3567 # Adjust old command line options whose type was changed 3568 # Avoids having to use "setup --wipe" when Meson is upgraded 3569 perl -i -ne ' 3570 s/^gettext = true$/gettext = auto/; 3571 s/^gettext = false$/gettext = disabled/; 3572 /^b_staticpic/ && next; 3573 print;' meson-private/cmd_line.txt 3574 fi 3575fi 3576 3577# Save the configure command line for later reuse. 3578cat <<EOD >config.status 3579#!/bin/sh 3580# Generated by configure. 3581# Run this file to recreate the current configuration. 3582# Compiler output produced by configure, useful for debugging 3583# configure, is in config.log if it exists. 3584EOD 3585 3586preserve_env() { 3587 envname=$1 3588 3589 eval envval=\$$envname 3590 3591 if test -n "$envval" 3592 then 3593 echo "$envname='$envval'" >> config.status 3594 echo "export $envname" >> config.status 3595 else 3596 echo "unset $envname" >> config.status 3597 fi 3598} 3599 3600# Preserve various env variables that influence what 3601# features/build target configure will detect 3602preserve_env AR 3603preserve_env AS 3604preserve_env CC 3605preserve_env CPP 3606preserve_env CFLAGS 3607preserve_env CXX 3608preserve_env CXXFLAGS 3609preserve_env INSTALL 3610preserve_env LD 3611preserve_env LDFLAGS 3612preserve_env LD_LIBRARY_PATH 3613preserve_env LIBTOOL 3614preserve_env MAKE 3615preserve_env NM 3616preserve_env OBJCOPY 3617preserve_env PATH 3618preserve_env PKG_CONFIG 3619preserve_env PKG_CONFIG_LIBDIR 3620preserve_env PKG_CONFIG_PATH 3621preserve_env PYTHON 3622preserve_env SDL2_CONFIG 3623preserve_env SMBD 3624preserve_env STRIP 3625preserve_env WINDRES 3626 3627printf "exec" >>config.status 3628for i in "$0" "$@"; do 3629 test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 3630done 3631echo ' "$@"' >>config.status 3632chmod +x config.status 3633 3634rm -r "$TMPDIR1" 3635