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" 804cb37d11SPhilippe Mathieu-DaudéTMPM="${TMPDIR1}/${TMPB}.m" 818cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe" 827d13299dSbellard 83da1d85e3SGerd Hoffmannrm -f config.log 849ac81bbbSmalc 85b48e3611SPeter Maydell# Print a helpful header at the top of config.log 86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log 87979ae168SPeter Maydellprintf "# Configured with:" >> config.log 88979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log 89979ae168SPeter Maydellecho >> config.log 90b48e3611SPeter Maydellecho "#" >> config.log 91b48e3611SPeter Maydell 92835af899SPaolo Bonziniquote_sh() { 93835af899SPaolo Bonzini printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," 94835af899SPaolo Bonzini} 95835af899SPaolo Bonzini 96d880a3baSPaolo Bonziniprint_error() { 97d880a3baSPaolo Bonzini (echo 9876ad07a4SPeter Maydell echo "ERROR: $1" 9976ad07a4SPeter Maydell while test -n "$2"; do 10076ad07a4SPeter Maydell echo " $2" 10176ad07a4SPeter Maydell shift 10276ad07a4SPeter Maydell done 103d880a3baSPaolo Bonzini echo) >&2 104d880a3baSPaolo Bonzini} 105d880a3baSPaolo Bonzini 106d880a3baSPaolo Bonzinierror_exit() { 107d880a3baSPaolo Bonzini print_error "$@" 10876ad07a4SPeter Maydell exit 1 10976ad07a4SPeter Maydell} 11076ad07a4SPeter Maydell 1119c83ffd8SPeter Maydelldo_compiler() { 1129c83ffd8SPeter Maydell # Run the compiler, capturing its output to the log. First argument 1139c83ffd8SPeter Maydell # is compiler binary to execute. 114630d86b7SDavid CARLIER compiler="$1" 1159c83ffd8SPeter Maydell shift 1168bbe05d7SIan Jackson if test -n "$BASH_VERSION"; then eval ' 1178bbe05d7SIan Jackson echo >>config.log " 1188bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]} 1198bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}" 1208bbe05d7SIan Jackson '; fi 1219c83ffd8SPeter Maydell echo $compiler "$@" >> config.log 1229c83ffd8SPeter Maydell $compiler "$@" >> config.log 2>&1 || return $? 1238dc38a78SPeter Maydell # Test passed. If this is an --enable-werror build, rerun 1248dc38a78SPeter Maydell # the test with -Werror and bail out if it fails. This 1258dc38a78SPeter Maydell # makes warning-generating-errors in configure test code 1268dc38a78SPeter Maydell # obvious to developers. 1278dc38a78SPeter Maydell if test "$werror" != "yes"; then 1288dc38a78SPeter Maydell return 0 1298dc38a78SPeter Maydell fi 1308dc38a78SPeter Maydell # Don't bother rerunning the compile if we were already using -Werror 1318dc38a78SPeter Maydell case "$*" in 1328dc38a78SPeter Maydell *-Werror*) 1338dc38a78SPeter Maydell return 0 1348dc38a78SPeter Maydell ;; 1358dc38a78SPeter Maydell esac 1369c83ffd8SPeter Maydell echo $compiler -Werror "$@" >> config.log 1379c83ffd8SPeter Maydell $compiler -Werror "$@" >> config.log 2>&1 && return $? 13876ad07a4SPeter Maydell error_exit "configure test passed without -Werror but failed with -Werror." \ 13976ad07a4SPeter Maydell "This is probably a bug in the configure script. The failing command" \ 14076ad07a4SPeter Maydell "will be at the bottom of config.log." \ 14176ad07a4SPeter Maydell "You can run configure with --disable-werror to bypass this check." 1428dc38a78SPeter Maydell} 1438dc38a78SPeter Maydell 1449c83ffd8SPeter Maydelldo_cc() { 1454dba2789SPaolo Bonzini do_compiler "$cc" $CPU_CFLAGS "$@" 1469c83ffd8SPeter Maydell} 1479c83ffd8SPeter Maydell 1489c83ffd8SPeter Maydelldo_cxx() { 1494dba2789SPaolo Bonzini do_compiler "$cxx" $CPU_CFLAGS "$@" 1509c83ffd8SPeter Maydell} 1519c83ffd8SPeter Maydell 1524cb37d11SPhilippe Mathieu-Daudédo_objc() { 1534cb37d11SPhilippe Mathieu-Daudé do_compiler "$objcc" $CPU_CFLAGS "$@" 1544cb37d11SPhilippe Mathieu-Daudé} 1554cb37d11SPhilippe Mathieu-Daudé 15600849b92SRichard Henderson# Append $2 to the variable named $1, with space separation 15700849b92SRichard Hendersonadd_to() { 15800849b92SRichard Henderson eval $1=\${$1:+\"\$$1 \"}\$2 15900849b92SRichard Henderson} 16000849b92SRichard Henderson 1619c83ffd8SPeter Maydellupdate_cxxflags() { 1629c83ffd8SPeter Maydell # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those 1639c83ffd8SPeter Maydell # options which some versions of GCC's C++ compiler complain about 1649c83ffd8SPeter Maydell # because they only make sense for C programs. 165de38c0ccSPaolo Bonzini QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS" 1668a9d3d56SRichard Henderson CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/) 1679c83ffd8SPeter Maydell for arg in $QEMU_CFLAGS; do 1689c83ffd8SPeter Maydell case $arg in 1699c83ffd8SPeter Maydell -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ 1709c83ffd8SPeter Maydell -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) 1719c83ffd8SPeter Maydell ;; 1729c83ffd8SPeter Maydell *) 1739c83ffd8SPeter Maydell QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg 1749c83ffd8SPeter Maydell ;; 1759c83ffd8SPeter Maydell esac 1769c83ffd8SPeter Maydell done 1779c83ffd8SPeter Maydell} 1789c83ffd8SPeter Maydell 17952166aa0SJuan Quintelacompile_object() { 180fd0e6053SJohn Snow local_cflags="$1" 181a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC 18252166aa0SJuan Quintela} 18352166aa0SJuan Quintela 18452166aa0SJuan Quintelacompile_prog() { 18552166aa0SJuan Quintela local_cflags="$1" 18652166aa0SJuan Quintela local_ldflags="$2" 187a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \ 188a2866660SPaolo Bonzini $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags 18952166aa0SJuan Quintela} 19052166aa0SJuan Quintela 19111568d6dSPaolo Bonzini# symbolically link $1 to $2. Portable version of "ln -sf". 19211568d6dSPaolo Bonzinisymlink() { 19372b8b5a1SStefan Weil rm -rf "$2" 194ec5b06d7SAnthony Liguori mkdir -p "$(dirname "$2")" 19572b8b5a1SStefan Weil ln -s "$1" "$2" 19611568d6dSPaolo Bonzini} 19711568d6dSPaolo Bonzini 1980dba6195SLoïc Minier# check whether a command is available to this shell (may be either an 1990dba6195SLoïc Minier# executable or a builtin) 2000dba6195SLoïc Minierhas() { 2010dba6195SLoïc Minier type "$1" >/dev/null 2>&1 2020dba6195SLoïc Minier} 2030dba6195SLoïc Minier 2040a01d76fSMarc-André Lureauversion_ge () { 2052df52b9bSAlex Bennée local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') 2062df52b9bSAlex Bennée local_ver2=$(echo "$2" | tr . ' ') 2070a01d76fSMarc-André Lureau while true; do 2080a01d76fSMarc-André Lureau set x $local_ver1 2090a01d76fSMarc-André Lureau local_first=${2-0} 210c44a33e2SStefano Garzarella # 'shift 2' if $2 is set, or 'shift' if $2 is not set 211c44a33e2SStefano Garzarella shift ${2:+2} 2120a01d76fSMarc-André Lureau local_ver1=$* 2130a01d76fSMarc-André Lureau set x $local_ver2 2140a01d76fSMarc-André Lureau # the second argument finished, the first must be greater or equal 2150a01d76fSMarc-André Lureau test $# = 1 && return 0 2160a01d76fSMarc-André Lureau test $local_first -lt $2 && return 1 2170a01d76fSMarc-André Lureau test $local_first -gt $2 && return 0 218c44a33e2SStefano Garzarella shift ${2:+2} 2190a01d76fSMarc-André Lureau local_ver2=$* 2200a01d76fSMarc-André Lureau done 2210a01d76fSMarc-André Lureau} 2220a01d76fSMarc-André Lureau 2233b6b7550SPaolo Bonziniglob() { 2243b6b7550SPaolo Bonzini eval test -z '"${1#'"$2"'}"' 2253b6b7550SPaolo Bonzini} 2263b6b7550SPaolo Bonzini 2274ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; 2284ace32e2SAntonio Ospitethen 2294ace32e2SAntonio Ospite error_exit "main directory cannot contain spaces nor colons" 2304ace32e2SAntonio Ospitefi 2314ace32e2SAntonio Ospite 23214211825SAntonio Ospite# default parameters 2332ff6b91eSJuan Quintelacpu="" 2341e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M" 23543ce4dfeSbellardstatic="no" 2363812c0c4SJoelle van Dynecross_compile="no" 2377d13299dSbellardcross_prefix="" 238b64ec4e4SFam Zhengblock_drv_rw_whitelist="" 239b64ec4e4SFam Zhengblock_drv_ro_whitelist="" 240e49d021eSPeter Maydellhost_cc="cc" 241cdad781dSDaniele Buonolto="false" 24263678e17SSteven Noonanstack_protector="" 2431e4f6065SDaniele Buonosafe_stack="" 244afc3a8f9SAlex Bennéeuse_containers="yes" 245f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 246ac0df51dSaliguori 24792712822SDaniel P. Berrangeif test -e "$source_path/.git" 24892712822SDaniel P. Berrangethen 2497d7dbf9dSDan Streetman git_submodules_action="update" 25092712822SDaniel P. Berrangeelse 2517d7dbf9dSDan Streetman git_submodules_action="ignore" 25292712822SDaniel P. Berrangefi 2532d652f24SPaolo Bonzini 2542d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb" 255cc84d63aSDaniel P. Berrangegit="git" 256ac0df51dSaliguori 257afb63ebdSStefan Weil# Don't accept a target_list environment variable. 258afb63ebdSStefan Weilunset target_list 259447e133fSAlex Bennéeunset target_list_exclude 260377529c0SPaolo Bonzini 261377529c0SPaolo Bonzini# Default value for a variable defining feature "foo". 262377529c0SPaolo Bonzini# * foo="no" feature will only be used if --enable-foo arg is given 263377529c0SPaolo Bonzini# * foo="" feature will be searched for, and if found, will be used 264377529c0SPaolo Bonzini# unless --disable-foo is given 265377529c0SPaolo Bonzini# * foo="yes" this value will only be set by --enable-foo flag. 266377529c0SPaolo Bonzini# feature will searched for, 267377529c0SPaolo Bonzini# if not found, configure exits with error 268377529c0SPaolo Bonzini# 269377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args. 270377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it 271377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found. 272377529c0SPaolo Bonzini 273c87ea116SAlex Bennéedefault_feature="" 274c87ea116SAlex Bennée# parse CC options second 275c87ea116SAlex Bennéefor opt do 276c87ea116SAlex Bennée optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 277c87ea116SAlex Bennée case "$opt" in 278c87ea116SAlex Bennée --without-default-features) 279c87ea116SAlex Bennée default_feature="no" 280c87ea116SAlex Bennée ;; 281c87ea116SAlex Bennée esac 282c87ea116SAlex Bennéedone 283c87ea116SAlex Bennée 284a2866660SPaolo BonziniEXTRA_CFLAGS="" 285a2866660SPaolo BonziniEXTRA_CXXFLAGS="" 286e910c7d9SPhilippe Mathieu-DaudéEXTRA_OBJCFLAGS="" 287a2866660SPaolo BonziniEXTRA_LDFLAGS="" 288a2866660SPaolo Bonzini 2890848f8acSThomas Huthvhost_kernel="$default_feature" 290c87ea116SAlex Bennéevhost_net="$default_feature" 291c87ea116SAlex Bennéevhost_crypto="$default_feature" 292c87ea116SAlex Bennéevhost_scsi="$default_feature" 293c87ea116SAlex Bennéevhost_vsock="$default_feature" 294d88618f7SStefan Hajnoczivhost_user="no" 295c87ea116SAlex Bennéevhost_user_fs="$default_feature" 2960848f8acSThomas Huthvhost_vdpa="$default_feature" 29728609749SPaolo Bonzinidebug_info="yes" 298377529c0SPaolo Bonzinidebug_tcg="no" 299377529c0SPaolo Bonzinidebug="no" 300247724cbSMarc-André Lureausanitizers="no" 3010aebab04SLingfeng Yangtsan="no" 3021f3f2bfeSMichael Tokarevfortify_source="yes" 3031d728c39SBlue Swirlgcov="no" 304c7328271SMiroslav RezaninaEXESUF="" 30517969268SFam Zhengmodules="no" 306377529c0SPaolo Bonziniprefix="/usr/local" 30710ff82d1SMarc-André Lureauqemu_suffix="qemu" 308377529c0SPaolo Bonzinisoftmmu="yes" 309b915a2f1SPaolo Bonzinilinux_user="" 310b915a2f1SPaolo Bonzinibsd_user="" 311377529c0SPaolo Bonzinipkgversion="" 31240d6444eSAvi Kivitypie="" 313519175a2SAlex Barcelocoroutine="" 314a1c5e949SDaniel P. Berrangetls_priority="NORMAL" 315ba4dd2aaSAlex Bennéeplugins="$default_feature" 316a5665051SPaolo Bonzinimeson="" 3173b4da132SPaolo Bonzinimeson_args="" 31848328880SPaolo Bonzinininja="" 319a5665051SPaolo Bonziniskip_meson=no 320377529c0SPaolo Bonzini 3213b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 3223b4da132SPaolo Bonzini# are included in the automatically generated help message) 3233b4da132SPaolo Bonzini 3243b4da132SPaolo Bonzini# 1. Track which submodules are needed 3250577e84dSThomas Huthif test "$default_feature" = no ; then 3260577e84dSThomas Huth capstone="disabled" 3270577e84dSThomas Huth slirp="disabled" 3280577e84dSThomas Huthelse 3293b4da132SPaolo Bonzini capstone="auto" 3303b4da132SPaolo Bonzini slirp="auto" 3310577e84dSThomas Huthfi 3320577e84dSThomas Huthfdt="auto" 3333b4da132SPaolo Bonzini 3343b4da132SPaolo Bonzini# 2. Support --with/--without option 3353b4da132SPaolo Bonzinidefault_devices="true" 3363b4da132SPaolo Bonzini 3373b4da132SPaolo Bonzini# 3. Automatically enable/disable other options 3383b4da132SPaolo Bonzinitcg="enabled" 3393b4da132SPaolo Bonzinicfi="false" 3403b4da132SPaolo Bonzini 341c87ea116SAlex Bennée# parse CC options second 342ac0df51dSaliguorifor opt do 34389138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 344ac0df51dSaliguori case "$opt" in 345ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3463812c0c4SJoelle van Dyne cross_compile="yes" 347ac0df51dSaliguori ;; 3483d8df640SPaolo Bonzini --cc=*) CC="$optarg" 349ac0df51dSaliguori ;; 35083f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 35183f73fceSTomoki Sekiyama ;; 3522ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3532ff6b91eSJuan Quintela ;; 354a2866660SPaolo Bonzini --extra-cflags=*) 355a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 356a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 357e910c7d9SPhilippe Mathieu-Daudé EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 358e2a2ed06SJuan Quintela ;; 359a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 36011cde1c8SBruno Dominguez ;; 361e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 362e910c7d9SPhilippe Mathieu-Daudé ;; 363a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 364e2a2ed06SJuan Quintela ;; 365d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 366d75402b5SAlex Bennée ;; 367479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 368d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 3692038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 370d422b2bcSAlex Bennée ;; 371d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 372d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 3732038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 374d75402b5SAlex Bennée ;; 375ac0df51dSaliguori esac 376ac0df51dSaliguoridone 377ac0df51dSaliguori# OS specific 378ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 37993148aa5SStefan Weil# we can eliminate its usage altogether. 380ac0df51dSaliguori 381e49d021eSPeter Maydell# Preferred compiler: 382e49d021eSPeter Maydell# ${CC} (if set) 383e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 384e49d021eSPeter Maydell# system compiler 385e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 386e49d021eSPeter Maydell cc="$host_cc" 387e49d021eSPeter Maydellelse 388b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 389e49d021eSPeter Maydellfi 390e49d021eSPeter Maydell 39183f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 39283f73fceSTomoki Sekiyama cxx="c++" 39383f73fceSTomoki Sekiyamaelse 39483f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 39583f73fceSTomoki Sekiyamafi 39683f73fceSTomoki Sekiyama 397b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 398cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 3995f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 4003dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 401b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 402b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 4039f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 4044852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 40535acbb30SPaolo Bonzinismbd="$SMBD" 406b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 407158bb224SKonstantin Kostiukwidl="${WIDL-${cross_prefix}widl}" 408b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 40917884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 41017884d7bSSergei Trofimovichquery_pkg_config() { 41117884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 41217884d7bSSergei Trofimovich} 41317884d7bSSergei Trofimovichpkg_config=query_pkg_config 41447c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 415ac0df51dSaliguori 416be17dc90SMichael S. Tsirkin# default flags for all hosts 4172d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 4182d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 4192d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 4202d31515bSPeter Maydell# provides these semantics.) 421de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 422086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 423c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 424be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4255770e8afSPaolo Bonzini 426de38c0ccSPaolo BonziniQEMU_LDFLAGS= 427de38c0ccSPaolo Bonzini 4285770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4298a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4305770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 431086d5f75SPaolo Bonzini 432be17dc90SMichael S. Tsirkin 433ac0df51dSaliguoricheck_define() { 434ac0df51dSaliguoricat > $TMPC <<EOF 435ac0df51dSaliguori#if !defined($1) 436fd786e1aSPeter Maydell#error $1 not defined 437ac0df51dSaliguori#endif 438ac0df51dSaliguoriint main(void) { return 0; } 439ac0df51dSaliguoriEOF 44052166aa0SJuan Quintela compile_object 441ac0df51dSaliguori} 442ac0df51dSaliguori 443307119e7SGerd Hoffmanncheck_include() { 444307119e7SGerd Hoffmanncat > $TMPC <<EOF 445307119e7SGerd Hoffmann#include <$1> 446307119e7SGerd Hoffmannint main(void) { return 0; } 447307119e7SGerd HoffmannEOF 448307119e7SGerd Hoffmann compile_object 449307119e7SGerd Hoffmann} 450307119e7SGerd Hoffmann 45193b25869SJohn Snowwrite_c_skeleton() { 45293b25869SJohn Snow cat > $TMPC <<EOF 45393b25869SJohn Snowint main(void) { return 0; } 45493b25869SJohn SnowEOF 45593b25869SJohn Snow} 45693b25869SJohn Snow 457bbea4050SPeter Maydellif check_define __linux__ ; then 458ba7c60c2SPaolo Bonzini targetos=linux 459bbea4050SPeter Maydellelif check_define _WIN32 ; then 460ba7c60c2SPaolo Bonzini targetos=windows 461bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 462ba7c60c2SPaolo Bonzini targetos=openbsd 463bbea4050SPeter Maydellelif check_define __sun__ ; then 464ba7c60c2SPaolo Bonzini targetos=sunos 465bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 466ba7c60c2SPaolo Bonzini targetos=haiku 467951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 468ba7c60c2SPaolo Bonzini targetos=freebsd 469951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 470ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 471951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 472ba7c60c2SPaolo Bonzini targetos=dragonfly 473951fedfcSPeter Maydellelif check_define __NetBSD__; then 474ba7c60c2SPaolo Bonzini targetos=netbsd 475951fedfcSPeter Maydellelif check_define __APPLE__; then 476ba7c60c2SPaolo Bonzini targetos=darwin 477bbea4050SPeter Maydellelse 478951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 479951fedfcSPeter Maydell # might be going to just print the --help text, or it might 480951fedfcSPeter Maydell # be the result of a missing compiler. 481ba7c60c2SPaolo Bonzini targetos=bogus 482bbea4050SPeter Maydellfi 483bbea4050SPeter Maydell 48465eff01bSPaolo Bonzini# OS specific 48565eff01bSPaolo Bonzini 4863b0d8643SPaolo Bonzinimingw32="no" 4873b0d8643SPaolo Bonzinibsd="no" 4883b0d8643SPaolo Bonzinilinux="no" 4893b0d8643SPaolo Bonzinisolaris="no" 49065eff01bSPaolo Bonzinicase $targetos in 49165eff01bSPaolo Bonziniwindows) 49265eff01bSPaolo Bonzini mingw32="yes" 49365eff01bSPaolo Bonzini plugins="no" 49465eff01bSPaolo Bonzini pie="no" 49565eff01bSPaolo Bonzini;; 49665eff01bSPaolo Bonzinignu/kfreebsd) 49765eff01bSPaolo Bonzini bsd="yes" 49865eff01bSPaolo Bonzini;; 49965eff01bSPaolo Bonzinifreebsd) 50065eff01bSPaolo Bonzini bsd="yes" 50165eff01bSPaolo Bonzini make="${MAKE-gmake}" 50265eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 50365eff01bSPaolo Bonzini;; 50465eff01bSPaolo Bonzinidragonfly) 50565eff01bSPaolo Bonzini bsd="yes" 50665eff01bSPaolo Bonzini make="${MAKE-gmake}" 50765eff01bSPaolo Bonzini;; 50865eff01bSPaolo Bonzininetbsd) 50965eff01bSPaolo Bonzini bsd="yes" 51065eff01bSPaolo Bonzini make="${MAKE-gmake}" 51165eff01bSPaolo Bonzini;; 51265eff01bSPaolo Bonziniopenbsd) 51365eff01bSPaolo Bonzini bsd="yes" 51465eff01bSPaolo Bonzini make="${MAKE-gmake}" 51565eff01bSPaolo Bonzini;; 51665eff01bSPaolo Bonzinidarwin) 51765eff01bSPaolo Bonzini bsd="yes" 51865eff01bSPaolo Bonzini darwin="yes" 51965eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 52065eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 52165eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 52265eff01bSPaolo Bonzini;; 52365eff01bSPaolo Bonzinisunos) 52465eff01bSPaolo Bonzini solaris="yes" 52565eff01bSPaolo Bonzini make="${MAKE-gmake}" 52665eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 52765eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 52865eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 52965eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 53065eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 53165eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 532bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 533bbea4050SPeter Maydell # the correct CPU with the --cpu option. 534bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 535bbea4050SPeter Maydell cpu="x86_64" 536bbea4050SPeter Maydell fi 53765eff01bSPaolo Bonzini;; 53865eff01bSPaolo Bonzinihaiku) 53965eff01bSPaolo Bonzini pie="no" 54065eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 54165eff01bSPaolo Bonzini;; 54265eff01bSPaolo Bonzinilinux) 54365eff01bSPaolo Bonzini linux="yes" 54465eff01bSPaolo Bonzini vhost_user=${default_feature:-yes} 54565eff01bSPaolo Bonzini;; 546bbea4050SPeter Maydellesac 547bbea4050SPeter Maydell 5482ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5492ff6b91eSJuan Quintela # command line argument 5502ff6b91eSJuan Quintela : 5512ff6b91eSJuan Quintelaelif check_define __i386__ ; then 552ac0df51dSaliguori cpu="i386" 553ac0df51dSaliguorielif check_define __x86_64__ ; then 554c72b26ecSRichard Henderson if check_define __ILP32__ ; then 555c72b26ecSRichard Henderson cpu="x32" 556c72b26ecSRichard Henderson else 557ac0df51dSaliguori cpu="x86_64" 558c72b26ecSRichard Henderson fi 5593aa9bd6cSblueswir1elif check_define __sparc__ ; then 5603aa9bd6cSblueswir1 if check_define __arch64__ ; then 5613aa9bd6cSblueswir1 cpu="sparc64" 5623aa9bd6cSblueswir1 else 5633aa9bd6cSblueswir1 cpu="sparc" 5643aa9bd6cSblueswir1 fi 565fdf7ed96Smalcelif check_define _ARCH_PPC ; then 566fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 567f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 568f8378accSRichard Henderson cpu="ppc64le" 569f8378accSRichard Henderson else 570fdf7ed96Smalc cpu="ppc64" 571f8378accSRichard Henderson fi 572ac0df51dSaliguori else 573fdf7ed96Smalc cpu="ppc" 574fdf7ed96Smalc fi 575afa05235SAurelien Jarnoelif check_define __mips__ ; then 576afa05235SAurelien Jarno cpu="mips" 577d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 578d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 579d66ed0eaSAurelien Jarno cpu="s390x" 580d66ed0eaSAurelien Jarno else 581d66ed0eaSAurelien Jarno cpu="s390" 582d66ed0eaSAurelien Jarno fi 583c4f80543SAlistair Franciselif check_define __riscv ; then 584ba0e7333SRichard Henderson cpu="riscv" 58521d89f84SPeter Maydellelif check_define __arm__ ; then 58621d89f84SPeter Maydell cpu="arm" 5871f080313SClaudio Fontanaelif check_define __aarch64__ ; then 5881f080313SClaudio Fontana cpu="aarch64" 589dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 590dfcf900bSWANG Xuerui cpu="loongarch64" 591fdf7ed96Smalcelse 59289138857SStefan Weil cpu=$(uname -m) 593ac0df51dSaliguorifi 594ac0df51dSaliguori 595823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 596359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 5977d13299dSbellardcase "$cpu" in 598e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 599e4da0e39SPaolo Bonzini cpu="arm" ;; 600e4da0e39SPaolo Bonzini 6017d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 60297a847bcSbellard cpu="i386" 603e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 604e4da0e39SPaolo Bonzini x32) 6054da270beSPaolo Bonzini cpu="x86_64" 606e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 607aaa5fa14Saurel32 x86_64|amd64) 608aaa5fa14Saurel32 cpu="x86_64" 609e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 610e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 611e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 612e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 613e4da0e39SPaolo Bonzini 614afa05235SAurelien Jarno mips*) 615e4da0e39SPaolo Bonzini cpu="mips" ;; 616e4da0e39SPaolo Bonzini 617e4da0e39SPaolo Bonzini ppc) 618e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 619e4da0e39SPaolo Bonzini ppc64) 620ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mbig-endian" ;; 621e4da0e39SPaolo Bonzini ppc64le) 622d8ff892dSPaolo Bonzini cpu="ppc64" 623ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mlittle-endian" ;; 624e4da0e39SPaolo Bonzini 625e4da0e39SPaolo Bonzini s390) 626823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 627e4da0e39SPaolo Bonzini s390x) 628e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 629e4da0e39SPaolo Bonzini 6303142255cSblueswir1 sparc|sun4[cdmuv]) 631ae228531Sbellard cpu="sparc" 632e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 633e4da0e39SPaolo Bonzini sparc64) 634e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6357d13299dSbellardesac 636e2d52ad3SJuan Quintela 6370db4a067SPaolo Bonzini: ${make=${MAKE-make}} 638b6daf4d3SPaolo Bonzini 639faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 640faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 641ddf90699SEduardo Habkost# we check that too 642faf44142SDaniel P. Berrangépython= 6430a01d76fSMarc-André Lureauexplicit_python=no 644ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 645faf44142SDaniel P. Berrangédo 646faf44142SDaniel P. Berrangé if has "$binary" 647faf44142SDaniel P. Berrangé then 64895c5f2deSPaolo Bonzini python=$(command -v "$binary") 649faf44142SDaniel P. Berrangé break 650faf44142SDaniel P. Berrangé fi 651faf44142SDaniel P. Berrangédone 652903458c8SMarkus Armbruster 653903458c8SMarkus Armbruster 65439d87c8cSAlex Bennée# Check for ancillary tools used in testing 65539d87c8cSAlex Bennéegenisoimage= 6563df437c7SAlex Bennéefor binary in genisoimage mkisofs 65739d87c8cSAlex Bennéedo 65839d87c8cSAlex Bennée if has $binary 65939d87c8cSAlex Bennée then 66039d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 66139d87c8cSAlex Bennée break 66239d87c8cSAlex Bennée fi 66339d87c8cSAlex Bennéedone 66439d87c8cSAlex Bennée 6653c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6663c4a4d0dSPeter Maydellif has clang; then 6673c4a4d0dSPeter Maydell objcc=clang 6683c4a4d0dSPeter Maydellelse 6693c4a4d0dSPeter Maydell objcc="$cc" 6703c4a4d0dSPeter Maydellfi 6713c4a4d0dSPeter Maydell 6723457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6733457a3f8SJuan Quintela EXESUF=".exe" 67478e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6755770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 67693b25869SJohn Snow write_c_skeleton; 677d17f305aSPaolo Bonzini prefix="/qemu" 67877433a5fSMarc-André Lureau qemu_suffix="" 6793457a3f8SJuan Quintelafi 6803457a3f8SJuan Quintela 681487fefdbSAnthony Liguoriwerror="" 68285aa5189Sbellard 68361d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 68461d63097SPaolo Bonzini 68561d63097SPaolo Bonzinimeson_options= 68661d63097SPaolo Bonzinimeson_option_parse() { 68761d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 68861d63097SPaolo Bonzini if test $? -eq 1; then 68961d63097SPaolo Bonzini echo "ERROR: unknown option $1" 69061d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 69161d63097SPaolo Bonzini exit 1 69261d63097SPaolo Bonzini fi 69361d63097SPaolo Bonzini} 69461d63097SPaolo Bonzini 6957d13299dSbellardfor opt do 69689138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 6977d13299dSbellard case "$opt" in 6982efc3265Sbellard --help|-h) show_help=yes 6992efc3265Sbellard ;; 70099123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 70199123e13SMike Frysinger ;; 702b1a550a0Spbrook --prefix=*) prefix="$optarg" 7037d13299dSbellard ;; 704b1a550a0Spbrook --interp-prefix=*) interp_prefix="$optarg" 70532ce6337Sbellard ;; 706ac0df51dSaliguori --cross-prefix=*) 7077d13299dSbellard ;; 708ac0df51dSaliguori --cc=*) 7097d13299dSbellard ;; 710b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 71183469015Sbellard ;; 71283f73fceSTomoki Sekiyama --cxx=*) 71383f73fceSTomoki Sekiyama ;; 7143c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 7153c4a4d0dSPeter Maydell ;; 716b1a550a0Spbrook --make=*) make="$optarg" 7177d13299dSbellard ;; 718b6daf4d3SPaolo Bonzini --install=*) 7196a882643Spbrook ;; 7200a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 721c886edfbSBlue Swirl ;; 722a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 723a5665051SPaolo Bonzini ;; 724a5665051SPaolo Bonzini --meson=*) meson="$optarg" 725a5665051SPaolo Bonzini ;; 72648328880SPaolo Bonzini --ninja=*) ninja="$optarg" 72748328880SPaolo Bonzini ;; 728e2d8830eSBrad --smbd=*) smbd="$optarg" 729e2d8830eSBrad ;; 730e2a2ed06SJuan Quintela --extra-cflags=*) 7317d13299dSbellard ;; 73211cde1c8SBruno Dominguez --extra-cxxflags=*) 73311cde1c8SBruno Dominguez ;; 734e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) 735e910c7d9SPhilippe Mathieu-Daudé ;; 736e2a2ed06SJuan Quintela --extra-ldflags=*) 7377d13299dSbellard ;; 738d75402b5SAlex Bennée --cross-cc-*) 739d75402b5SAlex Bennée ;; 74028609749SPaolo Bonzini --enable-debug-info) debug_info="yes" 74128609749SPaolo Bonzini ;; 74228609749SPaolo Bonzini --disable-debug-info) debug_info="no" 74328609749SPaolo Bonzini ;; 74417969268SFam Zheng --enable-modules) 74517969268SFam Zheng modules="yes" 74617969268SFam Zheng ;; 7473aa88b31SStefan Hajnoczi --disable-modules) 7483aa88b31SStefan Hajnoczi modules="no" 7493aa88b31SStefan Hajnoczi ;; 7502ff6b91eSJuan Quintela --cpu=*) 7517d13299dSbellard ;; 752b1a550a0Spbrook --target-list=*) target_list="$optarg" 753447e133fSAlex Bennée if test "$target_list_exclude"; then 754447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 755447e133fSAlex Bennée fi 756447e133fSAlex Bennée ;; 757447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 758447e133fSAlex Bennée if test "$target_list"; then 759447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 760447e133fSAlex Bennée fi 761de83cd02Sbellard ;; 7627bc3ca7fSPaolo Bonzini --with-default-devices) default_devices="true" 763f3494749SPaolo Bonzini ;; 7647bc3ca7fSPaolo Bonzini --without-default-devices) default_devices="false" 765f3494749SPaolo Bonzini ;; 766d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 767d1d5e9eeSAlex Bennée ;; 768d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 769d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 770d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 771d1d5e9eeSAlex Bennée if test -f "$cf"; then 772d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 773d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 774d1d5e9eeSAlex Bennée else 775d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 776d1d5e9eeSAlex Bennée fi 777d1d5e9eeSAlex Bennée ;; 778c87ea116SAlex Bennée --without-default-features) # processed above 779c87ea116SAlex Bennée ;; 7801d728c39SBlue Swirl --enable-gcov) gcov="yes" 7811d728c39SBlue Swirl ;; 78279427693SLoïc Minier --static) 78379427693SLoïc Minier static="yes" 78417884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 78543ce4dfeSbellard ;; 7860b24e75fSPaolo Bonzini --mandir=*) mandir="$optarg" 7870b24e75fSPaolo Bonzini ;; 7880b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 7890b24e75fSPaolo Bonzini ;; 7903aa5d2beSAlon Levy --libdir=*) libdir="$optarg" 7913aa5d2beSAlon Levy ;; 7928bf188aaSMichael Tokarev --libexecdir=*) libexecdir="$optarg" 7938bf188aaSMichael Tokarev ;; 7940f94d6daSAlon Levy --includedir=*) includedir="$optarg" 7950f94d6daSAlon Levy ;; 796528ae5b8SEduardo Habkost --datadir=*) datadir="$optarg" 7970b24e75fSPaolo Bonzini ;; 79877433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 799023d3d67SEduardo Habkost ;; 800c6502638SBruce Rogers --docdir=*) docdir="$optarg" 8010b24e75fSPaolo Bonzini ;; 802fe0038beSPaolo Bonzini --localedir=*) localedir="$optarg" 803fe0038beSPaolo Bonzini ;; 804ca2fb938SAndre Przywara --sysconfdir=*) sysconfdir="$optarg" 80507381cc1SAnthony Liguori ;; 806785c23aeSLuiz Capitulino --localstatedir=*) local_statedir="$optarg" 807785c23aeSLuiz Capitulino ;; 8083d5eecabSGerd Hoffmann --firmwarepath=*) firmwarepath="$optarg" 8093d5eecabSGerd Hoffmann ;; 810181ce1d0SOlaf Hering --host=*|--build=*|\ 811181ce1d0SOlaf Hering --disable-dependency-tracking|\ 812785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 813fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 814023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 815023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 816023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 817023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 818023ddd74SMax Filippov # lots of directory switches by default. 819023ddd74SMax Filippov ;; 82089138857SStefan Weil --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 821b64ec4e4SFam Zheng ;; 82289138857SStefan Weil --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 823eb852011SMarkus Armbruster ;; 824f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 825f8393946Saurel32 ;; 826f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 827f8393946Saurel32 ;; 828f3d08ee6SPaul Brook --enable-debug) 829f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 830f3d08ee6SPaul Brook debug_tcg="yes" 831c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 832f3d08ee6SPaul Brook debug="yes" 833b553a042SJohn Snow fortify_source="no" 834f3d08ee6SPaul Brook ;; 835247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 836247724cbSMarc-André Lureau ;; 837247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 838247724cbSMarc-André Lureau ;; 8390aebab04SLingfeng Yang --enable-tsan) tsan="yes" 8400aebab04SLingfeng Yang ;; 8410aebab04SLingfeng Yang --disable-tsan) tsan="no" 8420aebab04SLingfeng Yang ;; 8434d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 844c20709aaSbellard ;; 845fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 846fd6fc214SPaolo Bonzini ;; 8474d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 8487c57bdd8SMarc-André Lureau ;; 84903a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 850675b9b53SMarc-André Lureau ;; 8511badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 852d1a14257SAlex Bennée plugins="no" 853b3f6ea7eSPaolo Bonzini ;; 8541badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 855b3f6ea7eSPaolo Bonzini ;; 856cad25d69Spbrook --disable-system) softmmu="no" 8570a8e90f4Spbrook ;; 858cad25d69Spbrook --enable-system) softmmu="yes" 8590a8e90f4Spbrook ;; 8600953a80fSZachary Amsden --disable-user) 8610953a80fSZachary Amsden linux_user="no" ; 8620953a80fSZachary Amsden bsd_user="no" ; 8630953a80fSZachary Amsden ;; 8640953a80fSZachary Amsden --enable-user) ;; 865831b7825Sths --disable-linux-user) linux_user="no" 8660a8e90f4Spbrook ;; 867831b7825Sths --enable-linux-user) linux_user="yes" 868831b7825Sths ;; 86984778508Sblueswir1 --disable-bsd-user) bsd_user="no" 87084778508Sblueswir1 ;; 87184778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 87284778508Sblueswir1 ;; 87340d6444eSAvi Kivity --enable-pie) pie="yes" 87434005a00SKirill A. Shutemov ;; 87540d6444eSAvi Kivity --disable-pie) pie="no" 87634005a00SKirill A. Shutemov ;; 87785aa5189Sbellard --enable-werror) werror="yes" 87885aa5189Sbellard ;; 87985aa5189Sbellard --disable-werror) werror="no" 88085aa5189Sbellard ;; 881cdad781dSDaniele Buono --enable-lto) lto="true" 882cdad781dSDaniele Buono ;; 883cdad781dSDaniele Buono --disable-lto) lto="false" 884cdad781dSDaniele Buono ;; 88563678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 88663678e17SSteven Noonan ;; 88763678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 88863678e17SSteven Noonan ;; 8891e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 8901e4f6065SDaniele Buono ;; 8911e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 8921e4f6065SDaniele Buono ;; 8939e62ba48SDaniele Buono --enable-cfi) 8949e62ba48SDaniele Buono cfi="true"; 8959e62ba48SDaniele Buono lto="true"; 8969e62ba48SDaniele Buono ;; 8979e62ba48SDaniele Buono --disable-cfi) cfi="false" 8989e62ba48SDaniele Buono ;; 899fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 9002df87df7SJuan Quintela ;; 901fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 902fbb4121dSPaolo Bonzini ;; 903fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 904fbb4121dSPaolo Bonzini ;; 90503a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 9062df87df7SJuan Quintela ;; 9077e563bfbSThomas Huth --with-pkgversion=*) pkgversion="$optarg" 9084a19f1ecSpbrook ;; 909519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 910519175a2SAlex Barcelo ;; 911d5970055SMichael S. Tsirkin --disable-vhost-net) vhost_net="no" 912d5970055SMichael S. Tsirkin ;; 913d5970055SMichael S. Tsirkin --enable-vhost-net) vhost_net="yes" 914d5970055SMichael S. Tsirkin ;; 915042cea27SGonglei --disable-vhost-crypto) vhost_crypto="no" 916042cea27SGonglei ;; 917299e6f19SPaolo Bonzini --enable-vhost-crypto) vhost_crypto="yes" 918042cea27SGonglei ;; 9195e9be92dSNicholas Bellinger --disable-vhost-scsi) vhost_scsi="no" 9205e9be92dSNicholas Bellinger ;; 9215e9be92dSNicholas Bellinger --enable-vhost-scsi) vhost_scsi="yes" 9225e9be92dSNicholas Bellinger ;; 923fc0b9b0eSStefan Hajnoczi --disable-vhost-vsock) vhost_vsock="no" 924fc0b9b0eSStefan Hajnoczi ;; 925fc0b9b0eSStefan Hajnoczi --enable-vhost-vsock) vhost_vsock="yes" 926fc0b9b0eSStefan Hajnoczi ;; 92798fc1adaSDr. David Alan Gilbert --disable-vhost-user-fs) vhost_user_fs="no" 92898fc1adaSDr. David Alan Gilbert ;; 92998fc1adaSDr. David Alan Gilbert --enable-vhost-user-fs) vhost_user_fs="yes" 93098fc1adaSDr. David Alan Gilbert ;; 9311ffb3bbbSPaolo Bonzini --disable-zlib-test) 9321ece9905SAlon Levy ;; 93352b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 93452b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 935583f6e7bSStefan Hajnoczi ;; 936cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 937cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 938cb6414dfSFam Zheng ;; 939315d3184SFam Zheng --enable-uuid|--disable-uuid) 940315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 941315d3184SFam Zheng ;; 942a1c5e949SDaniel P. Berrange --tls-priority=*) tls_priority="$optarg" 943a1c5e949SDaniel P. Berrange ;; 944e6a74868SMarc-André Lureau --disable-vhost-user) vhost_user="no" 945e6a74868SMarc-André Lureau ;; 946299e6f19SPaolo Bonzini --enable-vhost-user) vhost_user="yes" 947299e6f19SPaolo Bonzini ;; 948108a6481SCindy Lu --disable-vhost-vdpa) vhost_vdpa="no" 949108a6481SCindy Lu ;; 950108a6481SCindy Lu --enable-vhost-vdpa) vhost_vdpa="yes" 951108a6481SCindy Lu ;; 952299e6f19SPaolo Bonzini --disable-vhost-kernel) vhost_kernel="no" 953299e6f19SPaolo Bonzini ;; 954299e6f19SPaolo Bonzini --enable-vhost-kernel) vhost_kernel="yes" 955e6a74868SMarc-André Lureau ;; 9568b18cdbfSRichard Henderson --disable-capstone) capstone="disabled" 9578ca80760SRichard Henderson ;; 9588b18cdbfSRichard Henderson --enable-capstone) capstone="enabled" 9598ca80760SRichard Henderson ;; 9608b18cdbfSRichard Henderson --enable-capstone=git) capstone="internal" 961e219c499SRichard Henderson ;; 96203a3c0b3SPaolo Bonzini --enable-capstone=*) capstone="$optarg" 963e219c499SRichard Henderson ;; 964cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 965cc84d63aSDaniel P. Berrange ;; 9667d7dbf9dSDan Streetman --with-git-submodules=*) 9677d7dbf9dSDan Streetman git_submodules_action="$optarg" 968f62bbee5SDaniel P. Berrange ;; 9699b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 9709b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 9719b8e4298SAlex Bennée else 9729b8e4298SAlex Bennée plugins="yes" 9739b8e4298SAlex Bennée fi 97440e8c6f4SAlex Bennée ;; 97540e8c6f4SAlex Bennée --disable-plugins) plugins="no" 97640e8c6f4SAlex Bennée ;; 977afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 978afc3a8f9SAlex Bennée ;; 979afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 980afc3a8f9SAlex Bennée ;; 981f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 982f48e590aSAlex Bennée ;; 9833b4da132SPaolo Bonzini # backwards compatibility options 9843b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 9853b4da132SPaolo Bonzini ;; 9863b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 9873b4da132SPaolo Bonzini ;; 9883b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 9893b4da132SPaolo Bonzini ;; 9903b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 9913b4da132SPaolo Bonzini ;; 9923b4da132SPaolo Bonzini # everything else has the same name in configure and meson 993*4fda6011SPaolo Bonzini --*) meson_option_parse "$opt" "$optarg" 9947f1559c6Sbalrog ;; 9957d13299dSbellard esac 9967d13299dSbellarddone 9977d13299dSbellard 998d1a14257SAlex Bennée# test for any invalid configuration combinations 999d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 1000d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 1001d1a14257SAlex Bennéefi 1002d1a14257SAlex Bennée 10037d7dbf9dSDan Streetmancase $git_submodules_action in 10047d7dbf9dSDan Streetman update|validate) 10057d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 10067d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 10077d7dbf9dSDan Streetman exit 1 10087d7dbf9dSDan Streetman fi 10097d7dbf9dSDan Streetman ;; 10107d7dbf9dSDan Streetman ignore) 1011b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 1012b80fd281SPaolo Bonzini then 1013b80fd281SPaolo Bonzini echo 1014b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 1015b80fd281SPaolo Bonzini echo 1016b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 1017b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 1018b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 1019b80fd281SPaolo Bonzini else 1020b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 1021b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 1022b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 1023b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 1024b80fd281SPaolo Bonzini echo 1025b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 1026b80fd281SPaolo Bonzini echo 1027b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 1028b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 1029b80fd281SPaolo Bonzini fi 1030b80fd281SPaolo Bonzini echo 1031b80fd281SPaolo Bonzini exit 1 1032b80fd281SPaolo Bonzini fi 10337d7dbf9dSDan Streetman ;; 10347d7dbf9dSDan Streetman *) 10357d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 10367d7dbf9dSDan Streetman exit 1 10377d7dbf9dSDan Streetman ;; 10387d7dbf9dSDan Streetmanesac 10397d7dbf9dSDan Streetman 104022a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}" 104122a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}" 104222a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}" 104322a87800SMarc-André Lureau 104422a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then 104515588a62SJoshua Watt bindir="${bindir:-$prefix}" 104622a87800SMarc-André Lureauelse 104715588a62SJoshua Watt bindir="${bindir:-$prefix/bin}" 104815588a62SJoshua Wattfi 104922a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}" 105022a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}" 1051ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}" 105222a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}" 105322a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}" 105416bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}" 105516bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}" 105622a87800SMarc-André Lureau 10579557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 1058b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 10592038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 10609557af9cSAlex Bennéefi 106179f3b12fSPeter Crosthwaite 106260e0df25SPeter Maydelldefault_target_list="" 10636e92f823SPeter Maydellmak_wilds="" 10646e92f823SPeter Maydell 1065b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 1066b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 1067b915a2f1SPaolo Bonzini linux_user=yes 1068b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 1069b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 1070b915a2f1SPaolo Bonzini fi 1071b915a2f1SPaolo Bonzinifi 1072b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 1073b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 1074b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 1075b915a2f1SPaolo Bonzini fi 1076b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 1077b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 1078b915a2f1SPaolo Bonzini fi 1079b915a2f1SPaolo Bonzinifi 108060e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 1081812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 108260e0df25SPeter Maydellfi 108360e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 1084812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 108560e0df25SPeter Maydellfi 108660e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 1087812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 108860e0df25SPeter Maydellfi 108960e0df25SPeter Maydell 1090447e133fSAlex Bennéefor config in $mak_wilds; do 1091447e133fSAlex Bennée target="$(basename "$config" .mak)" 109298db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 1093447e133fSAlex Bennée default_target_list="${default_target_list} $target" 1094447e133fSAlex Bennée fi 1095447e133fSAlex Bennéedone 10966e92f823SPeter Maydell 1097af5db58eSpbrookif test x"$show_help" = x"yes" ; then 1098af5db58eSpbrookcat << EOF 1099af5db58eSpbrook 1100af5db58eSpbrookUsage: configure [options] 1101af5db58eSpbrookOptions: [defaults in brackets after descriptions] 1102af5db58eSpbrook 110308fb77edSStefan WeilStandard options: 110408fb77edSStefan Weil --help print this message 110508fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 110608fb77edSStefan Weil --interp-prefix=PREFIX where to find shared libraries, etc. 110708fb77edSStefan Weil use %M for cpu name [$interp_prefix] 110874154d7eSThomas Huth --target-list=LIST set target list (default: build all) 110908fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 111008fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 1111447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 111208fb77edSStefan Weil 111308fb77edSStefan WeilAdvanced options (experts only): 11143812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 111508fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 111608fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 111708fb77edSStefan Weil build time 111808fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 111908fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1120a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1121a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 1122e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS 112308fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1124d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1125479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 112608fb77edSStefan Weil --make=MAKE use specified make [$make] 112708fb77edSStefan Weil --python=PYTHON use specified python [$python] 1128a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 112948328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 113008fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1131db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 11327d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 11337d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 11347d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 113508fb77edSStefan Weil --static enable static build [$static] 113608fb77edSStefan Weil --mandir=PATH install man pages in PATH 113710ff82d1SMarc-André Lureau --datadir=PATH install firmware in PATH/$qemu_suffix 1138fe0038beSPaolo Bonzini --localedir=PATH install translation in PATH/$qemu_suffix 113910ff82d1SMarc-André Lureau --docdir=PATH install documentation in PATH/$qemu_suffix 114008fb77edSStefan Weil --bindir=PATH install binaries in PATH 114108fb77edSStefan Weil --libdir=PATH install libraries in PATH 1142db1b5f13SThomas Huth --libexecdir=PATH install helper binaries in PATH 114310ff82d1SMarc-André Lureau --sysconfdir=PATH install config in PATH/$qemu_suffix 114408fb77edSStefan Weil --localstatedir=PATH install local state in PATH (set at runtime on win32) 11453d5eecabSGerd Hoffmann --firmwarepath=PATH search PATH for firmware files 114613336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1147ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1148db1b5f13SThomas Huth --with-pkgversion=VERS use specified string as sub-version of the package 1149c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1150c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1151c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1152d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1153d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 115408fb77edSStefan Weil --enable-debug enable common debug build options 1155247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 11560aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 115708fb77edSStefan Weil --disable-werror disable compilation abort on warning 115863678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 115916bfbc70SPaolo Bonzini --audio-drv-list=LIST set audio drivers to try if -audiodev is not used 116008fb77edSStefan Weil --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L 116108fb77edSStefan Weil --block-drv-rw-whitelist=L 116208fb77edSStefan Weil set block driver read-write whitelist 1163e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 116408fb77edSStefan Weil --block-drv-ro-whitelist=L 116508fb77edSStefan Weil set block driver read-only whitelist 1166e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 116708fb77edSStefan Weil --with-trace-file=NAME Full PATH,NAME of file to store traces 116808fb77edSStefan Weil Default:trace-<pid> 1169c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 117008fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 117133c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 117208fb77edSStefan Weil --enable-gcov enable test coverage analysis with gcov 1173a1c5e949SDaniel P. Berrange --tls-priority default TLS protocol/cipher priority string 117440e8c6f4SAlex Bennée --enable-plugins 117540e8c6f4SAlex Bennée enable plugins via shared library loading 1176afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1177f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 117861d63097SPaolo BonziniEOF 117961d63097SPaolo Bonzini meson_options_help 118061d63097SPaolo Bonzinicat << EOF 1181c23f23b9SMichael Tokarev system all system emulation targets 1182c23f23b9SMichael Tokarev user supported user emulation targets 1183c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1184c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1185c23f23b9SMichael Tokarev pie Position Independent Executables 118621e709aaSMarc-André Lureau modules modules support (non-Windows) 1187c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1188c23f23b9SMichael Tokarev debug-info debugging information 1189cdad781dSDaniele Buono lto Enable Link-Time Optimization. 11901e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 11911e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 1192299e6f19SPaolo Bonzini vhost-net vhost-net kernel acceleration support 1193299e6f19SPaolo Bonzini vhost-vsock virtio sockets device support 1194299e6f19SPaolo Bonzini vhost-scsi vhost-scsi kernel target support 1195299e6f19SPaolo Bonzini vhost-crypto vhost-user-crypto backend support 1196299e6f19SPaolo Bonzini vhost-kernel vhost kernel backend support 1197299e6f19SPaolo Bonzini vhost-user vhost-user backend support 1198108a6481SCindy Lu vhost-vdpa vhost-vdpa kernel backend support 119908fb77edSStefan Weil 120008fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1201af5db58eSpbrookEOF 12022d2ad6d0SFam Zhengexit 0 1203af5db58eSpbrookfi 1204af5db58eSpbrook 12059c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1206bb768f71SThomas Huthrm -f */config-devices.mak.d 12079c790242SThomas Huth 1208faf44142SDaniel P. Berrangéif test -z "$python" 1209faf44142SDaniel P. Berrangéthen 1210c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1211c53eeaf7SStefan Hajnoczifi 12128e2c76bdSRoman Bolshakovif ! has "$make" 12138e2c76bdSRoman Bolshakovthen 12148e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 12158e2c76bdSRoman Bolshakovfi 1216c53eeaf7SStefan Hajnoczi 1217c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1218c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 12191b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 12201b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1221c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1222c53eeaf7SStefan Hajnoczifi 1223c53eeaf7SStefan Hajnoczi 1224755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1225406ab2f3SCleber 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) 1226755ee70fSCleber Rosa 1227c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1228c53eeaf7SStefan Hajnoczipython="$python -B" 1229c53eeaf7SStefan Hajnoczi 12300a01d76fSMarc-André Lureauif test -z "$meson"; then 12316638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 12320a01d76fSMarc-André Lureau meson=meson 12337d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 12340a01d76fSMarc-André Lureau meson=git 12350a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 12360a01d76fSMarc-André Lureau meson=internal 12370a01d76fSMarc-André Lureau else 12380a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 12390a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 12400a01d76fSMarc-André Lureau else 1241a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1242a5665051SPaolo Bonzini fi 12430a01d76fSMarc-André Lureau fi 12440a01d76fSMarc-André Lureauelse 12450a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 12460a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 12470a01d76fSMarc-André Lureau # 12480a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 12490a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 12500a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 12510a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 12520a01d76fSMarc-André Lureau case "$meson" in 12530a01d76fSMarc-André Lureau git | internal) ;; 12540a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 12550a01d76fSMarc-André Lureau esac 12560a01d76fSMarc-André Lureau fi 12570a01d76fSMarc-André Lureaufi 1258a5665051SPaolo Bonzini 12590a01d76fSMarc-André Lureauif test "$meson" = git; then 12600a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 12610a01d76fSMarc-André Lureaufi 12620a01d76fSMarc-André Lureau 12630a01d76fSMarc-André Lureaucase "$meson" in 12640a01d76fSMarc-André Lureau git | internal) 12650a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 12660a01d76fSMarc-André Lureau ;; 126784ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 12680a01d76fSMarc-André Lureauesac 12690a01d76fSMarc-André Lureau 127009e93326SPaolo Bonzini# Probe for ninja 127148328880SPaolo Bonzini 127248328880SPaolo Bonziniif test -z "$ninja"; then 127348328880SPaolo Bonzini for c in ninja ninja-build samu; do 127448328880SPaolo Bonzini if has $c; then 127548328880SPaolo Bonzini ninja=$(command -v "$c") 127648328880SPaolo Bonzini break 127748328880SPaolo Bonzini fi 127848328880SPaolo Bonzini done 127909e93326SPaolo Bonzini if test -z "$ninja"; then 128009e93326SPaolo Bonzini error_exit "Cannot find Ninja" 128109e93326SPaolo Bonzini fi 128248328880SPaolo Bonzinifi 1283a5665051SPaolo Bonzini 12849aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 12859aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 12869aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 12879aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 12889aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 12899aae6e54SDaniel Henrique Barbozaif compile_object ; then 12909aae6e54SDaniel Henrique Barboza : C compiler works ok 12919aae6e54SDaniel Henrique Barbozaelse 12929aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 12939aae6e54SDaniel Henrique Barbozafi 12949aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 12959aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 12969aae6e54SDaniel Henrique Barbozafi 12979aae6e54SDaniel Henrique Barboza 12989c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 12999c83ffd8SPeter Maydell# by default. Only enable by default for git builds 13009c83ffd8SPeter Maydellif test -z "$werror" ; then 13017d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1302e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 13039c83ffd8SPeter Maydell werror="yes" 13049c83ffd8SPeter Maydell else 13059c83ffd8SPeter Maydell werror="no" 13069c83ffd8SPeter Maydell fi 13079c83ffd8SPeter Maydellfi 13089c83ffd8SPeter Maydell 1309975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1310fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1311fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1312fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1313fb59dabdSPeter Maydell # host OS we should stop now. 1314951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1315fb59dabdSPeter Maydellfi 1316fb59dabdSPeter Maydell 1317efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1318efc6c070SThomas Huthcat > $TMPC << EOF 1319efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1320efc6c070SThomas Huth# ifdef __apple_build_version__ 13212a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 13222a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1323efc6c070SThomas Huth# endif 1324efc6c070SThomas Huth# else 13252a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 13262a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1327efc6c070SThomas Huth# endif 1328efc6c070SThomas Huth# endif 1329efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 13303830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 13313830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1332efc6c070SThomas Huth# endif 1333efc6c070SThomas Huth#else 1334efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1335efc6c070SThomas Huth#endif 1336efc6c070SThomas Huthint main (void) { return 0; } 1337efc6c070SThomas HuthEOF 1338efc6c070SThomas Huthif ! compile_prog "" "" ; then 13393830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1340efc6c070SThomas Huthfi 1341efc6c070SThomas Huth 134200849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 134300849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 134400849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 134500849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 134600849b92SRichard Henderson# just silently disable some features, so it's too error prone. 134700849b92SRichard Henderson 134800849b92SRichard Hendersonwarn_flags= 134900849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 135000849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 135100849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 135200849b92SRichard Hendersonadd_to warn_flags -Wformat-security 135300849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 135400849b92SRichard Hendersonadd_to warn_flags -Winit-self 135500849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 135600849b92SRichard Hendersonadd_to warn_flags -Wempty-body 135700849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 135800849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 135900849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 13600a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 136100849b92SRichard Henderson 136200849b92SRichard Hendersonnowarn_flags= 136300849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 136400849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 136500849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 136600849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 136700849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1368aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1369bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 137000849b92SRichard Henderson 137100849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 137293b25869SJohn Snow 137393b25869SJohn Snowcc_has_warning_flag() { 137493b25869SJohn Snow write_c_skeleton; 137593b25869SJohn Snow 1376a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1377a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1378a1d29d6cSPeter Maydell # warning options). 137993b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 138093b25869SJohn Snow compile_prog "-Werror $optflag" "" 138193b25869SJohn Snow} 138293b25869SJohn Snow 13834cb37d11SPhilippe Mathieu-Daudéobjcc_has_warning_flag() { 13844cb37d11SPhilippe Mathieu-Daudé cat > $TMPM <<EOF 13854cb37d11SPhilippe Mathieu-Daudéint main(void) { return 0; } 13864cb37d11SPhilippe Mathieu-DaudéEOF 13874cb37d11SPhilippe Mathieu-Daudé 13884cb37d11SPhilippe Mathieu-Daudé # Use the positive sense of the flag when testing for -Wno-wombat 13894cb37d11SPhilippe Mathieu-Daudé # support (gcc will happily accept the -Wno- form of unknown 13904cb37d11SPhilippe Mathieu-Daudé # warning options). 13914cb37d11SPhilippe Mathieu-Daudé optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 13924cb37d11SPhilippe Mathieu-Daudé do_objc -Werror $optflag \ 13934cb37d11SPhilippe Mathieu-Daudé $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ 13944cb37d11SPhilippe Mathieu-Daudé -o $TMPE $TMPM $QEMU_LDFLAGS 13954cb37d11SPhilippe Mathieu-Daudé} 13964cb37d11SPhilippe Mathieu-Daudé 139793b25869SJohn Snowfor flag in $gcc_flags; do 139893b25869SJohn Snow if cc_has_warning_flag $flag ; then 13998d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 14008d05095cSPaolo Bonzini fi 14014cb37d11SPhilippe Mathieu-Daudé if objcc_has_warning_flag $flag ; then 14024cb37d11SPhilippe Mathieu-Daudé QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" 14034cb37d11SPhilippe Mathieu-Daudé fi 14048d05095cSPaolo Bonzinidone 14058d05095cSPaolo Bonzini 140663678e17SSteven Noonanif test "$stack_protector" != "no"; then 1407fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1408fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1409fccd35a0SRodrigo Rebello{ 1410fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1411fccd35a0SRodrigo Rebello while (*c) { 1412fccd35a0SRodrigo Rebello *p++ = *c++; 1413fccd35a0SRodrigo Rebello } 1414fccd35a0SRodrigo Rebello return 0; 1415fccd35a0SRodrigo Rebello} 1416fccd35a0SRodrigo RebelloEOF 141763678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 14183b463a3fSMiroslav Rezanina sp_on=0 141963678e17SSteven Noonan for flag in $gcc_flags; do 1420590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1421590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1422086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1423590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 142463678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1425db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 14263b463a3fSMiroslav Rezanina sp_on=1 142763678e17SSteven Noonan break 142863678e17SSteven Noonan fi 142963678e17SSteven Noonan done 14303b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 14313b463a3fSMiroslav Rezanina if test $sp_on = 0; then 14323b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 14333b463a3fSMiroslav Rezanina fi 14343b463a3fSMiroslav Rezanina fi 143537746c5eSMarc-André Lureaufi 143637746c5eSMarc-André Lureau 143720bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 143820bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 143920bc94a2SPaolo Bonzinicat > $TMPC << EOF 144020bc94a2SPaolo Bonzinistruct { 144120bc94a2SPaolo Bonzini int a[2]; 144220bc94a2SPaolo Bonzini} x = {0}; 144320bc94a2SPaolo BonziniEOF 144420bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 144520bc94a2SPaolo Bonzini : 144620bc94a2SPaolo Bonzinielse 144720bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 144820bc94a2SPaolo Bonzinifi 144920bc94a2SPaolo Bonzini 145021e709aaSMarc-André Lureau# Our module code doesn't support Windows 145121e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 145221e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 145321e709aaSMarc-André Lureaufi 145421e709aaSMarc-André Lureau 14555f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 145640d6444eSAvi Kivityif test "$static" = "yes" ; then 1457aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1458aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1459aa0d1f44SPaolo Bonzini fi 14605f2453acSAlex Bennée if test "$plugins" = "yes"; then 14615f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1462ba4dd2aaSAlex Bennée else 1463ba4dd2aaSAlex Bennée plugins="no" 14645f2453acSAlex Bennée fi 146540d6444eSAvi Kivityfi 146637650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 146740d6444eSAvi Kivity 146840d6444eSAvi Kivitycat > $TMPC << EOF 146921d4a791SAvi Kivity 147021d4a791SAvi Kivity#ifdef __linux__ 147121d4a791SAvi Kivity# define THREAD __thread 147221d4a791SAvi Kivity#else 147321d4a791SAvi Kivity# define THREAD 147421d4a791SAvi Kivity#endif 147521d4a791SAvi Kivitystatic THREAD int tls_var; 147621d4a791SAvi Kivityint main(void) { return tls_var; } 147740d6444eSAvi KivityEOF 1478b2634124SRichard Henderson 1479ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1480ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1481412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1482412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1483ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1484412aeacdSAlex Bennéefi 1485412aeacdSAlex Bennée 148612781462SRichard Hendersonif test "$static" = "yes"; then 1487eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 14885770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 148912781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 149012781462SRichard Henderson pie="yes" 149112781462SRichard Henderson elif test "$pie" = "yes"; then 149212781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 149312781462SRichard Henderson else 149412781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 149512781462SRichard Henderson pie="no" 149612781462SRichard Henderson fi 149712781462SRichard Hendersonelif test "$pie" = "no"; then 14985770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1499ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1500eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 15015770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 15025770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 150340d6444eSAvi Kivity pie="yes" 15042c674109SRichard Hendersonelif test "$pie" = "yes"; then 150576ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 150640d6444eSAvi Kivityelse 150740d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 150840d6444eSAvi Kivity pie="no" 150940d6444eSAvi Kivityfi 151040d6444eSAvi Kivity 1511e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1512e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1513e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1514e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1515e6cbd751SRichard Hendersonfi 1516e6cbd751SRichard Henderson 151709dada40SPaolo Bonzini########################################## 151809dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 151909dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 152009dada40SPaolo Bonzini# specification is necessary 152109dada40SPaolo Bonzini 152209dada40SPaolo Bonziniif test "$cpu" = "i386"; then 152309dada40SPaolo Bonzini cat > $TMPC << EOF 152409dada40SPaolo Bonzinistatic int sfaa(int *ptr) 152509dada40SPaolo Bonzini{ 152609dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 152709dada40SPaolo Bonzini} 152809dada40SPaolo Bonzini 152909dada40SPaolo Bonziniint main(void) 153009dada40SPaolo Bonzini{ 153109dada40SPaolo Bonzini int val = 42; 15321405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 153309dada40SPaolo Bonzini sfaa(&val); 153409dada40SPaolo Bonzini return val; 153509dada40SPaolo Bonzini} 153609dada40SPaolo BonziniEOF 153709dada40SPaolo Bonzini if ! compile_prog "" "" ; then 153809dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 153909dada40SPaolo Bonzini fi 154009dada40SPaolo Bonzinifi 154109dada40SPaolo Bonzini 154256267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 154356267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 154456267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 154556267b62SPhilippe Mathieu-Daudéfi 154656267b62SPhilippe Mathieu-Daudé 1547afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1548fdb75aefSPaolo Bonzini default_targets=yes 1549d880a3baSPaolo Bonzini for target in $default_target_list; do 1550d880a3baSPaolo Bonzini target_list="$target_list $target" 1551d880a3baSPaolo Bonzini done 1552d880a3baSPaolo Bonzini target_list="${target_list# }" 1553121afa9eSAnthony Liguorielse 1554fdb75aefSPaolo Bonzini default_targets=no 155589138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1556d880a3baSPaolo Bonzini for target in $target_list; do 155725b48338SPeter Maydell # Check that we recognised the target name; this allows a more 155825b48338SPeter Maydell # friendly error message than if we let it fall through. 155925b48338SPeter Maydell case " $default_target_list " in 156025b48338SPeter Maydell *" $target "*) 156125b48338SPeter Maydell ;; 156225b48338SPeter Maydell *) 156325b48338SPeter Maydell error_exit "Unknown target name '$target'" 156425b48338SPeter Maydell ;; 156525b48338SPeter Maydell esac 156625b48338SPeter Maydell done 1567d880a3baSPaolo Bonzinifi 156825b48338SPeter Maydell 1569f55fe278SPaolo Bonzini# see if system emulation was really requested 1570f55fe278SPaolo Bonzinicase " $target_list " in 1571f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1572f55fe278SPaolo Bonzini ;; 1573f55fe278SPaolo Bonzini *) softmmu=no 1574f55fe278SPaolo Bonzini ;; 1575f55fe278SPaolo Bonziniesac 15765327cf48Sbellard 1577249247c9SJuan Quintelafeature_not_found() { 1578249247c9SJuan Quintela feature=$1 157921684af0SStewart Smith remedy=$2 1580249247c9SJuan Quintela 158176ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 158221684af0SStewart Smith "configure was not able to find it." \ 158321684af0SStewart Smith "$remedy" 1584249247c9SJuan Quintela} 1585249247c9SJuan Quintela 15867d13299dSbellard# --- 15877d13299dSbellard# big/little endian test 15887d13299dSbellardcat > $TMPC << EOF 1589659eb157SThomas Huth#include <stdio.h> 159061cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 159161cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1592659eb157SThomas Huthint main(int argc, char *argv[]) 1593659eb157SThomas Huth{ 1594659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 15957d13299dSbellard} 15967d13299dSbellardEOF 15977d13299dSbellard 1598659eb157SThomas Huthif compile_prog ; then 1599659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 160061cc919fSMike Frysinger bigendian="yes" 1601659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 160261cc919fSMike Frysinger bigendian="no" 16037d13299dSbellard else 16047d13299dSbellard echo big/little test failed 1605659eb157SThomas Huth exit 1 16067d13299dSbellard fi 16077d13299dSbellardelse 160861cc919fSMike Frysinger echo big/little test failed 1609659eb157SThomas Huth exit 1 16107d13299dSbellardfi 16117d13299dSbellard 1612299e6f19SPaolo Bonzini######################################### 1613299e6f19SPaolo Bonzini# vhost interdependencies and host support 1614299e6f19SPaolo Bonzini 1615299e6f19SPaolo Bonzini# vhost backends 1616eb9baecdSSergio Lopezif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then 1617eb9baecdSSergio Lopez error_exit "vhost-user is not available on Windows" 1618299e6f19SPaolo Bonzinifi 1619108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux 1620108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then 1621108a6481SCindy Lu error_exit "vhost-vdpa is only available on Linux" 1622108a6481SCindy Lufi 1623299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux 1624299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then 1625299e6f19SPaolo Bonzini error_exit "vhost-kernel is only available on Linux" 1626299e6f19SPaolo Bonzinifi 1627299e6f19SPaolo Bonzini 1628299e6f19SPaolo Bonzini# vhost-kernel devices 1629299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel 1630299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then 1631299e6f19SPaolo Bonzini error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" 1632299e6f19SPaolo Bonzinifi 1633299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel 1634299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then 1635299e6f19SPaolo Bonzini error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" 1636299e6f19SPaolo Bonzinifi 1637299e6f19SPaolo Bonzini 1638299e6f19SPaolo Bonzini# vhost-user backends 1639299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user 1640299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then 1641299e6f19SPaolo Bonzini error_exit "--enable-vhost-net-user requires --enable-vhost-user" 1642299e6f19SPaolo Bonzinifi 1643299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user 1644299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then 1645299e6f19SPaolo Bonzini error_exit "--enable-vhost-crypto requires --enable-vhost-user" 1646299e6f19SPaolo Bonzinifi 164798fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user 164898fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then 164998fc1adaSDr. David Alan Gilbert error_exit "--enable-vhost-user-fs requires --enable-vhost-user" 165098fc1adaSDr. David Alan Gilbertfi 1651108a6481SCindy Lu#vhost-vdpa backends 1652108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa 1653108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then 1654108a6481SCindy Lu error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" 1655108a6481SCindy Lufi 1656299e6f19SPaolo Bonzini 165740bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity 1658299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then 1659299e6f19SPaolo Bonzini test "$vhost_net_user" = "yes" && vhost_net=yes 166040bc0ca9SLaurent Vivier test "$vhost_net_vdpa" = "yes" && vhost_net=yes 1661299e6f19SPaolo Bonzini test "$vhost_kernel" = "yes" && vhost_net=yes 1662299e6f19SPaolo Bonzinifi 1663299e6f19SPaolo Bonzini 1664015a33bdSGonglei########################################## 1665779ab5e3SStefan Weil# pkg-config probe 1666779ab5e3SStefan Weil 1667779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 166876ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1669779ab5e3SStefan Weilfi 1670779ab5e3SStefan Weil 1671779ab5e3SStefan Weil########################################## 1672e18df141SAnthony Liguori# glib support probe 1673a52d28afSPaolo Bonzini 1674b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 1675aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 1676aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 1677a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 1678b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 1679b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 168054cb65d8SEmilio G. Cotafi 1681e26110cfSFam Zheng 1682aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 1683e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 168489138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 168589138857SStefan Weil glib_libs=$($pkg_config --libs $i) 1686e18df141SAnthony Liguori else 1687e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 1688e26110cfSFam Zheng fi 1689e26110cfSFam Zhengdone 1690e26110cfSFam Zheng 1691215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 1692215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 1693215b0c2fSPaolo Bonzini 1694215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 1695215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 1696215b0c2fSPaolo Bonzinifi 1697215b0c2fSPaolo Bonzini 1698977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 1699977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 1700977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 1701977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 1702977a82abSDaniel P. Berrangecat > $TMPC <<EOF 1703977a82abSDaniel P. Berrange#include <glib.h> 1704977a82abSDaniel P. Berrange#include <unistd.h> 1705977a82abSDaniel P. Berrange 1706977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 1707977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 1708977a82abSDaniel P. Berrange 1709977a82abSDaniel P. Berrangeint main(void) { 1710977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 1711977a82abSDaniel P. Berrange return 0; 1712977a82abSDaniel P. Berrange} 1713977a82abSDaniel P. BerrangeEOF 1714977a82abSDaniel P. Berrange 1715215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 1716977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 1717977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 1718977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 1719977a82abSDaniel P. Berrange "build target" 1720977a82abSDaniel P. Berrangefi 1721977a82abSDaniel P. Berrange 17229bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 17239bda600bSEric Blakecat > $TMPC << EOF 17249bda600bSEric Blake#include <glib.h> 17259bda600bSEric Blaketypedef struct Foo { 17269bda600bSEric Blake int i; 17279bda600bSEric Blake} Foo; 17289bda600bSEric Blakestatic void foo_free(Foo *f) 17299bda600bSEric Blake{ 17309bda600bSEric Blake g_free(f); 17319bda600bSEric Blake} 1732e0e7fe07SMarc-André LureauG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free) 17339bda600bSEric Blakeint main(void) { return 0; } 17349bda600bSEric BlakeEOF 17359bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 17369bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 17379bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 17385770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 17399bda600bSEric Blake fi 17409bda600bSEric Blakefi 17419bda600bSEric Blake 1742e26110cfSFam Zheng########################################## 1743e26110cfSFam Zheng# SHA command probe for modules 1744e26110cfSFam Zhengif test "$modules" = yes; then 1745e26110cfSFam Zheng shacmd_probe="sha1sum sha1 shasum" 1746e26110cfSFam Zheng for c in $shacmd_probe; do 17478ccefb91SFam Zheng if has $c; then 1748e26110cfSFam Zheng shacmd="$c" 1749e26110cfSFam Zheng break 1750e26110cfSFam Zheng fi 1751e26110cfSFam Zheng done 1752e26110cfSFam Zheng if test "$shacmd" = ""; then 1753e26110cfSFam Zheng error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" 1754e26110cfSFam Zheng fi 1755e18df141SAnthony Liguorifi 1756e18df141SAnthony Liguori 1757e18df141SAnthony Liguori########################################## 1758f652e6afSaurel32# fdt probe 1759e169e1e1SPeter Maydell 1760fbb4121dSPaolo Bonzinicase "$fdt" in 1761fbb4121dSPaolo Bonzini auto | enabled | internal) 1762fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 1763aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 1764fbb4121dSPaolo Bonzini ;; 1765fbb4121dSPaolo Bonziniesac 1766f652e6afSaurel32 176720ff075bSMichael Walle########################################## 17688ca80760SRichard Henderson# capstone 17698ca80760SRichard Henderson 1770e219c499SRichard Hendersoncase "$capstone" in 17718b18cdbfSRichard Henderson auto | enabled | internal) 17728b18cdbfSRichard Henderson # Simpler to always update submodule, even if not needed. 1773e219c499SRichard Henderson git_submodules="${git_submodules} capstone" 1774e219c499SRichard Henderson ;; 1775e219c499SRichard Hendersonesac 17768ca80760SRichard Henderson 17778ca80760SRichard Henderson########################################## 1778519175a2SAlex Barcelo# check and set a backend for coroutine 1779d0e2fce5SAneesh Kumar K.V 17807c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 178133c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 178233c53c54SDaniel P. Berrange# specific one. 17837c2acc70SPeter Maydell 17847c2acc70SPeter Maydellucontext_works=no 1785d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 1786d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 1787d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 1788cdf84806SPeter Maydell#ifdef __stub_makecontext 1789cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 1790cdf84806SPeter Maydell#endif 179175cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 1792d0e2fce5SAneesh Kumar K.VEOF 1793d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 17947c2acc70SPeter Maydell ucontext_works=yes 1795d0e2fce5SAneesh Kumar K.V fi 1796519175a2SAlex Barcelofi 17977c2acc70SPeter Maydell 17987c2acc70SPeter Maydellif test "$coroutine" = ""; then 17997c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 18007c2acc70SPeter Maydell coroutine=win32 18017c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 18027c2acc70SPeter Maydell coroutine=ucontext 1803519175a2SAlex Barcelo else 18047c2acc70SPeter Maydell coroutine=sigaltstack 18057c2acc70SPeter Maydell fi 18067c2acc70SPeter Maydellelse 18077c2acc70SPeter Maydell case $coroutine in 18087c2acc70SPeter Maydell windows) 18097c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 18107c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 18117c2acc70SPeter Maydell fi 18127c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 18137c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 18147c2acc70SPeter Maydell coroutine=win32 18157c2acc70SPeter Maydell ;; 18167c2acc70SPeter Maydell ucontext) 18177c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 18187c2acc70SPeter Maydell feature_not_found "ucontext" 18197c2acc70SPeter Maydell fi 18207c2acc70SPeter Maydell ;; 182133c53c54SDaniel P. Berrange sigaltstack) 18227c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 18237c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 18247c2acc70SPeter Maydell fi 18257c2acc70SPeter Maydell ;; 18267c2acc70SPeter Maydell *) 182776ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 18287c2acc70SPeter Maydell ;; 18297c2acc70SPeter Maydell esac 1830d0e2fce5SAneesh Kumar K.Vfi 1831d0e2fce5SAneesh Kumar K.V 18321e4f6065SDaniele Buono################################################## 18331e4f6065SDaniele Buono# SafeStack 18341e4f6065SDaniele Buono 18351e4f6065SDaniele Buono 18361e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 18371e4f6065SDaniele Buonocat > $TMPC << EOF 18381e4f6065SDaniele Buonoint main(int argc, char *argv[]) 18391e4f6065SDaniele Buono{ 18401e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 18411e4f6065SDaniele Buono#error SafeStack Disabled 18421e4f6065SDaniele Buono#endif 18431e4f6065SDaniele Buono return 0; 18441e4f6065SDaniele Buono} 18451e4f6065SDaniele BuonoEOF 18461e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 18471e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 18481e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 18491e4f6065SDaniele Buono # Flag needed both at compilation and at linking 18501e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 18511e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 18521e4f6065SDaniele Buono else 18531e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 18541e4f6065SDaniele Buono fi 18551e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 18561e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 18571e4f6065SDaniele Buono fi 18581e4f6065SDaniele Buonoelse 18591e4f6065SDaniele Buonocat > $TMPC << EOF 18601e4f6065SDaniele Buonoint main(int argc, char *argv[]) 18611e4f6065SDaniele Buono{ 18621e4f6065SDaniele Buono#if defined(__has_feature) 18631e4f6065SDaniele Buono#if __has_feature(safe_stack) 18641e4f6065SDaniele Buono#error SafeStack Enabled 18651e4f6065SDaniele Buono#endif 18661e4f6065SDaniele Buono#endif 18671e4f6065SDaniele Buono return 0; 18681e4f6065SDaniele Buono} 18691e4f6065SDaniele BuonoEOF 18701e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 18711e4f6065SDaniele Buono # Make sure that safe-stack is disabled 18721e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 18731e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 18741e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 18751e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 18761e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 18771e4f6065SDaniele Buono fi 18781e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 18791e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 18801e4f6065SDaniele Buono fi 18811e4f6065SDaniele Buonoelse # "$safe_stack" = "" 18821e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 18831e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 18841e4f6065SDaniele Buono safe_stack="no" 18851e4f6065SDaniele Buono else 18861e4f6065SDaniele Buono safe_stack="yes" 18871e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 18881e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 18891e4f6065SDaniele Buono fi 18901e4f6065SDaniele Buono fi 18911e4f6065SDaniele Buonofi 18921e4f6065SDaniele Buonofi 18937d992e4dSPeter Lieven 189476a347e1SRichard Henderson######################################## 1895fd0e6053SJohn Snow# check if ccache is interfering with 1896fd0e6053SJohn Snow# semantic analysis of macros 1897fd0e6053SJohn Snow 18985e4dfd3dSJohn Snowunset CCACHE_CPP2 1899fd0e6053SJohn Snowccache_cpp2=no 1900fd0e6053SJohn Snowcat > $TMPC << EOF 1901fd0e6053SJohn Snowstatic const int Z = 1; 1902fd0e6053SJohn Snow#define fn() ({ Z; }) 1903fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 1904fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 1905fd0e6053SJohn Snow#define ID(X) (X) 1906fd0e6053SJohn Snowint main(int argc, char *argv[]) 1907fd0e6053SJohn Snow{ 1908fd0e6053SJohn Snow int x = 0, y = 0; 1909fd0e6053SJohn Snow x = ID(x); 1910fd0e6053SJohn Snow x = fn(); 1911fd0e6053SJohn Snow fn(); 1912fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 1913fd0e6053SJohn Snow if (TAUT(Z)) return 0; 1914fd0e6053SJohn Snow return 0; 1915fd0e6053SJohn Snow} 1916fd0e6053SJohn SnowEOF 1917fd0e6053SJohn Snow 1918fd0e6053SJohn Snowif ! compile_object "-Werror"; then 1919fd0e6053SJohn Snow ccache_cpp2=yes 1920fd0e6053SJohn Snowfi 1921fd0e6053SJohn Snow 1922b553a042SJohn Snow################################################# 1923b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 1924b553a042SJohn Snow 1925b553a042SJohn Snowif test "$fortify_source" != "no"; then 1926b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 1927b553a042SJohn Snow fortify_source="no"; 1928e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 1929cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 1930b553a042SJohn Snow fortify_source="no"; 1931b553a042SJohn Snow else 1932b553a042SJohn Snow fortify_source="yes" 1933b553a042SJohn Snow fi 1934b553a042SJohn Snowfi 1935b553a042SJohn Snow 1936d2042378SAneesh Kumar K.V########################################## 1937247724cbSMarc-André Lureau# checks for sanitizers 1938247724cbSMarc-André Lureau 1939247724cbSMarc-André Lureauhave_asan=no 1940247724cbSMarc-André Lureauhave_ubsan=no 1941d83414e1SMarc-André Lureauhave_asan_iface_h=no 1942d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 1943247724cbSMarc-André Lureau 1944247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 1945b9f44da2SMarc-André Lureau write_c_skeleton 1946247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 1947247724cbSMarc-André Lureau have_asan=yes 1948247724cbSMarc-André Lureau fi 1949b9f44da2SMarc-André Lureau 1950b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 1951b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 1952b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 1953b9f44da2SMarc-André Lureau cat > $TMPC << EOF 1954b9f44da2SMarc-André Lureau#include <stdlib.h> 1955b9f44da2SMarc-André Lureauint main(void) { 1956b9f44da2SMarc-André Lureau void *tmp = malloc(10); 1957f2dfe54cSLeonid Bloch if (tmp != NULL) { 1958b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 1959b9f44da2SMarc-André Lureau } 1960d1abf3fcSOlaf Hering return 1; 1961f2dfe54cSLeonid Bloch} 1962b9f44da2SMarc-André LureauEOF 1963247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 1964247724cbSMarc-André Lureau have_ubsan=yes 1965247724cbSMarc-André Lureau fi 1966d83414e1SMarc-André Lureau 1967d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 1968d83414e1SMarc-André Lureau have_asan_iface_h=yes 1969d83414e1SMarc-André Lureau fi 1970d83414e1SMarc-André Lureau 1971d83414e1SMarc-André Lureau cat > $TMPC << EOF 1972d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 1973d83414e1SMarc-André Lureauint main(void) { 1974d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 1975d83414e1SMarc-André Lureau return 0; 1976d83414e1SMarc-André Lureau} 1977d83414e1SMarc-André LureauEOF 1978d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 1979d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 1980d83414e1SMarc-André Lureau fi 1981247724cbSMarc-André Lureaufi 1982247724cbSMarc-André Lureau 19830aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 19840aebab04SLingfeng Yang# keep it separate until that is not the case. 19850aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 19860aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 19870aebab04SLingfeng Yangfi 19880aebab04SLingfeng Yanghave_tsan=no 19890aebab04SLingfeng Yanghave_tsan_iface_fiber=no 19900aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 19910aebab04SLingfeng Yang write_c_skeleton 19920aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 19930aebab04SLingfeng Yang have_tsan=yes 19940aebab04SLingfeng Yang fi 19950aebab04SLingfeng Yang cat > $TMPC << EOF 19960aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 19970aebab04SLingfeng Yangint main(void) { 19980aebab04SLingfeng Yang __tsan_create_fiber(0); 19990aebab04SLingfeng Yang return 0; 20000aebab04SLingfeng Yang} 20010aebab04SLingfeng YangEOF 20020aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 20030aebab04SLingfeng Yang have_tsan_iface_fiber=yes 20040aebab04SLingfeng Yang fi 20050aebab04SLingfeng Yangfi 20060aebab04SLingfeng Yang 2007adc28027SAlexander Bulekov########################################## 2008675b9b53SMarc-André Lureau# check for slirp 2009675b9b53SMarc-André Lureau 2010675b9b53SMarc-André Lureaucase "$slirp" in 20114d34a86bSPaolo Bonzini auto | enabled | internal) 20124d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 20137c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 2014675b9b53SMarc-André Lureau ;; 2015675b9b53SMarc-André Lureauesac 2016675b9b53SMarc-André Lureau 201754e7aac0SAlexey Krasikov########################################## 2018e86ecd4bSJuan Quintela# End of CC checks 2019e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 2020e86ecd4bSJuan Quintela 2021d83414e1SMarc-André Lureauwrite_c_skeleton 2022d83414e1SMarc-André Lureau 2023df42fa7dSPaolo Bonziniif test "$fortify_source" = "yes" ; then 2024086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 2025086d5f75SPaolo Bonzini debug=no 2026086d5f75SPaolo Bonzinifi 2027086d5f75SPaolo Bonzini 2028086d5f75SPaolo Bonzinicase "$ARCH" in 2029086d5f75SPaolo Bonzinialpha) 2030086d5f75SPaolo Bonzini # Ensure there's only a single GP 2031086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 2032086d5f75SPaolo Bonzini;; 2033086d5f75SPaolo Bonziniesac 2034086d5f75SPaolo Bonzini 2035247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 2036db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 2037db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 2038d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 2039d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 2040d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2041d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 2042d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 2043d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2044d83414e1SMarc-André Lureau fi 2045247724cbSMarc-André Lureaufi 20460aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 20470aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 20480aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 20490aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 20500aebab04SLingfeng Yang else 20510aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 20520aebab04SLingfeng Yang fi 20530aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 20540aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 20550aebab04SLingfeng Yangfi 2056247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 2057db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 2058db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 2059247724cbSMarc-André Lureaufi 2060247724cbSMarc-André Lureau 20616542aa9cSPeter Lieven########################################## 20623efac6ebSTomáš Golembiovský 20630aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 20640aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 2065e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 2066db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 2067e86ecd4bSJuan Quintela fi 2068e86ecd4bSJuan Quintelafi 2069e86ecd4bSJuan Quintela 2070b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 20719d6bc27bSMichael Roth 20729d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 20739d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 20749d6bc27bSMichael Rothfi 20759d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 20769d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 20779d6bc27bSMichael Rothfi 20789d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 207989138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 20809d6bc27bSMichael Rothfi 20819d6bc27bSMichael Roth 20826e444209SPaolo BonziniQEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 20839d6bc27bSMichael Roth 2084ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 2085ca35f780SPaolo Bonziniroms= 2086e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 2087ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 2088ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 2089e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 2090c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 2091c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 2092c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 2093e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 2094e57218b6SPeter Maydell ld_i386_emulation="$emu" 2095ca35f780SPaolo Bonzini roms="optionrom" 2096e57218b6SPeter Maydell break 2097e57218b6SPeter Maydell fi 2098e57218b6SPeter Maydell done 2099ca35f780SPaolo Bonzinifi 2100ca35f780SPaolo Bonzini 21012e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 2102a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 21039933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 21042e33c3f8SThomas Huth write_c_skeleton 2105a5b2afd5SThomas Huth compile_prog "-march=z900" "" 2106a5b2afd5SThomas Huth has_z900=$? 21073af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 2108a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 2109a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 2110a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 2111a5b2afd5SThomas Huth fi 21129933c305SChristian Borntraeger roms="$roms s390-ccw" 21131ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 21141ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 21151ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 21161ef6bfc2SPhilippe Mathieu-Daudé fi 21179933c305SChristian Borntraegerfi 21189933c305SChristian Borntraeger 211911cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 212011cde1c8SBruno 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. 212111cde1c8SBruno Dominguezif has $cxx; then 212211cde1c8SBruno Dominguez cat > $TMPC <<EOF 212311cde1c8SBruno Dominguezint c_function(void); 212411cde1c8SBruno Dominguezint main(void) { return c_function(); } 212511cde1c8SBruno DominguezEOF 212611cde1c8SBruno Dominguez 212711cde1c8SBruno Dominguez compile_object 212811cde1c8SBruno Dominguez 212911cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 213011cde1c8SBruno Dominguezextern "C" { 213111cde1c8SBruno Dominguez int c_function(void); 213211cde1c8SBruno Dominguez} 213311cde1c8SBruno Dominguezint c_function(void) { return 42; } 213411cde1c8SBruno DominguezEOF 213511cde1c8SBruno Dominguez 213611cde1c8SBruno Dominguez update_cxxflags 213711cde1c8SBruno Dominguez 2138a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 213911cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 214011cde1c8SBruno Dominguez : 214111cde1c8SBruno Dominguez else 214211cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 214311cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 214411cde1c8SBruno Dominguez cxx= 214511cde1c8SBruno Dominguez fi 214611cde1c8SBruno Dominguezelse 214711cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 214811cde1c8SBruno Dominguez cxx= 214911cde1c8SBruno Dominguezfi 215011cde1c8SBruno Dominguez 21517d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 21527d7dbf9dSDan Streetman exit 1 21535d91a2edSYonggang Luofi 21545d91a2edSYonggang Luo 215598ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 215697a847bcSbellard 215798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 215898ec69acSJuan Quintelaecho >> $config_host_mak 215998ec69acSJuan Quintela 2160e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 2161cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 2162aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 21637d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 2164804edf29SJuan Quintela 2165f8393946Saurel32if test "$debug_tcg" = "yes" ; then 21662358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 2167f8393946Saurel32fi 216867b915a5Sbellardif test "$mingw32" = "yes" ; then 216998ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 21706e444209SPaolo Bonzini echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak 21719dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 21729dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 21739dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 2174210fa556Spbrookelse 217535f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 2176210fa556Spbrookfi 2177128ab2ffSblueswir1 2178dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 2179dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 2180dffcb71cSMark McLoughlinfi 2181dffcb71cSMark McLoughlin 218283fb7adfSbellardif test "$darwin" = "yes" ; then 218398ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 218483fb7adfSbellardfi 2185b29fe3edSmalc 2186ec530c81Sbellardif test "$solaris" = "yes" ; then 218798ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 2188ec530c81Sbellardfi 218997a847bcSbellardif test "$static" = "yes" ; then 219098ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 219197a847bcSbellardfi 2192b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak 2193b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak 219489138857SStefan Weilqemu_version=$(head $source_path/VERSION) 21952358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak 219698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 21972b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 219817969268SFam Zhengif test "$modules" = "yes"; then 2199e26110cfSFam Zheng # $shacmd can generate a hash started with digit, which the compiler doesn't 2200e26110cfSFam Zheng # like as an symbol. So prefix it with an underscore 220189138857SStefan Weil echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak 220217969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 220317969268SFam Zhengfi 2204a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak 2205277abf15SJan Vesely 22065e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then 22075e9be92dSNicholas Bellinger echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 22085e9be92dSNicholas Bellingerfi 2209af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then 2210af3bba76SPaolo Bonzini echo "CONFIG_VHOST_NET=y" >> $config_host_mak 2211af3bba76SPaolo Bonzinifi 2212af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then 221356f41de7SPaolo Bonzini echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 221403ce5744SNikolay Nikolaevfi 2215108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then 2216108a6481SCindy Lu echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak 2217108a6481SCindy Lufi 2218042cea27SGongleiif test "$vhost_crypto" = "yes" ; then 2219042cea27SGonglei echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak 2220042cea27SGongleifi 2221fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then 2222fc0b9b0eSStefan Hajnoczi echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak 22235fe97d88SStefano Garzarella if test "$vhost_user" = "yes" ; then 22245fe97d88SStefano Garzarella echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak 22255fe97d88SStefano Garzarella fi 2226fc0b9b0eSStefan Hajnoczifi 2227299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then 2228299e6f19SPaolo Bonzini echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak 2229299e6f19SPaolo Bonzinifi 2230e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then 2231e6a74868SMarc-André Lureau echo "CONFIG_VHOST_USER=y" >> $config_host_mak 2232e6a74868SMarc-André Lureaufi 2233108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then 2234108a6481SCindy Lu echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak 2235108a6481SCindy Lufi 223698fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then 223798fc1adaSDr. David Alan Gilbert echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak 223898fc1adaSDr. David Alan Gilbertfi 223958d3f3ffSGerd Hoffmann 224083fb7adfSbellard# XXX: suppress that 22417d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 22422358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 22437d3505c5Sbellardfi 22447d3505c5Sbellard 22457c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 22467d992e4dSPeter Lieven 2247d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 2248d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 2249d83414e1SMarc-André Lureaufi 2250d83414e1SMarc-André Lureau 22510aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 22520aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 22530aebab04SLingfeng Yangfi 22540aebab04SLingfeng Yang 225540e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 225640e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 225740e8c6f4SAlex Bennéefi 225840e8c6f4SAlex Bennée 2259f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 2260b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 2261d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 2262f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 2263f48e590aSAlex Bennée fi 2264b1863cccSAlex Bennéefi 2265f48e590aSAlex Bennée 226698ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 2267804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 2268c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 226939d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 2270a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 227109e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 2272804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 2273804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 2274cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 22755f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 22763dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 2277804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 2278804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 227946eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak 2280a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 228111cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 22824cb37d11SPhilippe Mathieu-Daudéecho "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak 2283a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 2284a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 2285d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 22868a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 2287e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 2288a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 2289804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 2290804edf29SJuan Quintela 22916efd7517SPeter Maydell# use included Linux headers 22926efd7517SPeter Maydellif test "$linux" = "yes" ; then 2293a307beb6SAndreas Färber mkdir -p linux-headers 22946efd7517SPeter Maydell case "$cpu" in 22954da270beSPaolo Bonzini i386|x86_64) 229608312a63SPeter Maydell linux_arch=x86 22976efd7517SPeter Maydell ;; 2298d8ff892dSPaolo Bonzini ppc|ppc64) 229908312a63SPeter Maydell linux_arch=powerpc 23006efd7517SPeter Maydell ;; 23016efd7517SPeter Maydell s390x) 230208312a63SPeter Maydell linux_arch=s390 230308312a63SPeter Maydell ;; 23041f080313SClaudio Fontana aarch64) 23051f080313SClaudio Fontana linux_arch=arm64 23061f080313SClaudio Fontana ;; 2307dfcf900bSWANG Xuerui loongarch*) 2308dfcf900bSWANG Xuerui linux_arch=loongarch 2309dfcf900bSWANG Xuerui ;; 2310222e7d11SSanjay Lal mips64) 2311222e7d11SSanjay Lal linux_arch=mips 2312222e7d11SSanjay Lal ;; 231308312a63SPeter Maydell *) 231408312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 231508312a63SPeter Maydell linux_arch="$cpu" 23166efd7517SPeter Maydell ;; 23176efd7517SPeter Maydell esac 231808312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 231908312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 232008312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 232108312a63SPeter Maydell fi 23226efd7517SPeter Maydellfi 23236efd7517SPeter Maydell 232497a847bcSbellardfor target in $target_list; do 232597a847bcSbellard target_dir="$target" 232657a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 232797a847bcSbellard mkdir -p $target_dir 2328fdb75aefSPaolo Bonzini case $target in 2329fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 2330fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 23312408a527Saurel32 esac 233256aebc89Spbrookdone 23337d13299dSbellard 2334765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak 2335fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 2336fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 2337fdb75aefSPaolo Bonzinifi 2338a540f158SPeter Crosthwaite 2339fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 2340fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 2341fd0e6053SJohn Snowfi 2342fd0e6053SJohn Snow 23431e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 23441e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 23451e4f6065SDaniele Buonofi 23461e4f6065SDaniele Buono 2347e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 2348e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 2349e29e5c6eSPeter Maydell# (these can be both files and directories). 2350e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 2351e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 2352e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 2353e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 2354e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 2355e29e5c6eSPeter Maydell# directory and symlink the directory instead. 23562038f8c8SPaolo BonziniLINKS="Makefile" 23573941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 2358ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 2359e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 2360e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 2361bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 236239950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 23638f8fd9edSCleber RosaLINKS="$LINKS python" 2364c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 2365753d11f2SRichard Hendersonfor bios_file in \ 2366753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 23673a631b8eSBin Meng $source_path/pc-bios/*.elf \ 2368225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 2369753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 2370753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 2371e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 2372753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 23734e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 2374cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 2375cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 2376cd946e5cSJohn Arbuckle 2377753d11f2SRichard Hendersondo 2378e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 23797ea78b74SJan Kiszkadone 2380e29e5c6eSPeter Maydellfor f in $LINKS ; do 23810f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 23825dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 2383f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 2384f9245e10SPeter Maydell fi 23857d13299dSbellarddone 23861ad2134fSPaul Brook 23872038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 23882038f8c8SPaolo Bonzini export $i 23892038f8c8SPaolo Bonzinidone 2390544f4a25SPaolo Bonziniexport target_list source_path use_containers cpu host_cc 23912038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 23922038f8c8SPaolo Bonzini 239398409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 239498409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 239598409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 239698409991SHelge Konetzka 2397a5665051SPaolo Bonziniif test "$skip_meson" = no; then 2398fc929892SMarc-André Lureau cross="config-meson.cross.new" 2399fc929892SMarc-André Lureau meson_quote() { 2400ac7ebcc5SPaolo Bonzini test $# = 0 && return 240147b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 2402fc929892SMarc-André Lureau } 2403fc929892SMarc-André Lureau 2404fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 2405fc929892SMarc-André Lureau echo "[properties]" >> $cross 2406d1d5e9eeSAlex Bennée 2407d1d5e9eeSAlex Bennée # unroll any custom device configs 2408d1d5e9eeSAlex Bennée for a in $device_archs; do 2409d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 2410d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 2411d1d5e9eeSAlex Bennée done 2412d1d5e9eeSAlex Bennée 2413fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 241447b30835SPaolo Bonzini echo "[built-in options]" >> $cross 2415a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 2416a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 2417e910c7d9SPhilippe Mathieu-Daudé test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross 2418a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 2419a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 2420fc929892SMarc-André Lureau echo "[binaries]" >> $cross 24214dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 24224dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 24234dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 242447b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 242547b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 242647b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 242747b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 2428e8178514SPaolo Bonzini if has $sdl2_config; then 242947b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 2430e8178514SPaolo Bonzini fi 243147b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 2432158bb224SKonstantin Kostiuk echo "widl = [$(meson_quote $widl)]" >> $cross 243347b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 24343812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 2435fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 2436fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 2437ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 2438823eb013SPaolo Bonzini case "$cpu" in 2439f6bca9dfSJoelle van Dyne i386) 2440fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 2441fc929892SMarc-André Lureau ;; 2442fc929892SMarc-André Lureau *) 2443823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 2444fc929892SMarc-André Lureau ;; 2445fc929892SMarc-André Lureau esac 2446fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 2447fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 2448fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 2449fc929892SMarc-André Lureau else 2450fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 2451fc929892SMarc-André Lureau fi 2452fc929892SMarc-André Lureau else 2453fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 2454fc929892SMarc-André Lureau fi 2455fc929892SMarc-André Lureau mv $cross config-meson.cross 2456fc929892SMarc-André Lureau 2457a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 245861d63097SPaolo Bonzini run_meson() { 245909e93326SPaolo Bonzini NINJA=$ninja $meson setup \ 2460d17f305aSPaolo Bonzini --prefix "$prefix" \ 2461d17f305aSPaolo Bonzini --libdir "$libdir" \ 2462d17f305aSPaolo Bonzini --libexecdir "$libexecdir" \ 2463d17f305aSPaolo Bonzini --bindir "$bindir" \ 2464d17f305aSPaolo Bonzini --includedir "$includedir" \ 2465d17f305aSPaolo Bonzini --datadir "$datadir" \ 2466d17f305aSPaolo Bonzini --mandir "$mandir" \ 2467d17f305aSPaolo Bonzini --sysconfdir "$sysconfdir" \ 246816bf7a33SPaolo Bonzini --localedir "$localedir" \ 2469d17f305aSPaolo Bonzini --localstatedir "$local_statedir" \ 24703b4da132SPaolo Bonzini -Ddefault_devices=$default_devices \ 2471d17f305aSPaolo Bonzini -Ddocdir="$docdir" \ 247216bf7a33SPaolo Bonzini -Dqemu_firmwarepath="$firmwarepath" \ 247373f3aa37SMarc-André Lureau -Dqemu_suffix="$qemu_suffix" \ 247435acbb30SPaolo Bonzini -Dsmbd="$smbd" \ 2475a5665051SPaolo Bonzini -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ 2476a5665051SPaolo Bonzini -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ 2477a5665051SPaolo Bonzini -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ 2478da6d48b9SMarc-André Lureau -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ 2479bf0e56a3SMarc-André Lureau -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ 248014efd8d3SPaolo Bonzini -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg \ 24813b4da132SPaolo Bonzini -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ 2482537b7248SPaolo Bonzini $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ 2483332008e0SThomas Huth $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ 248461d63097SPaolo Bonzini "$@" $cross_arg "$PWD" "$source_path" 248561d63097SPaolo Bonzini } 248661d63097SPaolo Bonzini eval run_meson $meson_options 2487a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 2488a5665051SPaolo Bonzini error_exit "meson setup failed" 2489a5665051SPaolo Bonzini fi 2490699d3884SPaolo Bonzinielse 2491699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 2492699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 2493699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 2494699d3884SPaolo Bonzini perl -i -ne ' 2495699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 2496699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 2497654d6b04SPaolo Bonzini /^b_staticpic/ && next; 2498699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 2499699d3884SPaolo Bonzini fi 2500a5665051SPaolo Bonzinifi 2501a5665051SPaolo Bonzini 2502dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 2503dc655404SMichael S. Tsirkincat <<EOD >config.status 2504dc655404SMichael S. Tsirkin#!/bin/sh 2505dc655404SMichael S. Tsirkin# Generated by configure. 2506dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 2507dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 2508dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 2509dc655404SMichael S. TsirkinEOD 2510e811da7fSDaniel P. Berrangé 2511e811da7fSDaniel P. Berrangépreserve_env() { 2512e811da7fSDaniel P. Berrangé envname=$1 2513e811da7fSDaniel P. Berrangé 2514e811da7fSDaniel P. Berrangé eval envval=\$$envname 2515e811da7fSDaniel P. Berrangé 2516e811da7fSDaniel P. Berrangé if test -n "$envval" 2517e811da7fSDaniel P. Berrangé then 2518e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 2519e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 2520e811da7fSDaniel P. Berrangé else 2521e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 2522e811da7fSDaniel P. Berrangé fi 2523e811da7fSDaniel P. Berrangé} 2524e811da7fSDaniel P. Berrangé 2525e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 2526e811da7fSDaniel P. Berrangé# features/build target configure will detect 2527e811da7fSDaniel P. Berrangépreserve_env AR 2528e811da7fSDaniel P. Berrangépreserve_env AS 2529e811da7fSDaniel P. Berrangépreserve_env CC 2530e811da7fSDaniel P. Berrangépreserve_env CPP 25318009da03SPaolo Bonzinipreserve_env CFLAGS 2532e811da7fSDaniel P. Berrangépreserve_env CXX 25338009da03SPaolo Bonzinipreserve_env CXXFLAGS 2534e811da7fSDaniel P. Berrangépreserve_env INSTALL 2535e811da7fSDaniel P. Berrangépreserve_env LD 25368009da03SPaolo Bonzinipreserve_env LDFLAGS 2537e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 2538e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 2539e811da7fSDaniel P. Berrangépreserve_env MAKE 2540e811da7fSDaniel P. Berrangépreserve_env NM 2541e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 2542e811da7fSDaniel P. Berrangépreserve_env PATH 2543e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 2544e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 2545e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 2546e811da7fSDaniel P. Berrangépreserve_env PYTHON 2547e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 2548e811da7fSDaniel P. Berrangépreserve_env SMBD 2549e811da7fSDaniel P. Berrangépreserve_env STRIP 2550158bb224SKonstantin Kostiukpreserve_env WIDL 2551e811da7fSDaniel P. Berrangépreserve_env WINDRES 2552e811da7fSDaniel P. Berrangé 2553dc655404SMichael S. Tsirkinprintf "exec" >>config.status 2554a5665051SPaolo Bonzinifor i in "$0" "$@"; do 2555835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 2556a5665051SPaolo Bonzinidone 2557cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 2558dc655404SMichael S. Tsirkinchmod +x config.status 2559dc655404SMichael S. Tsirkin 25608cd05ab6SPeter Maydellrm -r "$TMPDIR1" 2561