17d13299dSbellard#!/bin/sh 27d13299dSbellard# 33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard 47d13299dSbellard# 58cd05ab6SPeter Maydell 699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools, 799519e67SCornelia Huck# just as autoconf does. 899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS= 999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS 1099519e67SCornelia Huck 115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests! 125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes 135e4dfd3dSJohn Snow 14dedad027SDaniel P. Berrangé# make source path absolute 15dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd) 16dedad027SDaniel P. Berrangé 17dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path" 18dedad027SDaniel P. Berrangéthen 19dedad027SDaniel P. Berrangé echo "Using './build' as the directory for build output" 20dedad027SDaniel P. Berrangé 21dedad027SDaniel P. Berrangé MARKER=build/auto-created-by-configure 22dedad027SDaniel P. Berrangé 23dedad027SDaniel P. Berrangé if test -e build 24dedad027SDaniel P. Berrangé then 25dedad027SDaniel P. Berrangé if test -f $MARKER 26dedad027SDaniel P. Berrangé then 27dedad027SDaniel P. Berrangé rm -rf build 28dedad027SDaniel P. Berrangé else 29dedad027SDaniel P. Berrangé echo "ERROR: ./build dir already exists and was not previously created by configure" 30dedad027SDaniel P. Berrangé exit 1 31dedad027SDaniel P. Berrangé fi 32dedad027SDaniel P. Berrangé fi 33dedad027SDaniel P. Berrangé 34dedad027SDaniel P. Berrangé mkdir build 35dedad027SDaniel P. Berrangé touch $MARKER 36dedad027SDaniel P. Berrangé 37dedad027SDaniel P. Berrangé cat > GNUmakefile <<'EOF' 38dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree 39dedad027SDaniel P. Berrangé# 'make' command invocation 40dedad027SDaniel P. Berrangé 41dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),) 42dedad027SDaniel P. Berrangérecurse: all 43dedad027SDaniel P. Berrangéendif 44dedad027SDaniel P. Berrangé 45dedad027SDaniel P. Berrangé.NOTPARALLEL: % 46dedad027SDaniel P. Berrangé%: force 47dedad027SDaniel P. Berrangé @echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...' 48dedad027SDaniel P. Berrangé @$(MAKE) -C build -f Makefile $(MAKECMDGOALS) 49dedad027SDaniel P. Berrangé @if test "$(MAKECMDGOALS)" = "distclean" && \ 50dedad027SDaniel P. Berrangé test -e build/auto-created-by-configure ; \ 51dedad027SDaniel P. Berrangé then \ 52dedad027SDaniel P. Berrangé rm -rf build GNUmakefile ; \ 53dedad027SDaniel P. Berrangé fi 54dedad027SDaniel P. Berrangéforce: ; 55dedad027SDaniel P. Berrangé.PHONY: force 56dedad027SDaniel P. BerrangéGNUmakefile: ; 57dedad027SDaniel P. Berrangé 58dedad027SDaniel P. BerrangéEOF 59dedad027SDaniel P. Berrangé cd build 60dedad027SDaniel P. Berrangé exec $source_path/configure "$@" 61dedad027SDaniel P. Berrangéfi 62dedad027SDaniel P. Berrangé 638cd05ab6SPeter Maydell# Temporary directory used for files created while 648cd05ab6SPeter Maydell# configure runs. Since it is in the build directory 658cd05ab6SPeter Maydell# we can safely blow away any previous version of it 668cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete 678cd05ab6SPeter Maydell# it when configure exits.) 688cd05ab6SPeter MaydellTMPDIR1="config-temp" 698cd05ab6SPeter Maydellrm -rf "${TMPDIR1}" 708cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}" 718cd05ab6SPeter Maydellif [ $? -ne 0 ]; then 728cd05ab6SPeter Maydell echo "ERROR: failed to create temporary directory" 738cd05ab6SPeter Maydell exit 1 747d13299dSbellardfi 757d13299dSbellard 768cd05ab6SPeter MaydellTMPB="qemu-conf" 778cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c" 7866518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o" 799c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx" 804cb37d11SPhilippe Mathieu-DaudéTMPM="${TMPDIR1}/${TMPB}.m" 818cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe" 827d13299dSbellard 83da1d85e3SGerd Hoffmannrm -f config.log 849ac81bbbSmalc 85b48e3611SPeter Maydell# Print a helpful header at the top of config.log 86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log 87979ae168SPeter Maydellprintf "# Configured with:" >> config.log 88979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log 89979ae168SPeter Maydellecho >> config.log 90b48e3611SPeter Maydellecho "#" >> config.log 91b48e3611SPeter Maydell 92835af899SPaolo Bonziniquote_sh() { 93835af899SPaolo Bonzini printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&'," 94835af899SPaolo Bonzini} 95835af899SPaolo Bonzini 96d880a3baSPaolo Bonziniprint_error() { 97d880a3baSPaolo Bonzini (echo 9876ad07a4SPeter Maydell echo "ERROR: $1" 9976ad07a4SPeter Maydell while test -n "$2"; do 10076ad07a4SPeter Maydell echo " $2" 10176ad07a4SPeter Maydell shift 10276ad07a4SPeter Maydell done 103d880a3baSPaolo Bonzini echo) >&2 104d880a3baSPaolo Bonzini} 105d880a3baSPaolo Bonzini 106d880a3baSPaolo Bonzinierror_exit() { 107d880a3baSPaolo Bonzini print_error "$@" 10876ad07a4SPeter Maydell exit 1 10976ad07a4SPeter Maydell} 11076ad07a4SPeter Maydell 1119c83ffd8SPeter Maydelldo_compiler() { 1129c83ffd8SPeter Maydell # Run the compiler, capturing its output to the log. First argument 1139c83ffd8SPeter Maydell # is compiler binary to execute. 114630d86b7SDavid CARLIER compiler="$1" 1159c83ffd8SPeter Maydell shift 1168bbe05d7SIan Jackson if test -n "$BASH_VERSION"; then eval ' 1178bbe05d7SIan Jackson echo >>config.log " 1188bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]} 1198bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}" 1208bbe05d7SIan Jackson '; fi 1219c83ffd8SPeter Maydell echo $compiler "$@" >> config.log 1229c83ffd8SPeter Maydell $compiler "$@" >> config.log 2>&1 || return $? 1238dc38a78SPeter Maydell # Test passed. If this is an --enable-werror build, rerun 1248dc38a78SPeter Maydell # the test with -Werror and bail out if it fails. This 1258dc38a78SPeter Maydell # makes warning-generating-errors in configure test code 1268dc38a78SPeter Maydell # obvious to developers. 1278dc38a78SPeter Maydell if test "$werror" != "yes"; then 1288dc38a78SPeter Maydell return 0 1298dc38a78SPeter Maydell fi 1308dc38a78SPeter Maydell # Don't bother rerunning the compile if we were already using -Werror 1318dc38a78SPeter Maydell case "$*" in 1328dc38a78SPeter Maydell *-Werror*) 1338dc38a78SPeter Maydell return 0 1348dc38a78SPeter Maydell ;; 1358dc38a78SPeter Maydell esac 1369c83ffd8SPeter Maydell echo $compiler -Werror "$@" >> config.log 1379c83ffd8SPeter Maydell $compiler -Werror "$@" >> config.log 2>&1 && return $? 13876ad07a4SPeter Maydell error_exit "configure test passed without -Werror but failed with -Werror." \ 13976ad07a4SPeter Maydell "This is probably a bug in the configure script. The failing command" \ 14076ad07a4SPeter Maydell "will be at the bottom of config.log." \ 14176ad07a4SPeter Maydell "You can run configure with --disable-werror to bypass this check." 1428dc38a78SPeter Maydell} 1438dc38a78SPeter Maydell 1449c83ffd8SPeter Maydelldo_cc() { 1454dba2789SPaolo Bonzini do_compiler "$cc" $CPU_CFLAGS "$@" 1469c83ffd8SPeter Maydell} 1479c83ffd8SPeter Maydell 1489c83ffd8SPeter Maydelldo_cxx() { 1494dba2789SPaolo Bonzini do_compiler "$cxx" $CPU_CFLAGS "$@" 1509c83ffd8SPeter Maydell} 1519c83ffd8SPeter Maydell 1524cb37d11SPhilippe Mathieu-Daudédo_objc() { 1534cb37d11SPhilippe Mathieu-Daudé do_compiler "$objcc" $CPU_CFLAGS "$@" 1544cb37d11SPhilippe Mathieu-Daudé} 1554cb37d11SPhilippe Mathieu-Daudé 15600849b92SRichard Henderson# Append $2 to the variable named $1, with space separation 15700849b92SRichard Hendersonadd_to() { 15800849b92SRichard Henderson eval $1=\${$1:+\"\$$1 \"}\$2 15900849b92SRichard Henderson} 16000849b92SRichard Henderson 1619c83ffd8SPeter Maydellupdate_cxxflags() { 1629c83ffd8SPeter Maydell # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those 1639c83ffd8SPeter Maydell # options which some versions of GCC's C++ compiler complain about 1649c83ffd8SPeter Maydell # because they only make sense for C programs. 165de38c0ccSPaolo Bonzini QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS" 1668a9d3d56SRichard Henderson CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/) 1679c83ffd8SPeter Maydell for arg in $QEMU_CFLAGS; do 1689c83ffd8SPeter Maydell case $arg in 1699c83ffd8SPeter Maydell -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ 1709c83ffd8SPeter Maydell -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) 1719c83ffd8SPeter Maydell ;; 1729c83ffd8SPeter Maydell *) 1739c83ffd8SPeter Maydell QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg 1749c83ffd8SPeter Maydell ;; 1759c83ffd8SPeter Maydell esac 1769c83ffd8SPeter Maydell done 1779c83ffd8SPeter Maydell} 1789c83ffd8SPeter Maydell 17952166aa0SJuan Quintelacompile_object() { 180fd0e6053SJohn Snow local_cflags="$1" 181a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC 18252166aa0SJuan Quintela} 18352166aa0SJuan Quintela 18452166aa0SJuan Quintelacompile_prog() { 18552166aa0SJuan Quintela local_cflags="$1" 18652166aa0SJuan Quintela local_ldflags="$2" 187a2866660SPaolo Bonzini do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \ 188a2866660SPaolo Bonzini $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags 18952166aa0SJuan Quintela} 19052166aa0SJuan Quintela 19111568d6dSPaolo Bonzini# symbolically link $1 to $2. Portable version of "ln -sf". 19211568d6dSPaolo Bonzinisymlink() { 19372b8b5a1SStefan Weil rm -rf "$2" 194ec5b06d7SAnthony Liguori mkdir -p "$(dirname "$2")" 19572b8b5a1SStefan Weil ln -s "$1" "$2" 19611568d6dSPaolo Bonzini} 19711568d6dSPaolo Bonzini 1980dba6195SLoïc Minier# check whether a command is available to this shell (may be either an 1990dba6195SLoïc Minier# executable or a builtin) 2000dba6195SLoïc Minierhas() { 2010dba6195SLoïc Minier type "$1" >/dev/null 2>&1 2020dba6195SLoïc Minier} 2030dba6195SLoïc Minier 2040a01d76fSMarc-André Lureauversion_ge () { 2052df52b9bSAlex Bennée local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ') 2062df52b9bSAlex Bennée local_ver2=$(echo "$2" | tr . ' ') 2070a01d76fSMarc-André Lureau while true; do 2080a01d76fSMarc-André Lureau set x $local_ver1 2090a01d76fSMarc-André Lureau local_first=${2-0} 210c44a33e2SStefano Garzarella # 'shift 2' if $2 is set, or 'shift' if $2 is not set 211c44a33e2SStefano Garzarella shift ${2:+2} 2120a01d76fSMarc-André Lureau local_ver1=$* 2130a01d76fSMarc-André Lureau set x $local_ver2 2140a01d76fSMarc-André Lureau # the second argument finished, the first must be greater or equal 2150a01d76fSMarc-André Lureau test $# = 1 && return 0 2160a01d76fSMarc-André Lureau test $local_first -lt $2 && return 1 2170a01d76fSMarc-André Lureau test $local_first -gt $2 && return 0 218c44a33e2SStefano Garzarella shift ${2:+2} 2190a01d76fSMarc-André Lureau local_ver2=$* 2200a01d76fSMarc-André Lureau done 2210a01d76fSMarc-André Lureau} 2220a01d76fSMarc-André Lureau 2233b6b7550SPaolo Bonziniglob() { 2243b6b7550SPaolo Bonzini eval test -z '"${1#'"$2"'}"' 2253b6b7550SPaolo Bonzini} 2263b6b7550SPaolo Bonzini 227e9a3591fSChristian Borntraegerld_has() { 228e9a3591fSChristian Borntraeger $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1 229e9a3591fSChristian Borntraeger} 230e9a3591fSChristian Borntraeger 2314ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]"; 2324ace32e2SAntonio Ospitethen 2334ace32e2SAntonio Ospite error_exit "main directory cannot contain spaces nor colons" 2344ace32e2SAntonio Ospitefi 2354ace32e2SAntonio Ospite 23614211825SAntonio Ospite# default parameters 2372ff6b91eSJuan Quintelacpu="" 238a31a8642SMichael S. Tsirkiniasl="iasl" 2391e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M" 24043ce4dfeSbellardstatic="no" 2413812c0c4SJoelle van Dynecross_compile="no" 2427d13299dSbellardcross_prefix="" 24387430d5bSPaolo Bonziniaudio_drv_list="default" 244b64ec4e4SFam Zhengblock_drv_rw_whitelist="" 245b64ec4e4SFam Zhengblock_drv_ro_whitelist="" 246e49d021eSPeter Maydellhost_cc="cc" 247cdad781dSDaniele Buonolto="false" 24863678e17SSteven Noonanstack_protector="" 2491e4f6065SDaniele Buonosafe_stack="" 250afc3a8f9SAlex Bennéeuse_containers="yes" 251f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") 252ac0df51dSaliguori 25392712822SDaniel P. Berrangeif test -e "$source_path/.git" 25492712822SDaniel P. Berrangethen 2557d7dbf9dSDan Streetman git_submodules_action="update" 25692712822SDaniel P. Berrangeelse 2577d7dbf9dSDan Streetman git_submodules_action="ignore" 25892712822SDaniel P. Berrangefi 2592d652f24SPaolo Bonzini 2602d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb" 261cc84d63aSDaniel P. Berrangegit="git" 262ac0df51dSaliguori 263afb63ebdSStefan Weil# Don't accept a target_list environment variable. 264afb63ebdSStefan Weilunset target_list 265447e133fSAlex Bennéeunset target_list_exclude 266377529c0SPaolo Bonzini 267377529c0SPaolo Bonzini# Default value for a variable defining feature "foo". 268377529c0SPaolo Bonzini# * foo="no" feature will only be used if --enable-foo arg is given 269377529c0SPaolo Bonzini# * foo="" feature will be searched for, and if found, will be used 270377529c0SPaolo Bonzini# unless --disable-foo is given 271377529c0SPaolo Bonzini# * foo="yes" this value will only be set by --enable-foo flag. 272377529c0SPaolo Bonzini# feature will searched for, 273377529c0SPaolo Bonzini# if not found, configure exits with error 274377529c0SPaolo Bonzini# 275377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args. 276377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it 277377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found. 278377529c0SPaolo Bonzini 279c87ea116SAlex Bennéedefault_feature="" 280c87ea116SAlex Bennée# parse CC options second 281c87ea116SAlex Bennéefor opt do 282c87ea116SAlex Bennée optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 283c87ea116SAlex Bennée case "$opt" in 284c87ea116SAlex Bennée --without-default-features) 285c87ea116SAlex Bennée default_feature="no" 286c87ea116SAlex Bennée ;; 287c87ea116SAlex Bennée esac 288c87ea116SAlex Bennéedone 289c87ea116SAlex Bennée 290a2866660SPaolo BonziniEXTRA_CFLAGS="" 291a2866660SPaolo BonziniEXTRA_CXXFLAGS="" 292e910c7d9SPhilippe Mathieu-DaudéEXTRA_OBJCFLAGS="" 293a2866660SPaolo BonziniEXTRA_LDFLAGS="" 294a2866660SPaolo Bonzini 295c87ea116SAlex Bennéexen_ctrl_version="$default_feature" 2960848f8acSThomas Huthvhost_kernel="$default_feature" 297c87ea116SAlex Bennéevhost_net="$default_feature" 298c87ea116SAlex Bennéevhost_crypto="$default_feature" 299c87ea116SAlex Bennéevhost_scsi="$default_feature" 300c87ea116SAlex Bennéevhost_vsock="$default_feature" 301d88618f7SStefan Hajnoczivhost_user="no" 302c87ea116SAlex Bennéevhost_user_fs="$default_feature" 3030848f8acSThomas Huthvhost_vdpa="$default_feature" 30428609749SPaolo Bonzinidebug_info="yes" 305377529c0SPaolo Bonzinidebug_tcg="no" 306377529c0SPaolo Bonzinidebug="no" 307247724cbSMarc-André Lureausanitizers="no" 3080aebab04SLingfeng Yangtsan="no" 3091f3f2bfeSMichael Tokarevfortify_source="yes" 3101d728c39SBlue Swirlgcov="no" 311c7328271SMiroslav RezaninaEXESUF="" 31217969268SFam Zhengmodules="no" 313377529c0SPaolo Bonziniprefix="/usr/local" 31410ff82d1SMarc-André Lureauqemu_suffix="qemu" 315377529c0SPaolo Bonzinisoftmmu="yes" 316b915a2f1SPaolo Bonzinilinux_user="" 317b915a2f1SPaolo Bonzinibsd_user="" 318377529c0SPaolo Bonzinipkgversion="" 31940d6444eSAvi Kivitypie="" 320377529c0SPaolo Bonzinitrace_file="trace" 321519175a2SAlex Barcelocoroutine="" 322a1c5e949SDaniel P. Berrangetls_priority="NORMAL" 323ba4dd2aaSAlex Bennéeplugins="$default_feature" 324a5665051SPaolo Bonzinimeson="" 3253b4da132SPaolo Bonzinimeson_args="" 32648328880SPaolo Bonzinininja="" 327a5665051SPaolo Bonziniskip_meson=no 328377529c0SPaolo Bonzini 3293b4da132SPaolo Bonzini# The following Meson options are handled manually (still they 3303b4da132SPaolo Bonzini# are included in the automatically generated help message) 3313b4da132SPaolo Bonzini 3323b4da132SPaolo Bonzini# 1. Track which submodules are needed 3330577e84dSThomas Huthif test "$default_feature" = no ; then 3340577e84dSThomas Huth capstone="disabled" 3350577e84dSThomas Huth slirp="disabled" 3360577e84dSThomas Huthelse 3373b4da132SPaolo Bonzini capstone="auto" 3383b4da132SPaolo Bonzini slirp="auto" 3390577e84dSThomas Huthfi 3400577e84dSThomas Huthfdt="auto" 3413b4da132SPaolo Bonzini 3423b4da132SPaolo Bonzini# 2. Support --with/--without option 3433b4da132SPaolo Bonzinidefault_devices="true" 3443b4da132SPaolo Bonzini 3453b4da132SPaolo Bonzini# 3. Automatically enable/disable other options 3463b4da132SPaolo Bonzinitcg="enabled" 3473b4da132SPaolo Bonzinicfi="false" 3483b4da132SPaolo Bonzini 3493b4da132SPaolo Bonzini# 4. Detection partly done in configure 3503b4da132SPaolo Bonzinixen=${default_feature:+disabled} 351898be3e0SPeter Maydell 352c87ea116SAlex Bennée# parse CC options second 353ac0df51dSaliguorifor opt do 35489138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 355ac0df51dSaliguori case "$opt" in 356ac0df51dSaliguori --cross-prefix=*) cross_prefix="$optarg" 3573812c0c4SJoelle van Dyne cross_compile="yes" 358ac0df51dSaliguori ;; 3593d8df640SPaolo Bonzini --cc=*) CC="$optarg" 360ac0df51dSaliguori ;; 36183f73fceSTomoki Sekiyama --cxx=*) CXX="$optarg" 36283f73fceSTomoki Sekiyama ;; 3632ff6b91eSJuan Quintela --cpu=*) cpu="$optarg" 3642ff6b91eSJuan Quintela ;; 365a2866660SPaolo Bonzini --extra-cflags=*) 366a2866660SPaolo Bonzini EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg" 367a2866660SPaolo Bonzini EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 368e910c7d9SPhilippe Mathieu-Daudé EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 369e2a2ed06SJuan Quintela ;; 370a2866660SPaolo Bonzini --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg" 37111cde1c8SBruno Dominguez ;; 372e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) EXTRA_OBJCFLAGS="$EXTRA_OBJCFLAGS $optarg" 373e910c7d9SPhilippe Mathieu-Daudé ;; 374a2866660SPaolo Bonzini --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg" 375e2a2ed06SJuan Quintela ;; 376d75402b5SAlex Bennée --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option" 377d75402b5SAlex Bennée ;; 378479ca4ccSMatheus Ferst --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*} 379d422b2bcSAlex Bennée eval "cross_cc_cflags_${cc_arch}=\$optarg" 3802038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}" 381d422b2bcSAlex Bennée ;; 382d75402b5SAlex Bennée --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*} 383d75402b5SAlex Bennée eval "cross_cc_${cc_arch}=\$optarg" 3842038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}" 385d75402b5SAlex Bennée ;; 386ac0df51dSaliguori esac 387ac0df51dSaliguoridone 388ac0df51dSaliguori# OS specific 389ac0df51dSaliguori# Using uname is really, really broken. Once we have the right set of checks 39093148aa5SStefan Weil# we can eliminate its usage altogether. 391ac0df51dSaliguori 392e49d021eSPeter Maydell# Preferred compiler: 393e49d021eSPeter Maydell# ${CC} (if set) 394e49d021eSPeter Maydell# ${cross_prefix}gcc (if cross-prefix specified) 395e49d021eSPeter Maydell# system compiler 396e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then 397e49d021eSPeter Maydell cc="$host_cc" 398e49d021eSPeter Maydellelse 399b3198cc2SStuart Yoder cc="${CC-${cross_prefix}gcc}" 400e49d021eSPeter Maydellfi 401e49d021eSPeter Maydell 40283f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then 40383f73fceSTomoki Sekiyama cxx="c++" 40483f73fceSTomoki Sekiyamaelse 40583f73fceSTomoki Sekiyama cxx="${CXX-${cross_prefix}g++}" 40683f73fceSTomoki Sekiyamafi 40783f73fceSTomoki Sekiyama 408b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}" 409cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}" 4105f6f0e27SRichard Hendersonccas="${CCAS-$cc}" 4113dd46c78SBlue Swirlcpp="${CPP-$cc -E}" 412b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}" 413b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}" 4149f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}" 4154852ee95SStefan Weilnm="${NM-${cross_prefix}nm}" 41635acbb30SPaolo Bonzinismbd="$SMBD" 417b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}" 418*158bb224SKonstantin Kostiukwidl="${WIDL-${cross_prefix}widl}" 419b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}" 42017884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}" 42117884d7bSSergei Trofimovichquery_pkg_config() { 42217884d7bSSergei Trofimovich "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@" 42317884d7bSSergei Trofimovich} 42417884d7bSSergei Trofimovichpkg_config=query_pkg_config 42547c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}" 426ac0df51dSaliguori 427be17dc90SMichael S. Tsirkin# default flags for all hosts 4282d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where 4292d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected 4302d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it 4312d31515bSPeter Maydell# provides these semantics.) 432de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv" 433086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" 434c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" 435be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" 4365770e8afSPaolo Bonzini 437de38c0ccSPaolo BonziniQEMU_LDFLAGS= 438de38c0ccSPaolo Bonzini 4395770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson 4408a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall" 4415770e8afSPaolo BonziniCONFIGURE_LDFLAGS= 442086d5f75SPaolo Bonzini 443be17dc90SMichael S. Tsirkin 444ac0df51dSaliguoricheck_define() { 445ac0df51dSaliguoricat > $TMPC <<EOF 446ac0df51dSaliguori#if !defined($1) 447fd786e1aSPeter Maydell#error $1 not defined 448ac0df51dSaliguori#endif 449ac0df51dSaliguoriint main(void) { return 0; } 450ac0df51dSaliguoriEOF 45152166aa0SJuan Quintela compile_object 452ac0df51dSaliguori} 453ac0df51dSaliguori 454307119e7SGerd Hoffmanncheck_include() { 455307119e7SGerd Hoffmanncat > $TMPC <<EOF 456307119e7SGerd Hoffmann#include <$1> 457307119e7SGerd Hoffmannint main(void) { return 0; } 458307119e7SGerd HoffmannEOF 459307119e7SGerd Hoffmann compile_object 460307119e7SGerd Hoffmann} 461307119e7SGerd Hoffmann 46293b25869SJohn Snowwrite_c_skeleton() { 46393b25869SJohn Snow cat > $TMPC <<EOF 46493b25869SJohn Snowint main(void) { return 0; } 46593b25869SJohn SnowEOF 46693b25869SJohn Snow} 46793b25869SJohn Snow 468bbea4050SPeter Maydellif check_define __linux__ ; then 469ba7c60c2SPaolo Bonzini targetos=linux 470bbea4050SPeter Maydellelif check_define _WIN32 ; then 471ba7c60c2SPaolo Bonzini targetos=windows 472bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then 473ba7c60c2SPaolo Bonzini targetos=openbsd 474bbea4050SPeter Maydellelif check_define __sun__ ; then 475ba7c60c2SPaolo Bonzini targetos=sunos 476bbea4050SPeter Maydellelif check_define __HAIKU__ ; then 477ba7c60c2SPaolo Bonzini targetos=haiku 478951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then 479ba7c60c2SPaolo Bonzini targetos=freebsd 480951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then 481ba7c60c2SPaolo Bonzini targetos=gnu/kfreebsd 482951fedfcSPeter Maydellelif check_define __DragonFly__ ; then 483ba7c60c2SPaolo Bonzini targetos=dragonfly 484951fedfcSPeter Maydellelif check_define __NetBSD__; then 485ba7c60c2SPaolo Bonzini targetos=netbsd 486951fedfcSPeter Maydellelif check_define __APPLE__; then 487ba7c60c2SPaolo Bonzini targetos=darwin 488bbea4050SPeter Maydellelse 489951fedfcSPeter Maydell # This is a fatal error, but don't report it yet, because we 490951fedfcSPeter Maydell # might be going to just print the --help text, or it might 491951fedfcSPeter Maydell # be the result of a missing compiler. 492ba7c60c2SPaolo Bonzini targetos=bogus 493bbea4050SPeter Maydellfi 494bbea4050SPeter Maydell 49565eff01bSPaolo Bonzini# OS specific 49665eff01bSPaolo Bonzini 4973b0d8643SPaolo Bonzinimingw32="no" 4983b0d8643SPaolo Bonzinibsd="no" 4993b0d8643SPaolo Bonzinilinux="no" 5003b0d8643SPaolo Bonzinisolaris="no" 50165eff01bSPaolo Bonzinicase $targetos in 50265eff01bSPaolo Bonziniwindows) 50365eff01bSPaolo Bonzini mingw32="yes" 50465eff01bSPaolo Bonzini plugins="no" 50565eff01bSPaolo Bonzini pie="no" 50665eff01bSPaolo Bonzini;; 50765eff01bSPaolo Bonzinignu/kfreebsd) 50865eff01bSPaolo Bonzini bsd="yes" 50965eff01bSPaolo Bonzini;; 51065eff01bSPaolo Bonzinifreebsd) 51165eff01bSPaolo Bonzini bsd="yes" 51265eff01bSPaolo Bonzini make="${MAKE-gmake}" 51365eff01bSPaolo Bonzini # needed for kinfo_getvmmap(3) in libutil.h 51465eff01bSPaolo Bonzini;; 51565eff01bSPaolo Bonzinidragonfly) 51665eff01bSPaolo Bonzini bsd="yes" 51765eff01bSPaolo Bonzini make="${MAKE-gmake}" 51865eff01bSPaolo Bonzini;; 51965eff01bSPaolo Bonzininetbsd) 52065eff01bSPaolo Bonzini bsd="yes" 52165eff01bSPaolo Bonzini make="${MAKE-gmake}" 52265eff01bSPaolo Bonzini;; 52365eff01bSPaolo Bonziniopenbsd) 52465eff01bSPaolo Bonzini bsd="yes" 52565eff01bSPaolo Bonzini make="${MAKE-gmake}" 52665eff01bSPaolo Bonzini;; 52765eff01bSPaolo Bonzinidarwin) 52865eff01bSPaolo Bonzini bsd="yes" 52965eff01bSPaolo Bonzini darwin="yes" 53065eff01bSPaolo Bonzini # Disable attempts to use ObjectiveC features in os/object.h since they 53165eff01bSPaolo Bonzini # won't work when we're compiling with gcc as a C compiler. 53265eff01bSPaolo Bonzini QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS" 53365eff01bSPaolo Bonzini;; 53465eff01bSPaolo Bonzinisunos) 53565eff01bSPaolo Bonzini solaris="yes" 53665eff01bSPaolo Bonzini make="${MAKE-gmake}" 53765eff01bSPaolo Bonzini# needed for CMSG_ macros in sys/socket.h 53865eff01bSPaolo Bonzini QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS" 53965eff01bSPaolo Bonzini# needed for TIOCWIN* defines in termios.h 54065eff01bSPaolo Bonzini QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS" 54165eff01bSPaolo Bonzini # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo 54265eff01bSPaolo Bonzini # Note that this check is broken for cross-compilation: if you're 543bbea4050SPeter Maydell # cross-compiling to one of these OSes then you'll need to specify 544bbea4050SPeter Maydell # the correct CPU with the --cpu option. 545bbea4050SPeter Maydell if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then 546bbea4050SPeter Maydell cpu="x86_64" 547bbea4050SPeter Maydell fi 54865eff01bSPaolo Bonzini;; 54965eff01bSPaolo Bonzinihaiku) 55065eff01bSPaolo Bonzini pie="no" 55165eff01bSPaolo Bonzini QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS" 55265eff01bSPaolo Bonzini;; 55365eff01bSPaolo Bonzinilinux) 55465eff01bSPaolo Bonzini linux="yes" 55565eff01bSPaolo Bonzini vhost_user=${default_feature:-yes} 55665eff01bSPaolo Bonzini;; 557bbea4050SPeter Maydellesac 558bbea4050SPeter Maydell 5592ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then 5602ff6b91eSJuan Quintela # command line argument 5612ff6b91eSJuan Quintela : 5622ff6b91eSJuan Quintelaelif check_define __i386__ ; then 563ac0df51dSaliguori cpu="i386" 564ac0df51dSaliguorielif check_define __x86_64__ ; then 565c72b26ecSRichard Henderson if check_define __ILP32__ ; then 566c72b26ecSRichard Henderson cpu="x32" 567c72b26ecSRichard Henderson else 568ac0df51dSaliguori cpu="x86_64" 569c72b26ecSRichard Henderson fi 5703aa9bd6cSblueswir1elif check_define __sparc__ ; then 5713aa9bd6cSblueswir1 if check_define __arch64__ ; then 5723aa9bd6cSblueswir1 cpu="sparc64" 5733aa9bd6cSblueswir1 else 5743aa9bd6cSblueswir1 cpu="sparc" 5753aa9bd6cSblueswir1 fi 576fdf7ed96Smalcelif check_define _ARCH_PPC ; then 577fdf7ed96Smalc if check_define _ARCH_PPC64 ; then 578f8378accSRichard Henderson if check_define _LITTLE_ENDIAN ; then 579f8378accSRichard Henderson cpu="ppc64le" 580f8378accSRichard Henderson else 581fdf7ed96Smalc cpu="ppc64" 582f8378accSRichard Henderson fi 583ac0df51dSaliguori else 584fdf7ed96Smalc cpu="ppc" 585fdf7ed96Smalc fi 586afa05235SAurelien Jarnoelif check_define __mips__ ; then 587afa05235SAurelien Jarno cpu="mips" 588d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then 589d66ed0eaSAurelien Jarno if check_define __s390x__ ; then 590d66ed0eaSAurelien Jarno cpu="s390x" 591d66ed0eaSAurelien Jarno else 592d66ed0eaSAurelien Jarno cpu="s390" 593d66ed0eaSAurelien Jarno fi 594c4f80543SAlistair Franciselif check_define __riscv ; then 595ba0e7333SRichard Henderson cpu="riscv" 59621d89f84SPeter Maydellelif check_define __arm__ ; then 59721d89f84SPeter Maydell cpu="arm" 5981f080313SClaudio Fontanaelif check_define __aarch64__ ; then 5991f080313SClaudio Fontana cpu="aarch64" 600dfcf900bSWANG Xueruielif check_define __loongarch64 ; then 601dfcf900bSWANG Xuerui cpu="loongarch64" 602fdf7ed96Smalcelse 60389138857SStefan Weil cpu=$(uname -m) 604ac0df51dSaliguorifi 605ac0df51dSaliguori 606823eb013SPaolo Bonzini# Normalise host CPU name, set multilib cflags 607359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests. 6087d13299dSbellardcase "$cpu" in 609e4da0e39SPaolo Bonzini armv*b|armv*l|arm) 610e4da0e39SPaolo Bonzini cpu="arm" ;; 611e4da0e39SPaolo Bonzini 6127d13299dSbellard i386|i486|i586|i686|i86pc|BePC) 61397a847bcSbellard cpu="i386" 614e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 615e4da0e39SPaolo Bonzini x32) 6164da270beSPaolo Bonzini cpu="x86_64" 617e4da0e39SPaolo Bonzini CPU_CFLAGS="-mx32" ;; 618aaa5fa14Saurel32 x86_64|amd64) 619aaa5fa14Saurel32 cpu="x86_64" 620e4da0e39SPaolo Bonzini # ??? Only extremely old AMD cpus do not have cmpxchg16b. 621e4da0e39SPaolo Bonzini # If we truly care, we should simply detect this case at 622e4da0e39SPaolo Bonzini # runtime and generate the fallback to serial emulation. 623e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcx16" ;; 624e4da0e39SPaolo Bonzini 625afa05235SAurelien Jarno mips*) 626e4da0e39SPaolo Bonzini cpu="mips" ;; 627e4da0e39SPaolo Bonzini 628e4da0e39SPaolo Bonzini ppc) 629e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32" ;; 630e4da0e39SPaolo Bonzini ppc64) 631ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mbig-endian" ;; 632e4da0e39SPaolo Bonzini ppc64le) 633d8ff892dSPaolo Bonzini cpu="ppc64" 634ced5cfffSMiroslav Rezanina CPU_CFLAGS="-m64 -mlittle-endian" ;; 635e4da0e39SPaolo Bonzini 636e4da0e39SPaolo Bonzini s390) 637823eb013SPaolo Bonzini CPU_CFLAGS="-m31" ;; 638e4da0e39SPaolo Bonzini s390x) 639e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64" ;; 640e4da0e39SPaolo Bonzini 6413142255cSblueswir1 sparc|sun4[cdmuv]) 642ae228531Sbellard cpu="sparc" 643e4da0e39SPaolo Bonzini CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;; 644e4da0e39SPaolo Bonzini sparc64) 645e4da0e39SPaolo Bonzini CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;; 6467d13299dSbellardesac 647e2d52ad3SJuan Quintela 6480db4a067SPaolo Bonzini: ${make=${MAKE-make}} 649b6daf4d3SPaolo Bonzini 650faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally 651faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so 652ddf90699SEduardo Habkost# we check that too 653faf44142SDaniel P. Berrangépython= 6540a01d76fSMarc-André Lureauexplicit_python=no 655ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python 656faf44142SDaniel P. Berrangédo 657faf44142SDaniel P. Berrangé if has "$binary" 658faf44142SDaniel P. Berrangé then 65995c5f2deSPaolo Bonzini python=$(command -v "$binary") 660faf44142SDaniel P. Berrangé break 661faf44142SDaniel P. Berrangé fi 662faf44142SDaniel P. Berrangédone 663903458c8SMarkus Armbruster 664903458c8SMarkus Armbruster 66539d87c8cSAlex Bennée# Check for ancillary tools used in testing 66639d87c8cSAlex Bennéegenisoimage= 6673df437c7SAlex Bennéefor binary in genisoimage mkisofs 66839d87c8cSAlex Bennéedo 66939d87c8cSAlex Bennée if has $binary 67039d87c8cSAlex Bennée then 67139d87c8cSAlex Bennée genisoimage=$(command -v "$binary") 67239d87c8cSAlex Bennée break 67339d87c8cSAlex Bennée fi 67439d87c8cSAlex Bennéedone 67539d87c8cSAlex Bennée 6763c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC 6773c4a4d0dSPeter Maydellif has clang; then 6783c4a4d0dSPeter Maydell objcc=clang 6793c4a4d0dSPeter Maydellelse 6803c4a4d0dSPeter Maydell objcc="$cc" 6813c4a4d0dSPeter Maydellfi 6823c4a4d0dSPeter Maydell 6833457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then 6843457a3f8SJuan Quintela EXESUF=".exe" 68578e9d4adSStefan Weil # MinGW needs -mthreads for TLS and macro _MT. 6865770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS" 68793b25869SJohn Snow write_c_skeleton; 688d17f305aSPaolo Bonzini prefix="/qemu" 68977433a5fSMarc-André Lureau qemu_suffix="" 6903457a3f8SJuan Quintelafi 6913457a3f8SJuan Quintela 692487fefdbSAnthony Liguoriwerror="" 69385aa5189Sbellard 69461d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh 69561d63097SPaolo Bonzini 69661d63097SPaolo Bonzinimeson_options= 69761d63097SPaolo Bonzinimeson_option_parse() { 69861d63097SPaolo Bonzini meson_options="$meson_options $(_meson_option_parse "$@")" 69961d63097SPaolo Bonzini if test $? -eq 1; then 70061d63097SPaolo Bonzini echo "ERROR: unknown option $1" 70161d63097SPaolo Bonzini echo "Try '$0 --help' for more information" 70261d63097SPaolo Bonzini exit 1 70361d63097SPaolo Bonzini fi 70461d63097SPaolo Bonzini} 70561d63097SPaolo Bonzini 7067d13299dSbellardfor opt do 70789138857SStefan Weil optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') 7087d13299dSbellard case "$opt" in 7092efc3265Sbellard --help|-h) show_help=yes 7102efc3265Sbellard ;; 71199123e13SMike Frysinger --version|-V) exec cat $source_path/VERSION 71299123e13SMike Frysinger ;; 713b1a550a0Spbrook --prefix=*) prefix="$optarg" 7147d13299dSbellard ;; 715b1a550a0Spbrook --interp-prefix=*) interp_prefix="$optarg" 71632ce6337Sbellard ;; 717ac0df51dSaliguori --cross-prefix=*) 7187d13299dSbellard ;; 719ac0df51dSaliguori --cc=*) 7207d13299dSbellard ;; 721b1a550a0Spbrook --host-cc=*) host_cc="$optarg" 72283469015Sbellard ;; 72383f73fceSTomoki Sekiyama --cxx=*) 72483f73fceSTomoki Sekiyama ;; 725e007dbecSMichael S. Tsirkin --iasl=*) iasl="$optarg" 726e007dbecSMichael S. Tsirkin ;; 7273c4a4d0dSPeter Maydell --objcc=*) objcc="$optarg" 7283c4a4d0dSPeter Maydell ;; 729b1a550a0Spbrook --make=*) make="$optarg" 7307d13299dSbellard ;; 731b6daf4d3SPaolo Bonzini --install=*) 7326a882643Spbrook ;; 7330a01d76fSMarc-André Lureau --python=*) python="$optarg" ; explicit_python=yes 734c886edfbSBlue Swirl ;; 7352eb054c2SPeter Maydell --sphinx-build=*) sphinx_build="$optarg" 7362eb054c2SPeter Maydell ;; 737a5665051SPaolo Bonzini --skip-meson) skip_meson=yes 738a5665051SPaolo Bonzini ;; 739a5665051SPaolo Bonzini --meson=*) meson="$optarg" 740a5665051SPaolo Bonzini ;; 74148328880SPaolo Bonzini --ninja=*) ninja="$optarg" 74248328880SPaolo Bonzini ;; 743e2d8830eSBrad --smbd=*) smbd="$optarg" 744e2d8830eSBrad ;; 745e2a2ed06SJuan Quintela --extra-cflags=*) 7467d13299dSbellard ;; 74711cde1c8SBruno Dominguez --extra-cxxflags=*) 74811cde1c8SBruno Dominguez ;; 749e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=*) 750e910c7d9SPhilippe Mathieu-Daudé ;; 751e2a2ed06SJuan Quintela --extra-ldflags=*) 7527d13299dSbellard ;; 753d75402b5SAlex Bennée --cross-cc-*) 754d75402b5SAlex Bennée ;; 75528609749SPaolo Bonzini --enable-debug-info) debug_info="yes" 75628609749SPaolo Bonzini ;; 75728609749SPaolo Bonzini --disable-debug-info) debug_info="no" 75828609749SPaolo Bonzini ;; 75917969268SFam Zheng --enable-modules) 76017969268SFam Zheng modules="yes" 76117969268SFam Zheng ;; 7623aa88b31SStefan Hajnoczi --disable-modules) 7633aa88b31SStefan Hajnoczi modules="no" 7643aa88b31SStefan Hajnoczi ;; 7652ff6b91eSJuan Quintela --cpu=*) 7667d13299dSbellard ;; 767b1a550a0Spbrook --target-list=*) target_list="$optarg" 768447e133fSAlex Bennée if test "$target_list_exclude"; then 769447e133fSAlex Bennée error_exit "Can't mix --target-list with --target-list-exclude" 770447e133fSAlex Bennée fi 771447e133fSAlex Bennée ;; 772447e133fSAlex Bennée --target-list-exclude=*) target_list_exclude="$optarg" 773447e133fSAlex Bennée if test "$target_list"; then 774447e133fSAlex Bennée error_exit "Can't mix --target-list-exclude with --target-list" 775447e133fSAlex Bennée fi 776de83cd02Sbellard ;; 77774242e0fSPaolo Bonzini --with-trace-file=*) trace_file="$optarg" 7789410b56cSPrerna Saxena ;; 7797bc3ca7fSPaolo Bonzini --with-default-devices) default_devices="true" 780f3494749SPaolo Bonzini ;; 7817bc3ca7fSPaolo Bonzini --without-default-devices) default_devices="false" 782f3494749SPaolo Bonzini ;; 783d1d5e9eeSAlex Bennée --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option" 784d1d5e9eeSAlex Bennée ;; 785d1d5e9eeSAlex Bennée --with-devices-*) device_arch=${opt#--with-devices-}; 786d1d5e9eeSAlex Bennée device_arch=${device_arch%%=*} 787d1d5e9eeSAlex Bennée cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak 788d1d5e9eeSAlex Bennée if test -f "$cf"; then 789d1d5e9eeSAlex Bennée device_archs="$device_archs $device_arch" 790d1d5e9eeSAlex Bennée eval "devices_${device_arch}=\$optarg" 791d1d5e9eeSAlex Bennée else 792d1d5e9eeSAlex Bennée error_exit "File $cf does not exist" 793d1d5e9eeSAlex Bennée fi 794d1d5e9eeSAlex Bennée ;; 795c87ea116SAlex Bennée --without-default-features) # processed above 796c87ea116SAlex Bennée ;; 7971d728c39SBlue Swirl --enable-gcov) gcov="yes" 7981d728c39SBlue Swirl ;; 79979427693SLoïc Minier --static) 80079427693SLoïc Minier static="yes" 80117884d7bSSergei Trofimovich QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS" 80243ce4dfeSbellard ;; 8030b24e75fSPaolo Bonzini --mandir=*) mandir="$optarg" 8040b24e75fSPaolo Bonzini ;; 8050b24e75fSPaolo Bonzini --bindir=*) bindir="$optarg" 8060b24e75fSPaolo Bonzini ;; 8073aa5d2beSAlon Levy --libdir=*) libdir="$optarg" 8083aa5d2beSAlon Levy ;; 8098bf188aaSMichael Tokarev --libexecdir=*) libexecdir="$optarg" 8108bf188aaSMichael Tokarev ;; 8110f94d6daSAlon Levy --includedir=*) includedir="$optarg" 8120f94d6daSAlon Levy ;; 813528ae5b8SEduardo Habkost --datadir=*) datadir="$optarg" 8140b24e75fSPaolo Bonzini ;; 81577433a5fSMarc-André Lureau --with-suffix=*) qemu_suffix="$optarg" 816023d3d67SEduardo Habkost ;; 817c6502638SBruce Rogers --docdir=*) docdir="$optarg" 8180b24e75fSPaolo Bonzini ;; 819fe0038beSPaolo Bonzini --localedir=*) localedir="$optarg" 820fe0038beSPaolo Bonzini ;; 821ca2fb938SAndre Przywara --sysconfdir=*) sysconfdir="$optarg" 82207381cc1SAnthony Liguori ;; 823785c23aeSLuiz Capitulino --localstatedir=*) local_statedir="$optarg" 824785c23aeSLuiz Capitulino ;; 8253d5eecabSGerd Hoffmann --firmwarepath=*) firmwarepath="$optarg" 8263d5eecabSGerd Hoffmann ;; 827181ce1d0SOlaf Hering --host=*|--build=*|\ 828181ce1d0SOlaf Hering --disable-dependency-tracking|\ 829785c23aeSLuiz Capitulino --sbindir=*|--sharedstatedir=*|\ 830fe0038beSPaolo Bonzini --oldincludedir=*|--datarootdir=*|--infodir=*|\ 831023ddd74SMax Filippov --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) 832023ddd74SMax Filippov # These switches are silently ignored, for compatibility with 833023ddd74SMax Filippov # autoconf-generated configure scripts. This allows QEMU's 834023ddd74SMax Filippov # configure to be used by RPM and similar macros that set 835023ddd74SMax Filippov # lots of directory switches by default. 836023ddd74SMax Filippov ;; 8370c58ac1cSmalc --audio-drv-list=*) audio_drv_list="$optarg" 8380c58ac1cSmalc ;; 83989138857SStefan Weil --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 840b64ec4e4SFam Zheng ;; 84189138857SStefan Weil --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g') 842eb852011SMarkus Armbruster ;; 843f8393946Saurel32 --enable-debug-tcg) debug_tcg="yes" 844f8393946Saurel32 ;; 845f8393946Saurel32 --disable-debug-tcg) debug_tcg="no" 846f8393946Saurel32 ;; 847f3d08ee6SPaul Brook --enable-debug) 848f3d08ee6SPaul Brook # Enable debugging options that aren't excessively noisy 849f3d08ee6SPaul Brook debug_tcg="yes" 850c55cf6abSPaolo Bonzini meson_option_parse --enable-debug-mutex "" 851f3d08ee6SPaul Brook debug="yes" 852b553a042SJohn Snow fortify_source="no" 853f3d08ee6SPaul Brook ;; 854247724cbSMarc-André Lureau --enable-sanitizers) sanitizers="yes" 855247724cbSMarc-André Lureau ;; 856247724cbSMarc-André Lureau --disable-sanitizers) sanitizers="no" 857247724cbSMarc-André Lureau ;; 8580aebab04SLingfeng Yang --enable-tsan) tsan="yes" 8590aebab04SLingfeng Yang ;; 8600aebab04SLingfeng Yang --disable-tsan) tsan="no" 8610aebab04SLingfeng Yang ;; 8624d34a86bSPaolo Bonzini --disable-slirp) slirp="disabled" 863c20709aaSbellard ;; 864fd6fc214SPaolo Bonzini --enable-slirp) slirp="enabled" 865fd6fc214SPaolo Bonzini ;; 8664d34a86bSPaolo Bonzini --enable-slirp=git) slirp="internal" 8677c57bdd8SMarc-André Lureau ;; 86803a3c0b3SPaolo Bonzini --enable-slirp=*) slirp="$optarg" 869675b9b53SMarc-André Lureau ;; 8701badb709SPaolo Bonzini --disable-xen) xen="disabled" 871e37630caSaliguori ;; 8721badb709SPaolo Bonzini --enable-xen) xen="enabled" 873fc321b4bSJuan Quintela ;; 8741badb709SPaolo Bonzini --disable-tcg) tcg="disabled" 875d1a14257SAlex Bennée plugins="no" 876b3f6ea7eSPaolo Bonzini ;; 8771badb709SPaolo Bonzini --enable-tcg) tcg="enabled" 878b3f6ea7eSPaolo Bonzini ;; 879cad25d69Spbrook --disable-system) softmmu="no" 8800a8e90f4Spbrook ;; 881cad25d69Spbrook --enable-system) softmmu="yes" 8820a8e90f4Spbrook ;; 8830953a80fSZachary Amsden --disable-user) 8840953a80fSZachary Amsden linux_user="no" ; 8850953a80fSZachary Amsden bsd_user="no" ; 8860953a80fSZachary Amsden ;; 8870953a80fSZachary Amsden --enable-user) ;; 888831b7825Sths --disable-linux-user) linux_user="no" 8890a8e90f4Spbrook ;; 890831b7825Sths --enable-linux-user) linux_user="yes" 891831b7825Sths ;; 89284778508Sblueswir1 --disable-bsd-user) bsd_user="no" 89384778508Sblueswir1 ;; 89484778508Sblueswir1 --enable-bsd-user) bsd_user="yes" 89584778508Sblueswir1 ;; 89640d6444eSAvi Kivity --enable-pie) pie="yes" 89734005a00SKirill A. Shutemov ;; 89840d6444eSAvi Kivity --disable-pie) pie="no" 89934005a00SKirill A. Shutemov ;; 90085aa5189Sbellard --enable-werror) werror="yes" 90185aa5189Sbellard ;; 90285aa5189Sbellard --disable-werror) werror="no" 90385aa5189Sbellard ;; 904cdad781dSDaniele Buono --enable-lto) lto="true" 905cdad781dSDaniele Buono ;; 906cdad781dSDaniele Buono --disable-lto) lto="false" 907cdad781dSDaniele Buono ;; 90863678e17SSteven Noonan --enable-stack-protector) stack_protector="yes" 90963678e17SSteven Noonan ;; 91063678e17SSteven Noonan --disable-stack-protector) stack_protector="no" 91163678e17SSteven Noonan ;; 9121e4f6065SDaniele Buono --enable-safe-stack) safe_stack="yes" 9131e4f6065SDaniele Buono ;; 9141e4f6065SDaniele Buono --disable-safe-stack) safe_stack="no" 9151e4f6065SDaniele Buono ;; 9169e62ba48SDaniele Buono --enable-cfi) 9179e62ba48SDaniele Buono cfi="true"; 9189e62ba48SDaniele Buono lto="true"; 9199e62ba48SDaniele Buono ;; 9209e62ba48SDaniele Buono --disable-cfi) cfi="false" 9219e62ba48SDaniele Buono ;; 922fbb4121dSPaolo Bonzini --disable-fdt) fdt="disabled" 9232df87df7SJuan Quintela ;; 924fbb4121dSPaolo Bonzini --enable-fdt) fdt="enabled" 925fbb4121dSPaolo Bonzini ;; 926fbb4121dSPaolo Bonzini --enable-fdt=git) fdt="internal" 927fbb4121dSPaolo Bonzini ;; 92803a3c0b3SPaolo Bonzini --enable-fdt=*) fdt="$optarg" 9292df87df7SJuan Quintela ;; 9307e563bfbSThomas Huth --with-pkgversion=*) pkgversion="$optarg" 9314a19f1ecSpbrook ;; 932519175a2SAlex Barcelo --with-coroutine=*) coroutine="$optarg" 933519175a2SAlex Barcelo ;; 934d5970055SMichael S. Tsirkin --disable-vhost-net) vhost_net="no" 935d5970055SMichael S. Tsirkin ;; 936d5970055SMichael S. Tsirkin --enable-vhost-net) vhost_net="yes" 937d5970055SMichael S. Tsirkin ;; 938042cea27SGonglei --disable-vhost-crypto) vhost_crypto="no" 939042cea27SGonglei ;; 940299e6f19SPaolo Bonzini --enable-vhost-crypto) vhost_crypto="yes" 941042cea27SGonglei ;; 9425e9be92dSNicholas Bellinger --disable-vhost-scsi) vhost_scsi="no" 9435e9be92dSNicholas Bellinger ;; 9445e9be92dSNicholas Bellinger --enable-vhost-scsi) vhost_scsi="yes" 9455e9be92dSNicholas Bellinger ;; 946fc0b9b0eSStefan Hajnoczi --disable-vhost-vsock) vhost_vsock="no" 947fc0b9b0eSStefan Hajnoczi ;; 948fc0b9b0eSStefan Hajnoczi --enable-vhost-vsock) vhost_vsock="yes" 949fc0b9b0eSStefan Hajnoczi ;; 95098fc1adaSDr. David Alan Gilbert --disable-vhost-user-fs) vhost_user_fs="no" 95198fc1adaSDr. David Alan Gilbert ;; 95298fc1adaSDr. David Alan Gilbert --enable-vhost-user-fs) vhost_user_fs="yes" 95398fc1adaSDr. David Alan Gilbert ;; 9541ffb3bbbSPaolo Bonzini --disable-zlib-test) 9551ece9905SAlon Levy ;; 95652b53c04SFam Zheng --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) 95752b53c04SFam Zheng echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2 958583f6e7bSStefan Hajnoczi ;; 959cb6414dfSFam Zheng --enable-vhdx|--disable-vhdx) 960cb6414dfSFam Zheng echo "$0: $opt is obsolete, VHDX driver is always built" >&2 961cb6414dfSFam Zheng ;; 962315d3184SFam Zheng --enable-uuid|--disable-uuid) 963315d3184SFam Zheng echo "$0: $opt is obsolete, UUID support is always built" >&2 964315d3184SFam Zheng ;; 965a1c5e949SDaniel P. Berrange --tls-priority=*) tls_priority="$optarg" 966a1c5e949SDaniel P. Berrange ;; 967e6a74868SMarc-André Lureau --disable-vhost-user) vhost_user="no" 968e6a74868SMarc-André Lureau ;; 969299e6f19SPaolo Bonzini --enable-vhost-user) vhost_user="yes" 970299e6f19SPaolo Bonzini ;; 971108a6481SCindy Lu --disable-vhost-vdpa) vhost_vdpa="no" 972108a6481SCindy Lu ;; 973108a6481SCindy Lu --enable-vhost-vdpa) vhost_vdpa="yes" 974108a6481SCindy Lu ;; 975299e6f19SPaolo Bonzini --disable-vhost-kernel) vhost_kernel="no" 976299e6f19SPaolo Bonzini ;; 977299e6f19SPaolo Bonzini --enable-vhost-kernel) vhost_kernel="yes" 978e6a74868SMarc-André Lureau ;; 9798b18cdbfSRichard Henderson --disable-capstone) capstone="disabled" 9808ca80760SRichard Henderson ;; 9818b18cdbfSRichard Henderson --enable-capstone) capstone="enabled" 9828ca80760SRichard Henderson ;; 9838b18cdbfSRichard Henderson --enable-capstone=git) capstone="internal" 984e219c499SRichard Henderson ;; 98503a3c0b3SPaolo Bonzini --enable-capstone=*) capstone="$optarg" 986e219c499SRichard Henderson ;; 987cc84d63aSDaniel P. Berrange --with-git=*) git="$optarg" 988cc84d63aSDaniel P. Berrange ;; 9897d7dbf9dSDan Streetman --with-git-submodules=*) 9907d7dbf9dSDan Streetman git_submodules_action="$optarg" 991f62bbee5SDaniel P. Berrange ;; 9929b8e4298SAlex Bennée --enable-plugins) if test "$mingw32" = "yes"; then 9939b8e4298SAlex Bennée error_exit "TCG plugins not currently supported on Windows platforms" 9949b8e4298SAlex Bennée else 9959b8e4298SAlex Bennée plugins="yes" 9969b8e4298SAlex Bennée fi 99740e8c6f4SAlex Bennée ;; 99840e8c6f4SAlex Bennée --disable-plugins) plugins="no" 99940e8c6f4SAlex Bennée ;; 1000afc3a8f9SAlex Bennée --enable-containers) use_containers="yes" 1001afc3a8f9SAlex Bennée ;; 1002afc3a8f9SAlex Bennée --disable-containers) use_containers="no" 1003afc3a8f9SAlex Bennée ;; 1004f48e590aSAlex Bennée --gdb=*) gdb_bin="$optarg" 1005f48e590aSAlex Bennée ;; 10063b4da132SPaolo Bonzini # backwards compatibility options 10073b4da132SPaolo Bonzini --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg" 10083b4da132SPaolo Bonzini ;; 10093b4da132SPaolo Bonzini --disable-blobs) meson_option_parse --disable-install-blobs "" 10103b4da132SPaolo Bonzini ;; 10113b4da132SPaolo Bonzini --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc 10123b4da132SPaolo Bonzini ;; 10133b4da132SPaolo Bonzini --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc 10143b4da132SPaolo Bonzini ;; 10153b4da132SPaolo Bonzini # everything else has the same name in configure and meson 101661d63097SPaolo Bonzini --enable-* | --disable-*) meson_option_parse "$opt" "$optarg" 101761d63097SPaolo Bonzini ;; 10182d2ad6d0SFam Zheng *) 10192d2ad6d0SFam Zheng echo "ERROR: unknown option $opt" 10202d2ad6d0SFam Zheng echo "Try '$0 --help' for more information" 10212d2ad6d0SFam Zheng exit 1 10227f1559c6Sbalrog ;; 10237d13299dSbellard esac 10247d13299dSbellarddone 10257d13299dSbellard 1026d1a14257SAlex Bennée# test for any invalid configuration combinations 1027d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then 1028d1a14257SAlex Bennée error_exit "Can't enable plugins on non-TCG builds" 1029d1a14257SAlex Bennéefi 1030d1a14257SAlex Bennée 10317d7dbf9dSDan Streetmancase $git_submodules_action in 10327d7dbf9dSDan Streetman update|validate) 10337d7dbf9dSDan Streetman if test ! -e "$source_path/.git"; then 10347d7dbf9dSDan Streetman echo "ERROR: cannot $git_submodules_action git submodules without .git" 10357d7dbf9dSDan Streetman exit 1 10367d7dbf9dSDan Streetman fi 10377d7dbf9dSDan Streetman ;; 10387d7dbf9dSDan Streetman ignore) 1039b80fd281SPaolo Bonzini if ! test -f "$source_path/ui/keycodemapdb/README" 1040b80fd281SPaolo Bonzini then 1041b80fd281SPaolo Bonzini echo 1042b80fd281SPaolo Bonzini echo "ERROR: missing GIT submodules" 1043b80fd281SPaolo Bonzini echo 1044b80fd281SPaolo Bonzini if test -e "$source_path/.git"; then 1045b80fd281SPaolo Bonzini echo "--with-git-submodules=ignore specified but submodules were not" 1046b80fd281SPaolo Bonzini echo "checked out. Please initialize and update submodules." 1047b80fd281SPaolo Bonzini else 1048b80fd281SPaolo Bonzini echo "This is not a GIT checkout but module content appears to" 1049b80fd281SPaolo Bonzini echo "be missing. Do not use 'git archive' or GitHub download links" 1050b80fd281SPaolo Bonzini echo "to acquire QEMU source archives. Non-GIT builds are only" 1051b80fd281SPaolo Bonzini echo "supported with source archives linked from:" 1052b80fd281SPaolo Bonzini echo 1053b80fd281SPaolo Bonzini echo " https://www.qemu.org/download/#source" 1054b80fd281SPaolo Bonzini echo 1055b80fd281SPaolo Bonzini echo "Developers working with GIT can use scripts/archive-source.sh" 1056b80fd281SPaolo Bonzini echo "if they need to create valid source archives." 1057b80fd281SPaolo Bonzini fi 1058b80fd281SPaolo Bonzini echo 1059b80fd281SPaolo Bonzini exit 1 1060b80fd281SPaolo Bonzini fi 10617d7dbf9dSDan Streetman ;; 10627d7dbf9dSDan Streetman *) 10637d7dbf9dSDan Streetman echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'" 10647d7dbf9dSDan Streetman exit 1 10657d7dbf9dSDan Streetman ;; 10667d7dbf9dSDan Streetmanesac 10677d7dbf9dSDan Streetman 106822a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}" 106922a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}" 107022a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}" 107122a87800SMarc-André Lureau 107222a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then 107315588a62SJoshua Watt bindir="${bindir:-$prefix}" 107422a87800SMarc-André Lureauelse 107515588a62SJoshua Watt bindir="${bindir:-$prefix/bin}" 107615588a62SJoshua Wattfi 107722a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}" 107822a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}" 1079ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}" 108022a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}" 108122a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}" 108216bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}" 108316bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}" 108422a87800SMarc-André Lureau 10859557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then 1086b1aa4de1SAlex Bennée eval "cross_cc_${cpu}=\$cc" 10872038f8c8SPaolo Bonzini cross_cc_vars="$cross_cc_vars cross_cc_${cpu}" 10889557af9cSAlex Bennéefi 108979f3b12fSPeter Crosthwaite 109060e0df25SPeter Maydelldefault_target_list="" 10916e92f823SPeter Maydellmak_wilds="" 10926e92f823SPeter Maydell 1093b915a2f1SPaolo Bonziniif [ "$linux_user" != no ]; then 1094b915a2f1SPaolo Bonzini if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then 1095b915a2f1SPaolo Bonzini linux_user=yes 1096b915a2f1SPaolo Bonzini elif [ "$linux_user" = yes ]; then 1097b915a2f1SPaolo Bonzini error_exit "linux-user not supported on this architecture" 1098b915a2f1SPaolo Bonzini fi 1099b915a2f1SPaolo Bonzinifi 1100b915a2f1SPaolo Bonziniif [ "$bsd_user" != no ]; then 1101b915a2f1SPaolo Bonzini if [ "$bsd_user" = "" ]; then 1102b915a2f1SPaolo Bonzini test $targetos = freebsd && bsd_user=yes 1103b915a2f1SPaolo Bonzini fi 1104b915a2f1SPaolo Bonzini if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then 1105b915a2f1SPaolo Bonzini error_exit "bsd-user not supported on this host OS" 1106b915a2f1SPaolo Bonzini fi 1107b915a2f1SPaolo Bonzinifi 110860e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then 1109812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak" 111060e0df25SPeter Maydellfi 111160e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then 1112812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak" 111360e0df25SPeter Maydellfi 111460e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then 1115812b31d3SAlex Bennée mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak" 111660e0df25SPeter Maydellfi 111760e0df25SPeter Maydell 1118447e133fSAlex Bennéefor config in $mak_wilds; do 1119447e133fSAlex Bennée target="$(basename "$config" .mak)" 112098db9a06SAlex Bennée if echo "$target_list_exclude" | grep -vq "$target"; then 1121447e133fSAlex Bennée default_target_list="${default_target_list} $target" 1122447e133fSAlex Bennée fi 1123447e133fSAlex Bennéedone 11246e92f823SPeter Maydell 1125af5db58eSpbrookif test x"$show_help" = x"yes" ; then 1126af5db58eSpbrookcat << EOF 1127af5db58eSpbrook 1128af5db58eSpbrookUsage: configure [options] 1129af5db58eSpbrookOptions: [defaults in brackets after descriptions] 1130af5db58eSpbrook 113108fb77edSStefan WeilStandard options: 113208fb77edSStefan Weil --help print this message 113308fb77edSStefan Weil --prefix=PREFIX install in PREFIX [$prefix] 113408fb77edSStefan Weil --interp-prefix=PREFIX where to find shared libraries, etc. 113508fb77edSStefan Weil use %M for cpu name [$interp_prefix] 113674154d7eSThomas Huth --target-list=LIST set target list (default: build all) 113708fb77edSStefan Weil$(echo Available targets: $default_target_list | \ 113808fb77edSStefan Weil fold -s -w 53 | sed -e 's/^/ /') 1139447e133fSAlex Bennée --target-list-exclude=LIST exclude a set of targets from the default target-list 114008fb77edSStefan Weil 114108fb77edSStefan WeilAdvanced options (experts only): 11423812c0c4SJoelle van Dyne --cross-prefix=PREFIX use PREFIX for compile tools, PREFIX can be blank [$cross_prefix] 114308fb77edSStefan Weil --cc=CC use C compiler CC [$cc] 114408fb77edSStefan Weil --iasl=IASL use ACPI compiler IASL [$iasl] 114508fb77edSStefan Weil --host-cc=CC use C compiler CC [$host_cc] for code run at 114608fb77edSStefan Weil build time 114708fb77edSStefan Weil --cxx=CXX use C++ compiler CXX [$cxx] 114808fb77edSStefan Weil --objcc=OBJCC use Objective-C compiler OBJCC [$objcc] 1149a2866660SPaolo Bonzini --extra-cflags=CFLAGS append extra C compiler flags CFLAGS 1150a2866660SPaolo Bonzini --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS 1151e910c7d9SPhilippe Mathieu-Daudé --extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS 115208fb77edSStefan Weil --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS 1153d75402b5SAlex Bennée --cross-cc-ARCH=CC use compiler when building ARCH guest test cases 1154479ca4ccSMatheus Ferst --cross-cc-cflags-ARCH= use compiler flags when building ARCH guest tests 115508fb77edSStefan Weil --make=MAKE use specified make [$make] 115608fb77edSStefan Weil --python=PYTHON use specified python [$python] 11572eb054c2SPeter Maydell --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build] 1158a5665051SPaolo Bonzini --meson=MESON use specified meson [$meson] 115948328880SPaolo Bonzini --ninja=NINJA use specified ninja [$ninja] 116008fb77edSStefan Weil --smbd=SMBD use specified smbd [$smbd] 1161db1b5f13SThomas Huth --with-git=GIT use specified git [$git] 11627d7dbf9dSDan Streetman --with-git-submodules=update update git submodules (default if .git dir exists) 11637d7dbf9dSDan Streetman --with-git-submodules=validate fail if git submodules are not up to date 11647d7dbf9dSDan Streetman --with-git-submodules=ignore do not update or check git submodules (default if no .git dir) 116508fb77edSStefan Weil --static enable static build [$static] 116608fb77edSStefan Weil --mandir=PATH install man pages in PATH 116710ff82d1SMarc-André Lureau --datadir=PATH install firmware in PATH/$qemu_suffix 1168fe0038beSPaolo Bonzini --localedir=PATH install translation in PATH/$qemu_suffix 116910ff82d1SMarc-André Lureau --docdir=PATH install documentation in PATH/$qemu_suffix 117008fb77edSStefan Weil --bindir=PATH install binaries in PATH 117108fb77edSStefan Weil --libdir=PATH install libraries in PATH 1172db1b5f13SThomas Huth --libexecdir=PATH install helper binaries in PATH 117310ff82d1SMarc-André Lureau --sysconfdir=PATH install config in PATH/$qemu_suffix 117408fb77edSStefan Weil --localstatedir=PATH install local state in PATH (set at runtime on win32) 11753d5eecabSGerd Hoffmann --firmwarepath=PATH search PATH for firmware files 117613336606SRobert Foley --efi-aarch64=PATH PATH of efi file to use for aarch64 VMs. 1177ca8c0909SMarc-André Lureau --with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix] 1178db1b5f13SThomas Huth --with-pkgversion=VERS use specified string as sub-version of the package 1179c035c8d6SPaolo Bonzini --without-default-features default all --enable-* options to "disabled" 1180c035c8d6SPaolo Bonzini --without-default-devices do not include any device that is not needed to 1181c035c8d6SPaolo Bonzini start the emulator (only use if you are including 1182d1d5e9eeSAlex Bennée desired devices in configs/devices/) 1183d1d5e9eeSAlex Bennée --with-devices-ARCH=NAME override default configs/devices 118408fb77edSStefan Weil --enable-debug enable common debug build options 1185247724cbSMarc-André Lureau --enable-sanitizers enable default sanitizers 11860aebab04SLingfeng Yang --enable-tsan enable thread sanitizer 118708fb77edSStefan Weil --disable-werror disable compilation abort on warning 118863678e17SSteven Noonan --disable-stack-protector disable compiler-provided stack protection 118916bfbc70SPaolo Bonzini --audio-drv-list=LIST set audio drivers to try if -audiodev is not used 119008fb77edSStefan Weil --block-drv-whitelist=L Same as --block-drv-rw-whitelist=L 119108fb77edSStefan Weil --block-drv-rw-whitelist=L 119208fb77edSStefan Weil set block driver read-write whitelist 1193e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 119408fb77edSStefan Weil --block-drv-ro-whitelist=L 119508fb77edSStefan Weil set block driver read-only whitelist 1196e5f05f8cSKevin Wolf (by default affects only QEMU, not tools like qemu-img) 119708fb77edSStefan Weil --with-trace-file=NAME Full PATH,NAME of file to store traces 119808fb77edSStefan Weil Default:trace-<pid> 1199c23f23b9SMichael Tokarev --cpu=CPU Build for host CPU [$cpu] 120008fb77edSStefan Weil --with-coroutine=BACKEND coroutine backend. Supported options: 120133c53c54SDaniel P. Berrange ucontext, sigaltstack, windows 120208fb77edSStefan Weil --enable-gcov enable test coverage analysis with gcov 1203a1c5e949SDaniel P. Berrange --tls-priority default TLS protocol/cipher priority string 120440e8c6f4SAlex Bennée --enable-plugins 120540e8c6f4SAlex Bennée enable plugins via shared library loading 1206afc3a8f9SAlex Bennée --disable-containers don't use containers for cross-building 1207f48e590aSAlex Bennée --gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin] 120861d63097SPaolo BonziniEOF 120961d63097SPaolo Bonzini meson_options_help 121061d63097SPaolo Bonzinicat << EOF 1211c23f23b9SMichael Tokarev system all system emulation targets 1212c23f23b9SMichael Tokarev user supported user emulation targets 1213c23f23b9SMichael Tokarev linux-user all linux usermode emulation targets 1214c23f23b9SMichael Tokarev bsd-user all BSD usermode emulation targets 1215c23f23b9SMichael Tokarev pie Position Independent Executables 121621e709aaSMarc-André Lureau modules modules support (non-Windows) 1217c23f23b9SMichael Tokarev debug-tcg TCG debugging (default is disabled) 1218c23f23b9SMichael Tokarev debug-info debugging information 1219cdad781dSDaniele Buono lto Enable Link-Time Optimization. 12201e4f6065SDaniele Buono safe-stack SafeStack Stack Smash Protection. Depends on 12211e4f6065SDaniele Buono clang/llvm >= 3.7 and requires coroutine backend ucontext. 1222299e6f19SPaolo Bonzini vhost-net vhost-net kernel acceleration support 1223299e6f19SPaolo Bonzini vhost-vsock virtio sockets device support 1224299e6f19SPaolo Bonzini vhost-scsi vhost-scsi kernel target support 1225299e6f19SPaolo Bonzini vhost-crypto vhost-user-crypto backend support 1226299e6f19SPaolo Bonzini vhost-kernel vhost kernel backend support 1227299e6f19SPaolo Bonzini vhost-user vhost-user backend support 1228108a6481SCindy Lu vhost-vdpa vhost-vdpa kernel backend support 122908fb77edSStefan Weil 123008fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched 1231af5db58eSpbrookEOF 12322d2ad6d0SFam Zhengexit 0 1233af5db58eSpbrookfi 1234af5db58eSpbrook 12359c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated 1236bb768f71SThomas Huthrm -f */config-devices.mak.d 12379c790242SThomas Huth 1238faf44142SDaniel P. Berrangéif test -z "$python" 1239faf44142SDaniel P. Berrangéthen 1240c53eeaf7SStefan Hajnoczi error_exit "Python not found. Use --python=/path/to/python" 1241c53eeaf7SStefan Hajnoczifi 12428e2c76bdSRoman Bolshakovif ! has "$make" 12438e2c76bdSRoman Bolshakovthen 12448e2c76bdSRoman Bolshakov error_exit "GNU make ($make) not found" 12458e2c76bdSRoman Bolshakovfi 1246c53eeaf7SStefan Hajnoczi 1247c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit 1248c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value. 12491b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then 12501b11f28dSThomas Huth error_exit "Cannot use '$python', Python >= 3.6 is required." \ 1251c53eeaf7SStefan Hajnoczi "Use --python=/path/to/python to specify a supported Python." 1252c53eeaf7SStefan Hajnoczifi 1253c53eeaf7SStefan Hajnoczi 1254755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it 1255406ab2f3SCleber Rosapython_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null) 1256755ee70fSCleber Rosa 1257c53eeaf7SStefan Hajnoczi# Suppress writing compiled files 1258c53eeaf7SStefan Hajnoczipython="$python -B" 1259c53eeaf7SStefan Hajnoczi 12600a01d76fSMarc-André Lureauif test -z "$meson"; then 12616638cae5SPaolo Bonzini if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then 12620a01d76fSMarc-André Lureau meson=meson 12637d7dbf9dSDan Streetman elif test $git_submodules_action != 'ignore' ; then 12640a01d76fSMarc-André Lureau meson=git 12650a01d76fSMarc-André Lureau elif test -e "${source_path}/meson/meson.py" ; then 12660a01d76fSMarc-André Lureau meson=internal 12670a01d76fSMarc-André Lureau else 12680a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 12690a01d76fSMarc-André Lureau error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found." 12700a01d76fSMarc-André Lureau else 1271a5665051SPaolo Bonzini error_exit "Meson not found. Use --meson=/path/to/meson" 1272a5665051SPaolo Bonzini fi 12730a01d76fSMarc-André Lureau fi 12740a01d76fSMarc-André Lureauelse 12750a01d76fSMarc-André Lureau # Meson uses its own Python interpreter to invoke other Python scripts, 12760a01d76fSMarc-André Lureau # but the user wants to use the one they specified with --python. 12770a01d76fSMarc-André Lureau # 12780a01d76fSMarc-André Lureau # We do not want to override the distro Python interpreter (and sometimes 12790a01d76fSMarc-André Lureau # cannot: for example in Homebrew /usr/bin/meson is a bash script), so 12800a01d76fSMarc-André Lureau # just require --meson=git|internal together with --python. 12810a01d76fSMarc-André Lureau if test "$explicit_python" = yes; then 12820a01d76fSMarc-André Lureau case "$meson" in 12830a01d76fSMarc-André Lureau git | internal) ;; 12840a01d76fSMarc-André Lureau *) error_exit "--python requires using QEMU's embedded Meson distribution." ;; 12850a01d76fSMarc-André Lureau esac 12860a01d76fSMarc-André Lureau fi 12870a01d76fSMarc-André Lureaufi 1288a5665051SPaolo Bonzini 12890a01d76fSMarc-André Lureauif test "$meson" = git; then 12900a01d76fSMarc-André Lureau git_submodules="${git_submodules} meson" 12910a01d76fSMarc-André Lureaufi 12920a01d76fSMarc-André Lureau 12930a01d76fSMarc-André Lureaucase "$meson" in 12940a01d76fSMarc-André Lureau git | internal) 12950a01d76fSMarc-André Lureau meson="$python ${source_path}/meson/meson.py" 12960a01d76fSMarc-André Lureau ;; 129784ec0c24SPaolo Bonzini *) meson=$(command -v "$meson") ;; 12980a01d76fSMarc-André Lureauesac 12990a01d76fSMarc-André Lureau 130009e93326SPaolo Bonzini# Probe for ninja 130148328880SPaolo Bonzini 130248328880SPaolo Bonziniif test -z "$ninja"; then 130348328880SPaolo Bonzini for c in ninja ninja-build samu; do 130448328880SPaolo Bonzini if has $c; then 130548328880SPaolo Bonzini ninja=$(command -v "$c") 130648328880SPaolo Bonzini break 130748328880SPaolo Bonzini fi 130848328880SPaolo Bonzini done 130909e93326SPaolo Bonzini if test -z "$ninja"; then 131009e93326SPaolo Bonzini error_exit "Cannot find Ninja" 131109e93326SPaolo Bonzini fi 131248328880SPaolo Bonzinifi 1313a5665051SPaolo Bonzini 13149aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing 13159aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the 13169aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case). 13179aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC. 13189aae6e54SDaniel Henrique Barbozawrite_c_skeleton; 13199aae6e54SDaniel Henrique Barbozaif compile_object ; then 13209aae6e54SDaniel Henrique Barboza : C compiler works ok 13219aae6e54SDaniel Henrique Barbozaelse 13229aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" either does not exist or does not work" 13239aae6e54SDaniel Henrique Barbozafi 13249aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then 13259aae6e54SDaniel Henrique Barboza error_exit "\"$cc\" cannot build an executable (is your linker broken?)" 13269aae6e54SDaniel Henrique Barbozafi 13279aae6e54SDaniel Henrique Barboza 13289c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror 13299c83ffd8SPeter Maydell# by default. Only enable by default for git builds 13309c83ffd8SPeter Maydellif test -z "$werror" ; then 13317d7dbf9dSDan Streetman if test "$git_submodules_action" != "ignore" && \ 1332e633a5c6SEric Blake { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then 13339c83ffd8SPeter Maydell werror="yes" 13349c83ffd8SPeter Maydell else 13359c83ffd8SPeter Maydell werror="no" 13369c83ffd8SPeter Maydell fi 13379c83ffd8SPeter Maydellfi 13389c83ffd8SPeter Maydell 1339975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then 1340fb59dabdSPeter Maydell # Now that we know that we're not printing the help and that 1341fb59dabdSPeter Maydell # the compiler works (so the results of the check_defines we used 1342fb59dabdSPeter Maydell # to identify the OS are reliable), if we didn't recognize the 1343fb59dabdSPeter Maydell # host OS we should stop now. 1344951fedfcSPeter Maydell error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" 1345fb59dabdSPeter Maydellfi 1346fb59dabdSPeter Maydell 1347efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements: 1348efc6c070SThomas Huthcat > $TMPC << EOF 1349efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__) 1350efc6c070SThomas Huth# ifdef __apple_build_version__ 13512a85a08cSDaniel P. Berrangé# if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0) 13522a85a08cSDaniel P. Berrangé# error You need at least XCode Clang v10.0 to compile QEMU 1353efc6c070SThomas Huth# endif 1354efc6c070SThomas Huth# else 13552a85a08cSDaniel P. Berrangé# if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0) 13562a85a08cSDaniel P. Berrangé# error You need at least Clang v6.0 to compile QEMU 1357efc6c070SThomas Huth# endif 1358efc6c070SThomas Huth# endif 1359efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__) 13603830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4) 13613830df5fSnia# error You need at least GCC v7.4.0 to compile QEMU 1362efc6c070SThomas Huth# endif 1363efc6c070SThomas Huth#else 1364efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU 1365efc6c070SThomas Huth#endif 1366efc6c070SThomas Huthint main (void) { return 0; } 1367efc6c070SThomas HuthEOF 1368efc6c070SThomas Huthif ! compile_prog "" "" ; then 13693830df5fSnia error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)" 1370efc6c070SThomas Huthfi 1371efc6c070SThomas Huth 137200849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately. 137300849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second. 137400849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all 137500849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would 137600849b92SRichard Henderson# just silently disable some features, so it's too error prone. 137700849b92SRichard Henderson 137800849b92SRichard Hendersonwarn_flags= 137900849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration 138000849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition 138100849b92SRichard Hendersonadd_to warn_flags -Wtype-limits 138200849b92SRichard Hendersonadd_to warn_flags -Wformat-security 138300849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k 138400849b92SRichard Hendersonadd_to warn_flags -Winit-self 138500849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers 138600849b92SRichard Hendersonadd_to warn_flags -Wempty-body 138700849b92SRichard Hendersonadd_to warn_flags -Wnested-externs 138800849b92SRichard Hendersonadd_to warn_flags -Wendif-labels 138900849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined 13900a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2 139100849b92SRichard Henderson 139200849b92SRichard Hendersonnowarn_flags= 139300849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides 139400849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs 139500849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value 139600849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int 139700849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition 1398aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare 1399bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi 140000849b92SRichard Henderson 140100849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags" 140293b25869SJohn Snow 140393b25869SJohn Snowcc_has_warning_flag() { 140493b25869SJohn Snow write_c_skeleton; 140593b25869SJohn Snow 1406a1d29d6cSPeter Maydell # Use the positive sense of the flag when testing for -Wno-wombat 1407a1d29d6cSPeter Maydell # support (gcc will happily accept the -Wno- form of unknown 1408a1d29d6cSPeter Maydell # warning options). 140993b25869SJohn Snow optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 141093b25869SJohn Snow compile_prog "-Werror $optflag" "" 141193b25869SJohn Snow} 141293b25869SJohn Snow 14134cb37d11SPhilippe Mathieu-Daudéobjcc_has_warning_flag() { 14144cb37d11SPhilippe Mathieu-Daudé cat > $TMPM <<EOF 14154cb37d11SPhilippe Mathieu-Daudéint main(void) { return 0; } 14164cb37d11SPhilippe Mathieu-DaudéEOF 14174cb37d11SPhilippe Mathieu-Daudé 14184cb37d11SPhilippe Mathieu-Daudé # Use the positive sense of the flag when testing for -Wno-wombat 14194cb37d11SPhilippe Mathieu-Daudé # support (gcc will happily accept the -Wno- form of unknown 14204cb37d11SPhilippe Mathieu-Daudé # warning options). 14214cb37d11SPhilippe Mathieu-Daudé optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" 14224cb37d11SPhilippe Mathieu-Daudé do_objc -Werror $optflag \ 14234cb37d11SPhilippe Mathieu-Daudé $OBJCFLAGS $EXTRA_OBJCFLAGS $CONFIGURE_OBJCFLAGS $QEMU_OBJCFLAGS \ 14244cb37d11SPhilippe Mathieu-Daudé -o $TMPE $TMPM $QEMU_LDFLAGS 14254cb37d11SPhilippe Mathieu-Daudé} 14264cb37d11SPhilippe Mathieu-Daudé 142793b25869SJohn Snowfor flag in $gcc_flags; do 142893b25869SJohn Snow if cc_has_warning_flag $flag ; then 14298d05095cSPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS $flag" 14308d05095cSPaolo Bonzini fi 14314cb37d11SPhilippe Mathieu-Daudé if objcc_has_warning_flag $flag ; then 14324cb37d11SPhilippe Mathieu-Daudé QEMU_OBJCFLAGS="$QEMU_OBJCFLAGS $flag" 14334cb37d11SPhilippe Mathieu-Daudé fi 14348d05095cSPaolo Bonzinidone 14358d05095cSPaolo Bonzini 143663678e17SSteven Noonanif test "$stack_protector" != "no"; then 1437fccd35a0SRodrigo Rebello cat > $TMPC << EOF 1438fccd35a0SRodrigo Rebelloint main(int argc, char *argv[]) 1439fccd35a0SRodrigo Rebello{ 1440fccd35a0SRodrigo Rebello char arr[64], *p = arr, *c = argv[0]; 1441fccd35a0SRodrigo Rebello while (*c) { 1442fccd35a0SRodrigo Rebello *p++ = *c++; 1443fccd35a0SRodrigo Rebello } 1444fccd35a0SRodrigo Rebello return 0; 1445fccd35a0SRodrigo Rebello} 1446fccd35a0SRodrigo RebelloEOF 144763678e17SSteven Noonan gcc_flags="-fstack-protector-strong -fstack-protector-all" 14483b463a3fSMiroslav Rezanina sp_on=0 144963678e17SSteven Noonan for flag in $gcc_flags; do 1450590e5dd9SPeter Maydell # We need to check both a compile and a link, since some compiler 1451590e5dd9SPeter Maydell # setups fail only on a .c->.o compile and some only at link time 1452086d5f75SPaolo Bonzini if compile_object "-Werror $flag" && 1453590e5dd9SPeter Maydell compile_prog "-Werror $flag" ""; then 145463678e17SSteven Noonan QEMU_CFLAGS="$QEMU_CFLAGS $flag" 1455db5adeaaSPaolo Bonzini QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 14563b463a3fSMiroslav Rezanina sp_on=1 145763678e17SSteven Noonan break 145863678e17SSteven Noonan fi 145963678e17SSteven Noonan done 14603b463a3fSMiroslav Rezanina if test "$stack_protector" = yes; then 14613b463a3fSMiroslav Rezanina if test $sp_on = 0; then 14623b463a3fSMiroslav Rezanina error_exit "Stack protector not supported" 14633b463a3fSMiroslav Rezanina fi 14643b463a3fSMiroslav Rezanina fi 146537746c5eSMarc-André Lureaufi 146637746c5eSMarc-André Lureau 146720bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for 146820bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}. 146920bc94a2SPaolo Bonzinicat > $TMPC << EOF 147020bc94a2SPaolo Bonzinistruct { 147120bc94a2SPaolo Bonzini int a[2]; 147220bc94a2SPaolo Bonzini} x = {0}; 147320bc94a2SPaolo BonziniEOF 147420bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then 147520bc94a2SPaolo Bonzini : 147620bc94a2SPaolo Bonzinielse 147720bc94a2SPaolo Bonzini QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces" 147820bc94a2SPaolo Bonzinifi 147920bc94a2SPaolo Bonzini 148021e709aaSMarc-André Lureau# Our module code doesn't support Windows 148121e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then 148221e709aaSMarc-André Lureau error_exit "Modules are not available for Windows" 148321e709aaSMarc-André Lureaufi 148421e709aaSMarc-André Lureau 14855f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE 148640d6444eSAvi Kivityif test "$static" = "yes" ; then 1487aa0d1f44SPaolo Bonzini if test "$modules" = "yes" ; then 1488aa0d1f44SPaolo Bonzini error_exit "static and modules are mutually incompatible" 1489aa0d1f44SPaolo Bonzini fi 14905f2453acSAlex Bennée if test "$plugins" = "yes"; then 14915f2453acSAlex Bennée error_exit "static and plugins are mutually incompatible" 1492ba4dd2aaSAlex Bennée else 1493ba4dd2aaSAlex Bennée plugins="no" 14945f2453acSAlex Bennée fi 149540d6444eSAvi Kivityfi 149637650689SPaolo Bonzinitest "$plugins" = "" && plugins=yes 149740d6444eSAvi Kivity 149840d6444eSAvi Kivitycat > $TMPC << EOF 149921d4a791SAvi Kivity 150021d4a791SAvi Kivity#ifdef __linux__ 150121d4a791SAvi Kivity# define THREAD __thread 150221d4a791SAvi Kivity#else 150321d4a791SAvi Kivity# define THREAD 150421d4a791SAvi Kivity#endif 150521d4a791SAvi Kivitystatic THREAD int tls_var; 150621d4a791SAvi Kivityint main(void) { return tls_var; } 150740d6444eSAvi KivityEOF 1508b2634124SRichard Henderson 1509ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for 1510ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed. 1511412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then 1512412aeacdSAlex Bennée CFLAGS_NOPIE="-fno-pie" 1513ffd205efSJessica Clarke LDFLAGS_NOPIE="-no-pie" 1514412aeacdSAlex Bennéefi 1515412aeacdSAlex Bennée 151612781462SRichard Hendersonif test "$static" = "yes"; then 1517eca7a8e6SRichard Henderson if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then 15185770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 151912781462SRichard Henderson QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS" 152012781462SRichard Henderson pie="yes" 152112781462SRichard Henderson elif test "$pie" = "yes"; then 152212781462SRichard Henderson error_exit "-static-pie not available due to missing toolchain support" 152312781462SRichard Henderson else 152412781462SRichard Henderson QEMU_LDFLAGS="-static $QEMU_LDFLAGS" 152512781462SRichard Henderson pie="no" 152612781462SRichard Henderson fi 152712781462SRichard Hendersonelif test "$pie" = "no"; then 15285770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" 1529ffd205efSJessica Clarke CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" 1530eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then 15315770e8afSPaolo Bonzini CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" 15325770e8afSPaolo Bonzini CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" 153340d6444eSAvi Kivity pie="yes" 15342c674109SRichard Hendersonelif test "$pie" = "yes"; then 153576ad07a4SPeter Maydell error_exit "PIE not available due to missing toolchain support" 153640d6444eSAvi Kivityelse 153740d6444eSAvi Kivity echo "Disabling PIE due to missing toolchain support" 153840d6444eSAvi Kivity pie="no" 153940d6444eSAvi Kivityfi 154040d6444eSAvi Kivity 1541e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW. 1542e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too. 1543e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then 1544e6cbd751SRichard Henderson QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS" 1545e6cbd751SRichard Hendersonfi 1546e6cbd751SRichard Henderson 154709dada40SPaolo Bonzini########################################## 154809dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains 154909dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit 155009dada40SPaolo Bonzini# specification is necessary 155109dada40SPaolo Bonzini 155209dada40SPaolo Bonziniif test "$cpu" = "i386"; then 155309dada40SPaolo Bonzini cat > $TMPC << EOF 155409dada40SPaolo Bonzinistatic int sfaa(int *ptr) 155509dada40SPaolo Bonzini{ 155609dada40SPaolo Bonzini return __sync_fetch_and_and(ptr, 0); 155709dada40SPaolo Bonzini} 155809dada40SPaolo Bonzini 155909dada40SPaolo Bonziniint main(void) 156009dada40SPaolo Bonzini{ 156109dada40SPaolo Bonzini int val = 42; 15621405b629SStefan Weil val = __sync_val_compare_and_swap(&val, 0, 1); 156309dada40SPaolo Bonzini sfaa(&val); 156409dada40SPaolo Bonzini return val; 156509dada40SPaolo Bonzini} 156609dada40SPaolo BonziniEOF 156709dada40SPaolo Bonzini if ! compile_prog "" "" ; then 156809dada40SPaolo Bonzini QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS" 156909dada40SPaolo Bonzini fi 157009dada40SPaolo Bonzinifi 157109dada40SPaolo Bonzini 157256267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then 157356267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-testfloat-3" 157456267b62SPhilippe Mathieu-Daudé git_submodules="$git_submodules tests/fp/berkeley-softfloat-3" 157556267b62SPhilippe Mathieu-Daudéfi 157656267b62SPhilippe Mathieu-Daudé 1577afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then 1578fdb75aefSPaolo Bonzini default_targets=yes 1579d880a3baSPaolo Bonzini for target in $default_target_list; do 1580d880a3baSPaolo Bonzini target_list="$target_list $target" 1581d880a3baSPaolo Bonzini done 1582d880a3baSPaolo Bonzini target_list="${target_list# }" 1583121afa9eSAnthony Liguorielse 1584fdb75aefSPaolo Bonzini default_targets=no 158589138857SStefan Weil target_list=$(echo "$target_list" | sed -e 's/,/ /g') 1586d880a3baSPaolo Bonzini for target in $target_list; do 158725b48338SPeter Maydell # Check that we recognised the target name; this allows a more 158825b48338SPeter Maydell # friendly error message than if we let it fall through. 158925b48338SPeter Maydell case " $default_target_list " in 159025b48338SPeter Maydell *" $target "*) 159125b48338SPeter Maydell ;; 159225b48338SPeter Maydell *) 159325b48338SPeter Maydell error_exit "Unknown target name '$target'" 159425b48338SPeter Maydell ;; 159525b48338SPeter Maydell esac 159625b48338SPeter Maydell done 1597d880a3baSPaolo Bonzinifi 159825b48338SPeter Maydell 1599f55fe278SPaolo Bonzini# see if system emulation was really requested 1600f55fe278SPaolo Bonzinicase " $target_list " in 1601f55fe278SPaolo Bonzini *"-softmmu "*) softmmu=yes 1602f55fe278SPaolo Bonzini ;; 1603f55fe278SPaolo Bonzini *) softmmu=no 1604f55fe278SPaolo Bonzini ;; 1605f55fe278SPaolo Bonziniesac 16065327cf48Sbellard 1607249247c9SJuan Quintelafeature_not_found() { 1608249247c9SJuan Quintela feature=$1 160921684af0SStewart Smith remedy=$2 1610249247c9SJuan Quintela 161176ad07a4SPeter Maydell error_exit "User requested feature $feature" \ 161221684af0SStewart Smith "configure was not able to find it." \ 161321684af0SStewart Smith "$remedy" 1614249247c9SJuan Quintela} 1615249247c9SJuan Quintela 16167d13299dSbellard# --- 16177d13299dSbellard# big/little endian test 16187d13299dSbellardcat > $TMPC << EOF 1619659eb157SThomas Huth#include <stdio.h> 162061cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; 162161cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; 1622659eb157SThomas Huthint main(int argc, char *argv[]) 1623659eb157SThomas Huth{ 1624659eb157SThomas Huth return printf("%s %s\n", (char *)big_endian, (char *)little_endian); 16257d13299dSbellard} 16267d13299dSbellardEOF 16277d13299dSbellard 1628659eb157SThomas Huthif compile_prog ; then 1629659eb157SThomas Huth if strings -a $TMPE | grep -q BiGeNdIaN ; then 163061cc919fSMike Frysinger bigendian="yes" 1631659eb157SThomas Huth elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then 163261cc919fSMike Frysinger bigendian="no" 16337d13299dSbellard else 16347d13299dSbellard echo big/little test failed 1635659eb157SThomas Huth exit 1 16367d13299dSbellard fi 16377d13299dSbellardelse 163861cc919fSMike Frysinger echo big/little test failed 1639659eb157SThomas Huth exit 1 16407d13299dSbellardfi 16417d13299dSbellard 1642299e6f19SPaolo Bonzini######################################### 1643299e6f19SPaolo Bonzini# vhost interdependencies and host support 1644299e6f19SPaolo Bonzini 1645299e6f19SPaolo Bonzini# vhost backends 1646eb9baecdSSergio Lopezif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then 1647eb9baecdSSergio Lopez error_exit "vhost-user is not available on Windows" 1648299e6f19SPaolo Bonzinifi 1649108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux 1650108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then 1651108a6481SCindy Lu error_exit "vhost-vdpa is only available on Linux" 1652108a6481SCindy Lufi 1653299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux 1654299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then 1655299e6f19SPaolo Bonzini error_exit "vhost-kernel is only available on Linux" 1656299e6f19SPaolo Bonzinifi 1657299e6f19SPaolo Bonzini 1658299e6f19SPaolo Bonzini# vhost-kernel devices 1659299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel 1660299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then 1661299e6f19SPaolo Bonzini error_exit "--enable-vhost-scsi requires --enable-vhost-kernel" 1662299e6f19SPaolo Bonzinifi 1663299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel 1664299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then 1665299e6f19SPaolo Bonzini error_exit "--enable-vhost-vsock requires --enable-vhost-kernel" 1666299e6f19SPaolo Bonzinifi 1667299e6f19SPaolo Bonzini 1668299e6f19SPaolo Bonzini# vhost-user backends 1669299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user 1670299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then 1671299e6f19SPaolo Bonzini error_exit "--enable-vhost-net-user requires --enable-vhost-user" 1672299e6f19SPaolo Bonzinifi 1673299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user 1674299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then 1675299e6f19SPaolo Bonzini error_exit "--enable-vhost-crypto requires --enable-vhost-user" 1676299e6f19SPaolo Bonzinifi 167798fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user 167898fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then 167998fc1adaSDr. David Alan Gilbert error_exit "--enable-vhost-user-fs requires --enable-vhost-user" 168098fc1adaSDr. David Alan Gilbertfi 1681108a6481SCindy Lu#vhost-vdpa backends 1682108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa 1683108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then 1684108a6481SCindy Lu error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa" 1685108a6481SCindy Lufi 1686299e6f19SPaolo Bonzini 168740bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity 1688299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then 1689299e6f19SPaolo Bonzini test "$vhost_net_user" = "yes" && vhost_net=yes 169040bc0ca9SLaurent Vivier test "$vhost_net_vdpa" = "yes" && vhost_net=yes 1691299e6f19SPaolo Bonzini test "$vhost_kernel" = "yes" && vhost_net=yes 1692299e6f19SPaolo Bonzinifi 1693299e6f19SPaolo Bonzini 1694015a33bdSGonglei########################################## 1695779ab5e3SStefan Weil# pkg-config probe 1696779ab5e3SStefan Weil 1697779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then 169876ad07a4SPeter Maydell error_exit "pkg-config binary '$pkg_config_exe' not found" 1699779ab5e3SStefan Weilfi 1700779ab5e3SStefan Weil 1701779ab5e3SStefan Weil########################################## 1702e37630caSaliguori# xen probe 1703e37630caSaliguori 17041badb709SPaolo Bonziniif test "$xen" != "disabled" ; then 1705c1cdd9d5SJuergen Gross # Check whether Xen library path is specified via --extra-ldflags to avoid 1706c1cdd9d5SJuergen Gross # overriding this setting with pkg-config output. If not, try pkg-config 1707c1cdd9d5SJuergen Gross # to obtain all needed flags. 1708c1cdd9d5SJuergen Gross 1709c1cdd9d5SJuergen Gross if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \ 1710c1cdd9d5SJuergen Gross $pkg_config --exists xencontrol ; then 1711c1cdd9d5SJuergen Gross xen_ctrl_version="$(printf '%d%02d%02d' \ 1712c1cdd9d5SJuergen Gross $($pkg_config --modversion xencontrol | sed 's/\./ /g') )" 17131badb709SPaolo Bonzini xen=enabled 17145b6a8f43SMichael Tokarev xen_pc="xencontrol xenstore xenforeignmemory xengnttab" 1715c1cdd9d5SJuergen Gross xen_pc="$xen_pc xenevtchn xendevicemodel" 171658ea9a7aSAnthony PERARD if $pkg_config --exists xentoolcore; then 171758ea9a7aSAnthony PERARD xen_pc="$xen_pc xentoolcore" 171858ea9a7aSAnthony PERARD fi 1719582ea95fSMarc-André Lureau xen_cflags="$($pkg_config --cflags $xen_pc)" 1720582ea95fSMarc-André Lureau xen_libs="$($pkg_config --libs $xen_pc)" 1721c1cdd9d5SJuergen Gross else 1722c1cdd9d5SJuergen Gross 17235b6a8f43SMichael Tokarev xen_libs="-lxenstore -lxenctrl" 1724d9506cabSAnthony PERARD xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn" 1725d5b93ddfSAnthony PERARD 172650ced5b3SStefan Weil # First we test whether Xen headers and libraries are available. 172750ced5b3SStefan Weil # If no, we are done and there is no Xen support. 172850ced5b3SStefan Weil # If yes, more tests are run to detect the Xen version. 172950ced5b3SStefan Weil 173050ced5b3SStefan Weil # Xen (any) 173150ced5b3SStefan Weil cat > $TMPC <<EOF 173250ced5b3SStefan Weil#include <xenctrl.h> 173350ced5b3SStefan Weilint main(void) { 173450ced5b3SStefan Weil return 0; 173550ced5b3SStefan Weil} 173650ced5b3SStefan WeilEOF 173750ced5b3SStefan Weil if ! compile_prog "" "$xen_libs" ; then 173850ced5b3SStefan Weil # Xen not found 17391badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 174021684af0SStewart Smith feature_not_found "xen" "Install xen devel" 174150ced5b3SStefan Weil fi 17421badb709SPaolo Bonzini xen=disabled 174350ced5b3SStefan Weil 1744d5b93ddfSAnthony PERARD # Xen unstable 174569deef08SPeter Maydell elif 174669deef08SPeter Maydell cat > $TMPC <<EOF && 17472cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API 17482cbf8903SRoss Lagerwall#define __XEN_TOOLS__ 17492cbf8903SRoss Lagerwall#include <xendevicemodel.h> 1750d3c49ebbSPaul Durrant#include <xenforeignmemory.h> 17512cbf8903SRoss Lagerwallint main(void) { 17522cbf8903SRoss Lagerwall xendevicemodel_handle *xd; 1753d3c49ebbSPaul Durrant xenforeignmemory_handle *xfmem; 17542cbf8903SRoss Lagerwall 17552cbf8903SRoss Lagerwall xd = xendevicemodel_open(0, 0); 17562cbf8903SRoss Lagerwall xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0); 17572cbf8903SRoss Lagerwall 1758d3c49ebbSPaul Durrant xfmem = xenforeignmemory_open(0, 0); 1759d3c49ebbSPaul Durrant xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0); 1760d3c49ebbSPaul Durrant 17612cbf8903SRoss Lagerwall return 0; 17622cbf8903SRoss Lagerwall} 17632cbf8903SRoss LagerwallEOF 17642cbf8903SRoss Lagerwall compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 17652cbf8903SRoss Lagerwall then 17662cbf8903SRoss Lagerwall xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 17672cbf8903SRoss Lagerwall xen_ctrl_version=41100 17681badb709SPaolo Bonzini xen=enabled 17692cbf8903SRoss Lagerwall elif 17702cbf8903SRoss Lagerwall cat > $TMPC <<EOF && 17715ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API 17725ba3d756SIgor Druzhinin#include <xenforeignmemory.h> 177358ea9a7aSAnthony PERARD#include <xentoolcore.h> 17745ba3d756SIgor Druzhininint main(void) { 17755ba3d756SIgor Druzhinin xenforeignmemory_handle *xfmem; 17765ba3d756SIgor Druzhinin 17775ba3d756SIgor Druzhinin xfmem = xenforeignmemory_open(0, 0); 17785ba3d756SIgor Druzhinin xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0); 177958ea9a7aSAnthony PERARD xentoolcore_restrict_all(0); 17805ba3d756SIgor Druzhinin 17815ba3d756SIgor Druzhinin return 0; 17825ba3d756SIgor Druzhinin} 17835ba3d756SIgor DruzhininEOF 178458ea9a7aSAnthony PERARD compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore" 17855ba3d756SIgor Druzhinin then 178658ea9a7aSAnthony PERARD xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore" 17875ba3d756SIgor Druzhinin xen_ctrl_version=41000 17881badb709SPaolo Bonzini xen=enabled 17895ba3d756SIgor Druzhinin elif 17905ba3d756SIgor Druzhinin cat > $TMPC <<EOF && 1791da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API 1792da8090ccSPaul Durrant#define __XEN_TOOLS__ 1793da8090ccSPaul Durrant#include <xendevicemodel.h> 1794da8090ccSPaul Durrantint main(void) { 1795da8090ccSPaul Durrant xendevicemodel_handle *xd; 1796da8090ccSPaul Durrant 1797da8090ccSPaul Durrant xd = xendevicemodel_open(0, 0); 1798da8090ccSPaul Durrant xendevicemodel_close(xd); 1799da8090ccSPaul Durrant 1800da8090ccSPaul Durrant return 0; 1801da8090ccSPaul Durrant} 1802da8090ccSPaul DurrantEOF 1803da8090ccSPaul Durrant compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs" 1804da8090ccSPaul Durrant then 1805da8090ccSPaul Durrant xen_stable_libs="-lxendevicemodel $xen_stable_libs" 1806f1167ee6SJuergen Gross xen_ctrl_version=40900 18071badb709SPaolo Bonzini xen=enabled 1808da8090ccSPaul Durrant elif 1809da8090ccSPaul Durrant cat > $TMPC <<EOF && 18105eeb39c2SIan Campbell/* 18115eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat 18125eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given. 1813b6eb9b45SPaulina Szubarczyk * 1814b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and 1815b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented. 1816b6eb9b45SPaulina Szubarczyk */ 1817b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API 1818b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API 1819b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API 1820b6eb9b45SPaulina Szubarczyk#include <xenctrl.h> 1821b6eb9b45SPaulina Szubarczyk#include <xenstore.h> 1822b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h> 1823b6eb9b45SPaulina Szubarczyk#include <xengnttab.h> 1824b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h> 1825b6eb9b45SPaulina Szubarczyk#include <stdint.h> 1826b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h> 1827b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS) 1828b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined 1829b6eb9b45SPaulina Szubarczyk#endif 1830b6eb9b45SPaulina Szubarczykint main(void) { 1831b6eb9b45SPaulina Szubarczyk xc_interface *xc = NULL; 1832b6eb9b45SPaulina Szubarczyk xenforeignmemory_handle *xfmem; 1833b6eb9b45SPaulina Szubarczyk xenevtchn_handle *xe; 1834b6eb9b45SPaulina Szubarczyk xengnttab_handle *xg; 1835b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy_segment_t* seg = NULL; 1836b6eb9b45SPaulina Szubarczyk 1837b6eb9b45SPaulina Szubarczyk xs_daemon_open(); 1838b6eb9b45SPaulina Szubarczyk 1839b6eb9b45SPaulina Szubarczyk xc = xc_interface_open(0, 0, 0); 1840b6eb9b45SPaulina Szubarczyk xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1841b6eb9b45SPaulina Szubarczyk xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 1842b6eb9b45SPaulina Szubarczyk xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 1843b6eb9b45SPaulina Szubarczyk xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 1844b6eb9b45SPaulina Szubarczyk 1845b6eb9b45SPaulina Szubarczyk xfmem = xenforeignmemory_open(0, 0); 1846b6eb9b45SPaulina Szubarczyk xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 1847b6eb9b45SPaulina Szubarczyk 1848b6eb9b45SPaulina Szubarczyk xe = xenevtchn_open(0, 0); 1849b6eb9b45SPaulina Szubarczyk xenevtchn_fd(xe); 1850b6eb9b45SPaulina Szubarczyk 1851b6eb9b45SPaulina Szubarczyk xg = xengnttab_open(0, 0); 1852b6eb9b45SPaulina Szubarczyk xengnttab_grant_copy(xg, 0, seg); 1853b6eb9b45SPaulina Szubarczyk 1854b6eb9b45SPaulina Szubarczyk return 0; 1855b6eb9b45SPaulina Szubarczyk} 1856b6eb9b45SPaulina SzubarczykEOF 1857b6eb9b45SPaulina Szubarczyk compile_prog "" "$xen_libs $xen_stable_libs" 1858b6eb9b45SPaulina Szubarczyk then 1859f1167ee6SJuergen Gross xen_ctrl_version=40800 18601badb709SPaolo Bonzini xen=enabled 1861b6eb9b45SPaulina Szubarczyk elif 1862b6eb9b45SPaulina Szubarczyk cat > $TMPC <<EOF && 1863b6eb9b45SPaulina Szubarczyk/* 1864b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat 1865b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given. 18665eeb39c2SIan Campbell */ 18675eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API 18685eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API 18695eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API 18705eeb39c2SIan Campbell#include <xenctrl.h> 18715eeb39c2SIan Campbell#include <xenstore.h> 18725eeb39c2SIan Campbell#include <xenevtchn.h> 18735eeb39c2SIan Campbell#include <xengnttab.h> 18745eeb39c2SIan Campbell#include <xenforeignmemory.h> 18755eeb39c2SIan Campbell#include <stdint.h> 18765eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h> 18775eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS) 18785eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined 18795eeb39c2SIan Campbell#endif 18805eeb39c2SIan Campbellint main(void) { 18815eeb39c2SIan Campbell xc_interface *xc = NULL; 18825eeb39c2SIan Campbell xenforeignmemory_handle *xfmem; 18835eeb39c2SIan Campbell xenevtchn_handle *xe; 18845eeb39c2SIan Campbell xengnttab_handle *xg; 18855eeb39c2SIan Campbell 18865eeb39c2SIan Campbell xs_daemon_open(); 18875eeb39c2SIan Campbell 18885eeb39c2SIan Campbell xc = xc_interface_open(0, 0, 0); 18895eeb39c2SIan Campbell xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 18905eeb39c2SIan Campbell xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 18915eeb39c2SIan Campbell xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 18925eeb39c2SIan Campbell xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 18935eeb39c2SIan Campbell 18945eeb39c2SIan Campbell xfmem = xenforeignmemory_open(0, 0); 18955eeb39c2SIan Campbell xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0); 18965eeb39c2SIan Campbell 18975eeb39c2SIan Campbell xe = xenevtchn_open(0, 0); 18985eeb39c2SIan Campbell xenevtchn_fd(xe); 18995eeb39c2SIan Campbell 19005eeb39c2SIan Campbell xg = xengnttab_open(0, 0); 19015eeb39c2SIan Campbell xengnttab_map_grant_ref(xg, 0, 0, 0); 19025eeb39c2SIan Campbell 19035eeb39c2SIan Campbell return 0; 19045eeb39c2SIan Campbell} 19055eeb39c2SIan CampbellEOF 19065eeb39c2SIan Campbell compile_prog "" "$xen_libs $xen_stable_libs" 19075eeb39c2SIan Campbell then 1908f1167ee6SJuergen Gross xen_ctrl_version=40701 19091badb709SPaolo Bonzini xen=enabled 1910cdadde39SRoger Pau Monne 1911cdadde39SRoger Pau Monne # Xen 4.6 1912cdadde39SRoger Pau Monne elif 1913cdadde39SRoger Pau Monne cat > $TMPC <<EOF && 1914cdadde39SRoger Pau Monne#include <xenctrl.h> 1915e108a3c1SAnthony PERARD#include <xenstore.h> 1916d5b93ddfSAnthony PERARD#include <stdint.h> 1917d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h> 1918d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS) 1919d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined 1920d5b93ddfSAnthony PERARD#endif 1921d5b93ddfSAnthony PERARDint main(void) { 1922d5b93ddfSAnthony PERARD xc_interface *xc; 1923d5b93ddfSAnthony PERARD xs_daemon_open(); 1924d5b93ddfSAnthony PERARD xc = xc_interface_open(0, 0, 0); 1925d5b93ddfSAnthony PERARD xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1926d5b93ddfSAnthony PERARD xc_gnttab_open(NULL, 0); 1927b87de24eSAnthony PERARD xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19288688e065SStefano Stabellini xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 1929d8b441a3SJan Beulich xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL); 193020a544c7SKonrad Rzeszutek Wilk xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0); 1931d8b441a3SJan Beulich return 0; 1932d8b441a3SJan Beulich} 1933d8b441a3SJan BeulichEOF 1934d8b441a3SJan Beulich compile_prog "" "$xen_libs" 1935d8b441a3SJan Beulich then 1936f1167ee6SJuergen Gross xen_ctrl_version=40600 19371badb709SPaolo Bonzini xen=enabled 1938d8b441a3SJan Beulich 1939d8b441a3SJan Beulich # Xen 4.5 1940d8b441a3SJan Beulich elif 1941d8b441a3SJan Beulich cat > $TMPC <<EOF && 1942d8b441a3SJan Beulich#include <xenctrl.h> 1943d8b441a3SJan Beulich#include <xenstore.h> 1944d8b441a3SJan Beulich#include <stdint.h> 1945d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h> 1946d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS) 1947d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined 1948d8b441a3SJan Beulich#endif 1949d8b441a3SJan Beulichint main(void) { 1950d8b441a3SJan Beulich xc_interface *xc; 1951d8b441a3SJan Beulich xs_daemon_open(); 1952d8b441a3SJan Beulich xc = xc_interface_open(0, 0, 0); 1953d8b441a3SJan Beulich xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 1954d8b441a3SJan Beulich xc_gnttab_open(NULL, 0); 1955d8b441a3SJan Beulich xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 1956d8b441a3SJan Beulich xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 19573996e85cSPaul Durrant xc_hvm_create_ioreq_server(xc, 0, 0, NULL); 19583996e85cSPaul Durrant return 0; 19593996e85cSPaul Durrant} 19603996e85cSPaul DurrantEOF 19613996e85cSPaul Durrant compile_prog "" "$xen_libs" 19623996e85cSPaul Durrant then 1963f1167ee6SJuergen Gross xen_ctrl_version=40500 19641badb709SPaolo Bonzini xen=enabled 19653996e85cSPaul Durrant 19663996e85cSPaul Durrant elif 19673996e85cSPaul Durrant cat > $TMPC <<EOF && 19683996e85cSPaul Durrant#include <xenctrl.h> 19693996e85cSPaul Durrant#include <xenstore.h> 19703996e85cSPaul Durrant#include <stdint.h> 19713996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h> 19723996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS) 19733996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined 19743996e85cSPaul Durrant#endif 19753996e85cSPaul Durrantint main(void) { 19763996e85cSPaul Durrant xc_interface *xc; 19773996e85cSPaul Durrant xs_daemon_open(); 19783996e85cSPaul Durrant xc = xc_interface_open(0, 0, 0); 19793996e85cSPaul Durrant xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0); 19803996e85cSPaul Durrant xc_gnttab_open(NULL, 0); 19813996e85cSPaul Durrant xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0); 19823996e85cSPaul Durrant xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000); 19838688e065SStefano Stabellini return 0; 19848688e065SStefano Stabellini} 19858688e065SStefano StabelliniEOF 19868688e065SStefano Stabellini compile_prog "" "$xen_libs" 198769deef08SPeter Maydell then 1988f1167ee6SJuergen Gross xen_ctrl_version=40200 19891badb709SPaolo Bonzini xen=enabled 19908688e065SStefano Stabellini 1991e37630caSaliguori else 19921badb709SPaolo Bonzini if test "$xen" = "enabled" ; then 1993edfb07edSIan Campbell feature_not_found "xen (unsupported version)" \ 1994edfb07edSIan Campbell "Install a supported xen (xen 4.2 or newer)" 1995fc321b4bSJuan Quintela fi 19961badb709SPaolo Bonzini xen=disabled 1997e37630caSaliguori fi 1998d5b93ddfSAnthony PERARD 19991badb709SPaolo Bonzini if test "$xen" = enabled; then 2000f1167ee6SJuergen Gross if test $xen_ctrl_version -ge 40701 ; then 2001582ea95fSMarc-André Lureau xen_libs="$xen_libs $xen_stable_libs " 20025eeb39c2SIan Campbell fi 2003d5b93ddfSAnthony PERARD fi 2004e37630caSaliguori fi 2005c1cdd9d5SJuergen Grossfi 2006e37630caSaliguori 2007d661d9a4SJustin Terry (VM)########################################## 2008e18df141SAnthony Liguori# glib support probe 2009a52d28afSPaolo Bonzini 2010b4c6036fSDaniel P. Berrangéglib_req_ver=2.56 2011aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0 2012aa0d1f44SPaolo Bonziniif test "$modules" = yes; then 2013a88afc64SGerd Hoffmann glib_modules="$glib_modules gmodule-export-2.0" 2014b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then 2015b906acacSPaolo Bonzini glib_modules="$glib_modules gmodule-no-export-2.0" 201654cb65d8SEmilio G. Cotafi 2017e26110cfSFam Zheng 2018aa0d1f44SPaolo Bonzinifor i in $glib_modules; do 2019e26110cfSFam Zheng if $pkg_config --atleast-version=$glib_req_ver $i; then 202089138857SStefan Weil glib_cflags=$($pkg_config --cflags $i) 202189138857SStefan Weil glib_libs=$($pkg_config --libs $i) 2022e18df141SAnthony Liguori else 2023e26110cfSFam Zheng error_exit "glib-$glib_req_ver $i is required to compile QEMU" 2024e26110cfSFam Zheng fi 2025e26110cfSFam Zhengdone 2026e26110cfSFam Zheng 2027215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it 2028215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static 2029215b0c2fSPaolo Bonzini 2030215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then 2031215b0c2fSPaolo Bonzini glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags" 2032215b0c2fSPaolo Bonzinifi 2033215b0c2fSPaolo Bonzini 2034977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the 2035977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches 2036977a82abSDaniel P. Berrange# problems on multi-arch where people try to build 2037977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers 2038977a82abSDaniel P. Berrangecat > $TMPC <<EOF 2039977a82abSDaniel P. Berrange#include <glib.h> 2040977a82abSDaniel P. Berrange#include <unistd.h> 2041977a82abSDaniel P. Berrange 2042977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \ 2043977a82abSDaniel P. Berrange typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused)); 2044977a82abSDaniel P. Berrange 2045977a82abSDaniel P. Berrangeint main(void) { 2046977a82abSDaniel P. Berrange QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T); 2047977a82abSDaniel P. Berrange return 0; 2048977a82abSDaniel P. Berrange} 2049977a82abSDaniel P. BerrangeEOF 2050977a82abSDaniel P. Berrange 2051215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then 2052977a82abSDaniel P. Berrange error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\ 2053977a82abSDaniel P. Berrange "You probably need to set PKG_CONFIG_LIBDIR"\ 2054977a82abSDaniel P. Berrange "to point to the right pkg-config files for your"\ 2055977a82abSDaniel P. Berrange "build target" 2056977a82abSDaniel P. Berrangefi 2057977a82abSDaniel P. Berrange 20589bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2 20599bda600bSEric Blakecat > $TMPC << EOF 20609bda600bSEric Blake#include <glib.h> 20619bda600bSEric Blaketypedef struct Foo { 20629bda600bSEric Blake int i; 20639bda600bSEric Blake} Foo; 20649bda600bSEric Blakestatic void foo_free(Foo *f) 20659bda600bSEric Blake{ 20669bda600bSEric Blake g_free(f); 20679bda600bSEric Blake} 2068e0e7fe07SMarc-André LureauG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free) 20699bda600bSEric Blakeint main(void) { return 0; } 20709bda600bSEric BlakeEOF 20719bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then 20729bda600bSEric Blake if cc_has_warning_flag "-Wno-unused-function"; then 20739bda600bSEric Blake glib_cflags="$glib_cflags -Wno-unused-function" 20745770e8afSPaolo Bonzini CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function" 20759bda600bSEric Blake fi 20769bda600bSEric Blakefi 20779bda600bSEric Blake 2078e26110cfSFam Zheng########################################## 2079e26110cfSFam Zheng# SHA command probe for modules 2080e26110cfSFam Zhengif test "$modules" = yes; then 2081e26110cfSFam Zheng shacmd_probe="sha1sum sha1 shasum" 2082e26110cfSFam Zheng for c in $shacmd_probe; do 20838ccefb91SFam Zheng if has $c; then 2084e26110cfSFam Zheng shacmd="$c" 2085e26110cfSFam Zheng break 2086e26110cfSFam Zheng fi 2087e26110cfSFam Zheng done 2088e26110cfSFam Zheng if test "$shacmd" = ""; then 2089e26110cfSFam Zheng error_exit "one of the checksum commands is required to enable modules: $shacmd_probe" 2090e26110cfSFam Zheng fi 2091e18df141SAnthony Liguorifi 2092e18df141SAnthony Liguori 2093e18df141SAnthony Liguori########################################## 2094f652e6afSaurel32# fdt probe 2095e169e1e1SPeter Maydell 2096fbb4121dSPaolo Bonzinicase "$fdt" in 2097fbb4121dSPaolo Bonzini auto | enabled | internal) 2098fbb4121dSPaolo Bonzini # Simpler to always update submodule, even if not needed. 2099aef45d51SDaniel P. Berrange git_submodules="${git_submodules} dtc" 2100fbb4121dSPaolo Bonzini ;; 2101fbb4121dSPaolo Bonziniesac 2102f652e6afSaurel32 210320ff075bSMichael Walle########################################## 21048ca80760SRichard Henderson# capstone 21058ca80760SRichard Henderson 2106e219c499SRichard Hendersoncase "$capstone" in 21078b18cdbfSRichard Henderson auto | enabled | internal) 21088b18cdbfSRichard Henderson # Simpler to always update submodule, even if not needed. 2109e219c499SRichard Henderson git_submodules="${git_submodules} capstone" 2110e219c499SRichard Henderson ;; 2111e219c499SRichard Hendersonesac 21128ca80760SRichard Henderson 21138ca80760SRichard Henderson########################################## 2114519175a2SAlex Barcelo# check and set a backend for coroutine 2115d0e2fce5SAneesh Kumar K.V 21167c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback 211733c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows 211833c53c54SDaniel P. Berrange# specific one. 21197c2acc70SPeter Maydell 21207c2acc70SPeter Maydellucontext_works=no 2121d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then 2122d0e2fce5SAneesh Kumar K.V cat > $TMPC << EOF 2123d0e2fce5SAneesh Kumar K.V#include <ucontext.h> 2124cdf84806SPeter Maydell#ifdef __stub_makecontext 2125cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail 2126cdf84806SPeter Maydell#endif 212775cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; } 2128d0e2fce5SAneesh Kumar K.VEOF 2129d0e2fce5SAneesh Kumar K.V if compile_prog "" "" ; then 21307c2acc70SPeter Maydell ucontext_works=yes 2131d0e2fce5SAneesh Kumar K.V fi 2132519175a2SAlex Barcelofi 21337c2acc70SPeter Maydell 21347c2acc70SPeter Maydellif test "$coroutine" = ""; then 21357c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 21367c2acc70SPeter Maydell coroutine=win32 21377c2acc70SPeter Maydell elif test "$ucontext_works" = "yes"; then 21387c2acc70SPeter Maydell coroutine=ucontext 2139519175a2SAlex Barcelo else 21407c2acc70SPeter Maydell coroutine=sigaltstack 21417c2acc70SPeter Maydell fi 21427c2acc70SPeter Maydellelse 21437c2acc70SPeter Maydell case $coroutine in 21447c2acc70SPeter Maydell windows) 21457c2acc70SPeter Maydell if test "$mingw32" != "yes"; then 21467c2acc70SPeter Maydell error_exit "'windows' coroutine backend only valid for Windows" 21477c2acc70SPeter Maydell fi 21487c2acc70SPeter Maydell # Unfortunately the user visible backend name doesn't match the 21497c2acc70SPeter Maydell # coroutine-*.c filename for this case, so we have to adjust it here. 21507c2acc70SPeter Maydell coroutine=win32 21517c2acc70SPeter Maydell ;; 21527c2acc70SPeter Maydell ucontext) 21537c2acc70SPeter Maydell if test "$ucontext_works" != "yes"; then 21547c2acc70SPeter Maydell feature_not_found "ucontext" 21557c2acc70SPeter Maydell fi 21567c2acc70SPeter Maydell ;; 215733c53c54SDaniel P. Berrange sigaltstack) 21587c2acc70SPeter Maydell if test "$mingw32" = "yes"; then 21597c2acc70SPeter Maydell error_exit "only the 'windows' coroutine backend is valid for Windows" 21607c2acc70SPeter Maydell fi 21617c2acc70SPeter Maydell ;; 21627c2acc70SPeter Maydell *) 216376ad07a4SPeter Maydell error_exit "unknown coroutine backend $coroutine" 21647c2acc70SPeter Maydell ;; 21657c2acc70SPeter Maydell esac 2166d0e2fce5SAneesh Kumar K.Vfi 2167d0e2fce5SAneesh Kumar K.V 21681e4f6065SDaniele Buono################################################## 21691e4f6065SDaniele Buono# SafeStack 21701e4f6065SDaniele Buono 21711e4f6065SDaniele Buono 21721e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 21731e4f6065SDaniele Buonocat > $TMPC << EOF 21741e4f6065SDaniele Buonoint main(int argc, char *argv[]) 21751e4f6065SDaniele Buono{ 21761e4f6065SDaniele Buono#if ! __has_feature(safe_stack) 21771e4f6065SDaniele Buono#error SafeStack Disabled 21781e4f6065SDaniele Buono#endif 21791e4f6065SDaniele Buono return 0; 21801e4f6065SDaniele Buono} 21811e4f6065SDaniele BuonoEOF 21821e4f6065SDaniele Buono flag="-fsanitize=safe-stack" 21831e4f6065SDaniele Buono # Check that safe-stack is supported and enabled. 21841e4f6065SDaniele Buono if compile_prog "-Werror $flag" "$flag"; then 21851e4f6065SDaniele Buono # Flag needed both at compilation and at linking 21861e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 21871e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 21881e4f6065SDaniele Buono else 21891e4f6065SDaniele Buono error_exit "SafeStack not supported by your compiler" 21901e4f6065SDaniele Buono fi 21911e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 21921e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 21931e4f6065SDaniele Buono fi 21941e4f6065SDaniele Buonoelse 21951e4f6065SDaniele Buonocat > $TMPC << EOF 21961e4f6065SDaniele Buonoint main(int argc, char *argv[]) 21971e4f6065SDaniele Buono{ 21981e4f6065SDaniele Buono#if defined(__has_feature) 21991e4f6065SDaniele Buono#if __has_feature(safe_stack) 22001e4f6065SDaniele Buono#error SafeStack Enabled 22011e4f6065SDaniele Buono#endif 22021e4f6065SDaniele Buono#endif 22031e4f6065SDaniele Buono return 0; 22041e4f6065SDaniele Buono} 22051e4f6065SDaniele BuonoEOF 22061e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then 22071e4f6065SDaniele Buono # Make sure that safe-stack is disabled 22081e4f6065SDaniele Buono if ! compile_prog "-Werror" ""; then 22091e4f6065SDaniele Buono # SafeStack was already enabled, try to explicitly remove the feature 22101e4f6065SDaniele Buono flag="-fno-sanitize=safe-stack" 22111e4f6065SDaniele Buono if ! compile_prog "-Werror $flag" "$flag"; then 22121e4f6065SDaniele Buono error_exit "Configure cannot disable SafeStack" 22131e4f6065SDaniele Buono fi 22141e4f6065SDaniele Buono QEMU_CFLAGS="$QEMU_CFLAGS $flag" 22151e4f6065SDaniele Buono QEMU_LDFLAGS="$QEMU_LDFLAGS $flag" 22161e4f6065SDaniele Buono fi 22171e4f6065SDaniele Buonoelse # "$safe_stack" = "" 22181e4f6065SDaniele Buono # Set safe_stack to yes or no based on pre-existing flags 22191e4f6065SDaniele Buono if compile_prog "-Werror" ""; then 22201e4f6065SDaniele Buono safe_stack="no" 22211e4f6065SDaniele Buono else 22221e4f6065SDaniele Buono safe_stack="yes" 22231e4f6065SDaniele Buono if test "$coroutine" != "ucontext"; then 22241e4f6065SDaniele Buono error_exit "SafeStack is only supported by the coroutine backend ucontext" 22251e4f6065SDaniele Buono fi 22261e4f6065SDaniele Buono fi 22271e4f6065SDaniele Buonofi 22281e4f6065SDaniele Buonofi 22297d992e4dSPeter Lieven 223076a347e1SRichard Henderson######################################## 2231fd0e6053SJohn Snow# check if ccache is interfering with 2232fd0e6053SJohn Snow# semantic analysis of macros 2233fd0e6053SJohn Snow 22345e4dfd3dSJohn Snowunset CCACHE_CPP2 2235fd0e6053SJohn Snowccache_cpp2=no 2236fd0e6053SJohn Snowcat > $TMPC << EOF 2237fd0e6053SJohn Snowstatic const int Z = 1; 2238fd0e6053SJohn Snow#define fn() ({ Z; }) 2239fd0e6053SJohn Snow#define TAUT(X) ((X) == Z) 2240fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y) 2241fd0e6053SJohn Snow#define ID(X) (X) 2242fd0e6053SJohn Snowint main(int argc, char *argv[]) 2243fd0e6053SJohn Snow{ 2244fd0e6053SJohn Snow int x = 0, y = 0; 2245fd0e6053SJohn Snow x = ID(x); 2246fd0e6053SJohn Snow x = fn(); 2247fd0e6053SJohn Snow fn(); 2248fd0e6053SJohn Snow if (PAREN(x, y)) return 0; 2249fd0e6053SJohn Snow if (TAUT(Z)) return 0; 2250fd0e6053SJohn Snow return 0; 2251fd0e6053SJohn Snow} 2252fd0e6053SJohn SnowEOF 2253fd0e6053SJohn Snow 2254fd0e6053SJohn Snowif ! compile_object "-Werror"; then 2255fd0e6053SJohn Snow ccache_cpp2=yes 2256fd0e6053SJohn Snowfi 2257fd0e6053SJohn Snow 2258b553a042SJohn Snow################################################# 2259b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE. 2260b553a042SJohn Snow 2261b553a042SJohn Snowif test "$fortify_source" != "no"; then 2262b553a042SJohn Snow if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then 2263b553a042SJohn Snow fortify_source="no"; 2264e189091fSPeter Maydell elif test -n "$cxx" && has $cxx && 2265cfcc7c14SJohn Snow echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then 2266b553a042SJohn Snow fortify_source="no"; 2267b553a042SJohn Snow else 2268b553a042SJohn Snow fortify_source="yes" 2269b553a042SJohn Snow fi 2270b553a042SJohn Snowfi 2271b553a042SJohn Snow 2272d2042378SAneesh Kumar K.V########################################## 2273247724cbSMarc-André Lureau# checks for sanitizers 2274247724cbSMarc-André Lureau 2275247724cbSMarc-André Lureauhave_asan=no 2276247724cbSMarc-André Lureauhave_ubsan=no 2277d83414e1SMarc-André Lureauhave_asan_iface_h=no 2278d83414e1SMarc-André Lureauhave_asan_iface_fiber=no 2279247724cbSMarc-André Lureau 2280247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then 2281b9f44da2SMarc-André Lureau write_c_skeleton 2282247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then 2283247724cbSMarc-André Lureau have_asan=yes 2284247724cbSMarc-André Lureau fi 2285b9f44da2SMarc-André Lureau 2286b9f44da2SMarc-André Lureau # we could use a simple skeleton for flags checks, but this also 2287b9f44da2SMarc-André Lureau # detect the static linking issue of ubsan, see also: 2288b9f44da2SMarc-André Lureau # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285 2289b9f44da2SMarc-André Lureau cat > $TMPC << EOF 2290b9f44da2SMarc-André Lureau#include <stdlib.h> 2291b9f44da2SMarc-André Lureauint main(void) { 2292b9f44da2SMarc-André Lureau void *tmp = malloc(10); 2293f2dfe54cSLeonid Bloch if (tmp != NULL) { 2294b9f44da2SMarc-André Lureau return *(int *)(tmp + 2); 2295b9f44da2SMarc-André Lureau } 2296d1abf3fcSOlaf Hering return 1; 2297f2dfe54cSLeonid Bloch} 2298b9f44da2SMarc-André LureauEOF 2299247724cbSMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then 2300247724cbSMarc-André Lureau have_ubsan=yes 2301247724cbSMarc-André Lureau fi 2302d83414e1SMarc-André Lureau 2303d83414e1SMarc-André Lureau if check_include "sanitizer/asan_interface.h" ; then 2304d83414e1SMarc-André Lureau have_asan_iface_h=yes 2305d83414e1SMarc-André Lureau fi 2306d83414e1SMarc-André Lureau 2307d83414e1SMarc-André Lureau cat > $TMPC << EOF 2308d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h> 2309d83414e1SMarc-André Lureauint main(void) { 2310d83414e1SMarc-André Lureau __sanitizer_start_switch_fiber(0, 0, 0); 2311d83414e1SMarc-André Lureau return 0; 2312d83414e1SMarc-André Lureau} 2313d83414e1SMarc-André LureauEOF 2314d83414e1SMarc-André Lureau if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then 2315d83414e1SMarc-André Lureau have_asan_iface_fiber=yes 2316d83414e1SMarc-André Lureau fi 2317247724cbSMarc-André Lureaufi 2318247724cbSMarc-André Lureau 23190aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers; 23200aebab04SLingfeng Yang# keep it separate until that is not the case. 23210aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then 23220aebab04SLingfeng Yang error_exit "TSAN is not supported with other sanitiziers." 23230aebab04SLingfeng Yangfi 23240aebab04SLingfeng Yanghave_tsan=no 23250aebab04SLingfeng Yanghave_tsan_iface_fiber=no 23260aebab04SLingfeng Yangif test "$tsan" = "yes" ; then 23270aebab04SLingfeng Yang write_c_skeleton 23280aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 23290aebab04SLingfeng Yang have_tsan=yes 23300aebab04SLingfeng Yang fi 23310aebab04SLingfeng Yang cat > $TMPC << EOF 23320aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h> 23330aebab04SLingfeng Yangint main(void) { 23340aebab04SLingfeng Yang __tsan_create_fiber(0); 23350aebab04SLingfeng Yang return 0; 23360aebab04SLingfeng Yang} 23370aebab04SLingfeng YangEOF 23380aebab04SLingfeng Yang if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then 23390aebab04SLingfeng Yang have_tsan_iface_fiber=yes 23400aebab04SLingfeng Yang fi 23410aebab04SLingfeng Yangfi 23420aebab04SLingfeng Yang 2343adc28027SAlexander Bulekov########################################## 2344675b9b53SMarc-André Lureau# check for slirp 2345675b9b53SMarc-André Lureau 2346675b9b53SMarc-André Lureaucase "$slirp" in 23474d34a86bSPaolo Bonzini auto | enabled | internal) 23484d34a86bSPaolo Bonzini # Simpler to always update submodule, even if not needed. 23497c57bdd8SMarc-André Lureau git_submodules="${git_submodules} slirp" 2350675b9b53SMarc-André Lureau ;; 2351675b9b53SMarc-André Lureauesac 2352675b9b53SMarc-André Lureau 235354e7aac0SAlexey Krasikov########################################## 2354e86ecd4bSJuan Quintela# End of CC checks 2355e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs 2356e86ecd4bSJuan Quintela 2357d83414e1SMarc-André Lureauwrite_c_skeleton 2358d83414e1SMarc-André Lureau 2359df42fa7dSPaolo Bonziniif test "$fortify_source" = "yes" ; then 2360086d5f75SPaolo Bonzini QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" 2361086d5f75SPaolo Bonzini debug=no 2362086d5f75SPaolo Bonzinifi 2363086d5f75SPaolo Bonzini 2364086d5f75SPaolo Bonzinicase "$ARCH" in 2365086d5f75SPaolo Bonzinialpha) 2366086d5f75SPaolo Bonzini # Ensure there's only a single GP 2367086d5f75SPaolo Bonzini QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS" 2368086d5f75SPaolo Bonzini;; 2369086d5f75SPaolo Bonziniesac 2370086d5f75SPaolo Bonzini 2371247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then 2372db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS" 2373db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS" 2374d83414e1SMarc-André Lureau if test "$have_asan_iface_h" = "no" ; then 2375d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header missing." \ 2376d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2377d83414e1SMarc-André Lureau elif test "$have_asan_iface_fiber" = "no" ; then 2378d83414e1SMarc-André Lureau echo "ASAN build enabled, but ASAN header is too old." \ 2379d83414e1SMarc-André Lureau "Without code annotation, the report may be inferior." 2380d83414e1SMarc-André Lureau fi 2381247724cbSMarc-André Lureaufi 23820aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then 23830aebab04SLingfeng Yang if test "$have_tsan_iface_fiber" = "yes" ; then 23840aebab04SLingfeng Yang QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS" 23850aebab04SLingfeng Yang QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS" 23860aebab04SLingfeng Yang else 23870aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing fiber annotation interface." 23880aebab04SLingfeng Yang fi 23890aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then 23900aebab04SLingfeng Yang error_exit "Cannot enable TSAN due to missing sanitize thread interface." 23910aebab04SLingfeng Yangfi 2392247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then 2393db5adeaaSPaolo Bonzini QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS" 2394db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS" 2395247724cbSMarc-André Lureaufi 2396247724cbSMarc-André Lureau 23976542aa9cSPeter Lieven########################################## 23983efac6ebSTomáš Golembiovský 23990aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries. 24000aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then 2401e86ecd4bSJuan Quintela if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then 2402db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS" 2403e86ecd4bSJuan Quintela fi 2404e86ecd4bSJuan Quintelafi 2405e86ecd4bSJuan Quintela 2406952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available 2407952afb71SBlue Swirlif test "$mingw32" = "yes" ; then 2408cb8baa77SMark Cave-Ayland flags="--no-seh --nxcompat" 2409cb8baa77SMark Cave-Ayland 2410cb8baa77SMark Cave-Ayland # Disable ASLR for debug builds to allow debugging with gdb 2411cb8baa77SMark Cave-Ayland if test "$debug" = "no" ; then 2412cb8baa77SMark Cave-Ayland flags="--dynamicbase $flags" 2413cb8baa77SMark Cave-Ayland fi 2414cb8baa77SMark Cave-Ayland 2415cb8baa77SMark Cave-Ayland for flag in $flags; do 2416e9a3591fSChristian Borntraeger if ld_has $flag ; then 2417db5adeaaSPaolo Bonzini QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS" 2418952afb71SBlue Swirl fi 2419952afb71SBlue Swirl done 2420952afb71SBlue Swirlfi 2421952afb71SBlue Swirl 2422b846ab7cSPaolo Bonzini# Guest agent Windows MSI package 24239d6bc27bSMichael Roth 24249d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then 24259d6bc27bSMichael Roth QEMU_GA_MANUFACTURER=QEMU 24269d6bc27bSMichael Rothfi 24279d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then 24289d6bc27bSMichael Roth QEMU_GA_DISTRO=Linux 24299d6bc27bSMichael Rothfi 24309d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then 243189138857SStefan Weil QEMU_GA_VERSION=$(cat $source_path/VERSION) 24329d6bc27bSMichael Rothfi 24339d6bc27bSMichael Roth 24346e444209SPaolo BonziniQEMU_GA_MSI_MINGW_BIN_PATH="$($pkg_config --variable=prefix glib-2.0)/bin" 24359d6bc27bSMichael Roth 2436ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler 2437ca35f780SPaolo Bonziniroms= 2438e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \ 2439ba7c60c2SPaolo Bonzini test "$targetos" != "darwin" && test "$targetos" != "sunos" && \ 2440ba7c60c2SPaolo Bonzini test "$targetos" != "haiku" && test "$softmmu" = yes ; then 2441e57218b6SPeter Maydell # Different host OS linkers have different ideas about the name of the ELF 2442c65d5e4eSBrad Smith # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd 2443c65d5e4eSBrad Smith # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe. 2444c65d5e4eSBrad Smith for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do 2445e57218b6SPeter Maydell if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then 2446e57218b6SPeter Maydell ld_i386_emulation="$emu" 2447ca35f780SPaolo Bonzini roms="optionrom" 2448e57218b6SPeter Maydell break 2449e57218b6SPeter Maydell fi 2450e57218b6SPeter Maydell done 2451ca35f780SPaolo Bonzinifi 2452ca35f780SPaolo Bonzini 24532e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900 2454a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports) 24559933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then 24562e33c3f8SThomas Huth write_c_skeleton 2457a5b2afd5SThomas Huth compile_prog "-march=z900" "" 2458a5b2afd5SThomas Huth has_z900=$? 24593af448b3SThomas Huth if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then 2460a5b2afd5SThomas Huth if [ $has_z900 != 0 ]; then 2461a5b2afd5SThomas Huth echo "WARNING: Your compiler does not support the z900!" 2462a5b2afd5SThomas Huth echo " The s390-ccw bios will only work with guest CPUs >= z10." 2463a5b2afd5SThomas Huth fi 24649933c305SChristian Borntraeger roms="$roms s390-ccw" 24651ef6bfc2SPhilippe Mathieu-Daudé # SLOF is required for building the s390-ccw firmware on s390x, 24661ef6bfc2SPhilippe Mathieu-Daudé # since it is using the libnet code from SLOF for network booting. 24671ef6bfc2SPhilippe Mathieu-Daudé git_submodules="${git_submodules} roms/SLOF" 24681ef6bfc2SPhilippe Mathieu-Daudé fi 24699933c305SChristian Borntraegerfi 24709933c305SChristian Borntraeger 247111cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler. 247211cde1c8SBruno Dominguez# All the QEMU_CXXFLAGS are based on QEMU_CFLAGS. Keep this at the end to don't miss any other that could be added. 247311cde1c8SBruno Dominguezif has $cxx; then 247411cde1c8SBruno Dominguez cat > $TMPC <<EOF 247511cde1c8SBruno Dominguezint c_function(void); 247611cde1c8SBruno Dominguezint main(void) { return c_function(); } 247711cde1c8SBruno DominguezEOF 247811cde1c8SBruno Dominguez 247911cde1c8SBruno Dominguez compile_object 248011cde1c8SBruno Dominguez 248111cde1c8SBruno Dominguez cat > $TMPCXX <<EOF 248211cde1c8SBruno Dominguezextern "C" { 248311cde1c8SBruno Dominguez int c_function(void); 248411cde1c8SBruno Dominguez} 248511cde1c8SBruno Dominguezint c_function(void) { return 42; } 248611cde1c8SBruno DominguezEOF 248711cde1c8SBruno Dominguez 248811cde1c8SBruno Dominguez update_cxxflags 248911cde1c8SBruno Dominguez 2490a2866660SPaolo Bonzini if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then 249111cde1c8SBruno Dominguez # C++ compiler $cxx works ok with C compiler $cc 249211cde1c8SBruno Dominguez : 249311cde1c8SBruno Dominguez else 249411cde1c8SBruno Dominguez echo "C++ compiler $cxx does not work with C compiler $cc" 249511cde1c8SBruno Dominguez echo "Disabling C++ specific optional code" 249611cde1c8SBruno Dominguez cxx= 249711cde1c8SBruno Dominguez fi 249811cde1c8SBruno Dominguezelse 249911cde1c8SBruno Dominguez echo "No C++ compiler available; disabling C++ specific optional code" 250011cde1c8SBruno Dominguez cxx= 250111cde1c8SBruno Dominguezfi 250211cde1c8SBruno Dominguez 25037d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then 25047d7dbf9dSDan Streetman exit 1 25055d91a2edSYonggang Luofi 25065d91a2edSYonggang Luo 250798ec69acSJuan Quintelaconfig_host_mak="config-host.mak" 250897a847bcSbellard 250998ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak 251098ec69acSJuan Quintelaecho >> $config_host_mak 251198ec69acSJuan Quintela 2512e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak 2513cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak 2514aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak 25157d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak 2516804edf29SJuan Quintela 2517f8393946Saurel32if test "$debug_tcg" = "yes" ; then 25182358a494SJuan Quintela echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak 2519f8393946Saurel32fi 252067b915a5Sbellardif test "$mingw32" = "yes" ; then 252198ec69acSJuan Quintela echo "CONFIG_WIN32=y" >> $config_host_mak 25226e444209SPaolo Bonzini echo "QEMU_GA_MSI_MINGW_BIN_PATH=${QEMU_GA_MSI_MINGW_BIN_PATH}" >> $config_host_mak 25239dacf32dSYossi Hindin echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak 25249dacf32dSYossi Hindin echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak 25259dacf32dSYossi Hindin echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak 2526210fa556Spbrookelse 252735f4df27SJuan Quintela echo "CONFIG_POSIX=y" >> $config_host_mak 2528210fa556Spbrookfi 2529128ab2ffSblueswir1 2530dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then 2531dffcb71cSMark McLoughlin echo "CONFIG_LINUX=y" >> $config_host_mak 2532dffcb71cSMark McLoughlinfi 2533dffcb71cSMark McLoughlin 253483fb7adfSbellardif test "$darwin" = "yes" ; then 253598ec69acSJuan Quintela echo "CONFIG_DARWIN=y" >> $config_host_mak 253683fb7adfSbellardfi 2537b29fe3edSmalc 2538ec530c81Sbellardif test "$solaris" = "yes" ; then 253998ec69acSJuan Quintela echo "CONFIG_SOLARIS=y" >> $config_host_mak 2540ec530c81Sbellardfi 254197a847bcSbellardif test "$static" = "yes" ; then 254298ec69acSJuan Quintela echo "CONFIG_STATIC=y" >> $config_host_mak 254397a847bcSbellardfi 2544b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak 2545b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak 254689138857SStefan Weilqemu_version=$(head $source_path/VERSION) 25472358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak 254898ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak 25492b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak 255017969268SFam Zhengif test "$modules" = "yes"; then 2551e26110cfSFam Zheng # $shacmd can generate a hash started with digit, which the compiler doesn't 2552e26110cfSFam Zheng # like as an symbol. So prefix it with an underscore 255389138857SStefan Weil echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak 255417969268SFam Zheng echo "CONFIG_MODULES=y" >> $config_host_mak 255517969268SFam Zhengfi 2556a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak 2557277abf15SJan Vesely 25581badb709SPaolo Bonziniif test "$xen" = "enabled" ; then 25596dbd588aSJan Kiszka echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak 2560d5b93ddfSAnthony PERARD echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak 2561582ea95fSMarc-André Lureau echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak 2562582ea95fSMarc-André Lureau echo "XEN_LIBS=$xen_libs" >> $config_host_mak 2563e37630caSaliguorifi 25645e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then 25655e9be92dSNicholas Bellinger echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak 25665e9be92dSNicholas Bellingerfi 2567af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then 2568af3bba76SPaolo Bonzini echo "CONFIG_VHOST_NET=y" >> $config_host_mak 2569af3bba76SPaolo Bonzinifi 2570af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then 257156f41de7SPaolo Bonzini echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak 257203ce5744SNikolay Nikolaevfi 2573108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then 2574108a6481SCindy Lu echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak 2575108a6481SCindy Lufi 2576042cea27SGongleiif test "$vhost_crypto" = "yes" ; then 2577042cea27SGonglei echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak 2578042cea27SGongleifi 2579fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then 2580fc0b9b0eSStefan Hajnoczi echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak 25815fe97d88SStefano Garzarella if test "$vhost_user" = "yes" ; then 25825fe97d88SStefano Garzarella echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak 25835fe97d88SStefano Garzarella fi 2584fc0b9b0eSStefan Hajnoczifi 2585299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then 2586299e6f19SPaolo Bonzini echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak 2587299e6f19SPaolo Bonzinifi 2588e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then 2589e6a74868SMarc-André Lureau echo "CONFIG_VHOST_USER=y" >> $config_host_mak 2590e6a74868SMarc-André Lureaufi 2591108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then 2592108a6481SCindy Lu echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak 2593108a6481SCindy Lufi 259498fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then 259598fc1adaSDr. David Alan Gilbert echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak 259698fc1adaSDr. David Alan Gilbertfi 259758d3f3ffSGerd Hoffmann 259883fb7adfSbellard# XXX: suppress that 25997d3505c5Sbellardif [ "$bsd" = "yes" ] ; then 26002358a494SJuan Quintela echo "CONFIG_BSD=y" >> $config_host_mak 26017d3505c5Sbellardfi 26027d3505c5Sbellard 26037c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak 26047d992e4dSPeter Lieven 2605d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then 2606d83414e1SMarc-André Lureau echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak 2607d83414e1SMarc-André Lureaufi 2608d83414e1SMarc-André Lureau 26090aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then 26100aebab04SLingfeng Yang echo "CONFIG_TSAN=y" >> $config_host_mak 26110aebab04SLingfeng Yangfi 26120aebab04SLingfeng Yang 261340e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then 261440e8c6f4SAlex Bennée echo "CONFIG_PLUGIN=y" >> $config_host_mak 261540e8c6f4SAlex Bennéefi 261640e8c6f4SAlex Bennée 2617f48e590aSAlex Bennéeif test -n "$gdb_bin"; then 2618b1863cccSAlex Bennée gdb_version=$($gdb_bin --version | head -n 1) 2619d6a66c81SAlex Bennée if version_ge ${gdb_version##* } 9.1; then 2620f48e590aSAlex Bennée echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak 2621f48e590aSAlex Bennée fi 2622b1863cccSAlex Bennéefi 2623f48e590aSAlex Bennée 262498ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak 2625804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak 2626c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak 262739d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak 2628a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak 262909e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak 2630804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak 2631804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak 2632cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak 26335f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak 26343dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak 2635804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak 2636804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak 263746eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak 2638a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak 263911cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak 26404cb37d11SPhilippe Mathieu-Daudéecho "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak 2641a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak 2642a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak 2643d83acfd0SMarc-André Lureauecho "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak 26448a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak 2645e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak 2646a70248dbSPaolo Bonziniecho "STRIP=$strip" >> $config_host_mak 2647804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak 2648804edf29SJuan Quintela 26496efd7517SPeter Maydell# use included Linux headers 26506efd7517SPeter Maydellif test "$linux" = "yes" ; then 2651a307beb6SAndreas Färber mkdir -p linux-headers 26526efd7517SPeter Maydell case "$cpu" in 26534da270beSPaolo Bonzini i386|x86_64) 265408312a63SPeter Maydell linux_arch=x86 26556efd7517SPeter Maydell ;; 2656d8ff892dSPaolo Bonzini ppc|ppc64) 265708312a63SPeter Maydell linux_arch=powerpc 26586efd7517SPeter Maydell ;; 26596efd7517SPeter Maydell s390x) 266008312a63SPeter Maydell linux_arch=s390 266108312a63SPeter Maydell ;; 26621f080313SClaudio Fontana aarch64) 26631f080313SClaudio Fontana linux_arch=arm64 26641f080313SClaudio Fontana ;; 2665dfcf900bSWANG Xuerui loongarch*) 2666dfcf900bSWANG Xuerui linux_arch=loongarch 2667dfcf900bSWANG Xuerui ;; 2668222e7d11SSanjay Lal mips64) 2669222e7d11SSanjay Lal linux_arch=mips 2670222e7d11SSanjay Lal ;; 267108312a63SPeter Maydell *) 267208312a63SPeter Maydell # For most CPUs the kernel architecture name and QEMU CPU name match. 267308312a63SPeter Maydell linux_arch="$cpu" 26746efd7517SPeter Maydell ;; 26756efd7517SPeter Maydell esac 267608312a63SPeter Maydell # For non-KVM architectures we will not have asm headers 267708312a63SPeter Maydell if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then 267808312a63SPeter Maydell symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm 267908312a63SPeter Maydell fi 26806efd7517SPeter Maydellfi 26816efd7517SPeter Maydell 268297a847bcSbellardfor target in $target_list; do 268397a847bcSbellard target_dir="$target" 268457a93f16SPhilippe Mathieu-Daudé target_name=$(echo $target | cut -d '-' -f 1)$EXESUF 268597a847bcSbellard mkdir -p $target_dir 2686fdb75aefSPaolo Bonzini case $target in 2687fdb75aefSPaolo Bonzini *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; 2688fdb75aefSPaolo Bonzini *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; 26892408a527Saurel32 esac 269056aebc89Spbrookdone 26917d13299dSbellard 2692765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak 2693fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then 2694fdb75aefSPaolo Bonzini echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak 2695fdb75aefSPaolo Bonzinifi 2696a540f158SPeter Crosthwaite 2697fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then 2698fd0e6053SJohn Snow echo "export CCACHE_CPP2=y" >> $config_host_mak 2699fd0e6053SJohn Snowfi 2700fd0e6053SJohn Snow 27011e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then 27021e4f6065SDaniele Buono echo "CONFIG_SAFESTACK=y" >> $config_host_mak 27031e4f6065SDaniele Buonofi 27041e4f6065SDaniele Buono 2705e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now. 2706e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree 2707e29e5c6eSPeter Maydell# (these can be both files and directories). 2708e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This 2709e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is 2710e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun 2711e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and 2712e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own 2713e29e5c6eSPeter Maydell# directory and symlink the directory instead. 27142038f8c8SPaolo BonziniLINKS="Makefile" 27153941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target" 2716ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile" 2717e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile" 2718e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit 2719bbbd9b6eSWillian RampazzoLINKS="$LINKS tests/avocado tests/data" 272039950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check" 27218f8fd9edSCleber RosaLINKS="$LINKS python" 2722c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile " 2723753d11f2SRichard Hendersonfor bios_file in \ 2724753d11f2SRichard Henderson $source_path/pc-bios/*.bin \ 27253a631b8eSBin Meng $source_path/pc-bios/*.elf \ 2726225a9ab8SAlexey Kardashevskiy $source_path/pc-bios/*.lid \ 2727753d11f2SRichard Henderson $source_path/pc-bios/*.rom \ 2728753d11f2SRichard Henderson $source_path/pc-bios/*.dtb \ 2729e89e33e1SDominik Dingel $source_path/pc-bios/*.img \ 2730753d11f2SRichard Henderson $source_path/pc-bios/openbios-* \ 27314e73c781SAlexander Graf $source_path/pc-bios/u-boot.* \ 2732cd946e5cSJohn Arbuckle $source_path/pc-bios/palcode-* \ 2733cd946e5cSJohn Arbuckle $source_path/pc-bios/qemu_vga.ndrv 2734cd946e5cSJohn Arbuckle 2735753d11f2SRichard Hendersondo 2736e29e5c6eSPeter Maydell LINKS="$LINKS pc-bios/$(basename $bios_file)" 27377ea78b74SJan Kiszkadone 2738e29e5c6eSPeter Maydellfor f in $LINKS ; do 27390f4d8894SPaolo Bonzini if [ -e "$source_path/$f" ]; then 27405dce7b8dSPaolo Bonzini mkdir -p `dirname ./$f` 2741f9245e10SPeter Maydell symlink "$source_path/$f" "$f" 2742f9245e10SPeter Maydell fi 27437d13299dSbellarddone 27441ad2134fSPaul Brook 27452038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do 27462038f8c8SPaolo Bonzini export $i 27472038f8c8SPaolo Bonzinidone 2748544f4a25SPaolo Bonziniexport target_list source_path use_containers cpu host_cc 27492038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh) 27502038f8c8SPaolo Bonzini 275198409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak 275298409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak 275398409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak 275498409991SHelge Konetzka 2755a5665051SPaolo Bonziniif test "$skip_meson" = no; then 2756fc929892SMarc-André Lureau cross="config-meson.cross.new" 2757fc929892SMarc-André Lureau meson_quote() { 2758ac7ebcc5SPaolo Bonzini test $# = 0 && return 275947b30835SPaolo Bonzini echo "'$(echo $* | sed "s/ /','/g")'" 2760fc929892SMarc-André Lureau } 2761fc929892SMarc-André Lureau 2762fc929892SMarc-André Lureau echo "# Automatically generated by configure - do not modify" > $cross 2763fc929892SMarc-André Lureau echo "[properties]" >> $cross 2764d1d5e9eeSAlex Bennée 2765d1d5e9eeSAlex Bennée # unroll any custom device configs 2766d1d5e9eeSAlex Bennée for a in $device_archs; do 2767d1d5e9eeSAlex Bennée eval "c=\$devices_${a}" 2768d1d5e9eeSAlex Bennée echo "${a}-softmmu = '$c'" >> $cross 2769d1d5e9eeSAlex Bennée done 2770d1d5e9eeSAlex Bennée 2771fc929892SMarc-André Lureau test -z "$cxx" && echo "link_language = 'c'" >> $cross 277247b30835SPaolo Bonzini echo "[built-in options]" >> $cross 2773a2866660SPaolo Bonzini echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross 2774a2866660SPaolo Bonzini echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross 2775e910c7d9SPhilippe Mathieu-Daudé test -n "$objcc" && echo "objc_args = [$(meson_quote $OBJCFLAGS $EXTRA_OBJCFLAGS)]" >> $cross 2776a2866660SPaolo Bonzini echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross 2777a2866660SPaolo Bonzini echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross 2778fc929892SMarc-André Lureau echo "[binaries]" >> $cross 27794dba2789SPaolo Bonzini echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross 27804dba2789SPaolo Bonzini test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross 27814dba2789SPaolo Bonzini test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross 278247b30835SPaolo Bonzini echo "ar = [$(meson_quote $ar)]" >> $cross 278347b30835SPaolo Bonzini echo "nm = [$(meson_quote $nm)]" >> $cross 278447b30835SPaolo Bonzini echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross 278547b30835SPaolo Bonzini echo "ranlib = [$(meson_quote $ranlib)]" >> $cross 2786e8178514SPaolo Bonzini if has $sdl2_config; then 278747b30835SPaolo Bonzini echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross 2788e8178514SPaolo Bonzini fi 278947b30835SPaolo Bonzini echo "strip = [$(meson_quote $strip)]" >> $cross 2790*158bb224SKonstantin Kostiuk echo "widl = [$(meson_quote $widl)]" >> $cross 279147b30835SPaolo Bonzini echo "windres = [$(meson_quote $windres)]" >> $cross 27923812c0c4SJoelle van Dyne if test "$cross_compile" = "yes"; then 2793fc929892SMarc-André Lureau cross_arg="--cross-file config-meson.cross" 2794fc929892SMarc-André Lureau echo "[host_machine]" >> $cross 2795ba7c60c2SPaolo Bonzini echo "system = '$targetos'" >> $cross 2796823eb013SPaolo Bonzini case "$cpu" in 2797f6bca9dfSJoelle van Dyne i386) 2798fc929892SMarc-André Lureau echo "cpu_family = 'x86'" >> $cross 2799fc929892SMarc-André Lureau ;; 2800fc929892SMarc-André Lureau *) 2801823eb013SPaolo Bonzini echo "cpu_family = '$cpu'" >> $cross 2802fc929892SMarc-André Lureau ;; 2803fc929892SMarc-André Lureau esac 2804fc929892SMarc-André Lureau echo "cpu = '$cpu'" >> $cross 2805fc929892SMarc-André Lureau if test "$bigendian" = "yes" ; then 2806fc929892SMarc-André Lureau echo "endian = 'big'" >> $cross 2807fc929892SMarc-André Lureau else 2808fc929892SMarc-André Lureau echo "endian = 'little'" >> $cross 2809fc929892SMarc-André Lureau fi 2810fc929892SMarc-André Lureau else 2811fc929892SMarc-André Lureau cross_arg="--native-file config-meson.cross" 2812fc929892SMarc-André Lureau fi 2813fc929892SMarc-André Lureau mv $cross config-meson.cross 2814fc929892SMarc-André Lureau 2815a5665051SPaolo Bonzini rm -rf meson-private meson-info meson-logs 281661d63097SPaolo Bonzini run_meson() { 281709e93326SPaolo Bonzini NINJA=$ninja $meson setup \ 2818d17f305aSPaolo Bonzini --prefix "$prefix" \ 2819d17f305aSPaolo Bonzini --libdir "$libdir" \ 2820d17f305aSPaolo Bonzini --libexecdir "$libexecdir" \ 2821d17f305aSPaolo Bonzini --bindir "$bindir" \ 2822d17f305aSPaolo Bonzini --includedir "$includedir" \ 2823d17f305aSPaolo Bonzini --datadir "$datadir" \ 2824d17f305aSPaolo Bonzini --mandir "$mandir" \ 2825d17f305aSPaolo Bonzini --sysconfdir "$sysconfdir" \ 282616bf7a33SPaolo Bonzini --localedir "$localedir" \ 2827d17f305aSPaolo Bonzini --localstatedir "$local_statedir" \ 28283b4da132SPaolo Bonzini -Daudio_drv_list=$audio_drv_list \ 28293b4da132SPaolo Bonzini -Ddefault_devices=$default_devices \ 2830d17f305aSPaolo Bonzini -Ddocdir="$docdir" \ 28315dc4618eSPaolo Bonzini -Diasl="$($iasl -h >/dev/null 2>&1 && printf %s "$iasl")" \ 283216bf7a33SPaolo Bonzini -Dqemu_firmwarepath="$firmwarepath" \ 283373f3aa37SMarc-André Lureau -Dqemu_suffix="$qemu_suffix" \ 283435acbb30SPaolo Bonzini -Dsmbd="$smbd" \ 28353b4da132SPaolo Bonzini -Dsphinx_build="$sphinx_build" \ 28363b4da132SPaolo Bonzini -Dtrace_file="$trace_file" \ 2837a5665051SPaolo Bonzini -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \ 2838a5665051SPaolo Bonzini -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \ 2839a5665051SPaolo Bonzini -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ 2840da6d48b9SMarc-André Lureau -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ 2841bf0e56a3SMarc-André Lureau -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ 28423b4da132SPaolo Bonzini -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \ 28433b4da132SPaolo Bonzini -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \ 2844537b7248SPaolo Bonzini $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \ 2845332008e0SThomas Huth $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \ 284661d63097SPaolo Bonzini "$@" $cross_arg "$PWD" "$source_path" 284761d63097SPaolo Bonzini } 284861d63097SPaolo Bonzini eval run_meson $meson_options 2849a5665051SPaolo Bonzini if test "$?" -ne 0 ; then 2850a5665051SPaolo Bonzini error_exit "meson setup failed" 2851a5665051SPaolo Bonzini fi 2852699d3884SPaolo Bonzinielse 2853699d3884SPaolo Bonzini if test -f meson-private/cmd_line.txt; then 2854699d3884SPaolo Bonzini # Adjust old command line options whose type was changed 2855699d3884SPaolo Bonzini # Avoids having to use "setup --wipe" when Meson is upgraded 2856699d3884SPaolo Bonzini perl -i -ne ' 2857699d3884SPaolo Bonzini s/^gettext = true$/gettext = auto/; 2858699d3884SPaolo Bonzini s/^gettext = false$/gettext = disabled/; 2859654d6b04SPaolo Bonzini /^b_staticpic/ && next; 2860699d3884SPaolo Bonzini print;' meson-private/cmd_line.txt 2861699d3884SPaolo Bonzini fi 2862a5665051SPaolo Bonzinifi 2863a5665051SPaolo Bonzini 2864dc655404SMichael S. Tsirkin# Save the configure command line for later reuse. 2865dc655404SMichael S. Tsirkincat <<EOD >config.status 2866dc655404SMichael S. Tsirkin#!/bin/sh 2867dc655404SMichael S. Tsirkin# Generated by configure. 2868dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration. 2869dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging 2870dc655404SMichael S. Tsirkin# configure, is in config.log if it exists. 2871dc655404SMichael S. TsirkinEOD 2872e811da7fSDaniel P. Berrangé 2873e811da7fSDaniel P. Berrangépreserve_env() { 2874e811da7fSDaniel P. Berrangé envname=$1 2875e811da7fSDaniel P. Berrangé 2876e811da7fSDaniel P. Berrangé eval envval=\$$envname 2877e811da7fSDaniel P. Berrangé 2878e811da7fSDaniel P. Berrangé if test -n "$envval" 2879e811da7fSDaniel P. Berrangé then 2880e811da7fSDaniel P. Berrangé echo "$envname='$envval'" >> config.status 2881e811da7fSDaniel P. Berrangé echo "export $envname" >> config.status 2882e811da7fSDaniel P. Berrangé else 2883e811da7fSDaniel P. Berrangé echo "unset $envname" >> config.status 2884e811da7fSDaniel P. Berrangé fi 2885e811da7fSDaniel P. Berrangé} 2886e811da7fSDaniel P. Berrangé 2887e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what 2888e811da7fSDaniel P. Berrangé# features/build target configure will detect 2889e811da7fSDaniel P. Berrangépreserve_env AR 2890e811da7fSDaniel P. Berrangépreserve_env AS 2891e811da7fSDaniel P. Berrangépreserve_env CC 2892e811da7fSDaniel P. Berrangépreserve_env CPP 28938009da03SPaolo Bonzinipreserve_env CFLAGS 2894e811da7fSDaniel P. Berrangépreserve_env CXX 28958009da03SPaolo Bonzinipreserve_env CXXFLAGS 2896e811da7fSDaniel P. Berrangépreserve_env INSTALL 2897e811da7fSDaniel P. Berrangépreserve_env LD 28988009da03SPaolo Bonzinipreserve_env LDFLAGS 2899e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH 2900e811da7fSDaniel P. Berrangépreserve_env LIBTOOL 2901e811da7fSDaniel P. Berrangépreserve_env MAKE 2902e811da7fSDaniel P. Berrangépreserve_env NM 2903e811da7fSDaniel P. Berrangépreserve_env OBJCOPY 2904e811da7fSDaniel P. Berrangépreserve_env PATH 2905e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG 2906e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR 2907e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH 2908e811da7fSDaniel P. Berrangépreserve_env PYTHON 2909e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG 2910e811da7fSDaniel P. Berrangépreserve_env SMBD 2911e811da7fSDaniel P. Berrangépreserve_env STRIP 2912*158bb224SKonstantin Kostiukpreserve_env WIDL 2913e811da7fSDaniel P. Berrangépreserve_env WINDRES 2914e811da7fSDaniel P. Berrangé 2915dc655404SMichael S. Tsirkinprintf "exec" >>config.status 2916a5665051SPaolo Bonzinifor i in "$0" "$@"; do 2917835af899SPaolo Bonzini test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status 2918a5665051SPaolo Bonzinidone 2919cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status 2920dc655404SMichael S. Tsirkinchmod +x config.status 2921dc655404SMichael S. Tsirkin 29228cd05ab6SPeter Maydellrm -r "$TMPDIR1" 2923