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="" 325a1c5e949SDaniel P. Berrangetls_priority="NORMAL" 326ba4dd2aaSAlex Bennéeplugins="$default_feature" 327c87ea116SAlex Bennéesecret_keyring="$default_feature" 328a5665051SPaolo Bonzinimeson="" 3293b4da132SPaolo Bonzinimeson_args="" 33048328880SPaolo Bonzinininja="" 3313b4da132SPaolo Bonzinigio="$default_feature" 332a5665051SPaolo Bonziniskip_meson=no 333377529c0SPaolo Bonzini 3343b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 3353b4da132SPaolo Bonzini# are included in the automatically generated help message) 3363b4da132SPaolo Bonzini 3373b4da132SPaolo Bonzini# 1. Track which submodules are needed 3383b4da132SPaolo Bonzinicapstone="auto" 3393b4da132SPaolo Bonzinifdt="auto" 3403b4da132SPaolo Bonzinislirp="auto" 3413b4da132SPaolo Bonzini 3423b4da132SPaolo Bonzini# 2. Support --with/--without option 3433b4da132SPaolo Bonzinidefault_devices="true" 3443b4da132SPaolo Bonzini 3453b4da132SPaolo Bonzini# 3. Automatically enable/disable other options 3463b4da132SPaolo Bonzinitcg="enabled" 3473b4da132SPaolo Bonzinicfi="false" 3483b4da132SPaolo Bonzini 3493b4da132SPaolo Bonzini# 4. Detection partly done in configure 3503b4da132SPaolo Bonzinixen=${default_feature:+disabled} 351898be3e0SPeter Maydell 352c87ea116SAlex Bennée# parse CC options second 353ac0df51dSaliguorifor opt do 35489138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 355ac0df51dSaliguori case "$opt" in 356ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3573812c0c4SJoelle van Dyne cross_compile="yes" 358ac0df51dSaliguori ;; 3593d8df640SPaolo Bonzini --cc=*) CC="$optarg" 360ac0df51dSaliguori ;; 36183f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 36283f73fceSTomoki Sekiyama ;; 3632ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3642ff6b91eSJuan Quintela ;; 365a2866660SPaolo Bonzini --extra-cflags=*) 366a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 367a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 368e2a2ed06SJuan Quintela ;; 369a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 37011cde1c8SBruno Dominguez ;; 371a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 372e2a2ed06SJuan Quintela ;; 3735bc62e01SGerd Hoffmann --enable-debug-info) debug_info="yes" 3745bc62e01SGerd Hoffmann ;; 3755bc62e01SGerd Hoffmann --disable-debug-info) debug_info="no" 3765bc62e01SGerd Hoffmann ;; 377d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 378d75402b5SAlex Bennée ;; 379479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 380d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 3812038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 382d422b2bcSAlex Bennée ;; 383d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 3842038f8c8SPaolo Bonzini cc_archs="$cc_archs $cc_arch" 385d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 3862038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 387d75402b5SAlex Bennée ;; 388ac0df51dSaliguori esac 389ac0df51dSaliguoridone 390ac0df51dSaliguori# OS specific 391ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 39293148aa5SStefan Weil# we can eliminate its usage altogether. 393ac0df51dSaliguori 394e49d021eSPeter Maydell# Preferred compiler: 395e49d021eSPeter Maydell# ${CC} (if set) 396e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 397e49d021eSPeter Maydell# system compiler 398e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 399e49d021eSPeter Maydell cc="$host_cc" 400e49d021eSPeter Maydellelse 401b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 402e49d021eSPeter Maydellfi 403e49d021eSPeter Maydell 40483f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 40583f73fceSTomoki Sekiyama cxx="c++" 40683f73fceSTomoki Sekiyamaelse 40783f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 40883f73fceSTomoki Sekiyamafi 40983f73fceSTomoki Sekiyama 410b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 411cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 4125f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 4133dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 414b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 415b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 4169f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 4174852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 418*35acbb30SPaolo Bonzinismbd="$SMBD" 419b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 420b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 42117884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 42217884d7bSSergei Trofimovichquery_pkg_config() { 42317884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 42417884d7bSSergei Trofimovich} 42517884d7bSSergei Trofimovichpkg_config=query_pkg_config 42647c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 427ac0df51dSaliguori 428be17dc90SMichael S. Tsirkin# default flags for all hosts 4292d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 4302d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 4312d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 4322d31515bSPeter Maydell# provides these semantics.) 433de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 434086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 435c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 436be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4375770e8afSPaolo Bonzini 438de38c0ccSPaolo BonziniQEMU_LDFLAGS= 439de38c0ccSPaolo Bonzini 4405770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4418a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4425770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 443086d5f75SPaolo Bonzini 444be17dc90SMichael S. Tsirkin 445ac0df51dSaliguoricheck_define() { 446ac0df51dSaliguoricat > $TMPC <<EOF 447ac0df51dSaliguori#if !defined($1) 448fd786e1aSPeter Maydell#error $1 not defined 449ac0df51dSaliguori#endif 450ac0df51dSaliguoriint main(void) { return 0; } 451ac0df51dSaliguoriEOF 45252166aa0SJuan Quintela compile_object 453ac0df51dSaliguori} 454ac0df51dSaliguori 455307119e7SGerd Hoffmanncheck_include() { 456307119e7SGerd Hoffmanncat > $TMPC <<EOF 457307119e7SGerd Hoffmann#include <$1> 458307119e7SGerd Hoffmannint main(void) { return 0; } 459307119e7SGerd HoffmannEOF 460307119e7SGerd Hoffmann compile_object 461307119e7SGerd Hoffmann} 462307119e7SGerd Hoffmann 46393b25869SJohn Snowwrite_c_skeleton() { 46493b25869SJohn Snow cat > $TMPC <<EOF 46593b25869SJohn Snowint main(void) { return 0; } 46693b25869SJohn SnowEOF 46793b25869SJohn Snow} 46893b25869SJohn Snow 469bbea4050SPeter Maydellif check_define __linux__ ; then 470ba7c60c2SPaolo Bonzini targetos=linux 471bbea4050SPeter Maydellelif check_define _WIN32 ; then 472ba7c60c2SPaolo Bonzini targetos=windows 473bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 474ba7c60c2SPaolo Bonzini targetos=openbsd 475bbea4050SPeter Maydellelif check_define __sun__ ; then 476ba7c60c2SPaolo Bonzini targetos=sunos 477bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 478ba7c60c2SPaolo Bonzini targetos=haiku 479951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 480ba7c60c2SPaolo Bonzini targetos=freebsd 481951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 482ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 483951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 484ba7c60c2SPaolo Bonzini targetos=dragonfly 485951fedfcSPeter Maydellelif check_define __NetBSD__; then 486ba7c60c2SPaolo Bonzini targetos=netbsd 487951fedfcSPeter Maydellelif check_define __APPLE__; then 488ba7c60c2SPaolo Bonzini targetos=darwin 489bbea4050SPeter Maydellelse 490951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 491951fedfcSPeter Maydell # might be going to just print the --help text, or it might 492951fedfcSPeter Maydell # be the result of a missing compiler. 493ba7c60c2SPaolo Bonzini targetos=bogus 494bbea4050SPeter Maydellfi 495bbea4050SPeter Maydell 49665eff01bSPaolo Bonzini# OS specific 49765eff01bSPaolo Bonzini 4983b0d8643SPaolo Bonzinimingw32="no" 4993b0d8643SPaolo Bonzinibsd="no" 5003b0d8643SPaolo Bonzinilinux="no" 5013b0d8643SPaolo Bonzinisolaris="no" 50265eff01bSPaolo Bonzinicase $targetos in 50365eff01bSPaolo Bonziniwindows) 50465eff01bSPaolo Bonzini mingw32="yes" 50565eff01bSPaolo Bonzini plugins="no" 50665eff01bSPaolo Bonzini pie="no" 50765eff01bSPaolo Bonzini;; 50865eff01bSPaolo Bonzinignu/kfreebsd) 50965eff01bSPaolo Bonzini bsd="yes" 51065eff01bSPaolo Bonzini;; 51165eff01bSPaolo Bonzinifreebsd) 51265eff01bSPaolo Bonzini bsd="yes" 51365eff01bSPaolo Bonzini make="${MAKE-gmake}" 51465eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 51565eff01bSPaolo Bonzini;; 51665eff01bSPaolo Bonzinidragonfly) 51765eff01bSPaolo Bonzini bsd="yes" 51865eff01bSPaolo Bonzini make="${MAKE-gmake}" 51965eff01bSPaolo Bonzini;; 52065eff01bSPaolo Bonzininetbsd) 52165eff01bSPaolo Bonzini bsd="yes" 52265eff01bSPaolo Bonzini make="${MAKE-gmake}" 52365eff01bSPaolo Bonzini;; 52465eff01bSPaolo Bonziniopenbsd) 52565eff01bSPaolo Bonzini bsd="yes" 52665eff01bSPaolo Bonzini make="${MAKE-gmake}" 52765eff01bSPaolo Bonzini;; 52865eff01bSPaolo Bonzinidarwin) 52965eff01bSPaolo Bonzini bsd="yes" 53065eff01bSPaolo Bonzini darwin="yes" 53165eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 53265eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 53365eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 53465eff01bSPaolo Bonzini;; 53565eff01bSPaolo Bonzinisunos) 53665eff01bSPaolo Bonzini solaris="yes" 53765eff01bSPaolo Bonzini make="${MAKE-gmake}" 53865eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 53965eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 54065eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 54165eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 54265eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 54365eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 544bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 545bbea4050SPeter Maydell # the correct CPU with the --cpu option. 546bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 547bbea4050SPeter Maydell cpu="x86_64" 548bbea4050SPeter Maydell fi 54965eff01bSPaolo Bonzini;; 55065eff01bSPaolo Bonzinihaiku) 55165eff01bSPaolo Bonzini pie="no" 55265eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 55365eff01bSPaolo Bonzini;; 55465eff01bSPaolo Bonzinilinux) 55565eff01bSPaolo Bonzini linux="yes" 55665eff01bSPaolo Bonzini vhost_user=${default_feature:-yes} 55765eff01bSPaolo Bonzini;; 558bbea4050SPeter Maydellesac 559bbea4050SPeter Maydell 5602ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5612ff6b91eSJuan Quintela # command line argument 5622ff6b91eSJuan Quintela : 5632ff6b91eSJuan Quintelaelif check_define __i386__ ; then 564ac0df51dSaliguori cpu="i386" 565ac0df51dSaliguorielif check_define __x86_64__ ; then 566c72b26ecSRichard Henderson if check_define __ILP32__ ; then 567c72b26ecSRichard Henderson cpu="x32" 568c72b26ecSRichard Henderson else 569ac0df51dSaliguori cpu="x86_64" 570c72b26ecSRichard Henderson fi 5713aa9bd6cSblueswir1elif check_define __sparc__ ; then 5723aa9bd6cSblueswir1 if check_define __arch64__ ; then 5733aa9bd6cSblueswir1 cpu="sparc64" 5743aa9bd6cSblueswir1 else 5753aa9bd6cSblueswir1 cpu="sparc" 5763aa9bd6cSblueswir1 fi 577fdf7ed96Smalcelif check_define _ARCH_PPC ; then 578fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 579f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 580f8378accSRichard Henderson cpu="ppc64le" 581f8378accSRichard Henderson else 582fdf7ed96Smalc cpu="ppc64" 583f8378accSRichard Henderson fi 584ac0df51dSaliguori else 585fdf7ed96Smalc cpu="ppc" 586fdf7ed96Smalc fi 587afa05235SAurelien Jarnoelif check_define __mips__ ; then 588afa05235SAurelien Jarno cpu="mips" 589d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 590d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 591d66ed0eaSAurelien Jarno cpu="s390x" 592d66ed0eaSAurelien Jarno else 593d66ed0eaSAurelien Jarno cpu="s390" 594d66ed0eaSAurelien Jarno fi 595c4f80543SAlistair Franciselif check_define __riscv ; then 596ba0e7333SRichard Henderson cpu="riscv" 59721d89f84SPeter Maydellelif check_define __arm__ ; then 59821d89f84SPeter Maydell cpu="arm" 5991f080313SClaudio Fontanaelif check_define __aarch64__ ; then 6001f080313SClaudio Fontana cpu="aarch64" 601dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 602dfcf900bSWANG Xuerui cpu="loongarch64" 603fdf7ed96Smalcelse 60489138857SStefan Weil cpu=$(uname -m) 605ac0df51dSaliguorifi 606ac0df51dSaliguori 607823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 608359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 6097d13299dSbellardcase "$cpu" in 610e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 611e4da0e39SPaolo Bonzini cpu="arm" ;; 612e4da0e39SPaolo Bonzini 6137d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 61497a847bcSbellard cpu="i386" 615e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 616e4da0e39SPaolo Bonzini x32) 6174da270beSPaolo Bonzini cpu="x86_64" 618e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 619aaa5fa14Saurel32 x86_64|amd64) 620aaa5fa14Saurel32 cpu="x86_64" 621e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 622e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 623e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 624e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 625e4da0e39SPaolo Bonzini 626afa05235SAurelien Jarno mips*) 627e4da0e39SPaolo Bonzini cpu="mips" ;; 628e4da0e39SPaolo Bonzini 629e4da0e39SPaolo Bonzini ppc) 630e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 631e4da0e39SPaolo Bonzini ppc64) 632d8ff892dSPaolo Bonzini CPU_CFLAGS="-m64 -mbig" ;; 633e4da0e39SPaolo Bonzini ppc64le) 634d8ff892dSPaolo Bonzini cpu="ppc64" 635d8ff892dSPaolo Bonzini CPU_CFLAGS="-m64 -mlittle" ;; 636e4da0e39SPaolo Bonzini 637e4da0e39SPaolo Bonzini s390) 638823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 639e4da0e39SPaolo Bonzini s390x) 640e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 641e4da0e39SPaolo Bonzini 6423142255cSblueswir1 sparc|sun4[cdmuv]) 643ae228531Sbellard cpu="sparc" 644e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 645e4da0e39SPaolo Bonzini sparc64) 646e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6477d13299dSbellardesac 648e2d52ad3SJuan Quintela 6490db4a067SPaolo Bonzini: ${make=${MAKE-make}} 650b6daf4d3SPaolo Bonzini 651faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 652faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 653ddf90699SEduardo Habkost# we check that too 654faf44142SDaniel P. Berrangépython= 6550a01d76fSMarc-André Lureauexplicit_python=no 656ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 657faf44142SDaniel P. Berrangédo 658faf44142SDaniel P. Berrangé if has "$binary" 659faf44142SDaniel P. Berrangé then 66095c5f2deSPaolo Bonzini python=$(command -v "$binary") 661faf44142SDaniel P. Berrangé break 662faf44142SDaniel P. Berrangé fi 663faf44142SDaniel P. Berrangédone 664903458c8SMarkus Armbruster 665903458c8SMarkus Armbruster 66639d87c8cSAlex Bennée# Check for ancillary tools used in testing 66739d87c8cSAlex Bennéegenisoimage= 6683df437c7SAlex Bennéefor binary in genisoimage mkisofs 66939d87c8cSAlex Bennéedo 67039d87c8cSAlex Bennée if has $binary 67139d87c8cSAlex Bennée then 67239d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 67339d87c8cSAlex Bennée break 67439d87c8cSAlex Bennée fi 67539d87c8cSAlex Bennéedone 67639d87c8cSAlex Bennée 6773c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6783c4a4d0dSPeter Maydellif has clang; then 6793c4a4d0dSPeter Maydell objcc=clang 6803c4a4d0dSPeter Maydellelse 6813c4a4d0dSPeter Maydell objcc="$cc" 6823c4a4d0dSPeter Maydellfi 6833c4a4d0dSPeter Maydell 6843457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6853457a3f8SJuan Quintela EXESUF=".exe" 68678e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6875770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 68893b25869SJohn Snow write_c_skeleton; 689d17f305aSPaolo Bonzini prefix="/qemu" 69077433a5fSMarc-André Lureau qemu_suffix="" 6913457a3f8SJuan Quintelafi 6923457a3f8SJuan Quintela 693487fefdbSAnthony Liguoriwerror="" 69485aa5189Sbellard 69561d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 69661d63097SPaolo Bonzini 69761d63097SPaolo Bonzinimeson_options= 69861d63097SPaolo Bonzinimeson_option_parse() { 69961d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 70061d63097SPaolo Bonzini if test $? -eq 1; then 70161d63097SPaolo Bonzini echo "ERROR: unknown option $1" 70261d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 70361d63097SPaolo Bonzini exit 1 70461d63097SPaolo Bonzini fi 70561d63097SPaolo Bonzini} 70661d63097SPaolo Bonzini 7077d13299dSbellardfor opt do 70889138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 7097d13299dSbellard case "$opt" in 7102efc3265Sbellard --help|-h) show_help=yes 7112efc3265Sbellard ;; 71299123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 71399123e13SMike Frysinger ;; 714b1a550a0Spbrook --prefix=*) prefix="$optarg" 7157d13299dSbellard ;; 716b1a550a0Spbrook --interp-prefix=*) interp_prefix="$optarg" 71732ce6337Sbellard ;; 718ac0df51dSaliguori --cross-prefix=*) 7197d13299dSbellard ;; 720ac0df51dSaliguori --cc=*) 7217d13299dSbellard ;; 722b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 72383469015Sbellard ;; 72483f73fceSTomoki Sekiyama --cxx=*) 72583f73fceSTomoki Sekiyama ;; 726e007dbecSMichael S. Tsirkin --iasl=*) iasl="$optarg" 727e007dbecSMichael S. Tsirkin ;; 7283c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 7293c4a4d0dSPeter Maydell ;; 730b1a550a0Spbrook --make=*) make="$optarg" 7317d13299dSbellard ;; 732b6daf4d3SPaolo Bonzini --install=*) 7336a882643Spbrook ;; 7340a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 735c886edfbSBlue Swirl ;; 7362eb054c2SPeter Maydell --sphinx-build=*) sphinx_build="$optarg" 7372eb054c2SPeter Maydell ;; 738a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 739a5665051SPaolo Bonzini ;; 740a5665051SPaolo Bonzini --meson=*) meson="$optarg" 741a5665051SPaolo Bonzini ;; 74248328880SPaolo Bonzini --ninja=*) ninja="$optarg" 74348328880SPaolo Bonzini ;; 744e2d8830eSBrad --smbd=*) smbd="$optarg" 745e2d8830eSBrad ;; 746e2a2ed06SJuan Quintela --extra-cflags=*) 7477d13299dSbellard ;; 74811cde1c8SBruno Dominguez --extra-cxxflags=*) 74911cde1c8SBruno Dominguez ;; 750e2a2ed06SJuan Quintela --extra-ldflags=*) 7517d13299dSbellard ;; 7525bc62e01SGerd Hoffmann --enable-debug-info) 7535bc62e01SGerd Hoffmann ;; 7545bc62e01SGerd Hoffmann --disable-debug-info) 7555bc62e01SGerd Hoffmann ;; 756d75402b5SAlex Bennée --cross-cc-*) 757d75402b5SAlex Bennée ;; 75817969268SFam Zheng --enable-modules) 75917969268SFam Zheng modules="yes" 76017969268SFam Zheng ;; 7613aa88b31SStefan Hajnoczi --disable-modules) 7623aa88b31SStefan Hajnoczi modules="no" 7633aa88b31SStefan Hajnoczi ;; 764bd83c861SChristian Ehrhardt --disable-module-upgrades) module_upgrades="no" 765bd83c861SChristian Ehrhardt ;; 766bd83c861SChristian Ehrhardt --enable-module-upgrades) module_upgrades="yes" 767bd83c861SChristian Ehrhardt ;; 7682ff6b91eSJuan Quintela --cpu=*) 7697d13299dSbellard ;; 770b1a550a0Spbrook --target-list=*) target_list="$optarg" 771447e133fSAlex Bennée if test "$target_list_exclude"; then 772447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 773447e133fSAlex Bennée fi 774447e133fSAlex Bennée ;; 775447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 776447e133fSAlex Bennée if test "$target_list"; then 777447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 778447e133fSAlex Bennée fi 779de83cd02Sbellard ;; 78074242e0fSPaolo Bonzini --with-trace-file=*) trace_file="$optarg" 7819410b56cSPrerna Saxena ;; 7827bc3ca7fSPaolo Bonzini --with-default-devices) default_devices="true" 783f3494749SPaolo Bonzini ;; 7847bc3ca7fSPaolo Bonzini --without-default-devices) default_devices="false" 785f3494749SPaolo Bonzini ;; 786d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 787d1d5e9eeSAlex Bennée ;; 788d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 789d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 790d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 791d1d5e9eeSAlex Bennée if test -f "$cf"; then 792d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 793d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 794d1d5e9eeSAlex Bennée else 795d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 796d1d5e9eeSAlex Bennée fi 797d1d5e9eeSAlex Bennée ;; 798c87ea116SAlex Bennée --without-default-features) # processed above 799c87ea116SAlex Bennée ;; 8001d728c39SBlue Swirl --enable-gcov) gcov="yes" 8011d728c39SBlue Swirl ;; 80279427693SLoïc Minier --static) 80379427693SLoïc Minier static="yes" 80417884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 80543ce4dfeSbellard ;; 8060b24e75fSPaolo Bonzini --mandir=*) mandir="$optarg" 8070b24e75fSPaolo Bonzini ;; 8080b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 8090b24e75fSPaolo Bonzini ;; 8103aa5d2beSAlon Levy --libdir=*) libdir="$optarg" 8113aa5d2beSAlon Levy ;; 8128bf188aaSMichael Tokarev --libexecdir=*) libexecdir="$optarg" 8138bf188aaSMichael Tokarev ;; 8140f94d6daSAlon Levy --includedir=*) includedir="$optarg" 8150f94d6daSAlon Levy ;; 816528ae5b8SEduardo Habkost --datadir=*) datadir="$optarg" 8170b24e75fSPaolo Bonzini ;; 81877433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 819023d3d67SEduardo Habkost ;; 820c6502638SBruce Rogers --docdir=*) docdir="$optarg" 8210b24e75fSPaolo Bonzini ;; 822fe0038beSPaolo Bonzini --localedir=*) localedir="$optarg" 823fe0038beSPaolo Bonzini ;; 824ca2fb938SAndre Przywara --sysconfdir=*) sysconfdir="$optarg" 82507381cc1SAnthony Liguori ;; 826785c23aeSLuiz Capitulino --localstatedir=*) local_statedir="$optarg" 827785c23aeSLuiz Capitulino ;; 8283d5eecabSGerd Hoffmann --firmwarepath=*) firmwarepath="$optarg" 8293d5eecabSGerd Hoffmann ;; 830181ce1d0SOlaf Hering --host=*|--build=*|\ 831181ce1d0SOlaf Hering --disable-dependency-tracking|\ 832785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 833fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 834023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 835023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 836023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 837023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 838023ddd74SMax Filippov # lots of directory switches by default. 839023ddd74SMax Filippov ;; 8400c58ac1cSmalc --audio-drv-list=*) audio_drv_list="$optarg" 8410c58ac1cSmalc ;; 84289138857SStefan Weil --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 843b64ec4e4SFam Zheng ;; 84489138857SStefan Weil --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 845eb852011SMarkus Armbruster ;; 846f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 847f8393946Saurel32 ;; 848f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 849f8393946Saurel32 ;; 850f3d08ee6SPaul Brook --enable-debug) 851f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 852f3d08ee6SPaul Brook debug_tcg="yes" 853c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 854f3d08ee6SPaul Brook debug="yes" 855b553a042SJohn Snow fortify_source="no" 856f3d08ee6SPaul Brook ;; 857247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 858247724cbSMarc-André Lureau ;; 859247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 860247724cbSMarc-André Lureau ;; 8610aebab04SLingfeng Yang --enable-tsan) tsan="yes" 8620aebab04SLingfeng Yang ;; 8630aebab04SLingfeng Yang --disable-tsan) tsan="no" 8640aebab04SLingfeng Yang ;; 8654d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 866c20709aaSbellard ;; 867fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 868fd6fc214SPaolo Bonzini ;; 8694d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 8707c57bdd8SMarc-André Lureau ;; 87103a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 872675b9b53SMarc-André Lureau ;; 8731badb709SPaolo Bonzini --disable-xen) xen="disabled" 874e37630caSaliguori ;; 8751badb709SPaolo Bonzini --enable-xen) xen="enabled" 876fc321b4bSJuan Quintela ;; 8771badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 878d1a14257SAlex Bennée plugins="no" 879b3f6ea7eSPaolo Bonzini ;; 8801badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 881b3f6ea7eSPaolo Bonzini ;; 882cad25d69Spbrook --disable-system) softmmu="no" 8830a8e90f4Spbrook ;; 884cad25d69Spbrook --enable-system) softmmu="yes" 8850a8e90f4Spbrook ;; 8860953a80fSZachary Amsden --disable-user) 8870953a80fSZachary Amsden linux_user="no" ; 8880953a80fSZachary Amsden bsd_user="no" ; 8890953a80fSZachary Amsden ;; 8900953a80fSZachary Amsden --enable-user) ;; 891831b7825Sths --disable-linux-user) linux_user="no" 8920a8e90f4Spbrook ;; 893831b7825Sths --enable-linux-user) linux_user="yes" 894831b7825Sths ;; 89584778508Sblueswir1 --disable-bsd-user) bsd_user="no" 89684778508Sblueswir1 ;; 89784778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 89884778508Sblueswir1 ;; 89940d6444eSAvi Kivity --enable-pie) pie="yes" 90034005a00SKirill A. Shutemov ;; 90140d6444eSAvi Kivity --disable-pie) pie="no" 90234005a00SKirill A. Shutemov ;; 90385aa5189Sbellard --enable-werror) werror="yes" 90485aa5189Sbellard ;; 90585aa5189Sbellard --disable-werror) werror="no" 90685aa5189Sbellard ;; 907cdad781dSDaniele Buono --enable-lto) lto="true" 908cdad781dSDaniele Buono ;; 909cdad781dSDaniele Buono --disable-lto) lto="false" 910cdad781dSDaniele Buono ;; 91163678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 91263678e17SSteven Noonan ;; 91363678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 91463678e17SSteven Noonan ;; 9151e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 9161e4f6065SDaniele Buono ;; 9171e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 9181e4f6065SDaniele Buono ;; 9199e62ba48SDaniele Buono --enable-cfi) 9209e62ba48SDaniele Buono cfi="true"; 9219e62ba48SDaniele Buono lto="true"; 9229e62ba48SDaniele Buono ;; 9239e62ba48SDaniele Buono --disable-cfi) cfi="false" 9249e62ba48SDaniele Buono ;; 925fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 9262df87df7SJuan Quintela ;; 927fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 928fbb4121dSPaolo Bonzini ;; 929fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 930fbb4121dSPaolo Bonzini ;; 93103a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 9322df87df7SJuan Quintela ;; 9337e563bfbSThomas Huth --with-pkgversion=*) pkgversion="$optarg" 9344a19f1ecSpbrook ;; 935519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 936519175a2SAlex Barcelo ;; 937d5970055SMichael S. Tsirkin --disable-vhost-net) vhost_net="no" 938d5970055SMichael S. Tsirkin ;; 939d5970055SMichael S. Tsirkin --enable-vhost-net) vhost_net="yes" 940d5970055SMichael S. Tsirkin ;; 941042cea27SGonglei --disable-vhost-crypto) vhost_crypto="no" 942042cea27SGonglei ;; 943299e6f19SPaolo Bonzini --enable-vhost-crypto) vhost_crypto="yes" 944042cea27SGonglei ;; 9455e9be92dSNicholas Bellinger --disable-vhost-scsi) vhost_scsi="no" 9465e9be92dSNicholas Bellinger ;; 9475e9be92dSNicholas Bellinger --enable-vhost-scsi) vhost_scsi="yes" 9485e9be92dSNicholas Bellinger ;; 949fc0b9b0eSStefan Hajnoczi --disable-vhost-vsock) vhost_vsock="no" 950fc0b9b0eSStefan Hajnoczi ;; 951fc0b9b0eSStefan Hajnoczi --enable-vhost-vsock) vhost_vsock="yes" 952fc0b9b0eSStefan Hajnoczi ;; 95398fc1adaSDr. David Alan Gilbert --disable-vhost-user-fs) vhost_user_fs="no" 95498fc1adaSDr. David Alan Gilbert ;; 95598fc1adaSDr. David Alan Gilbert --enable-vhost-user-fs) vhost_user_fs="yes" 95698fc1adaSDr. David Alan Gilbert ;; 957da076ffeSGerd Hoffmann --disable-opengl) opengl="no" 95820ff075bSMichael Walle ;; 959da076ffeSGerd Hoffmann --enable-opengl) opengl="yes" 96020ff075bSMichael Walle ;; 9611ffb3bbbSPaolo Bonzini --disable-zlib-test) 9621ece9905SAlon Levy ;; 963d138cee9SMichael Roth --enable-guest-agent) guest_agent="yes" 964d138cee9SMichael Roth ;; 965d138cee9SMichael Roth --disable-guest-agent) guest_agent="no" 966d138cee9SMichael Roth ;; 967d9840e25STomoki Sekiyama --with-vss-sdk) vss_win32_sdk="" 968d9840e25STomoki Sekiyama ;; 969d9840e25STomoki Sekiyama --with-vss-sdk=*) vss_win32_sdk="$optarg" 970d9840e25STomoki Sekiyama ;; 971d9840e25STomoki Sekiyama --without-vss-sdk) vss_win32_sdk="no" 972d9840e25STomoki Sekiyama ;; 973d9840e25STomoki Sekiyama --with-win-sdk) win_sdk="" 974d9840e25STomoki Sekiyama ;; 975d9840e25STomoki Sekiyama --with-win-sdk=*) win_sdk="$optarg" 976d9840e25STomoki Sekiyama ;; 977d9840e25STomoki Sekiyama --without-win-sdk) win_sdk="no" 978d9840e25STomoki Sekiyama ;; 9794b1c11fdSDaniel P. Berrange --enable-tools) want_tools="yes" 9804b1c11fdSDaniel P. Berrange ;; 9814b1c11fdSDaniel P. Berrange --disable-tools) want_tools="no" 9824b1c11fdSDaniel P. Berrange ;; 98352b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 98452b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 985583f6e7bSStefan Hajnoczi ;; 986cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 987cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 988cb6414dfSFam Zheng ;; 989315d3184SFam Zheng --enable-uuid|--disable-uuid) 990315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 991315d3184SFam Zheng ;; 992a1c5e949SDaniel P. Berrange --tls-priority=*) tls_priority="$optarg" 993a1c5e949SDaniel P. Berrange ;; 9942da776dbSMichael R. Hines --enable-rdma) rdma="yes" 9952da776dbSMichael R. Hines ;; 9962da776dbSMichael R. Hines --disable-rdma) rdma="no" 9972da776dbSMichael R. Hines ;; 99821ab34c9SMarcel Apfelbaum --enable-pvrdma) pvrdma="yes" 99921ab34c9SMarcel Apfelbaum ;; 100021ab34c9SMarcel Apfelbaum --disable-pvrdma) pvrdma="no" 100121ab34c9SMarcel Apfelbaum ;; 1002e6a74868SMarc-André Lureau --disable-vhost-user) vhost_user="no" 1003e6a74868SMarc-André Lureau ;; 1004299e6f19SPaolo Bonzini --enable-vhost-user) vhost_user="yes" 1005299e6f19SPaolo Bonzini ;; 1006108a6481SCindy Lu --disable-vhost-vdpa) vhost_vdpa="no" 1007108a6481SCindy Lu ;; 1008108a6481SCindy Lu --enable-vhost-vdpa) vhost_vdpa="yes" 1009108a6481SCindy Lu ;; 1010299e6f19SPaolo Bonzini --disable-vhost-kernel) vhost_kernel="no" 1011299e6f19SPaolo Bonzini ;; 1012299e6f19SPaolo Bonzini --enable-vhost-kernel) vhost_kernel="yes" 1013e6a74868SMarc-André Lureau ;; 10148b18cdbfSRichard Henderson --disable-capstone) capstone="disabled" 10158ca80760SRichard Henderson ;; 10168b18cdbfSRichard Henderson --enable-capstone) capstone="enabled" 10178ca80760SRichard Henderson ;; 10188b18cdbfSRichard Henderson --enable-capstone=git) capstone="internal" 1019e219c499SRichard Henderson ;; 102003a3c0b3SPaolo Bonzini --enable-capstone=*) capstone="$optarg" 1021e219c499SRichard Henderson ;; 1022cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 1023cc84d63aSDaniel P. Berrange ;; 10247d7dbf9dSDan Streetman --with-git-submodules=*) 10257d7dbf9dSDan Streetman git_submodules_action="$optarg" 1026f62bbee5SDaniel P. Berrange ;; 10279b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 10289b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 10299b8e4298SAlex Bennée else 10309b8e4298SAlex Bennée plugins="yes" 10319b8e4298SAlex Bennée fi 103240e8c6f4SAlex Bennée ;; 103340e8c6f4SAlex Bennée --disable-plugins) plugins="no" 103440e8c6f4SAlex Bennée ;; 1035afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 1036afc3a8f9SAlex Bennée ;; 1037afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 1038afc3a8f9SAlex Bennée ;; 1039f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 1040f48e590aSAlex Bennée ;; 104154e7aac0SAlexey Krasikov --enable-keyring) secret_keyring="yes" 104254e7aac0SAlexey Krasikov ;; 104354e7aac0SAlexey Krasikov --disable-keyring) secret_keyring="no" 104454e7aac0SAlexey Krasikov ;; 104520cf7b8eSDenis Plotnikov --enable-gio) gio=yes 104620cf7b8eSDenis Plotnikov ;; 104720cf7b8eSDenis Plotnikov --disable-gio) gio=no 104820cf7b8eSDenis Plotnikov ;; 10493b4da132SPaolo Bonzini # backwards compatibility options 10503b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 10513b4da132SPaolo Bonzini ;; 10523b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 10533b4da132SPaolo Bonzini ;; 10543b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 10553b4da132SPaolo Bonzini ;; 10563b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 10573b4da132SPaolo Bonzini ;; 10583b4da132SPaolo Bonzini # everything else has the same name in configure and meson 105961d63097SPaolo Bonzini --enable-* | --disable-*) meson_option_parse "$opt" "$optarg" 106061d63097SPaolo Bonzini ;; 10612d2ad6d0SFam Zheng *) 10622d2ad6d0SFam Zheng echo "ERROR: unknown option $opt" 10632d2ad6d0SFam Zheng echo "Try '$0 --help' for more information" 10642d2ad6d0SFam Zheng exit 1 10657f1559c6Sbalrog ;; 10667d13299dSbellard esac 10677d13299dSbellarddone 10687d13299dSbellard 1069d1a14257SAlex Bennée# test for any invalid configuration combinations 1070d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 1071d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 1072d1a14257SAlex Bennéefi 1073d1a14257SAlex Bennée 10747d7dbf9dSDan Streetmancase $git_submodules_action in 10757d7dbf9dSDan Streetman update|validate) 10767d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 10777d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 10787d7dbf9dSDan Streetman exit 1 10797d7dbf9dSDan Streetman fi 10807d7dbf9dSDan Streetman ;; 10817d7dbf9dSDan Streetman ignore) 1082b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 1083b80fd281SPaolo Bonzini then 1084b80fd281SPaolo Bonzini echo 1085b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 1086b80fd281SPaolo Bonzini echo 1087b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 1088b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 1089b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 1090b80fd281SPaolo Bonzini else 1091b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 1092b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 1093b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 1094b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 1095b80fd281SPaolo Bonzini echo 1096b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 1097b80fd281SPaolo Bonzini echo 1098b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 1099b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 1100b80fd281SPaolo Bonzini fi 1101b80fd281SPaolo Bonzini echo 1102b80fd281SPaolo Bonzini exit 1 1103b80fd281SPaolo Bonzini fi 11047d7dbf9dSDan Streetman ;; 11057d7dbf9dSDan Streetman *) 11067d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 11077d7dbf9dSDan Streetman exit 1 11087d7dbf9dSDan Streetman ;; 11097d7dbf9dSDan Streetmanesac 11107d7dbf9dSDan Streetman 111122a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}" 111222a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}" 111322a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}" 111422a87800SMarc-André Lureau 111522a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then 111615588a62SJoshua Watt bindir="${bindir:-$prefix}" 111722a87800SMarc-André Lureauelse 111815588a62SJoshua Watt bindir="${bindir:-$prefix/bin}" 111915588a62SJoshua Wattfi 112022a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}" 112122a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}" 1122ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}" 112322a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}" 112422a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}" 112516bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}" 112616bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}" 112722a87800SMarc-André Lureau 11289557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 1129b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 11302038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 11319557af9cSAlex Bennéefi 113279f3b12fSPeter Crosthwaite 113360e0df25SPeter Maydelldefault_target_list="" 11346e92f823SPeter Maydellmak_wilds="" 11356e92f823SPeter Maydell 1136b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 1137b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 1138b915a2f1SPaolo Bonzini linux_user=yes 1139b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 1140b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 1141b915a2f1SPaolo Bonzini fi 1142b915a2f1SPaolo Bonzinifi 1143b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 1144b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 1145b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 1146b915a2f1SPaolo Bonzini fi 1147b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 1148b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 1149b915a2f1SPaolo Bonzini fi 1150b915a2f1SPaolo Bonzinifi 115160e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 1152812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 115360e0df25SPeter Maydellfi 115460e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 1155812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 115660e0df25SPeter Maydellfi 115760e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 1158812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 115960e0df25SPeter Maydellfi 116060e0df25SPeter Maydell 1161447e133fSAlex Bennéefor config in $mak_wilds; do 1162447e133fSAlex Bennée target="$(basename "$config" .mak)" 116398db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 1164447e133fSAlex Bennée default_target_list="${default_target_list} $target" 1165447e133fSAlex Bennée fi 1166447e133fSAlex Bennéedone 11676e92f823SPeter Maydell 1168af5db58eSpbrookif test x"$show_help" = x"yes" ; then 1169af5db58eSpbrookcat << EOF 1170af5db58eSpbrook 1171af5db58eSpbrookUsage: configure [options] 1172af5db58eSpbrookOptions: [defaults in brackets after descriptions] 1173af5db58eSpbrook 117408fb77edSStefan WeilStandard options: 117508fb77edSStefan Weil --help print this message 117608fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 117708fb77edSStefan Weil --interp-prefix=PREFIX where to find shared libraries, etc. 117808fb77edSStefan Weil use %M for cpu name [$interp_prefix] 117974154d7eSThomas Huth --target-list=LIST set target list (default: build all) 118008fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 118108fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 1182447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 118308fb77edSStefan Weil 118408fb77edSStefan WeilAdvanced options (experts only): 11853812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 118608fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 118708fb77edSStefan Weil --iasl=IASL use ACPI compiler IASL [$iasl] 118808fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 118908fb77edSStefan Weil build time 119008fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 119108fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1192a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1193a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 119408fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1195d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1196479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 119708fb77edSStefan Weil --make=MAKE use specified make [$make] 119808fb77edSStefan Weil --python=PYTHON use specified python [$python] 11992eb054c2SPeter Maydell --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build] 1200a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 120148328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 120208fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1203db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 12047d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 12057d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 12067d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 120708fb77edSStefan Weil --static enable static build [$static] 120808fb77edSStefan Weil --mandir=PATH install man pages in PATH 120910ff82d1SMarc-André Lureau --datadir=PATH install firmware in PATH/$qemu_suffix 1210fe0038beSPaolo Bonzini --localedir=PATH install translation in PATH/$qemu_suffix 121110ff82d1SMarc-André Lureau --docdir=PATH install documentation in PATH/$qemu_suffix 121208fb77edSStefan Weil --bindir=PATH install binaries in PATH 121308fb77edSStefan Weil --libdir=PATH install libraries in PATH 1214db1b5f13SThomas Huth --libexecdir=PATH install helper binaries in PATH 121510ff82d1SMarc-André Lureau --sysconfdir=PATH install config in PATH/$qemu_suffix 121608fb77edSStefan Weil --localstatedir=PATH install local state in PATH (set at runtime on win32) 12173d5eecabSGerd Hoffmann --firmwarepath=PATH search PATH for firmware files 121813336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1219ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1220db1b5f13SThomas Huth --with-pkgversion=VERS use specified string as sub-version of the package 1221c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1222c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1223c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1224d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1225d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 122608fb77edSStefan Weil --enable-debug enable common debug build options 1227247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 12280aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 122908fb77edSStefan Weil --disable-werror disable compilation abort on warning 123063678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 123116bfbc70SPaolo Bonzini --audio-drv-list=LIST set audio drivers to try if -audiodev is not used 123208fb77edSStefan Weil --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L 123308fb77edSStefan Weil --block-drv-rw-whitelist=L 123408fb77edSStefan Weil set block driver read-write whitelist 1235e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 123608fb77edSStefan Weil --block-drv-ro-whitelist=L 123708fb77edSStefan Weil set block driver read-only whitelist 1238e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 123908fb77edSStefan Weil --with-trace-file=NAME Full PATH,NAME of file to store traces 124008fb77edSStefan Weil Default:trace-<pid> 1241c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 124208fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 124333c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 124408fb77edSStefan Weil --enable-gcov enable test coverage analysis with gcov 1245c23f23b9SMichael Tokarev --with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent 1246c23f23b9SMichael Tokarev --with-win-sdk=SDK-path path to Windows Platform SDK (to build VSS .tlb) 1247a1c5e949SDaniel P. Berrange --tls-priority default TLS protocol/cipher priority string 124840e8c6f4SAlex Bennée --enable-plugins 124940e8c6f4SAlex Bennée enable plugins via shared library loading 1250afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1251f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 125261d63097SPaolo BonziniEOF 125361d63097SPaolo Bonzini meson_options_help 125461d63097SPaolo Bonzinicat << EOF 1255c23f23b9SMichael Tokarev system all system emulation targets 1256c23f23b9SMichael Tokarev user supported user emulation targets 1257c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1258c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1259c23f23b9SMichael Tokarev guest-agent build the QEMU Guest Agent 1260c23f23b9SMichael Tokarev pie Position Independent Executables 126121e709aaSMarc-André Lureau modules modules support (non-Windows) 1262bd83c861SChristian Ehrhardt module-upgrades try to load modules from alternate paths for upgrades 1263c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1264c23f23b9SMichael Tokarev debug-info debugging information 1265cdad781dSDaniele Buono lto Enable Link-Time Optimization. 12661e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 12671e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 126821ab34c9SMarcel Apfelbaum rdma Enable RDMA-based migration 126921ab34c9SMarcel Apfelbaum pvrdma Enable PVRDMA support 1270299e6f19SPaolo Bonzini vhost-net vhost-net kernel acceleration support 1271299e6f19SPaolo Bonzini vhost-vsock virtio sockets device support 1272299e6f19SPaolo Bonzini vhost-scsi vhost-scsi kernel target support 1273299e6f19SPaolo Bonzini vhost-crypto vhost-user-crypto backend support 1274299e6f19SPaolo Bonzini vhost-kernel vhost kernel backend support 1275299e6f19SPaolo Bonzini vhost-user vhost-user backend support 1276108a6481SCindy Lu vhost-vdpa vhost-vdpa kernel backend support 1277c12d66aaSLin Ma opengl opengl support 12788de73fa8SCleber Rosa tools build qemu-io, qemu-nbd and qemu-img tools 127920cf7b8eSDenis Plotnikov gio libgio support 128008fb77edSStefan Weil 128108fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1282af5db58eSpbrookEOF 12832d2ad6d0SFam Zhengexit 0 1284af5db58eSpbrookfi 1285af5db58eSpbrook 12869c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1287bb768f71SThomas Huthrm -f */config-devices.mak.d 12889c790242SThomas Huth 1289faf44142SDaniel P. Berrangéif test -z "$python" 1290faf44142SDaniel P. Berrangéthen 1291c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1292c53eeaf7SStefan Hajnoczifi 12938e2c76bdSRoman Bolshakovif ! has "$make" 12948e2c76bdSRoman Bolshakovthen 12958e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 12968e2c76bdSRoman Bolshakovfi 1297c53eeaf7SStefan Hajnoczi 1298c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1299c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 13001b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 13011b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1302c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1303c53eeaf7SStefan Hajnoczifi 1304c53eeaf7SStefan Hajnoczi 1305755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1306406ab2f3SCleber 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) 1307755ee70fSCleber Rosa 1308c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1309c53eeaf7SStefan Hajnoczipython="$python -B" 1310c53eeaf7SStefan Hajnoczi 13110a01d76fSMarc-André Lureauif test -z "$meson"; then 13126638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 13130a01d76fSMarc-André Lureau meson=meson 13147d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 13150a01d76fSMarc-André Lureau meson=git 13160a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 13170a01d76fSMarc-André Lureau meson=internal 13180a01d76fSMarc-André Lureau else 13190a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 13200a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 13210a01d76fSMarc-André Lureau else 1322a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1323a5665051SPaolo Bonzini fi 13240a01d76fSMarc-André Lureau fi 13250a01d76fSMarc-André Lureauelse 13260a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 13270a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 13280a01d76fSMarc-André Lureau # 13290a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 13300a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 13310a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 13320a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 13330a01d76fSMarc-André Lureau case "$meson" in 13340a01d76fSMarc-André Lureau git | internal) ;; 13350a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 13360a01d76fSMarc-André Lureau esac 13370a01d76fSMarc-André Lureau fi 13380a01d76fSMarc-André Lureaufi 1339a5665051SPaolo Bonzini 13400a01d76fSMarc-André Lureauif test "$meson" = git; then 13410a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 13420a01d76fSMarc-André Lureaufi 13430a01d76fSMarc-André Lureau 13440a01d76fSMarc-André Lureaucase "$meson" in 13450a01d76fSMarc-André Lureau git | internal) 13460a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 13470a01d76fSMarc-André Lureau ;; 134884ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 13490a01d76fSMarc-André Lureauesac 13500a01d76fSMarc-André Lureau 135109e93326SPaolo Bonzini# Probe for ninja 135248328880SPaolo Bonzini 135348328880SPaolo Bonziniif test -z "$ninja"; then 135448328880SPaolo Bonzini for c in ninja ninja-build samu; do 135548328880SPaolo Bonzini if has $c; then 135648328880SPaolo Bonzini ninja=$(command -v "$c") 135748328880SPaolo Bonzini break 135848328880SPaolo Bonzini fi 135948328880SPaolo Bonzini done 136009e93326SPaolo Bonzini if test -z "$ninja"; then 136109e93326SPaolo Bonzini error_exit "Cannot find Ninja" 136209e93326SPaolo Bonzini fi 136348328880SPaolo Bonzinifi 1364a5665051SPaolo Bonzini 13659aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 13669aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 13679aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 13689aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 13699aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 13709aae6e54SDaniel Henrique Barbozaif compile_object ; then 13719aae6e54SDaniel Henrique Barboza : C compiler works ok 13729aae6e54SDaniel Henrique Barbozaelse 13739aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 13749aae6e54SDaniel Henrique Barbozafi 13759aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 13769aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 13779aae6e54SDaniel Henrique Barbozafi 13789aae6e54SDaniel Henrique Barboza 13799c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 13809c83ffd8SPeter Maydell# by default. Only enable by default for git builds 13819c83ffd8SPeter Maydellif test -z "$werror" ; then 13827d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1383e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 13849c83ffd8SPeter Maydell werror="yes" 13859c83ffd8SPeter Maydell else 13869c83ffd8SPeter Maydell werror="no" 13879c83ffd8SPeter Maydell fi 13889c83ffd8SPeter Maydellfi 13899c83ffd8SPeter Maydell 1390975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1391fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1392fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1393fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1394fb59dabdSPeter Maydell # host OS we should stop now. 1395951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1396fb59dabdSPeter Maydellfi 1397fb59dabdSPeter Maydell 1398efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1399efc6c070SThomas Huthcat > $TMPC << EOF 1400efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1401efc6c070SThomas Huth# ifdef __apple_build_version__ 14022a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 14032a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1404efc6c070SThomas Huth# endif 1405efc6c070SThomas Huth# else 14062a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 14072a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1408efc6c070SThomas Huth# endif 1409efc6c070SThomas Huth# endif 1410efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 14113830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 14123830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1413efc6c070SThomas Huth# endif 1414efc6c070SThomas Huth#else 1415efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1416efc6c070SThomas Huth#endif 1417efc6c070SThomas Huthint main (void) { return 0; } 1418efc6c070SThomas HuthEOF 1419efc6c070SThomas Huthif ! compile_prog "" "" ; then 14203830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1421efc6c070SThomas Huthfi 1422efc6c070SThomas Huth 142300849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 142400849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 142500849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 142600849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 142700849b92SRichard Henderson# just silently disable some features, so it's too error prone. 142800849b92SRichard Henderson 142900849b92SRichard Hendersonwarn_flags= 143000849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 143100849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 143200849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 143300849b92SRichard Hendersonadd_to warn_flags -Wformat-security 143400849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 143500849b92SRichard Hendersonadd_to warn_flags -Winit-self 143600849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 143700849b92SRichard Hendersonadd_to warn_flags -Wempty-body 143800849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 143900849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 144000849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 14410a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 144200849b92SRichard Henderson 144300849b92SRichard Hendersonnowarn_flags= 144400849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 144500849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 144600849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 144700849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 144800849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1449aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1450bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 145100849b92SRichard Henderson 145200849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 145393b25869SJohn Snow 145493b25869SJohn Snowcc_has_warning_flag() { 145593b25869SJohn Snow write_c_skeleton; 145693b25869SJohn Snow 1457a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1458a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1459a1d29d6cSPeter Maydell # warning options). 146093b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 146193b25869SJohn Snow compile_prog "-Werror $optflag" "" 146293b25869SJohn Snow} 146393b25869SJohn Snow 146493b25869SJohn Snowfor flag in $gcc_flags; do 146593b25869SJohn Snow if cc_has_warning_flag $flag ; then 14668d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 14678d05095cSPaolo Bonzini fi 14688d05095cSPaolo Bonzinidone 14698d05095cSPaolo Bonzini 147063678e17SSteven Noonanif test "$stack_protector" != "no"; then 1471fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1472fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1473fccd35a0SRodrigo Rebello{ 1474fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1475fccd35a0SRodrigo Rebello while (*c) { 1476fccd35a0SRodrigo Rebello *p++ = *c++; 1477fccd35a0SRodrigo Rebello } 1478fccd35a0SRodrigo Rebello return 0; 1479fccd35a0SRodrigo Rebello} 1480fccd35a0SRodrigo RebelloEOF 148163678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 14823b463a3fSMiroslav Rezanina sp_on=0 148363678e17SSteven Noonan for flag in $gcc_flags; do 1484590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1485590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1486086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1487590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 148863678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1489db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 14903b463a3fSMiroslav Rezanina sp_on=1 149163678e17SSteven Noonan break 149263678e17SSteven Noonan fi 149363678e17SSteven Noonan done 14943b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 14953b463a3fSMiroslav Rezanina if test $sp_on = 0; then 14963b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 14973b463a3fSMiroslav Rezanina fi 14983b463a3fSMiroslav Rezanina fi 149937746c5eSMarc-André Lureaufi 150037746c5eSMarc-André Lureau 150120bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 150220bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 150320bc94a2SPaolo Bonzinicat > $TMPC << EOF 150420bc94a2SPaolo Bonzinistruct { 150520bc94a2SPaolo Bonzini int a[2]; 150620bc94a2SPaolo Bonzini} x = {0}; 150720bc94a2SPaolo BonziniEOF 150820bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 150920bc94a2SPaolo Bonzini : 151020bc94a2SPaolo Bonzinielse 151120bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 151220bc94a2SPaolo Bonzinifi 151320bc94a2SPaolo Bonzini 151421e709aaSMarc-André Lureau# Our module code doesn't support Windows 151521e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 151621e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 151721e709aaSMarc-André Lureaufi 151821e709aaSMarc-André Lureau 1519bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled 1520bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then 1521bd83c861SChristian Ehrhardt error_exit "Can't enable module-upgrades as Modules are not enabled" 1522bd83c861SChristian Ehrhardtfi 1523bd83c861SChristian Ehrhardt 15245f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 152540d6444eSAvi Kivityif test "$static" = "yes" ; then 1526aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1527aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1528aa0d1f44SPaolo Bonzini fi 15295f2453acSAlex Bennée if test "$plugins" = "yes"; then 15305f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1531ba4dd2aaSAlex Bennée else 1532ba4dd2aaSAlex Bennée plugins="no" 15335f2453acSAlex Bennée fi 153440d6444eSAvi Kivityfi 153537650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 153640d6444eSAvi Kivity 153740d6444eSAvi Kivitycat > $TMPC << EOF 153821d4a791SAvi Kivity 153921d4a791SAvi Kivity#ifdef __linux__ 154021d4a791SAvi Kivity# define THREAD __thread 154121d4a791SAvi Kivity#else 154221d4a791SAvi Kivity# define THREAD 154321d4a791SAvi Kivity#endif 154421d4a791SAvi Kivitystatic THREAD int tls_var; 154521d4a791SAvi Kivityint main(void) { return tls_var; } 154640d6444eSAvi KivityEOF 1547b2634124SRichard Henderson 1548ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1549ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1550412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1551412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1552ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1553412aeacdSAlex Bennéefi 1554412aeacdSAlex Bennée 155512781462SRichard Hendersonif test "$static" = "yes"; then 1556eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 15575770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 155812781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 155912781462SRichard Henderson pie="yes" 156012781462SRichard Henderson elif test "$pie" = "yes"; then 156112781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 156212781462SRichard Henderson else 156312781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 156412781462SRichard Henderson pie="no" 156512781462SRichard Henderson fi 156612781462SRichard Hendersonelif test "$pie" = "no"; then 15675770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1568ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1569eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 15705770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 15715770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 157240d6444eSAvi Kivity pie="yes" 15732c674109SRichard Hendersonelif test "$pie" = "yes"; then 157476ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 157540d6444eSAvi Kivityelse 157640d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 157740d6444eSAvi Kivity pie="no" 157840d6444eSAvi Kivityfi 157940d6444eSAvi Kivity 1580e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1581e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1582e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1583e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1584e6cbd751SRichard Hendersonfi 1585e6cbd751SRichard Henderson 158609dada40SPaolo Bonzini########################################## 158709dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 158809dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 158909dada40SPaolo Bonzini# specification is necessary 159009dada40SPaolo Bonzini 159109dada40SPaolo Bonziniif test "$cpu" = "i386"; then 159209dada40SPaolo Bonzini cat > $TMPC << EOF 159309dada40SPaolo Bonzinistatic int sfaa(int *ptr) 159409dada40SPaolo Bonzini{ 159509dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 159609dada40SPaolo Bonzini} 159709dada40SPaolo Bonzini 159809dada40SPaolo Bonziniint main(void) 159909dada40SPaolo Bonzini{ 160009dada40SPaolo Bonzini int val = 42; 16011405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 160209dada40SPaolo Bonzini sfaa(&val); 160309dada40SPaolo Bonzini return val; 160409dada40SPaolo Bonzini} 160509dada40SPaolo BonziniEOF 160609dada40SPaolo Bonzini if ! compile_prog "" "" ; then 160709dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 160809dada40SPaolo Bonzini fi 160909dada40SPaolo Bonzinifi 161009dada40SPaolo Bonzini 161156267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 161256267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 161356267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 161456267b62SPhilippe Mathieu-Daudéfi 161556267b62SPhilippe Mathieu-Daudé 1616afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1617fdb75aefSPaolo Bonzini default_targets=yes 1618d880a3baSPaolo Bonzini for target in $default_target_list; do 1619d880a3baSPaolo Bonzini target_list="$target_list $target" 1620d880a3baSPaolo Bonzini done 1621d880a3baSPaolo Bonzini target_list="${target_list# }" 1622121afa9eSAnthony Liguorielse 1623fdb75aefSPaolo Bonzini default_targets=no 162489138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1625d880a3baSPaolo Bonzini for target in $target_list; do 162625b48338SPeter Maydell # Check that we recognised the target name; this allows a more 162725b48338SPeter Maydell # friendly error message than if we let it fall through. 162825b48338SPeter Maydell case " $default_target_list " in 162925b48338SPeter Maydell *" $target "*) 163025b48338SPeter Maydell ;; 163125b48338SPeter Maydell *) 163225b48338SPeter Maydell error_exit "Unknown target name '$target'" 163325b48338SPeter Maydell ;; 163425b48338SPeter Maydell esac 163525b48338SPeter Maydell done 1636d880a3baSPaolo Bonzinifi 163725b48338SPeter Maydell 1638f55fe278SPaolo Bonzini# see if system emulation was really requested 1639f55fe278SPaolo Bonzinicase " $target_list " in 1640f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1641f55fe278SPaolo Bonzini ;; 1642f55fe278SPaolo Bonzini *) softmmu=no 1643f55fe278SPaolo Bonzini ;; 1644f55fe278SPaolo Bonziniesac 16455327cf48Sbellard 1646249247c9SJuan Quintelafeature_not_found() { 1647249247c9SJuan Quintela feature=$1 164821684af0SStewart Smith remedy=$2 1649249247c9SJuan Quintela 165076ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 165121684af0SStewart Smith "configure was not able to find it." \ 165221684af0SStewart Smith "$remedy" 1653249247c9SJuan Quintela} 1654249247c9SJuan Quintela 16557d13299dSbellard# --- 16567d13299dSbellard# big/little endian test 16577d13299dSbellardcat > $TMPC << EOF 1658659eb157SThomas Huth#include <stdio.h> 165961cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 166061cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1661659eb157SThomas Huthint main(int argc, char *argv[]) 1662659eb157SThomas Huth{ 1663659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 16647d13299dSbellard} 16657d13299dSbellardEOF 16667d13299dSbellard 1667659eb157SThomas Huthif compile_prog ; then 1668659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 166961cc919fSMike Frysinger bigendian="yes" 1670659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 167161cc919fSMike Frysinger bigendian="no" 16727d13299dSbellard else 16737d13299dSbellard echo big/little test failed 1674659eb157SThomas Huth exit 1 16757d13299dSbellard fi 16767d13299dSbellardelse 167761cc919fSMike Frysinger echo big/little test failed 1678659eb157SThomas Huth exit 1 16797d13299dSbellardfi 16807d13299dSbellard 1681b0a47e79SJuan Quintela########################################## 1682e10ee3f5SPhilippe Mathieu-Daudé# system tools 1683e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then 1684e10ee3f5SPhilippe Mathieu-Daudé if test "$softmmu" = "no"; then 1685e10ee3f5SPhilippe Mathieu-Daudé want_tools=no 1686e10ee3f5SPhilippe Mathieu-Daudé else 1687e10ee3f5SPhilippe Mathieu-Daudé want_tools=yes 1688e10ee3f5SPhilippe Mathieu-Daudé fi 1689e10ee3f5SPhilippe Mathieu-Daudéfi 1690e10ee3f5SPhilippe Mathieu-Daudé 1691299e6f19SPaolo Bonzini######################################### 1692299e6f19SPaolo Bonzini# vhost interdependencies and host support 1693299e6f19SPaolo Bonzini 1694299e6f19SPaolo Bonzini# vhost backends 1695d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then 1696d88618f7SStefan Hajnoczi error_exit "vhost-user is only available on Linux" 1697299e6f19SPaolo Bonzinifi 1698108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux 1699108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then 1700108a6481SCindy Lu error_exit "vhost-vdpa is only available on Linux" 1701108a6481SCindy Lufi 1702299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux 1703299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then 1704299e6f19SPaolo Bonzini error_exit "vhost-kernel is only available on Linux" 1705299e6f19SPaolo Bonzinifi 1706299e6f19SPaolo Bonzini 1707299e6f19SPaolo Bonzini# vhost-kernel devices 1708299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel 1709299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then 1710299e6f19SPaolo Bonzini error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" 1711299e6f19SPaolo Bonzinifi 1712299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel 1713299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then 1714299e6f19SPaolo Bonzini error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" 1715299e6f19SPaolo Bonzinifi 1716299e6f19SPaolo Bonzini 1717299e6f19SPaolo Bonzini# vhost-user backends 1718299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user 1719299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then 1720299e6f19SPaolo Bonzini error_exit "--enable-vhost-net-user requires --enable-vhost-user" 1721299e6f19SPaolo Bonzinifi 1722299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user 1723299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then 1724299e6f19SPaolo Bonzini error_exit "--enable-vhost-crypto requires --enable-vhost-user" 1725299e6f19SPaolo Bonzinifi 172698fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user 172798fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then 172898fc1adaSDr. David Alan Gilbert error_exit "--enable-vhost-user-fs requires --enable-vhost-user" 172998fc1adaSDr. David Alan Gilbertfi 1730108a6481SCindy Lu#vhost-vdpa backends 1731108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa 1732108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then 1733108a6481SCindy Lu error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" 1734108a6481SCindy Lufi 1735299e6f19SPaolo Bonzini 173640bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity 1737299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then 1738299e6f19SPaolo Bonzini test "$vhost_net_user" = "yes" && vhost_net=yes 173940bc0ca9SLaurent Vivier test "$vhost_net_vdpa" = "yes" && vhost_net=yes 1740299e6f19SPaolo Bonzini test "$vhost_kernel" = "yes" && vhost_net=yes 1741299e6f19SPaolo Bonzinifi 1742299e6f19SPaolo Bonzini 1743015a33bdSGonglei########################################## 1744779ab5e3SStefan Weil# pkg-config probe 1745779ab5e3SStefan Weil 1746779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 174776ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1748779ab5e3SStefan Weilfi 1749779ab5e3SStefan Weil 1750779ab5e3SStefan Weil########################################## 1751e37630caSaliguori# xen probe 1752e37630caSaliguori 17531badb709SPaolo Bonziniif test "$xen" != "disabled" ; then 1754c1cdd9d5SJuergen Gross # Check whether Xen library path is specified via --extra-ldflags to avoid 1755c1cdd9d5SJuergen Gross # overriding this setting with pkg-config output. If not, try pkg-config 1756c1cdd9d5SJuergen Gross # to obtain all needed flags. 1757c1cdd9d5SJuergen Gross 1758c1cdd9d5SJuergen Gross if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ 1759c1cdd9d5SJuergen Gross $pkg_config --exists xencontrol ; then 1760c1cdd9d5SJuergen Gross xen_ctrl_version="$(printf '%d%02d%02d' \ 1761c1cdd9d5SJuergen Gross $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" 17621badb709SPaolo Bonzini xen=enabled 17635b6a8f43SMichael Tokarev xen_pc="xencontrol xenstore xenforeignmemory xengnttab" 1764c1cdd9d5SJuergen Gross xen_pc="$xen_pc xenevtchn xendevicemodel" 176558ea9a7aSAnthony PERARD if $pkg_config --exists xentoolcore; then 176658ea9a7aSAnthony PERARD xen_pc="$xen_pc xentoolcore" 176758ea9a7aSAnthony PERARD fi 1768582ea95fSMarc-André Lureau xen_cflags="$($pkg_config --cflags $xen_pc)" 1769582ea95fSMarc-André Lureau xen_libs="$($pkg_config --libs $xen_pc)" 1770c1cdd9d5SJuergen Gross else 1771c1cdd9d5SJuergen Gross 17725b6a8f43SMichael Tokarev xen_libs="-lxenstore -lxenctrl" 1773d9506cabSAnthony PERARD xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" 1774d5b93ddfSAnthony PERARD 177550ced5b3SStefan Weil # First we test whether Xen headers and libraries are available. 177650ced5b3SStefan Weil # If no, we are done and there is no Xen support. 177750ced5b3SStefan Weil # If yes, more tests are run to detect the Xen version. 177850ced5b3SStefan Weil 177950ced5b3SStefan Weil # Xen (any) 178050ced5b3SStefan Weil cat > $TMPC <<EOF 178150ced5b3SStefan Weil#include <xenctrl.h> 178250ced5b3SStefan Weilint main(void) { 178350ced5b3SStefan Weil return 0; 178450ced5b3SStefan Weil} 178550ced5b3SStefan WeilEOF 178650ced5b3SStefan Weil if ! compile_prog "" "$xen_libs" ; then 178750ced5b3SStefan Weil # Xen not found 17881badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 178921684af0SStewart Smith feature_not_found "xen" "Install xen devel" 179050ced5b3SStefan Weil fi 17911badb709SPaolo Bonzini xen=disabled 179250ced5b3SStefan Weil 1793d5b93ddfSAnthony PERARD # Xen unstable 179469deef08SPeter Maydell elif 179569deef08SPeter Maydell cat > $TMPC <<EOF && 17962cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API 17972cbf8903SRoss Lagerwall#define __XEN_TOOLS__ 17982cbf8903SRoss Lagerwall#include <xendevicemodel.h> 1799d3c49ebbSPaul Durrant#include <xenforeignmemory.h> 18002cbf8903SRoss Lagerwallint main(void) { 18012cbf8903SRoss Lagerwall xendevicemodel_handle *xd; 1802d3c49ebbSPaul Durrant xenforeignmemory_handle *xfmem; 18032cbf8903SRoss Lagerwall 18042cbf8903SRoss Lagerwall xd = xendevicemodel_open(0, 0); 18052cbf8903SRoss Lagerwall xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); 18062cbf8903SRoss Lagerwall 1807d3c49ebbSPaul Durrant xfmem = xenforeignmemory_open(0, 0); 1808d3c49ebbSPaul Durrant xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); 1809d3c49ebbSPaul Durrant 18102cbf8903SRoss Lagerwall return 0; 18112cbf8903SRoss Lagerwall} 18122cbf8903SRoss LagerwallEOF 18132cbf8903SRoss Lagerwall compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 18142cbf8903SRoss Lagerwall then 18152cbf8903SRoss Lagerwall xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 18162cbf8903SRoss Lagerwall xen_ctrl_version=41100 18171badb709SPaolo Bonzini xen=enabled 18182cbf8903SRoss Lagerwall elif 18192cbf8903SRoss Lagerwall cat > $TMPC <<EOF && 18205ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API 18215ba3d756SIgor Druzhinin#include <xenforeignmemory.h> 182258ea9a7aSAnthony PERARD#include <xentoolcore.h> 18235ba3d756SIgor Druzhininint main(void) { 18245ba3d756SIgor Druzhinin xenforeignmemory_handle *xfmem; 18255ba3d756SIgor Druzhinin 18265ba3d756SIgor Druzhinin xfmem = xenforeignmemory_open(0, 0); 18275ba3d756SIgor Druzhinin xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); 182858ea9a7aSAnthony PERARD xentoolcore_restrict_all(0); 18295ba3d756SIgor Druzhinin 18305ba3d756SIgor Druzhinin return 0; 18315ba3d756SIgor Druzhinin} 18325ba3d756SIgor DruzhininEOF 183358ea9a7aSAnthony PERARD compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 18345ba3d756SIgor Druzhinin then 183558ea9a7aSAnthony PERARD xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 18365ba3d756SIgor Druzhinin xen_ctrl_version=41000 18371badb709SPaolo Bonzini xen=enabled 18385ba3d756SIgor Druzhinin elif 18395ba3d756SIgor Druzhinin cat > $TMPC <<EOF && 1840da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API 1841da8090ccSPaul Durrant#define __XEN_TOOLS__ 1842da8090ccSPaul Durrant#include <xendevicemodel.h> 1843da8090ccSPaul Durrantint main(void) { 1844da8090ccSPaul Durrant xendevicemodel_handle *xd; 1845da8090ccSPaul Durrant 1846da8090ccSPaul Durrant xd = xendevicemodel_open(0, 0); 1847da8090ccSPaul Durrant xendevicemodel_close(xd); 1848da8090ccSPaul Durrant 1849da8090ccSPaul Durrant return 0; 1850da8090ccSPaul Durrant} 1851da8090ccSPaul DurrantEOF 1852da8090ccSPaul Durrant compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" 1853da8090ccSPaul Durrant then 1854da8090ccSPaul Durrant xen_stable_libs="-lxendevicemodel $xen_stable_libs" 1855f1167ee6SJuergen Gross xen_ctrl_version=40900 18561badb709SPaolo Bonzini xen=enabled 1857da8090ccSPaul Durrant elif 1858da8090ccSPaul Durrant cat > $TMPC <<EOF && 18595eeb39c2SIan Campbell/* 18605eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat 18615eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given. 1862b6eb9b45SPaulina Szubarczyk * 1863b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and 1864b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented. 1865b6eb9b45SPaulina Szubarczyk */ 1866b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API 1867b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API 1868b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API 1869b6eb9b45SPaulina Szubarczyk#include <xenctrl.h> 1870b6eb9b45SPaulina Szubarczyk#include <xenstore.h> 1871b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h> 1872b6eb9b45SPaulina Szubarczyk#include <xengnttab.h> 1873b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h> 1874b6eb9b45SPaulina Szubarczyk#include <stdint.h> 1875b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h> 1876b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS) 1877b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined 1878b6eb9b45SPaulina Szubarczyk#endif 1879b6eb9b45SPaulina Szubarczykint main(void) { 1880b6eb9b45SPaulina Szubarczyk xc_interface *xc = NULL; 1881b6eb9b45SPaulina Szubarczyk xenforeignmemory_handle *xfmem; 1882b6eb9b45SPaulina Szubarczyk xenevtchn_handle *xe; 1883b6eb9b45SPaulina Szubarczyk xengnttab_handle *xg; 1884b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy_segment_t* seg = NULL; 1885b6eb9b45SPaulina Szubarczyk 1886b6eb9b45SPaulina Szubarczyk xs_daemon_open(); 1887b6eb9b45SPaulina Szubarczyk 1888b6eb9b45SPaulina Szubarczyk xc = xc_interface_open(0, 0, 0); 1889b6eb9b45SPaulina Szubarczyk xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1890b6eb9b45SPaulina Szubarczyk xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 1891b6eb9b45SPaulina Szubarczyk xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 1892b6eb9b45SPaulina Szubarczyk xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 1893b6eb9b45SPaulina Szubarczyk 1894b6eb9b45SPaulina Szubarczyk xfmem = xenforeignmemory_open(0, 0); 1895b6eb9b45SPaulina Szubarczyk xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 1896b6eb9b45SPaulina Szubarczyk 1897b6eb9b45SPaulina Szubarczyk xe = xenevtchn_open(0, 0); 1898b6eb9b45SPaulina Szubarczyk xenevtchn_fd(xe); 1899b6eb9b45SPaulina Szubarczyk 1900b6eb9b45SPaulina Szubarczyk xg = xengnttab_open(0, 0); 1901b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy(xg, 0, seg); 1902b6eb9b45SPaulina Szubarczyk 1903b6eb9b45SPaulina Szubarczyk return 0; 1904b6eb9b45SPaulina Szubarczyk} 1905b6eb9b45SPaulina SzubarczykEOF 1906b6eb9b45SPaulina Szubarczyk compile_prog "" "$xen_libs $xen_stable_libs" 1907b6eb9b45SPaulina Szubarczyk then 1908f1167ee6SJuergen Gross xen_ctrl_version=40800 19091badb709SPaolo Bonzini xen=enabled 1910b6eb9b45SPaulina Szubarczyk elif 1911b6eb9b45SPaulina Szubarczyk cat > $TMPC <<EOF && 1912b6eb9b45SPaulina Szubarczyk/* 1913b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat 1914b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given. 19155eeb39c2SIan Campbell */ 19165eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API 19175eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API 19185eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API 19195eeb39c2SIan Campbell#include <xenctrl.h> 19205eeb39c2SIan Campbell#include <xenstore.h> 19215eeb39c2SIan Campbell#include <xenevtchn.h> 19225eeb39c2SIan Campbell#include <xengnttab.h> 19235eeb39c2SIan Campbell#include <xenforeignmemory.h> 19245eeb39c2SIan Campbell#include <stdint.h> 19255eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h> 19265eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS) 19275eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined 19285eeb39c2SIan Campbell#endif 19295eeb39c2SIan Campbellint main(void) { 19305eeb39c2SIan Campbell xc_interface *xc = NULL; 19315eeb39c2SIan Campbell xenforeignmemory_handle *xfmem; 19325eeb39c2SIan Campbell xenevtchn_handle *xe; 19335eeb39c2SIan Campbell xengnttab_handle *xg; 19345eeb39c2SIan Campbell 19355eeb39c2SIan Campbell xs_daemon_open(); 19365eeb39c2SIan Campbell 19375eeb39c2SIan Campbell xc = xc_interface_open(0, 0, 0); 19385eeb39c2SIan Campbell xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 19395eeb39c2SIan Campbell xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19405eeb39c2SIan Campbell xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 19415eeb39c2SIan Campbell xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 19425eeb39c2SIan Campbell 19435eeb39c2SIan Campbell xfmem = xenforeignmemory_open(0, 0); 19445eeb39c2SIan Campbell xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 19455eeb39c2SIan Campbell 19465eeb39c2SIan Campbell xe = xenevtchn_open(0, 0); 19475eeb39c2SIan Campbell xenevtchn_fd(xe); 19485eeb39c2SIan Campbell 19495eeb39c2SIan Campbell xg = xengnttab_open(0, 0); 19505eeb39c2SIan Campbell xengnttab_map_grant_ref(xg, 0, 0, 0); 19515eeb39c2SIan Campbell 19525eeb39c2SIan Campbell return 0; 19535eeb39c2SIan Campbell} 19545eeb39c2SIan CampbellEOF 19555eeb39c2SIan Campbell compile_prog "" "$xen_libs $xen_stable_libs" 19565eeb39c2SIan Campbell then 1957f1167ee6SJuergen Gross xen_ctrl_version=40701 19581badb709SPaolo Bonzini xen=enabled 1959cdadde39SRoger Pau Monne 1960cdadde39SRoger Pau Monne # Xen 4.6 1961cdadde39SRoger Pau Monne elif 1962cdadde39SRoger Pau Monne cat > $TMPC <<EOF && 1963cdadde39SRoger Pau Monne#include <xenctrl.h> 1964e108a3c1SAnthony PERARD#include <xenstore.h> 1965d5b93ddfSAnthony PERARD#include <stdint.h> 1966d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h> 1967d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS) 1968d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined 1969d5b93ddfSAnthony PERARD#endif 1970d5b93ddfSAnthony PERARDint main(void) { 1971d5b93ddfSAnthony PERARD xc_interface *xc; 1972d5b93ddfSAnthony PERARD xs_daemon_open(); 1973d5b93ddfSAnthony PERARD xc = xc_interface_open(0, 0, 0); 1974d5b93ddfSAnthony PERARD xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1975d5b93ddfSAnthony PERARD xc_gnttab_open(NULL, 0); 1976b87de24eSAnthony PERARD xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19778688e065SStefano Stabellini xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 1978d8b441a3SJan Beulich xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 197920a544c7SKonrad Rzeszutek Wilk xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); 1980d8b441a3SJan Beulich return 0; 1981d8b441a3SJan Beulich} 1982d8b441a3SJan BeulichEOF 1983d8b441a3SJan Beulich compile_prog "" "$xen_libs" 1984d8b441a3SJan Beulich then 1985f1167ee6SJuergen Gross xen_ctrl_version=40600 19861badb709SPaolo Bonzini xen=enabled 1987d8b441a3SJan Beulich 1988d8b441a3SJan Beulich # Xen 4.5 1989d8b441a3SJan Beulich elif 1990d8b441a3SJan Beulich cat > $TMPC <<EOF && 1991d8b441a3SJan Beulich#include <xenctrl.h> 1992d8b441a3SJan Beulich#include <xenstore.h> 1993d8b441a3SJan Beulich#include <stdint.h> 1994d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h> 1995d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS) 1996d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined 1997d8b441a3SJan Beulich#endif 1998d8b441a3SJan Beulichint main(void) { 1999d8b441a3SJan Beulich xc_interface *xc; 2000d8b441a3SJan Beulich xs_daemon_open(); 2001d8b441a3SJan Beulich xc = xc_interface_open(0, 0, 0); 2002d8b441a3SJan Beulich xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 2003d8b441a3SJan Beulich xc_gnttab_open(NULL, 0); 2004d8b441a3SJan Beulich xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 2005d8b441a3SJan Beulich xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 20063996e85cSPaul Durrant xc_hvm_create_ioreq_server(xc, 0, 0, NULL); 20073996e85cSPaul Durrant return 0; 20083996e85cSPaul Durrant} 20093996e85cSPaul DurrantEOF 20103996e85cSPaul Durrant compile_prog "" "$xen_libs" 20113996e85cSPaul Durrant then 2012f1167ee6SJuergen Gross xen_ctrl_version=40500 20131badb709SPaolo Bonzini xen=enabled 20143996e85cSPaul Durrant 20153996e85cSPaul Durrant elif 20163996e85cSPaul Durrant cat > $TMPC <<EOF && 20173996e85cSPaul Durrant#include <xenctrl.h> 20183996e85cSPaul Durrant#include <xenstore.h> 20193996e85cSPaul Durrant#include <stdint.h> 20203996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h> 20213996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS) 20223996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined 20233996e85cSPaul Durrant#endif 20243996e85cSPaul Durrantint main(void) { 20253996e85cSPaul Durrant xc_interface *xc; 20263996e85cSPaul Durrant xs_daemon_open(); 20273996e85cSPaul Durrant xc = xc_interface_open(0, 0, 0); 20283996e85cSPaul Durrant xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 20293996e85cSPaul Durrant xc_gnttab_open(NULL, 0); 20303996e85cSPaul Durrant xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 20313996e85cSPaul Durrant xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 20328688e065SStefano Stabellini return 0; 20338688e065SStefano Stabellini} 20348688e065SStefano StabelliniEOF 20358688e065SStefano Stabellini compile_prog "" "$xen_libs" 203669deef08SPeter Maydell then 2037f1167ee6SJuergen Gross xen_ctrl_version=40200 20381badb709SPaolo Bonzini xen=enabled 20398688e065SStefano Stabellini 2040e37630caSaliguori else 20411badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 2042edfb07edSIan Campbell feature_not_found "xen (unsupported version)" \ 2043edfb07edSIan Campbell "Install a supported xen (xen 4.2 or newer)" 2044fc321b4bSJuan Quintela fi 20451badb709SPaolo Bonzini xen=disabled 2046e37630caSaliguori fi 2047d5b93ddfSAnthony PERARD 20481badb709SPaolo Bonzini if test "$xen" = enabled; then 2049f1167ee6SJuergen Gross if test $xen_ctrl_version -ge 40701 ; then 2050582ea95fSMarc-André Lureau xen_libs="$xen_libs $xen_stable_libs " 20515eeb39c2SIan Campbell fi 2052d5b93ddfSAnthony PERARD fi 2053e37630caSaliguori fi 2054c1cdd9d5SJuergen Grossfi 2055e37630caSaliguori 2056d661d9a4SJustin Terry (VM)########################################## 20572da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries 20582da776dbSMichael R. Hinesif test "$rdma" != "no" ; then 20592da776dbSMichael R. Hines cat > $TMPC <<EOF 20602da776dbSMichael R. Hines#include <rdma/rdma_cma.h> 20612da776dbSMichael R. Hinesint main(void) { return 0; } 20622da776dbSMichael R. HinesEOF 2063ef6d4ccdSYuval Shaia rdma_libs="-lrdmacm -libverbs -libumad" 20642da776dbSMichael R. Hines if compile_prog "" "$rdma_libs" ; then 20652da776dbSMichael R. Hines rdma="yes" 20662da776dbSMichael R. Hines else 20672da776dbSMichael R. Hines if test "$rdma" = "yes" ; then 20682da776dbSMichael R. Hines error_exit \ 2069ef6d4ccdSYuval Shaia " OpenFabrics librdmacm/libibverbs/libibumad not present." \ 20702da776dbSMichael R. Hines " Your options:" \ 2071ef6d4ccdSYuval Shaia " (1) Fast: Install infiniband packages (devel) from your distro." \ 20722da776dbSMichael R. Hines " (2) Cleanest: Install libraries from www.openfabrics.org" \ 20732da776dbSMichael R. Hines " (3) Also: Install softiwarp if you don't have RDMA hardware" 20742da776dbSMichael R. Hines fi 20752da776dbSMichael R. Hines rdma="no" 20762da776dbSMichael R. Hines fi 20772da776dbSMichael R. Hinesfi 20782da776dbSMichael R. Hines 207921ab34c9SMarcel Apfelbaum########################################## 208021ab34c9SMarcel Apfelbaum# PVRDMA detection 208121ab34c9SMarcel Apfelbaum 208221ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF && 208321ab34c9SMarcel Apfelbaum#include <sys/mman.h> 208421ab34c9SMarcel Apfelbaum 208521ab34c9SMarcel Apfelbaumint 208621ab34c9SMarcel Apfelbaummain(void) 208721ab34c9SMarcel Apfelbaum{ 208821ab34c9SMarcel Apfelbaum char buf = 0; 208921ab34c9SMarcel Apfelbaum void *addr = &buf; 209021ab34c9SMarcel Apfelbaum addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED); 209121ab34c9SMarcel Apfelbaum 209221ab34c9SMarcel Apfelbaum return 0; 209321ab34c9SMarcel Apfelbaum} 209421ab34c9SMarcel ApfelbaumEOF 209521ab34c9SMarcel Apfelbaum 209621ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then 209721ab34c9SMarcel Apfelbaum case "$pvrdma" in 209821ab34c9SMarcel Apfelbaum "") 209921ab34c9SMarcel Apfelbaum if compile_prog "" ""; then 210021ab34c9SMarcel Apfelbaum pvrdma="yes" 210121ab34c9SMarcel Apfelbaum else 210221ab34c9SMarcel Apfelbaum pvrdma="no" 210321ab34c9SMarcel Apfelbaum fi 210421ab34c9SMarcel Apfelbaum ;; 210521ab34c9SMarcel Apfelbaum "yes") 210621ab34c9SMarcel Apfelbaum if ! compile_prog "" ""; then 210721ab34c9SMarcel Apfelbaum error_exit "PVRDMA is not supported since mremap is not implemented" 210821ab34c9SMarcel Apfelbaum fi 210921ab34c9SMarcel Apfelbaum pvrdma="yes" 211021ab34c9SMarcel Apfelbaum ;; 211121ab34c9SMarcel Apfelbaum "no") 211221ab34c9SMarcel Apfelbaum pvrdma="no" 211321ab34c9SMarcel Apfelbaum ;; 211421ab34c9SMarcel Apfelbaum esac 211521ab34c9SMarcel Apfelbaumelse 211621ab34c9SMarcel Apfelbaum if test "$pvrdma" = "yes" ; then 211721ab34c9SMarcel Apfelbaum error_exit "PVRDMA requires rdma suppport" 211821ab34c9SMarcel Apfelbaum fi 211921ab34c9SMarcel Apfelbaum pvrdma="no" 212021ab34c9SMarcel Apfelbaumfi 212195c6bff3SBenoît Canet 2122ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported 2123ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then 2124ee108585SYuval Shaia 2125ee108585SYuval Shaiacat > $TMPC <<EOF && 2126ee108585SYuval Shaia#include <infiniband/verbs.h> 2127ee108585SYuval Shaia 2128ee108585SYuval Shaiaint 2129ee108585SYuval Shaiamain(void) 2130ee108585SYuval Shaia{ 2131ee108585SYuval Shaia struct ibv_mr *mr; 2132ee108585SYuval Shaia struct ibv_pd *pd = NULL; 2133ee108585SYuval Shaia size_t length = 10; 2134ee108585SYuval Shaia uint64_t iova = 0; 2135ee108585SYuval Shaia int access = 0; 2136ee108585SYuval Shaia void *addr = NULL; 2137ee108585SYuval Shaia 2138ee108585SYuval Shaia mr = ibv_reg_mr_iova(pd, addr, length, iova, access); 2139ee108585SYuval Shaia 2140ee108585SYuval Shaia ibv_dereg_mr(mr); 2141ee108585SYuval Shaia 2142ee108585SYuval Shaia return 0; 2143ee108585SYuval Shaia} 2144ee108585SYuval ShaiaEOF 2145ee108585SYuval Shaia if ! compile_prog "" "-libverbs"; then 2146ee108585SYuval Shaia QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR" 2147ee108585SYuval Shaia fi 2148ee108585SYuval Shaiafi 2149ee108585SYuval Shaia 215095c6bff3SBenoît Canet########################################## 2151e18df141SAnthony Liguori# glib support probe 2152a52d28afSPaolo Bonzini 2153b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 2154aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 2155aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 2156a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 2157b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 2158b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 215954cb65d8SEmilio G. Cotafi 2160e26110cfSFam Zheng 2161aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 2162e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 216389138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 216489138857SStefan Weil glib_libs=$($pkg_config --libs $i) 2165e18df141SAnthony Liguori else 2166e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 2167e26110cfSFam Zheng fi 2168e26110cfSFam Zhengdone 2169e26110cfSFam Zheng 2170215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 2171215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 2172215b0c2fSPaolo Bonzini 2173215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 2174215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 2175215b0c2fSPaolo Bonzinifi 2176215b0c2fSPaolo Bonzini 217720cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then 217820cf7b8eSDenis Plotnikov pass=no 2179f876b765SMarc-André Lureau if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then 2180f876b765SMarc-André Lureau gio_cflags=$($pkg_config --cflags gio-2.0) 2181f876b765SMarc-André Lureau gio_libs=$($pkg_config --libs gio-2.0) 218225a97a56SMarc-André Lureau gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) 21835ecfb76cSPaolo Bonzini if ! has "$gdbus_codegen"; then 21840dba4897SMarc-André Lureau gdbus_codegen= 21850dba4897SMarc-André Lureau fi 218676346b62SPeter Maydell # Check that the libraries actually work -- Ubuntu 18.04 ships 218776346b62SPeter Maydell # with pkg-config --static --libs data for gio-2.0 that is missing 218876346b62SPeter Maydell # -lblkid and will give a link error. 218913ceae66SPeter Maydell cat > $TMPC <<EOF 219013ceae66SPeter Maydell#include <gio/gio.h> 219113ceae66SPeter Maydellint main(void) 219213ceae66SPeter Maydell{ 219313ceae66SPeter Maydell g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); 219413ceae66SPeter Maydell return 0; 219513ceae66SPeter Maydell} 219613ceae66SPeter MaydellEOF 219713ceae66SPeter Maydell if compile_prog "$gio_cflags" "$gio_libs" ; then 219820cf7b8eSDenis Plotnikov pass=yes 219976346b62SPeter Maydell else 220020cf7b8eSDenis Plotnikov pass=no 2201f876b765SMarc-André Lureau fi 2202f876b765SMarc-André Lureau 220320cf7b8eSDenis Plotnikov if test "$pass" = "yes" && 220420cf7b8eSDenis Plotnikov $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then 220525a97a56SMarc-André Lureau gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)" 220625a97a56SMarc-André Lureau gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)" 220725a97a56SMarc-André Lureau fi 220820cf7b8eSDenis Plotnikov fi 220920cf7b8eSDenis Plotnikov 221020cf7b8eSDenis Plotnikov if test "$pass" = "no"; then 221120cf7b8eSDenis Plotnikov if test "$gio" = "yes"; then 221220cf7b8eSDenis Plotnikov feature_not_found "gio" "Install libgio >= 2.0" 221320cf7b8eSDenis Plotnikov else 221420cf7b8eSDenis Plotnikov gio=no 221520cf7b8eSDenis Plotnikov fi 221620cf7b8eSDenis Plotnikov else 221720cf7b8eSDenis Plotnikov gio=yes 221820cf7b8eSDenis Plotnikov fi 221920cf7b8eSDenis Plotnikovfi 222025a97a56SMarc-André Lureau 2221977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 2222977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 2223977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 2224977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 2225977a82abSDaniel P. Berrangecat > $TMPC <<EOF 2226977a82abSDaniel P. Berrange#include <glib.h> 2227977a82abSDaniel P. Berrange#include <unistd.h> 2228977a82abSDaniel P. Berrange 2229977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 2230977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 2231977a82abSDaniel P. Berrange 2232977a82abSDaniel P. Berrangeint main(void) { 2233977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 2234977a82abSDaniel P. Berrange return 0; 2235977a82abSDaniel P. Berrange} 2236977a82abSDaniel P. BerrangeEOF 2237977a82abSDaniel P. Berrange 2238215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 2239977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 2240977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 2241977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 2242977a82abSDaniel P. Berrange "build target" 2243977a82abSDaniel P. Berrangefi 2244977a82abSDaniel P. Berrange 22459bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 22469bda600bSEric Blakecat > $TMPC << EOF 22479bda600bSEric Blake#include <glib.h> 22489bda600bSEric Blaketypedef struct Foo { 22499bda600bSEric Blake int i; 22509bda600bSEric Blake} Foo; 22519bda600bSEric Blakestatic void foo_free(Foo *f) 22529bda600bSEric Blake{ 22539bda600bSEric Blake g_free(f); 22549bda600bSEric Blake} 22559bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free); 22569bda600bSEric Blakeint main(void) { return 0; } 22579bda600bSEric BlakeEOF 22589bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 22599bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 22609bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 22615770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 22629bda600bSEric Blake fi 22639bda600bSEric Blakefi 22649bda600bSEric Blake 2265e26110cfSFam Zheng########################################## 2266e26110cfSFam Zheng# SHA command probe for modules 2267e26110cfSFam Zhengif test "$modules" = yes; then 2268e26110cfSFam Zheng shacmd_probe="sha1sum sha1 shasum" 2269e26110cfSFam Zheng for c in $shacmd_probe; do 22708ccefb91SFam Zheng if has $c; then 2271e26110cfSFam Zheng shacmd="$c" 2272e26110cfSFam Zheng break 2273e26110cfSFam Zheng fi 2274e26110cfSFam Zheng done 2275e26110cfSFam Zheng if test "$shacmd" = ""; then 2276e26110cfSFam Zheng error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" 2277e26110cfSFam Zheng fi 2278e18df141SAnthony Liguorifi 2279e18df141SAnthony Liguori 2280e18df141SAnthony Liguori########################################## 2281f652e6afSaurel32# fdt probe 2282e169e1e1SPeter Maydell 2283fbb4121dSPaolo Bonzinicase "$fdt" in 2284fbb4121dSPaolo Bonzini auto | enabled | internal) 2285fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 2286aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 2287fbb4121dSPaolo Bonzini ;; 2288fbb4121dSPaolo Bonziniesac 2289f652e6afSaurel32 229020ff075bSMichael Walle########################################## 22919d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk) 2292b1546f32SGerd Hoffmann 2293da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then 2294bc6a3565SAkihiko Odaki epoxy=no 2295bc6a3565SAkihiko Odaki if $pkg_config epoxy; then 2296bc6a3565SAkihiko Odaki cat > $TMPC << EOF 2297bc6a3565SAkihiko Odaki#include <epoxy/egl.h> 2298bc6a3565SAkihiko Odakiint main(void) { return 0; } 2299bc6a3565SAkihiko OdakiEOF 2300bc6a3565SAkihiko Odaki if compile_prog "" "" ; then 2301bc6a3565SAkihiko Odaki epoxy=yes 2302bc6a3565SAkihiko Odaki fi 2303bc6a3565SAkihiko Odaki fi 2304bc6a3565SAkihiko Odaki 2305bc6a3565SAkihiko Odaki if test "$epoxy" = "yes" ; then 2306bc6a3565SAkihiko Odaki opengl_cflags="$($pkg_config --cflags epoxy)" 2307bc6a3565SAkihiko Odaki opengl_libs="$($pkg_config --libs epoxy)" 2308da076ffeSGerd Hoffmann opengl=yes 230920ff075bSMichael Walle else 2310da076ffeSGerd Hoffmann if test "$opengl" = "yes" ; then 2311bc6a3565SAkihiko Odaki feature_not_found "opengl" "Please install epoxy with EGL" 231220ff075bSMichael Walle fi 2313f676c67eSJeremy White opengl_cflags="" 2314da076ffeSGerd Hoffmann opengl_libs="" 2315da076ffeSGerd Hoffmann opengl=no 231620ff075bSMichael Walle fi 231720ff075bSMichael Wallefi 231820ff075bSMichael Walle 2319955727d2SCortland Tölva# check for usbfs 2320955727d2SCortland Tölvahave_usbfs=no 2321955727d2SCortland Tölvaif test "$linux_user" = "yes"; then 232296566d09SThomas Petazzoni cat > $TMPC << EOF 232396566d09SThomas Petazzoni#include <linux/usbdevice_fs.h> 232496566d09SThomas Petazzoni 232596566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES 232696566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined" 232796566d09SThomas Petazzoni#endif 232896566d09SThomas Petazzoni 232996566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM 233096566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined" 233196566d09SThomas Petazzoni#endif 233296566d09SThomas Petazzoni 233396566d09SThomas Petazzoniint main(void) 233496566d09SThomas Petazzoni{ 233596566d09SThomas Petazzoni return 0; 233696566d09SThomas Petazzoni} 233796566d09SThomas PetazzoniEOF 233896566d09SThomas Petazzoni if compile_prog "" ""; then 2339955727d2SCortland Tölva have_usbfs=yes 2340955727d2SCortland Tölva fi 2341955727d2SCortland Tölvafi 2342751bcc39SMarc-André Lureau 2343de5071c5SBlue Swirl########################################## 2344d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win 2345d9840e25STomoki Sekiyama 23463b0d8643SPaolo Bonziniguest_agent_with_vss="no" 2347e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \ 2348e633a5c6SEric Blake test "$vss_win32_sdk" != "no" ; then 2349d9840e25STomoki Sekiyama case "$vss_win32_sdk" in 2350690604f6SMichael Roth "") vss_win32_include="-isystem $source_path" ;; 2351d9840e25STomoki Sekiyama *\ *) # The SDK is installed in "Program Files" by default, but we cannot 2352d9840e25STomoki Sekiyama # handle path with spaces. So we symlink the headers into ".sdk/vss". 2353690604f6SMichael Roth vss_win32_include="-isystem $source_path/.sdk/vss" 2354d9840e25STomoki Sekiyama symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc" 2355d9840e25STomoki Sekiyama ;; 2356690604f6SMichael Roth *) vss_win32_include="-isystem $vss_win32_sdk" 2357d9840e25STomoki Sekiyama esac 2358d9840e25STomoki Sekiyama cat > $TMPC << EOF 2359d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__ 2360d9840e25STomoki Sekiyama#include <inc/win2003/vss.h> 2361d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; } 2362d9840e25STomoki SekiyamaEOF 2363d9840e25STomoki Sekiyama if compile_prog "$vss_win32_include" "" ; then 2364d9840e25STomoki Sekiyama guest_agent_with_vss="yes" 2365d9840e25STomoki Sekiyama QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include" 2366d9840e25STomoki Sekiyama else 2367d9840e25STomoki Sekiyama if test "$vss_win32_sdk" != "" ; then 2368d9840e25STomoki Sekiyama echo "ERROR: Please download and install Microsoft VSS SDK:" 2369d9840e25STomoki Sekiyama echo "ERROR: http://www.microsoft.com/en-us/download/details.aspx?id=23490" 2370d9840e25STomoki Sekiyama echo "ERROR: On POSIX-systems, you can extract the SDK headers by:" 2371d9840e25STomoki Sekiyama echo "ERROR: scripts/extract-vsssdk-headers setup.exe" 2372d9840e25STomoki Sekiyama echo "ERROR: The headers are extracted in the directory \`inc'." 2373d9840e25STomoki Sekiyama feature_not_found "VSS support" 2374d9840e25STomoki Sekiyama fi 2375d9840e25STomoki Sekiyama fi 2376d9840e25STomoki Sekiyamafi 2377d9840e25STomoki Sekiyama 2378d9840e25STomoki Sekiyama########################################## 2379d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified) 2380d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent 2381d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the 2382d9840e25STomoki Sekiyama# pre-compiled .tlb file is included. 2383d9840e25STomoki Sekiyama 2384e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \ 2385e633a5c6SEric Blake test "$guest_agent_with_vss" = "yes" ; then 2386d9840e25STomoki Sekiyama if test -z "$win_sdk"; then 2387d9840e25STomoki Sekiyama programfiles="$PROGRAMFILES" 2388d9840e25STomoki Sekiyama test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432" 2389d9840e25STomoki Sekiyama if test -n "$programfiles"; then 2390d9840e25STomoki Sekiyama win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null 2391d9840e25STomoki Sekiyama else 2392d9840e25STomoki Sekiyama feature_not_found "Windows SDK" 2393d9840e25STomoki Sekiyama fi 2394d9840e25STomoki Sekiyama elif test "$win_sdk" = "no"; then 2395d9840e25STomoki Sekiyama win_sdk="" 2396d9840e25STomoki Sekiyama fi 2397d9840e25STomoki Sekiyamafi 2398d9840e25STomoki Sekiyama 2399d9840e25STomoki Sekiyama########################################## 240050cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h 24013b0d8643SPaolo Bonziniguest_agent_ntddscsi="no" 2402e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then 240350cbebb9SMichael Roth cat > $TMPC << EOF 240450cbebb9SMichael Roth#include <windows.h> 240550cbebb9SMichael Roth#include <ntddscsi.h> 240650cbebb9SMichael Rothint main(void) { 240750cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS) 240850cbebb9SMichael Roth#error Missing required ioctl definitions 240950cbebb9SMichael Roth#endif 241050cbebb9SMichael Roth SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 }; 241150cbebb9SMichael Roth return addr.Lun; 241250cbebb9SMichael Roth} 241350cbebb9SMichael RothEOF 241450cbebb9SMichael Roth if compile_prog "" "" ; then 241550cbebb9SMichael Roth guest_agent_ntddscsi=yes 241650cbebb9SMichael Roth fi 241750cbebb9SMichael Rothfi 241850cbebb9SMichael Roth 241950cbebb9SMichael Roth########################################## 24208ca80760SRichard Henderson# capstone 24218ca80760SRichard Henderson 2422e219c499SRichard Hendersoncase "$capstone" in 24238b18cdbfSRichard Henderson auto | enabled | internal) 24248b18cdbfSRichard Henderson # Simpler to always update submodule, even if not needed. 2425e219c499SRichard Henderson git_submodules="${git_submodules} capstone" 2426e219c499SRichard Henderson ;; 2427e219c499SRichard Hendersonesac 24288ca80760SRichard Henderson 24298ca80760SRichard Henderson########################################## 2430519175a2SAlex Barcelo# check and set a backend for coroutine 2431d0e2fce5SAneesh Kumar K.V 24327c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 243333c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 243433c53c54SDaniel P. Berrange# specific one. 24357c2acc70SPeter Maydell 24367c2acc70SPeter Maydellucontext_works=no 2437d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 2438d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 2439d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 2440cdf84806SPeter Maydell#ifdef __stub_makecontext 2441cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 2442cdf84806SPeter Maydell#endif 244375cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 2444d0e2fce5SAneesh Kumar K.VEOF 2445d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 24467c2acc70SPeter Maydell ucontext_works=yes 2447d0e2fce5SAneesh Kumar K.V fi 2448519175a2SAlex Barcelofi 24497c2acc70SPeter Maydell 24507c2acc70SPeter Maydellif test "$coroutine" = ""; then 24517c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 24527c2acc70SPeter Maydell coroutine=win32 24537c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 24547c2acc70SPeter Maydell coroutine=ucontext 2455519175a2SAlex Barcelo else 24567c2acc70SPeter Maydell coroutine=sigaltstack 24577c2acc70SPeter Maydell fi 24587c2acc70SPeter Maydellelse 24597c2acc70SPeter Maydell case $coroutine in 24607c2acc70SPeter Maydell windows) 24617c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 24627c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 24637c2acc70SPeter Maydell fi 24647c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 24657c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 24667c2acc70SPeter Maydell coroutine=win32 24677c2acc70SPeter Maydell ;; 24687c2acc70SPeter Maydell ucontext) 24697c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 24707c2acc70SPeter Maydell feature_not_found "ucontext" 24717c2acc70SPeter Maydell fi 24727c2acc70SPeter Maydell ;; 247333c53c54SDaniel P. Berrange sigaltstack) 24747c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 24757c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 24767c2acc70SPeter Maydell fi 24777c2acc70SPeter Maydell ;; 24787c2acc70SPeter Maydell *) 247976ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 24807c2acc70SPeter Maydell ;; 24817c2acc70SPeter Maydell esac 2482d0e2fce5SAneesh Kumar K.Vfi 2483d0e2fce5SAneesh Kumar K.V 24841e4f6065SDaniele Buono################################################## 24851e4f6065SDaniele Buono# SafeStack 24861e4f6065SDaniele Buono 24871e4f6065SDaniele Buono 24881e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 24891e4f6065SDaniele Buonocat > $TMPC << EOF 24901e4f6065SDaniele Buonoint main(int argc, char *argv[]) 24911e4f6065SDaniele Buono{ 24921e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 24931e4f6065SDaniele Buono#error SafeStack Disabled 24941e4f6065SDaniele Buono#endif 24951e4f6065SDaniele Buono return 0; 24961e4f6065SDaniele Buono} 24971e4f6065SDaniele BuonoEOF 24981e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 24991e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 25001e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 25011e4f6065SDaniele Buono # Flag needed both at compilation and at linking 25021e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 25031e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 25041e4f6065SDaniele Buono else 25051e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 25061e4f6065SDaniele Buono fi 25071e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 25081e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 25091e4f6065SDaniele Buono fi 25101e4f6065SDaniele Buonoelse 25111e4f6065SDaniele Buonocat > $TMPC << EOF 25121e4f6065SDaniele Buonoint main(int argc, char *argv[]) 25131e4f6065SDaniele Buono{ 25141e4f6065SDaniele Buono#if defined(__has_feature) 25151e4f6065SDaniele Buono#if __has_feature(safe_stack) 25161e4f6065SDaniele Buono#error SafeStack Enabled 25171e4f6065SDaniele Buono#endif 25181e4f6065SDaniele Buono#endif 25191e4f6065SDaniele Buono return 0; 25201e4f6065SDaniele Buono} 25211e4f6065SDaniele BuonoEOF 25221e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 25231e4f6065SDaniele Buono # Make sure that safe-stack is disabled 25241e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 25251e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 25261e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 25271e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 25281e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 25291e4f6065SDaniele Buono fi 25301e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 25311e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 25321e4f6065SDaniele Buono fi 25331e4f6065SDaniele Buonoelse # "$safe_stack" = "" 25341e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 25351e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 25361e4f6065SDaniele Buono safe_stack="no" 25371e4f6065SDaniele Buono else 25381e4f6065SDaniele Buono safe_stack="yes" 25391e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 25401e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 25411e4f6065SDaniele Buono fi 25421e4f6065SDaniele Buono fi 25431e4f6065SDaniele Buonofi 25441e4f6065SDaniele Buonofi 25457d992e4dSPeter Lieven 254676a347e1SRichard Henderson######################################## 2547f540166bSRichard Henderson# check if __[u]int128_t is usable. 2548f540166bSRichard Henderson 2549f540166bSRichard Hendersonint128=no 2550f540166bSRichard Hendersoncat > $TMPC << EOF 2551f540166bSRichard Henderson__int128_t a; 2552f540166bSRichard Henderson__uint128_t b; 2553f540166bSRichard Hendersonint main (void) { 2554f540166bSRichard Henderson a = a + b; 2555f540166bSRichard Henderson b = a * b; 2556464e3671SPeter Maydell a = a * a; 2557f540166bSRichard Henderson return 0; 2558f540166bSRichard Henderson} 2559f540166bSRichard HendersonEOF 2560f540166bSRichard Hendersonif compile_prog "" "" ; then 2561f540166bSRichard Henderson int128=yes 2562f540166bSRichard Hendersonfi 256376a347e1SRichard Henderson 25647ebee43eSRichard Henderson######################################### 25657ebee43eSRichard Henderson# See if 128-bit atomic operations are supported. 25667ebee43eSRichard Henderson 25677ebee43eSRichard Hendersonatomic128=no 25687ebee43eSRichard Hendersonif test "$int128" = "yes"; then 25697ebee43eSRichard Henderson cat > $TMPC << EOF 25707ebee43eSRichard Hendersonint main(void) 25717ebee43eSRichard Henderson{ 25727ebee43eSRichard Henderson unsigned __int128 x = 0, y = 0; 2573bceac547SThomas Huth y = __atomic_load(&x, 0); 2574bceac547SThomas Huth __atomic_store(&x, y, 0); 2575bceac547SThomas Huth __atomic_compare_exchange(&x, &y, x, 0, 0, 0); 25767ebee43eSRichard Henderson return 0; 25777ebee43eSRichard Henderson} 25787ebee43eSRichard HendersonEOF 25797ebee43eSRichard Henderson if compile_prog "" "" ; then 25807ebee43eSRichard Henderson atomic128=yes 25817ebee43eSRichard Henderson fi 25827ebee43eSRichard Hendersonfi 25837ebee43eSRichard Henderson 2584e6cd4bb5SRichard Hendersoncmpxchg128=no 2585e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then 2586e6cd4bb5SRichard Henderson cat > $TMPC << EOF 2587e6cd4bb5SRichard Hendersonint main(void) 2588e6cd4bb5SRichard Henderson{ 2589e6cd4bb5SRichard Henderson unsigned __int128 x = 0, y = 0; 2590e6cd4bb5SRichard Henderson __sync_val_compare_and_swap_16(&x, y, x); 2591e6cd4bb5SRichard Henderson return 0; 2592e6cd4bb5SRichard Henderson} 2593e6cd4bb5SRichard HendersonEOF 2594e6cd4bb5SRichard Henderson if compile_prog "" "" ; then 2595e6cd4bb5SRichard Henderson cmpxchg128=yes 2596e6cd4bb5SRichard Henderson fi 2597e6cd4bb5SRichard Hendersonfi 2598e6cd4bb5SRichard Henderson 2599fd0e6053SJohn Snow######################################## 2600fd0e6053SJohn Snow# check if ccache is interfering with 2601fd0e6053SJohn Snow# semantic analysis of macros 2602fd0e6053SJohn Snow 26035e4dfd3dSJohn Snowunset CCACHE_CPP2 2604fd0e6053SJohn Snowccache_cpp2=no 2605fd0e6053SJohn Snowcat > $TMPC << EOF 2606fd0e6053SJohn Snowstatic const int Z = 1; 2607fd0e6053SJohn Snow#define fn() ({ Z; }) 2608fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 2609fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 2610fd0e6053SJohn Snow#define ID(X) (X) 2611fd0e6053SJohn Snowint main(int argc, char *argv[]) 2612fd0e6053SJohn Snow{ 2613fd0e6053SJohn Snow int x = 0, y = 0; 2614fd0e6053SJohn Snow x = ID(x); 2615fd0e6053SJohn Snow x = fn(); 2616fd0e6053SJohn Snow fn(); 2617fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 2618fd0e6053SJohn Snow if (TAUT(Z)) return 0; 2619fd0e6053SJohn Snow return 0; 2620fd0e6053SJohn Snow} 2621fd0e6053SJohn SnowEOF 2622fd0e6053SJohn Snow 2623fd0e6053SJohn Snowif ! compile_object "-Werror"; then 2624fd0e6053SJohn Snow ccache_cpp2=yes 2625fd0e6053SJohn Snowfi 2626fd0e6053SJohn Snow 2627b553a042SJohn Snow################################################# 2628b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 2629b553a042SJohn Snow 2630b553a042SJohn Snowif test "$fortify_source" != "no"; then 2631b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 2632b553a042SJohn Snow fortify_source="no"; 2633e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 2634cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 2635b553a042SJohn Snow fortify_source="no"; 2636b553a042SJohn Snow else 2637b553a042SJohn Snow fortify_source="yes" 2638b553a042SJohn Snow fi 2639b553a042SJohn Snowfi 2640b553a042SJohn Snow 2641d2042378SAneesh Kumar K.V########################################## 2642247724cbSMarc-André Lureau# checks for sanitizers 2643247724cbSMarc-André Lureau 2644247724cbSMarc-André Lureauhave_asan=no 2645247724cbSMarc-André Lureauhave_ubsan=no 2646d83414e1SMarc-André Lureauhave_asan_iface_h=no 2647d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 2648247724cbSMarc-André Lureau 2649247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 2650b9f44da2SMarc-André Lureau write_c_skeleton 2651247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 2652247724cbSMarc-André Lureau have_asan=yes 2653247724cbSMarc-André Lureau fi 2654b9f44da2SMarc-André Lureau 2655b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 2656b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 2657b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 2658b9f44da2SMarc-André Lureau cat > $TMPC << EOF 2659b9f44da2SMarc-André Lureau#include <stdlib.h> 2660b9f44da2SMarc-André Lureauint main(void) { 2661b9f44da2SMarc-André Lureau void *tmp = malloc(10); 2662f2dfe54cSLeonid Bloch if (tmp != NULL) { 2663b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 2664b9f44da2SMarc-André Lureau } 2665d1abf3fcSOlaf Hering return 1; 2666f2dfe54cSLeonid Bloch} 2667b9f44da2SMarc-André LureauEOF 2668247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 2669247724cbSMarc-André Lureau have_ubsan=yes 2670247724cbSMarc-André Lureau fi 2671d83414e1SMarc-André Lureau 2672d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 2673d83414e1SMarc-André Lureau have_asan_iface_h=yes 2674d83414e1SMarc-André Lureau fi 2675d83414e1SMarc-André Lureau 2676d83414e1SMarc-André Lureau cat > $TMPC << EOF 2677d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 2678d83414e1SMarc-André Lureauint main(void) { 2679d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 2680d83414e1SMarc-André Lureau return 0; 2681d83414e1SMarc-André Lureau} 2682d83414e1SMarc-André LureauEOF 2683d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 2684d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 2685d83414e1SMarc-André Lureau fi 2686247724cbSMarc-André Lureaufi 2687247724cbSMarc-André Lureau 26880aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 26890aebab04SLingfeng Yang# keep it separate until that is not the case. 26900aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 26910aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 26920aebab04SLingfeng Yangfi 26930aebab04SLingfeng Yanghave_tsan=no 26940aebab04SLingfeng Yanghave_tsan_iface_fiber=no 26950aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 26960aebab04SLingfeng Yang write_c_skeleton 26970aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 26980aebab04SLingfeng Yang have_tsan=yes 26990aebab04SLingfeng Yang fi 27000aebab04SLingfeng Yang cat > $TMPC << EOF 27010aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 27020aebab04SLingfeng Yangint main(void) { 27030aebab04SLingfeng Yang __tsan_create_fiber(0); 27040aebab04SLingfeng Yang return 0; 27050aebab04SLingfeng Yang} 27060aebab04SLingfeng YangEOF 27070aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 27080aebab04SLingfeng Yang have_tsan_iface_fiber=yes 27090aebab04SLingfeng Yang fi 27100aebab04SLingfeng Yangfi 27110aebab04SLingfeng Yang 2712adc28027SAlexander Bulekov########################################## 2713675b9b53SMarc-André Lureau# check for slirp 2714675b9b53SMarc-André Lureau 2715675b9b53SMarc-André Lureaucase "$slirp" in 27164d34a86bSPaolo Bonzini auto | enabled | internal) 27174d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 27187c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 2719675b9b53SMarc-André Lureau ;; 2720675b9b53SMarc-André Lureauesac 2721675b9b53SMarc-André Lureau 272254e7aac0SAlexey Krasikov########################################## 272354e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall 272454e7aac0SAlexey Krasikov 272554e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then 272654e7aac0SAlexey Krasikov 272754e7aac0SAlexey Krasikov have_keyring=no 272854e7aac0SAlexey Krasikov cat > $TMPC << EOF 272954e7aac0SAlexey Krasikov#include <errno.h> 273054e7aac0SAlexey Krasikov#include <asm/unistd.h> 273154e7aac0SAlexey Krasikov#include <linux/keyctl.h> 273254e7aac0SAlexey Krasikov#include <unistd.h> 273354e7aac0SAlexey Krasikovint main(void) { 273454e7aac0SAlexey Krasikov return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0); 273554e7aac0SAlexey Krasikov} 273654e7aac0SAlexey KrasikovEOF 273754e7aac0SAlexey Krasikov if compile_prog "" "" ; then 273854e7aac0SAlexey Krasikov have_keyring=yes 273954e7aac0SAlexey Krasikov fi 274054e7aac0SAlexey Krasikovfi 274154e7aac0SAlexey Krasikovif test "$secret_keyring" != "no" 274254e7aac0SAlexey Krasikovthen 2743b418d265SDavid Edmondson if test "$have_keyring" = "yes" 274454e7aac0SAlexey Krasikov then 274554e7aac0SAlexey Krasikov secret_keyring=yes 274654e7aac0SAlexey Krasikov else 274754e7aac0SAlexey Krasikov if test "$secret_keyring" = "yes" 274854e7aac0SAlexey Krasikov then 274954e7aac0SAlexey Krasikov error_exit "syscall __NR_keyctl requested, \ 275054e7aac0SAlexey Krasikovbut not implemented on your system" 275154e7aac0SAlexey Krasikov else 275254e7aac0SAlexey Krasikov secret_keyring=no 275354e7aac0SAlexey Krasikov fi 275454e7aac0SAlexey Krasikov fi 275554e7aac0SAlexey Krasikovfi 275654e7aac0SAlexey Krasikov 275792500362SAlexey Krasikov########################################## 2758e86ecd4bSJuan Quintela# End of CC checks 2759e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 2760e86ecd4bSJuan Quintela 2761d83414e1SMarc-André Lureauwrite_c_skeleton 2762d83414e1SMarc-André Lureau 27631d728c39SBlue Swirlif test "$gcov" = "yes" ; then 2764bf0e56a3SMarc-André Lureau : 2765b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then 2766086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 2767086d5f75SPaolo Bonzini debug=no 2768086d5f75SPaolo Bonzinifi 2769086d5f75SPaolo Bonzini 2770086d5f75SPaolo Bonzinicase "$ARCH" in 2771086d5f75SPaolo Bonzinialpha) 2772086d5f75SPaolo Bonzini # Ensure there's only a single GP 2773086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 2774086d5f75SPaolo Bonzini;; 2775086d5f75SPaolo Bonziniesac 2776086d5f75SPaolo Bonzini 2777247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 2778db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 2779db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 2780d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 2781d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 2782d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2783d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 2784d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 2785d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2786d83414e1SMarc-André Lureau fi 2787247724cbSMarc-André Lureaufi 27880aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 27890aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 27900aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 27910aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 27920aebab04SLingfeng Yang else 27930aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 27940aebab04SLingfeng Yang fi 27950aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 27960aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 27970aebab04SLingfeng Yangfi 2798247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 2799db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 2800db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 2801247724cbSMarc-André Lureaufi 2802247724cbSMarc-André Lureau 28036542aa9cSPeter Lieven########################################## 28043efac6ebSTomáš Golembiovský 28050aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 28060aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 2807e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 2808db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 2809e86ecd4bSJuan Quintela fi 2810e86ecd4bSJuan Quintelafi 2811e86ecd4bSJuan Quintela 2812952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available 2813952afb71SBlue Swirlif test "$mingw32" = "yes" ; then 2814cb8baa77SMark Cave-Ayland flags="--no-seh --nxcompat" 2815cb8baa77SMark Cave-Ayland 2816cb8baa77SMark Cave-Ayland # Disable ASLR for debug builds to allow debugging with gdb 2817cb8baa77SMark Cave-Ayland if test "$debug" = "no" ; then 2818cb8baa77SMark Cave-Ayland flags="--dynamicbase $flags" 2819cb8baa77SMark Cave-Ayland fi 2820cb8baa77SMark Cave-Ayland 2821cb8baa77SMark Cave-Ayland for flag in $flags; do 2822e9a3591fSChristian Borntraeger if ld_has $flag ; then 2823db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS" 2824952afb71SBlue Swirl fi 2825952afb71SBlue Swirl done 2826952afb71SBlue Swirlfi 2827952afb71SBlue Swirl 28289d6bc27bSMichael Roth# Probe for guest agent support/options 28299d6bc27bSMichael Roth 2830e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then 2831a5125905SLaurent Vivier if [ "$softmmu" = no -a "$want_tools" = no ] ; then 2832a5125905SLaurent Vivier guest_agent=no 2833a5125905SLaurent Vivier elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then 2834e8ef31a3SMichael Tokarev guest_agent=yes 2835e8ef31a3SMichael Tokarev elif [ "$guest_agent" != yes ]; then 2836e8ef31a3SMichael Tokarev guest_agent=no 2837e8ef31a3SMichael Tokarev else 2838e8ef31a3SMichael Tokarev error_exit "Guest agent is not supported on this platform" 2839ca35f780SPaolo Bonzini fi 28404b1c11fdSDaniel P. Berrangefi 2841ca35f780SPaolo Bonzini 2842b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 28439d6bc27bSMichael Roth 28449d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 28459d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 28469d6bc27bSMichael Rothfi 28479d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 28489d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 28499d6bc27bSMichael Rothfi 28509d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 285189138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 28529d6bc27bSMichael Rothfi 28539d6bc27bSMichael Roth 2854b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 28559d6bc27bSMichael Roth 2856ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 2857ca35f780SPaolo Bonziniroms= 2858e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 2859ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 2860ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 2861e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 2862c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 2863c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 2864c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 2865e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 2866e57218b6SPeter Maydell ld_i386_emulation="$emu" 2867ca35f780SPaolo Bonzini roms="optionrom" 2868e57218b6SPeter Maydell break 2869e57218b6SPeter Maydell fi 2870e57218b6SPeter Maydell done 2871ca35f780SPaolo Bonzinifi 2872ca35f780SPaolo Bonzini 28732e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 2874a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 28759933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 28762e33c3f8SThomas Huth write_c_skeleton 2877a5b2afd5SThomas Huth compile_prog "-march=z900" "" 2878a5b2afd5SThomas Huth has_z900=$? 28793af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 2880a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 2881a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 2882a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 2883a5b2afd5SThomas Huth fi 28849933c305SChristian Borntraeger roms="$roms s390-ccw" 28851ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 28861ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 28871ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 28881ef6bfc2SPhilippe Mathieu-Daudé fi 28899933c305SChristian Borntraegerfi 28909933c305SChristian Borntraeger 289111cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 289211cde1c8SBruno 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. 289311cde1c8SBruno Dominguezif has $cxx; then 289411cde1c8SBruno Dominguez cat > $TMPC <<EOF 289511cde1c8SBruno Dominguezint c_function(void); 289611cde1c8SBruno Dominguezint main(void) { return c_function(); } 289711cde1c8SBruno DominguezEOF 289811cde1c8SBruno Dominguez 289911cde1c8SBruno Dominguez compile_object 290011cde1c8SBruno Dominguez 290111cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 290211cde1c8SBruno Dominguezextern "C" { 290311cde1c8SBruno Dominguez int c_function(void); 290411cde1c8SBruno Dominguez} 290511cde1c8SBruno Dominguezint c_function(void) { return 42; } 290611cde1c8SBruno DominguezEOF 290711cde1c8SBruno Dominguez 290811cde1c8SBruno Dominguez update_cxxflags 290911cde1c8SBruno Dominguez 2910a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 291111cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 291211cde1c8SBruno Dominguez : 291311cde1c8SBruno Dominguez else 291411cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 291511cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 291611cde1c8SBruno Dominguez cxx= 291711cde1c8SBruno Dominguez fi 291811cde1c8SBruno Dominguezelse 291911cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 292011cde1c8SBruno Dominguez cxx= 292111cde1c8SBruno Dominguezfi 292211cde1c8SBruno Dominguez 29237d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 29247d7dbf9dSDan Streetman exit 1 29255d91a2edSYonggang Luofi 29265d91a2edSYonggang Luo 292798ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 292897a847bcSbellard 292998ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 293098ec69acSJuan Quintelaecho >> $config_host_mak 293198ec69acSJuan Quintela 2932e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 2933cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 2934aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 29357d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 2936804edf29SJuan Quintela 2937f8393946Saurel32if test "$debug_tcg" = "yes" ; then 29382358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 2939f8393946Saurel32fi 294067b915a5Sbellardif test "$mingw32" = "yes" ; then 294198ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 2942d9840e25STomoki Sekiyama if test "$guest_agent_with_vss" = "yes" ; then 2943d9840e25STomoki Sekiyama echo "CONFIG_QGA_VSS=y" >> $config_host_mak 2944d9840e25STomoki Sekiyama echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak 2945d9840e25STomoki Sekiyama fi 294650cbebb9SMichael Roth if test "$guest_agent_ntddscsi" = "yes" ; then 294776dc75caSTomáš Golembiovský echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak 294850cbebb9SMichael Roth fi 29499dacf32dSYossi Hindin echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak 29509dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 29519dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 29529dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 2953210fa556Spbrookelse 295435f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 2955210fa556Spbrookfi 2956128ab2ffSblueswir1 2957dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 2958dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 2959dffcb71cSMark McLoughlinfi 2960dffcb71cSMark McLoughlin 296183fb7adfSbellardif test "$darwin" = "yes" ; then 296298ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 296383fb7adfSbellardfi 2964b29fe3edSmalc 2965ec530c81Sbellardif test "$solaris" = "yes" ; then 296698ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 2967ec530c81Sbellardfi 296897a847bcSbellardif test "$static" = "yes" ; then 296998ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 297097a847bcSbellardfi 2971c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then 2972c932ce31SPaolo Bonzini echo "CONFIG_TOOLS=y" >> $config_host_mak 2973c932ce31SPaolo Bonzinifi 2974f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then 2975f15bff25SPaolo Bonzini echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak 2976f15bff25SPaolo Bonzinifi 2977b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak 2978b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak 297989138857SStefan Weilqemu_version=$(head $source_path/VERSION) 29802358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak 298198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 29822b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 298317969268SFam Zhengif test "$modules" = "yes"; then 2984e26110cfSFam Zheng # $shacmd can generate a hash started with digit, which the compiler doesn't 2985e26110cfSFam Zheng # like as an symbol. So prefix it with an underscore 298689138857SStefan Weil echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak 298717969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 298817969268SFam Zhengfi 2989bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then 2990bd83c861SChristian Ehrhardt echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak 2991bd83c861SChristian Ehrhardtfi 2992955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then 2993955727d2SCortland Tölva echo "CONFIG_USBFS=y" >> $config_host_mak 2994955727d2SCortland Tölvafi 2995f876b765SMarc-André Lureauif test "$gio" = "yes" ; then 2996f876b765SMarc-André Lureau echo "CONFIG_GIO=y" >> $config_host_mak 2997f876b765SMarc-André Lureau echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak 2998f876b765SMarc-André Lureau echo "GIO_LIBS=$gio_libs" >> $config_host_mak 29995ecfb76cSPaolo Bonzinifi 30005ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then 300125a97a56SMarc-André Lureau echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak 3002f876b765SMarc-André Lureaufi 3003a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak 3004277abf15SJan Vesely 30051badb709SPaolo Bonziniif test "$xen" = "enabled" ; then 30066dbd588aSJan Kiszka echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak 3007d5b93ddfSAnthony PERARD echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak 3008582ea95fSMarc-André Lureau echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak 3009582ea95fSMarc-André Lureau echo "XEN_LIBS=$xen_libs" >> $config_host_mak 3010e37630caSaliguorifi 30115e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then 30125e9be92dSNicholas Bellinger echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 30135e9be92dSNicholas Bellingerfi 3014af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then 3015af3bba76SPaolo Bonzini echo "CONFIG_VHOST_NET=y" >> $config_host_mak 3016af3bba76SPaolo Bonzinifi 3017af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then 301856f41de7SPaolo Bonzini echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 301903ce5744SNikolay Nikolaevfi 3020108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then 3021108a6481SCindy Lu echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak 3022108a6481SCindy Lufi 3023042cea27SGongleiif test "$vhost_crypto" = "yes" ; then 3024042cea27SGonglei echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak 3025042cea27SGongleifi 3026fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then 3027fc0b9b0eSStefan Hajnoczi echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak 30285fe97d88SStefano Garzarella if test "$vhost_user" = "yes" ; then 30295fe97d88SStefano Garzarella echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak 30305fe97d88SStefano Garzarella fi 3031fc0b9b0eSStefan Hajnoczifi 3032299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then 3033299e6f19SPaolo Bonzini echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak 3034299e6f19SPaolo Bonzinifi 3035e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then 3036e6a74868SMarc-André Lureau echo "CONFIG_VHOST_USER=y" >> $config_host_mak 3037e6a74868SMarc-André Lureaufi 3038108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then 3039108a6481SCindy Lu echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak 3040108a6481SCindy Lufi 304198fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then 304298fc1adaSDr. David Alan Gilbert echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak 304398fc1adaSDr. David Alan Gilbertfi 3044e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then 3045e5b46549SRichard Henderson echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak 3046e5b46549SRichard Hendersonfi 304758d3f3ffSGerd Hoffmann 3048da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then 3049da076ffeSGerd Hoffmann echo "CONFIG_OPENGL=y" >> $config_host_mak 3050de2d3005SPaolo Bonzini echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak 3051da076ffeSGerd Hoffmann echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak 305220ff075bSMichael Wallefi 305320ff075bSMichael Walle 305483fb7adfSbellard# XXX: suppress that 30557d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 30562358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 30577d3505c5Sbellardfi 30587d3505c5Sbellard 30597c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 30607d992e4dSPeter Lieven 3061d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 3062d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 3063d83414e1SMarc-André Lureaufi 3064d83414e1SMarc-André Lureau 30650aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 30660aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 30670aebab04SLingfeng Yangfi 30680aebab04SLingfeng Yang 3069f540166bSRichard Hendersonif test "$int128" = "yes" ; then 3070f540166bSRichard Henderson echo "CONFIG_INT128=y" >> $config_host_mak 3071f540166bSRichard Hendersonfi 3072f540166bSRichard Henderson 30737ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then 30747ebee43eSRichard Henderson echo "CONFIG_ATOMIC128=y" >> $config_host_mak 30757ebee43eSRichard Hendersonfi 30767ebee43eSRichard Henderson 3077e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then 3078e6cd4bb5SRichard Henderson echo "CONFIG_CMPXCHG128=y" >> $config_host_mak 3079e6cd4bb5SRichard Hendersonfi 3080e6cd4bb5SRichard Henderson 30812da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then 30822da776dbSMichael R. Hines echo "CONFIG_RDMA=y" >> $config_host_mak 3083392fb643SFam Zheng echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak 30842da776dbSMichael R. Hinesfi 30852da776dbSMichael R. Hines 308621ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then 308721ab34c9SMarcel Apfelbaum echo "CONFIG_PVRDMA=y" >> $config_host_mak 308821ab34c9SMarcel Apfelbaumfi 308921ab34c9SMarcel Apfelbaum 309040e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 309140e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 309240e8c6f4SAlex Bennéefi 309340e8c6f4SAlex Bennée 3094f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 3095b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 3096d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 3097f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 3098f48e590aSAlex Bennée fi 3099b1863cccSAlex Bennéefi 3100f48e590aSAlex Bennée 310154e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then 310254e7aac0SAlexey Krasikov echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak 310354e7aac0SAlexey Krasikovfi 310454e7aac0SAlexey Krasikov 310598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 3106804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 3107c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 310839d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 3109a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 311009e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 3111804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 3112433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak 3113a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then 3114859aef02SPaolo Bonzini echo "CONFIG_IASL=$iasl" >> $config_host_mak 3115a31a8642SMichael S. Tsirkinfi 3116804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 3117cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 31185f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 31193dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 3120804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 3121804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 312246eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak 3123a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 312411cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 3125a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 3126a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 3127d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 31288a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 3129e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 3130a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 3131804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 3132804edf29SJuan Quintela 31336efd7517SPeter Maydell# use included Linux headers 31346efd7517SPeter Maydellif test "$linux" = "yes" ; then 3135a307beb6SAndreas Färber mkdir -p linux-headers 31366efd7517SPeter Maydell case "$cpu" in 31374da270beSPaolo Bonzini i386|x86_64) 313808312a63SPeter Maydell linux_arch=x86 31396efd7517SPeter Maydell ;; 3140d8ff892dSPaolo Bonzini ppc|ppc64) 314108312a63SPeter Maydell linux_arch=powerpc 31426efd7517SPeter Maydell ;; 31436efd7517SPeter Maydell s390x) 314408312a63SPeter Maydell linux_arch=s390 314508312a63SPeter Maydell ;; 31461f080313SClaudio Fontana aarch64) 31471f080313SClaudio Fontana linux_arch=arm64 31481f080313SClaudio Fontana ;; 3149dfcf900bSWANG Xuerui loongarch*) 3150dfcf900bSWANG Xuerui linux_arch=loongarch 3151dfcf900bSWANG Xuerui ;; 3152222e7d11SSanjay Lal mips64) 3153222e7d11SSanjay Lal linux_arch=mips 3154222e7d11SSanjay Lal ;; 315508312a63SPeter Maydell *) 315608312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 315708312a63SPeter Maydell linux_arch="$cpu" 31586efd7517SPeter Maydell ;; 31596efd7517SPeter Maydell esac 316008312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 316108312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 316208312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 316308312a63SPeter Maydell fi 31646efd7517SPeter Maydellfi 31656efd7517SPeter Maydell 316697a847bcSbellardfor target in $target_list; do 316797a847bcSbellard target_dir="$target" 316857a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 316997a847bcSbellard mkdir -p $target_dir 3170fdb75aefSPaolo Bonzini case $target in 3171fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 3172fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 31732408a527Saurel32 esac 317456aebc89Spbrookdone 31757d13299dSbellard 3176765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak 3177fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 3178fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 3179fdb75aefSPaolo Bonzinifi 3180a540f158SPeter Crosthwaite 3181fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 3182fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 3183fd0e6053SJohn Snowfi 3184fd0e6053SJohn Snow 31851e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 31861e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 31871e4f6065SDaniele Buonofi 31881e4f6065SDaniele Buono 3189e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 3190e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 3191e29e5c6eSPeter Maydell# (these can be both files and directories). 3192e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 3193e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 3194e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 3195e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 3196e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 3197e29e5c6eSPeter Maydell# directory and symlink the directory instead. 31982038f8c8SPaolo BonziniLINKS="Makefile" 31993941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 3200ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 3201e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 32028db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile" 3203e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp" 3204e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 3205bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 320639950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 32078f8fd9edSCleber RosaLINKS="$LINKS python" 3208c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 3209753d11f2SRichard Hendersonfor bios_file in \ 3210753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 32113a631b8eSBin Meng $source_path/pc-bios/*.elf \ 3212225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 3213753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 3214753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 3215e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 3216753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 32174e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 3218cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 3219cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 3220cd946e5cSJohn Arbuckle 3221753d11f2SRichard Hendersondo 3222e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 32237ea78b74SJan Kiszkadone 3224e29e5c6eSPeter Maydellfor f in $LINKS ; do 32250f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 32265dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 3227f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 3228f9245e10SPeter Maydell fi 32297d13299dSbellarddone 32301ad2134fSPaul Brook 32312038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 32322038f8c8SPaolo Bonzini export $i 32332038f8c8SPaolo Bonzinidone 3234fd0f79d7SRichard Hendersonexport target_list source_path use_containers cpu 32352038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 32362038f8c8SPaolo Bonzini 3237c34ebfdcSAnthony Liguori# temporary config to build submodules 3238bb7cb3adSPaolo Bonziniif test -f $source_path/roms/seabios/Makefile; then 32398db2a4fdSGerd Hoffmann for rom in seabios; do 3240c34ebfdcSAnthony Liguori config_mak=roms/$rom/config.mak 324137116c89SStefan Weil echo "# Automatically generated by configure - do not modify" > $config_mak 3242c34ebfdcSAnthony Liguori echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak 3243cdbd727cSRichard Henderson echo "AS=$as" >> $config_mak 32445f6f0e27SRichard Henderson echo "CCAS=$ccas" >> $config_mak 3245c34ebfdcSAnthony Liguori echo "CC=$cc" >> $config_mak 3246c34ebfdcSAnthony Liguori echo "BCC=bcc" >> $config_mak 32473dd46c78SBlue Swirl echo "CPP=$cpp" >> $config_mak 3248c34ebfdcSAnthony Liguori echo "OBJCOPY=objcopy" >> $config_mak 3249a31a8642SMichael S. Tsirkin echo "IASL=$iasl" >> $config_mak 3250c34ebfdcSAnthony Liguori echo "LD=$ld" >> $config_mak 32519f81aeb5SAlistair Francis echo "RANLIB=$ranlib" >> $config_mak 3252c34ebfdcSAnthony Liguori done 3253bb7cb3adSPaolo Bonzinifi 3254c34ebfdcSAnthony Liguori 325598409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 325698409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 325798409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 325898409991SHelge Konetzka 3259a5665051SPaolo Bonziniif test "$skip_meson" = no; then 3260fc929892SMarc-André Lureau cross="config-meson.cross.new" 3261fc929892SMarc-André Lureau meson_quote() { 3262ac7ebcc5SPaolo Bonzini test $# = 0 && return 326347b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 3264fc929892SMarc-André Lureau } 3265fc929892SMarc-André Lureau 3266fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 3267fc929892SMarc-André Lureau echo "[properties]" >> $cross 3268d1d5e9eeSAlex Bennée 3269d1d5e9eeSAlex Bennée # unroll any custom device configs 3270d1d5e9eeSAlex Bennée for a in $device_archs; do 3271d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 3272d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 3273d1d5e9eeSAlex Bennée done 3274d1d5e9eeSAlex Bennée 3275fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 327647b30835SPaolo Bonzini echo "[built-in options]" >> $cross 3277a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 3278a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 3279a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 3280a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 3281fc929892SMarc-André Lureau echo "[binaries]" >> $cross 32824dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 32834dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 32844dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 328547b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 328647b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 328747b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 328847b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 3289e8178514SPaolo Bonzini if has $sdl2_config; then 329047b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 3291e8178514SPaolo Bonzini fi 329247b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 329347b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 32943812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 3295fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 3296fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 3297ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 3298823eb013SPaolo Bonzini case "$cpu" in 3299f6bca9dfSJoelle van Dyne i386) 3300fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 3301fc929892SMarc-André Lureau ;; 3302fc929892SMarc-André Lureau *) 3303823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 3304fc929892SMarc-André Lureau ;; 3305fc929892SMarc-André Lureau esac 3306fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 3307fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 3308fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 3309fc929892SMarc-André Lureau else 3310fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 3311fc929892SMarc-André Lureau fi 3312fc929892SMarc-André Lureau else 3313fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 3314fc929892SMarc-André Lureau fi 3315fc929892SMarc-André Lureau mv $cross config-meson.cross 3316fc929892SMarc-André Lureau 3317a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 331861d63097SPaolo Bonzini run_meson() { 331909e93326SPaolo Bonzini NINJA=$ninja $meson setup \ 3320d17f305aSPaolo Bonzini --prefix "$prefix" \ 3321d17f305aSPaolo Bonzini --libdir "$libdir" \ 3322d17f305aSPaolo Bonzini --libexecdir "$libexecdir" \ 3323d17f305aSPaolo Bonzini --bindir "$bindir" \ 3324d17f305aSPaolo Bonzini --includedir "$includedir" \ 3325d17f305aSPaolo Bonzini --datadir "$datadir" \ 3326d17f305aSPaolo Bonzini --mandir "$mandir" \ 3327d17f305aSPaolo Bonzini --sysconfdir "$sysconfdir" \ 332816bf7a33SPaolo Bonzini --localedir "$localedir" \ 3329d17f305aSPaolo Bonzini --localstatedir "$local_statedir" \ 33303b4da132SPaolo Bonzini -Daudio_drv_list=$audio_drv_list \ 33313b4da132SPaolo Bonzini -Ddefault_devices=$default_devices \ 3332d17f305aSPaolo Bonzini -Ddocdir="$docdir" \ 333316bf7a33SPaolo Bonzini -Dqemu_firmwarepath="$firmwarepath" \ 333473f3aa37SMarc-André Lureau -Dqemu_suffix="$qemu_suffix" \ 3335*35acbb30SPaolo Bonzini -Dsmbd="$smbd" \ 33363b4da132SPaolo Bonzini -Dsphinx_build="$sphinx_build" \ 33373b4da132SPaolo Bonzini -Dtrace_file="$trace_file" \ 3338a5665051SPaolo Bonzini -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ 3339a5665051SPaolo Bonzini -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ 3340a5665051SPaolo Bonzini -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ 3341da6d48b9SMarc-André Lureau -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ 3342bf0e56a3SMarc-André Lureau -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ 33433b4da132SPaolo Bonzini -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ 33443b4da132SPaolo Bonzini -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ 3345537b7248SPaolo Bonzini $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ 3346332008e0SThomas Huth $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ 334761d63097SPaolo Bonzini "$@" $cross_arg "$PWD" "$source_path" 334861d63097SPaolo Bonzini } 334961d63097SPaolo Bonzini eval run_meson $meson_options 3350a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 3351a5665051SPaolo Bonzini error_exit "meson setup failed" 3352a5665051SPaolo Bonzini fi 3353699d3884SPaolo Bonzinielse 3354699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 3355699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 3356699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 3357699d3884SPaolo Bonzini perl -i -ne ' 3358699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 3359699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 3360654d6b04SPaolo Bonzini /^b_staticpic/ && next; 3361699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 3362699d3884SPaolo Bonzini fi 3363a5665051SPaolo Bonzinifi 3364a5665051SPaolo Bonzini 3365dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 3366dc655404SMichael S. Tsirkincat <<EOD >config.status 3367dc655404SMichael S. Tsirkin#!/bin/sh 3368dc655404SMichael S. Tsirkin# Generated by configure. 3369dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 3370dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 3371dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 3372dc655404SMichael S. TsirkinEOD 3373e811da7fSDaniel P. Berrangé 3374e811da7fSDaniel P. Berrangépreserve_env() { 3375e811da7fSDaniel P. Berrangé envname=$1 3376e811da7fSDaniel P. Berrangé 3377e811da7fSDaniel P. Berrangé eval envval=\$$envname 3378e811da7fSDaniel P. Berrangé 3379e811da7fSDaniel P. Berrangé if test -n "$envval" 3380e811da7fSDaniel P. Berrangé then 3381e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 3382e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 3383e811da7fSDaniel P. Berrangé else 3384e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 3385e811da7fSDaniel P. Berrangé fi 3386e811da7fSDaniel P. Berrangé} 3387e811da7fSDaniel P. Berrangé 3388e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 3389e811da7fSDaniel P. Berrangé# features/build target configure will detect 3390e811da7fSDaniel P. Berrangépreserve_env AR 3391e811da7fSDaniel P. Berrangépreserve_env AS 3392e811da7fSDaniel P. Berrangépreserve_env CC 3393e811da7fSDaniel P. Berrangépreserve_env CPP 33948009da03SPaolo Bonzinipreserve_env CFLAGS 3395e811da7fSDaniel P. Berrangépreserve_env CXX 33968009da03SPaolo Bonzinipreserve_env CXXFLAGS 3397e811da7fSDaniel P. Berrangépreserve_env INSTALL 3398e811da7fSDaniel P. Berrangépreserve_env LD 33998009da03SPaolo Bonzinipreserve_env LDFLAGS 3400e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 3401e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 3402e811da7fSDaniel P. Berrangépreserve_env MAKE 3403e811da7fSDaniel P. Berrangépreserve_env NM 3404e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 3405e811da7fSDaniel P. Berrangépreserve_env PATH 3406e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 3407e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 3408e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 3409e811da7fSDaniel P. Berrangépreserve_env PYTHON 3410e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 3411e811da7fSDaniel P. Berrangépreserve_env SMBD 3412e811da7fSDaniel P. Berrangépreserve_env STRIP 3413e811da7fSDaniel P. Berrangépreserve_env WINDRES 3414e811da7fSDaniel P. Berrangé 3415dc655404SMichael S. Tsirkinprintf "exec" >>config.status 3416a5665051SPaolo Bonzinifor i in "$0" "$@"; do 3417835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 3418a5665051SPaolo Bonzinidone 3419cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 3420dc655404SMichael S. Tsirkinchmod +x config.status 3421dc655404SMichael S. Tsirkin 34228cd05ab6SPeter Maydellrm -r "$TMPDIR1" 3423