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, 75b507233SPaolo Bonzini# just as autoconf does. Unlike autoconf, we assume that unset exists. 85b507233SPaolo Bonziniunset CLICOLOR_FORCE GREP_OPTIONS BASH_ENV ENV MAIL MAILPATH CDPATH 999519e67SCornelia Huck 105e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests! 115e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes 125e4dfd3dSJohn Snow 13dedad027SDaniel P. Berrangé# make source path absolute 14dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd) 15dedad027SDaniel P. Berrangé 16dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path" 17dedad027SDaniel P. Berrangéthen 18dedad027SDaniel P. Berrangé echo "Using './build' as the directory for build output" 19dedad027SDaniel P. Berrangé 20dedad027SDaniel P. Berrangé MARKER=build/auto-created-by-configure 21dedad027SDaniel P. Berrangé 22dedad027SDaniel P. Berrangé if test -e build 23dedad027SDaniel P. Berrangé then 24dedad027SDaniel P. Berrangé if test -f $MARKER 25dedad027SDaniel P. Berrangé then 26dedad027SDaniel P. Berrangé rm -rf build 27dedad027SDaniel P. Berrangé else 28dedad027SDaniel P. Berrangé echo "ERROR: ./build dir already exists and was not previously created by configure" 29dedad027SDaniel P. Berrangé exit 1 30dedad027SDaniel P. Berrangé fi 31dedad027SDaniel P. Berrangé fi 32dedad027SDaniel P. Berrangé 33f160a5b2SDinah Baum if ! mkdir build || ! touch $MARKER 34f160a5b2SDinah Baum then 35f160a5b2SDinah Baum echo "ERROR: Could not create ./build directory. Check the permissions on" 36f160a5b2SDinah Baum echo "your source directory, or try doing an out-of-tree build." 37f160a5b2SDinah Baum exit 1 38f160a5b2SDinah Baum fi 39dedad027SDaniel P. Berrangé 40dedad027SDaniel P. Berrangé cat > GNUmakefile <<'EOF' 41dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree 42dedad027SDaniel P. Berrangé# 'make' command invocation 43dedad027SDaniel P. Berrangé 44dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),) 45dedad027SDaniel P. Berrangérecurse: all 46dedad027SDaniel P. Berrangéendif 47dedad027SDaniel P. Berrangé 48dedad027SDaniel P. Berrangé.NOTPARALLEL: % 49dedad027SDaniel P. Berrangé%: force 50dedad027SDaniel P. Berrangé @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...' 51dedad027SDaniel P. Berrangé @$(MAKE) -C build -f Makefile $(MAKECMDGOALS) 52dedad027SDaniel P. Berrangé @if test "$(MAKECMDGOALS)" = "distclean" && \ 53dedad027SDaniel P. Berrangé test -e build/auto-created-by-configure ; \ 54dedad027SDaniel P. Berrangé then \ 55dedad027SDaniel P. Berrangé rm -rf build GNUmakefile ; \ 56dedad027SDaniel P. Berrangé fi 57dedad027SDaniel P. Berrangéforce: ; 58dedad027SDaniel P. Berrangé.PHONY: force 59dedad027SDaniel P. BerrangéGNUmakefile: ; 60dedad027SDaniel P. Berrangé 61dedad027SDaniel P. BerrangéEOF 62dedad027SDaniel P. Berrangé cd build 6364708615SPeter Maydell exec "$source_path/configure" "$@" 64dedad027SDaniel P. Berrangéfi 65dedad027SDaniel P. Berrangé 668cd05ab6SPeter Maydell# Temporary directory used for files created while 678cd05ab6SPeter Maydell# configure runs. Since it is in the build directory 688cd05ab6SPeter Maydell# we can safely blow away any previous version of it 698cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete 708cd05ab6SPeter Maydell# it when configure exits.) 718cd05ab6SPeter MaydellTMPDIR1="config-temp" 728cd05ab6SPeter Maydellrm -rf "${TMPDIR1}" 73563661c0SPeter Maydellif ! mkdir -p "${TMPDIR1}"; then 748cd05ab6SPeter Maydell echo "ERROR: failed to create temporary directory" 758cd05ab6SPeter Maydell exit 1 767d13299dSbellardfi 777d13299dSbellard 788cd05ab6SPeter MaydellTMPB="qemu-conf" 798cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c" 8066518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o" 818cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe" 827d13299dSbellard 83da1d85e3SGerd Hoffmannrm -f config.log 849ac81bbbSmalc 85b48e3611SPeter Maydell# Print a helpful header at the top of config.log 86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log 87979ae168SPeter Maydellprintf "# Configured with:" >> config.log 887f788779SAlex Bennée# repeat the invocation to log and stdout for CI 897f788779SAlex Bennéeinvoke=$(printf " '%s'" "$0" "$@") 907f788779SAlex Bennéetest -n "$GITLAB_CI" && echo "configuring with: $invoke" 917f788779SAlex Bennée{ echo "$invoke"; echo; echo "#"; } >> config.log 92b48e3611SPeter Maydell 93835af899SPaolo Bonziniquote_sh() { 94835af899SPaolo Bonzini printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," 95835af899SPaolo Bonzini} 96835af899SPaolo Bonzini 97d880a3baSPaolo Bonziniprint_error() { 98d880a3baSPaolo Bonzini (echo 9976ad07a4SPeter Maydell echo "ERROR: $1" 10076ad07a4SPeter Maydell while test -n "$2"; do 10176ad07a4SPeter Maydell echo " $2" 10276ad07a4SPeter Maydell shift 10376ad07a4SPeter Maydell done 104d880a3baSPaolo Bonzini echo) >&2 105d880a3baSPaolo Bonzini} 106d880a3baSPaolo Bonzini 107d880a3baSPaolo Bonzinierror_exit() { 108d880a3baSPaolo Bonzini print_error "$@" 10976ad07a4SPeter Maydell exit 1 11076ad07a4SPeter Maydell} 11176ad07a4SPeter Maydell 1129c83ffd8SPeter Maydelldo_compiler() { 1139c83ffd8SPeter Maydell # Run the compiler, capturing its output to the log. First argument 1149c83ffd8SPeter Maydell # is compiler binary to execute. 115b3b5472dSPeter Maydell compiler="$1" 116cd362defSPaolo Bonzini shift 117cd362defSPaolo Bonzini if test -n "$BASH_VERSION"; then eval ' 118cd362defSPaolo Bonzini echo >>config.log " 119cd362defSPaolo Bonzinifuncs: ${FUNCNAME[*]} 120cd362defSPaolo Bonzinilines: ${BASH_LINENO[*]}" 121cd362defSPaolo Bonzini '; fi 122cd362defSPaolo Bonzini echo $compiler "$@" >> config.log 123cd362defSPaolo Bonzini $compiler "$@" >> config.log 2>&1 || return $? 124cd362defSPaolo Bonzini} 125cd362defSPaolo Bonzini 1269c83ffd8SPeter Maydelldo_cc() { 127d0016b86SPaolo Bonzini do_compiler "$cc" $CPU_CFLAGS "$@" 1289c83ffd8SPeter Maydell} 1299c83ffd8SPeter Maydell 13052166aa0SJuan Quintelacompile_object() { 131fd0e6053SJohn Snow local_cflags="$1" 132a988b4c5SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -c -o $TMPO $TMPC 13352166aa0SJuan Quintela} 13452166aa0SJuan Quintela 13552166aa0SJuan Quintelacompile_prog() { 13652166aa0SJuan Quintela local_cflags="$1" 13752166aa0SJuan Quintela local_ldflags="$2" 138a988b4c5SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $local_cflags -o $TMPE $TMPC \ 139a988b4c5SPaolo Bonzini $LDFLAGS $EXTRA_LDFLAGS $local_ldflags 14052166aa0SJuan Quintela} 14152166aa0SJuan Quintela 14211568d6dSPaolo Bonzini# symbolically link $1 to $2. Portable version of "ln -sf". 14311568d6dSPaolo Bonzinisymlink() { 14472b8b5a1SStefan Weil rm -rf "$2" 145ec5b06d7SAnthony Liguori mkdir -p "$(dirname "$2")" 14672b8b5a1SStefan Weil ln -s "$1" "$2" 14711568d6dSPaolo Bonzini} 14811568d6dSPaolo Bonzini 1490dba6195SLoïc Minier# check whether a command is available to this shell (may be either an 1500dba6195SLoïc Minier# executable or a builtin) 1510dba6195SLoïc Minierhas() { 1520dba6195SLoïc Minier type "$1" >/dev/null 2>&1 1530dba6195SLoïc Minier} 1540dba6195SLoïc Minier 1550a01d76fSMarc-André Lureauversion_ge () { 1562df52b9bSAlex Bennée local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') 1572df52b9bSAlex Bennée local_ver2=$(echo "$2" | tr . ' ') 1580a01d76fSMarc-André Lureau while true; do 1590a01d76fSMarc-André Lureau set x $local_ver1 1600a01d76fSMarc-André Lureau local_first=${2-0} 161c44a33e2SStefano Garzarella # 'shift 2' if $2 is set, or 'shift' if $2 is not set 162c44a33e2SStefano Garzarella shift ${2:+2} 1630a01d76fSMarc-André Lureau local_ver1=$* 1640a01d76fSMarc-André Lureau set x $local_ver2 1650a01d76fSMarc-André Lureau # the second argument finished, the first must be greater or equal 1660a01d76fSMarc-André Lureau test $# = 1 && return 0 1670a01d76fSMarc-André Lureau test $local_first -lt $2 && return 1 1680a01d76fSMarc-André Lureau test $local_first -gt $2 && return 0 169c44a33e2SStefano Garzarella shift ${2:+2} 1700a01d76fSMarc-André Lureau local_ver2=$* 1710a01d76fSMarc-André Lureau done 1720a01d76fSMarc-André Lureau} 1730a01d76fSMarc-André Lureau 1744ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; 1754ace32e2SAntonio Ospitethen 1764ace32e2SAntonio Ospite error_exit "main directory cannot contain spaces nor colons" 1774ace32e2SAntonio Ospitefi 1784ace32e2SAntonio Ospite 17913cf376cSPaolo Bonzini# parse CC options first; some compiler tests are used to establish 18013cf376cSPaolo Bonzini# some defaults, based on the host environment 18113cf376cSPaolo Bonzini 18214211825SAntonio Ospite# default parameters 18342ede11aSAlex Bennéecontainer_engine="auto" 1842ff6b91eSJuan Quintelacpu="" 1853812c0c4SJoelle van Dynecross_compile="no" 1867d13299dSbellardcross_prefix="" 187e49d021eSPeter Maydellhost_cc="cc" 18813cf376cSPaolo BonziniEXTRA_CFLAGS="" 18913cf376cSPaolo BonziniEXTRA_CXXFLAGS="" 19013cf376cSPaolo BonziniEXTRA_OBJCFLAGS="" 19113cf376cSPaolo BonziniEXTRA_LDFLAGS="" 192377529c0SPaolo Bonzini 193377529c0SPaolo Bonzini# Default value for a variable defining feature "foo". 194377529c0SPaolo Bonzini# * foo="no" feature will only be used if --enable-foo arg is given 195377529c0SPaolo Bonzini# * foo="" feature will be searched for, and if found, will be used 196377529c0SPaolo Bonzini# unless --disable-foo is given 197377529c0SPaolo Bonzini# * foo="yes" this value will only be set by --enable-foo flag. 198377529c0SPaolo Bonzini# feature will searched for, 199377529c0SPaolo Bonzini# if not found, configure exits with error 200377529c0SPaolo Bonzini# 201377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args. 202377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it 203377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found. 204c87ea116SAlex Bennéedefault_feature="" 205c87ea116SAlex Bennée 206ac0df51dSaliguorifor opt do 20789138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 208ac0df51dSaliguori case "$opt" in 209ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 2103812c0c4SJoelle van Dyne cross_compile="yes" 211ac0df51dSaliguori ;; 2123d8df640SPaolo Bonzini --cc=*) CC="$optarg" 213ac0df51dSaliguori ;; 21483f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 21583f73fceSTomoki Sekiyama ;; 216c0c34c91SPeter Maydell --objcc=*) objcc="$optarg" 217c0c34c91SPeter Maydell ;; 2182ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 2192ff6b91eSJuan Quintela ;; 220a2866660SPaolo Bonzini --extra-cflags=*) 221a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 222a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 223e910c7d9SPhilippe Mathieu-Daudé EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 224e2a2ed06SJuan Quintela ;; 225a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 22611cde1c8SBruno Dominguez ;; 227e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 228e910c7d9SPhilippe Mathieu-Daudé ;; 229a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 230e2a2ed06SJuan Quintela ;; 231d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 232d75402b5SAlex Bennée ;; 233479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 234d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 235d422b2bcSAlex Bennée ;; 236d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 237d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 238d75402b5SAlex Bennée ;; 2395adb43beSPaolo Bonzini --cross-prefix-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-prefix-FOO option" 2405adb43beSPaolo Bonzini ;; 2415adb43beSPaolo Bonzini --cross-prefix-*) cc_arch=${opt#--cross-prefix-}; cc_arch=${cc_arch%%=*} 2425adb43beSPaolo Bonzini eval "cross_prefix_${cc_arch}=\$optarg" 2435adb43beSPaolo Bonzini ;; 24413cf376cSPaolo Bonzini --without-default-features) default_feature="no" 24513cf376cSPaolo Bonzini ;; 246ac0df51dSaliguori esac 247ac0df51dSaliguoridone 248ac0df51dSaliguori 249bafe78adSPaolo Bonzinidefault_cflags='-O2 -g' 25013cf376cSPaolo Bonzinigit_submodules_action="update" 25113cf376cSPaolo Bonzinigit="git" 25213cf376cSPaolo Bonzinidocs="auto" 25313cf376cSPaolo BonziniEXESUF="" 25413cf376cSPaolo Bonziniprefix="/usr/local" 25513cf376cSPaolo Bonziniqemu_suffix="qemu" 25624f9c07aSPaolo Bonzinisystem="yes" 25713cf376cSPaolo Bonzinilinux_user="" 25813cf376cSPaolo Bonzinibsd_user="" 25913cf376cSPaolo Bonziniplugins="$default_feature" 2602a5919abSPaolo Bonzinisubdirs="" 26113cf376cSPaolo Bonzinininja="" 26213cf376cSPaolo Bonzinipython= 263ac4ccac7SPaolo Bonzinidownload="enabled" 26413cf376cSPaolo Bonzinibindir="bin" 26513cf376cSPaolo Bonziniskip_meson=no 26613cf376cSPaolo Bonziniuse_containers="yes" 26713cf376cSPaolo Bonzinigdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 26813cf376cSPaolo Bonzinigdb_arches="" 26913cf376cSPaolo Bonziniwerror="" 27013cf376cSPaolo Bonzini 27113cf376cSPaolo Bonzini# Don't accept a target_list environment variable. 27213cf376cSPaolo Bonziniunset target_list 27313cf376cSPaolo Bonziniunset target_list_exclude 27413cf376cSPaolo Bonzini 27513cf376cSPaolo Bonzini# The following Meson options are handled manually (still they 27613cf376cSPaolo Bonzini# are included in the automatically generated help message) 2772019cabfSPaolo Bonzini# because they automatically enable/disable other options 27813cf376cSPaolo Bonzinitcg="auto" 27913cf376cSPaolo Bonzinicfi="false" 28013cf376cSPaolo Bonzini 2812019cabfSPaolo Bonzini# Meson has PIE as a boolean rather than enabled/disabled/auto, 2822019cabfSPaolo Bonzini# and we also need to check for -static-pie before Meson runs 2832019cabfSPaolo Bonzini# which requires knowing whether --static is enabled. 28413cf376cSPaolo Bonzinipie="" 28513cf376cSPaolo Bonzinistatic="no" 28613cf376cSPaolo Bonzini 287e49d021eSPeter Maydell# Preferred compiler: 288e49d021eSPeter Maydell# ${CC} (if set) 289e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 290e49d021eSPeter Maydell# system compiler 291e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 2923c7ee49bSPaolo Bonzini cc="cc" 293e49d021eSPeter Maydellelse 294b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 295e49d021eSPeter Maydellfi 296e49d021eSPeter Maydell 29783f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 29883f73fceSTomoki Sekiyama cxx="c++" 29983f73fceSTomoki Sekiyamaelse 30083f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 30183f73fceSTomoki Sekiyamafi 30283f73fceSTomoki Sekiyama 303c0c34c91SPeter Maydell# Preferred ObjC compiler: 304c0c34c91SPeter Maydell# $objcc (if set, i.e. via --objcc option) 305c0c34c91SPeter Maydell# ${cross_prefix}clang (if cross-prefix specified) 306c0c34c91SPeter Maydell# clang (if available) 307c0c34c91SPeter Maydell# $cc 308c0c34c91SPeter Maydellif test -z "${objcc}${cross_prefix}"; then 309c0c34c91SPeter Maydell if has clang; then 310c0c34c91SPeter Maydell objcc=clang 311c0c34c91SPeter Maydell else 312c0c34c91SPeter Maydell objcc="$cc" 313c0c34c91SPeter Maydell fi 314c0c34c91SPeter Maydellelse 315c0c34c91SPeter Maydell objcc="${objcc-${cross_prefix}clang}" 316c0c34c91SPeter Maydellfi 317c0c34c91SPeter Maydell 318b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 319cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 3205f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 321b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 322b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 3239f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 3244852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 32535acbb30SPaolo Bonzinismbd="$SMBD" 326b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 327158bb224SKonstantin Kostiukwidl="${WIDL-${cross_prefix}widl}" 328b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 329f9f0e617SAndrey Drobyshevwindmc="${WINDMC-${cross_prefix}windmc}" 330877c5567SPaolo Bonzinipkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}" 33147c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 332ac0df51dSaliguori 333ac0df51dSaliguoricheck_define() { 334ac0df51dSaliguoricat > $TMPC <<EOF 335ac0df51dSaliguori#if !defined($1) 336fd786e1aSPeter Maydell#error $1 not defined 337ac0df51dSaliguori#endif 338ac0df51dSaliguoriint main(void) { return 0; } 339ac0df51dSaliguoriEOF 34052166aa0SJuan Quintela compile_object 341ac0df51dSaliguori} 342ac0df51dSaliguori 34393b25869SJohn Snowwrite_c_skeleton() { 34493b25869SJohn Snow cat > $TMPC <<EOF 34593b25869SJohn Snowint main(void) { return 0; } 34693b25869SJohn SnowEOF 34793b25869SJohn Snow} 34893b25869SJohn Snow 349bbea4050SPeter Maydellif check_define __linux__ ; then 350ba7c60c2SPaolo Bonzini targetos=linux 351bbea4050SPeter Maydellelif check_define _WIN32 ; then 352ba7c60c2SPaolo Bonzini targetos=windows 353bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 354ba7c60c2SPaolo Bonzini targetos=openbsd 355bbea4050SPeter Maydellelif check_define __sun__ ; then 356ba7c60c2SPaolo Bonzini targetos=sunos 357bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 358ba7c60c2SPaolo Bonzini targetos=haiku 359951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 360ba7c60c2SPaolo Bonzini targetos=freebsd 361951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 362ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 363951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 364ba7c60c2SPaolo Bonzini targetos=dragonfly 365951fedfcSPeter Maydellelif check_define __NetBSD__; then 366ba7c60c2SPaolo Bonzini targetos=netbsd 367951fedfcSPeter Maydellelif check_define __APPLE__; then 368ba7c60c2SPaolo Bonzini targetos=darwin 369bbea4050SPeter Maydellelse 370951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 371951fedfcSPeter Maydell # might be going to just print the --help text, or it might 372951fedfcSPeter Maydell # be the result of a missing compiler. 373ba7c60c2SPaolo Bonzini targetos=bogus 374bbea4050SPeter Maydellfi 375bbea4050SPeter Maydell 3762ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 3772ff6b91eSJuan Quintela # command line argument 3782ff6b91eSJuan Quintela : 3792ff6b91eSJuan Quintelaelif check_define __i386__ ; then 380ac0df51dSaliguori cpu="i386" 381ac0df51dSaliguorielif check_define __x86_64__ ; then 382c72b26ecSRichard Henderson if check_define __ILP32__ ; then 383c72b26ecSRichard Henderson cpu="x32" 384c72b26ecSRichard Henderson else 385ac0df51dSaliguori cpu="x86_64" 386c72b26ecSRichard Henderson fi 3873aa9bd6cSblueswir1elif check_define __sparc__ ; then 3883aa9bd6cSblueswir1 if check_define __arch64__ ; then 3893aa9bd6cSblueswir1 cpu="sparc64" 3903aa9bd6cSblueswir1 else 3913aa9bd6cSblueswir1 cpu="sparc" 3923aa9bd6cSblueswir1 fi 393fdf7ed96Smalcelif check_define _ARCH_PPC ; then 394fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 395f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 396f8378accSRichard Henderson cpu="ppc64le" 397f8378accSRichard Henderson else 398fdf7ed96Smalc cpu="ppc64" 399f8378accSRichard Henderson fi 400ac0df51dSaliguori else 401fdf7ed96Smalc cpu="ppc" 402fdf7ed96Smalc fi 403afa05235SAurelien Jarnoelif check_define __mips__ ; then 404afa05235SAurelien Jarno cpu="mips" 405d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 406d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 407d66ed0eaSAurelien Jarno cpu="s390x" 408d66ed0eaSAurelien Jarno else 409d66ed0eaSAurelien Jarno cpu="s390" 410d66ed0eaSAurelien Jarno fi 411c4f80543SAlistair Franciselif check_define __riscv ; then 412e3e477c3SPhilippe Mathieu-Daudé if check_define _LP64 ; then 413e3e477c3SPhilippe Mathieu-Daudé cpu="riscv64" 414e3e477c3SPhilippe Mathieu-Daudé else 415e3e477c3SPhilippe Mathieu-Daudé cpu="riscv32" 416e3e477c3SPhilippe Mathieu-Daudé fi 41721d89f84SPeter Maydellelif check_define __arm__ ; then 41821d89f84SPeter Maydell cpu="arm" 4191f080313SClaudio Fontanaelif check_define __aarch64__ ; then 4201f080313SClaudio Fontana cpu="aarch64" 421dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 422dfcf900bSWANG Xuerui cpu="loongarch64" 423fdf7ed96Smalcelse 424f9c77801SPaolo Bonzini # Using uname is really broken, but it is just a fallback for architectures 425f9c77801SPaolo Bonzini # that are going to use TCI anyway 42689138857SStefan Weil cpu=$(uname -m) 427f9c77801SPaolo Bonzini echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'" 428ac0df51dSaliguorifi 429ac0df51dSaliguori 430971fac27SPaolo Bonzini# Normalise host CPU name to the values used by Meson cross files and in source 431971fac27SPaolo Bonzini# directories, and set multilib cflags. The canonicalization isn't really 432971fac27SPaolo Bonzini# necessary, because the architectures that we check for should not hit the 433971fac27SPaolo Bonzini# 'uname -m' case, but better safe than sorry in case --cpu= is used. 434971fac27SPaolo Bonzini# 435359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 436971fac27SPaolo Bonzini# Please keep it sorted and synchronized with meson.build's host_arch. 437971fac27SPaolo Bonzinihost_arch= 438971fac27SPaolo Bonzinilinux_arch= 4397d13299dSbellardcase "$cpu" in 440971fac27SPaolo Bonzini aarch64) 441971fac27SPaolo Bonzini host_arch=aarch64 442971fac27SPaolo Bonzini linux_arch=arm64 443971fac27SPaolo Bonzini ;; 444971fac27SPaolo Bonzini 445e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 446971fac27SPaolo Bonzini cpu=arm 447971fac27SPaolo Bonzini host_arch=arm 448971fac27SPaolo Bonzini linux_arch=arm 449971fac27SPaolo Bonzini ;; 450e4da0e39SPaolo Bonzini 451f9c77801SPaolo Bonzini i386|i486|i586|i686) 45297a847bcSbellard cpu="i386" 453971fac27SPaolo Bonzini host_arch=i386 454971fac27SPaolo Bonzini linux_arch=x86 455971fac27SPaolo Bonzini CPU_CFLAGS="-m32" 456971fac27SPaolo Bonzini ;; 457971fac27SPaolo Bonzini 458971fac27SPaolo Bonzini loongarch*) 459971fac27SPaolo Bonzini cpu=loongarch64 460971fac27SPaolo Bonzini host_arch=loongarch64 461971fac27SPaolo Bonzini ;; 462971fac27SPaolo Bonzini 463971fac27SPaolo Bonzini mips64*) 464971fac27SPaolo Bonzini cpu=mips64 465971fac27SPaolo Bonzini host_arch=mips 466971fac27SPaolo Bonzini linux_arch=mips 467971fac27SPaolo Bonzini ;; 468971fac27SPaolo Bonzini mips*) 469971fac27SPaolo Bonzini cpu=mips 470971fac27SPaolo Bonzini host_arch=mips 471971fac27SPaolo Bonzini linux_arch=mips 472971fac27SPaolo Bonzini ;; 473971fac27SPaolo Bonzini 474971fac27SPaolo Bonzini ppc) 475971fac27SPaolo Bonzini host_arch=ppc 476971fac27SPaolo Bonzini linux_arch=powerpc 477971fac27SPaolo Bonzini CPU_CFLAGS="-m32" 478971fac27SPaolo Bonzini ;; 479971fac27SPaolo Bonzini ppc64) 480971fac27SPaolo Bonzini host_arch=ppc64 481971fac27SPaolo Bonzini linux_arch=powerpc 482971fac27SPaolo Bonzini CPU_CFLAGS="-m64 -mbig-endian" 483971fac27SPaolo Bonzini ;; 484971fac27SPaolo Bonzini ppc64le) 485971fac27SPaolo Bonzini cpu=ppc64 486971fac27SPaolo Bonzini host_arch=ppc64 487971fac27SPaolo Bonzini linux_arch=powerpc 488971fac27SPaolo Bonzini CPU_CFLAGS="-m64 -mlittle-endian" 489971fac27SPaolo Bonzini ;; 490971fac27SPaolo Bonzini 491971fac27SPaolo Bonzini riscv32 | riscv64) 492971fac27SPaolo Bonzini host_arch=riscv 493971fac27SPaolo Bonzini linux_arch=riscv 494971fac27SPaolo Bonzini ;; 495971fac27SPaolo Bonzini 496971fac27SPaolo Bonzini s390) 497971fac27SPaolo Bonzini linux_arch=s390 498971fac27SPaolo Bonzini CPU_CFLAGS="-m31" 499971fac27SPaolo Bonzini ;; 500971fac27SPaolo Bonzini s390x) 501971fac27SPaolo Bonzini host_arch=s390x 502971fac27SPaolo Bonzini linux_arch=s390 503971fac27SPaolo Bonzini CPU_CFLAGS="-m64" 504971fac27SPaolo Bonzini ;; 505971fac27SPaolo Bonzini 506971fac27SPaolo Bonzini sparc|sun4[cdmuv]) 507971fac27SPaolo Bonzini cpu=sparc 508971fac27SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" 509971fac27SPaolo Bonzini ;; 510971fac27SPaolo Bonzini sparc64) 511971fac27SPaolo Bonzini host_arch=sparc64 512971fac27SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" 513971fac27SPaolo Bonzini ;; 514971fac27SPaolo Bonzini 515e4da0e39SPaolo Bonzini x32) 5164da270beSPaolo Bonzini cpu="x86_64" 517971fac27SPaolo Bonzini host_arch=x86_64 518971fac27SPaolo Bonzini linux_arch=x86 519971fac27SPaolo Bonzini CPU_CFLAGS="-mx32" 520971fac27SPaolo Bonzini ;; 521aaa5fa14Saurel32 x86_64|amd64) 522aaa5fa14Saurel32 cpu="x86_64" 523971fac27SPaolo Bonzini host_arch=x86_64 524971fac27SPaolo Bonzini linux_arch=x86 525e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 526e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 527e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 528971fac27SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" 529971fac27SPaolo Bonzini ;; 5307d13299dSbellardesac 531e2d52ad3SJuan Quintela 532971fac27SPaolo Bonziniif test -n "$host_arch" && { 533971fac27SPaolo Bonzini ! test -d "$source_path/linux-user/include/host/$host_arch" || 534971fac27SPaolo Bonzini ! test -d "$source_path/common-user/host/$host_arch"; }; then 535971fac27SPaolo Bonzini error_exit "linux-user/include/host/$host_arch does not exist." \ 536971fac27SPaolo Bonzini "This is a bug in the configure script, please report it." 537971fac27SPaolo Bonzinifi 538971fac27SPaolo Bonziniif test -n "$linux_arch" && ! test -d "$source_path/linux-headers/asm-$linux_arch"; then 539971fac27SPaolo Bonzini error_exit "linux-headers/asm-$linux_arch does not exist." \ 540971fac27SPaolo Bonzini "This is a bug in the configure script, please report it." 541971fac27SPaolo Bonzinifi 542971fac27SPaolo Bonzini 543fee6d412SJohn Snowcheck_py_version() { 544ca056f44SPaolo Bonzini # We require python >= 3.8. 545fee6d412SJohn Snow # NB: a True python conditional creates a non-zero return code (Failure) 546ca056f44SPaolo Bonzini "$1" -c 'import sys; sys.exit(sys.version_info < (3,8))' 547fee6d412SJohn Snow} 548fee6d412SJohn Snow 549fee6d412SJohn Snowfirst_python= 550fee6d412SJohn Snowif test -z "${PYTHON}"; then 551fee6d412SJohn Snow # A bare 'python' is traditionally python 2.x, but some distros 552fee6d412SJohn Snow # have it as python 3.x, so check in both places. 55319a39e27SJohn Snow for binary in python3 python python3.12 python3.11 \ 55419a39e27SJohn Snow python3.10 python3.9 python3.8; do 555fee6d412SJohn Snow if has "$binary"; then 55695c5f2deSPaolo Bonzini python=$(command -v "$binary") 557fee6d412SJohn Snow if check_py_version "$python"; then 558fee6d412SJohn Snow # This one is good. 559fee6d412SJohn Snow first_python= 560faf44142SDaniel P. Berrangé break 561fee6d412SJohn Snow else 562fee6d412SJohn Snow first_python=$python 563fee6d412SJohn Snow fi 564faf44142SDaniel P. Berrangé fi 565faf44142SDaniel P. Berrangé done 566fee6d412SJohn Snowelse 567fee6d412SJohn Snow # Same as above, but only check the environment variable. 568fee6d412SJohn Snow has "${PYTHON}" || error_exit "The PYTHON environment variable does not point to an executable" 569fee6d412SJohn Snow python=$(command -v "$PYTHON") 570fee6d412SJohn Snow if check_py_version "$python"; then 571fee6d412SJohn Snow # This one is good. 572fee6d412SJohn Snow first_python= 573fee6d412SJohn Snow else 574fee6d412SJohn Snow first_python=$first_python 575fee6d412SJohn Snow fi 576fee6d412SJohn Snowfi 577903458c8SMarkus Armbruster 57839d87c8cSAlex Bennée# Check for ancillary tools used in testing 57939d87c8cSAlex Bennéegenisoimage= 5803df437c7SAlex Bennéefor binary in genisoimage mkisofs 58139d87c8cSAlex Bennéedo 58239d87c8cSAlex Bennée if has $binary 58339d87c8cSAlex Bennée then 58439d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 58539d87c8cSAlex Bennée break 58639d87c8cSAlex Bennée fi 58739d87c8cSAlex Bennéedone 58839d87c8cSAlex Bennée 58980100e26SPaolo Bonziniif test "$targetos" = "windows" ; then 5903457a3f8SJuan Quintela EXESUF=".exe" 591d17f305aSPaolo Bonzini prefix="/qemu" 592c09c1ce7SPaolo Bonzini bindir="" 59377433a5fSMarc-André Lureau qemu_suffix="" 5943457a3f8SJuan Quintelafi 5953457a3f8SJuan Quintela 5968154f5e6SAkihiko Odakimeson_option_build_array() { 5978154f5e6SAkihiko Odaki printf '[' 598c5cfdabaSPeter Maydell (if test "$targetos" = windows; then 5998154f5e6SAkihiko Odaki IFS=\; 6008154f5e6SAkihiko Odaki else 6018154f5e6SAkihiko Odaki IFS=: 6028154f5e6SAkihiko Odaki fi 6038154f5e6SAkihiko Odaki for e in $1; do 60465842b03SPeter Maydell printf '"""' 60565842b03SPeter Maydell # backslash escape any '\' and '"' characters 60665842b03SPeter Maydell printf "%s" "$e" | sed -e 's/\([\"]\)/\\\1/g' 60765842b03SPeter Maydell printf '""",' 6088154f5e6SAkihiko Odaki done) 6098154f5e6SAkihiko Odaki printf ']\n' 6108154f5e6SAkihiko Odaki} 6118154f5e6SAkihiko Odaki 61264708615SPeter Maydell. "$source_path/scripts/meson-buildoptions.sh" 61361d63097SPaolo Bonzini 61461d63097SPaolo Bonzinimeson_options= 615c54b59eeSPaolo Bonzinimeson_option_add() { 616ae22ae65SPaolo Bonzini local arg 617ae22ae65SPaolo Bonzini for arg; do 618ae22ae65SPaolo Bonzini meson_options="$meson_options $(quote_sh "$arg")" 619ae22ae65SPaolo Bonzini done 620c54b59eeSPaolo Bonzini} 62161d63097SPaolo Bonzinimeson_option_parse() { 62261d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 62361d63097SPaolo Bonzini if test $? -eq 1; then 62461d63097SPaolo Bonzini echo "ERROR: unknown option $1" 62561d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 62661d63097SPaolo Bonzini exit 1 62761d63097SPaolo Bonzini fi 62861d63097SPaolo Bonzini} 62961d63097SPaolo Bonzini 6307d13299dSbellardfor opt do 63189138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 6327d13299dSbellard case "$opt" in 6332efc3265Sbellard --help|-h) show_help=yes 6342efc3265Sbellard ;; 63564708615SPeter Maydell --version|-V) exec cat "$source_path/VERSION" 63699123e13SMike Frysinger ;; 637b1a550a0Spbrook --prefix=*) prefix="$optarg" 6387d13299dSbellard ;; 639ac0df51dSaliguori --cross-prefix=*) 6407d13299dSbellard ;; 641ac0df51dSaliguori --cc=*) 6427d13299dSbellard ;; 643b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 64483469015Sbellard ;; 64583f73fceSTomoki Sekiyama --cxx=*) 64683f73fceSTomoki Sekiyama ;; 647c0c34c91SPeter Maydell --objcc=*) 6483c4a4d0dSPeter Maydell ;; 649b17bbf83SPaolo Bonzini --make=*) 6507d13299dSbellard ;; 651b6daf4d3SPaolo Bonzini --install=*) 6526a882643Spbrook ;; 65381e2b198SJohn Snow --python=*) python="$optarg" 654c886edfbSBlue Swirl ;; 655a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 656a5665051SPaolo Bonzini ;; 65748328880SPaolo Bonzini --ninja=*) ninja="$optarg" 65848328880SPaolo Bonzini ;; 659e2d8830eSBrad --smbd=*) smbd="$optarg" 660e2d8830eSBrad ;; 661e2a2ed06SJuan Quintela --extra-cflags=*) 6627d13299dSbellard ;; 66311cde1c8SBruno Dominguez --extra-cxxflags=*) 66411cde1c8SBruno Dominguez ;; 665e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) 666e910c7d9SPhilippe Mathieu-Daudé ;; 667e2a2ed06SJuan Quintela --extra-ldflags=*) 6687d13299dSbellard ;; 669d75402b5SAlex Bennée --cross-cc-*) 670d75402b5SAlex Bennée ;; 6715adb43beSPaolo Bonzini --cross-prefix-*) 6725adb43beSPaolo Bonzini ;; 6736b0cedcdSJohn Snow --enable-docs) docs=enabled 6746b0cedcdSJohn Snow ;; 6756b0cedcdSJohn Snow --disable-docs) docs=disabled 6766b0cedcdSJohn Snow ;; 6772ff6b91eSJuan Quintela --cpu=*) 6787d13299dSbellard ;; 679b1a550a0Spbrook --target-list=*) target_list="$optarg" 680447e133fSAlex Bennée if test "$target_list_exclude"; then 681447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 682447e133fSAlex Bennée fi 683447e133fSAlex Bennée ;; 684447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 685447e133fSAlex Bennée if test "$target_list"; then 686447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 687447e133fSAlex Bennée fi 688de83cd02Sbellard ;; 689c54b59eeSPaolo Bonzini --with-default-devices) meson_option_add -Ddefault_devices=true 690f3494749SPaolo Bonzini ;; 691c54b59eeSPaolo Bonzini --without-default-devices) meson_option_add -Ddefault_devices=false 692f3494749SPaolo Bonzini ;; 693d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 694d1d5e9eeSAlex Bennée ;; 695d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 696d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 697d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 698d1d5e9eeSAlex Bennée if test -f "$cf"; then 699d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 700d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 701d1d5e9eeSAlex Bennée else 702d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 703d1d5e9eeSAlex Bennée fi 704d1d5e9eeSAlex Bennée ;; 705c87ea116SAlex Bennée --without-default-features) # processed above 706c87ea116SAlex Bennée ;; 707877c5567SPaolo Bonzini --static) static="yes" 70843ce4dfeSbellard ;; 7090b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 7100b24e75fSPaolo Bonzini ;; 71177433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 712023d3d67SEduardo Habkost ;; 713181ce1d0SOlaf Hering --host=*|--build=*|\ 714181ce1d0SOlaf Hering --disable-dependency-tracking|\ 715785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 716fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 717023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 718023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 719023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 720023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 721023ddd74SMax Filippov # lots of directory switches by default. 722023ddd74SMax Filippov ;; 723f3d08ee6SPaul Brook --enable-debug) 724f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 7251d558c90SPaolo Bonzini meson_option_parse --enable-debug-tcg "" 72658a2e3f5SStefan Hajnoczi meson_option_parse --enable-debug-graph-lock "" 727c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 728c54b59eeSPaolo Bonzini meson_option_add -Doptimization=0 729bafe78adSPaolo Bonzini default_cflags='-O0 -g' 7300aebab04SLingfeng Yang ;; 7311badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 732b3f6ea7eSPaolo Bonzini ;; 7331badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 734b3f6ea7eSPaolo Bonzini ;; 73524f9c07aSPaolo Bonzini --disable-system) system="no" 7360a8e90f4Spbrook ;; 73724f9c07aSPaolo Bonzini --enable-system) system="yes" 7380a8e90f4Spbrook ;; 7390953a80fSZachary Amsden --disable-user) 7400953a80fSZachary Amsden linux_user="no" ; 7410953a80fSZachary Amsden bsd_user="no" ; 7420953a80fSZachary Amsden ;; 7430953a80fSZachary Amsden --enable-user) ;; 744831b7825Sths --disable-linux-user) linux_user="no" 7450a8e90f4Spbrook ;; 746831b7825Sths --enable-linux-user) linux_user="yes" 747831b7825Sths ;; 74884778508Sblueswir1 --disable-bsd-user) bsd_user="no" 74984778508Sblueswir1 ;; 75084778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 75184778508Sblueswir1 ;; 75240d6444eSAvi Kivity --enable-pie) pie="yes" 75334005a00SKirill A. Shutemov ;; 75440d6444eSAvi Kivity --disable-pie) pie="no" 75534005a00SKirill A. Shutemov ;; 75685aa5189Sbellard --enable-werror) werror="yes" 75785aa5189Sbellard ;; 75885aa5189Sbellard --disable-werror) werror="no" 75985aa5189Sbellard ;; 760ae22ae65SPaolo Bonzini --enable-cfi) cfi=true 7619e62ba48SDaniele Buono ;; 762ae22ae65SPaolo Bonzini --disable-cfi) cfi=false 7639e62ba48SDaniele Buono ;; 7646f3ae23bSPaolo Bonzini --disable-download) download="disabled"; git_submodules_action=validate; 765f62bbee5SDaniel P. Berrange ;; 7666f3ae23bSPaolo Bonzini --enable-download) download="enabled"; git_submodules_action=update; 7670c5f3dcbSJohn Snow ;; 76839fb3cfcSPaolo Bonzini --enable-plugins) plugins="yes" 76940e8c6f4SAlex Bennée ;; 77040e8c6f4SAlex Bennée --disable-plugins) plugins="no" 77140e8c6f4SAlex Bennée ;; 772afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 773afc3a8f9SAlex Bennée ;; 774afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 775afc3a8f9SAlex Bennée ;; 77642ede11aSAlex Bennée --container-engine=*) container_engine="$optarg" 77742ede11aSAlex Bennée ;; 778f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 779f48e590aSAlex Bennée ;; 7803b4da132SPaolo Bonzini # everything else has the same name in configure and meson 7814fda6011SPaolo Bonzini --*) meson_option_parse "$opt" "$optarg" 7827f1559c6Sbalrog ;; 783ff136d2aSDaniel P. Berrangé # Pass through -Dxxxx options to meson 784ff136d2aSDaniel P. Berrangé -D*) meson_options="$meson_options $opt" 785ff136d2aSDaniel P. Berrangé ;; 7867d13299dSbellard esac 7877d13299dSbellarddone 7887d13299dSbellard 7896f3ae23bSPaolo Bonziniif ! test -e "$source_path/.git" 7906f3ae23bSPaolo Bonzinithen 7918edddaa2SPaolo Bonzini git_submodules_action="validate" 7926f3ae23bSPaolo Bonzinifi 7936f3ae23bSPaolo Bonzini 7942019cabfSPaolo Bonziniif ! test -f "$source_path/subprojects/keycodemapdb/README" \ 795c06b1571SMichal Privoznik && test "$download" = disabled 7962019cabfSPaolo Bonzinithen 7972019cabfSPaolo Bonzini echo 7982019cabfSPaolo Bonzini echo "ERROR: missing subprojects" 7992019cabfSPaolo Bonzini echo 8002019cabfSPaolo Bonzini if test -e "$source_path/.git"; then 8012019cabfSPaolo Bonzini echo "--disable-download specified but subprojects were not" 8022019cabfSPaolo Bonzini echo 'checked out. Please invoke "meson subprojects download"' 8032019cabfSPaolo Bonzini echo "before configuring QEMU, or remove --disable-download" 8042019cabfSPaolo Bonzini echo "from the command line." 8052019cabfSPaolo Bonzini else 8062019cabfSPaolo Bonzini echo "This is not a GIT checkout but subproject content appears to" 8072019cabfSPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 8082019cabfSPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 8092019cabfSPaolo Bonzini echo "supported with source archives linked from:" 8102019cabfSPaolo Bonzini echo 8112019cabfSPaolo Bonzini echo " https://www.qemu.org/download/#source" 8122019cabfSPaolo Bonzini echo 8132019cabfSPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 8142019cabfSPaolo Bonzini echo "if they need to create valid source archives." 8152019cabfSPaolo Bonzini fi 8162019cabfSPaolo Bonzini echo 8172019cabfSPaolo Bonzini exit 1 8182019cabfSPaolo Bonzinifi 8192019cabfSPaolo Bonzini 82060e0df25SPeter Maydelldefault_target_list="" 8216e92f823SPeter Maydellmak_wilds="" 8226e92f823SPeter Maydell 823473cd070SPaolo Bonziniif [ -n "$host_arch" ] && [ -d "$source_path/common-user/host/$host_arch" ]; then 824b915a2f1SPaolo Bonzini if [ "$linux_user" != no ]; then 825473cd070SPaolo Bonzini if [ "$targetos" = linux ]; then 826b915a2f1SPaolo Bonzini linux_user=yes 827b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 828b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 829b915a2f1SPaolo Bonzini fi 830473cd070SPaolo Bonzini if [ "$linux_user" = "yes" ]; then 831473cd070SPaolo Bonzini mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 832473cd070SPaolo Bonzini fi 833b915a2f1SPaolo Bonzini fi 834b915a2f1SPaolo Bonzini if [ "$bsd_user" != no ]; then 835b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 836b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 837b915a2f1SPaolo Bonzini fi 83864708615SPeter Maydell if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then 839b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 840b915a2f1SPaolo Bonzini fi 841473cd070SPaolo Bonzini if [ "$bsd_user" = "yes" ]; then 842473cd070SPaolo Bonzini mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 843473cd070SPaolo Bonzini fi 844473cd070SPaolo Bonzini fi 845473cd070SPaolo Bonzinielse 846473cd070SPaolo Bonzini if [ "$linux_user" = yes ] || [ "$bsd_user" = yes ]; then 847473cd070SPaolo Bonzini error_exit "user mode emulation not supported on this architecture" 848473cd070SPaolo Bonzini fi 849b915a2f1SPaolo Bonzinifi 85024f9c07aSPaolo Bonziniif [ "$system" = "yes" ]; then 851812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 85260e0df25SPeter Maydellfi 85360e0df25SPeter Maydell 854447e133fSAlex Bennéefor config in $mak_wilds; do 855447e133fSAlex Bennée target="$(basename "$config" .mak)" 85698db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 857447e133fSAlex Bennée default_target_list="${default_target_list} $target" 858447e133fSAlex Bennée fi 859447e133fSAlex Bennéedone 8606e92f823SPeter Maydell 861af5db58eSpbrookif test x"$show_help" = x"yes" ; then 862af5db58eSpbrookcat << EOF 863af5db58eSpbrook 864af5db58eSpbrookUsage: configure [options] 865af5db58eSpbrookOptions: [defaults in brackets after descriptions] 866af5db58eSpbrook 86708fb77edSStefan WeilStandard options: 86808fb77edSStefan Weil --help print this message 86908fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 87074154d7eSThomas Huth --target-list=LIST set target list (default: build all) 87108fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 87208fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 873447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 87408fb77edSStefan Weil 87508fb77edSStefan WeilAdvanced options (experts only): 876ff136d2aSDaniel P. Berrangé -Dmesonoptname=val passthrough option to meson unmodified 8773812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 87808fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 8793c7ee49bSPaolo Bonzini --host-cc=CC when cross compiling, use C compiler CC for code run 8803c7ee49bSPaolo Bonzini at build time [$host_cc] 88108fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 88208fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 883a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 884a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 885e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS 88608fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 887d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 888479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 8895adb43beSPaolo Bonzini --cross-prefix-ARCH=PREFIX cross compiler prefix when building ARCH guest test cases 89008fb77edSStefan Weil --python=PYTHON use specified python [$python] 89148328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 89208fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 89308fb77edSStefan Weil --static enable static build [$static] 89408fb77edSStefan Weil --bindir=PATH install binaries in PATH 895ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 896c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 897c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 898c035c8d6SPaolo Bonzini start the emulator (only use if you are including 899d1d5e9eeSAlex Bennée desired devices in configs/devices/) 900d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 90108fb77edSStefan Weil --enable-debug enable common debug build options 90208fb77edSStefan Weil --disable-werror disable compilation abort on warning 903c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 904afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 90542ede11aSAlex Bennée --container-engine=TYPE which container engine to use [$container_engine] 906f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 90761d63097SPaolo BonziniEOF 90861d63097SPaolo Bonzini meson_options_help 90961d63097SPaolo Bonzinicat << EOF 910c23f23b9SMichael Tokarev system all system emulation targets 911c23f23b9SMichael Tokarev user supported user emulation targets 912c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 913c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 914c23f23b9SMichael Tokarev pie Position Independent Executables 91508fb77edSStefan Weil 91608fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 917af5db58eSpbrookEOF 9182d2ad6d0SFam Zhengexit 0 919af5db58eSpbrookfi 920af5db58eSpbrook 9219c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 922002d8c13SPeter Maydellrm -f ./*/config-devices.mak.d 9239c790242SThomas Huth 924faf44142SDaniel P. Berrangéif test -z "$python" 925faf44142SDaniel P. Berrangéthen 926fee6d412SJohn Snow # If first_python is set, there was a binary somewhere even though 927fee6d412SJohn Snow # it was not suitable. Use it for the error message. 928fee6d412SJohn Snow if test -n "$first_python"; then 929761f241cSJohn Snow error_exit "Cannot use '$first_python', Python >= 3.8 is required." \ 930fee6d412SJohn Snow "Use --python=/path/to/python to specify a supported Python." 931fee6d412SJohn Snow else 932c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 933c53eeaf7SStefan Hajnoczi fi 934fee6d412SJohn Snowfi 935fee6d412SJohn Snow 936fee6d412SJohn Snowif ! check_py_version "$python"; then 937ca056f44SPaolo Bonzini error_exit "Cannot use '$python', Python >= 3.8 is required." \ 938e46b82a0SJohn Snow "Use --python=/path/to/python to specify a supported Python." \ 939e46b82a0SJohn Snow "Maybe try:" \ 940e46b82a0SJohn Snow " openSUSE Leap 15.3+: zypper install python39" \ 941e46b82a0SJohn Snow " CentOS 8: dnf install python38" 942c53eeaf7SStefan Hajnoczifi 943c53eeaf7SStefan Hajnoczi 94481e2b198SJohn Snow# Resolve PATH 94581e2b198SJohn Snowpython="$(command -v "$python")" 94681e2b198SJohn Snow 94781e2b198SJohn Snow# Create a Python virtual environment using our configured python. 94881e2b198SJohn Snow# The stdout of this script will be the location of a symlink that 94981e2b198SJohn Snow# points to the configured Python. 95081e2b198SJohn Snow# Entry point scripts for pip, meson, and sphinx are generated if those 95181e2b198SJohn Snow# packages are present. 95281e2b198SJohn Snow 95381e2b198SJohn Snow# Defaults assumed for now: 95481e2b198SJohn Snow# - venv is cleared if it exists already; 95581e2b198SJohn Snow# - venv is allowed to use system packages; 9560c5f3dcbSJohn Snow# - all setup can be performed offline; 9570c5f3dcbSJohn Snow# - missing packages may be fetched from PyPI, 958ac4ccac7SPaolo Bonzini# unless --disable-download is passed. 95981e2b198SJohn Snow# - pip is not installed into the venv when possible, 96081e2b198SJohn Snow# but ensurepip is called as a fallback when necessary. 96181e2b198SJohn Snow 96281e2b198SJohn Snowecho "python determined to be '$python'" 96381e2b198SJohn Snowecho "python version: $($python --version)" 96481e2b198SJohn Snow 96581e2b198SJohn Snowpython="$($python -B "${source_path}/python/scripts/mkvenv.py" create pyvenv)" 96681e2b198SJohn Snowif test "$?" -ne 0 ; then 96781e2b198SJohn Snow error_exit "python venv creation failed" 96881e2b198SJohn Snowfi 96981e2b198SJohn Snow 97081e2b198SJohn Snow# Suppress writing compiled files 97181e2b198SJohn Snowpython="$python -B" 9726f6652ebSJohn Snowmkvenv="$python ${source_path}/python/scripts/mkvenv.py" 973462a6567SPaolo Bonzini 974edc21078SPaolo Bonzini# Finish preparing the virtual environment using vendored .whl files 975edc21078SPaolo Bonzini 976edc21078SPaolo Bonziniif $python -c 'import sys; sys.exit(sys.version_info >= (3,11))'; then 977edc21078SPaolo Bonzini $mkvenv ensure --dir "${source_path}/python/wheels" \ 978edc21078SPaolo Bonzini 'tomli>=1.2.0' || exit 1 979edc21078SPaolo Bonzinifi 980c853c4d0SPaolo Bonzini$mkvenv ensuregroup --dir "${source_path}/python/wheels" \ 981c853c4d0SPaolo Bonzini ${source_path}/pythondeps.toml meson || exit 1 982a5665051SPaolo Bonzini 98366e2c6cbSJohn Snow# At this point, we expect Meson to be installed and available. 98466e2c6cbSJohn Snow# We expect mkvenv or pip to have created pyvenv/bin/meson for us. 98566e2c6cbSJohn Snow# We ignore PATH completely here: we want to use the venv's Meson 98666e2c6cbSJohn Snow# *exclusively*. 9870a01d76fSMarc-André Lureau 98866e2c6cbSJohn Snowmeson="$(cd pyvenv/bin; pwd)/meson" 9890a01d76fSMarc-André Lureau 9906f6652ebSJohn Snow# Conditionally ensure Sphinx is installed. 9916f6652ebSJohn Snow 9920c5f3dcbSJohn Snowmkvenv_flags="" 993ac4ccac7SPaolo Bonziniif test "$download" = "enabled" -a "$docs" = "enabled" ; then 9940c5f3dcbSJohn Snow mkvenv_flags="--online" 9950c5f3dcbSJohn Snowfi 9960c5f3dcbSJohn Snow 9976f6652ebSJohn Snowif test "$docs" != "disabled" ; then 998c853c4d0SPaolo Bonzini if ! $mkvenv ensuregroup \ 9990c5f3dcbSJohn Snow $mkvenv_flags \ 1000c853c4d0SPaolo Bonzini ${source_path}/pythondeps.toml docs; 10016f6652ebSJohn Snow then 10026f6652ebSJohn Snow if test "$docs" = "enabled" ; then 10036f6652ebSJohn Snow exit 1 10046f6652ebSJohn Snow fi 10056f6652ebSJohn Snow echo "Sphinx not found/usable, disabling docs." 10066f6652ebSJohn Snow docs=disabled 10076f6652ebSJohn Snow else 10086f6652ebSJohn Snow docs=enabled 10096f6652ebSJohn Snow fi 10106f6652ebSJohn Snowfi 10116f6652ebSJohn Snow 101209e93326SPaolo Bonzini# Probe for ninja 101348328880SPaolo Bonzini 101448328880SPaolo Bonziniif test -z "$ninja"; then 101548328880SPaolo Bonzini for c in ninja ninja-build samu; do 101648328880SPaolo Bonzini if has $c; then 101748328880SPaolo Bonzini ninja=$(command -v "$c") 101848328880SPaolo Bonzini break 101948328880SPaolo Bonzini fi 102048328880SPaolo Bonzini done 102109e93326SPaolo Bonzini if test -z "$ninja"; then 102209e93326SPaolo Bonzini error_exit "Cannot find Ninja" 102309e93326SPaolo Bonzini fi 102448328880SPaolo Bonzinifi 1025a5665051SPaolo Bonzini 10269c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 10279c83ffd8SPeter Maydell# by default. Only enable by default for git builds 10289c83ffd8SPeter Maydellif test -z "$werror" ; then 10296f3ae23bSPaolo Bonzini if test -e "$source_path/.git" && \ 103080100e26SPaolo Bonzini { test "$targetos" = linux || test "$targetos" = "windows"; }; then 10319c83ffd8SPeter Maydell werror="yes" 10329c83ffd8SPeter Maydell else 10339c83ffd8SPeter Maydell werror="no" 10349c83ffd8SPeter Maydell fi 10359c83ffd8SPeter Maydellfi 10369c83ffd8SPeter Maydell 1037975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1038fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1039fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1040fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1041fb59dabdSPeter Maydell # host OS we should stop now. 1042951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1043fb59dabdSPeter Maydellfi 1044fb59dabdSPeter Maydell 104539fb3cfcSPaolo Bonzini# test for any invalid configuration combinations 104639fb3cfcSPaolo Bonziniif test "$targetos" = "windows"; then 104739fb3cfcSPaolo Bonzini if test "$plugins" = "yes"; then 104839fb3cfcSPaolo Bonzini error_exit "TCG plugins not currently supported on Windows platforms" 104939fb3cfcSPaolo Bonzini fi 105039fb3cfcSPaolo Bonzini plugins="no" 105139fb3cfcSPaolo Bonzinifi 105239fb3cfcSPaolo Bonziniif test "$tcg" = "disabled" ; then 105339fb3cfcSPaolo Bonzini if test "$plugins" = "yes"; then 105439fb3cfcSPaolo Bonzini error_exit "Can't enable plugins on non-TCG builds" 105539fb3cfcSPaolo Bonzini fi 105639fb3cfcSPaolo Bonzini plugins="no" 105739fb3cfcSPaolo Bonzinifi 105840d6444eSAvi Kivityif test "$static" = "yes" ; then 10595f2453acSAlex Bennée if test "$plugins" = "yes"; then 10605f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 106139fb3cfcSPaolo Bonzini fi 1062ba4dd2aaSAlex Bennée plugins="no" 10635f2453acSAlex Bennéefi 106439fb3cfcSPaolo Bonziniif test "$plugins" != "no"; then 106539fb3cfcSPaolo Bonzini plugins=yes 10662a5919abSPaolo Bonzini subdirs="$subdirs contrib/plugins" 10672a5919abSPaolo Bonzinifi 106840d6444eSAvi Kivity 106940d6444eSAvi Kivitycat > $TMPC << EOF 107021d4a791SAvi Kivity 107121d4a791SAvi Kivity#ifdef __linux__ 107221d4a791SAvi Kivity# define THREAD __thread 107321d4a791SAvi Kivity#else 107421d4a791SAvi Kivity# define THREAD 107521d4a791SAvi Kivity#endif 107621d4a791SAvi Kivitystatic THREAD int tls_var; 107721d4a791SAvi Kivityint main(void) { return tls_var; } 107840d6444eSAvi KivityEOF 1079b2634124SRichard Henderson 1080*2e938a9aSPaolo Bonziniif test "$targetos" = windows || test "$targetos" = haiku; then 1081*2e938a9aSPaolo Bonzini if test "$pie" = "yes"; then 1082*2e938a9aSPaolo Bonzini error_exit "PIE not available due to missing OS support" 1083*2e938a9aSPaolo Bonzini fi 1084*2e938a9aSPaolo Bonzini pie=no 1085*2e938a9aSPaolo Bonzinifi 1086*2e938a9aSPaolo Bonzini 1087*2e938a9aSPaolo Bonziniif test "$pie" != "no"; then 108812781462SRichard Henderson if test "$static" = "yes"; then 1089*2e938a9aSPaolo Bonzini pie_ldflags=-static-pie 1090*2e938a9aSPaolo Bonzini else 1091*2e938a9aSPaolo Bonzini pie_ldflags=-pie 1092*2e938a9aSPaolo Bonzini fi 1093*2e938a9aSPaolo Bonzini if compile_prog "-Werror -fPIE -DPIE" "$pie_ldflags"; then 109412781462SRichard Henderson pie="yes" 109512781462SRichard Henderson elif test "$pie" = "yes"; then 109612781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 109712781462SRichard Henderson else 109840d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 109940d6444eSAvi Kivity pie="no" 110040d6444eSAvi Kivity fi 1101a988b4c5SPaolo Bonzinifi 110240d6444eSAvi Kivity 110309dada40SPaolo Bonzini########################################## 110409dada40SPaolo Bonzini 1105afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1106fdb75aefSPaolo Bonzini default_targets=yes 1107d880a3baSPaolo Bonzini for target in $default_target_list; do 1108d880a3baSPaolo Bonzini target_list="$target_list $target" 1109d880a3baSPaolo Bonzini done 1110d880a3baSPaolo Bonzini target_list="${target_list# }" 1111121afa9eSAnthony Liguorielse 1112fdb75aefSPaolo Bonzini default_targets=no 111389138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1114d880a3baSPaolo Bonzini for target in $target_list; do 111525b48338SPeter Maydell # Check that we recognised the target name; this allows a more 111625b48338SPeter Maydell # friendly error message than if we let it fall through. 111725b48338SPeter Maydell case " $default_target_list " in 111825b48338SPeter Maydell *" $target "*) 111925b48338SPeter Maydell ;; 112025b48338SPeter Maydell *) 112125b48338SPeter Maydell error_exit "Unknown target name '$target'" 112225b48338SPeter Maydell ;; 112325b48338SPeter Maydell esac 112425b48338SPeter Maydell done 1125d880a3baSPaolo Bonzinifi 112625b48338SPeter Maydell 11277630156dSPhilippe Mathieu-Daudéif test "$tcg" = "auto"; then 11287630156dSPhilippe Mathieu-Daudé if test -z "$target_list"; then 11297630156dSPhilippe Mathieu-Daudé tcg="disabled" 11307630156dSPhilippe Mathieu-Daudé else 11317630156dSPhilippe Mathieu-Daudé tcg="enabled" 11327630156dSPhilippe Mathieu-Daudé fi 11337630156dSPhilippe Mathieu-Daudéfi 11347630156dSPhilippe Mathieu-Daudé 1135a47dd5c5SPaolo Bonzini######################################### 1136a47dd5c5SPaolo Bonzini# gdb test 1137a47dd5c5SPaolo Bonzini 1138a47dd5c5SPaolo Bonziniif test -n "$gdb_bin"; then 1139a47dd5c5SPaolo Bonzini gdb_version=$($gdb_bin --version | head -n 1) 1140a47dd5c5SPaolo Bonzini if version_ge ${gdb_version##* } 9.1; then 1141a47dd5c5SPaolo Bonzini gdb_arches=$($python "$source_path/scripts/probe-gdb-support.py" $gdb_bin) 1142a47dd5c5SPaolo Bonzini else 1143a47dd5c5SPaolo Bonzini gdb_bin="" 1144a47dd5c5SPaolo Bonzini fi 1145a47dd5c5SPaolo Bonzinifi 1146a47dd5c5SPaolo Bonzini 114733ab5f24SMichal Privoznik########################################## 11487d13299dSbellard# big/little endian test 11497d13299dSbellardcat > $TMPC << EOF 115033ab5f24SMichal Privoznik#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 115133ab5f24SMichal Privoznik# error LITTLE 115233ab5f24SMichal Privoznik#endif 115333ab5f24SMichal Privoznikint main(void) { return 0; } 11547d13299dSbellardEOF 11557d13299dSbellard 115633ab5f24SMichal Privoznikif ! compile_prog ; then 115761cc919fSMike Frysinger bigendian="no" 11587d13299dSbellardelse 115933ab5f24SMichal Privoznik cat > $TMPC << EOF 116033ab5f24SMichal Privoznik#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 116133ab5f24SMichal Privoznik# error BIG 116233ab5f24SMichal Privoznik#endif 116333ab5f24SMichal Privoznikint main(void) { return 0; } 116433ab5f24SMichal PrivoznikEOF 116533ab5f24SMichal Privoznik 116633ab5f24SMichal Privoznik if ! compile_prog ; then 116733ab5f24SMichal Privoznik bigendian="yes" 116833ab5f24SMichal Privoznik else 11697d13299dSbellard echo big/little test failed 1170659eb157SThomas Huth exit 1 11717d13299dSbellard fi 11727d13299dSbellardfi 11737d13299dSbellard 1174adc28027SAlexander Bulekov########################################## 1175cd362defSPaolo Bonzini# functions to probe cross compilers 1176cd362defSPaolo Bonzini 1177cd362defSPaolo Bonzinicontainer="no" 117860f999b7SAlex Bennéerunc="" 117947fdc8fbSStefan Weilif test $use_containers = "yes" && (has "docker" || has "podman"); then 118042ede11aSAlex Bennée case $($python "$source_path"/tests/docker/docker.py --engine "$container_engine" probe) in 1181c4575b59SPaolo Bonzini *docker) container=docker ;; 1182c4575b59SPaolo Bonzini podman) container=podman ;; 1183c4575b59SPaolo Bonzini no) container=no ;; 1184c4575b59SPaolo Bonzini esac 1185a3e28f81SPaolo Bonzini if test "$container" != "no"; then 1186a3e28f81SPaolo Bonzini docker_py="$python $source_path/tests/docker/docker.py --engine $container" 118742ede11aSAlex Bennée runc=$container 1188a3e28f81SPaolo Bonzini fi 1189cd362defSPaolo Bonzinifi 1190cd362defSPaolo Bonzini 1191cd362defSPaolo Bonzini# cross compilers defaults, can be overridden with --cross-cc-ARCH 11925adb43beSPaolo Bonzini: ${cross_prefix_aarch64="aarch64-linux-gnu-"} 11935adb43beSPaolo Bonzini: ${cross_prefix_aarch64_be="$cross_prefix_aarch64"} 11945adb43beSPaolo Bonzini: ${cross_prefix_alpha="alpha-linux-gnu-"} 11955adb43beSPaolo Bonzini: ${cross_prefix_arm="arm-linux-gnueabihf-"} 11965adb43beSPaolo Bonzini: ${cross_prefix_armeb="$cross_prefix_arm"} 11975adb43beSPaolo Bonzini: ${cross_prefix_hexagon="hexagon-unknown-linux-musl-"} 119834bb43b0SSong Gao: ${cross_prefix_loongarch64="loongarch64-unknown-linux-gnu-"} 11995adb43beSPaolo Bonzini: ${cross_prefix_hppa="hppa-linux-gnu-"} 12005adb43beSPaolo Bonzini: ${cross_prefix_i386="i686-linux-gnu-"} 12015adb43beSPaolo Bonzini: ${cross_prefix_m68k="m68k-linux-gnu-"} 12025adb43beSPaolo Bonzini: ${cross_prefix_microblaze="microblaze-linux-musl-"} 12035adb43beSPaolo Bonzini: ${cross_prefix_mips64el="mips64el-linux-gnuabi64-"} 12045adb43beSPaolo Bonzini: ${cross_prefix_mips64="mips64-linux-gnuabi64-"} 12055adb43beSPaolo Bonzini: ${cross_prefix_mipsel="mipsel-linux-gnu-"} 12065adb43beSPaolo Bonzini: ${cross_prefix_mips="mips-linux-gnu-"} 12075adb43beSPaolo Bonzini: ${cross_prefix_nios2="nios2-linux-gnu-"} 12085adb43beSPaolo Bonzini: ${cross_prefix_ppc="powerpc-linux-gnu-"} 12095adb43beSPaolo Bonzini: ${cross_prefix_ppc64="powerpc64-linux-gnu-"} 12105adb43beSPaolo Bonzini: ${cross_prefix_ppc64le="$cross_prefix_ppc64"} 12115adb43beSPaolo Bonzini: ${cross_prefix_riscv64="riscv64-linux-gnu-"} 12125adb43beSPaolo Bonzini: ${cross_prefix_s390x="s390x-linux-gnu-"} 12135adb43beSPaolo Bonzini: ${cross_prefix_sh4="sh4-linux-gnu-"} 12145adb43beSPaolo Bonzini: ${cross_prefix_sparc64="sparc64-linux-gnu-"} 12155adb43beSPaolo Bonzini: ${cross_prefix_sparc="$cross_prefix_sparc64"} 1216a3d3de8eSPaolo Bonzini: ${cross_prefix_tricore="tricore-"} 12175adb43beSPaolo Bonzini: ${cross_prefix_x86_64="x86_64-linux-gnu-"} 12185adb43beSPaolo Bonzini 1219cd362defSPaolo Bonzini: ${cross_cc_aarch64_be="$cross_cc_aarch64"} 1220cd362defSPaolo Bonzini: ${cross_cc_cflags_aarch64_be="-mbig-endian"} 122146af66edSPaolo Bonzini: ${cross_cc_armeb="$cross_cc_arm"} 1222cd362defSPaolo Bonzini: ${cross_cc_cflags_armeb="-mbig-endian"} 1223cd362defSPaolo Bonzini: ${cross_cc_hexagon="hexagon-unknown-linux-musl-clang"} 1224fc2622f6STaylor Simpson: ${cross_cc_cflags_hexagon="-mv73 -O2 -static"} 1225cd362defSPaolo Bonzini: ${cross_cc_cflags_i386="-m32"} 1226d44f2f96SPaolo Bonzini: ${cross_cc_cflags_ppc="-m32 -mbig-endian"} 1227cd362defSPaolo Bonzini: ${cross_cc_cflags_ppc64="-m64 -mbig-endian"} 1228cd362defSPaolo Bonzini: ${cross_cc_ppc64le="$cross_cc_ppc64"} 1229cd362defSPaolo Bonzini: ${cross_cc_cflags_ppc64le="-m64 -mlittle-endian"} 1230cd362defSPaolo Bonzini: ${cross_cc_cflags_sparc64="-m64 -mcpu=ultrasparc"} 123146af66edSPaolo Bonzini: ${cross_cc_sparc="$cross_cc_sparc64"} 123246af66edSPaolo Bonzini: ${cross_cc_cflags_sparc="-m32 -mcpu=supersparc"} 1233cd362defSPaolo Bonzini: ${cross_cc_cflags_x86_64="-m64"} 1234cd362defSPaolo Bonzini 12355adb43beSPaolo Bonzinicompute_target_variable() { 123692e288fcSPaolo Bonzini eval "$2=" 12375adb43beSPaolo Bonzini if eval test -n "\"\${cross_prefix_$1}\""; then 12385adb43beSPaolo Bonzini if eval has "\"\${cross_prefix_$1}\$3\""; then 12395adb43beSPaolo Bonzini eval "$2=\"\${cross_prefix_$1}\$3\"" 12405adb43beSPaolo Bonzini fi 12415adb43beSPaolo Bonzini fi 12425adb43beSPaolo Bonzini} 1243cd362defSPaolo Bonzini 124435fd22b0SPaolo Bonzinihave_target() { 124535fd22b0SPaolo Bonzini for i; do 124635fd22b0SPaolo Bonzini case " $target_list " in 124735fd22b0SPaolo Bonzini *" $i "*) return 0;; 124835fd22b0SPaolo Bonzini *) ;; 124935fd22b0SPaolo Bonzini esac 125035fd22b0SPaolo Bonzini done 125135fd22b0SPaolo Bonzini return 1 125235fd22b0SPaolo Bonzini} 125335fd22b0SPaolo Bonzini 125452f08deaSPaolo Bonzini# probe_target_compiler TARGET 125552f08deaSPaolo Bonzini# 125652f08deaSPaolo Bonzini# Look for a compiler for the given target, either native or cross. 125752f08deaSPaolo Bonzini# Set variables target_* if a compiler is found, and container_cross_* 125852f08deaSPaolo Bonzini# if a Docker-based cross-compiler image is known for the target. 125952f08deaSPaolo Bonzini# Set got_cross_cc to yes/no depending on whether a non-container-based 126052f08deaSPaolo Bonzini# compiler was found. 126152f08deaSPaolo Bonzini# 126252f08deaSPaolo Bonzini# If TARGET is a user-mode emulation target, also set build_static to 126352f08deaSPaolo Bonzini# "y" if static linking is possible. 126452f08deaSPaolo Bonzini# 1265cd362defSPaolo Bonziniprobe_target_compiler() { 1266cd362defSPaolo Bonzini # reset all output variables 126792e288fcSPaolo Bonzini got_cross_cc=no 1268cd362defSPaolo Bonzini container_image= 1269cd362defSPaolo Bonzini container_hosts= 1270cd362defSPaolo Bonzini container_cross_cc= 127187eb014cSPaolo Bonzini container_cross_ar= 1272cd362defSPaolo Bonzini container_cross_as= 1273cd362defSPaolo Bonzini container_cross_ld= 127487eb014cSPaolo Bonzini container_cross_nm= 127587eb014cSPaolo Bonzini container_cross_objcopy= 127687eb014cSPaolo Bonzini container_cross_ranlib= 127787eb014cSPaolo Bonzini container_cross_strip= 1278cd362defSPaolo Bonzini 127952f08deaSPaolo Bonzini target_arch=${1%%-*} 128052f08deaSPaolo Bonzini case $target_arch in 1281cd362defSPaolo Bonzini aarch64) container_hosts="x86_64 aarch64" ;; 1282cd362defSPaolo Bonzini alpha) container_hosts=x86_64 ;; 1283cd362defSPaolo Bonzini arm) container_hosts="x86_64 aarch64" ;; 1284cd362defSPaolo Bonzini cris) container_hosts=x86_64 ;; 1285cd362defSPaolo Bonzini hexagon) container_hosts=x86_64 ;; 1286cd362defSPaolo Bonzini hppa) container_hosts=x86_64 ;; 1287cd362defSPaolo Bonzini i386) container_hosts=x86_64 ;; 1288b70ec50bSRichard Henderson loongarch64) container_hosts=x86_64 ;; 1289cd362defSPaolo Bonzini m68k) container_hosts=x86_64 ;; 1290cd362defSPaolo Bonzini microblaze) container_hosts=x86_64 ;; 1291cd362defSPaolo Bonzini mips64el) container_hosts=x86_64 ;; 1292cd362defSPaolo Bonzini mips64) container_hosts=x86_64 ;; 1293cd362defSPaolo Bonzini mipsel) container_hosts=x86_64 ;; 1294cd362defSPaolo Bonzini mips) container_hosts=x86_64 ;; 1295cd362defSPaolo Bonzini nios2) container_hosts=x86_64 ;; 1296cd362defSPaolo Bonzini ppc) container_hosts=x86_64 ;; 1297cd362defSPaolo Bonzini ppc64|ppc64le) container_hosts=x86_64 ;; 1298cd362defSPaolo Bonzini riscv64) container_hosts=x86_64 ;; 1299cd362defSPaolo Bonzini s390x) container_hosts=x86_64 ;; 1300cd362defSPaolo Bonzini sh4) container_hosts=x86_64 ;; 1301cd362defSPaolo Bonzini sparc64) container_hosts=x86_64 ;; 1302cd362defSPaolo Bonzini tricore) container_hosts=x86_64 ;; 1303a04f3372SPaolo Bonzini x86_64) container_hosts="aarch64 ppc64le x86_64" ;; 1304cd362defSPaolo Bonzini xtensa*) container_hosts=x86_64 ;; 1305cd362defSPaolo Bonzini esac 1306cd362defSPaolo Bonzini 1307cd362defSPaolo Bonzini for host in $container_hosts; do 1308cd362defSPaolo Bonzini test "$container" != no || continue 1309cd362defSPaolo Bonzini test "$host" = "$cpu" || continue 131052f08deaSPaolo Bonzini case $target_arch in 1311cd362defSPaolo Bonzini aarch64) 1312cd362defSPaolo Bonzini # We don't have any bigendian build tools so we only use this for AArch64 1313cd362defSPaolo Bonzini container_image=debian-arm64-cross 13145adb43beSPaolo Bonzini container_cross_prefix=aarch64-linux-gnu- 1315e0f89512SAlex Bennée container_cross_cc=${container_cross_prefix}gcc 1316cd362defSPaolo Bonzini ;; 1317cd362defSPaolo Bonzini alpha) 1318cd362defSPaolo Bonzini container_image=debian-alpha-cross 13195adb43beSPaolo Bonzini container_cross_prefix=alpha-linux-gnu- 1320cd362defSPaolo Bonzini ;; 1321cd362defSPaolo Bonzini arm) 1322cd362defSPaolo Bonzini # We don't have any bigendian build tools so we only use this for ARM 1323cd362defSPaolo Bonzini container_image=debian-armhf-cross 13245adb43beSPaolo Bonzini container_cross_prefix=arm-linux-gnueabihf- 1325cd362defSPaolo Bonzini ;; 1326cd362defSPaolo Bonzini cris) 1327cd362defSPaolo Bonzini container_image=fedora-cris-cross 13285adb43beSPaolo Bonzini container_cross_prefix=cris-linux-gnu- 1329cd362defSPaolo Bonzini ;; 1330cd362defSPaolo Bonzini hexagon) 1331cd362defSPaolo Bonzini container_image=debian-hexagon-cross 13325adb43beSPaolo Bonzini container_cross_prefix=hexagon-unknown-linux-musl- 13335adb43beSPaolo Bonzini container_cross_cc=${container_cross_prefix}clang 1334cd362defSPaolo Bonzini ;; 1335cd362defSPaolo Bonzini hppa) 1336cd362defSPaolo Bonzini container_image=debian-hppa-cross 13375adb43beSPaolo Bonzini container_cross_prefix=hppa-linux-gnu- 1338cd362defSPaolo Bonzini ;; 1339cd362defSPaolo Bonzini i386) 1340cd362defSPaolo Bonzini container_image=fedora-i386-cross 13415adb43beSPaolo Bonzini container_cross_prefix= 1342cd362defSPaolo Bonzini ;; 1343b70ec50bSRichard Henderson loongarch64) 1344b70ec50bSRichard Henderson container_image=debian-loongarch-cross 1345b70ec50bSRichard Henderson container_cross_prefix=loongarch64-unknown-linux-gnu- 1346b70ec50bSRichard Henderson ;; 1347cd362defSPaolo Bonzini m68k) 1348cd362defSPaolo Bonzini container_image=debian-m68k-cross 13495adb43beSPaolo Bonzini container_cross_prefix=m68k-linux-gnu- 1350cd362defSPaolo Bonzini ;; 1351cd362defSPaolo Bonzini microblaze) 1352cd362defSPaolo Bonzini container_image=debian-microblaze-cross 13535adb43beSPaolo Bonzini container_cross_prefix=microblaze-linux-musl- 1354cd362defSPaolo Bonzini ;; 1355cd362defSPaolo Bonzini mips64el) 1356cd362defSPaolo Bonzini container_image=debian-mips64el-cross 13575adb43beSPaolo Bonzini container_cross_prefix=mips64el-linux-gnuabi64- 1358cd362defSPaolo Bonzini ;; 1359cd362defSPaolo Bonzini mips64) 1360cd362defSPaolo Bonzini container_image=debian-mips64-cross 13615adb43beSPaolo Bonzini container_cross_prefix=mips64-linux-gnuabi64- 1362cd362defSPaolo Bonzini ;; 1363cd362defSPaolo Bonzini mipsel) 1364cd362defSPaolo Bonzini container_image=debian-mipsel-cross 13655adb43beSPaolo Bonzini container_cross_prefix=mipsel-linux-gnu- 1366cd362defSPaolo Bonzini ;; 1367cd362defSPaolo Bonzini mips) 1368cd362defSPaolo Bonzini container_image=debian-mips-cross 13695adb43beSPaolo Bonzini container_cross_prefix=mips-linux-gnu- 1370cd362defSPaolo Bonzini ;; 1371cd362defSPaolo Bonzini nios2) 1372cd362defSPaolo Bonzini container_image=debian-nios2-cross 13735adb43beSPaolo Bonzini container_cross_prefix=nios2-linux-gnu- 1374cd362defSPaolo Bonzini ;; 1375cd362defSPaolo Bonzini ppc) 1376cd362defSPaolo Bonzini container_image=debian-powerpc-test-cross 13775adb43beSPaolo Bonzini container_cross_prefix=powerpc-linux-gnu- 1378e0f89512SAlex Bennée container_cross_cc=${container_cross_prefix}gcc 1379cd362defSPaolo Bonzini ;; 1380cd362defSPaolo Bonzini ppc64|ppc64le) 1381cd362defSPaolo Bonzini container_image=debian-powerpc-test-cross 1382705c881fSRichard Henderson container_cross_prefix=powerpc${target_arch#ppc}-linux-gnu- 13835adb43beSPaolo Bonzini container_cross_cc=${container_cross_prefix}gcc-10 1384cd362defSPaolo Bonzini ;; 1385cd362defSPaolo Bonzini riscv64) 1386cd362defSPaolo Bonzini container_image=debian-riscv64-test-cross 13875adb43beSPaolo Bonzini container_cross_prefix=riscv64-linux-gnu- 1388cd362defSPaolo Bonzini ;; 1389cd362defSPaolo Bonzini s390x) 1390cd362defSPaolo Bonzini container_image=debian-s390x-cross 13915adb43beSPaolo Bonzini container_cross_prefix=s390x-linux-gnu- 1392cd362defSPaolo Bonzini ;; 1393cd362defSPaolo Bonzini sh4) 1394cd362defSPaolo Bonzini container_image=debian-sh4-cross 13955adb43beSPaolo Bonzini container_cross_prefix=sh4-linux-gnu- 1396cd362defSPaolo Bonzini ;; 1397cd362defSPaolo Bonzini sparc64) 1398cd362defSPaolo Bonzini container_image=debian-sparc64-cross 13995adb43beSPaolo Bonzini container_cross_prefix=sparc64-linux-gnu- 1400cd362defSPaolo Bonzini ;; 1401cd362defSPaolo Bonzini tricore) 1402cd362defSPaolo Bonzini container_image=debian-tricore-cross 14035adb43beSPaolo Bonzini container_cross_prefix=tricore- 1404cd362defSPaolo Bonzini ;; 1405cd362defSPaolo Bonzini x86_64) 1406cd362defSPaolo Bonzini container_image=debian-amd64-cross 14075adb43beSPaolo Bonzini container_cross_prefix=x86_64-linux-gnu- 1408cd362defSPaolo Bonzini ;; 1409cd362defSPaolo Bonzini xtensa*) 1410cd362defSPaolo Bonzini container_image=debian-xtensa-cross 1411cd362defSPaolo Bonzini 1412cd362defSPaolo Bonzini # default to the dc232b cpu 14135adb43beSPaolo Bonzini container_cross_prefix=/opt/2020.07/xtensa-dc232b-elf/bin/xtensa-dc232b-elf- 1414cd362defSPaolo Bonzini ;; 1415cd362defSPaolo Bonzini esac 14165adb43beSPaolo Bonzini : ${container_cross_cc:=${container_cross_prefix}gcc} 141787eb014cSPaolo Bonzini : ${container_cross_ar:=${container_cross_prefix}ar} 14185adb43beSPaolo Bonzini : ${container_cross_as:=${container_cross_prefix}as} 14195adb43beSPaolo Bonzini : ${container_cross_ld:=${container_cross_prefix}ld} 142087eb014cSPaolo Bonzini : ${container_cross_nm:=${container_cross_prefix}nm} 142187eb014cSPaolo Bonzini : ${container_cross_objcopy:=${container_cross_prefix}objcopy} 142287eb014cSPaolo Bonzini : ${container_cross_ranlib:=${container_cross_prefix}ranlib} 142387eb014cSPaolo Bonzini : ${container_cross_strip:=${container_cross_prefix}strip} 1424cd362defSPaolo Bonzini done 1425cd362defSPaolo Bonzini 142692e288fcSPaolo Bonzini try=cross 142792e288fcSPaolo Bonzini case "$target_arch:$cpu" in 142892e288fcSPaolo Bonzini aarch64_be:aarch64 | \ 142992e288fcSPaolo Bonzini armeb:arm | \ 143092e288fcSPaolo Bonzini i386:x86_64 | \ 143192e288fcSPaolo Bonzini mips*:mips64 | \ 143292e288fcSPaolo Bonzini ppc*:ppc64 | \ 143392e288fcSPaolo Bonzini sparc:sparc64 | \ 143492e288fcSPaolo Bonzini "$cpu:$cpu") 143592e288fcSPaolo Bonzini try='native cross' ;; 143692e288fcSPaolo Bonzini esac 143752f08deaSPaolo Bonzini eval "target_cflags=\${cross_cc_cflags_$target_arch}" 1438b3b5472dSPeter Maydell for thistry in $try; do 1439b3b5472dSPeter Maydell case $thistry in 144092e288fcSPaolo Bonzini native) 144192e288fcSPaolo Bonzini target_cc=$cc 144292e288fcSPaolo Bonzini target_ccas=$ccas 144392e288fcSPaolo Bonzini target_ar=$ar 144492e288fcSPaolo Bonzini target_as=$as 144592e288fcSPaolo Bonzini target_ld=$ld 144692e288fcSPaolo Bonzini target_nm=$nm 144792e288fcSPaolo Bonzini target_objcopy=$objcopy 144892e288fcSPaolo Bonzini target_ranlib=$ranlib 144992e288fcSPaolo Bonzini target_strip=$strip 145092e288fcSPaolo Bonzini ;; 145192e288fcSPaolo Bonzini cross) 145292e288fcSPaolo Bonzini target_cc= 145352f08deaSPaolo Bonzini if eval test -n "\"\${cross_cc_$target_arch}\""; then 145452f08deaSPaolo Bonzini if eval has "\"\${cross_cc_$target_arch}\""; then 145552f08deaSPaolo Bonzini eval "target_cc=\"\${cross_cc_$target_arch}\"" 1456cd362defSPaolo Bonzini fi 14575adb43beSPaolo Bonzini else 145852f08deaSPaolo Bonzini compute_target_variable $target_arch target_cc gcc 1459cd362defSPaolo Bonzini fi 146087eb014cSPaolo Bonzini target_ccas=$target_cc 146152f08deaSPaolo Bonzini compute_target_variable $target_arch target_ar ar 146252f08deaSPaolo Bonzini compute_target_variable $target_arch target_as as 146352f08deaSPaolo Bonzini compute_target_variable $target_arch target_ld ld 146452f08deaSPaolo Bonzini compute_target_variable $target_arch target_nm nm 146552f08deaSPaolo Bonzini compute_target_variable $target_arch target_objcopy objcopy 146652f08deaSPaolo Bonzini compute_target_variable $target_arch target_ranlib ranlib 146752f08deaSPaolo Bonzini compute_target_variable $target_arch target_strip strip 1468640aabc8SPaolo Bonzini ;; 1469640aabc8SPaolo Bonzini esac 147092e288fcSPaolo Bonzini 14712ad60f6fSPaolo Bonzini if test -n "$target_cc"; then 147252f08deaSPaolo Bonzini case $target_arch in 14732ad60f6fSPaolo Bonzini i386|x86_64) 14742ad60f6fSPaolo Bonzini if $target_cc --version | grep -qi "clang"; then 147592e288fcSPaolo Bonzini continue 14762ad60f6fSPaolo Bonzini fi 14772ad60f6fSPaolo Bonzini ;; 14782ad60f6fSPaolo Bonzini esac 147992e288fcSPaolo Bonzini elif test -n "$target_as" && test -n "$target_ld"; then 148092e288fcSPaolo Bonzini # Special handling for assembler only targets 148192e288fcSPaolo Bonzini case $target in 148292e288fcSPaolo Bonzini tricore-softmmu) 148392e288fcSPaolo Bonzini build_static= 148492e288fcSPaolo Bonzini got_cross_cc=yes 148592e288fcSPaolo Bonzini break 148692e288fcSPaolo Bonzini ;; 148792e288fcSPaolo Bonzini *) 148892e288fcSPaolo Bonzini continue 148992e288fcSPaolo Bonzini ;; 149092e288fcSPaolo Bonzini esac 149192e288fcSPaolo Bonzini else 149292e288fcSPaolo Bonzini continue 149392e288fcSPaolo Bonzini fi 149492e288fcSPaolo Bonzini 149592e288fcSPaolo Bonzini write_c_skeleton 149692e288fcSPaolo Bonzini case $1 in 149792e288fcSPaolo Bonzini *-softmmu) 149892e288fcSPaolo Bonzini if do_compiler "$target_cc" $target_cflags -o $TMPO -c $TMPC && 149992e288fcSPaolo Bonzini do_compiler "$target_cc" $target_cflags -r -nostdlib -o "${TMPDIR1}/${TMPB}2.o" "$TMPO" -lgcc; then 150092e288fcSPaolo Bonzini got_cross_cc=yes 150192e288fcSPaolo Bonzini break 150292e288fcSPaolo Bonzini fi 150392e288fcSPaolo Bonzini ;; 150492e288fcSPaolo Bonzini *) 150592e288fcSPaolo Bonzini if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC -static ; then 150692e288fcSPaolo Bonzini build_static=y 150792e288fcSPaolo Bonzini got_cross_cc=yes 150892e288fcSPaolo Bonzini break 150992e288fcSPaolo Bonzini fi 151092e288fcSPaolo Bonzini if do_compiler "$target_cc" $target_cflags -o $TMPE $TMPC ; then 151192e288fcSPaolo Bonzini build_static= 151292e288fcSPaolo Bonzini got_cross_cc=yes 151392e288fcSPaolo Bonzini break 151492e288fcSPaolo Bonzini fi 151592e288fcSPaolo Bonzini ;; 151692e288fcSPaolo Bonzini esac 151792e288fcSPaolo Bonzini done 151892e288fcSPaolo Bonzini if test $got_cross_cc != yes; then 151992e288fcSPaolo Bonzini build_static= 152092e288fcSPaolo Bonzini target_cc= 152192e288fcSPaolo Bonzini target_ccas= 152292e288fcSPaolo Bonzini target_ar= 152392e288fcSPaolo Bonzini target_as= 152492e288fcSPaolo Bonzini target_ld= 152592e288fcSPaolo Bonzini target_nm= 152692e288fcSPaolo Bonzini target_objcopy= 152792e288fcSPaolo Bonzini target_ranlib= 152892e288fcSPaolo Bonzini target_strip= 15292ad60f6fSPaolo Bonzini fi 1530fde10960SAlex Bennée test -n "$target_cc" 1531cd362defSPaolo Bonzini} 1532cd362defSPaolo Bonzini 1533cd362defSPaolo Bonziniwrite_target_makefile() { 1534e81785abSPaolo Bonzini echo "EXTRA_CFLAGS=$target_cflags" 15350825cae0SPaolo Bonzini if test -z "$target_cc" && test -z "$target_as"; then 15360825cae0SPaolo Bonzini test -z "$container_image" && error_exit "Internal error: could not find cross compiler for $1?" 15370825cae0SPaolo Bonzini echo "$1: docker-image-$container_image" >> Makefile.prereqs 15380825cae0SPaolo Bonzini if test -n "$container_cross_cc"; then 15390825cae0SPaolo Bonzini echo "CC=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" 15400825cae0SPaolo Bonzini echo "CCAS=$docker_py cc --cc $container_cross_cc -i qemu/$container_image -s $source_path --" 15410825cae0SPaolo Bonzini fi 15420825cae0SPaolo Bonzini echo "AR=$docker_py cc --cc $container_cross_ar -i qemu/$container_image -s $source_path --" 15430825cae0SPaolo Bonzini echo "AS=$docker_py cc --cc $container_cross_as -i qemu/$container_image -s $source_path --" 15440825cae0SPaolo Bonzini echo "LD=$docker_py cc --cc $container_cross_ld -i qemu/$container_image -s $source_path --" 15450825cae0SPaolo Bonzini echo "NM=$docker_py cc --cc $container_cross_nm -i qemu/$container_image -s $source_path --" 15460825cae0SPaolo Bonzini echo "OBJCOPY=$docker_py cc --cc $container_cross_objcopy -i qemu/$container_image -s $source_path --" 15470825cae0SPaolo Bonzini echo "RANLIB=$docker_py cc --cc $container_cross_ranlib -i qemu/$container_image -s $source_path --" 15480825cae0SPaolo Bonzini echo "STRIP=$docker_py cc --cc $container_cross_strip -i qemu/$container_image -s $source_path --" 15490825cae0SPaolo Bonzini else 1550cd362defSPaolo Bonzini if test -n "$target_cc"; then 1551cd362defSPaolo Bonzini echo "CC=$target_cc" 155287eb014cSPaolo Bonzini echo "CCAS=$target_ccas" 155387eb014cSPaolo Bonzini fi 155487eb014cSPaolo Bonzini if test -n "$target_ar"; then 155587eb014cSPaolo Bonzini echo "AR=$target_ar" 1556cd362defSPaolo Bonzini fi 1557cd362defSPaolo Bonzini if test -n "$target_as"; then 1558cd362defSPaolo Bonzini echo "AS=$target_as" 1559cd362defSPaolo Bonzini fi 1560cd362defSPaolo Bonzini if test -n "$target_ld"; then 1561cd362defSPaolo Bonzini echo "LD=$target_ld" 1562cd362defSPaolo Bonzini fi 156387eb014cSPaolo Bonzini if test -n "$target_nm"; then 156487eb014cSPaolo Bonzini echo "NM=$target_nm" 156587eb014cSPaolo Bonzini fi 156687eb014cSPaolo Bonzini if test -n "$target_objcopy"; then 156787eb014cSPaolo Bonzini echo "OBJCOPY=$target_objcopy" 156887eb014cSPaolo Bonzini fi 156987eb014cSPaolo Bonzini if test -n "$target_ranlib"; then 157087eb014cSPaolo Bonzini echo "RANLIB=$target_ranlib" 157187eb014cSPaolo Bonzini fi 157287eb014cSPaolo Bonzini if test -n "$target_strip"; then 157387eb014cSPaolo Bonzini echo "STRIP=$target_strip" 157487eb014cSPaolo Bonzini fi 1575cd362defSPaolo Bonzini fi 1576cd362defSPaolo Bonzini} 1577cd362defSPaolo Bonzini 157833ab4787SPaolo Bonzini####################################### 157933ab4787SPaolo Bonzini# cross-compiled firmware targets 158033ab4787SPaolo Bonzini 1581ad388845SPaolo Bonzini# Set up build tree symlinks that point back into the source tree 1582ad388845SPaolo Bonzini# (these can be both files and directories). 1583ad388845SPaolo Bonzini# Caution: avoid adding files or directories here using wildcards. This 1584ad388845SPaolo Bonzini# will result in problems later if a new file matching the wildcard is 1585ad388845SPaolo Bonzini# added to the source tree -- nothing will cause configure to be rerun 1586ad388845SPaolo Bonzini# so the build tree will be missing the link back to the new file, and 1587ad388845SPaolo Bonzini# tests might fail. Prefer to keep the relevant files in their own 1588ad388845SPaolo Bonzini# directory and symlink the directory instead. 1589ad388845SPaolo BonziniLINKS="Makefile" 1590201aa17eSThomas HuthLINKS="$LINKS docs/config" 1591ad388845SPaolo BonziniLINKS="$LINKS pc-bios/optionrom/Makefile" 1592ad388845SPaolo BonziniLINKS="$LINKS pc-bios/s390-ccw/Makefile" 1593d695918fSPaolo BonziniLINKS="$LINKS pc-bios/vof/Makefile" 1594ad388845SPaolo BonziniLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 1595ad388845SPaolo BonziniLINKS="$LINKS tests/avocado tests/data" 1596ad388845SPaolo BonziniLINKS="$LINKS tests/qemu-iotests/check" 1597ad388845SPaolo BonziniLINKS="$LINKS python" 1598ad388845SPaolo BonziniLINKS="$LINKS contrib/plugins/Makefile " 1599ad388845SPaolo Bonzinifor f in $LINKS ; do 1600ad388845SPaolo Bonzini if [ -e "$source_path/$f" ]; then 1601ad388845SPaolo Bonzini symlink "$source_path/$f" "$f" 1602ad388845SPaolo Bonzini fi 1603ad388845SPaolo Bonzinidone 1604ad388845SPaolo Bonzini 1605b898bf28SPaolo Bonziniecho "# Automatically generated by configure - do not modify" > Makefile.prereqs 1606b898bf28SPaolo Bonzini 1607ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 160835fd22b0SPaolo Bonziniif have_target i386-softmmu x86_64-softmmu && \ 160935fd22b0SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 161035fd22b0SPaolo Bonzini test "$targetos" != "haiku" && \ 161161cbb356SPaolo Bonzini probe_target_compiler i386-softmmu; then 16122a5919abSPaolo Bonzini subdirs="$subdirs pc-bios/optionrom" 161333ab4787SPaolo Bonzini config_mak=pc-bios/optionrom/config.mak 161433ab4787SPaolo Bonzini echo "# Automatically generated by configure - do not modify" > $config_mak 161533ab4787SPaolo Bonzini echo "TOPSRC_DIR=$source_path" >> $config_mak 1616fde10960SAlex Bennée write_target_makefile >> $config_mak 161733ab4787SPaolo Bonzinifi 1618ca35f780SPaolo Bonzini 161935fd22b0SPaolo Bonziniif have_target ppc-softmmu ppc64-softmmu && \ 162035fd22b0SPaolo Bonzini probe_target_compiler ppc-softmmu; then 16212a5919abSPaolo Bonzini subdirs="$subdirs pc-bios/vof" 1622d695918fSPaolo Bonzini config_mak=pc-bios/vof/config.mak 1623d695918fSPaolo Bonzini echo "# Automatically generated by configure - do not modify" > $config_mak 1624d695918fSPaolo Bonzini echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak 1625fde10960SAlex Bennée write_target_makefile >> $config_mak 1626d695918fSPaolo Bonzinifi 1627d695918fSPaolo Bonzini 16289ffed426SPaolo Bonzini# Only build s390-ccw bios if the compiler has -march=z900 or -march=z10 16299ffed426SPaolo Bonzini# (which is the lowest architecture level that Clang supports) 1630b11f9bd9SPaolo Bonziniif have_target s390x-softmmu && probe_target_compiler s390x-softmmu && \ 1631b11f9bd9SPaolo Bonzini GIT=git "$source_path/scripts/git-submodule.sh" "$git_submodules_action" roms/SLOF >> config.log 2>&1; then 16322e33c3f8SThomas Huth write_c_skeleton 16339ffed426SPaolo Bonzini do_compiler "$target_cc" $target_cc_cflags -march=z900 -o $TMPO -c $TMPC 1634a5b2afd5SThomas Huth has_z900=$? 16359ffed426SPaolo Bonzini if [ $has_z900 = 0 ] || do_compiler "$target_cc" $target_cc_cflags -march=z10 -msoft-float -Werror -o $TMPO -c $TMPC; then 1636a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 1637a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 1638a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 1639a5b2afd5SThomas Huth fi 16402a5919abSPaolo Bonzini subdirs="$subdirs pc-bios/s390-ccw" 16419ffed426SPaolo Bonzini config_mak=pc-bios/s390-ccw/config-host.mak 16429ffed426SPaolo Bonzini echo "# Automatically generated by configure - do not modify" > $config_mak 16439ffed426SPaolo Bonzini echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak 1644b11f9bd9SPaolo Bonzini echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_mak 1645fde10960SAlex Bennée write_target_makefile >> $config_mak 16461ef6bfc2SPhilippe Mathieu-Daudé fi 16479933c305SChristian Borntraegerfi 16489933c305SChristian Borntraeger 16499ffed426SPaolo Bonzini####################################### 16509ffed426SPaolo Bonzini# generate config-host.mak 16519ffed426SPaolo Bonzini 165298ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 165397a847bcSbellard 165498ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 165598ec69acSJuan Quintelaecho >> $config_host_mak 165698ec69acSJuan Quintela 1657e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 1658804edf29SJuan Quintela 165980100e26SPaolo Bonziniif test "$targetos" = "windows"; then 1660954ed68fSPaolo Bonzini echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER-QEMU}" >> $config_host_mak 1661954ed68fSPaolo Bonzini echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO-Linux}" >> $config_host_mak 1662954ed68fSPaolo Bonzini echo "QEMU_GA_VERSION=${QEMU_GA_VERSION-$(cat "$source_path"/VERSION)}" >> $config_host_mak 166383fb7adfSbellardfi 1664b29fe3edSmalc 166598ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 16662b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 1667a47dd5c5SPaolo Bonziniecho "GDB=$gdb_bin" >> $config_host_mak 1668c4575b59SPaolo Bonziniif test "$container" != no; then 166960f999b7SAlex Bennée echo "RUNC=$runc" >> $config_host_mak 1670c4575b59SPaolo Bonzinifi 16712a5919abSPaolo Bonziniecho "SUBDIRS=$subdirs" >> $config_host_mak 1672c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 167339d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 1674a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 167509e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 1676804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 1677804edf29SJuan Quintela 1678971fac27SPaolo Bonzini# use included Linux headers for KVM architectures 167980100e26SPaolo Bonziniif test "$targetos" = "linux" && test -n "$linux_arch"; then 168008312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 168108312a63SPeter Maydellfi 16826efd7517SPeter Maydell 168397a847bcSbellardfor target in $target_list; do 168497a847bcSbellard target_dir="$target" 168557a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 1686fdb75aefSPaolo Bonzini case $target in 1687fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 1688fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 16892408a527Saurel32 esac 169056aebc89Spbrookdone 16917d13299dSbellard 1692fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 1693fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 1694fdb75aefSPaolo Bonzinifi 1695a540f158SPeter Crosthwaite 1696bafe78adSPaolo Bonzini# contrib/plugins configuration 1697bafe78adSPaolo Bonziniecho "# Automatically generated by configure - do not modify" > contrib/plugins/$config_host_mak 1698bafe78adSPaolo Bonziniecho "SRC_PATH=$source_path/contrib/plugins" >> contrib/plugins/$config_host_mak 1699bafe78adSPaolo Bonziniecho "PKG_CONFIG=${pkg_config}" >> contrib/plugins/$config_host_mak 1700bafe78adSPaolo Bonziniecho "CC=$cc $CPU_CFLAGS" >> contrib/plugins/$config_host_mak 1701bafe78adSPaolo Bonziniecho "CFLAGS=${CFLAGS-$default_cflags} $EXTRA_CFLAGS" >> contrib/plugins/$config_host_mak 1702bafe78adSPaolo Bonziniif test "$targetos" = darwin; then 1703bafe78adSPaolo Bonzini echo "CONFIG_DARWIN=y" >> contrib/plugins/$config_host_mak 1704bafe78adSPaolo Bonzinifi 1705bafe78adSPaolo Bonzini 1706cd362defSPaolo Bonzini# tests/tcg configuration 1707b898bf28SPaolo Bonzini(config_host_mak=tests/tcg/config-host.mak 1708d674342eSPaolo Bonzinimkdir -p tests/tcg 1709cd362defSPaolo Bonziniecho "# Automatically generated by configure - do not modify" > $config_host_mak 1710cd362defSPaolo Bonziniecho "SRC_PATH=$source_path" >> $config_host_mak 1711cd362defSPaolo Bonzini 1712cd362defSPaolo Bonzinitcg_tests_targets= 1713cd362defSPaolo Bonzinifor target in $target_list; do 1714cd362defSPaolo Bonzini arch=${target%%-*} 1715cd362defSPaolo Bonzini 1716cd362defSPaolo Bonzini case $target in 1717c48a5c47SPaolo Bonzini xtensa*-linux-user) 171824f9c07aSPaolo Bonzini # the toolchain is not complete with headers, only build system tests 1719c48a5c47SPaolo Bonzini continue 1720c48a5c47SPaolo Bonzini ;; 1721cd362defSPaolo Bonzini *-softmmu) 172264708615SPeter Maydell test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue 1723cd362defSPaolo Bonzini qemu="qemu-system-$arch" 1724cd362defSPaolo Bonzini ;; 1725cd362defSPaolo Bonzini *-linux-user|*-bsd-user) 1726cd362defSPaolo Bonzini qemu="qemu-$arch" 1727cd362defSPaolo Bonzini ;; 1728cd362defSPaolo Bonzini esac 1729cd362defSPaolo Bonzini 1730fde10960SAlex Bennée if probe_target_compiler $target || test -n "$container_image"; then 17310825cae0SPaolo Bonzini test -n "$container_image" && build_static=y 1732d674342eSPaolo Bonzini mkdir -p "tests/tcg/$target" 1733c7022a70SPaolo Bonzini config_target_mak=tests/tcg/$target/config-target.mak 1734d674342eSPaolo Bonzini ln -sf "$source_path/tests/tcg/Makefile.target" "tests/tcg/$target/Makefile" 1735c7022a70SPaolo Bonzini echo "# Automatically generated by configure - do not modify" > "$config_target_mak" 1736c7022a70SPaolo Bonzini echo "TARGET_NAME=$arch" >> "$config_target_mak" 1737a3e28f81SPaolo Bonzini echo "TARGET=$target" >> "$config_target_mak" 1738c7022a70SPaolo Bonzini write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak" 173915b273f8SPaolo Bonzini echo "BUILD_STATIC=$build_static" >> "$config_target_mak" 1740c7022a70SPaolo Bonzini echo "QEMU=$PWD/$qemu" >> "$config_target_mak" 1741bcbc36a9SAlex Bennée 1742bcbc36a9SAlex Bennée # will GDB work with these binaries? 1743bcbc36a9SAlex Bennée if test "${gdb_arches#*$arch}" != "$gdb_arches"; then 1744a47dd5c5SPaolo Bonzini echo "GDB=$gdb_bin" >> $config_target_mak 1745bcbc36a9SAlex Bennée fi 1746bcbc36a9SAlex Bennée 1747b898bf28SPaolo Bonzini echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs 1748cd362defSPaolo Bonzini tcg_tests_targets="$tcg_tests_targets $target" 1749cd362defSPaolo Bonzini fi 17502038f8c8SPaolo Bonzinidone 1751c0031d38SFabiano Rosas 1752c0031d38SFabiano Rosasif test "$tcg" = "enabled"; then 1753c0031d38SFabiano Rosas echo "TCG_TESTS_TARGETS=$tcg_tests_targets" >> config-host.mak 1754c0031d38SFabiano Rosasfi 1755c0031d38SFabiano Rosas) 17562038f8c8SPaolo Bonzini 1757a5665051SPaolo Bonziniif test "$skip_meson" = no; then 1758fc929892SMarc-André Lureau cross="config-meson.cross.new" 1759fc929892SMarc-André Lureau meson_quote() { 1760ac7ebcc5SPaolo Bonzini test $# = 0 && return 176147b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 1762fc929892SMarc-André Lureau } 1763fc929892SMarc-André Lureau 1764fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 1765fc929892SMarc-André Lureau echo "[properties]" >> $cross 1766d1d5e9eeSAlex Bennée 1767d1d5e9eeSAlex Bennée # unroll any custom device configs 1768d1d5e9eeSAlex Bennée for a in $device_archs; do 1769d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 1770d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 1771d1d5e9eeSAlex Bennée done 1772d1d5e9eeSAlex Bennée 177347b30835SPaolo Bonzini echo "[built-in options]" >> $cross 1774a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 1775a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 1776e910c7d9SPhilippe Mathieu-Daudé test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross 1777a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 1778a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 1779fc929892SMarc-André Lureau echo "[binaries]" >> $cross 17804dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 17814dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 17824dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 178347b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 178447b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 1785877c5567SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config)]" >> $cross 178647b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 1787e8178514SPaolo Bonzini if has $sdl2_config; then 178847b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 1789e8178514SPaolo Bonzini fi 179047b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 1791158bb224SKonstantin Kostiuk echo "widl = [$(meson_quote $widl)]" >> $cross 179247b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 1793f9f0e617SAndrey Drobyshev echo "windmc = [$(meson_quote $windmc)]" >> $cross 17943812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 1795fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 1796ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 1797823eb013SPaolo Bonzini case "$cpu" in 1798f6bca9dfSJoelle van Dyne i386) 1799fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 1800fc929892SMarc-André Lureau ;; 1801fc929892SMarc-André Lureau *) 1802823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 1803fc929892SMarc-André Lureau ;; 1804fc929892SMarc-André Lureau esac 1805fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 1806fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 1807fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 1808fc929892SMarc-André Lureau else 1809fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 1810fc929892SMarc-André Lureau fi 18113c7ee49bSPaolo Bonzini cross_arg="--cross-file config-meson.cross" 18123c7ee49bSPaolo Bonzini 18133c7ee49bSPaolo Bonzini native="config-meson.native.new" 18143c7ee49bSPaolo Bonzini echo "# Automatically generated by configure - do not modify" > $native 18153c7ee49bSPaolo Bonzini echo "[binaries]" >> $native 18163c7ee49bSPaolo Bonzini echo "c = [$(meson_quote $host_cc)]" >> $native 18173c7ee49bSPaolo Bonzini mv $native config-meson.native 18183c7ee49bSPaolo Bonzini cross_arg="$cross_arg --native-file config-meson.native" 1819fc929892SMarc-André Lureau else 1820fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 1821fc929892SMarc-André Lureau fi 1822fc929892SMarc-André Lureau mv $cross config-meson.cross 1823fc929892SMarc-André Lureau 1824a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 18250a31e3a0SPaolo Bonzini 18260a31e3a0SPaolo Bonzini # Built-in options 1827ac4ccac7SPaolo Bonzini test "$download" = "disabled" && meson_option_add "--wrap-mode=nodownload" 18280a31e3a0SPaolo Bonzini test "$bindir" != "bin" && meson_option_add "-Dbindir=$bindir" 18290a31e3a0SPaolo Bonzini test "$default_feature" = no && meson_option_add -Dauto_features=disabled 1830a0cbd2e8SPaolo Bonzini test "$static" = yes && meson_option_add -Dprefer_static=true 18310a31e3a0SPaolo Bonzini test "$pie" = no && meson_option_add -Db_pie=false 18320a31e3a0SPaolo Bonzini test "$werror" = yes && meson_option_add -Dwerror=true 18330a31e3a0SPaolo Bonzini 18340a31e3a0SPaolo Bonzini # QEMU options 1835ae22ae65SPaolo Bonzini test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi" 18366b0cedcdSJohn Snow test "$docs" != auto && meson_option_add "-Ddocs=$docs" 18370a31e3a0SPaolo Bonzini test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE" 18382c13c574SPaolo Bonzini test "$plugins" = yes && meson_option_add "-Dplugins=true" 18390a31e3a0SPaolo Bonzini test "$qemu_suffix" != qemu && meson_option_add "-Dqemu_suffix=$qemu_suffix" 18400a31e3a0SPaolo Bonzini test "$smbd" != '' && meson_option_add "-Dsmbd=$smbd" 18410a31e3a0SPaolo Bonzini test "$tcg" != enabled && meson_option_add "-Dtcg=$tcg" 184261d63097SPaolo Bonzini run_meson() { 18430a31e3a0SPaolo Bonzini NINJA=$ninja $meson setup --prefix "$prefix" "$@" $cross_arg "$PWD" "$source_path" 184461d63097SPaolo Bonzini } 184561d63097SPaolo Bonzini eval run_meson $meson_options 1846a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 1847a5665051SPaolo Bonzini error_exit "meson setup failed" 1848a5665051SPaolo Bonzini fi 18496c5f893dSPaolo Bonzini echo "$meson" > build.ninja.stamp 1850973038dbSPaolo Bonzinielse 1851973038dbSPaolo Bonzini if test -f meson-private/cmd_line.txt; then 1852973038dbSPaolo Bonzini # Adjust old command line options that were removed 1853973038dbSPaolo Bonzini # sed -i is not portable 1854973038dbSPaolo Bonzini perl -i -ne ' 1855973038dbSPaolo Bonzini /^sphinx_build/ && next; 1856973038dbSPaolo Bonzini print;' meson-private/cmd_line.txt 1857973038dbSPaolo Bonzini fi 1858a5665051SPaolo Bonzinifi 1859a5665051SPaolo Bonzini 1860dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 1861dc655404SMichael S. Tsirkincat <<EOD >config.status 1862dc655404SMichael S. Tsirkin#!/bin/sh 1863dc655404SMichael S. Tsirkin# Generated by configure. 1864dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 1865dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 1866dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 1867dc655404SMichael S. TsirkinEOD 1868e811da7fSDaniel P. Berrangé 1869e811da7fSDaniel P. Berrangépreserve_env() { 1870e811da7fSDaniel P. Berrangé envname=$1 1871e811da7fSDaniel P. Berrangé 1872e811da7fSDaniel P. Berrangé eval envval=\$$envname 1873e811da7fSDaniel P. Berrangé 1874e811da7fSDaniel P. Berrangé if test -n "$envval" 1875e811da7fSDaniel P. Berrangé then 1876e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 1877e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 1878e811da7fSDaniel P. Berrangé else 1879e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 1880e811da7fSDaniel P. Berrangé fi 1881e811da7fSDaniel P. Berrangé} 1882e811da7fSDaniel P. Berrangé 1883e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 1884e811da7fSDaniel P. Berrangé# features/build target configure will detect 1885e811da7fSDaniel P. Berrangépreserve_env AR 1886e811da7fSDaniel P. Berrangépreserve_env AS 1887e811da7fSDaniel P. Berrangépreserve_env CC 18888009da03SPaolo Bonzinipreserve_env CFLAGS 1889e811da7fSDaniel P. Berrangépreserve_env CXX 18908009da03SPaolo Bonzinipreserve_env CXXFLAGS 1891e811da7fSDaniel P. Berrangépreserve_env LD 18928009da03SPaolo Bonzinipreserve_env LDFLAGS 1893e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 1894e811da7fSDaniel P. Berrangépreserve_env NM 1895b5569e5bSPaolo Bonzinipreserve_env OBJCFLAGS 1896e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 1897e811da7fSDaniel P. Berrangépreserve_env PATH 1898e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 1899e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 1900e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 1901e811da7fSDaniel P. Berrangépreserve_env PYTHON 1902954ed68fSPaolo Bonzinipreserve_env QEMU_GA_MANUFACTURER 1903954ed68fSPaolo Bonzinipreserve_env QEMU_GA_DISTRO 1904954ed68fSPaolo Bonzinipreserve_env QEMU_GA_VERSION 1905e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 1906e811da7fSDaniel P. Berrangépreserve_env SMBD 1907e811da7fSDaniel P. Berrangépreserve_env STRIP 1908158bb224SKonstantin Kostiukpreserve_env WIDL 1909e811da7fSDaniel P. Berrangépreserve_env WINDRES 1910f9f0e617SAndrey Drobyshevpreserve_env WINDMC 1911e811da7fSDaniel P. Berrangé 1912dc655404SMichael S. Tsirkinprintf "exec" >>config.status 1913a5665051SPaolo Bonzinifor i in "$0" "$@"; do 1914835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 1915a5665051SPaolo Bonzinidone 1916cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 1917dc655404SMichael S. Tsirkinchmod +x config.status 1918dc655404SMichael S. Tsirkin 19198cd05ab6SPeter Maydellrm -r "$TMPDIR1" 1920