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 285377529c0SPaolo Bonzinidebug_tcg="no" 286247724cbSMarc-André Lureausanitizers="no" 2870aebab04SLingfeng Yangtsan="no" 2881f3f2bfeSMichael Tokarevfortify_source="yes" 289c7328271SMiroslav RezaninaEXESUF="" 29017969268SFam Zhengmodules="no" 291377529c0SPaolo Bonziniprefix="/usr/local" 29210ff82d1SMarc-André Lureauqemu_suffix="qemu" 293377529c0SPaolo Bonzinisoftmmu="yes" 294b915a2f1SPaolo Bonzinilinux_user="" 295b915a2f1SPaolo Bonzinibsd_user="" 29640d6444eSAvi Kivitypie="" 297519175a2SAlex Barcelocoroutine="" 298ba4dd2aaSAlex Bennéeplugins="$default_feature" 299a5665051SPaolo Bonzinimeson="" 3003b4da132SPaolo Bonzinimeson_args="" 30148328880SPaolo Bonzinininja="" 302c09c1ce7SPaolo Bonzinibindir="bin" 303a5665051SPaolo Bonziniskip_meson=no 304377529c0SPaolo Bonzini 3053b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 3063b4da132SPaolo Bonzini# are included in the automatically generated help message) 3073b4da132SPaolo Bonzini 3083b4da132SPaolo Bonzini# 1. Track which submodules are needed 3090577e84dSThomas Huthif test "$default_feature" = no ; then 3100577e84dSThomas Huth slirp="disabled" 3110577e84dSThomas Huthelse 3123b4da132SPaolo Bonzini slirp="auto" 3130577e84dSThomas Huthfi 3140577e84dSThomas Huthfdt="auto" 3153b4da132SPaolo Bonzini 316c54b59eeSPaolo Bonzini# 2. Automatically enable/disable other options 3173b4da132SPaolo Bonzinitcg="enabled" 3183b4da132SPaolo Bonzinicfi="false" 3193b4da132SPaolo Bonzini 320c87ea116SAlex Bennée# parse CC options second 321ac0df51dSaliguorifor opt do 32289138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 323ac0df51dSaliguori case "$opt" in 324ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3253812c0c4SJoelle van Dyne cross_compile="yes" 326ac0df51dSaliguori ;; 3273d8df640SPaolo Bonzini --cc=*) CC="$optarg" 328ac0df51dSaliguori ;; 32983f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 33083f73fceSTomoki Sekiyama ;; 3312ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3322ff6b91eSJuan Quintela ;; 333a2866660SPaolo Bonzini --extra-cflags=*) 334a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 335a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 336e910c7d9SPhilippe Mathieu-Daudé EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 337e2a2ed06SJuan Quintela ;; 338a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 33911cde1c8SBruno Dominguez ;; 340e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 341e910c7d9SPhilippe Mathieu-Daudé ;; 342a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 343e2a2ed06SJuan Quintela ;; 344d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 345d75402b5SAlex Bennée ;; 346479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 347d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 3482038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 349d422b2bcSAlex Bennée ;; 350d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 351d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 3522038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 353d75402b5SAlex Bennée ;; 354ac0df51dSaliguori esac 355ac0df51dSaliguoridone 356ac0df51dSaliguori# OS specific 357ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 35893148aa5SStefan Weil# we can eliminate its usage altogether. 359ac0df51dSaliguori 360e49d021eSPeter Maydell# Preferred compiler: 361e49d021eSPeter Maydell# ${CC} (if set) 362e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 363e49d021eSPeter Maydell# system compiler 364e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 365e49d021eSPeter Maydell cc="$host_cc" 366e49d021eSPeter Maydellelse 367b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 368e49d021eSPeter Maydellfi 369e49d021eSPeter Maydell 37083f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 37183f73fceSTomoki Sekiyama cxx="c++" 37283f73fceSTomoki Sekiyamaelse 37383f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 37483f73fceSTomoki Sekiyamafi 37583f73fceSTomoki Sekiyama 376b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 377cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 3785f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 3793dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 380b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 381b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 3829f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 3834852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 38435acbb30SPaolo Bonzinismbd="$SMBD" 385b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 386158bb224SKonstantin Kostiukwidl="${WIDL-${cross_prefix}widl}" 387b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 38817884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 38917884d7bSSergei Trofimovichquery_pkg_config() { 39017884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 39117884d7bSSergei Trofimovich} 39217884d7bSSergei Trofimovichpkg_config=query_pkg_config 39347c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 394ac0df51dSaliguori 395be17dc90SMichael S. Tsirkin# default flags for all hosts 3962d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 3972d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 3982d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 3992d31515bSPeter Maydell# provides these semantics.) 400de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 401086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 402c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 403be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4045770e8afSPaolo Bonzini 405de38c0ccSPaolo BonziniQEMU_LDFLAGS= 406de38c0ccSPaolo Bonzini 4075770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4088a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4095770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 410086d5f75SPaolo Bonzini 411be17dc90SMichael S. Tsirkin 412ac0df51dSaliguoricheck_define() { 413ac0df51dSaliguoricat > $TMPC <<EOF 414ac0df51dSaliguori#if !defined($1) 415fd786e1aSPeter Maydell#error $1 not defined 416ac0df51dSaliguori#endif 417ac0df51dSaliguoriint main(void) { return 0; } 418ac0df51dSaliguoriEOF 41952166aa0SJuan Quintela compile_object 420ac0df51dSaliguori} 421ac0df51dSaliguori 422307119e7SGerd Hoffmanncheck_include() { 423307119e7SGerd Hoffmanncat > $TMPC <<EOF 424307119e7SGerd Hoffmann#include <$1> 425307119e7SGerd Hoffmannint main(void) { return 0; } 426307119e7SGerd HoffmannEOF 427307119e7SGerd Hoffmann compile_object 428307119e7SGerd Hoffmann} 429307119e7SGerd Hoffmann 43093b25869SJohn Snowwrite_c_skeleton() { 43193b25869SJohn Snow cat > $TMPC <<EOF 43293b25869SJohn Snowint main(void) { return 0; } 43393b25869SJohn SnowEOF 43493b25869SJohn Snow} 43593b25869SJohn Snow 436bbea4050SPeter Maydellif check_define __linux__ ; then 437ba7c60c2SPaolo Bonzini targetos=linux 438bbea4050SPeter Maydellelif check_define _WIN32 ; then 439ba7c60c2SPaolo Bonzini targetos=windows 440bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 441ba7c60c2SPaolo Bonzini targetos=openbsd 442bbea4050SPeter Maydellelif check_define __sun__ ; then 443ba7c60c2SPaolo Bonzini targetos=sunos 444bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 445ba7c60c2SPaolo Bonzini targetos=haiku 446951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 447ba7c60c2SPaolo Bonzini targetos=freebsd 448951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 449ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 450951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 451ba7c60c2SPaolo Bonzini targetos=dragonfly 452951fedfcSPeter Maydellelif check_define __NetBSD__; then 453ba7c60c2SPaolo Bonzini targetos=netbsd 454951fedfcSPeter Maydellelif check_define __APPLE__; then 455ba7c60c2SPaolo Bonzini targetos=darwin 456bbea4050SPeter Maydellelse 457951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 458951fedfcSPeter Maydell # might be going to just print the --help text, or it might 459951fedfcSPeter Maydell # be the result of a missing compiler. 460ba7c60c2SPaolo Bonzini targetos=bogus 461bbea4050SPeter Maydellfi 462bbea4050SPeter Maydell 46365eff01bSPaolo Bonzini# OS specific 46465eff01bSPaolo Bonzini 4653b0d8643SPaolo Bonzinimingw32="no" 4663b0d8643SPaolo Bonzinibsd="no" 4673b0d8643SPaolo Bonzinilinux="no" 4683b0d8643SPaolo Bonzinisolaris="no" 46965eff01bSPaolo Bonzinicase $targetos in 47065eff01bSPaolo Bonziniwindows) 47165eff01bSPaolo Bonzini mingw32="yes" 47265eff01bSPaolo Bonzini plugins="no" 47365eff01bSPaolo Bonzini pie="no" 47465eff01bSPaolo Bonzini;; 47565eff01bSPaolo Bonzinignu/kfreebsd) 47665eff01bSPaolo Bonzini bsd="yes" 47765eff01bSPaolo Bonzini;; 47865eff01bSPaolo Bonzinifreebsd) 47965eff01bSPaolo Bonzini bsd="yes" 48065eff01bSPaolo Bonzini make="${MAKE-gmake}" 48165eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 48265eff01bSPaolo Bonzini;; 48365eff01bSPaolo Bonzinidragonfly) 48465eff01bSPaolo Bonzini bsd="yes" 48565eff01bSPaolo Bonzini make="${MAKE-gmake}" 48665eff01bSPaolo Bonzini;; 48765eff01bSPaolo Bonzininetbsd) 48865eff01bSPaolo Bonzini bsd="yes" 48965eff01bSPaolo Bonzini make="${MAKE-gmake}" 49065eff01bSPaolo Bonzini;; 49165eff01bSPaolo Bonziniopenbsd) 49265eff01bSPaolo Bonzini bsd="yes" 49365eff01bSPaolo Bonzini make="${MAKE-gmake}" 49465eff01bSPaolo Bonzini;; 49565eff01bSPaolo Bonzinidarwin) 49665eff01bSPaolo Bonzini bsd="yes" 49765eff01bSPaolo Bonzini darwin="yes" 49865eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 49965eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 50065eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 50165eff01bSPaolo Bonzini;; 50265eff01bSPaolo Bonzinisunos) 50365eff01bSPaolo Bonzini solaris="yes" 50465eff01bSPaolo Bonzini make="${MAKE-gmake}" 50565eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 50665eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 50765eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 50865eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 50965eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 51065eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 511bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 512bbea4050SPeter Maydell # the correct CPU with the --cpu option. 513bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 514bbea4050SPeter Maydell cpu="x86_64" 515bbea4050SPeter Maydell fi 51665eff01bSPaolo Bonzini;; 51765eff01bSPaolo Bonzinihaiku) 51865eff01bSPaolo Bonzini pie="no" 51965eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 52065eff01bSPaolo Bonzini;; 52165eff01bSPaolo Bonzinilinux) 52265eff01bSPaolo Bonzini linux="yes" 52365eff01bSPaolo Bonzini;; 524bbea4050SPeter Maydellesac 525bbea4050SPeter Maydell 5262ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5272ff6b91eSJuan Quintela # command line argument 5282ff6b91eSJuan Quintela : 5292ff6b91eSJuan Quintelaelif check_define __i386__ ; then 530ac0df51dSaliguori cpu="i386" 531ac0df51dSaliguorielif check_define __x86_64__ ; then 532c72b26ecSRichard Henderson if check_define __ILP32__ ; then 533c72b26ecSRichard Henderson cpu="x32" 534c72b26ecSRichard Henderson else 535ac0df51dSaliguori cpu="x86_64" 536c72b26ecSRichard Henderson fi 5373aa9bd6cSblueswir1elif check_define __sparc__ ; then 5383aa9bd6cSblueswir1 if check_define __arch64__ ; then 5393aa9bd6cSblueswir1 cpu="sparc64" 5403aa9bd6cSblueswir1 else 5413aa9bd6cSblueswir1 cpu="sparc" 5423aa9bd6cSblueswir1 fi 543fdf7ed96Smalcelif check_define _ARCH_PPC ; then 544fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 545f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 546f8378accSRichard Henderson cpu="ppc64le" 547f8378accSRichard Henderson else 548fdf7ed96Smalc cpu="ppc64" 549f8378accSRichard Henderson fi 550ac0df51dSaliguori else 551fdf7ed96Smalc cpu="ppc" 552fdf7ed96Smalc fi 553afa05235SAurelien Jarnoelif check_define __mips__ ; then 554afa05235SAurelien Jarno cpu="mips" 555d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 556d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 557d66ed0eaSAurelien Jarno cpu="s390x" 558d66ed0eaSAurelien Jarno else 559d66ed0eaSAurelien Jarno cpu="s390" 560d66ed0eaSAurelien Jarno fi 561c4f80543SAlistair Franciselif check_define __riscv ; then 562ba0e7333SRichard Henderson cpu="riscv" 56321d89f84SPeter Maydellelif check_define __arm__ ; then 56421d89f84SPeter Maydell cpu="arm" 5651f080313SClaudio Fontanaelif check_define __aarch64__ ; then 5661f080313SClaudio Fontana cpu="aarch64" 567dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 568dfcf900bSWANG Xuerui cpu="loongarch64" 569fdf7ed96Smalcelse 57089138857SStefan Weil cpu=$(uname -m) 571ac0df51dSaliguorifi 572ac0df51dSaliguori 573823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 574359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 5757d13299dSbellardcase "$cpu" in 576e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 577e4da0e39SPaolo Bonzini cpu="arm" ;; 578e4da0e39SPaolo Bonzini 5797d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 58097a847bcSbellard cpu="i386" 581e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 582e4da0e39SPaolo Bonzini x32) 5834da270beSPaolo Bonzini cpu="x86_64" 584e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 585aaa5fa14Saurel32 x86_64|amd64) 586aaa5fa14Saurel32 cpu="x86_64" 587e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 588e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 589e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 590e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 591e4da0e39SPaolo Bonzini 592afa05235SAurelien Jarno mips*) 593e4da0e39SPaolo Bonzini cpu="mips" ;; 594e4da0e39SPaolo Bonzini 595e4da0e39SPaolo Bonzini ppc) 596e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 597e4da0e39SPaolo Bonzini ppc64) 598ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mbig-endian" ;; 599e4da0e39SPaolo Bonzini ppc64le) 600d8ff892dSPaolo Bonzini cpu="ppc64" 601ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mlittle-endian" ;; 602e4da0e39SPaolo Bonzini 603e4da0e39SPaolo Bonzini s390) 604823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 605e4da0e39SPaolo Bonzini s390x) 606e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 607e4da0e39SPaolo Bonzini 6083142255cSblueswir1 sparc|sun4[cdmuv]) 609ae228531Sbellard cpu="sparc" 610e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 611e4da0e39SPaolo Bonzini sparc64) 612e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6137d13299dSbellardesac 614e2d52ad3SJuan Quintela 6150db4a067SPaolo Bonzini: ${make=${MAKE-make}} 616b6daf4d3SPaolo Bonzini 617faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 618faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 619ddf90699SEduardo Habkost# we check that too 620faf44142SDaniel P. Berrangépython= 6210a01d76fSMarc-André Lureauexplicit_python=no 622ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 623faf44142SDaniel P. Berrangédo 624faf44142SDaniel P. Berrangé if has "$binary" 625faf44142SDaniel P. Berrangé then 62695c5f2deSPaolo Bonzini python=$(command -v "$binary") 627faf44142SDaniel P. Berrangé break 628faf44142SDaniel P. Berrangé fi 629faf44142SDaniel P. Berrangédone 630903458c8SMarkus Armbruster 631903458c8SMarkus Armbruster 63239d87c8cSAlex Bennée# Check for ancillary tools used in testing 63339d87c8cSAlex Bennéegenisoimage= 6343df437c7SAlex Bennéefor binary in genisoimage mkisofs 63539d87c8cSAlex Bennéedo 63639d87c8cSAlex Bennée if has $binary 63739d87c8cSAlex Bennée then 63839d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 63939d87c8cSAlex Bennée break 64039d87c8cSAlex Bennée fi 64139d87c8cSAlex Bennéedone 64239d87c8cSAlex Bennée 6433c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6443c4a4d0dSPeter Maydellif has clang; then 6453c4a4d0dSPeter Maydell objcc=clang 6463c4a4d0dSPeter Maydellelse 6473c4a4d0dSPeter Maydell objcc="$cc" 6483c4a4d0dSPeter Maydellfi 6493c4a4d0dSPeter Maydell 6503457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6513457a3f8SJuan Quintela EXESUF=".exe" 65278e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6535770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 65493b25869SJohn Snow write_c_skeleton; 655d17f305aSPaolo Bonzini prefix="/qemu" 656c09c1ce7SPaolo Bonzini bindir="" 65777433a5fSMarc-André Lureau qemu_suffix="" 6583457a3f8SJuan Quintelafi 6593457a3f8SJuan Quintela 660487fefdbSAnthony Liguoriwerror="" 66185aa5189Sbellard 66261d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 66361d63097SPaolo Bonzini 66461d63097SPaolo Bonzinimeson_options= 665c54b59eeSPaolo Bonzinimeson_option_add() { 666c54b59eeSPaolo Bonzini meson_options="$meson_options $(quote_sh "$1")" 667c54b59eeSPaolo Bonzini} 66861d63097SPaolo Bonzinimeson_option_parse() { 66961d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 67061d63097SPaolo Bonzini if test $? -eq 1; then 67161d63097SPaolo Bonzini echo "ERROR: unknown option $1" 67261d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 67361d63097SPaolo Bonzini exit 1 67461d63097SPaolo Bonzini fi 67561d63097SPaolo Bonzini} 67661d63097SPaolo Bonzini 6777d13299dSbellardfor opt do 67889138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 6797d13299dSbellard case "$opt" in 6802efc3265Sbellard --help|-h) show_help=yes 6812efc3265Sbellard ;; 68299123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 68399123e13SMike Frysinger ;; 684b1a550a0Spbrook --prefix=*) prefix="$optarg" 6857d13299dSbellard ;; 686ac0df51dSaliguori --cross-prefix=*) 6877d13299dSbellard ;; 688ac0df51dSaliguori --cc=*) 6897d13299dSbellard ;; 690b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 69183469015Sbellard ;; 69283f73fceSTomoki Sekiyama --cxx=*) 69383f73fceSTomoki Sekiyama ;; 6943c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 6953c4a4d0dSPeter Maydell ;; 696b1a550a0Spbrook --make=*) make="$optarg" 6977d13299dSbellard ;; 698b6daf4d3SPaolo Bonzini --install=*) 6996a882643Spbrook ;; 7000a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 701c886edfbSBlue Swirl ;; 702a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 703a5665051SPaolo Bonzini ;; 704a5665051SPaolo Bonzini --meson=*) meson="$optarg" 705a5665051SPaolo Bonzini ;; 70648328880SPaolo Bonzini --ninja=*) ninja="$optarg" 70748328880SPaolo Bonzini ;; 708e2d8830eSBrad --smbd=*) smbd="$optarg" 709e2d8830eSBrad ;; 710e2a2ed06SJuan Quintela --extra-cflags=*) 7117d13299dSbellard ;; 71211cde1c8SBruno Dominguez --extra-cxxflags=*) 71311cde1c8SBruno Dominguez ;; 714e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) 715e910c7d9SPhilippe Mathieu-Daudé ;; 716e2a2ed06SJuan Quintela --extra-ldflags=*) 7177d13299dSbellard ;; 718d75402b5SAlex Bennée --cross-cc-*) 719d75402b5SAlex Bennée ;; 720c54b59eeSPaolo Bonzini --enable-debug-info) meson_option_add -Ddebug=true 72128609749SPaolo Bonzini ;; 722c54b59eeSPaolo Bonzini --disable-debug-info) meson_option_add -Ddebug=false 72328609749SPaolo Bonzini ;; 72417969268SFam Zheng --enable-modules) 72517969268SFam Zheng modules="yes" 72617969268SFam Zheng ;; 7273aa88b31SStefan Hajnoczi --disable-modules) 7283aa88b31SStefan Hajnoczi modules="no" 7293aa88b31SStefan Hajnoczi ;; 7302ff6b91eSJuan Quintela --cpu=*) 7317d13299dSbellard ;; 732b1a550a0Spbrook --target-list=*) target_list="$optarg" 733447e133fSAlex Bennée if test "$target_list_exclude"; then 734447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 735447e133fSAlex Bennée fi 736447e133fSAlex Bennée ;; 737447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 738447e133fSAlex Bennée if test "$target_list"; then 739447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 740447e133fSAlex Bennée fi 741de83cd02Sbellard ;; 742c54b59eeSPaolo Bonzini --with-default-devices) meson_option_add -Ddefault_devices=true 743f3494749SPaolo Bonzini ;; 744c54b59eeSPaolo Bonzini --without-default-devices) meson_option_add -Ddefault_devices=false 745f3494749SPaolo Bonzini ;; 746d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 747d1d5e9eeSAlex Bennée ;; 748d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 749d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 750d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 751d1d5e9eeSAlex Bennée if test -f "$cf"; then 752d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 753d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 754d1d5e9eeSAlex Bennée else 755d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 756d1d5e9eeSAlex Bennée fi 757d1d5e9eeSAlex Bennée ;; 758c87ea116SAlex Bennée --without-default-features) # processed above 759c87ea116SAlex Bennée ;; 76079427693SLoïc Minier --static) 76179427693SLoïc Minier static="yes" 76217884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 76343ce4dfeSbellard ;; 7640b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 7650b24e75fSPaolo Bonzini ;; 76677433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 767023d3d67SEduardo Habkost ;; 768181ce1d0SOlaf Hering --host=*|--build=*|\ 769181ce1d0SOlaf Hering --disable-dependency-tracking|\ 770785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 771fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 772023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 773023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 774023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 775023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 776023ddd74SMax Filippov # lots of directory switches by default. 777023ddd74SMax Filippov ;; 778f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 779f8393946Saurel32 ;; 780f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 781f8393946Saurel32 ;; 782f3d08ee6SPaul Brook --enable-debug) 783f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 784f3d08ee6SPaul Brook debug_tcg="yes" 785c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 786c54b59eeSPaolo Bonzini meson_option_add -Doptimization=0 787b553a042SJohn Snow fortify_source="no" 788f3d08ee6SPaul Brook ;; 789247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 790247724cbSMarc-André Lureau ;; 791247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 792247724cbSMarc-André Lureau ;; 7930aebab04SLingfeng Yang --enable-tsan) tsan="yes" 7940aebab04SLingfeng Yang ;; 7950aebab04SLingfeng Yang --disable-tsan) tsan="no" 7960aebab04SLingfeng Yang ;; 7974d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 798c20709aaSbellard ;; 799fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 800fd6fc214SPaolo Bonzini ;; 8014d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 8027c57bdd8SMarc-André Lureau ;; 80303a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 804675b9b53SMarc-André Lureau ;; 8051badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 806d1a14257SAlex Bennée plugins="no" 807b3f6ea7eSPaolo Bonzini ;; 8081badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 809b3f6ea7eSPaolo Bonzini ;; 810cad25d69Spbrook --disable-system) softmmu="no" 8110a8e90f4Spbrook ;; 812cad25d69Spbrook --enable-system) softmmu="yes" 8130a8e90f4Spbrook ;; 8140953a80fSZachary Amsden --disable-user) 8150953a80fSZachary Amsden linux_user="no" ; 8160953a80fSZachary Amsden bsd_user="no" ; 8170953a80fSZachary Amsden ;; 8180953a80fSZachary Amsden --enable-user) ;; 819831b7825Sths --disable-linux-user) linux_user="no" 8200a8e90f4Spbrook ;; 821831b7825Sths --enable-linux-user) linux_user="yes" 822831b7825Sths ;; 82384778508Sblueswir1 --disable-bsd-user) bsd_user="no" 82484778508Sblueswir1 ;; 82584778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 82684778508Sblueswir1 ;; 82740d6444eSAvi Kivity --enable-pie) pie="yes" 82834005a00SKirill A. Shutemov ;; 82940d6444eSAvi Kivity --disable-pie) pie="no" 83034005a00SKirill A. Shutemov ;; 83185aa5189Sbellard --enable-werror) werror="yes" 83285aa5189Sbellard ;; 83385aa5189Sbellard --disable-werror) werror="no" 83485aa5189Sbellard ;; 83563678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 83663678e17SSteven Noonan ;; 83763678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 83863678e17SSteven Noonan ;; 8391e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 8401e4f6065SDaniele Buono ;; 8411e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 8421e4f6065SDaniele Buono ;; 8439e62ba48SDaniele Buono --enable-cfi) 8449e62ba48SDaniele Buono cfi="true"; 845c54b59eeSPaolo Bonzini meson_option_add -Db_lto=true 8469e62ba48SDaniele Buono ;; 8479e62ba48SDaniele Buono --disable-cfi) cfi="false" 8489e62ba48SDaniele Buono ;; 849fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 8502df87df7SJuan Quintela ;; 851fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 852fbb4121dSPaolo Bonzini ;; 853fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 854fbb4121dSPaolo Bonzini ;; 85503a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 8562df87df7SJuan Quintela ;; 857519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 858519175a2SAlex Barcelo ;; 8591ffb3bbbSPaolo Bonzini --disable-zlib-test) 8601ece9905SAlon Levy ;; 86152b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 86252b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 863583f6e7bSStefan Hajnoczi ;; 864cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 865cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 866cb6414dfSFam Zheng ;; 867315d3184SFam Zheng --enable-uuid|--disable-uuid) 868315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 869315d3184SFam Zheng ;; 870cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 871cc84d63aSDaniel P. Berrange ;; 8727d7dbf9dSDan Streetman --with-git-submodules=*) 8737d7dbf9dSDan Streetman git_submodules_action="$optarg" 874f62bbee5SDaniel P. Berrange ;; 8759b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 8769b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 8779b8e4298SAlex Bennée else 8789b8e4298SAlex Bennée plugins="yes" 8799b8e4298SAlex Bennée fi 88040e8c6f4SAlex Bennée ;; 88140e8c6f4SAlex Bennée --disable-plugins) plugins="no" 88240e8c6f4SAlex Bennée ;; 883afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 884afc3a8f9SAlex Bennée ;; 885afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 886afc3a8f9SAlex Bennée ;; 887f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 888f48e590aSAlex Bennée ;; 8893b4da132SPaolo Bonzini # backwards compatibility options 8903b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 8913b4da132SPaolo Bonzini ;; 8923b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 8933b4da132SPaolo Bonzini ;; 8943b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 8953b4da132SPaolo Bonzini ;; 8963b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 8973b4da132SPaolo Bonzini ;; 8983b4da132SPaolo Bonzini # everything else has the same name in configure and meson 8994fda6011SPaolo Bonzini --*) meson_option_parse "$opt" "$optarg" 9007f1559c6Sbalrog ;; 9017d13299dSbellard esac 9027d13299dSbellarddone 9037d13299dSbellard 904d1a14257SAlex Bennée# test for any invalid configuration combinations 905d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 906d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 907d1a14257SAlex Bennéefi 908d1a14257SAlex Bennée 9097d7dbf9dSDan Streetmancase $git_submodules_action in 9107d7dbf9dSDan Streetman update|validate) 9117d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 9127d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 9137d7dbf9dSDan Streetman exit 1 9147d7dbf9dSDan Streetman fi 9157d7dbf9dSDan Streetman ;; 9167d7dbf9dSDan Streetman ignore) 917b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 918b80fd281SPaolo Bonzini then 919b80fd281SPaolo Bonzini echo 920b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 921b80fd281SPaolo Bonzini echo 922b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 923b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 924b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 925b80fd281SPaolo Bonzini else 926b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 927b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 928b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 929b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 930b80fd281SPaolo Bonzini echo 931b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 932b80fd281SPaolo Bonzini echo 933b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 934b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 935b80fd281SPaolo Bonzini fi 936b80fd281SPaolo Bonzini echo 937b80fd281SPaolo Bonzini exit 1 938b80fd281SPaolo Bonzini fi 9397d7dbf9dSDan Streetman ;; 9407d7dbf9dSDan Streetman *) 9417d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 9427d7dbf9dSDan Streetman exit 1 9437d7dbf9dSDan Streetman ;; 9447d7dbf9dSDan Streetmanesac 9457d7dbf9dSDan Streetman 9469557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 947b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 9482038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 9499557af9cSAlex Bennéefi 95079f3b12fSPeter Crosthwaite 95160e0df25SPeter Maydelldefault_target_list="" 9526e92f823SPeter Maydellmak_wilds="" 9536e92f823SPeter Maydell 954b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 955b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 956b915a2f1SPaolo Bonzini linux_user=yes 957b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 958b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 959b915a2f1SPaolo Bonzini fi 960b915a2f1SPaolo Bonzinifi 961b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 962b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 963b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 964b915a2f1SPaolo Bonzini fi 965b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 966b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 967b915a2f1SPaolo Bonzini fi 968b915a2f1SPaolo Bonzinifi 96960e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 970812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 97160e0df25SPeter Maydellfi 97260e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 973812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 97460e0df25SPeter Maydellfi 97560e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 976812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 97760e0df25SPeter Maydellfi 97860e0df25SPeter Maydell 979447e133fSAlex Bennéefor config in $mak_wilds; do 980447e133fSAlex Bennée target="$(basename "$config" .mak)" 98198db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 982447e133fSAlex Bennée default_target_list="${default_target_list} $target" 983447e133fSAlex Bennée fi 984447e133fSAlex Bennéedone 9856e92f823SPeter Maydell 986af5db58eSpbrookif test x"$show_help" = x"yes" ; then 987af5db58eSpbrookcat << EOF 988af5db58eSpbrook 989af5db58eSpbrookUsage: configure [options] 990af5db58eSpbrookOptions: [defaults in brackets after descriptions] 991af5db58eSpbrook 99208fb77edSStefan WeilStandard options: 99308fb77edSStefan Weil --help print this message 99408fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 99574154d7eSThomas Huth --target-list=LIST set target list (default: build all) 99608fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 99708fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 998447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 99908fb77edSStefan Weil 100008fb77edSStefan WeilAdvanced options (experts only): 10013812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 100208fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 100308fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 100408fb77edSStefan Weil build time 100508fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 100608fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1007a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1008a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 1009e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS 101008fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1011d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1012479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 101308fb77edSStefan Weil --make=MAKE use specified make [$make] 101408fb77edSStefan Weil --python=PYTHON use specified python [$python] 1015a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 101648328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 101708fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1018db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 10197d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 10207d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 10217d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 102208fb77edSStefan Weil --static enable static build [$static] 102308fb77edSStefan Weil --bindir=PATH install binaries in PATH 102413336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1025ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1026c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1027c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1028c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1029d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1030d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 103108fb77edSStefan Weil --enable-debug enable common debug build options 1032247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 10330aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 103408fb77edSStefan Weil --disable-werror disable compilation abort on warning 103563678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 1036c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 103708fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 103833c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 103940e8c6f4SAlex Bennée --enable-plugins 104040e8c6f4SAlex Bennée enable plugins via shared library loading 1041afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1042f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 104361d63097SPaolo BonziniEOF 104461d63097SPaolo Bonzini meson_options_help 104561d63097SPaolo Bonzinicat << EOF 1046c23f23b9SMichael Tokarev system all system emulation targets 1047c23f23b9SMichael Tokarev user supported user emulation targets 1048c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1049c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1050c23f23b9SMichael Tokarev pie Position Independent Executables 105121e709aaSMarc-André Lureau modules modules support (non-Windows) 1052c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1053c23f23b9SMichael Tokarev debug-info debugging information 10541e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 10551e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 105608fb77edSStefan Weil 105708fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1058af5db58eSpbrookEOF 10592d2ad6d0SFam Zhengexit 0 1060af5db58eSpbrookfi 1061af5db58eSpbrook 10629c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1063bb768f71SThomas Huthrm -f */config-devices.mak.d 10649c790242SThomas Huth 1065faf44142SDaniel P. Berrangéif test -z "$python" 1066faf44142SDaniel P. Berrangéthen 1067c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1068c53eeaf7SStefan Hajnoczifi 10698e2c76bdSRoman Bolshakovif ! has "$make" 10708e2c76bdSRoman Bolshakovthen 10718e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 10728e2c76bdSRoman Bolshakovfi 1073c53eeaf7SStefan Hajnoczi 1074c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1075c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 10761b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 10771b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1078c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1079c53eeaf7SStefan Hajnoczifi 1080c53eeaf7SStefan Hajnoczi 1081755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1082406ab2f3SCleber 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) 1083755ee70fSCleber Rosa 1084c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1085c53eeaf7SStefan Hajnoczipython="$python -B" 1086c53eeaf7SStefan Hajnoczi 10870a01d76fSMarc-André Lureauif test -z "$meson"; then 10886638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 10890a01d76fSMarc-André Lureau meson=meson 10907d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 10910a01d76fSMarc-André Lureau meson=git 10920a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 10930a01d76fSMarc-André Lureau meson=internal 10940a01d76fSMarc-André Lureau else 10950a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 10960a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 10970a01d76fSMarc-André Lureau else 1098a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1099a5665051SPaolo Bonzini fi 11000a01d76fSMarc-André Lureau fi 11010a01d76fSMarc-André Lureauelse 11020a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 11030a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 11040a01d76fSMarc-André Lureau # 11050a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 11060a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 11070a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 11080a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 11090a01d76fSMarc-André Lureau case "$meson" in 11100a01d76fSMarc-André Lureau git | internal) ;; 11110a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 11120a01d76fSMarc-André Lureau esac 11130a01d76fSMarc-André Lureau fi 11140a01d76fSMarc-André Lureaufi 1115a5665051SPaolo Bonzini 11160a01d76fSMarc-André Lureauif test "$meson" = git; then 11170a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 11180a01d76fSMarc-André Lureaufi 11190a01d76fSMarc-André Lureau 11200a01d76fSMarc-André Lureaucase "$meson" in 11210a01d76fSMarc-André Lureau git | internal) 11220a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 11230a01d76fSMarc-André Lureau ;; 112484ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 11250a01d76fSMarc-André Lureauesac 11260a01d76fSMarc-André Lureau 112709e93326SPaolo Bonzini# Probe for ninja 112848328880SPaolo Bonzini 112948328880SPaolo Bonziniif test -z "$ninja"; then 113048328880SPaolo Bonzini for c in ninja ninja-build samu; do 113148328880SPaolo Bonzini if has $c; then 113248328880SPaolo Bonzini ninja=$(command -v "$c") 113348328880SPaolo Bonzini break 113448328880SPaolo Bonzini fi 113548328880SPaolo Bonzini done 113609e93326SPaolo Bonzini if test -z "$ninja"; then 113709e93326SPaolo Bonzini error_exit "Cannot find Ninja" 113809e93326SPaolo Bonzini fi 113948328880SPaolo Bonzinifi 1140a5665051SPaolo Bonzini 11419aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 11429aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 11439aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 11449aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 11459aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 11469aae6e54SDaniel Henrique Barbozaif compile_object ; then 11479aae6e54SDaniel Henrique Barboza : C compiler works ok 11489aae6e54SDaniel Henrique Barbozaelse 11499aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 11509aae6e54SDaniel Henrique Barbozafi 11519aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 11529aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 11539aae6e54SDaniel Henrique Barbozafi 11549aae6e54SDaniel Henrique Barboza 11559c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 11569c83ffd8SPeter Maydell# by default. Only enable by default for git builds 11579c83ffd8SPeter Maydellif test -z "$werror" ; then 11587d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1159e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 11609c83ffd8SPeter Maydell werror="yes" 11619c83ffd8SPeter Maydell else 11629c83ffd8SPeter Maydell werror="no" 11639c83ffd8SPeter Maydell fi 11649c83ffd8SPeter Maydellfi 11659c83ffd8SPeter Maydell 1166975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1167fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1168fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1169fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1170fb59dabdSPeter Maydell # host OS we should stop now. 1171951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1172fb59dabdSPeter Maydellfi 1173fb59dabdSPeter Maydell 1174efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1175efc6c070SThomas Huthcat > $TMPC << EOF 1176efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1177efc6c070SThomas Huth# ifdef __apple_build_version__ 11782a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 11792a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1180efc6c070SThomas Huth# endif 1181efc6c070SThomas Huth# else 11822a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 11832a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1184efc6c070SThomas Huth# endif 1185efc6c070SThomas Huth# endif 1186efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 11873830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 11883830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1189efc6c070SThomas Huth# endif 1190efc6c070SThomas Huth#else 1191efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1192efc6c070SThomas Huth#endif 1193efc6c070SThomas Huthint main (void) { return 0; } 1194efc6c070SThomas HuthEOF 1195efc6c070SThomas Huthif ! compile_prog "" "" ; then 11963830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1197efc6c070SThomas Huthfi 1198efc6c070SThomas Huth 119900849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 120000849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 120100849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 120200849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 120300849b92SRichard Henderson# just silently disable some features, so it's too error prone. 120400849b92SRichard Henderson 120500849b92SRichard Hendersonwarn_flags= 120600849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 120700849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 120800849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 120900849b92SRichard Hendersonadd_to warn_flags -Wformat-security 121000849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 121100849b92SRichard Hendersonadd_to warn_flags -Winit-self 121200849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 121300849b92SRichard Hendersonadd_to warn_flags -Wempty-body 121400849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 121500849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 121600849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 12170a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 121800849b92SRichard Henderson 121900849b92SRichard Hendersonnowarn_flags= 122000849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 122100849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 122200849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 122300849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 122400849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1225aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1226bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 122700849b92SRichard Henderson 122800849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 122993b25869SJohn Snow 123093b25869SJohn Snowcc_has_warning_flag() { 123193b25869SJohn Snow write_c_skeleton; 123293b25869SJohn Snow 1233a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1234a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1235a1d29d6cSPeter Maydell # warning options). 123693b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 123793b25869SJohn Snow compile_prog "-Werror $optflag" "" 123893b25869SJohn Snow} 123993b25869SJohn Snow 12404cb37d11SPhilippe Mathieu-Daudéobjcc_has_warning_flag() { 12414cb37d11SPhilippe Mathieu-Daudé cat > $TMPM <<EOF 12424cb37d11SPhilippe Mathieu-Daudéint main(void) { return 0; } 12434cb37d11SPhilippe Mathieu-DaudéEOF 12444cb37d11SPhilippe Mathieu-Daudé 12454cb37d11SPhilippe Mathieu-Daudé # Use the positive sense of the flag when testing for -Wno-wombat 12464cb37d11SPhilippe Mathieu-Daudé # support (gcc will happily accept the -Wno- form of unknown 12474cb37d11SPhilippe Mathieu-Daudé # warning options). 12484cb37d11SPhilippe Mathieu-Daudé optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 12494cb37d11SPhilippe Mathieu-Daudé do_objc -Werror $optflag \ 12504cb37d11SPhilippe Mathieu-Daudé $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ 12514cb37d11SPhilippe Mathieu-Daudé -o $TMPE $TMPM $QEMU_LDFLAGS 12524cb37d11SPhilippe Mathieu-Daudé} 12534cb37d11SPhilippe Mathieu-Daudé 125493b25869SJohn Snowfor flag in $gcc_flags; do 125593b25869SJohn Snow if cc_has_warning_flag $flag ; then 12568d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 12578d05095cSPaolo Bonzini fi 12584cb37d11SPhilippe Mathieu-Daudé if objcc_has_warning_flag $flag ; then 12594cb37d11SPhilippe Mathieu-Daudé QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" 12604cb37d11SPhilippe Mathieu-Daudé fi 12618d05095cSPaolo Bonzinidone 12628d05095cSPaolo Bonzini 126363678e17SSteven Noonanif test "$stack_protector" != "no"; then 1264fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1265fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1266fccd35a0SRodrigo Rebello{ 1267fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1268fccd35a0SRodrigo Rebello while (*c) { 1269fccd35a0SRodrigo Rebello *p++ = *c++; 1270fccd35a0SRodrigo Rebello } 1271fccd35a0SRodrigo Rebello return 0; 1272fccd35a0SRodrigo Rebello} 1273fccd35a0SRodrigo RebelloEOF 127463678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 12753b463a3fSMiroslav Rezanina sp_on=0 127663678e17SSteven Noonan for flag in $gcc_flags; do 1277590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1278590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1279086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1280590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 128163678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1282db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 12833b463a3fSMiroslav Rezanina sp_on=1 128463678e17SSteven Noonan break 128563678e17SSteven Noonan fi 128663678e17SSteven Noonan done 12873b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 12883b463a3fSMiroslav Rezanina if test $sp_on = 0; then 12893b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 12903b463a3fSMiroslav Rezanina fi 12913b463a3fSMiroslav Rezanina fi 129237746c5eSMarc-André Lureaufi 129337746c5eSMarc-André Lureau 129420bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 129520bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 129620bc94a2SPaolo Bonzinicat > $TMPC << EOF 129720bc94a2SPaolo Bonzinistruct { 129820bc94a2SPaolo Bonzini int a[2]; 129920bc94a2SPaolo Bonzini} x = {0}; 130020bc94a2SPaolo BonziniEOF 130120bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 130220bc94a2SPaolo Bonzini : 130320bc94a2SPaolo Bonzinielse 130420bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 130520bc94a2SPaolo Bonzinifi 130620bc94a2SPaolo Bonzini 130721e709aaSMarc-André Lureau# Our module code doesn't support Windows 130821e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 130921e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 131021e709aaSMarc-André Lureaufi 131121e709aaSMarc-André Lureau 13125f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 131340d6444eSAvi Kivityif test "$static" = "yes" ; then 1314aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1315aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1316aa0d1f44SPaolo Bonzini fi 13175f2453acSAlex Bennée if test "$plugins" = "yes"; then 13185f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1319ba4dd2aaSAlex Bennée else 1320ba4dd2aaSAlex Bennée plugins="no" 13215f2453acSAlex Bennée fi 132240d6444eSAvi Kivityfi 132337650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 132440d6444eSAvi Kivity 132540d6444eSAvi Kivitycat > $TMPC << EOF 132621d4a791SAvi Kivity 132721d4a791SAvi Kivity#ifdef __linux__ 132821d4a791SAvi Kivity# define THREAD __thread 132921d4a791SAvi Kivity#else 133021d4a791SAvi Kivity# define THREAD 133121d4a791SAvi Kivity#endif 133221d4a791SAvi Kivitystatic THREAD int tls_var; 133321d4a791SAvi Kivityint main(void) { return tls_var; } 133440d6444eSAvi KivityEOF 1335b2634124SRichard Henderson 1336ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1337ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1338412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1339412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1340ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1341412aeacdSAlex Bennéefi 1342412aeacdSAlex Bennée 134312781462SRichard Hendersonif test "$static" = "yes"; then 1344eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 13455770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 134612781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 134712781462SRichard Henderson pie="yes" 134812781462SRichard Henderson elif test "$pie" = "yes"; then 134912781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 135012781462SRichard Henderson else 135112781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 135212781462SRichard Henderson pie="no" 135312781462SRichard Henderson fi 135412781462SRichard Hendersonelif test "$pie" = "no"; then 13555770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1356ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1357eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 13585770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 13595770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 136040d6444eSAvi Kivity pie="yes" 13612c674109SRichard Hendersonelif test "$pie" = "yes"; then 136276ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 136340d6444eSAvi Kivityelse 136440d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 136540d6444eSAvi Kivity pie="no" 136640d6444eSAvi Kivityfi 136740d6444eSAvi Kivity 1368e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1369e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1370e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1371e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1372e6cbd751SRichard Hendersonfi 1373e6cbd751SRichard Henderson 137409dada40SPaolo Bonzini########################################## 137509dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 137609dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 137709dada40SPaolo Bonzini# specification is necessary 137809dada40SPaolo Bonzini 137909dada40SPaolo Bonziniif test "$cpu" = "i386"; then 138009dada40SPaolo Bonzini cat > $TMPC << EOF 138109dada40SPaolo Bonzinistatic int sfaa(int *ptr) 138209dada40SPaolo Bonzini{ 138309dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 138409dada40SPaolo Bonzini} 138509dada40SPaolo Bonzini 138609dada40SPaolo Bonziniint main(void) 138709dada40SPaolo Bonzini{ 138809dada40SPaolo Bonzini int val = 42; 13891405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 139009dada40SPaolo Bonzini sfaa(&val); 139109dada40SPaolo Bonzini return val; 139209dada40SPaolo Bonzini} 139309dada40SPaolo BonziniEOF 139409dada40SPaolo Bonzini if ! compile_prog "" "" ; then 139509dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 139609dada40SPaolo Bonzini fi 139709dada40SPaolo Bonzinifi 139809dada40SPaolo Bonzini 139956267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 140056267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 140156267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 140256267b62SPhilippe Mathieu-Daudéfi 140356267b62SPhilippe Mathieu-Daudé 1404afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1405fdb75aefSPaolo Bonzini default_targets=yes 1406d880a3baSPaolo Bonzini for target in $default_target_list; do 1407d880a3baSPaolo Bonzini target_list="$target_list $target" 1408d880a3baSPaolo Bonzini done 1409d880a3baSPaolo Bonzini target_list="${target_list# }" 1410121afa9eSAnthony Liguorielse 1411fdb75aefSPaolo Bonzini default_targets=no 141289138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1413d880a3baSPaolo Bonzini for target in $target_list; do 141425b48338SPeter Maydell # Check that we recognised the target name; this allows a more 141525b48338SPeter Maydell # friendly error message than if we let it fall through. 141625b48338SPeter Maydell case " $default_target_list " in 141725b48338SPeter Maydell *" $target "*) 141825b48338SPeter Maydell ;; 141925b48338SPeter Maydell *) 142025b48338SPeter Maydell error_exit "Unknown target name '$target'" 142125b48338SPeter Maydell ;; 142225b48338SPeter Maydell esac 142325b48338SPeter Maydell done 1424d880a3baSPaolo Bonzinifi 142525b48338SPeter Maydell 1426f55fe278SPaolo Bonzini# see if system emulation was really requested 1427f55fe278SPaolo Bonzinicase " $target_list " in 1428f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1429f55fe278SPaolo Bonzini ;; 1430f55fe278SPaolo Bonzini *) softmmu=no 1431f55fe278SPaolo Bonzini ;; 1432f55fe278SPaolo Bonziniesac 14335327cf48Sbellard 1434249247c9SJuan Quintelafeature_not_found() { 1435249247c9SJuan Quintela feature=$1 143621684af0SStewart Smith remedy=$2 1437249247c9SJuan Quintela 143876ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 143921684af0SStewart Smith "configure was not able to find it." \ 144021684af0SStewart Smith "$remedy" 1441249247c9SJuan Quintela} 1442249247c9SJuan Quintela 14437d13299dSbellard# --- 14447d13299dSbellard# big/little endian test 14457d13299dSbellardcat > $TMPC << EOF 1446659eb157SThomas Huth#include <stdio.h> 144761cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 144861cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1449659eb157SThomas Huthint main(int argc, char *argv[]) 1450659eb157SThomas Huth{ 1451659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 14527d13299dSbellard} 14537d13299dSbellardEOF 14547d13299dSbellard 1455659eb157SThomas Huthif compile_prog ; then 1456659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 145761cc919fSMike Frysinger bigendian="yes" 1458659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 145961cc919fSMike Frysinger bigendian="no" 14607d13299dSbellard else 14617d13299dSbellard echo big/little test failed 1462659eb157SThomas Huth exit 1 14637d13299dSbellard fi 14647d13299dSbellardelse 146561cc919fSMike Frysinger echo big/little test failed 1466659eb157SThomas Huth exit 1 14677d13299dSbellardfi 14687d13299dSbellard 1469015a33bdSGonglei########################################## 1470779ab5e3SStefan Weil# pkg-config probe 1471779ab5e3SStefan Weil 1472779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 147376ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1474779ab5e3SStefan Weilfi 1475779ab5e3SStefan Weil 1476779ab5e3SStefan Weil########################################## 1477e18df141SAnthony Liguori# glib support probe 1478a52d28afSPaolo Bonzini 14790ce9b08cSThomas Huth# When bumping glib_req_ver, please check also whether we should increase 14800ce9b08cSThomas Huth# the _WIN32_WINNT setting in osdep.h according to the value from glib 1481b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 1482aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 1483aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 1484a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 1485b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 1486b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 148754cb65d8SEmilio G. Cotafi 1488e26110cfSFam Zheng 1489aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 1490e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 149189138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 149289138857SStefan Weil glib_libs=$($pkg_config --libs $i) 1493e18df141SAnthony Liguori else 1494e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 1495e26110cfSFam Zheng fi 1496e26110cfSFam Zhengdone 1497e26110cfSFam Zheng 1498*5b9e7d05SMarc-André Lureauglib_bindir="$($pkg_config --variable=bindir glib-2.0)" 1499*5b9e7d05SMarc-André Lureauif test -z "$glib_bindir" ; then 1500*5b9e7d05SMarc-André Lureau glib_bindir="$($pkg_config --variable=prefix glib-2.0)"/bin 1501*5b9e7d05SMarc-André Lureaufi 1502*5b9e7d05SMarc-André Lureau 1503215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 1504215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 1505215b0c2fSPaolo Bonzini 1506215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 1507215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 1508215b0c2fSPaolo Bonzinifi 1509215b0c2fSPaolo Bonzini 1510977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 1511977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 1512977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 1513977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 1514977a82abSDaniel P. Berrangecat > $TMPC <<EOF 1515977a82abSDaniel P. Berrange#include <glib.h> 1516977a82abSDaniel P. Berrange#include <unistd.h> 1517977a82abSDaniel P. Berrange 1518977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 1519977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 1520977a82abSDaniel P. Berrange 1521977a82abSDaniel P. Berrangeint main(void) { 1522977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 1523977a82abSDaniel P. Berrange return 0; 1524977a82abSDaniel P. Berrange} 1525977a82abSDaniel P. BerrangeEOF 1526977a82abSDaniel P. Berrange 1527215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 1528977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 1529977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 1530977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 1531977a82abSDaniel P. Berrange "build target" 1532977a82abSDaniel P. Berrangefi 1533977a82abSDaniel P. Berrange 15349bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 15359bda600bSEric Blakecat > $TMPC << EOF 15369bda600bSEric Blake#include <glib.h> 15379bda600bSEric Blaketypedef struct Foo { 15389bda600bSEric Blake int i; 15399bda600bSEric Blake} Foo; 15409bda600bSEric Blakestatic void foo_free(Foo *f) 15419bda600bSEric Blake{ 15429bda600bSEric Blake g_free(f); 15439bda600bSEric Blake} 1544e0e7fe07SMarc-André LureauG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free) 15459bda600bSEric Blakeint main(void) { return 0; } 15469bda600bSEric BlakeEOF 15479bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 15489bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 15499bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 15505770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 15519bda600bSEric Blake fi 15529bda600bSEric Blakefi 15539bda600bSEric Blake 1554e26110cfSFam Zheng########################################## 1555f652e6afSaurel32# fdt probe 1556e169e1e1SPeter Maydell 1557fbb4121dSPaolo Bonzinicase "$fdt" in 1558fbb4121dSPaolo Bonzini auto | enabled | internal) 1559fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 1560aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 1561fbb4121dSPaolo Bonzini ;; 1562fbb4121dSPaolo Bonziniesac 1563f652e6afSaurel32 156420ff075bSMichael Walle########################################## 1565519175a2SAlex Barcelo# check and set a backend for coroutine 1566d0e2fce5SAneesh Kumar K.V 15677c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 156833c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 156933c53c54SDaniel P. Berrange# specific one. 15707c2acc70SPeter Maydell 15717c2acc70SPeter Maydellucontext_works=no 1572d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 1573d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 1574d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 1575cdf84806SPeter Maydell#ifdef __stub_makecontext 1576cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 1577cdf84806SPeter Maydell#endif 157875cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 1579d0e2fce5SAneesh Kumar K.VEOF 1580d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 15817c2acc70SPeter Maydell ucontext_works=yes 1582d0e2fce5SAneesh Kumar K.V fi 1583519175a2SAlex Barcelofi 15847c2acc70SPeter Maydell 15857c2acc70SPeter Maydellif test "$coroutine" = ""; then 15867c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 15877c2acc70SPeter Maydell coroutine=win32 15887c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 15897c2acc70SPeter Maydell coroutine=ucontext 1590519175a2SAlex Barcelo else 15917c2acc70SPeter Maydell coroutine=sigaltstack 15927c2acc70SPeter Maydell fi 15937c2acc70SPeter Maydellelse 15947c2acc70SPeter Maydell case $coroutine in 15957c2acc70SPeter Maydell windows) 15967c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 15977c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 15987c2acc70SPeter Maydell fi 15997c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 16007c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 16017c2acc70SPeter Maydell coroutine=win32 16027c2acc70SPeter Maydell ;; 16037c2acc70SPeter Maydell ucontext) 16047c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 16057c2acc70SPeter Maydell feature_not_found "ucontext" 16067c2acc70SPeter Maydell fi 16077c2acc70SPeter Maydell ;; 160833c53c54SDaniel P. Berrange sigaltstack) 16097c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 16107c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 16117c2acc70SPeter Maydell fi 16127c2acc70SPeter Maydell ;; 16137c2acc70SPeter Maydell *) 161476ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 16157c2acc70SPeter Maydell ;; 16167c2acc70SPeter Maydell esac 1617d0e2fce5SAneesh Kumar K.Vfi 1618d0e2fce5SAneesh Kumar K.V 16191e4f6065SDaniele Buono################################################## 16201e4f6065SDaniele Buono# SafeStack 16211e4f6065SDaniele Buono 16221e4f6065SDaniele Buono 16231e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 16241e4f6065SDaniele Buonocat > $TMPC << EOF 16251e4f6065SDaniele Buonoint main(int argc, char *argv[]) 16261e4f6065SDaniele Buono{ 16271e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 16281e4f6065SDaniele Buono#error SafeStack Disabled 16291e4f6065SDaniele Buono#endif 16301e4f6065SDaniele Buono return 0; 16311e4f6065SDaniele Buono} 16321e4f6065SDaniele BuonoEOF 16331e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 16341e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 16351e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 16361e4f6065SDaniele Buono # Flag needed both at compilation and at linking 16371e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 16381e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 16391e4f6065SDaniele Buono else 16401e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 16411e4f6065SDaniele Buono fi 16421e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 16431e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 16441e4f6065SDaniele Buono fi 16451e4f6065SDaniele Buonoelse 16461e4f6065SDaniele Buonocat > $TMPC << EOF 16471e4f6065SDaniele Buonoint main(int argc, char *argv[]) 16481e4f6065SDaniele Buono{ 16491e4f6065SDaniele Buono#if defined(__has_feature) 16501e4f6065SDaniele Buono#if __has_feature(safe_stack) 16511e4f6065SDaniele Buono#error SafeStack Enabled 16521e4f6065SDaniele Buono#endif 16531e4f6065SDaniele Buono#endif 16541e4f6065SDaniele Buono return 0; 16551e4f6065SDaniele Buono} 16561e4f6065SDaniele BuonoEOF 16571e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 16581e4f6065SDaniele Buono # Make sure that safe-stack is disabled 16591e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 16601e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 16611e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 16621e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 16631e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 16641e4f6065SDaniele Buono fi 16651e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 16661e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 16671e4f6065SDaniele Buono fi 16681e4f6065SDaniele Buonoelse # "$safe_stack" = "" 16691e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 16701e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 16711e4f6065SDaniele Buono safe_stack="no" 16721e4f6065SDaniele Buono else 16731e4f6065SDaniele Buono safe_stack="yes" 16741e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 16751e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 16761e4f6065SDaniele Buono fi 16771e4f6065SDaniele Buono fi 16781e4f6065SDaniele Buonofi 16791e4f6065SDaniele Buonofi 16807d992e4dSPeter Lieven 168176a347e1SRichard Henderson######################################## 1682fd0e6053SJohn Snow# check if ccache is interfering with 1683fd0e6053SJohn Snow# semantic analysis of macros 1684fd0e6053SJohn Snow 16855e4dfd3dSJohn Snowunset CCACHE_CPP2 1686fd0e6053SJohn Snowccache_cpp2=no 1687fd0e6053SJohn Snowcat > $TMPC << EOF 1688fd0e6053SJohn Snowstatic const int Z = 1; 1689fd0e6053SJohn Snow#define fn() ({ Z; }) 1690fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 1691fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 1692fd0e6053SJohn Snow#define ID(X) (X) 1693fd0e6053SJohn Snowint main(int argc, char *argv[]) 1694fd0e6053SJohn Snow{ 1695fd0e6053SJohn Snow int x = 0, y = 0; 1696fd0e6053SJohn Snow x = ID(x); 1697fd0e6053SJohn Snow x = fn(); 1698fd0e6053SJohn Snow fn(); 1699fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 1700fd0e6053SJohn Snow if (TAUT(Z)) return 0; 1701fd0e6053SJohn Snow return 0; 1702fd0e6053SJohn Snow} 1703fd0e6053SJohn SnowEOF 1704fd0e6053SJohn Snow 1705fd0e6053SJohn Snowif ! compile_object "-Werror"; then 1706fd0e6053SJohn Snow ccache_cpp2=yes 1707fd0e6053SJohn Snowfi 1708fd0e6053SJohn Snow 1709b553a042SJohn Snow################################################# 1710b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 1711b553a042SJohn Snow 1712b553a042SJohn Snowif test "$fortify_source" != "no"; then 1713b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 1714b553a042SJohn Snow fortify_source="no"; 1715e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 1716cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 1717b553a042SJohn Snow fortify_source="no"; 1718b553a042SJohn Snow else 1719b553a042SJohn Snow fortify_source="yes" 1720b553a042SJohn Snow fi 1721b553a042SJohn Snowfi 1722b553a042SJohn Snow 1723d2042378SAneesh Kumar K.V########################################## 1724247724cbSMarc-André Lureau# checks for sanitizers 1725247724cbSMarc-André Lureau 1726247724cbSMarc-André Lureauhave_asan=no 1727247724cbSMarc-André Lureauhave_ubsan=no 1728d83414e1SMarc-André Lureauhave_asan_iface_h=no 1729d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 1730247724cbSMarc-André Lureau 1731247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 1732b9f44da2SMarc-André Lureau write_c_skeleton 1733247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 1734247724cbSMarc-André Lureau have_asan=yes 1735247724cbSMarc-André Lureau fi 1736b9f44da2SMarc-André Lureau 1737b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 1738b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 1739b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 1740b9f44da2SMarc-André Lureau cat > $TMPC << EOF 1741b9f44da2SMarc-André Lureau#include <stdlib.h> 1742b9f44da2SMarc-André Lureauint main(void) { 1743b9f44da2SMarc-André Lureau void *tmp = malloc(10); 1744f2dfe54cSLeonid Bloch if (tmp != NULL) { 1745b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 1746b9f44da2SMarc-André Lureau } 1747d1abf3fcSOlaf Hering return 1; 1748f2dfe54cSLeonid Bloch} 1749b9f44da2SMarc-André LureauEOF 1750247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 1751247724cbSMarc-André Lureau have_ubsan=yes 1752247724cbSMarc-André Lureau fi 1753d83414e1SMarc-André Lureau 1754d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 1755d83414e1SMarc-André Lureau have_asan_iface_h=yes 1756d83414e1SMarc-André Lureau fi 1757d83414e1SMarc-André Lureau 1758d83414e1SMarc-André Lureau cat > $TMPC << EOF 1759d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 1760d83414e1SMarc-André Lureauint main(void) { 1761d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 1762d83414e1SMarc-André Lureau return 0; 1763d83414e1SMarc-André Lureau} 1764d83414e1SMarc-André LureauEOF 1765d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 1766d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 1767d83414e1SMarc-André Lureau fi 1768247724cbSMarc-André Lureaufi 1769247724cbSMarc-André Lureau 17700aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 17710aebab04SLingfeng Yang# keep it separate until that is not the case. 17720aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 17730aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 17740aebab04SLingfeng Yangfi 17750aebab04SLingfeng Yanghave_tsan=no 17760aebab04SLingfeng Yanghave_tsan_iface_fiber=no 17770aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 17780aebab04SLingfeng Yang write_c_skeleton 17790aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 17800aebab04SLingfeng Yang have_tsan=yes 17810aebab04SLingfeng Yang fi 17820aebab04SLingfeng Yang cat > $TMPC << EOF 17830aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 17840aebab04SLingfeng Yangint main(void) { 17850aebab04SLingfeng Yang __tsan_create_fiber(0); 17860aebab04SLingfeng Yang return 0; 17870aebab04SLingfeng Yang} 17880aebab04SLingfeng YangEOF 17890aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 17900aebab04SLingfeng Yang have_tsan_iface_fiber=yes 17910aebab04SLingfeng Yang fi 17920aebab04SLingfeng Yangfi 17930aebab04SLingfeng Yang 1794adc28027SAlexander Bulekov########################################## 1795675b9b53SMarc-André Lureau# check for slirp 1796675b9b53SMarc-André Lureau 1797675b9b53SMarc-André Lureaucase "$slirp" in 17984d34a86bSPaolo Bonzini auto | enabled | internal) 17994d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 18007c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 1801675b9b53SMarc-André Lureau ;; 1802675b9b53SMarc-André Lureauesac 1803675b9b53SMarc-André Lureau 180454e7aac0SAlexey Krasikov########################################## 1805e86ecd4bSJuan Quintela# End of CC checks 1806e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 1807e86ecd4bSJuan Quintela 1808d83414e1SMarc-André Lureauwrite_c_skeleton 1809d83414e1SMarc-André Lureau 1810df42fa7dSPaolo Bonziniif test "$fortify_source" = "yes" ; then 1811086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 1812086d5f75SPaolo Bonzinifi 1813086d5f75SPaolo Bonzini 1814086d5f75SPaolo Bonzinicase "$ARCH" in 1815086d5f75SPaolo Bonzinialpha) 1816086d5f75SPaolo Bonzini # Ensure there's only a single GP 1817086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 1818086d5f75SPaolo Bonzini;; 1819086d5f75SPaolo Bonziniesac 1820086d5f75SPaolo Bonzini 1821247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 1822db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 1823db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 1824d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 1825d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 1826d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 1827d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 1828d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 1829d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 1830d83414e1SMarc-André Lureau fi 1831247724cbSMarc-André Lureaufi 18320aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 18330aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 18340aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 18350aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 18360aebab04SLingfeng Yang else 18370aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 18380aebab04SLingfeng Yang fi 18390aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 18400aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 18410aebab04SLingfeng Yangfi 1842247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 1843db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 1844db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 1845247724cbSMarc-André Lureaufi 1846247724cbSMarc-André Lureau 18476542aa9cSPeter Lieven########################################## 18483efac6ebSTomáš Golembiovský 18490aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 18500aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 1851e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 1852db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 1853e86ecd4bSJuan Quintela fi 1854e86ecd4bSJuan Quintelafi 1855e86ecd4bSJuan Quintela 1856b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 18579d6bc27bSMichael Roth 18589d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 18599d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 18609d6bc27bSMichael Rothfi 18619d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 18629d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 18639d6bc27bSMichael Rothfi 18649d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 186589138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 18669d6bc27bSMichael Rothfi 18679d6bc27bSMichael Roth 1868ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 1869ca35f780SPaolo Bonziniroms= 1870e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 1871ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 1872ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 1873e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 1874c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 1875c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 1876c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 1877e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 1878e57218b6SPeter Maydell ld_i386_emulation="$emu" 1879ca35f780SPaolo Bonzini roms="optionrom" 1880e57218b6SPeter Maydell break 1881e57218b6SPeter Maydell fi 1882e57218b6SPeter Maydell done 1883ca35f780SPaolo Bonzinifi 1884ca35f780SPaolo Bonzini 18852e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 1886a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 18879933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 18882e33c3f8SThomas Huth write_c_skeleton 1889a5b2afd5SThomas Huth compile_prog "-march=z900" "" 1890a5b2afd5SThomas Huth has_z900=$? 18913af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 1892a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 1893a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 1894a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 1895a5b2afd5SThomas Huth fi 18969933c305SChristian Borntraeger roms="$roms s390-ccw" 18971ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 18981ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 18991ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 19001ef6bfc2SPhilippe Mathieu-Daudé fi 19019933c305SChristian Borntraegerfi 19029933c305SChristian Borntraeger 190311cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 190411cde1c8SBruno 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. 190511cde1c8SBruno Dominguezif has $cxx; then 190611cde1c8SBruno Dominguez cat > $TMPC <<EOF 190711cde1c8SBruno Dominguezint c_function(void); 190811cde1c8SBruno Dominguezint main(void) { return c_function(); } 190911cde1c8SBruno DominguezEOF 191011cde1c8SBruno Dominguez 191111cde1c8SBruno Dominguez compile_object 191211cde1c8SBruno Dominguez 191311cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 191411cde1c8SBruno Dominguezextern "C" { 191511cde1c8SBruno Dominguez int c_function(void); 191611cde1c8SBruno Dominguez} 191711cde1c8SBruno Dominguezint c_function(void) { return 42; } 191811cde1c8SBruno DominguezEOF 191911cde1c8SBruno Dominguez 192011cde1c8SBruno Dominguez update_cxxflags 192111cde1c8SBruno Dominguez 1922a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 192311cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 192411cde1c8SBruno Dominguez : 192511cde1c8SBruno Dominguez else 192611cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 192711cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 192811cde1c8SBruno Dominguez cxx= 192911cde1c8SBruno Dominguez fi 193011cde1c8SBruno Dominguezelse 193111cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 193211cde1c8SBruno Dominguez cxx= 193311cde1c8SBruno Dominguezfi 193411cde1c8SBruno Dominguez 19357d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 19367d7dbf9dSDan Streetman exit 1 19375d91a2edSYonggang Luofi 19385d91a2edSYonggang Luo 193998ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 194097a847bcSbellard 194198ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 194298ec69acSJuan Quintelaecho >> $config_host_mak 194398ec69acSJuan Quintela 1944e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 1945cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 1946aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 19477d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 1948804edf29SJuan Quintela 1949f8393946Saurel32if test "$debug_tcg" = "yes" ; then 19502358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 1951f8393946Saurel32fi 195267b915a5Sbellardif test "$mingw32" = "yes" ; then 195398ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 19549dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 19559dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 19569dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 1957210fa556Spbrookelse 195835f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 1959210fa556Spbrookfi 1960128ab2ffSblueswir1 1961dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 1962dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 1963dffcb71cSMark McLoughlinfi 1964dffcb71cSMark McLoughlin 196583fb7adfSbellardif test "$darwin" = "yes" ; then 196698ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 196783fb7adfSbellardfi 1968b29fe3edSmalc 1969ec530c81Sbellardif test "$solaris" = "yes" ; then 197098ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 1971ec530c81Sbellardfi 197297a847bcSbellardif test "$static" = "yes" ; then 197398ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 197497a847bcSbellardfi 197598ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 19762b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 197717969268SFam Zhengif test "$modules" = "yes"; then 197817969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 197917969268SFam Zhengfi 1980277abf15SJan Vesely 198183fb7adfSbellard# XXX: suppress that 19827d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 19832358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 19847d3505c5Sbellardfi 19857d3505c5Sbellard 19867c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 19877d992e4dSPeter Lieven 1988d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 1989d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 1990d83414e1SMarc-André Lureaufi 1991d83414e1SMarc-André Lureau 19920aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 19930aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 19940aebab04SLingfeng Yangfi 19950aebab04SLingfeng Yang 199640e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 199740e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 199840e8c6f4SAlex Bennéefi 199940e8c6f4SAlex Bennée 2000f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 2001b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 2002d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 2003f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 2004f48e590aSAlex Bennée fi 2005b1863cccSAlex Bennéefi 2006f48e590aSAlex Bennée 200798ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 2008804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 2009c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 201039d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 2011a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 201209e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 2013804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 2014804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 2015cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 20165f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 20173dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 2018804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 2019804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 2020a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 202111cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 20224cb37d11SPhilippe Mathieu-Daudéecho "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak 2023a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 2024a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 2025*5b9e7d05SMarc-André Lureauecho "GLIB_BINDIR=$glib_bindir" >> $config_host_mak 2026d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 20278a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 2028e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 2029a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 2030804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 2031804edf29SJuan Quintela 20326efd7517SPeter Maydell# use included Linux headers 20336efd7517SPeter Maydellif test "$linux" = "yes" ; then 2034a307beb6SAndreas Färber mkdir -p linux-headers 20356efd7517SPeter Maydell case "$cpu" in 20364da270beSPaolo Bonzini i386|x86_64) 203708312a63SPeter Maydell linux_arch=x86 20386efd7517SPeter Maydell ;; 2039d8ff892dSPaolo Bonzini ppc|ppc64) 204008312a63SPeter Maydell linux_arch=powerpc 20416efd7517SPeter Maydell ;; 20426efd7517SPeter Maydell s390x) 204308312a63SPeter Maydell linux_arch=s390 204408312a63SPeter Maydell ;; 20451f080313SClaudio Fontana aarch64) 20461f080313SClaudio Fontana linux_arch=arm64 20471f080313SClaudio Fontana ;; 2048dfcf900bSWANG Xuerui loongarch*) 2049dfcf900bSWANG Xuerui linux_arch=loongarch 2050dfcf900bSWANG Xuerui ;; 2051222e7d11SSanjay Lal mips64) 2052222e7d11SSanjay Lal linux_arch=mips 2053222e7d11SSanjay Lal ;; 205408312a63SPeter Maydell *) 205508312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 205608312a63SPeter Maydell linux_arch="$cpu" 20576efd7517SPeter Maydell ;; 20586efd7517SPeter Maydell esac 205908312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 206008312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 206108312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 206208312a63SPeter Maydell fi 20636efd7517SPeter Maydellfi 20646efd7517SPeter Maydell 206597a847bcSbellardfor target in $target_list; do 206697a847bcSbellard target_dir="$target" 206757a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 206897a847bcSbellard mkdir -p $target_dir 2069fdb75aefSPaolo Bonzini case $target in 2070fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 2071fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 20722408a527Saurel32 esac 207356aebc89Spbrookdone 20747d13299dSbellard 2075fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 2076fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 2077fdb75aefSPaolo Bonzinifi 2078a540f158SPeter Crosthwaite 2079fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 2080fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 2081fd0e6053SJohn Snowfi 2082fd0e6053SJohn Snow 20831e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 20841e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 20851e4f6065SDaniele Buonofi 20861e4f6065SDaniele Buono 2087e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 2088e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 2089e29e5c6eSPeter Maydell# (these can be both files and directories). 2090e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 2091e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 2092e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 2093e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 2094e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 2095e29e5c6eSPeter Maydell# directory and symlink the directory instead. 20962038f8c8SPaolo BonziniLINKS="Makefile" 20973941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 2098ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 2099e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 2100e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 2101bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 210239950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 21038f8fd9edSCleber RosaLINKS="$LINKS python" 2104c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 2105753d11f2SRichard Hendersonfor bios_file in \ 2106753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 21073a631b8eSBin Meng $source_path/pc-bios/*.elf \ 2108225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 2109753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 2110753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 2111e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 2112753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 21134e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 2114cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 2115cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 2116cd946e5cSJohn Arbuckle 2117753d11f2SRichard Hendersondo 2118e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 21197ea78b74SJan Kiszkadone 2120e29e5c6eSPeter Maydellfor f in $LINKS ; do 21210f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 21225dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 2123f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 2124f9245e10SPeter Maydell fi 21257d13299dSbellarddone 21261ad2134fSPaul Brook 21272038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 21282038f8c8SPaolo Bonzini export $i 21292038f8c8SPaolo Bonzinidone 2130544f4a25SPaolo Bonziniexport target_list source_path use_containers cpu host_cc 21312038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 21322038f8c8SPaolo Bonzini 213398409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 213498409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 213598409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 213698409991SHelge Konetzka 2137a5665051SPaolo Bonziniif test "$skip_meson" = no; then 2138fc929892SMarc-André Lureau cross="config-meson.cross.new" 2139fc929892SMarc-André Lureau meson_quote() { 2140ac7ebcc5SPaolo Bonzini test $# = 0 && return 214147b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 2142fc929892SMarc-André Lureau } 2143fc929892SMarc-André Lureau 2144fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 2145fc929892SMarc-André Lureau echo "[properties]" >> $cross 2146d1d5e9eeSAlex Bennée 2147d1d5e9eeSAlex Bennée # unroll any custom device configs 2148d1d5e9eeSAlex Bennée for a in $device_archs; do 2149d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 2150d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 2151d1d5e9eeSAlex Bennée done 2152d1d5e9eeSAlex Bennée 2153fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 215447b30835SPaolo Bonzini echo "[built-in options]" >> $cross 2155a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 2156a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 2157e910c7d9SPhilippe Mathieu-Daudé test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross 2158a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 2159a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 2160fc929892SMarc-André Lureau echo "[binaries]" >> $cross 21614dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 21624dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 21634dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 216447b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 216547b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 216647b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 216747b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 2168e8178514SPaolo Bonzini if has $sdl2_config; then 216947b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 2170e8178514SPaolo Bonzini fi 217147b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 2172158bb224SKonstantin Kostiuk echo "widl = [$(meson_quote $widl)]" >> $cross 217347b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 21743812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 2175fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 2176fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 2177ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 2178823eb013SPaolo Bonzini case "$cpu" in 2179f6bca9dfSJoelle van Dyne i386) 2180fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 2181fc929892SMarc-André Lureau ;; 2182fc929892SMarc-André Lureau *) 2183823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 2184fc929892SMarc-André Lureau ;; 2185fc929892SMarc-André Lureau esac 2186fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 2187fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 2188fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 2189fc929892SMarc-André Lureau else 2190fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 2191fc929892SMarc-André Lureau fi 2192fc929892SMarc-André Lureau else 2193fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 2194fc929892SMarc-André Lureau fi 2195fc929892SMarc-André Lureau mv $cross config-meson.cross 2196fc929892SMarc-André Lureau 2197a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 21980a31e3a0SPaolo Bonzini 21990a31e3a0SPaolo Bonzini # Built-in options 22000a31e3a0SPaolo Bonzini test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir" 22010a31e3a0SPaolo Bonzini test "$default_feature" = no && meson_option_add -Dauto_features=disabled 22020a31e3a0SPaolo Bonzini test "$pie" = no && meson_option_add -Db_pie=false 22030a31e3a0SPaolo Bonzini test "$werror" = yes && meson_option_add -Dwerror=true 22040a31e3a0SPaolo Bonzini 22050a31e3a0SPaolo Bonzini # QEMU options 22060a31e3a0SPaolo Bonzini test "$cfi" != false && meson_option_add "-Dcfi=$cfi" 22070a31e3a0SPaolo Bonzini test "$fdt" != auto && meson_option_add "-Dfdt=$fdt" 22080a31e3a0SPaolo Bonzini test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE" 22090a31e3a0SPaolo Bonzini test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix" 22100a31e3a0SPaolo Bonzini test "$slirp" != auto && meson_option_add "-Dslirp=$slirp" 22110a31e3a0SPaolo Bonzini test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd" 22120a31e3a0SPaolo Bonzini test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg" 221361d63097SPaolo Bonzini run_meson() { 22140a31e3a0SPaolo Bonzini NINJA=$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path" 221561d63097SPaolo Bonzini } 221661d63097SPaolo Bonzini eval run_meson $meson_options 2217a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 2218a5665051SPaolo Bonzini error_exit "meson setup failed" 2219a5665051SPaolo Bonzini fi 2220699d3884SPaolo Bonzinielse 2221699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 2222699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 2223699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 2224699d3884SPaolo Bonzini perl -i -ne ' 2225699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 2226699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 2227654d6b04SPaolo Bonzini /^b_staticpic/ && next; 2228699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 2229699d3884SPaolo Bonzini fi 2230a5665051SPaolo Bonzinifi 2231a5665051SPaolo Bonzini 2232dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 2233dc655404SMichael S. Tsirkincat <<EOD >config.status 2234dc655404SMichael S. Tsirkin#!/bin/sh 2235dc655404SMichael S. Tsirkin# Generated by configure. 2236dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 2237dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 2238dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 2239dc655404SMichael S. TsirkinEOD 2240e811da7fSDaniel P. Berrangé 2241e811da7fSDaniel P. Berrangépreserve_env() { 2242e811da7fSDaniel P. Berrangé envname=$1 2243e811da7fSDaniel P. Berrangé 2244e811da7fSDaniel P. Berrangé eval envval=\$$envname 2245e811da7fSDaniel P. Berrangé 2246e811da7fSDaniel P. Berrangé if test -n "$envval" 2247e811da7fSDaniel P. Berrangé then 2248e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 2249e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 2250e811da7fSDaniel P. Berrangé else 2251e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 2252e811da7fSDaniel P. Berrangé fi 2253e811da7fSDaniel P. Berrangé} 2254e811da7fSDaniel P. Berrangé 2255e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 2256e811da7fSDaniel P. Berrangé# features/build target configure will detect 2257e811da7fSDaniel P. Berrangépreserve_env AR 2258e811da7fSDaniel P. Berrangépreserve_env AS 2259e811da7fSDaniel P. Berrangépreserve_env CC 2260e811da7fSDaniel P. Berrangépreserve_env CPP 22618009da03SPaolo Bonzinipreserve_env CFLAGS 2262e811da7fSDaniel P. Berrangépreserve_env CXX 22638009da03SPaolo Bonzinipreserve_env CXXFLAGS 2264e811da7fSDaniel P. Berrangépreserve_env INSTALL 2265e811da7fSDaniel P. Berrangépreserve_env LD 22668009da03SPaolo Bonzinipreserve_env LDFLAGS 2267e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 2268e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 2269e811da7fSDaniel P. Berrangépreserve_env MAKE 2270e811da7fSDaniel P. Berrangépreserve_env NM 2271e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 2272e811da7fSDaniel P. Berrangépreserve_env PATH 2273e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 2274e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 2275e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 2276e811da7fSDaniel P. Berrangépreserve_env PYTHON 2277e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 2278e811da7fSDaniel P. Berrangépreserve_env SMBD 2279e811da7fSDaniel P. Berrangépreserve_env STRIP 2280158bb224SKonstantin Kostiukpreserve_env WIDL 2281e811da7fSDaniel P. Berrangépreserve_env WINDRES 2282e811da7fSDaniel P. Berrangé 2283dc655404SMichael S. Tsirkinprintf "exec" >>config.status 2284a5665051SPaolo Bonzinifor i in "$0" "$@"; do 2285835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 2286a5665051SPaolo Bonzinidone 2287cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 2288dc655404SMichael S. Tsirkinchmod +x config.status 2289dc655404SMichael S. Tsirkin 22908cd05ab6SPeter Maydellrm -r "$TMPDIR1" 2291