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="" 241e5f05f8cSKevin Wolfblock_drv_whitelist_tools="no" 242e49d021eSPeter Maydellhost_cc="cc" 243957f1f99SMichael Rothlibs_qga="" 2445bc62e01SGerd Hoffmanndebug_info="yes" 245cdad781dSDaniele Buonolto="false" 24663678e17SSteven Noonanstack_protector="" 2471e4f6065SDaniele Buonosafe_stack="" 248afc3a8f9SAlex Bennéeuse_containers="yes" 249f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 250ac0df51dSaliguori 25192712822SDaniel P. Berrangeif test -e "$source_path/.git" 25292712822SDaniel P. Berrangethen 2537d7dbf9dSDan Streetman git_submodules_action="update" 25492712822SDaniel P. Berrangeelse 2557d7dbf9dSDan Streetman git_submodules_action="ignore" 25692712822SDaniel P. Berrangefi 2572d652f24SPaolo Bonzini 2582d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb" 259cc84d63aSDaniel P. Berrangegit="git" 260ac0df51dSaliguori 261afb63ebdSStefan Weil# Don't accept a target_list environment variable. 262afb63ebdSStefan Weilunset target_list 263447e133fSAlex Bennéeunset target_list_exclude 264377529c0SPaolo Bonzini 265377529c0SPaolo Bonzini# Default value for a variable defining feature "foo". 266377529c0SPaolo Bonzini# * foo="no" feature will only be used if --enable-foo arg is given 267377529c0SPaolo Bonzini# * foo="" feature will be searched for, and if found, will be used 268377529c0SPaolo Bonzini# unless --disable-foo is given 269377529c0SPaolo Bonzini# * foo="yes" this value will only be set by --enable-foo flag. 270377529c0SPaolo Bonzini# feature will searched for, 271377529c0SPaolo Bonzini# if not found, configure exits with error 272377529c0SPaolo Bonzini# 273377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args. 274377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it 275377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found. 276377529c0SPaolo Bonzini 277c87ea116SAlex Bennéedefault_feature="" 278c87ea116SAlex Bennée# parse CC options second 279c87ea116SAlex Bennéefor opt do 280c87ea116SAlex Bennée optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 281c87ea116SAlex Bennée case "$opt" in 282c87ea116SAlex Bennée --without-default-features) 283c87ea116SAlex Bennée default_feature="no" 284c87ea116SAlex Bennée ;; 285c87ea116SAlex Bennée esac 286c87ea116SAlex Bennéedone 287c87ea116SAlex Bennée 288a2866660SPaolo BonziniEXTRA_CFLAGS="" 289a2866660SPaolo BonziniEXTRA_CXXFLAGS="" 290a2866660SPaolo BonziniEXTRA_LDFLAGS="" 291a2866660SPaolo Bonzini 292c87ea116SAlex Bennéexen_ctrl_version="$default_feature" 293c87ea116SAlex Bennéemembarrier="$default_feature" 2940848f8acSThomas Huthvhost_kernel="$default_feature" 295c87ea116SAlex Bennéevhost_net="$default_feature" 296c87ea116SAlex Bennéevhost_crypto="$default_feature" 297c87ea116SAlex Bennéevhost_scsi="$default_feature" 298c87ea116SAlex Bennéevhost_vsock="$default_feature" 299d88618f7SStefan Hajnoczivhost_user="no" 300c87ea116SAlex Bennéevhost_user_fs="$default_feature" 3010848f8acSThomas Huthvhost_vdpa="$default_feature" 302c87ea116SAlex Bennéerdma="$default_feature" 303c87ea116SAlex Bennéepvrdma="$default_feature" 304377529c0SPaolo Bonzinigprof="no" 305377529c0SPaolo Bonzinidebug_tcg="no" 306377529c0SPaolo Bonzinidebug="no" 307247724cbSMarc-André Lureausanitizers="no" 3080aebab04SLingfeng Yangtsan="no" 309c87ea116SAlex Bennéefortify_source="$default_feature" 3101d728c39SBlue Swirlgcov="no" 311c7328271SMiroslav RezaninaEXESUF="" 31217969268SFam Zhengmodules="no" 313bd83c861SChristian Ehrhardtmodule_upgrades="no" 314377529c0SPaolo Bonziniprefix="/usr/local" 31510ff82d1SMarc-André Lureauqemu_suffix="qemu" 316377529c0SPaolo Bonziniprofiler="no" 317377529c0SPaolo Bonzinisoftmmu="yes" 318b915a2f1SPaolo Bonzinilinux_user="" 319b915a2f1SPaolo Bonzinibsd_user="" 320377529c0SPaolo Bonzinipkgversion="" 32140d6444eSAvi Kivitypie="" 3223556c233SPaolo Bonziniqom_cast_debug="yes" 323baf86d6bSPaolo Bonzinitrace_backends="log" 324377529c0SPaolo Bonzinitrace_file="trace" 325c87ea116SAlex Bennéeopengl="$default_feature" 3265dd89908SRichard Hendersoncpuid_h="no" 327c87ea116SAlex Bennéeavx2_opt="$default_feature" 328c87ea116SAlex Bennéeguest_agent="$default_feature" 329c87ea116SAlex Bennéevss_win32_sdk="$default_feature" 330d9840e25STomoki Sekiyamawin_sdk="no" 331c87ea116SAlex Bennéewant_tools="$default_feature" 332519175a2SAlex Barcelocoroutine="" 333c87ea116SAlex Bennéecoroutine_pool="$default_feature" 3347d992e4dSPeter Lievendebug_stack_usage="no" 335f0d92b56SLongpeng(Mike)crypto_afalg="no" 336a1c5e949SDaniel P. Berrangetls_priority="NORMAL" 337c87ea116SAlex Bennéetpm="$default_feature" 338c87ea116SAlex Bennéelive_block_migration=${default_feature:-yes} 339c87ea116SAlex Bennéenuma="$default_feature" 340c87ea116SAlex Bennéereplication=${default_feature:-yes} 341c87ea116SAlex Bennéebochs=${default_feature:-yes} 342c87ea116SAlex Bennéecloop=${default_feature:-yes} 343c87ea116SAlex Bennéedmg=${default_feature:-yes} 344c87ea116SAlex Bennéeqcow1=${default_feature:-yes} 345c87ea116SAlex Bennéevdi=${default_feature:-yes} 346c87ea116SAlex Bennéevvfat=${default_feature:-yes} 347c87ea116SAlex Bennéeqed=${default_feature:-yes} 348c87ea116SAlex Bennéeparallels=${default_feature:-yes} 349ba59fb77SPaolo Bonzinidebug_mutex="no" 350ba4dd2aaSAlex Bennéeplugins="$default_feature" 351b767d257SMarek Marczykowski-Góreckirng_none="no" 352c87ea116SAlex Bennéesecret_keyring="$default_feature" 353a5665051SPaolo Bonzinimeson="" 3543b4da132SPaolo Bonzinimeson_args="" 35548328880SPaolo Bonzinininja="" 3563b4da132SPaolo Bonzinigio="$default_feature" 357a5665051SPaolo Bonziniskip_meson=no 358b8e0c493SJoelle van Dyneslirp_smbd="$default_feature" 359377529c0SPaolo Bonzini 3603b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 3613b4da132SPaolo Bonzini# are included in the automatically generated help message) 3623b4da132SPaolo Bonzini 3633b4da132SPaolo Bonzini# 1. Track which submodules are needed 3643b4da132SPaolo Bonzinicapstone="auto" 3653b4da132SPaolo Bonzinifdt="auto" 3663b4da132SPaolo Bonzinislirp="auto" 3673b4da132SPaolo Bonzini 3683b4da132SPaolo Bonzini# 2. Support --with/--without option 3693b4da132SPaolo Bonzinidefault_devices="true" 3703b4da132SPaolo Bonzini 3713b4da132SPaolo Bonzini# 3. Automatically enable/disable other options 3723b4da132SPaolo Bonzinitcg="enabled" 3733b4da132SPaolo Bonzinicfi="false" 3743b4da132SPaolo Bonzini 3753b4da132SPaolo Bonzini# 4. Detection partly done in configure 3763b4da132SPaolo Bonzinixen=${default_feature:+disabled} 377898be3e0SPeter Maydell 378c87ea116SAlex Bennée# parse CC options second 379ac0df51dSaliguorifor opt do 38089138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 381ac0df51dSaliguori case "$opt" in 382ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3833812c0c4SJoelle van Dyne cross_compile="yes" 384ac0df51dSaliguori ;; 3853d8df640SPaolo Bonzini --cc=*) CC="$optarg" 386ac0df51dSaliguori ;; 38783f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 38883f73fceSTomoki Sekiyama ;; 3892ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3902ff6b91eSJuan Quintela ;; 391a2866660SPaolo Bonzini --extra-cflags=*) 392a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 393a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 394e2a2ed06SJuan Quintela ;; 395a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 39611cde1c8SBruno Dominguez ;; 397a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 398e2a2ed06SJuan Quintela ;; 3995bc62e01SGerd Hoffmann --enable-debug-info) debug_info="yes" 4005bc62e01SGerd Hoffmann ;; 4015bc62e01SGerd Hoffmann --disable-debug-info) debug_info="no" 4025bc62e01SGerd Hoffmann ;; 403d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 404d75402b5SAlex Bennée ;; 405479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 406d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 4072038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 408d422b2bcSAlex Bennée ;; 409d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 4102038f8c8SPaolo Bonzini cc_archs="$cc_archs $cc_arch" 411d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 4122038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 413d75402b5SAlex Bennée ;; 414ac0df51dSaliguori esac 415ac0df51dSaliguoridone 416ac0df51dSaliguori# OS specific 417ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 41893148aa5SStefan Weil# we can eliminate its usage altogether. 419ac0df51dSaliguori 420e49d021eSPeter Maydell# Preferred compiler: 421e49d021eSPeter Maydell# ${CC} (if set) 422e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 423e49d021eSPeter Maydell# system compiler 424e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 425e49d021eSPeter Maydell cc="$host_cc" 426e49d021eSPeter Maydellelse 427b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 428e49d021eSPeter Maydellfi 429e49d021eSPeter Maydell 43083f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 43183f73fceSTomoki Sekiyama cxx="c++" 43283f73fceSTomoki Sekiyamaelse 43383f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 43483f73fceSTomoki Sekiyamafi 43583f73fceSTomoki Sekiyama 436b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 437cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 4385f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 4393dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 440b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 441b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 4429f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 4434852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 444b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 445b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 44617884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 44717884d7bSSergei Trofimovichquery_pkg_config() { 44817884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 44917884d7bSSergei Trofimovich} 45017884d7bSSergei Trofimovichpkg_config=query_pkg_config 45147c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 452ac0df51dSaliguori 453be17dc90SMichael S. Tsirkin# default flags for all hosts 4542d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 4552d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 4562d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 4572d31515bSPeter Maydell# provides these semantics.) 458de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 459086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 460c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 461be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4625770e8afSPaolo Bonzini 463de38c0ccSPaolo BonziniQEMU_LDFLAGS= 464de38c0ccSPaolo Bonzini 4655770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4668a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4675770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 468086d5f75SPaolo Bonzini 469be17dc90SMichael S. Tsirkin 470ac0df51dSaliguoricheck_define() { 471ac0df51dSaliguoricat > $TMPC <<EOF 472ac0df51dSaliguori#if !defined($1) 473fd786e1aSPeter Maydell#error $1 not defined 474ac0df51dSaliguori#endif 475ac0df51dSaliguoriint main(void) { return 0; } 476ac0df51dSaliguoriEOF 47752166aa0SJuan Quintela compile_object 478ac0df51dSaliguori} 479ac0df51dSaliguori 480307119e7SGerd Hoffmanncheck_include() { 481307119e7SGerd Hoffmanncat > $TMPC <<EOF 482307119e7SGerd Hoffmann#include <$1> 483307119e7SGerd Hoffmannint main(void) { return 0; } 484307119e7SGerd HoffmannEOF 485307119e7SGerd Hoffmann compile_object 486307119e7SGerd Hoffmann} 487307119e7SGerd Hoffmann 48893b25869SJohn Snowwrite_c_skeleton() { 48993b25869SJohn Snow cat > $TMPC <<EOF 49093b25869SJohn Snowint main(void) { return 0; } 49193b25869SJohn SnowEOF 49293b25869SJohn Snow} 49393b25869SJohn Snow 494bbea4050SPeter Maydellif check_define __linux__ ; then 495ba7c60c2SPaolo Bonzini targetos=linux 496bbea4050SPeter Maydellelif check_define _WIN32 ; then 497ba7c60c2SPaolo Bonzini targetos=windows 498bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 499ba7c60c2SPaolo Bonzini targetos=openbsd 500bbea4050SPeter Maydellelif check_define __sun__ ; then 501ba7c60c2SPaolo Bonzini targetos=sunos 502bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 503ba7c60c2SPaolo Bonzini targetos=haiku 504951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 505ba7c60c2SPaolo Bonzini targetos=freebsd 506951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 507ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 508951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 509ba7c60c2SPaolo Bonzini targetos=dragonfly 510951fedfcSPeter Maydellelif check_define __NetBSD__; then 511ba7c60c2SPaolo Bonzini targetos=netbsd 512951fedfcSPeter Maydellelif check_define __APPLE__; then 513ba7c60c2SPaolo Bonzini targetos=darwin 514bbea4050SPeter Maydellelse 515951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 516951fedfcSPeter Maydell # might be going to just print the --help text, or it might 517951fedfcSPeter Maydell # be the result of a missing compiler. 518ba7c60c2SPaolo Bonzini targetos=bogus 519bbea4050SPeter Maydellfi 520bbea4050SPeter Maydell 52165eff01bSPaolo Bonzini# OS specific 52265eff01bSPaolo Bonzini 5233b0d8643SPaolo Bonzinimingw32="no" 5243b0d8643SPaolo Bonzinibsd="no" 5253b0d8643SPaolo Bonzinilinux="no" 5263b0d8643SPaolo Bonzinisolaris="no" 52765eff01bSPaolo Bonzinicase $targetos in 52865eff01bSPaolo Bonziniwindows) 52965eff01bSPaolo Bonzini mingw32="yes" 53065eff01bSPaolo Bonzini plugins="no" 53165eff01bSPaolo Bonzini pie="no" 53265eff01bSPaolo Bonzini;; 53365eff01bSPaolo Bonzinignu/kfreebsd) 53465eff01bSPaolo Bonzini bsd="yes" 53565eff01bSPaolo Bonzini;; 53665eff01bSPaolo Bonzinifreebsd) 53765eff01bSPaolo Bonzini bsd="yes" 53865eff01bSPaolo Bonzini make="${MAKE-gmake}" 53965eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 54065eff01bSPaolo Bonzini;; 54165eff01bSPaolo Bonzinidragonfly) 54265eff01bSPaolo Bonzini bsd="yes" 54365eff01bSPaolo Bonzini make="${MAKE-gmake}" 54465eff01bSPaolo Bonzini;; 54565eff01bSPaolo Bonzininetbsd) 54665eff01bSPaolo Bonzini bsd="yes" 54765eff01bSPaolo Bonzini make="${MAKE-gmake}" 54865eff01bSPaolo Bonzini;; 54965eff01bSPaolo Bonziniopenbsd) 55065eff01bSPaolo Bonzini bsd="yes" 55165eff01bSPaolo Bonzini make="${MAKE-gmake}" 55265eff01bSPaolo Bonzini;; 55365eff01bSPaolo Bonzinidarwin) 55465eff01bSPaolo Bonzini bsd="yes" 55565eff01bSPaolo Bonzini darwin="yes" 55665eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 55765eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 55865eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 55965eff01bSPaolo Bonzini;; 56065eff01bSPaolo Bonzinisunos) 56165eff01bSPaolo Bonzini solaris="yes" 56265eff01bSPaolo Bonzini make="${MAKE-gmake}" 56365eff01bSPaolo Bonzini smbd="${SMBD-/usr/sfw/sbin/smbd}" 56465eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 56565eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 56665eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 56765eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 56865eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 56965eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 570bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 571bbea4050SPeter Maydell # the correct CPU with the --cpu option. 572bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 573bbea4050SPeter Maydell cpu="x86_64" 574bbea4050SPeter Maydell fi 57565eff01bSPaolo Bonzini;; 57665eff01bSPaolo Bonzinihaiku) 57765eff01bSPaolo Bonzini pie="no" 57865eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 57965eff01bSPaolo Bonzini;; 58065eff01bSPaolo Bonzinilinux) 58165eff01bSPaolo Bonzini linux="yes" 58265eff01bSPaolo Bonzini vhost_user=${default_feature:-yes} 58365eff01bSPaolo Bonzini;; 584bbea4050SPeter Maydellesac 585bbea4050SPeter Maydell 5862ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5872ff6b91eSJuan Quintela # command line argument 5882ff6b91eSJuan Quintela : 5892ff6b91eSJuan Quintelaelif check_define __i386__ ; then 590ac0df51dSaliguori cpu="i386" 591ac0df51dSaliguorielif check_define __x86_64__ ; then 592c72b26ecSRichard Henderson if check_define __ILP32__ ; then 593c72b26ecSRichard Henderson cpu="x32" 594c72b26ecSRichard Henderson else 595ac0df51dSaliguori cpu="x86_64" 596c72b26ecSRichard Henderson fi 5973aa9bd6cSblueswir1elif check_define __sparc__ ; then 5983aa9bd6cSblueswir1 if check_define __arch64__ ; then 5993aa9bd6cSblueswir1 cpu="sparc64" 6003aa9bd6cSblueswir1 else 6013aa9bd6cSblueswir1 cpu="sparc" 6023aa9bd6cSblueswir1 fi 603fdf7ed96Smalcelif check_define _ARCH_PPC ; then 604fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 605f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 606f8378accSRichard Henderson cpu="ppc64le" 607f8378accSRichard Henderson else 608fdf7ed96Smalc cpu="ppc64" 609f8378accSRichard Henderson fi 610ac0df51dSaliguori else 611fdf7ed96Smalc cpu="ppc" 612fdf7ed96Smalc fi 613afa05235SAurelien Jarnoelif check_define __mips__ ; then 614afa05235SAurelien Jarno cpu="mips" 615d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 616d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 617d66ed0eaSAurelien Jarno cpu="s390x" 618d66ed0eaSAurelien Jarno else 619d66ed0eaSAurelien Jarno cpu="s390" 620d66ed0eaSAurelien Jarno fi 621c4f80543SAlistair Franciselif check_define __riscv ; then 622ba0e7333SRichard Henderson cpu="riscv" 62321d89f84SPeter Maydellelif check_define __arm__ ; then 62421d89f84SPeter Maydell cpu="arm" 6251f080313SClaudio Fontanaelif check_define __aarch64__ ; then 6261f080313SClaudio Fontana cpu="aarch64" 627dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 628dfcf900bSWANG Xuerui cpu="loongarch64" 629fdf7ed96Smalcelse 63089138857SStefan Weil cpu=$(uname -m) 631ac0df51dSaliguorifi 632ac0df51dSaliguori 633823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 634359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 6357d13299dSbellardcase "$cpu" in 636e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 637e4da0e39SPaolo Bonzini cpu="arm" ;; 638e4da0e39SPaolo Bonzini 6397d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 64097a847bcSbellard cpu="i386" 641e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 642e4da0e39SPaolo Bonzini x32) 6434da270beSPaolo Bonzini cpu="x86_64" 644e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 645aaa5fa14Saurel32 x86_64|amd64) 646aaa5fa14Saurel32 cpu="x86_64" 647e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 648e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 649e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 650e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 651e4da0e39SPaolo Bonzini 652afa05235SAurelien Jarno mips*) 653e4da0e39SPaolo Bonzini cpu="mips" ;; 654e4da0e39SPaolo Bonzini 655e4da0e39SPaolo Bonzini ppc) 656e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 657e4da0e39SPaolo Bonzini ppc64) 658d8ff892dSPaolo Bonzini CPU_CFLAGS="-m64 -mbig" ;; 659e4da0e39SPaolo Bonzini ppc64le) 660d8ff892dSPaolo Bonzini cpu="ppc64" 661d8ff892dSPaolo Bonzini CPU_CFLAGS="-m64 -mlittle" ;; 662e4da0e39SPaolo Bonzini 663e4da0e39SPaolo Bonzini s390) 664823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 665e4da0e39SPaolo Bonzini s390x) 666e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 667e4da0e39SPaolo Bonzini 6683142255cSblueswir1 sparc|sun4[cdmuv]) 669ae228531Sbellard cpu="sparc" 670e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 671e4da0e39SPaolo Bonzini sparc64) 672e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6737d13299dSbellardesac 674e2d52ad3SJuan Quintela 6750db4a067SPaolo Bonzini: ${make=${MAKE-make}} 676b6daf4d3SPaolo Bonzini 677faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 678faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 679ddf90699SEduardo Habkost# we check that too 680faf44142SDaniel P. Berrangépython= 6810a01d76fSMarc-André Lureauexplicit_python=no 682ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 683faf44142SDaniel P. Berrangédo 684faf44142SDaniel P. Berrangé if has "$binary" 685faf44142SDaniel P. Berrangé then 68695c5f2deSPaolo Bonzini python=$(command -v "$binary") 687faf44142SDaniel P. Berrangé break 688faf44142SDaniel P. Berrangé fi 689faf44142SDaniel P. Berrangédone 690903458c8SMarkus Armbruster 691903458c8SMarkus Armbruster 69239d87c8cSAlex Bennée# Check for ancillary tools used in testing 69339d87c8cSAlex Bennéegenisoimage= 6943df437c7SAlex Bennéefor binary in genisoimage mkisofs 69539d87c8cSAlex Bennéedo 69639d87c8cSAlex Bennée if has $binary 69739d87c8cSAlex Bennée then 69839d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 69939d87c8cSAlex Bennée break 70039d87c8cSAlex Bennée fi 70139d87c8cSAlex Bennéedone 70239d87c8cSAlex Bennée 7033c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 7043c4a4d0dSPeter Maydellif has clang; then 7053c4a4d0dSPeter Maydell objcc=clang 7063c4a4d0dSPeter Maydellelse 7073c4a4d0dSPeter Maydell objcc="$cc" 7083c4a4d0dSPeter Maydellfi 7093c4a4d0dSPeter Maydell 7103457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 7113457a3f8SJuan Quintela EXESUF=".exe" 71278e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 7135770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 71493b25869SJohn Snow write_c_skeleton; 715d17f305aSPaolo Bonzini prefix="/qemu" 71677433a5fSMarc-André Lureau qemu_suffix="" 717105fad6bSBishara AbuHattoum libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga" 7183457a3f8SJuan Quintelafi 7193457a3f8SJuan Quintela 720487fefdbSAnthony Liguoriwerror="" 72185aa5189Sbellard 72261d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 72361d63097SPaolo Bonzini 72461d63097SPaolo Bonzinimeson_options= 72561d63097SPaolo Bonzinimeson_option_parse() { 72661d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 72761d63097SPaolo Bonzini if test $? -eq 1; then 72861d63097SPaolo Bonzini echo "ERROR: unknown option $1" 72961d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 73061d63097SPaolo Bonzini exit 1 73161d63097SPaolo Bonzini fi 73261d63097SPaolo Bonzini} 73361d63097SPaolo Bonzini 7347d13299dSbellardfor opt do 73589138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 7367d13299dSbellard case "$opt" in 7372efc3265Sbellard --help|-h) show_help=yes 7382efc3265Sbellard ;; 73999123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 74099123e13SMike Frysinger ;; 741b1a550a0Spbrook --prefix=*) prefix="$optarg" 7427d13299dSbellard ;; 743b1a550a0Spbrook --interp-prefix=*) interp_prefix="$optarg" 74432ce6337Sbellard ;; 745ac0df51dSaliguori --cross-prefix=*) 7467d13299dSbellard ;; 747ac0df51dSaliguori --cc=*) 7487d13299dSbellard ;; 749b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 75083469015Sbellard ;; 75183f73fceSTomoki Sekiyama --cxx=*) 75283f73fceSTomoki Sekiyama ;; 753e007dbecSMichael S. Tsirkin --iasl=*) iasl="$optarg" 754e007dbecSMichael S. Tsirkin ;; 7553c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 7563c4a4d0dSPeter Maydell ;; 757b1a550a0Spbrook --make=*) make="$optarg" 7587d13299dSbellard ;; 759b6daf4d3SPaolo Bonzini --install=*) 7606a882643Spbrook ;; 7610a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 762c886edfbSBlue Swirl ;; 7632eb054c2SPeter Maydell --sphinx-build=*) sphinx_build="$optarg" 7642eb054c2SPeter Maydell ;; 765a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 766a5665051SPaolo Bonzini ;; 767a5665051SPaolo Bonzini --meson=*) meson="$optarg" 768a5665051SPaolo Bonzini ;; 76948328880SPaolo Bonzini --ninja=*) ninja="$optarg" 77048328880SPaolo Bonzini ;; 771e2d8830eSBrad --smbd=*) smbd="$optarg" 772e2d8830eSBrad ;; 773e2a2ed06SJuan Quintela --extra-cflags=*) 7747d13299dSbellard ;; 77511cde1c8SBruno Dominguez --extra-cxxflags=*) 77611cde1c8SBruno Dominguez ;; 777e2a2ed06SJuan Quintela --extra-ldflags=*) 7787d13299dSbellard ;; 7795bc62e01SGerd Hoffmann --enable-debug-info) 7805bc62e01SGerd Hoffmann ;; 7815bc62e01SGerd Hoffmann --disable-debug-info) 7825bc62e01SGerd Hoffmann ;; 783d75402b5SAlex Bennée --cross-cc-*) 784d75402b5SAlex Bennée ;; 78517969268SFam Zheng --enable-modules) 78617969268SFam Zheng modules="yes" 78717969268SFam Zheng ;; 7883aa88b31SStefan Hajnoczi --disable-modules) 7893aa88b31SStefan Hajnoczi modules="no" 7903aa88b31SStefan Hajnoczi ;; 791bd83c861SChristian Ehrhardt --disable-module-upgrades) module_upgrades="no" 792bd83c861SChristian Ehrhardt ;; 793bd83c861SChristian Ehrhardt --enable-module-upgrades) module_upgrades="yes" 794bd83c861SChristian Ehrhardt ;; 7952ff6b91eSJuan Quintela --cpu=*) 7967d13299dSbellard ;; 797b1a550a0Spbrook --target-list=*) target_list="$optarg" 798447e133fSAlex Bennée if test "$target_list_exclude"; then 799447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 800447e133fSAlex Bennée fi 801447e133fSAlex Bennée ;; 802447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 803447e133fSAlex Bennée if test "$target_list"; then 804447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 805447e133fSAlex Bennée fi 806de83cd02Sbellard ;; 80774242e0fSPaolo Bonzini --with-trace-file=*) trace_file="$optarg" 8089410b56cSPrerna Saxena ;; 8097bc3ca7fSPaolo Bonzini --with-default-devices) default_devices="true" 810f3494749SPaolo Bonzini ;; 8117bc3ca7fSPaolo Bonzini --without-default-devices) default_devices="false" 812f3494749SPaolo Bonzini ;; 813d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 814d1d5e9eeSAlex Bennée ;; 815d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 816d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 817d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 818d1d5e9eeSAlex Bennée if test -f "$cf"; then 819d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 820d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 821d1d5e9eeSAlex Bennée else 822d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 823d1d5e9eeSAlex Bennée fi 824d1d5e9eeSAlex Bennée ;; 825c87ea116SAlex Bennée --without-default-features) # processed above 826c87ea116SAlex Bennée ;; 8277d13299dSbellard --enable-gprof) gprof="yes" 8287d13299dSbellard ;; 8291d728c39SBlue Swirl --enable-gcov) gcov="yes" 8301d728c39SBlue Swirl ;; 83179427693SLoïc Minier --static) 83279427693SLoïc Minier static="yes" 83317884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 83443ce4dfeSbellard ;; 8350b24e75fSPaolo Bonzini --mandir=*) mandir="$optarg" 8360b24e75fSPaolo Bonzini ;; 8370b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 8380b24e75fSPaolo Bonzini ;; 8393aa5d2beSAlon Levy --libdir=*) libdir="$optarg" 8403aa5d2beSAlon Levy ;; 8418bf188aaSMichael Tokarev --libexecdir=*) libexecdir="$optarg" 8428bf188aaSMichael Tokarev ;; 8430f94d6daSAlon Levy --includedir=*) includedir="$optarg" 8440f94d6daSAlon Levy ;; 845528ae5b8SEduardo Habkost --datadir=*) datadir="$optarg" 8460b24e75fSPaolo Bonzini ;; 84777433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 848023d3d67SEduardo Habkost ;; 849c6502638SBruce Rogers --docdir=*) docdir="$optarg" 8500b24e75fSPaolo Bonzini ;; 851fe0038beSPaolo Bonzini --localedir=*) localedir="$optarg" 852fe0038beSPaolo Bonzini ;; 853ca2fb938SAndre Przywara --sysconfdir=*) sysconfdir="$optarg" 85407381cc1SAnthony Liguori ;; 855785c23aeSLuiz Capitulino --localstatedir=*) local_statedir="$optarg" 856785c23aeSLuiz Capitulino ;; 8573d5eecabSGerd Hoffmann --firmwarepath=*) firmwarepath="$optarg" 8583d5eecabSGerd Hoffmann ;; 859181ce1d0SOlaf Hering --host=*|--build=*|\ 860181ce1d0SOlaf Hering --disable-dependency-tracking|\ 861785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 862fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 863023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 864023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 865023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 866023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 867023ddd74SMax Filippov # lots of directory switches by default. 868023ddd74SMax Filippov ;; 8693556c233SPaolo Bonzini --disable-qom-cast-debug) qom_cast_debug="no" 8703556c233SPaolo Bonzini ;; 8713556c233SPaolo Bonzini --enable-qom-cast-debug) qom_cast_debug="yes" 8723556c233SPaolo Bonzini ;; 8730c58ac1cSmalc --audio-drv-list=*) audio_drv_list="$optarg" 8740c58ac1cSmalc ;; 87589138857SStefan Weil --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 876b64ec4e4SFam Zheng ;; 87789138857SStefan Weil --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 878eb852011SMarkus Armbruster ;; 879e5f05f8cSKevin Wolf --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes" 880e5f05f8cSKevin Wolf ;; 881e5f05f8cSKevin Wolf --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no" 882e5f05f8cSKevin Wolf ;; 883f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 884f8393946Saurel32 ;; 885f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 886f8393946Saurel32 ;; 887f3d08ee6SPaul Brook --enable-debug) 888f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 889f3d08ee6SPaul Brook debug_tcg="yes" 8901fcc6d42SPeter Xu debug_mutex="yes" 891f3d08ee6SPaul Brook debug="yes" 892b553a042SJohn Snow fortify_source="no" 893f3d08ee6SPaul Brook ;; 894247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 895247724cbSMarc-André Lureau ;; 896247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 897247724cbSMarc-André Lureau ;; 8980aebab04SLingfeng Yang --enable-tsan) tsan="yes" 8990aebab04SLingfeng Yang ;; 9000aebab04SLingfeng Yang --disable-tsan) tsan="no" 9010aebab04SLingfeng Yang ;; 9024d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 903c20709aaSbellard ;; 904fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 905fd6fc214SPaolo Bonzini ;; 9064d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 9077c57bdd8SMarc-André Lureau ;; 90803a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 909675b9b53SMarc-André Lureau ;; 9101badb709SPaolo Bonzini --disable-xen) xen="disabled" 911e37630caSaliguori ;; 9121badb709SPaolo Bonzini --enable-xen) xen="enabled" 913fc321b4bSJuan Quintela ;; 9141badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 915d1a14257SAlex Bennée plugins="no" 916b3f6ea7eSPaolo Bonzini ;; 9171badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 918b3f6ea7eSPaolo Bonzini ;; 91905c2a3e7Sbellard --enable-profiler) profiler="yes" 92005c2a3e7Sbellard ;; 921cad25d69Spbrook --disable-system) softmmu="no" 9220a8e90f4Spbrook ;; 923cad25d69Spbrook --enable-system) softmmu="yes" 9240a8e90f4Spbrook ;; 9250953a80fSZachary Amsden --disable-user) 9260953a80fSZachary Amsden linux_user="no" ; 9270953a80fSZachary Amsden bsd_user="no" ; 9280953a80fSZachary Amsden ;; 9290953a80fSZachary Amsden --enable-user) ;; 930831b7825Sths --disable-linux-user) linux_user="no" 9310a8e90f4Spbrook ;; 932831b7825Sths --enable-linux-user) linux_user="yes" 933831b7825Sths ;; 93484778508Sblueswir1 --disable-bsd-user) bsd_user="no" 93584778508Sblueswir1 ;; 93684778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 93784778508Sblueswir1 ;; 93840d6444eSAvi Kivity --enable-pie) pie="yes" 93934005a00SKirill A. Shutemov ;; 94040d6444eSAvi Kivity --disable-pie) pie="no" 94134005a00SKirill A. Shutemov ;; 94285aa5189Sbellard --enable-werror) werror="yes" 94385aa5189Sbellard ;; 94485aa5189Sbellard --disable-werror) werror="no" 94585aa5189Sbellard ;; 946cdad781dSDaniele Buono --enable-lto) lto="true" 947cdad781dSDaniele Buono ;; 948cdad781dSDaniele Buono --disable-lto) lto="false" 949cdad781dSDaniele Buono ;; 95063678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 95163678e17SSteven Noonan ;; 95263678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 95363678e17SSteven Noonan ;; 9541e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 9551e4f6065SDaniele Buono ;; 9561e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 9571e4f6065SDaniele Buono ;; 9589e62ba48SDaniele Buono --enable-cfi) 9599e62ba48SDaniele Buono cfi="true"; 9609e62ba48SDaniele Buono lto="true"; 9619e62ba48SDaniele Buono ;; 9629e62ba48SDaniele Buono --disable-cfi) cfi="false" 9639e62ba48SDaniele Buono ;; 964fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 9652df87df7SJuan Quintela ;; 966fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 967fbb4121dSPaolo Bonzini ;; 968fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 969fbb4121dSPaolo Bonzini ;; 97003a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 9712df87df7SJuan Quintela ;; 972a40161cbSPaolo Bonzini --disable-membarrier) membarrier="no" 973a40161cbSPaolo Bonzini ;; 974a40161cbSPaolo Bonzini --enable-membarrier) membarrier="yes" 975a40161cbSPaolo Bonzini ;; 9767e563bfbSThomas Huth --with-pkgversion=*) pkgversion="$optarg" 9774a19f1ecSpbrook ;; 978519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 979519175a2SAlex Barcelo ;; 98070c60c08SStefan Hajnoczi --disable-coroutine-pool) coroutine_pool="no" 98170c60c08SStefan Hajnoczi ;; 98270c60c08SStefan Hajnoczi --enable-coroutine-pool) coroutine_pool="yes" 98370c60c08SStefan Hajnoczi ;; 9847d992e4dSPeter Lieven --enable-debug-stack-usage) debug_stack_usage="yes" 9857d992e4dSPeter Lieven ;; 986f0d92b56SLongpeng(Mike) --enable-crypto-afalg) crypto_afalg="yes" 987f0d92b56SLongpeng(Mike) ;; 988f0d92b56SLongpeng(Mike) --disable-crypto-afalg) crypto_afalg="no" 989f0d92b56SLongpeng(Mike) ;; 990d5970055SMichael S. Tsirkin --disable-vhost-net) vhost_net="no" 991d5970055SMichael S. Tsirkin ;; 992d5970055SMichael S. Tsirkin --enable-vhost-net) vhost_net="yes" 993d5970055SMichael S. Tsirkin ;; 994042cea27SGonglei --disable-vhost-crypto) vhost_crypto="no" 995042cea27SGonglei ;; 996299e6f19SPaolo Bonzini --enable-vhost-crypto) vhost_crypto="yes" 997042cea27SGonglei ;; 9985e9be92dSNicholas Bellinger --disable-vhost-scsi) vhost_scsi="no" 9995e9be92dSNicholas Bellinger ;; 10005e9be92dSNicholas Bellinger --enable-vhost-scsi) vhost_scsi="yes" 10015e9be92dSNicholas Bellinger ;; 1002fc0b9b0eSStefan Hajnoczi --disable-vhost-vsock) vhost_vsock="no" 1003fc0b9b0eSStefan Hajnoczi ;; 1004fc0b9b0eSStefan Hajnoczi --enable-vhost-vsock) vhost_vsock="yes" 1005fc0b9b0eSStefan Hajnoczi ;; 100698fc1adaSDr. David Alan Gilbert --disable-vhost-user-fs) vhost_user_fs="no" 100798fc1adaSDr. David Alan Gilbert ;; 100898fc1adaSDr. David Alan Gilbert --enable-vhost-user-fs) vhost_user_fs="yes" 100998fc1adaSDr. David Alan Gilbert ;; 1010da076ffeSGerd Hoffmann --disable-opengl) opengl="no" 101120ff075bSMichael Walle ;; 1012da076ffeSGerd Hoffmann --enable-opengl) opengl="yes" 101320ff075bSMichael Walle ;; 10141ffb3bbbSPaolo Bonzini --disable-zlib-test) 10151ece9905SAlon Levy ;; 1016d138cee9SMichael Roth --enable-guest-agent) guest_agent="yes" 1017d138cee9SMichael Roth ;; 1018d138cee9SMichael Roth --disable-guest-agent) guest_agent="no" 1019d138cee9SMichael Roth ;; 1020d9840e25STomoki Sekiyama --with-vss-sdk) vss_win32_sdk="" 1021d9840e25STomoki Sekiyama ;; 1022d9840e25STomoki Sekiyama --with-vss-sdk=*) vss_win32_sdk="$optarg" 1023d9840e25STomoki Sekiyama ;; 1024d9840e25STomoki Sekiyama --without-vss-sdk) vss_win32_sdk="no" 1025d9840e25STomoki Sekiyama ;; 1026d9840e25STomoki Sekiyama --with-win-sdk) win_sdk="" 1027d9840e25STomoki Sekiyama ;; 1028d9840e25STomoki Sekiyama --with-win-sdk=*) win_sdk="$optarg" 1029d9840e25STomoki Sekiyama ;; 1030d9840e25STomoki Sekiyama --without-win-sdk) win_sdk="no" 1031d9840e25STomoki Sekiyama ;; 10324b1c11fdSDaniel P. Berrange --enable-tools) want_tools="yes" 10334b1c11fdSDaniel P. Berrange ;; 10344b1c11fdSDaniel P. Berrange --disable-tools) want_tools="no" 10354b1c11fdSDaniel P. Berrange ;; 103686583a07SLiam Merwick --disable-avx2) avx2_opt="no" 103786583a07SLiam Merwick ;; 103886583a07SLiam Merwick --enable-avx2) avx2_opt="yes" 103986583a07SLiam Merwick ;; 10406b8cd447SRobert Hoo --disable-avx512f) avx512f_opt="no" 10416b8cd447SRobert Hoo ;; 10426b8cd447SRobert Hoo --enable-avx512f) avx512f_opt="yes" 10436b8cd447SRobert Hoo ;; 104452b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 104552b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 1046583f6e7bSStefan Hajnoczi ;; 1047cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 1048cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 1049cb6414dfSFam Zheng ;; 1050315d3184SFam Zheng --enable-uuid|--disable-uuid) 1051315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 1052315d3184SFam Zheng ;; 1053a1c5e949SDaniel P. Berrange --tls-priority=*) tls_priority="$optarg" 1054a1c5e949SDaniel P. Berrange ;; 10552da776dbSMichael R. Hines --enable-rdma) rdma="yes" 10562da776dbSMichael R. Hines ;; 10572da776dbSMichael R. Hines --disable-rdma) rdma="no" 10582da776dbSMichael R. Hines ;; 105921ab34c9SMarcel Apfelbaum --enable-pvrdma) pvrdma="yes" 106021ab34c9SMarcel Apfelbaum ;; 106121ab34c9SMarcel Apfelbaum --disable-pvrdma) pvrdma="no" 106221ab34c9SMarcel Apfelbaum ;; 1063e91c793cSCole Robinson --disable-tpm) tpm="no" 1064e91c793cSCole Robinson ;; 1065ab214c29SStefan Berger --enable-tpm) tpm="yes" 1066ab214c29SStefan Berger ;; 1067ed1701c6SDr. David Alan Gilbert --disable-live-block-migration) live_block_migration="no" 1068ed1701c6SDr. David Alan Gilbert ;; 1069ed1701c6SDr. David Alan Gilbert --enable-live-block-migration) live_block_migration="yes" 1070ed1701c6SDr. David Alan Gilbert ;; 1071a99d57bbSWanlong Gao --disable-numa) numa="no" 1072a99d57bbSWanlong Gao ;; 1073a99d57bbSWanlong Gao --enable-numa) numa="yes" 1074a99d57bbSWanlong Gao ;; 1075a6b1d4c0SChanglong Xie --disable-replication) replication="no" 1076a6b1d4c0SChanglong Xie ;; 1077a6b1d4c0SChanglong Xie --enable-replication) replication="yes" 1078a6b1d4c0SChanglong Xie ;; 10792f740136SJeff Cody --disable-bochs) bochs="no" 10802f740136SJeff Cody ;; 10812f740136SJeff Cody --enable-bochs) bochs="yes" 10822f740136SJeff Cody ;; 10832f740136SJeff Cody --disable-cloop) cloop="no" 10842f740136SJeff Cody ;; 10852f740136SJeff Cody --enable-cloop) cloop="yes" 10862f740136SJeff Cody ;; 10872f740136SJeff Cody --disable-dmg) dmg="no" 10882f740136SJeff Cody ;; 10892f740136SJeff Cody --enable-dmg) dmg="yes" 10902f740136SJeff Cody ;; 10912f740136SJeff Cody --disable-qcow1) qcow1="no" 10922f740136SJeff Cody ;; 10932f740136SJeff Cody --enable-qcow1) qcow1="yes" 10942f740136SJeff Cody ;; 10952f740136SJeff Cody --disable-vdi) vdi="no" 10962f740136SJeff Cody ;; 10972f740136SJeff Cody --enable-vdi) vdi="yes" 10982f740136SJeff Cody ;; 10992f740136SJeff Cody --disable-vvfat) vvfat="no" 11002f740136SJeff Cody ;; 11012f740136SJeff Cody --enable-vvfat) vvfat="yes" 11022f740136SJeff Cody ;; 11032f740136SJeff Cody --disable-qed) qed="no" 11042f740136SJeff Cody ;; 11052f740136SJeff Cody --enable-qed) qed="yes" 11062f740136SJeff Cody ;; 11072f740136SJeff Cody --disable-parallels) parallels="no" 11082f740136SJeff Cody ;; 11092f740136SJeff Cody --enable-parallels) parallels="yes" 11102f740136SJeff Cody ;; 1111e6a74868SMarc-André Lureau --disable-vhost-user) vhost_user="no" 1112e6a74868SMarc-André Lureau ;; 1113299e6f19SPaolo Bonzini --enable-vhost-user) vhost_user="yes" 1114299e6f19SPaolo Bonzini ;; 1115108a6481SCindy Lu --disable-vhost-vdpa) vhost_vdpa="no" 1116108a6481SCindy Lu ;; 1117108a6481SCindy Lu --enable-vhost-vdpa) vhost_vdpa="yes" 1118108a6481SCindy Lu ;; 1119299e6f19SPaolo Bonzini --disable-vhost-kernel) vhost_kernel="no" 1120299e6f19SPaolo Bonzini ;; 1121299e6f19SPaolo Bonzini --enable-vhost-kernel) vhost_kernel="yes" 1122e6a74868SMarc-André Lureau ;; 11238b18cdbfSRichard Henderson --disable-capstone) capstone="disabled" 11248ca80760SRichard Henderson ;; 11258b18cdbfSRichard Henderson --enable-capstone) capstone="enabled" 11268ca80760SRichard Henderson ;; 11278b18cdbfSRichard Henderson --enable-capstone=git) capstone="internal" 1128e219c499SRichard Henderson ;; 112903a3c0b3SPaolo Bonzini --enable-capstone=*) capstone="$optarg" 1130e219c499SRichard Henderson ;; 1131cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 1132cc84d63aSDaniel P. Berrange ;; 11337d7dbf9dSDan Streetman --with-git-submodules=*) 11347d7dbf9dSDan Streetman git_submodules_action="$optarg" 1135f62bbee5SDaniel P. Berrange ;; 1136ba59fb77SPaolo Bonzini --enable-debug-mutex) debug_mutex=yes 1137ba59fb77SPaolo Bonzini ;; 1138ba59fb77SPaolo Bonzini --disable-debug-mutex) debug_mutex=no 1139ba59fb77SPaolo Bonzini ;; 11409b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 11419b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 11429b8e4298SAlex Bennée else 11439b8e4298SAlex Bennée plugins="yes" 11449b8e4298SAlex Bennée fi 114540e8c6f4SAlex Bennée ;; 114640e8c6f4SAlex Bennée --disable-plugins) plugins="no" 114740e8c6f4SAlex Bennée ;; 1148afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 1149afc3a8f9SAlex Bennée ;; 1150afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 1151afc3a8f9SAlex Bennée ;; 1152f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 1153f48e590aSAlex Bennée ;; 1154b767d257SMarek Marczykowski-Górecki --enable-rng-none) rng_none=yes 1155b767d257SMarek Marczykowski-Górecki ;; 1156b767d257SMarek Marczykowski-Górecki --disable-rng-none) rng_none=no 1157b767d257SMarek Marczykowski-Górecki ;; 115854e7aac0SAlexey Krasikov --enable-keyring) secret_keyring="yes" 115954e7aac0SAlexey Krasikov ;; 116054e7aac0SAlexey Krasikov --disable-keyring) secret_keyring="no" 116154e7aac0SAlexey Krasikov ;; 116220cf7b8eSDenis Plotnikov --enable-gio) gio=yes 116320cf7b8eSDenis Plotnikov ;; 116420cf7b8eSDenis Plotnikov --disable-gio) gio=no 116520cf7b8eSDenis Plotnikov ;; 1166b8e0c493SJoelle van Dyne --enable-slirp-smbd) slirp_smbd=yes 1167b8e0c493SJoelle van Dyne ;; 1168b8e0c493SJoelle van Dyne --disable-slirp-smbd) slirp_smbd=no 1169b8e0c493SJoelle van Dyne ;; 11703b4da132SPaolo Bonzini # backwards compatibility options 11713b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 11723b4da132SPaolo Bonzini ;; 11733b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 11743b4da132SPaolo Bonzini ;; 11753b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 11763b4da132SPaolo Bonzini ;; 11773b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 11783b4da132SPaolo Bonzini ;; 11793b4da132SPaolo Bonzini # everything else has the same name in configure and meson 118061d63097SPaolo Bonzini --enable-* | --disable-*) meson_option_parse "$opt" "$optarg" 118161d63097SPaolo Bonzini ;; 11822d2ad6d0SFam Zheng *) 11832d2ad6d0SFam Zheng echo "ERROR: unknown option $opt" 11842d2ad6d0SFam Zheng echo "Try '$0 --help' for more information" 11852d2ad6d0SFam Zheng exit 1 11867f1559c6Sbalrog ;; 11877d13299dSbellard esac 11887d13299dSbellarddone 11897d13299dSbellard 1190d1a14257SAlex Bennée# test for any invalid configuration combinations 1191d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 1192d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 1193d1a14257SAlex Bennéefi 1194d1a14257SAlex Bennée 11957d7dbf9dSDan Streetmancase $git_submodules_action in 11967d7dbf9dSDan Streetman update|validate) 11977d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 11987d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 11997d7dbf9dSDan Streetman exit 1 12007d7dbf9dSDan Streetman fi 12017d7dbf9dSDan Streetman ;; 12027d7dbf9dSDan Streetman ignore) 1203b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 1204b80fd281SPaolo Bonzini then 1205b80fd281SPaolo Bonzini echo 1206b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 1207b80fd281SPaolo Bonzini echo 1208b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 1209b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 1210b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 1211b80fd281SPaolo Bonzini else 1212b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 1213b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 1214b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 1215b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 1216b80fd281SPaolo Bonzini echo 1217b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 1218b80fd281SPaolo Bonzini echo 1219b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 1220b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 1221b80fd281SPaolo Bonzini fi 1222b80fd281SPaolo Bonzini echo 1223b80fd281SPaolo Bonzini exit 1 1224b80fd281SPaolo Bonzini fi 12257d7dbf9dSDan Streetman ;; 12267d7dbf9dSDan Streetman *) 12277d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 12287d7dbf9dSDan Streetman exit 1 12297d7dbf9dSDan Streetman ;; 12307d7dbf9dSDan Streetmanesac 12317d7dbf9dSDan Streetman 123222a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}" 123322a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}" 123422a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}" 123522a87800SMarc-André Lureau 123622a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then 123715588a62SJoshua Watt bindir="${bindir:-$prefix}" 123822a87800SMarc-André Lureauelse 123915588a62SJoshua Watt bindir="${bindir:-$prefix/bin}" 124015588a62SJoshua Wattfi 124122a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}" 124222a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}" 1243ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}" 124422a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}" 124522a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}" 124616bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}" 124716bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}" 124822a87800SMarc-André Lureau 12499557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 1250b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 12512038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 12529557af9cSAlex Bennéefi 125379f3b12fSPeter Crosthwaite 125460e0df25SPeter Maydelldefault_target_list="" 12556e92f823SPeter Maydellmak_wilds="" 12566e92f823SPeter Maydell 1257b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 1258b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 1259b915a2f1SPaolo Bonzini linux_user=yes 1260b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 1261b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 1262b915a2f1SPaolo Bonzini fi 1263b915a2f1SPaolo Bonzinifi 1264b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 1265b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 1266b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 1267b915a2f1SPaolo Bonzini fi 1268b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 1269b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 1270b915a2f1SPaolo Bonzini fi 1271b915a2f1SPaolo Bonzinifi 127260e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 1273812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 127460e0df25SPeter Maydellfi 127560e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 1276812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 127760e0df25SPeter Maydellfi 127860e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 1279812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 128060e0df25SPeter Maydellfi 128160e0df25SPeter Maydell 1282447e133fSAlex Bennéefor config in $mak_wilds; do 1283447e133fSAlex Bennée target="$(basename "$config" .mak)" 128498db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 1285447e133fSAlex Bennée default_target_list="${default_target_list} $target" 1286447e133fSAlex Bennée fi 1287447e133fSAlex Bennéedone 12886e92f823SPeter Maydell 1289af5db58eSpbrookif test x"$show_help" = x"yes" ; then 1290af5db58eSpbrookcat << EOF 1291af5db58eSpbrook 1292af5db58eSpbrookUsage: configure [options] 1293af5db58eSpbrookOptions: [defaults in brackets after descriptions] 1294af5db58eSpbrook 129508fb77edSStefan WeilStandard options: 129608fb77edSStefan Weil --help print this message 129708fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 129808fb77edSStefan Weil --interp-prefix=PREFIX where to find shared libraries, etc. 129908fb77edSStefan Weil use %M for cpu name [$interp_prefix] 1300*74154d7eSThomas Huth --target-list=LIST set target list (default: build all) 130108fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 130208fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 1303447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 130408fb77edSStefan Weil 130508fb77edSStefan WeilAdvanced options (experts only): 13063812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 130708fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 130808fb77edSStefan Weil --iasl=IASL use ACPI compiler IASL [$iasl] 130908fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 131008fb77edSStefan Weil build time 131108fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 131208fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1313a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1314a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 131508fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1316d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1317479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 131808fb77edSStefan Weil --make=MAKE use specified make [$make] 131908fb77edSStefan Weil --python=PYTHON use specified python [$python] 13202eb054c2SPeter Maydell --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build] 1321a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 132248328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 132308fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1324db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 13257d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 13267d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 13277d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 132808fb77edSStefan Weil --static enable static build [$static] 132908fb77edSStefan Weil --mandir=PATH install man pages in PATH 133010ff82d1SMarc-André Lureau --datadir=PATH install firmware in PATH/$qemu_suffix 1331fe0038beSPaolo Bonzini --localedir=PATH install translation in PATH/$qemu_suffix 133210ff82d1SMarc-André Lureau --docdir=PATH install documentation in PATH/$qemu_suffix 133308fb77edSStefan Weil --bindir=PATH install binaries in PATH 133408fb77edSStefan Weil --libdir=PATH install libraries in PATH 1335db1b5f13SThomas Huth --libexecdir=PATH install helper binaries in PATH 133610ff82d1SMarc-André Lureau --sysconfdir=PATH install config in PATH/$qemu_suffix 133708fb77edSStefan Weil --localstatedir=PATH install local state in PATH (set at runtime on win32) 13383d5eecabSGerd Hoffmann --firmwarepath=PATH search PATH for firmware files 133913336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1340ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1341db1b5f13SThomas Huth --with-pkgversion=VERS use specified string as sub-version of the package 1342c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1343c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1344c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1345d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1346d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 134708fb77edSStefan Weil --enable-debug enable common debug build options 1348247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 13490aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 135008fb77edSStefan Weil --disable-werror disable compilation abort on warning 135163678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 135216bfbc70SPaolo Bonzini --audio-drv-list=LIST set audio drivers to try if -audiodev is not used 135308fb77edSStefan Weil --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L 135408fb77edSStefan Weil --block-drv-rw-whitelist=L 135508fb77edSStefan Weil set block driver read-write whitelist 1356e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 135708fb77edSStefan Weil --block-drv-ro-whitelist=L 135808fb77edSStefan Weil set block driver read-only whitelist 1359e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 1360e5f05f8cSKevin Wolf --enable-block-drv-whitelist-in-tools 1361e5f05f8cSKevin Wolf use block whitelist also in tools instead of only QEMU 136208fb77edSStefan Weil --with-trace-file=NAME Full PATH,NAME of file to store traces 136308fb77edSStefan Weil Default:trace-<pid> 1364c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 136508fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 136633c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 136708fb77edSStefan Weil --enable-gcov enable test coverage analysis with gcov 1368c23f23b9SMichael Tokarev --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent 1369c23f23b9SMichael Tokarev --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb) 1370a1c5e949SDaniel P. Berrange --tls-priority default TLS protocol/cipher priority string 1371c12d66aaSLin Ma --enable-gprof QEMU profiling with gprof 1372c12d66aaSLin Ma --enable-profiler profiler support 1373c12d66aaSLin Ma --enable-debug-stack-usage 1374c12d66aaSLin Ma track the maximum stack usage of stacks created by qemu_alloc_stack 137540e8c6f4SAlex Bennée --enable-plugins 137640e8c6f4SAlex Bennée enable plugins via shared library loading 1377afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1378f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 137961d63097SPaolo BonziniEOF 138061d63097SPaolo Bonzini meson_options_help 138161d63097SPaolo Bonzinicat << EOF 1382c23f23b9SMichael Tokarev system all system emulation targets 1383c23f23b9SMichael Tokarev user supported user emulation targets 1384c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1385c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1386c23f23b9SMichael Tokarev guest-agent build the QEMU Guest Agent 1387c23f23b9SMichael Tokarev pie Position Independent Executables 138821e709aaSMarc-André Lureau modules modules support (non-Windows) 1389bd83c861SChristian Ehrhardt module-upgrades try to load modules from alternate paths for upgrades 1390c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1391c23f23b9SMichael Tokarev debug-info debugging information 1392cdad781dSDaniele Buono lto Enable Link-Time Optimization. 13931e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 13941e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 1395a40161cbSPaolo Bonzini membarrier membarrier system call (for Linux 4.14+ or Windows) 139621ab34c9SMarcel Apfelbaum rdma Enable RDMA-based migration 139721ab34c9SMarcel Apfelbaum pvrdma Enable PVRDMA support 1398299e6f19SPaolo Bonzini vhost-net vhost-net kernel acceleration support 1399299e6f19SPaolo Bonzini vhost-vsock virtio sockets device support 1400299e6f19SPaolo Bonzini vhost-scsi vhost-scsi kernel target support 1401299e6f19SPaolo Bonzini vhost-crypto vhost-user-crypto backend support 1402299e6f19SPaolo Bonzini vhost-kernel vhost kernel backend support 1403299e6f19SPaolo Bonzini vhost-user vhost-user backend support 1404108a6481SCindy Lu vhost-vdpa vhost-vdpa kernel backend support 1405ed1701c6SDr. David Alan Gilbert live-block-migration Block migration in the main migration stream 1406c23f23b9SMichael Tokarev coroutine-pool coroutine freelist (better performance) 1407c23f23b9SMichael Tokarev tpm TPM support 1408c23f23b9SMichael Tokarev numa libnuma support 140986583a07SLiam Merwick avx2 AVX2 optimization support 14106b8cd447SRobert Hoo avx512f AVX512F optimization support 1411a6b1d4c0SChanglong Xie replication replication support 1412c12d66aaSLin Ma opengl opengl support 1413c12d66aaSLin Ma qom-cast-debug cast debugging support 14148de73fa8SCleber Rosa tools build qemu-io, qemu-nbd and qemu-img tools 14152f740136SJeff Cody bochs bochs image format support 14162f740136SJeff Cody cloop cloop image format support 14172f740136SJeff Cody dmg dmg image format support 14182f740136SJeff Cody qcow1 qcow v1 image format support 14192f740136SJeff Cody vdi vdi image format support 14202f740136SJeff Cody vvfat vvfat image format support 14212f740136SJeff Cody qed qed image format support 14222f740136SJeff Cody parallels parallels image format support 1423f0d92b56SLongpeng(Mike) crypto-afalg Linux AF_ALG crypto backend driver 1424ba59fb77SPaolo Bonzini debug-mutex mutex debugging support 1425b767d257SMarek Marczykowski-Górecki rng-none dummy RNG, avoid using /dev/(u)random and getrandom() 142620cf7b8eSDenis Plotnikov gio libgio support 1427b8e0c493SJoelle van Dyne slirp-smbd use smbd (at path --smbd=*) in slirp networking 142808fb77edSStefan Weil 142908fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1430af5db58eSpbrookEOF 14312d2ad6d0SFam Zhengexit 0 1432af5db58eSpbrookfi 1433af5db58eSpbrook 14349c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1435bb768f71SThomas Huthrm -f */config-devices.mak.d 14369c790242SThomas Huth 1437faf44142SDaniel P. Berrangéif test -z "$python" 1438faf44142SDaniel P. Berrangéthen 1439c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1440c53eeaf7SStefan Hajnoczifi 14418e2c76bdSRoman Bolshakovif ! has "$make" 14428e2c76bdSRoman Bolshakovthen 14438e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 14448e2c76bdSRoman Bolshakovfi 1445c53eeaf7SStefan Hajnoczi 1446c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1447c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 14481b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 14491b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1450c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1451c53eeaf7SStefan Hajnoczifi 1452c53eeaf7SStefan Hajnoczi 1453755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1454406ab2f3SCleber 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) 1455755ee70fSCleber Rosa 1456c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1457c53eeaf7SStefan Hajnoczipython="$python -B" 1458c53eeaf7SStefan Hajnoczi 14590a01d76fSMarc-André Lureauif test -z "$meson"; then 14606638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 14610a01d76fSMarc-André Lureau meson=meson 14627d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 14630a01d76fSMarc-André Lureau meson=git 14640a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 14650a01d76fSMarc-André Lureau meson=internal 14660a01d76fSMarc-André Lureau else 14670a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 14680a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 14690a01d76fSMarc-André Lureau else 1470a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1471a5665051SPaolo Bonzini fi 14720a01d76fSMarc-André Lureau fi 14730a01d76fSMarc-André Lureauelse 14740a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 14750a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 14760a01d76fSMarc-André Lureau # 14770a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 14780a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 14790a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 14800a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 14810a01d76fSMarc-André Lureau case "$meson" in 14820a01d76fSMarc-André Lureau git | internal) ;; 14830a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 14840a01d76fSMarc-André Lureau esac 14850a01d76fSMarc-André Lureau fi 14860a01d76fSMarc-André Lureaufi 1487a5665051SPaolo Bonzini 14880a01d76fSMarc-André Lureauif test "$meson" = git; then 14890a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 14900a01d76fSMarc-André Lureaufi 14910a01d76fSMarc-André Lureau 14920a01d76fSMarc-André Lureaucase "$meson" in 14930a01d76fSMarc-André Lureau git | internal) 14940a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 14950a01d76fSMarc-André Lureau ;; 149684ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 14970a01d76fSMarc-André Lureauesac 14980a01d76fSMarc-André Lureau 149909e93326SPaolo Bonzini# Probe for ninja 150048328880SPaolo Bonzini 150148328880SPaolo Bonziniif test -z "$ninja"; then 150248328880SPaolo Bonzini for c in ninja ninja-build samu; do 150348328880SPaolo Bonzini if has $c; then 150448328880SPaolo Bonzini ninja=$(command -v "$c") 150548328880SPaolo Bonzini break 150648328880SPaolo Bonzini fi 150748328880SPaolo Bonzini done 150809e93326SPaolo Bonzini if test -z "$ninja"; then 150909e93326SPaolo Bonzini error_exit "Cannot find Ninja" 151009e93326SPaolo Bonzini fi 151148328880SPaolo Bonzinifi 1512a5665051SPaolo Bonzini 15139aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 15149aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 15159aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 15169aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 15179aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 15189aae6e54SDaniel Henrique Barbozaif compile_object ; then 15199aae6e54SDaniel Henrique Barboza : C compiler works ok 15209aae6e54SDaniel Henrique Barbozaelse 15219aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 15229aae6e54SDaniel Henrique Barbozafi 15239aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 15249aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 15259aae6e54SDaniel Henrique Barbozafi 15269aae6e54SDaniel Henrique Barboza 15279c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 15289c83ffd8SPeter Maydell# by default. Only enable by default for git builds 15299c83ffd8SPeter Maydellif test -z "$werror" ; then 15307d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1531e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 15329c83ffd8SPeter Maydell werror="yes" 15339c83ffd8SPeter Maydell else 15349c83ffd8SPeter Maydell werror="no" 15359c83ffd8SPeter Maydell fi 15369c83ffd8SPeter Maydellfi 15379c83ffd8SPeter Maydell 1538975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1539fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1540fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1541fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1542fb59dabdSPeter Maydell # host OS we should stop now. 1543951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1544fb59dabdSPeter Maydellfi 1545fb59dabdSPeter Maydell 1546efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1547efc6c070SThomas Huthcat > $TMPC << EOF 1548efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1549efc6c070SThomas Huth# ifdef __apple_build_version__ 15502a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 15512a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1552efc6c070SThomas Huth# endif 1553efc6c070SThomas Huth# else 15542a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 15552a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1556efc6c070SThomas Huth# endif 1557efc6c070SThomas Huth# endif 1558efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 15593830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 15603830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1561efc6c070SThomas Huth# endif 1562efc6c070SThomas Huth#else 1563efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1564efc6c070SThomas Huth#endif 1565efc6c070SThomas Huthint main (void) { return 0; } 1566efc6c070SThomas HuthEOF 1567efc6c070SThomas Huthif ! compile_prog "" "" ; then 15683830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1569efc6c070SThomas Huthfi 1570efc6c070SThomas Huth 157100849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 157200849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 157300849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 157400849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 157500849b92SRichard Henderson# just silently disable some features, so it's too error prone. 157600849b92SRichard Henderson 157700849b92SRichard Hendersonwarn_flags= 157800849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 157900849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 158000849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 158100849b92SRichard Hendersonadd_to warn_flags -Wformat-security 158200849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 158300849b92SRichard Hendersonadd_to warn_flags -Winit-self 158400849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 158500849b92SRichard Hendersonadd_to warn_flags -Wempty-body 158600849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 158700849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 158800849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 15890a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 159000849b92SRichard Henderson 159100849b92SRichard Hendersonnowarn_flags= 159200849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 159300849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 159400849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 159500849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 159600849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1597aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1598bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 159900849b92SRichard Henderson 160000849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 160193b25869SJohn Snow 160293b25869SJohn Snowcc_has_warning_flag() { 160393b25869SJohn Snow write_c_skeleton; 160493b25869SJohn Snow 1605a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1606a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1607a1d29d6cSPeter Maydell # warning options). 160893b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 160993b25869SJohn Snow compile_prog "-Werror $optflag" "" 161093b25869SJohn Snow} 161193b25869SJohn Snow 161293b25869SJohn Snowfor flag in $gcc_flags; do 161393b25869SJohn Snow if cc_has_warning_flag $flag ; then 16148d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 16158d05095cSPaolo Bonzini fi 16168d05095cSPaolo Bonzinidone 16178d05095cSPaolo Bonzini 161863678e17SSteven Noonanif test "$stack_protector" != "no"; then 1619fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1620fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1621fccd35a0SRodrigo Rebello{ 1622fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1623fccd35a0SRodrigo Rebello while (*c) { 1624fccd35a0SRodrigo Rebello *p++ = *c++; 1625fccd35a0SRodrigo Rebello } 1626fccd35a0SRodrigo Rebello return 0; 1627fccd35a0SRodrigo Rebello} 1628fccd35a0SRodrigo RebelloEOF 162963678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 16303b463a3fSMiroslav Rezanina sp_on=0 163163678e17SSteven Noonan for flag in $gcc_flags; do 1632590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1633590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1634086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1635590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 163663678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1637db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 16383b463a3fSMiroslav Rezanina sp_on=1 163963678e17SSteven Noonan break 164063678e17SSteven Noonan fi 164163678e17SSteven Noonan done 16423b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 16433b463a3fSMiroslav Rezanina if test $sp_on = 0; then 16443b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 16453b463a3fSMiroslav Rezanina fi 16463b463a3fSMiroslav Rezanina fi 164737746c5eSMarc-André Lureaufi 164837746c5eSMarc-André Lureau 164920bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 165020bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 165120bc94a2SPaolo Bonzinicat > $TMPC << EOF 165220bc94a2SPaolo Bonzinistruct { 165320bc94a2SPaolo Bonzini int a[2]; 165420bc94a2SPaolo Bonzini} x = {0}; 165520bc94a2SPaolo BonziniEOF 165620bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 165720bc94a2SPaolo Bonzini : 165820bc94a2SPaolo Bonzinielse 165920bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 166020bc94a2SPaolo Bonzinifi 166120bc94a2SPaolo Bonzini 166221e709aaSMarc-André Lureau# Our module code doesn't support Windows 166321e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 166421e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 166521e709aaSMarc-André Lureaufi 166621e709aaSMarc-André Lureau 1667bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled 1668bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then 1669bd83c861SChristian Ehrhardt error_exit "Can't enable module-upgrades as Modules are not enabled" 1670bd83c861SChristian Ehrhardtfi 1671bd83c861SChristian Ehrhardt 16725f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 167340d6444eSAvi Kivityif test "$static" = "yes" ; then 1674aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1675aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1676aa0d1f44SPaolo Bonzini fi 16775f2453acSAlex Bennée if test "$plugins" = "yes"; then 16785f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1679ba4dd2aaSAlex Bennée else 1680ba4dd2aaSAlex Bennée plugins="no" 16815f2453acSAlex Bennée fi 168240d6444eSAvi Kivityfi 168337650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 168440d6444eSAvi Kivity 168540d6444eSAvi Kivitycat > $TMPC << EOF 168621d4a791SAvi Kivity 168721d4a791SAvi Kivity#ifdef __linux__ 168821d4a791SAvi Kivity# define THREAD __thread 168921d4a791SAvi Kivity#else 169021d4a791SAvi Kivity# define THREAD 169121d4a791SAvi Kivity#endif 169221d4a791SAvi Kivitystatic THREAD int tls_var; 169321d4a791SAvi Kivityint main(void) { return tls_var; } 169440d6444eSAvi KivityEOF 1695b2634124SRichard Henderson 1696ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1697ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1698412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1699412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1700ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1701412aeacdSAlex Bennéefi 1702412aeacdSAlex Bennée 170312781462SRichard Hendersonif test "$static" = "yes"; then 1704eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 17055770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 170612781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 170712781462SRichard Henderson pie="yes" 170812781462SRichard Henderson elif test "$pie" = "yes"; then 170912781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 171012781462SRichard Henderson else 171112781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 171212781462SRichard Henderson pie="no" 171312781462SRichard Henderson fi 171412781462SRichard Hendersonelif test "$pie" = "no"; then 17155770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1716ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1717eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 17185770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 17195770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 172040d6444eSAvi Kivity pie="yes" 17212c674109SRichard Hendersonelif test "$pie" = "yes"; then 172276ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 172340d6444eSAvi Kivityelse 172440d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 172540d6444eSAvi Kivity pie="no" 172640d6444eSAvi Kivityfi 172740d6444eSAvi Kivity 1728e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1729e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1730e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1731e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1732e6cbd751SRichard Hendersonfi 1733e6cbd751SRichard Henderson 173409dada40SPaolo Bonzini########################################## 173509dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 173609dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 173709dada40SPaolo Bonzini# specification is necessary 173809dada40SPaolo Bonzini 173909dada40SPaolo Bonziniif test "$cpu" = "i386"; then 174009dada40SPaolo Bonzini cat > $TMPC << EOF 174109dada40SPaolo Bonzinistatic int sfaa(int *ptr) 174209dada40SPaolo Bonzini{ 174309dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 174409dada40SPaolo Bonzini} 174509dada40SPaolo Bonzini 174609dada40SPaolo Bonziniint main(void) 174709dada40SPaolo Bonzini{ 174809dada40SPaolo Bonzini int val = 42; 17491405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 175009dada40SPaolo Bonzini sfaa(&val); 175109dada40SPaolo Bonzini return val; 175209dada40SPaolo Bonzini} 175309dada40SPaolo BonziniEOF 175409dada40SPaolo Bonzini if ! compile_prog "" "" ; then 175509dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 175609dada40SPaolo Bonzini fi 175709dada40SPaolo Bonzinifi 175809dada40SPaolo Bonzini 175956267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 176056267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 176156267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 176256267b62SPhilippe Mathieu-Daudéfi 176356267b62SPhilippe Mathieu-Daudé 1764afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1765fdb75aefSPaolo Bonzini default_targets=yes 1766d880a3baSPaolo Bonzini for target in $default_target_list; do 1767d880a3baSPaolo Bonzini target_list="$target_list $target" 1768d880a3baSPaolo Bonzini done 1769d880a3baSPaolo Bonzini target_list="${target_list# }" 1770121afa9eSAnthony Liguorielse 1771fdb75aefSPaolo Bonzini default_targets=no 177289138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1773d880a3baSPaolo Bonzini for target in $target_list; do 177425b48338SPeter Maydell # Check that we recognised the target name; this allows a more 177525b48338SPeter Maydell # friendly error message than if we let it fall through. 177625b48338SPeter Maydell case " $default_target_list " in 177725b48338SPeter Maydell *" $target "*) 177825b48338SPeter Maydell ;; 177925b48338SPeter Maydell *) 178025b48338SPeter Maydell error_exit "Unknown target name '$target'" 178125b48338SPeter Maydell ;; 178225b48338SPeter Maydell esac 178325b48338SPeter Maydell done 1784d880a3baSPaolo Bonzinifi 178525b48338SPeter Maydell 1786f55fe278SPaolo Bonzini# see if system emulation was really requested 1787f55fe278SPaolo Bonzinicase " $target_list " in 1788f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1789f55fe278SPaolo Bonzini ;; 1790f55fe278SPaolo Bonzini *) softmmu=no 1791f55fe278SPaolo Bonzini ;; 1792f55fe278SPaolo Bonziniesac 17935327cf48Sbellard 1794249247c9SJuan Quintelafeature_not_found() { 1795249247c9SJuan Quintela feature=$1 179621684af0SStewart Smith remedy=$2 1797249247c9SJuan Quintela 179876ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 179921684af0SStewart Smith "configure was not able to find it." \ 180021684af0SStewart Smith "$remedy" 1801249247c9SJuan Quintela} 1802249247c9SJuan Quintela 18037d13299dSbellard# --- 18047d13299dSbellard# big/little endian test 18057d13299dSbellardcat > $TMPC << EOF 1806659eb157SThomas Huth#include <stdio.h> 180761cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 180861cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1809659eb157SThomas Huthint main(int argc, char *argv[]) 1810659eb157SThomas Huth{ 1811659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 18127d13299dSbellard} 18137d13299dSbellardEOF 18147d13299dSbellard 1815659eb157SThomas Huthif compile_prog ; then 1816659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 181761cc919fSMike Frysinger bigendian="yes" 1818659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 181961cc919fSMike Frysinger bigendian="no" 18207d13299dSbellard else 18217d13299dSbellard echo big/little test failed 1822659eb157SThomas Huth exit 1 18237d13299dSbellard fi 18247d13299dSbellardelse 182561cc919fSMike Frysinger echo big/little test failed 1826659eb157SThomas Huth exit 1 18277d13299dSbellardfi 18287d13299dSbellard 1829b0a47e79SJuan Quintela########################################## 1830e10ee3f5SPhilippe Mathieu-Daudé# system tools 1831e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then 1832e10ee3f5SPhilippe Mathieu-Daudé if test "$softmmu" = "no"; then 1833e10ee3f5SPhilippe Mathieu-Daudé want_tools=no 1834e10ee3f5SPhilippe Mathieu-Daudé else 1835e10ee3f5SPhilippe Mathieu-Daudé want_tools=yes 1836e10ee3f5SPhilippe Mathieu-Daudé fi 1837e10ee3f5SPhilippe Mathieu-Daudéfi 1838e10ee3f5SPhilippe Mathieu-Daudé 1839299e6f19SPaolo Bonzini######################################### 1840299e6f19SPaolo Bonzini# vhost interdependencies and host support 1841299e6f19SPaolo Bonzini 1842299e6f19SPaolo Bonzini# vhost backends 1843d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then 1844d88618f7SStefan Hajnoczi error_exit "vhost-user is only available on Linux" 1845299e6f19SPaolo Bonzinifi 1846108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux 1847108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then 1848108a6481SCindy Lu error_exit "vhost-vdpa is only available on Linux" 1849108a6481SCindy Lufi 1850299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux 1851299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then 1852299e6f19SPaolo Bonzini error_exit "vhost-kernel is only available on Linux" 1853299e6f19SPaolo Bonzinifi 1854299e6f19SPaolo Bonzini 1855299e6f19SPaolo Bonzini# vhost-kernel devices 1856299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel 1857299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then 1858299e6f19SPaolo Bonzini error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" 1859299e6f19SPaolo Bonzinifi 1860299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel 1861299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then 1862299e6f19SPaolo Bonzini error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" 1863299e6f19SPaolo Bonzinifi 1864299e6f19SPaolo Bonzini 1865299e6f19SPaolo Bonzini# vhost-user backends 1866299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user 1867299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then 1868299e6f19SPaolo Bonzini error_exit "--enable-vhost-net-user requires --enable-vhost-user" 1869299e6f19SPaolo Bonzinifi 1870299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user 1871299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then 1872299e6f19SPaolo Bonzini error_exit "--enable-vhost-crypto requires --enable-vhost-user" 1873299e6f19SPaolo Bonzinifi 187498fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user 187598fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then 187698fc1adaSDr. David Alan Gilbert error_exit "--enable-vhost-user-fs requires --enable-vhost-user" 187798fc1adaSDr. David Alan Gilbertfi 1878108a6481SCindy Lu#vhost-vdpa backends 1879108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa 1880108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then 1881108a6481SCindy Lu error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" 1882108a6481SCindy Lufi 1883299e6f19SPaolo Bonzini 188440bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity 1885299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then 1886299e6f19SPaolo Bonzini test "$vhost_net_user" = "yes" && vhost_net=yes 188740bc0ca9SLaurent Vivier test "$vhost_net_vdpa" = "yes" && vhost_net=yes 1888299e6f19SPaolo Bonzini test "$vhost_kernel" = "yes" && vhost_net=yes 1889299e6f19SPaolo Bonzinifi 1890299e6f19SPaolo Bonzini 1891015a33bdSGonglei########################################## 1892779ab5e3SStefan Weil# pkg-config probe 1893779ab5e3SStefan Weil 1894779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 189576ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1896779ab5e3SStefan Weilfi 1897779ab5e3SStefan Weil 1898779ab5e3SStefan Weil########################################## 1899e37630caSaliguori# xen probe 1900e37630caSaliguori 19011badb709SPaolo Bonziniif test "$xen" != "disabled" ; then 1902c1cdd9d5SJuergen Gross # Check whether Xen library path is specified via --extra-ldflags to avoid 1903c1cdd9d5SJuergen Gross # overriding this setting with pkg-config output. If not, try pkg-config 1904c1cdd9d5SJuergen Gross # to obtain all needed flags. 1905c1cdd9d5SJuergen Gross 1906c1cdd9d5SJuergen Gross if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ 1907c1cdd9d5SJuergen Gross $pkg_config --exists xencontrol ; then 1908c1cdd9d5SJuergen Gross xen_ctrl_version="$(printf '%d%02d%02d' \ 1909c1cdd9d5SJuergen Gross $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" 19101badb709SPaolo Bonzini xen=enabled 19115b6a8f43SMichael Tokarev xen_pc="xencontrol xenstore xenforeignmemory xengnttab" 1912c1cdd9d5SJuergen Gross xen_pc="$xen_pc xenevtchn xendevicemodel" 191358ea9a7aSAnthony PERARD if $pkg_config --exists xentoolcore; then 191458ea9a7aSAnthony PERARD xen_pc="$xen_pc xentoolcore" 191558ea9a7aSAnthony PERARD fi 1916582ea95fSMarc-André Lureau xen_cflags="$($pkg_config --cflags $xen_pc)" 1917582ea95fSMarc-André Lureau xen_libs="$($pkg_config --libs $xen_pc)" 1918c1cdd9d5SJuergen Gross else 1919c1cdd9d5SJuergen Gross 19205b6a8f43SMichael Tokarev xen_libs="-lxenstore -lxenctrl" 1921d9506cabSAnthony PERARD xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" 1922d5b93ddfSAnthony PERARD 192350ced5b3SStefan Weil # First we test whether Xen headers and libraries are available. 192450ced5b3SStefan Weil # If no, we are done and there is no Xen support. 192550ced5b3SStefan Weil # If yes, more tests are run to detect the Xen version. 192650ced5b3SStefan Weil 192750ced5b3SStefan Weil # Xen (any) 192850ced5b3SStefan Weil cat > $TMPC <<EOF 192950ced5b3SStefan Weil#include <xenctrl.h> 193050ced5b3SStefan Weilint main(void) { 193150ced5b3SStefan Weil return 0; 193250ced5b3SStefan Weil} 193350ced5b3SStefan WeilEOF 193450ced5b3SStefan Weil if ! compile_prog "" "$xen_libs" ; then 193550ced5b3SStefan Weil # Xen not found 19361badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 193721684af0SStewart Smith feature_not_found "xen" "Install xen devel" 193850ced5b3SStefan Weil fi 19391badb709SPaolo Bonzini xen=disabled 194050ced5b3SStefan Weil 1941d5b93ddfSAnthony PERARD # Xen unstable 194269deef08SPeter Maydell elif 194369deef08SPeter Maydell cat > $TMPC <<EOF && 19442cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API 19452cbf8903SRoss Lagerwall#define __XEN_TOOLS__ 19462cbf8903SRoss Lagerwall#include <xendevicemodel.h> 1947d3c49ebbSPaul Durrant#include <xenforeignmemory.h> 19482cbf8903SRoss Lagerwallint main(void) { 19492cbf8903SRoss Lagerwall xendevicemodel_handle *xd; 1950d3c49ebbSPaul Durrant xenforeignmemory_handle *xfmem; 19512cbf8903SRoss Lagerwall 19522cbf8903SRoss Lagerwall xd = xendevicemodel_open(0, 0); 19532cbf8903SRoss Lagerwall xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); 19542cbf8903SRoss Lagerwall 1955d3c49ebbSPaul Durrant xfmem = xenforeignmemory_open(0, 0); 1956d3c49ebbSPaul Durrant xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); 1957d3c49ebbSPaul Durrant 19582cbf8903SRoss Lagerwall return 0; 19592cbf8903SRoss Lagerwall} 19602cbf8903SRoss LagerwallEOF 19612cbf8903SRoss Lagerwall compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 19622cbf8903SRoss Lagerwall then 19632cbf8903SRoss Lagerwall xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 19642cbf8903SRoss Lagerwall xen_ctrl_version=41100 19651badb709SPaolo Bonzini xen=enabled 19662cbf8903SRoss Lagerwall elif 19672cbf8903SRoss Lagerwall cat > $TMPC <<EOF && 19685ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API 19695ba3d756SIgor Druzhinin#include <xenforeignmemory.h> 197058ea9a7aSAnthony PERARD#include <xentoolcore.h> 19715ba3d756SIgor Druzhininint main(void) { 19725ba3d756SIgor Druzhinin xenforeignmemory_handle *xfmem; 19735ba3d756SIgor Druzhinin 19745ba3d756SIgor Druzhinin xfmem = xenforeignmemory_open(0, 0); 19755ba3d756SIgor Druzhinin xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); 197658ea9a7aSAnthony PERARD xentoolcore_restrict_all(0); 19775ba3d756SIgor Druzhinin 19785ba3d756SIgor Druzhinin return 0; 19795ba3d756SIgor Druzhinin} 19805ba3d756SIgor DruzhininEOF 198158ea9a7aSAnthony PERARD compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 19825ba3d756SIgor Druzhinin then 198358ea9a7aSAnthony PERARD xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 19845ba3d756SIgor Druzhinin xen_ctrl_version=41000 19851badb709SPaolo Bonzini xen=enabled 19865ba3d756SIgor Druzhinin elif 19875ba3d756SIgor Druzhinin cat > $TMPC <<EOF && 1988da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API 1989da8090ccSPaul Durrant#define __XEN_TOOLS__ 1990da8090ccSPaul Durrant#include <xendevicemodel.h> 1991da8090ccSPaul Durrantint main(void) { 1992da8090ccSPaul Durrant xendevicemodel_handle *xd; 1993da8090ccSPaul Durrant 1994da8090ccSPaul Durrant xd = xendevicemodel_open(0, 0); 1995da8090ccSPaul Durrant xendevicemodel_close(xd); 1996da8090ccSPaul Durrant 1997da8090ccSPaul Durrant return 0; 1998da8090ccSPaul Durrant} 1999da8090ccSPaul DurrantEOF 2000da8090ccSPaul Durrant compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" 2001da8090ccSPaul Durrant then 2002da8090ccSPaul Durrant xen_stable_libs="-lxendevicemodel $xen_stable_libs" 2003f1167ee6SJuergen Gross xen_ctrl_version=40900 20041badb709SPaolo Bonzini xen=enabled 2005da8090ccSPaul Durrant elif 2006da8090ccSPaul Durrant cat > $TMPC <<EOF && 20075eeb39c2SIan Campbell/* 20085eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat 20095eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given. 2010b6eb9b45SPaulina Szubarczyk * 2011b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and 2012b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented. 2013b6eb9b45SPaulina Szubarczyk */ 2014b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API 2015b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API 2016b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API 2017b6eb9b45SPaulina Szubarczyk#include <xenctrl.h> 2018b6eb9b45SPaulina Szubarczyk#include <xenstore.h> 2019b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h> 2020b6eb9b45SPaulina Szubarczyk#include <xengnttab.h> 2021b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h> 2022b6eb9b45SPaulina Szubarczyk#include <stdint.h> 2023b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h> 2024b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS) 2025b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined 2026b6eb9b45SPaulina Szubarczyk#endif 2027b6eb9b45SPaulina Szubarczykint main(void) { 2028b6eb9b45SPaulina Szubarczyk xc_interface *xc = NULL; 2029b6eb9b45SPaulina Szubarczyk xenforeignmemory_handle *xfmem; 2030b6eb9b45SPaulina Szubarczyk xenevtchn_handle *xe; 2031b6eb9b45SPaulina Szubarczyk xengnttab_handle *xg; 2032b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy_segment_t* seg = NULL; 2033b6eb9b45SPaulina Szubarczyk 2034b6eb9b45SPaulina Szubarczyk xs_daemon_open(); 2035b6eb9b45SPaulina Szubarczyk 2036b6eb9b45SPaulina Szubarczyk xc = xc_interface_open(0, 0, 0); 2037b6eb9b45SPaulina Szubarczyk xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2038b6eb9b45SPaulina Szubarczyk xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2039b6eb9b45SPaulina Szubarczyk xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 2040b6eb9b45SPaulina Szubarczyk xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 2041b6eb9b45SPaulina Szubarczyk 2042b6eb9b45SPaulina Szubarczyk xfmem = xenforeignmemory_open(0, 0); 2043b6eb9b45SPaulina Szubarczyk xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 2044b6eb9b45SPaulina Szubarczyk 2045b6eb9b45SPaulina Szubarczyk xe = xenevtchn_open(0, 0); 2046b6eb9b45SPaulina Szubarczyk xenevtchn_fd(xe); 2047b6eb9b45SPaulina Szubarczyk 2048b6eb9b45SPaulina Szubarczyk xg = xengnttab_open(0, 0); 2049b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy(xg, 0, seg); 2050b6eb9b45SPaulina Szubarczyk 2051b6eb9b45SPaulina Szubarczyk return 0; 2052b6eb9b45SPaulina Szubarczyk} 2053b6eb9b45SPaulina SzubarczykEOF 2054b6eb9b45SPaulina Szubarczyk compile_prog "" "$xen_libs $xen_stable_libs" 2055b6eb9b45SPaulina Szubarczyk then 2056f1167ee6SJuergen Gross xen_ctrl_version=40800 20571badb709SPaolo Bonzini xen=enabled 2058b6eb9b45SPaulina Szubarczyk elif 2059b6eb9b45SPaulina Szubarczyk cat > $TMPC <<EOF && 2060b6eb9b45SPaulina Szubarczyk/* 2061b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat 2062b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given. 20635eeb39c2SIan Campbell */ 20645eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API 20655eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API 20665eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API 20675eeb39c2SIan Campbell#include <xenctrl.h> 20685eeb39c2SIan Campbell#include <xenstore.h> 20695eeb39c2SIan Campbell#include <xenevtchn.h> 20705eeb39c2SIan Campbell#include <xengnttab.h> 20715eeb39c2SIan Campbell#include <xenforeignmemory.h> 20725eeb39c2SIan Campbell#include <stdint.h> 20735eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h> 20745eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS) 20755eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined 20765eeb39c2SIan Campbell#endif 20775eeb39c2SIan Campbellint main(void) { 20785eeb39c2SIan Campbell xc_interface *xc = NULL; 20795eeb39c2SIan Campbell xenforeignmemory_handle *xfmem; 20805eeb39c2SIan Campbell xenevtchn_handle *xe; 20815eeb39c2SIan Campbell xengnttab_handle *xg; 20825eeb39c2SIan Campbell 20835eeb39c2SIan Campbell xs_daemon_open(); 20845eeb39c2SIan Campbell 20855eeb39c2SIan Campbell xc = xc_interface_open(0, 0, 0); 20865eeb39c2SIan Campbell xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 20875eeb39c2SIan Campbell xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 20885eeb39c2SIan Campbell xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 20895eeb39c2SIan Campbell xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 20905eeb39c2SIan Campbell 20915eeb39c2SIan Campbell xfmem = xenforeignmemory_open(0, 0); 20925eeb39c2SIan Campbell xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 20935eeb39c2SIan Campbell 20945eeb39c2SIan Campbell xe = xenevtchn_open(0, 0); 20955eeb39c2SIan Campbell xenevtchn_fd(xe); 20965eeb39c2SIan Campbell 20975eeb39c2SIan Campbell xg = xengnttab_open(0, 0); 20985eeb39c2SIan Campbell xengnttab_map_grant_ref(xg, 0, 0, 0); 20995eeb39c2SIan Campbell 21005eeb39c2SIan Campbell return 0; 21015eeb39c2SIan Campbell} 21025eeb39c2SIan CampbellEOF 21035eeb39c2SIan Campbell compile_prog "" "$xen_libs $xen_stable_libs" 21045eeb39c2SIan Campbell then 2105f1167ee6SJuergen Gross xen_ctrl_version=40701 21061badb709SPaolo Bonzini xen=enabled 2107cdadde39SRoger Pau Monne 2108cdadde39SRoger Pau Monne # Xen 4.6 2109cdadde39SRoger Pau Monne elif 2110cdadde39SRoger Pau Monne cat > $TMPC <<EOF && 2111cdadde39SRoger Pau Monne#include <xenctrl.h> 2112e108a3c1SAnthony PERARD#include <xenstore.h> 2113d5b93ddfSAnthony PERARD#include <stdint.h> 2114d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h> 2115d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS) 2116d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined 2117d5b93ddfSAnthony PERARD#endif 2118d5b93ddfSAnthony PERARDint main(void) { 2119d5b93ddfSAnthony PERARD xc_interface *xc; 2120d5b93ddfSAnthony PERARD xs_daemon_open(); 2121d5b93ddfSAnthony PERARD xc = xc_interface_open(0, 0, 0); 2122d5b93ddfSAnthony PERARD xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2123d5b93ddfSAnthony PERARD xc_gnttab_open(NULL, 0); 2124b87de24eSAnthony PERARD xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 21258688e065SStefano Stabellini xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 2126d8b441a3SJan Beulich xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 212720a544c7SKonrad Rzeszutek Wilk xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); 2128d8b441a3SJan Beulich return 0; 2129d8b441a3SJan Beulich} 2130d8b441a3SJan BeulichEOF 2131d8b441a3SJan Beulich compile_prog "" "$xen_libs" 2132d8b441a3SJan Beulich then 2133f1167ee6SJuergen Gross xen_ctrl_version=40600 21341badb709SPaolo Bonzini xen=enabled 2135d8b441a3SJan Beulich 2136d8b441a3SJan Beulich # Xen 4.5 2137d8b441a3SJan Beulich elif 2138d8b441a3SJan Beulich cat > $TMPC <<EOF && 2139d8b441a3SJan Beulich#include <xenctrl.h> 2140d8b441a3SJan Beulich#include <xenstore.h> 2141d8b441a3SJan Beulich#include <stdint.h> 2142d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h> 2143d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS) 2144d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined 2145d8b441a3SJan Beulich#endif 2146d8b441a3SJan Beulichint main(void) { 2147d8b441a3SJan Beulich xc_interface *xc; 2148d8b441a3SJan Beulich xs_daemon_open(); 2149d8b441a3SJan Beulich xc = xc_interface_open(0, 0, 0); 2150d8b441a3SJan Beulich xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2151d8b441a3SJan Beulich xc_gnttab_open(NULL, 0); 2152d8b441a3SJan Beulich xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2153d8b441a3SJan Beulich xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 21543996e85cSPaul Durrant xc_hvm_create_ioreq_server(xc, 0, 0, NULL); 21553996e85cSPaul Durrant return 0; 21563996e85cSPaul Durrant} 21573996e85cSPaul DurrantEOF 21583996e85cSPaul Durrant compile_prog "" "$xen_libs" 21593996e85cSPaul Durrant then 2160f1167ee6SJuergen Gross xen_ctrl_version=40500 21611badb709SPaolo Bonzini xen=enabled 21623996e85cSPaul Durrant 21633996e85cSPaul Durrant elif 21643996e85cSPaul Durrant cat > $TMPC <<EOF && 21653996e85cSPaul Durrant#include <xenctrl.h> 21663996e85cSPaul Durrant#include <xenstore.h> 21673996e85cSPaul Durrant#include <stdint.h> 21683996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h> 21693996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS) 21703996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined 21713996e85cSPaul Durrant#endif 21723996e85cSPaul Durrantint main(void) { 21733996e85cSPaul Durrant xc_interface *xc; 21743996e85cSPaul Durrant xs_daemon_open(); 21753996e85cSPaul Durrant xc = xc_interface_open(0, 0, 0); 21763996e85cSPaul Durrant xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 21773996e85cSPaul Durrant xc_gnttab_open(NULL, 0); 21783996e85cSPaul Durrant xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 21793996e85cSPaul Durrant xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 21808688e065SStefano Stabellini return 0; 21818688e065SStefano Stabellini} 21828688e065SStefano StabelliniEOF 21838688e065SStefano Stabellini compile_prog "" "$xen_libs" 218469deef08SPeter Maydell then 2185f1167ee6SJuergen Gross xen_ctrl_version=40200 21861badb709SPaolo Bonzini xen=enabled 21878688e065SStefano Stabellini 2188e37630caSaliguori else 21891badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 2190edfb07edSIan Campbell feature_not_found "xen (unsupported version)" \ 2191edfb07edSIan Campbell "Install a supported xen (xen 4.2 or newer)" 2192fc321b4bSJuan Quintela fi 21931badb709SPaolo Bonzini xen=disabled 2194e37630caSaliguori fi 2195d5b93ddfSAnthony PERARD 21961badb709SPaolo Bonzini if test "$xen" = enabled; then 2197f1167ee6SJuergen Gross if test $xen_ctrl_version -ge 40701 ; then 2198582ea95fSMarc-André Lureau xen_libs="$xen_libs $xen_stable_libs " 21995eeb39c2SIan Campbell fi 2200d5b93ddfSAnthony PERARD fi 2201e37630caSaliguori fi 2202c1cdd9d5SJuergen Grossfi 2203e37630caSaliguori 2204d661d9a4SJustin Terry (VM)########################################## 22052da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries 22062da776dbSMichael R. Hinesif test "$rdma" != "no" ; then 22072da776dbSMichael R. Hines cat > $TMPC <<EOF 22082da776dbSMichael R. Hines#include <rdma/rdma_cma.h> 22092da776dbSMichael R. Hinesint main(void) { return 0; } 22102da776dbSMichael R. HinesEOF 2211ef6d4ccdSYuval Shaia rdma_libs="-lrdmacm -libverbs -libumad" 22122da776dbSMichael R. Hines if compile_prog "" "$rdma_libs" ; then 22132da776dbSMichael R. Hines rdma="yes" 22142da776dbSMichael R. Hines else 22152da776dbSMichael R. Hines if test "$rdma" = "yes" ; then 22162da776dbSMichael R. Hines error_exit \ 2217ef6d4ccdSYuval Shaia " OpenFabrics librdmacm/libibverbs/libibumad not present." \ 22182da776dbSMichael R. Hines " Your options:" \ 2219ef6d4ccdSYuval Shaia " (1) Fast: Install infiniband packages (devel) from your distro." \ 22202da776dbSMichael R. Hines " (2) Cleanest: Install libraries from www.openfabrics.org" \ 22212da776dbSMichael R. Hines " (3) Also: Install softiwarp if you don't have RDMA hardware" 22222da776dbSMichael R. Hines fi 22232da776dbSMichael R. Hines rdma="no" 22242da776dbSMichael R. Hines fi 22252da776dbSMichael R. Hinesfi 22262da776dbSMichael R. Hines 222721ab34c9SMarcel Apfelbaum########################################## 222821ab34c9SMarcel Apfelbaum# PVRDMA detection 222921ab34c9SMarcel Apfelbaum 223021ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF && 223121ab34c9SMarcel Apfelbaum#include <sys/mman.h> 223221ab34c9SMarcel Apfelbaum 223321ab34c9SMarcel Apfelbaumint 223421ab34c9SMarcel Apfelbaummain(void) 223521ab34c9SMarcel Apfelbaum{ 223621ab34c9SMarcel Apfelbaum char buf = 0; 223721ab34c9SMarcel Apfelbaum void *addr = &buf; 223821ab34c9SMarcel Apfelbaum addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED); 223921ab34c9SMarcel Apfelbaum 224021ab34c9SMarcel Apfelbaum return 0; 224121ab34c9SMarcel Apfelbaum} 224221ab34c9SMarcel ApfelbaumEOF 224321ab34c9SMarcel Apfelbaum 224421ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then 224521ab34c9SMarcel Apfelbaum case "$pvrdma" in 224621ab34c9SMarcel Apfelbaum "") 224721ab34c9SMarcel Apfelbaum if compile_prog "" ""; then 224821ab34c9SMarcel Apfelbaum pvrdma="yes" 224921ab34c9SMarcel Apfelbaum else 225021ab34c9SMarcel Apfelbaum pvrdma="no" 225121ab34c9SMarcel Apfelbaum fi 225221ab34c9SMarcel Apfelbaum ;; 225321ab34c9SMarcel Apfelbaum "yes") 225421ab34c9SMarcel Apfelbaum if ! compile_prog "" ""; then 225521ab34c9SMarcel Apfelbaum error_exit "PVRDMA is not supported since mremap is not implemented" 225621ab34c9SMarcel Apfelbaum fi 225721ab34c9SMarcel Apfelbaum pvrdma="yes" 225821ab34c9SMarcel Apfelbaum ;; 225921ab34c9SMarcel Apfelbaum "no") 226021ab34c9SMarcel Apfelbaum pvrdma="no" 226121ab34c9SMarcel Apfelbaum ;; 226221ab34c9SMarcel Apfelbaum esac 226321ab34c9SMarcel Apfelbaumelse 226421ab34c9SMarcel Apfelbaum if test "$pvrdma" = "yes" ; then 226521ab34c9SMarcel Apfelbaum error_exit "PVRDMA requires rdma suppport" 226621ab34c9SMarcel Apfelbaum fi 226721ab34c9SMarcel Apfelbaum pvrdma="no" 226821ab34c9SMarcel Apfelbaumfi 226995c6bff3SBenoît Canet 2270ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported 2271ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then 2272ee108585SYuval Shaia 2273ee108585SYuval Shaiacat > $TMPC <<EOF && 2274ee108585SYuval Shaia#include <infiniband/verbs.h> 2275ee108585SYuval Shaia 2276ee108585SYuval Shaiaint 2277ee108585SYuval Shaiamain(void) 2278ee108585SYuval Shaia{ 2279ee108585SYuval Shaia struct ibv_mr *mr; 2280ee108585SYuval Shaia struct ibv_pd *pd = NULL; 2281ee108585SYuval Shaia size_t length = 10; 2282ee108585SYuval Shaia uint64_t iova = 0; 2283ee108585SYuval Shaia int access = 0; 2284ee108585SYuval Shaia void *addr = NULL; 2285ee108585SYuval Shaia 2286ee108585SYuval Shaia mr = ibv_reg_mr_iova(pd, addr, length, iova, access); 2287ee108585SYuval Shaia 2288ee108585SYuval Shaia ibv_dereg_mr(mr); 2289ee108585SYuval Shaia 2290ee108585SYuval Shaia return 0; 2291ee108585SYuval Shaia} 2292ee108585SYuval ShaiaEOF 2293ee108585SYuval Shaia if ! compile_prog "" "-libverbs"; then 2294ee108585SYuval Shaia QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR" 2295ee108585SYuval Shaia fi 2296ee108585SYuval Shaiafi 2297ee108585SYuval Shaia 229895c6bff3SBenoît Canet########################################## 2299e18df141SAnthony Liguori# glib support probe 2300a52d28afSPaolo Bonzini 2301b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 2302aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 2303aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 2304a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 2305b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 2306b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 230754cb65d8SEmilio G. Cotafi 2308e26110cfSFam Zheng 2309aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 2310e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 231189138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 231289138857SStefan Weil glib_libs=$($pkg_config --libs $i) 2313e18df141SAnthony Liguori else 2314e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 2315e26110cfSFam Zheng fi 2316e26110cfSFam Zhengdone 2317e26110cfSFam Zheng 2318215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 2319215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 2320215b0c2fSPaolo Bonzini 2321215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 2322215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 2323215b0c2fSPaolo Bonzinifi 2324215b0c2fSPaolo Bonzini 232520cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then 232620cf7b8eSDenis Plotnikov pass=no 2327f876b765SMarc-André Lureau if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then 2328f876b765SMarc-André Lureau gio_cflags=$($pkg_config --cflags gio-2.0) 2329f876b765SMarc-André Lureau gio_libs=$($pkg_config --libs gio-2.0) 233025a97a56SMarc-André Lureau gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) 23315ecfb76cSPaolo Bonzini if ! has "$gdbus_codegen"; then 23320dba4897SMarc-André Lureau gdbus_codegen= 23330dba4897SMarc-André Lureau fi 233476346b62SPeter Maydell # Check that the libraries actually work -- Ubuntu 18.04 ships 233576346b62SPeter Maydell # with pkg-config --static --libs data for gio-2.0 that is missing 233676346b62SPeter Maydell # -lblkid and will give a link error. 233713ceae66SPeter Maydell cat > $TMPC <<EOF 233813ceae66SPeter Maydell#include <gio/gio.h> 233913ceae66SPeter Maydellint main(void) 234013ceae66SPeter Maydell{ 234113ceae66SPeter Maydell g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); 234213ceae66SPeter Maydell return 0; 234313ceae66SPeter Maydell} 234413ceae66SPeter MaydellEOF 234513ceae66SPeter Maydell if compile_prog "$gio_cflags" "$gio_libs" ; then 234620cf7b8eSDenis Plotnikov pass=yes 234776346b62SPeter Maydell else 234820cf7b8eSDenis Plotnikov pass=no 2349f876b765SMarc-André Lureau fi 2350f876b765SMarc-André Lureau 235120cf7b8eSDenis Plotnikov if test "$pass" = "yes" && 235220cf7b8eSDenis Plotnikov $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then 235325a97a56SMarc-André Lureau gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)" 235425a97a56SMarc-André Lureau gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)" 235525a97a56SMarc-André Lureau fi 235620cf7b8eSDenis Plotnikov fi 235720cf7b8eSDenis Plotnikov 235820cf7b8eSDenis Plotnikov if test "$pass" = "no"; then 235920cf7b8eSDenis Plotnikov if test "$gio" = "yes"; then 236020cf7b8eSDenis Plotnikov feature_not_found "gio" "Install libgio >= 2.0" 236120cf7b8eSDenis Plotnikov else 236220cf7b8eSDenis Plotnikov gio=no 236320cf7b8eSDenis Plotnikov fi 236420cf7b8eSDenis Plotnikov else 236520cf7b8eSDenis Plotnikov gio=yes 236620cf7b8eSDenis Plotnikov fi 236720cf7b8eSDenis Plotnikovfi 236825a97a56SMarc-André Lureau 2369977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 2370977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 2371977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 2372977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 2373977a82abSDaniel P. Berrangecat > $TMPC <<EOF 2374977a82abSDaniel P. Berrange#include <glib.h> 2375977a82abSDaniel P. Berrange#include <unistd.h> 2376977a82abSDaniel P. Berrange 2377977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 2378977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 2379977a82abSDaniel P. Berrange 2380977a82abSDaniel P. Berrangeint main(void) { 2381977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 2382977a82abSDaniel P. Berrange return 0; 2383977a82abSDaniel P. Berrange} 2384977a82abSDaniel P. BerrangeEOF 2385977a82abSDaniel P. Berrange 2386215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 2387977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 2388977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 2389977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 2390977a82abSDaniel P. Berrange "build target" 2391977a82abSDaniel P. Berrangefi 2392977a82abSDaniel P. Berrange 23939bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 23949bda600bSEric Blakecat > $TMPC << EOF 23959bda600bSEric Blake#include <glib.h> 23969bda600bSEric Blaketypedef struct Foo { 23979bda600bSEric Blake int i; 23989bda600bSEric Blake} Foo; 23999bda600bSEric Blakestatic void foo_free(Foo *f) 24009bda600bSEric Blake{ 24019bda600bSEric Blake g_free(f); 24029bda600bSEric Blake} 24039bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free); 24049bda600bSEric Blakeint main(void) { return 0; } 24059bda600bSEric BlakeEOF 24069bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 24079bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 24089bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 24095770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 24109bda600bSEric Blake fi 24119bda600bSEric Blakefi 24129bda600bSEric Blake 2413e26110cfSFam Zheng########################################## 2414e26110cfSFam Zheng# SHA command probe for modules 2415e26110cfSFam Zhengif test "$modules" = yes; then 2416e26110cfSFam Zheng shacmd_probe="sha1sum sha1 shasum" 2417e26110cfSFam Zheng for c in $shacmd_probe; do 24188ccefb91SFam Zheng if has $c; then 2419e26110cfSFam Zheng shacmd="$c" 2420e26110cfSFam Zheng break 2421e26110cfSFam Zheng fi 2422e26110cfSFam Zheng done 2423e26110cfSFam Zheng if test "$shacmd" = ""; then 2424e26110cfSFam Zheng error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" 2425e26110cfSFam Zheng fi 2426e18df141SAnthony Liguorifi 2427e18df141SAnthony Liguori 2428e18df141SAnthony Liguori########################################## 24297aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX 24303b8acc11SPaolo Bonzini 24317aaa6a16SPaolo Bonziniif test "$tpm" = ""; then 24327aaa6a16SPaolo Bonzini if test "$mingw32" = "yes"; then 24337aaa6a16SPaolo Bonzini tpm=no 24343b8acc11SPaolo Bonzini else 24357aaa6a16SPaolo Bonzini tpm=yes 24367aaa6a16SPaolo Bonzini fi 24377aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then 24387aaa6a16SPaolo Bonzini if test "$mingw32" = "yes" ; then 24397aaa6a16SPaolo Bonzini error_exit "TPM emulation only available on POSIX systems" 24407aaa6a16SPaolo Bonzini fi 24413b8acc11SPaolo Bonzinifi 24423b8acc11SPaolo Bonzini 24433b8acc11SPaolo Bonzini########################################## 2444f652e6afSaurel32# fdt probe 2445e169e1e1SPeter Maydell 2446fbb4121dSPaolo Bonzinicase "$fdt" in 2447fbb4121dSPaolo Bonzini auto | enabled | internal) 2448fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 2449aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 2450fbb4121dSPaolo Bonzini ;; 2451fbb4121dSPaolo Bonziniesac 2452f652e6afSaurel32 245320ff075bSMichael Walle########################################## 24549d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk) 2455b1546f32SGerd Hoffmann 2456da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then 2457bc6a3565SAkihiko Odaki epoxy=no 2458bc6a3565SAkihiko Odaki if $pkg_config epoxy; then 2459bc6a3565SAkihiko Odaki cat > $TMPC << EOF 2460bc6a3565SAkihiko Odaki#include <epoxy/egl.h> 2461bc6a3565SAkihiko Odakiint main(void) { return 0; } 2462bc6a3565SAkihiko OdakiEOF 2463bc6a3565SAkihiko Odaki if compile_prog "" "" ; then 2464bc6a3565SAkihiko Odaki epoxy=yes 2465bc6a3565SAkihiko Odaki fi 2466bc6a3565SAkihiko Odaki fi 2467bc6a3565SAkihiko Odaki 2468bc6a3565SAkihiko Odaki if test "$epoxy" = "yes" ; then 2469bc6a3565SAkihiko Odaki opengl_cflags="$($pkg_config --cflags epoxy)" 2470bc6a3565SAkihiko Odaki opengl_libs="$($pkg_config --libs epoxy)" 2471da076ffeSGerd Hoffmann opengl=yes 247220ff075bSMichael Walle else 2473da076ffeSGerd Hoffmann if test "$opengl" = "yes" ; then 2474bc6a3565SAkihiko Odaki feature_not_found "opengl" "Please install epoxy with EGL" 247520ff075bSMichael Walle fi 2476f676c67eSJeremy White opengl_cflags="" 2477da076ffeSGerd Hoffmann opengl_libs="" 2478da076ffeSGerd Hoffmann opengl=no 247920ff075bSMichael Walle fi 248020ff075bSMichael Wallefi 248120ff075bSMichael Walle 2482dcc38d1cSMarcelo Tosatti########################################## 2483a99d57bbSWanlong Gao# libnuma probe 2484a99d57bbSWanlong Gao 2485a99d57bbSWanlong Gaoif test "$numa" != "no" ; then 2486a99d57bbSWanlong Gao cat > $TMPC << EOF 2487a99d57bbSWanlong Gao#include <numa.h> 2488a99d57bbSWanlong Gaoint main(void) { return numa_available(); } 2489a99d57bbSWanlong GaoEOF 2490a99d57bbSWanlong Gao 2491a99d57bbSWanlong Gao if compile_prog "" "-lnuma" ; then 2492a99d57bbSWanlong Gao numa=yes 2493ab318051SMarc-André Lureau numa_libs="-lnuma" 2494a99d57bbSWanlong Gao else 2495a99d57bbSWanlong Gao if test "$numa" = "yes" ; then 2496a99d57bbSWanlong Gao feature_not_found "numa" "install numactl devel" 2497a99d57bbSWanlong Gao fi 2498a99d57bbSWanlong Gao numa=no 2499a99d57bbSWanlong Gao fi 2500a99d57bbSWanlong Gaofi 2501a99d57bbSWanlong Gao 2502955727d2SCortland Tölva# check for usbfs 2503955727d2SCortland Tölvahave_usbfs=no 2504955727d2SCortland Tölvaif test "$linux_user" = "yes"; then 250596566d09SThomas Petazzoni cat > $TMPC << EOF 250696566d09SThomas Petazzoni#include <linux/usbdevice_fs.h> 250796566d09SThomas Petazzoni 250896566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES 250996566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined" 251096566d09SThomas Petazzoni#endif 251196566d09SThomas Petazzoni 251296566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM 251396566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined" 251496566d09SThomas Petazzoni#endif 251596566d09SThomas Petazzoni 251696566d09SThomas Petazzoniint main(void) 251796566d09SThomas Petazzoni{ 251896566d09SThomas Petazzoni return 0; 251996566d09SThomas Petazzoni} 252096566d09SThomas PetazzoniEOF 252196566d09SThomas Petazzoni if compile_prog "" ""; then 2522955727d2SCortland Tölva have_usbfs=yes 2523955727d2SCortland Tölva fi 2524955727d2SCortland Tölvafi 2525751bcc39SMarc-André Lureau 2526de5071c5SBlue Swirl########################################## 2527d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win 2528d9840e25STomoki Sekiyama 25293b0d8643SPaolo Bonziniguest_agent_with_vss="no" 2530e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \ 2531e633a5c6SEric Blake test "$vss_win32_sdk" != "no" ; then 2532d9840e25STomoki Sekiyama case "$vss_win32_sdk" in 2533690604f6SMichael Roth "") vss_win32_include="-isystem $source_path" ;; 2534d9840e25STomoki Sekiyama *\ *) # The SDK is installed in "Program Files" by default, but we cannot 2535d9840e25STomoki Sekiyama # handle path with spaces. So we symlink the headers into ".sdk/vss". 2536690604f6SMichael Roth vss_win32_include="-isystem $source_path/.sdk/vss" 2537d9840e25STomoki Sekiyama symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc" 2538d9840e25STomoki Sekiyama ;; 2539690604f6SMichael Roth *) vss_win32_include="-isystem $vss_win32_sdk" 2540d9840e25STomoki Sekiyama esac 2541d9840e25STomoki Sekiyama cat > $TMPC << EOF 2542d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__ 2543d9840e25STomoki Sekiyama#include <inc/win2003/vss.h> 2544d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; } 2545d9840e25STomoki SekiyamaEOF 2546d9840e25STomoki Sekiyama if compile_prog "$vss_win32_include" "" ; then 2547d9840e25STomoki Sekiyama guest_agent_with_vss="yes" 2548d9840e25STomoki Sekiyama QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include" 2549315d3184SFam Zheng libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga" 2550f33ca81fSMichael Roth qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb" 2551d9840e25STomoki Sekiyama else 2552d9840e25STomoki Sekiyama if test "$vss_win32_sdk" != "" ; then 2553d9840e25STomoki Sekiyama echo "ERROR: Please download and install Microsoft VSS SDK:" 2554d9840e25STomoki Sekiyama echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490" 2555d9840e25STomoki Sekiyama echo "ERROR: On POSIX-systems, you can extract the SDK headers by:" 2556d9840e25STomoki Sekiyama echo "ERROR: scripts/extract-vsssdk-headers setup.exe" 2557d9840e25STomoki Sekiyama echo "ERROR: The headers are extracted in the directory \`inc'." 2558d9840e25STomoki Sekiyama feature_not_found "VSS support" 2559d9840e25STomoki Sekiyama fi 2560d9840e25STomoki Sekiyama fi 2561d9840e25STomoki Sekiyamafi 2562d9840e25STomoki Sekiyama 2563d9840e25STomoki Sekiyama########################################## 2564d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified) 2565d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent 2566d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the 2567d9840e25STomoki Sekiyama# pre-compiled .tlb file is included. 2568d9840e25STomoki Sekiyama 2569e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \ 2570e633a5c6SEric Blake test "$guest_agent_with_vss" = "yes" ; then 2571d9840e25STomoki Sekiyama if test -z "$win_sdk"; then 2572d9840e25STomoki Sekiyama programfiles="$PROGRAMFILES" 2573d9840e25STomoki Sekiyama test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432" 2574d9840e25STomoki Sekiyama if test -n "$programfiles"; then 2575d9840e25STomoki Sekiyama win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null 2576d9840e25STomoki Sekiyama else 2577d9840e25STomoki Sekiyama feature_not_found "Windows SDK" 2578d9840e25STomoki Sekiyama fi 2579d9840e25STomoki Sekiyama elif test "$win_sdk" = "no"; then 2580d9840e25STomoki Sekiyama win_sdk="" 2581d9840e25STomoki Sekiyama fi 2582d9840e25STomoki Sekiyamafi 2583d9840e25STomoki Sekiyama 2584d9840e25STomoki Sekiyama########################################## 258550cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h 25863b0d8643SPaolo Bonziniguest_agent_ntddscsi="no" 2587e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then 258850cbebb9SMichael Roth cat > $TMPC << EOF 258950cbebb9SMichael Roth#include <windows.h> 259050cbebb9SMichael Roth#include <ntddscsi.h> 259150cbebb9SMichael Rothint main(void) { 259250cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS) 259350cbebb9SMichael Roth#error Missing required ioctl definitions 259450cbebb9SMichael Roth#endif 259550cbebb9SMichael Roth SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 }; 259650cbebb9SMichael Roth return addr.Lun; 259750cbebb9SMichael Roth} 259850cbebb9SMichael RothEOF 259950cbebb9SMichael Roth if compile_prog "" "" ; then 260050cbebb9SMichael Roth guest_agent_ntddscsi=yes 2601996b9cdcSMatt Hines libs_qga="-lsetupapi -lcfgmgr32 $libs_qga" 260250cbebb9SMichael Roth fi 260350cbebb9SMichael Rothfi 260450cbebb9SMichael Roth 260550cbebb9SMichael Roth########################################## 26068ca80760SRichard Henderson# capstone 26078ca80760SRichard Henderson 2608e219c499SRichard Hendersoncase "$capstone" in 26098b18cdbfSRichard Henderson auto | enabled | internal) 26108b18cdbfSRichard Henderson # Simpler to always update submodule, even if not needed. 2611e219c499SRichard Henderson git_submodules="${git_submodules} capstone" 2612e219c499SRichard Henderson ;; 2613e219c499SRichard Hendersonesac 26148ca80760SRichard Henderson 26158ca80760SRichard Henderson########################################## 2616519175a2SAlex Barcelo# check and set a backend for coroutine 2617d0e2fce5SAneesh Kumar K.V 26187c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 261933c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 262033c53c54SDaniel P. Berrange# specific one. 26217c2acc70SPeter Maydell 26227c2acc70SPeter Maydellucontext_works=no 2623d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 2624d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 2625d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 2626cdf84806SPeter Maydell#ifdef __stub_makecontext 2627cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 2628cdf84806SPeter Maydell#endif 262975cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 2630d0e2fce5SAneesh Kumar K.VEOF 2631d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 26327c2acc70SPeter Maydell ucontext_works=yes 2633d0e2fce5SAneesh Kumar K.V fi 2634519175a2SAlex Barcelofi 26357c2acc70SPeter Maydell 26367c2acc70SPeter Maydellif test "$coroutine" = ""; then 26377c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 26387c2acc70SPeter Maydell coroutine=win32 26397c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 26407c2acc70SPeter Maydell coroutine=ucontext 2641519175a2SAlex Barcelo else 26427c2acc70SPeter Maydell coroutine=sigaltstack 26437c2acc70SPeter Maydell fi 26447c2acc70SPeter Maydellelse 26457c2acc70SPeter Maydell case $coroutine in 26467c2acc70SPeter Maydell windows) 26477c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 26487c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 26497c2acc70SPeter Maydell fi 26507c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 26517c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 26527c2acc70SPeter Maydell coroutine=win32 26537c2acc70SPeter Maydell ;; 26547c2acc70SPeter Maydell ucontext) 26557c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 26567c2acc70SPeter Maydell feature_not_found "ucontext" 26577c2acc70SPeter Maydell fi 26587c2acc70SPeter Maydell ;; 265933c53c54SDaniel P. Berrange sigaltstack) 26607c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 26617c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 26627c2acc70SPeter Maydell fi 26637c2acc70SPeter Maydell ;; 26647c2acc70SPeter Maydell *) 266576ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 26667c2acc70SPeter Maydell ;; 26677c2acc70SPeter Maydell esac 2668d0e2fce5SAneesh Kumar K.Vfi 2669d0e2fce5SAneesh Kumar K.V 267070c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then 267170c60c08SStefan Hajnoczi coroutine_pool=yes 267270c60c08SStefan Hajnoczifi 267370c60c08SStefan Hajnoczi 26747d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then 26757d992e4dSPeter Lieven if test "$coroutine_pool" = "yes"; then 26767d992e4dSPeter Lieven echo "WARN: disabling coroutine pool for stack usage debugging" 26777d992e4dSPeter Lieven coroutine_pool=no 26787d992e4dSPeter Lieven fi 26797d992e4dSPeter Lievenfi 26807d992e4dSPeter Lieven 26811e4f6065SDaniele Buono################################################## 26821e4f6065SDaniele Buono# SafeStack 26831e4f6065SDaniele Buono 26841e4f6065SDaniele Buono 26851e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 26861e4f6065SDaniele Buonocat > $TMPC << EOF 26871e4f6065SDaniele Buonoint main(int argc, char *argv[]) 26881e4f6065SDaniele Buono{ 26891e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 26901e4f6065SDaniele Buono#error SafeStack Disabled 26911e4f6065SDaniele Buono#endif 26921e4f6065SDaniele Buono return 0; 26931e4f6065SDaniele Buono} 26941e4f6065SDaniele BuonoEOF 26951e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 26961e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 26971e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 26981e4f6065SDaniele Buono # Flag needed both at compilation and at linking 26991e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 27001e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 27011e4f6065SDaniele Buono else 27021e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 27031e4f6065SDaniele Buono fi 27041e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 27051e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 27061e4f6065SDaniele Buono fi 27071e4f6065SDaniele Buonoelse 27081e4f6065SDaniele Buonocat > $TMPC << EOF 27091e4f6065SDaniele Buonoint main(int argc, char *argv[]) 27101e4f6065SDaniele Buono{ 27111e4f6065SDaniele Buono#if defined(__has_feature) 27121e4f6065SDaniele Buono#if __has_feature(safe_stack) 27131e4f6065SDaniele Buono#error SafeStack Enabled 27141e4f6065SDaniele Buono#endif 27151e4f6065SDaniele Buono#endif 27161e4f6065SDaniele Buono return 0; 27171e4f6065SDaniele Buono} 27181e4f6065SDaniele BuonoEOF 27191e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 27201e4f6065SDaniele Buono # Make sure that safe-stack is disabled 27211e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 27221e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 27231e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 27241e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 27251e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 27261e4f6065SDaniele Buono fi 27271e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 27281e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 27291e4f6065SDaniele Buono fi 27301e4f6065SDaniele Buonoelse # "$safe_stack" = "" 27311e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 27321e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 27331e4f6065SDaniele Buono safe_stack="no" 27341e4f6065SDaniele Buono else 27351e4f6065SDaniele Buono safe_stack="yes" 27361e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 27371e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 27381e4f6065SDaniele Buono fi 27391e4f6065SDaniele Buono fi 27401e4f6065SDaniele Buonofi 27411e4f6065SDaniele Buonofi 27427d992e4dSPeter Lieven 274376a347e1SRichard Henderson######################################## 274476a347e1SRichard Henderson# check if cpuid.h is usable. 274576a347e1SRichard Henderson 274676a347e1SRichard Hendersoncat > $TMPC << EOF 274776a347e1SRichard Henderson#include <cpuid.h> 274876a347e1SRichard Hendersonint main(void) { 2749774d566cSPeter Maydell unsigned a, b, c, d; 27502a728de1SMichael S. Tsirkin unsigned max = __get_cpuid_max(0, 0); 2751774d566cSPeter Maydell 2752774d566cSPeter Maydell if (max >= 1) { 2753774d566cSPeter Maydell __cpuid(1, a, b, c, d); 2754774d566cSPeter Maydell } 2755774d566cSPeter Maydell 2756774d566cSPeter Maydell if (max >= 7) { 2757774d566cSPeter Maydell __cpuid_count(7, 0, a, b, c, d); 2758774d566cSPeter Maydell } 2759774d566cSPeter Maydell 276076a347e1SRichard Henderson return 0; 276176a347e1SRichard Henderson} 276276a347e1SRichard HendersonEOF 276376a347e1SRichard Hendersonif compile_prog "" "" ; then 276476a347e1SRichard Henderson cpuid_h=yes 276576a347e1SRichard Hendersonfi 276676a347e1SRichard Henderson 27675dd89908SRichard Henderson########################################## 27685dd89908SRichard Henderson# avx2 optimization requirement check 27695dd89908SRichard Henderson# 27705dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable, 27715dd89908SRichard Henderson# since we won't be able to select the new routines. 27725dd89908SRichard Henderson 2773e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then 27745dd89908SRichard Henderson cat > $TMPC << EOF 27755dd89908SRichard Henderson#pragma GCC push_options 27765dd89908SRichard Henderson#pragma GCC target("avx2") 27775dd89908SRichard Henderson#include <cpuid.h> 27785dd89908SRichard Henderson#include <immintrin.h> 27795dd89908SRichard Hendersonstatic int bar(void *a) { 27805dd89908SRichard Henderson __m256i x = *(__m256i *)a; 27815dd89908SRichard Henderson return _mm256_testz_si256(x, x); 27825dd89908SRichard Henderson} 27835dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); } 27845dd89908SRichard HendersonEOF 27855b945f23SRichard Henderson if compile_object "-Werror" ; then 27865dd89908SRichard Henderson avx2_opt="yes" 278786583a07SLiam Merwick else 278886583a07SLiam Merwick avx2_opt="no" 27895dd89908SRichard Henderson fi 27905dd89908SRichard Hendersonfi 27915dd89908SRichard Henderson 27926b8cd447SRobert Hoo########################################## 27936b8cd447SRobert Hoo# avx512f optimization requirement check 27946b8cd447SRobert Hoo# 27956b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable, 27966b8cd447SRobert Hoo# since we won't be able to select the new routines. 27976b8cd447SRobert Hoo# by default, it is turned off. 27986b8cd447SRobert Hoo# if user explicitly want to enable it, check environment 27996b8cd447SRobert Hoo 28006b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then 28016b8cd447SRobert Hoo cat > $TMPC << EOF 28026b8cd447SRobert Hoo#pragma GCC push_options 28036b8cd447SRobert Hoo#pragma GCC target("avx512f") 28046b8cd447SRobert Hoo#include <cpuid.h> 28056b8cd447SRobert Hoo#include <immintrin.h> 28066b8cd447SRobert Hoostatic int bar(void *a) { 28076b8cd447SRobert Hoo __m512i x = *(__m512i *)a; 28086b8cd447SRobert Hoo return _mm512_test_epi64_mask(x, x); 28096b8cd447SRobert Hoo} 28106b8cd447SRobert Hooint main(int argc, char *argv[]) 28116b8cd447SRobert Hoo{ 28126b8cd447SRobert Hoo return bar(argv[0]); 28136b8cd447SRobert Hoo} 28146b8cd447SRobert HooEOF 28155b945f23SRichard Henderson if ! compile_object "-Werror" ; then 28166b8cd447SRobert Hoo avx512f_opt="no" 28176b8cd447SRobert Hoo fi 28186b8cd447SRobert Hooelse 28196b8cd447SRobert Hoo avx512f_opt="no" 28206b8cd447SRobert Hoofi 28216b8cd447SRobert Hoo 2822f540166bSRichard Henderson######################################## 2823f540166bSRichard Henderson# check if __[u]int128_t is usable. 2824f540166bSRichard Henderson 2825f540166bSRichard Hendersonint128=no 2826f540166bSRichard Hendersoncat > $TMPC << EOF 2827f540166bSRichard Henderson__int128_t a; 2828f540166bSRichard Henderson__uint128_t b; 2829f540166bSRichard Hendersonint main (void) { 2830f540166bSRichard Henderson a = a + b; 2831f540166bSRichard Henderson b = a * b; 2832464e3671SPeter Maydell a = a * a; 2833f540166bSRichard Henderson return 0; 2834f540166bSRichard Henderson} 2835f540166bSRichard HendersonEOF 2836f540166bSRichard Hendersonif compile_prog "" "" ; then 2837f540166bSRichard Henderson int128=yes 2838f540166bSRichard Hendersonfi 283976a347e1SRichard Henderson 28407ebee43eSRichard Henderson######################################### 28417ebee43eSRichard Henderson# See if 128-bit atomic operations are supported. 28427ebee43eSRichard Henderson 28437ebee43eSRichard Hendersonatomic128=no 28447ebee43eSRichard Hendersonif test "$int128" = "yes"; then 28457ebee43eSRichard Henderson cat > $TMPC << EOF 28467ebee43eSRichard Hendersonint main(void) 28477ebee43eSRichard Henderson{ 28487ebee43eSRichard Henderson unsigned __int128 x = 0, y = 0; 2849bceac547SThomas Huth y = __atomic_load(&x, 0); 2850bceac547SThomas Huth __atomic_store(&x, y, 0); 2851bceac547SThomas Huth __atomic_compare_exchange(&x, &y, x, 0, 0, 0); 28527ebee43eSRichard Henderson return 0; 28537ebee43eSRichard Henderson} 28547ebee43eSRichard HendersonEOF 28557ebee43eSRichard Henderson if compile_prog "" "" ; then 28567ebee43eSRichard Henderson atomic128=yes 28577ebee43eSRichard Henderson fi 28587ebee43eSRichard Hendersonfi 28597ebee43eSRichard Henderson 2860e6cd4bb5SRichard Hendersoncmpxchg128=no 2861e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then 2862e6cd4bb5SRichard Henderson cat > $TMPC << EOF 2863e6cd4bb5SRichard Hendersonint main(void) 2864e6cd4bb5SRichard Henderson{ 2865e6cd4bb5SRichard Henderson unsigned __int128 x = 0, y = 0; 2866e6cd4bb5SRichard Henderson __sync_val_compare_and_swap_16(&x, y, x); 2867e6cd4bb5SRichard Henderson return 0; 2868e6cd4bb5SRichard Henderson} 2869e6cd4bb5SRichard HendersonEOF 2870e6cd4bb5SRichard Henderson if compile_prog "" "" ; then 2871e6cd4bb5SRichard Henderson cmpxchg128=yes 2872e6cd4bb5SRichard Henderson fi 2873e6cd4bb5SRichard Hendersonfi 2874e6cd4bb5SRichard Henderson 2875fd0e6053SJohn Snow######################################## 2876fd0e6053SJohn Snow# check if ccache is interfering with 2877fd0e6053SJohn Snow# semantic analysis of macros 2878fd0e6053SJohn Snow 28795e4dfd3dSJohn Snowunset CCACHE_CPP2 2880fd0e6053SJohn Snowccache_cpp2=no 2881fd0e6053SJohn Snowcat > $TMPC << EOF 2882fd0e6053SJohn Snowstatic const int Z = 1; 2883fd0e6053SJohn Snow#define fn() ({ Z; }) 2884fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 2885fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 2886fd0e6053SJohn Snow#define ID(X) (X) 2887fd0e6053SJohn Snowint main(int argc, char *argv[]) 2888fd0e6053SJohn Snow{ 2889fd0e6053SJohn Snow int x = 0, y = 0; 2890fd0e6053SJohn Snow x = ID(x); 2891fd0e6053SJohn Snow x = fn(); 2892fd0e6053SJohn Snow fn(); 2893fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 2894fd0e6053SJohn Snow if (TAUT(Z)) return 0; 2895fd0e6053SJohn Snow return 0; 2896fd0e6053SJohn Snow} 2897fd0e6053SJohn SnowEOF 2898fd0e6053SJohn Snow 2899fd0e6053SJohn Snowif ! compile_object "-Werror"; then 2900fd0e6053SJohn Snow ccache_cpp2=yes 2901fd0e6053SJohn Snowfi 2902fd0e6053SJohn Snow 2903b553a042SJohn Snow################################################# 2904b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 2905b553a042SJohn Snow 2906b553a042SJohn Snowif test "$fortify_source" != "no"; then 2907b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 2908b553a042SJohn Snow fortify_source="no"; 2909e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 2910cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 2911b553a042SJohn Snow fortify_source="no"; 2912b553a042SJohn Snow else 2913b553a042SJohn Snow fortify_source="yes" 2914b553a042SJohn Snow fi 2915b553a042SJohn Snowfi 2916b553a042SJohn Snow 2917d2042378SAneesh Kumar K.V########################################## 2918a40161cbSPaolo Bonzini# check for usable membarrier system call 2919a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then 2920a40161cbSPaolo Bonzini have_membarrier=no 2921a40161cbSPaolo Bonzini if test "$mingw32" = "yes" ; then 2922a40161cbSPaolo Bonzini have_membarrier=yes 2923a40161cbSPaolo Bonzini elif test "$linux" = "yes" ; then 2924a40161cbSPaolo Bonzini cat > $TMPC << EOF 2925a40161cbSPaolo Bonzini #include <linux/membarrier.h> 2926a40161cbSPaolo Bonzini #include <sys/syscall.h> 2927a40161cbSPaolo Bonzini #include <unistd.h> 2928a40161cbSPaolo Bonzini #include <stdlib.h> 2929a40161cbSPaolo Bonzini int main(void) { 2930a40161cbSPaolo Bonzini syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0); 2931a40161cbSPaolo Bonzini syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0); 2932a40161cbSPaolo Bonzini exit(0); 2933a40161cbSPaolo Bonzini } 2934a40161cbSPaolo BonziniEOF 2935a40161cbSPaolo Bonzini if compile_prog "" "" ; then 2936a40161cbSPaolo Bonzini have_membarrier=yes 2937a40161cbSPaolo Bonzini fi 2938a40161cbSPaolo Bonzini fi 2939a40161cbSPaolo Bonzini if test "$have_membarrier" = "no"; then 2940a40161cbSPaolo Bonzini feature_not_found "membarrier" "membarrier system call not available" 2941a40161cbSPaolo Bonzini fi 2942a40161cbSPaolo Bonzinielse 2943a40161cbSPaolo Bonzini # Do not enable it by default even for Mingw32, because it doesn't 2944a40161cbSPaolo Bonzini # work on Wine. 2945a40161cbSPaolo Bonzini membarrier=no 2946a40161cbSPaolo Bonzinifi 2947a40161cbSPaolo Bonzini 2948a40161cbSPaolo Bonzini########################################## 2949f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment 29504f67366eSThomas Huthhave_afalg=no 2951f0d92b56SLongpeng(Mike)cat > $TMPC << EOF 2952f0d92b56SLongpeng(Mike)#include <errno.h> 2953f0d92b56SLongpeng(Mike)#include <sys/types.h> 2954f0d92b56SLongpeng(Mike)#include <sys/socket.h> 2955f0d92b56SLongpeng(Mike)#include <linux/if_alg.h> 2956f0d92b56SLongpeng(Mike)int main(void) { 2957f0d92b56SLongpeng(Mike) int sock; 2958f0d92b56SLongpeng(Mike) sock = socket(AF_ALG, SOCK_SEQPACKET, 0); 2959f0d92b56SLongpeng(Mike) return sock; 2960f0d92b56SLongpeng(Mike)} 2961f0d92b56SLongpeng(Mike)EOF 2962f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then 2963f0d92b56SLongpeng(Mike) have_afalg=yes 2964f0d92b56SLongpeng(Mike)fi 2965f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" 2966f0d92b56SLongpeng(Mike)then 2967f0d92b56SLongpeng(Mike) if test "$have_afalg" != "yes" 2968f0d92b56SLongpeng(Mike) then 2969f0d92b56SLongpeng(Mike) error_exit "AF_ALG requested but could not be detected" 2970f0d92b56SLongpeng(Mike) fi 2971f0d92b56SLongpeng(Mike)fi 2972f0d92b56SLongpeng(Mike) 2973f0d92b56SLongpeng(Mike) 2974db1ed1abSRichard Henderson########################################## 2975247724cbSMarc-André Lureau# checks for sanitizers 2976247724cbSMarc-André Lureau 2977247724cbSMarc-André Lureauhave_asan=no 2978247724cbSMarc-André Lureauhave_ubsan=no 2979d83414e1SMarc-André Lureauhave_asan_iface_h=no 2980d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 2981247724cbSMarc-André Lureau 2982247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 2983b9f44da2SMarc-André Lureau write_c_skeleton 2984247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 2985247724cbSMarc-André Lureau have_asan=yes 2986247724cbSMarc-André Lureau fi 2987b9f44da2SMarc-André Lureau 2988b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 2989b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 2990b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 2991b9f44da2SMarc-André Lureau cat > $TMPC << EOF 2992b9f44da2SMarc-André Lureau#include <stdlib.h> 2993b9f44da2SMarc-André Lureauint main(void) { 2994b9f44da2SMarc-André Lureau void *tmp = malloc(10); 2995f2dfe54cSLeonid Bloch if (tmp != NULL) { 2996b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 2997b9f44da2SMarc-André Lureau } 2998d1abf3fcSOlaf Hering return 1; 2999f2dfe54cSLeonid Bloch} 3000b9f44da2SMarc-André LureauEOF 3001247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 3002247724cbSMarc-André Lureau have_ubsan=yes 3003247724cbSMarc-André Lureau fi 3004d83414e1SMarc-André Lureau 3005d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 3006d83414e1SMarc-André Lureau have_asan_iface_h=yes 3007d83414e1SMarc-André Lureau fi 3008d83414e1SMarc-André Lureau 3009d83414e1SMarc-André Lureau cat > $TMPC << EOF 3010d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 3011d83414e1SMarc-André Lureauint main(void) { 3012d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 3013d83414e1SMarc-André Lureau return 0; 3014d83414e1SMarc-André Lureau} 3015d83414e1SMarc-André LureauEOF 3016d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 3017d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 3018d83414e1SMarc-André Lureau fi 3019247724cbSMarc-André Lureaufi 3020247724cbSMarc-André Lureau 30210aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 30220aebab04SLingfeng Yang# keep it separate until that is not the case. 30230aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 30240aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 30250aebab04SLingfeng Yangfi 30260aebab04SLingfeng Yanghave_tsan=no 30270aebab04SLingfeng Yanghave_tsan_iface_fiber=no 30280aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 30290aebab04SLingfeng Yang write_c_skeleton 30300aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 30310aebab04SLingfeng Yang have_tsan=yes 30320aebab04SLingfeng Yang fi 30330aebab04SLingfeng Yang cat > $TMPC << EOF 30340aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 30350aebab04SLingfeng Yangint main(void) { 30360aebab04SLingfeng Yang __tsan_create_fiber(0); 30370aebab04SLingfeng Yang return 0; 30380aebab04SLingfeng Yang} 30390aebab04SLingfeng YangEOF 30400aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 30410aebab04SLingfeng Yang have_tsan_iface_fiber=yes 30420aebab04SLingfeng Yang fi 30430aebab04SLingfeng Yangfi 30440aebab04SLingfeng Yang 3045adc28027SAlexander Bulekov########################################## 3046675b9b53SMarc-André Lureau# check for slirp 3047675b9b53SMarc-André Lureau 3048675b9b53SMarc-André Lureaucase "$slirp" in 30494d34a86bSPaolo Bonzini auto | enabled | internal) 30504d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 30517c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 3052675b9b53SMarc-André Lureau ;; 3053675b9b53SMarc-André Lureauesac 3054675b9b53SMarc-André Lureau 3055b8e0c493SJoelle van Dyne# Check for slirp smbd dupport 3056b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}} 3057b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then 3058b8e0c493SJoelle van Dyne if test "$mingw32" = "yes" ; then 3059b8e0c493SJoelle van Dyne if test "$slirp_smbd" = "yes" ; then 3060b8e0c493SJoelle van Dyne error_exit "Host smbd not supported on this platform." 3061b8e0c493SJoelle van Dyne fi 3062b8e0c493SJoelle van Dyne slirp_smbd=no 3063b8e0c493SJoelle van Dyne else 3064b8e0c493SJoelle van Dyne slirp_smbd=yes 3065b8e0c493SJoelle van Dyne fi 3066b8e0c493SJoelle van Dynefi 3067b8e0c493SJoelle van Dyne 306854e7aac0SAlexey Krasikov########################################## 306954e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall 307054e7aac0SAlexey Krasikov 307154e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then 307254e7aac0SAlexey Krasikov 307354e7aac0SAlexey Krasikov have_keyring=no 307454e7aac0SAlexey Krasikov cat > $TMPC << EOF 307554e7aac0SAlexey Krasikov#include <errno.h> 307654e7aac0SAlexey Krasikov#include <asm/unistd.h> 307754e7aac0SAlexey Krasikov#include <linux/keyctl.h> 307854e7aac0SAlexey Krasikov#include <unistd.h> 307954e7aac0SAlexey Krasikovint main(void) { 308054e7aac0SAlexey Krasikov return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0); 308154e7aac0SAlexey Krasikov} 308254e7aac0SAlexey KrasikovEOF 308354e7aac0SAlexey Krasikov if compile_prog "" "" ; then 308454e7aac0SAlexey Krasikov have_keyring=yes 308554e7aac0SAlexey Krasikov fi 308654e7aac0SAlexey Krasikovfi 308754e7aac0SAlexey Krasikovif test "$secret_keyring" != "no" 308854e7aac0SAlexey Krasikovthen 3089b418d265SDavid Edmondson if test "$have_keyring" = "yes" 309054e7aac0SAlexey Krasikov then 309154e7aac0SAlexey Krasikov secret_keyring=yes 309254e7aac0SAlexey Krasikov else 309354e7aac0SAlexey Krasikov if test "$secret_keyring" = "yes" 309454e7aac0SAlexey Krasikov then 309554e7aac0SAlexey Krasikov error_exit "syscall __NR_keyctl requested, \ 309654e7aac0SAlexey Krasikovbut not implemented on your system" 309754e7aac0SAlexey Krasikov else 309854e7aac0SAlexey Krasikov secret_keyring=no 309954e7aac0SAlexey Krasikov fi 310054e7aac0SAlexey Krasikov fi 310154e7aac0SAlexey Krasikovfi 310254e7aac0SAlexey Krasikov 310392500362SAlexey Krasikov########################################## 3104e86ecd4bSJuan Quintela# End of CC checks 3105e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 3106e86ecd4bSJuan Quintela 3107d83414e1SMarc-André Lureauwrite_c_skeleton 3108d83414e1SMarc-André Lureau 31091d728c39SBlue Swirlif test "$gcov" = "yes" ; then 3110bf0e56a3SMarc-André Lureau : 3111b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then 3112086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 3113086d5f75SPaolo Bonzini debug=no 3114086d5f75SPaolo Bonzinifi 3115086d5f75SPaolo Bonzini 3116086d5f75SPaolo Bonzinicase "$ARCH" in 3117086d5f75SPaolo Bonzinialpha) 3118086d5f75SPaolo Bonzini # Ensure there's only a single GP 3119086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 3120086d5f75SPaolo Bonzini;; 3121086d5f75SPaolo Bonziniesac 3122086d5f75SPaolo Bonzini 3123086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then 3124086d5f75SPaolo Bonzini QEMU_CFLAGS="-p $QEMU_CFLAGS" 3125086d5f75SPaolo Bonzini QEMU_LDFLAGS="-p $QEMU_LDFLAGS" 3126086d5f75SPaolo Bonzinifi 3127a316e378SJuan Quintela 3128247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 3129db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 3130db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 3131d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 3132d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 3133d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 3134d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 3135d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 3136d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 3137d83414e1SMarc-André Lureau fi 3138247724cbSMarc-André Lureaufi 31390aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 31400aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 31410aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 31420aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 31430aebab04SLingfeng Yang else 31440aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 31450aebab04SLingfeng Yang fi 31460aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 31470aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 31480aebab04SLingfeng Yangfi 3149247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 3150db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 3151db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 3152247724cbSMarc-André Lureaufi 3153247724cbSMarc-André Lureau 31546542aa9cSPeter Lieven########################################## 31553efac6ebSTomáš Golembiovský 31560aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 31570aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 3158e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 3159db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 3160e86ecd4bSJuan Quintela fi 3161e86ecd4bSJuan Quintelafi 3162e86ecd4bSJuan Quintela 3163952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available 3164952afb71SBlue Swirlif test "$mingw32" = "yes" ; then 3165cb8baa77SMark Cave-Ayland flags="--no-seh --nxcompat" 3166cb8baa77SMark Cave-Ayland 3167cb8baa77SMark Cave-Ayland # Disable ASLR for debug builds to allow debugging with gdb 3168cb8baa77SMark Cave-Ayland if test "$debug" = "no" ; then 3169cb8baa77SMark Cave-Ayland flags="--dynamicbase $flags" 3170cb8baa77SMark Cave-Ayland fi 3171cb8baa77SMark Cave-Ayland 3172cb8baa77SMark Cave-Ayland for flag in $flags; do 3173e9a3591fSChristian Borntraeger if ld_has $flag ; then 3174db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS" 3175952afb71SBlue Swirl fi 3176952afb71SBlue Swirl done 3177952afb71SBlue Swirlfi 3178952afb71SBlue Swirl 31799d6bc27bSMichael Roth# Probe for guest agent support/options 31809d6bc27bSMichael Roth 3181e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then 3182a5125905SLaurent Vivier if [ "$softmmu" = no -a "$want_tools" = no ] ; then 3183a5125905SLaurent Vivier guest_agent=no 3184a5125905SLaurent Vivier elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then 3185e8ef31a3SMichael Tokarev guest_agent=yes 3186e8ef31a3SMichael Tokarev elif [ "$guest_agent" != yes ]; then 3187e8ef31a3SMichael Tokarev guest_agent=no 3188e8ef31a3SMichael Tokarev else 3189e8ef31a3SMichael Tokarev error_exit "Guest agent is not supported on this platform" 3190ca35f780SPaolo Bonzini fi 31914b1c11fdSDaniel P. Berrangefi 3192ca35f780SPaolo Bonzini 3193b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 31949d6bc27bSMichael Roth 31959d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 31969d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 31979d6bc27bSMichael Rothfi 31989d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 31999d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 32009d6bc27bSMichael Rothfi 32019d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 320289138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 32039d6bc27bSMichael Rothfi 32049d6bc27bSMichael Roth 3205b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 32069d6bc27bSMichael Roth 3207ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 3208ca35f780SPaolo Bonziniroms= 3209e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 3210ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 3211ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 3212e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 3213c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 3214c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 3215c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 3216e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 3217e57218b6SPeter Maydell ld_i386_emulation="$emu" 3218ca35f780SPaolo Bonzini roms="optionrom" 3219e57218b6SPeter Maydell break 3220e57218b6SPeter Maydell fi 3221e57218b6SPeter Maydell done 3222ca35f780SPaolo Bonzinifi 3223ca35f780SPaolo Bonzini 32242e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 3225a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 32269933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 32272e33c3f8SThomas Huth write_c_skeleton 3228a5b2afd5SThomas Huth compile_prog "-march=z900" "" 3229a5b2afd5SThomas Huth has_z900=$? 32303af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 3231a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 3232a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 3233a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 3234a5b2afd5SThomas Huth fi 32359933c305SChristian Borntraeger roms="$roms s390-ccw" 32361ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 32371ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 32381ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 32391ef6bfc2SPhilippe Mathieu-Daudé fi 32409933c305SChristian Borntraegerfi 32419933c305SChristian Borntraeger 324211cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 324311cde1c8SBruno 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. 324411cde1c8SBruno Dominguezif has $cxx; then 324511cde1c8SBruno Dominguez cat > $TMPC <<EOF 324611cde1c8SBruno Dominguezint c_function(void); 324711cde1c8SBruno Dominguezint main(void) { return c_function(); } 324811cde1c8SBruno DominguezEOF 324911cde1c8SBruno Dominguez 325011cde1c8SBruno Dominguez compile_object 325111cde1c8SBruno Dominguez 325211cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 325311cde1c8SBruno Dominguezextern "C" { 325411cde1c8SBruno Dominguez int c_function(void); 325511cde1c8SBruno Dominguez} 325611cde1c8SBruno Dominguezint c_function(void) { return 42; } 325711cde1c8SBruno DominguezEOF 325811cde1c8SBruno Dominguez 325911cde1c8SBruno Dominguez update_cxxflags 326011cde1c8SBruno Dominguez 3261a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 326211cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 326311cde1c8SBruno Dominguez : 326411cde1c8SBruno Dominguez else 326511cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 326611cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 326711cde1c8SBruno Dominguez cxx= 326811cde1c8SBruno Dominguez fi 326911cde1c8SBruno Dominguezelse 327011cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 327111cde1c8SBruno Dominguez cxx= 327211cde1c8SBruno Dominguezfi 327311cde1c8SBruno Dominguez 32747d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 32757d7dbf9dSDan Streetman exit 1 32765d91a2edSYonggang Luofi 32775d91a2edSYonggang Luo 327898ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 327997a847bcSbellard 328098ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 328198ec69acSJuan Quintelaecho >> $config_host_mak 328298ec69acSJuan Quintela 3283e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 3284cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 3285aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 32867d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 3287804edf29SJuan Quintela 3288f8393946Saurel32if test "$debug_tcg" = "yes" ; then 32892358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 3290f8393946Saurel32fi 329167b915a5Sbellardif test "$mingw32" = "yes" ; then 329298ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 3293d9840e25STomoki Sekiyama if test "$guest_agent_with_vss" = "yes" ; then 3294d9840e25STomoki Sekiyama echo "CONFIG_QGA_VSS=y" >> $config_host_mak 3295f33ca81fSMichael Roth echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak 3296d9840e25STomoki Sekiyama echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak 3297d9840e25STomoki Sekiyama fi 329850cbebb9SMichael Roth if test "$guest_agent_ntddscsi" = "yes" ; then 329976dc75caSTomáš Golembiovský echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak 330050cbebb9SMichael Roth fi 33019dacf32dSYossi Hindin echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak 33029dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 33039dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 33049dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 3305210fa556Spbrookelse 330635f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 3307210fa556Spbrookfi 3308128ab2ffSblueswir1 3309dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 3310dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 3311dffcb71cSMark McLoughlinfi 3312dffcb71cSMark McLoughlin 331383fb7adfSbellardif test "$darwin" = "yes" ; then 331498ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 331583fb7adfSbellardfi 3316b29fe3edSmalc 3317ec530c81Sbellardif test "$solaris" = "yes" ; then 331898ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 3319ec530c81Sbellardfi 332097a847bcSbellardif test "$static" = "yes" ; then 332198ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 332297a847bcSbellardfi 33231ba16968SStefan Weilif test "$profiler" = "yes" ; then 33242358a494SJuan Quintela echo "CONFIG_PROFILER=y" >> $config_host_mak 332505c2a3e7Sbellardfi 3326c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then 3327c932ce31SPaolo Bonzini echo "CONFIG_TOOLS=y" >> $config_host_mak 3328c932ce31SPaolo Bonzinifi 3329f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then 3330f15bff25SPaolo Bonzini echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak 3331f15bff25SPaolo Bonzinifi 3332b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then 3333b8e0c493SJoelle van Dyne echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak 3334e2d8830eSBrad echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak 3335b8e0c493SJoelle van Dynefi 33364cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then 33374cc600d2SPaolo Bonzini echo "CONFIG_GPROF=y" >> $config_host_mak 33384cc600d2SPaolo Bonzinifi 3339b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak 3340b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak 3341e5f05f8cSKevin Wolfif test "$block_drv_whitelist_tools" = "yes" ; then 3342e5f05f8cSKevin Wolf echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak 3343e5f05f8cSKevin Wolffi 334489138857SStefan Weilqemu_version=$(head $source_path/VERSION) 33452358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak 334698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 33472b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 334817969268SFam Zhengif test "$modules" = "yes"; then 3349e26110cfSFam Zheng # $shacmd can generate a hash started with digit, which the compiler doesn't 3350e26110cfSFam Zheng # like as an symbol. So prefix it with an underscore 335189138857SStefan Weil echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak 335217969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 335317969268SFam Zhengfi 3354bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then 3355bd83c861SChristian Ehrhardt echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak 3356bd83c861SChristian Ehrhardtfi 3357955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then 3358955727d2SCortland Tölva echo "CONFIG_USBFS=y" >> $config_host_mak 3359955727d2SCortland Tölvafi 3360f876b765SMarc-André Lureauif test "$gio" = "yes" ; then 3361f876b765SMarc-André Lureau echo "CONFIG_GIO=y" >> $config_host_mak 3362f876b765SMarc-André Lureau echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak 3363f876b765SMarc-André Lureau echo "GIO_LIBS=$gio_libs" >> $config_host_mak 33645ecfb76cSPaolo Bonzinifi 33655ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then 336625a97a56SMarc-André Lureau echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak 3367f876b765SMarc-André Lureaufi 3368a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak 3369277abf15SJan Vesely 33701badb709SPaolo Bonziniif test "$xen" = "enabled" ; then 33716dbd588aSJan Kiszka echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak 3372d5b93ddfSAnthony PERARD echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak 3373582ea95fSMarc-André Lureau echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak 3374582ea95fSMarc-André Lureau echo "XEN_LIBS=$xen_libs" >> $config_host_mak 3375e37630caSaliguorifi 33765e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then 33775e9be92dSNicholas Bellinger echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 33785e9be92dSNicholas Bellingerfi 3379af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then 3380af3bba76SPaolo Bonzini echo "CONFIG_VHOST_NET=y" >> $config_host_mak 3381af3bba76SPaolo Bonzinifi 3382af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then 338356f41de7SPaolo Bonzini echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 338403ce5744SNikolay Nikolaevfi 3385108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then 3386108a6481SCindy Lu echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak 3387108a6481SCindy Lufi 3388042cea27SGongleiif test "$vhost_crypto" = "yes" ; then 3389042cea27SGonglei echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak 3390042cea27SGongleifi 3391fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then 3392fc0b9b0eSStefan Hajnoczi echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak 33935fe97d88SStefano Garzarella if test "$vhost_user" = "yes" ; then 33945fe97d88SStefano Garzarella echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak 33955fe97d88SStefano Garzarella fi 3396fc0b9b0eSStefan Hajnoczifi 3397299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then 3398299e6f19SPaolo Bonzini echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak 3399299e6f19SPaolo Bonzinifi 3400e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then 3401e6a74868SMarc-André Lureau echo "CONFIG_VHOST_USER=y" >> $config_host_mak 3402e6a74868SMarc-André Lureaufi 3403108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then 3404108a6481SCindy Lu echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak 3405108a6481SCindy Lufi 340698fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then 340798fc1adaSDr. David Alan Gilbert echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak 340898fc1adaSDr. David Alan Gilbertfi 3409a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then 3410a40161cbSPaolo Bonzini echo "CONFIG_MEMBARRIER=y" >> $config_host_mak 3411a40161cbSPaolo Bonzinifi 3412e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then 3413e5b46549SRichard Henderson echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak 3414e5b46549SRichard Hendersonfi 341558d3f3ffSGerd Hoffmann 3416da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then 3417da076ffeSGerd Hoffmann echo "CONFIG_OPENGL=y" >> $config_host_mak 3418de2d3005SPaolo Bonzini echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak 3419da076ffeSGerd Hoffmann echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak 342020ff075bSMichael Wallefi 342120ff075bSMichael Walle 342299f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then 342399f2dbd3SLiang Li echo "CONFIG_AVX2_OPT=y" >> $config_host_mak 342499f2dbd3SLiang Lifi 342599f2dbd3SLiang Li 34266b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then 34276b8cd447SRobert Hoo echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak 34286b8cd447SRobert Hoofi 34296b8cd447SRobert Hoo 343083fb7adfSbellard# XXX: suppress that 34317d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 34322358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 34337d3505c5Sbellardfi 34347d3505c5Sbellard 34353556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then 34363556c233SPaolo Bonzini echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak 34373556c233SPaolo Bonzinifi 343820ff6c80SAnthony Liguori 34397c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 344070c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then 344170c60c08SStefan Hajnoczi echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak 344270c60c08SStefan Hajnoczielse 344370c60c08SStefan Hajnoczi echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak 344470c60c08SStefan Hajnoczifi 3445d0e2fce5SAneesh Kumar K.V 34467d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then 34477d992e4dSPeter Lieven echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak 34487d992e4dSPeter Lievenfi 34497d992e4dSPeter Lieven 3450f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then 3451f0d92b56SLongpeng(Mike) echo "CONFIG_AF_ALG=y" >> $config_host_mak 3452f0d92b56SLongpeng(Mike)fi 3453f0d92b56SLongpeng(Mike) 3454d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 3455d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 3456d83414e1SMarc-André Lureaufi 3457d83414e1SMarc-André Lureau 34580aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 34590aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 34600aebab04SLingfeng Yangfi 34610aebab04SLingfeng Yang 346276a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then 346376a347e1SRichard Henderson echo "CONFIG_CPUID_H=y" >> $config_host_mak 346476a347e1SRichard Hendersonfi 346576a347e1SRichard Henderson 3466f540166bSRichard Hendersonif test "$int128" = "yes" ; then 3467f540166bSRichard Henderson echo "CONFIG_INT128=y" >> $config_host_mak 3468f540166bSRichard Hendersonfi 3469f540166bSRichard Henderson 34707ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then 34717ebee43eSRichard Henderson echo "CONFIG_ATOMIC128=y" >> $config_host_mak 34727ebee43eSRichard Hendersonfi 34737ebee43eSRichard Henderson 3474e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then 3475e6cd4bb5SRichard Henderson echo "CONFIG_CMPXCHG128=y" >> $config_host_mak 3476e6cd4bb5SRichard Hendersonfi 3477e6cd4bb5SRichard Henderson 3478ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then 3479ed1701c6SDr. David Alan Gilbert echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak 3480ed1701c6SDr. David Alan Gilbertfi 3481ed1701c6SDr. David Alan Gilbert 34823b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then 34833cae16dbSPaolo Bonzini echo 'CONFIG_TPM=y' >> $config_host_mak 34843b8acc11SPaolo Bonzinifi 34853b8acc11SPaolo Bonzini 34862da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then 34872da776dbSMichael R. Hines echo "CONFIG_RDMA=y" >> $config_host_mak 3488392fb643SFam Zheng echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak 34892da776dbSMichael R. Hinesfi 34902da776dbSMichael R. Hines 349121ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then 349221ab34c9SMarcel Apfelbaum echo "CONFIG_PVRDMA=y" >> $config_host_mak 349321ab34c9SMarcel Apfelbaumfi 349421ab34c9SMarcel Apfelbaum 3495a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then 3496a6b1d4c0SChanglong Xie echo "CONFIG_REPLICATION=y" >> $config_host_mak 3497a6b1d4c0SChanglong Xiefi 3498a6b1d4c0SChanglong Xie 3499ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then 3500ba59fb77SPaolo Bonzini echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak 3501ba59fb77SPaolo Bonzinifi 3502e0580342SKamil Rytarowski 35032f740136SJeff Codyif test "$bochs" = "yes" ; then 35042f740136SJeff Cody echo "CONFIG_BOCHS=y" >> $config_host_mak 35052f740136SJeff Codyfi 35062f740136SJeff Codyif test "$cloop" = "yes" ; then 35072f740136SJeff Cody echo "CONFIG_CLOOP=y" >> $config_host_mak 35082f740136SJeff Codyfi 35092f740136SJeff Codyif test "$dmg" = "yes" ; then 35102f740136SJeff Cody echo "CONFIG_DMG=y" >> $config_host_mak 35112f740136SJeff Codyfi 35122f740136SJeff Codyif test "$qcow1" = "yes" ; then 35132f740136SJeff Cody echo "CONFIG_QCOW1=y" >> $config_host_mak 35142f740136SJeff Codyfi 35152f740136SJeff Codyif test "$vdi" = "yes" ; then 35162f740136SJeff Cody echo "CONFIG_VDI=y" >> $config_host_mak 35172f740136SJeff Codyfi 35182f740136SJeff Codyif test "$vvfat" = "yes" ; then 35192f740136SJeff Cody echo "CONFIG_VVFAT=y" >> $config_host_mak 35202f740136SJeff Codyfi 35212f740136SJeff Codyif test "$qed" = "yes" ; then 35222f740136SJeff Cody echo "CONFIG_QED=y" >> $config_host_mak 35232f740136SJeff Codyfi 35242f740136SJeff Codyif test "$parallels" = "yes" ; then 35252f740136SJeff Cody echo "CONFIG_PARALLELS=y" >> $config_host_mak 35262f740136SJeff Codyfi 35272f740136SJeff Cody 352840e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 352940e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 353040e8c6f4SAlex Bennéefi 353140e8c6f4SAlex Bennée 3532f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 3533b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 3534d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 3535f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 3536f48e590aSAlex Bennée fi 3537b1863cccSAlex Bennéefi 3538f48e590aSAlex Bennée 353954e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then 354054e7aac0SAlexey Krasikov echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak 354154e7aac0SAlexey Krasikovfi 354254e7aac0SAlexey Krasikov 354398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 3544804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 3545c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 354639d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 3547a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 354809e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 3549804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 3550433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak 3551a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then 3552859aef02SPaolo Bonzini echo "CONFIG_IASL=$iasl" >> $config_host_mak 3553a31a8642SMichael S. Tsirkinfi 3554804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 3555cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 35565f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 35573dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 3558804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 3559804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 356046eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak 3561a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 356211cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 3563a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 3564a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 3565d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 35668a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 3567e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 3568a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 3569804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 3570f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak 3571804edf29SJuan Quintela 3572b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then 3573b767d257SMarek Marczykowski-Górecki echo "CONFIG_RNG_NONE=y" >> $config_host_mak 3574b767d257SMarek Marczykowski-Góreckifi 3575b767d257SMarek Marczykowski-Górecki 35766efd7517SPeter Maydell# use included Linux headers 35776efd7517SPeter Maydellif test "$linux" = "yes" ; then 3578a307beb6SAndreas Färber mkdir -p linux-headers 35796efd7517SPeter Maydell case "$cpu" in 35804da270beSPaolo Bonzini i386|x86_64) 358108312a63SPeter Maydell linux_arch=x86 35826efd7517SPeter Maydell ;; 3583d8ff892dSPaolo Bonzini ppc|ppc64) 358408312a63SPeter Maydell linux_arch=powerpc 35856efd7517SPeter Maydell ;; 35866efd7517SPeter Maydell s390x) 358708312a63SPeter Maydell linux_arch=s390 358808312a63SPeter Maydell ;; 35891f080313SClaudio Fontana aarch64) 35901f080313SClaudio Fontana linux_arch=arm64 35911f080313SClaudio Fontana ;; 3592dfcf900bSWANG Xuerui loongarch*) 3593dfcf900bSWANG Xuerui linux_arch=loongarch 3594dfcf900bSWANG Xuerui ;; 3595222e7d11SSanjay Lal mips64) 3596222e7d11SSanjay Lal linux_arch=mips 3597222e7d11SSanjay Lal ;; 359808312a63SPeter Maydell *) 359908312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 360008312a63SPeter Maydell linux_arch="$cpu" 36016efd7517SPeter Maydell ;; 36026efd7517SPeter Maydell esac 360308312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 360408312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 360508312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 360608312a63SPeter Maydell fi 36076efd7517SPeter Maydellfi 36086efd7517SPeter Maydell 360997a847bcSbellardfor target in $target_list; do 361097a847bcSbellard target_dir="$target" 361157a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 361297a847bcSbellard mkdir -p $target_dir 3613fdb75aefSPaolo Bonzini case $target in 3614fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 3615fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 36162408a527Saurel32 esac 361756aebc89Spbrookdone 36187d13299dSbellard 3619765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak 3620fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 3621fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 3622fdb75aefSPaolo Bonzinifi 3623a540f158SPeter Crosthwaite 3624a99d57bbSWanlong Gaoif test "$numa" = "yes"; then 3625a99d57bbSWanlong Gao echo "CONFIG_NUMA=y" >> $config_host_mak 3626ab318051SMarc-André Lureau echo "NUMA_LIBS=$numa_libs" >> $config_host_mak 3627a99d57bbSWanlong Gaofi 3628a99d57bbSWanlong Gao 3629fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 3630fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 3631fd0e6053SJohn Snowfi 3632fd0e6053SJohn Snow 36331e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 36341e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 36351e4f6065SDaniele Buonofi 36361e4f6065SDaniele Buono 3637e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 3638e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 3639e29e5c6eSPeter Maydell# (these can be both files and directories). 3640e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 3641e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 3642e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 3643e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 3644e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 3645e29e5c6eSPeter Maydell# directory and symlink the directory instead. 36462038f8c8SPaolo BonziniLINKS="Makefile" 36473941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 3648ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 3649e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 36508db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile" 3651e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp" 3652e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 3653bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 365439950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 36558f8fd9edSCleber RosaLINKS="$LINKS python" 3656c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 3657753d11f2SRichard Hendersonfor bios_file in \ 3658753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 36593a631b8eSBin Meng $source_path/pc-bios/*.elf \ 3660225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 3661753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 3662753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 3663e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 3664753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 36654e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 3666cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 3667cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 3668cd946e5cSJohn Arbuckle 3669753d11f2SRichard Hendersondo 3670e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 36717ea78b74SJan Kiszkadone 3672e29e5c6eSPeter Maydellfor f in $LINKS ; do 36730f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 36745dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 3675f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 3676f9245e10SPeter Maydell fi 36777d13299dSbellarddone 36781ad2134fSPaul Brook 36792038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 36802038f8c8SPaolo Bonzini export $i 36812038f8c8SPaolo Bonzinidone 3682fd0f79d7SRichard Hendersonexport target_list source_path use_containers cpu 36832038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 36842038f8c8SPaolo Bonzini 3685c34ebfdcSAnthony Liguori# temporary config to build submodules 3686bb7cb3adSPaolo Bonziniif test -f $source_path/roms/seabios/Makefile; then 36878db2a4fdSGerd Hoffmann for rom in seabios; do 3688c34ebfdcSAnthony Liguori config_mak=roms/$rom/config.mak 368937116c89SStefan Weil echo "# Automatically generated by configure - do not modify" > $config_mak 3690c34ebfdcSAnthony Liguori echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak 3691cdbd727cSRichard Henderson echo "AS=$as" >> $config_mak 36925f6f0e27SRichard Henderson echo "CCAS=$ccas" >> $config_mak 3693c34ebfdcSAnthony Liguori echo "CC=$cc" >> $config_mak 3694c34ebfdcSAnthony Liguori echo "BCC=bcc" >> $config_mak 36953dd46c78SBlue Swirl echo "CPP=$cpp" >> $config_mak 3696c34ebfdcSAnthony Liguori echo "OBJCOPY=objcopy" >> $config_mak 3697a31a8642SMichael S. Tsirkin echo "IASL=$iasl" >> $config_mak 3698c34ebfdcSAnthony Liguori echo "LD=$ld" >> $config_mak 36999f81aeb5SAlistair Francis echo "RANLIB=$ranlib" >> $config_mak 3700c34ebfdcSAnthony Liguori done 3701bb7cb3adSPaolo Bonzinifi 3702c34ebfdcSAnthony Liguori 370398409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 370498409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 370598409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 370698409991SHelge Konetzka 3707a5665051SPaolo Bonziniif test "$skip_meson" = no; then 3708fc929892SMarc-André Lureau cross="config-meson.cross.new" 3709fc929892SMarc-André Lureau meson_quote() { 3710ac7ebcc5SPaolo Bonzini test $# = 0 && return 371147b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 3712fc929892SMarc-André Lureau } 3713fc929892SMarc-André Lureau 3714fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 3715fc929892SMarc-André Lureau echo "[properties]" >> $cross 3716d1d5e9eeSAlex Bennée 3717d1d5e9eeSAlex Bennée # unroll any custom device configs 3718d1d5e9eeSAlex Bennée for a in $device_archs; do 3719d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 3720d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 3721d1d5e9eeSAlex Bennée done 3722d1d5e9eeSAlex Bennée 3723fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 372447b30835SPaolo Bonzini echo "[built-in options]" >> $cross 3725a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 3726a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 3727a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 3728a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 3729fc929892SMarc-André Lureau echo "[binaries]" >> $cross 37304dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 37314dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 37324dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 373347b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 373447b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 373547b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 373647b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 3737e8178514SPaolo Bonzini if has $sdl2_config; then 373847b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 3739e8178514SPaolo Bonzini fi 374047b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 374147b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 37423812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 3743fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 3744fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 3745ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 3746823eb013SPaolo Bonzini case "$cpu" in 3747f6bca9dfSJoelle van Dyne i386) 3748fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 3749fc929892SMarc-André Lureau ;; 3750fc929892SMarc-André Lureau *) 3751823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 3752fc929892SMarc-André Lureau ;; 3753fc929892SMarc-André Lureau esac 3754fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 3755fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 3756fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 3757fc929892SMarc-André Lureau else 3758fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 3759fc929892SMarc-André Lureau fi 3760fc929892SMarc-André Lureau else 3761fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 3762fc929892SMarc-André Lureau fi 3763fc929892SMarc-André Lureau mv $cross config-meson.cross 3764fc929892SMarc-André Lureau 3765a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 376661d63097SPaolo Bonzini run_meson() { 376709e93326SPaolo Bonzini NINJA=$ninja $meson setup \ 3768d17f305aSPaolo Bonzini --prefix "$prefix" \ 3769d17f305aSPaolo Bonzini --libdir "$libdir" \ 3770d17f305aSPaolo Bonzini --libexecdir "$libexecdir" \ 3771d17f305aSPaolo Bonzini --bindir "$bindir" \ 3772d17f305aSPaolo Bonzini --includedir "$includedir" \ 3773d17f305aSPaolo Bonzini --datadir "$datadir" \ 3774d17f305aSPaolo Bonzini --mandir "$mandir" \ 3775d17f305aSPaolo Bonzini --sysconfdir "$sysconfdir" \ 377616bf7a33SPaolo Bonzini --localedir "$localedir" \ 3777d17f305aSPaolo Bonzini --localstatedir "$local_statedir" \ 37783b4da132SPaolo Bonzini -Daudio_drv_list=$audio_drv_list \ 37793b4da132SPaolo Bonzini -Ddefault_devices=$default_devices \ 3780d17f305aSPaolo Bonzini -Ddocdir="$docdir" \ 378116bf7a33SPaolo Bonzini -Dqemu_firmwarepath="$firmwarepath" \ 378273f3aa37SMarc-André Lureau -Dqemu_suffix="$qemu_suffix" \ 37833b4da132SPaolo Bonzini -Dsphinx_build="$sphinx_build" \ 37843b4da132SPaolo Bonzini -Dtrace_file="$trace_file" \ 3785a5665051SPaolo Bonzini -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ 3786a5665051SPaolo Bonzini -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ 3787a5665051SPaolo Bonzini -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ 3788da6d48b9SMarc-André Lureau -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ 3789bf0e56a3SMarc-André Lureau -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ 37903b4da132SPaolo Bonzini -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ 37913b4da132SPaolo Bonzini -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ 3792537b7248SPaolo Bonzini $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ 3793332008e0SThomas Huth $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ 379461d63097SPaolo Bonzini "$@" $cross_arg "$PWD" "$source_path" 379561d63097SPaolo Bonzini } 379661d63097SPaolo Bonzini eval run_meson $meson_options 3797a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 3798a5665051SPaolo Bonzini error_exit "meson setup failed" 3799a5665051SPaolo Bonzini fi 3800699d3884SPaolo Bonzinielse 3801699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 3802699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 3803699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 3804699d3884SPaolo Bonzini perl -i -ne ' 3805699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 3806699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 3807654d6b04SPaolo Bonzini /^b_staticpic/ && next; 3808699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 3809699d3884SPaolo Bonzini fi 3810a5665051SPaolo Bonzinifi 3811a5665051SPaolo Bonzini 3812dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 3813dc655404SMichael S. Tsirkincat <<EOD >config.status 3814dc655404SMichael S. Tsirkin#!/bin/sh 3815dc655404SMichael S. Tsirkin# Generated by configure. 3816dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 3817dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 3818dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 3819dc655404SMichael S. TsirkinEOD 3820e811da7fSDaniel P. Berrangé 3821e811da7fSDaniel P. Berrangépreserve_env() { 3822e811da7fSDaniel P. Berrangé envname=$1 3823e811da7fSDaniel P. Berrangé 3824e811da7fSDaniel P. Berrangé eval envval=\$$envname 3825e811da7fSDaniel P. Berrangé 3826e811da7fSDaniel P. Berrangé if test -n "$envval" 3827e811da7fSDaniel P. Berrangé then 3828e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 3829e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 3830e811da7fSDaniel P. Berrangé else 3831e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 3832e811da7fSDaniel P. Berrangé fi 3833e811da7fSDaniel P. Berrangé} 3834e811da7fSDaniel P. Berrangé 3835e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 3836e811da7fSDaniel P. Berrangé# features/build target configure will detect 3837e811da7fSDaniel P. Berrangépreserve_env AR 3838e811da7fSDaniel P. Berrangépreserve_env AS 3839e811da7fSDaniel P. Berrangépreserve_env CC 3840e811da7fSDaniel P. Berrangépreserve_env CPP 38418009da03SPaolo Bonzinipreserve_env CFLAGS 3842e811da7fSDaniel P. Berrangépreserve_env CXX 38438009da03SPaolo Bonzinipreserve_env CXXFLAGS 3844e811da7fSDaniel P. Berrangépreserve_env INSTALL 3845e811da7fSDaniel P. Berrangépreserve_env LD 38468009da03SPaolo Bonzinipreserve_env LDFLAGS 3847e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 3848e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 3849e811da7fSDaniel P. Berrangépreserve_env MAKE 3850e811da7fSDaniel P. Berrangépreserve_env NM 3851e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 3852e811da7fSDaniel P. Berrangépreserve_env PATH 3853e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 3854e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 3855e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 3856e811da7fSDaniel P. Berrangépreserve_env PYTHON 3857e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 3858e811da7fSDaniel P. Berrangépreserve_env SMBD 3859e811da7fSDaniel P. Berrangépreserve_env STRIP 3860e811da7fSDaniel P. Berrangépreserve_env WINDRES 3861e811da7fSDaniel P. Berrangé 3862dc655404SMichael S. Tsirkinprintf "exec" >>config.status 3863a5665051SPaolo Bonzinifor i in "$0" "$@"; do 3864835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 3865a5665051SPaolo Bonzinidone 3866cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 3867dc655404SMichael S. Tsirkinchmod +x config.status 3868dc655404SMichael S. Tsirkin 38698cd05ab6SPeter Maydellrm -r "$TMPDIR1" 3870