17d13299dSbellard#!/bin/sh 27d13299dSbellard# 33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard 47d13299dSbellard# 58cd05ab6SPeter Maydell 699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools, 799519e67SCornelia Huck# just as autoconf does. 899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS= 999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS 1099519e67SCornelia Huck 115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests! 125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes 135e4dfd3dSJohn Snow 14dedad027SDaniel P. Berrangé# make source path absolute 15dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd) 16dedad027SDaniel P. Berrangé 17dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path" 18dedad027SDaniel P. Berrangéthen 19dedad027SDaniel P. Berrangé echo "Using './build' as the directory for build output" 20dedad027SDaniel P. Berrangé 21dedad027SDaniel P. Berrangé MARKER=build/auto-created-by-configure 22dedad027SDaniel P. Berrangé 23dedad027SDaniel P. Berrangé if test -e build 24dedad027SDaniel P. Berrangé then 25dedad027SDaniel P. Berrangé if test -f $MARKER 26dedad027SDaniel P. Berrangé then 27dedad027SDaniel P. Berrangé rm -rf build 28dedad027SDaniel P. Berrangé else 29dedad027SDaniel P. Berrangé echo "ERROR: ./build dir already exists and was not previously created by configure" 30dedad027SDaniel P. Berrangé exit 1 31dedad027SDaniel P. Berrangé fi 32dedad027SDaniel P. Berrangé fi 33dedad027SDaniel P. Berrangé 34dedad027SDaniel P. Berrangé mkdir build 35dedad027SDaniel P. Berrangé touch $MARKER 36dedad027SDaniel P. Berrangé 37dedad027SDaniel P. Berrangé cat > GNUmakefile <<'EOF' 38dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree 39dedad027SDaniel P. Berrangé# 'make' command invocation 40dedad027SDaniel P. Berrangé 41dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),) 42dedad027SDaniel P. Berrangérecurse: all 43dedad027SDaniel P. Berrangéendif 44dedad027SDaniel P. Berrangé 45dedad027SDaniel P. Berrangé.NOTPARALLEL: % 46dedad027SDaniel P. Berrangé%: force 47dedad027SDaniel P. Berrangé @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...' 48dedad027SDaniel P. Berrangé @$(MAKE) -C build -f Makefile $(MAKECMDGOALS) 49dedad027SDaniel P. Berrangé @if test "$(MAKECMDGOALS)" = "distclean" && \ 50dedad027SDaniel P. Berrangé test -e build/auto-created-by-configure ; \ 51dedad027SDaniel P. Berrangé then \ 52dedad027SDaniel P. Berrangé rm -rf build GNUmakefile ; \ 53dedad027SDaniel P. Berrangé fi 54dedad027SDaniel P. Berrangéforce: ; 55dedad027SDaniel P. Berrangé.PHONY: force 56dedad027SDaniel P. BerrangéGNUmakefile: ; 57dedad027SDaniel P. Berrangé 58dedad027SDaniel P. BerrangéEOF 59dedad027SDaniel P. Berrangé cd build 60dedad027SDaniel P. Berrangé exec $source_path/configure "$@" 61dedad027SDaniel P. Berrangéfi 62dedad027SDaniel P. Berrangé 638cd05ab6SPeter Maydell# Temporary directory used for files created while 648cd05ab6SPeter Maydell# configure runs. Since it is in the build directory 658cd05ab6SPeter Maydell# we can safely blow away any previous version of it 668cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete 678cd05ab6SPeter Maydell# it when configure exits.) 688cd05ab6SPeter MaydellTMPDIR1="config-temp" 698cd05ab6SPeter Maydellrm -rf "${TMPDIR1}" 708cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}" 718cd05ab6SPeter Maydellif [ $? -ne 0 ]; then 728cd05ab6SPeter Maydell echo "ERROR: failed to create temporary directory" 738cd05ab6SPeter Maydell exit 1 747d13299dSbellardfi 757d13299dSbellard 768cd05ab6SPeter MaydellTMPB="qemu-conf" 778cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c" 7866518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o" 799c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx" 808cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe" 817d13299dSbellard 82da1d85e3SGerd Hoffmannrm -f config.log 839ac81bbbSmalc 84b48e3611SPeter Maydell# Print a helpful header at the top of config.log 85b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log 86979ae168SPeter Maydellprintf "# Configured with:" >> config.log 87979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log 88979ae168SPeter Maydellecho >> config.log 89b48e3611SPeter Maydellecho "#" >> config.log 90b48e3611SPeter Maydell 91835af899SPaolo Bonziniquote_sh() { 92835af899SPaolo Bonzini printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," 93835af899SPaolo Bonzini} 94835af899SPaolo Bonzini 95d880a3baSPaolo Bonziniprint_error() { 96d880a3baSPaolo Bonzini (echo 9776ad07a4SPeter Maydell echo "ERROR: $1" 9876ad07a4SPeter Maydell while test -n "$2"; do 9976ad07a4SPeter Maydell echo " $2" 10076ad07a4SPeter Maydell shift 10176ad07a4SPeter Maydell done 102d880a3baSPaolo Bonzini echo) >&2 103d880a3baSPaolo Bonzini} 104d880a3baSPaolo Bonzini 105d880a3baSPaolo Bonzinierror_exit() { 106d880a3baSPaolo Bonzini print_error "$@" 10776ad07a4SPeter Maydell exit 1 10876ad07a4SPeter Maydell} 10976ad07a4SPeter Maydell 1109c83ffd8SPeter Maydelldo_compiler() { 1119c83ffd8SPeter Maydell # Run the compiler, capturing its output to the log. First argument 1129c83ffd8SPeter Maydell # is compiler binary to execute. 113630d86b7SDavid CARLIER compiler="$1" 1149c83ffd8SPeter Maydell shift 1158bbe05d7SIan Jackson if test -n "$BASH_VERSION"; then eval ' 1168bbe05d7SIan Jackson echo >>config.log " 1178bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]} 1188bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}" 1198bbe05d7SIan Jackson '; fi 1209c83ffd8SPeter Maydell echo $compiler "$@" >> config.log 1219c83ffd8SPeter Maydell $compiler "$@" >> config.log 2>&1 || return $? 1228dc38a78SPeter Maydell # Test passed. If this is an --enable-werror build, rerun 1238dc38a78SPeter Maydell # the test with -Werror and bail out if it fails. This 1248dc38a78SPeter Maydell # makes warning-generating-errors in configure test code 1258dc38a78SPeter Maydell # obvious to developers. 1268dc38a78SPeter Maydell if test "$werror" != "yes"; then 1278dc38a78SPeter Maydell return 0 1288dc38a78SPeter Maydell fi 1298dc38a78SPeter Maydell # Don't bother rerunning the compile if we were already using -Werror 1308dc38a78SPeter Maydell case "$*" in 1318dc38a78SPeter Maydell *-Werror*) 1328dc38a78SPeter Maydell return 0 1338dc38a78SPeter Maydell ;; 1348dc38a78SPeter Maydell esac 1359c83ffd8SPeter Maydell echo $compiler -Werror "$@" >> config.log 1369c83ffd8SPeter Maydell $compiler -Werror "$@" >> config.log 2>&1 && return $? 13776ad07a4SPeter Maydell error_exit "configure test passed without -Werror but failed with -Werror." \ 13876ad07a4SPeter Maydell "This is probably a bug in the configure script. The failing command" \ 13976ad07a4SPeter Maydell "will be at the bottom of config.log." \ 14076ad07a4SPeter Maydell "You can run configure with --disable-werror to bypass this check." 1418dc38a78SPeter Maydell} 1428dc38a78SPeter Maydell 1439c83ffd8SPeter Maydelldo_cc() { 1444dba2789SPaolo Bonzini do_compiler "$cc" $CPU_CFLAGS "$@" 1459c83ffd8SPeter Maydell} 1469c83ffd8SPeter Maydell 1479c83ffd8SPeter Maydelldo_cxx() { 1484dba2789SPaolo Bonzini do_compiler "$cxx" $CPU_CFLAGS "$@" 1499c83ffd8SPeter Maydell} 1509c83ffd8SPeter Maydell 15100849b92SRichard Henderson# Append $2 to the variable named $1, with space separation 15200849b92SRichard Hendersonadd_to() { 15300849b92SRichard Henderson eval $1=\${$1:+\"\$$1 \"}\$2 15400849b92SRichard Henderson} 15500849b92SRichard Henderson 1569c83ffd8SPeter Maydellupdate_cxxflags() { 1579c83ffd8SPeter Maydell # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those 1589c83ffd8SPeter Maydell # options which some versions of GCC's C++ compiler complain about 1599c83ffd8SPeter Maydell # because they only make sense for C programs. 160de38c0ccSPaolo Bonzini QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS" 1618a9d3d56SRichard Henderson CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/) 1629c83ffd8SPeter Maydell for arg in $QEMU_CFLAGS; do 1639c83ffd8SPeter Maydell case $arg in 1649c83ffd8SPeter Maydell -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ 1659c83ffd8SPeter Maydell -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) 1669c83ffd8SPeter Maydell ;; 1679c83ffd8SPeter Maydell *) 1689c83ffd8SPeter Maydell QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg 1699c83ffd8SPeter Maydell ;; 1709c83ffd8SPeter Maydell esac 1719c83ffd8SPeter Maydell done 1729c83ffd8SPeter Maydell} 1739c83ffd8SPeter Maydell 17452166aa0SJuan Quintelacompile_object() { 175fd0e6053SJohn Snow local_cflags="$1" 176a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC 17752166aa0SJuan Quintela} 17852166aa0SJuan Quintela 17952166aa0SJuan Quintelacompile_prog() { 18052166aa0SJuan Quintela local_cflags="$1" 18152166aa0SJuan Quintela local_ldflags="$2" 182a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \ 183a2866660SPaolo Bonzini $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags 18452166aa0SJuan Quintela} 18552166aa0SJuan Quintela 18611568d6dSPaolo Bonzini# symbolically link $1 to $2. Portable version of "ln -sf". 18711568d6dSPaolo Bonzinisymlink() { 18872b8b5a1SStefan Weil rm -rf "$2" 189ec5b06d7SAnthony Liguori mkdir -p "$(dirname "$2")" 19072b8b5a1SStefan Weil ln -s "$1" "$2" 19111568d6dSPaolo Bonzini} 19211568d6dSPaolo Bonzini 1930dba6195SLoïc Minier# check whether a command is available to this shell (may be either an 1940dba6195SLoïc Minier# executable or a builtin) 1950dba6195SLoïc Minierhas() { 1960dba6195SLoïc Minier type "$1" >/dev/null 2>&1 1970dba6195SLoïc Minier} 1980dba6195SLoïc Minier 1990a01d76fSMarc-André Lureauversion_ge () { 2002df52b9bSAlex Bennée local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') 2012df52b9bSAlex Bennée local_ver2=$(echo "$2" | tr . ' ') 2020a01d76fSMarc-André Lureau while true; do 2030a01d76fSMarc-André Lureau set x $local_ver1 2040a01d76fSMarc-André Lureau local_first=${2-0} 205c44a33e2SStefano Garzarella # 'shift 2' if $2 is set, or 'shift' if $2 is not set 206c44a33e2SStefano Garzarella shift ${2:+2} 2070a01d76fSMarc-André Lureau local_ver1=$* 2080a01d76fSMarc-André Lureau set x $local_ver2 2090a01d76fSMarc-André Lureau # the second argument finished, the first must be greater or equal 2100a01d76fSMarc-André Lureau test $# = 1 && return 0 2110a01d76fSMarc-André Lureau test $local_first -lt $2 && return 1 2120a01d76fSMarc-André Lureau test $local_first -gt $2 && return 0 213c44a33e2SStefano Garzarella shift ${2:+2} 2140a01d76fSMarc-André Lureau local_ver2=$* 2150a01d76fSMarc-André Lureau done 2160a01d76fSMarc-André Lureau} 2170a01d76fSMarc-André Lureau 2183b6b7550SPaolo Bonziniglob() { 2193b6b7550SPaolo Bonzini eval test -z '"${1#'"$2"'}"' 2203b6b7550SPaolo Bonzini} 2213b6b7550SPaolo Bonzini 222e9a3591fSChristian Borntraegerld_has() { 223e9a3591fSChristian Borntraeger $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 224e9a3591fSChristian Borntraeger} 225e9a3591fSChristian Borntraeger 2264ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; 2274ace32e2SAntonio Ospitethen 2284ace32e2SAntonio Ospite error_exit "main directory cannot contain spaces nor colons" 2294ace32e2SAntonio Ospitefi 2304ace32e2SAntonio Ospite 23114211825SAntonio Ospite# default parameters 2322ff6b91eSJuan Quintelacpu="" 233a31a8642SMichael S. Tsirkiniasl="iasl" 2341e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M" 23543ce4dfeSbellardstatic="no" 2363812c0c4SJoelle van Dynecross_compile="no" 2377d13299dSbellardcross_prefix="" 23887430d5bSPaolo Bonziniaudio_drv_list="default" 239b64ec4e4SFam Zhengblock_drv_rw_whitelist="" 240b64ec4e4SFam Zhengblock_drv_ro_whitelist="" 241e49d021eSPeter Maydellhost_cc="cc" 2425bc62e01SGerd Hoffmanndebug_info="yes" 243cdad781dSDaniele Buonolto="false" 24463678e17SSteven Noonanstack_protector="" 2451e4f6065SDaniele Buonosafe_stack="" 246afc3a8f9SAlex Bennéeuse_containers="yes" 247f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 248ac0df51dSaliguori 24992712822SDaniel P. Berrangeif test -e "$source_path/.git" 25092712822SDaniel P. Berrangethen 2517d7dbf9dSDan Streetman git_submodules_action="update" 25292712822SDaniel P. Berrangeelse 2537d7dbf9dSDan Streetman git_submodules_action="ignore" 25492712822SDaniel P. Berrangefi 2552d652f24SPaolo Bonzini 2562d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb" 257cc84d63aSDaniel P. Berrangegit="git" 258ac0df51dSaliguori 259afb63ebdSStefan Weil# Don't accept a target_list environment variable. 260afb63ebdSStefan Weilunset target_list 261447e133fSAlex Bennéeunset target_list_exclude 262377529c0SPaolo Bonzini 263377529c0SPaolo Bonzini# Default value for a variable defining feature "foo". 264377529c0SPaolo Bonzini# * foo="no" feature will only be used if --enable-foo arg is given 265377529c0SPaolo Bonzini# * foo="" feature will be searched for, and if found, will be used 266377529c0SPaolo Bonzini# unless --disable-foo is given 267377529c0SPaolo Bonzini# * foo="yes" this value will only be set by --enable-foo flag. 268377529c0SPaolo Bonzini# feature will searched for, 269377529c0SPaolo Bonzini# if not found, configure exits with error 270377529c0SPaolo Bonzini# 271377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args. 272377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it 273377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found. 274377529c0SPaolo Bonzini 275c87ea116SAlex Bennéedefault_feature="" 276c87ea116SAlex Bennée# parse CC options second 277c87ea116SAlex Bennéefor opt do 278c87ea116SAlex Bennée optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 279c87ea116SAlex Bennée case "$opt" in 280c87ea116SAlex Bennée --without-default-features) 281c87ea116SAlex Bennée default_feature="no" 282c87ea116SAlex Bennée ;; 283c87ea116SAlex Bennée esac 284c87ea116SAlex Bennéedone 285c87ea116SAlex Bennée 286a2866660SPaolo BonziniEXTRA_CFLAGS="" 287a2866660SPaolo BonziniEXTRA_CXXFLAGS="" 288a2866660SPaolo BonziniEXTRA_LDFLAGS="" 289a2866660SPaolo Bonzini 290c87ea116SAlex Bennéexen_ctrl_version="$default_feature" 2910848f8acSThomas Huthvhost_kernel="$default_feature" 292c87ea116SAlex Bennéevhost_net="$default_feature" 293c87ea116SAlex Bennéevhost_crypto="$default_feature" 294c87ea116SAlex Bennéevhost_scsi="$default_feature" 295c87ea116SAlex Bennéevhost_vsock="$default_feature" 296d88618f7SStefan Hajnoczivhost_user="no" 297c87ea116SAlex Bennéevhost_user_fs="$default_feature" 2980848f8acSThomas Huthvhost_vdpa="$default_feature" 299c87ea116SAlex Bennéerdma="$default_feature" 300c87ea116SAlex Bennéepvrdma="$default_feature" 301377529c0SPaolo Bonzinidebug_tcg="no" 302377529c0SPaolo Bonzinidebug="no" 303247724cbSMarc-André Lureausanitizers="no" 3040aebab04SLingfeng Yangtsan="no" 305c87ea116SAlex Bennéefortify_source="$default_feature" 3061d728c39SBlue Swirlgcov="no" 307c7328271SMiroslav RezaninaEXESUF="" 30817969268SFam Zhengmodules="no" 309bd83c861SChristian Ehrhardtmodule_upgrades="no" 310377529c0SPaolo Bonziniprefix="/usr/local" 31110ff82d1SMarc-André Lureauqemu_suffix="qemu" 312377529c0SPaolo Bonzinisoftmmu="yes" 313b915a2f1SPaolo Bonzinilinux_user="" 314b915a2f1SPaolo Bonzinibsd_user="" 315377529c0SPaolo Bonzinipkgversion="" 31640d6444eSAvi Kivitypie="" 317baf86d6bSPaolo Bonzinitrace_backends="log" 318377529c0SPaolo Bonzinitrace_file="trace" 319c87ea116SAlex Bennéeopengl="$default_feature" 320519175a2SAlex Barcelocoroutine="" 321a1c5e949SDaniel P. Berrangetls_priority="NORMAL" 322ba4dd2aaSAlex Bennéeplugins="$default_feature" 323c87ea116SAlex Bennéesecret_keyring="$default_feature" 324a5665051SPaolo Bonzinimeson="" 3253b4da132SPaolo Bonzinimeson_args="" 32648328880SPaolo Bonzinininja="" 3273b4da132SPaolo Bonzinigio="$default_feature" 328a5665051SPaolo Bonziniskip_meson=no 329377529c0SPaolo Bonzini 3303b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 3313b4da132SPaolo Bonzini# are included in the automatically generated help message) 3323b4da132SPaolo Bonzini 3333b4da132SPaolo Bonzini# 1. Track which submodules are needed 3340577e84dSThomas Huthif test "$default_feature" = no ; then 3350577e84dSThomas Huth capstone="disabled" 3360577e84dSThomas Huth slirp="disabled" 3370577e84dSThomas Huthelse 3383b4da132SPaolo Bonzini capstone="auto" 3393b4da132SPaolo Bonzini slirp="auto" 3400577e84dSThomas Huthfi 3410577e84dSThomas Huthfdt="auto" 3423b4da132SPaolo Bonzini 3433b4da132SPaolo Bonzini# 2. Support --with/--without option 3443b4da132SPaolo Bonzinidefault_devices="true" 3453b4da132SPaolo Bonzini 3463b4da132SPaolo Bonzini# 3. Automatically enable/disable other options 3473b4da132SPaolo Bonzinitcg="enabled" 3483b4da132SPaolo Bonzinicfi="false" 3493b4da132SPaolo Bonzini 3503b4da132SPaolo Bonzini# 4. Detection partly done in configure 3513b4da132SPaolo Bonzinixen=${default_feature:+disabled} 352898be3e0SPeter Maydell 353c87ea116SAlex Bennée# parse CC options second 354ac0df51dSaliguorifor opt do 35589138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 356ac0df51dSaliguori case "$opt" in 357ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3583812c0c4SJoelle van Dyne cross_compile="yes" 359ac0df51dSaliguori ;; 3603d8df640SPaolo Bonzini --cc=*) CC="$optarg" 361ac0df51dSaliguori ;; 36283f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 36383f73fceSTomoki Sekiyama ;; 3642ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3652ff6b91eSJuan Quintela ;; 366a2866660SPaolo Bonzini --extra-cflags=*) 367a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 368a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 369e2a2ed06SJuan Quintela ;; 370a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 37111cde1c8SBruno Dominguez ;; 372a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 373e2a2ed06SJuan Quintela ;; 3745bc62e01SGerd Hoffmann --enable-debug-info) debug_info="yes" 3755bc62e01SGerd Hoffmann ;; 3765bc62e01SGerd Hoffmann --disable-debug-info) debug_info="no" 3775bc62e01SGerd Hoffmann ;; 378d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 379d75402b5SAlex Bennée ;; 380479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 381d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 3822038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 383d422b2bcSAlex Bennée ;; 384d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 3852038f8c8SPaolo Bonzini cc_archs="$cc_archs $cc_arch" 386d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 3872038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 388d75402b5SAlex Bennée ;; 389ac0df51dSaliguori esac 390ac0df51dSaliguoridone 391ac0df51dSaliguori# OS specific 392ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 39393148aa5SStefan Weil# we can eliminate its usage altogether. 394ac0df51dSaliguori 395e49d021eSPeter Maydell# Preferred compiler: 396e49d021eSPeter Maydell# ${CC} (if set) 397e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 398e49d021eSPeter Maydell# system compiler 399e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 400e49d021eSPeter Maydell cc="$host_cc" 401e49d021eSPeter Maydellelse 402b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 403e49d021eSPeter Maydellfi 404e49d021eSPeter Maydell 40583f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 40683f73fceSTomoki Sekiyama cxx="c++" 40783f73fceSTomoki Sekiyamaelse 40883f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 40983f73fceSTomoki Sekiyamafi 41083f73fceSTomoki Sekiyama 411b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 412cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 4135f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 4143dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 415b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 416b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 4179f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 4184852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 41935acbb30SPaolo Bonzinismbd="$SMBD" 420b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 421b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 42217884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 42317884d7bSSergei Trofimovichquery_pkg_config() { 42417884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 42517884d7bSSergei Trofimovich} 42617884d7bSSergei Trofimovichpkg_config=query_pkg_config 42747c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 428ac0df51dSaliguori 429be17dc90SMichael S. Tsirkin# default flags for all hosts 4302d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 4312d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 4322d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 4332d31515bSPeter Maydell# provides these semantics.) 434de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 435086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 436c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 437be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4385770e8afSPaolo Bonzini 439de38c0ccSPaolo BonziniQEMU_LDFLAGS= 440de38c0ccSPaolo Bonzini 4415770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4428a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4435770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 444086d5f75SPaolo Bonzini 445be17dc90SMichael S. Tsirkin 446ac0df51dSaliguoricheck_define() { 447ac0df51dSaliguoricat > $TMPC <<EOF 448ac0df51dSaliguori#if !defined($1) 449fd786e1aSPeter Maydell#error $1 not defined 450ac0df51dSaliguori#endif 451ac0df51dSaliguoriint main(void) { return 0; } 452ac0df51dSaliguoriEOF 45352166aa0SJuan Quintela compile_object 454ac0df51dSaliguori} 455ac0df51dSaliguori 456307119e7SGerd Hoffmanncheck_include() { 457307119e7SGerd Hoffmanncat > $TMPC <<EOF 458307119e7SGerd Hoffmann#include <$1> 459307119e7SGerd Hoffmannint main(void) { return 0; } 460307119e7SGerd HoffmannEOF 461307119e7SGerd Hoffmann compile_object 462307119e7SGerd Hoffmann} 463307119e7SGerd Hoffmann 46493b25869SJohn Snowwrite_c_skeleton() { 46593b25869SJohn Snow cat > $TMPC <<EOF 46693b25869SJohn Snowint main(void) { return 0; } 46793b25869SJohn SnowEOF 46893b25869SJohn Snow} 46993b25869SJohn Snow 470bbea4050SPeter Maydellif check_define __linux__ ; then 471ba7c60c2SPaolo Bonzini targetos=linux 472bbea4050SPeter Maydellelif check_define _WIN32 ; then 473ba7c60c2SPaolo Bonzini targetos=windows 474bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 475ba7c60c2SPaolo Bonzini targetos=openbsd 476bbea4050SPeter Maydellelif check_define __sun__ ; then 477ba7c60c2SPaolo Bonzini targetos=sunos 478bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 479ba7c60c2SPaolo Bonzini targetos=haiku 480951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 481ba7c60c2SPaolo Bonzini targetos=freebsd 482951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 483ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 484951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 485ba7c60c2SPaolo Bonzini targetos=dragonfly 486951fedfcSPeter Maydellelif check_define __NetBSD__; then 487ba7c60c2SPaolo Bonzini targetos=netbsd 488951fedfcSPeter Maydellelif check_define __APPLE__; then 489ba7c60c2SPaolo Bonzini targetos=darwin 490bbea4050SPeter Maydellelse 491951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 492951fedfcSPeter Maydell # might be going to just print the --help text, or it might 493951fedfcSPeter Maydell # be the result of a missing compiler. 494ba7c60c2SPaolo Bonzini targetos=bogus 495bbea4050SPeter Maydellfi 496bbea4050SPeter Maydell 49765eff01bSPaolo Bonzini# OS specific 49865eff01bSPaolo Bonzini 4993b0d8643SPaolo Bonzinimingw32="no" 5003b0d8643SPaolo Bonzinibsd="no" 5013b0d8643SPaolo Bonzinilinux="no" 5023b0d8643SPaolo Bonzinisolaris="no" 50365eff01bSPaolo Bonzinicase $targetos in 50465eff01bSPaolo Bonziniwindows) 50565eff01bSPaolo Bonzini mingw32="yes" 50665eff01bSPaolo Bonzini plugins="no" 50765eff01bSPaolo Bonzini pie="no" 50865eff01bSPaolo Bonzini;; 50965eff01bSPaolo Bonzinignu/kfreebsd) 51065eff01bSPaolo Bonzini bsd="yes" 51165eff01bSPaolo Bonzini;; 51265eff01bSPaolo Bonzinifreebsd) 51365eff01bSPaolo Bonzini bsd="yes" 51465eff01bSPaolo Bonzini make="${MAKE-gmake}" 51565eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 51665eff01bSPaolo Bonzini;; 51765eff01bSPaolo Bonzinidragonfly) 51865eff01bSPaolo Bonzini bsd="yes" 51965eff01bSPaolo Bonzini make="${MAKE-gmake}" 52065eff01bSPaolo Bonzini;; 52165eff01bSPaolo Bonzininetbsd) 52265eff01bSPaolo Bonzini bsd="yes" 52365eff01bSPaolo Bonzini make="${MAKE-gmake}" 52465eff01bSPaolo Bonzini;; 52565eff01bSPaolo Bonziniopenbsd) 52665eff01bSPaolo Bonzini bsd="yes" 52765eff01bSPaolo Bonzini make="${MAKE-gmake}" 52865eff01bSPaolo Bonzini;; 52965eff01bSPaolo Bonzinidarwin) 53065eff01bSPaolo Bonzini bsd="yes" 53165eff01bSPaolo Bonzini darwin="yes" 53265eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 53365eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 53465eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 53565eff01bSPaolo Bonzini;; 53665eff01bSPaolo Bonzinisunos) 53765eff01bSPaolo Bonzini solaris="yes" 53865eff01bSPaolo Bonzini make="${MAKE-gmake}" 53965eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 54065eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 54165eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 54265eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 54365eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 54465eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 545bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 546bbea4050SPeter Maydell # the correct CPU with the --cpu option. 547bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 548bbea4050SPeter Maydell cpu="x86_64" 549bbea4050SPeter Maydell fi 55065eff01bSPaolo Bonzini;; 55165eff01bSPaolo Bonzinihaiku) 55265eff01bSPaolo Bonzini pie="no" 55365eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 55465eff01bSPaolo Bonzini;; 55565eff01bSPaolo Bonzinilinux) 55665eff01bSPaolo Bonzini linux="yes" 55765eff01bSPaolo Bonzini vhost_user=${default_feature:-yes} 55865eff01bSPaolo Bonzini;; 559bbea4050SPeter Maydellesac 560bbea4050SPeter Maydell 5612ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5622ff6b91eSJuan Quintela # command line argument 5632ff6b91eSJuan Quintela : 5642ff6b91eSJuan Quintelaelif check_define __i386__ ; then 565ac0df51dSaliguori cpu="i386" 566ac0df51dSaliguorielif check_define __x86_64__ ; then 567c72b26ecSRichard Henderson if check_define __ILP32__ ; then 568c72b26ecSRichard Henderson cpu="x32" 569c72b26ecSRichard Henderson else 570ac0df51dSaliguori cpu="x86_64" 571c72b26ecSRichard Henderson fi 5723aa9bd6cSblueswir1elif check_define __sparc__ ; then 5733aa9bd6cSblueswir1 if check_define __arch64__ ; then 5743aa9bd6cSblueswir1 cpu="sparc64" 5753aa9bd6cSblueswir1 else 5763aa9bd6cSblueswir1 cpu="sparc" 5773aa9bd6cSblueswir1 fi 578fdf7ed96Smalcelif check_define _ARCH_PPC ; then 579fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 580f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 581f8378accSRichard Henderson cpu="ppc64le" 582f8378accSRichard Henderson else 583fdf7ed96Smalc cpu="ppc64" 584f8378accSRichard Henderson fi 585ac0df51dSaliguori else 586fdf7ed96Smalc cpu="ppc" 587fdf7ed96Smalc fi 588afa05235SAurelien Jarnoelif check_define __mips__ ; then 589afa05235SAurelien Jarno cpu="mips" 590d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 591d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 592d66ed0eaSAurelien Jarno cpu="s390x" 593d66ed0eaSAurelien Jarno else 594d66ed0eaSAurelien Jarno cpu="s390" 595d66ed0eaSAurelien Jarno fi 596c4f80543SAlistair Franciselif check_define __riscv ; then 597ba0e7333SRichard Henderson cpu="riscv" 59821d89f84SPeter Maydellelif check_define __arm__ ; then 59921d89f84SPeter Maydell cpu="arm" 6001f080313SClaudio Fontanaelif check_define __aarch64__ ; then 6011f080313SClaudio Fontana cpu="aarch64" 602dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 603dfcf900bSWANG Xuerui cpu="loongarch64" 604fdf7ed96Smalcelse 60589138857SStefan Weil cpu=$(uname -m) 606ac0df51dSaliguorifi 607ac0df51dSaliguori 608823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 609359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 6107d13299dSbellardcase "$cpu" in 611e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 612e4da0e39SPaolo Bonzini cpu="arm" ;; 613e4da0e39SPaolo Bonzini 6147d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 61597a847bcSbellard cpu="i386" 616e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 617e4da0e39SPaolo Bonzini x32) 6184da270beSPaolo Bonzini cpu="x86_64" 619e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 620aaa5fa14Saurel32 x86_64|amd64) 621aaa5fa14Saurel32 cpu="x86_64" 622e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 623e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 624e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 625e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 626e4da0e39SPaolo Bonzini 627afa05235SAurelien Jarno mips*) 628e4da0e39SPaolo Bonzini cpu="mips" ;; 629e4da0e39SPaolo Bonzini 630e4da0e39SPaolo Bonzini ppc) 631e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 632e4da0e39SPaolo Bonzini ppc64) 633*ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mbig-endian" ;; 634e4da0e39SPaolo Bonzini ppc64le) 635d8ff892dSPaolo Bonzini cpu="ppc64" 636*ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mlittle-endian" ;; 637e4da0e39SPaolo Bonzini 638e4da0e39SPaolo Bonzini s390) 639823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 640e4da0e39SPaolo Bonzini s390x) 641e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 642e4da0e39SPaolo Bonzini 6433142255cSblueswir1 sparc|sun4[cdmuv]) 644ae228531Sbellard cpu="sparc" 645e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 646e4da0e39SPaolo Bonzini sparc64) 647e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6487d13299dSbellardesac 649e2d52ad3SJuan Quintela 6500db4a067SPaolo Bonzini: ${make=${MAKE-make}} 651b6daf4d3SPaolo Bonzini 652faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 653faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 654ddf90699SEduardo Habkost# we check that too 655faf44142SDaniel P. Berrangépython= 6560a01d76fSMarc-André Lureauexplicit_python=no 657ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 658faf44142SDaniel P. Berrangédo 659faf44142SDaniel P. Berrangé if has "$binary" 660faf44142SDaniel P. Berrangé then 66195c5f2deSPaolo Bonzini python=$(command -v "$binary") 662faf44142SDaniel P. Berrangé break 663faf44142SDaniel P. Berrangé fi 664faf44142SDaniel P. Berrangédone 665903458c8SMarkus Armbruster 666903458c8SMarkus Armbruster 66739d87c8cSAlex Bennée# Check for ancillary tools used in testing 66839d87c8cSAlex Bennéegenisoimage= 6693df437c7SAlex Bennéefor binary in genisoimage mkisofs 67039d87c8cSAlex Bennéedo 67139d87c8cSAlex Bennée if has $binary 67239d87c8cSAlex Bennée then 67339d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 67439d87c8cSAlex Bennée break 67539d87c8cSAlex Bennée fi 67639d87c8cSAlex Bennéedone 67739d87c8cSAlex Bennée 6783c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6793c4a4d0dSPeter Maydellif has clang; then 6803c4a4d0dSPeter Maydell objcc=clang 6813c4a4d0dSPeter Maydellelse 6823c4a4d0dSPeter Maydell objcc="$cc" 6833c4a4d0dSPeter Maydellfi 6843c4a4d0dSPeter Maydell 6853457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6863457a3f8SJuan Quintela EXESUF=".exe" 68778e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6885770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 68993b25869SJohn Snow write_c_skeleton; 690d17f305aSPaolo Bonzini prefix="/qemu" 69177433a5fSMarc-André Lureau qemu_suffix="" 6923457a3f8SJuan Quintelafi 6933457a3f8SJuan Quintela 694487fefdbSAnthony Liguoriwerror="" 69585aa5189Sbellard 69661d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 69761d63097SPaolo Bonzini 69861d63097SPaolo Bonzinimeson_options= 69961d63097SPaolo Bonzinimeson_option_parse() { 70061d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 70161d63097SPaolo Bonzini if test $? -eq 1; then 70261d63097SPaolo Bonzini echo "ERROR: unknown option $1" 70361d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 70461d63097SPaolo Bonzini exit 1 70561d63097SPaolo Bonzini fi 70661d63097SPaolo Bonzini} 70761d63097SPaolo Bonzini 7087d13299dSbellardfor opt do 70989138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 7107d13299dSbellard case "$opt" in 7112efc3265Sbellard --help|-h) show_help=yes 7122efc3265Sbellard ;; 71399123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 71499123e13SMike Frysinger ;; 715b1a550a0Spbrook --prefix=*) prefix="$optarg" 7167d13299dSbellard ;; 717b1a550a0Spbrook --interp-prefix=*) interp_prefix="$optarg" 71832ce6337Sbellard ;; 719ac0df51dSaliguori --cross-prefix=*) 7207d13299dSbellard ;; 721ac0df51dSaliguori --cc=*) 7227d13299dSbellard ;; 723b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 72483469015Sbellard ;; 72583f73fceSTomoki Sekiyama --cxx=*) 72683f73fceSTomoki Sekiyama ;; 727e007dbecSMichael S. Tsirkin --iasl=*) iasl="$optarg" 728e007dbecSMichael S. Tsirkin ;; 7293c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 7303c4a4d0dSPeter Maydell ;; 731b1a550a0Spbrook --make=*) make="$optarg" 7327d13299dSbellard ;; 733b6daf4d3SPaolo Bonzini --install=*) 7346a882643Spbrook ;; 7350a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 736c886edfbSBlue Swirl ;; 7372eb054c2SPeter Maydell --sphinx-build=*) sphinx_build="$optarg" 7382eb054c2SPeter Maydell ;; 739a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 740a5665051SPaolo Bonzini ;; 741a5665051SPaolo Bonzini --meson=*) meson="$optarg" 742a5665051SPaolo Bonzini ;; 74348328880SPaolo Bonzini --ninja=*) ninja="$optarg" 74448328880SPaolo Bonzini ;; 745e2d8830eSBrad --smbd=*) smbd="$optarg" 746e2d8830eSBrad ;; 747e2a2ed06SJuan Quintela --extra-cflags=*) 7487d13299dSbellard ;; 74911cde1c8SBruno Dominguez --extra-cxxflags=*) 75011cde1c8SBruno Dominguez ;; 751e2a2ed06SJuan Quintela --extra-ldflags=*) 7527d13299dSbellard ;; 7535bc62e01SGerd Hoffmann --enable-debug-info) 7545bc62e01SGerd Hoffmann ;; 7555bc62e01SGerd Hoffmann --disable-debug-info) 7565bc62e01SGerd Hoffmann ;; 757d75402b5SAlex Bennée --cross-cc-*) 758d75402b5SAlex Bennée ;; 75917969268SFam Zheng --enable-modules) 76017969268SFam Zheng modules="yes" 76117969268SFam Zheng ;; 7623aa88b31SStefan Hajnoczi --disable-modules) 7633aa88b31SStefan Hajnoczi modules="no" 7643aa88b31SStefan Hajnoczi ;; 765bd83c861SChristian Ehrhardt --disable-module-upgrades) module_upgrades="no" 766bd83c861SChristian Ehrhardt ;; 767bd83c861SChristian Ehrhardt --enable-module-upgrades) module_upgrades="yes" 768bd83c861SChristian Ehrhardt ;; 7692ff6b91eSJuan Quintela --cpu=*) 7707d13299dSbellard ;; 771b1a550a0Spbrook --target-list=*) target_list="$optarg" 772447e133fSAlex Bennée if test "$target_list_exclude"; then 773447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 774447e133fSAlex Bennée fi 775447e133fSAlex Bennée ;; 776447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 777447e133fSAlex Bennée if test "$target_list"; then 778447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 779447e133fSAlex Bennée fi 780de83cd02Sbellard ;; 78174242e0fSPaolo Bonzini --with-trace-file=*) trace_file="$optarg" 7829410b56cSPrerna Saxena ;; 7837bc3ca7fSPaolo Bonzini --with-default-devices) default_devices="true" 784f3494749SPaolo Bonzini ;; 7857bc3ca7fSPaolo Bonzini --without-default-devices) default_devices="false" 786f3494749SPaolo Bonzini ;; 787d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 788d1d5e9eeSAlex Bennée ;; 789d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 790d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 791d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 792d1d5e9eeSAlex Bennée if test -f "$cf"; then 793d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 794d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 795d1d5e9eeSAlex Bennée else 796d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 797d1d5e9eeSAlex Bennée fi 798d1d5e9eeSAlex Bennée ;; 799c87ea116SAlex Bennée --without-default-features) # processed above 800c87ea116SAlex Bennée ;; 8011d728c39SBlue Swirl --enable-gcov) gcov="yes" 8021d728c39SBlue Swirl ;; 80379427693SLoïc Minier --static) 80479427693SLoïc Minier static="yes" 80517884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 80643ce4dfeSbellard ;; 8070b24e75fSPaolo Bonzini --mandir=*) mandir="$optarg" 8080b24e75fSPaolo Bonzini ;; 8090b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 8100b24e75fSPaolo Bonzini ;; 8113aa5d2beSAlon Levy --libdir=*) libdir="$optarg" 8123aa5d2beSAlon Levy ;; 8138bf188aaSMichael Tokarev --libexecdir=*) libexecdir="$optarg" 8148bf188aaSMichael Tokarev ;; 8150f94d6daSAlon Levy --includedir=*) includedir="$optarg" 8160f94d6daSAlon Levy ;; 817528ae5b8SEduardo Habkost --datadir=*) datadir="$optarg" 8180b24e75fSPaolo Bonzini ;; 81977433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 820023d3d67SEduardo Habkost ;; 821c6502638SBruce Rogers --docdir=*) docdir="$optarg" 8220b24e75fSPaolo Bonzini ;; 823fe0038beSPaolo Bonzini --localedir=*) localedir="$optarg" 824fe0038beSPaolo Bonzini ;; 825ca2fb938SAndre Przywara --sysconfdir=*) sysconfdir="$optarg" 82607381cc1SAnthony Liguori ;; 827785c23aeSLuiz Capitulino --localstatedir=*) local_statedir="$optarg" 828785c23aeSLuiz Capitulino ;; 8293d5eecabSGerd Hoffmann --firmwarepath=*) firmwarepath="$optarg" 8303d5eecabSGerd Hoffmann ;; 831181ce1d0SOlaf Hering --host=*|--build=*|\ 832181ce1d0SOlaf Hering --disable-dependency-tracking|\ 833785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 834fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 835023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 836023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 837023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 838023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 839023ddd74SMax Filippov # lots of directory switches by default. 840023ddd74SMax Filippov ;; 8410c58ac1cSmalc --audio-drv-list=*) audio_drv_list="$optarg" 8420c58ac1cSmalc ;; 84389138857SStefan Weil --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 844b64ec4e4SFam Zheng ;; 84589138857SStefan Weil --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 846eb852011SMarkus Armbruster ;; 847f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 848f8393946Saurel32 ;; 849f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 850f8393946Saurel32 ;; 851f3d08ee6SPaul Brook --enable-debug) 852f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 853f3d08ee6SPaul Brook debug_tcg="yes" 854c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 855f3d08ee6SPaul Brook debug="yes" 856b553a042SJohn Snow fortify_source="no" 857f3d08ee6SPaul Brook ;; 858247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 859247724cbSMarc-André Lureau ;; 860247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 861247724cbSMarc-André Lureau ;; 8620aebab04SLingfeng Yang --enable-tsan) tsan="yes" 8630aebab04SLingfeng Yang ;; 8640aebab04SLingfeng Yang --disable-tsan) tsan="no" 8650aebab04SLingfeng Yang ;; 8664d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 867c20709aaSbellard ;; 868fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 869fd6fc214SPaolo Bonzini ;; 8704d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 8717c57bdd8SMarc-André Lureau ;; 87203a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 873675b9b53SMarc-André Lureau ;; 8741badb709SPaolo Bonzini --disable-xen) xen="disabled" 875e37630caSaliguori ;; 8761badb709SPaolo Bonzini --enable-xen) xen="enabled" 877fc321b4bSJuan Quintela ;; 8781badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 879d1a14257SAlex Bennée plugins="no" 880b3f6ea7eSPaolo Bonzini ;; 8811badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 882b3f6ea7eSPaolo Bonzini ;; 883cad25d69Spbrook --disable-system) softmmu="no" 8840a8e90f4Spbrook ;; 885cad25d69Spbrook --enable-system) softmmu="yes" 8860a8e90f4Spbrook ;; 8870953a80fSZachary Amsden --disable-user) 8880953a80fSZachary Amsden linux_user="no" ; 8890953a80fSZachary Amsden bsd_user="no" ; 8900953a80fSZachary Amsden ;; 8910953a80fSZachary Amsden --enable-user) ;; 892831b7825Sths --disable-linux-user) linux_user="no" 8930a8e90f4Spbrook ;; 894831b7825Sths --enable-linux-user) linux_user="yes" 895831b7825Sths ;; 89684778508Sblueswir1 --disable-bsd-user) bsd_user="no" 89784778508Sblueswir1 ;; 89884778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 89984778508Sblueswir1 ;; 90040d6444eSAvi Kivity --enable-pie) pie="yes" 90134005a00SKirill A. Shutemov ;; 90240d6444eSAvi Kivity --disable-pie) pie="no" 90334005a00SKirill A. Shutemov ;; 90485aa5189Sbellard --enable-werror) werror="yes" 90585aa5189Sbellard ;; 90685aa5189Sbellard --disable-werror) werror="no" 90785aa5189Sbellard ;; 908cdad781dSDaniele Buono --enable-lto) lto="true" 909cdad781dSDaniele Buono ;; 910cdad781dSDaniele Buono --disable-lto) lto="false" 911cdad781dSDaniele Buono ;; 91263678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 91363678e17SSteven Noonan ;; 91463678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 91563678e17SSteven Noonan ;; 9161e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 9171e4f6065SDaniele Buono ;; 9181e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 9191e4f6065SDaniele Buono ;; 9209e62ba48SDaniele Buono --enable-cfi) 9219e62ba48SDaniele Buono cfi="true"; 9229e62ba48SDaniele Buono lto="true"; 9239e62ba48SDaniele Buono ;; 9249e62ba48SDaniele Buono --disable-cfi) cfi="false" 9259e62ba48SDaniele Buono ;; 926fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 9272df87df7SJuan Quintela ;; 928fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 929fbb4121dSPaolo Bonzini ;; 930fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 931fbb4121dSPaolo Bonzini ;; 93203a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 9332df87df7SJuan Quintela ;; 9347e563bfbSThomas Huth --with-pkgversion=*) pkgversion="$optarg" 9354a19f1ecSpbrook ;; 936519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 937519175a2SAlex Barcelo ;; 938d5970055SMichael S. Tsirkin --disable-vhost-net) vhost_net="no" 939d5970055SMichael S. Tsirkin ;; 940d5970055SMichael S. Tsirkin --enable-vhost-net) vhost_net="yes" 941d5970055SMichael S. Tsirkin ;; 942042cea27SGonglei --disable-vhost-crypto) vhost_crypto="no" 943042cea27SGonglei ;; 944299e6f19SPaolo Bonzini --enable-vhost-crypto) vhost_crypto="yes" 945042cea27SGonglei ;; 9465e9be92dSNicholas Bellinger --disable-vhost-scsi) vhost_scsi="no" 9475e9be92dSNicholas Bellinger ;; 9485e9be92dSNicholas Bellinger --enable-vhost-scsi) vhost_scsi="yes" 9495e9be92dSNicholas Bellinger ;; 950fc0b9b0eSStefan Hajnoczi --disable-vhost-vsock) vhost_vsock="no" 951fc0b9b0eSStefan Hajnoczi ;; 952fc0b9b0eSStefan Hajnoczi --enable-vhost-vsock) vhost_vsock="yes" 953fc0b9b0eSStefan Hajnoczi ;; 95498fc1adaSDr. David Alan Gilbert --disable-vhost-user-fs) vhost_user_fs="no" 95598fc1adaSDr. David Alan Gilbert ;; 95698fc1adaSDr. David Alan Gilbert --enable-vhost-user-fs) vhost_user_fs="yes" 95798fc1adaSDr. David Alan Gilbert ;; 958da076ffeSGerd Hoffmann --disable-opengl) opengl="no" 95920ff075bSMichael Walle ;; 960da076ffeSGerd Hoffmann --enable-opengl) opengl="yes" 96120ff075bSMichael Walle ;; 9621ffb3bbbSPaolo Bonzini --disable-zlib-test) 9631ece9905SAlon Levy ;; 96452b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 96552b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 966583f6e7bSStefan Hajnoczi ;; 967cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 968cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 969cb6414dfSFam Zheng ;; 970315d3184SFam Zheng --enable-uuid|--disable-uuid) 971315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 972315d3184SFam Zheng ;; 973a1c5e949SDaniel P. Berrange --tls-priority=*) tls_priority="$optarg" 974a1c5e949SDaniel P. Berrange ;; 9752da776dbSMichael R. Hines --enable-rdma) rdma="yes" 9762da776dbSMichael R. Hines ;; 9772da776dbSMichael R. Hines --disable-rdma) rdma="no" 9782da776dbSMichael R. Hines ;; 97921ab34c9SMarcel Apfelbaum --enable-pvrdma) pvrdma="yes" 98021ab34c9SMarcel Apfelbaum ;; 98121ab34c9SMarcel Apfelbaum --disable-pvrdma) pvrdma="no" 98221ab34c9SMarcel Apfelbaum ;; 983e6a74868SMarc-André Lureau --disable-vhost-user) vhost_user="no" 984e6a74868SMarc-André Lureau ;; 985299e6f19SPaolo Bonzini --enable-vhost-user) vhost_user="yes" 986299e6f19SPaolo Bonzini ;; 987108a6481SCindy Lu --disable-vhost-vdpa) vhost_vdpa="no" 988108a6481SCindy Lu ;; 989108a6481SCindy Lu --enable-vhost-vdpa) vhost_vdpa="yes" 990108a6481SCindy Lu ;; 991299e6f19SPaolo Bonzini --disable-vhost-kernel) vhost_kernel="no" 992299e6f19SPaolo Bonzini ;; 993299e6f19SPaolo Bonzini --enable-vhost-kernel) vhost_kernel="yes" 994e6a74868SMarc-André Lureau ;; 9958b18cdbfSRichard Henderson --disable-capstone) capstone="disabled" 9968ca80760SRichard Henderson ;; 9978b18cdbfSRichard Henderson --enable-capstone) capstone="enabled" 9988ca80760SRichard Henderson ;; 9998b18cdbfSRichard Henderson --enable-capstone=git) capstone="internal" 1000e219c499SRichard Henderson ;; 100103a3c0b3SPaolo Bonzini --enable-capstone=*) capstone="$optarg" 1002e219c499SRichard Henderson ;; 1003cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 1004cc84d63aSDaniel P. Berrange ;; 10057d7dbf9dSDan Streetman --with-git-submodules=*) 10067d7dbf9dSDan Streetman git_submodules_action="$optarg" 1007f62bbee5SDaniel P. Berrange ;; 10089b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 10099b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 10109b8e4298SAlex Bennée else 10119b8e4298SAlex Bennée plugins="yes" 10129b8e4298SAlex Bennée fi 101340e8c6f4SAlex Bennée ;; 101440e8c6f4SAlex Bennée --disable-plugins) plugins="no" 101540e8c6f4SAlex Bennée ;; 1016afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 1017afc3a8f9SAlex Bennée ;; 1018afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 1019afc3a8f9SAlex Bennée ;; 1020f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 1021f48e590aSAlex Bennée ;; 102254e7aac0SAlexey Krasikov --enable-keyring) secret_keyring="yes" 102354e7aac0SAlexey Krasikov ;; 102454e7aac0SAlexey Krasikov --disable-keyring) secret_keyring="no" 102554e7aac0SAlexey Krasikov ;; 102620cf7b8eSDenis Plotnikov --enable-gio) gio=yes 102720cf7b8eSDenis Plotnikov ;; 102820cf7b8eSDenis Plotnikov --disable-gio) gio=no 102920cf7b8eSDenis Plotnikov ;; 10303b4da132SPaolo Bonzini # backwards compatibility options 10313b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 10323b4da132SPaolo Bonzini ;; 10333b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 10343b4da132SPaolo Bonzini ;; 10353b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 10363b4da132SPaolo Bonzini ;; 10373b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 10383b4da132SPaolo Bonzini ;; 10393b4da132SPaolo Bonzini # everything else has the same name in configure and meson 104061d63097SPaolo Bonzini --enable-* | --disable-*) meson_option_parse "$opt" "$optarg" 104161d63097SPaolo Bonzini ;; 10422d2ad6d0SFam Zheng *) 10432d2ad6d0SFam Zheng echo "ERROR: unknown option $opt" 10442d2ad6d0SFam Zheng echo "Try '$0 --help' for more information" 10452d2ad6d0SFam Zheng exit 1 10467f1559c6Sbalrog ;; 10477d13299dSbellard esac 10487d13299dSbellarddone 10497d13299dSbellard 1050d1a14257SAlex Bennée# test for any invalid configuration combinations 1051d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 1052d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 1053d1a14257SAlex Bennéefi 1054d1a14257SAlex Bennée 10557d7dbf9dSDan Streetmancase $git_submodules_action in 10567d7dbf9dSDan Streetman update|validate) 10577d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 10587d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 10597d7dbf9dSDan Streetman exit 1 10607d7dbf9dSDan Streetman fi 10617d7dbf9dSDan Streetman ;; 10627d7dbf9dSDan Streetman ignore) 1063b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 1064b80fd281SPaolo Bonzini then 1065b80fd281SPaolo Bonzini echo 1066b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 1067b80fd281SPaolo Bonzini echo 1068b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 1069b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 1070b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 1071b80fd281SPaolo Bonzini else 1072b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 1073b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 1074b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 1075b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 1076b80fd281SPaolo Bonzini echo 1077b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 1078b80fd281SPaolo Bonzini echo 1079b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 1080b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 1081b80fd281SPaolo Bonzini fi 1082b80fd281SPaolo Bonzini echo 1083b80fd281SPaolo Bonzini exit 1 1084b80fd281SPaolo Bonzini fi 10857d7dbf9dSDan Streetman ;; 10867d7dbf9dSDan Streetman *) 10877d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 10887d7dbf9dSDan Streetman exit 1 10897d7dbf9dSDan Streetman ;; 10907d7dbf9dSDan Streetmanesac 10917d7dbf9dSDan Streetman 109222a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}" 109322a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}" 109422a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}" 109522a87800SMarc-André Lureau 109622a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then 109715588a62SJoshua Watt bindir="${bindir:-$prefix}" 109822a87800SMarc-André Lureauelse 109915588a62SJoshua Watt bindir="${bindir:-$prefix/bin}" 110015588a62SJoshua Wattfi 110122a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}" 110222a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}" 1103ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}" 110422a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}" 110522a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}" 110616bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}" 110716bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}" 110822a87800SMarc-André Lureau 11099557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 1110b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 11112038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 11129557af9cSAlex Bennéefi 111379f3b12fSPeter Crosthwaite 111460e0df25SPeter Maydelldefault_target_list="" 11156e92f823SPeter Maydellmak_wilds="" 11166e92f823SPeter Maydell 1117b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 1118b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 1119b915a2f1SPaolo Bonzini linux_user=yes 1120b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 1121b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 1122b915a2f1SPaolo Bonzini fi 1123b915a2f1SPaolo Bonzinifi 1124b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 1125b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 1126b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 1127b915a2f1SPaolo Bonzini fi 1128b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 1129b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 1130b915a2f1SPaolo Bonzini fi 1131b915a2f1SPaolo Bonzinifi 113260e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 1133812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 113460e0df25SPeter Maydellfi 113560e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 1136812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 113760e0df25SPeter Maydellfi 113860e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 1139812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 114060e0df25SPeter Maydellfi 114160e0df25SPeter Maydell 1142447e133fSAlex Bennéefor config in $mak_wilds; do 1143447e133fSAlex Bennée target="$(basename "$config" .mak)" 114498db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 1145447e133fSAlex Bennée default_target_list="${default_target_list} $target" 1146447e133fSAlex Bennée fi 1147447e133fSAlex Bennéedone 11486e92f823SPeter Maydell 1149af5db58eSpbrookif test x"$show_help" = x"yes" ; then 1150af5db58eSpbrookcat << EOF 1151af5db58eSpbrook 1152af5db58eSpbrookUsage: configure [options] 1153af5db58eSpbrookOptions: [defaults in brackets after descriptions] 1154af5db58eSpbrook 115508fb77edSStefan WeilStandard options: 115608fb77edSStefan Weil --help print this message 115708fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 115808fb77edSStefan Weil --interp-prefix=PREFIX where to find shared libraries, etc. 115908fb77edSStefan Weil use %M for cpu name [$interp_prefix] 116074154d7eSThomas Huth --target-list=LIST set target list (default: build all) 116108fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 116208fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 1163447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 116408fb77edSStefan Weil 116508fb77edSStefan WeilAdvanced options (experts only): 11663812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 116708fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 116808fb77edSStefan Weil --iasl=IASL use ACPI compiler IASL [$iasl] 116908fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 117008fb77edSStefan Weil build time 117108fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 117208fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1173a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1174a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 117508fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1176d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1177479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 117808fb77edSStefan Weil --make=MAKE use specified make [$make] 117908fb77edSStefan Weil --python=PYTHON use specified python [$python] 11802eb054c2SPeter Maydell --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build] 1181a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 118248328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 118308fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1184db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 11857d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 11867d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 11877d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 118808fb77edSStefan Weil --static enable static build [$static] 118908fb77edSStefan Weil --mandir=PATH install man pages in PATH 119010ff82d1SMarc-André Lureau --datadir=PATH install firmware in PATH/$qemu_suffix 1191fe0038beSPaolo Bonzini --localedir=PATH install translation in PATH/$qemu_suffix 119210ff82d1SMarc-André Lureau --docdir=PATH install documentation in PATH/$qemu_suffix 119308fb77edSStefan Weil --bindir=PATH install binaries in PATH 119408fb77edSStefan Weil --libdir=PATH install libraries in PATH 1195db1b5f13SThomas Huth --libexecdir=PATH install helper binaries in PATH 119610ff82d1SMarc-André Lureau --sysconfdir=PATH install config in PATH/$qemu_suffix 119708fb77edSStefan Weil --localstatedir=PATH install local state in PATH (set at runtime on win32) 11983d5eecabSGerd Hoffmann --firmwarepath=PATH search PATH for firmware files 119913336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1200ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1201db1b5f13SThomas Huth --with-pkgversion=VERS use specified string as sub-version of the package 1202c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1203c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1204c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1205d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1206d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 120708fb77edSStefan Weil --enable-debug enable common debug build options 1208247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 12090aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 121008fb77edSStefan Weil --disable-werror disable compilation abort on warning 121163678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 121216bfbc70SPaolo Bonzini --audio-drv-list=LIST set audio drivers to try if -audiodev is not used 121308fb77edSStefan Weil --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L 121408fb77edSStefan Weil --block-drv-rw-whitelist=L 121508fb77edSStefan Weil set block driver read-write whitelist 1216e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 121708fb77edSStefan Weil --block-drv-ro-whitelist=L 121808fb77edSStefan Weil set block driver read-only whitelist 1219e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 122008fb77edSStefan Weil --with-trace-file=NAME Full PATH,NAME of file to store traces 122108fb77edSStefan Weil Default:trace-<pid> 1222c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 122308fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 122433c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 122508fb77edSStefan Weil --enable-gcov enable test coverage analysis with gcov 1226a1c5e949SDaniel P. Berrange --tls-priority default TLS protocol/cipher priority string 122740e8c6f4SAlex Bennée --enable-plugins 122840e8c6f4SAlex Bennée enable plugins via shared library loading 1229afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1230f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 123161d63097SPaolo BonziniEOF 123261d63097SPaolo Bonzini meson_options_help 123361d63097SPaolo Bonzinicat << EOF 1234c23f23b9SMichael Tokarev system all system emulation targets 1235c23f23b9SMichael Tokarev user supported user emulation targets 1236c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1237c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1238c23f23b9SMichael Tokarev pie Position Independent Executables 123921e709aaSMarc-André Lureau modules modules support (non-Windows) 1240bd83c861SChristian Ehrhardt module-upgrades try to load modules from alternate paths for upgrades 1241c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1242c23f23b9SMichael Tokarev debug-info debugging information 1243cdad781dSDaniele Buono lto Enable Link-Time Optimization. 12441e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 12451e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 124621ab34c9SMarcel Apfelbaum rdma Enable RDMA-based migration 124721ab34c9SMarcel Apfelbaum pvrdma Enable PVRDMA support 1248299e6f19SPaolo Bonzini vhost-net vhost-net kernel acceleration support 1249299e6f19SPaolo Bonzini vhost-vsock virtio sockets device support 1250299e6f19SPaolo Bonzini vhost-scsi vhost-scsi kernel target support 1251299e6f19SPaolo Bonzini vhost-crypto vhost-user-crypto backend support 1252299e6f19SPaolo Bonzini vhost-kernel vhost kernel backend support 1253299e6f19SPaolo Bonzini vhost-user vhost-user backend support 1254108a6481SCindy Lu vhost-vdpa vhost-vdpa kernel backend support 1255c12d66aaSLin Ma opengl opengl support 125620cf7b8eSDenis Plotnikov gio libgio support 125708fb77edSStefan Weil 125808fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1259af5db58eSpbrookEOF 12602d2ad6d0SFam Zhengexit 0 1261af5db58eSpbrookfi 1262af5db58eSpbrook 12639c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1264bb768f71SThomas Huthrm -f */config-devices.mak.d 12659c790242SThomas Huth 1266faf44142SDaniel P. Berrangéif test -z "$python" 1267faf44142SDaniel P. Berrangéthen 1268c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1269c53eeaf7SStefan Hajnoczifi 12708e2c76bdSRoman Bolshakovif ! has "$make" 12718e2c76bdSRoman Bolshakovthen 12728e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 12738e2c76bdSRoman Bolshakovfi 1274c53eeaf7SStefan Hajnoczi 1275c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1276c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 12771b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 12781b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1279c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1280c53eeaf7SStefan Hajnoczifi 1281c53eeaf7SStefan Hajnoczi 1282755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1283406ab2f3SCleber Rosapython_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null) 1284755ee70fSCleber Rosa 1285c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1286c53eeaf7SStefan Hajnoczipython="$python -B" 1287c53eeaf7SStefan Hajnoczi 12880a01d76fSMarc-André Lureauif test -z "$meson"; then 12896638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 12900a01d76fSMarc-André Lureau meson=meson 12917d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 12920a01d76fSMarc-André Lureau meson=git 12930a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 12940a01d76fSMarc-André Lureau meson=internal 12950a01d76fSMarc-André Lureau else 12960a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 12970a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 12980a01d76fSMarc-André Lureau else 1299a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1300a5665051SPaolo Bonzini fi 13010a01d76fSMarc-André Lureau fi 13020a01d76fSMarc-André Lureauelse 13030a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 13040a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 13050a01d76fSMarc-André Lureau # 13060a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 13070a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 13080a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 13090a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 13100a01d76fSMarc-André Lureau case "$meson" in 13110a01d76fSMarc-André Lureau git | internal) ;; 13120a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 13130a01d76fSMarc-André Lureau esac 13140a01d76fSMarc-André Lureau fi 13150a01d76fSMarc-André Lureaufi 1316a5665051SPaolo Bonzini 13170a01d76fSMarc-André Lureauif test "$meson" = git; then 13180a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 13190a01d76fSMarc-André Lureaufi 13200a01d76fSMarc-André Lureau 13210a01d76fSMarc-André Lureaucase "$meson" in 13220a01d76fSMarc-André Lureau git | internal) 13230a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 13240a01d76fSMarc-André Lureau ;; 132584ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 13260a01d76fSMarc-André Lureauesac 13270a01d76fSMarc-André Lureau 132809e93326SPaolo Bonzini# Probe for ninja 132948328880SPaolo Bonzini 133048328880SPaolo Bonziniif test -z "$ninja"; then 133148328880SPaolo Bonzini for c in ninja ninja-build samu; do 133248328880SPaolo Bonzini if has $c; then 133348328880SPaolo Bonzini ninja=$(command -v "$c") 133448328880SPaolo Bonzini break 133548328880SPaolo Bonzini fi 133648328880SPaolo Bonzini done 133709e93326SPaolo Bonzini if test -z "$ninja"; then 133809e93326SPaolo Bonzini error_exit "Cannot find Ninja" 133909e93326SPaolo Bonzini fi 134048328880SPaolo Bonzinifi 1341a5665051SPaolo Bonzini 13429aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 13439aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 13449aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 13459aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 13469aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 13479aae6e54SDaniel Henrique Barbozaif compile_object ; then 13489aae6e54SDaniel Henrique Barboza : C compiler works ok 13499aae6e54SDaniel Henrique Barbozaelse 13509aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 13519aae6e54SDaniel Henrique Barbozafi 13529aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 13539aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 13549aae6e54SDaniel Henrique Barbozafi 13559aae6e54SDaniel Henrique Barboza 13569c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 13579c83ffd8SPeter Maydell# by default. Only enable by default for git builds 13589c83ffd8SPeter Maydellif test -z "$werror" ; then 13597d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1360e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 13619c83ffd8SPeter Maydell werror="yes" 13629c83ffd8SPeter Maydell else 13639c83ffd8SPeter Maydell werror="no" 13649c83ffd8SPeter Maydell fi 13659c83ffd8SPeter Maydellfi 13669c83ffd8SPeter Maydell 1367975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1368fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1369fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1370fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1371fb59dabdSPeter Maydell # host OS we should stop now. 1372951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1373fb59dabdSPeter Maydellfi 1374fb59dabdSPeter Maydell 1375efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1376efc6c070SThomas Huthcat > $TMPC << EOF 1377efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1378efc6c070SThomas Huth# ifdef __apple_build_version__ 13792a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 13802a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1381efc6c070SThomas Huth# endif 1382efc6c070SThomas Huth# else 13832a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 13842a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1385efc6c070SThomas Huth# endif 1386efc6c070SThomas Huth# endif 1387efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 13883830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 13893830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1390efc6c070SThomas Huth# endif 1391efc6c070SThomas Huth#else 1392efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1393efc6c070SThomas Huth#endif 1394efc6c070SThomas Huthint main (void) { return 0; } 1395efc6c070SThomas HuthEOF 1396efc6c070SThomas Huthif ! compile_prog "" "" ; then 13973830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1398efc6c070SThomas Huthfi 1399efc6c070SThomas Huth 140000849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 140100849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 140200849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 140300849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 140400849b92SRichard Henderson# just silently disable some features, so it's too error prone. 140500849b92SRichard Henderson 140600849b92SRichard Hendersonwarn_flags= 140700849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 140800849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 140900849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 141000849b92SRichard Hendersonadd_to warn_flags -Wformat-security 141100849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 141200849b92SRichard Hendersonadd_to warn_flags -Winit-self 141300849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 141400849b92SRichard Hendersonadd_to warn_flags -Wempty-body 141500849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 141600849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 141700849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 14180a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 141900849b92SRichard Henderson 142000849b92SRichard Hendersonnowarn_flags= 142100849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 142200849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 142300849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 142400849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 142500849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1426aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1427bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 142800849b92SRichard Henderson 142900849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 143093b25869SJohn Snow 143193b25869SJohn Snowcc_has_warning_flag() { 143293b25869SJohn Snow write_c_skeleton; 143393b25869SJohn Snow 1434a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1435a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1436a1d29d6cSPeter Maydell # warning options). 143793b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 143893b25869SJohn Snow compile_prog "-Werror $optflag" "" 143993b25869SJohn Snow} 144093b25869SJohn Snow 144193b25869SJohn Snowfor flag in $gcc_flags; do 144293b25869SJohn Snow if cc_has_warning_flag $flag ; then 14438d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 14448d05095cSPaolo Bonzini fi 14458d05095cSPaolo Bonzinidone 14468d05095cSPaolo Bonzini 144763678e17SSteven Noonanif test "$stack_protector" != "no"; then 1448fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1449fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1450fccd35a0SRodrigo Rebello{ 1451fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1452fccd35a0SRodrigo Rebello while (*c) { 1453fccd35a0SRodrigo Rebello *p++ = *c++; 1454fccd35a0SRodrigo Rebello } 1455fccd35a0SRodrigo Rebello return 0; 1456fccd35a0SRodrigo Rebello} 1457fccd35a0SRodrigo RebelloEOF 145863678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 14593b463a3fSMiroslav Rezanina sp_on=0 146063678e17SSteven Noonan for flag in $gcc_flags; do 1461590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1462590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1463086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1464590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 146563678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1466db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 14673b463a3fSMiroslav Rezanina sp_on=1 146863678e17SSteven Noonan break 146963678e17SSteven Noonan fi 147063678e17SSteven Noonan done 14713b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 14723b463a3fSMiroslav Rezanina if test $sp_on = 0; then 14733b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 14743b463a3fSMiroslav Rezanina fi 14753b463a3fSMiroslav Rezanina fi 147637746c5eSMarc-André Lureaufi 147737746c5eSMarc-André Lureau 147820bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 147920bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 148020bc94a2SPaolo Bonzinicat > $TMPC << EOF 148120bc94a2SPaolo Bonzinistruct { 148220bc94a2SPaolo Bonzini int a[2]; 148320bc94a2SPaolo Bonzini} x = {0}; 148420bc94a2SPaolo BonziniEOF 148520bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 148620bc94a2SPaolo Bonzini : 148720bc94a2SPaolo Bonzinielse 148820bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 148920bc94a2SPaolo Bonzinifi 149020bc94a2SPaolo Bonzini 149121e709aaSMarc-André Lureau# Our module code doesn't support Windows 149221e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 149321e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 149421e709aaSMarc-André Lureaufi 149521e709aaSMarc-André Lureau 1496bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled 1497bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then 1498bd83c861SChristian Ehrhardt error_exit "Can't enable module-upgrades as Modules are not enabled" 1499bd83c861SChristian Ehrhardtfi 1500bd83c861SChristian Ehrhardt 15015f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 150240d6444eSAvi Kivityif test "$static" = "yes" ; then 1503aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1504aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1505aa0d1f44SPaolo Bonzini fi 15065f2453acSAlex Bennée if test "$plugins" = "yes"; then 15075f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1508ba4dd2aaSAlex Bennée else 1509ba4dd2aaSAlex Bennée plugins="no" 15105f2453acSAlex Bennée fi 151140d6444eSAvi Kivityfi 151237650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 151340d6444eSAvi Kivity 151440d6444eSAvi Kivitycat > $TMPC << EOF 151521d4a791SAvi Kivity 151621d4a791SAvi Kivity#ifdef __linux__ 151721d4a791SAvi Kivity# define THREAD __thread 151821d4a791SAvi Kivity#else 151921d4a791SAvi Kivity# define THREAD 152021d4a791SAvi Kivity#endif 152121d4a791SAvi Kivitystatic THREAD int tls_var; 152221d4a791SAvi Kivityint main(void) { return tls_var; } 152340d6444eSAvi KivityEOF 1524b2634124SRichard Henderson 1525ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1526ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1527412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1528412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1529ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1530412aeacdSAlex Bennéefi 1531412aeacdSAlex Bennée 153212781462SRichard Hendersonif test "$static" = "yes"; then 1533eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 15345770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 153512781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 153612781462SRichard Henderson pie="yes" 153712781462SRichard Henderson elif test "$pie" = "yes"; then 153812781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 153912781462SRichard Henderson else 154012781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 154112781462SRichard Henderson pie="no" 154212781462SRichard Henderson fi 154312781462SRichard Hendersonelif test "$pie" = "no"; then 15445770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1545ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1546eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 15475770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 15485770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 154940d6444eSAvi Kivity pie="yes" 15502c674109SRichard Hendersonelif test "$pie" = "yes"; then 155176ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 155240d6444eSAvi Kivityelse 155340d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 155440d6444eSAvi Kivity pie="no" 155540d6444eSAvi Kivityfi 155640d6444eSAvi Kivity 1557e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1558e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1559e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1560e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1561e6cbd751SRichard Hendersonfi 1562e6cbd751SRichard Henderson 156309dada40SPaolo Bonzini########################################## 156409dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 156509dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 156609dada40SPaolo Bonzini# specification is necessary 156709dada40SPaolo Bonzini 156809dada40SPaolo Bonziniif test "$cpu" = "i386"; then 156909dada40SPaolo Bonzini cat > $TMPC << EOF 157009dada40SPaolo Bonzinistatic int sfaa(int *ptr) 157109dada40SPaolo Bonzini{ 157209dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 157309dada40SPaolo Bonzini} 157409dada40SPaolo Bonzini 157509dada40SPaolo Bonziniint main(void) 157609dada40SPaolo Bonzini{ 157709dada40SPaolo Bonzini int val = 42; 15781405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 157909dada40SPaolo Bonzini sfaa(&val); 158009dada40SPaolo Bonzini return val; 158109dada40SPaolo Bonzini} 158209dada40SPaolo BonziniEOF 158309dada40SPaolo Bonzini if ! compile_prog "" "" ; then 158409dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 158509dada40SPaolo Bonzini fi 158609dada40SPaolo Bonzinifi 158709dada40SPaolo Bonzini 158856267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 158956267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 159056267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 159156267b62SPhilippe Mathieu-Daudéfi 159256267b62SPhilippe Mathieu-Daudé 1593afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1594fdb75aefSPaolo Bonzini default_targets=yes 1595d880a3baSPaolo Bonzini for target in $default_target_list; do 1596d880a3baSPaolo Bonzini target_list="$target_list $target" 1597d880a3baSPaolo Bonzini done 1598d880a3baSPaolo Bonzini target_list="${target_list# }" 1599121afa9eSAnthony Liguorielse 1600fdb75aefSPaolo Bonzini default_targets=no 160189138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1602d880a3baSPaolo Bonzini for target in $target_list; do 160325b48338SPeter Maydell # Check that we recognised the target name; this allows a more 160425b48338SPeter Maydell # friendly error message than if we let it fall through. 160525b48338SPeter Maydell case " $default_target_list " in 160625b48338SPeter Maydell *" $target "*) 160725b48338SPeter Maydell ;; 160825b48338SPeter Maydell *) 160925b48338SPeter Maydell error_exit "Unknown target name '$target'" 161025b48338SPeter Maydell ;; 161125b48338SPeter Maydell esac 161225b48338SPeter Maydell done 1613d880a3baSPaolo Bonzinifi 161425b48338SPeter Maydell 1615f55fe278SPaolo Bonzini# see if system emulation was really requested 1616f55fe278SPaolo Bonzinicase " $target_list " in 1617f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1618f55fe278SPaolo Bonzini ;; 1619f55fe278SPaolo Bonzini *) softmmu=no 1620f55fe278SPaolo Bonzini ;; 1621f55fe278SPaolo Bonziniesac 16225327cf48Sbellard 1623249247c9SJuan Quintelafeature_not_found() { 1624249247c9SJuan Quintela feature=$1 162521684af0SStewart Smith remedy=$2 1626249247c9SJuan Quintela 162776ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 162821684af0SStewart Smith "configure was not able to find it." \ 162921684af0SStewart Smith "$remedy" 1630249247c9SJuan Quintela} 1631249247c9SJuan Quintela 16327d13299dSbellard# --- 16337d13299dSbellard# big/little endian test 16347d13299dSbellardcat > $TMPC << EOF 1635659eb157SThomas Huth#include <stdio.h> 163661cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 163761cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1638659eb157SThomas Huthint main(int argc, char *argv[]) 1639659eb157SThomas Huth{ 1640659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 16417d13299dSbellard} 16427d13299dSbellardEOF 16437d13299dSbellard 1644659eb157SThomas Huthif compile_prog ; then 1645659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 164661cc919fSMike Frysinger bigendian="yes" 1647659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 164861cc919fSMike Frysinger bigendian="no" 16497d13299dSbellard else 16507d13299dSbellard echo big/little test failed 1651659eb157SThomas Huth exit 1 16527d13299dSbellard fi 16537d13299dSbellardelse 165461cc919fSMike Frysinger echo big/little test failed 1655659eb157SThomas Huth exit 1 16567d13299dSbellardfi 16577d13299dSbellard 1658299e6f19SPaolo Bonzini######################################### 1659299e6f19SPaolo Bonzini# vhost interdependencies and host support 1660299e6f19SPaolo Bonzini 1661299e6f19SPaolo Bonzini# vhost backends 1662d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then 1663d88618f7SStefan Hajnoczi error_exit "vhost-user is only available on Linux" 1664299e6f19SPaolo Bonzinifi 1665108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux 1666108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then 1667108a6481SCindy Lu error_exit "vhost-vdpa is only available on Linux" 1668108a6481SCindy Lufi 1669299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux 1670299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then 1671299e6f19SPaolo Bonzini error_exit "vhost-kernel is only available on Linux" 1672299e6f19SPaolo Bonzinifi 1673299e6f19SPaolo Bonzini 1674299e6f19SPaolo Bonzini# vhost-kernel devices 1675299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel 1676299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then 1677299e6f19SPaolo Bonzini error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" 1678299e6f19SPaolo Bonzinifi 1679299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel 1680299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then 1681299e6f19SPaolo Bonzini error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" 1682299e6f19SPaolo Bonzinifi 1683299e6f19SPaolo Bonzini 1684299e6f19SPaolo Bonzini# vhost-user backends 1685299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user 1686299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then 1687299e6f19SPaolo Bonzini error_exit "--enable-vhost-net-user requires --enable-vhost-user" 1688299e6f19SPaolo Bonzinifi 1689299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user 1690299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then 1691299e6f19SPaolo Bonzini error_exit "--enable-vhost-crypto requires --enable-vhost-user" 1692299e6f19SPaolo Bonzinifi 169398fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user 169498fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then 169598fc1adaSDr. David Alan Gilbert error_exit "--enable-vhost-user-fs requires --enable-vhost-user" 169698fc1adaSDr. David Alan Gilbertfi 1697108a6481SCindy Lu#vhost-vdpa backends 1698108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa 1699108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then 1700108a6481SCindy Lu error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" 1701108a6481SCindy Lufi 1702299e6f19SPaolo Bonzini 170340bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity 1704299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then 1705299e6f19SPaolo Bonzini test "$vhost_net_user" = "yes" && vhost_net=yes 170640bc0ca9SLaurent Vivier test "$vhost_net_vdpa" = "yes" && vhost_net=yes 1707299e6f19SPaolo Bonzini test "$vhost_kernel" = "yes" && vhost_net=yes 1708299e6f19SPaolo Bonzinifi 1709299e6f19SPaolo Bonzini 1710015a33bdSGonglei########################################## 1711779ab5e3SStefan Weil# pkg-config probe 1712779ab5e3SStefan Weil 1713779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 171476ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1715779ab5e3SStefan Weilfi 1716779ab5e3SStefan Weil 1717779ab5e3SStefan Weil########################################## 1718e37630caSaliguori# xen probe 1719e37630caSaliguori 17201badb709SPaolo Bonziniif test "$xen" != "disabled" ; then 1721c1cdd9d5SJuergen Gross # Check whether Xen library path is specified via --extra-ldflags to avoid 1722c1cdd9d5SJuergen Gross # overriding this setting with pkg-config output. If not, try pkg-config 1723c1cdd9d5SJuergen Gross # to obtain all needed flags. 1724c1cdd9d5SJuergen Gross 1725c1cdd9d5SJuergen Gross if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ 1726c1cdd9d5SJuergen Gross $pkg_config --exists xencontrol ; then 1727c1cdd9d5SJuergen Gross xen_ctrl_version="$(printf '%d%02d%02d' \ 1728c1cdd9d5SJuergen Gross $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" 17291badb709SPaolo Bonzini xen=enabled 17305b6a8f43SMichael Tokarev xen_pc="xencontrol xenstore xenforeignmemory xengnttab" 1731c1cdd9d5SJuergen Gross xen_pc="$xen_pc xenevtchn xendevicemodel" 173258ea9a7aSAnthony PERARD if $pkg_config --exists xentoolcore; then 173358ea9a7aSAnthony PERARD xen_pc="$xen_pc xentoolcore" 173458ea9a7aSAnthony PERARD fi 1735582ea95fSMarc-André Lureau xen_cflags="$($pkg_config --cflags $xen_pc)" 1736582ea95fSMarc-André Lureau xen_libs="$($pkg_config --libs $xen_pc)" 1737c1cdd9d5SJuergen Gross else 1738c1cdd9d5SJuergen Gross 17395b6a8f43SMichael Tokarev xen_libs="-lxenstore -lxenctrl" 1740d9506cabSAnthony PERARD xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" 1741d5b93ddfSAnthony PERARD 174250ced5b3SStefan Weil # First we test whether Xen headers and libraries are available. 174350ced5b3SStefan Weil # If no, we are done and there is no Xen support. 174450ced5b3SStefan Weil # If yes, more tests are run to detect the Xen version. 174550ced5b3SStefan Weil 174650ced5b3SStefan Weil # Xen (any) 174750ced5b3SStefan Weil cat > $TMPC <<EOF 174850ced5b3SStefan Weil#include <xenctrl.h> 174950ced5b3SStefan Weilint main(void) { 175050ced5b3SStefan Weil return 0; 175150ced5b3SStefan Weil} 175250ced5b3SStefan WeilEOF 175350ced5b3SStefan Weil if ! compile_prog "" "$xen_libs" ; then 175450ced5b3SStefan Weil # Xen not found 17551badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 175621684af0SStewart Smith feature_not_found "xen" "Install xen devel" 175750ced5b3SStefan Weil fi 17581badb709SPaolo Bonzini xen=disabled 175950ced5b3SStefan Weil 1760d5b93ddfSAnthony PERARD # Xen unstable 176169deef08SPeter Maydell elif 176269deef08SPeter Maydell cat > $TMPC <<EOF && 17632cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API 17642cbf8903SRoss Lagerwall#define __XEN_TOOLS__ 17652cbf8903SRoss Lagerwall#include <xendevicemodel.h> 1766d3c49ebbSPaul Durrant#include <xenforeignmemory.h> 17672cbf8903SRoss Lagerwallint main(void) { 17682cbf8903SRoss Lagerwall xendevicemodel_handle *xd; 1769d3c49ebbSPaul Durrant xenforeignmemory_handle *xfmem; 17702cbf8903SRoss Lagerwall 17712cbf8903SRoss Lagerwall xd = xendevicemodel_open(0, 0); 17722cbf8903SRoss Lagerwall xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); 17732cbf8903SRoss Lagerwall 1774d3c49ebbSPaul Durrant xfmem = xenforeignmemory_open(0, 0); 1775d3c49ebbSPaul Durrant xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); 1776d3c49ebbSPaul Durrant 17772cbf8903SRoss Lagerwall return 0; 17782cbf8903SRoss Lagerwall} 17792cbf8903SRoss LagerwallEOF 17802cbf8903SRoss Lagerwall compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 17812cbf8903SRoss Lagerwall then 17822cbf8903SRoss Lagerwall xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 17832cbf8903SRoss Lagerwall xen_ctrl_version=41100 17841badb709SPaolo Bonzini xen=enabled 17852cbf8903SRoss Lagerwall elif 17862cbf8903SRoss Lagerwall cat > $TMPC <<EOF && 17875ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API 17885ba3d756SIgor Druzhinin#include <xenforeignmemory.h> 178958ea9a7aSAnthony PERARD#include <xentoolcore.h> 17905ba3d756SIgor Druzhininint main(void) { 17915ba3d756SIgor Druzhinin xenforeignmemory_handle *xfmem; 17925ba3d756SIgor Druzhinin 17935ba3d756SIgor Druzhinin xfmem = xenforeignmemory_open(0, 0); 17945ba3d756SIgor Druzhinin xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); 179558ea9a7aSAnthony PERARD xentoolcore_restrict_all(0); 17965ba3d756SIgor Druzhinin 17975ba3d756SIgor Druzhinin return 0; 17985ba3d756SIgor Druzhinin} 17995ba3d756SIgor DruzhininEOF 180058ea9a7aSAnthony PERARD compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 18015ba3d756SIgor Druzhinin then 180258ea9a7aSAnthony PERARD xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 18035ba3d756SIgor Druzhinin xen_ctrl_version=41000 18041badb709SPaolo Bonzini xen=enabled 18055ba3d756SIgor Druzhinin elif 18065ba3d756SIgor Druzhinin cat > $TMPC <<EOF && 1807da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API 1808da8090ccSPaul Durrant#define __XEN_TOOLS__ 1809da8090ccSPaul Durrant#include <xendevicemodel.h> 1810da8090ccSPaul Durrantint main(void) { 1811da8090ccSPaul Durrant xendevicemodel_handle *xd; 1812da8090ccSPaul Durrant 1813da8090ccSPaul Durrant xd = xendevicemodel_open(0, 0); 1814da8090ccSPaul Durrant xendevicemodel_close(xd); 1815da8090ccSPaul Durrant 1816da8090ccSPaul Durrant return 0; 1817da8090ccSPaul Durrant} 1818da8090ccSPaul DurrantEOF 1819da8090ccSPaul Durrant compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" 1820da8090ccSPaul Durrant then 1821da8090ccSPaul Durrant xen_stable_libs="-lxendevicemodel $xen_stable_libs" 1822f1167ee6SJuergen Gross xen_ctrl_version=40900 18231badb709SPaolo Bonzini xen=enabled 1824da8090ccSPaul Durrant elif 1825da8090ccSPaul Durrant cat > $TMPC <<EOF && 18265eeb39c2SIan Campbell/* 18275eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat 18285eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given. 1829b6eb9b45SPaulina Szubarczyk * 1830b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and 1831b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented. 1832b6eb9b45SPaulina Szubarczyk */ 1833b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API 1834b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API 1835b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API 1836b6eb9b45SPaulina Szubarczyk#include <xenctrl.h> 1837b6eb9b45SPaulina Szubarczyk#include <xenstore.h> 1838b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h> 1839b6eb9b45SPaulina Szubarczyk#include <xengnttab.h> 1840b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h> 1841b6eb9b45SPaulina Szubarczyk#include <stdint.h> 1842b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h> 1843b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS) 1844b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined 1845b6eb9b45SPaulina Szubarczyk#endif 1846b6eb9b45SPaulina Szubarczykint main(void) { 1847b6eb9b45SPaulina Szubarczyk xc_interface *xc = NULL; 1848b6eb9b45SPaulina Szubarczyk xenforeignmemory_handle *xfmem; 1849b6eb9b45SPaulina Szubarczyk xenevtchn_handle *xe; 1850b6eb9b45SPaulina Szubarczyk xengnttab_handle *xg; 1851b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy_segment_t* seg = NULL; 1852b6eb9b45SPaulina Szubarczyk 1853b6eb9b45SPaulina Szubarczyk xs_daemon_open(); 1854b6eb9b45SPaulina Szubarczyk 1855b6eb9b45SPaulina Szubarczyk xc = xc_interface_open(0, 0, 0); 1856b6eb9b45SPaulina Szubarczyk xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1857b6eb9b45SPaulina Szubarczyk xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 1858b6eb9b45SPaulina Szubarczyk xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 1859b6eb9b45SPaulina Szubarczyk xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 1860b6eb9b45SPaulina Szubarczyk 1861b6eb9b45SPaulina Szubarczyk xfmem = xenforeignmemory_open(0, 0); 1862b6eb9b45SPaulina Szubarczyk xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 1863b6eb9b45SPaulina Szubarczyk 1864b6eb9b45SPaulina Szubarczyk xe = xenevtchn_open(0, 0); 1865b6eb9b45SPaulina Szubarczyk xenevtchn_fd(xe); 1866b6eb9b45SPaulina Szubarczyk 1867b6eb9b45SPaulina Szubarczyk xg = xengnttab_open(0, 0); 1868b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy(xg, 0, seg); 1869b6eb9b45SPaulina Szubarczyk 1870b6eb9b45SPaulina Szubarczyk return 0; 1871b6eb9b45SPaulina Szubarczyk} 1872b6eb9b45SPaulina SzubarczykEOF 1873b6eb9b45SPaulina Szubarczyk compile_prog "" "$xen_libs $xen_stable_libs" 1874b6eb9b45SPaulina Szubarczyk then 1875f1167ee6SJuergen Gross xen_ctrl_version=40800 18761badb709SPaolo Bonzini xen=enabled 1877b6eb9b45SPaulina Szubarczyk elif 1878b6eb9b45SPaulina Szubarczyk cat > $TMPC <<EOF && 1879b6eb9b45SPaulina Szubarczyk/* 1880b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat 1881b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given. 18825eeb39c2SIan Campbell */ 18835eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API 18845eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API 18855eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API 18865eeb39c2SIan Campbell#include <xenctrl.h> 18875eeb39c2SIan Campbell#include <xenstore.h> 18885eeb39c2SIan Campbell#include <xenevtchn.h> 18895eeb39c2SIan Campbell#include <xengnttab.h> 18905eeb39c2SIan Campbell#include <xenforeignmemory.h> 18915eeb39c2SIan Campbell#include <stdint.h> 18925eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h> 18935eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS) 18945eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined 18955eeb39c2SIan Campbell#endif 18965eeb39c2SIan Campbellint main(void) { 18975eeb39c2SIan Campbell xc_interface *xc = NULL; 18985eeb39c2SIan Campbell xenforeignmemory_handle *xfmem; 18995eeb39c2SIan Campbell xenevtchn_handle *xe; 19005eeb39c2SIan Campbell xengnttab_handle *xg; 19015eeb39c2SIan Campbell 19025eeb39c2SIan Campbell xs_daemon_open(); 19035eeb39c2SIan Campbell 19045eeb39c2SIan Campbell xc = xc_interface_open(0, 0, 0); 19055eeb39c2SIan Campbell xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 19065eeb39c2SIan Campbell xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19075eeb39c2SIan Campbell xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 19085eeb39c2SIan Campbell xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 19095eeb39c2SIan Campbell 19105eeb39c2SIan Campbell xfmem = xenforeignmemory_open(0, 0); 19115eeb39c2SIan Campbell xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 19125eeb39c2SIan Campbell 19135eeb39c2SIan Campbell xe = xenevtchn_open(0, 0); 19145eeb39c2SIan Campbell xenevtchn_fd(xe); 19155eeb39c2SIan Campbell 19165eeb39c2SIan Campbell xg = xengnttab_open(0, 0); 19175eeb39c2SIan Campbell xengnttab_map_grant_ref(xg, 0, 0, 0); 19185eeb39c2SIan Campbell 19195eeb39c2SIan Campbell return 0; 19205eeb39c2SIan Campbell} 19215eeb39c2SIan CampbellEOF 19225eeb39c2SIan Campbell compile_prog "" "$xen_libs $xen_stable_libs" 19235eeb39c2SIan Campbell then 1924f1167ee6SJuergen Gross xen_ctrl_version=40701 19251badb709SPaolo Bonzini xen=enabled 1926cdadde39SRoger Pau Monne 1927cdadde39SRoger Pau Monne # Xen 4.6 1928cdadde39SRoger Pau Monne elif 1929cdadde39SRoger Pau Monne cat > $TMPC <<EOF && 1930cdadde39SRoger Pau Monne#include <xenctrl.h> 1931e108a3c1SAnthony PERARD#include <xenstore.h> 1932d5b93ddfSAnthony PERARD#include <stdint.h> 1933d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h> 1934d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS) 1935d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined 1936d5b93ddfSAnthony PERARD#endif 1937d5b93ddfSAnthony PERARDint main(void) { 1938d5b93ddfSAnthony PERARD xc_interface *xc; 1939d5b93ddfSAnthony PERARD xs_daemon_open(); 1940d5b93ddfSAnthony PERARD xc = xc_interface_open(0, 0, 0); 1941d5b93ddfSAnthony PERARD xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1942d5b93ddfSAnthony PERARD xc_gnttab_open(NULL, 0); 1943b87de24eSAnthony PERARD xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19448688e065SStefano Stabellini xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 1945d8b441a3SJan Beulich xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 194620a544c7SKonrad Rzeszutek Wilk xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); 1947d8b441a3SJan Beulich return 0; 1948d8b441a3SJan Beulich} 1949d8b441a3SJan BeulichEOF 1950d8b441a3SJan Beulich compile_prog "" "$xen_libs" 1951d8b441a3SJan Beulich then 1952f1167ee6SJuergen Gross xen_ctrl_version=40600 19531badb709SPaolo Bonzini xen=enabled 1954d8b441a3SJan Beulich 1955d8b441a3SJan Beulich # Xen 4.5 1956d8b441a3SJan Beulich elif 1957d8b441a3SJan Beulich cat > $TMPC <<EOF && 1958d8b441a3SJan Beulich#include <xenctrl.h> 1959d8b441a3SJan Beulich#include <xenstore.h> 1960d8b441a3SJan Beulich#include <stdint.h> 1961d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h> 1962d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS) 1963d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined 1964d8b441a3SJan Beulich#endif 1965d8b441a3SJan Beulichint main(void) { 1966d8b441a3SJan Beulich xc_interface *xc; 1967d8b441a3SJan Beulich xs_daemon_open(); 1968d8b441a3SJan Beulich xc = xc_interface_open(0, 0, 0); 1969d8b441a3SJan Beulich xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1970d8b441a3SJan Beulich xc_gnttab_open(NULL, 0); 1971d8b441a3SJan Beulich xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 1972d8b441a3SJan Beulich xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 19733996e85cSPaul Durrant xc_hvm_create_ioreq_server(xc, 0, 0, NULL); 19743996e85cSPaul Durrant return 0; 19753996e85cSPaul Durrant} 19763996e85cSPaul DurrantEOF 19773996e85cSPaul Durrant compile_prog "" "$xen_libs" 19783996e85cSPaul Durrant then 1979f1167ee6SJuergen Gross xen_ctrl_version=40500 19801badb709SPaolo Bonzini xen=enabled 19813996e85cSPaul Durrant 19823996e85cSPaul Durrant elif 19833996e85cSPaul Durrant cat > $TMPC <<EOF && 19843996e85cSPaul Durrant#include <xenctrl.h> 19853996e85cSPaul Durrant#include <xenstore.h> 19863996e85cSPaul Durrant#include <stdint.h> 19873996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h> 19883996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS) 19893996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined 19903996e85cSPaul Durrant#endif 19913996e85cSPaul Durrantint main(void) { 19923996e85cSPaul Durrant xc_interface *xc; 19933996e85cSPaul Durrant xs_daemon_open(); 19943996e85cSPaul Durrant xc = xc_interface_open(0, 0, 0); 19953996e85cSPaul Durrant xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 19963996e85cSPaul Durrant xc_gnttab_open(NULL, 0); 19973996e85cSPaul Durrant xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19983996e85cSPaul Durrant xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 19998688e065SStefano Stabellini return 0; 20008688e065SStefano Stabellini} 20018688e065SStefano StabelliniEOF 20028688e065SStefano Stabellini compile_prog "" "$xen_libs" 200369deef08SPeter Maydell then 2004f1167ee6SJuergen Gross xen_ctrl_version=40200 20051badb709SPaolo Bonzini xen=enabled 20068688e065SStefano Stabellini 2007e37630caSaliguori else 20081badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 2009edfb07edSIan Campbell feature_not_found "xen (unsupported version)" \ 2010edfb07edSIan Campbell "Install a supported xen (xen 4.2 or newer)" 2011fc321b4bSJuan Quintela fi 20121badb709SPaolo Bonzini xen=disabled 2013e37630caSaliguori fi 2014d5b93ddfSAnthony PERARD 20151badb709SPaolo Bonzini if test "$xen" = enabled; then 2016f1167ee6SJuergen Gross if test $xen_ctrl_version -ge 40701 ; then 2017582ea95fSMarc-André Lureau xen_libs="$xen_libs $xen_stable_libs " 20185eeb39c2SIan Campbell fi 2019d5b93ddfSAnthony PERARD fi 2020e37630caSaliguori fi 2021c1cdd9d5SJuergen Grossfi 2022e37630caSaliguori 2023d661d9a4SJustin Terry (VM)########################################## 20242da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries 20252da776dbSMichael R. Hinesif test "$rdma" != "no" ; then 20262da776dbSMichael R. Hines cat > $TMPC <<EOF 20272da776dbSMichael R. Hines#include <rdma/rdma_cma.h> 20282da776dbSMichael R. Hinesint main(void) { return 0; } 20292da776dbSMichael R. HinesEOF 2030ef6d4ccdSYuval Shaia rdma_libs="-lrdmacm -libverbs -libumad" 20312da776dbSMichael R. Hines if compile_prog "" "$rdma_libs" ; then 20322da776dbSMichael R. Hines rdma="yes" 20332da776dbSMichael R. Hines else 20342da776dbSMichael R. Hines if test "$rdma" = "yes" ; then 20352da776dbSMichael R. Hines error_exit \ 2036ef6d4ccdSYuval Shaia " OpenFabrics librdmacm/libibverbs/libibumad not present." \ 20372da776dbSMichael R. Hines " Your options:" \ 2038ef6d4ccdSYuval Shaia " (1) Fast: Install infiniband packages (devel) from your distro." \ 20392da776dbSMichael R. Hines " (2) Cleanest: Install libraries from www.openfabrics.org" \ 20402da776dbSMichael R. Hines " (3) Also: Install softiwarp if you don't have RDMA hardware" 20412da776dbSMichael R. Hines fi 20422da776dbSMichael R. Hines rdma="no" 20432da776dbSMichael R. Hines fi 20442da776dbSMichael R. Hinesfi 20452da776dbSMichael R. Hines 204621ab34c9SMarcel Apfelbaum########################################## 204721ab34c9SMarcel Apfelbaum# PVRDMA detection 204821ab34c9SMarcel Apfelbaum 204921ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF && 205021ab34c9SMarcel Apfelbaum#include <sys/mman.h> 205121ab34c9SMarcel Apfelbaum 205221ab34c9SMarcel Apfelbaumint 205321ab34c9SMarcel Apfelbaummain(void) 205421ab34c9SMarcel Apfelbaum{ 205521ab34c9SMarcel Apfelbaum char buf = 0; 205621ab34c9SMarcel Apfelbaum void *addr = &buf; 205721ab34c9SMarcel Apfelbaum addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED); 205821ab34c9SMarcel Apfelbaum 205921ab34c9SMarcel Apfelbaum return 0; 206021ab34c9SMarcel Apfelbaum} 206121ab34c9SMarcel ApfelbaumEOF 206221ab34c9SMarcel Apfelbaum 206321ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then 206421ab34c9SMarcel Apfelbaum case "$pvrdma" in 206521ab34c9SMarcel Apfelbaum "") 206621ab34c9SMarcel Apfelbaum if compile_prog "" ""; then 206721ab34c9SMarcel Apfelbaum pvrdma="yes" 206821ab34c9SMarcel Apfelbaum else 206921ab34c9SMarcel Apfelbaum pvrdma="no" 207021ab34c9SMarcel Apfelbaum fi 207121ab34c9SMarcel Apfelbaum ;; 207221ab34c9SMarcel Apfelbaum "yes") 207321ab34c9SMarcel Apfelbaum if ! compile_prog "" ""; then 207421ab34c9SMarcel Apfelbaum error_exit "PVRDMA is not supported since mremap is not implemented" 207521ab34c9SMarcel Apfelbaum fi 207621ab34c9SMarcel Apfelbaum pvrdma="yes" 207721ab34c9SMarcel Apfelbaum ;; 207821ab34c9SMarcel Apfelbaum "no") 207921ab34c9SMarcel Apfelbaum pvrdma="no" 208021ab34c9SMarcel Apfelbaum ;; 208121ab34c9SMarcel Apfelbaum esac 208221ab34c9SMarcel Apfelbaumelse 208321ab34c9SMarcel Apfelbaum if test "$pvrdma" = "yes" ; then 208421ab34c9SMarcel Apfelbaum error_exit "PVRDMA requires rdma suppport" 208521ab34c9SMarcel Apfelbaum fi 208621ab34c9SMarcel Apfelbaum pvrdma="no" 208721ab34c9SMarcel Apfelbaumfi 208895c6bff3SBenoît Canet 2089ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported 2090ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then 2091ee108585SYuval Shaia 2092ee108585SYuval Shaiacat > $TMPC <<EOF && 2093ee108585SYuval Shaia#include <infiniband/verbs.h> 2094ee108585SYuval Shaia 2095ee108585SYuval Shaiaint 2096ee108585SYuval Shaiamain(void) 2097ee108585SYuval Shaia{ 2098ee108585SYuval Shaia struct ibv_mr *mr; 2099ee108585SYuval Shaia struct ibv_pd *pd = NULL; 2100ee108585SYuval Shaia size_t length = 10; 2101ee108585SYuval Shaia uint64_t iova = 0; 2102ee108585SYuval Shaia int access = 0; 2103ee108585SYuval Shaia void *addr = NULL; 2104ee108585SYuval Shaia 2105ee108585SYuval Shaia mr = ibv_reg_mr_iova(pd, addr, length, iova, access); 2106ee108585SYuval Shaia 2107ee108585SYuval Shaia ibv_dereg_mr(mr); 2108ee108585SYuval Shaia 2109ee108585SYuval Shaia return 0; 2110ee108585SYuval Shaia} 2111ee108585SYuval ShaiaEOF 2112ee108585SYuval Shaia if ! compile_prog "" "-libverbs"; then 2113ee108585SYuval Shaia QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR" 2114ee108585SYuval Shaia fi 2115ee108585SYuval Shaiafi 2116ee108585SYuval Shaia 211795c6bff3SBenoît Canet########################################## 2118e18df141SAnthony Liguori# glib support probe 2119a52d28afSPaolo Bonzini 2120b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 2121aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 2122aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 2123a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 2124b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 2125b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 212654cb65d8SEmilio G. Cotafi 2127e26110cfSFam Zheng 2128aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 2129e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 213089138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 213189138857SStefan Weil glib_libs=$($pkg_config --libs $i) 2132e18df141SAnthony Liguori else 2133e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 2134e26110cfSFam Zheng fi 2135e26110cfSFam Zhengdone 2136e26110cfSFam Zheng 2137215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 2138215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 2139215b0c2fSPaolo Bonzini 2140215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 2141215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 2142215b0c2fSPaolo Bonzinifi 2143215b0c2fSPaolo Bonzini 214420cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then 214520cf7b8eSDenis Plotnikov pass=no 2146f876b765SMarc-André Lureau if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then 2147f876b765SMarc-André Lureau gio_cflags=$($pkg_config --cflags gio-2.0) 2148f876b765SMarc-André Lureau gio_libs=$($pkg_config --libs gio-2.0) 214925a97a56SMarc-André Lureau gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) 21505ecfb76cSPaolo Bonzini if ! has "$gdbus_codegen"; then 21510dba4897SMarc-André Lureau gdbus_codegen= 21520dba4897SMarc-André Lureau fi 215376346b62SPeter Maydell # Check that the libraries actually work -- Ubuntu 18.04 ships 215476346b62SPeter Maydell # with pkg-config --static --libs data for gio-2.0 that is missing 215576346b62SPeter Maydell # -lblkid and will give a link error. 215613ceae66SPeter Maydell cat > $TMPC <<EOF 215713ceae66SPeter Maydell#include <gio/gio.h> 215813ceae66SPeter Maydellint main(void) 215913ceae66SPeter Maydell{ 216013ceae66SPeter Maydell g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); 216113ceae66SPeter Maydell return 0; 216213ceae66SPeter Maydell} 216313ceae66SPeter MaydellEOF 216413ceae66SPeter Maydell if compile_prog "$gio_cflags" "$gio_libs" ; then 216520cf7b8eSDenis Plotnikov pass=yes 216676346b62SPeter Maydell else 216720cf7b8eSDenis Plotnikov pass=no 2168f876b765SMarc-André Lureau fi 2169f876b765SMarc-André Lureau 217020cf7b8eSDenis Plotnikov if test "$pass" = "yes" && 217120cf7b8eSDenis Plotnikov $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then 217225a97a56SMarc-André Lureau gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)" 217325a97a56SMarc-André Lureau gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)" 217425a97a56SMarc-André Lureau fi 217520cf7b8eSDenis Plotnikov fi 217620cf7b8eSDenis Plotnikov 217720cf7b8eSDenis Plotnikov if test "$pass" = "no"; then 217820cf7b8eSDenis Plotnikov if test "$gio" = "yes"; then 217920cf7b8eSDenis Plotnikov feature_not_found "gio" "Install libgio >= 2.0" 218020cf7b8eSDenis Plotnikov else 218120cf7b8eSDenis Plotnikov gio=no 218220cf7b8eSDenis Plotnikov fi 218320cf7b8eSDenis Plotnikov else 218420cf7b8eSDenis Plotnikov gio=yes 218520cf7b8eSDenis Plotnikov fi 218620cf7b8eSDenis Plotnikovfi 218725a97a56SMarc-André Lureau 2188977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 2189977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 2190977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 2191977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 2192977a82abSDaniel P. Berrangecat > $TMPC <<EOF 2193977a82abSDaniel P. Berrange#include <glib.h> 2194977a82abSDaniel P. Berrange#include <unistd.h> 2195977a82abSDaniel P. Berrange 2196977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 2197977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 2198977a82abSDaniel P. Berrange 2199977a82abSDaniel P. Berrangeint main(void) { 2200977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 2201977a82abSDaniel P. Berrange return 0; 2202977a82abSDaniel P. Berrange} 2203977a82abSDaniel P. BerrangeEOF 2204977a82abSDaniel P. Berrange 2205215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 2206977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 2207977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 2208977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 2209977a82abSDaniel P. Berrange "build target" 2210977a82abSDaniel P. Berrangefi 2211977a82abSDaniel P. Berrange 22129bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 22139bda600bSEric Blakecat > $TMPC << EOF 22149bda600bSEric Blake#include <glib.h> 22159bda600bSEric Blaketypedef struct Foo { 22169bda600bSEric Blake int i; 22179bda600bSEric Blake} Foo; 22189bda600bSEric Blakestatic void foo_free(Foo *f) 22199bda600bSEric Blake{ 22209bda600bSEric Blake g_free(f); 22219bda600bSEric Blake} 22229bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free); 22239bda600bSEric Blakeint main(void) { return 0; } 22249bda600bSEric BlakeEOF 22259bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 22269bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 22279bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 22285770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 22299bda600bSEric Blake fi 22309bda600bSEric Blakefi 22319bda600bSEric Blake 2232e26110cfSFam Zheng########################################## 2233e26110cfSFam Zheng# SHA command probe for modules 2234e26110cfSFam Zhengif test "$modules" = yes; then 2235e26110cfSFam Zheng shacmd_probe="sha1sum sha1 shasum" 2236e26110cfSFam Zheng for c in $shacmd_probe; do 22378ccefb91SFam Zheng if has $c; then 2238e26110cfSFam Zheng shacmd="$c" 2239e26110cfSFam Zheng break 2240e26110cfSFam Zheng fi 2241e26110cfSFam Zheng done 2242e26110cfSFam Zheng if test "$shacmd" = ""; then 2243e26110cfSFam Zheng error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" 2244e26110cfSFam Zheng fi 2245e18df141SAnthony Liguorifi 2246e18df141SAnthony Liguori 2247e18df141SAnthony Liguori########################################## 2248f652e6afSaurel32# fdt probe 2249e169e1e1SPeter Maydell 2250fbb4121dSPaolo Bonzinicase "$fdt" in 2251fbb4121dSPaolo Bonzini auto | enabled | internal) 2252fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 2253aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 2254fbb4121dSPaolo Bonzini ;; 2255fbb4121dSPaolo Bonziniesac 2256f652e6afSaurel32 225720ff075bSMichael Walle########################################## 22589d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk) 2259b1546f32SGerd Hoffmann 2260da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then 2261bc6a3565SAkihiko Odaki epoxy=no 2262bc6a3565SAkihiko Odaki if $pkg_config epoxy; then 2263bc6a3565SAkihiko Odaki cat > $TMPC << EOF 2264bc6a3565SAkihiko Odaki#include <epoxy/egl.h> 2265bc6a3565SAkihiko Odakiint main(void) { return 0; } 2266bc6a3565SAkihiko OdakiEOF 2267bc6a3565SAkihiko Odaki if compile_prog "" "" ; then 2268bc6a3565SAkihiko Odaki epoxy=yes 2269bc6a3565SAkihiko Odaki fi 2270bc6a3565SAkihiko Odaki fi 2271bc6a3565SAkihiko Odaki 2272bc6a3565SAkihiko Odaki if test "$epoxy" = "yes" ; then 2273bc6a3565SAkihiko Odaki opengl_cflags="$($pkg_config --cflags epoxy)" 2274bc6a3565SAkihiko Odaki opengl_libs="$($pkg_config --libs epoxy)" 2275da076ffeSGerd Hoffmann opengl=yes 227620ff075bSMichael Walle else 2277da076ffeSGerd Hoffmann if test "$opengl" = "yes" ; then 2278bc6a3565SAkihiko Odaki feature_not_found "opengl" "Please install epoxy with EGL" 227920ff075bSMichael Walle fi 2280f676c67eSJeremy White opengl_cflags="" 2281da076ffeSGerd Hoffmann opengl_libs="" 2282da076ffeSGerd Hoffmann opengl=no 228320ff075bSMichael Walle fi 228420ff075bSMichael Wallefi 228520ff075bSMichael Walle 2286955727d2SCortland Tölva# check for usbfs 2287955727d2SCortland Tölvahave_usbfs=no 2288955727d2SCortland Tölvaif test "$linux_user" = "yes"; then 228996566d09SThomas Petazzoni cat > $TMPC << EOF 229096566d09SThomas Petazzoni#include <linux/usbdevice_fs.h> 229196566d09SThomas Petazzoni 229296566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES 229396566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined" 229496566d09SThomas Petazzoni#endif 229596566d09SThomas Petazzoni 229696566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM 229796566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined" 229896566d09SThomas Petazzoni#endif 229996566d09SThomas Petazzoni 230096566d09SThomas Petazzoniint main(void) 230196566d09SThomas Petazzoni{ 230296566d09SThomas Petazzoni return 0; 230396566d09SThomas Petazzoni} 230496566d09SThomas PetazzoniEOF 230596566d09SThomas Petazzoni if compile_prog "" ""; then 2306955727d2SCortland Tölva have_usbfs=yes 2307955727d2SCortland Tölva fi 2308955727d2SCortland Tölvafi 2309751bcc39SMarc-André Lureau 2310de5071c5SBlue Swirl########################################## 23118ca80760SRichard Henderson# capstone 23128ca80760SRichard Henderson 2313e219c499SRichard Hendersoncase "$capstone" in 23148b18cdbfSRichard Henderson auto | enabled | internal) 23158b18cdbfSRichard Henderson # Simpler to always update submodule, even if not needed. 2316e219c499SRichard Henderson git_submodules="${git_submodules} capstone" 2317e219c499SRichard Henderson ;; 2318e219c499SRichard Hendersonesac 23198ca80760SRichard Henderson 23208ca80760SRichard Henderson########################################## 2321519175a2SAlex Barcelo# check and set a backend for coroutine 2322d0e2fce5SAneesh Kumar K.V 23237c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 232433c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 232533c53c54SDaniel P. Berrange# specific one. 23267c2acc70SPeter Maydell 23277c2acc70SPeter Maydellucontext_works=no 2328d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 2329d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 2330d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 2331cdf84806SPeter Maydell#ifdef __stub_makecontext 2332cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 2333cdf84806SPeter Maydell#endif 233475cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 2335d0e2fce5SAneesh Kumar K.VEOF 2336d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 23377c2acc70SPeter Maydell ucontext_works=yes 2338d0e2fce5SAneesh Kumar K.V fi 2339519175a2SAlex Barcelofi 23407c2acc70SPeter Maydell 23417c2acc70SPeter Maydellif test "$coroutine" = ""; then 23427c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 23437c2acc70SPeter Maydell coroutine=win32 23447c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 23457c2acc70SPeter Maydell coroutine=ucontext 2346519175a2SAlex Barcelo else 23477c2acc70SPeter Maydell coroutine=sigaltstack 23487c2acc70SPeter Maydell fi 23497c2acc70SPeter Maydellelse 23507c2acc70SPeter Maydell case $coroutine in 23517c2acc70SPeter Maydell windows) 23527c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 23537c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 23547c2acc70SPeter Maydell fi 23557c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 23567c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 23577c2acc70SPeter Maydell coroutine=win32 23587c2acc70SPeter Maydell ;; 23597c2acc70SPeter Maydell ucontext) 23607c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 23617c2acc70SPeter Maydell feature_not_found "ucontext" 23627c2acc70SPeter Maydell fi 23637c2acc70SPeter Maydell ;; 236433c53c54SDaniel P. Berrange sigaltstack) 23657c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 23667c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 23677c2acc70SPeter Maydell fi 23687c2acc70SPeter Maydell ;; 23697c2acc70SPeter Maydell *) 237076ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 23717c2acc70SPeter Maydell ;; 23727c2acc70SPeter Maydell esac 2373d0e2fce5SAneesh Kumar K.Vfi 2374d0e2fce5SAneesh Kumar K.V 23751e4f6065SDaniele Buono################################################## 23761e4f6065SDaniele Buono# SafeStack 23771e4f6065SDaniele Buono 23781e4f6065SDaniele Buono 23791e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 23801e4f6065SDaniele Buonocat > $TMPC << EOF 23811e4f6065SDaniele Buonoint main(int argc, char *argv[]) 23821e4f6065SDaniele Buono{ 23831e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 23841e4f6065SDaniele Buono#error SafeStack Disabled 23851e4f6065SDaniele Buono#endif 23861e4f6065SDaniele Buono return 0; 23871e4f6065SDaniele Buono} 23881e4f6065SDaniele BuonoEOF 23891e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 23901e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 23911e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 23921e4f6065SDaniele Buono # Flag needed both at compilation and at linking 23931e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 23941e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 23951e4f6065SDaniele Buono else 23961e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 23971e4f6065SDaniele Buono fi 23981e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 23991e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 24001e4f6065SDaniele Buono fi 24011e4f6065SDaniele Buonoelse 24021e4f6065SDaniele Buonocat > $TMPC << EOF 24031e4f6065SDaniele Buonoint main(int argc, char *argv[]) 24041e4f6065SDaniele Buono{ 24051e4f6065SDaniele Buono#if defined(__has_feature) 24061e4f6065SDaniele Buono#if __has_feature(safe_stack) 24071e4f6065SDaniele Buono#error SafeStack Enabled 24081e4f6065SDaniele Buono#endif 24091e4f6065SDaniele Buono#endif 24101e4f6065SDaniele Buono return 0; 24111e4f6065SDaniele Buono} 24121e4f6065SDaniele BuonoEOF 24131e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 24141e4f6065SDaniele Buono # Make sure that safe-stack is disabled 24151e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 24161e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 24171e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 24181e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 24191e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 24201e4f6065SDaniele Buono fi 24211e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 24221e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 24231e4f6065SDaniele Buono fi 24241e4f6065SDaniele Buonoelse # "$safe_stack" = "" 24251e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 24261e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 24271e4f6065SDaniele Buono safe_stack="no" 24281e4f6065SDaniele Buono else 24291e4f6065SDaniele Buono safe_stack="yes" 24301e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 24311e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 24321e4f6065SDaniele Buono fi 24331e4f6065SDaniele Buono fi 24341e4f6065SDaniele Buonofi 24351e4f6065SDaniele Buonofi 24367d992e4dSPeter Lieven 243776a347e1SRichard Henderson######################################## 2438f540166bSRichard Henderson# check if __[u]int128_t is usable. 2439f540166bSRichard Henderson 2440f540166bSRichard Hendersonint128=no 2441f540166bSRichard Hendersoncat > $TMPC << EOF 2442f540166bSRichard Henderson__int128_t a; 2443f540166bSRichard Henderson__uint128_t b; 2444f540166bSRichard Hendersonint main (void) { 2445f540166bSRichard Henderson a = a + b; 2446f540166bSRichard Henderson b = a * b; 2447464e3671SPeter Maydell a = a * a; 2448f540166bSRichard Henderson return 0; 2449f540166bSRichard Henderson} 2450f540166bSRichard HendersonEOF 2451f540166bSRichard Hendersonif compile_prog "" "" ; then 2452f540166bSRichard Henderson int128=yes 2453f540166bSRichard Hendersonfi 245476a347e1SRichard Henderson 24557ebee43eSRichard Henderson######################################### 24567ebee43eSRichard Henderson# See if 128-bit atomic operations are supported. 24577ebee43eSRichard Henderson 24587ebee43eSRichard Hendersonatomic128=no 24597ebee43eSRichard Hendersonif test "$int128" = "yes"; then 24607ebee43eSRichard Henderson cat > $TMPC << EOF 24617ebee43eSRichard Hendersonint main(void) 24627ebee43eSRichard Henderson{ 24637ebee43eSRichard Henderson unsigned __int128 x = 0, y = 0; 2464bceac547SThomas Huth y = __atomic_load(&x, 0); 2465bceac547SThomas Huth __atomic_store(&x, y, 0); 2466bceac547SThomas Huth __atomic_compare_exchange(&x, &y, x, 0, 0, 0); 24677ebee43eSRichard Henderson return 0; 24687ebee43eSRichard Henderson} 24697ebee43eSRichard HendersonEOF 24707ebee43eSRichard Henderson if compile_prog "" "" ; then 24717ebee43eSRichard Henderson atomic128=yes 24727ebee43eSRichard Henderson fi 24737ebee43eSRichard Hendersonfi 24747ebee43eSRichard Henderson 2475e6cd4bb5SRichard Hendersoncmpxchg128=no 2476e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then 2477e6cd4bb5SRichard Henderson cat > $TMPC << EOF 2478e6cd4bb5SRichard Hendersonint main(void) 2479e6cd4bb5SRichard Henderson{ 2480e6cd4bb5SRichard Henderson unsigned __int128 x = 0, y = 0; 2481e6cd4bb5SRichard Henderson __sync_val_compare_and_swap_16(&x, y, x); 2482e6cd4bb5SRichard Henderson return 0; 2483e6cd4bb5SRichard Henderson} 2484e6cd4bb5SRichard HendersonEOF 2485e6cd4bb5SRichard Henderson if compile_prog "" "" ; then 2486e6cd4bb5SRichard Henderson cmpxchg128=yes 2487e6cd4bb5SRichard Henderson fi 2488e6cd4bb5SRichard Hendersonfi 2489e6cd4bb5SRichard Henderson 2490fd0e6053SJohn Snow######################################## 2491fd0e6053SJohn Snow# check if ccache is interfering with 2492fd0e6053SJohn Snow# semantic analysis of macros 2493fd0e6053SJohn Snow 24945e4dfd3dSJohn Snowunset CCACHE_CPP2 2495fd0e6053SJohn Snowccache_cpp2=no 2496fd0e6053SJohn Snowcat > $TMPC << EOF 2497fd0e6053SJohn Snowstatic const int Z = 1; 2498fd0e6053SJohn Snow#define fn() ({ Z; }) 2499fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 2500fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 2501fd0e6053SJohn Snow#define ID(X) (X) 2502fd0e6053SJohn Snowint main(int argc, char *argv[]) 2503fd0e6053SJohn Snow{ 2504fd0e6053SJohn Snow int x = 0, y = 0; 2505fd0e6053SJohn Snow x = ID(x); 2506fd0e6053SJohn Snow x = fn(); 2507fd0e6053SJohn Snow fn(); 2508fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 2509fd0e6053SJohn Snow if (TAUT(Z)) return 0; 2510fd0e6053SJohn Snow return 0; 2511fd0e6053SJohn Snow} 2512fd0e6053SJohn SnowEOF 2513fd0e6053SJohn Snow 2514fd0e6053SJohn Snowif ! compile_object "-Werror"; then 2515fd0e6053SJohn Snow ccache_cpp2=yes 2516fd0e6053SJohn Snowfi 2517fd0e6053SJohn Snow 2518b553a042SJohn Snow################################################# 2519b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 2520b553a042SJohn Snow 2521b553a042SJohn Snowif test "$fortify_source" != "no"; then 2522b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 2523b553a042SJohn Snow fortify_source="no"; 2524e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 2525cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 2526b553a042SJohn Snow fortify_source="no"; 2527b553a042SJohn Snow else 2528b553a042SJohn Snow fortify_source="yes" 2529b553a042SJohn Snow fi 2530b553a042SJohn Snowfi 2531b553a042SJohn Snow 2532d2042378SAneesh Kumar K.V########################################## 2533247724cbSMarc-André Lureau# checks for sanitizers 2534247724cbSMarc-André Lureau 2535247724cbSMarc-André Lureauhave_asan=no 2536247724cbSMarc-André Lureauhave_ubsan=no 2537d83414e1SMarc-André Lureauhave_asan_iface_h=no 2538d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 2539247724cbSMarc-André Lureau 2540247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 2541b9f44da2SMarc-André Lureau write_c_skeleton 2542247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 2543247724cbSMarc-André Lureau have_asan=yes 2544247724cbSMarc-André Lureau fi 2545b9f44da2SMarc-André Lureau 2546b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 2547b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 2548b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 2549b9f44da2SMarc-André Lureau cat > $TMPC << EOF 2550b9f44da2SMarc-André Lureau#include <stdlib.h> 2551b9f44da2SMarc-André Lureauint main(void) { 2552b9f44da2SMarc-André Lureau void *tmp = malloc(10); 2553f2dfe54cSLeonid Bloch if (tmp != NULL) { 2554b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 2555b9f44da2SMarc-André Lureau } 2556d1abf3fcSOlaf Hering return 1; 2557f2dfe54cSLeonid Bloch} 2558b9f44da2SMarc-André LureauEOF 2559247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 2560247724cbSMarc-André Lureau have_ubsan=yes 2561247724cbSMarc-André Lureau fi 2562d83414e1SMarc-André Lureau 2563d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 2564d83414e1SMarc-André Lureau have_asan_iface_h=yes 2565d83414e1SMarc-André Lureau fi 2566d83414e1SMarc-André Lureau 2567d83414e1SMarc-André Lureau cat > $TMPC << EOF 2568d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 2569d83414e1SMarc-André Lureauint main(void) { 2570d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 2571d83414e1SMarc-André Lureau return 0; 2572d83414e1SMarc-André Lureau} 2573d83414e1SMarc-André LureauEOF 2574d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 2575d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 2576d83414e1SMarc-André Lureau fi 2577247724cbSMarc-André Lureaufi 2578247724cbSMarc-André Lureau 25790aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 25800aebab04SLingfeng Yang# keep it separate until that is not the case. 25810aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 25820aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 25830aebab04SLingfeng Yangfi 25840aebab04SLingfeng Yanghave_tsan=no 25850aebab04SLingfeng Yanghave_tsan_iface_fiber=no 25860aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 25870aebab04SLingfeng Yang write_c_skeleton 25880aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 25890aebab04SLingfeng Yang have_tsan=yes 25900aebab04SLingfeng Yang fi 25910aebab04SLingfeng Yang cat > $TMPC << EOF 25920aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 25930aebab04SLingfeng Yangint main(void) { 25940aebab04SLingfeng Yang __tsan_create_fiber(0); 25950aebab04SLingfeng Yang return 0; 25960aebab04SLingfeng Yang} 25970aebab04SLingfeng YangEOF 25980aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 25990aebab04SLingfeng Yang have_tsan_iface_fiber=yes 26000aebab04SLingfeng Yang fi 26010aebab04SLingfeng Yangfi 26020aebab04SLingfeng Yang 2603adc28027SAlexander Bulekov########################################## 2604675b9b53SMarc-André Lureau# check for slirp 2605675b9b53SMarc-André Lureau 2606675b9b53SMarc-André Lureaucase "$slirp" in 26074d34a86bSPaolo Bonzini auto | enabled | internal) 26084d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 26097c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 2610675b9b53SMarc-André Lureau ;; 2611675b9b53SMarc-André Lureauesac 2612675b9b53SMarc-André Lureau 261354e7aac0SAlexey Krasikov########################################## 261454e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall 261554e7aac0SAlexey Krasikov 261654e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then 261754e7aac0SAlexey Krasikov 261854e7aac0SAlexey Krasikov have_keyring=no 261954e7aac0SAlexey Krasikov cat > $TMPC << EOF 262054e7aac0SAlexey Krasikov#include <errno.h> 262154e7aac0SAlexey Krasikov#include <asm/unistd.h> 262254e7aac0SAlexey Krasikov#include <linux/keyctl.h> 262354e7aac0SAlexey Krasikov#include <unistd.h> 262454e7aac0SAlexey Krasikovint main(void) { 262554e7aac0SAlexey Krasikov return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0); 262654e7aac0SAlexey Krasikov} 262754e7aac0SAlexey KrasikovEOF 262854e7aac0SAlexey Krasikov if compile_prog "" "" ; then 262954e7aac0SAlexey Krasikov have_keyring=yes 263054e7aac0SAlexey Krasikov fi 263154e7aac0SAlexey Krasikovfi 263254e7aac0SAlexey Krasikovif test "$secret_keyring" != "no" 263354e7aac0SAlexey Krasikovthen 2634b418d265SDavid Edmondson if test "$have_keyring" = "yes" 263554e7aac0SAlexey Krasikov then 263654e7aac0SAlexey Krasikov secret_keyring=yes 263754e7aac0SAlexey Krasikov else 263854e7aac0SAlexey Krasikov if test "$secret_keyring" = "yes" 263954e7aac0SAlexey Krasikov then 264054e7aac0SAlexey Krasikov error_exit "syscall __NR_keyctl requested, \ 264154e7aac0SAlexey Krasikovbut not implemented on your system" 264254e7aac0SAlexey Krasikov else 264354e7aac0SAlexey Krasikov secret_keyring=no 264454e7aac0SAlexey Krasikov fi 264554e7aac0SAlexey Krasikov fi 264654e7aac0SAlexey Krasikovfi 264754e7aac0SAlexey Krasikov 264892500362SAlexey Krasikov########################################## 2649e86ecd4bSJuan Quintela# End of CC checks 2650e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 2651e86ecd4bSJuan Quintela 2652d83414e1SMarc-André Lureauwrite_c_skeleton 2653d83414e1SMarc-André Lureau 26541d728c39SBlue Swirlif test "$gcov" = "yes" ; then 2655bf0e56a3SMarc-André Lureau : 2656b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then 2657086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 2658086d5f75SPaolo Bonzini debug=no 2659086d5f75SPaolo Bonzinifi 2660086d5f75SPaolo Bonzini 2661086d5f75SPaolo Bonzinicase "$ARCH" in 2662086d5f75SPaolo Bonzinialpha) 2663086d5f75SPaolo Bonzini # Ensure there's only a single GP 2664086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 2665086d5f75SPaolo Bonzini;; 2666086d5f75SPaolo Bonziniesac 2667086d5f75SPaolo Bonzini 2668247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 2669db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 2670db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 2671d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 2672d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 2673d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2674d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 2675d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 2676d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2677d83414e1SMarc-André Lureau fi 2678247724cbSMarc-André Lureaufi 26790aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 26800aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 26810aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 26820aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 26830aebab04SLingfeng Yang else 26840aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 26850aebab04SLingfeng Yang fi 26860aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 26870aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 26880aebab04SLingfeng Yangfi 2689247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 2690db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 2691db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 2692247724cbSMarc-André Lureaufi 2693247724cbSMarc-André Lureau 26946542aa9cSPeter Lieven########################################## 26953efac6ebSTomáš Golembiovský 26960aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 26970aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 2698e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 2699db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 2700e86ecd4bSJuan Quintela fi 2701e86ecd4bSJuan Quintelafi 2702e86ecd4bSJuan Quintela 2703952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available 2704952afb71SBlue Swirlif test "$mingw32" = "yes" ; then 2705cb8baa77SMark Cave-Ayland flags="--no-seh --nxcompat" 2706cb8baa77SMark Cave-Ayland 2707cb8baa77SMark Cave-Ayland # Disable ASLR for debug builds to allow debugging with gdb 2708cb8baa77SMark Cave-Ayland if test "$debug" = "no" ; then 2709cb8baa77SMark Cave-Ayland flags="--dynamicbase $flags" 2710cb8baa77SMark Cave-Ayland fi 2711cb8baa77SMark Cave-Ayland 2712cb8baa77SMark Cave-Ayland for flag in $flags; do 2713e9a3591fSChristian Borntraeger if ld_has $flag ; then 2714db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS" 2715952afb71SBlue Swirl fi 2716952afb71SBlue Swirl done 2717952afb71SBlue Swirlfi 2718952afb71SBlue Swirl 2719b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 27209d6bc27bSMichael Roth 27219d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 27229d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 27239d6bc27bSMichael Rothfi 27249d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 27259d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 27269d6bc27bSMichael Rothfi 27279d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 272889138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 27299d6bc27bSMichael Rothfi 27309d6bc27bSMichael Roth 2731b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 27329d6bc27bSMichael Roth 2733ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 2734ca35f780SPaolo Bonziniroms= 2735e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 2736ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 2737ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 2738e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 2739c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 2740c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 2741c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 2742e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 2743e57218b6SPeter Maydell ld_i386_emulation="$emu" 2744ca35f780SPaolo Bonzini roms="optionrom" 2745e57218b6SPeter Maydell break 2746e57218b6SPeter Maydell fi 2747e57218b6SPeter Maydell done 2748ca35f780SPaolo Bonzinifi 2749ca35f780SPaolo Bonzini 27502e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 2751a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 27529933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 27532e33c3f8SThomas Huth write_c_skeleton 2754a5b2afd5SThomas Huth compile_prog "-march=z900" "" 2755a5b2afd5SThomas Huth has_z900=$? 27563af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 2757a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 2758a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 2759a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 2760a5b2afd5SThomas Huth fi 27619933c305SChristian Borntraeger roms="$roms s390-ccw" 27621ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 27631ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 27641ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 27651ef6bfc2SPhilippe Mathieu-Daudé fi 27669933c305SChristian Borntraegerfi 27679933c305SChristian Borntraeger 276811cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 276911cde1c8SBruno Dominguez# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added. 277011cde1c8SBruno Dominguezif has $cxx; then 277111cde1c8SBruno Dominguez cat > $TMPC <<EOF 277211cde1c8SBruno Dominguezint c_function(void); 277311cde1c8SBruno Dominguezint main(void) { return c_function(); } 277411cde1c8SBruno DominguezEOF 277511cde1c8SBruno Dominguez 277611cde1c8SBruno Dominguez compile_object 277711cde1c8SBruno Dominguez 277811cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 277911cde1c8SBruno Dominguezextern "C" { 278011cde1c8SBruno Dominguez int c_function(void); 278111cde1c8SBruno Dominguez} 278211cde1c8SBruno Dominguezint c_function(void) { return 42; } 278311cde1c8SBruno DominguezEOF 278411cde1c8SBruno Dominguez 278511cde1c8SBruno Dominguez update_cxxflags 278611cde1c8SBruno Dominguez 2787a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 278811cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 278911cde1c8SBruno Dominguez : 279011cde1c8SBruno Dominguez else 279111cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 279211cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 279311cde1c8SBruno Dominguez cxx= 279411cde1c8SBruno Dominguez fi 279511cde1c8SBruno Dominguezelse 279611cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 279711cde1c8SBruno Dominguez cxx= 279811cde1c8SBruno Dominguezfi 279911cde1c8SBruno Dominguez 28007d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 28017d7dbf9dSDan Streetman exit 1 28025d91a2edSYonggang Luofi 28035d91a2edSYonggang Luo 280498ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 280597a847bcSbellard 280698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 280798ec69acSJuan Quintelaecho >> $config_host_mak 280898ec69acSJuan Quintela 2809e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 2810cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 2811aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 28127d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 2813804edf29SJuan Quintela 2814f8393946Saurel32if test "$debug_tcg" = "yes" ; then 28152358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 2816f8393946Saurel32fi 281767b915a5Sbellardif test "$mingw32" = "yes" ; then 281898ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 28199dacf32dSYossi Hindin echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak 28209dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 28219dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 28229dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 2823210fa556Spbrookelse 282435f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 2825210fa556Spbrookfi 2826128ab2ffSblueswir1 2827dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 2828dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 2829dffcb71cSMark McLoughlinfi 2830dffcb71cSMark McLoughlin 283183fb7adfSbellardif test "$darwin" = "yes" ; then 283298ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 283383fb7adfSbellardfi 2834b29fe3edSmalc 2835ec530c81Sbellardif test "$solaris" = "yes" ; then 283698ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 2837ec530c81Sbellardfi 283897a847bcSbellardif test "$static" = "yes" ; then 283998ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 284097a847bcSbellardfi 2841b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak 2842b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak 284389138857SStefan Weilqemu_version=$(head $source_path/VERSION) 28442358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak 284598ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 28462b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 284717969268SFam Zhengif test "$modules" = "yes"; then 2848e26110cfSFam Zheng # $shacmd can generate a hash started with digit, which the compiler doesn't 2849e26110cfSFam Zheng # like as an symbol. So prefix it with an underscore 285089138857SStefan Weil echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak 285117969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 285217969268SFam Zhengfi 2853bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then 2854bd83c861SChristian Ehrhardt echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak 2855bd83c861SChristian Ehrhardtfi 2856955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then 2857955727d2SCortland Tölva echo "CONFIG_USBFS=y" >> $config_host_mak 2858955727d2SCortland Tölvafi 2859f876b765SMarc-André Lureauif test "$gio" = "yes" ; then 2860f876b765SMarc-André Lureau echo "CONFIG_GIO=y" >> $config_host_mak 2861f876b765SMarc-André Lureau echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak 2862f876b765SMarc-André Lureau echo "GIO_LIBS=$gio_libs" >> $config_host_mak 28635ecfb76cSPaolo Bonzinifi 28645ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then 286525a97a56SMarc-André Lureau echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak 2866f876b765SMarc-André Lureaufi 2867a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak 2868277abf15SJan Vesely 28691badb709SPaolo Bonziniif test "$xen" = "enabled" ; then 28706dbd588aSJan Kiszka echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak 2871d5b93ddfSAnthony PERARD echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak 2872582ea95fSMarc-André Lureau echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak 2873582ea95fSMarc-André Lureau echo "XEN_LIBS=$xen_libs" >> $config_host_mak 2874e37630caSaliguorifi 28755e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then 28765e9be92dSNicholas Bellinger echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 28775e9be92dSNicholas Bellingerfi 2878af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then 2879af3bba76SPaolo Bonzini echo "CONFIG_VHOST_NET=y" >> $config_host_mak 2880af3bba76SPaolo Bonzinifi 2881af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then 288256f41de7SPaolo Bonzini echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 288303ce5744SNikolay Nikolaevfi 2884108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then 2885108a6481SCindy Lu echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak 2886108a6481SCindy Lufi 2887042cea27SGongleiif test "$vhost_crypto" = "yes" ; then 2888042cea27SGonglei echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak 2889042cea27SGongleifi 2890fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then 2891fc0b9b0eSStefan Hajnoczi echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak 28925fe97d88SStefano Garzarella if test "$vhost_user" = "yes" ; then 28935fe97d88SStefano Garzarella echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak 28945fe97d88SStefano Garzarella fi 2895fc0b9b0eSStefan Hajnoczifi 2896299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then 2897299e6f19SPaolo Bonzini echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak 2898299e6f19SPaolo Bonzinifi 2899e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then 2900e6a74868SMarc-André Lureau echo "CONFIG_VHOST_USER=y" >> $config_host_mak 2901e6a74868SMarc-André Lureaufi 2902108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then 2903108a6481SCindy Lu echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak 2904108a6481SCindy Lufi 290598fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then 290698fc1adaSDr. David Alan Gilbert echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak 290798fc1adaSDr. David Alan Gilbertfi 2908e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then 2909e5b46549SRichard Henderson echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak 2910e5b46549SRichard Hendersonfi 291158d3f3ffSGerd Hoffmann 2912da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then 2913da076ffeSGerd Hoffmann echo "CONFIG_OPENGL=y" >> $config_host_mak 2914de2d3005SPaolo Bonzini echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak 2915da076ffeSGerd Hoffmann echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak 291620ff075bSMichael Wallefi 291720ff075bSMichael Walle 291883fb7adfSbellard# XXX: suppress that 29197d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 29202358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 29217d3505c5Sbellardfi 29227d3505c5Sbellard 29237c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 29247d992e4dSPeter Lieven 2925d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 2926d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 2927d83414e1SMarc-André Lureaufi 2928d83414e1SMarc-André Lureau 29290aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 29300aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 29310aebab04SLingfeng Yangfi 29320aebab04SLingfeng Yang 2933f540166bSRichard Hendersonif test "$int128" = "yes" ; then 2934f540166bSRichard Henderson echo "CONFIG_INT128=y" >> $config_host_mak 2935f540166bSRichard Hendersonfi 2936f540166bSRichard Henderson 29377ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then 29387ebee43eSRichard Henderson echo "CONFIG_ATOMIC128=y" >> $config_host_mak 29397ebee43eSRichard Hendersonfi 29407ebee43eSRichard Henderson 2941e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then 2942e6cd4bb5SRichard Henderson echo "CONFIG_CMPXCHG128=y" >> $config_host_mak 2943e6cd4bb5SRichard Hendersonfi 2944e6cd4bb5SRichard Henderson 29452da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then 29462da776dbSMichael R. Hines echo "CONFIG_RDMA=y" >> $config_host_mak 2947392fb643SFam Zheng echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak 29482da776dbSMichael R. Hinesfi 29492da776dbSMichael R. Hines 295021ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then 295121ab34c9SMarcel Apfelbaum echo "CONFIG_PVRDMA=y" >> $config_host_mak 295221ab34c9SMarcel Apfelbaumfi 295321ab34c9SMarcel Apfelbaum 295440e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 295540e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 295640e8c6f4SAlex Bennéefi 295740e8c6f4SAlex Bennée 2958f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 2959b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 2960d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 2961f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 2962f48e590aSAlex Bennée fi 2963b1863cccSAlex Bennéefi 2964f48e590aSAlex Bennée 296554e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then 296654e7aac0SAlexey Krasikov echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak 296754e7aac0SAlexey Krasikovfi 296854e7aac0SAlexey Krasikov 296998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 2970804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 2971c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 297239d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 2973a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 297409e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 2975804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 2976433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak 2977804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 2978cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 29795f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 29803dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 2981804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 2982804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 298346eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak 2984a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 298511cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 2986a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 2987a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 2988d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 29898a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 2990e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 2991a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 2992804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 2993804edf29SJuan Quintela 29946efd7517SPeter Maydell# use included Linux headers 29956efd7517SPeter Maydellif test "$linux" = "yes" ; then 2996a307beb6SAndreas Färber mkdir -p linux-headers 29976efd7517SPeter Maydell case "$cpu" in 29984da270beSPaolo Bonzini i386|x86_64) 299908312a63SPeter Maydell linux_arch=x86 30006efd7517SPeter Maydell ;; 3001d8ff892dSPaolo Bonzini ppc|ppc64) 300208312a63SPeter Maydell linux_arch=powerpc 30036efd7517SPeter Maydell ;; 30046efd7517SPeter Maydell s390x) 300508312a63SPeter Maydell linux_arch=s390 300608312a63SPeter Maydell ;; 30071f080313SClaudio Fontana aarch64) 30081f080313SClaudio Fontana linux_arch=arm64 30091f080313SClaudio Fontana ;; 3010dfcf900bSWANG Xuerui loongarch*) 3011dfcf900bSWANG Xuerui linux_arch=loongarch 3012dfcf900bSWANG Xuerui ;; 3013222e7d11SSanjay Lal mips64) 3014222e7d11SSanjay Lal linux_arch=mips 3015222e7d11SSanjay Lal ;; 301608312a63SPeter Maydell *) 301708312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 301808312a63SPeter Maydell linux_arch="$cpu" 30196efd7517SPeter Maydell ;; 30206efd7517SPeter Maydell esac 302108312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 302208312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 302308312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 302408312a63SPeter Maydell fi 30256efd7517SPeter Maydellfi 30266efd7517SPeter Maydell 302797a847bcSbellardfor target in $target_list; do 302897a847bcSbellard target_dir="$target" 302957a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 303097a847bcSbellard mkdir -p $target_dir 3031fdb75aefSPaolo Bonzini case $target in 3032fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 3033fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 30342408a527Saurel32 esac 303556aebc89Spbrookdone 30367d13299dSbellard 3037765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak 3038fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 3039fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 3040fdb75aefSPaolo Bonzinifi 3041a540f158SPeter Crosthwaite 3042fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 3043fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 3044fd0e6053SJohn Snowfi 3045fd0e6053SJohn Snow 30461e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 30471e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 30481e4f6065SDaniele Buonofi 30491e4f6065SDaniele Buono 3050e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 3051e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 3052e29e5c6eSPeter Maydell# (these can be both files and directories). 3053e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 3054e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 3055e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 3056e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 3057e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 3058e29e5c6eSPeter Maydell# directory and symlink the directory instead. 30592038f8c8SPaolo BonziniLINKS="Makefile" 30603941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 3061ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 3062e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 30638db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile" 3064e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp" 3065e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 3066bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 306739950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 30688f8fd9edSCleber RosaLINKS="$LINKS python" 3069c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 3070753d11f2SRichard Hendersonfor bios_file in \ 3071753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 30723a631b8eSBin Meng $source_path/pc-bios/*.elf \ 3073225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 3074753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 3075753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 3076e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 3077753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 30784e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 3079cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 3080cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 3081cd946e5cSJohn Arbuckle 3082753d11f2SRichard Hendersondo 3083e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 30847ea78b74SJan Kiszkadone 3085e29e5c6eSPeter Maydellfor f in $LINKS ; do 30860f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 30875dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 3088f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 3089f9245e10SPeter Maydell fi 30907d13299dSbellarddone 30911ad2134fSPaul Brook 30922038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 30932038f8c8SPaolo Bonzini export $i 30942038f8c8SPaolo Bonzinidone 3095fd0f79d7SRichard Hendersonexport target_list source_path use_containers cpu 30962038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 30972038f8c8SPaolo Bonzini 3098c34ebfdcSAnthony Liguori# temporary config to build submodules 3099bb7cb3adSPaolo Bonziniif test -f $source_path/roms/seabios/Makefile; then 31008db2a4fdSGerd Hoffmann for rom in seabios; do 3101c34ebfdcSAnthony Liguori config_mak=roms/$rom/config.mak 310237116c89SStefan Weil echo "# Automatically generated by configure - do not modify" > $config_mak 3103c34ebfdcSAnthony Liguori echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak 3104cdbd727cSRichard Henderson echo "AS=$as" >> $config_mak 31055f6f0e27SRichard Henderson echo "CCAS=$ccas" >> $config_mak 3106c34ebfdcSAnthony Liguori echo "CC=$cc" >> $config_mak 3107c34ebfdcSAnthony Liguori echo "BCC=bcc" >> $config_mak 31083dd46c78SBlue Swirl echo "CPP=$cpp" >> $config_mak 3109c34ebfdcSAnthony Liguori echo "OBJCOPY=objcopy" >> $config_mak 3110a31a8642SMichael S. Tsirkin echo "IASL=$iasl" >> $config_mak 3111c34ebfdcSAnthony Liguori echo "LD=$ld" >> $config_mak 31129f81aeb5SAlistair Francis echo "RANLIB=$ranlib" >> $config_mak 3113c34ebfdcSAnthony Liguori done 3114bb7cb3adSPaolo Bonzinifi 3115c34ebfdcSAnthony Liguori 311698409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 311798409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 311898409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 311998409991SHelge Konetzka 3120a5665051SPaolo Bonziniif test "$skip_meson" = no; then 3121fc929892SMarc-André Lureau cross="config-meson.cross.new" 3122fc929892SMarc-André Lureau meson_quote() { 3123ac7ebcc5SPaolo Bonzini test $# = 0 && return 312447b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 3125fc929892SMarc-André Lureau } 3126fc929892SMarc-André Lureau 3127fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 3128fc929892SMarc-André Lureau echo "[properties]" >> $cross 3129d1d5e9eeSAlex Bennée 3130d1d5e9eeSAlex Bennée # unroll any custom device configs 3131d1d5e9eeSAlex Bennée for a in $device_archs; do 3132d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 3133d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 3134d1d5e9eeSAlex Bennée done 3135d1d5e9eeSAlex Bennée 3136fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 313747b30835SPaolo Bonzini echo "[built-in options]" >> $cross 3138a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 3139a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 3140a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 3141a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 3142fc929892SMarc-André Lureau echo "[binaries]" >> $cross 31434dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 31444dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 31454dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 314647b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 314747b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 314847b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 314947b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 3150e8178514SPaolo Bonzini if has $sdl2_config; then 315147b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 3152e8178514SPaolo Bonzini fi 315347b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 315447b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 31553812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 3156fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 3157fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 3158ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 3159823eb013SPaolo Bonzini case "$cpu" in 3160f6bca9dfSJoelle van Dyne i386) 3161fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 3162fc929892SMarc-André Lureau ;; 3163fc929892SMarc-André Lureau *) 3164823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 3165fc929892SMarc-André Lureau ;; 3166fc929892SMarc-André Lureau esac 3167fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 3168fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 3169fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 3170fc929892SMarc-André Lureau else 3171fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 3172fc929892SMarc-André Lureau fi 3173fc929892SMarc-André Lureau else 3174fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 3175fc929892SMarc-André Lureau fi 3176fc929892SMarc-André Lureau mv $cross config-meson.cross 3177fc929892SMarc-André Lureau 3178a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 317961d63097SPaolo Bonzini run_meson() { 318009e93326SPaolo Bonzini NINJA=$ninja $meson setup \ 3181d17f305aSPaolo Bonzini --prefix "$prefix" \ 3182d17f305aSPaolo Bonzini --libdir "$libdir" \ 3183d17f305aSPaolo Bonzini --libexecdir "$libexecdir" \ 3184d17f305aSPaolo Bonzini --bindir "$bindir" \ 3185d17f305aSPaolo Bonzini --includedir "$includedir" \ 3186d17f305aSPaolo Bonzini --datadir "$datadir" \ 3187d17f305aSPaolo Bonzini --mandir "$mandir" \ 3188d17f305aSPaolo Bonzini --sysconfdir "$sysconfdir" \ 318916bf7a33SPaolo Bonzini --localedir "$localedir" \ 3190d17f305aSPaolo Bonzini --localstatedir "$local_statedir" \ 31913b4da132SPaolo Bonzini -Daudio_drv_list=$audio_drv_list \ 31923b4da132SPaolo Bonzini -Ddefault_devices=$default_devices \ 3193d17f305aSPaolo Bonzini -Ddocdir="$docdir" \ 31945dc4618eSPaolo Bonzini -Diasl="$($iasl -h >/dev/null 2>&1 && printf %s "$iasl")" \ 319516bf7a33SPaolo Bonzini -Dqemu_firmwarepath="$firmwarepath" \ 319673f3aa37SMarc-André Lureau -Dqemu_suffix="$qemu_suffix" \ 319735acbb30SPaolo Bonzini -Dsmbd="$smbd" \ 31983b4da132SPaolo Bonzini -Dsphinx_build="$sphinx_build" \ 31993b4da132SPaolo Bonzini -Dtrace_file="$trace_file" \ 3200a5665051SPaolo Bonzini -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ 3201a5665051SPaolo Bonzini -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ 3202a5665051SPaolo Bonzini -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ 3203da6d48b9SMarc-André Lureau -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ 3204bf0e56a3SMarc-André Lureau -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ 32053b4da132SPaolo Bonzini -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ 32063b4da132SPaolo Bonzini -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ 3207537b7248SPaolo Bonzini $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ 3208332008e0SThomas Huth $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ 320961d63097SPaolo Bonzini "$@" $cross_arg "$PWD" "$source_path" 321061d63097SPaolo Bonzini } 321161d63097SPaolo Bonzini eval run_meson $meson_options 3212a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 3213a5665051SPaolo Bonzini error_exit "meson setup failed" 3214a5665051SPaolo Bonzini fi 3215699d3884SPaolo Bonzinielse 3216699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 3217699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 3218699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 3219699d3884SPaolo Bonzini perl -i -ne ' 3220699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 3221699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 3222654d6b04SPaolo Bonzini /^b_staticpic/ && next; 3223699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 3224699d3884SPaolo Bonzini fi 3225a5665051SPaolo Bonzinifi 3226a5665051SPaolo Bonzini 3227dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 3228dc655404SMichael S. Tsirkincat <<EOD >config.status 3229dc655404SMichael S. Tsirkin#!/bin/sh 3230dc655404SMichael S. Tsirkin# Generated by configure. 3231dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 3232dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 3233dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 3234dc655404SMichael S. TsirkinEOD 3235e811da7fSDaniel P. Berrangé 3236e811da7fSDaniel P. Berrangépreserve_env() { 3237e811da7fSDaniel P. Berrangé envname=$1 3238e811da7fSDaniel P. Berrangé 3239e811da7fSDaniel P. Berrangé eval envval=\$$envname 3240e811da7fSDaniel P. Berrangé 3241e811da7fSDaniel P. Berrangé if test -n "$envval" 3242e811da7fSDaniel P. Berrangé then 3243e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 3244e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 3245e811da7fSDaniel P. Berrangé else 3246e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 3247e811da7fSDaniel P. Berrangé fi 3248e811da7fSDaniel P. Berrangé} 3249e811da7fSDaniel P. Berrangé 3250e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 3251e811da7fSDaniel P. Berrangé# features/build target configure will detect 3252e811da7fSDaniel P. Berrangépreserve_env AR 3253e811da7fSDaniel P. Berrangépreserve_env AS 3254e811da7fSDaniel P. Berrangépreserve_env CC 3255e811da7fSDaniel P. Berrangépreserve_env CPP 32568009da03SPaolo Bonzinipreserve_env CFLAGS 3257e811da7fSDaniel P. Berrangépreserve_env CXX 32588009da03SPaolo Bonzinipreserve_env CXXFLAGS 3259e811da7fSDaniel P. Berrangépreserve_env INSTALL 3260e811da7fSDaniel P. Berrangépreserve_env LD 32618009da03SPaolo Bonzinipreserve_env LDFLAGS 3262e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 3263e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 3264e811da7fSDaniel P. Berrangépreserve_env MAKE 3265e811da7fSDaniel P. Berrangépreserve_env NM 3266e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 3267e811da7fSDaniel P. Berrangépreserve_env PATH 3268e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 3269e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 3270e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 3271e811da7fSDaniel P. Berrangépreserve_env PYTHON 3272e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 3273e811da7fSDaniel P. Berrangépreserve_env SMBD 3274e811da7fSDaniel P. Berrangépreserve_env STRIP 3275e811da7fSDaniel P. Berrangépreserve_env WINDRES 3276e811da7fSDaniel P. Berrangé 3277dc655404SMichael S. Tsirkinprintf "exec" >>config.status 3278a5665051SPaolo Bonzinifor i in "$0" "$@"; do 3279835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 3280a5665051SPaolo Bonzinidone 3281cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 3282dc655404SMichael S. Tsirkinchmod +x config.status 3283dc655404SMichael S. Tsirkin 32848cd05ab6SPeter Maydellrm -r "$TMPDIR1" 3285