17d13299dSbellard#!/bin/sh 27d13299dSbellard# 33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard 47d13299dSbellard# 58cd05ab6SPeter Maydell 699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools, 799519e67SCornelia Huck# just as autoconf does. 899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS= 999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS 1099519e67SCornelia Huck 115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests! 125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes 135e4dfd3dSJohn Snow 14dedad027SDaniel P. Berrangé# make source path absolute 15dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd) 16dedad027SDaniel P. Berrangé 17dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path" 18dedad027SDaniel P. Berrangéthen 19dedad027SDaniel P. Berrangé echo "Using './build' as the directory for build output" 20dedad027SDaniel P. Berrangé 21dedad027SDaniel P. Berrangé MARKER=build/auto-created-by-configure 22dedad027SDaniel P. Berrangé 23dedad027SDaniel P. Berrangé if test -e build 24dedad027SDaniel P. Berrangé then 25dedad027SDaniel P. Berrangé if test -f $MARKER 26dedad027SDaniel P. Berrangé then 27dedad027SDaniel P. Berrangé rm -rf build 28dedad027SDaniel P. Berrangé else 29dedad027SDaniel P. Berrangé echo "ERROR: ./build dir already exists and was not previously created by configure" 30dedad027SDaniel P. Berrangé exit 1 31dedad027SDaniel P. Berrangé fi 32dedad027SDaniel P. Berrangé fi 33dedad027SDaniel P. Berrangé 34dedad027SDaniel P. Berrangé mkdir build 35dedad027SDaniel P. Berrangé touch $MARKER 36dedad027SDaniel P. Berrangé 37dedad027SDaniel P. Berrangé cat > GNUmakefile <<'EOF' 38dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree 39dedad027SDaniel P. Berrangé# 'make' command invocation 40dedad027SDaniel P. Berrangé 41dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),) 42dedad027SDaniel P. Berrangérecurse: all 43dedad027SDaniel P. Berrangéendif 44dedad027SDaniel P. Berrangé 45dedad027SDaniel P. Berrangé.NOTPARALLEL: % 46dedad027SDaniel P. Berrangé%: force 47dedad027SDaniel P. Berrangé @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...' 48dedad027SDaniel P. Berrangé @$(MAKE) -C build -f Makefile $(MAKECMDGOALS) 49dedad027SDaniel P. Berrangé @if test "$(MAKECMDGOALS)" = "distclean" && \ 50dedad027SDaniel P. Berrangé test -e build/auto-created-by-configure ; \ 51dedad027SDaniel P. Berrangé then \ 52dedad027SDaniel P. Berrangé rm -rf build GNUmakefile ; \ 53dedad027SDaniel P. Berrangé fi 54dedad027SDaniel P. Berrangéforce: ; 55dedad027SDaniel P. Berrangé.PHONY: force 56dedad027SDaniel P. BerrangéGNUmakefile: ; 57dedad027SDaniel P. Berrangé 58dedad027SDaniel P. BerrangéEOF 59dedad027SDaniel P. Berrangé cd build 60dedad027SDaniel P. Berrangé exec $source_path/configure "$@" 61dedad027SDaniel P. Berrangéfi 62dedad027SDaniel P. Berrangé 638cd05ab6SPeter Maydell# Temporary directory used for files created while 648cd05ab6SPeter Maydell# configure runs. Since it is in the build directory 658cd05ab6SPeter Maydell# we can safely blow away any previous version of it 668cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete 678cd05ab6SPeter Maydell# it when configure exits.) 688cd05ab6SPeter MaydellTMPDIR1="config-temp" 698cd05ab6SPeter Maydellrm -rf "${TMPDIR1}" 708cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}" 718cd05ab6SPeter Maydellif [ $? -ne 0 ]; then 728cd05ab6SPeter Maydell echo "ERROR: failed to create temporary directory" 738cd05ab6SPeter Maydell exit 1 747d13299dSbellardfi 757d13299dSbellard 768cd05ab6SPeter MaydellTMPB="qemu-conf" 778cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c" 7866518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o" 799c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx" 808cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe" 817d13299dSbellard 82da1d85e3SGerd Hoffmannrm -f config.log 839ac81bbbSmalc 84b48e3611SPeter Maydell# Print a helpful header at the top of config.log 85b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log 86979ae168SPeter Maydellprintf "# Configured with:" >> config.log 87979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log 88979ae168SPeter Maydellecho >> config.log 89b48e3611SPeter Maydellecho "#" >> config.log 90b48e3611SPeter Maydell 91835af899SPaolo Bonziniquote_sh() { 92835af899SPaolo Bonzini printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," 93835af899SPaolo Bonzini} 94835af899SPaolo Bonzini 95d880a3baSPaolo Bonziniprint_error() { 96d880a3baSPaolo Bonzini (echo 9776ad07a4SPeter Maydell echo "ERROR: $1" 9876ad07a4SPeter Maydell while test -n "$2"; do 9976ad07a4SPeter Maydell echo " $2" 10076ad07a4SPeter Maydell shift 10176ad07a4SPeter Maydell done 102d880a3baSPaolo Bonzini echo) >&2 103d880a3baSPaolo Bonzini} 104d880a3baSPaolo Bonzini 105d880a3baSPaolo Bonzinierror_exit() { 106d880a3baSPaolo Bonzini print_error "$@" 10776ad07a4SPeter Maydell exit 1 10876ad07a4SPeter Maydell} 10976ad07a4SPeter Maydell 1109c83ffd8SPeter Maydelldo_compiler() { 1119c83ffd8SPeter Maydell # Run the compiler, capturing its output to the log. First argument 1129c83ffd8SPeter Maydell # is compiler binary to execute. 113630d86b7SDavid CARLIER compiler="$1" 1149c83ffd8SPeter Maydell shift 1158bbe05d7SIan Jackson if test -n "$BASH_VERSION"; then eval ' 1168bbe05d7SIan Jackson echo >>config.log " 1178bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]} 1188bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}" 1198bbe05d7SIan Jackson '; fi 1209c83ffd8SPeter Maydell echo $compiler "$@" >> config.log 1219c83ffd8SPeter Maydell $compiler "$@" >> config.log 2>&1 || return $? 1228dc38a78SPeter Maydell # Test passed. If this is an --enable-werror build, rerun 1238dc38a78SPeter Maydell # the test with -Werror and bail out if it fails. This 1248dc38a78SPeter Maydell # makes warning-generating-errors in configure test code 1258dc38a78SPeter Maydell # obvious to developers. 1268dc38a78SPeter Maydell if test "$werror" != "yes"; then 1278dc38a78SPeter Maydell return 0 1288dc38a78SPeter Maydell fi 1298dc38a78SPeter Maydell # Don't bother rerunning the compile if we were already using -Werror 1308dc38a78SPeter Maydell case "$*" in 1318dc38a78SPeter Maydell *-Werror*) 1328dc38a78SPeter Maydell return 0 1338dc38a78SPeter Maydell ;; 1348dc38a78SPeter Maydell esac 1359c83ffd8SPeter Maydell echo $compiler -Werror "$@" >> config.log 1369c83ffd8SPeter Maydell $compiler -Werror "$@" >> config.log 2>&1 && return $? 13776ad07a4SPeter Maydell error_exit "configure test passed without -Werror but failed with -Werror." \ 13876ad07a4SPeter Maydell "This is probably a bug in the configure script. The failing command" \ 13976ad07a4SPeter Maydell "will be at the bottom of config.log." \ 14076ad07a4SPeter Maydell "You can run configure with --disable-werror to bypass this check." 1418dc38a78SPeter Maydell} 1428dc38a78SPeter Maydell 1439c83ffd8SPeter Maydelldo_cc() { 1444dba2789SPaolo Bonzini do_compiler "$cc" $CPU_CFLAGS "$@" 1459c83ffd8SPeter Maydell} 1469c83ffd8SPeter Maydell 1479c83ffd8SPeter Maydelldo_cxx() { 1484dba2789SPaolo Bonzini do_compiler "$cxx" $CPU_CFLAGS "$@" 1499c83ffd8SPeter Maydell} 1509c83ffd8SPeter Maydell 15100849b92SRichard Henderson# Append $2 to the variable named $1, with space separation 15200849b92SRichard Hendersonadd_to() { 15300849b92SRichard Henderson eval $1=\${$1:+\"\$$1 \"}\$2 15400849b92SRichard Henderson} 15500849b92SRichard Henderson 1569c83ffd8SPeter Maydellupdate_cxxflags() { 1579c83ffd8SPeter Maydell # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those 1589c83ffd8SPeter Maydell # options which some versions of GCC's C++ compiler complain about 1599c83ffd8SPeter Maydell # because they only make sense for C programs. 160de38c0ccSPaolo Bonzini QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS" 1618a9d3d56SRichard Henderson CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/) 1629c83ffd8SPeter Maydell for arg in $QEMU_CFLAGS; do 1639c83ffd8SPeter Maydell case $arg in 1649c83ffd8SPeter Maydell -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ 1659c83ffd8SPeter Maydell -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) 1669c83ffd8SPeter Maydell ;; 1679c83ffd8SPeter Maydell *) 1689c83ffd8SPeter Maydell QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg 1699c83ffd8SPeter Maydell ;; 1709c83ffd8SPeter Maydell esac 1719c83ffd8SPeter Maydell done 1729c83ffd8SPeter Maydell} 1739c83ffd8SPeter Maydell 17452166aa0SJuan Quintelacompile_object() { 175fd0e6053SJohn Snow local_cflags="$1" 176a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC 17752166aa0SJuan Quintela} 17852166aa0SJuan Quintela 17952166aa0SJuan Quintelacompile_prog() { 18052166aa0SJuan Quintela local_cflags="$1" 18152166aa0SJuan Quintela local_ldflags="$2" 182a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \ 183a2866660SPaolo Bonzini $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags 18452166aa0SJuan Quintela} 18552166aa0SJuan Quintela 18611568d6dSPaolo Bonzini# symbolically link $1 to $2. Portable version of "ln -sf". 18711568d6dSPaolo Bonzinisymlink() { 18872b8b5a1SStefan Weil rm -rf "$2" 189ec5b06d7SAnthony Liguori mkdir -p "$(dirname "$2")" 19072b8b5a1SStefan Weil ln -s "$1" "$2" 19111568d6dSPaolo Bonzini} 19211568d6dSPaolo Bonzini 1930dba6195SLoïc Minier# check whether a command is available to this shell (may be either an 1940dba6195SLoïc Minier# executable or a builtin) 1950dba6195SLoïc Minierhas() { 1960dba6195SLoïc Minier type "$1" >/dev/null 2>&1 1970dba6195SLoïc Minier} 1980dba6195SLoïc Minier 1990a01d76fSMarc-André Lureauversion_ge () { 2002df52b9bSAlex Bennée local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') 2012df52b9bSAlex Bennée local_ver2=$(echo "$2" | tr . ' ') 2020a01d76fSMarc-André Lureau while true; do 2030a01d76fSMarc-André Lureau set x $local_ver1 2040a01d76fSMarc-André Lureau local_first=${2-0} 205c44a33e2SStefano Garzarella # 'shift 2' if $2 is set, or 'shift' if $2 is not set 206c44a33e2SStefano Garzarella shift ${2:+2} 2070a01d76fSMarc-André Lureau local_ver1=$* 2080a01d76fSMarc-André Lureau set x $local_ver2 2090a01d76fSMarc-André Lureau # the second argument finished, the first must be greater or equal 2100a01d76fSMarc-André Lureau test $# = 1 && return 0 2110a01d76fSMarc-André Lureau test $local_first -lt $2 && return 1 2120a01d76fSMarc-André Lureau test $local_first -gt $2 && return 0 213c44a33e2SStefano Garzarella shift ${2:+2} 2140a01d76fSMarc-André Lureau local_ver2=$* 2150a01d76fSMarc-André Lureau done 2160a01d76fSMarc-André Lureau} 2170a01d76fSMarc-André Lureau 2183b6b7550SPaolo Bonziniglob() { 2193b6b7550SPaolo Bonzini eval test -z '"${1#'"$2"'}"' 2203b6b7550SPaolo Bonzini} 2213b6b7550SPaolo Bonzini 222e9a3591fSChristian Borntraegerld_has() { 223e9a3591fSChristian Borntraeger $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 224e9a3591fSChristian Borntraeger} 225e9a3591fSChristian Borntraeger 2264ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; 2274ace32e2SAntonio Ospitethen 2284ace32e2SAntonio Ospite error_exit "main directory cannot contain spaces nor colons" 2294ace32e2SAntonio Ospitefi 2304ace32e2SAntonio Ospite 23114211825SAntonio Ospite# default parameters 2322ff6b91eSJuan Quintelacpu="" 233a31a8642SMichael S. Tsirkiniasl="iasl" 2341e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M" 23543ce4dfeSbellardstatic="no" 2363812c0c4SJoelle van Dynecross_compile="no" 2377d13299dSbellardcross_prefix="" 23887430d5bSPaolo Bonziniaudio_drv_list="default" 239b64ec4e4SFam Zhengblock_drv_rw_whitelist="" 240b64ec4e4SFam Zhengblock_drv_ro_whitelist="" 241e49d021eSPeter Maydellhost_cc="cc" 2425bc62e01SGerd Hoffmanndebug_info="yes" 243cdad781dSDaniele Buonolto="false" 24463678e17SSteven Noonanstack_protector="" 2451e4f6065SDaniele Buonosafe_stack="" 246afc3a8f9SAlex Bennéeuse_containers="yes" 247f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 248ac0df51dSaliguori 24992712822SDaniel P. Berrangeif test -e "$source_path/.git" 25092712822SDaniel P. Berrangethen 2517d7dbf9dSDan Streetman git_submodules_action="update" 25292712822SDaniel P. Berrangeelse 2537d7dbf9dSDan Streetman git_submodules_action="ignore" 25492712822SDaniel P. Berrangefi 2552d652f24SPaolo Bonzini 2562d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb" 257cc84d63aSDaniel P. Berrangegit="git" 258ac0df51dSaliguori 259afb63ebdSStefan Weil# Don't accept a target_list environment variable. 260afb63ebdSStefan Weilunset target_list 261447e133fSAlex Bennéeunset target_list_exclude 262377529c0SPaolo Bonzini 263377529c0SPaolo Bonzini# Default value for a variable defining feature "foo". 264377529c0SPaolo Bonzini# * foo="no" feature will only be used if --enable-foo arg is given 265377529c0SPaolo Bonzini# * foo="" feature will be searched for, and if found, will be used 266377529c0SPaolo Bonzini# unless --disable-foo is given 267377529c0SPaolo Bonzini# * foo="yes" this value will only be set by --enable-foo flag. 268377529c0SPaolo Bonzini# feature will searched for, 269377529c0SPaolo Bonzini# if not found, configure exits with error 270377529c0SPaolo Bonzini# 271377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args. 272377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it 273377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found. 274377529c0SPaolo Bonzini 275c87ea116SAlex Bennéedefault_feature="" 276c87ea116SAlex Bennée# parse CC options second 277c87ea116SAlex Bennéefor opt do 278c87ea116SAlex Bennée optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 279c87ea116SAlex Bennée case "$opt" in 280c87ea116SAlex Bennée --without-default-features) 281c87ea116SAlex Bennée default_feature="no" 282c87ea116SAlex Bennée ;; 283c87ea116SAlex Bennée esac 284c87ea116SAlex Bennéedone 285c87ea116SAlex Bennée 286a2866660SPaolo BonziniEXTRA_CFLAGS="" 287a2866660SPaolo BonziniEXTRA_CXXFLAGS="" 288a2866660SPaolo BonziniEXTRA_LDFLAGS="" 289a2866660SPaolo Bonzini 290c87ea116SAlex Bennéexen_ctrl_version="$default_feature" 2910848f8acSThomas Huthvhost_kernel="$default_feature" 292c87ea116SAlex Bennéevhost_net="$default_feature" 293c87ea116SAlex Bennéevhost_crypto="$default_feature" 294c87ea116SAlex Bennéevhost_scsi="$default_feature" 295c87ea116SAlex Bennéevhost_vsock="$default_feature" 296d88618f7SStefan Hajnoczivhost_user="no" 297c87ea116SAlex Bennéevhost_user_fs="$default_feature" 2980848f8acSThomas Huthvhost_vdpa="$default_feature" 299c87ea116SAlex Bennéerdma="$default_feature" 300c87ea116SAlex Bennéepvrdma="$default_feature" 301377529c0SPaolo Bonzinidebug_tcg="no" 302377529c0SPaolo Bonzinidebug="no" 303247724cbSMarc-André Lureausanitizers="no" 3040aebab04SLingfeng Yangtsan="no" 305c87ea116SAlex Bennéefortify_source="$default_feature" 3061d728c39SBlue Swirlgcov="no" 307c7328271SMiroslav RezaninaEXESUF="" 30817969268SFam Zhengmodules="no" 309bd83c861SChristian Ehrhardtmodule_upgrades="no" 310377529c0SPaolo Bonziniprefix="/usr/local" 31110ff82d1SMarc-André Lureauqemu_suffix="qemu" 312377529c0SPaolo Bonzinisoftmmu="yes" 313b915a2f1SPaolo Bonzinilinux_user="" 314b915a2f1SPaolo Bonzinibsd_user="" 315377529c0SPaolo Bonzinipkgversion="" 31640d6444eSAvi Kivitypie="" 317baf86d6bSPaolo Bonzinitrace_backends="log" 318377529c0SPaolo Bonzinitrace_file="trace" 319c87ea116SAlex Bennéeopengl="$default_feature" 320c87ea116SAlex Bennéeguest_agent="$default_feature" 321c87ea116SAlex Bennéevss_win32_sdk="$default_feature" 322d9840e25STomoki Sekiyamawin_sdk="no" 323c87ea116SAlex Bennéewant_tools="$default_feature" 324519175a2SAlex Barcelocoroutine="" 325c87ea116SAlex Bennéecoroutine_pool="$default_feature" 3267d992e4dSPeter Lievendebug_stack_usage="no" 327a1c5e949SDaniel P. Berrangetls_priority="NORMAL" 328ba4dd2aaSAlex Bennéeplugins="$default_feature" 329c87ea116SAlex Bennéesecret_keyring="$default_feature" 330a5665051SPaolo Bonzinimeson="" 3313b4da132SPaolo Bonzinimeson_args="" 33248328880SPaolo Bonzinininja="" 3333b4da132SPaolo Bonzinigio="$default_feature" 334a5665051SPaolo Bonziniskip_meson=no 335b8e0c493SJoelle van Dyneslirp_smbd="$default_feature" 336377529c0SPaolo Bonzini 3373b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 3383b4da132SPaolo Bonzini# are included in the automatically generated help message) 3393b4da132SPaolo Bonzini 3403b4da132SPaolo Bonzini# 1. Track which submodules are needed 3413b4da132SPaolo Bonzinicapstone="auto" 3423b4da132SPaolo Bonzinifdt="auto" 3433b4da132SPaolo Bonzinislirp="auto" 3443b4da132SPaolo Bonzini 3453b4da132SPaolo Bonzini# 2. Support --with/--without option 3463b4da132SPaolo Bonzinidefault_devices="true" 3473b4da132SPaolo Bonzini 3483b4da132SPaolo Bonzini# 3. Automatically enable/disable other options 3493b4da132SPaolo Bonzinitcg="enabled" 3503b4da132SPaolo Bonzinicfi="false" 3513b4da132SPaolo Bonzini 3523b4da132SPaolo Bonzini# 4. Detection partly done in configure 3533b4da132SPaolo Bonzinixen=${default_feature:+disabled} 354898be3e0SPeter Maydell 355c87ea116SAlex Bennée# parse CC options second 356ac0df51dSaliguorifor opt do 35789138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 358ac0df51dSaliguori case "$opt" in 359ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3603812c0c4SJoelle van Dyne cross_compile="yes" 361ac0df51dSaliguori ;; 3623d8df640SPaolo Bonzini --cc=*) CC="$optarg" 363ac0df51dSaliguori ;; 36483f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 36583f73fceSTomoki Sekiyama ;; 3662ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3672ff6b91eSJuan Quintela ;; 368a2866660SPaolo Bonzini --extra-cflags=*) 369a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 370a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 371e2a2ed06SJuan Quintela ;; 372a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 37311cde1c8SBruno Dominguez ;; 374a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 375e2a2ed06SJuan Quintela ;; 3765bc62e01SGerd Hoffmann --enable-debug-info) debug_info="yes" 3775bc62e01SGerd Hoffmann ;; 3785bc62e01SGerd Hoffmann --disable-debug-info) debug_info="no" 3795bc62e01SGerd Hoffmann ;; 380d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 381d75402b5SAlex Bennée ;; 382479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 383d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 3842038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 385d422b2bcSAlex Bennée ;; 386d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 3872038f8c8SPaolo Bonzini cc_archs="$cc_archs $cc_arch" 388d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 3892038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 390d75402b5SAlex Bennée ;; 391ac0df51dSaliguori esac 392ac0df51dSaliguoridone 393ac0df51dSaliguori# OS specific 394ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 39593148aa5SStefan Weil# we can eliminate its usage altogether. 396ac0df51dSaliguori 397e49d021eSPeter Maydell# Preferred compiler: 398e49d021eSPeter Maydell# ${CC} (if set) 399e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 400e49d021eSPeter Maydell# system compiler 401e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 402e49d021eSPeter Maydell cc="$host_cc" 403e49d021eSPeter Maydellelse 404b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 405e49d021eSPeter Maydellfi 406e49d021eSPeter Maydell 40783f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 40883f73fceSTomoki Sekiyama cxx="c++" 40983f73fceSTomoki Sekiyamaelse 41083f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 41183f73fceSTomoki Sekiyamafi 41283f73fceSTomoki Sekiyama 413b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 414cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 4155f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 4163dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 417b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 418b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 4199f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 4204852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 421b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 422b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 42317884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 42417884d7bSSergei Trofimovichquery_pkg_config() { 42517884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 42617884d7bSSergei Trofimovich} 42717884d7bSSergei Trofimovichpkg_config=query_pkg_config 42847c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 429ac0df51dSaliguori 430be17dc90SMichael S. Tsirkin# default flags for all hosts 4312d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 4322d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 4332d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 4342d31515bSPeter Maydell# provides these semantics.) 435de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 436086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 437c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 438be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4395770e8afSPaolo Bonzini 440de38c0ccSPaolo BonziniQEMU_LDFLAGS= 441de38c0ccSPaolo Bonzini 4425770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4438a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4445770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 445086d5f75SPaolo Bonzini 446be17dc90SMichael S. Tsirkin 447ac0df51dSaliguoricheck_define() { 448ac0df51dSaliguoricat > $TMPC <<EOF 449ac0df51dSaliguori#if !defined($1) 450fd786e1aSPeter Maydell#error $1 not defined 451ac0df51dSaliguori#endif 452ac0df51dSaliguoriint main(void) { return 0; } 453ac0df51dSaliguoriEOF 45452166aa0SJuan Quintela compile_object 455ac0df51dSaliguori} 456ac0df51dSaliguori 457307119e7SGerd Hoffmanncheck_include() { 458307119e7SGerd Hoffmanncat > $TMPC <<EOF 459307119e7SGerd Hoffmann#include <$1> 460307119e7SGerd Hoffmannint main(void) { return 0; } 461307119e7SGerd HoffmannEOF 462307119e7SGerd Hoffmann compile_object 463307119e7SGerd Hoffmann} 464307119e7SGerd Hoffmann 46593b25869SJohn Snowwrite_c_skeleton() { 46693b25869SJohn Snow cat > $TMPC <<EOF 46793b25869SJohn Snowint main(void) { return 0; } 46893b25869SJohn SnowEOF 46993b25869SJohn Snow} 47093b25869SJohn Snow 471bbea4050SPeter Maydellif check_define __linux__ ; then 472ba7c60c2SPaolo Bonzini targetos=linux 473bbea4050SPeter Maydellelif check_define _WIN32 ; then 474ba7c60c2SPaolo Bonzini targetos=windows 475bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 476ba7c60c2SPaolo Bonzini targetos=openbsd 477bbea4050SPeter Maydellelif check_define __sun__ ; then 478ba7c60c2SPaolo Bonzini targetos=sunos 479bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 480ba7c60c2SPaolo Bonzini targetos=haiku 481951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 482ba7c60c2SPaolo Bonzini targetos=freebsd 483951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 484ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 485951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 486ba7c60c2SPaolo Bonzini targetos=dragonfly 487951fedfcSPeter Maydellelif check_define __NetBSD__; then 488ba7c60c2SPaolo Bonzini targetos=netbsd 489951fedfcSPeter Maydellelif check_define __APPLE__; then 490ba7c60c2SPaolo Bonzini targetos=darwin 491bbea4050SPeter Maydellelse 492951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 493951fedfcSPeter Maydell # might be going to just print the --help text, or it might 494951fedfcSPeter Maydell # be the result of a missing compiler. 495ba7c60c2SPaolo Bonzini targetos=bogus 496bbea4050SPeter Maydellfi 497bbea4050SPeter Maydell 49865eff01bSPaolo Bonzini# OS specific 49965eff01bSPaolo Bonzini 5003b0d8643SPaolo Bonzinimingw32="no" 5013b0d8643SPaolo Bonzinibsd="no" 5023b0d8643SPaolo Bonzinilinux="no" 5033b0d8643SPaolo Bonzinisolaris="no" 50465eff01bSPaolo Bonzinicase $targetos in 50565eff01bSPaolo Bonziniwindows) 50665eff01bSPaolo Bonzini mingw32="yes" 50765eff01bSPaolo Bonzini plugins="no" 50865eff01bSPaolo Bonzini pie="no" 50965eff01bSPaolo Bonzini;; 51065eff01bSPaolo Bonzinignu/kfreebsd) 51165eff01bSPaolo Bonzini bsd="yes" 51265eff01bSPaolo Bonzini;; 51365eff01bSPaolo Bonzinifreebsd) 51465eff01bSPaolo Bonzini bsd="yes" 51565eff01bSPaolo Bonzini make="${MAKE-gmake}" 51665eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 51765eff01bSPaolo Bonzini;; 51865eff01bSPaolo Bonzinidragonfly) 51965eff01bSPaolo Bonzini bsd="yes" 52065eff01bSPaolo Bonzini make="${MAKE-gmake}" 52165eff01bSPaolo Bonzini;; 52265eff01bSPaolo Bonzininetbsd) 52365eff01bSPaolo Bonzini bsd="yes" 52465eff01bSPaolo Bonzini make="${MAKE-gmake}" 52565eff01bSPaolo Bonzini;; 52665eff01bSPaolo Bonziniopenbsd) 52765eff01bSPaolo Bonzini bsd="yes" 52865eff01bSPaolo Bonzini make="${MAKE-gmake}" 52965eff01bSPaolo Bonzini;; 53065eff01bSPaolo Bonzinidarwin) 53165eff01bSPaolo Bonzini bsd="yes" 53265eff01bSPaolo Bonzini darwin="yes" 53365eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 53465eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 53565eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 53665eff01bSPaolo Bonzini;; 53765eff01bSPaolo Bonzinisunos) 53865eff01bSPaolo Bonzini solaris="yes" 53965eff01bSPaolo Bonzini make="${MAKE-gmake}" 54065eff01bSPaolo Bonzini smbd="${SMBD-/usr/sfw/sbin/smbd}" 54165eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 54265eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 54365eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 54465eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 54565eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 54665eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 547bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 548bbea4050SPeter Maydell # the correct CPU with the --cpu option. 549bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 550bbea4050SPeter Maydell cpu="x86_64" 551bbea4050SPeter Maydell fi 55265eff01bSPaolo Bonzini;; 55365eff01bSPaolo Bonzinihaiku) 55465eff01bSPaolo Bonzini pie="no" 55565eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 55665eff01bSPaolo Bonzini;; 55765eff01bSPaolo Bonzinilinux) 55865eff01bSPaolo Bonzini linux="yes" 55965eff01bSPaolo Bonzini vhost_user=${default_feature:-yes} 56065eff01bSPaolo Bonzini;; 561bbea4050SPeter Maydellesac 562bbea4050SPeter Maydell 5632ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5642ff6b91eSJuan Quintela # command line argument 5652ff6b91eSJuan Quintela : 5662ff6b91eSJuan Quintelaelif check_define __i386__ ; then 567ac0df51dSaliguori cpu="i386" 568ac0df51dSaliguorielif check_define __x86_64__ ; then 569c72b26ecSRichard Henderson if check_define __ILP32__ ; then 570c72b26ecSRichard Henderson cpu="x32" 571c72b26ecSRichard Henderson else 572ac0df51dSaliguori cpu="x86_64" 573c72b26ecSRichard Henderson fi 5743aa9bd6cSblueswir1elif check_define __sparc__ ; then 5753aa9bd6cSblueswir1 if check_define __arch64__ ; then 5763aa9bd6cSblueswir1 cpu="sparc64" 5773aa9bd6cSblueswir1 else 5783aa9bd6cSblueswir1 cpu="sparc" 5793aa9bd6cSblueswir1 fi 580fdf7ed96Smalcelif check_define _ARCH_PPC ; then 581fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 582f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 583f8378accSRichard Henderson cpu="ppc64le" 584f8378accSRichard Henderson else 585fdf7ed96Smalc cpu="ppc64" 586f8378accSRichard Henderson fi 587ac0df51dSaliguori else 588fdf7ed96Smalc cpu="ppc" 589fdf7ed96Smalc fi 590afa05235SAurelien Jarnoelif check_define __mips__ ; then 591afa05235SAurelien Jarno cpu="mips" 592d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 593d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 594d66ed0eaSAurelien Jarno cpu="s390x" 595d66ed0eaSAurelien Jarno else 596d66ed0eaSAurelien Jarno cpu="s390" 597d66ed0eaSAurelien Jarno fi 598c4f80543SAlistair Franciselif check_define __riscv ; then 599ba0e7333SRichard Henderson cpu="riscv" 60021d89f84SPeter Maydellelif check_define __arm__ ; then 60121d89f84SPeter Maydell cpu="arm" 6021f080313SClaudio Fontanaelif check_define __aarch64__ ; then 6031f080313SClaudio Fontana cpu="aarch64" 604dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 605dfcf900bSWANG Xuerui cpu="loongarch64" 606fdf7ed96Smalcelse 60789138857SStefan Weil cpu=$(uname -m) 608ac0df51dSaliguorifi 609ac0df51dSaliguori 610823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 611359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 6127d13299dSbellardcase "$cpu" in 613e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 614e4da0e39SPaolo Bonzini cpu="arm" ;; 615e4da0e39SPaolo Bonzini 6167d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 61797a847bcSbellard cpu="i386" 618e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 619e4da0e39SPaolo Bonzini x32) 6204da270beSPaolo Bonzini cpu="x86_64" 621e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 622aaa5fa14Saurel32 x86_64|amd64) 623aaa5fa14Saurel32 cpu="x86_64" 624e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 625e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 626e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 627e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 628e4da0e39SPaolo Bonzini 629afa05235SAurelien Jarno mips*) 630e4da0e39SPaolo Bonzini cpu="mips" ;; 631e4da0e39SPaolo Bonzini 632e4da0e39SPaolo Bonzini ppc) 633e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 634e4da0e39SPaolo Bonzini ppc64) 635d8ff892dSPaolo Bonzini CPU_CFLAGS="-m64 -mbig" ;; 636e4da0e39SPaolo Bonzini ppc64le) 637d8ff892dSPaolo Bonzini cpu="ppc64" 638d8ff892dSPaolo Bonzini CPU_CFLAGS="-m64 -mlittle" ;; 639e4da0e39SPaolo Bonzini 640e4da0e39SPaolo Bonzini s390) 641823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 642e4da0e39SPaolo Bonzini s390x) 643e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 644e4da0e39SPaolo Bonzini 6453142255cSblueswir1 sparc|sun4[cdmuv]) 646ae228531Sbellard cpu="sparc" 647e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 648e4da0e39SPaolo Bonzini sparc64) 649e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6507d13299dSbellardesac 651e2d52ad3SJuan Quintela 6520db4a067SPaolo Bonzini: ${make=${MAKE-make}} 653b6daf4d3SPaolo Bonzini 654faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 655faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 656ddf90699SEduardo Habkost# we check that too 657faf44142SDaniel P. Berrangépython= 6580a01d76fSMarc-André Lureauexplicit_python=no 659ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 660faf44142SDaniel P. Berrangédo 661faf44142SDaniel P. Berrangé if has "$binary" 662faf44142SDaniel P. Berrangé then 66395c5f2deSPaolo Bonzini python=$(command -v "$binary") 664faf44142SDaniel P. Berrangé break 665faf44142SDaniel P. Berrangé fi 666faf44142SDaniel P. Berrangédone 667903458c8SMarkus Armbruster 668903458c8SMarkus Armbruster 66939d87c8cSAlex Bennée# Check for ancillary tools used in testing 67039d87c8cSAlex Bennéegenisoimage= 6713df437c7SAlex Bennéefor binary in genisoimage mkisofs 67239d87c8cSAlex Bennéedo 67339d87c8cSAlex Bennée if has $binary 67439d87c8cSAlex Bennée then 67539d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 67639d87c8cSAlex Bennée break 67739d87c8cSAlex Bennée fi 67839d87c8cSAlex Bennéedone 67939d87c8cSAlex Bennée 6803c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6813c4a4d0dSPeter Maydellif has clang; then 6823c4a4d0dSPeter Maydell objcc=clang 6833c4a4d0dSPeter Maydellelse 6843c4a4d0dSPeter Maydell objcc="$cc" 6853c4a4d0dSPeter Maydellfi 6863c4a4d0dSPeter Maydell 6873457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6883457a3f8SJuan Quintela EXESUF=".exe" 68978e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6905770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 69193b25869SJohn Snow write_c_skeleton; 692d17f305aSPaolo Bonzini prefix="/qemu" 69377433a5fSMarc-André Lureau qemu_suffix="" 6943457a3f8SJuan Quintelafi 6953457a3f8SJuan Quintela 696487fefdbSAnthony Liguoriwerror="" 69785aa5189Sbellard 69861d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 69961d63097SPaolo Bonzini 70061d63097SPaolo Bonzinimeson_options= 70161d63097SPaolo Bonzinimeson_option_parse() { 70261d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 70361d63097SPaolo Bonzini if test $? -eq 1; then 70461d63097SPaolo Bonzini echo "ERROR: unknown option $1" 70561d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 70661d63097SPaolo Bonzini exit 1 70761d63097SPaolo Bonzini fi 70861d63097SPaolo Bonzini} 70961d63097SPaolo Bonzini 7107d13299dSbellardfor opt do 71189138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 7127d13299dSbellard case "$opt" in 7132efc3265Sbellard --help|-h) show_help=yes 7142efc3265Sbellard ;; 71599123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 71699123e13SMike Frysinger ;; 717b1a550a0Spbrook --prefix=*) prefix="$optarg" 7187d13299dSbellard ;; 719b1a550a0Spbrook --interp-prefix=*) interp_prefix="$optarg" 72032ce6337Sbellard ;; 721ac0df51dSaliguori --cross-prefix=*) 7227d13299dSbellard ;; 723ac0df51dSaliguori --cc=*) 7247d13299dSbellard ;; 725b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 72683469015Sbellard ;; 72783f73fceSTomoki Sekiyama --cxx=*) 72883f73fceSTomoki Sekiyama ;; 729e007dbecSMichael S. Tsirkin --iasl=*) iasl="$optarg" 730e007dbecSMichael S. Tsirkin ;; 7313c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 7323c4a4d0dSPeter Maydell ;; 733b1a550a0Spbrook --make=*) make="$optarg" 7347d13299dSbellard ;; 735b6daf4d3SPaolo Bonzini --install=*) 7366a882643Spbrook ;; 7370a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 738c886edfbSBlue Swirl ;; 7392eb054c2SPeter Maydell --sphinx-build=*) sphinx_build="$optarg" 7402eb054c2SPeter Maydell ;; 741a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 742a5665051SPaolo Bonzini ;; 743a5665051SPaolo Bonzini --meson=*) meson="$optarg" 744a5665051SPaolo Bonzini ;; 74548328880SPaolo Bonzini --ninja=*) ninja="$optarg" 74648328880SPaolo Bonzini ;; 747e2d8830eSBrad --smbd=*) smbd="$optarg" 748e2d8830eSBrad ;; 749e2a2ed06SJuan Quintela --extra-cflags=*) 7507d13299dSbellard ;; 75111cde1c8SBruno Dominguez --extra-cxxflags=*) 75211cde1c8SBruno Dominguez ;; 753e2a2ed06SJuan Quintela --extra-ldflags=*) 7547d13299dSbellard ;; 7555bc62e01SGerd Hoffmann --enable-debug-info) 7565bc62e01SGerd Hoffmann ;; 7575bc62e01SGerd Hoffmann --disable-debug-info) 7585bc62e01SGerd Hoffmann ;; 759d75402b5SAlex Bennée --cross-cc-*) 760d75402b5SAlex Bennée ;; 76117969268SFam Zheng --enable-modules) 76217969268SFam Zheng modules="yes" 76317969268SFam Zheng ;; 7643aa88b31SStefan Hajnoczi --disable-modules) 7653aa88b31SStefan Hajnoczi modules="no" 7663aa88b31SStefan Hajnoczi ;; 767bd83c861SChristian Ehrhardt --disable-module-upgrades) module_upgrades="no" 768bd83c861SChristian Ehrhardt ;; 769bd83c861SChristian Ehrhardt --enable-module-upgrades) module_upgrades="yes" 770bd83c861SChristian Ehrhardt ;; 7712ff6b91eSJuan Quintela --cpu=*) 7727d13299dSbellard ;; 773b1a550a0Spbrook --target-list=*) target_list="$optarg" 774447e133fSAlex Bennée if test "$target_list_exclude"; then 775447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 776447e133fSAlex Bennée fi 777447e133fSAlex Bennée ;; 778447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 779447e133fSAlex Bennée if test "$target_list"; then 780447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 781447e133fSAlex Bennée fi 782de83cd02Sbellard ;; 78374242e0fSPaolo Bonzini --with-trace-file=*) trace_file="$optarg" 7849410b56cSPrerna Saxena ;; 7857bc3ca7fSPaolo Bonzini --with-default-devices) default_devices="true" 786f3494749SPaolo Bonzini ;; 7877bc3ca7fSPaolo Bonzini --without-default-devices) default_devices="false" 788f3494749SPaolo Bonzini ;; 789d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 790d1d5e9eeSAlex Bennée ;; 791d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 792d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 793d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 794d1d5e9eeSAlex Bennée if test -f "$cf"; then 795d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 796d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 797d1d5e9eeSAlex Bennée else 798d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 799d1d5e9eeSAlex Bennée fi 800d1d5e9eeSAlex Bennée ;; 801c87ea116SAlex Bennée --without-default-features) # processed above 802c87ea116SAlex Bennée ;; 8031d728c39SBlue Swirl --enable-gcov) gcov="yes" 8041d728c39SBlue Swirl ;; 80579427693SLoïc Minier --static) 80679427693SLoïc Minier static="yes" 80717884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 80843ce4dfeSbellard ;; 8090b24e75fSPaolo Bonzini --mandir=*) mandir="$optarg" 8100b24e75fSPaolo Bonzini ;; 8110b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 8120b24e75fSPaolo Bonzini ;; 8133aa5d2beSAlon Levy --libdir=*) libdir="$optarg" 8143aa5d2beSAlon Levy ;; 8158bf188aaSMichael Tokarev --libexecdir=*) libexecdir="$optarg" 8168bf188aaSMichael Tokarev ;; 8170f94d6daSAlon Levy --includedir=*) includedir="$optarg" 8180f94d6daSAlon Levy ;; 819528ae5b8SEduardo Habkost --datadir=*) datadir="$optarg" 8200b24e75fSPaolo Bonzini ;; 82177433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 822023d3d67SEduardo Habkost ;; 823c6502638SBruce Rogers --docdir=*) docdir="$optarg" 8240b24e75fSPaolo Bonzini ;; 825fe0038beSPaolo Bonzini --localedir=*) localedir="$optarg" 826fe0038beSPaolo Bonzini ;; 827ca2fb938SAndre Przywara --sysconfdir=*) sysconfdir="$optarg" 82807381cc1SAnthony Liguori ;; 829785c23aeSLuiz Capitulino --localstatedir=*) local_statedir="$optarg" 830785c23aeSLuiz Capitulino ;; 8313d5eecabSGerd Hoffmann --firmwarepath=*) firmwarepath="$optarg" 8323d5eecabSGerd Hoffmann ;; 833181ce1d0SOlaf Hering --host=*|--build=*|\ 834181ce1d0SOlaf Hering --disable-dependency-tracking|\ 835785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 836fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 837023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 838023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 839023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 840023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 841023ddd74SMax Filippov # lots of directory switches by default. 842023ddd74SMax Filippov ;; 8430c58ac1cSmalc --audio-drv-list=*) audio_drv_list="$optarg" 8440c58ac1cSmalc ;; 84589138857SStefan Weil --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 846b64ec4e4SFam Zheng ;; 84789138857SStefan Weil --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 848eb852011SMarkus Armbruster ;; 849f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 850f8393946Saurel32 ;; 851f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 852f8393946Saurel32 ;; 853f3d08ee6SPaul Brook --enable-debug) 854f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 855f3d08ee6SPaul Brook debug_tcg="yes" 856*c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 857f3d08ee6SPaul Brook debug="yes" 858b553a042SJohn Snow fortify_source="no" 859f3d08ee6SPaul Brook ;; 860247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 861247724cbSMarc-André Lureau ;; 862247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 863247724cbSMarc-André Lureau ;; 8640aebab04SLingfeng Yang --enable-tsan) tsan="yes" 8650aebab04SLingfeng Yang ;; 8660aebab04SLingfeng Yang --disable-tsan) tsan="no" 8670aebab04SLingfeng Yang ;; 8684d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 869c20709aaSbellard ;; 870fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 871fd6fc214SPaolo Bonzini ;; 8724d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 8737c57bdd8SMarc-André Lureau ;; 87403a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 875675b9b53SMarc-André Lureau ;; 8761badb709SPaolo Bonzini --disable-xen) xen="disabled" 877e37630caSaliguori ;; 8781badb709SPaolo Bonzini --enable-xen) xen="enabled" 879fc321b4bSJuan Quintela ;; 8801badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 881d1a14257SAlex Bennée plugins="no" 882b3f6ea7eSPaolo Bonzini ;; 8831badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 884b3f6ea7eSPaolo Bonzini ;; 885cad25d69Spbrook --disable-system) softmmu="no" 8860a8e90f4Spbrook ;; 887cad25d69Spbrook --enable-system) softmmu="yes" 8880a8e90f4Spbrook ;; 8890953a80fSZachary Amsden --disable-user) 8900953a80fSZachary Amsden linux_user="no" ; 8910953a80fSZachary Amsden bsd_user="no" ; 8920953a80fSZachary Amsden ;; 8930953a80fSZachary Amsden --enable-user) ;; 894831b7825Sths --disable-linux-user) linux_user="no" 8950a8e90f4Spbrook ;; 896831b7825Sths --enable-linux-user) linux_user="yes" 897831b7825Sths ;; 89884778508Sblueswir1 --disable-bsd-user) bsd_user="no" 89984778508Sblueswir1 ;; 90084778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 90184778508Sblueswir1 ;; 90240d6444eSAvi Kivity --enable-pie) pie="yes" 90334005a00SKirill A. Shutemov ;; 90440d6444eSAvi Kivity --disable-pie) pie="no" 90534005a00SKirill A. Shutemov ;; 90685aa5189Sbellard --enable-werror) werror="yes" 90785aa5189Sbellard ;; 90885aa5189Sbellard --disable-werror) werror="no" 90985aa5189Sbellard ;; 910cdad781dSDaniele Buono --enable-lto) lto="true" 911cdad781dSDaniele Buono ;; 912cdad781dSDaniele Buono --disable-lto) lto="false" 913cdad781dSDaniele Buono ;; 91463678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 91563678e17SSteven Noonan ;; 91663678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 91763678e17SSteven Noonan ;; 9181e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 9191e4f6065SDaniele Buono ;; 9201e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 9211e4f6065SDaniele Buono ;; 9229e62ba48SDaniele Buono --enable-cfi) 9239e62ba48SDaniele Buono cfi="true"; 9249e62ba48SDaniele Buono lto="true"; 9259e62ba48SDaniele Buono ;; 9269e62ba48SDaniele Buono --disable-cfi) cfi="false" 9279e62ba48SDaniele Buono ;; 928fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 9292df87df7SJuan Quintela ;; 930fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 931fbb4121dSPaolo Bonzini ;; 932fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 933fbb4121dSPaolo Bonzini ;; 93403a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 9352df87df7SJuan Quintela ;; 9367e563bfbSThomas Huth --with-pkgversion=*) pkgversion="$optarg" 9374a19f1ecSpbrook ;; 938519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 939519175a2SAlex Barcelo ;; 94070c60c08SStefan Hajnoczi --disable-coroutine-pool) coroutine_pool="no" 94170c60c08SStefan Hajnoczi ;; 94270c60c08SStefan Hajnoczi --enable-coroutine-pool) coroutine_pool="yes" 94370c60c08SStefan Hajnoczi ;; 9447d992e4dSPeter Lieven --enable-debug-stack-usage) debug_stack_usage="yes" 9457d992e4dSPeter Lieven ;; 946d5970055SMichael S. Tsirkin --disable-vhost-net) vhost_net="no" 947d5970055SMichael S. Tsirkin ;; 948d5970055SMichael S. Tsirkin --enable-vhost-net) vhost_net="yes" 949d5970055SMichael S. Tsirkin ;; 950042cea27SGonglei --disable-vhost-crypto) vhost_crypto="no" 951042cea27SGonglei ;; 952299e6f19SPaolo Bonzini --enable-vhost-crypto) vhost_crypto="yes" 953042cea27SGonglei ;; 9545e9be92dSNicholas Bellinger --disable-vhost-scsi) vhost_scsi="no" 9555e9be92dSNicholas Bellinger ;; 9565e9be92dSNicholas Bellinger --enable-vhost-scsi) vhost_scsi="yes" 9575e9be92dSNicholas Bellinger ;; 958fc0b9b0eSStefan Hajnoczi --disable-vhost-vsock) vhost_vsock="no" 959fc0b9b0eSStefan Hajnoczi ;; 960fc0b9b0eSStefan Hajnoczi --enable-vhost-vsock) vhost_vsock="yes" 961fc0b9b0eSStefan Hajnoczi ;; 96298fc1adaSDr. David Alan Gilbert --disable-vhost-user-fs) vhost_user_fs="no" 96398fc1adaSDr. David Alan Gilbert ;; 96498fc1adaSDr. David Alan Gilbert --enable-vhost-user-fs) vhost_user_fs="yes" 96598fc1adaSDr. David Alan Gilbert ;; 966da076ffeSGerd Hoffmann --disable-opengl) opengl="no" 96720ff075bSMichael Walle ;; 968da076ffeSGerd Hoffmann --enable-opengl) opengl="yes" 96920ff075bSMichael Walle ;; 9701ffb3bbbSPaolo Bonzini --disable-zlib-test) 9711ece9905SAlon Levy ;; 972d138cee9SMichael Roth --enable-guest-agent) guest_agent="yes" 973d138cee9SMichael Roth ;; 974d138cee9SMichael Roth --disable-guest-agent) guest_agent="no" 975d138cee9SMichael Roth ;; 976d9840e25STomoki Sekiyama --with-vss-sdk) vss_win32_sdk="" 977d9840e25STomoki Sekiyama ;; 978d9840e25STomoki Sekiyama --with-vss-sdk=*) vss_win32_sdk="$optarg" 979d9840e25STomoki Sekiyama ;; 980d9840e25STomoki Sekiyama --without-vss-sdk) vss_win32_sdk="no" 981d9840e25STomoki Sekiyama ;; 982d9840e25STomoki Sekiyama --with-win-sdk) win_sdk="" 983d9840e25STomoki Sekiyama ;; 984d9840e25STomoki Sekiyama --with-win-sdk=*) win_sdk="$optarg" 985d9840e25STomoki Sekiyama ;; 986d9840e25STomoki Sekiyama --without-win-sdk) win_sdk="no" 987d9840e25STomoki Sekiyama ;; 9884b1c11fdSDaniel P. Berrange --enable-tools) want_tools="yes" 9894b1c11fdSDaniel P. Berrange ;; 9904b1c11fdSDaniel P. Berrange --disable-tools) want_tools="no" 9914b1c11fdSDaniel P. Berrange ;; 99252b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 99352b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 994583f6e7bSStefan Hajnoczi ;; 995cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 996cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 997cb6414dfSFam Zheng ;; 998315d3184SFam Zheng --enable-uuid|--disable-uuid) 999315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 1000315d3184SFam Zheng ;; 1001a1c5e949SDaniel P. Berrange --tls-priority=*) tls_priority="$optarg" 1002a1c5e949SDaniel P. Berrange ;; 10032da776dbSMichael R. Hines --enable-rdma) rdma="yes" 10042da776dbSMichael R. Hines ;; 10052da776dbSMichael R. Hines --disable-rdma) rdma="no" 10062da776dbSMichael R. Hines ;; 100721ab34c9SMarcel Apfelbaum --enable-pvrdma) pvrdma="yes" 100821ab34c9SMarcel Apfelbaum ;; 100921ab34c9SMarcel Apfelbaum --disable-pvrdma) pvrdma="no" 101021ab34c9SMarcel Apfelbaum ;; 1011e6a74868SMarc-André Lureau --disable-vhost-user) vhost_user="no" 1012e6a74868SMarc-André Lureau ;; 1013299e6f19SPaolo Bonzini --enable-vhost-user) vhost_user="yes" 1014299e6f19SPaolo Bonzini ;; 1015108a6481SCindy Lu --disable-vhost-vdpa) vhost_vdpa="no" 1016108a6481SCindy Lu ;; 1017108a6481SCindy Lu --enable-vhost-vdpa) vhost_vdpa="yes" 1018108a6481SCindy Lu ;; 1019299e6f19SPaolo Bonzini --disable-vhost-kernel) vhost_kernel="no" 1020299e6f19SPaolo Bonzini ;; 1021299e6f19SPaolo Bonzini --enable-vhost-kernel) vhost_kernel="yes" 1022e6a74868SMarc-André Lureau ;; 10238b18cdbfSRichard Henderson --disable-capstone) capstone="disabled" 10248ca80760SRichard Henderson ;; 10258b18cdbfSRichard Henderson --enable-capstone) capstone="enabled" 10268ca80760SRichard Henderson ;; 10278b18cdbfSRichard Henderson --enable-capstone=git) capstone="internal" 1028e219c499SRichard Henderson ;; 102903a3c0b3SPaolo Bonzini --enable-capstone=*) capstone="$optarg" 1030e219c499SRichard Henderson ;; 1031cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 1032cc84d63aSDaniel P. Berrange ;; 10337d7dbf9dSDan Streetman --with-git-submodules=*) 10347d7dbf9dSDan Streetman git_submodules_action="$optarg" 1035f62bbee5SDaniel P. Berrange ;; 10369b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 10379b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 10389b8e4298SAlex Bennée else 10399b8e4298SAlex Bennée plugins="yes" 10409b8e4298SAlex Bennée fi 104140e8c6f4SAlex Bennée ;; 104240e8c6f4SAlex Bennée --disable-plugins) plugins="no" 104340e8c6f4SAlex Bennée ;; 1044afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 1045afc3a8f9SAlex Bennée ;; 1046afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 1047afc3a8f9SAlex Bennée ;; 1048f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 1049f48e590aSAlex Bennée ;; 105054e7aac0SAlexey Krasikov --enable-keyring) secret_keyring="yes" 105154e7aac0SAlexey Krasikov ;; 105254e7aac0SAlexey Krasikov --disable-keyring) secret_keyring="no" 105354e7aac0SAlexey Krasikov ;; 105420cf7b8eSDenis Plotnikov --enable-gio) gio=yes 105520cf7b8eSDenis Plotnikov ;; 105620cf7b8eSDenis Plotnikov --disable-gio) gio=no 105720cf7b8eSDenis Plotnikov ;; 1058b8e0c493SJoelle van Dyne --enable-slirp-smbd) slirp_smbd=yes 1059b8e0c493SJoelle van Dyne ;; 1060b8e0c493SJoelle van Dyne --disable-slirp-smbd) slirp_smbd=no 1061b8e0c493SJoelle van Dyne ;; 10623b4da132SPaolo Bonzini # backwards compatibility options 10633b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 10643b4da132SPaolo Bonzini ;; 10653b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 10663b4da132SPaolo Bonzini ;; 10673b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 10683b4da132SPaolo Bonzini ;; 10693b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 10703b4da132SPaolo Bonzini ;; 10713b4da132SPaolo Bonzini # everything else has the same name in configure and meson 107261d63097SPaolo Bonzini --enable-* | --disable-*) meson_option_parse "$opt" "$optarg" 107361d63097SPaolo Bonzini ;; 10742d2ad6d0SFam Zheng *) 10752d2ad6d0SFam Zheng echo "ERROR: unknown option $opt" 10762d2ad6d0SFam Zheng echo "Try '$0 --help' for more information" 10772d2ad6d0SFam Zheng exit 1 10787f1559c6Sbalrog ;; 10797d13299dSbellard esac 10807d13299dSbellarddone 10817d13299dSbellard 1082d1a14257SAlex Bennée# test for any invalid configuration combinations 1083d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 1084d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 1085d1a14257SAlex Bennéefi 1086d1a14257SAlex Bennée 10877d7dbf9dSDan Streetmancase $git_submodules_action in 10887d7dbf9dSDan Streetman update|validate) 10897d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 10907d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 10917d7dbf9dSDan Streetman exit 1 10927d7dbf9dSDan Streetman fi 10937d7dbf9dSDan Streetman ;; 10947d7dbf9dSDan Streetman ignore) 1095b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 1096b80fd281SPaolo Bonzini then 1097b80fd281SPaolo Bonzini echo 1098b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 1099b80fd281SPaolo Bonzini echo 1100b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 1101b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 1102b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 1103b80fd281SPaolo Bonzini else 1104b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 1105b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 1106b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 1107b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 1108b80fd281SPaolo Bonzini echo 1109b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 1110b80fd281SPaolo Bonzini echo 1111b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 1112b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 1113b80fd281SPaolo Bonzini fi 1114b80fd281SPaolo Bonzini echo 1115b80fd281SPaolo Bonzini exit 1 1116b80fd281SPaolo Bonzini fi 11177d7dbf9dSDan Streetman ;; 11187d7dbf9dSDan Streetman *) 11197d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 11207d7dbf9dSDan Streetman exit 1 11217d7dbf9dSDan Streetman ;; 11227d7dbf9dSDan Streetmanesac 11237d7dbf9dSDan Streetman 112422a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}" 112522a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}" 112622a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}" 112722a87800SMarc-André Lureau 112822a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then 112915588a62SJoshua Watt bindir="${bindir:-$prefix}" 113022a87800SMarc-André Lureauelse 113115588a62SJoshua Watt bindir="${bindir:-$prefix/bin}" 113215588a62SJoshua Wattfi 113322a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}" 113422a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}" 1135ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}" 113622a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}" 113722a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}" 113816bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}" 113916bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}" 114022a87800SMarc-André Lureau 11419557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 1142b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 11432038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 11449557af9cSAlex Bennéefi 114579f3b12fSPeter Crosthwaite 114660e0df25SPeter Maydelldefault_target_list="" 11476e92f823SPeter Maydellmak_wilds="" 11486e92f823SPeter Maydell 1149b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 1150b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 1151b915a2f1SPaolo Bonzini linux_user=yes 1152b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 1153b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 1154b915a2f1SPaolo Bonzini fi 1155b915a2f1SPaolo Bonzinifi 1156b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 1157b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 1158b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 1159b915a2f1SPaolo Bonzini fi 1160b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 1161b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 1162b915a2f1SPaolo Bonzini fi 1163b915a2f1SPaolo Bonzinifi 116460e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 1165812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 116660e0df25SPeter Maydellfi 116760e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 1168812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 116960e0df25SPeter Maydellfi 117060e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 1171812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 117260e0df25SPeter Maydellfi 117360e0df25SPeter Maydell 1174447e133fSAlex Bennéefor config in $mak_wilds; do 1175447e133fSAlex Bennée target="$(basename "$config" .mak)" 117698db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 1177447e133fSAlex Bennée default_target_list="${default_target_list} $target" 1178447e133fSAlex Bennée fi 1179447e133fSAlex Bennéedone 11806e92f823SPeter Maydell 1181af5db58eSpbrookif test x"$show_help" = x"yes" ; then 1182af5db58eSpbrookcat << EOF 1183af5db58eSpbrook 1184af5db58eSpbrookUsage: configure [options] 1185af5db58eSpbrookOptions: [defaults in brackets after descriptions] 1186af5db58eSpbrook 118708fb77edSStefan WeilStandard options: 118808fb77edSStefan Weil --help print this message 118908fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 119008fb77edSStefan Weil --interp-prefix=PREFIX where to find shared libraries, etc. 119108fb77edSStefan Weil use %M for cpu name [$interp_prefix] 119274154d7eSThomas Huth --target-list=LIST set target list (default: build all) 119308fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 119408fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 1195447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 119608fb77edSStefan Weil 119708fb77edSStefan WeilAdvanced options (experts only): 11983812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 119908fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 120008fb77edSStefan Weil --iasl=IASL use ACPI compiler IASL [$iasl] 120108fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 120208fb77edSStefan Weil build time 120308fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 120408fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1205a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1206a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 120708fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1208d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1209479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 121008fb77edSStefan Weil --make=MAKE use specified make [$make] 121108fb77edSStefan Weil --python=PYTHON use specified python [$python] 12122eb054c2SPeter Maydell --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build] 1213a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 121448328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 121508fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1216db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 12177d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 12187d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 12197d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 122008fb77edSStefan Weil --static enable static build [$static] 122108fb77edSStefan Weil --mandir=PATH install man pages in PATH 122210ff82d1SMarc-André Lureau --datadir=PATH install firmware in PATH/$qemu_suffix 1223fe0038beSPaolo Bonzini --localedir=PATH install translation in PATH/$qemu_suffix 122410ff82d1SMarc-André Lureau --docdir=PATH install documentation in PATH/$qemu_suffix 122508fb77edSStefan Weil --bindir=PATH install binaries in PATH 122608fb77edSStefan Weil --libdir=PATH install libraries in PATH 1227db1b5f13SThomas Huth --libexecdir=PATH install helper binaries in PATH 122810ff82d1SMarc-André Lureau --sysconfdir=PATH install config in PATH/$qemu_suffix 122908fb77edSStefan Weil --localstatedir=PATH install local state in PATH (set at runtime on win32) 12303d5eecabSGerd Hoffmann --firmwarepath=PATH search PATH for firmware files 123113336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1232ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1233db1b5f13SThomas Huth --with-pkgversion=VERS use specified string as sub-version of the package 1234c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1235c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1236c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1237d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1238d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 123908fb77edSStefan Weil --enable-debug enable common debug build options 1240247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 12410aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 124208fb77edSStefan Weil --disable-werror disable compilation abort on warning 124363678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 124416bfbc70SPaolo Bonzini --audio-drv-list=LIST set audio drivers to try if -audiodev is not used 124508fb77edSStefan Weil --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L 124608fb77edSStefan Weil --block-drv-rw-whitelist=L 124708fb77edSStefan Weil set block driver read-write whitelist 1248e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 124908fb77edSStefan Weil --block-drv-ro-whitelist=L 125008fb77edSStefan Weil set block driver read-only whitelist 1251e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 125208fb77edSStefan Weil --with-trace-file=NAME Full PATH,NAME of file to store traces 125308fb77edSStefan Weil Default:trace-<pid> 1254c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 125508fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 125633c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 125708fb77edSStefan Weil --enable-gcov enable test coverage analysis with gcov 1258c23f23b9SMichael Tokarev --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent 1259c23f23b9SMichael Tokarev --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb) 1260a1c5e949SDaniel P. Berrange --tls-priority default TLS protocol/cipher priority string 1261c12d66aaSLin Ma --enable-debug-stack-usage 1262c12d66aaSLin Ma track the maximum stack usage of stacks created by qemu_alloc_stack 126340e8c6f4SAlex Bennée --enable-plugins 126440e8c6f4SAlex Bennée enable plugins via shared library loading 1265afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1266f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 126761d63097SPaolo BonziniEOF 126861d63097SPaolo Bonzini meson_options_help 126961d63097SPaolo Bonzinicat << EOF 1270c23f23b9SMichael Tokarev system all system emulation targets 1271c23f23b9SMichael Tokarev user supported user emulation targets 1272c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1273c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1274c23f23b9SMichael Tokarev guest-agent build the QEMU Guest Agent 1275c23f23b9SMichael Tokarev pie Position Independent Executables 127621e709aaSMarc-André Lureau modules modules support (non-Windows) 1277bd83c861SChristian Ehrhardt module-upgrades try to load modules from alternate paths for upgrades 1278c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1279c23f23b9SMichael Tokarev debug-info debugging information 1280cdad781dSDaniele Buono lto Enable Link-Time Optimization. 12811e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 12821e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 128321ab34c9SMarcel Apfelbaum rdma Enable RDMA-based migration 128421ab34c9SMarcel Apfelbaum pvrdma Enable PVRDMA support 1285299e6f19SPaolo Bonzini vhost-net vhost-net kernel acceleration support 1286299e6f19SPaolo Bonzini vhost-vsock virtio sockets device support 1287299e6f19SPaolo Bonzini vhost-scsi vhost-scsi kernel target support 1288299e6f19SPaolo Bonzini vhost-crypto vhost-user-crypto backend support 1289299e6f19SPaolo Bonzini vhost-kernel vhost kernel backend support 1290299e6f19SPaolo Bonzini vhost-user vhost-user backend support 1291108a6481SCindy Lu vhost-vdpa vhost-vdpa kernel backend support 1292c23f23b9SMichael Tokarev coroutine-pool coroutine freelist (better performance) 1293c12d66aaSLin Ma opengl opengl support 12948de73fa8SCleber Rosa tools build qemu-io, qemu-nbd and qemu-img tools 129520cf7b8eSDenis Plotnikov gio libgio support 1296b8e0c493SJoelle van Dyne slirp-smbd use smbd (at path --smbd=*) in slirp networking 129708fb77edSStefan Weil 129808fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1299af5db58eSpbrookEOF 13002d2ad6d0SFam Zhengexit 0 1301af5db58eSpbrookfi 1302af5db58eSpbrook 13039c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1304bb768f71SThomas Huthrm -f */config-devices.mak.d 13059c790242SThomas Huth 1306faf44142SDaniel P. Berrangéif test -z "$python" 1307faf44142SDaniel P. Berrangéthen 1308c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1309c53eeaf7SStefan Hajnoczifi 13108e2c76bdSRoman Bolshakovif ! has "$make" 13118e2c76bdSRoman Bolshakovthen 13128e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 13138e2c76bdSRoman Bolshakovfi 1314c53eeaf7SStefan Hajnoczi 1315c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1316c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 13171b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 13181b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1319c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1320c53eeaf7SStefan Hajnoczifi 1321c53eeaf7SStefan Hajnoczi 1322755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1323406ab2f3SCleber 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) 1324755ee70fSCleber Rosa 1325c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1326c53eeaf7SStefan Hajnoczipython="$python -B" 1327c53eeaf7SStefan Hajnoczi 13280a01d76fSMarc-André Lureauif test -z "$meson"; then 13296638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 13300a01d76fSMarc-André Lureau meson=meson 13317d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 13320a01d76fSMarc-André Lureau meson=git 13330a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 13340a01d76fSMarc-André Lureau meson=internal 13350a01d76fSMarc-André Lureau else 13360a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 13370a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 13380a01d76fSMarc-André Lureau else 1339a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1340a5665051SPaolo Bonzini fi 13410a01d76fSMarc-André Lureau fi 13420a01d76fSMarc-André Lureauelse 13430a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 13440a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 13450a01d76fSMarc-André Lureau # 13460a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 13470a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 13480a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 13490a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 13500a01d76fSMarc-André Lureau case "$meson" in 13510a01d76fSMarc-André Lureau git | internal) ;; 13520a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 13530a01d76fSMarc-André Lureau esac 13540a01d76fSMarc-André Lureau fi 13550a01d76fSMarc-André Lureaufi 1356a5665051SPaolo Bonzini 13570a01d76fSMarc-André Lureauif test "$meson" = git; then 13580a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 13590a01d76fSMarc-André Lureaufi 13600a01d76fSMarc-André Lureau 13610a01d76fSMarc-André Lureaucase "$meson" in 13620a01d76fSMarc-André Lureau git | internal) 13630a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 13640a01d76fSMarc-André Lureau ;; 136584ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 13660a01d76fSMarc-André Lureauesac 13670a01d76fSMarc-André Lureau 136809e93326SPaolo Bonzini# Probe for ninja 136948328880SPaolo Bonzini 137048328880SPaolo Bonziniif test -z "$ninja"; then 137148328880SPaolo Bonzini for c in ninja ninja-build samu; do 137248328880SPaolo Bonzini if has $c; then 137348328880SPaolo Bonzini ninja=$(command -v "$c") 137448328880SPaolo Bonzini break 137548328880SPaolo Bonzini fi 137648328880SPaolo Bonzini done 137709e93326SPaolo Bonzini if test -z "$ninja"; then 137809e93326SPaolo Bonzini error_exit "Cannot find Ninja" 137909e93326SPaolo Bonzini fi 138048328880SPaolo Bonzinifi 1381a5665051SPaolo Bonzini 13829aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 13839aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 13849aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 13859aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 13869aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 13879aae6e54SDaniel Henrique Barbozaif compile_object ; then 13889aae6e54SDaniel Henrique Barboza : C compiler works ok 13899aae6e54SDaniel Henrique Barbozaelse 13909aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 13919aae6e54SDaniel Henrique Barbozafi 13929aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 13939aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 13949aae6e54SDaniel Henrique Barbozafi 13959aae6e54SDaniel Henrique Barboza 13969c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 13979c83ffd8SPeter Maydell# by default. Only enable by default for git builds 13989c83ffd8SPeter Maydellif test -z "$werror" ; then 13997d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1400e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 14019c83ffd8SPeter Maydell werror="yes" 14029c83ffd8SPeter Maydell else 14039c83ffd8SPeter Maydell werror="no" 14049c83ffd8SPeter Maydell fi 14059c83ffd8SPeter Maydellfi 14069c83ffd8SPeter Maydell 1407975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1408fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1409fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1410fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1411fb59dabdSPeter Maydell # host OS we should stop now. 1412951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1413fb59dabdSPeter Maydellfi 1414fb59dabdSPeter Maydell 1415efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1416efc6c070SThomas Huthcat > $TMPC << EOF 1417efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1418efc6c070SThomas Huth# ifdef __apple_build_version__ 14192a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 14202a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1421efc6c070SThomas Huth# endif 1422efc6c070SThomas Huth# else 14232a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 14242a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1425efc6c070SThomas Huth# endif 1426efc6c070SThomas Huth# endif 1427efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 14283830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 14293830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1430efc6c070SThomas Huth# endif 1431efc6c070SThomas Huth#else 1432efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1433efc6c070SThomas Huth#endif 1434efc6c070SThomas Huthint main (void) { return 0; } 1435efc6c070SThomas HuthEOF 1436efc6c070SThomas Huthif ! compile_prog "" "" ; then 14373830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1438efc6c070SThomas Huthfi 1439efc6c070SThomas Huth 144000849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 144100849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 144200849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 144300849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 144400849b92SRichard Henderson# just silently disable some features, so it's too error prone. 144500849b92SRichard Henderson 144600849b92SRichard Hendersonwarn_flags= 144700849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 144800849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 144900849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 145000849b92SRichard Hendersonadd_to warn_flags -Wformat-security 145100849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 145200849b92SRichard Hendersonadd_to warn_flags -Winit-self 145300849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 145400849b92SRichard Hendersonadd_to warn_flags -Wempty-body 145500849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 145600849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 145700849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 14580a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 145900849b92SRichard Henderson 146000849b92SRichard Hendersonnowarn_flags= 146100849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 146200849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 146300849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 146400849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 146500849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1466aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1467bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 146800849b92SRichard Henderson 146900849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 147093b25869SJohn Snow 147193b25869SJohn Snowcc_has_warning_flag() { 147293b25869SJohn Snow write_c_skeleton; 147393b25869SJohn Snow 1474a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1475a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1476a1d29d6cSPeter Maydell # warning options). 147793b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 147893b25869SJohn Snow compile_prog "-Werror $optflag" "" 147993b25869SJohn Snow} 148093b25869SJohn Snow 148193b25869SJohn Snowfor flag in $gcc_flags; do 148293b25869SJohn Snow if cc_has_warning_flag $flag ; then 14838d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 14848d05095cSPaolo Bonzini fi 14858d05095cSPaolo Bonzinidone 14868d05095cSPaolo Bonzini 148763678e17SSteven Noonanif test "$stack_protector" != "no"; then 1488fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1489fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1490fccd35a0SRodrigo Rebello{ 1491fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1492fccd35a0SRodrigo Rebello while (*c) { 1493fccd35a0SRodrigo Rebello *p++ = *c++; 1494fccd35a0SRodrigo Rebello } 1495fccd35a0SRodrigo Rebello return 0; 1496fccd35a0SRodrigo Rebello} 1497fccd35a0SRodrigo RebelloEOF 149863678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 14993b463a3fSMiroslav Rezanina sp_on=0 150063678e17SSteven Noonan for flag in $gcc_flags; do 1501590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1502590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1503086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1504590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 150563678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1506db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 15073b463a3fSMiroslav Rezanina sp_on=1 150863678e17SSteven Noonan break 150963678e17SSteven Noonan fi 151063678e17SSteven Noonan done 15113b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 15123b463a3fSMiroslav Rezanina if test $sp_on = 0; then 15133b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 15143b463a3fSMiroslav Rezanina fi 15153b463a3fSMiroslav Rezanina fi 151637746c5eSMarc-André Lureaufi 151737746c5eSMarc-André Lureau 151820bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 151920bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 152020bc94a2SPaolo Bonzinicat > $TMPC << EOF 152120bc94a2SPaolo Bonzinistruct { 152220bc94a2SPaolo Bonzini int a[2]; 152320bc94a2SPaolo Bonzini} x = {0}; 152420bc94a2SPaolo BonziniEOF 152520bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 152620bc94a2SPaolo Bonzini : 152720bc94a2SPaolo Bonzinielse 152820bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 152920bc94a2SPaolo Bonzinifi 153020bc94a2SPaolo Bonzini 153121e709aaSMarc-André Lureau# Our module code doesn't support Windows 153221e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 153321e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 153421e709aaSMarc-André Lureaufi 153521e709aaSMarc-André Lureau 1536bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled 1537bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then 1538bd83c861SChristian Ehrhardt error_exit "Can't enable module-upgrades as Modules are not enabled" 1539bd83c861SChristian Ehrhardtfi 1540bd83c861SChristian Ehrhardt 15415f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 154240d6444eSAvi Kivityif test "$static" = "yes" ; then 1543aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1544aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1545aa0d1f44SPaolo Bonzini fi 15465f2453acSAlex Bennée if test "$plugins" = "yes"; then 15475f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1548ba4dd2aaSAlex Bennée else 1549ba4dd2aaSAlex Bennée plugins="no" 15505f2453acSAlex Bennée fi 155140d6444eSAvi Kivityfi 155237650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 155340d6444eSAvi Kivity 155440d6444eSAvi Kivitycat > $TMPC << EOF 155521d4a791SAvi Kivity 155621d4a791SAvi Kivity#ifdef __linux__ 155721d4a791SAvi Kivity# define THREAD __thread 155821d4a791SAvi Kivity#else 155921d4a791SAvi Kivity# define THREAD 156021d4a791SAvi Kivity#endif 156121d4a791SAvi Kivitystatic THREAD int tls_var; 156221d4a791SAvi Kivityint main(void) { return tls_var; } 156340d6444eSAvi KivityEOF 1564b2634124SRichard Henderson 1565ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1566ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1567412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1568412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1569ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1570412aeacdSAlex Bennéefi 1571412aeacdSAlex Bennée 157212781462SRichard Hendersonif test "$static" = "yes"; then 1573eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 15745770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 157512781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 157612781462SRichard Henderson pie="yes" 157712781462SRichard Henderson elif test "$pie" = "yes"; then 157812781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 157912781462SRichard Henderson else 158012781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 158112781462SRichard Henderson pie="no" 158212781462SRichard Henderson fi 158312781462SRichard Hendersonelif test "$pie" = "no"; then 15845770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1585ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1586eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 15875770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 15885770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 158940d6444eSAvi Kivity pie="yes" 15902c674109SRichard Hendersonelif test "$pie" = "yes"; then 159176ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 159240d6444eSAvi Kivityelse 159340d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 159440d6444eSAvi Kivity pie="no" 159540d6444eSAvi Kivityfi 159640d6444eSAvi Kivity 1597e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1598e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1599e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1600e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1601e6cbd751SRichard Hendersonfi 1602e6cbd751SRichard Henderson 160309dada40SPaolo Bonzini########################################## 160409dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 160509dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 160609dada40SPaolo Bonzini# specification is necessary 160709dada40SPaolo Bonzini 160809dada40SPaolo Bonziniif test "$cpu" = "i386"; then 160909dada40SPaolo Bonzini cat > $TMPC << EOF 161009dada40SPaolo Bonzinistatic int sfaa(int *ptr) 161109dada40SPaolo Bonzini{ 161209dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 161309dada40SPaolo Bonzini} 161409dada40SPaolo Bonzini 161509dada40SPaolo Bonziniint main(void) 161609dada40SPaolo Bonzini{ 161709dada40SPaolo Bonzini int val = 42; 16181405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 161909dada40SPaolo Bonzini sfaa(&val); 162009dada40SPaolo Bonzini return val; 162109dada40SPaolo Bonzini} 162209dada40SPaolo BonziniEOF 162309dada40SPaolo Bonzini if ! compile_prog "" "" ; then 162409dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 162509dada40SPaolo Bonzini fi 162609dada40SPaolo Bonzinifi 162709dada40SPaolo Bonzini 162856267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 162956267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 163056267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 163156267b62SPhilippe Mathieu-Daudéfi 163256267b62SPhilippe Mathieu-Daudé 1633afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1634fdb75aefSPaolo Bonzini default_targets=yes 1635d880a3baSPaolo Bonzini for target in $default_target_list; do 1636d880a3baSPaolo Bonzini target_list="$target_list $target" 1637d880a3baSPaolo Bonzini done 1638d880a3baSPaolo Bonzini target_list="${target_list# }" 1639121afa9eSAnthony Liguorielse 1640fdb75aefSPaolo Bonzini default_targets=no 164189138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1642d880a3baSPaolo Bonzini for target in $target_list; do 164325b48338SPeter Maydell # Check that we recognised the target name; this allows a more 164425b48338SPeter Maydell # friendly error message than if we let it fall through. 164525b48338SPeter Maydell case " $default_target_list " in 164625b48338SPeter Maydell *" $target "*) 164725b48338SPeter Maydell ;; 164825b48338SPeter Maydell *) 164925b48338SPeter Maydell error_exit "Unknown target name '$target'" 165025b48338SPeter Maydell ;; 165125b48338SPeter Maydell esac 165225b48338SPeter Maydell done 1653d880a3baSPaolo Bonzinifi 165425b48338SPeter Maydell 1655f55fe278SPaolo Bonzini# see if system emulation was really requested 1656f55fe278SPaolo Bonzinicase " $target_list " in 1657f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1658f55fe278SPaolo Bonzini ;; 1659f55fe278SPaolo Bonzini *) softmmu=no 1660f55fe278SPaolo Bonzini ;; 1661f55fe278SPaolo Bonziniesac 16625327cf48Sbellard 1663249247c9SJuan Quintelafeature_not_found() { 1664249247c9SJuan Quintela feature=$1 166521684af0SStewart Smith remedy=$2 1666249247c9SJuan Quintela 166776ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 166821684af0SStewart Smith "configure was not able to find it." \ 166921684af0SStewart Smith "$remedy" 1670249247c9SJuan Quintela} 1671249247c9SJuan Quintela 16727d13299dSbellard# --- 16737d13299dSbellard# big/little endian test 16747d13299dSbellardcat > $TMPC << EOF 1675659eb157SThomas Huth#include <stdio.h> 167661cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 167761cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1678659eb157SThomas Huthint main(int argc, char *argv[]) 1679659eb157SThomas Huth{ 1680659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 16817d13299dSbellard} 16827d13299dSbellardEOF 16837d13299dSbellard 1684659eb157SThomas Huthif compile_prog ; then 1685659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 168661cc919fSMike Frysinger bigendian="yes" 1687659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 168861cc919fSMike Frysinger bigendian="no" 16897d13299dSbellard else 16907d13299dSbellard echo big/little test failed 1691659eb157SThomas Huth exit 1 16927d13299dSbellard fi 16937d13299dSbellardelse 169461cc919fSMike Frysinger echo big/little test failed 1695659eb157SThomas Huth exit 1 16967d13299dSbellardfi 16977d13299dSbellard 1698b0a47e79SJuan Quintela########################################## 1699e10ee3f5SPhilippe Mathieu-Daudé# system tools 1700e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then 1701e10ee3f5SPhilippe Mathieu-Daudé if test "$softmmu" = "no"; then 1702e10ee3f5SPhilippe Mathieu-Daudé want_tools=no 1703e10ee3f5SPhilippe Mathieu-Daudé else 1704e10ee3f5SPhilippe Mathieu-Daudé want_tools=yes 1705e10ee3f5SPhilippe Mathieu-Daudé fi 1706e10ee3f5SPhilippe Mathieu-Daudéfi 1707e10ee3f5SPhilippe Mathieu-Daudé 1708299e6f19SPaolo Bonzini######################################### 1709299e6f19SPaolo Bonzini# vhost interdependencies and host support 1710299e6f19SPaolo Bonzini 1711299e6f19SPaolo Bonzini# vhost backends 1712d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then 1713d88618f7SStefan Hajnoczi error_exit "vhost-user is only available on Linux" 1714299e6f19SPaolo Bonzinifi 1715108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux 1716108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then 1717108a6481SCindy Lu error_exit "vhost-vdpa is only available on Linux" 1718108a6481SCindy Lufi 1719299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux 1720299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then 1721299e6f19SPaolo Bonzini error_exit "vhost-kernel is only available on Linux" 1722299e6f19SPaolo Bonzinifi 1723299e6f19SPaolo Bonzini 1724299e6f19SPaolo Bonzini# vhost-kernel devices 1725299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel 1726299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then 1727299e6f19SPaolo Bonzini error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" 1728299e6f19SPaolo Bonzinifi 1729299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel 1730299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then 1731299e6f19SPaolo Bonzini error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" 1732299e6f19SPaolo Bonzinifi 1733299e6f19SPaolo Bonzini 1734299e6f19SPaolo Bonzini# vhost-user backends 1735299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user 1736299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then 1737299e6f19SPaolo Bonzini error_exit "--enable-vhost-net-user requires --enable-vhost-user" 1738299e6f19SPaolo Bonzinifi 1739299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user 1740299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then 1741299e6f19SPaolo Bonzini error_exit "--enable-vhost-crypto requires --enable-vhost-user" 1742299e6f19SPaolo Bonzinifi 174398fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user 174498fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then 174598fc1adaSDr. David Alan Gilbert error_exit "--enable-vhost-user-fs requires --enable-vhost-user" 174698fc1adaSDr. David Alan Gilbertfi 1747108a6481SCindy Lu#vhost-vdpa backends 1748108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa 1749108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then 1750108a6481SCindy Lu error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" 1751108a6481SCindy Lufi 1752299e6f19SPaolo Bonzini 175340bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity 1754299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then 1755299e6f19SPaolo Bonzini test "$vhost_net_user" = "yes" && vhost_net=yes 175640bc0ca9SLaurent Vivier test "$vhost_net_vdpa" = "yes" && vhost_net=yes 1757299e6f19SPaolo Bonzini test "$vhost_kernel" = "yes" && vhost_net=yes 1758299e6f19SPaolo Bonzinifi 1759299e6f19SPaolo Bonzini 1760015a33bdSGonglei########################################## 1761779ab5e3SStefan Weil# pkg-config probe 1762779ab5e3SStefan Weil 1763779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 176476ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1765779ab5e3SStefan Weilfi 1766779ab5e3SStefan Weil 1767779ab5e3SStefan Weil########################################## 1768e37630caSaliguori# xen probe 1769e37630caSaliguori 17701badb709SPaolo Bonziniif test "$xen" != "disabled" ; then 1771c1cdd9d5SJuergen Gross # Check whether Xen library path is specified via --extra-ldflags to avoid 1772c1cdd9d5SJuergen Gross # overriding this setting with pkg-config output. If not, try pkg-config 1773c1cdd9d5SJuergen Gross # to obtain all needed flags. 1774c1cdd9d5SJuergen Gross 1775c1cdd9d5SJuergen Gross if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ 1776c1cdd9d5SJuergen Gross $pkg_config --exists xencontrol ; then 1777c1cdd9d5SJuergen Gross xen_ctrl_version="$(printf '%d%02d%02d' \ 1778c1cdd9d5SJuergen Gross $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" 17791badb709SPaolo Bonzini xen=enabled 17805b6a8f43SMichael Tokarev xen_pc="xencontrol xenstore xenforeignmemory xengnttab" 1781c1cdd9d5SJuergen Gross xen_pc="$xen_pc xenevtchn xendevicemodel" 178258ea9a7aSAnthony PERARD if $pkg_config --exists xentoolcore; then 178358ea9a7aSAnthony PERARD xen_pc="$xen_pc xentoolcore" 178458ea9a7aSAnthony PERARD fi 1785582ea95fSMarc-André Lureau xen_cflags="$($pkg_config --cflags $xen_pc)" 1786582ea95fSMarc-André Lureau xen_libs="$($pkg_config --libs $xen_pc)" 1787c1cdd9d5SJuergen Gross else 1788c1cdd9d5SJuergen Gross 17895b6a8f43SMichael Tokarev xen_libs="-lxenstore -lxenctrl" 1790d9506cabSAnthony PERARD xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" 1791d5b93ddfSAnthony PERARD 179250ced5b3SStefan Weil # First we test whether Xen headers and libraries are available. 179350ced5b3SStefan Weil # If no, we are done and there is no Xen support. 179450ced5b3SStefan Weil # If yes, more tests are run to detect the Xen version. 179550ced5b3SStefan Weil 179650ced5b3SStefan Weil # Xen (any) 179750ced5b3SStefan Weil cat > $TMPC <<EOF 179850ced5b3SStefan Weil#include <xenctrl.h> 179950ced5b3SStefan Weilint main(void) { 180050ced5b3SStefan Weil return 0; 180150ced5b3SStefan Weil} 180250ced5b3SStefan WeilEOF 180350ced5b3SStefan Weil if ! compile_prog "" "$xen_libs" ; then 180450ced5b3SStefan Weil # Xen not found 18051badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 180621684af0SStewart Smith feature_not_found "xen" "Install xen devel" 180750ced5b3SStefan Weil fi 18081badb709SPaolo Bonzini xen=disabled 180950ced5b3SStefan Weil 1810d5b93ddfSAnthony PERARD # Xen unstable 181169deef08SPeter Maydell elif 181269deef08SPeter Maydell cat > $TMPC <<EOF && 18132cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API 18142cbf8903SRoss Lagerwall#define __XEN_TOOLS__ 18152cbf8903SRoss Lagerwall#include <xendevicemodel.h> 1816d3c49ebbSPaul Durrant#include <xenforeignmemory.h> 18172cbf8903SRoss Lagerwallint main(void) { 18182cbf8903SRoss Lagerwall xendevicemodel_handle *xd; 1819d3c49ebbSPaul Durrant xenforeignmemory_handle *xfmem; 18202cbf8903SRoss Lagerwall 18212cbf8903SRoss Lagerwall xd = xendevicemodel_open(0, 0); 18222cbf8903SRoss Lagerwall xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); 18232cbf8903SRoss Lagerwall 1824d3c49ebbSPaul Durrant xfmem = xenforeignmemory_open(0, 0); 1825d3c49ebbSPaul Durrant xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); 1826d3c49ebbSPaul Durrant 18272cbf8903SRoss Lagerwall return 0; 18282cbf8903SRoss Lagerwall} 18292cbf8903SRoss LagerwallEOF 18302cbf8903SRoss Lagerwall compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 18312cbf8903SRoss Lagerwall then 18322cbf8903SRoss Lagerwall xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 18332cbf8903SRoss Lagerwall xen_ctrl_version=41100 18341badb709SPaolo Bonzini xen=enabled 18352cbf8903SRoss Lagerwall elif 18362cbf8903SRoss Lagerwall cat > $TMPC <<EOF && 18375ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API 18385ba3d756SIgor Druzhinin#include <xenforeignmemory.h> 183958ea9a7aSAnthony PERARD#include <xentoolcore.h> 18405ba3d756SIgor Druzhininint main(void) { 18415ba3d756SIgor Druzhinin xenforeignmemory_handle *xfmem; 18425ba3d756SIgor Druzhinin 18435ba3d756SIgor Druzhinin xfmem = xenforeignmemory_open(0, 0); 18445ba3d756SIgor Druzhinin xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); 184558ea9a7aSAnthony PERARD xentoolcore_restrict_all(0); 18465ba3d756SIgor Druzhinin 18475ba3d756SIgor Druzhinin return 0; 18485ba3d756SIgor Druzhinin} 18495ba3d756SIgor DruzhininEOF 185058ea9a7aSAnthony PERARD compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 18515ba3d756SIgor Druzhinin then 185258ea9a7aSAnthony PERARD xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 18535ba3d756SIgor Druzhinin xen_ctrl_version=41000 18541badb709SPaolo Bonzini xen=enabled 18555ba3d756SIgor Druzhinin elif 18565ba3d756SIgor Druzhinin cat > $TMPC <<EOF && 1857da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API 1858da8090ccSPaul Durrant#define __XEN_TOOLS__ 1859da8090ccSPaul Durrant#include <xendevicemodel.h> 1860da8090ccSPaul Durrantint main(void) { 1861da8090ccSPaul Durrant xendevicemodel_handle *xd; 1862da8090ccSPaul Durrant 1863da8090ccSPaul Durrant xd = xendevicemodel_open(0, 0); 1864da8090ccSPaul Durrant xendevicemodel_close(xd); 1865da8090ccSPaul Durrant 1866da8090ccSPaul Durrant return 0; 1867da8090ccSPaul Durrant} 1868da8090ccSPaul DurrantEOF 1869da8090ccSPaul Durrant compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" 1870da8090ccSPaul Durrant then 1871da8090ccSPaul Durrant xen_stable_libs="-lxendevicemodel $xen_stable_libs" 1872f1167ee6SJuergen Gross xen_ctrl_version=40900 18731badb709SPaolo Bonzini xen=enabled 1874da8090ccSPaul Durrant elif 1875da8090ccSPaul Durrant cat > $TMPC <<EOF && 18765eeb39c2SIan Campbell/* 18775eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat 18785eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given. 1879b6eb9b45SPaulina Szubarczyk * 1880b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and 1881b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented. 1882b6eb9b45SPaulina Szubarczyk */ 1883b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API 1884b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API 1885b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API 1886b6eb9b45SPaulina Szubarczyk#include <xenctrl.h> 1887b6eb9b45SPaulina Szubarczyk#include <xenstore.h> 1888b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h> 1889b6eb9b45SPaulina Szubarczyk#include <xengnttab.h> 1890b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h> 1891b6eb9b45SPaulina Szubarczyk#include <stdint.h> 1892b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h> 1893b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS) 1894b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined 1895b6eb9b45SPaulina Szubarczyk#endif 1896b6eb9b45SPaulina Szubarczykint main(void) { 1897b6eb9b45SPaulina Szubarczyk xc_interface *xc = NULL; 1898b6eb9b45SPaulina Szubarczyk xenforeignmemory_handle *xfmem; 1899b6eb9b45SPaulina Szubarczyk xenevtchn_handle *xe; 1900b6eb9b45SPaulina Szubarczyk xengnttab_handle *xg; 1901b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy_segment_t* seg = NULL; 1902b6eb9b45SPaulina Szubarczyk 1903b6eb9b45SPaulina Szubarczyk xs_daemon_open(); 1904b6eb9b45SPaulina Szubarczyk 1905b6eb9b45SPaulina Szubarczyk xc = xc_interface_open(0, 0, 0); 1906b6eb9b45SPaulina Szubarczyk xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1907b6eb9b45SPaulina Szubarczyk xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 1908b6eb9b45SPaulina Szubarczyk xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 1909b6eb9b45SPaulina Szubarczyk xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 1910b6eb9b45SPaulina Szubarczyk 1911b6eb9b45SPaulina Szubarczyk xfmem = xenforeignmemory_open(0, 0); 1912b6eb9b45SPaulina Szubarczyk xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 1913b6eb9b45SPaulina Szubarczyk 1914b6eb9b45SPaulina Szubarczyk xe = xenevtchn_open(0, 0); 1915b6eb9b45SPaulina Szubarczyk xenevtchn_fd(xe); 1916b6eb9b45SPaulina Szubarczyk 1917b6eb9b45SPaulina Szubarczyk xg = xengnttab_open(0, 0); 1918b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy(xg, 0, seg); 1919b6eb9b45SPaulina Szubarczyk 1920b6eb9b45SPaulina Szubarczyk return 0; 1921b6eb9b45SPaulina Szubarczyk} 1922b6eb9b45SPaulina SzubarczykEOF 1923b6eb9b45SPaulina Szubarczyk compile_prog "" "$xen_libs $xen_stable_libs" 1924b6eb9b45SPaulina Szubarczyk then 1925f1167ee6SJuergen Gross xen_ctrl_version=40800 19261badb709SPaolo Bonzini xen=enabled 1927b6eb9b45SPaulina Szubarczyk elif 1928b6eb9b45SPaulina Szubarczyk cat > $TMPC <<EOF && 1929b6eb9b45SPaulina Szubarczyk/* 1930b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat 1931b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given. 19325eeb39c2SIan Campbell */ 19335eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API 19345eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API 19355eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API 19365eeb39c2SIan Campbell#include <xenctrl.h> 19375eeb39c2SIan Campbell#include <xenstore.h> 19385eeb39c2SIan Campbell#include <xenevtchn.h> 19395eeb39c2SIan Campbell#include <xengnttab.h> 19405eeb39c2SIan Campbell#include <xenforeignmemory.h> 19415eeb39c2SIan Campbell#include <stdint.h> 19425eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h> 19435eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS) 19445eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined 19455eeb39c2SIan Campbell#endif 19465eeb39c2SIan Campbellint main(void) { 19475eeb39c2SIan Campbell xc_interface *xc = NULL; 19485eeb39c2SIan Campbell xenforeignmemory_handle *xfmem; 19495eeb39c2SIan Campbell xenevtchn_handle *xe; 19505eeb39c2SIan Campbell xengnttab_handle *xg; 19515eeb39c2SIan Campbell 19525eeb39c2SIan Campbell xs_daemon_open(); 19535eeb39c2SIan Campbell 19545eeb39c2SIan Campbell xc = xc_interface_open(0, 0, 0); 19555eeb39c2SIan Campbell xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 19565eeb39c2SIan Campbell xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19575eeb39c2SIan Campbell xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 19585eeb39c2SIan Campbell xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 19595eeb39c2SIan Campbell 19605eeb39c2SIan Campbell xfmem = xenforeignmemory_open(0, 0); 19615eeb39c2SIan Campbell xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 19625eeb39c2SIan Campbell 19635eeb39c2SIan Campbell xe = xenevtchn_open(0, 0); 19645eeb39c2SIan Campbell xenevtchn_fd(xe); 19655eeb39c2SIan Campbell 19665eeb39c2SIan Campbell xg = xengnttab_open(0, 0); 19675eeb39c2SIan Campbell xengnttab_map_grant_ref(xg, 0, 0, 0); 19685eeb39c2SIan Campbell 19695eeb39c2SIan Campbell return 0; 19705eeb39c2SIan Campbell} 19715eeb39c2SIan CampbellEOF 19725eeb39c2SIan Campbell compile_prog "" "$xen_libs $xen_stable_libs" 19735eeb39c2SIan Campbell then 1974f1167ee6SJuergen Gross xen_ctrl_version=40701 19751badb709SPaolo Bonzini xen=enabled 1976cdadde39SRoger Pau Monne 1977cdadde39SRoger Pau Monne # Xen 4.6 1978cdadde39SRoger Pau Monne elif 1979cdadde39SRoger Pau Monne cat > $TMPC <<EOF && 1980cdadde39SRoger Pau Monne#include <xenctrl.h> 1981e108a3c1SAnthony PERARD#include <xenstore.h> 1982d5b93ddfSAnthony PERARD#include <stdint.h> 1983d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h> 1984d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS) 1985d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined 1986d5b93ddfSAnthony PERARD#endif 1987d5b93ddfSAnthony PERARDint main(void) { 1988d5b93ddfSAnthony PERARD xc_interface *xc; 1989d5b93ddfSAnthony PERARD xs_daemon_open(); 1990d5b93ddfSAnthony PERARD xc = xc_interface_open(0, 0, 0); 1991d5b93ddfSAnthony PERARD xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1992d5b93ddfSAnthony PERARD xc_gnttab_open(NULL, 0); 1993b87de24eSAnthony PERARD xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19948688e065SStefano Stabellini xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 1995d8b441a3SJan Beulich xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 199620a544c7SKonrad Rzeszutek Wilk xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); 1997d8b441a3SJan Beulich return 0; 1998d8b441a3SJan Beulich} 1999d8b441a3SJan BeulichEOF 2000d8b441a3SJan Beulich compile_prog "" "$xen_libs" 2001d8b441a3SJan Beulich then 2002f1167ee6SJuergen Gross xen_ctrl_version=40600 20031badb709SPaolo Bonzini xen=enabled 2004d8b441a3SJan Beulich 2005d8b441a3SJan Beulich # Xen 4.5 2006d8b441a3SJan Beulich elif 2007d8b441a3SJan Beulich cat > $TMPC <<EOF && 2008d8b441a3SJan Beulich#include <xenctrl.h> 2009d8b441a3SJan Beulich#include <xenstore.h> 2010d8b441a3SJan Beulich#include <stdint.h> 2011d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h> 2012d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS) 2013d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined 2014d8b441a3SJan Beulich#endif 2015d8b441a3SJan Beulichint main(void) { 2016d8b441a3SJan Beulich xc_interface *xc; 2017d8b441a3SJan Beulich xs_daemon_open(); 2018d8b441a3SJan Beulich xc = xc_interface_open(0, 0, 0); 2019d8b441a3SJan Beulich xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2020d8b441a3SJan Beulich xc_gnttab_open(NULL, 0); 2021d8b441a3SJan Beulich xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2022d8b441a3SJan Beulich xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 20233996e85cSPaul Durrant xc_hvm_create_ioreq_server(xc, 0, 0, NULL); 20243996e85cSPaul Durrant return 0; 20253996e85cSPaul Durrant} 20263996e85cSPaul DurrantEOF 20273996e85cSPaul Durrant compile_prog "" "$xen_libs" 20283996e85cSPaul Durrant then 2029f1167ee6SJuergen Gross xen_ctrl_version=40500 20301badb709SPaolo Bonzini xen=enabled 20313996e85cSPaul Durrant 20323996e85cSPaul Durrant elif 20333996e85cSPaul Durrant cat > $TMPC <<EOF && 20343996e85cSPaul Durrant#include <xenctrl.h> 20353996e85cSPaul Durrant#include <xenstore.h> 20363996e85cSPaul Durrant#include <stdint.h> 20373996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h> 20383996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS) 20393996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined 20403996e85cSPaul Durrant#endif 20413996e85cSPaul Durrantint main(void) { 20423996e85cSPaul Durrant xc_interface *xc; 20433996e85cSPaul Durrant xs_daemon_open(); 20443996e85cSPaul Durrant xc = xc_interface_open(0, 0, 0); 20453996e85cSPaul Durrant xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 20463996e85cSPaul Durrant xc_gnttab_open(NULL, 0); 20473996e85cSPaul Durrant xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 20483996e85cSPaul Durrant xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 20498688e065SStefano Stabellini return 0; 20508688e065SStefano Stabellini} 20518688e065SStefano StabelliniEOF 20528688e065SStefano Stabellini compile_prog "" "$xen_libs" 205369deef08SPeter Maydell then 2054f1167ee6SJuergen Gross xen_ctrl_version=40200 20551badb709SPaolo Bonzini xen=enabled 20568688e065SStefano Stabellini 2057e37630caSaliguori else 20581badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 2059edfb07edSIan Campbell feature_not_found "xen (unsupported version)" \ 2060edfb07edSIan Campbell "Install a supported xen (xen 4.2 or newer)" 2061fc321b4bSJuan Quintela fi 20621badb709SPaolo Bonzini xen=disabled 2063e37630caSaliguori fi 2064d5b93ddfSAnthony PERARD 20651badb709SPaolo Bonzini if test "$xen" = enabled; then 2066f1167ee6SJuergen Gross if test $xen_ctrl_version -ge 40701 ; then 2067582ea95fSMarc-André Lureau xen_libs="$xen_libs $xen_stable_libs " 20685eeb39c2SIan Campbell fi 2069d5b93ddfSAnthony PERARD fi 2070e37630caSaliguori fi 2071c1cdd9d5SJuergen Grossfi 2072e37630caSaliguori 2073d661d9a4SJustin Terry (VM)########################################## 20742da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries 20752da776dbSMichael R. Hinesif test "$rdma" != "no" ; then 20762da776dbSMichael R. Hines cat > $TMPC <<EOF 20772da776dbSMichael R. Hines#include <rdma/rdma_cma.h> 20782da776dbSMichael R. Hinesint main(void) { return 0; } 20792da776dbSMichael R. HinesEOF 2080ef6d4ccdSYuval Shaia rdma_libs="-lrdmacm -libverbs -libumad" 20812da776dbSMichael R. Hines if compile_prog "" "$rdma_libs" ; then 20822da776dbSMichael R. Hines rdma="yes" 20832da776dbSMichael R. Hines else 20842da776dbSMichael R. Hines if test "$rdma" = "yes" ; then 20852da776dbSMichael R. Hines error_exit \ 2086ef6d4ccdSYuval Shaia " OpenFabrics librdmacm/libibverbs/libibumad not present." \ 20872da776dbSMichael R. Hines " Your options:" \ 2088ef6d4ccdSYuval Shaia " (1) Fast: Install infiniband packages (devel) from your distro." \ 20892da776dbSMichael R. Hines " (2) Cleanest: Install libraries from www.openfabrics.org" \ 20902da776dbSMichael R. Hines " (3) Also: Install softiwarp if you don't have RDMA hardware" 20912da776dbSMichael R. Hines fi 20922da776dbSMichael R. Hines rdma="no" 20932da776dbSMichael R. Hines fi 20942da776dbSMichael R. Hinesfi 20952da776dbSMichael R. Hines 209621ab34c9SMarcel Apfelbaum########################################## 209721ab34c9SMarcel Apfelbaum# PVRDMA detection 209821ab34c9SMarcel Apfelbaum 209921ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF && 210021ab34c9SMarcel Apfelbaum#include <sys/mman.h> 210121ab34c9SMarcel Apfelbaum 210221ab34c9SMarcel Apfelbaumint 210321ab34c9SMarcel Apfelbaummain(void) 210421ab34c9SMarcel Apfelbaum{ 210521ab34c9SMarcel Apfelbaum char buf = 0; 210621ab34c9SMarcel Apfelbaum void *addr = &buf; 210721ab34c9SMarcel Apfelbaum addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED); 210821ab34c9SMarcel Apfelbaum 210921ab34c9SMarcel Apfelbaum return 0; 211021ab34c9SMarcel Apfelbaum} 211121ab34c9SMarcel ApfelbaumEOF 211221ab34c9SMarcel Apfelbaum 211321ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then 211421ab34c9SMarcel Apfelbaum case "$pvrdma" in 211521ab34c9SMarcel Apfelbaum "") 211621ab34c9SMarcel Apfelbaum if compile_prog "" ""; then 211721ab34c9SMarcel Apfelbaum pvrdma="yes" 211821ab34c9SMarcel Apfelbaum else 211921ab34c9SMarcel Apfelbaum pvrdma="no" 212021ab34c9SMarcel Apfelbaum fi 212121ab34c9SMarcel Apfelbaum ;; 212221ab34c9SMarcel Apfelbaum "yes") 212321ab34c9SMarcel Apfelbaum if ! compile_prog "" ""; then 212421ab34c9SMarcel Apfelbaum error_exit "PVRDMA is not supported since mremap is not implemented" 212521ab34c9SMarcel Apfelbaum fi 212621ab34c9SMarcel Apfelbaum pvrdma="yes" 212721ab34c9SMarcel Apfelbaum ;; 212821ab34c9SMarcel Apfelbaum "no") 212921ab34c9SMarcel Apfelbaum pvrdma="no" 213021ab34c9SMarcel Apfelbaum ;; 213121ab34c9SMarcel Apfelbaum esac 213221ab34c9SMarcel Apfelbaumelse 213321ab34c9SMarcel Apfelbaum if test "$pvrdma" = "yes" ; then 213421ab34c9SMarcel Apfelbaum error_exit "PVRDMA requires rdma suppport" 213521ab34c9SMarcel Apfelbaum fi 213621ab34c9SMarcel Apfelbaum pvrdma="no" 213721ab34c9SMarcel Apfelbaumfi 213895c6bff3SBenoît Canet 2139ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported 2140ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then 2141ee108585SYuval Shaia 2142ee108585SYuval Shaiacat > $TMPC <<EOF && 2143ee108585SYuval Shaia#include <infiniband/verbs.h> 2144ee108585SYuval Shaia 2145ee108585SYuval Shaiaint 2146ee108585SYuval Shaiamain(void) 2147ee108585SYuval Shaia{ 2148ee108585SYuval Shaia struct ibv_mr *mr; 2149ee108585SYuval Shaia struct ibv_pd *pd = NULL; 2150ee108585SYuval Shaia size_t length = 10; 2151ee108585SYuval Shaia uint64_t iova = 0; 2152ee108585SYuval Shaia int access = 0; 2153ee108585SYuval Shaia void *addr = NULL; 2154ee108585SYuval Shaia 2155ee108585SYuval Shaia mr = ibv_reg_mr_iova(pd, addr, length, iova, access); 2156ee108585SYuval Shaia 2157ee108585SYuval Shaia ibv_dereg_mr(mr); 2158ee108585SYuval Shaia 2159ee108585SYuval Shaia return 0; 2160ee108585SYuval Shaia} 2161ee108585SYuval ShaiaEOF 2162ee108585SYuval Shaia if ! compile_prog "" "-libverbs"; then 2163ee108585SYuval Shaia QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR" 2164ee108585SYuval Shaia fi 2165ee108585SYuval Shaiafi 2166ee108585SYuval Shaia 216795c6bff3SBenoît Canet########################################## 2168e18df141SAnthony Liguori# glib support probe 2169a52d28afSPaolo Bonzini 2170b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 2171aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 2172aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 2173a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 2174b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 2175b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 217654cb65d8SEmilio G. Cotafi 2177e26110cfSFam Zheng 2178aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 2179e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 218089138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 218189138857SStefan Weil glib_libs=$($pkg_config --libs $i) 2182e18df141SAnthony Liguori else 2183e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 2184e26110cfSFam Zheng fi 2185e26110cfSFam Zhengdone 2186e26110cfSFam Zheng 2187215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 2188215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 2189215b0c2fSPaolo Bonzini 2190215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 2191215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 2192215b0c2fSPaolo Bonzinifi 2193215b0c2fSPaolo Bonzini 219420cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then 219520cf7b8eSDenis Plotnikov pass=no 2196f876b765SMarc-André Lureau if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then 2197f876b765SMarc-André Lureau gio_cflags=$($pkg_config --cflags gio-2.0) 2198f876b765SMarc-André Lureau gio_libs=$($pkg_config --libs gio-2.0) 219925a97a56SMarc-André Lureau gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) 22005ecfb76cSPaolo Bonzini if ! has "$gdbus_codegen"; then 22010dba4897SMarc-André Lureau gdbus_codegen= 22020dba4897SMarc-André Lureau fi 220376346b62SPeter Maydell # Check that the libraries actually work -- Ubuntu 18.04 ships 220476346b62SPeter Maydell # with pkg-config --static --libs data for gio-2.0 that is missing 220576346b62SPeter Maydell # -lblkid and will give a link error. 220613ceae66SPeter Maydell cat > $TMPC <<EOF 220713ceae66SPeter Maydell#include <gio/gio.h> 220813ceae66SPeter Maydellint main(void) 220913ceae66SPeter Maydell{ 221013ceae66SPeter Maydell g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); 221113ceae66SPeter Maydell return 0; 221213ceae66SPeter Maydell} 221313ceae66SPeter MaydellEOF 221413ceae66SPeter Maydell if compile_prog "$gio_cflags" "$gio_libs" ; then 221520cf7b8eSDenis Plotnikov pass=yes 221676346b62SPeter Maydell else 221720cf7b8eSDenis Plotnikov pass=no 2218f876b765SMarc-André Lureau fi 2219f876b765SMarc-André Lureau 222020cf7b8eSDenis Plotnikov if test "$pass" = "yes" && 222120cf7b8eSDenis Plotnikov $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then 222225a97a56SMarc-André Lureau gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)" 222325a97a56SMarc-André Lureau gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)" 222425a97a56SMarc-André Lureau fi 222520cf7b8eSDenis Plotnikov fi 222620cf7b8eSDenis Plotnikov 222720cf7b8eSDenis Plotnikov if test "$pass" = "no"; then 222820cf7b8eSDenis Plotnikov if test "$gio" = "yes"; then 222920cf7b8eSDenis Plotnikov feature_not_found "gio" "Install libgio >= 2.0" 223020cf7b8eSDenis Plotnikov else 223120cf7b8eSDenis Plotnikov gio=no 223220cf7b8eSDenis Plotnikov fi 223320cf7b8eSDenis Plotnikov else 223420cf7b8eSDenis Plotnikov gio=yes 223520cf7b8eSDenis Plotnikov fi 223620cf7b8eSDenis Plotnikovfi 223725a97a56SMarc-André Lureau 2238977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 2239977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 2240977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 2241977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 2242977a82abSDaniel P. Berrangecat > $TMPC <<EOF 2243977a82abSDaniel P. Berrange#include <glib.h> 2244977a82abSDaniel P. Berrange#include <unistd.h> 2245977a82abSDaniel P. Berrange 2246977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 2247977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 2248977a82abSDaniel P. Berrange 2249977a82abSDaniel P. Berrangeint main(void) { 2250977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 2251977a82abSDaniel P. Berrange return 0; 2252977a82abSDaniel P. Berrange} 2253977a82abSDaniel P. BerrangeEOF 2254977a82abSDaniel P. Berrange 2255215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 2256977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 2257977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 2258977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 2259977a82abSDaniel P. Berrange "build target" 2260977a82abSDaniel P. Berrangefi 2261977a82abSDaniel P. Berrange 22629bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 22639bda600bSEric Blakecat > $TMPC << EOF 22649bda600bSEric Blake#include <glib.h> 22659bda600bSEric Blaketypedef struct Foo { 22669bda600bSEric Blake int i; 22679bda600bSEric Blake} Foo; 22689bda600bSEric Blakestatic void foo_free(Foo *f) 22699bda600bSEric Blake{ 22709bda600bSEric Blake g_free(f); 22719bda600bSEric Blake} 22729bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free); 22739bda600bSEric Blakeint main(void) { return 0; } 22749bda600bSEric BlakeEOF 22759bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 22769bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 22779bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 22785770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 22799bda600bSEric Blake fi 22809bda600bSEric Blakefi 22819bda600bSEric Blake 2282e26110cfSFam Zheng########################################## 2283e26110cfSFam Zheng# SHA command probe for modules 2284e26110cfSFam Zhengif test "$modules" = yes; then 2285e26110cfSFam Zheng shacmd_probe="sha1sum sha1 shasum" 2286e26110cfSFam Zheng for c in $shacmd_probe; do 22878ccefb91SFam Zheng if has $c; then 2288e26110cfSFam Zheng shacmd="$c" 2289e26110cfSFam Zheng break 2290e26110cfSFam Zheng fi 2291e26110cfSFam Zheng done 2292e26110cfSFam Zheng if test "$shacmd" = ""; then 2293e26110cfSFam Zheng error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" 2294e26110cfSFam Zheng fi 2295e18df141SAnthony Liguorifi 2296e18df141SAnthony Liguori 2297e18df141SAnthony Liguori########################################## 2298f652e6afSaurel32# fdt probe 2299e169e1e1SPeter Maydell 2300fbb4121dSPaolo Bonzinicase "$fdt" in 2301fbb4121dSPaolo Bonzini auto | enabled | internal) 2302fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 2303aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 2304fbb4121dSPaolo Bonzini ;; 2305fbb4121dSPaolo Bonziniesac 2306f652e6afSaurel32 230720ff075bSMichael Walle########################################## 23089d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk) 2309b1546f32SGerd Hoffmann 2310da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then 2311bc6a3565SAkihiko Odaki epoxy=no 2312bc6a3565SAkihiko Odaki if $pkg_config epoxy; then 2313bc6a3565SAkihiko Odaki cat > $TMPC << EOF 2314bc6a3565SAkihiko Odaki#include <epoxy/egl.h> 2315bc6a3565SAkihiko Odakiint main(void) { return 0; } 2316bc6a3565SAkihiko OdakiEOF 2317bc6a3565SAkihiko Odaki if compile_prog "" "" ; then 2318bc6a3565SAkihiko Odaki epoxy=yes 2319bc6a3565SAkihiko Odaki fi 2320bc6a3565SAkihiko Odaki fi 2321bc6a3565SAkihiko Odaki 2322bc6a3565SAkihiko Odaki if test "$epoxy" = "yes" ; then 2323bc6a3565SAkihiko Odaki opengl_cflags="$($pkg_config --cflags epoxy)" 2324bc6a3565SAkihiko Odaki opengl_libs="$($pkg_config --libs epoxy)" 2325da076ffeSGerd Hoffmann opengl=yes 232620ff075bSMichael Walle else 2327da076ffeSGerd Hoffmann if test "$opengl" = "yes" ; then 2328bc6a3565SAkihiko Odaki feature_not_found "opengl" "Please install epoxy with EGL" 232920ff075bSMichael Walle fi 2330f676c67eSJeremy White opengl_cflags="" 2331da076ffeSGerd Hoffmann opengl_libs="" 2332da076ffeSGerd Hoffmann opengl=no 233320ff075bSMichael Walle fi 233420ff075bSMichael Wallefi 233520ff075bSMichael Walle 2336955727d2SCortland Tölva# check for usbfs 2337955727d2SCortland Tölvahave_usbfs=no 2338955727d2SCortland Tölvaif test "$linux_user" = "yes"; then 233996566d09SThomas Petazzoni cat > $TMPC << EOF 234096566d09SThomas Petazzoni#include <linux/usbdevice_fs.h> 234196566d09SThomas Petazzoni 234296566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES 234396566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined" 234496566d09SThomas Petazzoni#endif 234596566d09SThomas Petazzoni 234696566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM 234796566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined" 234896566d09SThomas Petazzoni#endif 234996566d09SThomas Petazzoni 235096566d09SThomas Petazzoniint main(void) 235196566d09SThomas Petazzoni{ 235296566d09SThomas Petazzoni return 0; 235396566d09SThomas Petazzoni} 235496566d09SThomas PetazzoniEOF 235596566d09SThomas Petazzoni if compile_prog "" ""; then 2356955727d2SCortland Tölva have_usbfs=yes 2357955727d2SCortland Tölva fi 2358955727d2SCortland Tölvafi 2359751bcc39SMarc-André Lureau 2360de5071c5SBlue Swirl########################################## 2361d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win 2362d9840e25STomoki Sekiyama 23633b0d8643SPaolo Bonziniguest_agent_with_vss="no" 2364e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \ 2365e633a5c6SEric Blake test "$vss_win32_sdk" != "no" ; then 2366d9840e25STomoki Sekiyama case "$vss_win32_sdk" in 2367690604f6SMichael Roth "") vss_win32_include="-isystem $source_path" ;; 2368d9840e25STomoki Sekiyama *\ *) # The SDK is installed in "Program Files" by default, but we cannot 2369d9840e25STomoki Sekiyama # handle path with spaces. So we symlink the headers into ".sdk/vss". 2370690604f6SMichael Roth vss_win32_include="-isystem $source_path/.sdk/vss" 2371d9840e25STomoki Sekiyama symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc" 2372d9840e25STomoki Sekiyama ;; 2373690604f6SMichael Roth *) vss_win32_include="-isystem $vss_win32_sdk" 2374d9840e25STomoki Sekiyama esac 2375d9840e25STomoki Sekiyama cat > $TMPC << EOF 2376d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__ 2377d9840e25STomoki Sekiyama#include <inc/win2003/vss.h> 2378d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; } 2379d9840e25STomoki SekiyamaEOF 2380d9840e25STomoki Sekiyama if compile_prog "$vss_win32_include" "" ; then 2381d9840e25STomoki Sekiyama guest_agent_with_vss="yes" 2382d9840e25STomoki Sekiyama QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include" 2383d9840e25STomoki Sekiyama else 2384d9840e25STomoki Sekiyama if test "$vss_win32_sdk" != "" ; then 2385d9840e25STomoki Sekiyama echo "ERROR: Please download and install Microsoft VSS SDK:" 2386d9840e25STomoki Sekiyama echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490" 2387d9840e25STomoki Sekiyama echo "ERROR: On POSIX-systems, you can extract the SDK headers by:" 2388d9840e25STomoki Sekiyama echo "ERROR: scripts/extract-vsssdk-headers setup.exe" 2389d9840e25STomoki Sekiyama echo "ERROR: The headers are extracted in the directory \`inc'." 2390d9840e25STomoki Sekiyama feature_not_found "VSS support" 2391d9840e25STomoki Sekiyama fi 2392d9840e25STomoki Sekiyama fi 2393d9840e25STomoki Sekiyamafi 2394d9840e25STomoki Sekiyama 2395d9840e25STomoki Sekiyama########################################## 2396d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified) 2397d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent 2398d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the 2399d9840e25STomoki Sekiyama# pre-compiled .tlb file is included. 2400d9840e25STomoki Sekiyama 2401e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \ 2402e633a5c6SEric Blake test "$guest_agent_with_vss" = "yes" ; then 2403d9840e25STomoki Sekiyama if test -z "$win_sdk"; then 2404d9840e25STomoki Sekiyama programfiles="$PROGRAMFILES" 2405d9840e25STomoki Sekiyama test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432" 2406d9840e25STomoki Sekiyama if test -n "$programfiles"; then 2407d9840e25STomoki Sekiyama win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null 2408d9840e25STomoki Sekiyama else 2409d9840e25STomoki Sekiyama feature_not_found "Windows SDK" 2410d9840e25STomoki Sekiyama fi 2411d9840e25STomoki Sekiyama elif test "$win_sdk" = "no"; then 2412d9840e25STomoki Sekiyama win_sdk="" 2413d9840e25STomoki Sekiyama fi 2414d9840e25STomoki Sekiyamafi 2415d9840e25STomoki Sekiyama 2416d9840e25STomoki Sekiyama########################################## 241750cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h 24183b0d8643SPaolo Bonziniguest_agent_ntddscsi="no" 2419e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then 242050cbebb9SMichael Roth cat > $TMPC << EOF 242150cbebb9SMichael Roth#include <windows.h> 242250cbebb9SMichael Roth#include <ntddscsi.h> 242350cbebb9SMichael Rothint main(void) { 242450cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS) 242550cbebb9SMichael Roth#error Missing required ioctl definitions 242650cbebb9SMichael Roth#endif 242750cbebb9SMichael Roth SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 }; 242850cbebb9SMichael Roth return addr.Lun; 242950cbebb9SMichael Roth} 243050cbebb9SMichael RothEOF 243150cbebb9SMichael Roth if compile_prog "" "" ; then 243250cbebb9SMichael Roth guest_agent_ntddscsi=yes 243350cbebb9SMichael Roth fi 243450cbebb9SMichael Rothfi 243550cbebb9SMichael Roth 243650cbebb9SMichael Roth########################################## 24378ca80760SRichard Henderson# capstone 24388ca80760SRichard Henderson 2439e219c499SRichard Hendersoncase "$capstone" in 24408b18cdbfSRichard Henderson auto | enabled | internal) 24418b18cdbfSRichard Henderson # Simpler to always update submodule, even if not needed. 2442e219c499SRichard Henderson git_submodules="${git_submodules} capstone" 2443e219c499SRichard Henderson ;; 2444e219c499SRichard Hendersonesac 24458ca80760SRichard Henderson 24468ca80760SRichard Henderson########################################## 2447519175a2SAlex Barcelo# check and set a backend for coroutine 2448d0e2fce5SAneesh Kumar K.V 24497c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 245033c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 245133c53c54SDaniel P. Berrange# specific one. 24527c2acc70SPeter Maydell 24537c2acc70SPeter Maydellucontext_works=no 2454d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 2455d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 2456d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 2457cdf84806SPeter Maydell#ifdef __stub_makecontext 2458cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 2459cdf84806SPeter Maydell#endif 246075cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 2461d0e2fce5SAneesh Kumar K.VEOF 2462d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 24637c2acc70SPeter Maydell ucontext_works=yes 2464d0e2fce5SAneesh Kumar K.V fi 2465519175a2SAlex Barcelofi 24667c2acc70SPeter Maydell 24677c2acc70SPeter Maydellif test "$coroutine" = ""; then 24687c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 24697c2acc70SPeter Maydell coroutine=win32 24707c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 24717c2acc70SPeter Maydell coroutine=ucontext 2472519175a2SAlex Barcelo else 24737c2acc70SPeter Maydell coroutine=sigaltstack 24747c2acc70SPeter Maydell fi 24757c2acc70SPeter Maydellelse 24767c2acc70SPeter Maydell case $coroutine in 24777c2acc70SPeter Maydell windows) 24787c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 24797c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 24807c2acc70SPeter Maydell fi 24817c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 24827c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 24837c2acc70SPeter Maydell coroutine=win32 24847c2acc70SPeter Maydell ;; 24857c2acc70SPeter Maydell ucontext) 24867c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 24877c2acc70SPeter Maydell feature_not_found "ucontext" 24887c2acc70SPeter Maydell fi 24897c2acc70SPeter Maydell ;; 249033c53c54SDaniel P. Berrange sigaltstack) 24917c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 24927c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 24937c2acc70SPeter Maydell fi 24947c2acc70SPeter Maydell ;; 24957c2acc70SPeter Maydell *) 249676ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 24977c2acc70SPeter Maydell ;; 24987c2acc70SPeter Maydell esac 2499d0e2fce5SAneesh Kumar K.Vfi 2500d0e2fce5SAneesh Kumar K.V 250170c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then 250270c60c08SStefan Hajnoczi coroutine_pool=yes 250370c60c08SStefan Hajnoczifi 250470c60c08SStefan Hajnoczi 25057d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then 25067d992e4dSPeter Lieven if test "$coroutine_pool" = "yes"; then 25077d992e4dSPeter Lieven echo "WARN: disabling coroutine pool for stack usage debugging" 25087d992e4dSPeter Lieven coroutine_pool=no 25097d992e4dSPeter Lieven fi 25107d992e4dSPeter Lievenfi 25117d992e4dSPeter Lieven 25121e4f6065SDaniele Buono################################################## 25131e4f6065SDaniele Buono# SafeStack 25141e4f6065SDaniele Buono 25151e4f6065SDaniele Buono 25161e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 25171e4f6065SDaniele Buonocat > $TMPC << EOF 25181e4f6065SDaniele Buonoint main(int argc, char *argv[]) 25191e4f6065SDaniele Buono{ 25201e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 25211e4f6065SDaniele Buono#error SafeStack Disabled 25221e4f6065SDaniele Buono#endif 25231e4f6065SDaniele Buono return 0; 25241e4f6065SDaniele Buono} 25251e4f6065SDaniele BuonoEOF 25261e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 25271e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 25281e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 25291e4f6065SDaniele Buono # Flag needed both at compilation and at linking 25301e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 25311e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 25321e4f6065SDaniele Buono else 25331e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 25341e4f6065SDaniele Buono fi 25351e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 25361e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 25371e4f6065SDaniele Buono fi 25381e4f6065SDaniele Buonoelse 25391e4f6065SDaniele Buonocat > $TMPC << EOF 25401e4f6065SDaniele Buonoint main(int argc, char *argv[]) 25411e4f6065SDaniele Buono{ 25421e4f6065SDaniele Buono#if defined(__has_feature) 25431e4f6065SDaniele Buono#if __has_feature(safe_stack) 25441e4f6065SDaniele Buono#error SafeStack Enabled 25451e4f6065SDaniele Buono#endif 25461e4f6065SDaniele Buono#endif 25471e4f6065SDaniele Buono return 0; 25481e4f6065SDaniele Buono} 25491e4f6065SDaniele BuonoEOF 25501e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 25511e4f6065SDaniele Buono # Make sure that safe-stack is disabled 25521e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 25531e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 25541e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 25551e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 25561e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 25571e4f6065SDaniele Buono fi 25581e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 25591e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 25601e4f6065SDaniele Buono fi 25611e4f6065SDaniele Buonoelse # "$safe_stack" = "" 25621e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 25631e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 25641e4f6065SDaniele Buono safe_stack="no" 25651e4f6065SDaniele Buono else 25661e4f6065SDaniele Buono safe_stack="yes" 25671e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 25681e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 25691e4f6065SDaniele Buono fi 25701e4f6065SDaniele Buono fi 25711e4f6065SDaniele Buonofi 25721e4f6065SDaniele Buonofi 25737d992e4dSPeter Lieven 257476a347e1SRichard Henderson######################################## 2575f540166bSRichard Henderson# check if __[u]int128_t is usable. 2576f540166bSRichard Henderson 2577f540166bSRichard Hendersonint128=no 2578f540166bSRichard Hendersoncat > $TMPC << EOF 2579f540166bSRichard Henderson__int128_t a; 2580f540166bSRichard Henderson__uint128_t b; 2581f540166bSRichard Hendersonint main (void) { 2582f540166bSRichard Henderson a = a + b; 2583f540166bSRichard Henderson b = a * b; 2584464e3671SPeter Maydell a = a * a; 2585f540166bSRichard Henderson return 0; 2586f540166bSRichard Henderson} 2587f540166bSRichard HendersonEOF 2588f540166bSRichard Hendersonif compile_prog "" "" ; then 2589f540166bSRichard Henderson int128=yes 2590f540166bSRichard Hendersonfi 259176a347e1SRichard Henderson 25927ebee43eSRichard Henderson######################################### 25937ebee43eSRichard Henderson# See if 128-bit atomic operations are supported. 25947ebee43eSRichard Henderson 25957ebee43eSRichard Hendersonatomic128=no 25967ebee43eSRichard Hendersonif test "$int128" = "yes"; then 25977ebee43eSRichard Henderson cat > $TMPC << EOF 25987ebee43eSRichard Hendersonint main(void) 25997ebee43eSRichard Henderson{ 26007ebee43eSRichard Henderson unsigned __int128 x = 0, y = 0; 2601bceac547SThomas Huth y = __atomic_load(&x, 0); 2602bceac547SThomas Huth __atomic_store(&x, y, 0); 2603bceac547SThomas Huth __atomic_compare_exchange(&x, &y, x, 0, 0, 0); 26047ebee43eSRichard Henderson return 0; 26057ebee43eSRichard Henderson} 26067ebee43eSRichard HendersonEOF 26077ebee43eSRichard Henderson if compile_prog "" "" ; then 26087ebee43eSRichard Henderson atomic128=yes 26097ebee43eSRichard Henderson fi 26107ebee43eSRichard Hendersonfi 26117ebee43eSRichard Henderson 2612e6cd4bb5SRichard Hendersoncmpxchg128=no 2613e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then 2614e6cd4bb5SRichard Henderson cat > $TMPC << EOF 2615e6cd4bb5SRichard Hendersonint main(void) 2616e6cd4bb5SRichard Henderson{ 2617e6cd4bb5SRichard Henderson unsigned __int128 x = 0, y = 0; 2618e6cd4bb5SRichard Henderson __sync_val_compare_and_swap_16(&x, y, x); 2619e6cd4bb5SRichard Henderson return 0; 2620e6cd4bb5SRichard Henderson} 2621e6cd4bb5SRichard HendersonEOF 2622e6cd4bb5SRichard Henderson if compile_prog "" "" ; then 2623e6cd4bb5SRichard Henderson cmpxchg128=yes 2624e6cd4bb5SRichard Henderson fi 2625e6cd4bb5SRichard Hendersonfi 2626e6cd4bb5SRichard Henderson 2627fd0e6053SJohn Snow######################################## 2628fd0e6053SJohn Snow# check if ccache is interfering with 2629fd0e6053SJohn Snow# semantic analysis of macros 2630fd0e6053SJohn Snow 26315e4dfd3dSJohn Snowunset CCACHE_CPP2 2632fd0e6053SJohn Snowccache_cpp2=no 2633fd0e6053SJohn Snowcat > $TMPC << EOF 2634fd0e6053SJohn Snowstatic const int Z = 1; 2635fd0e6053SJohn Snow#define fn() ({ Z; }) 2636fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 2637fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 2638fd0e6053SJohn Snow#define ID(X) (X) 2639fd0e6053SJohn Snowint main(int argc, char *argv[]) 2640fd0e6053SJohn Snow{ 2641fd0e6053SJohn Snow int x = 0, y = 0; 2642fd0e6053SJohn Snow x = ID(x); 2643fd0e6053SJohn Snow x = fn(); 2644fd0e6053SJohn Snow fn(); 2645fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 2646fd0e6053SJohn Snow if (TAUT(Z)) return 0; 2647fd0e6053SJohn Snow return 0; 2648fd0e6053SJohn Snow} 2649fd0e6053SJohn SnowEOF 2650fd0e6053SJohn Snow 2651fd0e6053SJohn Snowif ! compile_object "-Werror"; then 2652fd0e6053SJohn Snow ccache_cpp2=yes 2653fd0e6053SJohn Snowfi 2654fd0e6053SJohn Snow 2655b553a042SJohn Snow################################################# 2656b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 2657b553a042SJohn Snow 2658b553a042SJohn Snowif test "$fortify_source" != "no"; then 2659b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 2660b553a042SJohn Snow fortify_source="no"; 2661e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 2662cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 2663b553a042SJohn Snow fortify_source="no"; 2664b553a042SJohn Snow else 2665b553a042SJohn Snow fortify_source="yes" 2666b553a042SJohn Snow fi 2667b553a042SJohn Snowfi 2668b553a042SJohn Snow 2669d2042378SAneesh Kumar K.V########################################## 2670247724cbSMarc-André Lureau# checks for sanitizers 2671247724cbSMarc-André Lureau 2672247724cbSMarc-André Lureauhave_asan=no 2673247724cbSMarc-André Lureauhave_ubsan=no 2674d83414e1SMarc-André Lureauhave_asan_iface_h=no 2675d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 2676247724cbSMarc-André Lureau 2677247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 2678b9f44da2SMarc-André Lureau write_c_skeleton 2679247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 2680247724cbSMarc-André Lureau have_asan=yes 2681247724cbSMarc-André Lureau fi 2682b9f44da2SMarc-André Lureau 2683b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 2684b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 2685b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 2686b9f44da2SMarc-André Lureau cat > $TMPC << EOF 2687b9f44da2SMarc-André Lureau#include <stdlib.h> 2688b9f44da2SMarc-André Lureauint main(void) { 2689b9f44da2SMarc-André Lureau void *tmp = malloc(10); 2690f2dfe54cSLeonid Bloch if (tmp != NULL) { 2691b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 2692b9f44da2SMarc-André Lureau } 2693d1abf3fcSOlaf Hering return 1; 2694f2dfe54cSLeonid Bloch} 2695b9f44da2SMarc-André LureauEOF 2696247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 2697247724cbSMarc-André Lureau have_ubsan=yes 2698247724cbSMarc-André Lureau fi 2699d83414e1SMarc-André Lureau 2700d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 2701d83414e1SMarc-André Lureau have_asan_iface_h=yes 2702d83414e1SMarc-André Lureau fi 2703d83414e1SMarc-André Lureau 2704d83414e1SMarc-André Lureau cat > $TMPC << EOF 2705d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 2706d83414e1SMarc-André Lureauint main(void) { 2707d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 2708d83414e1SMarc-André Lureau return 0; 2709d83414e1SMarc-André Lureau} 2710d83414e1SMarc-André LureauEOF 2711d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 2712d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 2713d83414e1SMarc-André Lureau fi 2714247724cbSMarc-André Lureaufi 2715247724cbSMarc-André Lureau 27160aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 27170aebab04SLingfeng Yang# keep it separate until that is not the case. 27180aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 27190aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 27200aebab04SLingfeng Yangfi 27210aebab04SLingfeng Yanghave_tsan=no 27220aebab04SLingfeng Yanghave_tsan_iface_fiber=no 27230aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 27240aebab04SLingfeng Yang write_c_skeleton 27250aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 27260aebab04SLingfeng Yang have_tsan=yes 27270aebab04SLingfeng Yang fi 27280aebab04SLingfeng Yang cat > $TMPC << EOF 27290aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 27300aebab04SLingfeng Yangint main(void) { 27310aebab04SLingfeng Yang __tsan_create_fiber(0); 27320aebab04SLingfeng Yang return 0; 27330aebab04SLingfeng Yang} 27340aebab04SLingfeng YangEOF 27350aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 27360aebab04SLingfeng Yang have_tsan_iface_fiber=yes 27370aebab04SLingfeng Yang fi 27380aebab04SLingfeng Yangfi 27390aebab04SLingfeng Yang 2740adc28027SAlexander Bulekov########################################## 2741675b9b53SMarc-André Lureau# check for slirp 2742675b9b53SMarc-André Lureau 2743675b9b53SMarc-André Lureaucase "$slirp" in 27444d34a86bSPaolo Bonzini auto | enabled | internal) 27454d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 27467c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 2747675b9b53SMarc-André Lureau ;; 2748675b9b53SMarc-André Lureauesac 2749675b9b53SMarc-André Lureau 2750b8e0c493SJoelle van Dyne# Check for slirp smbd dupport 2751b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}} 2752b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then 2753b8e0c493SJoelle van Dyne if test "$mingw32" = "yes" ; then 2754b8e0c493SJoelle van Dyne if test "$slirp_smbd" = "yes" ; then 2755b8e0c493SJoelle van Dyne error_exit "Host smbd not supported on this platform." 2756b8e0c493SJoelle van Dyne fi 2757b8e0c493SJoelle van Dyne slirp_smbd=no 2758b8e0c493SJoelle van Dyne else 2759b8e0c493SJoelle van Dyne slirp_smbd=yes 2760b8e0c493SJoelle van Dyne fi 2761b8e0c493SJoelle van Dynefi 2762b8e0c493SJoelle van Dyne 276354e7aac0SAlexey Krasikov########################################## 276454e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall 276554e7aac0SAlexey Krasikov 276654e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then 276754e7aac0SAlexey Krasikov 276854e7aac0SAlexey Krasikov have_keyring=no 276954e7aac0SAlexey Krasikov cat > $TMPC << EOF 277054e7aac0SAlexey Krasikov#include <errno.h> 277154e7aac0SAlexey Krasikov#include <asm/unistd.h> 277254e7aac0SAlexey Krasikov#include <linux/keyctl.h> 277354e7aac0SAlexey Krasikov#include <unistd.h> 277454e7aac0SAlexey Krasikovint main(void) { 277554e7aac0SAlexey Krasikov return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0); 277654e7aac0SAlexey Krasikov} 277754e7aac0SAlexey KrasikovEOF 277854e7aac0SAlexey Krasikov if compile_prog "" "" ; then 277954e7aac0SAlexey Krasikov have_keyring=yes 278054e7aac0SAlexey Krasikov fi 278154e7aac0SAlexey Krasikovfi 278254e7aac0SAlexey Krasikovif test "$secret_keyring" != "no" 278354e7aac0SAlexey Krasikovthen 2784b418d265SDavid Edmondson if test "$have_keyring" = "yes" 278554e7aac0SAlexey Krasikov then 278654e7aac0SAlexey Krasikov secret_keyring=yes 278754e7aac0SAlexey Krasikov else 278854e7aac0SAlexey Krasikov if test "$secret_keyring" = "yes" 278954e7aac0SAlexey Krasikov then 279054e7aac0SAlexey Krasikov error_exit "syscall __NR_keyctl requested, \ 279154e7aac0SAlexey Krasikovbut not implemented on your system" 279254e7aac0SAlexey Krasikov else 279354e7aac0SAlexey Krasikov secret_keyring=no 279454e7aac0SAlexey Krasikov fi 279554e7aac0SAlexey Krasikov fi 279654e7aac0SAlexey Krasikovfi 279754e7aac0SAlexey Krasikov 279892500362SAlexey Krasikov########################################## 2799e86ecd4bSJuan Quintela# End of CC checks 2800e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 2801e86ecd4bSJuan Quintela 2802d83414e1SMarc-André Lureauwrite_c_skeleton 2803d83414e1SMarc-André Lureau 28041d728c39SBlue Swirlif test "$gcov" = "yes" ; then 2805bf0e56a3SMarc-André Lureau : 2806b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then 2807086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 2808086d5f75SPaolo Bonzini debug=no 2809086d5f75SPaolo Bonzinifi 2810086d5f75SPaolo Bonzini 2811086d5f75SPaolo Bonzinicase "$ARCH" in 2812086d5f75SPaolo Bonzinialpha) 2813086d5f75SPaolo Bonzini # Ensure there's only a single GP 2814086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 2815086d5f75SPaolo Bonzini;; 2816086d5f75SPaolo Bonziniesac 2817086d5f75SPaolo Bonzini 2818247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 2819db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 2820db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 2821d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 2822d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 2823d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2824d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 2825d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 2826d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2827d83414e1SMarc-André Lureau fi 2828247724cbSMarc-André Lureaufi 28290aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 28300aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 28310aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 28320aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 28330aebab04SLingfeng Yang else 28340aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 28350aebab04SLingfeng Yang fi 28360aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 28370aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 28380aebab04SLingfeng Yangfi 2839247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 2840db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 2841db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 2842247724cbSMarc-André Lureaufi 2843247724cbSMarc-André Lureau 28446542aa9cSPeter Lieven########################################## 28453efac6ebSTomáš Golembiovský 28460aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 28470aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 2848e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 2849db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 2850e86ecd4bSJuan Quintela fi 2851e86ecd4bSJuan Quintelafi 2852e86ecd4bSJuan Quintela 2853952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available 2854952afb71SBlue Swirlif test "$mingw32" = "yes" ; then 2855cb8baa77SMark Cave-Ayland flags="--no-seh --nxcompat" 2856cb8baa77SMark Cave-Ayland 2857cb8baa77SMark Cave-Ayland # Disable ASLR for debug builds to allow debugging with gdb 2858cb8baa77SMark Cave-Ayland if test "$debug" = "no" ; then 2859cb8baa77SMark Cave-Ayland flags="--dynamicbase $flags" 2860cb8baa77SMark Cave-Ayland fi 2861cb8baa77SMark Cave-Ayland 2862cb8baa77SMark Cave-Ayland for flag in $flags; do 2863e9a3591fSChristian Borntraeger if ld_has $flag ; then 2864db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS" 2865952afb71SBlue Swirl fi 2866952afb71SBlue Swirl done 2867952afb71SBlue Swirlfi 2868952afb71SBlue Swirl 28699d6bc27bSMichael Roth# Probe for guest agent support/options 28709d6bc27bSMichael Roth 2871e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then 2872a5125905SLaurent Vivier if [ "$softmmu" = no -a "$want_tools" = no ] ; then 2873a5125905SLaurent Vivier guest_agent=no 2874a5125905SLaurent Vivier elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then 2875e8ef31a3SMichael Tokarev guest_agent=yes 2876e8ef31a3SMichael Tokarev elif [ "$guest_agent" != yes ]; then 2877e8ef31a3SMichael Tokarev guest_agent=no 2878e8ef31a3SMichael Tokarev else 2879e8ef31a3SMichael Tokarev error_exit "Guest agent is not supported on this platform" 2880ca35f780SPaolo Bonzini fi 28814b1c11fdSDaniel P. Berrangefi 2882ca35f780SPaolo Bonzini 2883b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 28849d6bc27bSMichael Roth 28859d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 28869d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 28879d6bc27bSMichael Rothfi 28889d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 28899d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 28909d6bc27bSMichael Rothfi 28919d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 289289138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 28939d6bc27bSMichael Rothfi 28949d6bc27bSMichael Roth 2895b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 28969d6bc27bSMichael Roth 2897ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 2898ca35f780SPaolo Bonziniroms= 2899e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 2900ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 2901ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 2902e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 2903c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 2904c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 2905c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 2906e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 2907e57218b6SPeter Maydell ld_i386_emulation="$emu" 2908ca35f780SPaolo Bonzini roms="optionrom" 2909e57218b6SPeter Maydell break 2910e57218b6SPeter Maydell fi 2911e57218b6SPeter Maydell done 2912ca35f780SPaolo Bonzinifi 2913ca35f780SPaolo Bonzini 29142e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 2915a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 29169933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 29172e33c3f8SThomas Huth write_c_skeleton 2918a5b2afd5SThomas Huth compile_prog "-march=z900" "" 2919a5b2afd5SThomas Huth has_z900=$? 29203af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 2921a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 2922a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 2923a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 2924a5b2afd5SThomas Huth fi 29259933c305SChristian Borntraeger roms="$roms s390-ccw" 29261ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 29271ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 29281ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 29291ef6bfc2SPhilippe Mathieu-Daudé fi 29309933c305SChristian Borntraegerfi 29319933c305SChristian Borntraeger 293211cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 293311cde1c8SBruno 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. 293411cde1c8SBruno Dominguezif has $cxx; then 293511cde1c8SBruno Dominguez cat > $TMPC <<EOF 293611cde1c8SBruno Dominguezint c_function(void); 293711cde1c8SBruno Dominguezint main(void) { return c_function(); } 293811cde1c8SBruno DominguezEOF 293911cde1c8SBruno Dominguez 294011cde1c8SBruno Dominguez compile_object 294111cde1c8SBruno Dominguez 294211cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 294311cde1c8SBruno Dominguezextern "C" { 294411cde1c8SBruno Dominguez int c_function(void); 294511cde1c8SBruno Dominguez} 294611cde1c8SBruno Dominguezint c_function(void) { return 42; } 294711cde1c8SBruno DominguezEOF 294811cde1c8SBruno Dominguez 294911cde1c8SBruno Dominguez update_cxxflags 295011cde1c8SBruno Dominguez 2951a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 295211cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 295311cde1c8SBruno Dominguez : 295411cde1c8SBruno Dominguez else 295511cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 295611cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 295711cde1c8SBruno Dominguez cxx= 295811cde1c8SBruno Dominguez fi 295911cde1c8SBruno Dominguezelse 296011cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 296111cde1c8SBruno Dominguez cxx= 296211cde1c8SBruno Dominguezfi 296311cde1c8SBruno Dominguez 29647d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 29657d7dbf9dSDan Streetman exit 1 29665d91a2edSYonggang Luofi 29675d91a2edSYonggang Luo 296898ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 296997a847bcSbellard 297098ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 297198ec69acSJuan Quintelaecho >> $config_host_mak 297298ec69acSJuan Quintela 2973e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 2974cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 2975aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 29767d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 2977804edf29SJuan Quintela 2978f8393946Saurel32if test "$debug_tcg" = "yes" ; then 29792358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 2980f8393946Saurel32fi 298167b915a5Sbellardif test "$mingw32" = "yes" ; then 298298ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 2983d9840e25STomoki Sekiyama if test "$guest_agent_with_vss" = "yes" ; then 2984d9840e25STomoki Sekiyama echo "CONFIG_QGA_VSS=y" >> $config_host_mak 2985d9840e25STomoki Sekiyama echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak 2986d9840e25STomoki Sekiyama fi 298750cbebb9SMichael Roth if test "$guest_agent_ntddscsi" = "yes" ; then 298876dc75caSTomáš Golembiovský echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak 298950cbebb9SMichael Roth fi 29909dacf32dSYossi Hindin echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak 29919dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 29929dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 29939dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 2994210fa556Spbrookelse 299535f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 2996210fa556Spbrookfi 2997128ab2ffSblueswir1 2998dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 2999dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 3000dffcb71cSMark McLoughlinfi 3001dffcb71cSMark McLoughlin 300283fb7adfSbellardif test "$darwin" = "yes" ; then 300398ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 300483fb7adfSbellardfi 3005b29fe3edSmalc 3006ec530c81Sbellardif test "$solaris" = "yes" ; then 300798ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 3008ec530c81Sbellardfi 300997a847bcSbellardif test "$static" = "yes" ; then 301098ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 301197a847bcSbellardfi 3012c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then 3013c932ce31SPaolo Bonzini echo "CONFIG_TOOLS=y" >> $config_host_mak 3014c932ce31SPaolo Bonzinifi 3015f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then 3016f15bff25SPaolo Bonzini echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak 3017f15bff25SPaolo Bonzinifi 3018b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then 3019b8e0c493SJoelle van Dyne echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak 3020e2d8830eSBrad echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak 3021b8e0c493SJoelle van Dynefi 3022b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak 3023b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak 302489138857SStefan Weilqemu_version=$(head $source_path/VERSION) 30252358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak 302698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 30272b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 302817969268SFam Zhengif test "$modules" = "yes"; then 3029e26110cfSFam Zheng # $shacmd can generate a hash started with digit, which the compiler doesn't 3030e26110cfSFam Zheng # like as an symbol. So prefix it with an underscore 303189138857SStefan Weil echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak 303217969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 303317969268SFam Zhengfi 3034bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then 3035bd83c861SChristian Ehrhardt echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak 3036bd83c861SChristian Ehrhardtfi 3037955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then 3038955727d2SCortland Tölva echo "CONFIG_USBFS=y" >> $config_host_mak 3039955727d2SCortland Tölvafi 3040f876b765SMarc-André Lureauif test "$gio" = "yes" ; then 3041f876b765SMarc-André Lureau echo "CONFIG_GIO=y" >> $config_host_mak 3042f876b765SMarc-André Lureau echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak 3043f876b765SMarc-André Lureau echo "GIO_LIBS=$gio_libs" >> $config_host_mak 30445ecfb76cSPaolo Bonzinifi 30455ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then 304625a97a56SMarc-André Lureau echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak 3047f876b765SMarc-André Lureaufi 3048a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak 3049277abf15SJan Vesely 30501badb709SPaolo Bonziniif test "$xen" = "enabled" ; then 30516dbd588aSJan Kiszka echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak 3052d5b93ddfSAnthony PERARD echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak 3053582ea95fSMarc-André Lureau echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak 3054582ea95fSMarc-André Lureau echo "XEN_LIBS=$xen_libs" >> $config_host_mak 3055e37630caSaliguorifi 30565e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then 30575e9be92dSNicholas Bellinger echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 30585e9be92dSNicholas Bellingerfi 3059af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then 3060af3bba76SPaolo Bonzini echo "CONFIG_VHOST_NET=y" >> $config_host_mak 3061af3bba76SPaolo Bonzinifi 3062af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then 306356f41de7SPaolo Bonzini echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 306403ce5744SNikolay Nikolaevfi 3065108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then 3066108a6481SCindy Lu echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak 3067108a6481SCindy Lufi 3068042cea27SGongleiif test "$vhost_crypto" = "yes" ; then 3069042cea27SGonglei echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak 3070042cea27SGongleifi 3071fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then 3072fc0b9b0eSStefan Hajnoczi echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak 30735fe97d88SStefano Garzarella if test "$vhost_user" = "yes" ; then 30745fe97d88SStefano Garzarella echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak 30755fe97d88SStefano Garzarella fi 3076fc0b9b0eSStefan Hajnoczifi 3077299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then 3078299e6f19SPaolo Bonzini echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak 3079299e6f19SPaolo Bonzinifi 3080e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then 3081e6a74868SMarc-André Lureau echo "CONFIG_VHOST_USER=y" >> $config_host_mak 3082e6a74868SMarc-André Lureaufi 3083108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then 3084108a6481SCindy Lu echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak 3085108a6481SCindy Lufi 308698fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then 308798fc1adaSDr. David Alan Gilbert echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak 308898fc1adaSDr. David Alan Gilbertfi 3089e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then 3090e5b46549SRichard Henderson echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak 3091e5b46549SRichard Hendersonfi 309258d3f3ffSGerd Hoffmann 3093da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then 3094da076ffeSGerd Hoffmann echo "CONFIG_OPENGL=y" >> $config_host_mak 3095de2d3005SPaolo Bonzini echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak 3096da076ffeSGerd Hoffmann echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak 309720ff075bSMichael Wallefi 309820ff075bSMichael Walle 309983fb7adfSbellard# XXX: suppress that 31007d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 31012358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 31027d3505c5Sbellardfi 31037d3505c5Sbellard 31047c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 310570c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then 310670c60c08SStefan Hajnoczi echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak 310770c60c08SStefan Hajnoczielse 310870c60c08SStefan Hajnoczi echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak 310970c60c08SStefan Hajnoczifi 3110d0e2fce5SAneesh Kumar K.V 31117d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then 31127d992e4dSPeter Lieven echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak 31137d992e4dSPeter Lievenfi 31147d992e4dSPeter Lieven 3115d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 3116d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 3117d83414e1SMarc-André Lureaufi 3118d83414e1SMarc-André Lureau 31190aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 31200aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 31210aebab04SLingfeng Yangfi 31220aebab04SLingfeng Yang 3123f540166bSRichard Hendersonif test "$int128" = "yes" ; then 3124f540166bSRichard Henderson echo "CONFIG_INT128=y" >> $config_host_mak 3125f540166bSRichard Hendersonfi 3126f540166bSRichard Henderson 31277ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then 31287ebee43eSRichard Henderson echo "CONFIG_ATOMIC128=y" >> $config_host_mak 31297ebee43eSRichard Hendersonfi 31307ebee43eSRichard Henderson 3131e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then 3132e6cd4bb5SRichard Henderson echo "CONFIG_CMPXCHG128=y" >> $config_host_mak 3133e6cd4bb5SRichard Hendersonfi 3134e6cd4bb5SRichard Henderson 31352da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then 31362da776dbSMichael R. Hines echo "CONFIG_RDMA=y" >> $config_host_mak 3137392fb643SFam Zheng echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak 31382da776dbSMichael R. Hinesfi 31392da776dbSMichael R. Hines 314021ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then 314121ab34c9SMarcel Apfelbaum echo "CONFIG_PVRDMA=y" >> $config_host_mak 314221ab34c9SMarcel Apfelbaumfi 314321ab34c9SMarcel Apfelbaum 314440e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 314540e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 314640e8c6f4SAlex Bennéefi 314740e8c6f4SAlex Bennée 3148f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 3149b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 3150d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 3151f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 3152f48e590aSAlex Bennée fi 3153b1863cccSAlex Bennéefi 3154f48e590aSAlex Bennée 315554e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then 315654e7aac0SAlexey Krasikov echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak 315754e7aac0SAlexey Krasikovfi 315854e7aac0SAlexey Krasikov 315998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 3160804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 3161c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 316239d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 3163a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 316409e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 3165804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 3166433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak 3167a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then 3168859aef02SPaolo Bonzini echo "CONFIG_IASL=$iasl" >> $config_host_mak 3169a31a8642SMichael S. Tsirkinfi 3170804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 3171cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 31725f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 31733dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 3174804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 3175804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 317646eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak 3177a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 317811cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 3179a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 3180a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 3181d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 31828a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 3183e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 3184a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 3185804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 3186804edf29SJuan Quintela 31876efd7517SPeter Maydell# use included Linux headers 31886efd7517SPeter Maydellif test "$linux" = "yes" ; then 3189a307beb6SAndreas Färber mkdir -p linux-headers 31906efd7517SPeter Maydell case "$cpu" in 31914da270beSPaolo Bonzini i386|x86_64) 319208312a63SPeter Maydell linux_arch=x86 31936efd7517SPeter Maydell ;; 3194d8ff892dSPaolo Bonzini ppc|ppc64) 319508312a63SPeter Maydell linux_arch=powerpc 31966efd7517SPeter Maydell ;; 31976efd7517SPeter Maydell s390x) 319808312a63SPeter Maydell linux_arch=s390 319908312a63SPeter Maydell ;; 32001f080313SClaudio Fontana aarch64) 32011f080313SClaudio Fontana linux_arch=arm64 32021f080313SClaudio Fontana ;; 3203dfcf900bSWANG Xuerui loongarch*) 3204dfcf900bSWANG Xuerui linux_arch=loongarch 3205dfcf900bSWANG Xuerui ;; 3206222e7d11SSanjay Lal mips64) 3207222e7d11SSanjay Lal linux_arch=mips 3208222e7d11SSanjay Lal ;; 320908312a63SPeter Maydell *) 321008312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 321108312a63SPeter Maydell linux_arch="$cpu" 32126efd7517SPeter Maydell ;; 32136efd7517SPeter Maydell esac 321408312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 321508312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 321608312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 321708312a63SPeter Maydell fi 32186efd7517SPeter Maydellfi 32196efd7517SPeter Maydell 322097a847bcSbellardfor target in $target_list; do 322197a847bcSbellard target_dir="$target" 322257a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 322397a847bcSbellard mkdir -p $target_dir 3224fdb75aefSPaolo Bonzini case $target in 3225fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 3226fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 32272408a527Saurel32 esac 322856aebc89Spbrookdone 32297d13299dSbellard 3230765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak 3231fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 3232fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 3233fdb75aefSPaolo Bonzinifi 3234a540f158SPeter Crosthwaite 3235fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 3236fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 3237fd0e6053SJohn Snowfi 3238fd0e6053SJohn Snow 32391e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 32401e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 32411e4f6065SDaniele Buonofi 32421e4f6065SDaniele Buono 3243e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 3244e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 3245e29e5c6eSPeter Maydell# (these can be both files and directories). 3246e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 3247e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 3248e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 3249e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 3250e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 3251e29e5c6eSPeter Maydell# directory and symlink the directory instead. 32522038f8c8SPaolo BonziniLINKS="Makefile" 32533941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 3254ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 3255e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 32568db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile" 3257e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp" 3258e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 3259bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 326039950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 32618f8fd9edSCleber RosaLINKS="$LINKS python" 3262c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 3263753d11f2SRichard Hendersonfor bios_file in \ 3264753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 32653a631b8eSBin Meng $source_path/pc-bios/*.elf \ 3266225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 3267753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 3268753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 3269e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 3270753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 32714e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 3272cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 3273cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 3274cd946e5cSJohn Arbuckle 3275753d11f2SRichard Hendersondo 3276e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 32777ea78b74SJan Kiszkadone 3278e29e5c6eSPeter Maydellfor f in $LINKS ; do 32790f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 32805dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 3281f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 3282f9245e10SPeter Maydell fi 32837d13299dSbellarddone 32841ad2134fSPaul Brook 32852038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 32862038f8c8SPaolo Bonzini export $i 32872038f8c8SPaolo Bonzinidone 3288fd0f79d7SRichard Hendersonexport target_list source_path use_containers cpu 32892038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 32902038f8c8SPaolo Bonzini 3291c34ebfdcSAnthony Liguori# temporary config to build submodules 3292bb7cb3adSPaolo Bonziniif test -f $source_path/roms/seabios/Makefile; then 32938db2a4fdSGerd Hoffmann for rom in seabios; do 3294c34ebfdcSAnthony Liguori config_mak=roms/$rom/config.mak 329537116c89SStefan Weil echo "# Automatically generated by configure - do not modify" > $config_mak 3296c34ebfdcSAnthony Liguori echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak 3297cdbd727cSRichard Henderson echo "AS=$as" >> $config_mak 32985f6f0e27SRichard Henderson echo "CCAS=$ccas" >> $config_mak 3299c34ebfdcSAnthony Liguori echo "CC=$cc" >> $config_mak 3300c34ebfdcSAnthony Liguori echo "BCC=bcc" >> $config_mak 33013dd46c78SBlue Swirl echo "CPP=$cpp" >> $config_mak 3302c34ebfdcSAnthony Liguori echo "OBJCOPY=objcopy" >> $config_mak 3303a31a8642SMichael S. Tsirkin echo "IASL=$iasl" >> $config_mak 3304c34ebfdcSAnthony Liguori echo "LD=$ld" >> $config_mak 33059f81aeb5SAlistair Francis echo "RANLIB=$ranlib" >> $config_mak 3306c34ebfdcSAnthony Liguori done 3307bb7cb3adSPaolo Bonzinifi 3308c34ebfdcSAnthony Liguori 330998409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 331098409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 331198409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 331298409991SHelge Konetzka 3313a5665051SPaolo Bonziniif test "$skip_meson" = no; then 3314fc929892SMarc-André Lureau cross="config-meson.cross.new" 3315fc929892SMarc-André Lureau meson_quote() { 3316ac7ebcc5SPaolo Bonzini test $# = 0 && return 331747b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 3318fc929892SMarc-André Lureau } 3319fc929892SMarc-André Lureau 3320fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 3321fc929892SMarc-André Lureau echo "[properties]" >> $cross 3322d1d5e9eeSAlex Bennée 3323d1d5e9eeSAlex Bennée # unroll any custom device configs 3324d1d5e9eeSAlex Bennée for a in $device_archs; do 3325d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 3326d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 3327d1d5e9eeSAlex Bennée done 3328d1d5e9eeSAlex Bennée 3329fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 333047b30835SPaolo Bonzini echo "[built-in options]" >> $cross 3331a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 3332a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 3333a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 3334a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 3335fc929892SMarc-André Lureau echo "[binaries]" >> $cross 33364dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 33374dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 33384dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 333947b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 334047b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 334147b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 334247b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 3343e8178514SPaolo Bonzini if has $sdl2_config; then 334447b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 3345e8178514SPaolo Bonzini fi 334647b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 334747b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 33483812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 3349fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 3350fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 3351ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 3352823eb013SPaolo Bonzini case "$cpu" in 3353f6bca9dfSJoelle van Dyne i386) 3354fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 3355fc929892SMarc-André Lureau ;; 3356fc929892SMarc-André Lureau *) 3357823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 3358fc929892SMarc-André Lureau ;; 3359fc929892SMarc-André Lureau esac 3360fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 3361fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 3362fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 3363fc929892SMarc-André Lureau else 3364fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 3365fc929892SMarc-André Lureau fi 3366fc929892SMarc-André Lureau else 3367fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 3368fc929892SMarc-André Lureau fi 3369fc929892SMarc-André Lureau mv $cross config-meson.cross 3370fc929892SMarc-André Lureau 3371a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 337261d63097SPaolo Bonzini run_meson() { 337309e93326SPaolo Bonzini NINJA=$ninja $meson setup \ 3374d17f305aSPaolo Bonzini --prefix "$prefix" \ 3375d17f305aSPaolo Bonzini --libdir "$libdir" \ 3376d17f305aSPaolo Bonzini --libexecdir "$libexecdir" \ 3377d17f305aSPaolo Bonzini --bindir "$bindir" \ 3378d17f305aSPaolo Bonzini --includedir "$includedir" \ 3379d17f305aSPaolo Bonzini --datadir "$datadir" \ 3380d17f305aSPaolo Bonzini --mandir "$mandir" \ 3381d17f305aSPaolo Bonzini --sysconfdir "$sysconfdir" \ 338216bf7a33SPaolo Bonzini --localedir "$localedir" \ 3383d17f305aSPaolo Bonzini --localstatedir "$local_statedir" \ 33843b4da132SPaolo Bonzini -Daudio_drv_list=$audio_drv_list \ 33853b4da132SPaolo Bonzini -Ddefault_devices=$default_devices \ 3386d17f305aSPaolo Bonzini -Ddocdir="$docdir" \ 338716bf7a33SPaolo Bonzini -Dqemu_firmwarepath="$firmwarepath" \ 338873f3aa37SMarc-André Lureau -Dqemu_suffix="$qemu_suffix" \ 33893b4da132SPaolo Bonzini -Dsphinx_build="$sphinx_build" \ 33903b4da132SPaolo Bonzini -Dtrace_file="$trace_file" \ 3391a5665051SPaolo Bonzini -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ 3392a5665051SPaolo Bonzini -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ 3393a5665051SPaolo Bonzini -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ 3394da6d48b9SMarc-André Lureau -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ 3395bf0e56a3SMarc-André Lureau -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ 33963b4da132SPaolo Bonzini -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ 33973b4da132SPaolo Bonzini -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ 3398537b7248SPaolo Bonzini $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ 3399332008e0SThomas Huth $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ 340061d63097SPaolo Bonzini "$@" $cross_arg "$PWD" "$source_path" 340161d63097SPaolo Bonzini } 340261d63097SPaolo Bonzini eval run_meson $meson_options 3403a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 3404a5665051SPaolo Bonzini error_exit "meson setup failed" 3405a5665051SPaolo Bonzini fi 3406699d3884SPaolo Bonzinielse 3407699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 3408699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 3409699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 3410699d3884SPaolo Bonzini perl -i -ne ' 3411699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 3412699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 3413654d6b04SPaolo Bonzini /^b_staticpic/ && next; 3414699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 3415699d3884SPaolo Bonzini fi 3416a5665051SPaolo Bonzinifi 3417a5665051SPaolo Bonzini 3418dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 3419dc655404SMichael S. Tsirkincat <<EOD >config.status 3420dc655404SMichael S. Tsirkin#!/bin/sh 3421dc655404SMichael S. Tsirkin# Generated by configure. 3422dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 3423dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 3424dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 3425dc655404SMichael S. TsirkinEOD 3426e811da7fSDaniel P. Berrangé 3427e811da7fSDaniel P. Berrangépreserve_env() { 3428e811da7fSDaniel P. Berrangé envname=$1 3429e811da7fSDaniel P. Berrangé 3430e811da7fSDaniel P. Berrangé eval envval=\$$envname 3431e811da7fSDaniel P. Berrangé 3432e811da7fSDaniel P. Berrangé if test -n "$envval" 3433e811da7fSDaniel P. Berrangé then 3434e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 3435e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 3436e811da7fSDaniel P. Berrangé else 3437e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 3438e811da7fSDaniel P. Berrangé fi 3439e811da7fSDaniel P. Berrangé} 3440e811da7fSDaniel P. Berrangé 3441e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 3442e811da7fSDaniel P. Berrangé# features/build target configure will detect 3443e811da7fSDaniel P. Berrangépreserve_env AR 3444e811da7fSDaniel P. Berrangépreserve_env AS 3445e811da7fSDaniel P. Berrangépreserve_env CC 3446e811da7fSDaniel P. Berrangépreserve_env CPP 34478009da03SPaolo Bonzinipreserve_env CFLAGS 3448e811da7fSDaniel P. Berrangépreserve_env CXX 34498009da03SPaolo Bonzinipreserve_env CXXFLAGS 3450e811da7fSDaniel P. Berrangépreserve_env INSTALL 3451e811da7fSDaniel P. Berrangépreserve_env LD 34528009da03SPaolo Bonzinipreserve_env LDFLAGS 3453e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 3454e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 3455e811da7fSDaniel P. Berrangépreserve_env MAKE 3456e811da7fSDaniel P. Berrangépreserve_env NM 3457e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 3458e811da7fSDaniel P. Berrangépreserve_env PATH 3459e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 3460e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 3461e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 3462e811da7fSDaniel P. Berrangépreserve_env PYTHON 3463e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 3464e811da7fSDaniel P. Berrangépreserve_env SMBD 3465e811da7fSDaniel P. Berrangépreserve_env STRIP 3466e811da7fSDaniel P. Berrangépreserve_env WINDRES 3467e811da7fSDaniel P. Berrangé 3468dc655404SMichael S. Tsirkinprintf "exec" >>config.status 3469a5665051SPaolo Bonzinifor i in "$0" "$@"; do 3470835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 3471a5665051SPaolo Bonzinidone 3472cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 3473dc655404SMichael S. Tsirkinchmod +x config.status 3474dc655404SMichael S. Tsirkin 34758cd05ab6SPeter Maydellrm -r "$TMPDIR1" 3476