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 capstone="disabled" 3110577e84dSThomas Huth slirp="disabled" 3120577e84dSThomas Huthelse 3133b4da132SPaolo Bonzini capstone="auto" 3143b4da132SPaolo Bonzini slirp="auto" 3150577e84dSThomas Huthfi 3160577e84dSThomas Huthfdt="auto" 3173b4da132SPaolo Bonzini 318c54b59eeSPaolo Bonzini# 2. Automatically enable/disable other options 3193b4da132SPaolo Bonzinitcg="enabled" 3203b4da132SPaolo Bonzinicfi="false" 3213b4da132SPaolo Bonzini 322c87ea116SAlex Bennée# parse CC options second 323ac0df51dSaliguorifor opt do 32489138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 325ac0df51dSaliguori case "$opt" in 326ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3273812c0c4SJoelle van Dyne cross_compile="yes" 328ac0df51dSaliguori ;; 3293d8df640SPaolo Bonzini --cc=*) CC="$optarg" 330ac0df51dSaliguori ;; 33183f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 33283f73fceSTomoki Sekiyama ;; 3332ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3342ff6b91eSJuan Quintela ;; 335a2866660SPaolo Bonzini --extra-cflags=*) 336a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 337a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 338e910c7d9SPhilippe Mathieu-Daudé EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 339e2a2ed06SJuan Quintela ;; 340a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 34111cde1c8SBruno Dominguez ;; 342e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 343e910c7d9SPhilippe Mathieu-Daudé ;; 344a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 345e2a2ed06SJuan Quintela ;; 346d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 347d75402b5SAlex Bennée ;; 348479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 349d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 3502038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 351d422b2bcSAlex Bennée ;; 352d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 353d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 3542038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 355d75402b5SAlex Bennée ;; 356ac0df51dSaliguori esac 357ac0df51dSaliguoridone 358ac0df51dSaliguori# OS specific 359ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 36093148aa5SStefan Weil# we can eliminate its usage altogether. 361ac0df51dSaliguori 362e49d021eSPeter Maydell# Preferred compiler: 363e49d021eSPeter Maydell# ${CC} (if set) 364e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 365e49d021eSPeter Maydell# system compiler 366e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 367e49d021eSPeter Maydell cc="$host_cc" 368e49d021eSPeter Maydellelse 369b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 370e49d021eSPeter Maydellfi 371e49d021eSPeter Maydell 37283f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 37383f73fceSTomoki Sekiyama cxx="c++" 37483f73fceSTomoki Sekiyamaelse 37583f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 37683f73fceSTomoki Sekiyamafi 37783f73fceSTomoki Sekiyama 378b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 379cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 3805f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 3813dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 382b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 383b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 3849f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 3854852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 38635acbb30SPaolo Bonzinismbd="$SMBD" 387b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 388158bb224SKonstantin Kostiukwidl="${WIDL-${cross_prefix}widl}" 389b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 39017884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 39117884d7bSSergei Trofimovichquery_pkg_config() { 39217884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 39317884d7bSSergei Trofimovich} 39417884d7bSSergei Trofimovichpkg_config=query_pkg_config 39547c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 396ac0df51dSaliguori 397be17dc90SMichael S. Tsirkin# default flags for all hosts 3982d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 3992d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 4002d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 4012d31515bSPeter Maydell# provides these semantics.) 402de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 403086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 404c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 405be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4065770e8afSPaolo Bonzini 407de38c0ccSPaolo BonziniQEMU_LDFLAGS= 408de38c0ccSPaolo Bonzini 4095770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4108a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4115770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 412086d5f75SPaolo Bonzini 413be17dc90SMichael S. Tsirkin 414ac0df51dSaliguoricheck_define() { 415ac0df51dSaliguoricat > $TMPC <<EOF 416ac0df51dSaliguori#if !defined($1) 417fd786e1aSPeter Maydell#error $1 not defined 418ac0df51dSaliguori#endif 419ac0df51dSaliguoriint main(void) { return 0; } 420ac0df51dSaliguoriEOF 42152166aa0SJuan Quintela compile_object 422ac0df51dSaliguori} 423ac0df51dSaliguori 424307119e7SGerd Hoffmanncheck_include() { 425307119e7SGerd Hoffmanncat > $TMPC <<EOF 426307119e7SGerd Hoffmann#include <$1> 427307119e7SGerd Hoffmannint main(void) { return 0; } 428307119e7SGerd HoffmannEOF 429307119e7SGerd Hoffmann compile_object 430307119e7SGerd Hoffmann} 431307119e7SGerd Hoffmann 43293b25869SJohn Snowwrite_c_skeleton() { 43393b25869SJohn Snow cat > $TMPC <<EOF 43493b25869SJohn Snowint main(void) { return 0; } 43593b25869SJohn SnowEOF 43693b25869SJohn Snow} 43793b25869SJohn Snow 438bbea4050SPeter Maydellif check_define __linux__ ; then 439ba7c60c2SPaolo Bonzini targetos=linux 440bbea4050SPeter Maydellelif check_define _WIN32 ; then 441ba7c60c2SPaolo Bonzini targetos=windows 442bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 443ba7c60c2SPaolo Bonzini targetos=openbsd 444bbea4050SPeter Maydellelif check_define __sun__ ; then 445ba7c60c2SPaolo Bonzini targetos=sunos 446bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 447ba7c60c2SPaolo Bonzini targetos=haiku 448951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 449ba7c60c2SPaolo Bonzini targetos=freebsd 450951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 451ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 452951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 453ba7c60c2SPaolo Bonzini targetos=dragonfly 454951fedfcSPeter Maydellelif check_define __NetBSD__; then 455ba7c60c2SPaolo Bonzini targetos=netbsd 456951fedfcSPeter Maydellelif check_define __APPLE__; then 457ba7c60c2SPaolo Bonzini targetos=darwin 458bbea4050SPeter Maydellelse 459951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 460951fedfcSPeter Maydell # might be going to just print the --help text, or it might 461951fedfcSPeter Maydell # be the result of a missing compiler. 462ba7c60c2SPaolo Bonzini targetos=bogus 463bbea4050SPeter Maydellfi 464bbea4050SPeter Maydell 46565eff01bSPaolo Bonzini# OS specific 46665eff01bSPaolo Bonzini 4673b0d8643SPaolo Bonzinimingw32="no" 4683b0d8643SPaolo Bonzinibsd="no" 4693b0d8643SPaolo Bonzinilinux="no" 4703b0d8643SPaolo Bonzinisolaris="no" 47165eff01bSPaolo Bonzinicase $targetos in 47265eff01bSPaolo Bonziniwindows) 47365eff01bSPaolo Bonzini mingw32="yes" 47465eff01bSPaolo Bonzini plugins="no" 47565eff01bSPaolo Bonzini pie="no" 47665eff01bSPaolo Bonzini;; 47765eff01bSPaolo Bonzinignu/kfreebsd) 47865eff01bSPaolo Bonzini bsd="yes" 47965eff01bSPaolo Bonzini;; 48065eff01bSPaolo Bonzinifreebsd) 48165eff01bSPaolo Bonzini bsd="yes" 48265eff01bSPaolo Bonzini make="${MAKE-gmake}" 48365eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 48465eff01bSPaolo Bonzini;; 48565eff01bSPaolo Bonzinidragonfly) 48665eff01bSPaolo Bonzini bsd="yes" 48765eff01bSPaolo Bonzini make="${MAKE-gmake}" 48865eff01bSPaolo Bonzini;; 48965eff01bSPaolo Bonzininetbsd) 49065eff01bSPaolo Bonzini bsd="yes" 49165eff01bSPaolo Bonzini make="${MAKE-gmake}" 49265eff01bSPaolo Bonzini;; 49365eff01bSPaolo Bonziniopenbsd) 49465eff01bSPaolo Bonzini bsd="yes" 49565eff01bSPaolo Bonzini make="${MAKE-gmake}" 49665eff01bSPaolo Bonzini;; 49765eff01bSPaolo Bonzinidarwin) 49865eff01bSPaolo Bonzini bsd="yes" 49965eff01bSPaolo Bonzini darwin="yes" 50065eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 50165eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 50265eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 50365eff01bSPaolo Bonzini;; 50465eff01bSPaolo Bonzinisunos) 50565eff01bSPaolo Bonzini solaris="yes" 50665eff01bSPaolo Bonzini make="${MAKE-gmake}" 50765eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 50865eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 50965eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 51065eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 51165eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 51265eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 513bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 514bbea4050SPeter Maydell # the correct CPU with the --cpu option. 515bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 516bbea4050SPeter Maydell cpu="x86_64" 517bbea4050SPeter Maydell fi 51865eff01bSPaolo Bonzini;; 51965eff01bSPaolo Bonzinihaiku) 52065eff01bSPaolo Bonzini pie="no" 52165eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 52265eff01bSPaolo Bonzini;; 52365eff01bSPaolo Bonzinilinux) 52465eff01bSPaolo Bonzini linux="yes" 52565eff01bSPaolo Bonzini;; 526bbea4050SPeter Maydellesac 527bbea4050SPeter Maydell 5282ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5292ff6b91eSJuan Quintela # command line argument 5302ff6b91eSJuan Quintela : 5312ff6b91eSJuan Quintelaelif check_define __i386__ ; then 532ac0df51dSaliguori cpu="i386" 533ac0df51dSaliguorielif check_define __x86_64__ ; then 534c72b26ecSRichard Henderson if check_define __ILP32__ ; then 535c72b26ecSRichard Henderson cpu="x32" 536c72b26ecSRichard Henderson else 537ac0df51dSaliguori cpu="x86_64" 538c72b26ecSRichard Henderson fi 5393aa9bd6cSblueswir1elif check_define __sparc__ ; then 5403aa9bd6cSblueswir1 if check_define __arch64__ ; then 5413aa9bd6cSblueswir1 cpu="sparc64" 5423aa9bd6cSblueswir1 else 5433aa9bd6cSblueswir1 cpu="sparc" 5443aa9bd6cSblueswir1 fi 545fdf7ed96Smalcelif check_define _ARCH_PPC ; then 546fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 547f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 548f8378accSRichard Henderson cpu="ppc64le" 549f8378accSRichard Henderson else 550fdf7ed96Smalc cpu="ppc64" 551f8378accSRichard Henderson fi 552ac0df51dSaliguori else 553fdf7ed96Smalc cpu="ppc" 554fdf7ed96Smalc fi 555afa05235SAurelien Jarnoelif check_define __mips__ ; then 556afa05235SAurelien Jarno cpu="mips" 557d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 558d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 559d66ed0eaSAurelien Jarno cpu="s390x" 560d66ed0eaSAurelien Jarno else 561d66ed0eaSAurelien Jarno cpu="s390" 562d66ed0eaSAurelien Jarno fi 563c4f80543SAlistair Franciselif check_define __riscv ; then 564ba0e7333SRichard Henderson cpu="riscv" 56521d89f84SPeter Maydellelif check_define __arm__ ; then 56621d89f84SPeter Maydell cpu="arm" 5671f080313SClaudio Fontanaelif check_define __aarch64__ ; then 5681f080313SClaudio Fontana cpu="aarch64" 569dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 570dfcf900bSWANG Xuerui cpu="loongarch64" 571fdf7ed96Smalcelse 57289138857SStefan Weil cpu=$(uname -m) 573ac0df51dSaliguorifi 574ac0df51dSaliguori 575823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 576359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 5777d13299dSbellardcase "$cpu" in 578e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 579e4da0e39SPaolo Bonzini cpu="arm" ;; 580e4da0e39SPaolo Bonzini 5817d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 58297a847bcSbellard cpu="i386" 583e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 584e4da0e39SPaolo Bonzini x32) 5854da270beSPaolo Bonzini cpu="x86_64" 586e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 587aaa5fa14Saurel32 x86_64|amd64) 588aaa5fa14Saurel32 cpu="x86_64" 589e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 590e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 591e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 592e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 593e4da0e39SPaolo Bonzini 594afa05235SAurelien Jarno mips*) 595e4da0e39SPaolo Bonzini cpu="mips" ;; 596e4da0e39SPaolo Bonzini 597e4da0e39SPaolo Bonzini ppc) 598e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 599e4da0e39SPaolo Bonzini ppc64) 600ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mbig-endian" ;; 601e4da0e39SPaolo Bonzini ppc64le) 602d8ff892dSPaolo Bonzini cpu="ppc64" 603ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mlittle-endian" ;; 604e4da0e39SPaolo Bonzini 605e4da0e39SPaolo Bonzini s390) 606823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 607e4da0e39SPaolo Bonzini s390x) 608e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 609e4da0e39SPaolo Bonzini 6103142255cSblueswir1 sparc|sun4[cdmuv]) 611ae228531Sbellard cpu="sparc" 612e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 613e4da0e39SPaolo Bonzini sparc64) 614e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6157d13299dSbellardesac 616e2d52ad3SJuan Quintela 6170db4a067SPaolo Bonzini: ${make=${MAKE-make}} 618b6daf4d3SPaolo Bonzini 619faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 620faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 621ddf90699SEduardo Habkost# we check that too 622faf44142SDaniel P. Berrangépython= 6230a01d76fSMarc-André Lureauexplicit_python=no 624ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 625faf44142SDaniel P. Berrangédo 626faf44142SDaniel P. Berrangé if has "$binary" 627faf44142SDaniel P. Berrangé then 62895c5f2deSPaolo Bonzini python=$(command -v "$binary") 629faf44142SDaniel P. Berrangé break 630faf44142SDaniel P. Berrangé fi 631faf44142SDaniel P. Berrangédone 632903458c8SMarkus Armbruster 633903458c8SMarkus Armbruster 63439d87c8cSAlex Bennée# Check for ancillary tools used in testing 63539d87c8cSAlex Bennéegenisoimage= 6363df437c7SAlex Bennéefor binary in genisoimage mkisofs 63739d87c8cSAlex Bennéedo 63839d87c8cSAlex Bennée if has $binary 63939d87c8cSAlex Bennée then 64039d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 64139d87c8cSAlex Bennée break 64239d87c8cSAlex Bennée fi 64339d87c8cSAlex Bennéedone 64439d87c8cSAlex Bennée 6453c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6463c4a4d0dSPeter Maydellif has clang; then 6473c4a4d0dSPeter Maydell objcc=clang 6483c4a4d0dSPeter Maydellelse 6493c4a4d0dSPeter Maydell objcc="$cc" 6503c4a4d0dSPeter Maydellfi 6513c4a4d0dSPeter Maydell 6523457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6533457a3f8SJuan Quintela EXESUF=".exe" 65478e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6555770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 65693b25869SJohn Snow write_c_skeleton; 657d17f305aSPaolo Bonzini prefix="/qemu" 658c09c1ce7SPaolo Bonzini bindir="" 65977433a5fSMarc-André Lureau qemu_suffix="" 6603457a3f8SJuan Quintelafi 6613457a3f8SJuan Quintela 662487fefdbSAnthony Liguoriwerror="" 66385aa5189Sbellard 66461d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 66561d63097SPaolo Bonzini 66661d63097SPaolo Bonzinimeson_options= 667c54b59eeSPaolo Bonzinimeson_option_add() { 668c54b59eeSPaolo Bonzini meson_options="$meson_options $(quote_sh "$1")" 669c54b59eeSPaolo Bonzini} 67061d63097SPaolo Bonzinimeson_option_parse() { 67161d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 67261d63097SPaolo Bonzini if test $? -eq 1; then 67361d63097SPaolo Bonzini echo "ERROR: unknown option $1" 67461d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 67561d63097SPaolo Bonzini exit 1 67661d63097SPaolo Bonzini fi 67761d63097SPaolo Bonzini} 67861d63097SPaolo Bonzini 6797d13299dSbellardfor opt do 68089138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 6817d13299dSbellard case "$opt" in 6822efc3265Sbellard --help|-h) show_help=yes 6832efc3265Sbellard ;; 68499123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 68599123e13SMike Frysinger ;; 686b1a550a0Spbrook --prefix=*) prefix="$optarg" 6877d13299dSbellard ;; 688ac0df51dSaliguori --cross-prefix=*) 6897d13299dSbellard ;; 690ac0df51dSaliguori --cc=*) 6917d13299dSbellard ;; 692b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 69383469015Sbellard ;; 69483f73fceSTomoki Sekiyama --cxx=*) 69583f73fceSTomoki Sekiyama ;; 6963c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 6973c4a4d0dSPeter Maydell ;; 698b1a550a0Spbrook --make=*) make="$optarg" 6997d13299dSbellard ;; 700b6daf4d3SPaolo Bonzini --install=*) 7016a882643Spbrook ;; 7020a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 703c886edfbSBlue Swirl ;; 704a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 705a5665051SPaolo Bonzini ;; 706a5665051SPaolo Bonzini --meson=*) meson="$optarg" 707a5665051SPaolo Bonzini ;; 70848328880SPaolo Bonzini --ninja=*) ninja="$optarg" 70948328880SPaolo Bonzini ;; 710e2d8830eSBrad --smbd=*) smbd="$optarg" 711e2d8830eSBrad ;; 712e2a2ed06SJuan Quintela --extra-cflags=*) 7137d13299dSbellard ;; 71411cde1c8SBruno Dominguez --extra-cxxflags=*) 71511cde1c8SBruno Dominguez ;; 716e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) 717e910c7d9SPhilippe Mathieu-Daudé ;; 718e2a2ed06SJuan Quintela --extra-ldflags=*) 7197d13299dSbellard ;; 720d75402b5SAlex Bennée --cross-cc-*) 721d75402b5SAlex Bennée ;; 722c54b59eeSPaolo Bonzini --enable-debug-info) meson_option_add -Ddebug=true 72328609749SPaolo Bonzini ;; 724c54b59eeSPaolo Bonzini --disable-debug-info) meson_option_add -Ddebug=false 72528609749SPaolo Bonzini ;; 72617969268SFam Zheng --enable-modules) 72717969268SFam Zheng modules="yes" 72817969268SFam Zheng ;; 7293aa88b31SStefan Hajnoczi --disable-modules) 7303aa88b31SStefan Hajnoczi modules="no" 7313aa88b31SStefan Hajnoczi ;; 7322ff6b91eSJuan Quintela --cpu=*) 7337d13299dSbellard ;; 734b1a550a0Spbrook --target-list=*) target_list="$optarg" 735447e133fSAlex Bennée if test "$target_list_exclude"; then 736447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 737447e133fSAlex Bennée fi 738447e133fSAlex Bennée ;; 739447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 740447e133fSAlex Bennée if test "$target_list"; then 741447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 742447e133fSAlex Bennée fi 743de83cd02Sbellard ;; 744c54b59eeSPaolo Bonzini --with-default-devices) meson_option_add -Ddefault_devices=true 745f3494749SPaolo Bonzini ;; 746c54b59eeSPaolo Bonzini --without-default-devices) meson_option_add -Ddefault_devices=false 747f3494749SPaolo Bonzini ;; 748d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 749d1d5e9eeSAlex Bennée ;; 750d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 751d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 752d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 753d1d5e9eeSAlex Bennée if test -f "$cf"; then 754d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 755d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 756d1d5e9eeSAlex Bennée else 757d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 758d1d5e9eeSAlex Bennée fi 759d1d5e9eeSAlex Bennée ;; 760c87ea116SAlex Bennée --without-default-features) # processed above 761c87ea116SAlex Bennée ;; 76279427693SLoïc Minier --static) 76379427693SLoïc Minier static="yes" 76417884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 76543ce4dfeSbellard ;; 7660b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 7670b24e75fSPaolo Bonzini ;; 76877433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 769023d3d67SEduardo Habkost ;; 770181ce1d0SOlaf Hering --host=*|--build=*|\ 771181ce1d0SOlaf Hering --disable-dependency-tracking|\ 772785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 773fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 774023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 775023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 776023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 777023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 778023ddd74SMax Filippov # lots of directory switches by default. 779023ddd74SMax Filippov ;; 780f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 781f8393946Saurel32 ;; 782f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 783f8393946Saurel32 ;; 784f3d08ee6SPaul Brook --enable-debug) 785f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 786f3d08ee6SPaul Brook debug_tcg="yes" 787c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 788c54b59eeSPaolo Bonzini meson_option_add -Doptimization=0 789b553a042SJohn Snow fortify_source="no" 790f3d08ee6SPaul Brook ;; 791247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 792247724cbSMarc-André Lureau ;; 793247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 794247724cbSMarc-André Lureau ;; 7950aebab04SLingfeng Yang --enable-tsan) tsan="yes" 7960aebab04SLingfeng Yang ;; 7970aebab04SLingfeng Yang --disable-tsan) tsan="no" 7980aebab04SLingfeng Yang ;; 7994d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 800c20709aaSbellard ;; 801fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 802fd6fc214SPaolo Bonzini ;; 8034d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 8047c57bdd8SMarc-André Lureau ;; 80503a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 806675b9b53SMarc-André Lureau ;; 8071badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 808d1a14257SAlex Bennée plugins="no" 809b3f6ea7eSPaolo Bonzini ;; 8101badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 811b3f6ea7eSPaolo Bonzini ;; 812cad25d69Spbrook --disable-system) softmmu="no" 8130a8e90f4Spbrook ;; 814cad25d69Spbrook --enable-system) softmmu="yes" 8150a8e90f4Spbrook ;; 8160953a80fSZachary Amsden --disable-user) 8170953a80fSZachary Amsden linux_user="no" ; 8180953a80fSZachary Amsden bsd_user="no" ; 8190953a80fSZachary Amsden ;; 8200953a80fSZachary Amsden --enable-user) ;; 821831b7825Sths --disable-linux-user) linux_user="no" 8220a8e90f4Spbrook ;; 823831b7825Sths --enable-linux-user) linux_user="yes" 824831b7825Sths ;; 82584778508Sblueswir1 --disable-bsd-user) bsd_user="no" 82684778508Sblueswir1 ;; 82784778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 82884778508Sblueswir1 ;; 82940d6444eSAvi Kivity --enable-pie) pie="yes" 83034005a00SKirill A. Shutemov ;; 83140d6444eSAvi Kivity --disable-pie) pie="no" 83234005a00SKirill A. Shutemov ;; 83385aa5189Sbellard --enable-werror) werror="yes" 83485aa5189Sbellard ;; 83585aa5189Sbellard --disable-werror) werror="no" 83685aa5189Sbellard ;; 83763678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 83863678e17SSteven Noonan ;; 83963678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 84063678e17SSteven Noonan ;; 8411e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 8421e4f6065SDaniele Buono ;; 8431e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 8441e4f6065SDaniele Buono ;; 8459e62ba48SDaniele Buono --enable-cfi) 8469e62ba48SDaniele Buono cfi="true"; 847c54b59eeSPaolo Bonzini meson_option_add -Db_lto=true 8489e62ba48SDaniele Buono ;; 8499e62ba48SDaniele Buono --disable-cfi) cfi="false" 8509e62ba48SDaniele Buono ;; 851fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 8522df87df7SJuan Quintela ;; 853fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 854fbb4121dSPaolo Bonzini ;; 855fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 856fbb4121dSPaolo Bonzini ;; 85703a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 8582df87df7SJuan Quintela ;; 859519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 860519175a2SAlex Barcelo ;; 8611ffb3bbbSPaolo Bonzini --disable-zlib-test) 8621ece9905SAlon Levy ;; 86352b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 86452b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 865583f6e7bSStefan Hajnoczi ;; 866cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 867cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 868cb6414dfSFam Zheng ;; 869315d3184SFam Zheng --enable-uuid|--disable-uuid) 870315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 871315d3184SFam Zheng ;; 8728b18cdbfSRichard Henderson --disable-capstone) capstone="disabled" 8738ca80760SRichard Henderson ;; 8748b18cdbfSRichard Henderson --enable-capstone) capstone="enabled" 8758ca80760SRichard Henderson ;; 8768b18cdbfSRichard Henderson --enable-capstone=git) capstone="internal" 877e219c499SRichard Henderson ;; 87803a3c0b3SPaolo Bonzini --enable-capstone=*) capstone="$optarg" 879e219c499SRichard Henderson ;; 880cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 881cc84d63aSDaniel P. Berrange ;; 8827d7dbf9dSDan Streetman --with-git-submodules=*) 8837d7dbf9dSDan Streetman git_submodules_action="$optarg" 884f62bbee5SDaniel P. Berrange ;; 8859b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 8869b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 8879b8e4298SAlex Bennée else 8889b8e4298SAlex Bennée plugins="yes" 8899b8e4298SAlex Bennée fi 89040e8c6f4SAlex Bennée ;; 89140e8c6f4SAlex Bennée --disable-plugins) plugins="no" 89240e8c6f4SAlex Bennée ;; 893afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 894afc3a8f9SAlex Bennée ;; 895afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 896afc3a8f9SAlex Bennée ;; 897f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 898f48e590aSAlex Bennée ;; 8993b4da132SPaolo Bonzini # backwards compatibility options 9003b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 9013b4da132SPaolo Bonzini ;; 9023b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 9033b4da132SPaolo Bonzini ;; 9043b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 9053b4da132SPaolo Bonzini ;; 9063b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 9073b4da132SPaolo Bonzini ;; 9083b4da132SPaolo Bonzini # everything else has the same name in configure and meson 9094fda6011SPaolo Bonzini --*) meson_option_parse "$opt" "$optarg" 9107f1559c6Sbalrog ;; 9117d13299dSbellard esac 9127d13299dSbellarddone 9137d13299dSbellard 914d1a14257SAlex Bennée# test for any invalid configuration combinations 915d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 916d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 917d1a14257SAlex Bennéefi 918d1a14257SAlex Bennée 9197d7dbf9dSDan Streetmancase $git_submodules_action in 9207d7dbf9dSDan Streetman update|validate) 9217d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 9227d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 9237d7dbf9dSDan Streetman exit 1 9247d7dbf9dSDan Streetman fi 9257d7dbf9dSDan Streetman ;; 9267d7dbf9dSDan Streetman ignore) 927b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 928b80fd281SPaolo Bonzini then 929b80fd281SPaolo Bonzini echo 930b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 931b80fd281SPaolo Bonzini echo 932b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 933b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 934b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 935b80fd281SPaolo Bonzini else 936b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 937b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 938b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 939b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 940b80fd281SPaolo Bonzini echo 941b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 942b80fd281SPaolo Bonzini echo 943b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 944b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 945b80fd281SPaolo Bonzini fi 946b80fd281SPaolo Bonzini echo 947b80fd281SPaolo Bonzini exit 1 948b80fd281SPaolo Bonzini fi 9497d7dbf9dSDan Streetman ;; 9507d7dbf9dSDan Streetman *) 9517d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 9527d7dbf9dSDan Streetman exit 1 9537d7dbf9dSDan Streetman ;; 9547d7dbf9dSDan Streetmanesac 9557d7dbf9dSDan Streetman 9569557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 957b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 9582038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 9599557af9cSAlex Bennéefi 96079f3b12fSPeter Crosthwaite 96160e0df25SPeter Maydelldefault_target_list="" 9626e92f823SPeter Maydellmak_wilds="" 9636e92f823SPeter Maydell 964b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 965b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 966b915a2f1SPaolo Bonzini linux_user=yes 967b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 968b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 969b915a2f1SPaolo Bonzini fi 970b915a2f1SPaolo Bonzinifi 971b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 972b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 973b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 974b915a2f1SPaolo Bonzini fi 975b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 976b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 977b915a2f1SPaolo Bonzini fi 978b915a2f1SPaolo Bonzinifi 97960e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 980812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 98160e0df25SPeter Maydellfi 98260e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 983812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 98460e0df25SPeter Maydellfi 98560e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 986812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 98760e0df25SPeter Maydellfi 98860e0df25SPeter Maydell 989447e133fSAlex Bennéefor config in $mak_wilds; do 990447e133fSAlex Bennée target="$(basename "$config" .mak)" 99198db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 992447e133fSAlex Bennée default_target_list="${default_target_list} $target" 993447e133fSAlex Bennée fi 994447e133fSAlex Bennéedone 9956e92f823SPeter Maydell 996af5db58eSpbrookif test x"$show_help" = x"yes" ; then 997af5db58eSpbrookcat << EOF 998af5db58eSpbrook 999af5db58eSpbrookUsage: configure [options] 1000af5db58eSpbrookOptions: [defaults in brackets after descriptions] 1001af5db58eSpbrook 100208fb77edSStefan WeilStandard options: 100308fb77edSStefan Weil --help print this message 100408fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 100574154d7eSThomas Huth --target-list=LIST set target list (default: build all) 100608fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 100708fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 1008447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 100908fb77edSStefan Weil 101008fb77edSStefan WeilAdvanced options (experts only): 10113812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 101208fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 101308fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 101408fb77edSStefan Weil build time 101508fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 101608fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1017a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1018a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 1019e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS 102008fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1021d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1022479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 102308fb77edSStefan Weil --make=MAKE use specified make [$make] 102408fb77edSStefan Weil --python=PYTHON use specified python [$python] 1025a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 102648328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 102708fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1028db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 10297d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 10307d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 10317d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 103208fb77edSStefan Weil --static enable static build [$static] 103308fb77edSStefan Weil --bindir=PATH install binaries in PATH 103413336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1035ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1036c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1037c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1038c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1039d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1040d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 104108fb77edSStefan Weil --enable-debug enable common debug build options 1042247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 10430aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 104408fb77edSStefan Weil --disable-werror disable compilation abort on warning 104563678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 1046c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 104708fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 104833c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 104940e8c6f4SAlex Bennée --enable-plugins 105040e8c6f4SAlex Bennée enable plugins via shared library loading 1051afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1052f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 105361d63097SPaolo BonziniEOF 105461d63097SPaolo Bonzini meson_options_help 105561d63097SPaolo Bonzinicat << EOF 1056c23f23b9SMichael Tokarev system all system emulation targets 1057c23f23b9SMichael Tokarev user supported user emulation targets 1058c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1059c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1060c23f23b9SMichael Tokarev pie Position Independent Executables 106121e709aaSMarc-André Lureau modules modules support (non-Windows) 1062c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1063c23f23b9SMichael Tokarev debug-info debugging information 10641e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 10651e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 106608fb77edSStefan Weil 106708fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1068af5db58eSpbrookEOF 10692d2ad6d0SFam Zhengexit 0 1070af5db58eSpbrookfi 1071af5db58eSpbrook 10729c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1073bb768f71SThomas Huthrm -f */config-devices.mak.d 10749c790242SThomas Huth 1075faf44142SDaniel P. Berrangéif test -z "$python" 1076faf44142SDaniel P. Berrangéthen 1077c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1078c53eeaf7SStefan Hajnoczifi 10798e2c76bdSRoman Bolshakovif ! has "$make" 10808e2c76bdSRoman Bolshakovthen 10818e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 10828e2c76bdSRoman Bolshakovfi 1083c53eeaf7SStefan Hajnoczi 1084c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1085c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 10861b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 10871b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1088c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1089c53eeaf7SStefan Hajnoczifi 1090c53eeaf7SStefan Hajnoczi 1091755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1092406ab2f3SCleber 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) 1093755ee70fSCleber Rosa 1094c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1095c53eeaf7SStefan Hajnoczipython="$python -B" 1096c53eeaf7SStefan Hajnoczi 10970a01d76fSMarc-André Lureauif test -z "$meson"; then 10986638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 10990a01d76fSMarc-André Lureau meson=meson 11007d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 11010a01d76fSMarc-André Lureau meson=git 11020a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 11030a01d76fSMarc-André Lureau meson=internal 11040a01d76fSMarc-André Lureau else 11050a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 11060a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 11070a01d76fSMarc-André Lureau else 1108a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1109a5665051SPaolo Bonzini fi 11100a01d76fSMarc-André Lureau fi 11110a01d76fSMarc-André Lureauelse 11120a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 11130a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 11140a01d76fSMarc-André Lureau # 11150a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 11160a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 11170a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 11180a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 11190a01d76fSMarc-André Lureau case "$meson" in 11200a01d76fSMarc-André Lureau git | internal) ;; 11210a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 11220a01d76fSMarc-André Lureau esac 11230a01d76fSMarc-André Lureau fi 11240a01d76fSMarc-André Lureaufi 1125a5665051SPaolo Bonzini 11260a01d76fSMarc-André Lureauif test "$meson" = git; then 11270a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 11280a01d76fSMarc-André Lureaufi 11290a01d76fSMarc-André Lureau 11300a01d76fSMarc-André Lureaucase "$meson" in 11310a01d76fSMarc-André Lureau git | internal) 11320a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 11330a01d76fSMarc-André Lureau ;; 113484ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 11350a01d76fSMarc-André Lureauesac 11360a01d76fSMarc-André Lureau 113709e93326SPaolo Bonzini# Probe for ninja 113848328880SPaolo Bonzini 113948328880SPaolo Bonziniif test -z "$ninja"; then 114048328880SPaolo Bonzini for c in ninja ninja-build samu; do 114148328880SPaolo Bonzini if has $c; then 114248328880SPaolo Bonzini ninja=$(command -v "$c") 114348328880SPaolo Bonzini break 114448328880SPaolo Bonzini fi 114548328880SPaolo Bonzini done 114609e93326SPaolo Bonzini if test -z "$ninja"; then 114709e93326SPaolo Bonzini error_exit "Cannot find Ninja" 114809e93326SPaolo Bonzini fi 114948328880SPaolo Bonzinifi 1150a5665051SPaolo Bonzini 11519aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 11529aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 11539aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 11549aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 11559aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 11569aae6e54SDaniel Henrique Barbozaif compile_object ; then 11579aae6e54SDaniel Henrique Barboza : C compiler works ok 11589aae6e54SDaniel Henrique Barbozaelse 11599aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 11609aae6e54SDaniel Henrique Barbozafi 11619aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 11629aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 11639aae6e54SDaniel Henrique Barbozafi 11649aae6e54SDaniel Henrique Barboza 11659c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 11669c83ffd8SPeter Maydell# by default. Only enable by default for git builds 11679c83ffd8SPeter Maydellif test -z "$werror" ; then 11687d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1169e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 11709c83ffd8SPeter Maydell werror="yes" 11719c83ffd8SPeter Maydell else 11729c83ffd8SPeter Maydell werror="no" 11739c83ffd8SPeter Maydell fi 11749c83ffd8SPeter Maydellfi 11759c83ffd8SPeter Maydell 1176975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1177fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1178fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1179fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1180fb59dabdSPeter Maydell # host OS we should stop now. 1181951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1182fb59dabdSPeter Maydellfi 1183fb59dabdSPeter Maydell 1184efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1185efc6c070SThomas Huthcat > $TMPC << EOF 1186efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1187efc6c070SThomas Huth# ifdef __apple_build_version__ 11882a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 11892a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1190efc6c070SThomas Huth# endif 1191efc6c070SThomas Huth# else 11922a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 11932a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1194efc6c070SThomas Huth# endif 1195efc6c070SThomas Huth# endif 1196efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 11973830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 11983830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1199efc6c070SThomas Huth# endif 1200efc6c070SThomas Huth#else 1201efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1202efc6c070SThomas Huth#endif 1203efc6c070SThomas Huthint main (void) { return 0; } 1204efc6c070SThomas HuthEOF 1205efc6c070SThomas Huthif ! compile_prog "" "" ; then 12063830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1207efc6c070SThomas Huthfi 1208efc6c070SThomas Huth 120900849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 121000849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 121100849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 121200849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 121300849b92SRichard Henderson# just silently disable some features, so it's too error prone. 121400849b92SRichard Henderson 121500849b92SRichard Hendersonwarn_flags= 121600849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 121700849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 121800849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 121900849b92SRichard Hendersonadd_to warn_flags -Wformat-security 122000849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 122100849b92SRichard Hendersonadd_to warn_flags -Winit-self 122200849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 122300849b92SRichard Hendersonadd_to warn_flags -Wempty-body 122400849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 122500849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 122600849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 12270a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 122800849b92SRichard Henderson 122900849b92SRichard Hendersonnowarn_flags= 123000849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 123100849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 123200849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 123300849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 123400849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1235aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1236bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 123700849b92SRichard Henderson 123800849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 123993b25869SJohn Snow 124093b25869SJohn Snowcc_has_warning_flag() { 124193b25869SJohn Snow write_c_skeleton; 124293b25869SJohn Snow 1243a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1244a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1245a1d29d6cSPeter Maydell # warning options). 124693b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 124793b25869SJohn Snow compile_prog "-Werror $optflag" "" 124893b25869SJohn Snow} 124993b25869SJohn Snow 12504cb37d11SPhilippe Mathieu-Daudéobjcc_has_warning_flag() { 12514cb37d11SPhilippe Mathieu-Daudé cat > $TMPM <<EOF 12524cb37d11SPhilippe Mathieu-Daudéint main(void) { return 0; } 12534cb37d11SPhilippe Mathieu-DaudéEOF 12544cb37d11SPhilippe Mathieu-Daudé 12554cb37d11SPhilippe Mathieu-Daudé # Use the positive sense of the flag when testing for -Wno-wombat 12564cb37d11SPhilippe Mathieu-Daudé # support (gcc will happily accept the -Wno- form of unknown 12574cb37d11SPhilippe Mathieu-Daudé # warning options). 12584cb37d11SPhilippe Mathieu-Daudé optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 12594cb37d11SPhilippe Mathieu-Daudé do_objc -Werror $optflag \ 12604cb37d11SPhilippe Mathieu-Daudé $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ 12614cb37d11SPhilippe Mathieu-Daudé -o $TMPE $TMPM $QEMU_LDFLAGS 12624cb37d11SPhilippe Mathieu-Daudé} 12634cb37d11SPhilippe Mathieu-Daudé 126493b25869SJohn Snowfor flag in $gcc_flags; do 126593b25869SJohn Snow if cc_has_warning_flag $flag ; then 12668d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 12678d05095cSPaolo Bonzini fi 12684cb37d11SPhilippe Mathieu-Daudé if objcc_has_warning_flag $flag ; then 12694cb37d11SPhilippe Mathieu-Daudé QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" 12704cb37d11SPhilippe Mathieu-Daudé fi 12718d05095cSPaolo Bonzinidone 12728d05095cSPaolo Bonzini 127363678e17SSteven Noonanif test "$stack_protector" != "no"; then 1274fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1275fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1276fccd35a0SRodrigo Rebello{ 1277fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1278fccd35a0SRodrigo Rebello while (*c) { 1279fccd35a0SRodrigo Rebello *p++ = *c++; 1280fccd35a0SRodrigo Rebello } 1281fccd35a0SRodrigo Rebello return 0; 1282fccd35a0SRodrigo Rebello} 1283fccd35a0SRodrigo RebelloEOF 128463678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 12853b463a3fSMiroslav Rezanina sp_on=0 128663678e17SSteven Noonan for flag in $gcc_flags; do 1287590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1288590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1289086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1290590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 129163678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1292db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 12933b463a3fSMiroslav Rezanina sp_on=1 129463678e17SSteven Noonan break 129563678e17SSteven Noonan fi 129663678e17SSteven Noonan done 12973b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 12983b463a3fSMiroslav Rezanina if test $sp_on = 0; then 12993b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 13003b463a3fSMiroslav Rezanina fi 13013b463a3fSMiroslav Rezanina fi 130237746c5eSMarc-André Lureaufi 130337746c5eSMarc-André Lureau 130420bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 130520bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 130620bc94a2SPaolo Bonzinicat > $TMPC << EOF 130720bc94a2SPaolo Bonzinistruct { 130820bc94a2SPaolo Bonzini int a[2]; 130920bc94a2SPaolo Bonzini} x = {0}; 131020bc94a2SPaolo BonziniEOF 131120bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 131220bc94a2SPaolo Bonzini : 131320bc94a2SPaolo Bonzinielse 131420bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 131520bc94a2SPaolo Bonzinifi 131620bc94a2SPaolo Bonzini 131721e709aaSMarc-André Lureau# Our module code doesn't support Windows 131821e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 131921e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 132021e709aaSMarc-André Lureaufi 132121e709aaSMarc-André Lureau 13225f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 132340d6444eSAvi Kivityif test "$static" = "yes" ; then 1324aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1325aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1326aa0d1f44SPaolo Bonzini fi 13275f2453acSAlex Bennée if test "$plugins" = "yes"; then 13285f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1329ba4dd2aaSAlex Bennée else 1330ba4dd2aaSAlex Bennée plugins="no" 13315f2453acSAlex Bennée fi 133240d6444eSAvi Kivityfi 133337650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 133440d6444eSAvi Kivity 133540d6444eSAvi Kivitycat > $TMPC << EOF 133621d4a791SAvi Kivity 133721d4a791SAvi Kivity#ifdef __linux__ 133821d4a791SAvi Kivity# define THREAD __thread 133921d4a791SAvi Kivity#else 134021d4a791SAvi Kivity# define THREAD 134121d4a791SAvi Kivity#endif 134221d4a791SAvi Kivitystatic THREAD int tls_var; 134321d4a791SAvi Kivityint main(void) { return tls_var; } 134440d6444eSAvi KivityEOF 1345b2634124SRichard Henderson 1346ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1347ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1348412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1349412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1350ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1351412aeacdSAlex Bennéefi 1352412aeacdSAlex Bennée 135312781462SRichard Hendersonif test "$static" = "yes"; then 1354eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 13555770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 135612781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 135712781462SRichard Henderson pie="yes" 135812781462SRichard Henderson elif test "$pie" = "yes"; then 135912781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 136012781462SRichard Henderson else 136112781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 136212781462SRichard Henderson pie="no" 136312781462SRichard Henderson fi 136412781462SRichard Hendersonelif test "$pie" = "no"; then 13655770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1366ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1367eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 13685770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 13695770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 137040d6444eSAvi Kivity pie="yes" 13712c674109SRichard Hendersonelif test "$pie" = "yes"; then 137276ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 137340d6444eSAvi Kivityelse 137440d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 137540d6444eSAvi Kivity pie="no" 137640d6444eSAvi Kivityfi 137740d6444eSAvi Kivity 1378e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1379e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1380e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1381e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1382e6cbd751SRichard Hendersonfi 1383e6cbd751SRichard Henderson 138409dada40SPaolo Bonzini########################################## 138509dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 138609dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 138709dada40SPaolo Bonzini# specification is necessary 138809dada40SPaolo Bonzini 138909dada40SPaolo Bonziniif test "$cpu" = "i386"; then 139009dada40SPaolo Bonzini cat > $TMPC << EOF 139109dada40SPaolo Bonzinistatic int sfaa(int *ptr) 139209dada40SPaolo Bonzini{ 139309dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 139409dada40SPaolo Bonzini} 139509dada40SPaolo Bonzini 139609dada40SPaolo Bonziniint main(void) 139709dada40SPaolo Bonzini{ 139809dada40SPaolo Bonzini int val = 42; 13991405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 140009dada40SPaolo Bonzini sfaa(&val); 140109dada40SPaolo Bonzini return val; 140209dada40SPaolo Bonzini} 140309dada40SPaolo BonziniEOF 140409dada40SPaolo Bonzini if ! compile_prog "" "" ; then 140509dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 140609dada40SPaolo Bonzini fi 140709dada40SPaolo Bonzinifi 140809dada40SPaolo Bonzini 140956267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 141056267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 141156267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 141256267b62SPhilippe Mathieu-Daudéfi 141356267b62SPhilippe Mathieu-Daudé 1414afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1415fdb75aefSPaolo Bonzini default_targets=yes 1416d880a3baSPaolo Bonzini for target in $default_target_list; do 1417d880a3baSPaolo Bonzini target_list="$target_list $target" 1418d880a3baSPaolo Bonzini done 1419d880a3baSPaolo Bonzini target_list="${target_list# }" 1420121afa9eSAnthony Liguorielse 1421fdb75aefSPaolo Bonzini default_targets=no 142289138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1423d880a3baSPaolo Bonzini for target in $target_list; do 142425b48338SPeter Maydell # Check that we recognised the target name; this allows a more 142525b48338SPeter Maydell # friendly error message than if we let it fall through. 142625b48338SPeter Maydell case " $default_target_list " in 142725b48338SPeter Maydell *" $target "*) 142825b48338SPeter Maydell ;; 142925b48338SPeter Maydell *) 143025b48338SPeter Maydell error_exit "Unknown target name '$target'" 143125b48338SPeter Maydell ;; 143225b48338SPeter Maydell esac 143325b48338SPeter Maydell done 1434d880a3baSPaolo Bonzinifi 143525b48338SPeter Maydell 1436f55fe278SPaolo Bonzini# see if system emulation was really requested 1437f55fe278SPaolo Bonzinicase " $target_list " in 1438f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1439f55fe278SPaolo Bonzini ;; 1440f55fe278SPaolo Bonzini *) softmmu=no 1441f55fe278SPaolo Bonzini ;; 1442f55fe278SPaolo Bonziniesac 14435327cf48Sbellard 1444249247c9SJuan Quintelafeature_not_found() { 1445249247c9SJuan Quintela feature=$1 144621684af0SStewart Smith remedy=$2 1447249247c9SJuan Quintela 144876ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 144921684af0SStewart Smith "configure was not able to find it." \ 145021684af0SStewart Smith "$remedy" 1451249247c9SJuan Quintela} 1452249247c9SJuan Quintela 14537d13299dSbellard# --- 14547d13299dSbellard# big/little endian test 14557d13299dSbellardcat > $TMPC << EOF 1456659eb157SThomas Huth#include <stdio.h> 145761cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 145861cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1459659eb157SThomas Huthint main(int argc, char *argv[]) 1460659eb157SThomas Huth{ 1461659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 14627d13299dSbellard} 14637d13299dSbellardEOF 14647d13299dSbellard 1465659eb157SThomas Huthif compile_prog ; then 1466659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 146761cc919fSMike Frysinger bigendian="yes" 1468659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 146961cc919fSMike Frysinger bigendian="no" 14707d13299dSbellard else 14717d13299dSbellard echo big/little test failed 1472659eb157SThomas Huth exit 1 14737d13299dSbellard fi 14747d13299dSbellardelse 147561cc919fSMike Frysinger echo big/little test failed 1476659eb157SThomas Huth exit 1 14777d13299dSbellardfi 14787d13299dSbellard 1479015a33bdSGonglei########################################## 1480779ab5e3SStefan Weil# pkg-config probe 1481779ab5e3SStefan Weil 1482779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 148376ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1484779ab5e3SStefan Weilfi 1485779ab5e3SStefan Weil 1486779ab5e3SStefan Weil########################################## 1487e18df141SAnthony Liguori# glib support probe 1488a52d28afSPaolo Bonzini 1489*0ce9b08cSThomas Huth# When bumping glib_req_ver, please check also whether we should increase 1490*0ce9b08cSThomas Huth# the _WIN32_WINNT setting in osdep.h according to the value from glib 1491b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 1492aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 1493aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 1494a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 1495b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 1496b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 149754cb65d8SEmilio G. Cotafi 1498e26110cfSFam Zheng 1499aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 1500e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 150189138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 150289138857SStefan Weil glib_libs=$($pkg_config --libs $i) 1503e18df141SAnthony Liguori else 1504e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 1505e26110cfSFam Zheng fi 1506e26110cfSFam Zhengdone 1507e26110cfSFam Zheng 1508215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 1509215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 1510215b0c2fSPaolo Bonzini 1511215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 1512215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 1513215b0c2fSPaolo Bonzinifi 1514215b0c2fSPaolo Bonzini 1515977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 1516977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 1517977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 1518977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 1519977a82abSDaniel P. Berrangecat > $TMPC <<EOF 1520977a82abSDaniel P. Berrange#include <glib.h> 1521977a82abSDaniel P. Berrange#include <unistd.h> 1522977a82abSDaniel P. Berrange 1523977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 1524977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 1525977a82abSDaniel P. Berrange 1526977a82abSDaniel P. Berrangeint main(void) { 1527977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 1528977a82abSDaniel P. Berrange return 0; 1529977a82abSDaniel P. Berrange} 1530977a82abSDaniel P. BerrangeEOF 1531977a82abSDaniel P. Berrange 1532215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 1533977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 1534977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 1535977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 1536977a82abSDaniel P. Berrange "build target" 1537977a82abSDaniel P. Berrangefi 1538977a82abSDaniel P. Berrange 15399bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 15409bda600bSEric Blakecat > $TMPC << EOF 15419bda600bSEric Blake#include <glib.h> 15429bda600bSEric Blaketypedef struct Foo { 15439bda600bSEric Blake int i; 15449bda600bSEric Blake} Foo; 15459bda600bSEric Blakestatic void foo_free(Foo *f) 15469bda600bSEric Blake{ 15479bda600bSEric Blake g_free(f); 15489bda600bSEric Blake} 1549e0e7fe07SMarc-André LureauG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free) 15509bda600bSEric Blakeint main(void) { return 0; } 15519bda600bSEric BlakeEOF 15529bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 15539bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 15549bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 15555770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 15569bda600bSEric Blake fi 15579bda600bSEric Blakefi 15589bda600bSEric Blake 1559e26110cfSFam Zheng########################################## 1560f652e6afSaurel32# fdt probe 1561e169e1e1SPeter Maydell 1562fbb4121dSPaolo Bonzinicase "$fdt" in 1563fbb4121dSPaolo Bonzini auto | enabled | internal) 1564fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 1565aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 1566fbb4121dSPaolo Bonzini ;; 1567fbb4121dSPaolo Bonziniesac 1568f652e6afSaurel32 156920ff075bSMichael Walle########################################## 15708ca80760SRichard Henderson# capstone 15718ca80760SRichard Henderson 1572e219c499SRichard Hendersoncase "$capstone" in 15738b18cdbfSRichard Henderson auto | enabled | internal) 15748b18cdbfSRichard Henderson # Simpler to always update submodule, even if not needed. 1575e219c499SRichard Henderson git_submodules="${git_submodules} capstone" 1576e219c499SRichard Henderson ;; 1577e219c499SRichard Hendersonesac 15788ca80760SRichard Henderson 15798ca80760SRichard Henderson########################################## 1580519175a2SAlex Barcelo# check and set a backend for coroutine 1581d0e2fce5SAneesh Kumar K.V 15827c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 158333c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 158433c53c54SDaniel P. Berrange# specific one. 15857c2acc70SPeter Maydell 15867c2acc70SPeter Maydellucontext_works=no 1587d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 1588d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 1589d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 1590cdf84806SPeter Maydell#ifdef __stub_makecontext 1591cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 1592cdf84806SPeter Maydell#endif 159375cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 1594d0e2fce5SAneesh Kumar K.VEOF 1595d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 15967c2acc70SPeter Maydell ucontext_works=yes 1597d0e2fce5SAneesh Kumar K.V fi 1598519175a2SAlex Barcelofi 15997c2acc70SPeter Maydell 16007c2acc70SPeter Maydellif test "$coroutine" = ""; then 16017c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 16027c2acc70SPeter Maydell coroutine=win32 16037c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 16047c2acc70SPeter Maydell coroutine=ucontext 1605519175a2SAlex Barcelo else 16067c2acc70SPeter Maydell coroutine=sigaltstack 16077c2acc70SPeter Maydell fi 16087c2acc70SPeter Maydellelse 16097c2acc70SPeter Maydell case $coroutine in 16107c2acc70SPeter Maydell windows) 16117c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 16127c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 16137c2acc70SPeter Maydell fi 16147c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 16157c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 16167c2acc70SPeter Maydell coroutine=win32 16177c2acc70SPeter Maydell ;; 16187c2acc70SPeter Maydell ucontext) 16197c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 16207c2acc70SPeter Maydell feature_not_found "ucontext" 16217c2acc70SPeter Maydell fi 16227c2acc70SPeter Maydell ;; 162333c53c54SDaniel P. Berrange sigaltstack) 16247c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 16257c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 16267c2acc70SPeter Maydell fi 16277c2acc70SPeter Maydell ;; 16287c2acc70SPeter Maydell *) 162976ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 16307c2acc70SPeter Maydell ;; 16317c2acc70SPeter Maydell esac 1632d0e2fce5SAneesh Kumar K.Vfi 1633d0e2fce5SAneesh Kumar K.V 16341e4f6065SDaniele Buono################################################## 16351e4f6065SDaniele Buono# SafeStack 16361e4f6065SDaniele Buono 16371e4f6065SDaniele Buono 16381e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 16391e4f6065SDaniele Buonocat > $TMPC << EOF 16401e4f6065SDaniele Buonoint main(int argc, char *argv[]) 16411e4f6065SDaniele Buono{ 16421e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 16431e4f6065SDaniele Buono#error SafeStack Disabled 16441e4f6065SDaniele Buono#endif 16451e4f6065SDaniele Buono return 0; 16461e4f6065SDaniele Buono} 16471e4f6065SDaniele BuonoEOF 16481e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 16491e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 16501e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 16511e4f6065SDaniele Buono # Flag needed both at compilation and at linking 16521e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 16531e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 16541e4f6065SDaniele Buono else 16551e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 16561e4f6065SDaniele Buono fi 16571e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 16581e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 16591e4f6065SDaniele Buono fi 16601e4f6065SDaniele Buonoelse 16611e4f6065SDaniele Buonocat > $TMPC << EOF 16621e4f6065SDaniele Buonoint main(int argc, char *argv[]) 16631e4f6065SDaniele Buono{ 16641e4f6065SDaniele Buono#if defined(__has_feature) 16651e4f6065SDaniele Buono#if __has_feature(safe_stack) 16661e4f6065SDaniele Buono#error SafeStack Enabled 16671e4f6065SDaniele Buono#endif 16681e4f6065SDaniele Buono#endif 16691e4f6065SDaniele Buono return 0; 16701e4f6065SDaniele Buono} 16711e4f6065SDaniele BuonoEOF 16721e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 16731e4f6065SDaniele Buono # Make sure that safe-stack is disabled 16741e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 16751e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 16761e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 16771e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 16781e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 16791e4f6065SDaniele Buono fi 16801e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 16811e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 16821e4f6065SDaniele Buono fi 16831e4f6065SDaniele Buonoelse # "$safe_stack" = "" 16841e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 16851e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 16861e4f6065SDaniele Buono safe_stack="no" 16871e4f6065SDaniele Buono else 16881e4f6065SDaniele Buono safe_stack="yes" 16891e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 16901e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 16911e4f6065SDaniele Buono fi 16921e4f6065SDaniele Buono fi 16931e4f6065SDaniele Buonofi 16941e4f6065SDaniele Buonofi 16957d992e4dSPeter Lieven 169676a347e1SRichard Henderson######################################## 1697fd0e6053SJohn Snow# check if ccache is interfering with 1698fd0e6053SJohn Snow# semantic analysis of macros 1699fd0e6053SJohn Snow 17005e4dfd3dSJohn Snowunset CCACHE_CPP2 1701fd0e6053SJohn Snowccache_cpp2=no 1702fd0e6053SJohn Snowcat > $TMPC << EOF 1703fd0e6053SJohn Snowstatic const int Z = 1; 1704fd0e6053SJohn Snow#define fn() ({ Z; }) 1705fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 1706fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 1707fd0e6053SJohn Snow#define ID(X) (X) 1708fd0e6053SJohn Snowint main(int argc, char *argv[]) 1709fd0e6053SJohn Snow{ 1710fd0e6053SJohn Snow int x = 0, y = 0; 1711fd0e6053SJohn Snow x = ID(x); 1712fd0e6053SJohn Snow x = fn(); 1713fd0e6053SJohn Snow fn(); 1714fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 1715fd0e6053SJohn Snow if (TAUT(Z)) return 0; 1716fd0e6053SJohn Snow return 0; 1717fd0e6053SJohn Snow} 1718fd0e6053SJohn SnowEOF 1719fd0e6053SJohn Snow 1720fd0e6053SJohn Snowif ! compile_object "-Werror"; then 1721fd0e6053SJohn Snow ccache_cpp2=yes 1722fd0e6053SJohn Snowfi 1723fd0e6053SJohn Snow 1724b553a042SJohn Snow################################################# 1725b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 1726b553a042SJohn Snow 1727b553a042SJohn Snowif test "$fortify_source" != "no"; then 1728b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 1729b553a042SJohn Snow fortify_source="no"; 1730e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 1731cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 1732b553a042SJohn Snow fortify_source="no"; 1733b553a042SJohn Snow else 1734b553a042SJohn Snow fortify_source="yes" 1735b553a042SJohn Snow fi 1736b553a042SJohn Snowfi 1737b553a042SJohn Snow 1738d2042378SAneesh Kumar K.V########################################## 1739247724cbSMarc-André Lureau# checks for sanitizers 1740247724cbSMarc-André Lureau 1741247724cbSMarc-André Lureauhave_asan=no 1742247724cbSMarc-André Lureauhave_ubsan=no 1743d83414e1SMarc-André Lureauhave_asan_iface_h=no 1744d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 1745247724cbSMarc-André Lureau 1746247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 1747b9f44da2SMarc-André Lureau write_c_skeleton 1748247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 1749247724cbSMarc-André Lureau have_asan=yes 1750247724cbSMarc-André Lureau fi 1751b9f44da2SMarc-André Lureau 1752b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 1753b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 1754b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 1755b9f44da2SMarc-André Lureau cat > $TMPC << EOF 1756b9f44da2SMarc-André Lureau#include <stdlib.h> 1757b9f44da2SMarc-André Lureauint main(void) { 1758b9f44da2SMarc-André Lureau void *tmp = malloc(10); 1759f2dfe54cSLeonid Bloch if (tmp != NULL) { 1760b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 1761b9f44da2SMarc-André Lureau } 1762d1abf3fcSOlaf Hering return 1; 1763f2dfe54cSLeonid Bloch} 1764b9f44da2SMarc-André LureauEOF 1765247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 1766247724cbSMarc-André Lureau have_ubsan=yes 1767247724cbSMarc-André Lureau fi 1768d83414e1SMarc-André Lureau 1769d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 1770d83414e1SMarc-André Lureau have_asan_iface_h=yes 1771d83414e1SMarc-André Lureau fi 1772d83414e1SMarc-André Lureau 1773d83414e1SMarc-André Lureau cat > $TMPC << EOF 1774d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 1775d83414e1SMarc-André Lureauint main(void) { 1776d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 1777d83414e1SMarc-André Lureau return 0; 1778d83414e1SMarc-André Lureau} 1779d83414e1SMarc-André LureauEOF 1780d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 1781d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 1782d83414e1SMarc-André Lureau fi 1783247724cbSMarc-André Lureaufi 1784247724cbSMarc-André Lureau 17850aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 17860aebab04SLingfeng Yang# keep it separate until that is not the case. 17870aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 17880aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 17890aebab04SLingfeng Yangfi 17900aebab04SLingfeng Yanghave_tsan=no 17910aebab04SLingfeng Yanghave_tsan_iface_fiber=no 17920aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 17930aebab04SLingfeng Yang write_c_skeleton 17940aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 17950aebab04SLingfeng Yang have_tsan=yes 17960aebab04SLingfeng Yang fi 17970aebab04SLingfeng Yang cat > $TMPC << EOF 17980aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 17990aebab04SLingfeng Yangint main(void) { 18000aebab04SLingfeng Yang __tsan_create_fiber(0); 18010aebab04SLingfeng Yang return 0; 18020aebab04SLingfeng Yang} 18030aebab04SLingfeng YangEOF 18040aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 18050aebab04SLingfeng Yang have_tsan_iface_fiber=yes 18060aebab04SLingfeng Yang fi 18070aebab04SLingfeng Yangfi 18080aebab04SLingfeng Yang 1809adc28027SAlexander Bulekov########################################## 1810675b9b53SMarc-André Lureau# check for slirp 1811675b9b53SMarc-André Lureau 1812675b9b53SMarc-André Lureaucase "$slirp" in 18134d34a86bSPaolo Bonzini auto | enabled | internal) 18144d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 18157c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 1816675b9b53SMarc-André Lureau ;; 1817675b9b53SMarc-André Lureauesac 1818675b9b53SMarc-André Lureau 181954e7aac0SAlexey Krasikov########################################## 1820e86ecd4bSJuan Quintela# End of CC checks 1821e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 1822e86ecd4bSJuan Quintela 1823d83414e1SMarc-André Lureauwrite_c_skeleton 1824d83414e1SMarc-André Lureau 1825df42fa7dSPaolo Bonziniif test "$fortify_source" = "yes" ; then 1826086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 1827086d5f75SPaolo Bonzinifi 1828086d5f75SPaolo Bonzini 1829086d5f75SPaolo Bonzinicase "$ARCH" in 1830086d5f75SPaolo Bonzinialpha) 1831086d5f75SPaolo Bonzini # Ensure there's only a single GP 1832086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 1833086d5f75SPaolo Bonzini;; 1834086d5f75SPaolo Bonziniesac 1835086d5f75SPaolo Bonzini 1836247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 1837db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 1838db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 1839d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 1840d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 1841d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 1842d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 1843d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 1844d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 1845d83414e1SMarc-André Lureau fi 1846247724cbSMarc-André Lureaufi 18470aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 18480aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 18490aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 18500aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 18510aebab04SLingfeng Yang else 18520aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 18530aebab04SLingfeng Yang fi 18540aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 18550aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 18560aebab04SLingfeng Yangfi 1857247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 1858db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 1859db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 1860247724cbSMarc-André Lureaufi 1861247724cbSMarc-André Lureau 18626542aa9cSPeter Lieven########################################## 18633efac6ebSTomáš Golembiovský 18640aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 18650aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 1866e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 1867db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 1868e86ecd4bSJuan Quintela fi 1869e86ecd4bSJuan Quintelafi 1870e86ecd4bSJuan Quintela 1871b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 18729d6bc27bSMichael Roth 18739d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 18749d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 18759d6bc27bSMichael Rothfi 18769d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 18779d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 18789d6bc27bSMichael Rothfi 18799d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 188089138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 18819d6bc27bSMichael Rothfi 18829d6bc27bSMichael Roth 18836e444209SPaolo BonziniQEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 18849d6bc27bSMichael Roth 1885ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 1886ca35f780SPaolo Bonziniroms= 1887e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 1888ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 1889ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 1890e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 1891c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 1892c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 1893c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 1894e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 1895e57218b6SPeter Maydell ld_i386_emulation="$emu" 1896ca35f780SPaolo Bonzini roms="optionrom" 1897e57218b6SPeter Maydell break 1898e57218b6SPeter Maydell fi 1899e57218b6SPeter Maydell done 1900ca35f780SPaolo Bonzinifi 1901ca35f780SPaolo Bonzini 19022e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 1903a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 19049933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 19052e33c3f8SThomas Huth write_c_skeleton 1906a5b2afd5SThomas Huth compile_prog "-march=z900" "" 1907a5b2afd5SThomas Huth has_z900=$? 19083af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 1909a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 1910a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 1911a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 1912a5b2afd5SThomas Huth fi 19139933c305SChristian Borntraeger roms="$roms s390-ccw" 19141ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 19151ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 19161ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 19171ef6bfc2SPhilippe Mathieu-Daudé fi 19189933c305SChristian Borntraegerfi 19199933c305SChristian Borntraeger 192011cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 192111cde1c8SBruno 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. 192211cde1c8SBruno Dominguezif has $cxx; then 192311cde1c8SBruno Dominguez cat > $TMPC <<EOF 192411cde1c8SBruno Dominguezint c_function(void); 192511cde1c8SBruno Dominguezint main(void) { return c_function(); } 192611cde1c8SBruno DominguezEOF 192711cde1c8SBruno Dominguez 192811cde1c8SBruno Dominguez compile_object 192911cde1c8SBruno Dominguez 193011cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 193111cde1c8SBruno Dominguezextern "C" { 193211cde1c8SBruno Dominguez int c_function(void); 193311cde1c8SBruno Dominguez} 193411cde1c8SBruno Dominguezint c_function(void) { return 42; } 193511cde1c8SBruno DominguezEOF 193611cde1c8SBruno Dominguez 193711cde1c8SBruno Dominguez update_cxxflags 193811cde1c8SBruno Dominguez 1939a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 194011cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 194111cde1c8SBruno Dominguez : 194211cde1c8SBruno Dominguez else 194311cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 194411cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 194511cde1c8SBruno Dominguez cxx= 194611cde1c8SBruno Dominguez fi 194711cde1c8SBruno Dominguezelse 194811cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 194911cde1c8SBruno Dominguez cxx= 195011cde1c8SBruno Dominguezfi 195111cde1c8SBruno Dominguez 19527d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 19537d7dbf9dSDan Streetman exit 1 19545d91a2edSYonggang Luofi 19555d91a2edSYonggang Luo 195698ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 195797a847bcSbellard 195898ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 195998ec69acSJuan Quintelaecho >> $config_host_mak 196098ec69acSJuan Quintela 1961e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 1962cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 1963aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 19647d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 1965804edf29SJuan Quintela 1966f8393946Saurel32if test "$debug_tcg" = "yes" ; then 19672358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 1968f8393946Saurel32fi 196967b915a5Sbellardif test "$mingw32" = "yes" ; then 197098ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 19716e444209SPaolo Bonzini echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak 19729dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 19739dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 19749dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 1975210fa556Spbrookelse 197635f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 1977210fa556Spbrookfi 1978128ab2ffSblueswir1 1979dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 1980dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 1981dffcb71cSMark McLoughlinfi 1982dffcb71cSMark McLoughlin 198383fb7adfSbellardif test "$darwin" = "yes" ; then 198498ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 198583fb7adfSbellardfi 1986b29fe3edSmalc 1987ec530c81Sbellardif test "$solaris" = "yes" ; then 198898ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 1989ec530c81Sbellardfi 199097a847bcSbellardif test "$static" = "yes" ; then 199198ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 199297a847bcSbellardfi 199398ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 19942b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 199517969268SFam Zhengif test "$modules" = "yes"; then 199617969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 199717969268SFam Zhengfi 1998277abf15SJan Vesely 199983fb7adfSbellard# XXX: suppress that 20007d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 20012358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 20027d3505c5Sbellardfi 20037d3505c5Sbellard 20047c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 20057d992e4dSPeter Lieven 2006d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 2007d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 2008d83414e1SMarc-André Lureaufi 2009d83414e1SMarc-André Lureau 20100aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 20110aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 20120aebab04SLingfeng Yangfi 20130aebab04SLingfeng Yang 201440e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 201540e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 201640e8c6f4SAlex Bennéefi 201740e8c6f4SAlex Bennée 2018f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 2019b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 2020d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 2021f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 2022f48e590aSAlex Bennée fi 2023b1863cccSAlex Bennéefi 2024f48e590aSAlex Bennée 202598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 2026804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 2027c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 202839d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 2029a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 203009e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 2031804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 2032804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 2033cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 20345f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 20353dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 2036804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 2037804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 2038a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 203911cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 20404cb37d11SPhilippe Mathieu-Daudéecho "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak 2041a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 2042a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 2043d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 20448a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 2045e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 2046a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 2047804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 2048804edf29SJuan Quintela 20496efd7517SPeter Maydell# use included Linux headers 20506efd7517SPeter Maydellif test "$linux" = "yes" ; then 2051a307beb6SAndreas Färber mkdir -p linux-headers 20526efd7517SPeter Maydell case "$cpu" in 20534da270beSPaolo Bonzini i386|x86_64) 205408312a63SPeter Maydell linux_arch=x86 20556efd7517SPeter Maydell ;; 2056d8ff892dSPaolo Bonzini ppc|ppc64) 205708312a63SPeter Maydell linux_arch=powerpc 20586efd7517SPeter Maydell ;; 20596efd7517SPeter Maydell s390x) 206008312a63SPeter Maydell linux_arch=s390 206108312a63SPeter Maydell ;; 20621f080313SClaudio Fontana aarch64) 20631f080313SClaudio Fontana linux_arch=arm64 20641f080313SClaudio Fontana ;; 2065dfcf900bSWANG Xuerui loongarch*) 2066dfcf900bSWANG Xuerui linux_arch=loongarch 2067dfcf900bSWANG Xuerui ;; 2068222e7d11SSanjay Lal mips64) 2069222e7d11SSanjay Lal linux_arch=mips 2070222e7d11SSanjay Lal ;; 207108312a63SPeter Maydell *) 207208312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 207308312a63SPeter Maydell linux_arch="$cpu" 20746efd7517SPeter Maydell ;; 20756efd7517SPeter Maydell esac 207608312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 207708312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 207808312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 207908312a63SPeter Maydell fi 20806efd7517SPeter Maydellfi 20816efd7517SPeter Maydell 208297a847bcSbellardfor target in $target_list; do 208397a847bcSbellard target_dir="$target" 208457a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 208597a847bcSbellard mkdir -p $target_dir 2086fdb75aefSPaolo Bonzini case $target in 2087fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 2088fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 20892408a527Saurel32 esac 209056aebc89Spbrookdone 20917d13299dSbellard 2092fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 2093fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 2094fdb75aefSPaolo Bonzinifi 2095a540f158SPeter Crosthwaite 2096fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 2097fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 2098fd0e6053SJohn Snowfi 2099fd0e6053SJohn Snow 21001e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 21011e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 21021e4f6065SDaniele Buonofi 21031e4f6065SDaniele Buono 2104e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 2105e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 2106e29e5c6eSPeter Maydell# (these can be both files and directories). 2107e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 2108e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 2109e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 2110e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 2111e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 2112e29e5c6eSPeter Maydell# directory and symlink the directory instead. 21132038f8c8SPaolo BonziniLINKS="Makefile" 21143941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 2115ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 2116e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 2117e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 2118bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 211939950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 21208f8fd9edSCleber RosaLINKS="$LINKS python" 2121c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 2122753d11f2SRichard Hendersonfor bios_file in \ 2123753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 21243a631b8eSBin Meng $source_path/pc-bios/*.elf \ 2125225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 2126753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 2127753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 2128e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 2129753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 21304e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 2131cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 2132cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 2133cd946e5cSJohn Arbuckle 2134753d11f2SRichard Hendersondo 2135e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 21367ea78b74SJan Kiszkadone 2137e29e5c6eSPeter Maydellfor f in $LINKS ; do 21380f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 21395dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 2140f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 2141f9245e10SPeter Maydell fi 21427d13299dSbellarddone 21431ad2134fSPaul Brook 21442038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 21452038f8c8SPaolo Bonzini export $i 21462038f8c8SPaolo Bonzinidone 2147544f4a25SPaolo Bonziniexport target_list source_path use_containers cpu host_cc 21482038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 21492038f8c8SPaolo Bonzini 215098409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 215198409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 215298409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 215398409991SHelge Konetzka 2154a5665051SPaolo Bonziniif test "$skip_meson" = no; then 2155fc929892SMarc-André Lureau cross="config-meson.cross.new" 2156fc929892SMarc-André Lureau meson_quote() { 2157ac7ebcc5SPaolo Bonzini test $# = 0 && return 215847b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 2159fc929892SMarc-André Lureau } 2160fc929892SMarc-André Lureau 2161fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 2162fc929892SMarc-André Lureau echo "[properties]" >> $cross 2163d1d5e9eeSAlex Bennée 2164d1d5e9eeSAlex Bennée # unroll any custom device configs 2165d1d5e9eeSAlex Bennée for a in $device_archs; do 2166d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 2167d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 2168d1d5e9eeSAlex Bennée done 2169d1d5e9eeSAlex Bennée 2170fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 217147b30835SPaolo Bonzini echo "[built-in options]" >> $cross 2172a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 2173a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 2174e910c7d9SPhilippe Mathieu-Daudé test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross 2175a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 2176a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 2177fc929892SMarc-André Lureau echo "[binaries]" >> $cross 21784dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 21794dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 21804dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 218147b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 218247b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 218347b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 218447b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 2185e8178514SPaolo Bonzini if has $sdl2_config; then 218647b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 2187e8178514SPaolo Bonzini fi 218847b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 2189158bb224SKonstantin Kostiuk echo "widl = [$(meson_quote $widl)]" >> $cross 219047b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 21913812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 2192fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 2193fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 2194ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 2195823eb013SPaolo Bonzini case "$cpu" in 2196f6bca9dfSJoelle van Dyne i386) 2197fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 2198fc929892SMarc-André Lureau ;; 2199fc929892SMarc-André Lureau *) 2200823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 2201fc929892SMarc-André Lureau ;; 2202fc929892SMarc-André Lureau esac 2203fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 2204fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 2205fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 2206fc929892SMarc-André Lureau else 2207fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 2208fc929892SMarc-André Lureau fi 2209fc929892SMarc-André Lureau else 2210fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 2211fc929892SMarc-André Lureau fi 2212fc929892SMarc-André Lureau mv $cross config-meson.cross 2213fc929892SMarc-André Lureau 2214a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 22150a31e3a0SPaolo Bonzini 22160a31e3a0SPaolo Bonzini # Built-in options 22170a31e3a0SPaolo Bonzini test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir" 22180a31e3a0SPaolo Bonzini test "$default_feature" = no && meson_option_add -Dauto_features=disabled 22190a31e3a0SPaolo Bonzini test "$pie" = no && meson_option_add -Db_pie=false 22200a31e3a0SPaolo Bonzini test "$werror" = yes && meson_option_add -Dwerror=true 22210a31e3a0SPaolo Bonzini 22220a31e3a0SPaolo Bonzini # QEMU options 22230a31e3a0SPaolo Bonzini test "$capstone" != auto && meson_option_add "-Dcapstone=$capstone" 22240a31e3a0SPaolo Bonzini test "$cfi" != false && meson_option_add "-Dcfi=$cfi" 22250a31e3a0SPaolo Bonzini test "$fdt" != auto && meson_option_add "-Dfdt=$fdt" 22260a31e3a0SPaolo Bonzini test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE" 22270a31e3a0SPaolo Bonzini test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix" 22280a31e3a0SPaolo Bonzini test "$slirp" != auto && meson_option_add "-Dslirp=$slirp" 22290a31e3a0SPaolo Bonzini test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd" 22300a31e3a0SPaolo Bonzini test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg" 223161d63097SPaolo Bonzini run_meson() { 22320a31e3a0SPaolo Bonzini NINJA=$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path" 223361d63097SPaolo Bonzini } 223461d63097SPaolo Bonzini eval run_meson $meson_options 2235a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 2236a5665051SPaolo Bonzini error_exit "meson setup failed" 2237a5665051SPaolo Bonzini fi 2238699d3884SPaolo Bonzinielse 2239699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 2240699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 2241699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 2242699d3884SPaolo Bonzini perl -i -ne ' 2243699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 2244699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 2245654d6b04SPaolo Bonzini /^b_staticpic/ && next; 2246699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 2247699d3884SPaolo Bonzini fi 2248a5665051SPaolo Bonzinifi 2249a5665051SPaolo Bonzini 2250dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 2251dc655404SMichael S. Tsirkincat <<EOD >config.status 2252dc655404SMichael S. Tsirkin#!/bin/sh 2253dc655404SMichael S. Tsirkin# Generated by configure. 2254dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 2255dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 2256dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 2257dc655404SMichael S. TsirkinEOD 2258e811da7fSDaniel P. Berrangé 2259e811da7fSDaniel P. Berrangépreserve_env() { 2260e811da7fSDaniel P. Berrangé envname=$1 2261e811da7fSDaniel P. Berrangé 2262e811da7fSDaniel P. Berrangé eval envval=\$$envname 2263e811da7fSDaniel P. Berrangé 2264e811da7fSDaniel P. Berrangé if test -n "$envval" 2265e811da7fSDaniel P. Berrangé then 2266e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 2267e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 2268e811da7fSDaniel P. Berrangé else 2269e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 2270e811da7fSDaniel P. Berrangé fi 2271e811da7fSDaniel P. Berrangé} 2272e811da7fSDaniel P. Berrangé 2273e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 2274e811da7fSDaniel P. Berrangé# features/build target configure will detect 2275e811da7fSDaniel P. Berrangépreserve_env AR 2276e811da7fSDaniel P. Berrangépreserve_env AS 2277e811da7fSDaniel P. Berrangépreserve_env CC 2278e811da7fSDaniel P. Berrangépreserve_env CPP 22798009da03SPaolo Bonzinipreserve_env CFLAGS 2280e811da7fSDaniel P. Berrangépreserve_env CXX 22818009da03SPaolo Bonzinipreserve_env CXXFLAGS 2282e811da7fSDaniel P. Berrangépreserve_env INSTALL 2283e811da7fSDaniel P. Berrangépreserve_env LD 22848009da03SPaolo Bonzinipreserve_env LDFLAGS 2285e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 2286e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 2287e811da7fSDaniel P. Berrangépreserve_env MAKE 2288e811da7fSDaniel P. Berrangépreserve_env NM 2289e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 2290e811da7fSDaniel P. Berrangépreserve_env PATH 2291e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 2292e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 2293e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 2294e811da7fSDaniel P. Berrangépreserve_env PYTHON 2295e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 2296e811da7fSDaniel P. Berrangépreserve_env SMBD 2297e811da7fSDaniel P. Berrangépreserve_env STRIP 2298158bb224SKonstantin Kostiukpreserve_env WIDL 2299e811da7fSDaniel P. Berrangépreserve_env WINDRES 2300e811da7fSDaniel P. Berrangé 2301dc655404SMichael S. Tsirkinprintf "exec" >>config.status 2302a5665051SPaolo Bonzinifor i in "$0" "$@"; do 2303835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 2304a5665051SPaolo Bonzinidone 2305cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 2306dc655404SMichael S. Tsirkinchmod +x config.status 2307dc655404SMichael S. Tsirkin 23088cd05ab6SPeter Maydellrm -r "$TMPDIR1" 2309