xref: /openbmc/qemu/configure (revision de38c0cc)
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"
808cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
8126fffe29SEmilio G. CotaTMPTXT="${TMPDIR1}/${TMPB}.txt"
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
15200849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
15300849b92SRichard Hendersonadd_to() {
15400849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15500849b92SRichard Henderson}
15600849b92SRichard Henderson
1579c83ffd8SPeter Maydellupdate_cxxflags() {
1589c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1599c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1609c83ffd8SPeter Maydell    # because they only make sense for C programs.
161*de38c0ccSPaolo Bonzini    QEMU_CXXFLAGS="-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
1628a9d3d56SRichard Henderson    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu11/-std=gnu++11/)
1639c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1649c83ffd8SPeter Maydell        case $arg in
1659c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1669c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1679c83ffd8SPeter Maydell                ;;
1689c83ffd8SPeter Maydell            *)
1699c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1709c83ffd8SPeter Maydell                ;;
1719c83ffd8SPeter Maydell        esac
1729c83ffd8SPeter Maydell    done
1739c83ffd8SPeter Maydell}
1749c83ffd8SPeter Maydell
17552166aa0SJuan Quintelacompile_object() {
176fd0e6053SJohn Snow  local_cflags="$1"
177a2866660SPaolo Bonzini  do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
17852166aa0SJuan Quintela}
17952166aa0SJuan Quintela
18052166aa0SJuan Quintelacompile_prog() {
18152166aa0SJuan Quintela  local_cflags="$1"
18252166aa0SJuan Quintela  local_ldflags="$2"
183a2866660SPaolo Bonzini  do_cc $CFLAGS $EXTRA_CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
184a2866660SPaolo Bonzini      $LDFLAGS $EXTRA_LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
18552166aa0SJuan Quintela}
18652166aa0SJuan Quintela
18711568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
18811568d6dSPaolo Bonzinisymlink() {
18972b8b5a1SStefan Weil  rm -rf "$2"
190ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
19172b8b5a1SStefan Weil  ln -s "$1" "$2"
19211568d6dSPaolo Bonzini}
19311568d6dSPaolo Bonzini
1940dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1950dba6195SLoïc Minier# executable or a builtin)
1960dba6195SLoïc Minierhas() {
1970dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1980dba6195SLoïc Minier}
1990dba6195SLoïc Minier
2000a01d76fSMarc-André Lureauversion_ge () {
2012df52b9bSAlex Bennée    local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
2022df52b9bSAlex Bennée    local_ver2=$(echo "$2" | tr . ' ')
2030a01d76fSMarc-André Lureau    while true; do
2040a01d76fSMarc-André Lureau        set x $local_ver1
2050a01d76fSMarc-André Lureau        local_first=${2-0}
206c44a33e2SStefano Garzarella        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
207c44a33e2SStefano Garzarella        shift ${2:+2}
2080a01d76fSMarc-André Lureau        local_ver1=$*
2090a01d76fSMarc-André Lureau        set x $local_ver2
2100a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2110a01d76fSMarc-André Lureau        test $# = 1 && return 0
2120a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2130a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
214c44a33e2SStefano Garzarella        shift ${2:+2}
2150a01d76fSMarc-André Lureau        local_ver2=$*
2160a01d76fSMarc-André Lureau    done
2170a01d76fSMarc-André Lureau}
2180a01d76fSMarc-André Lureau
2193b6b7550SPaolo Bonziniglob() {
2203b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2213b6b7550SPaolo Bonzini}
2223b6b7550SPaolo Bonzini
223e9a3591fSChristian Borntraegerld_has() {
224e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
225e9a3591fSChristian Borntraeger}
226e9a3591fSChristian Borntraeger
2274ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2284ace32e2SAntonio Ospitethen
2294ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2304ace32e2SAntonio Ospitefi
2314ace32e2SAntonio Ospite
23214211825SAntonio Ospite# default parameters
2332ff6b91eSJuan Quintelacpu=""
234a31a8642SMichael S. Tsirkiniasl="iasl"
2351e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
23643ce4dfeSbellardstatic="no"
2373812c0c4SJoelle van Dynecross_compile="no"
2387d13299dSbellardcross_prefix=""
23987430d5bSPaolo Bonziniaudio_drv_list="default"
240b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
241b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
242e5f05f8cSKevin Wolfblock_drv_whitelist_tools="no"
243e49d021eSPeter Maydellhost_cc="cc"
244957f1f99SMichael Rothlibs_qga=""
2455bc62e01SGerd Hoffmanndebug_info="yes"
246cdad781dSDaniele Buonolto="false"
24763678e17SSteven Noonanstack_protector=""
2481e4f6065SDaniele Buonosafe_stack=""
249afc3a8f9SAlex Bennéeuse_containers="yes"
250f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
251ac0df51dSaliguori
25292712822SDaniel P. Berrangeif test -e "$source_path/.git"
25392712822SDaniel P. Berrangethen
2547d7dbf9dSDan Streetman    git_submodules_action="update"
25592712822SDaniel P. Berrangeelse
2567d7dbf9dSDan Streetman    git_submodules_action="ignore"
25792712822SDaniel P. Berrangefi
2582d652f24SPaolo Bonzini
2592d652f24SPaolo Bonzinigit_submodules="ui/keycodemapdb"
260cc84d63aSDaniel P. Berrangegit="git"
261ac0df51dSaliguori
262afb63ebdSStefan Weil# Don't accept a target_list environment variable.
263afb63ebdSStefan Weilunset target_list
264447e133fSAlex Bennéeunset target_list_exclude
265377529c0SPaolo Bonzini
266377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
267377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
268377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
269377529c0SPaolo Bonzini#              unless --disable-foo is given
270377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
271377529c0SPaolo Bonzini#              feature will searched for,
272377529c0SPaolo Bonzini#              if not found, configure exits with error
273377529c0SPaolo Bonzini#
274377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
275377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
276377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
277377529c0SPaolo Bonzini
278c87ea116SAlex Bennéedefault_feature=""
279c87ea116SAlex Bennée# parse CC options second
280c87ea116SAlex Bennéefor opt do
281c87ea116SAlex Bennée  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
282c87ea116SAlex Bennée  case "$opt" in
283c87ea116SAlex Bennée      --without-default-features)
284c87ea116SAlex Bennée          default_feature="no"
285c87ea116SAlex Bennée  ;;
286c87ea116SAlex Bennée  esac
287c87ea116SAlex Bennéedone
288c87ea116SAlex Bennée
289a2866660SPaolo BonziniEXTRA_CFLAGS=""
290a2866660SPaolo BonziniEXTRA_CXXFLAGS=""
291a2866660SPaolo BonziniEXTRA_LDFLAGS=""
292a2866660SPaolo Bonzini
293c87ea116SAlex Bennéexen_ctrl_version="$default_feature"
294c87ea116SAlex Bennéexfs="$default_feature"
295c87ea116SAlex Bennéemembarrier="$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"
304c87ea116SAlex Bennéerdma="$default_feature"
305c87ea116SAlex Bennéepvrdma="$default_feature"
306377529c0SPaolo Bonzinigprof="no"
307377529c0SPaolo Bonzinidebug_tcg="no"
308377529c0SPaolo Bonzinidebug="no"
309247724cbSMarc-André Lureausanitizers="no"
3100aebab04SLingfeng Yangtsan="no"
311c87ea116SAlex Bennéefortify_source="$default_feature"
312377529c0SPaolo Bonzinistrip_opt="yes"
313377529c0SPaolo Bonzinimingw32="no"
3141d728c39SBlue Swirlgcov="no"
315c7328271SMiroslav RezaninaEXESUF=""
31617969268SFam Zhengmodules="no"
317bd83c861SChristian Ehrhardtmodule_upgrades="no"
318377529c0SPaolo Bonziniprefix="/usr/local"
31910ff82d1SMarc-André Lureauqemu_suffix="qemu"
320377529c0SPaolo Bonzinibsd="no"
321377529c0SPaolo Bonzinilinux="no"
322377529c0SPaolo Bonzinisolaris="no"
323377529c0SPaolo Bonziniprofiler="no"
324377529c0SPaolo Bonzinisoftmmu="yes"
325377529c0SPaolo Bonzinilinux_user="no"
326377529c0SPaolo Bonzinibsd_user="no"
327377529c0SPaolo Bonzinipkgversion=""
32840d6444eSAvi Kivitypie=""
3293556c233SPaolo Bonziniqom_cast_debug="yes"
330baf86d6bSPaolo Bonzinitrace_backends="log"
331377529c0SPaolo Bonzinitrace_file="trace"
332c87ea116SAlex Bennéeopengl="$default_feature"
3335dd89908SRichard Hendersoncpuid_h="no"
334c87ea116SAlex Bennéeavx2_opt="$default_feature"
335c87ea116SAlex Bennéeguest_agent="$default_feature"
336d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
33750cbebb9SMichael Rothguest_agent_ntddscsi="no"
338c87ea116SAlex Bennéevss_win32_sdk="$default_feature"
339d9840e25STomoki Sekiyamawin_sdk="no"
340c87ea116SAlex Bennéewant_tools="$default_feature"
341519175a2SAlex Barcelocoroutine=""
342c87ea116SAlex Bennéecoroutine_pool="$default_feature"
3437d992e4dSPeter Lievendebug_stack_usage="no"
344f0d92b56SLongpeng(Mike)crypto_afalg="no"
345a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
346c87ea116SAlex Bennéetpm="$default_feature"
347c87ea116SAlex Bennéelibssh="$default_feature"
348c87ea116SAlex Bennéelive_block_migration=${default_feature:-yes}
349c87ea116SAlex Bennéenuma="$default_feature"
350c87ea116SAlex Bennéereplication=${default_feature:-yes}
351c87ea116SAlex Bennéebochs=${default_feature:-yes}
352c87ea116SAlex Bennéecloop=${default_feature:-yes}
353c87ea116SAlex Bennéedmg=${default_feature:-yes}
354c87ea116SAlex Bennéeqcow1=${default_feature:-yes}
355c87ea116SAlex Bennéevdi=${default_feature:-yes}
356c87ea116SAlex Bennéevvfat=${default_feature:-yes}
357c87ea116SAlex Bennéeqed=${default_feature:-yes}
358c87ea116SAlex Bennéeparallels=${default_feature:-yes}
359ba59fb77SPaolo Bonzinidebug_mutex="no"
360ba4dd2aaSAlex Bennéeplugins="$default_feature"
361b767d257SMarek Marczykowski-Góreckirng_none="no"
362c87ea116SAlex Bennéesecret_keyring="$default_feature"
363a5665051SPaolo Bonzinimeson=""
3643b4da132SPaolo Bonzinimeson_args=""
36548328880SPaolo Bonzinininja=""
3663b4da132SPaolo Bonzinigio="$default_feature"
367a5665051SPaolo Bonziniskip_meson=no
368b8e0c493SJoelle van Dyneslirp_smbd="$default_feature"
369377529c0SPaolo Bonzini
3703b4da132SPaolo Bonzini# The following Meson options are handled manually (still they
3713b4da132SPaolo Bonzini# are included in the automatically generated help message)
3723b4da132SPaolo Bonzini
3733b4da132SPaolo Bonzini# 1. Track which submodules are needed
3743b4da132SPaolo Bonzinicapstone="auto"
3753b4da132SPaolo Bonzinifdt="auto"
3763b4da132SPaolo Bonzinislirp="auto"
3773b4da132SPaolo Bonzini
3783b4da132SPaolo Bonzini# 2. Support --with/--without option
3793b4da132SPaolo Bonzinidefault_devices="true"
3803b4da132SPaolo Bonzini
3813b4da132SPaolo Bonzini# 3. Automatically enable/disable other options
3823b4da132SPaolo Bonzinitcg="enabled"
3833b4da132SPaolo Bonzinicfi="false"
3843b4da132SPaolo Bonzini
3853b4da132SPaolo Bonzini# 4. Detection partly done in configure
3863b4da132SPaolo Bonzinixen=${default_feature:+disabled}
387898be3e0SPeter Maydell
388c87ea116SAlex Bennée# parse CC options second
389ac0df51dSaliguorifor opt do
39089138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
391ac0df51dSaliguori  case "$opt" in
392ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
3933812c0c4SJoelle van Dyne                    cross_compile="yes"
394ac0df51dSaliguori  ;;
3953d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
396ac0df51dSaliguori  ;;
39783f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
39883f73fceSTomoki Sekiyama  ;;
3992ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4002ff6b91eSJuan Quintela  ;;
401a2866660SPaolo Bonzini  --extra-cflags=*)
402a2866660SPaolo Bonzini    EXTRA_CFLAGS="$EXTRA_CFLAGS $optarg"
403a2866660SPaolo Bonzini    EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
404e2a2ed06SJuan Quintela    ;;
405a2866660SPaolo Bonzini  --extra-cxxflags=*) EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $optarg"
40611cde1c8SBruno Dominguez  ;;
407a2866660SPaolo Bonzini  --extra-ldflags=*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS $optarg"
408e2a2ed06SJuan Quintela  ;;
4095bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4105bc62e01SGerd Hoffmann  ;;
4115bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4125bc62e01SGerd Hoffmann  ;;
413d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
414d75402b5SAlex Bennée  ;;
415d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
416d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
4172038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
418d422b2bcSAlex Bennée  ;;
419d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
4202038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
421d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
4222038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
423d75402b5SAlex Bennée  ;;
424ac0df51dSaliguori  esac
425ac0df51dSaliguoridone
426ac0df51dSaliguori# OS specific
427ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
42893148aa5SStefan Weil# we can eliminate its usage altogether.
429ac0df51dSaliguori
430e49d021eSPeter Maydell# Preferred compiler:
431e49d021eSPeter Maydell#  ${CC} (if set)
432e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
433e49d021eSPeter Maydell#  system compiler
434e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
435e49d021eSPeter Maydell  cc="$host_cc"
436e49d021eSPeter Maydellelse
437b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
438e49d021eSPeter Maydellfi
439e49d021eSPeter Maydell
44083f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
44183f73fceSTomoki Sekiyama  cxx="c++"
44283f73fceSTomoki Sekiyamaelse
44383f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
44483f73fceSTomoki Sekiyamafi
44583f73fceSTomoki Sekiyama
446b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
447cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
4485f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
4493dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
450b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
451b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
4529f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
4534852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
454b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
455b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
45617884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
45717884d7bSSergei Trofimovichquery_pkg_config() {
45817884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
45917884d7bSSergei Trofimovich}
46017884d7bSSergei Trofimovichpkg_config=query_pkg_config
46147c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
462ac0df51dSaliguori
463be17dc90SMichael S. Tsirkin# default flags for all hosts
4642d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
4652d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
4662d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
4672d31515bSPeter Maydell# provides these semantics.)
468*de38c0ccSPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv"
469086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
470c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
471be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
4725770e8afSPaolo Bonzini
473*de38c0ccSPaolo BonziniQEMU_LDFLAGS=
474*de38c0ccSPaolo Bonzini
4755770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson
4768a9d3d56SRichard HendersonCONFIGURE_CFLAGS="-std=gnu11 -Wall"
4775770e8afSPaolo BonziniCONFIGURE_LDFLAGS=
478086d5f75SPaolo Bonzini
479be17dc90SMichael S. Tsirkin
480ac0df51dSaliguoricheck_define() {
481ac0df51dSaliguoricat > $TMPC <<EOF
482ac0df51dSaliguori#if !defined($1)
483fd786e1aSPeter Maydell#error $1 not defined
484ac0df51dSaliguori#endif
485ac0df51dSaliguoriint main(void) { return 0; }
486ac0df51dSaliguoriEOF
48752166aa0SJuan Quintela  compile_object
488ac0df51dSaliguori}
489ac0df51dSaliguori
490307119e7SGerd Hoffmanncheck_include() {
491307119e7SGerd Hoffmanncat > $TMPC <<EOF
492307119e7SGerd Hoffmann#include <$1>
493307119e7SGerd Hoffmannint main(void) { return 0; }
494307119e7SGerd HoffmannEOF
495307119e7SGerd Hoffmann  compile_object
496307119e7SGerd Hoffmann}
497307119e7SGerd Hoffmann
49893b25869SJohn Snowwrite_c_skeleton() {
49993b25869SJohn Snow    cat > $TMPC <<EOF
50093b25869SJohn Snowint main(void) { return 0; }
50193b25869SJohn SnowEOF
50293b25869SJohn Snow}
50393b25869SJohn Snow
504bbea4050SPeter Maydellif check_define __linux__ ; then
505bbea4050SPeter Maydell  targetos="Linux"
506bbea4050SPeter Maydellelif check_define _WIN32 ; then
507bbea4050SPeter Maydell  targetos='MINGW32'
508bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
509bbea4050SPeter Maydell  targetos='OpenBSD'
510bbea4050SPeter Maydellelif check_define __sun__ ; then
511bbea4050SPeter Maydell  targetos='SunOS'
512bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
513bbea4050SPeter Maydell  targetos='Haiku'
514951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
515951fedfcSPeter Maydell  targetos='FreeBSD'
516951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
517951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
518951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
519951fedfcSPeter Maydell  targetos='DragonFly'
520951fedfcSPeter Maydellelif check_define __NetBSD__; then
521951fedfcSPeter Maydell  targetos='NetBSD'
522951fedfcSPeter Maydellelif check_define __APPLE__; then
523951fedfcSPeter Maydell  targetos='Darwin'
524bbea4050SPeter Maydellelse
525951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
526951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
527951fedfcSPeter Maydell  # be the result of a missing compiler.
528951fedfcSPeter Maydell  targetos='bogus'
529bbea4050SPeter Maydellfi
530bbea4050SPeter Maydell
531bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
532bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
533bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
534bbea4050SPeter Maydell# the correct CPU with the --cpu option.
535bbea4050SPeter Maydellcase $targetos in
536bbea4050SPeter MaydellSunOS)
53789138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
538bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
539bbea4050SPeter Maydell    cpu="x86_64"
540bbea4050SPeter Maydell  fi
541bbea4050SPeter Maydellesac
542bbea4050SPeter Maydell
5432ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
5442ff6b91eSJuan Quintela  # command line argument
5452ff6b91eSJuan Quintela  :
5462ff6b91eSJuan Quintelaelif check_define __i386__ ; then
547ac0df51dSaliguori  cpu="i386"
548ac0df51dSaliguorielif check_define __x86_64__ ; then
549c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
550c72b26ecSRichard Henderson    cpu="x32"
551c72b26ecSRichard Henderson  else
552ac0df51dSaliguori    cpu="x86_64"
553c72b26ecSRichard Henderson  fi
5543aa9bd6cSblueswir1elif check_define __sparc__ ; then
5553aa9bd6cSblueswir1  if check_define __arch64__ ; then
5563aa9bd6cSblueswir1    cpu="sparc64"
5573aa9bd6cSblueswir1  else
5583aa9bd6cSblueswir1    cpu="sparc"
5593aa9bd6cSblueswir1  fi
560fdf7ed96Smalcelif check_define _ARCH_PPC ; then
561fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
562f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
563f8378accSRichard Henderson      cpu="ppc64le"
564f8378accSRichard Henderson    else
565fdf7ed96Smalc      cpu="ppc64"
566f8378accSRichard Henderson    fi
567ac0df51dSaliguori  else
568fdf7ed96Smalc    cpu="ppc"
569fdf7ed96Smalc  fi
570afa05235SAurelien Jarnoelif check_define __mips__ ; then
571afa05235SAurelien Jarno  cpu="mips"
572d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
573d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
574d66ed0eaSAurelien Jarno    cpu="s390x"
575d66ed0eaSAurelien Jarno  else
576d66ed0eaSAurelien Jarno    cpu="s390"
577d66ed0eaSAurelien Jarno  fi
578c4f80543SAlistair Franciselif check_define __riscv ; then
579ba0e7333SRichard Henderson  cpu="riscv"
58021d89f84SPeter Maydellelif check_define __arm__ ; then
58121d89f84SPeter Maydell  cpu="arm"
5821f080313SClaudio Fontanaelif check_define __aarch64__ ; then
5831f080313SClaudio Fontana  cpu="aarch64"
584fdf7ed96Smalcelse
58589138857SStefan Weil  cpu=$(uname -m)
586ac0df51dSaliguorifi
587ac0df51dSaliguori
588359bc95dSPeter MaydellARCH=
589359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
590359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
5917d13299dSbellardcase "$cpu" in
592ba0e7333SRichard Henderson  ppc|ppc64|s390x|sparc64|x32|riscv)
593898be3e0SPeter Maydell  ;;
594f8378accSRichard Henderson  ppc64le)
595f8378accSRichard Henderson    ARCH="ppc64"
596f8378accSRichard Henderson  ;;
5977d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
59897a847bcSbellard    cpu="i386"
5997d13299dSbellard  ;;
600aaa5fa14Saurel32  x86_64|amd64)
601aaa5fa14Saurel32    cpu="x86_64"
602aaa5fa14Saurel32  ;;
60321d89f84SPeter Maydell  armv*b|armv*l|arm)
60421d89f84SPeter Maydell    cpu="arm"
6057d13299dSbellard  ;;
6061f080313SClaudio Fontana  aarch64)
6071f080313SClaudio Fontana    cpu="aarch64"
6081f080313SClaudio Fontana  ;;
609afa05235SAurelien Jarno  mips*)
610afa05235SAurelien Jarno    cpu="mips"
611afa05235SAurelien Jarno  ;;
6123142255cSblueswir1  sparc|sun4[cdmuv])
613ae228531Sbellard    cpu="sparc"
614ae228531Sbellard  ;;
6157d13299dSbellard  *)
616359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
617359bc95dSPeter Maydell    ARCH=unknown
6187d13299dSbellard  ;;
6197d13299dSbellardesac
620359bc95dSPeter Maydellif test -z "$ARCH"; then
621359bc95dSPeter Maydell  ARCH="$cpu"
622359bc95dSPeter Maydellfi
623e2d52ad3SJuan Quintela
6247d13299dSbellard# OS specific
6250dbfc675SJuan Quintela
6267d13299dSbellardcase $targetos in
62767b915a5SbellardMINGW32*)
62867b915a5Sbellard  mingw32="yes"
629898be3e0SPeter Maydell  supported_os="yes"
6309b8e4298SAlex Bennée  plugins="no"
631fb648e9cSDaniel P. Berrangé  pie="no"
63267b915a5Sbellard;;
6335c40d2bdSthsGNU/kFreeBSD)
634a167ba50SAurelien Jarno  bsd="yes"
6355c40d2bdSths;;
6367d3505c5SbellardFreeBSD)
6377d3505c5Sbellard  bsd="yes"
638e2a74729SWarner Losh  bsd_user="yes"
6390db4a067SPaolo Bonzini  make="${MAKE-gmake}"
640f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
6417d3505c5Sbellard;;
642c5e97233Sblueswir1DragonFly)
643c5e97233Sblueswir1  bsd="yes"
6440db4a067SPaolo Bonzini  make="${MAKE-gmake}"
645c5e97233Sblueswir1;;
6467d3505c5SbellardNetBSD)
6477d3505c5Sbellard  bsd="yes"
6480db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6497d3505c5Sbellard;;
6507d3505c5SbellardOpenBSD)
6517d3505c5Sbellard  bsd="yes"
6520db4a067SPaolo Bonzini  make="${MAKE-gmake}"
6537d3505c5Sbellard;;
65483fb7adfSbellardDarwin)
65583fb7adfSbellard  bsd="yes"
65683fb7adfSbellard  darwin="yes"
657a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
658a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
659a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
66083fb7adfSbellard;;
661ec530c81SbellardSunOS)
662ec530c81Sbellard  solaris="yes"
6630db4a067SPaolo Bonzini  make="${MAKE-gmake}"
664e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
665d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
666d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
667d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
668d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
669ec530c81Sbellard;;
670179cf400SAndreas FärberHaiku)
671179cf400SAndreas Färber  haiku="yes"
672b8ee198dSRichard Zak  pie="no"
673b8ee198dSRichard Zak  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE -fPIC $QEMU_CFLAGS"
674179cf400SAndreas Färber;;
675898be3e0SPeter MaydellLinux)
6765327cf48Sbellard  linux="yes"
677831b7825Sths  linux_user="yes"
678c87ea116SAlex Bennée  vhost_user=${default_feature:-yes}
679898be3e0SPeter Maydell;;
6807d13299dSbellardesac
6817d13299dSbellard
6820db4a067SPaolo Bonzini: ${make=${MAKE-make}}
683b6daf4d3SPaolo Bonzini
684faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
685faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
686ddf90699SEduardo Habkost# we check that too
687faf44142SDaniel P. Berrangépython=
6880a01d76fSMarc-André Lureauexplicit_python=no
689ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
690faf44142SDaniel P. Berrangédo
691faf44142SDaniel P. Berrangé    if has "$binary"
692faf44142SDaniel P. Berrangé    then
69395c5f2deSPaolo Bonzini        python=$(command -v "$binary")
694faf44142SDaniel P. Berrangé        break
695faf44142SDaniel P. Berrangé    fi
696faf44142SDaniel P. Berrangédone
697903458c8SMarkus Armbruster
698903458c8SMarkus Armbruster
69939d87c8cSAlex Bennée# Check for ancillary tools used in testing
70039d87c8cSAlex Bennéegenisoimage=
7013df437c7SAlex Bennéefor binary in genisoimage mkisofs
70239d87c8cSAlex Bennéedo
70339d87c8cSAlex Bennée    if has $binary
70439d87c8cSAlex Bennée    then
70539d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
70639d87c8cSAlex Bennée        break
70739d87c8cSAlex Bennée    fi
70839d87c8cSAlex Bennéedone
70939d87c8cSAlex Bennée
7103c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
7113c4a4d0dSPeter Maydellif has clang; then
7123c4a4d0dSPeter Maydell  objcc=clang
7133c4a4d0dSPeter Maydellelse
7143c4a4d0dSPeter Maydell  objcc="$cc"
7153c4a4d0dSPeter Maydellfi
7163c4a4d0dSPeter Maydell
7173457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
7183457a3f8SJuan Quintela  EXESUF=".exe"
71978e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
7205770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
72193b25869SJohn Snow  write_c_skeleton;
722d17f305aSPaolo Bonzini  prefix="/qemu"
72377433a5fSMarc-André Lureau  qemu_suffix=""
724105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
7253457a3f8SJuan Quintelafi
7263457a3f8SJuan Quintela
727487fefdbSAnthony Liguoriwerror=""
72885aa5189Sbellard
72961d63097SPaolo Bonzini. $source_path/scripts/meson-buildoptions.sh
73061d63097SPaolo Bonzini
73161d63097SPaolo Bonzinimeson_options=
73261d63097SPaolo Bonzinimeson_option_parse() {
73361d63097SPaolo Bonzini  meson_options="$meson_options $(_meson_option_parse "$@")"
73461d63097SPaolo Bonzini  if test $? -eq 1; then
73561d63097SPaolo Bonzini    echo "ERROR: unknown option $1"
73661d63097SPaolo Bonzini    echo "Try '$0 --help' for more information"
73761d63097SPaolo Bonzini    exit 1
73861d63097SPaolo Bonzini  fi
73961d63097SPaolo Bonzini}
74061d63097SPaolo Bonzini
7417d13299dSbellardfor opt do
74289138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
7437d13299dSbellard  case "$opt" in
7442efc3265Sbellard  --help|-h) show_help=yes
7452efc3265Sbellard  ;;
74699123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
74799123e13SMike Frysinger  ;;
748b1a550a0Spbrook  --prefix=*) prefix="$optarg"
7497d13299dSbellard  ;;
750b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
75132ce6337Sbellard  ;;
752ac0df51dSaliguori  --cross-prefix=*)
7537d13299dSbellard  ;;
754ac0df51dSaliguori  --cc=*)
7557d13299dSbellard  ;;
756b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
75783469015Sbellard  ;;
75883f73fceSTomoki Sekiyama  --cxx=*)
75983f73fceSTomoki Sekiyama  ;;
760e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
761e007dbecSMichael S. Tsirkin  ;;
7623c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
7633c4a4d0dSPeter Maydell  ;;
764b1a550a0Spbrook  --make=*) make="$optarg"
7657d13299dSbellard  ;;
766b6daf4d3SPaolo Bonzini  --install=*)
7676a882643Spbrook  ;;
7680a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
769c886edfbSBlue Swirl  ;;
7702eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
7712eb054c2SPeter Maydell  ;;
772a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
773a5665051SPaolo Bonzini  ;;
774a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
775a5665051SPaolo Bonzini  ;;
77648328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
77748328880SPaolo Bonzini  ;;
778e2d8830eSBrad  --smbd=*) smbd="$optarg"
779e2d8830eSBrad  ;;
780e2a2ed06SJuan Quintela  --extra-cflags=*)
7817d13299dSbellard  ;;
78211cde1c8SBruno Dominguez  --extra-cxxflags=*)
78311cde1c8SBruno Dominguez  ;;
784e2a2ed06SJuan Quintela  --extra-ldflags=*)
7857d13299dSbellard  ;;
7865bc62e01SGerd Hoffmann  --enable-debug-info)
7875bc62e01SGerd Hoffmann  ;;
7885bc62e01SGerd Hoffmann  --disable-debug-info)
7895bc62e01SGerd Hoffmann  ;;
790d75402b5SAlex Bennée  --cross-cc-*)
791d75402b5SAlex Bennée  ;;
79217969268SFam Zheng  --enable-modules)
79317969268SFam Zheng      modules="yes"
79417969268SFam Zheng  ;;
7953aa88b31SStefan Hajnoczi  --disable-modules)
7963aa88b31SStefan Hajnoczi      modules="no"
7973aa88b31SStefan Hajnoczi  ;;
798bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
799bd83c861SChristian Ehrhardt  ;;
800bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
801bd83c861SChristian Ehrhardt  ;;
8022ff6b91eSJuan Quintela  --cpu=*)
8037d13299dSbellard  ;;
804b1a550a0Spbrook  --target-list=*) target_list="$optarg"
805447e133fSAlex Bennée                   if test "$target_list_exclude"; then
806447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
807447e133fSAlex Bennée                   fi
808447e133fSAlex Bennée  ;;
809447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
810447e133fSAlex Bennée                   if test "$target_list"; then
811447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
812447e133fSAlex Bennée                   fi
813de83cd02Sbellard  ;;
81474242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
8159410b56cSPrerna Saxena  ;;
8167bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
817f3494749SPaolo Bonzini  ;;
8187bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
819f3494749SPaolo Bonzini  ;;
820d1d5e9eeSAlex Bennée  --with-devices-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --with-devices-FOO option"
821d1d5e9eeSAlex Bennée  ;;
822d1d5e9eeSAlex Bennée  --with-devices-*) device_arch=${opt#--with-devices-};
823d1d5e9eeSAlex Bennée                    device_arch=${device_arch%%=*}
824d1d5e9eeSAlex Bennée                    cf=$source_path/configs/devices/$device_arch-softmmu/$optarg.mak
825d1d5e9eeSAlex Bennée                    if test -f "$cf"; then
826d1d5e9eeSAlex Bennée                        device_archs="$device_archs $device_arch"
827d1d5e9eeSAlex Bennée                        eval "devices_${device_arch}=\$optarg"
828d1d5e9eeSAlex Bennée                    else
829d1d5e9eeSAlex Bennée                        error_exit "File $cf does not exist"
830d1d5e9eeSAlex Bennée                    fi
831d1d5e9eeSAlex Bennée  ;;
832c87ea116SAlex Bennée  --without-default-features) # processed above
833c87ea116SAlex Bennée  ;;
8347d13299dSbellard  --enable-gprof) gprof="yes"
8357d13299dSbellard  ;;
8361d728c39SBlue Swirl  --enable-gcov) gcov="yes"
8371d728c39SBlue Swirl  ;;
83879427693SLoïc Minier  --static)
83979427693SLoïc Minier    static="yes"
84017884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
84143ce4dfeSbellard  ;;
8420b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
8430b24e75fSPaolo Bonzini  ;;
8440b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
8450b24e75fSPaolo Bonzini  ;;
8463aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
8473aa5d2beSAlon Levy  ;;
8488bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
8498bf188aaSMichael Tokarev  ;;
8500f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
8510f94d6daSAlon Levy  ;;
852528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
8530b24e75fSPaolo Bonzini  ;;
85477433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
855023d3d67SEduardo Habkost  ;;
856c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
8570b24e75fSPaolo Bonzini  ;;
858fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
859fe0038beSPaolo Bonzini  ;;
860ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
86107381cc1SAnthony Liguori  ;;
862785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
863785c23aeSLuiz Capitulino  ;;
8643d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
8653d5eecabSGerd Hoffmann  ;;
866181ce1d0SOlaf Hering  --host=*|--build=*|\
867181ce1d0SOlaf Hering  --disable-dependency-tracking|\
868785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
869fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
870023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
871023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
872023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
873023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
874023ddd74SMax Filippov    # lots of directory switches by default.
875023ddd74SMax Filippov  ;;
8763556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
8773556c233SPaolo Bonzini  ;;
8783556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
8793556c233SPaolo Bonzini  ;;
8800c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
8810c58ac1cSmalc  ;;
88289138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
883b64ec4e4SFam Zheng  ;;
88489138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
885eb852011SMarkus Armbruster  ;;
886e5f05f8cSKevin Wolf  --enable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="yes"
887e5f05f8cSKevin Wolf  ;;
888e5f05f8cSKevin Wolf  --disable-block-drv-whitelist-in-tools) block_drv_whitelist_tools="no"
889e5f05f8cSKevin Wolf  ;;
890f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
891f8393946Saurel32  ;;
892f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
893f8393946Saurel32  ;;
894f3d08ee6SPaul Brook  --enable-debug)
895f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
896f3d08ee6SPaul Brook      debug_tcg="yes"
8971fcc6d42SPeter Xu      debug_mutex="yes"
898f3d08ee6SPaul Brook      debug="yes"
899f3d08ee6SPaul Brook      strip_opt="no"
900b553a042SJohn Snow      fortify_source="no"
901f3d08ee6SPaul Brook  ;;
902247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
903247724cbSMarc-André Lureau  ;;
904247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
905247724cbSMarc-André Lureau  ;;
9060aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
9070aebab04SLingfeng Yang  ;;
9080aebab04SLingfeng Yang  --disable-tsan) tsan="no"
9090aebab04SLingfeng Yang  ;;
9101625af87Saliguori  --disable-strip) strip_opt="no"
9111625af87Saliguori  ;;
9124d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
913c20709aaSbellard  ;;
914fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
915fd6fc214SPaolo Bonzini  ;;
9164d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
9177c57bdd8SMarc-André Lureau  ;;
91803a3c0b3SPaolo Bonzini  --enable-slirp=*) slirp="$optarg"
919675b9b53SMarc-André Lureau  ;;
9201badb709SPaolo Bonzini  --disable-xen) xen="disabled"
921e37630caSaliguori  ;;
9221badb709SPaolo Bonzini  --enable-xen) xen="enabled"
923fc321b4bSJuan Quintela  ;;
9241badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
925d1a14257SAlex Bennée                 plugins="no"
926b3f6ea7eSPaolo Bonzini  ;;
9271badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
928b3f6ea7eSPaolo Bonzini  ;;
92905c2a3e7Sbellard  --enable-profiler) profiler="yes"
93005c2a3e7Sbellard  ;;
931cad25d69Spbrook  --disable-system) softmmu="no"
9320a8e90f4Spbrook  ;;
933cad25d69Spbrook  --enable-system) softmmu="yes"
9340a8e90f4Spbrook  ;;
9350953a80fSZachary Amsden  --disable-user)
9360953a80fSZachary Amsden      linux_user="no" ;
9370953a80fSZachary Amsden      bsd_user="no" ;
9380953a80fSZachary Amsden  ;;
9390953a80fSZachary Amsden  --enable-user) ;;
940831b7825Sths  --disable-linux-user) linux_user="no"
9410a8e90f4Spbrook  ;;
942831b7825Sths  --enable-linux-user) linux_user="yes"
943831b7825Sths  ;;
94484778508Sblueswir1  --disable-bsd-user) bsd_user="no"
94584778508Sblueswir1  ;;
94684778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
94784778508Sblueswir1  ;;
94840d6444eSAvi Kivity  --enable-pie) pie="yes"
94934005a00SKirill A. Shutemov  ;;
95040d6444eSAvi Kivity  --disable-pie) pie="no"
95134005a00SKirill A. Shutemov  ;;
95285aa5189Sbellard  --enable-werror) werror="yes"
95385aa5189Sbellard  ;;
95485aa5189Sbellard  --disable-werror) werror="no"
95585aa5189Sbellard  ;;
956cdad781dSDaniele Buono  --enable-lto) lto="true"
957cdad781dSDaniele Buono  ;;
958cdad781dSDaniele Buono  --disable-lto) lto="false"
959cdad781dSDaniele Buono  ;;
96063678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
96163678e17SSteven Noonan  ;;
96263678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
96363678e17SSteven Noonan  ;;
9641e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
9651e4f6065SDaniele Buono  ;;
9661e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
9671e4f6065SDaniele Buono  ;;
9689e62ba48SDaniele Buono  --enable-cfi)
9699e62ba48SDaniele Buono      cfi="true";
9709e62ba48SDaniele Buono      lto="true";
9719e62ba48SDaniele Buono  ;;
9729e62ba48SDaniele Buono  --disable-cfi) cfi="false"
9739e62ba48SDaniele Buono  ;;
974fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
9752df87df7SJuan Quintela  ;;
976fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
977fbb4121dSPaolo Bonzini  ;;
978fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
979fbb4121dSPaolo Bonzini  ;;
98003a3c0b3SPaolo Bonzini  --enable-fdt=*) fdt="$optarg"
9812df87df7SJuan Quintela  ;;
982a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
983a40161cbSPaolo Bonzini  ;;
984a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
985a40161cbSPaolo Bonzini  ;;
9867e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
9874a19f1ecSpbrook  ;;
988519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
989519175a2SAlex Barcelo  ;;
99070c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
99170c60c08SStefan Hajnoczi  ;;
99270c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
99370c60c08SStefan Hajnoczi  ;;
9947d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
9957d992e4dSPeter Lieven  ;;
996f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
997f0d92b56SLongpeng(Mike)  ;;
998f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
999f0d92b56SLongpeng(Mike)  ;;
1000d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1001d5970055SMichael S. Tsirkin  ;;
1002d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1003d5970055SMichael S. Tsirkin  ;;
1004042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1005042cea27SGonglei  ;;
1006299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1007042cea27SGonglei  ;;
10085e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
10095e9be92dSNicholas Bellinger  ;;
10105e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
10115e9be92dSNicholas Bellinger  ;;
1012fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1013fc0b9b0eSStefan Hajnoczi  ;;
1014fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1015fc0b9b0eSStefan Hajnoczi  ;;
101698fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
101798fc1adaSDr. David Alan Gilbert  ;;
101898fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
101998fc1adaSDr. David Alan Gilbert  ;;
1020da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
102120ff075bSMichael Walle  ;;
1022da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
102320ff075bSMichael Walle  ;;
10248c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
10258c84cf11SSergei Trofimovich  ;;
10268c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
10278c84cf11SSergei Trofimovich  ;;
10281ffb3bbbSPaolo Bonzini  --disable-zlib-test)
10291ece9905SAlon Levy  ;;
1030d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1031d138cee9SMichael Roth  ;;
1032d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1033d138cee9SMichael Roth  ;;
1034d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1035d9840e25STomoki Sekiyama  ;;
1036d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1037d9840e25STomoki Sekiyama  ;;
1038d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1039d9840e25STomoki Sekiyama  ;;
1040d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1041d9840e25STomoki Sekiyama  ;;
1042d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1043d9840e25STomoki Sekiyama  ;;
1044d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1045d9840e25STomoki Sekiyama  ;;
10464b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
10474b1c11fdSDaniel P. Berrange  ;;
10484b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
10494b1c11fdSDaniel P. Berrange  ;;
105086583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
105186583a07SLiam Merwick  ;;
105286583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
105386583a07SLiam Merwick  ;;
10546b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
10556b8cd447SRobert Hoo  ;;
10566b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
10576b8cd447SRobert Hoo  ;;
105852b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
105952b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1060583f6e7bSStefan Hajnoczi  ;;
1061cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1062cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1063cb6414dfSFam Zheng  ;;
1064315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1065315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1066315d3184SFam Zheng  ;;
1067a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1068a1c5e949SDaniel P. Berrange  ;;
10692da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
10702da776dbSMichael R. Hines  ;;
10712da776dbSMichael R. Hines  --disable-rdma) rdma="no"
10722da776dbSMichael R. Hines  ;;
107321ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
107421ab34c9SMarcel Apfelbaum  ;;
107521ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
107621ab34c9SMarcel Apfelbaum  ;;
1077e91c793cSCole Robinson  --disable-tpm) tpm="no"
1078e91c793cSCole Robinson  ;;
1079ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1080ab214c29SStefan Berger  ;;
1081b10d49d7SPino Toscano  --disable-libssh) libssh="no"
10820a12ec87SRichard W.M. Jones  ;;
1083b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
10840a12ec87SRichard W.M. Jones  ;;
1085ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1086ed1701c6SDr. David Alan Gilbert  ;;
1087ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1088ed1701c6SDr. David Alan Gilbert  ;;
1089a99d57bbSWanlong Gao  --disable-numa) numa="no"
1090a99d57bbSWanlong Gao  ;;
1091a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1092a99d57bbSWanlong Gao  ;;
1093a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1094a6b1d4c0SChanglong Xie  ;;
1095a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1096a6b1d4c0SChanglong Xie  ;;
10972f740136SJeff Cody  --disable-bochs) bochs="no"
10982f740136SJeff Cody  ;;
10992f740136SJeff Cody  --enable-bochs) bochs="yes"
11002f740136SJeff Cody  ;;
11012f740136SJeff Cody  --disable-cloop) cloop="no"
11022f740136SJeff Cody  ;;
11032f740136SJeff Cody  --enable-cloop) cloop="yes"
11042f740136SJeff Cody  ;;
11052f740136SJeff Cody  --disable-dmg) dmg="no"
11062f740136SJeff Cody  ;;
11072f740136SJeff Cody  --enable-dmg) dmg="yes"
11082f740136SJeff Cody  ;;
11092f740136SJeff Cody  --disable-qcow1) qcow1="no"
11102f740136SJeff Cody  ;;
11112f740136SJeff Cody  --enable-qcow1) qcow1="yes"
11122f740136SJeff Cody  ;;
11132f740136SJeff Cody  --disable-vdi) vdi="no"
11142f740136SJeff Cody  ;;
11152f740136SJeff Cody  --enable-vdi) vdi="yes"
11162f740136SJeff Cody  ;;
11172f740136SJeff Cody  --disable-vvfat) vvfat="no"
11182f740136SJeff Cody  ;;
11192f740136SJeff Cody  --enable-vvfat) vvfat="yes"
11202f740136SJeff Cody  ;;
11212f740136SJeff Cody  --disable-qed) qed="no"
11222f740136SJeff Cody  ;;
11232f740136SJeff Cody  --enable-qed) qed="yes"
11242f740136SJeff Cody  ;;
11252f740136SJeff Cody  --disable-parallels) parallels="no"
11262f740136SJeff Cody  ;;
11272f740136SJeff Cody  --enable-parallels) parallels="yes"
11282f740136SJeff Cody  ;;
1129e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1130e6a74868SMarc-André Lureau  ;;
1131299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1132299e6f19SPaolo Bonzini  ;;
1133108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1134108a6481SCindy Lu  ;;
1135108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1136108a6481SCindy Lu  ;;
1137299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1138299e6f19SPaolo Bonzini  ;;
1139299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1140e6a74868SMarc-André Lureau  ;;
11418b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
11428ca80760SRichard Henderson  ;;
11438b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
11448ca80760SRichard Henderson  ;;
11458b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1146e219c499SRichard Henderson  ;;
114703a3c0b3SPaolo Bonzini  --enable-capstone=*) capstone="$optarg"
1148e219c499SRichard Henderson  ;;
1149cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1150cc84d63aSDaniel P. Berrange  ;;
11517d7dbf9dSDan Streetman  --with-git-submodules=*)
11527d7dbf9dSDan Streetman      git_submodules_action="$optarg"
1153f62bbee5SDaniel P. Berrange  ;;
1154ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1155ba59fb77SPaolo Bonzini  ;;
1156ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1157ba59fb77SPaolo Bonzini  ;;
11589b8e4298SAlex Bennée  --enable-plugins) if test "$mingw32" = "yes"; then
11599b8e4298SAlex Bennée                        error_exit "TCG plugins not currently supported on Windows platforms"
11609b8e4298SAlex Bennée                    else
11619b8e4298SAlex Bennée                        plugins="yes"
11629b8e4298SAlex Bennée                    fi
116340e8c6f4SAlex Bennée  ;;
116440e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
116540e8c6f4SAlex Bennée  ;;
1166afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1167afc3a8f9SAlex Bennée  ;;
1168afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1169afc3a8f9SAlex Bennée  ;;
1170f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1171f48e590aSAlex Bennée  ;;
1172b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1173b767d257SMarek Marczykowski-Górecki  ;;
1174b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1175b767d257SMarek Marczykowski-Górecki  ;;
117654e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
117754e7aac0SAlexey Krasikov  ;;
117854e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
117954e7aac0SAlexey Krasikov  ;;
118020cf7b8eSDenis Plotnikov  --enable-gio) gio=yes
118120cf7b8eSDenis Plotnikov  ;;
118220cf7b8eSDenis Plotnikov  --disable-gio) gio=no
118320cf7b8eSDenis Plotnikov  ;;
1184b8e0c493SJoelle van Dyne  --enable-slirp-smbd) slirp_smbd=yes
1185b8e0c493SJoelle van Dyne  ;;
1186b8e0c493SJoelle van Dyne  --disable-slirp-smbd) slirp_smbd=no
1187b8e0c493SJoelle van Dyne  ;;
11883b4da132SPaolo Bonzini  # backwards compatibility options
11893b4da132SPaolo Bonzini  --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
11903b4da132SPaolo Bonzini  ;;
11913b4da132SPaolo Bonzini  --disable-blobs) meson_option_parse --disable-install-blobs ""
11923b4da132SPaolo Bonzini  ;;
11933b4da132SPaolo Bonzini  --enable-tcmalloc) meson_option_parse --enable-malloc=tcmalloc tcmalloc
11943b4da132SPaolo Bonzini  ;;
11953b4da132SPaolo Bonzini  --enable-jemalloc) meson_option_parse --enable-malloc=jemalloc jemalloc
11963b4da132SPaolo Bonzini  ;;
11973b4da132SPaolo Bonzini  # everything else has the same name in configure and meson
119861d63097SPaolo Bonzini  --enable-* | --disable-*) meson_option_parse "$opt" "$optarg"
119961d63097SPaolo Bonzini  ;;
12002d2ad6d0SFam Zheng  *)
12012d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
12022d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
12032d2ad6d0SFam Zheng      exit 1
12047f1559c6Sbalrog  ;;
12057d13299dSbellard  esac
12067d13299dSbellarddone
12077d13299dSbellard
1208d1a14257SAlex Bennée# test for any invalid configuration combinations
1209d1a14257SAlex Bennéeif test "$plugins" = "yes" -a "$tcg" = "disabled"; then
1210d1a14257SAlex Bennée    error_exit "Can't enable plugins on non-TCG builds"
1211d1a14257SAlex Bennéefi
1212d1a14257SAlex Bennée
12137d7dbf9dSDan Streetmancase $git_submodules_action in
12147d7dbf9dSDan Streetman    update|validate)
12157d7dbf9dSDan Streetman        if test ! -e "$source_path/.git"; then
12167d7dbf9dSDan Streetman            echo "ERROR: cannot $git_submodules_action git submodules without .git"
12177d7dbf9dSDan Streetman            exit 1
12187d7dbf9dSDan Streetman        fi
12197d7dbf9dSDan Streetman    ;;
12207d7dbf9dSDan Streetman    ignore)
1221b80fd281SPaolo Bonzini        if ! test -f "$source_path/ui/keycodemapdb/README"
1222b80fd281SPaolo Bonzini        then
1223b80fd281SPaolo Bonzini            echo
1224b80fd281SPaolo Bonzini            echo "ERROR: missing GIT submodules"
1225b80fd281SPaolo Bonzini            echo
1226b80fd281SPaolo Bonzini            if test -e "$source_path/.git"; then
1227b80fd281SPaolo Bonzini                echo "--with-git-submodules=ignore specified but submodules were not"
1228b80fd281SPaolo Bonzini                echo "checked out.  Please initialize and update submodules."
1229b80fd281SPaolo Bonzini            else
1230b80fd281SPaolo Bonzini                echo "This is not a GIT checkout but module content appears to"
1231b80fd281SPaolo Bonzini                echo "be missing. Do not use 'git archive' or GitHub download links"
1232b80fd281SPaolo Bonzini                echo "to acquire QEMU source archives. Non-GIT builds are only"
1233b80fd281SPaolo Bonzini                echo "supported with source archives linked from:"
1234b80fd281SPaolo Bonzini                echo
1235b80fd281SPaolo Bonzini                echo "  https://www.qemu.org/download/#source"
1236b80fd281SPaolo Bonzini                echo
1237b80fd281SPaolo Bonzini                echo "Developers working with GIT can use scripts/archive-source.sh"
1238b80fd281SPaolo Bonzini                echo "if they need to create valid source archives."
1239b80fd281SPaolo Bonzini            fi
1240b80fd281SPaolo Bonzini            echo
1241b80fd281SPaolo Bonzini            exit 1
1242b80fd281SPaolo Bonzini        fi
12437d7dbf9dSDan Streetman    ;;
12447d7dbf9dSDan Streetman    *)
12457d7dbf9dSDan Streetman        echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
12467d7dbf9dSDan Streetman        exit 1
12477d7dbf9dSDan Streetman    ;;
12487d7dbf9dSDan Streetmanesac
12497d7dbf9dSDan Streetman
125022a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
125122a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
125222a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
125322a87800SMarc-André Lureau
125422a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
125515588a62SJoshua Watt    bindir="${bindir:-$prefix}"
125622a87800SMarc-André Lureauelse
125715588a62SJoshua Watt    bindir="${bindir:-$prefix/bin}"
125815588a62SJoshua Wattfi
125922a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}"
126022a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}"
1261ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}"
126222a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}"
126322a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}"
126416bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
126516bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
126622a87800SMarc-André Lureau
126740293e58Sbellardcase "$cpu" in
1268ff66ee53SPaolo Bonzini    ppc) CPU_CFLAGS="-m32" ;;
1269ff66ee53SPaolo Bonzini    ppc64) CPU_CFLAGS="-m64" ;;
1270ff66ee53SPaolo Bonzini    sparc) CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc" ;;
1271ff66ee53SPaolo Bonzini    sparc64) CPU_CFLAGS="-m64 -mcpu=ultrasparc" ;;
1272ff66ee53SPaolo Bonzini    s390) CPU_CFLAGS="-m31" ;;
1273ff66ee53SPaolo Bonzini    s390x) CPU_CFLAGS="-m64" ;;
1274ff66ee53SPaolo Bonzini    i386) CPU_CFLAGS="-m32" ;;
1275ff66ee53SPaolo Bonzini    x32) CPU_CFLAGS="-mx32" ;;
1276ff66ee53SPaolo Bonzini
12777ebee43eSRichard Henderson    # ??? Only extremely old AMD cpus do not have cmpxchg16b.
12787ebee43eSRichard Henderson    # If we truly care, we should simply detect this case at
12797ebee43eSRichard Henderson    # runtime and generate the fallback to serial emulation.
1280ff66ee53SPaolo Bonzini    x86_64) CPU_CFLAGS="-m64 -mcx16" ;;
1281ff66ee53SPaolo Bonzini
128230163d89SPeter Maydell    # No special flags required for other host CPUs
12833142255cSblueswir1esac
12843142255cSblueswir1
12859557af9cSAlex Bennéeif eval test -z "\${cross_cc_$cpu}"; then
1286b1aa4de1SAlex Bennée    eval "cross_cc_${cpu}=\$cc"
12872038f8c8SPaolo Bonzini    cross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
12889557af9cSAlex Bennéefi
128979f3b12fSPeter Crosthwaite
1290affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1291affc88ccSPeter Maydell# support, even if we're using TCI.
1292affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1293affc88ccSPeter Maydell  bsd_user="no"
1294affc88ccSPeter Maydell  linux_user="no"
1295affc88ccSPeter Maydellfi
1296affc88ccSPeter Maydell
129760e0df25SPeter Maydelldefault_target_list=""
129843692239SMarkus Armbrusterdeprecated_targets_list=ppc64abi32-linux-user
1299fdb75aefSPaolo Bonzinideprecated_features=""
13006e92f823SPeter Maydellmak_wilds=""
13016e92f823SPeter Maydell
130260e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
1303812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-softmmu.mak"
130460e0df25SPeter Maydellfi
130560e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
1306812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-linux-user.mak"
130760e0df25SPeter Maydellfi
130860e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
1309812b31d3SAlex Bennée    mak_wilds="${mak_wilds} $source_path/configs/targets/*-bsd-user.mak"
131060e0df25SPeter Maydellfi
131160e0df25SPeter Maydell
13123a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
13133a5ae4a9SAlex Bennée# skip it.
13143a5ae4a9SAlex Bennéeif test -z "$target_list"; then
13153a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
13163a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
13173a5ae4a9SAlex Bennée    else
13183a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
13193a5ae4a9SAlex Bennée    fi
13202d838d9bSAlex Bennéefi
13212d838d9bSAlex Bennée
1322447e133fSAlex Bennéefor config in $mak_wilds; do
1323447e133fSAlex Bennée    target="$(basename "$config" .mak)"
132498db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1325447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1326447e133fSAlex Bennée    fi
1327447e133fSAlex Bennéedone
13286e92f823SPeter Maydell
1329af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1330af5db58eSpbrookcat << EOF
1331af5db58eSpbrook
1332af5db58eSpbrookUsage: configure [options]
1333af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1334af5db58eSpbrook
133508fb77edSStefan WeilStandard options:
133608fb77edSStefan Weil  --help                   print this message
133708fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
133808fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
133908fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
13402deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
134108fb77edSStefan Weil$(echo Available targets: $default_target_list | \
134208fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
13432deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
13442deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1345447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
134608fb77edSStefan Weil
134708fb77edSStefan WeilAdvanced options (experts only):
13483812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
134908fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
135008fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
135108fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
135208fb77edSStefan Weil                           build time
135308fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
135408fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
1355a2866660SPaolo Bonzini  --extra-cflags=CFLAGS    append extra C compiler flags CFLAGS
1356a2866660SPaolo Bonzini  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
135708fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1358d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1359d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
136008fb77edSStefan Weil  --make=MAKE              use specified make [$make]
136108fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
13622eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1363a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
136448328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
136508fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1366db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
13677d7dbf9dSDan Streetman  --with-git-submodules=update   update git submodules (default if .git dir exists)
13687d7dbf9dSDan Streetman  --with-git-submodules=validate fail if git submodules are not up to date
13697d7dbf9dSDan Streetman  --with-git-submodules=ignore   do not update or check git submodules (default if no .git dir)
137008fb77edSStefan Weil  --static                 enable static build [$static]
137108fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
137210ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1373fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
137410ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
137508fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
137608fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1377db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
137810ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
137908fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
13803d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
138113336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1382ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1383db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
1384c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1385c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1386c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1387d1d5e9eeSAlex Bennée                           desired devices in configs/devices/)
1388d1d5e9eeSAlex Bennée  --with-devices-ARCH=NAME override default configs/devices
138908fb77edSStefan Weil  --enable-debug           enable common debug build options
1390247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
13910aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
139208fb77edSStefan Weil  --disable-strip          disable stripping binaries
139308fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
139463678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
139516bfbc70SPaolo Bonzini  --audio-drv-list=LIST    set audio drivers to try if -audiodev is not used
139608fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
139708fb77edSStefan Weil  --block-drv-rw-whitelist=L
139808fb77edSStefan Weil                           set block driver read-write whitelist
1399e5f05f8cSKevin Wolf                           (by default affects only QEMU, not tools like qemu-img)
140008fb77edSStefan Weil  --block-drv-ro-whitelist=L
140108fb77edSStefan Weil                           set block driver read-only whitelist
1402e5f05f8cSKevin Wolf                           (by default affects only QEMU, not tools like qemu-img)
1403e5f05f8cSKevin Wolf  --enable-block-drv-whitelist-in-tools
1404e5f05f8cSKevin Wolf                           use block whitelist also in tools instead of only QEMU
140508fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
140608fb77edSStefan Weil                           Default:trace-<pid>
1407c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
140808fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
140933c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
141008fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1411c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1412c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1413a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1414c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1415c12d66aaSLin Ma  --enable-profiler        profiler support
1416c12d66aaSLin Ma  --enable-debug-stack-usage
1417c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
141840e8c6f4SAlex Bennée  --enable-plugins
141940e8c6f4SAlex Bennée                           enable plugins via shared library loading
1420afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1421f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
142261d63097SPaolo BonziniEOF
142361d63097SPaolo Bonzini  meson_options_help
142461d63097SPaolo Bonzinicat << EOF
1425c23f23b9SMichael Tokarev  system          all system emulation targets
1426c23f23b9SMichael Tokarev  user            supported user emulation targets
1427c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1428c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1429c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1430c23f23b9SMichael Tokarev  pie             Position Independent Executables
143121e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1432bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1433c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1434c23f23b9SMichael Tokarev  debug-info      debugging information
1435cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
14361e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
14371e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
1438a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
143921ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
144021ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1441299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1442299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1443299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1444299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1445299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1446299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1447108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
1448ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1449c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1450c23f23b9SMichael Tokarev  tpm             TPM support
1451b10d49d7SPino Toscano  libssh          ssh block device support
1452c23f23b9SMichael Tokarev  numa            libnuma support
145386583a07SLiam Merwick  avx2            AVX2 optimization support
14546b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1455a6b1d4c0SChanglong Xie  replication     replication support
1456c12d66aaSLin Ma  opengl          opengl support
1457c12d66aaSLin Ma  xfsctl          xfsctl support
1458c12d66aaSLin Ma  qom-cast-debug  cast debugging support
14598de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
14602f740136SJeff Cody  bochs           bochs image format support
14612f740136SJeff Cody  cloop           cloop image format support
14622f740136SJeff Cody  dmg             dmg image format support
14632f740136SJeff Cody  qcow1           qcow v1 image format support
14642f740136SJeff Cody  vdi             vdi image format support
14652f740136SJeff Cody  vvfat           vvfat image format support
14662f740136SJeff Cody  qed             qed image format support
14672f740136SJeff Cody  parallels       parallels image format support
1468f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
1469ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
1470b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
147120cf7b8eSDenis Plotnikov  gio             libgio support
1472b8e0c493SJoelle van Dyne  slirp-smbd      use smbd (at path --smbd=*) in slirp networking
147308fb77edSStefan Weil
147408fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1475af5db58eSpbrookEOF
14762d2ad6d0SFam Zhengexit 0
1477af5db58eSpbrookfi
1478af5db58eSpbrook
14799c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1480bb768f71SThomas Huthrm -f */config-devices.mak.d
14819c790242SThomas Huth
1482faf44142SDaniel P. Berrangéif test -z "$python"
1483faf44142SDaniel P. Berrangéthen
1484c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1485c53eeaf7SStefan Hajnoczifi
14868e2c76bdSRoman Bolshakovif ! has "$make"
14878e2c76bdSRoman Bolshakovthen
14888e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
14898e2c76bdSRoman Bolshakovfi
1490c53eeaf7SStefan Hajnoczi
1491c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1492c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
14931b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
14941b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1495c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1496c53eeaf7SStefan Hajnoczifi
1497c53eeaf7SStefan Hajnoczi
1498755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1499406ab2f3SCleber 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)
1500755ee70fSCleber Rosa
1501c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1502c53eeaf7SStefan Hajnoczipython="$python -B"
1503c53eeaf7SStefan Hajnoczi
15040a01d76fSMarc-André Lureauif test -z "$meson"; then
15056638cae5SPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
15060a01d76fSMarc-André Lureau        meson=meson
15077d7dbf9dSDan Streetman    elif test $git_submodules_action != 'ignore' ; then
15080a01d76fSMarc-André Lureau        meson=git
15090a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
15100a01d76fSMarc-André Lureau        meson=internal
15110a01d76fSMarc-André Lureau    else
15120a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
15130a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
15140a01d76fSMarc-André Lureau        else
1515a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1516a5665051SPaolo Bonzini        fi
15170a01d76fSMarc-André Lureau    fi
15180a01d76fSMarc-André Lureauelse
15190a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
15200a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
15210a01d76fSMarc-André Lureau    #
15220a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
15230a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
15240a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
15250a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
15260a01d76fSMarc-André Lureau        case "$meson" in
15270a01d76fSMarc-André Lureau            git | internal) ;;
15280a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
15290a01d76fSMarc-André Lureau        esac
15300a01d76fSMarc-André Lureau    fi
15310a01d76fSMarc-André Lureaufi
1532a5665051SPaolo Bonzini
15330a01d76fSMarc-André Lureauif test "$meson" = git; then
15340a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
15350a01d76fSMarc-André Lureaufi
15360a01d76fSMarc-André Lureau
15370a01d76fSMarc-André Lureaucase "$meson" in
15380a01d76fSMarc-André Lureau    git | internal)
15390a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
15400a01d76fSMarc-André Lureau        ;;
154184ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
15420a01d76fSMarc-André Lureauesac
15430a01d76fSMarc-André Lureau
154409e93326SPaolo Bonzini# Probe for ninja
154548328880SPaolo Bonzini
154648328880SPaolo Bonziniif test -z "$ninja"; then
154748328880SPaolo Bonzini    for c in ninja ninja-build samu; do
154848328880SPaolo Bonzini        if has $c; then
154948328880SPaolo Bonzini            ninja=$(command -v "$c")
155048328880SPaolo Bonzini            break
155148328880SPaolo Bonzini        fi
155248328880SPaolo Bonzini    done
155309e93326SPaolo Bonzini    if test -z "$ninja"; then
155409e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
155509e93326SPaolo Bonzini    fi
155648328880SPaolo Bonzinifi
1557a5665051SPaolo Bonzini
15589aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
15599aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
15609aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
15619aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
15629aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
15639aae6e54SDaniel Henrique Barbozaif compile_object ; then
15649aae6e54SDaniel Henrique Barboza  : C compiler works ok
15659aae6e54SDaniel Henrique Barbozaelse
15669aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
15679aae6e54SDaniel Henrique Barbozafi
15689aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
15699aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
15709aae6e54SDaniel Henrique Barbozafi
15719aae6e54SDaniel Henrique Barboza
15729c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
15739c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
15749c83ffd8SPeter Maydellif test -z "$werror" ; then
15757d7dbf9dSDan Streetman    if test "$git_submodules_action" != "ignore" && \
1576e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
15779c83ffd8SPeter Maydell        werror="yes"
15789c83ffd8SPeter Maydell    else
15799c83ffd8SPeter Maydell        werror="no"
15809c83ffd8SPeter Maydell    fi
15819c83ffd8SPeter Maydellfi
15829c83ffd8SPeter Maydell
1583975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
1584fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1585fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1586fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1587fb59dabdSPeter Maydell    # host OS we should stop now.
1588951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1589fb59dabdSPeter Maydellfi
1590fb59dabdSPeter Maydell
1591efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
1592efc6c070SThomas Huthcat > $TMPC << EOF
1593efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
1594efc6c070SThomas Huth# ifdef __apple_build_version__
15952a85a08cSDaniel P. Berrangé#  if __clang_major__ < 10 || (__clang_major__ == 10 && __clang_minor__ < 0)
15962a85a08cSDaniel P. Berrangé#   error You need at least XCode Clang v10.0 to compile QEMU
1597efc6c070SThomas Huth#  endif
1598efc6c070SThomas Huth# else
15992a85a08cSDaniel P. Berrangé#  if __clang_major__ < 6 || (__clang_major__ == 6 && __clang_minor__ < 0)
16002a85a08cSDaniel P. Berrangé#   error You need at least Clang v6.0 to compile QEMU
1601efc6c070SThomas Huth#  endif
1602efc6c070SThomas Huth# endif
1603efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
16043830df5fSnia# if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 4)
16053830df5fSnia#  error You need at least GCC v7.4.0 to compile QEMU
1606efc6c070SThomas Huth# endif
1607efc6c070SThomas Huth#else
1608efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
1609efc6c070SThomas Huth#endif
1610efc6c070SThomas Huthint main (void) { return 0; }
1611efc6c070SThomas HuthEOF
1612efc6c070SThomas Huthif ! compile_prog "" "" ; then
16133830df5fSnia    error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v10.0)"
1614efc6c070SThomas Huthfi
1615efc6c070SThomas Huth
161600849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
161700849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
161800849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
161900849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
162000849b92SRichard Henderson# just silently disable some features, so it's too error prone.
162100849b92SRichard Henderson
162200849b92SRichard Hendersonwarn_flags=
162300849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
162400849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
162500849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
162600849b92SRichard Hendersonadd_to warn_flags -Wformat-security
162700849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
162800849b92SRichard Hendersonadd_to warn_flags -Winit-self
162900849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
163000849b92SRichard Hendersonadd_to warn_flags -Wempty-body
163100849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
163200849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
163300849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
16340a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
163500849b92SRichard Henderson
163600849b92SRichard Hendersonnowarn_flags=
163700849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
163800849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
163900849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
164000849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
164100849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
1642aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
1643bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
164400849b92SRichard Henderson
164500849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
164693b25869SJohn Snow
164793b25869SJohn Snowcc_has_warning_flag() {
164893b25869SJohn Snow    write_c_skeleton;
164993b25869SJohn Snow
1650a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
1651a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
1652a1d29d6cSPeter Maydell    # warning options).
165393b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
165493b25869SJohn Snow    compile_prog "-Werror $optflag" ""
165593b25869SJohn Snow}
165693b25869SJohn Snow
165793b25869SJohn Snowfor flag in $gcc_flags; do
165893b25869SJohn Snow    if cc_has_warning_flag $flag ; then
16598d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
16608d05095cSPaolo Bonzini    fi
16618d05095cSPaolo Bonzinidone
16628d05095cSPaolo Bonzini
166363678e17SSteven Noonanif test "$stack_protector" != "no"; then
1664fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
1665fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
1666fccd35a0SRodrigo Rebello{
1667fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
1668fccd35a0SRodrigo Rebello    while (*c) {
1669fccd35a0SRodrigo Rebello        *p++ = *c++;
1670fccd35a0SRodrigo Rebello    }
1671fccd35a0SRodrigo Rebello    return 0;
1672fccd35a0SRodrigo Rebello}
1673fccd35a0SRodrigo RebelloEOF
167463678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
16753b463a3fSMiroslav Rezanina  sp_on=0
167663678e17SSteven Noonan  for flag in $gcc_flags; do
1677590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
1678590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
1679086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
1680590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
168163678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
1682db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
16833b463a3fSMiroslav Rezanina      sp_on=1
168463678e17SSteven Noonan      break
168563678e17SSteven Noonan    fi
168663678e17SSteven Noonan  done
16873b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
16883b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
16893b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
16903b463a3fSMiroslav Rezanina    fi
16913b463a3fSMiroslav Rezanina  fi
169237746c5eSMarc-André Lureaufi
169337746c5eSMarc-André Lureau
169420bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
169520bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
169620bc94a2SPaolo Bonzinicat > $TMPC << EOF
169720bc94a2SPaolo Bonzinistruct {
169820bc94a2SPaolo Bonzini  int a[2];
169920bc94a2SPaolo Bonzini} x = {0};
170020bc94a2SPaolo BonziniEOF
170120bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
170220bc94a2SPaolo Bonzini  :
170320bc94a2SPaolo Bonzinielse
170420bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
170520bc94a2SPaolo Bonzinifi
170620bc94a2SPaolo Bonzini
170721e709aaSMarc-André Lureau# Our module code doesn't support Windows
170821e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
170921e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
171021e709aaSMarc-André Lureaufi
171121e709aaSMarc-André Lureau
1712bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
1713bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
1714bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
1715bd83c861SChristian Ehrhardtfi
1716bd83c861SChristian Ehrhardt
17175f2453acSAlex Bennée# Static linking is not possible with plugins, modules or PIE
171840d6444eSAvi Kivityif test "$static" = "yes" ; then
1719aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
1720aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
1721aa0d1f44SPaolo Bonzini  fi
17225f2453acSAlex Bennée  if test "$plugins" = "yes"; then
17235f2453acSAlex Bennée    error_exit "static and plugins are mutually incompatible"
1724ba4dd2aaSAlex Bennée  else
1725ba4dd2aaSAlex Bennée    plugins="no"
17265f2453acSAlex Bennée  fi
172740d6444eSAvi Kivityfi
172840d6444eSAvi Kivity
172940d6444eSAvi Kivitycat > $TMPC << EOF
173021d4a791SAvi Kivity
173121d4a791SAvi Kivity#ifdef __linux__
173221d4a791SAvi Kivity#  define THREAD __thread
173321d4a791SAvi Kivity#else
173421d4a791SAvi Kivity#  define THREAD
173521d4a791SAvi Kivity#endif
173621d4a791SAvi Kivitystatic THREAD int tls_var;
173721d4a791SAvi Kivityint main(void) { return tls_var; }
173840d6444eSAvi KivityEOF
1739b2634124SRichard Henderson
1740ffd205efSJessica Clarke# Check we support -fno-pie and -no-pie first; we will need the former for
1741ffd205efSJessica Clarke# building ROMs, and both for everything if --disable-pie is passed.
1742412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
1743412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
1744ffd205efSJessica Clarke  LDFLAGS_NOPIE="-no-pie"
1745412aeacdSAlex Bennéefi
1746412aeacdSAlex Bennée
174712781462SRichard Hendersonif test "$static" = "yes"; then
1748eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
17495770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
175012781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
175112781462SRichard Henderson    pie="yes"
175212781462SRichard Henderson  elif test "$pie" = "yes"; then
175312781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
175412781462SRichard Henderson  else
175512781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
175612781462SRichard Henderson    pie="no"
175712781462SRichard Henderson  fi
175812781462SRichard Hendersonelif test "$pie" = "no"; then
17595770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
1760ffd205efSJessica Clarke  CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
1761eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
17625770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
17635770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
176440d6444eSAvi Kivity  pie="yes"
17652c674109SRichard Hendersonelif test "$pie" = "yes"; then
176676ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
176740d6444eSAvi Kivityelse
176840d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
176940d6444eSAvi Kivity  pie="no"
177040d6444eSAvi Kivityfi
177140d6444eSAvi Kivity
1772e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
1773e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
1774e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
1775e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
1776e6cbd751SRichard Hendersonfi
1777e6cbd751SRichard Henderson
177809dada40SPaolo Bonzini##########################################
177909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
178009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
178109dada40SPaolo Bonzini# specification is necessary
178209dada40SPaolo Bonzini
178309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
178409dada40SPaolo Bonzini  cat > $TMPC << EOF
178509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
178609dada40SPaolo Bonzini{
178709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
178809dada40SPaolo Bonzini}
178909dada40SPaolo Bonzini
179009dada40SPaolo Bonziniint main(void)
179109dada40SPaolo Bonzini{
179209dada40SPaolo Bonzini  int val = 42;
17931405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
179409dada40SPaolo Bonzini  sfaa(&val);
179509dada40SPaolo Bonzini  return val;
179609dada40SPaolo Bonzini}
179709dada40SPaolo BonziniEOF
179809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
179909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
180009dada40SPaolo Bonzini  fi
180109dada40SPaolo Bonzinifi
180209dada40SPaolo Bonzini
180356267b62SPhilippe Mathieu-Daudéif test "$tcg" = "enabled"; then
180456267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
180556267b62SPhilippe Mathieu-Daudé    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
180656267b62SPhilippe Mathieu-Daudéfi
180756267b62SPhilippe Mathieu-Daudé
1808afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
1809fdb75aefSPaolo Bonzini    default_targets=yes
1810d880a3baSPaolo Bonzini    for target in $default_target_list; do
1811d880a3baSPaolo Bonzini        target_list="$target_list $target"
1812d880a3baSPaolo Bonzini    done
1813d880a3baSPaolo Bonzini    target_list="${target_list# }"
1814121afa9eSAnthony Liguorielse
1815fdb75aefSPaolo Bonzini    default_targets=no
181689138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
1817d880a3baSPaolo Bonzini    for target in $target_list; do
181825b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
181925b48338SPeter Maydell        # friendly error message than if we let it fall through.
182025b48338SPeter Maydell        case " $default_target_list " in
182125b48338SPeter Maydell            *" $target "*)
182225b48338SPeter Maydell                ;;
182325b48338SPeter Maydell            *)
182425b48338SPeter Maydell                error_exit "Unknown target name '$target'"
182525b48338SPeter Maydell                ;;
182625b48338SPeter Maydell        esac
182725b48338SPeter Maydell    done
1828d880a3baSPaolo Bonzinifi
182925b48338SPeter Maydell
1830fdb75aefSPaolo Bonzinifor target in $target_list; do
1831fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
1832fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
1833fdb75aefSPaolo Bonzini        add_to deprecated_features $target
1834fdb75aefSPaolo Bonzini    fi
1835fdb75aefSPaolo Bonzinidone
1836fdb75aefSPaolo Bonzini
1837f55fe278SPaolo Bonzini# see if system emulation was really requested
1838f55fe278SPaolo Bonzinicase " $target_list " in
1839f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
1840f55fe278SPaolo Bonzini  ;;
1841f55fe278SPaolo Bonzini  *) softmmu=no
1842f55fe278SPaolo Bonzini  ;;
1843f55fe278SPaolo Bonziniesac
18445327cf48Sbellard
1845249247c9SJuan Quintelafeature_not_found() {
1846249247c9SJuan Quintela  feature=$1
184721684af0SStewart Smith  remedy=$2
1848249247c9SJuan Quintela
184976ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
185021684af0SStewart Smith      "configure was not able to find it." \
185121684af0SStewart Smith      "$remedy"
1852249247c9SJuan Quintela}
1853249247c9SJuan Quintela
18547d13299dSbellard# ---
18557d13299dSbellard# big/little endian test
18567d13299dSbellardcat > $TMPC << EOF
1857659eb157SThomas Huth#include <stdio.h>
185861cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
185961cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
1860659eb157SThomas Huthint main(int argc, char *argv[])
1861659eb157SThomas Huth{
1862659eb157SThomas Huth    return printf("%s %s\n", (char *)big_endian, (char *)little_endian);
18637d13299dSbellard}
18647d13299dSbellardEOF
18657d13299dSbellard
1866659eb157SThomas Huthif compile_prog ; then
1867659eb157SThomas Huth    if strings -a $TMPE | grep -q BiGeNdIaN ; then
186861cc919fSMike Frysinger        bigendian="yes"
1869659eb157SThomas Huth    elif strings -a $TMPE | grep -q LiTtLeEnDiAn ; then
187061cc919fSMike Frysinger        bigendian="no"
18717d13299dSbellard    else
18727d13299dSbellard        echo big/little test failed
1873659eb157SThomas Huth        exit 1
18747d13299dSbellard    fi
18757d13299dSbellardelse
187661cc919fSMike Frysinger    echo big/little test failed
1877659eb157SThomas Huth    exit 1
18787d13299dSbellardfi
18797d13299dSbellard
1880b0a47e79SJuan Quintela##########################################
1881e10ee3f5SPhilippe Mathieu-Daudé# system tools
1882e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
1883e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
1884e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
1885e10ee3f5SPhilippe Mathieu-Daudé    else
1886e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
1887e10ee3f5SPhilippe Mathieu-Daudé    fi
1888e10ee3f5SPhilippe Mathieu-Daudéfi
1889e10ee3f5SPhilippe Mathieu-Daudé
1890299e6f19SPaolo Bonzini#########################################
1891299e6f19SPaolo Bonzini# vhost interdependencies and host support
1892299e6f19SPaolo Bonzini
1893299e6f19SPaolo Bonzini# vhost backends
1894d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
1895d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
1896299e6f19SPaolo Bonzinifi
1897108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
1898108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
1899108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
1900108a6481SCindy Lufi
1901299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
1902299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
1903299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
1904299e6f19SPaolo Bonzinifi
1905299e6f19SPaolo Bonzini
1906299e6f19SPaolo Bonzini# vhost-kernel devices
1907299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
1908299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
1909299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
1910299e6f19SPaolo Bonzinifi
1911299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
1912299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
1913299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
1914299e6f19SPaolo Bonzinifi
1915299e6f19SPaolo Bonzini
1916299e6f19SPaolo Bonzini# vhost-user backends
1917299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
1918299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
1919299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
1920299e6f19SPaolo Bonzinifi
1921299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
1922299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
1923299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
1924299e6f19SPaolo Bonzinifi
192598fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
192698fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
192798fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
192898fc1adaSDr. David Alan Gilbertfi
1929108a6481SCindy Lu#vhost-vdpa backends
1930108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
1931108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
1932108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
1933108a6481SCindy Lufi
1934299e6f19SPaolo Bonzini
193540bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
1936299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
1937299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
193840bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
1939299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
1940299e6f19SPaolo Bonzinifi
1941299e6f19SPaolo Bonzini
1942015a33bdSGonglei##########################################
1943779ab5e3SStefan Weil# pkg-config probe
1944779ab5e3SStefan Weil
1945779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
194676ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
1947779ab5e3SStefan Weilfi
1948779ab5e3SStefan Weil
1949779ab5e3SStefan Weil##########################################
1950e37630caSaliguori# xen probe
1951e37630caSaliguori
19521badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
1953c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
1954c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
1955c1cdd9d5SJuergen Gross  # to obtain all needed flags.
1956c1cdd9d5SJuergen Gross
1957c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
1958c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
1959c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
1960c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
19611badb709SPaolo Bonzini    xen=enabled
19625b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
1963c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
196458ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
196558ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
196658ea9a7aSAnthony PERARD    fi
1967582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
1968582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
1969c1cdd9d5SJuergen Gross  else
1970c1cdd9d5SJuergen Gross
19715b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
1972d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
1973d5b93ddfSAnthony PERARD
197450ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
197550ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
197650ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
197750ced5b3SStefan Weil
197850ced5b3SStefan Weil    # Xen (any)
197950ced5b3SStefan Weil    cat > $TMPC <<EOF
198050ced5b3SStefan Weil#include <xenctrl.h>
198150ced5b3SStefan Weilint main(void) {
198250ced5b3SStefan Weil  return 0;
198350ced5b3SStefan Weil}
198450ced5b3SStefan WeilEOF
198550ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
198650ced5b3SStefan Weil      # Xen not found
19871badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
198821684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
198950ced5b3SStefan Weil      fi
19901badb709SPaolo Bonzini      xen=disabled
199150ced5b3SStefan Weil
1992d5b93ddfSAnthony PERARD    # Xen unstable
199369deef08SPeter Maydell    elif
199469deef08SPeter Maydell        cat > $TMPC <<EOF &&
19952cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
19962cbf8903SRoss Lagerwall#define __XEN_TOOLS__
19972cbf8903SRoss Lagerwall#include <xendevicemodel.h>
1998d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
19992cbf8903SRoss Lagerwallint main(void) {
20002cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2001d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
20022cbf8903SRoss Lagerwall
20032cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
20042cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
20052cbf8903SRoss Lagerwall
2006d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2007d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2008d3c49ebbSPaul Durrant
20092cbf8903SRoss Lagerwall  return 0;
20102cbf8903SRoss Lagerwall}
20112cbf8903SRoss LagerwallEOF
20122cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
20132cbf8903SRoss Lagerwall      then
20142cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
20152cbf8903SRoss Lagerwall      xen_ctrl_version=41100
20161badb709SPaolo Bonzini      xen=enabled
20172cbf8903SRoss Lagerwall    elif
20182cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
20195ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
20205ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
202158ea9a7aSAnthony PERARD#include <xentoolcore.h>
20225ba3d756SIgor Druzhininint main(void) {
20235ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
20245ba3d756SIgor Druzhinin
20255ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
20265ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
202758ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
20285ba3d756SIgor Druzhinin
20295ba3d756SIgor Druzhinin  return 0;
20305ba3d756SIgor Druzhinin}
20315ba3d756SIgor DruzhininEOF
203258ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
20335ba3d756SIgor Druzhinin      then
203458ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
20355ba3d756SIgor Druzhinin      xen_ctrl_version=41000
20361badb709SPaolo Bonzini      xen=enabled
20375ba3d756SIgor Druzhinin    elif
20385ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2039da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2040da8090ccSPaul Durrant#define __XEN_TOOLS__
2041da8090ccSPaul Durrant#include <xendevicemodel.h>
2042da8090ccSPaul Durrantint main(void) {
2043da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2044da8090ccSPaul Durrant
2045da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2046da8090ccSPaul Durrant  xendevicemodel_close(xd);
2047da8090ccSPaul Durrant
2048da8090ccSPaul Durrant  return 0;
2049da8090ccSPaul Durrant}
2050da8090ccSPaul DurrantEOF
2051da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2052da8090ccSPaul Durrant      then
2053da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2054f1167ee6SJuergen Gross      xen_ctrl_version=40900
20551badb709SPaolo Bonzini      xen=enabled
2056da8090ccSPaul Durrant    elif
2057da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
20585eeb39c2SIan Campbell/*
20595eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
20605eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2061b6eb9b45SPaulina Szubarczyk *
2062b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2063b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2064b6eb9b45SPaulina Szubarczyk */
2065b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2066b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2067b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2068b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2069b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2070b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2071b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2072b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2073b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2074b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2075b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2076b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2077b6eb9b45SPaulina Szubarczyk#endif
2078b6eb9b45SPaulina Szubarczykint main(void) {
2079b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2080b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2081b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2082b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2083b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2084b6eb9b45SPaulina Szubarczyk
2085b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2086b6eb9b45SPaulina Szubarczyk
2087b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2088b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2089b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2090b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2091b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2092b6eb9b45SPaulina Szubarczyk
2093b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2094b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2095b6eb9b45SPaulina Szubarczyk
2096b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2097b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2098b6eb9b45SPaulina Szubarczyk
2099b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2100b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2101b6eb9b45SPaulina Szubarczyk
2102b6eb9b45SPaulina Szubarczyk  return 0;
2103b6eb9b45SPaulina Szubarczyk}
2104b6eb9b45SPaulina SzubarczykEOF
2105b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2106b6eb9b45SPaulina Szubarczyk      then
2107f1167ee6SJuergen Gross      xen_ctrl_version=40800
21081badb709SPaolo Bonzini      xen=enabled
2109b6eb9b45SPaulina Szubarczyk    elif
2110b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2111b6eb9b45SPaulina Szubarczyk/*
2112b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2113b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
21145eeb39c2SIan Campbell */
21155eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
21165eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
21175eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
21185eeb39c2SIan Campbell#include <xenctrl.h>
21195eeb39c2SIan Campbell#include <xenstore.h>
21205eeb39c2SIan Campbell#include <xenevtchn.h>
21215eeb39c2SIan Campbell#include <xengnttab.h>
21225eeb39c2SIan Campbell#include <xenforeignmemory.h>
21235eeb39c2SIan Campbell#include <stdint.h>
21245eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
21255eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
21265eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
21275eeb39c2SIan Campbell#endif
21285eeb39c2SIan Campbellint main(void) {
21295eeb39c2SIan Campbell  xc_interface *xc = NULL;
21305eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
21315eeb39c2SIan Campbell  xenevtchn_handle *xe;
21325eeb39c2SIan Campbell  xengnttab_handle *xg;
21335eeb39c2SIan Campbell
21345eeb39c2SIan Campbell  xs_daemon_open();
21355eeb39c2SIan Campbell
21365eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
21375eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
21385eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
21395eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
21405eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
21415eeb39c2SIan Campbell
21425eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
21435eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
21445eeb39c2SIan Campbell
21455eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
21465eeb39c2SIan Campbell  xenevtchn_fd(xe);
21475eeb39c2SIan Campbell
21485eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
21495eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
21505eeb39c2SIan Campbell
21515eeb39c2SIan Campbell  return 0;
21525eeb39c2SIan Campbell}
21535eeb39c2SIan CampbellEOF
21545eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
21555eeb39c2SIan Campbell      then
2156f1167ee6SJuergen Gross      xen_ctrl_version=40701
21571badb709SPaolo Bonzini      xen=enabled
2158cdadde39SRoger Pau Monne
2159cdadde39SRoger Pau Monne    # Xen 4.6
2160cdadde39SRoger Pau Monne    elif
2161cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2162cdadde39SRoger Pau Monne#include <xenctrl.h>
2163e108a3c1SAnthony PERARD#include <xenstore.h>
2164d5b93ddfSAnthony PERARD#include <stdint.h>
2165d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2166d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2167d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2168d5b93ddfSAnthony PERARD#endif
2169d5b93ddfSAnthony PERARDint main(void) {
2170d5b93ddfSAnthony PERARD  xc_interface *xc;
2171d5b93ddfSAnthony PERARD  xs_daemon_open();
2172d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2173d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2174d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2175b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
21768688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2177d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
217820a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2179d8b441a3SJan Beulich  return 0;
2180d8b441a3SJan Beulich}
2181d8b441a3SJan BeulichEOF
2182d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2183d8b441a3SJan Beulich      then
2184f1167ee6SJuergen Gross      xen_ctrl_version=40600
21851badb709SPaolo Bonzini      xen=enabled
2186d8b441a3SJan Beulich
2187d8b441a3SJan Beulich    # Xen 4.5
2188d8b441a3SJan Beulich    elif
2189d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2190d8b441a3SJan Beulich#include <xenctrl.h>
2191d8b441a3SJan Beulich#include <xenstore.h>
2192d8b441a3SJan Beulich#include <stdint.h>
2193d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2194d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2195d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2196d8b441a3SJan Beulich#endif
2197d8b441a3SJan Beulichint main(void) {
2198d8b441a3SJan Beulich  xc_interface *xc;
2199d8b441a3SJan Beulich  xs_daemon_open();
2200d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2201d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2202d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2203d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2204d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
22053996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
22063996e85cSPaul Durrant  return 0;
22073996e85cSPaul Durrant}
22083996e85cSPaul DurrantEOF
22093996e85cSPaul Durrant        compile_prog "" "$xen_libs"
22103996e85cSPaul Durrant      then
2211f1167ee6SJuergen Gross      xen_ctrl_version=40500
22121badb709SPaolo Bonzini      xen=enabled
22133996e85cSPaul Durrant
22143996e85cSPaul Durrant    elif
22153996e85cSPaul Durrant        cat > $TMPC <<EOF &&
22163996e85cSPaul Durrant#include <xenctrl.h>
22173996e85cSPaul Durrant#include <xenstore.h>
22183996e85cSPaul Durrant#include <stdint.h>
22193996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
22203996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
22213996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
22223996e85cSPaul Durrant#endif
22233996e85cSPaul Durrantint main(void) {
22243996e85cSPaul Durrant  xc_interface *xc;
22253996e85cSPaul Durrant  xs_daemon_open();
22263996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
22273996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
22283996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
22293996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
22303996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
22318688e065SStefano Stabellini  return 0;
22328688e065SStefano Stabellini}
22338688e065SStefano StabelliniEOF
22348688e065SStefano Stabellini        compile_prog "" "$xen_libs"
223569deef08SPeter Maydell      then
2236f1167ee6SJuergen Gross      xen_ctrl_version=40200
22371badb709SPaolo Bonzini      xen=enabled
22388688e065SStefano Stabellini
2239e37630caSaliguori    else
22401badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2241edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2242edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2243fc321b4bSJuan Quintela      fi
22441badb709SPaolo Bonzini      xen=disabled
2245e37630caSaliguori    fi
2246d5b93ddfSAnthony PERARD
22471badb709SPaolo Bonzini    if test "$xen" = enabled; then
2248f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2249582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
22505eeb39c2SIan Campbell      fi
2251d5b93ddfSAnthony PERARD    fi
2252e37630caSaliguori  fi
2253c1cdd9d5SJuergen Grossfi
2254e37630caSaliguori
2255d661d9a4SJustin Terry (VM)##########################################
22562da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
22572da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
22582da776dbSMichael R. Hines  cat > $TMPC <<EOF
22592da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
22602da776dbSMichael R. Hinesint main(void) { return 0; }
22612da776dbSMichael R. HinesEOF
2262ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
22632da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
22642da776dbSMichael R. Hines    rdma="yes"
22652da776dbSMichael R. Hines  else
22662da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
22672da776dbSMichael R. Hines        error_exit \
2268ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
22692da776dbSMichael R. Hines            " Your options:" \
2270ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
22712da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
22722da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
22732da776dbSMichael R. Hines    fi
22742da776dbSMichael R. Hines    rdma="no"
22752da776dbSMichael R. Hines  fi
22762da776dbSMichael R. Hinesfi
22772da776dbSMichael R. Hines
227821ab34c9SMarcel Apfelbaum##########################################
227921ab34c9SMarcel Apfelbaum# PVRDMA detection
228021ab34c9SMarcel Apfelbaum
228121ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
228221ab34c9SMarcel Apfelbaum#include <sys/mman.h>
228321ab34c9SMarcel Apfelbaum
228421ab34c9SMarcel Apfelbaumint
228521ab34c9SMarcel Apfelbaummain(void)
228621ab34c9SMarcel Apfelbaum{
228721ab34c9SMarcel Apfelbaum    char buf = 0;
228821ab34c9SMarcel Apfelbaum    void *addr = &buf;
228921ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
229021ab34c9SMarcel Apfelbaum
229121ab34c9SMarcel Apfelbaum    return 0;
229221ab34c9SMarcel Apfelbaum}
229321ab34c9SMarcel ApfelbaumEOF
229421ab34c9SMarcel Apfelbaum
229521ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
229621ab34c9SMarcel Apfelbaum    case "$pvrdma" in
229721ab34c9SMarcel Apfelbaum    "")
229821ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
229921ab34c9SMarcel Apfelbaum            pvrdma="yes"
230021ab34c9SMarcel Apfelbaum        else
230121ab34c9SMarcel Apfelbaum            pvrdma="no"
230221ab34c9SMarcel Apfelbaum        fi
230321ab34c9SMarcel Apfelbaum        ;;
230421ab34c9SMarcel Apfelbaum    "yes")
230521ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
230621ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
230721ab34c9SMarcel Apfelbaum        fi
230821ab34c9SMarcel Apfelbaum        pvrdma="yes"
230921ab34c9SMarcel Apfelbaum        ;;
231021ab34c9SMarcel Apfelbaum    "no")
231121ab34c9SMarcel Apfelbaum        pvrdma="no"
231221ab34c9SMarcel Apfelbaum        ;;
231321ab34c9SMarcel Apfelbaum    esac
231421ab34c9SMarcel Apfelbaumelse
231521ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
231621ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
231721ab34c9SMarcel Apfelbaum    fi
231821ab34c9SMarcel Apfelbaum    pvrdma="no"
231921ab34c9SMarcel Apfelbaumfi
232095c6bff3SBenoît Canet
2321ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
2322ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
2323ee108585SYuval Shaia
2324ee108585SYuval Shaiacat > $TMPC <<EOF &&
2325ee108585SYuval Shaia#include <infiniband/verbs.h>
2326ee108585SYuval Shaia
2327ee108585SYuval Shaiaint
2328ee108585SYuval Shaiamain(void)
2329ee108585SYuval Shaia{
2330ee108585SYuval Shaia    struct ibv_mr *mr;
2331ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
2332ee108585SYuval Shaia    size_t length = 10;
2333ee108585SYuval Shaia    uint64_t iova = 0;
2334ee108585SYuval Shaia    int access = 0;
2335ee108585SYuval Shaia    void *addr = NULL;
2336ee108585SYuval Shaia
2337ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
2338ee108585SYuval Shaia
2339ee108585SYuval Shaia    ibv_dereg_mr(mr);
2340ee108585SYuval Shaia
2341ee108585SYuval Shaia    return 0;
2342ee108585SYuval Shaia}
2343ee108585SYuval ShaiaEOF
2344ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
2345ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
2346ee108585SYuval Shaia    fi
2347ee108585SYuval Shaiafi
2348ee108585SYuval Shaia
234995c6bff3SBenoît Canet##########################################
2350c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
2351dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
2352dce512deSChristoph Hellwig  cat > $TMPC << EOF
2353ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
2354dce512deSChristoph Hellwig#include <xfs/xfs.h>
2355dce512deSChristoph Hellwigint main(void)
2356dce512deSChristoph Hellwig{
2357dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
2358dce512deSChristoph Hellwig    return 0;
2359dce512deSChristoph Hellwig}
2360dce512deSChristoph HellwigEOF
2361dce512deSChristoph Hellwig  if compile_prog "" "" ; then
2362dce512deSChristoph Hellwig    xfs="yes"
2363dce512deSChristoph Hellwig  else
2364dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
2365e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
2366dce512deSChristoph Hellwig    fi
2367dce512deSChristoph Hellwig    xfs=no
2368dce512deSChristoph Hellwig  fi
2369dce512deSChristoph Hellwigfi
2370dce512deSChristoph Hellwig
2371dce512deSChristoph Hellwig##########################################
2372ba4dd2aaSAlex Bennée# plugin linker support probe
2373ba4dd2aaSAlex Bennée
2374ba4dd2aaSAlex Bennéeif test "$plugins" != "no"; then
2375ba4dd2aaSAlex Bennée
2376ba4dd2aaSAlex Bennée    #########################################
2377ba4dd2aaSAlex Bennée    # See if --dynamic-list is supported by the linker
2378ba4dd2aaSAlex Bennée
2379ba4dd2aaSAlex Bennée    ld_dynamic_list="no"
2380ba4dd2aaSAlex Bennée    cat > $TMPTXT <<EOF
2381ba4dd2aaSAlex Bennée{
2382ba4dd2aaSAlex Bennée  foo;
2383ba4dd2aaSAlex Bennée};
2384ba4dd2aaSAlex BennéeEOF
2385ba4dd2aaSAlex Bennée
2386ba4dd2aaSAlex Bennée        cat > $TMPC <<EOF
2387ba4dd2aaSAlex Bennée#include <stdio.h>
2388ba4dd2aaSAlex Bennéevoid foo(void);
2389ba4dd2aaSAlex Bennée
2390ba4dd2aaSAlex Bennéevoid foo(void)
2391ba4dd2aaSAlex Bennée{
2392ba4dd2aaSAlex Bennée  printf("foo\n");
2393ba4dd2aaSAlex Bennée}
2394ba4dd2aaSAlex Bennée
2395ba4dd2aaSAlex Bennéeint main(void)
2396ba4dd2aaSAlex Bennée{
2397ba4dd2aaSAlex Bennée  foo();
2398ba4dd2aaSAlex Bennée  return 0;
2399ba4dd2aaSAlex Bennée}
2400ba4dd2aaSAlex BennéeEOF
2401ba4dd2aaSAlex Bennée
2402ba4dd2aaSAlex Bennée    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
2403ba4dd2aaSAlex Bennée        ld_dynamic_list="yes"
2404ba4dd2aaSAlex Bennée    fi
2405ba4dd2aaSAlex Bennée
2406ba4dd2aaSAlex Bennée    #########################################
2407ba4dd2aaSAlex Bennée    # See if -exported_symbols_list is supported by the linker
2408ba4dd2aaSAlex Bennée
2409ba4dd2aaSAlex Bennée    ld_exported_symbols_list="no"
2410ba4dd2aaSAlex Bennée    cat > $TMPTXT <<EOF
2411ba4dd2aaSAlex Bennée  _foo
2412ba4dd2aaSAlex BennéeEOF
2413ba4dd2aaSAlex Bennée
2414ba4dd2aaSAlex Bennée    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
2415ba4dd2aaSAlex Bennée        ld_exported_symbols_list="yes"
2416ba4dd2aaSAlex Bennée    fi
2417ba4dd2aaSAlex Bennée
2418ba4dd2aaSAlex Bennée    if test "$ld_dynamic_list" = "no" &&
2419ba4dd2aaSAlex Bennée       test "$ld_exported_symbols_list" = "no" ; then
2420ba4dd2aaSAlex Bennée        if test "$plugins" = "yes"; then
2421ba4dd2aaSAlex Bennée            error_exit \
2422ba4dd2aaSAlex Bennée                "Plugin support requires dynamic linking and specifying a set of symbols " \
2423ba4dd2aaSAlex Bennée                "that are exported to plugins. Unfortunately your linker doesn't " \
2424ba4dd2aaSAlex Bennée                "support the flag (--dynamic-list or -exported_symbols_list) used " \
2425ba4dd2aaSAlex Bennée                "for this purpose."
2426ba4dd2aaSAlex Bennée        else
2427ba4dd2aaSAlex Bennée            plugins="no"
2428ba4dd2aaSAlex Bennée        fi
2429ba4dd2aaSAlex Bennée    else
2430ba4dd2aaSAlex Bennée        plugins="yes"
2431ba4dd2aaSAlex Bennée    fi
2432ba4dd2aaSAlex Bennéefi
2433ba4dd2aaSAlex Bennée
2434ba4dd2aaSAlex Bennée##########################################
2435e18df141SAnthony Liguori# glib support probe
2436a52d28afSPaolo Bonzini
2437b4c6036fSDaniel P. Berrangéglib_req_ver=2.56
2438aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
2439aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
2440a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
2441b906acacSPaolo Bonzinielif test "$plugins" = "yes"; then
2442b906acacSPaolo Bonzini    glib_modules="$glib_modules gmodule-no-export-2.0"
244354cb65d8SEmilio G. Cotafi
2444e26110cfSFam Zheng
2445aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
2446e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
244789138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
244889138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
2449e18df141SAnthony Liguori    else
2450e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
2451e26110cfSFam Zheng    fi
2452e26110cfSFam Zhengdone
2453e26110cfSFam Zheng
2454215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
2455215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
2456215b0c2fSPaolo Bonzini
2457215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
2458215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
2459215b0c2fSPaolo Bonzinifi
2460215b0c2fSPaolo Bonzini
246120cf7b8eSDenis Plotnikovif ! test "$gio" = "no"; then
246220cf7b8eSDenis Plotnikov    pass=no
2463f876b765SMarc-André Lureau    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
2464f876b765SMarc-André Lureau        gio_cflags=$($pkg_config --cflags gio-2.0)
2465f876b765SMarc-André Lureau        gio_libs=$($pkg_config --libs gio-2.0)
246625a97a56SMarc-André Lureau        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
24675ecfb76cSPaolo Bonzini        if ! has "$gdbus_codegen"; then
24680dba4897SMarc-André Lureau            gdbus_codegen=
24690dba4897SMarc-André Lureau        fi
247076346b62SPeter Maydell        # Check that the libraries actually work -- Ubuntu 18.04 ships
247176346b62SPeter Maydell        # with pkg-config --static --libs data for gio-2.0 that is missing
247276346b62SPeter Maydell        # -lblkid and will give a link error.
247313ceae66SPeter Maydell        cat > $TMPC <<EOF
247413ceae66SPeter Maydell#include <gio/gio.h>
247513ceae66SPeter Maydellint main(void)
247613ceae66SPeter Maydell{
247713ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
247813ceae66SPeter Maydell    return 0;
247913ceae66SPeter Maydell}
248013ceae66SPeter MaydellEOF
248113ceae66SPeter Maydell        if compile_prog "$gio_cflags" "$gio_libs" ; then
248220cf7b8eSDenis Plotnikov            pass=yes
248376346b62SPeter Maydell        else
248420cf7b8eSDenis Plotnikov            pass=no
2485f876b765SMarc-André Lureau        fi
2486f876b765SMarc-André Lureau
248720cf7b8eSDenis Plotnikov        if test "$pass" = "yes" &&
248820cf7b8eSDenis Plotnikov            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
248925a97a56SMarc-André Lureau            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
249025a97a56SMarc-André Lureau            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
249125a97a56SMarc-André Lureau        fi
249220cf7b8eSDenis Plotnikov    fi
249320cf7b8eSDenis Plotnikov
249420cf7b8eSDenis Plotnikov    if test "$pass" = "no"; then
249520cf7b8eSDenis Plotnikov        if test "$gio" = "yes"; then
249620cf7b8eSDenis Plotnikov            feature_not_found "gio" "Install libgio >= 2.0"
249720cf7b8eSDenis Plotnikov        else
249820cf7b8eSDenis Plotnikov            gio=no
249920cf7b8eSDenis Plotnikov        fi
250020cf7b8eSDenis Plotnikov    else
250120cf7b8eSDenis Plotnikov        gio=yes
250220cf7b8eSDenis Plotnikov    fi
250320cf7b8eSDenis Plotnikovfi
250425a97a56SMarc-André Lureau
2505977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
2506977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
2507977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
2508977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
2509977a82abSDaniel P. Berrangecat > $TMPC <<EOF
2510977a82abSDaniel P. Berrange#include <glib.h>
2511977a82abSDaniel P. Berrange#include <unistd.h>
2512977a82abSDaniel P. Berrange
2513977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
2514977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
2515977a82abSDaniel P. Berrange
2516977a82abSDaniel P. Berrangeint main(void) {
2517977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
2518977a82abSDaniel P. Berrange   return 0;
2519977a82abSDaniel P. Berrange}
2520977a82abSDaniel P. BerrangeEOF
2521977a82abSDaniel P. Berrange
2522215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
2523977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
2524977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
2525977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
2526977a82abSDaniel P. Berrange	       "build target"
2527977a82abSDaniel P. Berrangefi
2528977a82abSDaniel P. Berrange
25299bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
25309bda600bSEric Blakecat > $TMPC << EOF
25319bda600bSEric Blake#include <glib.h>
25329bda600bSEric Blaketypedef struct Foo {
25339bda600bSEric Blake    int i;
25349bda600bSEric Blake} Foo;
25359bda600bSEric Blakestatic void foo_free(Foo *f)
25369bda600bSEric Blake{
25379bda600bSEric Blake    g_free(f);
25389bda600bSEric Blake}
25399bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
25409bda600bSEric Blakeint main(void) { return 0; }
25419bda600bSEric BlakeEOF
25429bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
25439bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
25449bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
25455770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
25469bda600bSEric Blake    fi
25479bda600bSEric Blakefi
25489bda600bSEric Blake
2549e26110cfSFam Zheng##########################################
2550e26110cfSFam Zheng# SHA command probe for modules
2551e26110cfSFam Zhengif test "$modules" = yes; then
2552e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
2553e26110cfSFam Zheng    for c in $shacmd_probe; do
25548ccefb91SFam Zheng        if has $c; then
2555e26110cfSFam Zheng            shacmd="$c"
2556e26110cfSFam Zheng            break
2557e26110cfSFam Zheng        fi
2558e26110cfSFam Zheng    done
2559e26110cfSFam Zheng    if test "$shacmd" = ""; then
2560e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
2561e26110cfSFam Zheng    fi
2562e18df141SAnthony Liguorifi
2563e18df141SAnthony Liguori
2564e18df141SAnthony Liguori##########################################
2565b10d49d7SPino Toscano# libssh probe
2566b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
2567b4c10fc6SThomas Huth  if $pkg_config --exists "libssh >= 0.8.7"; then
2568b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
2569b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
2570b10d49d7SPino Toscano    libssh=yes
25710a12ec87SRichard W.M. Jones  else
2572b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
2573b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
25740a12ec87SRichard W.M. Jones    fi
2575b10d49d7SPino Toscano    libssh=no
25760a12ec87SRichard W.M. Jones  fi
25770a12ec87SRichard W.M. Jonesfi
25780a12ec87SRichard W.M. Jones
25790a12ec87SRichard W.M. Jones##########################################
25807aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
25813b8acc11SPaolo Bonzini
25827aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
25837aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
25847aaa6a16SPaolo Bonzini    tpm=no
25853b8acc11SPaolo Bonzini  else
25867aaa6a16SPaolo Bonzini    tpm=yes
25877aaa6a16SPaolo Bonzini  fi
25887aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
25897aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
25907aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
25917aaa6a16SPaolo Bonzini  fi
25923b8acc11SPaolo Bonzinifi
25933b8acc11SPaolo Bonzini
25943b8acc11SPaolo Bonzini##########################################
2595f652e6afSaurel32# fdt probe
2596e169e1e1SPeter Maydell
2597fbb4121dSPaolo Bonzinicase "$fdt" in
2598fbb4121dSPaolo Bonzini  auto | enabled | internal)
2599fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
2600aef45d51SDaniel P. Berrange    git_submodules="${git_submodules} dtc"
2601fbb4121dSPaolo Bonzini    ;;
2602fbb4121dSPaolo Bonziniesac
2603f652e6afSaurel32
260420ff075bSMichael Walle##########################################
26059d49bcf6SMarkus Armbruster# opengl probe (for sdl2, gtk)
2606b1546f32SGerd Hoffmann
2607da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
2608bc6a3565SAkihiko Odaki  epoxy=no
2609bc6a3565SAkihiko Odaki  if $pkg_config epoxy; then
2610bc6a3565SAkihiko Odaki    cat > $TMPC << EOF
2611bc6a3565SAkihiko Odaki#include <epoxy/egl.h>
2612bc6a3565SAkihiko Odakiint main(void) { return 0; }
2613bc6a3565SAkihiko OdakiEOF
2614bc6a3565SAkihiko Odaki    if compile_prog "" "" ; then
2615bc6a3565SAkihiko Odaki      epoxy=yes
2616bc6a3565SAkihiko Odaki    fi
2617bc6a3565SAkihiko Odaki  fi
2618bc6a3565SAkihiko Odaki
2619bc6a3565SAkihiko Odaki  if test "$epoxy" = "yes" ; then
2620bc6a3565SAkihiko Odaki    opengl_cflags="$($pkg_config --cflags epoxy)"
2621bc6a3565SAkihiko Odaki    opengl_libs="$($pkg_config --libs epoxy)"
2622da076ffeSGerd Hoffmann    opengl=yes
262320ff075bSMichael Walle  else
2624da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
2625bc6a3565SAkihiko Odaki      feature_not_found "opengl" "Please install epoxy with EGL"
262620ff075bSMichael Walle    fi
2627f676c67eSJeremy White    opengl_cflags=""
2628da076ffeSGerd Hoffmann    opengl_libs=""
2629da076ffeSGerd Hoffmann    opengl=no
263020ff075bSMichael Walle  fi
263120ff075bSMichael Wallefi
263220ff075bSMichael Walle
2633dcc38d1cSMarcelo Tosatti##########################################
2634a99d57bbSWanlong Gao# libnuma probe
2635a99d57bbSWanlong Gao
2636a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
2637a99d57bbSWanlong Gao  cat > $TMPC << EOF
2638a99d57bbSWanlong Gao#include <numa.h>
2639a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
2640a99d57bbSWanlong GaoEOF
2641a99d57bbSWanlong Gao
2642a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
2643a99d57bbSWanlong Gao    numa=yes
2644ab318051SMarc-André Lureau    numa_libs="-lnuma"
2645a99d57bbSWanlong Gao  else
2646a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
2647a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
2648a99d57bbSWanlong Gao    fi
2649a99d57bbSWanlong Gao    numa=no
2650a99d57bbSWanlong Gao  fi
2651a99d57bbSWanlong Gaofi
2652a99d57bbSWanlong Gao
2653955727d2SCortland Tölva# check for usbfs
2654955727d2SCortland Tölvahave_usbfs=no
2655955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
265696566d09SThomas Petazzoni  cat > $TMPC << EOF
265796566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
265896566d09SThomas Petazzoni
265996566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
266096566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
266196566d09SThomas Petazzoni#endif
266296566d09SThomas Petazzoni
266396566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
266496566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
266596566d09SThomas Petazzoni#endif
266696566d09SThomas Petazzoni
266796566d09SThomas Petazzoniint main(void)
266896566d09SThomas Petazzoni{
266996566d09SThomas Petazzoni    return 0;
267096566d09SThomas Petazzoni}
267196566d09SThomas PetazzoniEOF
267296566d09SThomas Petazzoni  if compile_prog "" ""; then
2673955727d2SCortland Tölva    have_usbfs=yes
2674955727d2SCortland Tölva  fi
2675955727d2SCortland Tölvafi
2676751bcc39SMarc-André Lureau
2677de5071c5SBlue Swirl##########################################
2678d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
2679d9840e25STomoki Sekiyama
2680e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2681e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
2682d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
2683690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
2684d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
2685d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
2686690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
2687d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
2688d9840e25STomoki Sekiyama	  ;;
2689690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
2690d9840e25STomoki Sekiyama  esac
2691d9840e25STomoki Sekiyama  cat > $TMPC << EOF
2692d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
2693d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
2694d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
2695d9840e25STomoki SekiyamaEOF
2696d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
2697d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
2698d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
2699315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
2700f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
2701d9840e25STomoki Sekiyama  else
2702d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
2703d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
2704d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
2705d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
2706d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
2707d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
2708d9840e25STomoki Sekiyama      feature_not_found "VSS support"
2709d9840e25STomoki Sekiyama    fi
2710d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
2711d9840e25STomoki Sekiyama  fi
2712d9840e25STomoki Sekiyamafi
2713d9840e25STomoki Sekiyama
2714d9840e25STomoki Sekiyama##########################################
2715d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
2716d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
2717d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
2718d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
2719d9840e25STomoki Sekiyama
2720e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
2721e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
2722d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
2723d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
2724d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
2725d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
2726d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
2727d9840e25STomoki Sekiyama    else
2728d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
2729d9840e25STomoki Sekiyama    fi
2730d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
2731d9840e25STomoki Sekiyama    win_sdk=""
2732d9840e25STomoki Sekiyama  fi
2733d9840e25STomoki Sekiyamafi
2734d9840e25STomoki Sekiyama
2735d9840e25STomoki Sekiyama##########################################
273650cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
2737e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
273850cbebb9SMichael Roth  cat > $TMPC << EOF
273950cbebb9SMichael Roth#include <windows.h>
274050cbebb9SMichael Roth#include <ntddscsi.h>
274150cbebb9SMichael Rothint main(void) {
274250cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
274350cbebb9SMichael Roth#error Missing required ioctl definitions
274450cbebb9SMichael Roth#endif
274550cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
274650cbebb9SMichael Roth  return addr.Lun;
274750cbebb9SMichael Roth}
274850cbebb9SMichael RothEOF
274950cbebb9SMichael Roth  if compile_prog "" "" ; then
275050cbebb9SMichael Roth    guest_agent_ntddscsi=yes
2751996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
275250cbebb9SMichael Roth  fi
275350cbebb9SMichael Rothfi
275450cbebb9SMichael Roth
275550cbebb9SMichael Roth##########################################
27568ca80760SRichard Henderson# capstone
27578ca80760SRichard Henderson
2758e219c499SRichard Hendersoncase "$capstone" in
27598b18cdbfSRichard Henderson  auto | enabled | internal)
27608b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
2761e219c499SRichard Henderson    git_submodules="${git_submodules} capstone"
2762e219c499SRichard Henderson    ;;
2763e219c499SRichard Hendersonesac
27648ca80760SRichard Henderson
27658ca80760SRichard Henderson##########################################
2766519175a2SAlex Barcelo# check and set a backend for coroutine
2767d0e2fce5SAneesh Kumar K.V
27687c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
276933c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
277033c53c54SDaniel P. Berrange# specific one.
27717c2acc70SPeter Maydell
27727c2acc70SPeter Maydellucontext_works=no
2773d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
2774d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
2775d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
2776cdf84806SPeter Maydell#ifdef __stub_makecontext
2777cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
2778cdf84806SPeter Maydell#endif
277975cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
2780d0e2fce5SAneesh Kumar K.VEOF
2781d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
27827c2acc70SPeter Maydell    ucontext_works=yes
2783d0e2fce5SAneesh Kumar K.V  fi
2784519175a2SAlex Barcelofi
27857c2acc70SPeter Maydell
27867c2acc70SPeter Maydellif test "$coroutine" = ""; then
27877c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
27887c2acc70SPeter Maydell    coroutine=win32
27897c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
27907c2acc70SPeter Maydell    coroutine=ucontext
2791519175a2SAlex Barcelo  else
27927c2acc70SPeter Maydell    coroutine=sigaltstack
27937c2acc70SPeter Maydell  fi
27947c2acc70SPeter Maydellelse
27957c2acc70SPeter Maydell  case $coroutine in
27967c2acc70SPeter Maydell  windows)
27977c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
27987c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
27997c2acc70SPeter Maydell    fi
28007c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
28017c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
28027c2acc70SPeter Maydell    coroutine=win32
28037c2acc70SPeter Maydell    ;;
28047c2acc70SPeter Maydell  ucontext)
28057c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
28067c2acc70SPeter Maydell      feature_not_found "ucontext"
28077c2acc70SPeter Maydell    fi
28087c2acc70SPeter Maydell    ;;
280933c53c54SDaniel P. Berrange  sigaltstack)
28107c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
28117c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
28127c2acc70SPeter Maydell    fi
28137c2acc70SPeter Maydell    ;;
28147c2acc70SPeter Maydell  *)
281576ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
28167c2acc70SPeter Maydell    ;;
28177c2acc70SPeter Maydell  esac
2818d0e2fce5SAneesh Kumar K.Vfi
2819d0e2fce5SAneesh Kumar K.V
282070c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
282170c60c08SStefan Hajnoczi  coroutine_pool=yes
282270c60c08SStefan Hajnoczifi
282370c60c08SStefan Hajnoczi
28247d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
28257d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
28267d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
28277d992e4dSPeter Lieven    coroutine_pool=no
28287d992e4dSPeter Lieven  fi
28297d992e4dSPeter Lievenfi
28307d992e4dSPeter Lieven
28311e4f6065SDaniele Buono##################################################
28321e4f6065SDaniele Buono# SafeStack
28331e4f6065SDaniele Buono
28341e4f6065SDaniele Buono
28351e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
28361e4f6065SDaniele Buonocat > $TMPC << EOF
28371e4f6065SDaniele Buonoint main(int argc, char *argv[])
28381e4f6065SDaniele Buono{
28391e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
28401e4f6065SDaniele Buono#error SafeStack Disabled
28411e4f6065SDaniele Buono#endif
28421e4f6065SDaniele Buono    return 0;
28431e4f6065SDaniele Buono}
28441e4f6065SDaniele BuonoEOF
28451e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
28461e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
28471e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
28481e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
28491e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
28501e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
28511e4f6065SDaniele Buono  else
28521e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
28531e4f6065SDaniele Buono  fi
28541e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
28551e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
28561e4f6065SDaniele Buono  fi
28571e4f6065SDaniele Buonoelse
28581e4f6065SDaniele Buonocat > $TMPC << EOF
28591e4f6065SDaniele Buonoint main(int argc, char *argv[])
28601e4f6065SDaniele Buono{
28611e4f6065SDaniele Buono#if defined(__has_feature)
28621e4f6065SDaniele Buono#if __has_feature(safe_stack)
28631e4f6065SDaniele Buono#error SafeStack Enabled
28641e4f6065SDaniele Buono#endif
28651e4f6065SDaniele Buono#endif
28661e4f6065SDaniele Buono    return 0;
28671e4f6065SDaniele Buono}
28681e4f6065SDaniele BuonoEOF
28691e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
28701e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
28711e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
28721e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
28731e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
28741e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
28751e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
28761e4f6065SDaniele Buono    fi
28771e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
28781e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
28791e4f6065SDaniele Buono  fi
28801e4f6065SDaniele Buonoelse # "$safe_stack" = ""
28811e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
28821e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
28831e4f6065SDaniele Buono    safe_stack="no"
28841e4f6065SDaniele Buono  else
28851e4f6065SDaniele Buono    safe_stack="yes"
28861e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
28871e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
28881e4f6065SDaniele Buono    fi
28891e4f6065SDaniele Buono  fi
28901e4f6065SDaniele Buonofi
28911e4f6065SDaniele Buonofi
28927d992e4dSPeter Lieven
289376a347e1SRichard Henderson########################################
289476a347e1SRichard Henderson# check if cpuid.h is usable.
289576a347e1SRichard Henderson
289676a347e1SRichard Hendersoncat > $TMPC << EOF
289776a347e1SRichard Henderson#include <cpuid.h>
289876a347e1SRichard Hendersonint main(void) {
2899774d566cSPeter Maydell    unsigned a, b, c, d;
2900774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
2901774d566cSPeter Maydell
2902774d566cSPeter Maydell    if (max >= 1) {
2903774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
2904774d566cSPeter Maydell    }
2905774d566cSPeter Maydell
2906774d566cSPeter Maydell    if (max >= 7) {
2907774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
2908774d566cSPeter Maydell    }
2909774d566cSPeter Maydell
291076a347e1SRichard Henderson    return 0;
291176a347e1SRichard Henderson}
291276a347e1SRichard HendersonEOF
291376a347e1SRichard Hendersonif compile_prog "" "" ; then
291476a347e1SRichard Henderson    cpuid_h=yes
291576a347e1SRichard Hendersonfi
291676a347e1SRichard Henderson
29175dd89908SRichard Henderson##########################################
29185dd89908SRichard Henderson# avx2 optimization requirement check
29195dd89908SRichard Henderson#
29205dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
29215dd89908SRichard Henderson# since we won't be able to select the new routines.
29225dd89908SRichard Henderson
2923e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
29245dd89908SRichard Henderson  cat > $TMPC << EOF
29255dd89908SRichard Henderson#pragma GCC push_options
29265dd89908SRichard Henderson#pragma GCC target("avx2")
29275dd89908SRichard Henderson#include <cpuid.h>
29285dd89908SRichard Henderson#include <immintrin.h>
29295dd89908SRichard Hendersonstatic int bar(void *a) {
29305dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
29315dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
29325dd89908SRichard Henderson}
29335dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
29345dd89908SRichard HendersonEOF
29355b945f23SRichard Henderson  if compile_object "-Werror" ; then
29365dd89908SRichard Henderson    avx2_opt="yes"
293786583a07SLiam Merwick  else
293886583a07SLiam Merwick    avx2_opt="no"
29395dd89908SRichard Henderson  fi
29405dd89908SRichard Hendersonfi
29415dd89908SRichard Henderson
29426b8cd447SRobert Hoo##########################################
29436b8cd447SRobert Hoo# avx512f optimization requirement check
29446b8cd447SRobert Hoo#
29456b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
29466b8cd447SRobert Hoo# since we won't be able to select the new routines.
29476b8cd447SRobert Hoo# by default, it is turned off.
29486b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
29496b8cd447SRobert Hoo
29506b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
29516b8cd447SRobert Hoo  cat > $TMPC << EOF
29526b8cd447SRobert Hoo#pragma GCC push_options
29536b8cd447SRobert Hoo#pragma GCC target("avx512f")
29546b8cd447SRobert Hoo#include <cpuid.h>
29556b8cd447SRobert Hoo#include <immintrin.h>
29566b8cd447SRobert Hoostatic int bar(void *a) {
29576b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
29586b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
29596b8cd447SRobert Hoo}
29606b8cd447SRobert Hooint main(int argc, char *argv[])
29616b8cd447SRobert Hoo{
29626b8cd447SRobert Hoo	return bar(argv[0]);
29636b8cd447SRobert Hoo}
29646b8cd447SRobert HooEOF
29655b945f23SRichard Henderson  if ! compile_object "-Werror" ; then
29666b8cd447SRobert Hoo    avx512f_opt="no"
29676b8cd447SRobert Hoo  fi
29686b8cd447SRobert Hooelse
29696b8cd447SRobert Hoo  avx512f_opt="no"
29706b8cd447SRobert Hoofi
29716b8cd447SRobert Hoo
2972f540166bSRichard Henderson########################################
2973f540166bSRichard Henderson# check if __[u]int128_t is usable.
2974f540166bSRichard Henderson
2975f540166bSRichard Hendersonint128=no
2976f540166bSRichard Hendersoncat > $TMPC << EOF
2977f540166bSRichard Henderson__int128_t a;
2978f540166bSRichard Henderson__uint128_t b;
2979f540166bSRichard Hendersonint main (void) {
2980f540166bSRichard Henderson  a = a + b;
2981f540166bSRichard Henderson  b = a * b;
2982464e3671SPeter Maydell  a = a * a;
2983f540166bSRichard Henderson  return 0;
2984f540166bSRichard Henderson}
2985f540166bSRichard HendersonEOF
2986f540166bSRichard Hendersonif compile_prog "" "" ; then
2987f540166bSRichard Henderson    int128=yes
2988f540166bSRichard Hendersonfi
298976a347e1SRichard Henderson
29907ebee43eSRichard Henderson#########################################
29917ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
29927ebee43eSRichard Henderson
29937ebee43eSRichard Hendersonatomic128=no
29947ebee43eSRichard Hendersonif test "$int128" = "yes"; then
29957ebee43eSRichard Henderson  cat > $TMPC << EOF
29967ebee43eSRichard Hendersonint main(void)
29977ebee43eSRichard Henderson{
29987ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
2999bceac547SThomas Huth  y = __atomic_load(&x, 0);
3000bceac547SThomas Huth  __atomic_store(&x, y, 0);
3001bceac547SThomas Huth  __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
30027ebee43eSRichard Henderson  return 0;
30037ebee43eSRichard Henderson}
30047ebee43eSRichard HendersonEOF
30057ebee43eSRichard Henderson  if compile_prog "" "" ; then
30067ebee43eSRichard Henderson    atomic128=yes
30077ebee43eSRichard Henderson  fi
30087ebee43eSRichard Hendersonfi
30097ebee43eSRichard Henderson
3010e6cd4bb5SRichard Hendersoncmpxchg128=no
3011e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
3012e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
3013e6cd4bb5SRichard Hendersonint main(void)
3014e6cd4bb5SRichard Henderson{
3015e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
3016e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
3017e6cd4bb5SRichard Henderson  return 0;
3018e6cd4bb5SRichard Henderson}
3019e6cd4bb5SRichard HendersonEOF
3020e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
3021e6cd4bb5SRichard Henderson    cmpxchg128=yes
3022e6cd4bb5SRichard Henderson  fi
3023e6cd4bb5SRichard Hendersonfi
3024e6cd4bb5SRichard Henderson
3025fd0e6053SJohn Snow########################################
3026fd0e6053SJohn Snow# check if ccache is interfering with
3027fd0e6053SJohn Snow# semantic analysis of macros
3028fd0e6053SJohn Snow
30295e4dfd3dSJohn Snowunset CCACHE_CPP2
3030fd0e6053SJohn Snowccache_cpp2=no
3031fd0e6053SJohn Snowcat > $TMPC << EOF
3032fd0e6053SJohn Snowstatic const int Z = 1;
3033fd0e6053SJohn Snow#define fn() ({ Z; })
3034fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
3035fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
3036fd0e6053SJohn Snow#define ID(X) (X)
3037fd0e6053SJohn Snowint main(int argc, char *argv[])
3038fd0e6053SJohn Snow{
3039fd0e6053SJohn Snow    int x = 0, y = 0;
3040fd0e6053SJohn Snow    x = ID(x);
3041fd0e6053SJohn Snow    x = fn();
3042fd0e6053SJohn Snow    fn();
3043fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
3044fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
3045fd0e6053SJohn Snow    return 0;
3046fd0e6053SJohn Snow}
3047fd0e6053SJohn SnowEOF
3048fd0e6053SJohn Snow
3049fd0e6053SJohn Snowif ! compile_object "-Werror"; then
3050fd0e6053SJohn Snow    ccache_cpp2=yes
3051fd0e6053SJohn Snowfi
3052fd0e6053SJohn Snow
3053b553a042SJohn Snow#################################################
3054b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
3055b553a042SJohn Snow
3056b553a042SJohn Snowif test "$fortify_source" != "no"; then
3057b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
3058b553a042SJohn Snow    fortify_source="no";
3059e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
3060cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
3061b553a042SJohn Snow    fortify_source="no";
3062b553a042SJohn Snow  else
3063b553a042SJohn Snow    fortify_source="yes"
3064b553a042SJohn Snow  fi
3065b553a042SJohn Snowfi
3066b553a042SJohn Snow
3067d2042378SAneesh Kumar K.V##########################################
3068a40161cbSPaolo Bonzini# check for usable membarrier system call
3069a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
3070a40161cbSPaolo Bonzini    have_membarrier=no
3071a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
3072a40161cbSPaolo Bonzini        have_membarrier=yes
3073a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
3074a40161cbSPaolo Bonzini        cat > $TMPC << EOF
3075a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
3076a40161cbSPaolo Bonzini    #include <sys/syscall.h>
3077a40161cbSPaolo Bonzini    #include <unistd.h>
3078a40161cbSPaolo Bonzini    #include <stdlib.h>
3079a40161cbSPaolo Bonzini    int main(void) {
3080a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
3081a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
3082a40161cbSPaolo Bonzini	exit(0);
3083a40161cbSPaolo Bonzini    }
3084a40161cbSPaolo BonziniEOF
3085a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
3086a40161cbSPaolo Bonzini            have_membarrier=yes
3087a40161cbSPaolo Bonzini        fi
3088a40161cbSPaolo Bonzini    fi
3089a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
3090a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
3091a40161cbSPaolo Bonzini    fi
3092a40161cbSPaolo Bonzinielse
3093a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
3094a40161cbSPaolo Bonzini    # work on Wine.
3095a40161cbSPaolo Bonzini    membarrier=no
3096a40161cbSPaolo Bonzinifi
3097a40161cbSPaolo Bonzini
3098a40161cbSPaolo Bonzini##########################################
3099f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
31004f67366eSThomas Huthhave_afalg=no
3101f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
3102f0d92b56SLongpeng(Mike)#include <errno.h>
3103f0d92b56SLongpeng(Mike)#include <sys/types.h>
3104f0d92b56SLongpeng(Mike)#include <sys/socket.h>
3105f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
3106f0d92b56SLongpeng(Mike)int main(void) {
3107f0d92b56SLongpeng(Mike)    int sock;
3108f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
3109f0d92b56SLongpeng(Mike)    return sock;
3110f0d92b56SLongpeng(Mike)}
3111f0d92b56SLongpeng(Mike)EOF
3112f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
3113f0d92b56SLongpeng(Mike)    have_afalg=yes
3114f0d92b56SLongpeng(Mike)fi
3115f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
3116f0d92b56SLongpeng(Mike)then
3117f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
3118f0d92b56SLongpeng(Mike)    then
3119f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
3120f0d92b56SLongpeng(Mike)    fi
3121f0d92b56SLongpeng(Mike)fi
3122f0d92b56SLongpeng(Mike)
3123f0d92b56SLongpeng(Mike)
3124db1ed1abSRichard Henderson##########################################
3125247724cbSMarc-André Lureau# checks for sanitizers
3126247724cbSMarc-André Lureau
3127247724cbSMarc-André Lureauhave_asan=no
3128247724cbSMarc-André Lureauhave_ubsan=no
3129d83414e1SMarc-André Lureauhave_asan_iface_h=no
3130d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
3131247724cbSMarc-André Lureau
3132247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
3133b9f44da2SMarc-André Lureau  write_c_skeleton
3134247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
3135247724cbSMarc-André Lureau      have_asan=yes
3136247724cbSMarc-André Lureau  fi
3137b9f44da2SMarc-André Lureau
3138b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
3139b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
3140b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
3141b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
3142b9f44da2SMarc-André Lureau#include <stdlib.h>
3143b9f44da2SMarc-André Lureauint main(void) {
3144b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
3145f2dfe54cSLeonid Bloch    if (tmp != NULL) {
3146b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
3147b9f44da2SMarc-André Lureau    }
3148d1abf3fcSOlaf Hering    return 1;
3149f2dfe54cSLeonid Bloch}
3150b9f44da2SMarc-André LureauEOF
3151247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
3152247724cbSMarc-André Lureau      have_ubsan=yes
3153247724cbSMarc-André Lureau  fi
3154d83414e1SMarc-André Lureau
3155d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
3156d83414e1SMarc-André Lureau      have_asan_iface_h=yes
3157d83414e1SMarc-André Lureau  fi
3158d83414e1SMarc-André Lureau
3159d83414e1SMarc-André Lureau  cat > $TMPC << EOF
3160d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
3161d83414e1SMarc-André Lureauint main(void) {
3162d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
3163d83414e1SMarc-André Lureau  return 0;
3164d83414e1SMarc-André Lureau}
3165d83414e1SMarc-André LureauEOF
3166d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
3167d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
3168d83414e1SMarc-André Lureau  fi
3169247724cbSMarc-André Lureaufi
3170247724cbSMarc-André Lureau
31710aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
31720aebab04SLingfeng Yang# keep it separate until that is not the case.
31730aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
31740aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
31750aebab04SLingfeng Yangfi
31760aebab04SLingfeng Yanghave_tsan=no
31770aebab04SLingfeng Yanghave_tsan_iface_fiber=no
31780aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
31790aebab04SLingfeng Yang  write_c_skeleton
31800aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
31810aebab04SLingfeng Yang      have_tsan=yes
31820aebab04SLingfeng Yang  fi
31830aebab04SLingfeng Yang  cat > $TMPC << EOF
31840aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
31850aebab04SLingfeng Yangint main(void) {
31860aebab04SLingfeng Yang  __tsan_create_fiber(0);
31870aebab04SLingfeng Yang  return 0;
31880aebab04SLingfeng Yang}
31890aebab04SLingfeng YangEOF
31900aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
31910aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
31920aebab04SLingfeng Yang  fi
31930aebab04SLingfeng Yangfi
31940aebab04SLingfeng Yang
3195adc28027SAlexander Bulekov##########################################
3196675b9b53SMarc-André Lureau# check for slirp
3197675b9b53SMarc-André Lureau
3198675b9b53SMarc-André Lureaucase "$slirp" in
31994d34a86bSPaolo Bonzini  auto | enabled | internal)
32004d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
32017c57bdd8SMarc-André Lureau    git_submodules="${git_submodules} slirp"
3202675b9b53SMarc-André Lureau    ;;
3203675b9b53SMarc-André Lureauesac
3204675b9b53SMarc-André Lureau
3205b8e0c493SJoelle van Dyne# Check for slirp smbd dupport
3206b8e0c493SJoelle van Dyne: ${smbd=${SMBD-/usr/sbin/smbd}}
3207b8e0c493SJoelle van Dyneif test "$slirp_smbd" != "no" ; then
3208b8e0c493SJoelle van Dyne  if test "$mingw32" = "yes" ; then
3209b8e0c493SJoelle van Dyne    if test "$slirp_smbd" = "yes" ; then
3210b8e0c493SJoelle van Dyne      error_exit "Host smbd not supported on this platform."
3211b8e0c493SJoelle van Dyne    fi
3212b8e0c493SJoelle van Dyne    slirp_smbd=no
3213b8e0c493SJoelle van Dyne  else
3214b8e0c493SJoelle van Dyne    slirp_smbd=yes
3215b8e0c493SJoelle van Dyne  fi
3216b8e0c493SJoelle van Dynefi
3217b8e0c493SJoelle van Dyne
321854e7aac0SAlexey Krasikov##########################################
321954e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
322054e7aac0SAlexey Krasikov
322154e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
322254e7aac0SAlexey Krasikov
322354e7aac0SAlexey Krasikov    have_keyring=no
322454e7aac0SAlexey Krasikov    cat > $TMPC << EOF
322554e7aac0SAlexey Krasikov#include <errno.h>
322654e7aac0SAlexey Krasikov#include <asm/unistd.h>
322754e7aac0SAlexey Krasikov#include <linux/keyctl.h>
322854e7aac0SAlexey Krasikov#include <unistd.h>
322954e7aac0SAlexey Krasikovint main(void) {
323054e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
323154e7aac0SAlexey Krasikov}
323254e7aac0SAlexey KrasikovEOF
323354e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
323454e7aac0SAlexey Krasikov        have_keyring=yes
323554e7aac0SAlexey Krasikov    fi
323654e7aac0SAlexey Krasikovfi
323754e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
323854e7aac0SAlexey Krasikovthen
3239b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
324054e7aac0SAlexey Krasikov    then
324154e7aac0SAlexey Krasikov	secret_keyring=yes
324254e7aac0SAlexey Krasikov    else
324354e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
324454e7aac0SAlexey Krasikov	then
324554e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
324654e7aac0SAlexey Krasikovbut not implemented on your system"
324754e7aac0SAlexey Krasikov	else
324854e7aac0SAlexey Krasikov	    secret_keyring=no
324954e7aac0SAlexey Krasikov	fi
325054e7aac0SAlexey Krasikov    fi
325154e7aac0SAlexey Krasikovfi
325254e7aac0SAlexey Krasikov
325392500362SAlexey Krasikov##########################################
3254e86ecd4bSJuan Quintela# End of CC checks
3255e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
3256e86ecd4bSJuan Quintela
3257d83414e1SMarc-André Lureauwrite_c_skeleton
3258d83414e1SMarc-André Lureau
32591d728c39SBlue Swirlif test "$gcov" = "yes" ; then
3260bf0e56a3SMarc-André Lureau  :
3261b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
3262086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
3263086d5f75SPaolo Bonzini  debug=no
3264086d5f75SPaolo Bonzinifi
3265086d5f75SPaolo Bonzini
3266086d5f75SPaolo Bonzinicase "$ARCH" in
3267086d5f75SPaolo Bonzinialpha)
3268086d5f75SPaolo Bonzini  # Ensure there's only a single GP
3269086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
3270086d5f75SPaolo Bonzini;;
3271086d5f75SPaolo Bonziniesac
3272086d5f75SPaolo Bonzini
3273086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
3274086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
3275086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
3276086d5f75SPaolo Bonzinifi
3277a316e378SJuan Quintela
3278247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
3279db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
3280db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
3281d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
3282d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
3283d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
3284d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
3285d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
3286d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
3287d83414e1SMarc-André Lureau  fi
3288247724cbSMarc-André Lureaufi
32890aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
32900aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
32910aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
32920aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
32930aebab04SLingfeng Yang  else
32940aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
32950aebab04SLingfeng Yang  fi
32960aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
32970aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
32980aebab04SLingfeng Yangfi
3299247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
3300db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
3301db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
3302247724cbSMarc-André Lureaufi
3303247724cbSMarc-André Lureau
33046542aa9cSPeter Lieven##########################################
33053efac6ebSTomáš Golembiovský
33060aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
33070aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
3308e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
3309db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
3310e86ecd4bSJuan Quintela    fi
3311e86ecd4bSJuan Quintelafi
3312e86ecd4bSJuan Quintela
3313952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
3314952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
3315cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
3316cb8baa77SMark Cave-Ayland
3317cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
3318cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
3319cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
3320cb8baa77SMark Cave-Ayland    fi
3321cb8baa77SMark Cave-Ayland
3322cb8baa77SMark Cave-Ayland    for flag in $flags; do
3323e9a3591fSChristian Borntraeger        if ld_has $flag ; then
3324db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
3325952afb71SBlue Swirl        fi
3326952afb71SBlue Swirl    done
3327952afb71SBlue Swirlfi
3328952afb71SBlue Swirl
33299d6bc27bSMichael Roth# Probe for guest agent support/options
33309d6bc27bSMichael Roth
3331e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
3332a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
3333a5125905SLaurent Vivier      guest_agent=no
3334a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
3335e8ef31a3SMichael Tokarev      guest_agent=yes
3336e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
3337e8ef31a3SMichael Tokarev      guest_agent=no
3338e8ef31a3SMichael Tokarev  else
3339e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
3340ca35f780SPaolo Bonzini  fi
33414b1c11fdSDaniel P. Berrangefi
3342ca35f780SPaolo Bonzini
3343b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
33449d6bc27bSMichael Roth
33459d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
33469d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
33479d6bc27bSMichael Rothfi
33489d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
33499d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
33509d6bc27bSMichael Rothfi
33519d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
335289138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
33539d6bc27bSMichael Rothfi
33549d6bc27bSMichael Roth
3355b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
33569d6bc27bSMichael Roth
3357ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
3358ca35f780SPaolo Bonziniroms=
3359e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
3360e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
33617000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
3362e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
3363c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
3364c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
3365c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
3366e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
3367e57218b6SPeter Maydell            ld_i386_emulation="$emu"
3368ca35f780SPaolo Bonzini            roms="optionrom"
3369e57218b6SPeter Maydell            break
3370e57218b6SPeter Maydell        fi
3371e57218b6SPeter Maydell    done
3372ca35f780SPaolo Bonzinifi
3373ca35f780SPaolo Bonzini
33742e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
3375a5b2afd5SThomas Huth# or -march=z10 (which is the lowest architecture level that Clang supports)
33769933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
33772e33c3f8SThomas Huth  write_c_skeleton
3378a5b2afd5SThomas Huth  compile_prog "-march=z900" ""
3379a5b2afd5SThomas Huth  has_z900=$?
33803af448b3SThomas Huth  if [ $has_z900 = 0 ] || compile_object "-march=z10 -msoft-float -Werror"; then
3381a5b2afd5SThomas Huth    if [ $has_z900 != 0 ]; then
3382a5b2afd5SThomas Huth      echo "WARNING: Your compiler does not support the z900!"
3383a5b2afd5SThomas Huth      echo "         The s390-ccw bios will only work with guest CPUs >= z10."
3384a5b2afd5SThomas Huth    fi
33859933c305SChristian Borntraeger    roms="$roms s390-ccw"
33861ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
33871ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
33881ef6bfc2SPhilippe Mathieu-Daudé    git_submodules="${git_submodules} roms/SLOF"
33891ef6bfc2SPhilippe Mathieu-Daudé  fi
33909933c305SChristian Borntraegerfi
33919933c305SChristian Borntraeger
339211cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
339311cde1c8SBruno 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.
339411cde1c8SBruno Dominguezif has $cxx; then
339511cde1c8SBruno Dominguez    cat > $TMPC <<EOF
339611cde1c8SBruno Dominguezint c_function(void);
339711cde1c8SBruno Dominguezint main(void) { return c_function(); }
339811cde1c8SBruno DominguezEOF
339911cde1c8SBruno Dominguez
340011cde1c8SBruno Dominguez    compile_object
340111cde1c8SBruno Dominguez
340211cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
340311cde1c8SBruno Dominguezextern "C" {
340411cde1c8SBruno Dominguez   int c_function(void);
340511cde1c8SBruno Dominguez}
340611cde1c8SBruno Dominguezint c_function(void) { return 42; }
340711cde1c8SBruno DominguezEOF
340811cde1c8SBruno Dominguez
340911cde1c8SBruno Dominguez    update_cxxflags
341011cde1c8SBruno Dominguez
3411a2866660SPaolo Bonzini    if do_cxx $CXXFLAGS $EXTRA_CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
341211cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
341311cde1c8SBruno Dominguez        :
341411cde1c8SBruno Dominguez    else
341511cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
341611cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
341711cde1c8SBruno Dominguez        cxx=
341811cde1c8SBruno Dominguez    fi
341911cde1c8SBruno Dominguezelse
342011cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
342111cde1c8SBruno Dominguez    cxx=
342211cde1c8SBruno Dominguezfi
342311cde1c8SBruno Dominguez
34247d7dbf9dSDan Streetmanif !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
34257d7dbf9dSDan Streetman    exit 1
34265d91a2edSYonggang Luofi
34275d91a2edSYonggang Luo
342898ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
342997a847bcSbellard
343098ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
343198ec69acSJuan Quintelaecho >> $config_host_mak
343298ec69acSJuan Quintela
3433e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
3434cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
3435aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
34367d7dbf9dSDan Streetmanecho "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
3437804edf29SJuan Quintela
343898ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
3439727e5283SPaolo Bonzini
3440f8393946Saurel32if test "$debug_tcg" = "yes" ; then
34412358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
3442f8393946Saurel32fi
34431625af87Saliguoriif test "$strip_opt" = "yes" ; then
344452ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
34451625af87Saliguorifi
344667b915a5Sbellardif test "$mingw32" = "yes" ; then
344798ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
3448d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
3449d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
3450f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
3451d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
3452d9840e25STomoki Sekiyama  fi
345350cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
345476dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
345550cbebb9SMichael Roth  fi
34569dacf32dSYossi Hindin  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
34579dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
34589dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
34599dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
3460210fa556Spbrookelse
346135f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
3462210fa556Spbrookfi
3463128ab2ffSblueswir1
3464dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
3465dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
3466dffcb71cSMark McLoughlinfi
3467dffcb71cSMark McLoughlin
346883fb7adfSbellardif test "$darwin" = "yes" ; then
346998ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
347083fb7adfSbellardfi
3471b29fe3edSmalc
3472ec530c81Sbellardif test "$solaris" = "yes" ; then
347398ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
3474ec530c81Sbellardfi
3475179cf400SAndreas Färberif test "$haiku" = "yes" ; then
3476179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
3477179cf400SAndreas Färberfi
347897a847bcSbellardif test "$static" = "yes" ; then
347998ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
348097a847bcSbellardfi
34811ba16968SStefan Weilif test "$profiler" = "yes" ; then
34822358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
348305c2a3e7Sbellardfi
3484c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
3485c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
3486c932ce31SPaolo Bonzinifi
3487f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
3488f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
3489f15bff25SPaolo Bonzinifi
3490b8e0c493SJoelle van Dyneif test "$slirp_smbd" = "yes" ; then
3491b8e0c493SJoelle van Dyne  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
3492e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
3493b8e0c493SJoelle van Dynefi
34944cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
34954cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
34964cc600d2SPaolo Bonzinifi
3497b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
3498b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
3499e5f05f8cSKevin Wolfif test "$block_drv_whitelist_tools" = "yes" ; then
3500e5f05f8cSKevin Wolf  echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
3501e5f05f8cSKevin Wolffi
3502dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
3503dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
3504dce512deSChristoph Hellwigfi
350589138857SStefan Weilqemu_version=$(head $source_path/VERSION)
35062358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
350798ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
35082b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
350917969268SFam Zhengif test "$modules" = "yes"; then
3510e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
3511e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
351289138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
351317969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
351417969268SFam Zhengfi
3515bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
3516bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
3517bd83c861SChristian Ehrhardtfi
3518955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
3519955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
3520955727d2SCortland Tölvafi
3521f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
3522f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
3523f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
3524f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
35255ecfb76cSPaolo Bonzinifi
35265ecfb76cSPaolo Bonziniif test "$gdbus_codegen" != "" ; then
352725a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
3528f876b765SMarc-André Lureaufi
3529a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
3530277abf15SJan Vesely
35311badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
35326dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
3533d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
3534582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
3535582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
3536e37630caSaliguorifi
35375e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
35385e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
35395e9be92dSNicholas Bellingerfi
3540af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
3541af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
3542af3bba76SPaolo Bonzinifi
3543af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
354456f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
354503ce5744SNikolay Nikolaevfi
3546108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
3547108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
3548108a6481SCindy Lufi
3549042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
3550042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
3551042cea27SGongleifi
3552fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
3553fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
35545fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
35555fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
35565fe97d88SStefano Garzarella  fi
3557fc0b9b0eSStefan Hajnoczifi
3558299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
3559299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
3560299e6f19SPaolo Bonzinifi
3561e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
3562e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
3563e6a74868SMarc-André Lureaufi
3564108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
3565108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
3566108a6481SCindy Lufi
356798fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
356898fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
356998fc1adaSDr. David Alan Gilbertfi
3570a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
3571a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
3572a40161cbSPaolo Bonzinifi
3573e5b46549SRichard Hendersonif test "$tcg" = "enabled" -a "$tcg_interpreter" = "true" ; then
3574e5b46549SRichard Henderson  echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
3575e5b46549SRichard Hendersonfi
357658d3f3ffSGerd Hoffmann
3577da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
3578da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
3579de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
3580da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
358120ff075bSMichael Wallefi
358220ff075bSMichael Walle
358399f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
358499f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
358599f2dbd3SLiang Lifi
358699f2dbd3SLiang Li
35876b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
35886b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
35896b8cd447SRobert Hoofi
35906b8cd447SRobert Hoo
359183fb7adfSbellard# XXX: suppress that
35927d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
35932358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
35947d3505c5Sbellardfi
35957d3505c5Sbellard
35963556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
35973556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
35983556c233SPaolo Bonzinifi
359920ff6c80SAnthony Liguori
36007c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
360170c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
360270c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
360370c60c08SStefan Hajnoczielse
360470c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
360570c60c08SStefan Hajnoczifi
3606d0e2fce5SAneesh Kumar K.V
36077d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
36087d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
36097d992e4dSPeter Lievenfi
36107d992e4dSPeter Lieven
3611f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
3612f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
3613f0d92b56SLongpeng(Mike)fi
3614f0d92b56SLongpeng(Mike)
3615d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
3616d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
3617d83414e1SMarc-André Lureaufi
3618d83414e1SMarc-André Lureau
36190aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
36200aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
36210aebab04SLingfeng Yangfi
36220aebab04SLingfeng Yang
362376a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
362476a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
362576a347e1SRichard Hendersonfi
362676a347e1SRichard Henderson
3627f540166bSRichard Hendersonif test "$int128" = "yes" ; then
3628f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
3629f540166bSRichard Hendersonfi
3630f540166bSRichard Henderson
36317ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
36327ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
36337ebee43eSRichard Hendersonfi
36347ebee43eSRichard Henderson
3635e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
3636e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
3637e6cd4bb5SRichard Hendersonfi
3638e6cd4bb5SRichard Henderson
3639b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
3640484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
3641b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
3642b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
36430a12ec87SRichard W.M. Jonesfi
36440a12ec87SRichard W.M. Jones
3645ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
3646ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
3647ed1701c6SDr. David Alan Gilbertfi
3648ed1701c6SDr. David Alan Gilbert
36493b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
36503cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
36513b8acc11SPaolo Bonzinifi
36523b8acc11SPaolo Bonzini
36532da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
36542da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
3655392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
36562da776dbSMichael R. Hinesfi
36572da776dbSMichael R. Hines
365821ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
365921ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
366021ab34c9SMarcel Apfelbaumfi
366121ab34c9SMarcel Apfelbaum
3662a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
3663a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
3664a6b1d4c0SChanglong Xiefi
3665a6b1d4c0SChanglong Xie
3666ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
3667ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
3668ba59fb77SPaolo Bonzinifi
3669e0580342SKamil Rytarowski
36702f740136SJeff Codyif test "$bochs" = "yes" ; then
36712f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
36722f740136SJeff Codyfi
36732f740136SJeff Codyif test "$cloop" = "yes" ; then
36742f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
36752f740136SJeff Codyfi
36762f740136SJeff Codyif test "$dmg" = "yes" ; then
36772f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
36782f740136SJeff Codyfi
36792f740136SJeff Codyif test "$qcow1" = "yes" ; then
36802f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
36812f740136SJeff Codyfi
36822f740136SJeff Codyif test "$vdi" = "yes" ; then
36832f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
36842f740136SJeff Codyfi
36852f740136SJeff Codyif test "$vvfat" = "yes" ; then
36862f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
36872f740136SJeff Codyfi
36882f740136SJeff Codyif test "$qed" = "yes" ; then
36892f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
36902f740136SJeff Codyfi
36912f740136SJeff Codyif test "$parallels" = "yes" ; then
36922f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
36932f740136SJeff Codyfi
36942f740136SJeff Cody
369540e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
369640e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
369726fffe29SEmilio G. Cota    # Copy the export object list to the build dir
369826fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
369926fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
370026fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
370126fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
370226fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
370326fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
370426fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
370526fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
370626fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
370726fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
370826fffe29SEmilio G. Cota    else
370926fffe29SEmilio G. Cota	error_exit \
371026fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
371126fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
371226fffe29SEmilio G. Cota    fi
371340e8c6f4SAlex Bennéefi
371440e8c6f4SAlex Bennée
3715f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
3716b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
3717d6a66c81SAlex Bennée    if version_ge ${gdb_version##* } 9.1; then
3718f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
3719f48e590aSAlex Bennée    fi
3720b1863cccSAlex Bennéefi
3721f48e590aSAlex Bennée
372254e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
372354e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
372454e7aac0SAlexey Krasikovfi
372554e7aac0SAlexey Krasikov
372698ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
3727804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
3728c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
372939d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
3730a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
373109e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
3732804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
3733433de74cSBastian Koppelmannecho "HOST_CC=$host_cc" >> $config_host_mak
3734a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
3735859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
3736a31a8642SMichael S. Tsirkinfi
3737804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
3738cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
37395f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
37403dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
3741804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
3742804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
374346eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
3744a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
374511cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
3746a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
3747a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
37488a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
3749e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
3750804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
3751f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
3752804edf29SJuan Quintela
3753b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
3754b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
3755b767d257SMarek Marczykowski-Góreckifi
3756b767d257SMarek Marczykowski-Górecki
37576efd7517SPeter Maydell# use included Linux headers
37586efd7517SPeter Maydellif test "$linux" = "yes" ; then
3759a307beb6SAndreas Färber  mkdir -p linux-headers
37606efd7517SPeter Maydell  case "$cpu" in
3761c72b26ecSRichard Henderson  i386|x86_64|x32)
376208312a63SPeter Maydell    linux_arch=x86
37636efd7517SPeter Maydell    ;;
3764f8378accSRichard Henderson  ppc|ppc64|ppc64le)
376508312a63SPeter Maydell    linux_arch=powerpc
37666efd7517SPeter Maydell    ;;
37676efd7517SPeter Maydell  s390x)
376808312a63SPeter Maydell    linux_arch=s390
376908312a63SPeter Maydell    ;;
37701f080313SClaudio Fontana  aarch64)
37711f080313SClaudio Fontana    linux_arch=arm64
37721f080313SClaudio Fontana    ;;
3773222e7d11SSanjay Lal  mips64)
3774222e7d11SSanjay Lal    linux_arch=mips
3775222e7d11SSanjay Lal    ;;
377608312a63SPeter Maydell  *)
377708312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
377808312a63SPeter Maydell    linux_arch="$cpu"
37796efd7517SPeter Maydell    ;;
37806efd7517SPeter Maydell  esac
378108312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
378208312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
378308312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
378408312a63SPeter Maydell    fi
37856efd7517SPeter Maydellfi
37866efd7517SPeter Maydell
378797a847bcSbellardfor target in $target_list; do
378897a847bcSbellard    target_dir="$target"
378989138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
379097a847bcSbellard    mkdir -p $target_dir
3791fdb75aefSPaolo Bonzini    case $target in
3792fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
3793fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
37942408a527Saurel32    esac
379556aebc89Spbrookdone
37967d13299dSbellard
3797765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
3798fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
3799fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
3800fdb75aefSPaolo Bonzinifi
3801a540f158SPeter Crosthwaite
3802a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
3803a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
3804ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
3805a99d57bbSWanlong Gaofi
3806a99d57bbSWanlong Gao
3807fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
3808fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
3809fd0e6053SJohn Snowfi
3810fd0e6053SJohn Snow
38111e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
38121e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
38131e4f6065SDaniele Buonofi
38141e4f6065SDaniele Buono
3815e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
3816e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
3817e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
3818e29e5c6eSPeter Maydell# (these can be both files and directories).
3819e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
3820e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
3821e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
3822e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
3823e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
3824e29e5c6eSPeter Maydell# directory and symlink the directory instead.
382509db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
382609db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
382709db9b9dSGerd Hoffmann# a "make distclean" in between.
38289d49bcf6SMarkus ArmbrusterDIRS="tests tests/tcg tests/qapi-schema tests/qtest/libqos"
38291cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
3830b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
3831744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
38328db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
3833c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
38342038f8c8SPaolo BonziniLINKS="Makefile"
38353941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
3836ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
3837e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
38388db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
3839e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
3840e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
384139950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
384239950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
38438f8fd9edSCleber RosaLINKS="$LINKS python"
3844c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
384509db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
3846753d11f2SRichard Hendersonfor bios_file in \
3847753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
38483a631b8eSBin Meng    $source_path/pc-bios/*.elf \
3849225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
3850753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
3851753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
3852e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
3853753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
38544e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
385526ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
3856cd946e5cSJohn Arbuckle    $source_path/pc-bios/palcode-* \
3857cd946e5cSJohn Arbuckle    $source_path/pc-bios/qemu_vga.ndrv
3858cd946e5cSJohn Arbuckle
3859753d11f2SRichard Hendersondo
3860e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
38617ea78b74SJan Kiszkadone
3862d1807a4fSPaolo Bonzinimkdir -p $DIRS
3863e29e5c6eSPeter Maydellfor f in $LINKS ; do
38640f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
3865f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
3866f9245e10SPeter Maydell    fi
38677d13299dSbellarddone
386809db9b9dSGerd Hoffmannfor f in $UNLINK ; do
386909db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
387009db9b9dSGerd Hoffmann        rm -f "$f"
387109db9b9dSGerd Hoffmann    fi
387209db9b9dSGerd Hoffmanndone
38731ad2134fSPaul Brook
38742038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
38752038f8c8SPaolo Bonzini  export $i
38762038f8c8SPaolo Bonzinidone
3877de6d7e6bSAlex Bennéeexport target_list source_path use_containers ARCH
38782038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
38792038f8c8SPaolo Bonzini
3880c34ebfdcSAnthony Liguori# temporary config to build submodules
38818db2a4fdSGerd Hoffmannfor rom in seabios; do
3882c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
388337116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
3884c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
3885cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
38865f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
3887c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
3888c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
38893dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
3890c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
3891a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
3892c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
38939f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
3894c34ebfdcSAnthony Liguoridone
3895c34ebfdcSAnthony Liguori
389698409991SHelge Konetzkaconfig_mak=pc-bios/optionrom/config.mak
389798409991SHelge Konetzkaecho "# Automatically generated by configure - do not modify" > $config_mak
389898409991SHelge Konetzkaecho "TOPSRC_DIR=$source_path" >> $config_mak
389998409991SHelge Konetzka
3900a5665051SPaolo Bonziniif test "$skip_meson" = no; then
3901fc929892SMarc-André Lureau  cross="config-meson.cross.new"
3902fc929892SMarc-André Lureau  meson_quote() {
3903ac7ebcc5SPaolo Bonzini    test $# = 0 && return
390447b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
3905fc929892SMarc-André Lureau  }
3906fc929892SMarc-André Lureau
3907fc929892SMarc-André Lureau  echo "# Automatically generated by configure - do not modify" > $cross
3908fc929892SMarc-André Lureau  echo "[properties]" >> $cross
3909d1d5e9eeSAlex Bennée
3910d1d5e9eeSAlex Bennée  # unroll any custom device configs
3911d1d5e9eeSAlex Bennée  for a in $device_archs; do
3912d1d5e9eeSAlex Bennée      eval "c=\$devices_${a}"
3913d1d5e9eeSAlex Bennée      echo "${a}-softmmu = '$c'" >> $cross
3914d1d5e9eeSAlex Bennée  done
3915d1d5e9eeSAlex Bennée
3916fc929892SMarc-André Lureau  test -z "$cxx" && echo "link_language = 'c'" >> $cross
391747b30835SPaolo Bonzini  echo "[built-in options]" >> $cross
3918a2866660SPaolo Bonzini  echo "c_args = [$(meson_quote $CFLAGS $EXTRA_CFLAGS)]" >> $cross
3919a2866660SPaolo Bonzini  echo "cpp_args = [$(meson_quote $CXXFLAGS $EXTRA_CXXFLAGS)]" >> $cross
3920a2866660SPaolo Bonzini  echo "c_link_args = [$(meson_quote $CFLAGS $LDFLAGS $EXTRA_CFLAGS $EXTRA_LDFLAGS)]" >> $cross
3921a2866660SPaolo Bonzini  echo "cpp_link_args = [$(meson_quote $CXXFLAGS $LDFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS)]" >> $cross
3922fc929892SMarc-André Lureau  echo "[binaries]" >> $cross
39234dba2789SPaolo Bonzini  echo "c = [$(meson_quote $cc $CPU_CFLAGS)]" >> $cross
39244dba2789SPaolo Bonzini  test -n "$cxx" && echo "cpp = [$(meson_quote $cxx $CPU_CFLAGS)]" >> $cross
39254dba2789SPaolo Bonzini  test -n "$objcc" && echo "objc = [$(meson_quote $objcc $CPU_CFLAGS)]" >> $cross
392647b30835SPaolo Bonzini  echo "ar = [$(meson_quote $ar)]" >> $cross
392747b30835SPaolo Bonzini  echo "nm = [$(meson_quote $nm)]" >> $cross
392847b30835SPaolo Bonzini  echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
392947b30835SPaolo Bonzini  echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
3930e8178514SPaolo Bonzini  if has $sdl2_config; then
393147b30835SPaolo Bonzini    echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
3932e8178514SPaolo Bonzini  fi
393347b30835SPaolo Bonzini  echo "strip = [$(meson_quote $strip)]" >> $cross
393447b30835SPaolo Bonzini  echo "windres = [$(meson_quote $windres)]" >> $cross
39353812c0c4SJoelle van Dyne  if test "$cross_compile" = "yes"; then
3936fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
3937fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
3938fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
3939fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
3940fc929892SMarc-André Lureau    fi
3941853b4bafSThomas Huth    if test "$linux" = "yes" ; then
3942853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
3943853b4bafSThomas Huth    fi
39440ca321eaSJoelle van Dyne    if test "$darwin" = "yes" ; then
39450ca321eaSJoelle van Dyne        echo "system = 'darwin'" >> $cross
39460ca321eaSJoelle van Dyne    fi
3947fc929892SMarc-André Lureau    case "$ARCH" in
3948f6bca9dfSJoelle van Dyne        i386)
3949fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
3950fc929892SMarc-André Lureau            ;;
3951f8bb7e1cSDavid Michael        x86_64|x32)
3952f6bca9dfSJoelle van Dyne            echo "cpu_family = 'x86_64'" >> $cross
3953f6bca9dfSJoelle van Dyne            ;;
3954fc929892SMarc-André Lureau        ppc64le)
3955fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
3956fc929892SMarc-André Lureau            ;;
3957fc929892SMarc-André Lureau        *)
3958fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
3959fc929892SMarc-André Lureau            ;;
3960fc929892SMarc-André Lureau    esac
3961fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
3962fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
3963fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
3964fc929892SMarc-André Lureau    else
3965fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
3966fc929892SMarc-André Lureau    fi
3967fc929892SMarc-André Lureau  else
3968fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
3969fc929892SMarc-André Lureau  fi
3970fc929892SMarc-André Lureau  mv $cross config-meson.cross
3971fc929892SMarc-André Lureau
3972a5665051SPaolo Bonzini  rm -rf meson-private meson-info meson-logs
397361d63097SPaolo Bonzini  run_meson() {
397409e93326SPaolo Bonzini    NINJA=$ninja $meson setup \
3975d17f305aSPaolo Bonzini        --prefix "$prefix" \
3976d17f305aSPaolo Bonzini        --libdir "$libdir" \
3977d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
3978d17f305aSPaolo Bonzini        --bindir "$bindir" \
3979d17f305aSPaolo Bonzini        --includedir "$includedir" \
3980d17f305aSPaolo Bonzini        --datadir "$datadir" \
3981d17f305aSPaolo Bonzini        --mandir "$mandir" \
3982d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
398316bf7a33SPaolo Bonzini        --localedir "$localedir" \
3984d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
39853b4da132SPaolo Bonzini        -Daudio_drv_list=$audio_drv_list \
39863b4da132SPaolo Bonzini        -Ddefault_devices=$default_devices \
3987d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
398816bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
398973f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
39903b4da132SPaolo Bonzini        -Dsphinx_build="$sphinx_build" \
39913b4da132SPaolo Bonzini        -Dtrace_file="$trace_file" \
3992a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
3993a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
3994a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
3995a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
3996da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
3997bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
39983b4da132SPaolo Bonzini        -Db_lto=$lto -Dcfi=$cfi -Dtcg=$tcg -Dxen=$xen \
39993b4da132SPaolo Bonzini        -Dcapstone=$capstone -Dfdt=$fdt -Dslirp=$slirp \
4000537b7248SPaolo Bonzini        $(test -n "${LIB_FUZZING_ENGINE+xxx}" && echo "-Dfuzzing_engine=$LIB_FUZZING_ENGINE") \
4001332008e0SThomas Huth        $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
400261d63097SPaolo Bonzini        "$@" $cross_arg "$PWD" "$source_path"
400361d63097SPaolo Bonzini  }
400461d63097SPaolo Bonzini  eval run_meson $meson_options
4005a5665051SPaolo Bonzini  if test "$?" -ne 0 ; then
4006a5665051SPaolo Bonzini      error_exit "meson setup failed"
4007a5665051SPaolo Bonzini  fi
4008699d3884SPaolo Bonzinielse
4009699d3884SPaolo Bonzini  if test -f meson-private/cmd_line.txt; then
4010699d3884SPaolo Bonzini    # Adjust old command line options whose type was changed
4011699d3884SPaolo Bonzini    # Avoids having to use "setup --wipe" when Meson is upgraded
4012699d3884SPaolo Bonzini    perl -i -ne '
4013699d3884SPaolo Bonzini      s/^gettext = true$/gettext = auto/;
4014699d3884SPaolo Bonzini      s/^gettext = false$/gettext = disabled/;
4015654d6b04SPaolo Bonzini      /^b_staticpic/ && next;
4016699d3884SPaolo Bonzini      print;' meson-private/cmd_line.txt
4017699d3884SPaolo Bonzini  fi
4018a5665051SPaolo Bonzinifi
4019a5665051SPaolo Bonzini
40202d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
40212d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
4022a476b216SMao Zhongyi    echo "Please see docs/about/deprecated.rst"
40232d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
40242d838d9bSAlex Bennéefi
40252d838d9bSAlex Bennée
4026e0447a83SThomas Huth# Create list of config switches that should be poisoned in common code...
4027e0447a83SThomas Huth# but filter out CONFIG_TCG and CONFIG_USER_ONLY which are special.
402854b0306eSThomas Huthtarget_configs_h=$(ls *-config-devices.h *-config-target.h 2>/dev/null)
402954b0306eSThomas Huthif test -n "$target_configs_h" ; then
4030e0447a83SThomas Huth    sed -n -e '/CONFIG_TCG/d' -e '/CONFIG_USER_ONLY/d' \
4031e0447a83SThomas Huth        -e '/^#define / { s///; s/ .*//; s/^/#pragma GCC poison /p; }' \
403254b0306eSThomas Huth        $target_configs_h | sort -u > config-poison.h
403354b0306eSThomas Huthelse
403454b0306eSThomas Huth    :> config-poison.h
403554b0306eSThomas Huthfi
4036e0447a83SThomas Huth
4037dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
4038dc655404SMichael S. Tsirkincat <<EOD >config.status
4039dc655404SMichael S. Tsirkin#!/bin/sh
4040dc655404SMichael S. Tsirkin# Generated by configure.
4041dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
4042dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
4043dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
4044dc655404SMichael S. TsirkinEOD
4045e811da7fSDaniel P. Berrangé
4046e811da7fSDaniel P. Berrangépreserve_env() {
4047e811da7fSDaniel P. Berrangé    envname=$1
4048e811da7fSDaniel P. Berrangé
4049e811da7fSDaniel P. Berrangé    eval envval=\$$envname
4050e811da7fSDaniel P. Berrangé
4051e811da7fSDaniel P. Berrangé    if test -n "$envval"
4052e811da7fSDaniel P. Berrangé    then
4053e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
4054e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
4055e811da7fSDaniel P. Berrangé    else
4056e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
4057e811da7fSDaniel P. Berrangé    fi
4058e811da7fSDaniel P. Berrangé}
4059e811da7fSDaniel P. Berrangé
4060e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
4061e811da7fSDaniel P. Berrangé# features/build target configure will detect
4062e811da7fSDaniel P. Berrangépreserve_env AR
4063e811da7fSDaniel P. Berrangépreserve_env AS
4064e811da7fSDaniel P. Berrangépreserve_env CC
4065e811da7fSDaniel P. Berrangépreserve_env CPP
40668009da03SPaolo Bonzinipreserve_env CFLAGS
4067e811da7fSDaniel P. Berrangépreserve_env CXX
40688009da03SPaolo Bonzinipreserve_env CXXFLAGS
4069e811da7fSDaniel P. Berrangépreserve_env INSTALL
4070e811da7fSDaniel P. Berrangépreserve_env LD
40718009da03SPaolo Bonzinipreserve_env LDFLAGS
4072e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
4073e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
4074e811da7fSDaniel P. Berrangépreserve_env MAKE
4075e811da7fSDaniel P. Berrangépreserve_env NM
4076e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
4077e811da7fSDaniel P. Berrangépreserve_env PATH
4078e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
4079e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
4080e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
4081e811da7fSDaniel P. Berrangépreserve_env PYTHON
4082e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
4083e811da7fSDaniel P. Berrangépreserve_env SMBD
4084e811da7fSDaniel P. Berrangépreserve_env STRIP
4085e811da7fSDaniel P. Berrangépreserve_env WINDRES
4086e811da7fSDaniel P. Berrangé
4087dc655404SMichael S. Tsirkinprintf "exec" >>config.status
4088a5665051SPaolo Bonzinifor i in "$0" "$@"; do
4089835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
4090a5665051SPaolo Bonzinidone
4091cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
4092dc655404SMichael S. Tsirkinchmod +x config.status
4093dc655404SMichael S. Tsirkin
40948cd05ab6SPeter Maydellrm -r "$TMPDIR1"
4095