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 6064708615SPeter Maydell 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}" 70563661c0SPeter Maydellif ! mkdir -p "${TMPDIR1}"; then 718cd05ab6SPeter Maydell echo "ERROR: failed to create temporary directory" 728cd05ab6SPeter Maydell exit 1 737d13299dSbellardfi 747d13299dSbellard 758cd05ab6SPeter MaydellTMPB="qemu-conf" 768cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c" 7766518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o" 784cb37d11SPhilippe Mathieu-DaudéTMPM="${TMPDIR1}/${TMPB}.m" 798cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe" 807d13299dSbellard 81da1d85e3SGerd Hoffmannrm -f config.log 829ac81bbbSmalc 83b48e3611SPeter Maydell# Print a helpful header at the top of config.log 84b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log 85979ae168SPeter Maydellprintf "# Configured with:" >> config.log 867f788779SAlex Bennée# repeat the invocation to log and stdout for CI 877f788779SAlex Bennéeinvoke=$(printf " '%s'" "$0" "$@") 887f788779SAlex Bennéetest -n "$GITLAB_CI" && echo "configuring with: $invoke" 897f788779SAlex Bennée{ echo "$invoke"; echo; echo "#"; } >> config.log 90b48e3611SPeter Maydell 91835af899SPaolo Bonziniquote_sh() { 92835af899SPaolo Bonzini printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," 93835af899SPaolo Bonzini} 94835af899SPaolo Bonzini 95d880a3baSPaolo Bonziniprint_error() { 96d880a3baSPaolo Bonzini (echo 9776ad07a4SPeter Maydell echo "ERROR: $1" 9876ad07a4SPeter Maydell while test -n "$2"; do 9976ad07a4SPeter Maydell echo " $2" 10076ad07a4SPeter Maydell shift 10176ad07a4SPeter Maydell done 102d880a3baSPaolo Bonzini echo) >&2 103d880a3baSPaolo Bonzini} 104d880a3baSPaolo Bonzini 105d880a3baSPaolo Bonzinierror_exit() { 106d880a3baSPaolo Bonzini print_error "$@" 10776ad07a4SPeter Maydell exit 1 10876ad07a4SPeter Maydell} 10976ad07a4SPeter Maydell 1109c83ffd8SPeter Maydelldo_compiler() { 1119c83ffd8SPeter Maydell # Run the compiler, capturing its output to the log. First argument 1129c83ffd8SPeter Maydell # is compiler binary to execute. 113b3b5472dSPeter Maydell compiler="$1" 114cd362defSPaolo Bonzini shift 115cd362defSPaolo Bonzini if test -n "$BASH_VERSION"; then eval ' 116cd362defSPaolo Bonzini echo >>config.log " 117cd362defSPaolo Bonzinifuncs: ${FUNCNAME[*]} 118cd362defSPaolo Bonzinilines: ${BASH_LINENO[*]}" 119cd362defSPaolo Bonzini '; fi 120cd362defSPaolo Bonzini echo $compiler "$@" >> config.log 121cd362defSPaolo Bonzini $compiler "$@" >> config.log 2>&1 || return $? 122cd362defSPaolo Bonzini} 123cd362defSPaolo Bonzini 124cd362defSPaolo Bonzinido_compiler_werror() { 125cd362defSPaolo Bonzini # Run the compiler, capturing its output to the log. First argument 126cd362defSPaolo Bonzini # is compiler binary to execute. 127630d86b7SDavid CARLIER compiler="$1" 1289c83ffd8SPeter Maydell shift 1298bbe05d7SIan Jackson if test -n "$BASH_VERSION"; then eval ' 1308bbe05d7SIan Jackson echo >>config.log " 1318bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]} 1328bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}" 1338bbe05d7SIan Jackson '; fi 1349c83ffd8SPeter Maydell echo $compiler "$@" >> config.log 1359c83ffd8SPeter Maydell $compiler "$@" >> config.log 2>&1 || return $? 1368dc38a78SPeter Maydell # Test passed. If this is an --enable-werror build, rerun 1378dc38a78SPeter Maydell # the test with -Werror and bail out if it fails. This 1388dc38a78SPeter Maydell # makes warning-generating-errors in configure test code 1398dc38a78SPeter Maydell # obvious to developers. 1408dc38a78SPeter Maydell if test "$werror" != "yes"; then 1418dc38a78SPeter Maydell return 0 1428dc38a78SPeter Maydell fi 1438dc38a78SPeter Maydell # Don't bother rerunning the compile if we were already using -Werror 1448dc38a78SPeter Maydell case "$*" in 1458dc38a78SPeter Maydell *-Werror*) 1468dc38a78SPeter Maydell return 0 1478dc38a78SPeter Maydell ;; 1488dc38a78SPeter Maydell esac 1499c83ffd8SPeter Maydell echo $compiler -Werror "$@" >> config.log 1509c83ffd8SPeter Maydell $compiler -Werror "$@" >> config.log 2>&1 && return $? 15176ad07a4SPeter Maydell error_exit "configure test passed without -Werror but failed with -Werror." \ 15276ad07a4SPeter Maydell "This is probably a bug in the configure script. The failing command" \ 15376ad07a4SPeter Maydell "will be at the bottom of config.log." \ 15476ad07a4SPeter Maydell "You can run configure with --disable-werror to bypass this check." 1558dc38a78SPeter Maydell} 1568dc38a78SPeter Maydell 1579c83ffd8SPeter Maydelldo_cc() { 158cd362defSPaolo Bonzini do_compiler_werror "$cc" $CPU_CFLAGS "$@" 1599c83ffd8SPeter Maydell} 1609c83ffd8SPeter Maydell 1614cb37d11SPhilippe Mathieu-Daudédo_objc() { 162cd362defSPaolo Bonzini do_compiler_werror "$objcc" $CPU_CFLAGS "$@" 1634cb37d11SPhilippe Mathieu-Daudé} 1644cb37d11SPhilippe Mathieu-Daudé 16500849b92SRichard Henderson# Append $2 to the variable named $1, with space separation 16600849b92SRichard Hendersonadd_to() { 16700849b92SRichard Henderson eval $1=\${$1:+\"\$$1 \"}\$2 16800849b92SRichard Henderson} 16900849b92SRichard Henderson 17052166aa0SJuan Quintelacompile_object() { 171fd0e6053SJohn Snow local_cflags="$1" 172a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC 17352166aa0SJuan Quintela} 17452166aa0SJuan Quintela 17552166aa0SJuan Quintelacompile_prog() { 17652166aa0SJuan Quintela local_cflags="$1" 17752166aa0SJuan Quintela local_ldflags="$2" 178a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \ 179a2866660SPaolo Bonzini $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags 18052166aa0SJuan Quintela} 18152166aa0SJuan Quintela 18211568d6dSPaolo Bonzini# symbolically link $1 to $2. Portable version of "ln -sf". 18311568d6dSPaolo Bonzinisymlink() { 18472b8b5a1SStefan Weil rm -rf "$2" 185ec5b06d7SAnthony Liguori mkdir -p "$(dirname "$2")" 18672b8b5a1SStefan Weil ln -s "$1" "$2" 18711568d6dSPaolo Bonzini} 18811568d6dSPaolo Bonzini 1890dba6195SLoïc Minier# check whether a command is available to this shell (may be either an 1900dba6195SLoïc Minier# executable or a builtin) 1910dba6195SLoïc Minierhas() { 1920dba6195SLoïc Minier type "$1" >/dev/null 2>&1 1930dba6195SLoïc Minier} 1940dba6195SLoïc Minier 1950a01d76fSMarc-André Lureauversion_ge () { 1962df52b9bSAlex Bennée local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') 1972df52b9bSAlex Bennée local_ver2=$(echo "$2" | tr . ' ') 1980a01d76fSMarc-André Lureau while true; do 1990a01d76fSMarc-André Lureau set x $local_ver1 2000a01d76fSMarc-André Lureau local_first=${2-0} 201c44a33e2SStefano Garzarella # 'shift 2' if $2 is set, or 'shift' if $2 is not set 202c44a33e2SStefano Garzarella shift ${2:+2} 2030a01d76fSMarc-André Lureau local_ver1=$* 2040a01d76fSMarc-André Lureau set x $local_ver2 2050a01d76fSMarc-André Lureau # the second argument finished, the first must be greater or equal 2060a01d76fSMarc-André Lureau test $# = 1 && return 0 2070a01d76fSMarc-André Lureau test $local_first -lt $2 && return 1 2080a01d76fSMarc-André Lureau test $local_first -gt $2 && return 0 209c44a33e2SStefano Garzarella shift ${2:+2} 2100a01d76fSMarc-André Lureau local_ver2=$* 2110a01d76fSMarc-André Lureau done 2120a01d76fSMarc-André Lureau} 2130a01d76fSMarc-André Lureau 2144ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; 2154ace32e2SAntonio Ospitethen 2164ace32e2SAntonio Ospite error_exit "main directory cannot contain spaces nor colons" 2174ace32e2SAntonio Ospitefi 2184ace32e2SAntonio Ospite 21914211825SAntonio Ospite# default parameters 2202ff6b91eSJuan Quintelacpu="" 22143ce4dfeSbellardstatic="no" 2223812c0c4SJoelle van Dynecross_compile="no" 2237d13299dSbellardcross_prefix="" 224e49d021eSPeter Maydellhost_cc="cc" 22563678e17SSteven Noonanstack_protector="" 2261e4f6065SDaniele Buonosafe_stack="" 227afc3a8f9SAlex Bennéeuse_containers="yes" 228f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 229ac0df51dSaliguori 23092712822SDaniel P. Berrangeif test -e "$source_path/.git" 23192712822SDaniel P. Berrangethen 2327d7dbf9dSDan Streetman git_submodules_action="update" 23392712822SDaniel P. Berrangeelse 2347d7dbf9dSDan Streetman git_submodules_action="ignore" 23592712822SDaniel P. Berrangefi 2362d652f24SPaolo Bonzini 2372d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb" 238cc84d63aSDaniel P. Berrangegit="git" 239ac0df51dSaliguori 240afb63ebdSStefan Weil# Don't accept a target_list environment variable. 241afb63ebdSStefan Weilunset target_list 242447e133fSAlex Bennéeunset target_list_exclude 243377529c0SPaolo Bonzini 244377529c0SPaolo Bonzini# Default value for a variable defining feature "foo". 245377529c0SPaolo Bonzini# * foo="no" feature will only be used if --enable-foo arg is given 246377529c0SPaolo Bonzini# * foo="" feature will be searched for, and if found, will be used 247377529c0SPaolo Bonzini# unless --disable-foo is given 248377529c0SPaolo Bonzini# * foo="yes" this value will only be set by --enable-foo flag. 249377529c0SPaolo Bonzini# feature will searched for, 250377529c0SPaolo Bonzini# if not found, configure exits with error 251377529c0SPaolo Bonzini# 252377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args. 253377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it 254377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found. 255377529c0SPaolo Bonzini 256c87ea116SAlex Bennéedefault_feature="" 257c87ea116SAlex Bennée# parse CC options second 258c87ea116SAlex Bennéefor opt do 259c87ea116SAlex Bennée optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 260c87ea116SAlex Bennée case "$opt" in 261c87ea116SAlex Bennée --without-default-features) 262c87ea116SAlex Bennée default_feature="no" 263c87ea116SAlex Bennée ;; 264c87ea116SAlex Bennée esac 265c87ea116SAlex Bennéedone 266c87ea116SAlex Bennée 267a2866660SPaolo BonziniEXTRA_CFLAGS="" 268a2866660SPaolo BonziniEXTRA_CXXFLAGS="" 269e910c7d9SPhilippe Mathieu-DaudéEXTRA_OBJCFLAGS="" 270a2866660SPaolo BonziniEXTRA_LDFLAGS="" 271a2866660SPaolo Bonzini 272377529c0SPaolo Bonzinidebug_tcg="no" 273247724cbSMarc-André Lureausanitizers="no" 2740aebab04SLingfeng Yangtsan="no" 2751f3f2bfeSMichael Tokarevfortify_source="yes" 276c7328271SMiroslav RezaninaEXESUF="" 27717969268SFam Zhengmodules="no" 278377529c0SPaolo Bonziniprefix="/usr/local" 27910ff82d1SMarc-André Lureauqemu_suffix="qemu" 280377529c0SPaolo Bonzinisoftmmu="yes" 281b915a2f1SPaolo Bonzinilinux_user="" 282b915a2f1SPaolo Bonzinibsd_user="" 28340d6444eSAvi Kivitypie="" 284519175a2SAlex Barcelocoroutine="" 285ba4dd2aaSAlex Bennéeplugins="$default_feature" 286a5665051SPaolo Bonzinimeson="" 28748328880SPaolo Bonzinininja="" 288c09c1ce7SPaolo Bonzinibindir="bin" 289a5665051SPaolo Bonziniskip_meson=no 29055116968SJagannathan Ramanvfio_user_server="disabled" 291377529c0SPaolo Bonzini 2923b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 2933b4da132SPaolo Bonzini# are included in the automatically generated help message) 2943b4da132SPaolo Bonzini 2953b4da132SPaolo Bonzini# 1. Track which submodules are needed 2960577e84dSThomas Huthfdt="auto" 2973b4da132SPaolo Bonzini 298c54b59eeSPaolo Bonzini# 2. Automatically enable/disable other options 2997630156dSPhilippe Mathieu-Daudétcg="auto" 3003b4da132SPaolo Bonzinicfi="false" 3013b4da132SPaolo Bonzini 302c87ea116SAlex Bennée# parse CC options second 303ac0df51dSaliguorifor opt do 30489138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 305ac0df51dSaliguori case "$opt" in 306ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3073812c0c4SJoelle van Dyne cross_compile="yes" 308ac0df51dSaliguori ;; 3093d8df640SPaolo Bonzini --cc=*) CC="$optarg" 310ac0df51dSaliguori ;; 31183f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 31283f73fceSTomoki Sekiyama ;; 3132ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3142ff6b91eSJuan Quintela ;; 315a2866660SPaolo Bonzini --extra-cflags=*) 316a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 317a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 318e910c7d9SPhilippe Mathieu-Daudé EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 319e2a2ed06SJuan Quintela ;; 320a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 32111cde1c8SBruno Dominguez ;; 322e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 323e910c7d9SPhilippe Mathieu-Daudé ;; 324a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 325e2a2ed06SJuan Quintela ;; 326d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 327d75402b5SAlex Bennée ;; 328479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 329d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 330d422b2bcSAlex Bennée ;; 331d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 332d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 333d75402b5SAlex Bennée ;; 3345adb43beSPaolo Bonzini --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option" 3355adb43beSPaolo Bonzini ;; 3365adb43beSPaolo Bonzini --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*} 3375adb43beSPaolo Bonzini eval "cross_prefix_${cc_arch}=\$optarg" 3385adb43beSPaolo Bonzini ;; 339ac0df51dSaliguori esac 340ac0df51dSaliguoridone 341ac0df51dSaliguori 342e49d021eSPeter Maydell# Preferred compiler: 343e49d021eSPeter Maydell# ${CC} (if set) 344e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 345e49d021eSPeter Maydell# system compiler 346e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 347e49d021eSPeter Maydell cc="$host_cc" 348e49d021eSPeter Maydellelse 349b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 350e49d021eSPeter Maydellfi 351e49d021eSPeter Maydell 35283f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 35383f73fceSTomoki Sekiyama cxx="c++" 35483f73fceSTomoki Sekiyamaelse 35583f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 35683f73fceSTomoki Sekiyamafi 35783f73fceSTomoki Sekiyama 358b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 359cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 3605f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 361b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 362b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 3639f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 3644852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 36535acbb30SPaolo Bonzinismbd="$SMBD" 366b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 367158bb224SKonstantin Kostiukwidl="${WIDL-${cross_prefix}widl}" 368b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 369f9f0e617SAndrey Drobyshevwindmc="${WINDMC-${cross_prefix}windmc}" 37017884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 37117884d7bSSergei Trofimovichquery_pkg_config() { 37217884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 37317884d7bSSergei Trofimovich} 37417884d7bSSergei Trofimovichpkg_config=query_pkg_config 37547c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 376ac0df51dSaliguori 377be17dc90SMichael S. Tsirkin# default flags for all hosts 3782d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 3792d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 3802d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 3812d31515bSPeter Maydell# provides these semantics.) 382de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 383be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 3845770e8afSPaolo Bonzini 385de38c0ccSPaolo BonziniQEMU_LDFLAGS= 386de38c0ccSPaolo Bonzini 3875770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 3888a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 3895770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 390086d5f75SPaolo Bonzini 391be17dc90SMichael S. Tsirkin 392ac0df51dSaliguoricheck_define() { 393ac0df51dSaliguoricat > $TMPC <<EOF 394ac0df51dSaliguori#if !defined($1) 395fd786e1aSPeter Maydell#error $1 not defined 396ac0df51dSaliguori#endif 397ac0df51dSaliguoriint main(void) { return 0; } 398ac0df51dSaliguoriEOF 39952166aa0SJuan Quintela compile_object 400ac0df51dSaliguori} 401ac0df51dSaliguori 402307119e7SGerd Hoffmanncheck_include() { 403307119e7SGerd Hoffmanncat > $TMPC <<EOF 404307119e7SGerd Hoffmann#include <$1> 405307119e7SGerd Hoffmannint main(void) { return 0; } 406307119e7SGerd HoffmannEOF 407307119e7SGerd Hoffmann compile_object 408307119e7SGerd Hoffmann} 409307119e7SGerd Hoffmann 41093b25869SJohn Snowwrite_c_skeleton() { 41193b25869SJohn Snow cat > $TMPC <<EOF 41293b25869SJohn Snowint main(void) { return 0; } 41393b25869SJohn SnowEOF 41493b25869SJohn Snow} 41593b25869SJohn Snow 416bbea4050SPeter Maydellif check_define __linux__ ; then 417ba7c60c2SPaolo Bonzini targetos=linux 418bbea4050SPeter Maydellelif check_define _WIN32 ; then 419ba7c60c2SPaolo Bonzini targetos=windows 420bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 421ba7c60c2SPaolo Bonzini targetos=openbsd 422bbea4050SPeter Maydellelif check_define __sun__ ; then 423ba7c60c2SPaolo Bonzini targetos=sunos 424bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 425ba7c60c2SPaolo Bonzini targetos=haiku 426951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 427ba7c60c2SPaolo Bonzini targetos=freebsd 428951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 429ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 430951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 431ba7c60c2SPaolo Bonzini targetos=dragonfly 432951fedfcSPeter Maydellelif check_define __NetBSD__; then 433ba7c60c2SPaolo Bonzini targetos=netbsd 434951fedfcSPeter Maydellelif check_define __APPLE__; then 435ba7c60c2SPaolo Bonzini targetos=darwin 436bbea4050SPeter Maydellelse 437951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 438951fedfcSPeter Maydell # might be going to just print the --help text, or it might 439951fedfcSPeter Maydell # be the result of a missing compiler. 440ba7c60c2SPaolo Bonzini targetos=bogus 441bbea4050SPeter Maydellfi 442bbea4050SPeter Maydell 44365eff01bSPaolo Bonzini# OS specific 44465eff01bSPaolo Bonzini 4453b0d8643SPaolo Bonzinimingw32="no" 4463b0d8643SPaolo Bonzinibsd="no" 4473b0d8643SPaolo Bonzinilinux="no" 4483b0d8643SPaolo Bonzinisolaris="no" 44965eff01bSPaolo Bonzinicase $targetos in 45065eff01bSPaolo Bonziniwindows) 45165eff01bSPaolo Bonzini mingw32="yes" 45265eff01bSPaolo Bonzini plugins="no" 45365eff01bSPaolo Bonzini pie="no" 45465eff01bSPaolo Bonzini;; 45565eff01bSPaolo Bonzinignu/kfreebsd) 45665eff01bSPaolo Bonzini bsd="yes" 45765eff01bSPaolo Bonzini;; 45865eff01bSPaolo Bonzinifreebsd) 45965eff01bSPaolo Bonzini bsd="yes" 46065eff01bSPaolo Bonzini make="${MAKE-gmake}" 46165eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 46265eff01bSPaolo Bonzini;; 46365eff01bSPaolo Bonzinidragonfly) 46465eff01bSPaolo Bonzini bsd="yes" 46565eff01bSPaolo Bonzini make="${MAKE-gmake}" 46665eff01bSPaolo Bonzini;; 46765eff01bSPaolo Bonzininetbsd) 46865eff01bSPaolo Bonzini bsd="yes" 46965eff01bSPaolo Bonzini make="${MAKE-gmake}" 47065eff01bSPaolo Bonzini;; 47165eff01bSPaolo Bonziniopenbsd) 47265eff01bSPaolo Bonzini bsd="yes" 47365eff01bSPaolo Bonzini make="${MAKE-gmake}" 47465eff01bSPaolo Bonzini;; 47565eff01bSPaolo Bonzinidarwin) 47665eff01bSPaolo Bonzini bsd="yes" 47765eff01bSPaolo Bonzini darwin="yes" 47865eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 47965eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 48065eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 48165eff01bSPaolo Bonzini;; 48265eff01bSPaolo Bonzinisunos) 48365eff01bSPaolo Bonzini solaris="yes" 48465eff01bSPaolo Bonzini make="${MAKE-gmake}" 48565eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 48665eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 48765eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 48865eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 48965eff01bSPaolo Bonzini;; 49065eff01bSPaolo Bonzinihaiku) 49165eff01bSPaolo Bonzini pie="no" 49265eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 49365eff01bSPaolo Bonzini;; 49465eff01bSPaolo Bonzinilinux) 49565eff01bSPaolo Bonzini linux="yes" 49665eff01bSPaolo Bonzini;; 497bbea4050SPeter Maydellesac 498bbea4050SPeter Maydell 4992ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5002ff6b91eSJuan Quintela # command line argument 5012ff6b91eSJuan Quintela : 5022ff6b91eSJuan Quintelaelif check_define __i386__ ; then 503ac0df51dSaliguori cpu="i386" 504ac0df51dSaliguorielif check_define __x86_64__ ; then 505c72b26ecSRichard Henderson if check_define __ILP32__ ; then 506c72b26ecSRichard Henderson cpu="x32" 507c72b26ecSRichard Henderson else 508ac0df51dSaliguori cpu="x86_64" 509c72b26ecSRichard Henderson fi 5103aa9bd6cSblueswir1elif check_define __sparc__ ; then 5113aa9bd6cSblueswir1 if check_define __arch64__ ; then 5123aa9bd6cSblueswir1 cpu="sparc64" 5133aa9bd6cSblueswir1 else 5143aa9bd6cSblueswir1 cpu="sparc" 5153aa9bd6cSblueswir1 fi 516fdf7ed96Smalcelif check_define _ARCH_PPC ; then 517fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 518f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 519f8378accSRichard Henderson cpu="ppc64le" 520f8378accSRichard Henderson else 521fdf7ed96Smalc cpu="ppc64" 522f8378accSRichard Henderson fi 523ac0df51dSaliguori else 524fdf7ed96Smalc cpu="ppc" 525fdf7ed96Smalc fi 526afa05235SAurelien Jarnoelif check_define __mips__ ; then 527afa05235SAurelien Jarno cpu="mips" 528d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 529d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 530d66ed0eaSAurelien Jarno cpu="s390x" 531d66ed0eaSAurelien Jarno else 532d66ed0eaSAurelien Jarno cpu="s390" 533d66ed0eaSAurelien Jarno fi 534c4f80543SAlistair Franciselif check_define __riscv ; then 535ba0e7333SRichard Henderson cpu="riscv" 53621d89f84SPeter Maydellelif check_define __arm__ ; then 53721d89f84SPeter Maydell cpu="arm" 5381f080313SClaudio Fontanaelif check_define __aarch64__ ; then 5391f080313SClaudio Fontana cpu="aarch64" 540dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 541dfcf900bSWANG Xuerui cpu="loongarch64" 542fdf7ed96Smalcelse 543f9c77801SPaolo Bonzini # Using uname is really broken, but it is just a fallback for architectures 544f9c77801SPaolo Bonzini # that are going to use TCI anyway 54589138857SStefan Weil cpu=$(uname -m) 546f9c77801SPaolo Bonzini echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'" 547ac0df51dSaliguorifi 548ac0df51dSaliguori 549f9c77801SPaolo Bonzini# Normalise host CPU name and set multilib cflags. The canonicalization 550f9c77801SPaolo Bonzini# isn't really necessary, because the architectures that we check for 551f9c77801SPaolo Bonzini# should not hit the 'uname -m' case, but better safe than sorry. 552359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 5537d13299dSbellardcase "$cpu" in 554e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 555e4da0e39SPaolo Bonzini cpu="arm" ;; 556e4da0e39SPaolo Bonzini 557f9c77801SPaolo Bonzini i386|i486|i586|i686) 55897a847bcSbellard cpu="i386" 559e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 560e4da0e39SPaolo Bonzini x32) 5614da270beSPaolo Bonzini cpu="x86_64" 562e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 563aaa5fa14Saurel32 x86_64|amd64) 564aaa5fa14Saurel32 cpu="x86_64" 565e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 566e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 567e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 568e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 569e4da0e39SPaolo Bonzini 570afa05235SAurelien Jarno mips*) 571e4da0e39SPaolo Bonzini cpu="mips" ;; 572e4da0e39SPaolo Bonzini 573e4da0e39SPaolo Bonzini ppc) 574e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 575e4da0e39SPaolo Bonzini ppc64) 576ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mbig-endian" ;; 577e4da0e39SPaolo Bonzini ppc64le) 578d8ff892dSPaolo Bonzini cpu="ppc64" 579ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mlittle-endian" ;; 580e4da0e39SPaolo Bonzini 581e4da0e39SPaolo Bonzini s390) 582823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 583e4da0e39SPaolo Bonzini s390x) 584e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 585e4da0e39SPaolo Bonzini 5863142255cSblueswir1 sparc|sun4[cdmuv]) 587ae228531Sbellard cpu="sparc" 588e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 589e4da0e39SPaolo Bonzini sparc64) 590e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 5917d13299dSbellardesac 592e2d52ad3SJuan Quintela 5930db4a067SPaolo Bonzini: ${make=${MAKE-make}} 594b6daf4d3SPaolo Bonzini 595faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 596faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 597ddf90699SEduardo Habkost# we check that too 598faf44142SDaniel P. Berrangépython= 5990a01d76fSMarc-André Lureauexplicit_python=no 600ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 601faf44142SDaniel P. Berrangédo 602faf44142SDaniel P. Berrangé if has "$binary" 603faf44142SDaniel P. Berrangé then 60495c5f2deSPaolo Bonzini python=$(command -v "$binary") 605faf44142SDaniel P. Berrangé break 606faf44142SDaniel P. Berrangé fi 607faf44142SDaniel P. Berrangédone 608903458c8SMarkus Armbruster 609903458c8SMarkus Armbruster 61039d87c8cSAlex Bennée# Check for ancillary tools used in testing 61139d87c8cSAlex Bennéegenisoimage= 6123df437c7SAlex Bennéefor binary in genisoimage mkisofs 61339d87c8cSAlex Bennéedo 61439d87c8cSAlex Bennée if has $binary 61539d87c8cSAlex Bennée then 61639d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 61739d87c8cSAlex Bennée break 61839d87c8cSAlex Bennée fi 61939d87c8cSAlex Bennéedone 62039d87c8cSAlex Bennée 6213c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6223c4a4d0dSPeter Maydellif has clang; then 6233c4a4d0dSPeter Maydell objcc=clang 6243c4a4d0dSPeter Maydellelse 6253c4a4d0dSPeter Maydell objcc="$cc" 6263c4a4d0dSPeter Maydellfi 6273c4a4d0dSPeter Maydell 6283457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6293457a3f8SJuan Quintela EXESUF=".exe" 63078e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6315770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 632d17f305aSPaolo Bonzini prefix="/qemu" 633c09c1ce7SPaolo Bonzini bindir="" 63477433a5fSMarc-André Lureau qemu_suffix="" 6353457a3f8SJuan Quintelafi 6363457a3f8SJuan Quintela 637487fefdbSAnthony Liguoriwerror="" 63885aa5189Sbellard 6398154f5e6SAkihiko Odakimeson_option_build_array() { 6408154f5e6SAkihiko Odaki printf '[' 641c5cfdabaSPeter Maydell (if test "$targetos" = windows; then 6428154f5e6SAkihiko Odaki IFS=\; 6438154f5e6SAkihiko Odaki else 6448154f5e6SAkihiko Odaki IFS=: 6458154f5e6SAkihiko Odaki fi 6468154f5e6SAkihiko Odaki for e in $1; do 64765842b03SPeter Maydell printf '"""' 64865842b03SPeter Maydell # backslash escape any '\' and '"' characters 64965842b03SPeter Maydell printf "%s" "$e" | sed -e 's/\([\"]\)/\\\1/g' 65065842b03SPeter Maydell printf '""",' 6518154f5e6SAkihiko Odaki done) 6528154f5e6SAkihiko Odaki printf ']\n' 6538154f5e6SAkihiko Odaki} 6548154f5e6SAkihiko Odaki 65564708615SPeter Maydell. "$source_path/scripts/meson-buildoptions.sh" 65661d63097SPaolo Bonzini 65761d63097SPaolo Bonzinimeson_options= 658c54b59eeSPaolo Bonzinimeson_option_add() { 659c54b59eeSPaolo Bonzini meson_options="$meson_options $(quote_sh "$1")" 660c54b59eeSPaolo Bonzini} 66161d63097SPaolo Bonzinimeson_option_parse() { 66261d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 66361d63097SPaolo Bonzini if test $? -eq 1; then 66461d63097SPaolo Bonzini echo "ERROR: unknown option $1" 66561d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 66661d63097SPaolo Bonzini exit 1 66761d63097SPaolo Bonzini fi 66861d63097SPaolo Bonzini} 66961d63097SPaolo Bonzini 6707d13299dSbellardfor opt do 67189138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 6727d13299dSbellard case "$opt" in 6732efc3265Sbellard --help|-h) show_help=yes 6742efc3265Sbellard ;; 67564708615SPeter Maydell --version|-V) exec cat "$source_path/VERSION" 67699123e13SMike Frysinger ;; 677b1a550a0Spbrook --prefix=*) prefix="$optarg" 6787d13299dSbellard ;; 679ac0df51dSaliguori --cross-prefix=*) 6807d13299dSbellard ;; 681ac0df51dSaliguori --cc=*) 6827d13299dSbellard ;; 683b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 68483469015Sbellard ;; 68583f73fceSTomoki Sekiyama --cxx=*) 68683f73fceSTomoki Sekiyama ;; 6873c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 6883c4a4d0dSPeter Maydell ;; 689b1a550a0Spbrook --make=*) make="$optarg" 6907d13299dSbellard ;; 691b6daf4d3SPaolo Bonzini --install=*) 6926a882643Spbrook ;; 6930a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 694c886edfbSBlue Swirl ;; 695a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 696a5665051SPaolo Bonzini ;; 697a5665051SPaolo Bonzini --meson=*) meson="$optarg" 698a5665051SPaolo Bonzini ;; 69948328880SPaolo Bonzini --ninja=*) ninja="$optarg" 70048328880SPaolo Bonzini ;; 701e2d8830eSBrad --smbd=*) smbd="$optarg" 702e2d8830eSBrad ;; 703e2a2ed06SJuan Quintela --extra-cflags=*) 7047d13299dSbellard ;; 70511cde1c8SBruno Dominguez --extra-cxxflags=*) 70611cde1c8SBruno Dominguez ;; 707e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) 708e910c7d9SPhilippe Mathieu-Daudé ;; 709e2a2ed06SJuan Quintela --extra-ldflags=*) 7107d13299dSbellard ;; 711d75402b5SAlex Bennée --cross-cc-*) 712d75402b5SAlex Bennée ;; 7135adb43beSPaolo Bonzini --cross-prefix-*) 7145adb43beSPaolo Bonzini ;; 715c54b59eeSPaolo Bonzini --enable-debug-info) meson_option_add -Ddebug=true 71628609749SPaolo Bonzini ;; 717c54b59eeSPaolo Bonzini --disable-debug-info) meson_option_add -Ddebug=false 71828609749SPaolo Bonzini ;; 71917969268SFam Zheng --enable-modules) 72017969268SFam Zheng modules="yes" 72117969268SFam Zheng ;; 7223aa88b31SStefan Hajnoczi --disable-modules) 7233aa88b31SStefan Hajnoczi modules="no" 7243aa88b31SStefan Hajnoczi ;; 7252ff6b91eSJuan Quintela --cpu=*) 7267d13299dSbellard ;; 727b1a550a0Spbrook --target-list=*) target_list="$optarg" 728447e133fSAlex Bennée if test "$target_list_exclude"; then 729447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 730447e133fSAlex Bennée fi 731447e133fSAlex Bennée ;; 732447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 733447e133fSAlex Bennée if test "$target_list"; then 734447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 735447e133fSAlex Bennée fi 736de83cd02Sbellard ;; 737c54b59eeSPaolo Bonzini --with-default-devices) meson_option_add -Ddefault_devices=true 738f3494749SPaolo Bonzini ;; 739c54b59eeSPaolo Bonzini --without-default-devices) meson_option_add -Ddefault_devices=false 740f3494749SPaolo Bonzini ;; 741d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 742d1d5e9eeSAlex Bennée ;; 743d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 744d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 745d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 746d1d5e9eeSAlex Bennée if test -f "$cf"; then 747d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 748d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 749d1d5e9eeSAlex Bennée else 750d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 751d1d5e9eeSAlex Bennée fi 752d1d5e9eeSAlex Bennée ;; 753c87ea116SAlex Bennée --without-default-features) # processed above 754c87ea116SAlex Bennée ;; 75579427693SLoïc Minier --static) 75679427693SLoïc Minier static="yes" 75717884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 75843ce4dfeSbellard ;; 7590b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 7600b24e75fSPaolo Bonzini ;; 76177433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 762023d3d67SEduardo Habkost ;; 763181ce1d0SOlaf Hering --host=*|--build=*|\ 764181ce1d0SOlaf Hering --disable-dependency-tracking|\ 765785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 766fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 767023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 768023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 769023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 770023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 771023ddd74SMax Filippov # lots of directory switches by default. 772023ddd74SMax Filippov ;; 773f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 774f8393946Saurel32 ;; 775f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 776f8393946Saurel32 ;; 777f3d08ee6SPaul Brook --enable-debug) 778f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 779f3d08ee6SPaul Brook debug_tcg="yes" 780c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 781c54b59eeSPaolo Bonzini meson_option_add -Doptimization=0 782b553a042SJohn Snow fortify_source="no" 783f3d08ee6SPaul Brook ;; 784247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 785247724cbSMarc-André Lureau ;; 786247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 787247724cbSMarc-André Lureau ;; 7880aebab04SLingfeng Yang --enable-tsan) tsan="yes" 7890aebab04SLingfeng Yang ;; 7900aebab04SLingfeng Yang --disable-tsan) tsan="no" 7910aebab04SLingfeng Yang ;; 7921badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 793d1a14257SAlex Bennée plugins="no" 794b3f6ea7eSPaolo Bonzini ;; 7951badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 796b3f6ea7eSPaolo Bonzini ;; 797cad25d69Spbrook --disable-system) softmmu="no" 7980a8e90f4Spbrook ;; 799cad25d69Spbrook --enable-system) softmmu="yes" 8000a8e90f4Spbrook ;; 8010953a80fSZachary Amsden --disable-user) 8020953a80fSZachary Amsden linux_user="no" ; 8030953a80fSZachary Amsden bsd_user="no" ; 8040953a80fSZachary Amsden ;; 8050953a80fSZachary Amsden --enable-user) ;; 806831b7825Sths --disable-linux-user) linux_user="no" 8070a8e90f4Spbrook ;; 808831b7825Sths --enable-linux-user) linux_user="yes" 809831b7825Sths ;; 81084778508Sblueswir1 --disable-bsd-user) bsd_user="no" 81184778508Sblueswir1 ;; 81284778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 81384778508Sblueswir1 ;; 81440d6444eSAvi Kivity --enable-pie) pie="yes" 81534005a00SKirill A. Shutemov ;; 81640d6444eSAvi Kivity --disable-pie) pie="no" 81734005a00SKirill A. Shutemov ;; 81885aa5189Sbellard --enable-werror) werror="yes" 81985aa5189Sbellard ;; 82085aa5189Sbellard --disable-werror) werror="no" 82185aa5189Sbellard ;; 82263678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 82363678e17SSteven Noonan ;; 82463678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 82563678e17SSteven Noonan ;; 8261e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 8271e4f6065SDaniele Buono ;; 8281e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 8291e4f6065SDaniele Buono ;; 8309e62ba48SDaniele Buono --enable-cfi) 8319e62ba48SDaniele Buono cfi="true"; 832c54b59eeSPaolo Bonzini meson_option_add -Db_lto=true 8339e62ba48SDaniele Buono ;; 8349e62ba48SDaniele Buono --disable-cfi) cfi="false" 8359e62ba48SDaniele Buono ;; 836fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 8372df87df7SJuan Quintela ;; 838fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 839fbb4121dSPaolo Bonzini ;; 840fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 841fbb4121dSPaolo Bonzini ;; 84203a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 8432df87df7SJuan Quintela ;; 844519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 845519175a2SAlex Barcelo ;; 846cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 847cc84d63aSDaniel P. Berrange ;; 8487d7dbf9dSDan Streetman --with-git-submodules=*) 8497d7dbf9dSDan Streetman git_submodules_action="$optarg" 850f62bbee5SDaniel P. Berrange ;; 8519b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 8529b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 8539b8e4298SAlex Bennée else 8549b8e4298SAlex Bennée plugins="yes" 8559b8e4298SAlex Bennée fi 85640e8c6f4SAlex Bennée ;; 85740e8c6f4SAlex Bennée --disable-plugins) plugins="no" 85840e8c6f4SAlex Bennée ;; 859afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 860afc3a8f9SAlex Bennée ;; 861afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 862afc3a8f9SAlex Bennée ;; 863f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 864f48e590aSAlex Bennée ;; 86555116968SJagannathan Raman --enable-vfio-user-server) vfio_user_server="enabled" 86655116968SJagannathan Raman ;; 86755116968SJagannathan Raman --disable-vfio-user-server) vfio_user_server="disabled" 86855116968SJagannathan Raman ;; 8693b4da132SPaolo Bonzini # everything else has the same name in configure and meson 8704fda6011SPaolo Bonzini --*) meson_option_parse "$opt" "$optarg" 8717f1559c6Sbalrog ;; 8727d13299dSbellard esac 8737d13299dSbellarddone 8747d13299dSbellard 875d1a14257SAlex Bennée# test for any invalid configuration combinations 876d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 877d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 878d1a14257SAlex Bennéefi 879d1a14257SAlex Bennée 8807d7dbf9dSDan Streetmancase $git_submodules_action in 8817d7dbf9dSDan Streetman update|validate) 8827d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 8837d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 8847d7dbf9dSDan Streetman exit 1 8857d7dbf9dSDan Streetman fi 8867d7dbf9dSDan Streetman ;; 8877d7dbf9dSDan Streetman ignore) 888b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 889b80fd281SPaolo Bonzini then 890b80fd281SPaolo Bonzini echo 891b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 892b80fd281SPaolo Bonzini echo 893b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 894b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 895b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 896b80fd281SPaolo Bonzini else 897b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 898b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 899b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 900b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 901b80fd281SPaolo Bonzini echo 902b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 903b80fd281SPaolo Bonzini echo 904b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 905b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 906b80fd281SPaolo Bonzini fi 907b80fd281SPaolo Bonzini echo 908b80fd281SPaolo Bonzini exit 1 909b80fd281SPaolo Bonzini fi 9107d7dbf9dSDan Streetman ;; 9117d7dbf9dSDan Streetman *) 9127d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 9137d7dbf9dSDan Streetman exit 1 9147d7dbf9dSDan Streetman ;; 9157d7dbf9dSDan Streetmanesac 9167d7dbf9dSDan Streetman 91760e0df25SPeter Maydelldefault_target_list="" 9186e92f823SPeter Maydellmak_wilds="" 9196e92f823SPeter Maydell 920b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 92164708615SPeter Maydell if [ "$targetos" = linux ] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then 922b915a2f1SPaolo Bonzini linux_user=yes 923b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 924b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 925b915a2f1SPaolo Bonzini fi 926b915a2f1SPaolo Bonzinifi 927b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 928b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 929b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 930b915a2f1SPaolo Bonzini fi 93164708615SPeter Maydell if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then 932b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 933b915a2f1SPaolo Bonzini fi 934b915a2f1SPaolo Bonzinifi 93560e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 936812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 93760e0df25SPeter Maydellfi 93860e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 939812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 94060e0df25SPeter Maydellfi 94160e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 942812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 94360e0df25SPeter Maydellfi 94460e0df25SPeter Maydell 945447e133fSAlex Bennéefor config in $mak_wilds; do 946447e133fSAlex Bennée target="$(basename "$config" .mak)" 94798db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 948447e133fSAlex Bennée default_target_list="${default_target_list} $target" 949447e133fSAlex Bennée fi 950447e133fSAlex Bennéedone 9516e92f823SPeter Maydell 952af5db58eSpbrookif test x"$show_help" = x"yes" ; then 953af5db58eSpbrookcat << EOF 954af5db58eSpbrook 955af5db58eSpbrookUsage: configure [options] 956af5db58eSpbrookOptions: [defaults in brackets after descriptions] 957af5db58eSpbrook 95808fb77edSStefan WeilStandard options: 95908fb77edSStefan Weil --help print this message 96008fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 96174154d7eSThomas Huth --target-list=LIST set target list (default: build all) 96208fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 96308fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 964447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 96508fb77edSStefan Weil 96608fb77edSStefan WeilAdvanced options (experts only): 9673812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 96808fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 96908fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 97008fb77edSStefan Weil build time 97108fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 97208fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 973a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 974a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 975e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS 97608fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 977d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 978479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 9795adb43beSPaolo Bonzini --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases 98008fb77edSStefan Weil --make=MAKE use specified make [$make] 98108fb77edSStefan Weil --python=PYTHON use specified python [$python] 982a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 98348328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 98408fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 985db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 9867d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 9877d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 9887d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 98908fb77edSStefan Weil --static enable static build [$static] 99008fb77edSStefan Weil --bindir=PATH install binaries in PATH 991ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 992c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 993c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 994c035c8d6SPaolo Bonzini start the emulator (only use if you are including 995d1d5e9eeSAlex Bennée desired devices in configs/devices/) 996d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 99708fb77edSStefan Weil --enable-debug enable common debug build options 998247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 9990aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 100008fb77edSStefan Weil --disable-werror disable compilation abort on warning 100163678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 1002c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 100308fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 100433c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 100540e8c6f4SAlex Bennée --enable-plugins 100640e8c6f4SAlex Bennée enable plugins via shared library loading 1007afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1008f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 100961d63097SPaolo BonziniEOF 101061d63097SPaolo Bonzini meson_options_help 101161d63097SPaolo Bonzinicat << EOF 1012c23f23b9SMichael Tokarev system all system emulation targets 1013c23f23b9SMichael Tokarev user supported user emulation targets 1014c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1015c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1016c23f23b9SMichael Tokarev pie Position Independent Executables 101721e709aaSMarc-André Lureau modules modules support (non-Windows) 1018c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1019c23f23b9SMichael Tokarev debug-info debugging information 10201e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 102174a1b256SThomas Huth clang/llvm and requires coroutine backend ucontext. 102208fb77edSStefan Weil 102308fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1024af5db58eSpbrookEOF 10252d2ad6d0SFam Zhengexit 0 1026af5db58eSpbrookfi 1027af5db58eSpbrook 10289c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1029002d8c13SPeter Maydellrm -f ./*/config-devices.mak.d 10309c790242SThomas Huth 1031faf44142SDaniel P. Berrangéif test -z "$python" 1032faf44142SDaniel P. Berrangéthen 1033c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1034c53eeaf7SStefan Hajnoczifi 10358e2c76bdSRoman Bolshakovif ! has "$make" 10368e2c76bdSRoman Bolshakovthen 10378e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 10388e2c76bdSRoman Bolshakovfi 1039c53eeaf7SStefan Hajnoczi 1040c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1041c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 10421b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 10431b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1044c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1045c53eeaf7SStefan Hajnoczifi 1046c53eeaf7SStefan Hajnoczi 1047*462a6567SPaolo Bonzini# Resolve PATH + suppress writing compiled files 1048*462a6567SPaolo Bonzinipython="$(command -v "$python") -B" 1049*462a6567SPaolo Bonzini 1050*462a6567SPaolo Bonzinihas_meson() { 1051*462a6567SPaolo Bonzini local python_dir=$(dirname "$python") 1052*462a6567SPaolo Bonzini # PEP405: pyvenv.cfg is either adjacent to the Python executable 1053*462a6567SPaolo Bonzini # or one directory above 1054*462a6567SPaolo Bonzini if test -f $python_dir/pyvenv.cfg || test -f $python_dir/../pyvenv.cfg; then 1055*462a6567SPaolo Bonzini # Ensure that Meson and Python come from the same virtual environment 1056*462a6567SPaolo Bonzini test -x "$python_dir/meson" && 1057*462a6567SPaolo Bonzini test "$(command -v meson)" -ef "$python_dir/meson" 1058*462a6567SPaolo Bonzini else 1059*462a6567SPaolo Bonzini has meson 1060*462a6567SPaolo Bonzini fi 1061*462a6567SPaolo Bonzini} 1062c53eeaf7SStefan Hajnoczi 10630a01d76fSMarc-André Lureauif test -z "$meson"; then 1064*462a6567SPaolo Bonzini if test "$explicit_python" = no && has_meson && version_ge "$(meson --version)" 0.61.5; then 10650a01d76fSMarc-André Lureau meson=meson 106664708615SPeter Maydell elif test "$git_submodules_action" != 'ignore' ; then 10670a01d76fSMarc-André Lureau meson=git 10680a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 10690a01d76fSMarc-André Lureau meson=internal 10700a01d76fSMarc-André Lureau else 10710a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 10720a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 10730a01d76fSMarc-André Lureau else 1074a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1075a5665051SPaolo Bonzini fi 10760a01d76fSMarc-André Lureau fi 10770a01d76fSMarc-André Lureauelse 10780a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 10790a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 10800a01d76fSMarc-André Lureau # 10810a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 10820a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 10830a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 10840a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 10850a01d76fSMarc-André Lureau case "$meson" in 10860a01d76fSMarc-André Lureau git | internal) ;; 10870a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 10880a01d76fSMarc-André Lureau esac 10890a01d76fSMarc-André Lureau fi 10900a01d76fSMarc-André Lureaufi 1091a5665051SPaolo Bonzini 10920a01d76fSMarc-André Lureauif test "$meson" = git; then 10930a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 10940a01d76fSMarc-André Lureaufi 10950a01d76fSMarc-André Lureau 10960a01d76fSMarc-André Lureaucase "$meson" in 10970a01d76fSMarc-André Lureau git | internal) 10980a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 10990a01d76fSMarc-André Lureau ;; 110084ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 11010a01d76fSMarc-André Lureauesac 11020a01d76fSMarc-André Lureau 110309e93326SPaolo Bonzini# Probe for ninja 110448328880SPaolo Bonzini 110548328880SPaolo Bonziniif test -z "$ninja"; then 110648328880SPaolo Bonzini for c in ninja ninja-build samu; do 110748328880SPaolo Bonzini if has $c; then 110848328880SPaolo Bonzini ninja=$(command -v "$c") 110948328880SPaolo Bonzini break 111048328880SPaolo Bonzini fi 111148328880SPaolo Bonzini done 111209e93326SPaolo Bonzini if test -z "$ninja"; then 111309e93326SPaolo Bonzini error_exit "Cannot find Ninja" 111409e93326SPaolo Bonzini fi 111548328880SPaolo Bonzinifi 1116a5665051SPaolo Bonzini 11179aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 11189aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 11199aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 11209aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 11219aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 11229aae6e54SDaniel Henrique Barbozaif compile_object ; then 11239aae6e54SDaniel Henrique Barboza : C compiler works ok 11249aae6e54SDaniel Henrique Barbozaelse 11259aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 11269aae6e54SDaniel Henrique Barbozafi 11279aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 11289aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 11299aae6e54SDaniel Henrique Barbozafi 11309aae6e54SDaniel Henrique Barboza 11319c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 11329c83ffd8SPeter Maydell# by default. Only enable by default for git builds 11339c83ffd8SPeter Maydellif test -z "$werror" ; then 11347d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1135e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 11369c83ffd8SPeter Maydell werror="yes" 11379c83ffd8SPeter Maydell else 11389c83ffd8SPeter Maydell werror="no" 11399c83ffd8SPeter Maydell fi 11409c83ffd8SPeter Maydellfi 11419c83ffd8SPeter Maydell 1142975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1143fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1144fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1145fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1146fb59dabdSPeter Maydell # host OS we should stop now. 1147951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1148fb59dabdSPeter Maydellfi 1149fb59dabdSPeter Maydell 1150efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1151efc6c070SThomas Huthcat > $TMPC << EOF 1152efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1153efc6c070SThomas Huth# ifdef __apple_build_version__ 115474a1b256SThomas Huth# if __clang_major__ < 12 || (__clang_major__ == 12 && __clang_minor__ < 0) 115574a1b256SThomas Huth# error You need at least XCode Clang v12.0 to compile QEMU 1156efc6c070SThomas Huth# endif 1157efc6c070SThomas Huth# else 115874a1b256SThomas Huth# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 115974a1b256SThomas Huth# error You need at least Clang v10.0 to compile QEMU 1160efc6c070SThomas Huth# endif 1161efc6c070SThomas Huth# endif 1162efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 11633830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 11643830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1165efc6c070SThomas Huth# endif 1166efc6c070SThomas Huth#else 1167efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1168efc6c070SThomas Huth#endif 1169efc6c070SThomas Huthint main (void) { return 0; } 1170efc6c070SThomas HuthEOF 1171efc6c070SThomas Huthif ! compile_prog "" "" ; then 117274a1b256SThomas Huth error_exit "You need at least GCC v7.4 or Clang v10.0 (or XCode Clang v12.0)" 1173efc6c070SThomas Huthfi 1174efc6c070SThomas Huth 117500849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 117600849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 117700849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 117800849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 117900849b92SRichard Henderson# just silently disable some features, so it's too error prone. 118000849b92SRichard Henderson 118100849b92SRichard Hendersonwarn_flags= 1182ca9b5c2eSPaolo Bonziniadd_to warn_flags -Wundef 1183ca9b5c2eSPaolo Bonziniadd_to warn_flags -Wwrite-strings 1184ca9b5c2eSPaolo Bonziniadd_to warn_flags -Wmissing-prototypes 1185ca9b5c2eSPaolo Bonziniadd_to warn_flags -Wstrict-prototypes 1186ca9b5c2eSPaolo Bonziniadd_to warn_flags -Wredundant-decls 118700849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 118800849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 118900849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 119000849b92SRichard Hendersonadd_to warn_flags -Wformat-security 119100849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 119200849b92SRichard Hendersonadd_to warn_flags -Winit-self 119300849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 119400849b92SRichard Hendersonadd_to warn_flags -Wempty-body 119500849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 119600849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 119700849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 11980a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 119988a0ef00SDaniel P. Berrangéadd_to warn_flags -Wmissing-format-attribute 12003d2d4cc5SKevin Wolfadd_to warn_flags -Wthread-safety 120100849b92SRichard Henderson 120200849b92SRichard Hendersonnowarn_flags= 120300849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 120400849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 120500849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 120600849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 120700849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1208aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1209bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 121028d01b1dSChenyi Qiangadd_to nowarn_flags -Wno-gnu-variable-sized-type-not-at-end 121100849b92SRichard Henderson 121200849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 121393b25869SJohn Snow 121493b25869SJohn Snowcc_has_warning_flag() { 121593b25869SJohn Snow write_c_skeleton; 121693b25869SJohn Snow 1217a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1218a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1219a1d29d6cSPeter Maydell # warning options). 122093b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 122193b25869SJohn Snow compile_prog "-Werror $optflag" "" 122293b25869SJohn Snow} 122393b25869SJohn Snow 12244cb37d11SPhilippe Mathieu-Daudéobjcc_has_warning_flag() { 12254cb37d11SPhilippe Mathieu-Daudé cat > $TMPM <<EOF 12264cb37d11SPhilippe Mathieu-Daudéint main(void) { return 0; } 12274cb37d11SPhilippe Mathieu-DaudéEOF 12284cb37d11SPhilippe Mathieu-Daudé 12294cb37d11SPhilippe Mathieu-Daudé # Use the positive sense of the flag when testing for -Wno-wombat 12304cb37d11SPhilippe Mathieu-Daudé # support (gcc will happily accept the -Wno- form of unknown 12314cb37d11SPhilippe Mathieu-Daudé # warning options). 12324cb37d11SPhilippe Mathieu-Daudé optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 12334cb37d11SPhilippe Mathieu-Daudé do_objc -Werror $optflag \ 12344cb37d11SPhilippe Mathieu-Daudé $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ 12354cb37d11SPhilippe Mathieu-Daudé -o $TMPE $TMPM $QEMU_LDFLAGS 12364cb37d11SPhilippe Mathieu-Daudé} 12374cb37d11SPhilippe Mathieu-Daudé 123893b25869SJohn Snowfor flag in $gcc_flags; do 123993b25869SJohn Snow if cc_has_warning_flag $flag ; then 12408d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 12418d05095cSPaolo Bonzini fi 12424cb37d11SPhilippe Mathieu-Daudé if objcc_has_warning_flag $flag ; then 12434cb37d11SPhilippe Mathieu-Daudé QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" 12444cb37d11SPhilippe Mathieu-Daudé fi 12458d05095cSPaolo Bonzinidone 12468d05095cSPaolo Bonzini 124763678e17SSteven Noonanif test "$stack_protector" != "no"; then 1248fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1249fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1250fccd35a0SRodrigo Rebello{ 12518a0afbb2SStefan Weil char arr[64], *p = arr, *c = argv[argc - 1]; 1252fccd35a0SRodrigo Rebello while (*c) { 1253fccd35a0SRodrigo Rebello *p++ = *c++; 1254fccd35a0SRodrigo Rebello } 1255fccd35a0SRodrigo Rebello return 0; 1256fccd35a0SRodrigo Rebello} 1257fccd35a0SRodrigo RebelloEOF 125863678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 12593b463a3fSMiroslav Rezanina sp_on=0 126063678e17SSteven Noonan for flag in $gcc_flags; do 1261590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1262590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1263086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1264590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 126563678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1266db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 12673b463a3fSMiroslav Rezanina sp_on=1 126863678e17SSteven Noonan break 126963678e17SSteven Noonan fi 127063678e17SSteven Noonan done 12713b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 12723b463a3fSMiroslav Rezanina if test $sp_on = 0; then 12733b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 12743b463a3fSMiroslav Rezanina fi 12753b463a3fSMiroslav Rezanina fi 127637746c5eSMarc-André Lureaufi 127737746c5eSMarc-André Lureau 127821e709aaSMarc-André Lureau# Our module code doesn't support Windows 127921e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 128021e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 128121e709aaSMarc-André Lureaufi 128221e709aaSMarc-André Lureau 12835f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 128440d6444eSAvi Kivityif test "$static" = "yes" ; then 1285aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1286aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1287aa0d1f44SPaolo Bonzini fi 12885f2453acSAlex Bennée if test "$plugins" = "yes"; then 12895f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1290ba4dd2aaSAlex Bennée else 1291ba4dd2aaSAlex Bennée plugins="no" 12925f2453acSAlex Bennée fi 129340d6444eSAvi Kivityfi 129437650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 129540d6444eSAvi Kivity 129640d6444eSAvi Kivitycat > $TMPC << EOF 129721d4a791SAvi Kivity 129821d4a791SAvi Kivity#ifdef __linux__ 129921d4a791SAvi Kivity# define THREAD __thread 130021d4a791SAvi Kivity#else 130121d4a791SAvi Kivity# define THREAD 130221d4a791SAvi Kivity#endif 130321d4a791SAvi Kivitystatic THREAD int tls_var; 130421d4a791SAvi Kivityint main(void) { return tls_var; } 130540d6444eSAvi KivityEOF 1306b2634124SRichard Henderson 1307977cccb8SAlex Bennée# Meson currently only handles pie as a boolean for now so if we have 1308977cccb8SAlex Bennée# explicitly disabled PIE we need to extend our cflags because it wont. 130912781462SRichard Hendersonif test "$static" = "yes"; then 1310eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 13115770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 131212781462SRichard Henderson pie="yes" 131312781462SRichard Henderson elif test "$pie" = "yes"; then 131412781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 131512781462SRichard Henderson else 131612781462SRichard Henderson pie="no" 1317977cccb8SAlex Bennée QEMU_CFLAGS="-fno-pie -no-pie $QEMU_CFLAGS" 131812781462SRichard Henderson fi 131912781462SRichard Hendersonelif test "$pie" = "no"; then 1320b9eae9efSPaolo Bonzini if compile_prog "-Werror -fno-pie" "-no-pie"; then 1321b9eae9efSPaolo Bonzini CONFIGURE_CFLAGS="-fno-pie $CONFIGURE_CFLAGS" 1322b9eae9efSPaolo Bonzini CONFIGURE_LDFLAGS="-no-pie $CONFIGURE_LDFLAGS" 1323abafb64bSAlex Bennée QEMU_CFLAGS="-fno-pie -no-pie $QEMU_CFLAGS" 1324b9eae9efSPaolo Bonzini fi 1325eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 13265770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 13275770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 132840d6444eSAvi Kivity pie="yes" 13292c674109SRichard Hendersonelif test "$pie" = "yes"; then 133076ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 133140d6444eSAvi Kivityelse 133240d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 133340d6444eSAvi Kivity pie="no" 133440d6444eSAvi Kivityfi 133540d6444eSAvi Kivity 133609dada40SPaolo Bonzini########################################## 133709dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 133809dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 133909dada40SPaolo Bonzini# specification is necessary 134009dada40SPaolo Bonzini 134109dada40SPaolo Bonziniif test "$cpu" = "i386"; then 134209dada40SPaolo Bonzini cat > $TMPC << EOF 134309dada40SPaolo Bonzinistatic int sfaa(int *ptr) 134409dada40SPaolo Bonzini{ 134509dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 134609dada40SPaolo Bonzini} 134709dada40SPaolo Bonzini 134809dada40SPaolo Bonziniint main(void) 134909dada40SPaolo Bonzini{ 135009dada40SPaolo Bonzini int val = 42; 13511405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 135209dada40SPaolo Bonzini sfaa(&val); 135309dada40SPaolo Bonzini return val; 135409dada40SPaolo Bonzini} 135509dada40SPaolo BonziniEOF 135609dada40SPaolo Bonzini if ! compile_prog "" "" ; then 135709dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 135809dada40SPaolo Bonzini fi 135909dada40SPaolo Bonzinifi 136009dada40SPaolo Bonzini 1361afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1362fdb75aefSPaolo Bonzini default_targets=yes 1363d880a3baSPaolo Bonzini for target in $default_target_list; do 1364d880a3baSPaolo Bonzini target_list="$target_list $target" 1365d880a3baSPaolo Bonzini done 1366d880a3baSPaolo Bonzini target_list="${target_list# }" 1367121afa9eSAnthony Liguorielse 1368fdb75aefSPaolo Bonzini default_targets=no 136989138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1370d880a3baSPaolo Bonzini for target in $target_list; do 137125b48338SPeter Maydell # Check that we recognised the target name; this allows a more 137225b48338SPeter Maydell # friendly error message than if we let it fall through. 137325b48338SPeter Maydell case " $default_target_list " in 137425b48338SPeter Maydell *" $target "*) 137525b48338SPeter Maydell ;; 137625b48338SPeter Maydell *) 137725b48338SPeter Maydell error_exit "Unknown target name '$target'" 137825b48338SPeter Maydell ;; 137925b48338SPeter Maydell esac 138025b48338SPeter Maydell done 1381d880a3baSPaolo Bonzinifi 138225b48338SPeter Maydell 1383f55fe278SPaolo Bonzini# see if system emulation was really requested 1384f55fe278SPaolo Bonzinicase " $target_list " in 1385f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1386f55fe278SPaolo Bonzini ;; 1387f55fe278SPaolo Bonzini *) softmmu=no 1388f55fe278SPaolo Bonzini ;; 1389f55fe278SPaolo Bonziniesac 13905327cf48Sbellard 13917630156dSPhilippe Mathieu-Daudéif test "$tcg" = "auto"; then 13927630156dSPhilippe Mathieu-Daudé if test -z "$target_list"; then 13937630156dSPhilippe Mathieu-Daudé tcg="disabled" 13947630156dSPhilippe Mathieu-Daudé else 13957630156dSPhilippe Mathieu-Daudé tcg="enabled" 13967630156dSPhilippe Mathieu-Daudé fi 13977630156dSPhilippe Mathieu-Daudéfi 13987630156dSPhilippe Mathieu-Daudé 13997630156dSPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 14007630156dSPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 14017630156dSPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 14027630156dSPhilippe Mathieu-Daudéfi 14037630156dSPhilippe Mathieu-Daudé 140433ab5f24SMichal Privoznik########################################## 14057d13299dSbellard# big/little endian test 14067d13299dSbellardcat > $TMPC << EOF 140733ab5f24SMichal Privoznik#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 140833ab5f24SMichal Privoznik# error LITTLE 140933ab5f24SMichal Privoznik#endif 141033ab5f24SMichal Privoznikint main(void) { return 0; } 14117d13299dSbellardEOF 14127d13299dSbellard 141333ab5f24SMichal Privoznikif ! compile_prog ; then 141461cc919fSMike Frysinger bigendian="no" 14157d13299dSbellardelse 141633ab5f24SMichal Privoznik cat > $TMPC << EOF 141733ab5f24SMichal Privoznik#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 141833ab5f24SMichal Privoznik# error BIG 141933ab5f24SMichal Privoznik#endif 142033ab5f24SMichal Privoznikint main(void) { return 0; } 142133ab5f24SMichal PrivoznikEOF 142233ab5f24SMichal Privoznik 142333ab5f24SMichal Privoznik if ! compile_prog ; then 142433ab5f24SMichal Privoznik bigendian="yes" 142533ab5f24SMichal Privoznik else 14267d13299dSbellard echo big/little test failed 1427659eb157SThomas Huth exit 1 14287d13299dSbellard fi 14297d13299dSbellardfi 14307d13299dSbellard 1431015a33bdSGonglei########################################## 1432779ab5e3SStefan Weil# pkg-config probe 1433779ab5e3SStefan Weil 1434779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 143576ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1436779ab5e3SStefan Weilfi 1437779ab5e3SStefan Weil 1438779ab5e3SStefan Weil########################################## 1439e18df141SAnthony Liguori# glib support probe 1440a52d28afSPaolo Bonzini 14410ce9b08cSThomas Huth# When bumping glib_req_ver, please check also whether we should increase 14420ce9b08cSThomas Huth# the _WIN32_WINNT setting in osdep.h according to the value from glib 1443b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 1444aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 1445aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 1446a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 1447b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 1448b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 144954cb65d8SEmilio G. Cotafi 1450e26110cfSFam Zheng 1451aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 1452e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 145389138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 145489138857SStefan Weil glib_libs=$($pkg_config --libs $i) 1455e18df141SAnthony Liguori else 1456e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 1457e26110cfSFam Zheng fi 1458e26110cfSFam Zhengdone 1459e26110cfSFam Zheng 14605b9e7d05SMarc-André Lureauglib_bindir="$($pkg_config --variable=bindir glib-2.0)" 14615b9e7d05SMarc-André Lureauif test -z "$glib_bindir" ; then 14625b9e7d05SMarc-André Lureau glib_bindir="$($pkg_config --variable=prefix glib-2.0)"/bin 14635b9e7d05SMarc-André Lureaufi 14645b9e7d05SMarc-André Lureau 1465215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 1466215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 1467215b0c2fSPaolo Bonzini 1468215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 1469215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 1470215b0c2fSPaolo Bonzinifi 1471215b0c2fSPaolo Bonzini 1472977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 1473977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 1474977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 1475977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 1476977a82abSDaniel P. Berrangecat > $TMPC <<EOF 1477977a82abSDaniel P. Berrange#include <glib.h> 1478977a82abSDaniel P. Berrange#include <unistd.h> 1479977a82abSDaniel P. Berrange 1480977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 1481977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 1482977a82abSDaniel P. Berrange 1483977a82abSDaniel P. Berrangeint main(void) { 1484977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 1485977a82abSDaniel P. Berrange return 0; 1486977a82abSDaniel P. Berrange} 1487977a82abSDaniel P. BerrangeEOF 1488977a82abSDaniel P. Berrange 1489215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 1490977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 1491977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 1492977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 1493977a82abSDaniel P. Berrange "build target" 1494977a82abSDaniel P. Berrangefi 1495977a82abSDaniel P. Berrange 14969bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 14979bda600bSEric Blakecat > $TMPC << EOF 14989bda600bSEric Blake#include <glib.h> 14999bda600bSEric Blaketypedef struct Foo { 15009bda600bSEric Blake int i; 15019bda600bSEric Blake} Foo; 15029bda600bSEric Blakestatic void foo_free(Foo *f) 15039bda600bSEric Blake{ 15049bda600bSEric Blake g_free(f); 15059bda600bSEric Blake} 1506e0e7fe07SMarc-André LureauG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free) 15079bda600bSEric Blakeint main(void) { return 0; } 15089bda600bSEric BlakeEOF 15099bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 15109bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 15119bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 15125770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 15139bda600bSEric Blake fi 15149bda600bSEric Blakefi 15159bda600bSEric Blake 1516e26110cfSFam Zheng########################################## 1517f652e6afSaurel32# fdt probe 1518e169e1e1SPeter Maydell 1519fbb4121dSPaolo Bonzinicase "$fdt" in 1520fbb4121dSPaolo Bonzini auto | enabled | internal) 1521fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 1522aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 1523fbb4121dSPaolo Bonzini ;; 1524fbb4121dSPaolo Bonziniesac 1525f652e6afSaurel32 152620ff075bSMichael Walle########################################## 1527519175a2SAlex Barcelo# check and set a backend for coroutine 1528d0e2fce5SAneesh Kumar K.V 15297c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 153033c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 153133c53c54SDaniel P. Berrange# specific one. 15327c2acc70SPeter Maydell 15337c2acc70SPeter Maydellucontext_works=no 1534d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 1535d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 1536d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 1537cdf84806SPeter Maydell#ifdef __stub_makecontext 1538cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 1539cdf84806SPeter Maydell#endif 154075cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 1541d0e2fce5SAneesh Kumar K.VEOF 1542d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 15437c2acc70SPeter Maydell ucontext_works=yes 1544d0e2fce5SAneesh Kumar K.V fi 1545519175a2SAlex Barcelofi 15467c2acc70SPeter Maydell 15477c2acc70SPeter Maydellif test "$coroutine" = ""; then 15487c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 15497c2acc70SPeter Maydell coroutine=win32 15507c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 15517c2acc70SPeter Maydell coroutine=ucontext 1552519175a2SAlex Barcelo else 15537c2acc70SPeter Maydell coroutine=sigaltstack 15547c2acc70SPeter Maydell fi 15557c2acc70SPeter Maydellelse 15567c2acc70SPeter Maydell case $coroutine in 15577c2acc70SPeter Maydell windows) 15587c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 15597c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 15607c2acc70SPeter Maydell fi 15617c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 15627c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 15637c2acc70SPeter Maydell coroutine=win32 15647c2acc70SPeter Maydell ;; 15657c2acc70SPeter Maydell ucontext) 15667c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 15677cb58448SPaolo Bonzini error_exit "'ucontext' backend requested but makecontext not available" 15687c2acc70SPeter Maydell fi 15697c2acc70SPeter Maydell ;; 157033c53c54SDaniel P. Berrange sigaltstack) 15717c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 15727c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 15737c2acc70SPeter Maydell fi 15747c2acc70SPeter Maydell ;; 15757c2acc70SPeter Maydell *) 157676ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 15777c2acc70SPeter Maydell ;; 15787c2acc70SPeter Maydell esac 1579d0e2fce5SAneesh Kumar K.Vfi 1580d0e2fce5SAneesh Kumar K.V 15811e4f6065SDaniele Buono################################################## 15821e4f6065SDaniele Buono# SafeStack 15831e4f6065SDaniele Buono 15841e4f6065SDaniele Buono 15851e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 15861e4f6065SDaniele Buonocat > $TMPC << EOF 15878a0afbb2SStefan Weilint main(void) 15881e4f6065SDaniele Buono{ 15891e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 15901e4f6065SDaniele Buono#error SafeStack Disabled 15911e4f6065SDaniele Buono#endif 15921e4f6065SDaniele Buono return 0; 15931e4f6065SDaniele Buono} 15941e4f6065SDaniele BuonoEOF 15951e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 15961e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 15971e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 15981e4f6065SDaniele Buono # Flag needed both at compilation and at linking 15991e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 16001e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 16011e4f6065SDaniele Buono else 16021e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 16031e4f6065SDaniele Buono fi 16041e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 16051e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 16061e4f6065SDaniele Buono fi 16071e4f6065SDaniele Buonoelse 16081e4f6065SDaniele Buonocat > $TMPC << EOF 16098a0afbb2SStefan Weilint main(void) 16101e4f6065SDaniele Buono{ 16111e4f6065SDaniele Buono#if defined(__has_feature) 16121e4f6065SDaniele Buono#if __has_feature(safe_stack) 16131e4f6065SDaniele Buono#error SafeStack Enabled 16141e4f6065SDaniele Buono#endif 16151e4f6065SDaniele Buono#endif 16161e4f6065SDaniele Buono return 0; 16171e4f6065SDaniele Buono} 16181e4f6065SDaniele BuonoEOF 16191e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 16201e4f6065SDaniele Buono # Make sure that safe-stack is disabled 16211e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 16221e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 16231e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 16241e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 16251e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 16261e4f6065SDaniele Buono fi 16271e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 16281e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 16291e4f6065SDaniele Buono fi 16301e4f6065SDaniele Buonoelse # "$safe_stack" = "" 16311e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 16321e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 16331e4f6065SDaniele Buono safe_stack="no" 16341e4f6065SDaniele Buono else 16351e4f6065SDaniele Buono safe_stack="yes" 16361e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 16371e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 16381e4f6065SDaniele Buono fi 16391e4f6065SDaniele Buono fi 16401e4f6065SDaniele Buonofi 16411e4f6065SDaniele Buonofi 16427d992e4dSPeter Lieven 164376a347e1SRichard Henderson######################################## 1644fd0e6053SJohn Snow# check if ccache is interfering with 1645fd0e6053SJohn Snow# semantic analysis of macros 1646fd0e6053SJohn Snow 16475e4dfd3dSJohn Snowunset CCACHE_CPP2 1648fd0e6053SJohn Snowccache_cpp2=no 1649fd0e6053SJohn Snowcat > $TMPC << EOF 1650fd0e6053SJohn Snowstatic const int Z = 1; 1651fd0e6053SJohn Snow#define fn() ({ Z; }) 1652fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 1653fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 1654fd0e6053SJohn Snow#define ID(X) (X) 16558a0afbb2SStefan Weilint main(void) 1656fd0e6053SJohn Snow{ 1657fd0e6053SJohn Snow int x = 0, y = 0; 1658fd0e6053SJohn Snow x = ID(x); 1659fd0e6053SJohn Snow x = fn(); 1660fd0e6053SJohn Snow fn(); 1661fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 1662fd0e6053SJohn Snow if (TAUT(Z)) return 0; 1663fd0e6053SJohn Snow return 0; 1664fd0e6053SJohn Snow} 1665fd0e6053SJohn SnowEOF 1666fd0e6053SJohn Snow 1667fd0e6053SJohn Snowif ! compile_object "-Werror"; then 1668fd0e6053SJohn Snow ccache_cpp2=yes 1669fd0e6053SJohn Snowfi 1670fd0e6053SJohn Snow 1671b553a042SJohn Snow################################################# 1672b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 1673b553a042SJohn Snow 1674b553a042SJohn Snowif test "$fortify_source" != "no"; then 1675b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 1676b553a042SJohn Snow fortify_source="no"; 1677e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 1678cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 1679b553a042SJohn Snow fortify_source="no"; 1680b553a042SJohn Snow else 1681b553a042SJohn Snow fortify_source="yes" 1682b553a042SJohn Snow fi 1683b553a042SJohn Snowfi 1684b553a042SJohn Snow 1685d2042378SAneesh Kumar K.V########################################## 1686247724cbSMarc-André Lureau# checks for sanitizers 1687247724cbSMarc-André Lureau 1688247724cbSMarc-André Lureauhave_asan=no 1689247724cbSMarc-André Lureauhave_ubsan=no 1690d83414e1SMarc-André Lureauhave_asan_iface_h=no 1691d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 1692247724cbSMarc-André Lureau 1693247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 1694b9f44da2SMarc-André Lureau write_c_skeleton 1695247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 1696247724cbSMarc-André Lureau have_asan=yes 1697247724cbSMarc-André Lureau fi 1698b9f44da2SMarc-André Lureau 1699b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 1700b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 1701b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 1702b9f44da2SMarc-André Lureau cat > $TMPC << EOF 1703b9f44da2SMarc-André Lureau#include <stdlib.h> 1704b9f44da2SMarc-André Lureauint main(void) { 1705b9f44da2SMarc-André Lureau void *tmp = malloc(10); 1706f2dfe54cSLeonid Bloch if (tmp != NULL) { 1707b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 1708b9f44da2SMarc-André Lureau } 1709d1abf3fcSOlaf Hering return 1; 1710f2dfe54cSLeonid Bloch} 1711b9f44da2SMarc-André LureauEOF 1712247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 1713247724cbSMarc-André Lureau have_ubsan=yes 1714247724cbSMarc-André Lureau fi 1715d83414e1SMarc-André Lureau 1716d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 1717d83414e1SMarc-André Lureau have_asan_iface_h=yes 1718d83414e1SMarc-André Lureau fi 1719d83414e1SMarc-André Lureau 1720d83414e1SMarc-André Lureau cat > $TMPC << EOF 1721d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 1722d83414e1SMarc-André Lureauint main(void) { 1723d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 1724d83414e1SMarc-André Lureau return 0; 1725d83414e1SMarc-André Lureau} 1726d83414e1SMarc-André LureauEOF 1727d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 1728d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 1729d83414e1SMarc-André Lureau fi 1730247724cbSMarc-André Lureaufi 1731247724cbSMarc-André Lureau 17320aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 17330aebab04SLingfeng Yang# keep it separate until that is not the case. 17340aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 17350aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 17360aebab04SLingfeng Yangfi 17370aebab04SLingfeng Yanghave_tsan=no 17380aebab04SLingfeng Yanghave_tsan_iface_fiber=no 17390aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 17400aebab04SLingfeng Yang write_c_skeleton 17410aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 17420aebab04SLingfeng Yang have_tsan=yes 17430aebab04SLingfeng Yang fi 17440aebab04SLingfeng Yang cat > $TMPC << EOF 17450aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 17460aebab04SLingfeng Yangint main(void) { 17470aebab04SLingfeng Yang __tsan_create_fiber(0); 17480aebab04SLingfeng Yang return 0; 17490aebab04SLingfeng Yang} 17500aebab04SLingfeng YangEOF 17510aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 17520aebab04SLingfeng Yang have_tsan_iface_fiber=yes 17530aebab04SLingfeng Yang fi 17540aebab04SLingfeng Yangfi 17550aebab04SLingfeng Yang 1756adc28027SAlexander Bulekov########################################## 1757cd362defSPaolo Bonzini# functions to probe cross compilers 1758cd362defSPaolo Bonzini 1759cd362defSPaolo Bonzinicontainer="no" 176047fdc8fbSStefan Weilif test $use_containers = "yes" && (has "docker" || has "podman"); then 1761c4575b59SPaolo Bonzini case $($python "$source_path"/tests/docker/docker.py probe) in 1762c4575b59SPaolo Bonzini *docker) container=docker ;; 1763c4575b59SPaolo Bonzini podman) container=podman ;; 1764c4575b59SPaolo Bonzini no) container=no ;; 1765c4575b59SPaolo Bonzini esac 1766a3e28f81SPaolo Bonzini if test "$container" != "no"; then 1767a3e28f81SPaolo Bonzini docker_py="$python $source_path/tests/docker/docker.py --engine $container" 1768a3e28f81SPaolo Bonzini fi 1769cd362defSPaolo Bonzinifi 1770cd362defSPaolo Bonzini 1771cd362defSPaolo Bonzini# cross compilers defaults, can be overridden with --cross-cc-ARCH 17725adb43beSPaolo Bonzini: ${cross_prefix_aarch64="aarch64-linux-gnu-"} 17735adb43beSPaolo Bonzini: ${cross_prefix_aarch64_be="$cross_prefix_aarch64"} 17745adb43beSPaolo Bonzini: ${cross_prefix_alpha="alpha-linux-gnu-"} 17755adb43beSPaolo Bonzini: ${cross_prefix_arm="arm-linux-gnueabihf-"} 17765adb43beSPaolo Bonzini: ${cross_prefix_armeb="$cross_prefix_arm"} 17775adb43beSPaolo Bonzini: ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"} 177834bb43b0SSong Gao: ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"} 17795adb43beSPaolo Bonzini: ${cross_prefix_hppa="hppa-linux-gnu-"} 17805adb43beSPaolo Bonzini: ${cross_prefix_i386="i686-linux-gnu-"} 17815adb43beSPaolo Bonzini: ${cross_prefix_m68k="m68k-linux-gnu-"} 17825adb43beSPaolo Bonzini: ${cross_prefix_microblaze="microblaze-linux-musl-"} 17835adb43beSPaolo Bonzini: ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"} 17845adb43beSPaolo Bonzini: ${cross_prefix_mips64="mips64-linux-gnuabi64-"} 17855adb43beSPaolo Bonzini: ${cross_prefix_mipsel="mipsel-linux-gnu-"} 17865adb43beSPaolo Bonzini: ${cross_prefix_mips="mips-linux-gnu-"} 17875adb43beSPaolo Bonzini: ${cross_prefix_nios2="nios2-linux-gnu-"} 17885adb43beSPaolo Bonzini: ${cross_prefix_ppc="powerpc-linux-gnu-"} 17895adb43beSPaolo Bonzini: ${cross_prefix_ppc64="powerpc64-linux-gnu-"} 17905adb43beSPaolo Bonzini: ${cross_prefix_ppc64le="$cross_prefix_ppc64"} 17915adb43beSPaolo Bonzini: ${cross_prefix_riscv64="riscv64-linux-gnu-"} 17925adb43beSPaolo Bonzini: ${cross_prefix_s390x="s390x-linux-gnu-"} 17935adb43beSPaolo Bonzini: ${cross_prefix_sh4="sh4-linux-gnu-"} 17945adb43beSPaolo Bonzini: ${cross_prefix_sparc64="sparc64-linux-gnu-"} 17955adb43beSPaolo Bonzini: ${cross_prefix_sparc="$cross_prefix_sparc64"} 17965adb43beSPaolo Bonzini: ${cross_prefix_x86_64="x86_64-linux-gnu-"} 17975adb43beSPaolo Bonzini 1798cd362defSPaolo Bonzini: ${cross_cc_aarch64_be="$cross_cc_aarch64"} 1799cd362defSPaolo Bonzini: ${cross_cc_cflags_aarch64_be="-mbig-endian"} 180046af66edSPaolo Bonzini: ${cross_cc_armeb="$cross_cc_arm"} 1801cd362defSPaolo Bonzini: ${cross_cc_cflags_armeb="-mbig-endian"} 1802cd362defSPaolo Bonzini: ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"} 1803cd362defSPaolo Bonzini: ${cross_cc_cflags_hexagon="-mv67 -O2 -static"} 1804cd362defSPaolo Bonzini: ${cross_cc_cflags_i386="-m32"} 1805d44f2f96SPaolo Bonzini: ${cross_cc_cflags_ppc="-m32 -mbig-endian"} 1806cd362defSPaolo Bonzini: ${cross_cc_cflags_ppc64="-m64 -mbig-endian"} 1807cd362defSPaolo Bonzini: ${cross_cc_ppc64le="$cross_cc_ppc64"} 1808cd362defSPaolo Bonzini: ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"} 1809cd362defSPaolo Bonzini: ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"} 181046af66edSPaolo Bonzini: ${cross_cc_sparc="$cross_cc_sparc64"} 181146af66edSPaolo Bonzini: ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"} 1812cd362defSPaolo Bonzini: ${cross_cc_cflags_x86_64="-m64"} 1813cd362defSPaolo Bonzini 18145adb43beSPaolo Bonzinicompute_target_variable() { 181592e288fcSPaolo Bonzini eval "$2=" 18165adb43beSPaolo Bonzini if eval test -n "\"\${cross_prefix_$1}\""; then 18175adb43beSPaolo Bonzini if eval has "\"\${cross_prefix_$1}\$3\""; then 18185adb43beSPaolo Bonzini eval "$2=\"\${cross_prefix_$1}\$3\"" 18195adb43beSPaolo Bonzini fi 18205adb43beSPaolo Bonzini fi 18215adb43beSPaolo Bonzini} 1822cd362defSPaolo Bonzini 182335fd22b0SPaolo Bonzinihave_target() { 182435fd22b0SPaolo Bonzini for i; do 182535fd22b0SPaolo Bonzini case " $target_list " in 182635fd22b0SPaolo Bonzini *" $i "*) return 0;; 182735fd22b0SPaolo Bonzini *) ;; 182835fd22b0SPaolo Bonzini esac 182935fd22b0SPaolo Bonzini done 183035fd22b0SPaolo Bonzini return 1 183135fd22b0SPaolo Bonzini} 183235fd22b0SPaolo Bonzini 183352f08deaSPaolo Bonzini# probe_target_compiler TARGET 183452f08deaSPaolo Bonzini# 183552f08deaSPaolo Bonzini# Look for a compiler for the given target, either native or cross. 183652f08deaSPaolo Bonzini# Set variables target_* if a compiler is found, and container_cross_* 183752f08deaSPaolo Bonzini# if a Docker-based cross-compiler image is known for the target. 183852f08deaSPaolo Bonzini# Set got_cross_cc to yes/no depending on whether a non-container-based 183952f08deaSPaolo Bonzini# compiler was found. 184052f08deaSPaolo Bonzini# 184152f08deaSPaolo Bonzini# If TARGET is a user-mode emulation target, also set build_static to 184252f08deaSPaolo Bonzini# "y" if static linking is possible. 184352f08deaSPaolo Bonzini# 1844cd362defSPaolo Bonziniprobe_target_compiler() { 1845cd362defSPaolo Bonzini # reset all output variables 184692e288fcSPaolo Bonzini got_cross_cc=no 1847cd362defSPaolo Bonzini container_image= 1848cd362defSPaolo Bonzini container_hosts= 1849cd362defSPaolo Bonzini container_cross_cc= 185087eb014cSPaolo Bonzini container_cross_ar= 1851cd362defSPaolo Bonzini container_cross_as= 1852cd362defSPaolo Bonzini container_cross_ld= 185387eb014cSPaolo Bonzini container_cross_nm= 185487eb014cSPaolo Bonzini container_cross_objcopy= 185587eb014cSPaolo Bonzini container_cross_ranlib= 185687eb014cSPaolo Bonzini container_cross_strip= 1857cd362defSPaolo Bonzini 1858c3b570b5SAlex Bennée # We shall skip configuring the target compiler if the user didn't 1859c3b570b5SAlex Bennée # bother enabling an appropriate guest. This avoids building 1860c3b570b5SAlex Bennée # extraneous firmware images and tests. 186173acb87bSMukilan Thiyagarajan if test "${target_list#*$1}" = "$1"; then 1862c3b570b5SAlex Bennée return 1 1863c3b570b5SAlex Bennée fi 1864c3b570b5SAlex Bennée 186552f08deaSPaolo Bonzini target_arch=${1%%-*} 186652f08deaSPaolo Bonzini case $target_arch in 1867cd362defSPaolo Bonzini aarch64) container_hosts="x86_64 aarch64" ;; 1868cd362defSPaolo Bonzini alpha) container_hosts=x86_64 ;; 1869cd362defSPaolo Bonzini arm) container_hosts="x86_64 aarch64" ;; 1870cd362defSPaolo Bonzini cris) container_hosts=x86_64 ;; 1871cd362defSPaolo Bonzini hexagon) container_hosts=x86_64 ;; 1872cd362defSPaolo Bonzini hppa) container_hosts=x86_64 ;; 1873cd362defSPaolo Bonzini i386) container_hosts=x86_64 ;; 1874b70ec50bSRichard Henderson loongarch64) container_hosts=x86_64 ;; 1875cd362defSPaolo Bonzini m68k) container_hosts=x86_64 ;; 1876cd362defSPaolo Bonzini microblaze) container_hosts=x86_64 ;; 1877cd362defSPaolo Bonzini mips64el) container_hosts=x86_64 ;; 1878cd362defSPaolo Bonzini mips64) container_hosts=x86_64 ;; 1879cd362defSPaolo Bonzini mipsel) container_hosts=x86_64 ;; 1880cd362defSPaolo Bonzini mips) container_hosts=x86_64 ;; 1881cd362defSPaolo Bonzini nios2) container_hosts=x86_64 ;; 1882cd362defSPaolo Bonzini ppc) container_hosts=x86_64 ;; 1883cd362defSPaolo Bonzini ppc64|ppc64le) container_hosts=x86_64 ;; 1884cd362defSPaolo Bonzini riscv64) container_hosts=x86_64 ;; 1885cd362defSPaolo Bonzini s390x) container_hosts=x86_64 ;; 1886cd362defSPaolo Bonzini sh4) container_hosts=x86_64 ;; 1887cd362defSPaolo Bonzini sparc64) container_hosts=x86_64 ;; 1888cd362defSPaolo Bonzini tricore) container_hosts=x86_64 ;; 1889cd362defSPaolo Bonzini x86_64) container_hosts="aarch64 ppc64el x86_64" ;; 1890cd362defSPaolo Bonzini xtensa*) container_hosts=x86_64 ;; 1891cd362defSPaolo Bonzini esac 1892cd362defSPaolo Bonzini 1893cd362defSPaolo Bonzini for host in $container_hosts; do 1894cd362defSPaolo Bonzini test "$container" != no || continue 1895cd362defSPaolo Bonzini test "$host" = "$cpu" || continue 189652f08deaSPaolo Bonzini case $target_arch in 1897cd362defSPaolo Bonzini aarch64) 1898cd362defSPaolo Bonzini # We don't have any bigendian build tools so we only use this for AArch64 1899cd362defSPaolo Bonzini container_image=debian-arm64-cross 19005adb43beSPaolo Bonzini container_cross_prefix=aarch64-linux-gnu- 19015adb43beSPaolo Bonzini container_cross_cc=${container_cross_prefix}gcc-10 1902cd362defSPaolo Bonzini ;; 1903cd362defSPaolo Bonzini alpha) 1904cd362defSPaolo Bonzini container_image=debian-alpha-cross 19055adb43beSPaolo Bonzini container_cross_prefix=alpha-linux-gnu- 1906cd362defSPaolo Bonzini ;; 1907cd362defSPaolo Bonzini arm) 1908cd362defSPaolo Bonzini # We don't have any bigendian build tools so we only use this for ARM 1909cd362defSPaolo Bonzini container_image=debian-armhf-cross 19105adb43beSPaolo Bonzini container_cross_prefix=arm-linux-gnueabihf- 1911cd362defSPaolo Bonzini ;; 1912cd362defSPaolo Bonzini cris) 1913cd362defSPaolo Bonzini container_image=fedora-cris-cross 19145adb43beSPaolo Bonzini container_cross_prefix=cris-linux-gnu- 1915cd362defSPaolo Bonzini ;; 1916cd362defSPaolo Bonzini hexagon) 1917cd362defSPaolo Bonzini container_image=debian-hexagon-cross 19185adb43beSPaolo Bonzini container_cross_prefix=hexagon-unknown-linux-musl- 19195adb43beSPaolo Bonzini container_cross_cc=${container_cross_prefix}clang 1920cd362defSPaolo Bonzini ;; 1921cd362defSPaolo Bonzini hppa) 1922cd362defSPaolo Bonzini container_image=debian-hppa-cross 19235adb43beSPaolo Bonzini container_cross_prefix=hppa-linux-gnu- 1924cd362defSPaolo Bonzini ;; 1925cd362defSPaolo Bonzini i386) 1926cd362defSPaolo Bonzini container_image=fedora-i386-cross 19275adb43beSPaolo Bonzini container_cross_prefix= 1928cd362defSPaolo Bonzini ;; 1929b70ec50bSRichard Henderson loongarch64) 1930b70ec50bSRichard Henderson container_image=debian-loongarch-cross 1931b70ec50bSRichard Henderson container_cross_prefix=loongarch64-unknown-linux-gnu- 1932b70ec50bSRichard Henderson ;; 1933cd362defSPaolo Bonzini m68k) 1934cd362defSPaolo Bonzini container_image=debian-m68k-cross 19355adb43beSPaolo Bonzini container_cross_prefix=m68k-linux-gnu- 1936cd362defSPaolo Bonzini ;; 1937cd362defSPaolo Bonzini microblaze) 1938cd362defSPaolo Bonzini container_image=debian-microblaze-cross 19395adb43beSPaolo Bonzini container_cross_prefix=microblaze-linux-musl- 1940cd362defSPaolo Bonzini ;; 1941cd362defSPaolo Bonzini mips64el) 1942cd362defSPaolo Bonzini container_image=debian-mips64el-cross 19435adb43beSPaolo Bonzini container_cross_prefix=mips64el-linux-gnuabi64- 1944cd362defSPaolo Bonzini ;; 1945cd362defSPaolo Bonzini mips64) 1946cd362defSPaolo Bonzini container_image=debian-mips64-cross 19475adb43beSPaolo Bonzini container_cross_prefix=mips64-linux-gnuabi64- 1948cd362defSPaolo Bonzini ;; 1949cd362defSPaolo Bonzini mipsel) 1950cd362defSPaolo Bonzini container_image=debian-mipsel-cross 19515adb43beSPaolo Bonzini container_cross_prefix=mipsel-linux-gnu- 1952cd362defSPaolo Bonzini ;; 1953cd362defSPaolo Bonzini mips) 1954cd362defSPaolo Bonzini container_image=debian-mips-cross 19555adb43beSPaolo Bonzini container_cross_prefix=mips-linux-gnu- 1956cd362defSPaolo Bonzini ;; 1957cd362defSPaolo Bonzini nios2) 1958cd362defSPaolo Bonzini container_image=debian-nios2-cross 19595adb43beSPaolo Bonzini container_cross_prefix=nios2-linux-gnu- 1960cd362defSPaolo Bonzini ;; 1961cd362defSPaolo Bonzini ppc) 1962cd362defSPaolo Bonzini container_image=debian-powerpc-test-cross 19635adb43beSPaolo Bonzini container_cross_prefix=powerpc-linux-gnu- 19645adb43beSPaolo Bonzini container_cross_cc=${container_cross_prefix}gcc-10 1965cd362defSPaolo Bonzini ;; 1966cd362defSPaolo Bonzini ppc64|ppc64le) 1967cd362defSPaolo Bonzini container_image=debian-powerpc-test-cross 1968705c881fSRichard Henderson container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu- 19695adb43beSPaolo Bonzini container_cross_cc=${container_cross_prefix}gcc-10 1970cd362defSPaolo Bonzini ;; 1971cd362defSPaolo Bonzini riscv64) 1972cd362defSPaolo Bonzini container_image=debian-riscv64-test-cross 19735adb43beSPaolo Bonzini container_cross_prefix=riscv64-linux-gnu- 1974cd362defSPaolo Bonzini ;; 1975cd362defSPaolo Bonzini s390x) 1976cd362defSPaolo Bonzini container_image=debian-s390x-cross 19775adb43beSPaolo Bonzini container_cross_prefix=s390x-linux-gnu- 1978cd362defSPaolo Bonzini ;; 1979cd362defSPaolo Bonzini sh4) 1980cd362defSPaolo Bonzini container_image=debian-sh4-cross 19815adb43beSPaolo Bonzini container_cross_prefix=sh4-linux-gnu- 1982cd362defSPaolo Bonzini ;; 1983cd362defSPaolo Bonzini sparc64) 1984cd362defSPaolo Bonzini container_image=debian-sparc64-cross 19855adb43beSPaolo Bonzini container_cross_prefix=sparc64-linux-gnu- 1986cd362defSPaolo Bonzini ;; 1987cd362defSPaolo Bonzini tricore) 1988cd362defSPaolo Bonzini container_image=debian-tricore-cross 19895adb43beSPaolo Bonzini container_cross_prefix=tricore- 1990cd362defSPaolo Bonzini container_cross_as=tricore-as 1991cd362defSPaolo Bonzini container_cross_ld=tricore-ld 19925adb43beSPaolo Bonzini break 1993cd362defSPaolo Bonzini ;; 1994cd362defSPaolo Bonzini x86_64) 1995cd362defSPaolo Bonzini container_image=debian-amd64-cross 19965adb43beSPaolo Bonzini container_cross_prefix=x86_64-linux-gnu- 1997cd362defSPaolo Bonzini ;; 1998cd362defSPaolo Bonzini xtensa*) 1999cd362defSPaolo Bonzini container_hosts=x86_64 2000cd362defSPaolo Bonzini container_image=debian-xtensa-cross 2001cd362defSPaolo Bonzini 2002cd362defSPaolo Bonzini # default to the dc232b cpu 20035adb43beSPaolo Bonzini container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf- 2004cd362defSPaolo Bonzini ;; 2005cd362defSPaolo Bonzini esac 20065adb43beSPaolo Bonzini : ${container_cross_cc:=${container_cross_prefix}gcc} 200787eb014cSPaolo Bonzini : ${container_cross_ar:=${container_cross_prefix}ar} 20085adb43beSPaolo Bonzini : ${container_cross_as:=${container_cross_prefix}as} 20095adb43beSPaolo Bonzini : ${container_cross_ld:=${container_cross_prefix}ld} 201087eb014cSPaolo Bonzini : ${container_cross_nm:=${container_cross_prefix}nm} 201187eb014cSPaolo Bonzini : ${container_cross_objcopy:=${container_cross_prefix}objcopy} 201287eb014cSPaolo Bonzini : ${container_cross_ranlib:=${container_cross_prefix}ranlib} 201387eb014cSPaolo Bonzini : ${container_cross_strip:=${container_cross_prefix}strip} 2014cd362defSPaolo Bonzini done 2015cd362defSPaolo Bonzini 201692e288fcSPaolo Bonzini try=cross 201792e288fcSPaolo Bonzini case "$target_arch:$cpu" in 201892e288fcSPaolo Bonzini aarch64_be:aarch64 | \ 201992e288fcSPaolo Bonzini armeb:arm | \ 202092e288fcSPaolo Bonzini i386:x86_64 | \ 202192e288fcSPaolo Bonzini mips*:mips64 | \ 202292e288fcSPaolo Bonzini ppc*:ppc64 | \ 202392e288fcSPaolo Bonzini sparc:sparc64 | \ 202492e288fcSPaolo Bonzini "$cpu:$cpu") 202592e288fcSPaolo Bonzini try='native cross' ;; 202692e288fcSPaolo Bonzini esac 202752f08deaSPaolo Bonzini eval "target_cflags=\${cross_cc_cflags_$target_arch}" 2028b3b5472dSPeter Maydell for thistry in $try; do 2029b3b5472dSPeter Maydell case $thistry in 203092e288fcSPaolo Bonzini native) 203192e288fcSPaolo Bonzini target_cc=$cc 203292e288fcSPaolo Bonzini target_ccas=$ccas 203392e288fcSPaolo Bonzini target_ar=$ar 203492e288fcSPaolo Bonzini target_as=$as 203592e288fcSPaolo Bonzini target_ld=$ld 203692e288fcSPaolo Bonzini target_nm=$nm 203792e288fcSPaolo Bonzini target_objcopy=$objcopy 203892e288fcSPaolo Bonzini target_ranlib=$ranlib 203992e288fcSPaolo Bonzini target_strip=$strip 204092e288fcSPaolo Bonzini ;; 204192e288fcSPaolo Bonzini cross) 204292e288fcSPaolo Bonzini target_cc= 204352f08deaSPaolo Bonzini if eval test -n "\"\${cross_cc_$target_arch}\""; then 204452f08deaSPaolo Bonzini if eval has "\"\${cross_cc_$target_arch}\""; then 204552f08deaSPaolo Bonzini eval "target_cc=\"\${cross_cc_$target_arch}\"" 2046cd362defSPaolo Bonzini fi 20475adb43beSPaolo Bonzini else 204852f08deaSPaolo Bonzini compute_target_variable $target_arch target_cc gcc 2049cd362defSPaolo Bonzini fi 205087eb014cSPaolo Bonzini target_ccas=$target_cc 205152f08deaSPaolo Bonzini compute_target_variable $target_arch target_ar ar 205252f08deaSPaolo Bonzini compute_target_variable $target_arch target_as as 205352f08deaSPaolo Bonzini compute_target_variable $target_arch target_ld ld 205452f08deaSPaolo Bonzini compute_target_variable $target_arch target_nm nm 205552f08deaSPaolo Bonzini compute_target_variable $target_arch target_objcopy objcopy 205652f08deaSPaolo Bonzini compute_target_variable $target_arch target_ranlib ranlib 205752f08deaSPaolo Bonzini compute_target_variable $target_arch target_strip strip 2058640aabc8SPaolo Bonzini ;; 2059640aabc8SPaolo Bonzini esac 206092e288fcSPaolo Bonzini 20612ad60f6fSPaolo Bonzini if test -n "$target_cc"; then 206252f08deaSPaolo Bonzini case $target_arch in 20632ad60f6fSPaolo Bonzini i386|x86_64) 20642ad60f6fSPaolo Bonzini if $target_cc --version | grep -qi "clang"; then 206592e288fcSPaolo Bonzini continue 20662ad60f6fSPaolo Bonzini fi 20672ad60f6fSPaolo Bonzini ;; 20682ad60f6fSPaolo Bonzini esac 206992e288fcSPaolo Bonzini elif test -n "$target_as" && test -n "$target_ld"; then 207092e288fcSPaolo Bonzini # Special handling for assembler only targets 207192e288fcSPaolo Bonzini case $target in 207292e288fcSPaolo Bonzini tricore-softmmu) 207392e288fcSPaolo Bonzini build_static= 207492e288fcSPaolo Bonzini got_cross_cc=yes 207592e288fcSPaolo Bonzini break 207692e288fcSPaolo Bonzini ;; 207792e288fcSPaolo Bonzini *) 207892e288fcSPaolo Bonzini continue 207992e288fcSPaolo Bonzini ;; 208092e288fcSPaolo Bonzini esac 208192e288fcSPaolo Bonzini else 208292e288fcSPaolo Bonzini continue 208392e288fcSPaolo Bonzini fi 208492e288fcSPaolo Bonzini 208592e288fcSPaolo Bonzini write_c_skeleton 208692e288fcSPaolo Bonzini case $1 in 208792e288fcSPaolo Bonzini *-softmmu) 208892e288fcSPaolo Bonzini if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC && 208992e288fcSPaolo Bonzini do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then 209092e288fcSPaolo Bonzini got_cross_cc=yes 209192e288fcSPaolo Bonzini break 209292e288fcSPaolo Bonzini fi 209392e288fcSPaolo Bonzini ;; 209492e288fcSPaolo Bonzini *) 209592e288fcSPaolo Bonzini if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then 209692e288fcSPaolo Bonzini build_static=y 209792e288fcSPaolo Bonzini got_cross_cc=yes 209892e288fcSPaolo Bonzini break 209992e288fcSPaolo Bonzini fi 210092e288fcSPaolo Bonzini if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then 210192e288fcSPaolo Bonzini build_static= 210292e288fcSPaolo Bonzini got_cross_cc=yes 210392e288fcSPaolo Bonzini break 210492e288fcSPaolo Bonzini fi 210592e288fcSPaolo Bonzini ;; 210692e288fcSPaolo Bonzini esac 210792e288fcSPaolo Bonzini done 210892e288fcSPaolo Bonzini if test $got_cross_cc != yes; then 210992e288fcSPaolo Bonzini build_static= 211092e288fcSPaolo Bonzini target_cc= 211192e288fcSPaolo Bonzini target_ccas= 211292e288fcSPaolo Bonzini target_ar= 211392e288fcSPaolo Bonzini target_as= 211492e288fcSPaolo Bonzini target_ld= 211592e288fcSPaolo Bonzini target_nm= 211692e288fcSPaolo Bonzini target_objcopy= 211792e288fcSPaolo Bonzini target_ranlib= 211892e288fcSPaolo Bonzini target_strip= 21192ad60f6fSPaolo Bonzini fi 2120fde10960SAlex Bennée test -n "$target_cc" 2121cd362defSPaolo Bonzini} 2122cd362defSPaolo Bonzini 2123cd362defSPaolo Bonziniwrite_target_makefile() { 2124e81785abSPaolo Bonzini echo "EXTRA_CFLAGS=$target_cflags" 21250825cae0SPaolo Bonzini if test -z "$target_cc" && test -z "$target_as"; then 21260825cae0SPaolo Bonzini test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?" 21270825cae0SPaolo Bonzini echo "$1: docker-image-$container_image" >> Makefile.prereqs 21280825cae0SPaolo Bonzini if test -n "$container_cross_cc"; then 21290825cae0SPaolo Bonzini echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" 21300825cae0SPaolo Bonzini echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" 21310825cae0SPaolo Bonzini fi 21320825cae0SPaolo Bonzini echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --" 21330825cae0SPaolo Bonzini echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --" 21340825cae0SPaolo Bonzini echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --" 21350825cae0SPaolo Bonzini echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --" 21360825cae0SPaolo Bonzini echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --" 21370825cae0SPaolo Bonzini echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --" 21380825cae0SPaolo Bonzini echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --" 21390825cae0SPaolo Bonzini else 2140cd362defSPaolo Bonzini if test -n "$target_cc"; then 2141cd362defSPaolo Bonzini echo "CC=$target_cc" 214287eb014cSPaolo Bonzini echo "CCAS=$target_ccas" 214387eb014cSPaolo Bonzini fi 214487eb014cSPaolo Bonzini if test -n "$target_ar"; then 214587eb014cSPaolo Bonzini echo "AR=$target_ar" 2146cd362defSPaolo Bonzini fi 2147cd362defSPaolo Bonzini if test -n "$target_as"; then 2148cd362defSPaolo Bonzini echo "AS=$target_as" 2149cd362defSPaolo Bonzini fi 2150cd362defSPaolo Bonzini if test -n "$target_ld"; then 2151cd362defSPaolo Bonzini echo "LD=$target_ld" 2152cd362defSPaolo Bonzini fi 215387eb014cSPaolo Bonzini if test -n "$target_nm"; then 215487eb014cSPaolo Bonzini echo "NM=$target_nm" 215587eb014cSPaolo Bonzini fi 215687eb014cSPaolo Bonzini if test -n "$target_objcopy"; then 215787eb014cSPaolo Bonzini echo "OBJCOPY=$target_objcopy" 215887eb014cSPaolo Bonzini fi 215987eb014cSPaolo Bonzini if test -n "$target_ranlib"; then 216087eb014cSPaolo Bonzini echo "RANLIB=$target_ranlib" 216187eb014cSPaolo Bonzini fi 216287eb014cSPaolo Bonzini if test -n "$target_strip"; then 216387eb014cSPaolo Bonzini echo "STRIP=$target_strip" 216487eb014cSPaolo Bonzini fi 2165cd362defSPaolo Bonzini fi 2166cd362defSPaolo Bonzini} 2167cd362defSPaolo Bonzini 2168cd362defSPaolo Bonzini########################################## 216955116968SJagannathan Raman# check for vfio_user_server 217055116968SJagannathan Raman 217155116968SJagannathan Ramancase "$vfio_user_server" in 217255116968SJagannathan Raman enabled ) 217355116968SJagannathan Raman if test "$git_submodules_action" != "ignore"; then 217455116968SJagannathan Raman git_submodules="${git_submodules} subprojects/libvfio-user" 217555116968SJagannathan Raman fi 217655116968SJagannathan Raman ;; 217755116968SJagannathan Ramanesac 217855116968SJagannathan Raman 217955116968SJagannathan Raman########################################## 2180e86ecd4bSJuan Quintela# End of CC checks 2181e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 2182e86ecd4bSJuan Quintela 2183d83414e1SMarc-André Lureauwrite_c_skeleton 2184d83414e1SMarc-André Lureau 2185df42fa7dSPaolo Bonziniif test "$fortify_source" = "yes" ; then 2186086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 2187086d5f75SPaolo Bonzinifi 2188086d5f75SPaolo Bonzini 2189247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 2190db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 2191db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 2192d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 2193d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 2194d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2195d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 2196d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 2197d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2198d83414e1SMarc-André Lureau fi 2199247724cbSMarc-André Lureaufi 22000aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 22010aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 22020aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 22030aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 22040aebab04SLingfeng Yang else 22050aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 22060aebab04SLingfeng Yang fi 22070aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 22080aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 22090aebab04SLingfeng Yangfi 2210247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 2211db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 2212db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 2213247724cbSMarc-André Lureaufi 2214247724cbSMarc-André Lureau 221533ab4787SPaolo Bonzini####################################### 221633ab4787SPaolo Bonzini# cross-compiled firmware targets 221733ab4787SPaolo Bonzini 2218ad388845SPaolo Bonzini# Set up build tree symlinks that point back into the source tree 2219ad388845SPaolo Bonzini# (these can be both files and directories). 2220ad388845SPaolo Bonzini# Caution: avoid adding files or directories here using wildcards. This 2221ad388845SPaolo Bonzini# will result in problems later if a new file matching the wildcard is 2222ad388845SPaolo Bonzini# added to the source tree -- nothing will cause configure to be rerun 2223ad388845SPaolo Bonzini# so the build tree will be missing the link back to the new file, and 2224ad388845SPaolo Bonzini# tests might fail. Prefer to keep the relevant files in their own 2225ad388845SPaolo Bonzini# directory and symlink the directory instead. 2226ad388845SPaolo BonziniLINKS="Makefile" 2227ad388845SPaolo BonziniLINKS="$LINKS pc-bios/optionrom/Makefile" 2228ad388845SPaolo BonziniLINKS="$LINKS pc-bios/s390-ccw/Makefile" 2229d695918fSPaolo BonziniLINKS="$LINKS pc-bios/vof/Makefile" 2230ad388845SPaolo BonziniLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 2231ad388845SPaolo BonziniLINKS="$LINKS tests/avocado tests/data" 2232ad388845SPaolo BonziniLINKS="$LINKS tests/qemu-iotests/check" 2233ad388845SPaolo BonziniLINKS="$LINKS python" 2234ad388845SPaolo BonziniLINKS="$LINKS contrib/plugins/Makefile " 2235ad388845SPaolo Bonzinifor f in $LINKS ; do 2236ad388845SPaolo Bonzini if [ -e "$source_path/$f" ]; then 2237cc3c71e8SPeter Maydell mkdir -p "$(dirname ./"$f")" 2238ad388845SPaolo Bonzini symlink "$source_path/$f" "$f" 2239ad388845SPaolo Bonzini fi 2240ad388845SPaolo Bonzinidone 2241ad388845SPaolo Bonzini 2242b898bf28SPaolo Bonziniecho "# Automatically generated by configure - do not modify" > Makefile.prereqs 2243b898bf28SPaolo Bonzini 2244ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 2245ca35f780SPaolo Bonziniroms= 224635fd22b0SPaolo Bonziniif have_target i386-softmmu x86_64-softmmu && \ 224735fd22b0SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 224835fd22b0SPaolo Bonzini test "$targetos" != "haiku" && \ 224961cbb356SPaolo Bonzini probe_target_compiler i386-softmmu; then 225076ca98b0SPaolo Bonzini roms="pc-bios/optionrom" 225133ab4787SPaolo Bonzini config_mak=pc-bios/optionrom/config.mak 225233ab4787SPaolo Bonzini echo "# Automatically generated by configure - do not modify" > $config_mak 225333ab4787SPaolo Bonzini echo "TOPSRC_DIR=$source_path" >> $config_mak 2254fde10960SAlex Bennée write_target_makefile >> $config_mak 225533ab4787SPaolo Bonzinifi 2256ca35f780SPaolo Bonzini 225735fd22b0SPaolo Bonziniif have_target ppc-softmmu ppc64-softmmu && \ 225835fd22b0SPaolo Bonzini probe_target_compiler ppc-softmmu; then 225976ca98b0SPaolo Bonzini roms="$roms pc-bios/vof" 2260d695918fSPaolo Bonzini config_mak=pc-bios/vof/config.mak 2261d695918fSPaolo Bonzini echo "# Automatically generated by configure - do not modify" > $config_mak 2262d695918fSPaolo Bonzini echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak 2263fde10960SAlex Bennée write_target_makefile >> $config_mak 2264d695918fSPaolo Bonzinifi 2265d695918fSPaolo Bonzini 22669ffed426SPaolo Bonzini# Only build s390-ccw bios if the compiler has -march=z900 or -march=z10 22679ffed426SPaolo Bonzini# (which is the lowest architecture level that Clang supports) 226835fd22b0SPaolo Bonziniif have_target s390x-softmmu && probe_target_compiler s390x-softmmu; then 22692e33c3f8SThomas Huth write_c_skeleton 22709ffed426SPaolo Bonzini do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC 2271a5b2afd5SThomas Huth has_z900=$? 22729ffed426SPaolo Bonzini if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then 2273a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 2274a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 2275a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 2276a5b2afd5SThomas Huth fi 227776ca98b0SPaolo Bonzini roms="$roms pc-bios/s390-ccw" 22789ffed426SPaolo Bonzini config_mak=pc-bios/s390-ccw/config-host.mak 22799ffed426SPaolo Bonzini echo "# Automatically generated by configure - do not modify" > $config_mak 22809ffed426SPaolo Bonzini echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak 2281fde10960SAlex Bennée write_target_makefile >> $config_mak 22821ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 22831ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 22841ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 22851ef6bfc2SPhilippe Mathieu-Daudé fi 22869933c305SChristian Borntraegerfi 22879933c305SChristian Borntraeger 22889ffed426SPaolo Bonzini####################################### 22899ffed426SPaolo Bonzini# generate config-host.mak 22909ffed426SPaolo Bonzini 22917d7dbf9dSDan Streetmanif ! (GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 22927d7dbf9dSDan Streetman exit 1 22935d91a2edSYonggang Luofi 22945d91a2edSYonggang Luo 229598ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 229697a847bcSbellard 229798ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 229898ec69acSJuan Quintelaecho >> $config_host_mak 229998ec69acSJuan Quintela 2300e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 2301cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 2302aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 23037d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 2304804edf29SJuan Quintela 2305f8393946Saurel32if test "$debug_tcg" = "yes" ; then 23062358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 2307f8393946Saurel32fi 230867b915a5Sbellardif test "$mingw32" = "yes" ; then 230998ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 2310954ed68fSPaolo Bonzini echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER-QEMU}" >> $config_host_mak 2311954ed68fSPaolo Bonzini echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO-Linux}" >> $config_host_mak 2312954ed68fSPaolo Bonzini echo "QEMU_GA_VERSION=${QEMU_GA_VERSION-$(cat "$source_path"/VERSION)}" >> $config_host_mak 2313210fa556Spbrookelse 231435f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 2315210fa556Spbrookfi 2316128ab2ffSblueswir1 2317dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 2318dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 2319dffcb71cSMark McLoughlinfi 2320dffcb71cSMark McLoughlin 232183fb7adfSbellardif test "$darwin" = "yes" ; then 232298ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 232383fb7adfSbellardfi 2324b29fe3edSmalc 2325ec530c81Sbellardif test "$solaris" = "yes" ; then 232698ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 2327ec530c81Sbellardfi 232897a847bcSbellardif test "$static" = "yes" ; then 232998ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 233097a847bcSbellardfi 233198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 23322b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 233317969268SFam Zhengif test "$modules" = "yes"; then 233417969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 233517969268SFam Zhengfi 2336277abf15SJan Vesely 233783fb7adfSbellard# XXX: suppress that 23387d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 23392358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 23407d3505c5Sbellardfi 23417d3505c5Sbellard 23427c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 23437d992e4dSPeter Lieven 2344d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 2345d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 2346d83414e1SMarc-André Lureaufi 2347d83414e1SMarc-André Lureau 23480aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 23490aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 23500aebab04SLingfeng Yangfi 23510aebab04SLingfeng Yang 235240e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 235340e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 235440e8c6f4SAlex Bennéefi 235540e8c6f4SAlex Bennée 2356f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 2357b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 2358d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 2359f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 236048543dd7SAlex Bennée else 236148543dd7SAlex Bennée gdb_bin="" 2362f48e590aSAlex Bennée fi 2363b1863cccSAlex Bennéefi 2364f48e590aSAlex Bennée 2365c4575b59SPaolo Bonziniif test "$container" != no; then 2366c4575b59SPaolo Bonzini echo "ENGINE=$container" >> $config_host_mak 2367c4575b59SPaolo Bonzinifi 236898ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 2369804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 2370c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 237139d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 2372a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 237309e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 2374804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 2375a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 23764cb37d11SPhilippe Mathieu-Daudéecho "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak 2377a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 2378a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 23795b9e7d05SMarc-André Lureauecho "GLIB_BINDIR=$glib_bindir" >> $config_host_mak 2380acedc9a6SPaolo Bonziniecho "GLIB_VERSION=$($pkg_config --modversion glib-2.0)" >> $config_host_mak 23818a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 2382804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 2383804edf29SJuan Quintela 23846efd7517SPeter Maydell# use included Linux headers 23856efd7517SPeter Maydellif test "$linux" = "yes" ; then 2386a307beb6SAndreas Färber mkdir -p linux-headers 23876efd7517SPeter Maydell case "$cpu" in 23884da270beSPaolo Bonzini i386|x86_64) 238908312a63SPeter Maydell linux_arch=x86 23906efd7517SPeter Maydell ;; 2391d8ff892dSPaolo Bonzini ppc|ppc64) 239208312a63SPeter Maydell linux_arch=powerpc 23936efd7517SPeter Maydell ;; 23946efd7517SPeter Maydell s390x) 239508312a63SPeter Maydell linux_arch=s390 239608312a63SPeter Maydell ;; 23971f080313SClaudio Fontana aarch64) 23981f080313SClaudio Fontana linux_arch=arm64 23991f080313SClaudio Fontana ;; 2400dfcf900bSWANG Xuerui loongarch*) 2401dfcf900bSWANG Xuerui linux_arch=loongarch 2402dfcf900bSWANG Xuerui ;; 2403222e7d11SSanjay Lal mips64) 2404222e7d11SSanjay Lal linux_arch=mips 2405222e7d11SSanjay Lal ;; 240608312a63SPeter Maydell *) 240708312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 240808312a63SPeter Maydell linux_arch="$cpu" 24096efd7517SPeter Maydell ;; 24106efd7517SPeter Maydell esac 241108312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 241208312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 241308312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 241408312a63SPeter Maydell fi 24156efd7517SPeter Maydellfi 24166efd7517SPeter Maydell 241797a847bcSbellardfor target in $target_list; do 241897a847bcSbellard target_dir="$target" 241957a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 242064708615SPeter Maydell mkdir -p "$target_dir" 2421fdb75aefSPaolo Bonzini case $target in 2422fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 2423fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 24242408a527Saurel32 esac 242556aebc89Spbrookdone 24267d13299dSbellard 2427fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 2428fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 2429fdb75aefSPaolo Bonzinifi 2430a540f158SPeter Crosthwaite 2431fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 2432fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 2433fd0e6053SJohn Snowfi 2434fd0e6053SJohn Snow 24351e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 24361e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 24371e4f6065SDaniele Buonofi 24381e4f6065SDaniele Buono 2439cd362defSPaolo Bonzini# tests/tcg configuration 2440b898bf28SPaolo Bonzini(config_host_mak=tests/tcg/config-host.mak 2441d674342eSPaolo Bonzinimkdir -p tests/tcg 2442cd362defSPaolo Bonziniecho "# Automatically generated by configure - do not modify" > $config_host_mak 2443cd362defSPaolo Bonziniecho "SRC_PATH=$source_path" >> $config_host_mak 2444cd362defSPaolo Bonziniecho "HOST_CC=$host_cc" >> $config_host_mak 2445cd362defSPaolo Bonzini 244648543dd7SAlex Bennée# versioned checked in the main config_host.mak above 244748543dd7SAlex Bennéeif test -n "$gdb_bin"; then 244848543dd7SAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 244948543dd7SAlex Bennéefi 2450d1d94d96SPaolo Bonziniif test "$plugins" = "yes" ; then 2451d1d94d96SPaolo Bonzini echo "CONFIG_PLUGIN=y" >> $config_host_mak 2452d1d94d96SPaolo Bonzinifi 245348543dd7SAlex Bennée 2454cd362defSPaolo Bonzinitcg_tests_targets= 2455cd362defSPaolo Bonzinifor target in $target_list; do 2456cd362defSPaolo Bonzini arch=${target%%-*} 2457cd362defSPaolo Bonzini 2458cd362defSPaolo Bonzini case $target in 2459c48a5c47SPaolo Bonzini xtensa*-linux-user) 2460c48a5c47SPaolo Bonzini # the toolchain is not complete with headers, only build softmmu tests 2461c48a5c47SPaolo Bonzini continue 2462c48a5c47SPaolo Bonzini ;; 2463cd362defSPaolo Bonzini *-softmmu) 246464708615SPeter Maydell test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue 2465cd362defSPaolo Bonzini qemu="qemu-system-$arch" 2466cd362defSPaolo Bonzini ;; 2467cd362defSPaolo Bonzini *-linux-user|*-bsd-user) 2468cd362defSPaolo Bonzini qemu="qemu-$arch" 2469cd362defSPaolo Bonzini ;; 2470cd362defSPaolo Bonzini esac 2471cd362defSPaolo Bonzini 2472fde10960SAlex Bennée if probe_target_compiler $target || test -n "$container_image"; then 24730825cae0SPaolo Bonzini test -n "$container_image" && build_static=y 2474d674342eSPaolo Bonzini mkdir -p "tests/tcg/$target" 2475c7022a70SPaolo Bonzini config_target_mak=tests/tcg/$target/config-target.mak 2476d674342eSPaolo Bonzini ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile" 2477c7022a70SPaolo Bonzini echo "# Automatically generated by configure - do not modify" > "$config_target_mak" 2478c7022a70SPaolo Bonzini echo "TARGET_NAME=$arch" >> "$config_target_mak" 2479a3e28f81SPaolo Bonzini echo "TARGET=$target" >> "$config_target_mak" 2480c7022a70SPaolo Bonzini write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak" 248115b273f8SPaolo Bonzini echo "BUILD_STATIC=$build_static" >> "$config_target_mak" 2482c7022a70SPaolo Bonzini echo "QEMU=$PWD/$qemu" >> "$config_target_mak" 2483b898bf28SPaolo Bonzini echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs 2484cd362defSPaolo Bonzini tcg_tests_targets="$tcg_tests_targets $target" 2485cd362defSPaolo Bonzini fi 24862038f8c8SPaolo Bonzinidone 2487c0031d38SFabiano Rosas 2488c0031d38SFabiano Rosasif test "$tcg" = "enabled"; then 2489c0031d38SFabiano Rosas echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak 2490c0031d38SFabiano Rosasfi 2491c0031d38SFabiano Rosas) 24922038f8c8SPaolo Bonzini 2493a5665051SPaolo Bonziniif test "$skip_meson" = no; then 2494fc929892SMarc-André Lureau cross="config-meson.cross.new" 2495fc929892SMarc-André Lureau meson_quote() { 2496ac7ebcc5SPaolo Bonzini test $# = 0 && return 249747b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 2498fc929892SMarc-André Lureau } 2499fc929892SMarc-André Lureau 2500fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 2501fc929892SMarc-André Lureau echo "[properties]" >> $cross 2502d1d5e9eeSAlex Bennée 2503d1d5e9eeSAlex Bennée # unroll any custom device configs 2504d1d5e9eeSAlex Bennée for a in $device_archs; do 2505d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 2506d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 2507d1d5e9eeSAlex Bennée done 2508d1d5e9eeSAlex Bennée 250947b30835SPaolo Bonzini echo "[built-in options]" >> $cross 2510a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 2511a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 2512e910c7d9SPhilippe Mathieu-Daudé test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross 2513a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 2514a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 2515fc929892SMarc-André Lureau echo "[binaries]" >> $cross 25164dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 25174dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 25184dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 251947b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 252047b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 252147b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 252247b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 2523e8178514SPaolo Bonzini if has $sdl2_config; then 252447b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 2525e8178514SPaolo Bonzini fi 252647b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 2527158bb224SKonstantin Kostiuk echo "widl = [$(meson_quote $widl)]" >> $cross 252847b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 2529f9f0e617SAndrey Drobyshev echo "windmc = [$(meson_quote $windmc)]" >> $cross 25303812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 2531fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 2532fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 2533ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 2534823eb013SPaolo Bonzini case "$cpu" in 2535f6bca9dfSJoelle van Dyne i386) 2536fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 2537fc929892SMarc-André Lureau ;; 2538fc929892SMarc-André Lureau *) 2539823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 2540fc929892SMarc-André Lureau ;; 2541fc929892SMarc-André Lureau esac 2542fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 2543fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 2544fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 2545fc929892SMarc-André Lureau else 2546fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 2547fc929892SMarc-André Lureau fi 2548fc929892SMarc-André Lureau else 2549fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 2550fc929892SMarc-André Lureau fi 2551fc929892SMarc-André Lureau mv $cross config-meson.cross 2552fc929892SMarc-André Lureau 2553a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 25540a31e3a0SPaolo Bonzini 25550a31e3a0SPaolo Bonzini # Built-in options 25560a31e3a0SPaolo Bonzini test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir" 25570a31e3a0SPaolo Bonzini test "$default_feature" = no && meson_option_add -Dauto_features=disabled 25580a31e3a0SPaolo Bonzini test "$pie" = no && meson_option_add -Db_pie=false 25590a31e3a0SPaolo Bonzini test "$werror" = yes && meson_option_add -Dwerror=true 25600a31e3a0SPaolo Bonzini 25610a31e3a0SPaolo Bonzini # QEMU options 25620a31e3a0SPaolo Bonzini test "$cfi" != false && meson_option_add "-Dcfi=$cfi" 25630a31e3a0SPaolo Bonzini test "$fdt" != auto && meson_option_add "-Dfdt=$fdt" 25640a31e3a0SPaolo Bonzini test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE" 25650a31e3a0SPaolo Bonzini test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix" 25660a31e3a0SPaolo Bonzini test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd" 25670a31e3a0SPaolo Bonzini test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg" 256855116968SJagannathan Raman test "$vfio_user_server" != auto && meson_option_add "-Dvfio_user_server=$vfio_user_server" 256961d63097SPaolo Bonzini run_meson() { 25700a31e3a0SPaolo Bonzini NINJA=$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path" 257161d63097SPaolo Bonzini } 257261d63097SPaolo Bonzini eval run_meson $meson_options 2573a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 2574a5665051SPaolo Bonzini error_exit "meson setup failed" 2575a5665051SPaolo Bonzini fi 2576a5665051SPaolo Bonzinifi 2577a5665051SPaolo Bonzini 2578dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 2579dc655404SMichael S. Tsirkincat <<EOD >config.status 2580dc655404SMichael S. Tsirkin#!/bin/sh 2581dc655404SMichael S. Tsirkin# Generated by configure. 2582dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 2583dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 2584dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 2585dc655404SMichael S. TsirkinEOD 2586e811da7fSDaniel P. Berrangé 2587e811da7fSDaniel P. Berrangépreserve_env() { 2588e811da7fSDaniel P. Berrangé envname=$1 2589e811da7fSDaniel P. Berrangé 2590e811da7fSDaniel P. Berrangé eval envval=\$$envname 2591e811da7fSDaniel P. Berrangé 2592e811da7fSDaniel P. Berrangé if test -n "$envval" 2593e811da7fSDaniel P. Berrangé then 2594e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 2595e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 2596e811da7fSDaniel P. Berrangé else 2597e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 2598e811da7fSDaniel P. Berrangé fi 2599e811da7fSDaniel P. Berrangé} 2600e811da7fSDaniel P. Berrangé 2601e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 2602e811da7fSDaniel P. Berrangé# features/build target configure will detect 2603e811da7fSDaniel P. Berrangépreserve_env AR 2604e811da7fSDaniel P. Berrangépreserve_env AS 2605e811da7fSDaniel P. Berrangépreserve_env CC 26068009da03SPaolo Bonzinipreserve_env CFLAGS 2607e811da7fSDaniel P. Berrangépreserve_env CXX 26088009da03SPaolo Bonzinipreserve_env CXXFLAGS 2609e811da7fSDaniel P. Berrangépreserve_env LD 26108009da03SPaolo Bonzinipreserve_env LDFLAGS 2611e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 2612e811da7fSDaniel P. Berrangépreserve_env MAKE 2613e811da7fSDaniel P. Berrangépreserve_env NM 2614b5569e5bSPaolo Bonzinipreserve_env OBJCFLAGS 2615e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 2616e811da7fSDaniel P. Berrangépreserve_env PATH 2617e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 2618e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 2619e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 2620e811da7fSDaniel P. Berrangépreserve_env PYTHON 2621954ed68fSPaolo Bonzinipreserve_env QEMU_GA_MANUFACTURER 2622954ed68fSPaolo Bonzinipreserve_env QEMU_GA_DISTRO 2623954ed68fSPaolo Bonzinipreserve_env QEMU_GA_VERSION 2624e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 2625e811da7fSDaniel P. Berrangépreserve_env SMBD 2626e811da7fSDaniel P. Berrangépreserve_env STRIP 2627158bb224SKonstantin Kostiukpreserve_env WIDL 2628e811da7fSDaniel P. Berrangépreserve_env WINDRES 2629f9f0e617SAndrey Drobyshevpreserve_env WINDMC 2630e811da7fSDaniel P. Berrangé 2631dc655404SMichael S. Tsirkinprintf "exec" >>config.status 2632a5665051SPaolo Bonzinifor i in "$0" "$@"; do 2633835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 2634a5665051SPaolo Bonzinidone 2635cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 2636dc655404SMichael S. Tsirkinchmod +x config.status 2637dc655404SMichael S. Tsirkin 26388cd05ab6SPeter Maydellrm -r "$TMPDIR1" 2639