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="" 23443ce4dfeSbellardstatic="no" 2353812c0c4SJoelle van Dynecross_compile="no" 2367d13299dSbellardcross_prefix="" 237e49d021eSPeter Maydellhost_cc="cc" 23863678e17SSteven Noonanstack_protector="" 2391e4f6065SDaniele Buonosafe_stack="" 240afc3a8f9SAlex Bennéeuse_containers="yes" 241f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 242ac0df51dSaliguori 24392712822SDaniel P. Berrangeif test -e "$source_path/.git" 24492712822SDaniel P. Berrangethen 2457d7dbf9dSDan Streetman git_submodules_action="update" 24692712822SDaniel P. Berrangeelse 2477d7dbf9dSDan Streetman git_submodules_action="ignore" 24892712822SDaniel P. Berrangefi 2492d652f24SPaolo Bonzini 2502d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb" 251cc84d63aSDaniel P. Berrangegit="git" 252ac0df51dSaliguori 253afb63ebdSStefan Weil# Don't accept a target_list environment variable. 254afb63ebdSStefan Weilunset target_list 255447e133fSAlex Bennéeunset target_list_exclude 256377529c0SPaolo Bonzini 257377529c0SPaolo Bonzini# Default value for a variable defining feature "foo". 258377529c0SPaolo Bonzini# * foo="no" feature will only be used if --enable-foo arg is given 259377529c0SPaolo Bonzini# * foo="" feature will be searched for, and if found, will be used 260377529c0SPaolo Bonzini# unless --disable-foo is given 261377529c0SPaolo Bonzini# * foo="yes" this value will only be set by --enable-foo flag. 262377529c0SPaolo Bonzini# feature will searched for, 263377529c0SPaolo Bonzini# if not found, configure exits with error 264377529c0SPaolo Bonzini# 265377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args. 266377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it 267377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found. 268377529c0SPaolo Bonzini 269c87ea116SAlex Bennéedefault_feature="" 270c87ea116SAlex Bennée# parse CC options second 271c87ea116SAlex Bennéefor opt do 272c87ea116SAlex Bennée optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 273c87ea116SAlex Bennée case "$opt" in 274c87ea116SAlex Bennée --without-default-features) 275c87ea116SAlex Bennée default_feature="no" 276c87ea116SAlex Bennée ;; 277c87ea116SAlex Bennée esac 278c87ea116SAlex Bennéedone 279c87ea116SAlex Bennée 280a2866660SPaolo BonziniEXTRA_CFLAGS="" 281a2866660SPaolo BonziniEXTRA_CXXFLAGS="" 282e910c7d9SPhilippe Mathieu-DaudéEXTRA_OBJCFLAGS="" 283a2866660SPaolo BonziniEXTRA_LDFLAGS="" 284a2866660SPaolo Bonzini 2850848f8acSThomas Huthvhost_kernel="$default_feature" 286c87ea116SAlex Bennéevhost_net="$default_feature" 287c87ea116SAlex Bennéevhost_crypto="$default_feature" 288c87ea116SAlex Bennéevhost_scsi="$default_feature" 289c87ea116SAlex Bennéevhost_vsock="$default_feature" 290d88618f7SStefan Hajnoczivhost_user="no" 291c87ea116SAlex Bennéevhost_user_fs="$default_feature" 2920848f8acSThomas Huthvhost_vdpa="$default_feature" 293377529c0SPaolo Bonzinidebug_tcg="no" 294247724cbSMarc-André Lureausanitizers="no" 2950aebab04SLingfeng Yangtsan="no" 2961f3f2bfeSMichael Tokarevfortify_source="yes" 297c7328271SMiroslav RezaninaEXESUF="" 29817969268SFam Zhengmodules="no" 299377529c0SPaolo Bonziniprefix="/usr/local" 30010ff82d1SMarc-André Lureauqemu_suffix="qemu" 301377529c0SPaolo Bonzinisoftmmu="yes" 302b915a2f1SPaolo Bonzinilinux_user="" 303b915a2f1SPaolo Bonzinibsd_user="" 30440d6444eSAvi Kivitypie="" 305519175a2SAlex Barcelocoroutine="" 306ba4dd2aaSAlex Bennéeplugins="$default_feature" 307a5665051SPaolo Bonzinimeson="" 3083b4da132SPaolo Bonzinimeson_args="" 30948328880SPaolo Bonzinininja="" 310c09c1ce7SPaolo Bonzinibindir="bin" 311a5665051SPaolo Bonziniskip_meson=no 312377529c0SPaolo Bonzini 3133b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 3143b4da132SPaolo Bonzini# are included in the automatically generated help message) 3153b4da132SPaolo Bonzini 3163b4da132SPaolo Bonzini# 1. Track which submodules are needed 3170577e84dSThomas Huthif test "$default_feature" = no ; then 3180577e84dSThomas Huth capstone="disabled" 3190577e84dSThomas Huth slirp="disabled" 3200577e84dSThomas Huthelse 3213b4da132SPaolo Bonzini capstone="auto" 3223b4da132SPaolo Bonzini slirp="auto" 3230577e84dSThomas Huthfi 3240577e84dSThomas Huthfdt="auto" 3253b4da132SPaolo Bonzini 326*c54b59eeSPaolo Bonzini# 2. Automatically enable/disable other options 3273b4da132SPaolo Bonzinitcg="enabled" 3283b4da132SPaolo Bonzinicfi="false" 3293b4da132SPaolo Bonzini 330c87ea116SAlex Bennée# parse CC options second 331ac0df51dSaliguorifor opt do 33289138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 333ac0df51dSaliguori case "$opt" in 334ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3353812c0c4SJoelle van Dyne cross_compile="yes" 336ac0df51dSaliguori ;; 3373d8df640SPaolo Bonzini --cc=*) CC="$optarg" 338ac0df51dSaliguori ;; 33983f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 34083f73fceSTomoki Sekiyama ;; 3412ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3422ff6b91eSJuan Quintela ;; 343a2866660SPaolo Bonzini --extra-cflags=*) 344a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 345a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 346e910c7d9SPhilippe Mathieu-Daudé EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 347e2a2ed06SJuan Quintela ;; 348a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 34911cde1c8SBruno Dominguez ;; 350e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 351e910c7d9SPhilippe Mathieu-Daudé ;; 352a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 353e2a2ed06SJuan Quintela ;; 354d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 355d75402b5SAlex Bennée ;; 356479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 357d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 3582038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 359d422b2bcSAlex Bennée ;; 360d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 361d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 3622038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 363d75402b5SAlex Bennée ;; 364ac0df51dSaliguori esac 365ac0df51dSaliguoridone 366ac0df51dSaliguori# OS specific 367ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 36893148aa5SStefan Weil# we can eliminate its usage altogether. 369ac0df51dSaliguori 370e49d021eSPeter Maydell# Preferred compiler: 371e49d021eSPeter Maydell# ${CC} (if set) 372e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 373e49d021eSPeter Maydell# system compiler 374e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 375e49d021eSPeter Maydell cc="$host_cc" 376e49d021eSPeter Maydellelse 377b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 378e49d021eSPeter Maydellfi 379e49d021eSPeter Maydell 38083f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 38183f73fceSTomoki Sekiyama cxx="c++" 38283f73fceSTomoki Sekiyamaelse 38383f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 38483f73fceSTomoki Sekiyamafi 38583f73fceSTomoki Sekiyama 386b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 387cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 3885f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 3893dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 390b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 391b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 3929f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 3934852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 39435acbb30SPaolo Bonzinismbd="$SMBD" 395b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 396158bb224SKonstantin Kostiukwidl="${WIDL-${cross_prefix}widl}" 397b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 39817884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 39917884d7bSSergei Trofimovichquery_pkg_config() { 40017884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 40117884d7bSSergei Trofimovich} 40217884d7bSSergei Trofimovichpkg_config=query_pkg_config 40347c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 404ac0df51dSaliguori 405be17dc90SMichael S. Tsirkin# default flags for all hosts 4062d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 4072d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 4082d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 4092d31515bSPeter Maydell# provides these semantics.) 410de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 411086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 412c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 413be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4145770e8afSPaolo Bonzini 415de38c0ccSPaolo BonziniQEMU_LDFLAGS= 416de38c0ccSPaolo Bonzini 4175770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4188a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4195770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 420086d5f75SPaolo Bonzini 421be17dc90SMichael S. Tsirkin 422ac0df51dSaliguoricheck_define() { 423ac0df51dSaliguoricat > $TMPC <<EOF 424ac0df51dSaliguori#if !defined($1) 425fd786e1aSPeter Maydell#error $1 not defined 426ac0df51dSaliguori#endif 427ac0df51dSaliguoriint main(void) { return 0; } 428ac0df51dSaliguoriEOF 42952166aa0SJuan Quintela compile_object 430ac0df51dSaliguori} 431ac0df51dSaliguori 432307119e7SGerd Hoffmanncheck_include() { 433307119e7SGerd Hoffmanncat > $TMPC <<EOF 434307119e7SGerd Hoffmann#include <$1> 435307119e7SGerd Hoffmannint main(void) { return 0; } 436307119e7SGerd HoffmannEOF 437307119e7SGerd Hoffmann compile_object 438307119e7SGerd Hoffmann} 439307119e7SGerd Hoffmann 44093b25869SJohn Snowwrite_c_skeleton() { 44193b25869SJohn Snow cat > $TMPC <<EOF 44293b25869SJohn Snowint main(void) { return 0; } 44393b25869SJohn SnowEOF 44493b25869SJohn Snow} 44593b25869SJohn Snow 446bbea4050SPeter Maydellif check_define __linux__ ; then 447ba7c60c2SPaolo Bonzini targetos=linux 448bbea4050SPeter Maydellelif check_define _WIN32 ; then 449ba7c60c2SPaolo Bonzini targetos=windows 450bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 451ba7c60c2SPaolo Bonzini targetos=openbsd 452bbea4050SPeter Maydellelif check_define __sun__ ; then 453ba7c60c2SPaolo Bonzini targetos=sunos 454bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 455ba7c60c2SPaolo Bonzini targetos=haiku 456951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 457ba7c60c2SPaolo Bonzini targetos=freebsd 458951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 459ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 460951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 461ba7c60c2SPaolo Bonzini targetos=dragonfly 462951fedfcSPeter Maydellelif check_define __NetBSD__; then 463ba7c60c2SPaolo Bonzini targetos=netbsd 464951fedfcSPeter Maydellelif check_define __APPLE__; then 465ba7c60c2SPaolo Bonzini targetos=darwin 466bbea4050SPeter Maydellelse 467951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 468951fedfcSPeter Maydell # might be going to just print the --help text, or it might 469951fedfcSPeter Maydell # be the result of a missing compiler. 470ba7c60c2SPaolo Bonzini targetos=bogus 471bbea4050SPeter Maydellfi 472bbea4050SPeter Maydell 47365eff01bSPaolo Bonzini# OS specific 47465eff01bSPaolo Bonzini 4753b0d8643SPaolo Bonzinimingw32="no" 4763b0d8643SPaolo Bonzinibsd="no" 4773b0d8643SPaolo Bonzinilinux="no" 4783b0d8643SPaolo Bonzinisolaris="no" 47965eff01bSPaolo Bonzinicase $targetos in 48065eff01bSPaolo Bonziniwindows) 48165eff01bSPaolo Bonzini mingw32="yes" 48265eff01bSPaolo Bonzini plugins="no" 48365eff01bSPaolo Bonzini pie="no" 48465eff01bSPaolo Bonzini;; 48565eff01bSPaolo Bonzinignu/kfreebsd) 48665eff01bSPaolo Bonzini bsd="yes" 48765eff01bSPaolo Bonzini;; 48865eff01bSPaolo Bonzinifreebsd) 48965eff01bSPaolo Bonzini bsd="yes" 49065eff01bSPaolo Bonzini make="${MAKE-gmake}" 49165eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 49265eff01bSPaolo Bonzini;; 49365eff01bSPaolo Bonzinidragonfly) 49465eff01bSPaolo Bonzini bsd="yes" 49565eff01bSPaolo Bonzini make="${MAKE-gmake}" 49665eff01bSPaolo Bonzini;; 49765eff01bSPaolo Bonzininetbsd) 49865eff01bSPaolo Bonzini bsd="yes" 49965eff01bSPaolo Bonzini make="${MAKE-gmake}" 50065eff01bSPaolo Bonzini;; 50165eff01bSPaolo Bonziniopenbsd) 50265eff01bSPaolo Bonzini bsd="yes" 50365eff01bSPaolo Bonzini make="${MAKE-gmake}" 50465eff01bSPaolo Bonzini;; 50565eff01bSPaolo Bonzinidarwin) 50665eff01bSPaolo Bonzini bsd="yes" 50765eff01bSPaolo Bonzini darwin="yes" 50865eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 50965eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 51065eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 51165eff01bSPaolo Bonzini;; 51265eff01bSPaolo Bonzinisunos) 51365eff01bSPaolo Bonzini solaris="yes" 51465eff01bSPaolo Bonzini make="${MAKE-gmake}" 51565eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 51665eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 51765eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 51865eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 51965eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 52065eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 521bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 522bbea4050SPeter Maydell # the correct CPU with the --cpu option. 523bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 524bbea4050SPeter Maydell cpu="x86_64" 525bbea4050SPeter Maydell fi 52665eff01bSPaolo Bonzini;; 52765eff01bSPaolo Bonzinihaiku) 52865eff01bSPaolo Bonzini pie="no" 52965eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 53065eff01bSPaolo Bonzini;; 53165eff01bSPaolo Bonzinilinux) 53265eff01bSPaolo Bonzini linux="yes" 53365eff01bSPaolo Bonzini vhost_user=${default_feature:-yes} 53465eff01bSPaolo Bonzini;; 535bbea4050SPeter Maydellesac 536bbea4050SPeter Maydell 5372ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5382ff6b91eSJuan Quintela # command line argument 5392ff6b91eSJuan Quintela : 5402ff6b91eSJuan Quintelaelif check_define __i386__ ; then 541ac0df51dSaliguori cpu="i386" 542ac0df51dSaliguorielif check_define __x86_64__ ; then 543c72b26ecSRichard Henderson if check_define __ILP32__ ; then 544c72b26ecSRichard Henderson cpu="x32" 545c72b26ecSRichard Henderson else 546ac0df51dSaliguori cpu="x86_64" 547c72b26ecSRichard Henderson fi 5483aa9bd6cSblueswir1elif check_define __sparc__ ; then 5493aa9bd6cSblueswir1 if check_define __arch64__ ; then 5503aa9bd6cSblueswir1 cpu="sparc64" 5513aa9bd6cSblueswir1 else 5523aa9bd6cSblueswir1 cpu="sparc" 5533aa9bd6cSblueswir1 fi 554fdf7ed96Smalcelif check_define _ARCH_PPC ; then 555fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 556f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 557f8378accSRichard Henderson cpu="ppc64le" 558f8378accSRichard Henderson else 559fdf7ed96Smalc cpu="ppc64" 560f8378accSRichard Henderson fi 561ac0df51dSaliguori else 562fdf7ed96Smalc cpu="ppc" 563fdf7ed96Smalc fi 564afa05235SAurelien Jarnoelif check_define __mips__ ; then 565afa05235SAurelien Jarno cpu="mips" 566d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 567d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 568d66ed0eaSAurelien Jarno cpu="s390x" 569d66ed0eaSAurelien Jarno else 570d66ed0eaSAurelien Jarno cpu="s390" 571d66ed0eaSAurelien Jarno fi 572c4f80543SAlistair Franciselif check_define __riscv ; then 573ba0e7333SRichard Henderson cpu="riscv" 57421d89f84SPeter Maydellelif check_define __arm__ ; then 57521d89f84SPeter Maydell cpu="arm" 5761f080313SClaudio Fontanaelif check_define __aarch64__ ; then 5771f080313SClaudio Fontana cpu="aarch64" 578dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 579dfcf900bSWANG Xuerui cpu="loongarch64" 580fdf7ed96Smalcelse 58189138857SStefan Weil cpu=$(uname -m) 582ac0df51dSaliguorifi 583ac0df51dSaliguori 584823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 585359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 5867d13299dSbellardcase "$cpu" in 587e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 588e4da0e39SPaolo Bonzini cpu="arm" ;; 589e4da0e39SPaolo Bonzini 5907d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 59197a847bcSbellard cpu="i386" 592e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 593e4da0e39SPaolo Bonzini x32) 5944da270beSPaolo Bonzini cpu="x86_64" 595e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 596aaa5fa14Saurel32 x86_64|amd64) 597aaa5fa14Saurel32 cpu="x86_64" 598e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 599e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 600e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 601e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 602e4da0e39SPaolo Bonzini 603afa05235SAurelien Jarno mips*) 604e4da0e39SPaolo Bonzini cpu="mips" ;; 605e4da0e39SPaolo Bonzini 606e4da0e39SPaolo Bonzini ppc) 607e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 608e4da0e39SPaolo Bonzini ppc64) 609ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mbig-endian" ;; 610e4da0e39SPaolo Bonzini ppc64le) 611d8ff892dSPaolo Bonzini cpu="ppc64" 612ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mlittle-endian" ;; 613e4da0e39SPaolo Bonzini 614e4da0e39SPaolo Bonzini s390) 615823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 616e4da0e39SPaolo Bonzini s390x) 617e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 618e4da0e39SPaolo Bonzini 6193142255cSblueswir1 sparc|sun4[cdmuv]) 620ae228531Sbellard cpu="sparc" 621e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 622e4da0e39SPaolo Bonzini sparc64) 623e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6247d13299dSbellardesac 625e2d52ad3SJuan Quintela 6260db4a067SPaolo Bonzini: ${make=${MAKE-make}} 627b6daf4d3SPaolo Bonzini 628faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 629faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 630ddf90699SEduardo Habkost# we check that too 631faf44142SDaniel P. Berrangépython= 6320a01d76fSMarc-André Lureauexplicit_python=no 633ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 634faf44142SDaniel P. Berrangédo 635faf44142SDaniel P. Berrangé if has "$binary" 636faf44142SDaniel P. Berrangé then 63795c5f2deSPaolo Bonzini python=$(command -v "$binary") 638faf44142SDaniel P. Berrangé break 639faf44142SDaniel P. Berrangé fi 640faf44142SDaniel P. Berrangédone 641903458c8SMarkus Armbruster 642903458c8SMarkus Armbruster 64339d87c8cSAlex Bennée# Check for ancillary tools used in testing 64439d87c8cSAlex Bennéegenisoimage= 6453df437c7SAlex Bennéefor binary in genisoimage mkisofs 64639d87c8cSAlex Bennéedo 64739d87c8cSAlex Bennée if has $binary 64839d87c8cSAlex Bennée then 64939d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 65039d87c8cSAlex Bennée break 65139d87c8cSAlex Bennée fi 65239d87c8cSAlex Bennéedone 65339d87c8cSAlex Bennée 6543c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6553c4a4d0dSPeter Maydellif has clang; then 6563c4a4d0dSPeter Maydell objcc=clang 6573c4a4d0dSPeter Maydellelse 6583c4a4d0dSPeter Maydell objcc="$cc" 6593c4a4d0dSPeter Maydellfi 6603c4a4d0dSPeter Maydell 6613457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6623457a3f8SJuan Quintela EXESUF=".exe" 66378e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6645770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 66593b25869SJohn Snow write_c_skeleton; 666d17f305aSPaolo Bonzini prefix="/qemu" 667c09c1ce7SPaolo Bonzini bindir="" 66877433a5fSMarc-André Lureau qemu_suffix="" 6693457a3f8SJuan Quintelafi 6703457a3f8SJuan Quintela 671487fefdbSAnthony Liguoriwerror="" 67285aa5189Sbellard 67361d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 67461d63097SPaolo Bonzini 67561d63097SPaolo Bonzinimeson_options= 676*c54b59eeSPaolo Bonzinimeson_option_add() { 677*c54b59eeSPaolo Bonzini meson_options="$meson_options $(quote_sh "$1")" 678*c54b59eeSPaolo Bonzini} 67961d63097SPaolo Bonzinimeson_option_parse() { 68061d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 68161d63097SPaolo Bonzini if test $? -eq 1; then 68261d63097SPaolo Bonzini echo "ERROR: unknown option $1" 68361d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 68461d63097SPaolo Bonzini exit 1 68561d63097SPaolo Bonzini fi 68661d63097SPaolo Bonzini} 68761d63097SPaolo Bonzini 6887d13299dSbellardfor opt do 68989138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 6907d13299dSbellard case "$opt" in 6912efc3265Sbellard --help|-h) show_help=yes 6922efc3265Sbellard ;; 69399123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 69499123e13SMike Frysinger ;; 695b1a550a0Spbrook --prefix=*) prefix="$optarg" 6967d13299dSbellard ;; 697ac0df51dSaliguori --cross-prefix=*) 6987d13299dSbellard ;; 699ac0df51dSaliguori --cc=*) 7007d13299dSbellard ;; 701b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 70283469015Sbellard ;; 70383f73fceSTomoki Sekiyama --cxx=*) 70483f73fceSTomoki Sekiyama ;; 7053c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 7063c4a4d0dSPeter Maydell ;; 707b1a550a0Spbrook --make=*) make="$optarg" 7087d13299dSbellard ;; 709b6daf4d3SPaolo Bonzini --install=*) 7106a882643Spbrook ;; 7110a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 712c886edfbSBlue Swirl ;; 713a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 714a5665051SPaolo Bonzini ;; 715a5665051SPaolo Bonzini --meson=*) meson="$optarg" 716a5665051SPaolo Bonzini ;; 71748328880SPaolo Bonzini --ninja=*) ninja="$optarg" 71848328880SPaolo Bonzini ;; 719e2d8830eSBrad --smbd=*) smbd="$optarg" 720e2d8830eSBrad ;; 721e2a2ed06SJuan Quintela --extra-cflags=*) 7227d13299dSbellard ;; 72311cde1c8SBruno Dominguez --extra-cxxflags=*) 72411cde1c8SBruno Dominguez ;; 725e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) 726e910c7d9SPhilippe Mathieu-Daudé ;; 727e2a2ed06SJuan Quintela --extra-ldflags=*) 7287d13299dSbellard ;; 729d75402b5SAlex Bennée --cross-cc-*) 730d75402b5SAlex Bennée ;; 731*c54b59eeSPaolo Bonzini --enable-debug-info) meson_option_add -Ddebug=true 73228609749SPaolo Bonzini ;; 733*c54b59eeSPaolo Bonzini --disable-debug-info) meson_option_add -Ddebug=false 73428609749SPaolo Bonzini ;; 73517969268SFam Zheng --enable-modules) 73617969268SFam Zheng modules="yes" 73717969268SFam Zheng ;; 7383aa88b31SStefan Hajnoczi --disable-modules) 7393aa88b31SStefan Hajnoczi modules="no" 7403aa88b31SStefan Hajnoczi ;; 7412ff6b91eSJuan Quintela --cpu=*) 7427d13299dSbellard ;; 743b1a550a0Spbrook --target-list=*) target_list="$optarg" 744447e133fSAlex Bennée if test "$target_list_exclude"; then 745447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 746447e133fSAlex Bennée fi 747447e133fSAlex Bennée ;; 748447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 749447e133fSAlex Bennée if test "$target_list"; then 750447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 751447e133fSAlex Bennée fi 752de83cd02Sbellard ;; 753*c54b59eeSPaolo Bonzini --with-default-devices) meson_option_add -Ddefault_devices=true 754f3494749SPaolo Bonzini ;; 755*c54b59eeSPaolo Bonzini --without-default-devices) meson_option_add -Ddefault_devices=false 756f3494749SPaolo Bonzini ;; 757d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 758d1d5e9eeSAlex Bennée ;; 759d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 760d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 761d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 762d1d5e9eeSAlex Bennée if test -f "$cf"; then 763d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 764d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 765d1d5e9eeSAlex Bennée else 766d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 767d1d5e9eeSAlex Bennée fi 768d1d5e9eeSAlex Bennée ;; 769c87ea116SAlex Bennée --without-default-features) # processed above 770c87ea116SAlex Bennée ;; 77179427693SLoïc Minier --static) 77279427693SLoïc Minier static="yes" 77317884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 77443ce4dfeSbellard ;; 7750b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 7760b24e75fSPaolo Bonzini ;; 77777433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 778023d3d67SEduardo Habkost ;; 779181ce1d0SOlaf Hering --host=*|--build=*|\ 780181ce1d0SOlaf Hering --disable-dependency-tracking|\ 781785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 782fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 783023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 784023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 785023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 786023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 787023ddd74SMax Filippov # lots of directory switches by default. 788023ddd74SMax Filippov ;; 789f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 790f8393946Saurel32 ;; 791f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 792f8393946Saurel32 ;; 793f3d08ee6SPaul Brook --enable-debug) 794f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 795f3d08ee6SPaul Brook debug_tcg="yes" 796c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 797*c54b59eeSPaolo Bonzini meson_option_add -Doptimization=0 798b553a042SJohn Snow fortify_source="no" 799f3d08ee6SPaul Brook ;; 800247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 801247724cbSMarc-André Lureau ;; 802247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 803247724cbSMarc-André Lureau ;; 8040aebab04SLingfeng Yang --enable-tsan) tsan="yes" 8050aebab04SLingfeng Yang ;; 8060aebab04SLingfeng Yang --disable-tsan) tsan="no" 8070aebab04SLingfeng Yang ;; 8084d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 809c20709aaSbellard ;; 810fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 811fd6fc214SPaolo Bonzini ;; 8124d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 8137c57bdd8SMarc-André Lureau ;; 81403a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 815675b9b53SMarc-André Lureau ;; 8161badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 817d1a14257SAlex Bennée plugins="no" 818b3f6ea7eSPaolo Bonzini ;; 8191badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 820b3f6ea7eSPaolo Bonzini ;; 821cad25d69Spbrook --disable-system) softmmu="no" 8220a8e90f4Spbrook ;; 823cad25d69Spbrook --enable-system) softmmu="yes" 8240a8e90f4Spbrook ;; 8250953a80fSZachary Amsden --disable-user) 8260953a80fSZachary Amsden linux_user="no" ; 8270953a80fSZachary Amsden bsd_user="no" ; 8280953a80fSZachary Amsden ;; 8290953a80fSZachary Amsden --enable-user) ;; 830831b7825Sths --disable-linux-user) linux_user="no" 8310a8e90f4Spbrook ;; 832831b7825Sths --enable-linux-user) linux_user="yes" 833831b7825Sths ;; 83484778508Sblueswir1 --disable-bsd-user) bsd_user="no" 83584778508Sblueswir1 ;; 83684778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 83784778508Sblueswir1 ;; 83840d6444eSAvi Kivity --enable-pie) pie="yes" 83934005a00SKirill A. Shutemov ;; 84040d6444eSAvi Kivity --disable-pie) pie="no" 84134005a00SKirill A. Shutemov ;; 84285aa5189Sbellard --enable-werror) werror="yes" 84385aa5189Sbellard ;; 84485aa5189Sbellard --disable-werror) werror="no" 84585aa5189Sbellard ;; 84663678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 84763678e17SSteven Noonan ;; 84863678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 84963678e17SSteven Noonan ;; 8501e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 8511e4f6065SDaniele Buono ;; 8521e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 8531e4f6065SDaniele Buono ;; 8549e62ba48SDaniele Buono --enable-cfi) 8559e62ba48SDaniele Buono cfi="true"; 856*c54b59eeSPaolo Bonzini meson_option_add -Db_lto=true 8579e62ba48SDaniele Buono ;; 8589e62ba48SDaniele Buono --disable-cfi) cfi="false" 8599e62ba48SDaniele Buono ;; 860fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 8612df87df7SJuan Quintela ;; 862fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 863fbb4121dSPaolo Bonzini ;; 864fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 865fbb4121dSPaolo Bonzini ;; 86603a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 8672df87df7SJuan Quintela ;; 868519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 869519175a2SAlex Barcelo ;; 870d5970055SMichael S. Tsirkin --disable-vhost-net) vhost_net="no" 871d5970055SMichael S. Tsirkin ;; 872d5970055SMichael S. Tsirkin --enable-vhost-net) vhost_net="yes" 873d5970055SMichael S. Tsirkin ;; 874042cea27SGonglei --disable-vhost-crypto) vhost_crypto="no" 875042cea27SGonglei ;; 876299e6f19SPaolo Bonzini --enable-vhost-crypto) vhost_crypto="yes" 877042cea27SGonglei ;; 8785e9be92dSNicholas Bellinger --disable-vhost-scsi) vhost_scsi="no" 8795e9be92dSNicholas Bellinger ;; 8805e9be92dSNicholas Bellinger --enable-vhost-scsi) vhost_scsi="yes" 8815e9be92dSNicholas Bellinger ;; 882fc0b9b0eSStefan Hajnoczi --disable-vhost-vsock) vhost_vsock="no" 883fc0b9b0eSStefan Hajnoczi ;; 884fc0b9b0eSStefan Hajnoczi --enable-vhost-vsock) vhost_vsock="yes" 885fc0b9b0eSStefan Hajnoczi ;; 88698fc1adaSDr. David Alan Gilbert --disable-vhost-user-fs) vhost_user_fs="no" 88798fc1adaSDr. David Alan Gilbert ;; 88898fc1adaSDr. David Alan Gilbert --enable-vhost-user-fs) vhost_user_fs="yes" 88998fc1adaSDr. David Alan Gilbert ;; 8901ffb3bbbSPaolo Bonzini --disable-zlib-test) 8911ece9905SAlon Levy ;; 89252b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 89352b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 894583f6e7bSStefan Hajnoczi ;; 895cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 896cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 897cb6414dfSFam Zheng ;; 898315d3184SFam Zheng --enable-uuid|--disable-uuid) 899315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 900315d3184SFam Zheng ;; 901e6a74868SMarc-André Lureau --disable-vhost-user) vhost_user="no" 902e6a74868SMarc-André Lureau ;; 903299e6f19SPaolo Bonzini --enable-vhost-user) vhost_user="yes" 904299e6f19SPaolo Bonzini ;; 905108a6481SCindy Lu --disable-vhost-vdpa) vhost_vdpa="no" 906108a6481SCindy Lu ;; 907108a6481SCindy Lu --enable-vhost-vdpa) vhost_vdpa="yes" 908108a6481SCindy Lu ;; 909299e6f19SPaolo Bonzini --disable-vhost-kernel) vhost_kernel="no" 910299e6f19SPaolo Bonzini ;; 911299e6f19SPaolo Bonzini --enable-vhost-kernel) vhost_kernel="yes" 912e6a74868SMarc-André Lureau ;; 9138b18cdbfSRichard Henderson --disable-capstone) capstone="disabled" 9148ca80760SRichard Henderson ;; 9158b18cdbfSRichard Henderson --enable-capstone) capstone="enabled" 9168ca80760SRichard Henderson ;; 9178b18cdbfSRichard Henderson --enable-capstone=git) capstone="internal" 918e219c499SRichard Henderson ;; 91903a3c0b3SPaolo Bonzini --enable-capstone=*) capstone="$optarg" 920e219c499SRichard Henderson ;; 921cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 922cc84d63aSDaniel P. Berrange ;; 9237d7dbf9dSDan Streetman --with-git-submodules=*) 9247d7dbf9dSDan Streetman git_submodules_action="$optarg" 925f62bbee5SDaniel P. Berrange ;; 9269b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 9279b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 9289b8e4298SAlex Bennée else 9299b8e4298SAlex Bennée plugins="yes" 9309b8e4298SAlex Bennée fi 93140e8c6f4SAlex Bennée ;; 93240e8c6f4SAlex Bennée --disable-plugins) plugins="no" 93340e8c6f4SAlex Bennée ;; 934afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 935afc3a8f9SAlex Bennée ;; 936afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 937afc3a8f9SAlex Bennée ;; 938f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 939f48e590aSAlex Bennée ;; 9403b4da132SPaolo Bonzini # backwards compatibility options 9413b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 9423b4da132SPaolo Bonzini ;; 9433b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 9443b4da132SPaolo Bonzini ;; 9453b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 9463b4da132SPaolo Bonzini ;; 9473b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 9483b4da132SPaolo Bonzini ;; 9493b4da132SPaolo Bonzini # everything else has the same name in configure and meson 9504fda6011SPaolo Bonzini --*) meson_option_parse "$opt" "$optarg" 9517f1559c6Sbalrog ;; 9527d13299dSbellard esac 9537d13299dSbellarddone 9547d13299dSbellard 955d1a14257SAlex Bennée# test for any invalid configuration combinations 956d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 957d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 958d1a14257SAlex Bennéefi 959d1a14257SAlex Bennée 9607d7dbf9dSDan Streetmancase $git_submodules_action in 9617d7dbf9dSDan Streetman update|validate) 9627d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 9637d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 9647d7dbf9dSDan Streetman exit 1 9657d7dbf9dSDan Streetman fi 9667d7dbf9dSDan Streetman ;; 9677d7dbf9dSDan Streetman ignore) 968b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 969b80fd281SPaolo Bonzini then 970b80fd281SPaolo Bonzini echo 971b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 972b80fd281SPaolo Bonzini echo 973b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 974b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 975b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 976b80fd281SPaolo Bonzini else 977b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 978b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 979b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 980b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 981b80fd281SPaolo Bonzini echo 982b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 983b80fd281SPaolo Bonzini echo 984b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 985b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 986b80fd281SPaolo Bonzini fi 987b80fd281SPaolo Bonzini echo 988b80fd281SPaolo Bonzini exit 1 989b80fd281SPaolo Bonzini fi 9907d7dbf9dSDan Streetman ;; 9917d7dbf9dSDan Streetman *) 9927d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 9937d7dbf9dSDan Streetman exit 1 9947d7dbf9dSDan Streetman ;; 9957d7dbf9dSDan Streetmanesac 9967d7dbf9dSDan Streetman 9979557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 998b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 9992038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 10009557af9cSAlex Bennéefi 100179f3b12fSPeter Crosthwaite 100260e0df25SPeter Maydelldefault_target_list="" 10036e92f823SPeter Maydellmak_wilds="" 10046e92f823SPeter Maydell 1005b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 1006b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 1007b915a2f1SPaolo Bonzini linux_user=yes 1008b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 1009b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 1010b915a2f1SPaolo Bonzini fi 1011b915a2f1SPaolo Bonzinifi 1012b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 1013b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 1014b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 1015b915a2f1SPaolo Bonzini fi 1016b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 1017b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 1018b915a2f1SPaolo Bonzini fi 1019b915a2f1SPaolo Bonzinifi 102060e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 1021812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 102260e0df25SPeter Maydellfi 102360e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 1024812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 102560e0df25SPeter Maydellfi 102660e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 1027812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 102860e0df25SPeter Maydellfi 102960e0df25SPeter Maydell 1030447e133fSAlex Bennéefor config in $mak_wilds; do 1031447e133fSAlex Bennée target="$(basename "$config" .mak)" 103298db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 1033447e133fSAlex Bennée default_target_list="${default_target_list} $target" 1034447e133fSAlex Bennée fi 1035447e133fSAlex Bennéedone 10366e92f823SPeter Maydell 1037af5db58eSpbrookif test x"$show_help" = x"yes" ; then 1038af5db58eSpbrookcat << EOF 1039af5db58eSpbrook 1040af5db58eSpbrookUsage: configure [options] 1041af5db58eSpbrookOptions: [defaults in brackets after descriptions] 1042af5db58eSpbrook 104308fb77edSStefan WeilStandard options: 104408fb77edSStefan Weil --help print this message 104508fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 104674154d7eSThomas Huth --target-list=LIST set target list (default: build all) 104708fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 104808fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 1049447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 105008fb77edSStefan Weil 105108fb77edSStefan WeilAdvanced options (experts only): 10523812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 105308fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 105408fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 105508fb77edSStefan Weil build time 105608fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 105708fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1058a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1059a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 1060e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS 106108fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1062d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1063479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 106408fb77edSStefan Weil --make=MAKE use specified make [$make] 106508fb77edSStefan Weil --python=PYTHON use specified python [$python] 1066a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 106748328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 106808fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1069db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 10707d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 10717d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 10727d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 107308fb77edSStefan Weil --static enable static build [$static] 107408fb77edSStefan Weil --bindir=PATH install binaries in PATH 107513336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1076ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1077c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1078c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1079c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1080d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1081d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 108208fb77edSStefan Weil --enable-debug enable common debug build options 1083247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 10840aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 108508fb77edSStefan Weil --disable-werror disable compilation abort on warning 108663678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 108716bfbc70SPaolo Bonzini --audio-drv-list=LIST set audio drivers to try if -audiodev is not used 108808fb77edSStefan Weil --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L 108908fb77edSStefan Weil --with-trace-file=NAME Full PATH,NAME of file to store traces 109008fb77edSStefan Weil Default:trace-<pid> 1091c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 109208fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 109333c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 109440e8c6f4SAlex Bennée --enable-plugins 109540e8c6f4SAlex Bennée enable plugins via shared library loading 1096afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1097f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 109861d63097SPaolo BonziniEOF 109961d63097SPaolo Bonzini meson_options_help 110061d63097SPaolo Bonzinicat << EOF 1101c23f23b9SMichael Tokarev system all system emulation targets 1102c23f23b9SMichael Tokarev user supported user emulation targets 1103c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1104c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1105c23f23b9SMichael Tokarev pie Position Independent Executables 110621e709aaSMarc-André Lureau modules modules support (non-Windows) 1107c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1108c23f23b9SMichael Tokarev debug-info debugging information 11091e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 11101e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 1111299e6f19SPaolo Bonzini vhost-net vhost-net kernel acceleration support 1112299e6f19SPaolo Bonzini vhost-vsock virtio sockets device support 1113299e6f19SPaolo Bonzini vhost-scsi vhost-scsi kernel target support 1114299e6f19SPaolo Bonzini vhost-crypto vhost-user-crypto backend support 1115299e6f19SPaolo Bonzini vhost-kernel vhost kernel backend support 1116299e6f19SPaolo Bonzini vhost-user vhost-user backend support 1117108a6481SCindy Lu vhost-vdpa vhost-vdpa kernel backend support 111808fb77edSStefan Weil 111908fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1120af5db58eSpbrookEOF 11212d2ad6d0SFam Zhengexit 0 1122af5db58eSpbrookfi 1123af5db58eSpbrook 11249c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1125bb768f71SThomas Huthrm -f */config-devices.mak.d 11269c790242SThomas Huth 1127faf44142SDaniel P. Berrangéif test -z "$python" 1128faf44142SDaniel P. Berrangéthen 1129c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1130c53eeaf7SStefan Hajnoczifi 11318e2c76bdSRoman Bolshakovif ! has "$make" 11328e2c76bdSRoman Bolshakovthen 11338e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 11348e2c76bdSRoman Bolshakovfi 1135c53eeaf7SStefan Hajnoczi 1136c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1137c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 11381b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 11391b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1140c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1141c53eeaf7SStefan Hajnoczifi 1142c53eeaf7SStefan Hajnoczi 1143755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1144406ab2f3SCleber 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) 1145755ee70fSCleber Rosa 1146c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1147c53eeaf7SStefan Hajnoczipython="$python -B" 1148c53eeaf7SStefan Hajnoczi 11490a01d76fSMarc-André Lureauif test -z "$meson"; then 11506638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 11510a01d76fSMarc-André Lureau meson=meson 11527d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 11530a01d76fSMarc-André Lureau meson=git 11540a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 11550a01d76fSMarc-André Lureau meson=internal 11560a01d76fSMarc-André Lureau else 11570a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 11580a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 11590a01d76fSMarc-André Lureau else 1160a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1161a5665051SPaolo Bonzini fi 11620a01d76fSMarc-André Lureau fi 11630a01d76fSMarc-André Lureauelse 11640a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 11650a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 11660a01d76fSMarc-André Lureau # 11670a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 11680a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 11690a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 11700a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 11710a01d76fSMarc-André Lureau case "$meson" in 11720a01d76fSMarc-André Lureau git | internal) ;; 11730a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 11740a01d76fSMarc-André Lureau esac 11750a01d76fSMarc-André Lureau fi 11760a01d76fSMarc-André Lureaufi 1177a5665051SPaolo Bonzini 11780a01d76fSMarc-André Lureauif test "$meson" = git; then 11790a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 11800a01d76fSMarc-André Lureaufi 11810a01d76fSMarc-André Lureau 11820a01d76fSMarc-André Lureaucase "$meson" in 11830a01d76fSMarc-André Lureau git | internal) 11840a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 11850a01d76fSMarc-André Lureau ;; 118684ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 11870a01d76fSMarc-André Lureauesac 11880a01d76fSMarc-André Lureau 118909e93326SPaolo Bonzini# Probe for ninja 119048328880SPaolo Bonzini 119148328880SPaolo Bonziniif test -z "$ninja"; then 119248328880SPaolo Bonzini for c in ninja ninja-build samu; do 119348328880SPaolo Bonzini if has $c; then 119448328880SPaolo Bonzini ninja=$(command -v "$c") 119548328880SPaolo Bonzini break 119648328880SPaolo Bonzini fi 119748328880SPaolo Bonzini done 119809e93326SPaolo Bonzini if test -z "$ninja"; then 119909e93326SPaolo Bonzini error_exit "Cannot find Ninja" 120009e93326SPaolo Bonzini fi 120148328880SPaolo Bonzinifi 1202a5665051SPaolo Bonzini 12039aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 12049aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 12059aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 12069aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 12079aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 12089aae6e54SDaniel Henrique Barbozaif compile_object ; then 12099aae6e54SDaniel Henrique Barboza : C compiler works ok 12109aae6e54SDaniel Henrique Barbozaelse 12119aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 12129aae6e54SDaniel Henrique Barbozafi 12139aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 12149aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 12159aae6e54SDaniel Henrique Barbozafi 12169aae6e54SDaniel Henrique Barboza 12179c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 12189c83ffd8SPeter Maydell# by default. Only enable by default for git builds 12199c83ffd8SPeter Maydellif test -z "$werror" ; then 12207d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1221e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 12229c83ffd8SPeter Maydell werror="yes" 12239c83ffd8SPeter Maydell else 12249c83ffd8SPeter Maydell werror="no" 12259c83ffd8SPeter Maydell fi 12269c83ffd8SPeter Maydellfi 12279c83ffd8SPeter Maydell 1228975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1229fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1230fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1231fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1232fb59dabdSPeter Maydell # host OS we should stop now. 1233951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1234fb59dabdSPeter Maydellfi 1235fb59dabdSPeter Maydell 1236efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1237efc6c070SThomas Huthcat > $TMPC << EOF 1238efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1239efc6c070SThomas Huth# ifdef __apple_build_version__ 12402a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 12412a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1242efc6c070SThomas Huth# endif 1243efc6c070SThomas Huth# else 12442a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 12452a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1246efc6c070SThomas Huth# endif 1247efc6c070SThomas Huth# endif 1248efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 12493830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 12503830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1251efc6c070SThomas Huth# endif 1252efc6c070SThomas Huth#else 1253efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1254efc6c070SThomas Huth#endif 1255efc6c070SThomas Huthint main (void) { return 0; } 1256efc6c070SThomas HuthEOF 1257efc6c070SThomas Huthif ! compile_prog "" "" ; then 12583830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1259efc6c070SThomas Huthfi 1260efc6c070SThomas Huth 126100849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 126200849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 126300849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 126400849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 126500849b92SRichard Henderson# just silently disable some features, so it's too error prone. 126600849b92SRichard Henderson 126700849b92SRichard Hendersonwarn_flags= 126800849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 126900849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 127000849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 127100849b92SRichard Hendersonadd_to warn_flags -Wformat-security 127200849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 127300849b92SRichard Hendersonadd_to warn_flags -Winit-self 127400849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 127500849b92SRichard Hendersonadd_to warn_flags -Wempty-body 127600849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 127700849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 127800849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 12790a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 128000849b92SRichard Henderson 128100849b92SRichard Hendersonnowarn_flags= 128200849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 128300849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 128400849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 128500849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 128600849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1287aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1288bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 128900849b92SRichard Henderson 129000849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 129193b25869SJohn Snow 129293b25869SJohn Snowcc_has_warning_flag() { 129393b25869SJohn Snow write_c_skeleton; 129493b25869SJohn Snow 1295a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1296a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1297a1d29d6cSPeter Maydell # warning options). 129893b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 129993b25869SJohn Snow compile_prog "-Werror $optflag" "" 130093b25869SJohn Snow} 130193b25869SJohn Snow 13024cb37d11SPhilippe Mathieu-Daudéobjcc_has_warning_flag() { 13034cb37d11SPhilippe Mathieu-Daudé cat > $TMPM <<EOF 13044cb37d11SPhilippe Mathieu-Daudéint main(void) { return 0; } 13054cb37d11SPhilippe Mathieu-DaudéEOF 13064cb37d11SPhilippe Mathieu-Daudé 13074cb37d11SPhilippe Mathieu-Daudé # Use the positive sense of the flag when testing for -Wno-wombat 13084cb37d11SPhilippe Mathieu-Daudé # support (gcc will happily accept the -Wno- form of unknown 13094cb37d11SPhilippe Mathieu-Daudé # warning options). 13104cb37d11SPhilippe Mathieu-Daudé optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 13114cb37d11SPhilippe Mathieu-Daudé do_objc -Werror $optflag \ 13124cb37d11SPhilippe Mathieu-Daudé $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ 13134cb37d11SPhilippe Mathieu-Daudé -o $TMPE $TMPM $QEMU_LDFLAGS 13144cb37d11SPhilippe Mathieu-Daudé} 13154cb37d11SPhilippe Mathieu-Daudé 131693b25869SJohn Snowfor flag in $gcc_flags; do 131793b25869SJohn Snow if cc_has_warning_flag $flag ; then 13188d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 13198d05095cSPaolo Bonzini fi 13204cb37d11SPhilippe Mathieu-Daudé if objcc_has_warning_flag $flag ; then 13214cb37d11SPhilippe Mathieu-Daudé QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" 13224cb37d11SPhilippe Mathieu-Daudé fi 13238d05095cSPaolo Bonzinidone 13248d05095cSPaolo Bonzini 132563678e17SSteven Noonanif test "$stack_protector" != "no"; then 1326fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1327fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1328fccd35a0SRodrigo Rebello{ 1329fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1330fccd35a0SRodrigo Rebello while (*c) { 1331fccd35a0SRodrigo Rebello *p++ = *c++; 1332fccd35a0SRodrigo Rebello } 1333fccd35a0SRodrigo Rebello return 0; 1334fccd35a0SRodrigo Rebello} 1335fccd35a0SRodrigo RebelloEOF 133663678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 13373b463a3fSMiroslav Rezanina sp_on=0 133863678e17SSteven Noonan for flag in $gcc_flags; do 1339590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1340590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1341086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1342590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 134363678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1344db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 13453b463a3fSMiroslav Rezanina sp_on=1 134663678e17SSteven Noonan break 134763678e17SSteven Noonan fi 134863678e17SSteven Noonan done 13493b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 13503b463a3fSMiroslav Rezanina if test $sp_on = 0; then 13513b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 13523b463a3fSMiroslav Rezanina fi 13533b463a3fSMiroslav Rezanina fi 135437746c5eSMarc-André Lureaufi 135537746c5eSMarc-André Lureau 135620bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 135720bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 135820bc94a2SPaolo Bonzinicat > $TMPC << EOF 135920bc94a2SPaolo Bonzinistruct { 136020bc94a2SPaolo Bonzini int a[2]; 136120bc94a2SPaolo Bonzini} x = {0}; 136220bc94a2SPaolo BonziniEOF 136320bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 136420bc94a2SPaolo Bonzini : 136520bc94a2SPaolo Bonzinielse 136620bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 136720bc94a2SPaolo Bonzinifi 136820bc94a2SPaolo Bonzini 136921e709aaSMarc-André Lureau# Our module code doesn't support Windows 137021e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 137121e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 137221e709aaSMarc-André Lureaufi 137321e709aaSMarc-André Lureau 13745f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 137540d6444eSAvi Kivityif test "$static" = "yes" ; then 1376aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1377aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1378aa0d1f44SPaolo Bonzini fi 13795f2453acSAlex Bennée if test "$plugins" = "yes"; then 13805f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1381ba4dd2aaSAlex Bennée else 1382ba4dd2aaSAlex Bennée plugins="no" 13835f2453acSAlex Bennée fi 138440d6444eSAvi Kivityfi 138537650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 138640d6444eSAvi Kivity 138740d6444eSAvi Kivitycat > $TMPC << EOF 138821d4a791SAvi Kivity 138921d4a791SAvi Kivity#ifdef __linux__ 139021d4a791SAvi Kivity# define THREAD __thread 139121d4a791SAvi Kivity#else 139221d4a791SAvi Kivity# define THREAD 139321d4a791SAvi Kivity#endif 139421d4a791SAvi Kivitystatic THREAD int tls_var; 139521d4a791SAvi Kivityint main(void) { return tls_var; } 139640d6444eSAvi KivityEOF 1397b2634124SRichard Henderson 1398ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1399ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1400412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1401412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1402ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1403412aeacdSAlex Bennéefi 1404412aeacdSAlex Bennée 140512781462SRichard Hendersonif test "$static" = "yes"; then 1406eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 14075770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 140812781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 140912781462SRichard Henderson pie="yes" 141012781462SRichard Henderson elif test "$pie" = "yes"; then 141112781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 141212781462SRichard Henderson else 141312781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 141412781462SRichard Henderson pie="no" 141512781462SRichard Henderson fi 141612781462SRichard Hendersonelif test "$pie" = "no"; then 14175770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1418ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1419eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 14205770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 14215770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 142240d6444eSAvi Kivity pie="yes" 14232c674109SRichard Hendersonelif test "$pie" = "yes"; then 142476ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 142540d6444eSAvi Kivityelse 142640d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 142740d6444eSAvi Kivity pie="no" 142840d6444eSAvi Kivityfi 142940d6444eSAvi Kivity 1430e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1431e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1432e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1433e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1434e6cbd751SRichard Hendersonfi 1435e6cbd751SRichard Henderson 143609dada40SPaolo Bonzini########################################## 143709dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 143809dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 143909dada40SPaolo Bonzini# specification is necessary 144009dada40SPaolo Bonzini 144109dada40SPaolo Bonziniif test "$cpu" = "i386"; then 144209dada40SPaolo Bonzini cat > $TMPC << EOF 144309dada40SPaolo Bonzinistatic int sfaa(int *ptr) 144409dada40SPaolo Bonzini{ 144509dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 144609dada40SPaolo Bonzini} 144709dada40SPaolo Bonzini 144809dada40SPaolo Bonziniint main(void) 144909dada40SPaolo Bonzini{ 145009dada40SPaolo Bonzini int val = 42; 14511405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 145209dada40SPaolo Bonzini sfaa(&val); 145309dada40SPaolo Bonzini return val; 145409dada40SPaolo Bonzini} 145509dada40SPaolo BonziniEOF 145609dada40SPaolo Bonzini if ! compile_prog "" "" ; then 145709dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 145809dada40SPaolo Bonzini fi 145909dada40SPaolo Bonzinifi 146009dada40SPaolo Bonzini 146156267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 146256267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 146356267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 146456267b62SPhilippe Mathieu-Daudéfi 146556267b62SPhilippe Mathieu-Daudé 1466afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1467fdb75aefSPaolo Bonzini default_targets=yes 1468d880a3baSPaolo Bonzini for target in $default_target_list; do 1469d880a3baSPaolo Bonzini target_list="$target_list $target" 1470d880a3baSPaolo Bonzini done 1471d880a3baSPaolo Bonzini target_list="${target_list# }" 1472121afa9eSAnthony Liguorielse 1473fdb75aefSPaolo Bonzini default_targets=no 147489138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1475d880a3baSPaolo Bonzini for target in $target_list; do 147625b48338SPeter Maydell # Check that we recognised the target name; this allows a more 147725b48338SPeter Maydell # friendly error message than if we let it fall through. 147825b48338SPeter Maydell case " $default_target_list " in 147925b48338SPeter Maydell *" $target "*) 148025b48338SPeter Maydell ;; 148125b48338SPeter Maydell *) 148225b48338SPeter Maydell error_exit "Unknown target name '$target'" 148325b48338SPeter Maydell ;; 148425b48338SPeter Maydell esac 148525b48338SPeter Maydell done 1486d880a3baSPaolo Bonzinifi 148725b48338SPeter Maydell 1488f55fe278SPaolo Bonzini# see if system emulation was really requested 1489f55fe278SPaolo Bonzinicase " $target_list " in 1490f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1491f55fe278SPaolo Bonzini ;; 1492f55fe278SPaolo Bonzini *) softmmu=no 1493f55fe278SPaolo Bonzini ;; 1494f55fe278SPaolo Bonziniesac 14955327cf48Sbellard 1496249247c9SJuan Quintelafeature_not_found() { 1497249247c9SJuan Quintela feature=$1 149821684af0SStewart Smith remedy=$2 1499249247c9SJuan Quintela 150076ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 150121684af0SStewart Smith "configure was not able to find it." \ 150221684af0SStewart Smith "$remedy" 1503249247c9SJuan Quintela} 1504249247c9SJuan Quintela 15057d13299dSbellard# --- 15067d13299dSbellard# big/little endian test 15077d13299dSbellardcat > $TMPC << EOF 1508659eb157SThomas Huth#include <stdio.h> 150961cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 151061cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1511659eb157SThomas Huthint main(int argc, char *argv[]) 1512659eb157SThomas Huth{ 1513659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 15147d13299dSbellard} 15157d13299dSbellardEOF 15167d13299dSbellard 1517659eb157SThomas Huthif compile_prog ; then 1518659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 151961cc919fSMike Frysinger bigendian="yes" 1520659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 152161cc919fSMike Frysinger bigendian="no" 15227d13299dSbellard else 15237d13299dSbellard echo big/little test failed 1524659eb157SThomas Huth exit 1 15257d13299dSbellard fi 15267d13299dSbellardelse 152761cc919fSMike Frysinger echo big/little test failed 1528659eb157SThomas Huth exit 1 15297d13299dSbellardfi 15307d13299dSbellard 1531299e6f19SPaolo Bonzini######################################### 1532299e6f19SPaolo Bonzini# vhost interdependencies and host support 1533299e6f19SPaolo Bonzini 1534299e6f19SPaolo Bonzini# vhost backends 1535eb9baecdSSergio Lopezif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then 1536eb9baecdSSergio Lopez error_exit "vhost-user is not available on Windows" 1537299e6f19SPaolo Bonzinifi 1538108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux 1539108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then 1540108a6481SCindy Lu error_exit "vhost-vdpa is only available on Linux" 1541108a6481SCindy Lufi 1542299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux 1543299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then 1544299e6f19SPaolo Bonzini error_exit "vhost-kernel is only available on Linux" 1545299e6f19SPaolo Bonzinifi 1546299e6f19SPaolo Bonzini 1547299e6f19SPaolo Bonzini# vhost-kernel devices 1548299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel 1549299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then 1550299e6f19SPaolo Bonzini error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" 1551299e6f19SPaolo Bonzinifi 1552299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel 1553299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then 1554299e6f19SPaolo Bonzini error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" 1555299e6f19SPaolo Bonzinifi 1556299e6f19SPaolo Bonzini 1557299e6f19SPaolo Bonzini# vhost-user backends 1558299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user 1559299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then 1560299e6f19SPaolo Bonzini error_exit "--enable-vhost-net-user requires --enable-vhost-user" 1561299e6f19SPaolo Bonzinifi 1562299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user 1563299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then 1564299e6f19SPaolo Bonzini error_exit "--enable-vhost-crypto requires --enable-vhost-user" 1565299e6f19SPaolo Bonzinifi 156698fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user 156798fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then 156898fc1adaSDr. David Alan Gilbert error_exit "--enable-vhost-user-fs requires --enable-vhost-user" 156998fc1adaSDr. David Alan Gilbertfi 1570108a6481SCindy Lu#vhost-vdpa backends 1571108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa 1572108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then 1573108a6481SCindy Lu error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" 1574108a6481SCindy Lufi 1575299e6f19SPaolo Bonzini 157640bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity 1577299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then 1578299e6f19SPaolo Bonzini test "$vhost_net_user" = "yes" && vhost_net=yes 157940bc0ca9SLaurent Vivier test "$vhost_net_vdpa" = "yes" && vhost_net=yes 1580299e6f19SPaolo Bonzini test "$vhost_kernel" = "yes" && vhost_net=yes 1581299e6f19SPaolo Bonzinifi 1582299e6f19SPaolo Bonzini 1583015a33bdSGonglei########################################## 1584779ab5e3SStefan Weil# pkg-config probe 1585779ab5e3SStefan Weil 1586779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 158776ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1588779ab5e3SStefan Weilfi 1589779ab5e3SStefan Weil 1590779ab5e3SStefan Weil########################################## 1591e18df141SAnthony Liguori# glib support probe 1592a52d28afSPaolo Bonzini 1593b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 1594aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 1595aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 1596a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 1597b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 1598b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 159954cb65d8SEmilio G. Cotafi 1600e26110cfSFam Zheng 1601aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 1602e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 160389138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 160489138857SStefan Weil glib_libs=$($pkg_config --libs $i) 1605e18df141SAnthony Liguori else 1606e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 1607e26110cfSFam Zheng fi 1608e26110cfSFam Zhengdone 1609e26110cfSFam Zheng 1610215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 1611215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 1612215b0c2fSPaolo Bonzini 1613215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 1614215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 1615215b0c2fSPaolo Bonzinifi 1616215b0c2fSPaolo Bonzini 1617977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 1618977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 1619977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 1620977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 1621977a82abSDaniel P. Berrangecat > $TMPC <<EOF 1622977a82abSDaniel P. Berrange#include <glib.h> 1623977a82abSDaniel P. Berrange#include <unistd.h> 1624977a82abSDaniel P. Berrange 1625977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 1626977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 1627977a82abSDaniel P. Berrange 1628977a82abSDaniel P. Berrangeint main(void) { 1629977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 1630977a82abSDaniel P. Berrange return 0; 1631977a82abSDaniel P. Berrange} 1632977a82abSDaniel P. BerrangeEOF 1633977a82abSDaniel P. Berrange 1634215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 1635977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 1636977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 1637977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 1638977a82abSDaniel P. Berrange "build target" 1639977a82abSDaniel P. Berrangefi 1640977a82abSDaniel P. Berrange 16419bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 16429bda600bSEric Blakecat > $TMPC << EOF 16439bda600bSEric Blake#include <glib.h> 16449bda600bSEric Blaketypedef struct Foo { 16459bda600bSEric Blake int i; 16469bda600bSEric Blake} Foo; 16479bda600bSEric Blakestatic void foo_free(Foo *f) 16489bda600bSEric Blake{ 16499bda600bSEric Blake g_free(f); 16509bda600bSEric Blake} 1651e0e7fe07SMarc-André LureauG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free) 16529bda600bSEric Blakeint main(void) { return 0; } 16539bda600bSEric BlakeEOF 16549bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 16559bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 16569bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 16575770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 16589bda600bSEric Blake fi 16599bda600bSEric Blakefi 16609bda600bSEric Blake 1661e26110cfSFam Zheng########################################## 1662f652e6afSaurel32# fdt probe 1663e169e1e1SPeter Maydell 1664fbb4121dSPaolo Bonzinicase "$fdt" in 1665fbb4121dSPaolo Bonzini auto | enabled | internal) 1666fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 1667aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 1668fbb4121dSPaolo Bonzini ;; 1669fbb4121dSPaolo Bonziniesac 1670f652e6afSaurel32 167120ff075bSMichael Walle########################################## 16728ca80760SRichard Henderson# capstone 16738ca80760SRichard Henderson 1674e219c499SRichard Hendersoncase "$capstone" in 16758b18cdbfSRichard Henderson auto | enabled | internal) 16768b18cdbfSRichard Henderson # Simpler to always update submodule, even if not needed. 1677e219c499SRichard Henderson git_submodules="${git_submodules} capstone" 1678e219c499SRichard Henderson ;; 1679e219c499SRichard Hendersonesac 16808ca80760SRichard Henderson 16818ca80760SRichard Henderson########################################## 1682519175a2SAlex Barcelo# check and set a backend for coroutine 1683d0e2fce5SAneesh Kumar K.V 16847c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 168533c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 168633c53c54SDaniel P. Berrange# specific one. 16877c2acc70SPeter Maydell 16887c2acc70SPeter Maydellucontext_works=no 1689d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 1690d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 1691d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 1692cdf84806SPeter Maydell#ifdef __stub_makecontext 1693cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 1694cdf84806SPeter Maydell#endif 169575cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 1696d0e2fce5SAneesh Kumar K.VEOF 1697d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 16987c2acc70SPeter Maydell ucontext_works=yes 1699d0e2fce5SAneesh Kumar K.V fi 1700519175a2SAlex Barcelofi 17017c2acc70SPeter Maydell 17027c2acc70SPeter Maydellif test "$coroutine" = ""; then 17037c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 17047c2acc70SPeter Maydell coroutine=win32 17057c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 17067c2acc70SPeter Maydell coroutine=ucontext 1707519175a2SAlex Barcelo else 17087c2acc70SPeter Maydell coroutine=sigaltstack 17097c2acc70SPeter Maydell fi 17107c2acc70SPeter Maydellelse 17117c2acc70SPeter Maydell case $coroutine in 17127c2acc70SPeter Maydell windows) 17137c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 17147c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 17157c2acc70SPeter Maydell fi 17167c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 17177c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 17187c2acc70SPeter Maydell coroutine=win32 17197c2acc70SPeter Maydell ;; 17207c2acc70SPeter Maydell ucontext) 17217c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 17227c2acc70SPeter Maydell feature_not_found "ucontext" 17237c2acc70SPeter Maydell fi 17247c2acc70SPeter Maydell ;; 172533c53c54SDaniel P. Berrange sigaltstack) 17267c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 17277c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 17287c2acc70SPeter Maydell fi 17297c2acc70SPeter Maydell ;; 17307c2acc70SPeter Maydell *) 173176ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 17327c2acc70SPeter Maydell ;; 17337c2acc70SPeter Maydell esac 1734d0e2fce5SAneesh Kumar K.Vfi 1735d0e2fce5SAneesh Kumar K.V 17361e4f6065SDaniele Buono################################################## 17371e4f6065SDaniele Buono# SafeStack 17381e4f6065SDaniele Buono 17391e4f6065SDaniele Buono 17401e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 17411e4f6065SDaniele Buonocat > $TMPC << EOF 17421e4f6065SDaniele Buonoint main(int argc, char *argv[]) 17431e4f6065SDaniele Buono{ 17441e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 17451e4f6065SDaniele Buono#error SafeStack Disabled 17461e4f6065SDaniele Buono#endif 17471e4f6065SDaniele Buono return 0; 17481e4f6065SDaniele Buono} 17491e4f6065SDaniele BuonoEOF 17501e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 17511e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 17521e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 17531e4f6065SDaniele Buono # Flag needed both at compilation and at linking 17541e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 17551e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 17561e4f6065SDaniele Buono else 17571e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 17581e4f6065SDaniele Buono fi 17591e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 17601e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 17611e4f6065SDaniele Buono fi 17621e4f6065SDaniele Buonoelse 17631e4f6065SDaniele Buonocat > $TMPC << EOF 17641e4f6065SDaniele Buonoint main(int argc, char *argv[]) 17651e4f6065SDaniele Buono{ 17661e4f6065SDaniele Buono#if defined(__has_feature) 17671e4f6065SDaniele Buono#if __has_feature(safe_stack) 17681e4f6065SDaniele Buono#error SafeStack Enabled 17691e4f6065SDaniele Buono#endif 17701e4f6065SDaniele Buono#endif 17711e4f6065SDaniele Buono return 0; 17721e4f6065SDaniele Buono} 17731e4f6065SDaniele BuonoEOF 17741e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 17751e4f6065SDaniele Buono # Make sure that safe-stack is disabled 17761e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 17771e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 17781e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 17791e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 17801e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 17811e4f6065SDaniele Buono fi 17821e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 17831e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 17841e4f6065SDaniele Buono fi 17851e4f6065SDaniele Buonoelse # "$safe_stack" = "" 17861e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 17871e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 17881e4f6065SDaniele Buono safe_stack="no" 17891e4f6065SDaniele Buono else 17901e4f6065SDaniele Buono safe_stack="yes" 17911e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 17921e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 17931e4f6065SDaniele Buono fi 17941e4f6065SDaniele Buono fi 17951e4f6065SDaniele Buonofi 17961e4f6065SDaniele Buonofi 17977d992e4dSPeter Lieven 179876a347e1SRichard Henderson######################################## 1799fd0e6053SJohn Snow# check if ccache is interfering with 1800fd0e6053SJohn Snow# semantic analysis of macros 1801fd0e6053SJohn Snow 18025e4dfd3dSJohn Snowunset CCACHE_CPP2 1803fd0e6053SJohn Snowccache_cpp2=no 1804fd0e6053SJohn Snowcat > $TMPC << EOF 1805fd0e6053SJohn Snowstatic const int Z = 1; 1806fd0e6053SJohn Snow#define fn() ({ Z; }) 1807fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 1808fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 1809fd0e6053SJohn Snow#define ID(X) (X) 1810fd0e6053SJohn Snowint main(int argc, char *argv[]) 1811fd0e6053SJohn Snow{ 1812fd0e6053SJohn Snow int x = 0, y = 0; 1813fd0e6053SJohn Snow x = ID(x); 1814fd0e6053SJohn Snow x = fn(); 1815fd0e6053SJohn Snow fn(); 1816fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 1817fd0e6053SJohn Snow if (TAUT(Z)) return 0; 1818fd0e6053SJohn Snow return 0; 1819fd0e6053SJohn Snow} 1820fd0e6053SJohn SnowEOF 1821fd0e6053SJohn Snow 1822fd0e6053SJohn Snowif ! compile_object "-Werror"; then 1823fd0e6053SJohn Snow ccache_cpp2=yes 1824fd0e6053SJohn Snowfi 1825fd0e6053SJohn Snow 1826b553a042SJohn Snow################################################# 1827b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 1828b553a042SJohn Snow 1829b553a042SJohn Snowif test "$fortify_source" != "no"; then 1830b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 1831b553a042SJohn Snow fortify_source="no"; 1832e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 1833cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 1834b553a042SJohn Snow fortify_source="no"; 1835b553a042SJohn Snow else 1836b553a042SJohn Snow fortify_source="yes" 1837b553a042SJohn Snow fi 1838b553a042SJohn Snowfi 1839b553a042SJohn Snow 1840d2042378SAneesh Kumar K.V########################################## 1841247724cbSMarc-André Lureau# checks for sanitizers 1842247724cbSMarc-André Lureau 1843247724cbSMarc-André Lureauhave_asan=no 1844247724cbSMarc-André Lureauhave_ubsan=no 1845d83414e1SMarc-André Lureauhave_asan_iface_h=no 1846d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 1847247724cbSMarc-André Lureau 1848247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 1849b9f44da2SMarc-André Lureau write_c_skeleton 1850247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 1851247724cbSMarc-André Lureau have_asan=yes 1852247724cbSMarc-André Lureau fi 1853b9f44da2SMarc-André Lureau 1854b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 1855b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 1856b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 1857b9f44da2SMarc-André Lureau cat > $TMPC << EOF 1858b9f44da2SMarc-André Lureau#include <stdlib.h> 1859b9f44da2SMarc-André Lureauint main(void) { 1860b9f44da2SMarc-André Lureau void *tmp = malloc(10); 1861f2dfe54cSLeonid Bloch if (tmp != NULL) { 1862b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 1863b9f44da2SMarc-André Lureau } 1864d1abf3fcSOlaf Hering return 1; 1865f2dfe54cSLeonid Bloch} 1866b9f44da2SMarc-André LureauEOF 1867247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 1868247724cbSMarc-André Lureau have_ubsan=yes 1869247724cbSMarc-André Lureau fi 1870d83414e1SMarc-André Lureau 1871d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 1872d83414e1SMarc-André Lureau have_asan_iface_h=yes 1873d83414e1SMarc-André Lureau fi 1874d83414e1SMarc-André Lureau 1875d83414e1SMarc-André Lureau cat > $TMPC << EOF 1876d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 1877d83414e1SMarc-André Lureauint main(void) { 1878d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 1879d83414e1SMarc-André Lureau return 0; 1880d83414e1SMarc-André Lureau} 1881d83414e1SMarc-André LureauEOF 1882d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 1883d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 1884d83414e1SMarc-André Lureau fi 1885247724cbSMarc-André Lureaufi 1886247724cbSMarc-André Lureau 18870aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 18880aebab04SLingfeng Yang# keep it separate until that is not the case. 18890aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 18900aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 18910aebab04SLingfeng Yangfi 18920aebab04SLingfeng Yanghave_tsan=no 18930aebab04SLingfeng Yanghave_tsan_iface_fiber=no 18940aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 18950aebab04SLingfeng Yang write_c_skeleton 18960aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 18970aebab04SLingfeng Yang have_tsan=yes 18980aebab04SLingfeng Yang fi 18990aebab04SLingfeng Yang cat > $TMPC << EOF 19000aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 19010aebab04SLingfeng Yangint main(void) { 19020aebab04SLingfeng Yang __tsan_create_fiber(0); 19030aebab04SLingfeng Yang return 0; 19040aebab04SLingfeng Yang} 19050aebab04SLingfeng YangEOF 19060aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 19070aebab04SLingfeng Yang have_tsan_iface_fiber=yes 19080aebab04SLingfeng Yang fi 19090aebab04SLingfeng Yangfi 19100aebab04SLingfeng Yang 1911adc28027SAlexander Bulekov########################################## 1912675b9b53SMarc-André Lureau# check for slirp 1913675b9b53SMarc-André Lureau 1914675b9b53SMarc-André Lureaucase "$slirp" in 19154d34a86bSPaolo Bonzini auto | enabled | internal) 19164d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 19177c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 1918675b9b53SMarc-André Lureau ;; 1919675b9b53SMarc-André Lureauesac 1920675b9b53SMarc-André Lureau 192154e7aac0SAlexey Krasikov########################################## 1922e86ecd4bSJuan Quintela# End of CC checks 1923e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 1924e86ecd4bSJuan Quintela 1925d83414e1SMarc-André Lureauwrite_c_skeleton 1926d83414e1SMarc-André Lureau 1927df42fa7dSPaolo Bonziniif test "$fortify_source" = "yes" ; then 1928086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 1929086d5f75SPaolo Bonzinifi 1930086d5f75SPaolo Bonzini 1931086d5f75SPaolo Bonzinicase "$ARCH" in 1932086d5f75SPaolo Bonzinialpha) 1933086d5f75SPaolo Bonzini # Ensure there's only a single GP 1934086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 1935086d5f75SPaolo Bonzini;; 1936086d5f75SPaolo Bonziniesac 1937086d5f75SPaolo Bonzini 1938247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 1939db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 1940db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 1941d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 1942d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 1943d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 1944d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 1945d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 1946d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 1947d83414e1SMarc-André Lureau fi 1948247724cbSMarc-André Lureaufi 19490aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 19500aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 19510aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 19520aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 19530aebab04SLingfeng Yang else 19540aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 19550aebab04SLingfeng Yang fi 19560aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 19570aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 19580aebab04SLingfeng Yangfi 1959247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 1960db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 1961db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 1962247724cbSMarc-André Lureaufi 1963247724cbSMarc-André Lureau 19646542aa9cSPeter Lieven########################################## 19653efac6ebSTomáš Golembiovský 19660aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 19670aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 1968e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 1969db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 1970e86ecd4bSJuan Quintela fi 1971e86ecd4bSJuan Quintelafi 1972e86ecd4bSJuan Quintela 1973b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 19749d6bc27bSMichael Roth 19759d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 19769d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 19779d6bc27bSMichael Rothfi 19789d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 19799d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 19809d6bc27bSMichael Rothfi 19819d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 198289138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 19839d6bc27bSMichael Rothfi 19849d6bc27bSMichael Roth 19856e444209SPaolo BonziniQEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 19869d6bc27bSMichael Roth 1987ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 1988ca35f780SPaolo Bonziniroms= 1989e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 1990ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 1991ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 1992e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 1993c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 1994c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 1995c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 1996e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 1997e57218b6SPeter Maydell ld_i386_emulation="$emu" 1998ca35f780SPaolo Bonzini roms="optionrom" 1999e57218b6SPeter Maydell break 2000e57218b6SPeter Maydell fi 2001e57218b6SPeter Maydell done 2002ca35f780SPaolo Bonzinifi 2003ca35f780SPaolo Bonzini 20042e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 2005a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 20069933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 20072e33c3f8SThomas Huth write_c_skeleton 2008a5b2afd5SThomas Huth compile_prog "-march=z900" "" 2009a5b2afd5SThomas Huth has_z900=$? 20103af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 2011a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 2012a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 2013a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 2014a5b2afd5SThomas Huth fi 20159933c305SChristian Borntraeger roms="$roms s390-ccw" 20161ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 20171ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 20181ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 20191ef6bfc2SPhilippe Mathieu-Daudé fi 20209933c305SChristian Borntraegerfi 20219933c305SChristian Borntraeger 202211cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 202311cde1c8SBruno 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. 202411cde1c8SBruno Dominguezif has $cxx; then 202511cde1c8SBruno Dominguez cat > $TMPC <<EOF 202611cde1c8SBruno Dominguezint c_function(void); 202711cde1c8SBruno Dominguezint main(void) { return c_function(); } 202811cde1c8SBruno DominguezEOF 202911cde1c8SBruno Dominguez 203011cde1c8SBruno Dominguez compile_object 203111cde1c8SBruno Dominguez 203211cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 203311cde1c8SBruno Dominguezextern "C" { 203411cde1c8SBruno Dominguez int c_function(void); 203511cde1c8SBruno Dominguez} 203611cde1c8SBruno Dominguezint c_function(void) { return 42; } 203711cde1c8SBruno DominguezEOF 203811cde1c8SBruno Dominguez 203911cde1c8SBruno Dominguez update_cxxflags 204011cde1c8SBruno Dominguez 2041a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 204211cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 204311cde1c8SBruno Dominguez : 204411cde1c8SBruno Dominguez else 204511cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 204611cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 204711cde1c8SBruno Dominguez cxx= 204811cde1c8SBruno Dominguez fi 204911cde1c8SBruno Dominguezelse 205011cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 205111cde1c8SBruno Dominguez cxx= 205211cde1c8SBruno Dominguezfi 205311cde1c8SBruno Dominguez 20547d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 20557d7dbf9dSDan Streetman exit 1 20565d91a2edSYonggang Luofi 20575d91a2edSYonggang Luo 205898ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 205997a847bcSbellard 206098ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 206198ec69acSJuan Quintelaecho >> $config_host_mak 206298ec69acSJuan Quintela 2063e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 2064cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 2065aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 20667d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 2067804edf29SJuan Quintela 2068f8393946Saurel32if test "$debug_tcg" = "yes" ; then 20692358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 2070f8393946Saurel32fi 207167b915a5Sbellardif test "$mingw32" = "yes" ; then 207298ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 20736e444209SPaolo Bonzini echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak 20749dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 20759dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 20769dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 2077210fa556Spbrookelse 207835f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 2079210fa556Spbrookfi 2080128ab2ffSblueswir1 2081dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 2082dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 2083dffcb71cSMark McLoughlinfi 2084dffcb71cSMark McLoughlin 208583fb7adfSbellardif test "$darwin" = "yes" ; then 208698ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 208783fb7adfSbellardfi 2088b29fe3edSmalc 2089ec530c81Sbellardif test "$solaris" = "yes" ; then 209098ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 2091ec530c81Sbellardfi 209297a847bcSbellardif test "$static" = "yes" ; then 209398ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 209497a847bcSbellardfi 209589138857SStefan Weilqemu_version=$(head $source_path/VERSION) 209698ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 20972b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 209817969268SFam Zhengif test "$modules" = "yes"; then 209917969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 210017969268SFam Zhengfi 2101277abf15SJan Vesely 21025e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then 21035e9be92dSNicholas Bellinger echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 21045e9be92dSNicholas Bellingerfi 2105af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then 2106af3bba76SPaolo Bonzini echo "CONFIG_VHOST_NET=y" >> $config_host_mak 2107af3bba76SPaolo Bonzinifi 2108af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then 210956f41de7SPaolo Bonzini echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 211003ce5744SNikolay Nikolaevfi 2111108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then 2112108a6481SCindy Lu echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak 2113108a6481SCindy Lufi 2114042cea27SGongleiif test "$vhost_crypto" = "yes" ; then 2115042cea27SGonglei echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak 2116042cea27SGongleifi 2117fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then 2118fc0b9b0eSStefan Hajnoczi echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak 21195fe97d88SStefano Garzarella if test "$vhost_user" = "yes" ; then 21205fe97d88SStefano Garzarella echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak 21215fe97d88SStefano Garzarella fi 2122fc0b9b0eSStefan Hajnoczifi 2123299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then 2124299e6f19SPaolo Bonzini echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak 2125299e6f19SPaolo Bonzinifi 2126e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then 2127e6a74868SMarc-André Lureau echo "CONFIG_VHOST_USER=y" >> $config_host_mak 2128e6a74868SMarc-André Lureaufi 2129108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then 2130108a6481SCindy Lu echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak 2131108a6481SCindy Lufi 213298fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then 213398fc1adaSDr. David Alan Gilbert echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak 213498fc1adaSDr. David Alan Gilbertfi 213558d3f3ffSGerd Hoffmann 213683fb7adfSbellard# XXX: suppress that 21377d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 21382358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 21397d3505c5Sbellardfi 21407d3505c5Sbellard 21417c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 21427d992e4dSPeter Lieven 2143d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 2144d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 2145d83414e1SMarc-André Lureaufi 2146d83414e1SMarc-André Lureau 21470aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 21480aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 21490aebab04SLingfeng Yangfi 21500aebab04SLingfeng Yang 215140e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 215240e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 215340e8c6f4SAlex Bennéefi 215440e8c6f4SAlex Bennée 2155f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 2156b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 2157d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 2158f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 2159f48e590aSAlex Bennée fi 2160b1863cccSAlex Bennéefi 2161f48e590aSAlex Bennée 216298ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 2163804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 2164c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 216539d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 2166a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 216709e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 2168804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 2169804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 2170cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 21715f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 21723dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 2173804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 2174804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 217546eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak 2176a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 217711cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 21784cb37d11SPhilippe Mathieu-Daudéecho "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak 2179a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 2180a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 2181d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 21828a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 2183e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 2184a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 2185804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 2186804edf29SJuan Quintela 21876efd7517SPeter Maydell# use included Linux headers 21886efd7517SPeter Maydellif test "$linux" = "yes" ; then 2189a307beb6SAndreas Färber mkdir -p linux-headers 21906efd7517SPeter Maydell case "$cpu" in 21914da270beSPaolo Bonzini i386|x86_64) 219208312a63SPeter Maydell linux_arch=x86 21936efd7517SPeter Maydell ;; 2194d8ff892dSPaolo Bonzini ppc|ppc64) 219508312a63SPeter Maydell linux_arch=powerpc 21966efd7517SPeter Maydell ;; 21976efd7517SPeter Maydell s390x) 219808312a63SPeter Maydell linux_arch=s390 219908312a63SPeter Maydell ;; 22001f080313SClaudio Fontana aarch64) 22011f080313SClaudio Fontana linux_arch=arm64 22021f080313SClaudio Fontana ;; 2203dfcf900bSWANG Xuerui loongarch*) 2204dfcf900bSWANG Xuerui linux_arch=loongarch 2205dfcf900bSWANG Xuerui ;; 2206222e7d11SSanjay Lal mips64) 2207222e7d11SSanjay Lal linux_arch=mips 2208222e7d11SSanjay Lal ;; 220908312a63SPeter Maydell *) 221008312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 221108312a63SPeter Maydell linux_arch="$cpu" 22126efd7517SPeter Maydell ;; 22136efd7517SPeter Maydell esac 221408312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 221508312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 221608312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 221708312a63SPeter Maydell fi 22186efd7517SPeter Maydellfi 22196efd7517SPeter Maydell 222097a847bcSbellardfor target in $target_list; do 222197a847bcSbellard target_dir="$target" 222257a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 222397a847bcSbellard mkdir -p $target_dir 2224fdb75aefSPaolo Bonzini case $target in 2225fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 2226fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 22272408a527Saurel32 esac 222856aebc89Spbrookdone 22297d13299dSbellard 2230fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 2231fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 2232fdb75aefSPaolo Bonzinifi 2233a540f158SPeter Crosthwaite 2234fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 2235fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 2236fd0e6053SJohn Snowfi 2237fd0e6053SJohn Snow 22381e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 22391e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 22401e4f6065SDaniele Buonofi 22411e4f6065SDaniele Buono 2242e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 2243e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 2244e29e5c6eSPeter Maydell# (these can be both files and directories). 2245e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 2246e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 2247e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 2248e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 2249e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 2250e29e5c6eSPeter Maydell# directory and symlink the directory instead. 22512038f8c8SPaolo BonziniLINKS="Makefile" 22523941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 2253ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 2254e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 2255e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 2256bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 225739950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 22588f8fd9edSCleber RosaLINKS="$LINKS python" 2259c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 2260753d11f2SRichard Hendersonfor bios_file in \ 2261753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 22623a631b8eSBin Meng $source_path/pc-bios/*.elf \ 2263225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 2264753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 2265753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 2266e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 2267753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 22684e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 2269cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 2270cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 2271cd946e5cSJohn Arbuckle 2272753d11f2SRichard Hendersondo 2273e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 22747ea78b74SJan Kiszkadone 2275e29e5c6eSPeter Maydellfor f in $LINKS ; do 22760f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 22775dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 2278f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 2279f9245e10SPeter Maydell fi 22807d13299dSbellarddone 22811ad2134fSPaul Brook 22822038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 22832038f8c8SPaolo Bonzini export $i 22842038f8c8SPaolo Bonzinidone 2285544f4a25SPaolo Bonziniexport target_list source_path use_containers cpu host_cc 22862038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 22872038f8c8SPaolo Bonzini 228898409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 228998409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 229098409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 229198409991SHelge Konetzka 2292a5665051SPaolo Bonziniif test "$skip_meson" = no; then 2293fc929892SMarc-André Lureau cross="config-meson.cross.new" 2294fc929892SMarc-André Lureau meson_quote() { 2295ac7ebcc5SPaolo Bonzini test $# = 0 && return 229647b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 2297fc929892SMarc-André Lureau } 2298fc929892SMarc-André Lureau 2299fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 2300fc929892SMarc-André Lureau echo "[properties]" >> $cross 2301d1d5e9eeSAlex Bennée 2302d1d5e9eeSAlex Bennée # unroll any custom device configs 2303d1d5e9eeSAlex Bennée for a in $device_archs; do 2304d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 2305d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 2306d1d5e9eeSAlex Bennée done 2307d1d5e9eeSAlex Bennée 2308fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 230947b30835SPaolo Bonzini echo "[built-in options]" >> $cross 2310a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 2311a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 2312e910c7d9SPhilippe Mathieu-Daudé test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross 2313a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 2314a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 2315fc929892SMarc-André Lureau echo "[binaries]" >> $cross 23164dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 23174dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 23184dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 231947b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 232047b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 232147b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 232247b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 2323e8178514SPaolo Bonzini if has $sdl2_config; then 232447b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 2325e8178514SPaolo Bonzini fi 232647b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 2327158bb224SKonstantin Kostiuk echo "widl = [$(meson_quote $widl)]" >> $cross 232847b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 23293812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 2330fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 2331fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 2332ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 2333823eb013SPaolo Bonzini case "$cpu" in 2334f6bca9dfSJoelle van Dyne i386) 2335fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 2336fc929892SMarc-André Lureau ;; 2337fc929892SMarc-André Lureau *) 2338823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 2339fc929892SMarc-André Lureau ;; 2340fc929892SMarc-André Lureau esac 2341fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 2342fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 2343fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 2344fc929892SMarc-André Lureau else 2345fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 2346fc929892SMarc-André Lureau fi 2347fc929892SMarc-André Lureau else 2348fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 2349fc929892SMarc-André Lureau fi 2350fc929892SMarc-André Lureau mv $cross config-meson.cross 2351fc929892SMarc-André Lureau 2352a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 235361d63097SPaolo Bonzini run_meson() { 235409e93326SPaolo Bonzini NINJA=$ninja $meson setup \ 2355d17f305aSPaolo Bonzini --prefix "$prefix" \ 2356d17f305aSPaolo Bonzini --bindir "$bindir" \ 235773f3aa37SMarc-André Lureau -Dqemu_suffix="$qemu_suffix" \ 235835acbb30SPaolo Bonzini -Dsmbd="$smbd" \ 2359a5665051SPaolo Bonzini -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ 2360da6d48b9SMarc-André Lureau -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ 2361*c54b59eeSPaolo Bonzini -Dcfi=$cfi -Dtcg=$tcg \ 23623b4da132SPaolo Bonzini -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ 2363537b7248SPaolo Bonzini $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ 2364332008e0SThomas Huth $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ 236561d63097SPaolo Bonzini "$@" $cross_arg "$PWD" "$source_path" 236661d63097SPaolo Bonzini } 236761d63097SPaolo Bonzini eval run_meson $meson_options 2368a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 2369a5665051SPaolo Bonzini error_exit "meson setup failed" 2370a5665051SPaolo Bonzini fi 2371699d3884SPaolo Bonzinielse 2372699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 2373699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 2374699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 2375699d3884SPaolo Bonzini perl -i -ne ' 2376699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 2377699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 2378654d6b04SPaolo Bonzini /^b_staticpic/ && next; 2379699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 2380699d3884SPaolo Bonzini fi 2381a5665051SPaolo Bonzinifi 2382a5665051SPaolo Bonzini 2383dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 2384dc655404SMichael S. Tsirkincat <<EOD >config.status 2385dc655404SMichael S. Tsirkin#!/bin/sh 2386dc655404SMichael S. Tsirkin# Generated by configure. 2387dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 2388dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 2389dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 2390dc655404SMichael S. TsirkinEOD 2391e811da7fSDaniel P. Berrangé 2392e811da7fSDaniel P. Berrangépreserve_env() { 2393e811da7fSDaniel P. Berrangé envname=$1 2394e811da7fSDaniel P. Berrangé 2395e811da7fSDaniel P. Berrangé eval envval=\$$envname 2396e811da7fSDaniel P. Berrangé 2397e811da7fSDaniel P. Berrangé if test -n "$envval" 2398e811da7fSDaniel P. Berrangé then 2399e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 2400e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 2401e811da7fSDaniel P. Berrangé else 2402e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 2403e811da7fSDaniel P. Berrangé fi 2404e811da7fSDaniel P. Berrangé} 2405e811da7fSDaniel P. Berrangé 2406e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 2407e811da7fSDaniel P. Berrangé# features/build target configure will detect 2408e811da7fSDaniel P. Berrangépreserve_env AR 2409e811da7fSDaniel P. Berrangépreserve_env AS 2410e811da7fSDaniel P. Berrangépreserve_env CC 2411e811da7fSDaniel P. Berrangépreserve_env CPP 24128009da03SPaolo Bonzinipreserve_env CFLAGS 2413e811da7fSDaniel P. Berrangépreserve_env CXX 24148009da03SPaolo Bonzinipreserve_env CXXFLAGS 2415e811da7fSDaniel P. Berrangépreserve_env INSTALL 2416e811da7fSDaniel P. Berrangépreserve_env LD 24178009da03SPaolo Bonzinipreserve_env LDFLAGS 2418e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 2419e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 2420e811da7fSDaniel P. Berrangépreserve_env MAKE 2421e811da7fSDaniel P. Berrangépreserve_env NM 2422e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 2423e811da7fSDaniel P. Berrangépreserve_env PATH 2424e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 2425e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 2426e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 2427e811da7fSDaniel P. Berrangépreserve_env PYTHON 2428e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 2429e811da7fSDaniel P. Berrangépreserve_env SMBD 2430e811da7fSDaniel P. Berrangépreserve_env STRIP 2431158bb224SKonstantin Kostiukpreserve_env WIDL 2432e811da7fSDaniel P. Berrangépreserve_env WINDRES 2433e811da7fSDaniel P. Berrangé 2434dc655404SMichael S. Tsirkinprintf "exec" >>config.status 2435a5665051SPaolo Bonzinifor i in "$0" "$@"; do 2436835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 2437a5665051SPaolo Bonzinidone 2438cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 2439dc655404SMichael S. Tsirkinchmod +x config.status 2440dc655404SMichael S. Tsirkin 24418cd05ab6SPeter Maydellrm -r "$TMPDIR1" 2442