xref: /openbmc/qemu/configure (revision 3812c0c4cbaf4b7b1be959ec6ca3303cdf92ca46)
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.
1149c83ffd8SPeter Maydell    local 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() {
1459c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
1489c83ffd8SPeter Maydelldo_cxx() {
1499c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
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.
16153422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
1625770e8afSPaolo Bonzini    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu99/-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"
1775770e8afSPaolo Bonzini  do_cc $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"
1835770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
1845770e8afSPaolo Bonzini      $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 () {
2010a01d76fSMarc-André Lureau    local_ver1=`echo $1 | tr . ' '`
2020a01d76fSMarc-André Lureau    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
2195b808275SLluís Vilanovahave_backend () {
2205b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2215b808275SLluís Vilanova}
2225b808275SLluís Vilanova
2233b6b7550SPaolo Bonziniglob() {
2243b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2253b6b7550SPaolo Bonzini}
2263b6b7550SPaolo Bonzini
227e9a3591fSChristian Borntraegerld_has() {
228e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
229e9a3591fSChristian Borntraeger}
230e9a3591fSChristian Borntraeger
2314ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2324ace32e2SAntonio Ospitethen
2334ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2344ace32e2SAntonio Ospitefi
2354ace32e2SAntonio Ospite
23614211825SAntonio Ospite# default parameters
2372ff6b91eSJuan Quintelacpu=""
238a31a8642SMichael S. Tsirkiniasl="iasl"
2391e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
24043ce4dfeSbellardstatic="no"
241*3812c0c4SJoelle van Dynecross_compile="no"
2427d13299dSbellardcross_prefix=""
2430c58ac1cSmalcaudio_drv_list=""
244b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
245b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
246e49d021eSPeter Maydellhost_cc="cc"
247d5631638Smalcaudio_win_int=""
248957f1f99SMichael Rothlibs_qga=""
2495bc62e01SGerd Hoffmanndebug_info="yes"
250cdad781dSDaniele Buonolto="false"
25163678e17SSteven Noonanstack_protector=""
2521e4f6065SDaniele Buonosafe_stack=""
253afc3a8f9SAlex Bennéeuse_containers="yes"
254f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
255ac0df51dSaliguori
25692712822SDaniel P. Berrangeif test -e "$source_path/.git"
25792712822SDaniel P. Berrangethen
258f62bbee5SDaniel P. Berrange    git_update=yes
25992712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
2603ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
2613ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
26292712822SDaniel P. Berrangeelse
263f62bbee5SDaniel P. Berrange    git_update=no
264aef45d51SDaniel P. Berrange    git_submodules=""
2655c0ef67aSDaniel P. Berrangé
2665c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
2675c0ef67aSDaniel P. Berrangé    then
2685c0ef67aSDaniel P. Berrangé        echo
2695c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
2705c0ef67aSDaniel P. Berrangé        echo
2715c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
2725c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
2735c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
2745c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
2755c0ef67aSDaniel P. Berrangé        echo
276a3e3b521SPeter Maydell        echo "  https://www.qemu.org/download/#source"
2775c0ef67aSDaniel P. Berrangé        echo
2785c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
2795c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
2805c0ef67aSDaniel P. Berrangé        echo
2815c0ef67aSDaniel P. Berrangé        exit 1
2825c0ef67aSDaniel P. Berrangé    fi
28392712822SDaniel P. Berrangefi
284cc84d63aSDaniel P. Berrangegit="git"
285ac0df51dSaliguori
286afb63ebdSStefan Weil# Don't accept a target_list environment variable.
287afb63ebdSStefan Weilunset target_list
288447e133fSAlex Bennéeunset target_list_exclude
289377529c0SPaolo Bonzini
290377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
291377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
292377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
293377529c0SPaolo Bonzini#              unless --disable-foo is given
294377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
295377529c0SPaolo Bonzini#              feature will searched for,
296377529c0SPaolo Bonzini#              if not found, configure exits with error
297377529c0SPaolo Bonzini#
298377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
299377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
300377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
301377529c0SPaolo Bonzini
302c87ea116SAlex Bennéedefault_feature=""
303c87ea116SAlex Bennée# parse CC options second
304c87ea116SAlex Bennéefor opt do
305c87ea116SAlex Bennée  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
306c87ea116SAlex Bennée  case "$opt" in
307c87ea116SAlex Bennée      --without-default-features)
308c87ea116SAlex Bennée          default_feature="no"
309c87ea116SAlex Bennée  ;;
310c87ea116SAlex Bennée  esac
311c87ea116SAlex Bennéedone
312c87ea116SAlex Bennée
3138c6d4ff4SPaolo Bonzinibrlapi="auto"
314f9cd86feSPaolo Bonzinicurl="auto"
3155285e593SYonggang Luoiconv="auto"
3165285e593SYonggang Luocurses="auto"
317e3667660SYonggang Luodocs="auto"
318fbb4121dSPaolo Bonzinifdt="auto"
31958952137SVincenzo Maffionenetmap="no"
32035be72baSPaolo Bonzinisdl="auto"
32135be72baSPaolo Bonzinisdl_image="auto"
322cece116cSMisono Tomohirovirtiofsd="auto"
32369202b40SPaolo Bonzinivirtfs="auto"
3245c53015aSPaolo Bonzinilibudev="auto"
3256ec0e15dSPaolo Bonzinimpath="auto"
326a0b93237SPaolo Bonzinivnc="enabled"
327deb62371SPaolo Bonzinisparse="auto"
328c87ea116SAlex Bennéevde="$default_feature"
329a0b93237SPaolo Bonzinivnc_sasl="auto"
330a0b93237SPaolo Bonzinivnc_jpeg="auto"
331a0b93237SPaolo Bonzinivnc_png="auto"
3324113f4cfSLaurent Vivierxkbcommon="auto"
333c87ea116SAlex Bennéexen="$default_feature"
334c87ea116SAlex Bennéexen_ctrl_version="$default_feature"
3351badb709SPaolo Bonzinixen_pci_passthrough="auto"
336c87ea116SAlex Bennéelinux_aio="$default_feature"
337c87ea116SAlex Bennéelinux_io_uring="$default_feature"
338727c8bb8SPaolo Bonzinicap_ng="auto"
339f7f2d651SPaolo Bonziniattr="auto"
340c87ea116SAlex Bennéexfs="$default_feature"
3411badb709SPaolo Bonzinitcg="enabled"
342c87ea116SAlex Bennéemembarrier="$default_feature"
343c87ea116SAlex Bennéevhost_net="$default_feature"
344c87ea116SAlex Bennéevhost_crypto="$default_feature"
345c87ea116SAlex Bennéevhost_scsi="$default_feature"
346c87ea116SAlex Bennéevhost_vsock="$default_feature"
347d88618f7SStefan Hajnoczivhost_user="no"
348e5e856c1SStefan Hajnoczivhost_user_blk_server="auto"
349c87ea116SAlex Bennéevhost_user_fs="$default_feature"
3503bd40ec7SPaolo Bonzinikvm="auto"
3513bd40ec7SPaolo Bonzinihax="auto"
3523bd40ec7SPaolo Bonzinihvf="auto"
3533bd40ec7SPaolo Bonziniwhpx="auto"
354c87ea116SAlex Bennéerdma="$default_feature"
355c87ea116SAlex Bennéepvrdma="$default_feature"
356377529c0SPaolo Bonzinigprof="no"
357377529c0SPaolo Bonzinidebug_tcg="no"
358377529c0SPaolo Bonzinidebug="no"
359247724cbSMarc-André Lureausanitizers="no"
3600aebab04SLingfeng Yangtsan="no"
361c87ea116SAlex Bennéefortify_source="$default_feature"
362377529c0SPaolo Bonzinistrip_opt="yes"
36323a77b2dSPaolo Bonzinitcg_interpreter="false"
364377529c0SPaolo Bonzinibigendian="no"
365377529c0SPaolo Bonzinimingw32="no"
3661d728c39SBlue Swirlgcov="no"
367c87ea116SAlex BennéeEXESUF="$default_feature"
368484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
36917969268SFam Zhengmodules="no"
370bd83c861SChristian Ehrhardtmodule_upgrades="no"
371377529c0SPaolo Bonziniprefix="/usr/local"
37210ff82d1SMarc-André Lureauqemu_suffix="qemu"
3734d34a86bSPaolo Bonzinislirp="auto"
374377529c0SPaolo Bonzinioss_lib=""
375377529c0SPaolo Bonzinibsd="no"
376377529c0SPaolo Bonzinilinux="no"
377377529c0SPaolo Bonzinisolaris="no"
378377529c0SPaolo Bonziniprofiler="no"
379b4e312e9SPaolo Bonzinicocoa="auto"
380377529c0SPaolo Bonzinisoftmmu="yes"
381377529c0SPaolo Bonzinilinux_user="no"
382377529c0SPaolo Bonzinibsd_user="no"
383c8d5450bSPaolo Bonziniblobs="true"
384377529c0SPaolo Bonzinipkgversion=""
38540d6444eSAvi Kivitypie=""
3863556c233SPaolo Bonziniqom_cast_debug="yes"
387baf86d6bSPaolo Bonzinitrace_backends="log"
388377529c0SPaolo Bonzinitrace_file="trace"
389c87ea116SAlex Bennéespice="$default_feature"
390fabd1e93SPaolo Bonzinirbd="auto"
391c87ea116SAlex Bennéesmartcard="$default_feature"
3920a40bcb7SCésar Belleyu2f="auto"
393c87ea116SAlex Bennéelibusb="$default_feature"
394c87ea116SAlex Bennéeusb_redir="$default_feature"
395c87ea116SAlex Bennéeopengl="$default_feature"
396014cb152SGerd Hoffmannopengl_dmabuf="no"
3975dd89908SRichard Hendersoncpuid_h="no"
398c87ea116SAlex Bennéeavx2_opt="$default_feature"
3998b18cdbfSRichard Hendersoncapstone="auto"
4000c32a0aeSPaolo Bonzinilzo="auto"
401241611eaSPaolo Bonzinisnappy="auto"
40229ba6116SPaolo Bonzinibzip2="auto"
403ecea3696SPaolo Bonzinilzfse="auto"
404b1def33dSPaolo Bonzinizstd="auto"
405c87ea116SAlex Bennéeguest_agent="$default_feature"
406d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
40750cbebb9SMichael Rothguest_agent_ntddscsi="no"
408b846ab7cSPaolo Bonziniguest_agent_msi="auto"
409c87ea116SAlex Bennéevss_win32_sdk="$default_feature"
410d9840e25STomoki Sekiyamawin_sdk="no"
411c87ea116SAlex Bennéewant_tools="$default_feature"
4129db405a3SPaolo Bonzinilibiscsi="auto"
41330045c05SPaolo Bonzinilibnfs="auto"
414519175a2SAlex Barcelocoroutine=""
415c87ea116SAlex Bennéecoroutine_pool="$default_feature"
4167d992e4dSPeter Lievendebug_stack_usage="no"
417f0d92b56SLongpeng(Mike)crypto_afalg="no"
4189e62ba48SDaniele Buonocfi="false"
4199e62ba48SDaniele Buonocfi_debug="false"
42090835c2bSPaolo Bonziniseccomp="auto"
42108821ca2SPaolo Bonziniglusterfs="auto"
4221b695471SPaolo Bonzinigtk="auto"
423a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
424c87ea116SAlex Bennéegnutls="$default_feature"
425c87ea116SAlex Bennéenettle="$default_feature"
426dc2207afSDaniel P. Berrangénettle_xts="no"
427c87ea116SAlex Bennéegcrypt="$default_feature"
4281f923c70SLongpeng(Mike)gcrypt_hmac="no"
429e0576942SDaniel P. Berrangégcrypt_xts="no"
430e0576942SDaniel P. Berrangéqemu_private_xts="yes"
431c87ea116SAlex Bennéeauth_pam="$default_feature"
432c87ea116SAlex Bennéevte="$default_feature"
433c87ea116SAlex Bennéevirglrenderer="$default_feature"
434c87ea116SAlex Bennéetpm="$default_feature"
435c87ea116SAlex Bennéelibssh="$default_feature"
436c87ea116SAlex Bennéelive_block_migration=${default_feature:-yes}
437c87ea116SAlex Bennéenuma="$default_feature"
4382847b469SFam Zhengtcmalloc="no"
4397b01cb97SAlexandre Derumierjemalloc="no"
440c87ea116SAlex Bennéereplication=${default_feature:-yes}
441c87ea116SAlex Bennéebochs=${default_feature:-yes}
442c87ea116SAlex Bennéecloop=${default_feature:-yes}
443c87ea116SAlex Bennéedmg=${default_feature:-yes}
444c87ea116SAlex Bennéeqcow1=${default_feature:-yes}
445c87ea116SAlex Bennéevdi=${default_feature:-yes}
446c87ea116SAlex Bennéevvfat=${default_feature:-yes}
447c87ea116SAlex Bennéeqed=${default_feature:-yes}
448c87ea116SAlex Bennéeparallels=${default_feature:-yes}
449e1c42697SDaniel P. Berrangésheepdog="no"
450c87ea116SAlex Bennéelibxml2="$default_feature"
451ba59fb77SPaolo Bonzinidebug_mutex="no"
452c87ea116SAlex Bennéelibpmem="$default_feature"
4537bc3ca7fSPaolo Bonzinidefault_devices="true"
45440e8c6f4SAlex Bennéeplugins="no"
455adc28027SAlexander Bulekovfuzzing="no"
456b767d257SMarek Marczykowski-Góreckirng_none="no"
457c87ea116SAlex Bennéesecret_keyring="$default_feature"
458c87ea116SAlex Bennéelibdaxctl="$default_feature"
459a5665051SPaolo Bonzinimeson=""
46048328880SPaolo Bonzinininja=""
461a5665051SPaolo Bonziniskip_meson=no
4620e8e77d4SAlex Bennéegettext="auto"
463a484a719SMax Reitzfuse="auto"
464df4ea709SMax Reitzfuse_lseek="auto"
465377529c0SPaolo Bonzini
466aa087962SPaolo Bonzinimalloc_trim="auto"
467898be3e0SPeter Maydell
468c87ea116SAlex Bennée# parse CC options second
469ac0df51dSaliguorifor opt do
47089138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
471ac0df51dSaliguori  case "$opt" in
472ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
473*3812c0c4SJoelle van Dyne                    cross_compile="yes"
474ac0df51dSaliguori  ;;
4753d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
476ac0df51dSaliguori  ;;
47783f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
47883f73fceSTomoki Sekiyama  ;;
4792ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4802ff6b91eSJuan Quintela  ;;
481de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
482db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
483e2a2ed06SJuan Quintela  ;;
48411cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
48511cde1c8SBruno Dominguez  ;;
486db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
487f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
488e2a2ed06SJuan Quintela  ;;
4895bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4905bc62e01SGerd Hoffmann  ;;
4915bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4925bc62e01SGerd Hoffmann  ;;
493d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
494d75402b5SAlex Bennée  ;;
495d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
496d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
4972038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
498d422b2bcSAlex Bennée  ;;
499d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
5002038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
501d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
5022038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
503d75402b5SAlex Bennée  ;;
504ac0df51dSaliguori  esac
505ac0df51dSaliguoridone
506ac0df51dSaliguori# OS specific
507ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
50893148aa5SStefan Weil# we can eliminate its usage altogether.
509ac0df51dSaliguori
510e49d021eSPeter Maydell# Preferred compiler:
511e49d021eSPeter Maydell#  ${CC} (if set)
512e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
513e49d021eSPeter Maydell#  system compiler
514e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
515e49d021eSPeter Maydell  cc="$host_cc"
516e49d021eSPeter Maydellelse
517b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
518e49d021eSPeter Maydellfi
519e49d021eSPeter Maydell
52083f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
52183f73fceSTomoki Sekiyama  cxx="c++"
52283f73fceSTomoki Sekiyamaelse
52383f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
52483f73fceSTomoki Sekiyamafi
52583f73fceSTomoki Sekiyama
526b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
527cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5285f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5293dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
530b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
531b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5329f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5334852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
534b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
535b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
53617884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
53717884d7bSSergei Trofimovichquery_pkg_config() {
53817884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
53917884d7bSSergei Trofimovich}
54017884d7bSSergei Trofimovichpkg_config=query_pkg_config
54147c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
542ac0df51dSaliguori
54345d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
54445d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
54545d285abSPeter Maydell
546be17dc90SMichael S. Tsirkin# default flags for all hosts
5472d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5482d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5492d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5502d31515bSPeter Maydell# provides these semantics.)
551086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
552086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
553c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
554be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5555770e8afSPaolo Bonzini
5565770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson
5575770e8afSPaolo BonziniCONFIGURE_CFLAGS="-std=gnu99 -Wall"
5585770e8afSPaolo BonziniCONFIGURE_LDFLAGS=
559086d5f75SPaolo Bonzini
560be17dc90SMichael S. Tsirkin
561ac0df51dSaliguoricheck_define() {
562ac0df51dSaliguoricat > $TMPC <<EOF
563ac0df51dSaliguori#if !defined($1)
564fd786e1aSPeter Maydell#error $1 not defined
565ac0df51dSaliguori#endif
566ac0df51dSaliguoriint main(void) { return 0; }
567ac0df51dSaliguoriEOF
56852166aa0SJuan Quintela  compile_object
569ac0df51dSaliguori}
570ac0df51dSaliguori
571307119e7SGerd Hoffmanncheck_include() {
572307119e7SGerd Hoffmanncat > $TMPC <<EOF
573307119e7SGerd Hoffmann#include <$1>
574307119e7SGerd Hoffmannint main(void) { return 0; }
575307119e7SGerd HoffmannEOF
576307119e7SGerd Hoffmann  compile_object
577307119e7SGerd Hoffmann}
578307119e7SGerd Hoffmann
57993b25869SJohn Snowwrite_c_skeleton() {
58093b25869SJohn Snow    cat > $TMPC <<EOF
58193b25869SJohn Snowint main(void) { return 0; }
58293b25869SJohn SnowEOF
58393b25869SJohn Snow}
58493b25869SJohn Snow
585adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
586adc28027SAlexander Bulekov    cat > $TMPC <<EOF
587adc28027SAlexander Bulekov#include <stdint.h>
588adc28027SAlexander Bulekov#include <sys/types.h>
589adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
590adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
591adc28027SAlexander BulekovEOF
592adc28027SAlexander Bulekov}
593adc28027SAlexander Bulekov
594bbea4050SPeter Maydellif check_define __linux__ ; then
595bbea4050SPeter Maydell  targetos="Linux"
596bbea4050SPeter Maydellelif check_define _WIN32 ; then
597bbea4050SPeter Maydell  targetos='MINGW32'
598bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
599bbea4050SPeter Maydell  targetos='OpenBSD'
600bbea4050SPeter Maydellelif check_define __sun__ ; then
601bbea4050SPeter Maydell  targetos='SunOS'
602bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
603bbea4050SPeter Maydell  targetos='Haiku'
604951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
605951fedfcSPeter Maydell  targetos='FreeBSD'
606951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
607951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
608951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
609951fedfcSPeter Maydell  targetos='DragonFly'
610951fedfcSPeter Maydellelif check_define __NetBSD__; then
611951fedfcSPeter Maydell  targetos='NetBSD'
612951fedfcSPeter Maydellelif check_define __APPLE__; then
613951fedfcSPeter Maydell  targetos='Darwin'
614bbea4050SPeter Maydellelse
615951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
616951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
617951fedfcSPeter Maydell  # be the result of a missing compiler.
618951fedfcSPeter Maydell  targetos='bogus'
619bbea4050SPeter Maydellfi
620bbea4050SPeter Maydell
621bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
622bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
623bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
624bbea4050SPeter Maydell# the correct CPU with the --cpu option.
625bbea4050SPeter Maydellcase $targetos in
626bbea4050SPeter MaydellDarwin)
627bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
628bbea4050SPeter Maydell  # run 64-bit userspace code.
629bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
630bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
631bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
632bbea4050SPeter Maydell    cpu="x86_64"
633bbea4050SPeter Maydell  fi
6345869f8ddSGerd Hoffmann  HOST_DSOSUF=".dylib"
635bbea4050SPeter Maydell  ;;
636bbea4050SPeter MaydellSunOS)
63789138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
638bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
639bbea4050SPeter Maydell    cpu="x86_64"
640bbea4050SPeter Maydell  fi
641bbea4050SPeter Maydellesac
642bbea4050SPeter Maydell
6432ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6442ff6b91eSJuan Quintela  # command line argument
6452ff6b91eSJuan Quintela  :
6462ff6b91eSJuan Quintelaelif check_define __i386__ ; then
647ac0df51dSaliguori  cpu="i386"
648ac0df51dSaliguorielif check_define __x86_64__ ; then
649c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
650c72b26ecSRichard Henderson    cpu="x32"
651c72b26ecSRichard Henderson  else
652ac0df51dSaliguori    cpu="x86_64"
653c72b26ecSRichard Henderson  fi
6543aa9bd6cSblueswir1elif check_define __sparc__ ; then
6553aa9bd6cSblueswir1  if check_define __arch64__ ; then
6563aa9bd6cSblueswir1    cpu="sparc64"
6573aa9bd6cSblueswir1  else
6583aa9bd6cSblueswir1    cpu="sparc"
6593aa9bd6cSblueswir1  fi
660fdf7ed96Smalcelif check_define _ARCH_PPC ; then
661fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
662f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
663f8378accSRichard Henderson      cpu="ppc64le"
664f8378accSRichard Henderson    else
665fdf7ed96Smalc      cpu="ppc64"
666f8378accSRichard Henderson    fi
667ac0df51dSaliguori  else
668fdf7ed96Smalc    cpu="ppc"
669fdf7ed96Smalc  fi
670afa05235SAurelien Jarnoelif check_define __mips__ ; then
671afa05235SAurelien Jarno  cpu="mips"
672d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
673d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
674d66ed0eaSAurelien Jarno    cpu="s390x"
675d66ed0eaSAurelien Jarno  else
676d66ed0eaSAurelien Jarno    cpu="s390"
677d66ed0eaSAurelien Jarno  fi
678c4f80543SAlistair Franciselif check_define __riscv ; then
679c4f80543SAlistair Francis  if check_define _LP64 ; then
680c4f80543SAlistair Francis    cpu="riscv64"
681c4f80543SAlistair Francis  else
682c4f80543SAlistair Francis    cpu="riscv32"
683c4f80543SAlistair Francis  fi
68421d89f84SPeter Maydellelif check_define __arm__ ; then
68521d89f84SPeter Maydell  cpu="arm"
6861f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6871f080313SClaudio Fontana  cpu="aarch64"
688fdf7ed96Smalcelse
68989138857SStefan Weil  cpu=$(uname -m)
690ac0df51dSaliguorifi
691ac0df51dSaliguori
692359bc95dSPeter MaydellARCH=
693359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
694359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6957d13299dSbellardcase "$cpu" in
696ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
697898be3e0SPeter Maydell  ;;
698f8378accSRichard Henderson  ppc64le)
699f8378accSRichard Henderson    ARCH="ppc64"
700f8378accSRichard Henderson  ;;
7017d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
70297a847bcSbellard    cpu="i386"
7037d13299dSbellard  ;;
704aaa5fa14Saurel32  x86_64|amd64)
705aaa5fa14Saurel32    cpu="x86_64"
706aaa5fa14Saurel32  ;;
70721d89f84SPeter Maydell  armv*b|armv*l|arm)
70821d89f84SPeter Maydell    cpu="arm"
7097d13299dSbellard  ;;
7101f080313SClaudio Fontana  aarch64)
7111f080313SClaudio Fontana    cpu="aarch64"
7121f080313SClaudio Fontana  ;;
713afa05235SAurelien Jarno  mips*)
714afa05235SAurelien Jarno    cpu="mips"
715afa05235SAurelien Jarno  ;;
7163142255cSblueswir1  sparc|sun4[cdmuv])
717ae228531Sbellard    cpu="sparc"
718ae228531Sbellard  ;;
7197d13299dSbellard  *)
720359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
721359bc95dSPeter Maydell    ARCH=unknown
7227d13299dSbellard  ;;
7237d13299dSbellardesac
724359bc95dSPeter Maydellif test -z "$ARCH"; then
725359bc95dSPeter Maydell  ARCH="$cpu"
726359bc95dSPeter Maydellfi
727e2d52ad3SJuan Quintela
7287d13299dSbellard# OS specific
7290dbfc675SJuan Quintela
7307d13299dSbellardcase $targetos in
73167b915a5SbellardMINGW32*)
73267b915a5Sbellard  mingw32="yes"
7333cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
734307119e7SGerd Hoffmann  if check_include dsound.h; then
7353cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
736307119e7SGerd Hoffmann  else
737307119e7SGerd Hoffmann    audio_drv_list=""
738307119e7SGerd Hoffmann  fi
739898be3e0SPeter Maydell  supported_os="yes"
740fb648e9cSDaniel P. Berrangé  pie="no"
74167b915a5Sbellard;;
7425c40d2bdSthsGNU/kFreeBSD)
743a167ba50SAurelien Jarno  bsd="yes"
7446a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7450bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7465c40d2bdSths;;
7477d3505c5SbellardFreeBSD)
7487d3505c5Sbellard  bsd="yes"
7490db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7506a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7510bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
752f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
75358952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
7547d3505c5Sbellard;;
755c5e97233Sblueswir1DragonFly)
756c5e97233Sblueswir1  bsd="yes"
7570db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7586a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7590bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
760c5e97233Sblueswir1;;
7617d3505c5SbellardNetBSD)
7627d3505c5Sbellard  bsd="yes"
7630db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7646a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7650bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7668ef92a88Sblueswir1  oss_lib="-lossaudio"
7677d3505c5Sbellard;;
7687d3505c5SbellardOpenBSD)
7697d3505c5Sbellard  bsd="yes"
7700db4a067SPaolo Bonzini  make="${MAKE-gmake}"
771f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
7720bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
7737d3505c5Sbellard;;
77483fb7adfSbellardDarwin)
77583fb7adfSbellard  bsd="yes"
77683fb7adfSbellard  darwin="yes"
7771b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
778a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
779db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
7801b0f9cc2Saliguori  fi
7816a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
78214382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
783db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
784a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
785a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
786a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
78783fb7adfSbellard;;
788ec530c81SbellardSunOS)
789ec530c81Sbellard  solaris="yes"
7900db4a067SPaolo Bonzini  make="${MAKE-gmake}"
791e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7926b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7936a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
7946b4d2ba1Sths  fi
795c2de5c91Smalc  audio_possible_drivers="oss sdl"
796d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
797d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
798d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
799d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
800ec530c81Sbellard;;
801179cf400SAndreas FärberHaiku)
802179cf400SAndreas Färber  haiku="yes"
803cde99253SThomas Huth  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE $QEMU_CFLAGS"
804179cf400SAndreas Färber;;
805898be3e0SPeter MaydellLinux)
8067183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
8070bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
8085327cf48Sbellard  linux="yes"
809831b7825Sths  linux_user="yes"
810c87ea116SAlex Bennée  vhost_user=${default_feature:-yes}
811898be3e0SPeter Maydell;;
8127d13299dSbellardesac
8137d13299dSbellard
8147d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
815b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
81684778508Sblueswir1    bsd_user="yes"
8177d3505c5Sbellard  fi
81808de3949SAndreas Färberfi
8197d3505c5Sbellard
8200db4a067SPaolo Bonzini: ${make=${MAKE-make}}
821b6daf4d3SPaolo Bonzini
822faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
823faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
824ddf90699SEduardo Habkost# we check that too
825faf44142SDaniel P. Berrangépython=
8260a01d76fSMarc-André Lureauexplicit_python=no
827ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
828faf44142SDaniel P. Berrangédo
829faf44142SDaniel P. Berrangé    if has "$binary"
830faf44142SDaniel P. Berrangé    then
83195c5f2deSPaolo Bonzini        python=$(command -v "$binary")
832faf44142SDaniel P. Berrangé        break
833faf44142SDaniel P. Berrangé    fi
834faf44142SDaniel P. Berrangédone
835903458c8SMarkus Armbruster
836903458c8SMarkus Armbruster
83739d87c8cSAlex Bennée# Check for ancillary tools used in testing
83839d87c8cSAlex Bennéegenisoimage=
8393df437c7SAlex Bennéefor binary in genisoimage mkisofs
84039d87c8cSAlex Bennéedo
84139d87c8cSAlex Bennée    if has $binary
84239d87c8cSAlex Bennée    then
84339d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
84439d87c8cSAlex Bennée        break
84539d87c8cSAlex Bennée    fi
84639d87c8cSAlex Bennéedone
84739d87c8cSAlex Bennée
848e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
8490db4a067SPaolo Bonzini
8503c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8513c4a4d0dSPeter Maydellif has clang; then
8523c4a4d0dSPeter Maydell  objcc=clang
8533c4a4d0dSPeter Maydellelse
8543c4a4d0dSPeter Maydell  objcc="$cc"
8553c4a4d0dSPeter Maydellfi
8563c4a4d0dSPeter Maydell
8573457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8583457a3f8SJuan Quintela  EXESUF=".exe"
859484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
86078e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
8615770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
86293b25869SJohn Snow  write_c_skeleton;
863d17f305aSPaolo Bonzini  prefix="/qemu"
86477433a5fSMarc-André Lureau  qemu_suffix=""
865105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8663457a3f8SJuan Quintelafi
8673457a3f8SJuan Quintela
868487fefdbSAnthony Liguoriwerror=""
86985aa5189Sbellard
8707d13299dSbellardfor opt do
87189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8727d13299dSbellard  case "$opt" in
8732efc3265Sbellard  --help|-h) show_help=yes
8742efc3265Sbellard  ;;
87599123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
87699123e13SMike Frysinger  ;;
877b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8787d13299dSbellard  ;;
879b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
88032ce6337Sbellard  ;;
881ac0df51dSaliguori  --cross-prefix=*)
8827d13299dSbellard  ;;
883ac0df51dSaliguori  --cc=*)
8847d13299dSbellard  ;;
885b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
88683469015Sbellard  ;;
88783f73fceSTomoki Sekiyama  --cxx=*)
88883f73fceSTomoki Sekiyama  ;;
889e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
890e007dbecSMichael S. Tsirkin  ;;
8913c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8923c4a4d0dSPeter Maydell  ;;
893b1a550a0Spbrook  --make=*) make="$optarg"
8947d13299dSbellard  ;;
895b6daf4d3SPaolo Bonzini  --install=*)
8966a882643Spbrook  ;;
8970a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
898c886edfbSBlue Swirl  ;;
8992eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
9002eb054c2SPeter Maydell  ;;
901a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
902a5665051SPaolo Bonzini  ;;
903a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
904a5665051SPaolo Bonzini  ;;
90548328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
90648328880SPaolo Bonzini  ;;
907e2d8830eSBrad  --smbd=*) smbd="$optarg"
908e2d8830eSBrad  ;;
909e2a2ed06SJuan Quintela  --extra-cflags=*)
9107d13299dSbellard  ;;
91111cde1c8SBruno Dominguez  --extra-cxxflags=*)
91211cde1c8SBruno Dominguez  ;;
913e2a2ed06SJuan Quintela  --extra-ldflags=*)
9147d13299dSbellard  ;;
9155bc62e01SGerd Hoffmann  --enable-debug-info)
9165bc62e01SGerd Hoffmann  ;;
9175bc62e01SGerd Hoffmann  --disable-debug-info)
9185bc62e01SGerd Hoffmann  ;;
919d75402b5SAlex Bennée  --cross-cc-*)
920d75402b5SAlex Bennée  ;;
92117969268SFam Zheng  --enable-modules)
92217969268SFam Zheng      modules="yes"
92317969268SFam Zheng  ;;
9243aa88b31SStefan Hajnoczi  --disable-modules)
9253aa88b31SStefan Hajnoczi      modules="no"
9263aa88b31SStefan Hajnoczi  ;;
927bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
928bd83c861SChristian Ehrhardt  ;;
929bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
930bd83c861SChristian Ehrhardt  ;;
9312ff6b91eSJuan Quintela  --cpu=*)
9327d13299dSbellard  ;;
933b1a550a0Spbrook  --target-list=*) target_list="$optarg"
934447e133fSAlex Bennée                   if test "$target_list_exclude"; then
935447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
936447e133fSAlex Bennée                   fi
937447e133fSAlex Bennée  ;;
938447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
939447e133fSAlex Bennée                   if test "$target_list"; then
940447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
941447e133fSAlex Bennée                   fi
942de83cd02Sbellard  ;;
9435b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9445b808275SLluís Vilanova  ;;
9455b808275SLluís Vilanova  # XXX: backwards compatibility
9465b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
94794a420b1SStefan Hajnoczi  ;;
94874242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9499410b56cSPrerna Saxena  ;;
9507bc3ca7fSPaolo Bonzini  --with-default-devices) default_devices="true"
951f3494749SPaolo Bonzini  ;;
9527bc3ca7fSPaolo Bonzini  --without-default-devices) default_devices="false"
953f3494749SPaolo Bonzini  ;;
954c87ea116SAlex Bennée  --without-default-features) # processed above
955c87ea116SAlex Bennée  ;;
9567d13299dSbellard  --enable-gprof) gprof="yes"
9577d13299dSbellard  ;;
9581d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9591d728c39SBlue Swirl  ;;
96079427693SLoïc Minier  --static)
96179427693SLoïc Minier    static="yes"
96217884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
96343ce4dfeSbellard  ;;
9640b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9650b24e75fSPaolo Bonzini  ;;
9660b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9670b24e75fSPaolo Bonzini  ;;
9683aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9693aa5d2beSAlon Levy  ;;
9708bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9718bf188aaSMichael Tokarev  ;;
9720f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9730f94d6daSAlon Levy  ;;
974528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9750b24e75fSPaolo Bonzini  ;;
97677433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
977023d3d67SEduardo Habkost  ;;
978c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
9790b24e75fSPaolo Bonzini  ;;
980fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
981fe0038beSPaolo Bonzini  ;;
982ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
98307381cc1SAnthony Liguori  ;;
984785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
985785c23aeSLuiz Capitulino  ;;
9863d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9873d5eecabSGerd Hoffmann  ;;
988181ce1d0SOlaf Hering  --host=*|--build=*|\
989181ce1d0SOlaf Hering  --disable-dependency-tracking|\
990785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
991fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
992023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
993023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
994023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
995023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
996023ddd74SMax Filippov    # lots of directory switches by default.
997023ddd74SMax Filippov  ;;
99835be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
99997a847bcSbellard  ;;
100035be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
1001c4198157SJuan Quintela  ;;
100235be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
1003a442fe2fSDaniel P. Berrangé  ;;
100435be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
1005a442fe2fSDaniel P. Berrangé  ;;
10063556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
10073556c233SPaolo Bonzini  ;;
10083556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
10093556c233SPaolo Bonzini  ;;
101069202b40SPaolo Bonzini  --disable-virtfs) virtfs="disabled"
1011983eef5aSMeador Inge  ;;
101269202b40SPaolo Bonzini  --enable-virtfs) virtfs="enabled"
1013983eef5aSMeador Inge  ;;
10145c53015aSPaolo Bonzini  --disable-libudev) libudev="disabled"
10155c53015aSPaolo Bonzini  ;;
10165c53015aSPaolo Bonzini  --enable-libudev) libudev="enabled"
10175c53015aSPaolo Bonzini  ;;
1018cece116cSMisono Tomohiro  --disable-virtiofsd) virtiofsd="disabled"
1019cece116cSMisono Tomohiro  ;;
1020cece116cSMisono Tomohiro  --enable-virtiofsd) virtiofsd="enabled"
1021cece116cSMisono Tomohiro  ;;
10226ec0e15dSPaolo Bonzini  --disable-mpath) mpath="disabled"
1023fe8fc5aeSPaolo Bonzini  ;;
10246ec0e15dSPaolo Bonzini  --enable-mpath) mpath="enabled"
1025fe8fc5aeSPaolo Bonzini  ;;
1026a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
1027821601eaSJes Sorensen  ;;
1028a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
1029821601eaSJes Sorensen  ;;
10300e8e77d4SAlex Bennée  --disable-gettext) gettext="disabled"
1031e8f3bd71SMarc-André Lureau  ;;
10320e8e77d4SAlex Bennée  --enable-gettext) gettext="enabled"
1033e8f3bd71SMarc-André Lureau  ;;
10342f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10352f6a1ab0Sblueswir1  ;;
10360c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10370c58ac1cSmalc  ;;
103889138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1039b64ec4e4SFam Zheng  ;;
104089138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1041eb852011SMarkus Armbruster  ;;
1042f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1043f8393946Saurel32  ;;
1044f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1045f8393946Saurel32  ;;
1046f3d08ee6SPaul Brook  --enable-debug)
1047f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1048f3d08ee6SPaul Brook      debug_tcg="yes"
10491fcc6d42SPeter Xu      debug_mutex="yes"
1050f3d08ee6SPaul Brook      debug="yes"
1051f3d08ee6SPaul Brook      strip_opt="no"
1052b553a042SJohn Snow      fortify_source="no"
1053f3d08ee6SPaul Brook  ;;
1054247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1055247724cbSMarc-André Lureau  ;;
1056247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1057247724cbSMarc-André Lureau  ;;
10580aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
10590aebab04SLingfeng Yang  ;;
10600aebab04SLingfeng Yang  --disable-tsan) tsan="no"
10610aebab04SLingfeng Yang  ;;
1062deb62371SPaolo Bonzini  --enable-sparse) sparse="enabled"
106303b4fe7dSaliguori  ;;
1064deb62371SPaolo Bonzini  --disable-sparse) sparse="disabled"
106503b4fe7dSaliguori  ;;
10661625af87Saliguori  --disable-strip) strip_opt="no"
10671625af87Saliguori  ;;
1068a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
10692f9606b3Saliguori  ;;
1070a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1071ea784e3bSJuan Quintela  ;;
1072a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
10732f6f5c7aSCorentin Chary  ;;
1074a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
10752f6f5c7aSCorentin Chary  ;;
1076a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1077efe556adSCorentin Chary  ;;
1078a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1079efe556adSCorentin Chary  ;;
10804d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
1081c20709aaSbellard  ;;
1082fd6fc214SPaolo Bonzini  --enable-slirp) slirp="enabled"
1083fd6fc214SPaolo Bonzini  ;;
10844d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
10857c57bdd8SMarc-André Lureau  ;;
1086675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1087675b9b53SMarc-André Lureau  ;;
1088e0e6c8c0Saliguori  --disable-vde) vde="no"
10898a16d273Sths  ;;
1090dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1091dfb278bdSJuan Quintela  ;;
109258952137SVincenzo Maffione  --disable-netmap) netmap="no"
109358952137SVincenzo Maffione  ;;
109458952137SVincenzo Maffione  --enable-netmap) netmap="yes"
109558952137SVincenzo Maffione  ;;
10961badb709SPaolo Bonzini  --disable-xen) xen="disabled"
1097e37630caSaliguori  ;;
10981badb709SPaolo Bonzini  --enable-xen) xen="enabled"
1099fc321b4bSJuan Quintela  ;;
11001badb709SPaolo Bonzini  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
1101eb6fda0fSAnthony PERARD  ;;
11021badb709SPaolo Bonzini  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
1103eb6fda0fSAnthony PERARD  ;;
11048c6d4ff4SPaolo Bonzini  --disable-brlapi) brlapi="disabled"
11052e4d9fb1Saurel32  ;;
11068c6d4ff4SPaolo Bonzini  --enable-brlapi) brlapi="enabled"
11074ffcedb6SJuan Quintela  ;;
11081badb709SPaolo Bonzini  --disable-kvm) kvm="disabled"
11097ba1e619Saliguori  ;;
11101badb709SPaolo Bonzini  --enable-kvm) kvm="enabled"
1111b31a0277SJuan Quintela  ;;
11121badb709SPaolo Bonzini  --disable-hax) hax="disabled"
1113180fb750Szhanghailiang  ;;
11141badb709SPaolo Bonzini  --enable-hax) hax="enabled"
1115180fb750Szhanghailiang  ;;
11161badb709SPaolo Bonzini  --disable-hvf) hvf="disabled"
1117c97d6d2cSSergio Andres Gomez Del Real  ;;
11181badb709SPaolo Bonzini  --enable-hvf) hvf="enabled"
1119c97d6d2cSSergio Andres Gomez Del Real  ;;
11201badb709SPaolo Bonzini  --disable-whpx) whpx="disabled"
1121d661d9a4SJustin Terry (VM)  ;;
11221badb709SPaolo Bonzini  --enable-whpx) whpx="enabled"
1123d661d9a4SJustin Terry (VM)  ;;
112423a77b2dSPaolo Bonzini  --disable-tcg-interpreter) tcg_interpreter="true"
11259195b2c2SStefan Weil  ;;
112623a77b2dSPaolo Bonzini  --enable-tcg-interpreter) tcg_interpreter="false"
11279195b2c2SStefan Weil  ;;
1128727c8bb8SPaolo Bonzini  --disable-cap-ng)  cap_ng="disabled"
112947e98658SCorey Bryant  ;;
1130727c8bb8SPaolo Bonzini  --enable-cap-ng) cap_ng="enabled"
113147e98658SCorey Bryant  ;;
11321badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
1133b3f6ea7eSPaolo Bonzini  ;;
11341badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
1135b3f6ea7eSPaolo Bonzini  ;;
1136aa087962SPaolo Bonzini  --disable-malloc-trim) malloc_trim="disabled"
11375a22ab71SYang Zhong  ;;
1138aa087962SPaolo Bonzini  --enable-malloc-trim) malloc_trim="enabled"
11395a22ab71SYang Zhong  ;;
1140cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1141cd4ec0b4SGerd Hoffmann  ;;
1142cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1143cd4ec0b4SGerd Hoffmann  ;;
11449db405a3SPaolo Bonzini  --disable-libiscsi) libiscsi="disabled"
1145c589b249SRonnie Sahlberg  ;;
11469db405a3SPaolo Bonzini  --enable-libiscsi) libiscsi="enabled"
1147c589b249SRonnie Sahlberg  ;;
114830045c05SPaolo Bonzini  --disable-libnfs) libnfs="disabled"
11496542aa9cSPeter Lieven  ;;
115030045c05SPaolo Bonzini  --enable-libnfs) libnfs="enabled"
11516542aa9cSPeter Lieven  ;;
115205c2a3e7Sbellard  --enable-profiler) profiler="yes"
115305c2a3e7Sbellard  ;;
1154b4e312e9SPaolo Bonzini  --disable-cocoa) cocoa="disabled"
115514821030SPavel Borzenkov  ;;
1156a23a6789SPaolo Bonzini  --enable-cocoa) cocoa="enabled"
11575b0753e0Sbellard  ;;
1158cad25d69Spbrook  --disable-system) softmmu="no"
11590a8e90f4Spbrook  ;;
1160cad25d69Spbrook  --enable-system) softmmu="yes"
11610a8e90f4Spbrook  ;;
11620953a80fSZachary Amsden  --disable-user)
11630953a80fSZachary Amsden      linux_user="no" ;
11640953a80fSZachary Amsden      bsd_user="no" ;
11650953a80fSZachary Amsden  ;;
11660953a80fSZachary Amsden  --enable-user) ;;
1167831b7825Sths  --disable-linux-user) linux_user="no"
11680a8e90f4Spbrook  ;;
1169831b7825Sths  --enable-linux-user) linux_user="yes"
1170831b7825Sths  ;;
117184778508Sblueswir1  --disable-bsd-user) bsd_user="no"
117284778508Sblueswir1  ;;
117384778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
117484778508Sblueswir1  ;;
117540d6444eSAvi Kivity  --enable-pie) pie="yes"
117634005a00SKirill A. Shutemov  ;;
117740d6444eSAvi Kivity  --disable-pie) pie="no"
117834005a00SKirill A. Shutemov  ;;
117985aa5189Sbellard  --enable-werror) werror="yes"
118085aa5189Sbellard  ;;
118185aa5189Sbellard  --disable-werror) werror="no"
118285aa5189Sbellard  ;;
1183cdad781dSDaniele Buono  --enable-lto) lto="true"
1184cdad781dSDaniele Buono  ;;
1185cdad781dSDaniele Buono  --disable-lto) lto="false"
1186cdad781dSDaniele Buono  ;;
118763678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
118863678e17SSteven Noonan  ;;
118963678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
119063678e17SSteven Noonan  ;;
11911e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
11921e4f6065SDaniele Buono  ;;
11931e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
11941e4f6065SDaniele Buono  ;;
11959e62ba48SDaniele Buono  --enable-cfi)
11969e62ba48SDaniele Buono      cfi="true";
11979e62ba48SDaniele Buono      lto="true";
11989e62ba48SDaniele Buono  ;;
11999e62ba48SDaniele Buono  --disable-cfi) cfi="false"
12009e62ba48SDaniele Buono  ;;
12019e62ba48SDaniele Buono  --enable-cfi-debug) cfi_debug="true"
12029e62ba48SDaniele Buono  ;;
12039e62ba48SDaniele Buono  --disable-cfi-debug) cfi_debug="false"
12049e62ba48SDaniele Buono  ;;
12055285e593SYonggang Luo  --disable-curses) curses="disabled"
12064d3b6f6eSbalrog  ;;
12075285e593SYonggang Luo  --enable-curses) curses="enabled"
1208c584a6d0SJuan Quintela  ;;
12095285e593SYonggang Luo  --disable-iconv) iconv="disabled"
1210e08bb301SSamuel Thibault  ;;
12115285e593SYonggang Luo  --enable-iconv) iconv="enabled"
1212e08bb301SSamuel Thibault  ;;
1213f9cd86feSPaolo Bonzini  --disable-curl) curl="disabled"
1214769ce76dSAlexander Graf  ;;
1215f9cd86feSPaolo Bonzini  --enable-curl) curl="enabled"
1216788c8196SJuan Quintela  ;;
1217fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
12182df87df7SJuan Quintela  ;;
1219fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
1220fbb4121dSPaolo Bonzini  ;;
1221fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
1222fbb4121dSPaolo Bonzini  ;;
1223fbb4121dSPaolo Bonzini  --enable-fdt=system) fdt="system"
12242df87df7SJuan Quintela  ;;
12255c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12265c6c3a6cSChristoph Hellwig  ;;
12275c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12285c6c3a6cSChristoph Hellwig  ;;
1229c10dd856SAarushi Mehta  --disable-linux-io-uring) linux_io_uring="no"
1230c10dd856SAarushi Mehta  ;;
1231c10dd856SAarushi Mehta  --enable-linux-io-uring) linux_io_uring="yes"
1232c10dd856SAarushi Mehta  ;;
1233f7f2d651SPaolo Bonzini  --disable-attr) attr="disabled"
1234758e8e38SVenkateswararao Jujjuri (JV)  ;;
1235f7f2d651SPaolo Bonzini  --enable-attr) attr="enabled"
1236758e8e38SVenkateswararao Jujjuri (JV)  ;;
1237a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1238a40161cbSPaolo Bonzini  ;;
1239a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1240a40161cbSPaolo Bonzini  ;;
1241c8d5450bSPaolo Bonzini  --disable-blobs) blobs="false"
124277755340Sths  ;;
12437e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12444a19f1ecSpbrook  ;;
1245519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1246519175a2SAlex Barcelo  ;;
124770c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
124870c60c08SStefan Hajnoczi  ;;
124970c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
125070c60c08SStefan Hajnoczi  ;;
12517d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12527d992e4dSPeter Lieven  ;;
1253f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1254f0d92b56SLongpeng(Mike)  ;;
1255f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1256f0d92b56SLongpeng(Mike)  ;;
1257e3667660SYonggang Luo  --disable-docs) docs="disabled"
125870ec5dc0SAnthony Liguori  ;;
1259e3667660SYonggang Luo  --enable-docs) docs="enabled"
126083a3ab8bSJuan Quintela  ;;
1261d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1262d5970055SMichael S. Tsirkin  ;;
1263d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1264d5970055SMichael S. Tsirkin  ;;
1265042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1266042cea27SGonglei  ;;
1267299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1268042cea27SGonglei  ;;
12695e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12705e9be92dSNicholas Bellinger  ;;
12715e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12725e9be92dSNicholas Bellinger  ;;
1273fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1274fc0b9b0eSStefan Hajnoczi  ;;
1275fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1276fc0b9b0eSStefan Hajnoczi  ;;
1277e5e856c1SStefan Hajnoczi  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
1278bc15e44cSStefan Hajnoczi  ;;
1279e5e856c1SStefan Hajnoczi  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
1280bc15e44cSStefan Hajnoczi  ;;
128198fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
128298fc1adaSDr. David Alan Gilbert  ;;
128398fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
128498fc1adaSDr. David Alan Gilbert  ;;
1285da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
128620ff075bSMichael Walle  ;;
1287da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
128820ff075bSMichael Walle  ;;
1289fabd1e93SPaolo Bonzini  --disable-rbd) rbd="disabled"
1290f27aaf4bSChristian Brunner  ;;
1291fabd1e93SPaolo Bonzini  --enable-rbd) rbd="enabled"
1292f27aaf4bSChristian Brunner  ;;
12938c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12948c84cf11SSergei Trofimovich  ;;
12958c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12968c84cf11SSergei Trofimovich  ;;
12977b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1298111a38b0SRobert Relyea  ;;
12997b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1300111a38b0SRobert Relyea  ;;
13010a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
13020a40bcb7SCésar Belley  ;;
13030a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
13040a40bcb7SCésar Belley  ;;
13052b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
13062b2325ffSGerd Hoffmann  ;;
13072b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
13082b2325ffSGerd Hoffmann  ;;
130969354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
131069354a83SHans de Goede  ;;
131169354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
131269354a83SHans de Goede  ;;
13131ffb3bbbSPaolo Bonzini  --disable-zlib-test)
13141ece9905SAlon Levy  ;;
13150c32a0aeSPaolo Bonzini  --disable-lzo) lzo="disabled"
1316b25c9dffSStefan Weil  ;;
13170c32a0aeSPaolo Bonzini  --enable-lzo) lzo="enabled"
1318607dacd0Sqiaonuohan  ;;
1319241611eaSPaolo Bonzini  --disable-snappy) snappy="disabled"
1320b25c9dffSStefan Weil  ;;
1321241611eaSPaolo Bonzini  --enable-snappy) snappy="enabled"
1322607dacd0Sqiaonuohan  ;;
132329ba6116SPaolo Bonzini  --disable-bzip2) bzip2="disabled"
13246b383c08SPeter Wu  ;;
132529ba6116SPaolo Bonzini  --enable-bzip2) bzip2="enabled"
13266b383c08SPeter Wu  ;;
1327ecea3696SPaolo Bonzini  --enable-lzfse) lzfse="enabled"
132883bc1f97SJulio Faracco  ;;
1329ecea3696SPaolo Bonzini  --disable-lzfse) lzfse="disabled"
133083bc1f97SJulio Faracco  ;;
1331b1def33dSPaolo Bonzini  --disable-zstd) zstd="disabled"
13323a678481SJuan Quintela  ;;
1333b1def33dSPaolo Bonzini  --enable-zstd) zstd="enabled"
13343a678481SJuan Quintela  ;;
1335d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1336d138cee9SMichael Roth  ;;
1337d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1338d138cee9SMichael Roth  ;;
1339b846ab7cSPaolo Bonzini  --enable-guest-agent-msi) guest_agent_msi="enabled"
13409dacf32dSYossi Hindin  ;;
1341b846ab7cSPaolo Bonzini  --disable-guest-agent-msi) guest_agent_msi="disabled"
13429dacf32dSYossi Hindin  ;;
1343d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1344d9840e25STomoki Sekiyama  ;;
1345d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1346d9840e25STomoki Sekiyama  ;;
1347d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1348d9840e25STomoki Sekiyama  ;;
1349d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1350d9840e25STomoki Sekiyama  ;;
1351d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1352d9840e25STomoki Sekiyama  ;;
1353d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1354d9840e25STomoki Sekiyama  ;;
13554b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13564b1c11fdSDaniel P. Berrange  ;;
13574b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13584b1c11fdSDaniel P. Berrange  ;;
135990835c2bSPaolo Bonzini  --enable-seccomp) seccomp="enabled"
1360f794573eSEduardo Otubo  ;;
136190835c2bSPaolo Bonzini  --disable-seccomp) seccomp="disabled"
1362f794573eSEduardo Otubo  ;;
136308821ca2SPaolo Bonzini  --disable-glusterfs) glusterfs="disabled"
1364eb100396SBharata B Rao  ;;
136586583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
136686583a07SLiam Merwick  ;;
136786583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
136886583a07SLiam Merwick  ;;
13696b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
13706b8cd447SRobert Hoo  ;;
13716b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
13726b8cd447SRobert Hoo  ;;
13736b8cd447SRobert Hoo
137408821ca2SPaolo Bonzini  --enable-glusterfs) glusterfs="enabled"
1375eb100396SBharata B Rao  ;;
137652b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
137752b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1378583f6e7bSStefan Hajnoczi  ;;
1379cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1380cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1381cb6414dfSFam Zheng  ;;
1382315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1383315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1384315d3184SFam Zheng  ;;
13851b695471SPaolo Bonzini  --disable-gtk) gtk="disabled"
1386a4ccabcfSAnthony Liguori  ;;
13871b695471SPaolo Bonzini  --enable-gtk) gtk="enabled"
1388a4ccabcfSAnthony Liguori  ;;
1389a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1390a1c5e949SDaniel P. Berrange  ;;
1391ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1392ddbb0d09SDaniel P. Berrange  ;;
1393ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1394ddbb0d09SDaniel P. Berrange  ;;
139591bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
139691bfcdb0SDaniel P. Berrange  ;;
139791bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
139891bfcdb0SDaniel P. Berrange  ;;
139991bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
140091bfcdb0SDaniel P. Berrange  ;;
140191bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
140291bfcdb0SDaniel P. Berrange  ;;
14038953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
14048953caf3SDaniel P. Berrange  ;;
14058953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
14068953caf3SDaniel P. Berrange  ;;
14072da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
14082da776dbSMichael R. Hines  ;;
14092da776dbSMichael R. Hines  --disable-rdma) rdma="no"
14102da776dbSMichael R. Hines  ;;
141121ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
141221ab34c9SMarcel Apfelbaum  ;;
141321ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
141421ab34c9SMarcel Apfelbaum  ;;
1415bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1416bbbf9bfbSStefan Weil  ;;
1417bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1418bbbf9bfbSStefan Weil  ;;
14199d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
14209d9e1521SGerd Hoffmann  ;;
14219d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
14229d9e1521SGerd Hoffmann  ;;
1423e91c793cSCole Robinson  --disable-tpm) tpm="no"
1424e91c793cSCole Robinson  ;;
1425ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1426ab214c29SStefan Berger  ;;
1427b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14280a12ec87SRichard W.M. Jones  ;;
1429b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14300a12ec87SRichard W.M. Jones  ;;
1431ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1432ed1701c6SDr. David Alan Gilbert  ;;
1433ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1434ed1701c6SDr. David Alan Gilbert  ;;
1435a99d57bbSWanlong Gao  --disable-numa) numa="no"
1436a99d57bbSWanlong Gao  ;;
1437a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1438a99d57bbSWanlong Gao  ;;
1439ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1440ed279a06SKlim Kireev  ;;
1441ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1442ed279a06SKlim Kireev  ;;
14432847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14442847b469SFam Zheng  ;;
14452847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14462847b469SFam Zheng  ;;
14477b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14487b01cb97SAlexandre Derumier  ;;
14497b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14507b01cb97SAlexandre Derumier  ;;
1451a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1452a6b1d4c0SChanglong Xie  ;;
1453a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1454a6b1d4c0SChanglong Xie  ;;
14552f740136SJeff Cody  --disable-bochs) bochs="no"
14562f740136SJeff Cody  ;;
14572f740136SJeff Cody  --enable-bochs) bochs="yes"
14582f740136SJeff Cody  ;;
14592f740136SJeff Cody  --disable-cloop) cloop="no"
14602f740136SJeff Cody  ;;
14612f740136SJeff Cody  --enable-cloop) cloop="yes"
14622f740136SJeff Cody  ;;
14632f740136SJeff Cody  --disable-dmg) dmg="no"
14642f740136SJeff Cody  ;;
14652f740136SJeff Cody  --enable-dmg) dmg="yes"
14662f740136SJeff Cody  ;;
14672f740136SJeff Cody  --disable-qcow1) qcow1="no"
14682f740136SJeff Cody  ;;
14692f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14702f740136SJeff Cody  ;;
14712f740136SJeff Cody  --disable-vdi) vdi="no"
14722f740136SJeff Cody  ;;
14732f740136SJeff Cody  --enable-vdi) vdi="yes"
14742f740136SJeff Cody  ;;
14752f740136SJeff Cody  --disable-vvfat) vvfat="no"
14762f740136SJeff Cody  ;;
14772f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14782f740136SJeff Cody  ;;
14792f740136SJeff Cody  --disable-qed) qed="no"
14802f740136SJeff Cody  ;;
14812f740136SJeff Cody  --enable-qed) qed="yes"
14822f740136SJeff Cody  ;;
14832f740136SJeff Cody  --disable-parallels) parallels="no"
14842f740136SJeff Cody  ;;
14852f740136SJeff Cody  --enable-parallels) parallels="yes"
14862f740136SJeff Cody  ;;
14872f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
14882f740136SJeff Cody  ;;
14892f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
14902f740136SJeff Cody  ;;
1491e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1492e6a74868SMarc-André Lureau  ;;
1493299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1494299e6f19SPaolo Bonzini  ;;
1495108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1496108a6481SCindy Lu  ;;
1497108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1498108a6481SCindy Lu  ;;
1499299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1500299e6f19SPaolo Bonzini  ;;
1501299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1502e6a74868SMarc-André Lureau  ;;
15038b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
15048ca80760SRichard Henderson  ;;
15058b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
15068ca80760SRichard Henderson  ;;
15078b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1508e219c499SRichard Henderson  ;;
1509e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1510e219c499SRichard Henderson  ;;
1511cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1512cc84d63aSDaniel P. Berrange  ;;
1513f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1514f62bbee5SDaniel P. Berrange  ;;
1515f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1516f62bbee5SDaniel P. Berrange  ;;
1517ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1518ba59fb77SPaolo Bonzini  ;;
1519ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1520ba59fb77SPaolo Bonzini  ;;
152117824406SJunyan He  --enable-libpmem) libpmem=yes
152217824406SJunyan He  ;;
152317824406SJunyan He  --disable-libpmem) libpmem=no
152417824406SJunyan He  ;;
15254113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
152675411919SJames Le Cuirot  ;;
15274113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
152875411919SJames Le Cuirot  ;;
152940e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
153040e8c6f4SAlex Bennée  ;;
153140e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
153240e8c6f4SAlex Bennée  ;;
1533afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1534afc3a8f9SAlex Bennée  ;;
1535afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1536afc3a8f9SAlex Bennée  ;;
1537adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1538adc28027SAlexander Bulekov  ;;
1539adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1540adc28027SAlexander Bulekov  ;;
1541f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1542f48e590aSAlex Bennée  ;;
1543b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1544b767d257SMarek Marczykowski-Górecki  ;;
1545b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1546b767d257SMarek Marczykowski-Górecki  ;;
154754e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
154854e7aac0SAlexey Krasikov  ;;
154954e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
155054e7aac0SAlexey Krasikov  ;;
155121b2eca6SJingqi Liu  --enable-libdaxctl) libdaxctl=yes
155221b2eca6SJingqi Liu  ;;
155321b2eca6SJingqi Liu  --disable-libdaxctl) libdaxctl=no
155421b2eca6SJingqi Liu  ;;
1555a484a719SMax Reitz  --enable-fuse) fuse="enabled"
1556a484a719SMax Reitz  ;;
1557a484a719SMax Reitz  --disable-fuse) fuse="disabled"
1558a484a719SMax Reitz  ;;
1559df4ea709SMax Reitz  --enable-fuse-lseek) fuse_lseek="enabled"
1560df4ea709SMax Reitz  ;;
1561df4ea709SMax Reitz  --disable-fuse-lseek) fuse_lseek="disabled"
1562df4ea709SMax Reitz  ;;
15632d2ad6d0SFam Zheng  *)
15642d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15652d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15662d2ad6d0SFam Zheng      exit 1
15677f1559c6Sbalrog  ;;
15687d13299dSbellard  esac
15697d13299dSbellarddone
15707d13299dSbellard
157122a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
157222a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
157322a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
157422a87800SMarc-André Lureau
157522a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
157615588a62SJoshua Watt    bindir="${bindir:-$prefix}"
157722a87800SMarc-André Lureauelse
157815588a62SJoshua Watt    bindir="${bindir:-$prefix/bin}"
157915588a62SJoshua Wattfi
158022a87800SMarc-André Lureaumandir="${mandir:-$prefix/share/man}"
158122a87800SMarc-André Lureaudatadir="${datadir:-$prefix/share}"
1582ca8c0909SMarc-André Lureaudocdir="${docdir:-$prefix/share/doc}"
158322a87800SMarc-André Lureausysconfdir="${sysconfdir:-$prefix/etc}"
158422a87800SMarc-André Lureaulocal_statedir="${local_statedir:-$prefix/var}"
158516bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
158616bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
158722a87800SMarc-André Lureau
158840293e58Sbellardcase "$cpu" in
1589e3608d66SRichard Henderson    ppc)
1590e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1591db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1592e3608d66SRichard Henderson           ;;
1593e3608d66SRichard Henderson    ppc64)
1594e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1595db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1596e3608d66SRichard Henderson           ;;
15979b9c37c3SRichard Henderson    sparc)
1598f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1599db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
16003142255cSblueswir1           ;;
1601ed968ff1SJuan Quintela    sparc64)
160279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1603db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
16043142255cSblueswir1           ;;
160576d83bdeSths    s390)
1606061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1607db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
160828d7cc49SRichard Henderson           ;;
160928d7cc49SRichard Henderson    s390x)
1610061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1611db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
161276d83bdeSths           ;;
161340293e58Sbellard    i386)
161479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1615db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
161640293e58Sbellard           ;;
161740293e58Sbellard    x86_64)
16187ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
16197ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16207ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16217ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1622db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1623379f6698SPaul Brook           ;;
1624c72b26ecSRichard Henderson    x32)
1625c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1626db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1627c72b26ecSRichard Henderson           ;;
162830163d89SPeter Maydell    # No special flags required for other host CPUs
16293142255cSblueswir1esac
16303142255cSblueswir1
16312038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
16322038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
163379f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
163479f3b12fSPeter Crosthwaite
1635affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1636affc88ccSPeter Maydell# support, even if we're using TCI.
1637affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1638affc88ccSPeter Maydell  bsd_user="no"
1639affc88ccSPeter Maydell  linux_user="no"
1640affc88ccSPeter Maydellfi
1641affc88ccSPeter Maydell
164260e0df25SPeter Maydelldefault_target_list=""
1643fdb75aefSPaolo Bonzinideprecated_targets_list=ppc64abi32-linux-user,tilegx-linux-user,lm32-softmmu,unicore32-softmmu
1644fdb75aefSPaolo Bonzinideprecated_features=""
16456e92f823SPeter Maydellmak_wilds=""
16466e92f823SPeter Maydell
164760e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
164873362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-softmmu.mak"
164960e0df25SPeter Maydellfi
165060e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
165173362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-linux-user.mak"
165260e0df25SPeter Maydellfi
165360e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
165473362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-bsd-user.mak"
165560e0df25SPeter Maydellfi
165660e0df25SPeter Maydell
16573a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
16583a5ae4a9SAlex Bennée# skip it.
16593a5ae4a9SAlex Bennéeif test -z "$target_list"; then
16603a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
16613a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
16623a5ae4a9SAlex Bennée    else
16633a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
16643a5ae4a9SAlex Bennée    fi
16652d838d9bSAlex Bennéefi
16662d838d9bSAlex Bennée
1667447e133fSAlex Bennéefor config in $mak_wilds; do
1668447e133fSAlex Bennée    target="$(basename "$config" .mak)"
166998db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1670447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1671447e133fSAlex Bennée    fi
1672447e133fSAlex Bennéedone
16736e92f823SPeter Maydell
1674c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
167564a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1676c53eeaf7SStefan Hajnoczi
1677af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1678af5db58eSpbrookcat << EOF
1679af5db58eSpbrook
1680af5db58eSpbrookUsage: configure [options]
1681af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1682af5db58eSpbrook
168308fb77edSStefan WeilStandard options:
168408fb77edSStefan Weil  --help                   print this message
168508fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
168608fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
168708fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
16882deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
168908fb77edSStefan Weil$(echo Available targets: $default_target_list | \
169008fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
16912deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
16922deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1693447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
169408fb77edSStefan Weil
169508fb77edSStefan WeilAdvanced options (experts only):
1696*3812c0c4SJoelle van Dyne  --cross-prefix=PREFIX    use PREFIX for compile tools, PREFIX can be blank [$cross_prefix]
169708fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
169808fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
169908fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
170008fb77edSStefan Weil                           build time
170108fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
170208fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
170308fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
170411cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
170508fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1706d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1707d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
170808fb77edSStefan Weil  --make=MAKE              use specified make [$make]
170908fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
17102eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1711a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
171248328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
171308fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1714db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
171508fb77edSStefan Weil  --static                 enable static build [$static]
171608fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
171710ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1718fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
171910ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
172008fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
172108fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1722db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
172310ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
172408fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
17253d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
172613336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1727ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1728db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
1729c035c8d6SPaolo Bonzini  --without-default-features default all --enable-* options to "disabled"
1730c035c8d6SPaolo Bonzini  --without-default-devices  do not include any device that is not needed to
1731c035c8d6SPaolo Bonzini                           start the emulator (only use if you are including
1732c035c8d6SPaolo Bonzini                           desired devices in default-configs/devices/)
173308fb77edSStefan Weil  --enable-debug           enable common debug build options
1734247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
17350aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
173608fb77edSStefan Weil  --disable-strip          disable stripping binaries
173708fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
173863678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
173908fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
174008fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
174108fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
174208fb77edSStefan Weil  --block-drv-rw-whitelist=L
174308fb77edSStefan Weil                           set block driver read-write whitelist
174408fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
174508fb77edSStefan Weil  --block-drv-ro-whitelist=L
174608fb77edSStefan Weil                           set block driver read-only whitelist
174708fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
17485b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1749c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
175008fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
175108fb77edSStefan Weil                           Default:trace-<pid>
1752c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1753c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
17545a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1755c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1756c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
175708fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
175833c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
175908fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1760c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1761c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1762c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1763a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1764c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1765c12d66aaSLin Ma  --enable-profiler        profiler support
1766c12d66aaSLin Ma  --enable-debug-stack-usage
1767c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
176840e8c6f4SAlex Bennée  --enable-plugins
176940e8c6f4SAlex Bennée                           enable plugins via shared library loading
1770afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1771f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1772c23f23b9SMichael Tokarev
1773c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1774c87ea116SAlex Bennéedisabled with --disable-FEATURE, default is enabled if available
1775c87ea116SAlex Bennée(unless built with --without-default-features):
1776c23f23b9SMichael Tokarev
1777c23f23b9SMichael Tokarev  system          all system emulation targets
1778c23f23b9SMichael Tokarev  user            supported user emulation targets
1779c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1780c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1781c23f23b9SMichael Tokarev  docs            build documentation
1782c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1783c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1784c23f23b9SMichael Tokarev  pie             Position Independent Executables
178521e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1786bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1787c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1788c23f23b9SMichael Tokarev  debug-info      debugging information
1789cdad781dSDaniele Buono  lto             Enable Link-Time Optimization.
1790c23f23b9SMichael Tokarev  sparse          sparse checker
17911e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
17921e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
17939e62ba48SDaniele Buono  cfi             Enable Control-Flow Integrity for indirect function calls.
17949e62ba48SDaniele Buono                  In case of a cfi violation, QEMU is terminated with SIGILL
17959e62ba48SDaniele Buono                  Depends on lto and is incompatible with modules
17969e62ba48SDaniele Buono                  Automatically enables Link-Time Optimization (lto)
17979e62ba48SDaniele Buono  cfi-debug       In case of a cfi violation, a message containing the line that
17989e62ba48SDaniele Buono                  triggered the error is written to stderr. After the error,
17999e62ba48SDaniele Buono                  QEMU is still terminated with SIGILL
1800ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
180191bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
180291bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18038953caf3SDaniel P. Berrange  auth-pam        PAM access control
1804c23f23b9SMichael Tokarev  sdl             SDL UI
180504c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1806c23f23b9SMichael Tokarev  gtk             gtk UI
1807c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1808c23f23b9SMichael Tokarev  curses          curses UI
1809e08bb301SSamuel Thibault  iconv           font glyph conversion support
1810c23f23b9SMichael Tokarev  vnc             VNC UI support
1811c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1812c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1813c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1814c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1815c23f23b9SMichael Tokarev  virtfs          VirtFS
1816cece116cSMisono Tomohiro  virtiofsd       build virtiofs daemon (virtiofsd)
18175c53015aSPaolo Bonzini  libudev         Use libudev to enumerate host devices
1818fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1819c23f23b9SMichael Tokarev  xen             xen backend driver support
182070c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1821c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1822c23f23b9SMichael Tokarev  curl            curl connectivity
1823a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1824c23f23b9SMichael Tokarev  fdt             fdt device tree
1825c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1826b0cb0a66SVincent Palatin  hax             HAX acceleration support
1827c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1828d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
182921ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
183021ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1831c23f23b9SMichael Tokarev  vde             support for vde network
1832c23f23b9SMichael Tokarev  netmap          support for netmap network
1833c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1834c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1835c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1836c23f23b9SMichael Tokarev  attr            attr and xattr support
1837299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1838299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1839299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1840299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1841299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1842299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1843bc15e44cSStefan Hajnoczi  vhost-user-blk-server    vhost-user-blk server support
1844108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
1845c23f23b9SMichael Tokarev  spice           spice
1846c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1847c23f23b9SMichael Tokarev  libiscsi        iscsi support
1848c23f23b9SMichael Tokarev  libnfs          nfs support
18497b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
18500a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1851c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1852ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1853c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1854c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1855c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1856c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1857c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
185883bc1f97SJulio Faracco  lzfse           support of lzfse compression library
185983bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
18603a678481SJuan Quintela  zstd            support for zstd compression library
1861d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1862c23f23b9SMichael Tokarev  seccomp         seccomp support
1863c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1864c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1865c23f23b9SMichael Tokarev  tpm             TPM support
1866b10d49d7SPino Toscano  libssh          ssh block device support
1867c23f23b9SMichael Tokarev  numa            libnuma support
1868ed279a06SKlim Kireev  libxml2         for Parallels image format
1869c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
18707b01cb97SAlexandre Derumier  jemalloc        jemalloc support
187186583a07SLiam Merwick  avx2            AVX2 optimization support
18726b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1873a6b1d4c0SChanglong Xie  replication     replication support
1874c12d66aaSLin Ma  opengl          opengl support
1875c12d66aaSLin Ma  virglrenderer   virgl rendering support
1876c12d66aaSLin Ma  xfsctl          xfsctl support
1877c12d66aaSLin Ma  qom-cast-debug  cast debugging support
18788de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
18792f740136SJeff Cody  bochs           bochs image format support
18802f740136SJeff Cody  cloop           cloop image format support
18812f740136SJeff Cody  dmg             dmg image format support
18822f740136SJeff Cody  qcow1           qcow v1 image format support
18832f740136SJeff Cody  vdi             vdi image format support
18842f740136SJeff Cody  vvfat           vvfat image format support
18852f740136SJeff Cody  qed             qed image format support
18862f740136SJeff Cody  parallels       parallels image format support
1887e1c42697SDaniel P. Berrangé  sheepdog        sheepdog block driver support (deprecated)
1888f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
18898ca80760SRichard Henderson  capstone        capstone disassembler support
1890ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
189117824406SJunyan He  libpmem         libpmem support
189275411919SJames Le Cuirot  xkbcommon       xkbcommon support
1893b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
189421b2eca6SJingqi Liu  libdaxctl       libdaxctl support
1895a484a719SMax Reitz  fuse            FUSE block device export
1896df4ea709SMax Reitz  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
189708fb77edSStefan Weil
189808fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1899af5db58eSpbrookEOF
19002d2ad6d0SFam Zhengexit 0
1901af5db58eSpbrookfi
1902af5db58eSpbrook
19039c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1904bb768f71SThomas Huthrm -f */config-devices.mak.d
19059c790242SThomas Huth
1906faf44142SDaniel P. Berrangéif test -z "$python"
1907faf44142SDaniel P. Berrangéthen
1908c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1909c53eeaf7SStefan Hajnoczifi
19108e2c76bdSRoman Bolshakovif ! has "$make"
19118e2c76bdSRoman Bolshakovthen
19128e2c76bdSRoman Bolshakov    error_exit "GNU make ($make) not found"
19138e2c76bdSRoman Bolshakovfi
1914c53eeaf7SStefan Hajnoczi
1915c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1916c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
19171b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
19181b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1919c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1920c53eeaf7SStefan Hajnoczifi
1921c53eeaf7SStefan Hajnoczi
1922755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1923406ab2f3SCleber 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)
1924755ee70fSCleber Rosa
1925c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1926c53eeaf7SStefan Hajnoczipython="$python -B"
1927c53eeaf7SStefan Hajnoczi
19280a01d76fSMarc-André Lureauif test -z "$meson"; then
19296ebd89cfSPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
19300a01d76fSMarc-André Lureau        meson=meson
19310a01d76fSMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
19320a01d76fSMarc-André Lureau        meson=git
19330a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
19340a01d76fSMarc-André Lureau        meson=internal
19350a01d76fSMarc-André Lureau    else
19360a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
19370a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
19380a01d76fSMarc-André Lureau        else
1939a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1940a5665051SPaolo Bonzini        fi
19410a01d76fSMarc-André Lureau    fi
19420a01d76fSMarc-André Lureauelse
19430a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
19440a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
19450a01d76fSMarc-André Lureau    #
19460a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
19470a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
19480a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
19490a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
19500a01d76fSMarc-André Lureau        case "$meson" in
19510a01d76fSMarc-André Lureau            git | internal) ;;
19520a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
19530a01d76fSMarc-André Lureau        esac
19540a01d76fSMarc-André Lureau    fi
19550a01d76fSMarc-André Lureaufi
1956a5665051SPaolo Bonzini
19570a01d76fSMarc-André Lureauif test "$meson" = git; then
19580a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
19590a01d76fSMarc-André Lureaufi
19600a01d76fSMarc-André Lureau
19610a01d76fSMarc-André Lureaucase "$meson" in
19620a01d76fSMarc-André Lureau    git | internal)
19630a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
19640a01d76fSMarc-André Lureau        ;;
196584ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
19660a01d76fSMarc-André Lureauesac
19670a01d76fSMarc-André Lureau
196809e93326SPaolo Bonzini# Probe for ninja
196948328880SPaolo Bonzini
197048328880SPaolo Bonziniif test -z "$ninja"; then
197148328880SPaolo Bonzini    for c in ninja ninja-build samu; do
197248328880SPaolo Bonzini        if has $c; then
197348328880SPaolo Bonzini            ninja=$(command -v "$c")
197448328880SPaolo Bonzini            break
197548328880SPaolo Bonzini        fi
197648328880SPaolo Bonzini    done
197709e93326SPaolo Bonzini    if test -z "$ninja"; then
197809e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
197909e93326SPaolo Bonzini    fi
198048328880SPaolo Bonzinifi
1981a5665051SPaolo Bonzini
19829aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
19839aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
19849aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
19859aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
19869aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
19879aae6e54SDaniel Henrique Barbozaif compile_object ; then
19889aae6e54SDaniel Henrique Barboza  : C compiler works ok
19899aae6e54SDaniel Henrique Barbozaelse
19909aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
19919aae6e54SDaniel Henrique Barbozafi
19929aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
19939aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
19949aae6e54SDaniel Henrique Barbozafi
19959aae6e54SDaniel Henrique Barboza
19969c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
19979c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
19989c83ffd8SPeter Maydellif test -z "$werror" ; then
1999fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
2000e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20019c83ffd8SPeter Maydell        werror="yes"
20029c83ffd8SPeter Maydell    else
20039c83ffd8SPeter Maydell        werror="no"
20049c83ffd8SPeter Maydell    fi
20059c83ffd8SPeter Maydellfi
20069c83ffd8SPeter Maydell
2007975ff037SPaolo Bonziniif test "$targetos" = "bogus"; then
2008fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2009fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2010fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2011fb59dabdSPeter Maydell    # host OS we should stop now.
2012951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2013fb59dabdSPeter Maydellfi
2014fb59dabdSPeter Maydell
2015efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2016efc6c070SThomas Huthcat > $TMPC << EOF
2017efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2018efc6c070SThomas Huth# ifdef __apple_build_version__
2019efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
2020efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
2021efc6c070SThomas Huth#  endif
2022efc6c070SThomas Huth# else
2023efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
2024efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
2025efc6c070SThomas Huth#  endif
2026efc6c070SThomas Huth# endif
2027efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2028efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
2029efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
2030efc6c070SThomas Huth# endif
2031efc6c070SThomas Huth#else
2032efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2033efc6c070SThomas Huth#endif
2034efc6c070SThomas Huthint main (void) { return 0; }
2035efc6c070SThomas HuthEOF
2036efc6c070SThomas Huthif ! compile_prog "" "" ; then
2037efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2038efc6c070SThomas Huthfi
2039efc6c070SThomas Huth
204000849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
204100849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
204200849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
204300849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
204400849b92SRichard Henderson# just silently disable some features, so it's too error prone.
204500849b92SRichard Henderson
204600849b92SRichard Hendersonwarn_flags=
204700849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
204800849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
204900849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
205000849b92SRichard Hendersonadd_to warn_flags -Wformat-security
205100849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
205200849b92SRichard Hendersonadd_to warn_flags -Winit-self
205300849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
205400849b92SRichard Hendersonadd_to warn_flags -Wempty-body
205500849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
205600849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
205700849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
20580a2ebce9SThomas Huthadd_to warn_flags -Wimplicit-fallthrough=2
205900849b92SRichard Henderson
206000849b92SRichard Hendersonnowarn_flags=
206100849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
206200849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
206300849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
206400849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
206500849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2066aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2067bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
206800849b92SRichard Henderson
206900849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
207093b25869SJohn Snow
207193b25869SJohn Snowcc_has_warning_flag() {
207293b25869SJohn Snow    write_c_skeleton;
207393b25869SJohn Snow
2074a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2075a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2076a1d29d6cSPeter Maydell    # warning options).
207793b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
207893b25869SJohn Snow    compile_prog "-Werror $optflag" ""
207993b25869SJohn Snow}
208093b25869SJohn Snow
208193b25869SJohn Snowfor flag in $gcc_flags; do
208293b25869SJohn Snow    if cc_has_warning_flag $flag ; then
20838d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
20848d05095cSPaolo Bonzini    fi
20858d05095cSPaolo Bonzinidone
20868d05095cSPaolo Bonzini
208763678e17SSteven Noonanif test "$stack_protector" != "no"; then
2088fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2089fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2090fccd35a0SRodrigo Rebello{
2091fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2092fccd35a0SRodrigo Rebello    while (*c) {
2093fccd35a0SRodrigo Rebello        *p++ = *c++;
2094fccd35a0SRodrigo Rebello    }
2095fccd35a0SRodrigo Rebello    return 0;
2096fccd35a0SRodrigo Rebello}
2097fccd35a0SRodrigo RebelloEOF
209863678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
20993b463a3fSMiroslav Rezanina  sp_on=0
210063678e17SSteven Noonan  for flag in $gcc_flags; do
2101590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2102590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2103086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2104590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
210563678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2106db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21073b463a3fSMiroslav Rezanina      sp_on=1
210863678e17SSteven Noonan      break
210963678e17SSteven Noonan    fi
211063678e17SSteven Noonan  done
21113b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
21123b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
21133b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
21143b463a3fSMiroslav Rezanina    fi
21153b463a3fSMiroslav Rezanina  fi
211637746c5eSMarc-André Lureaufi
211737746c5eSMarc-André Lureau
211820bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
211920bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
212020bc94a2SPaolo Bonzinicat > $TMPC << EOF
212120bc94a2SPaolo Bonzinistruct {
212220bc94a2SPaolo Bonzini  int a[2];
212320bc94a2SPaolo Bonzini} x = {0};
212420bc94a2SPaolo BonziniEOF
212520bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
212620bc94a2SPaolo Bonzini  :
212720bc94a2SPaolo Bonzinielse
212820bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
212920bc94a2SPaolo Bonzinifi
213020bc94a2SPaolo Bonzini
213121e709aaSMarc-André Lureau# Our module code doesn't support Windows
213221e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
213321e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
213421e709aaSMarc-André Lureaufi
213521e709aaSMarc-André Lureau
2136bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2137bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2138bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2139bd83c861SChristian Ehrhardtfi
2140bd83c861SChristian Ehrhardt
2141d376e9deSThomas Huth# Static linking is not possible with modules or PIE
214240d6444eSAvi Kivityif test "$static" = "yes" ; then
2143aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2144aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2145aa0d1f44SPaolo Bonzini  fi
214640d6444eSAvi Kivityfi
214740d6444eSAvi Kivity
2148768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2149768b7855SEmilio G. Cota  cat > $TMPC << EOF
2150768b7855SEmilio G. Cotastatic __thread int tls_var;
2151768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2152768b7855SEmilio G. CotaEOF
2153768b7855SEmilio G. Cota
2154768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2155768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2156768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2157768b7855SEmilio G. Cotafi
2158768b7855SEmilio G. Cota
215940d6444eSAvi Kivitycat > $TMPC << EOF
216021d4a791SAvi Kivity
216121d4a791SAvi Kivity#ifdef __linux__
216221d4a791SAvi Kivity#  define THREAD __thread
216321d4a791SAvi Kivity#else
216421d4a791SAvi Kivity#  define THREAD
216521d4a791SAvi Kivity#endif
216621d4a791SAvi Kivitystatic THREAD int tls_var;
216721d4a791SAvi Kivityint main(void) { return tls_var; }
216840d6444eSAvi KivityEOF
2169b2634124SRichard Henderson
2170b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2171412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2172412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2173412aeacdSAlex Bennéefi
2174412aeacdSAlex Bennée
217512781462SRichard Hendersonif test "$static" = "yes"; then
2176eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
21775770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
217812781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
217912781462SRichard Henderson    pie="yes"
218012781462SRichard Henderson  elif test "$pie" = "yes"; then
218112781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
218212781462SRichard Henderson  else
218312781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
218412781462SRichard Henderson    pie="no"
218512781462SRichard Henderson  fi
218612781462SRichard Hendersonelif test "$pie" = "no"; then
21875770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
2188eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
21895770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
21905770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
219140d6444eSAvi Kivity  pie="yes"
21922c674109SRichard Hendersonelif test "$pie" = "yes"; then
219376ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
219440d6444eSAvi Kivityelse
219540d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
219640d6444eSAvi Kivity  pie="no"
219740d6444eSAvi Kivityfi
219840d6444eSAvi Kivity
2199e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2200e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2201e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2202e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2203e6cbd751SRichard Hendersonfi
2204e6cbd751SRichard Henderson
220509dada40SPaolo Bonzini##########################################
220609dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
220709dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
220809dada40SPaolo Bonzini# specification is necessary
220909dada40SPaolo Bonzini
221009dada40SPaolo Bonziniif test "$cpu" = "i386"; then
221109dada40SPaolo Bonzini  cat > $TMPC << EOF
221209dada40SPaolo Bonzinistatic int sfaa(int *ptr)
221309dada40SPaolo Bonzini{
221409dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
221509dada40SPaolo Bonzini}
221609dada40SPaolo Bonzini
221709dada40SPaolo Bonziniint main(void)
221809dada40SPaolo Bonzini{
221909dada40SPaolo Bonzini  int val = 42;
22201405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
222109dada40SPaolo Bonzini  sfaa(&val);
222209dada40SPaolo Bonzini  return val;
222309dada40SPaolo Bonzini}
222409dada40SPaolo BonziniEOF
222509dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
222609dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
222709dada40SPaolo Bonzini  fi
222809dada40SPaolo Bonzinifi
222909dada40SPaolo Bonzini
223009dada40SPaolo Bonzini#########################################
2231ec530c81Sbellard# Solaris specific configure tool chain decisions
223209dada40SPaolo Bonzini
2233ec530c81Sbellardif test "$solaris" = "yes" ; then
22346792aa11SLoïc Minier  if has ar; then
22356792aa11SLoïc Minier    :
22366792aa11SLoïc Minier  else
2237ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
223876ad07a4SPeter Maydell      error_exit "No path includes ar" \
223976ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2240ec530c81Sbellard    fi
224176ad07a4SPeter Maydell    error_exit "No path includes ar"
2242ec530c81Sbellard  fi
2243ec530c81Sbellardfi
2244ec530c81Sbellard
2245afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2246fdb75aefSPaolo Bonzini    default_targets=yes
2247d880a3baSPaolo Bonzini    for target in $default_target_list; do
2248d880a3baSPaolo Bonzini        target_list="$target_list $target"
2249d880a3baSPaolo Bonzini    done
2250d880a3baSPaolo Bonzini    target_list="${target_list# }"
2251121afa9eSAnthony Liguorielse
2252fdb75aefSPaolo Bonzini    default_targets=no
225389138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2254d880a3baSPaolo Bonzini    for target in $target_list; do
225525b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
225625b48338SPeter Maydell        # friendly error message than if we let it fall through.
225725b48338SPeter Maydell        case " $default_target_list " in
225825b48338SPeter Maydell            *" $target "*)
225925b48338SPeter Maydell                ;;
226025b48338SPeter Maydell            *)
226125b48338SPeter Maydell                error_exit "Unknown target name '$target'"
226225b48338SPeter Maydell                ;;
226325b48338SPeter Maydell        esac
226425b48338SPeter Maydell    done
2265d880a3baSPaolo Bonzinifi
226625b48338SPeter Maydell
2267fdb75aefSPaolo Bonzinifor target in $target_list; do
2268fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
2269fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
2270fdb75aefSPaolo Bonzini        add_to deprecated_features $target
2271fdb75aefSPaolo Bonzini    fi
2272fdb75aefSPaolo Bonzinidone
2273fdb75aefSPaolo Bonzini
2274f55fe278SPaolo Bonzini# see if system emulation was really requested
2275f55fe278SPaolo Bonzinicase " $target_list " in
2276f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2277f55fe278SPaolo Bonzini  ;;
2278f55fe278SPaolo Bonzini  *) softmmu=no
2279f55fe278SPaolo Bonzini  ;;
2280f55fe278SPaolo Bonziniesac
22815327cf48Sbellard
2282249247c9SJuan Quintelafeature_not_found() {
2283249247c9SJuan Quintela  feature=$1
228421684af0SStewart Smith  remedy=$2
2285249247c9SJuan Quintela
228676ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
228721684af0SStewart Smith      "configure was not able to find it." \
228821684af0SStewart Smith      "$remedy"
2289249247c9SJuan Quintela}
2290249247c9SJuan Quintela
22917d13299dSbellard# ---
22927d13299dSbellard# big/little endian test
22937d13299dSbellardcat > $TMPC << EOF
229461cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
229561cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
229661cc919fSMike Frysingerextern int foo(short *, short *);
229761cc919fSMike Frysingerint main(int argc, char *argv[]) {
229861cc919fSMike Frysinger    return foo(big_endian, little_endian);
22997d13299dSbellard}
23007d13299dSbellardEOF
23017d13299dSbellard
230261cc919fSMike Frysingerif compile_object ; then
230312f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
230461cc919fSMike Frysinger        bigendian="yes"
230512f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
230661cc919fSMike Frysinger        bigendian="no"
23077d13299dSbellard    else
23087d13299dSbellard        echo big/little test failed
23097d13299dSbellard    fi
23107d13299dSbellardelse
231161cc919fSMike Frysinger    echo big/little test failed
23127d13299dSbellardfi
23137d13299dSbellard
2314b0a47e79SJuan Quintela##########################################
2315e10ee3f5SPhilippe Mathieu-Daudé# system tools
2316e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2317e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2318e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2319e10ee3f5SPhilippe Mathieu-Daudé    else
2320e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2321e10ee3f5SPhilippe Mathieu-Daudé    fi
2322e10ee3f5SPhilippe Mathieu-Daudéfi
2323e10ee3f5SPhilippe Mathieu-Daudé
2324e10ee3f5SPhilippe Mathieu-Daudé##########################################
232590520ee4SPhilippe Mathieu-Daudé# Disable features only meaningful for system-mode emulation
232690520ee4SPhilippe Mathieu-Daudéif test "$softmmu" = "no"; then
232790520ee4SPhilippe Mathieu-Daudé    audio_drv_list=""
232890520ee4SPhilippe Mathieu-Daudéfi
232990520ee4SPhilippe Mathieu-Daudé
233090520ee4SPhilippe Mathieu-Daudé##########################################
23316b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
23326b39b063SEric Blakecat > $TMPC << EOF
23336b39b063SEric Blake#include <stdint.h>
23346b39b063SEric Blake#include <stdio.h>
23356b39b063SEric Blakeint main(int argc, char *argv[]) {
23366b39b063SEric Blake    return printf("%zu", SIZE_MAX);
23376b39b063SEric Blake}
23386b39b063SEric BlakeEOF
23396b39b063SEric Blakehave_broken_size_max=no
23406b39b063SEric Blakeif ! compile_object -Werror ; then
23416b39b063SEric Blake    have_broken_size_max=yes
23426b39b063SEric Blakefi
23436b39b063SEric Blake
2344a30878e7SPeter Maydell##########################################
2345015a33bdSGonglei# L2TPV3 probe
2346015a33bdSGonglei
2347015a33bdSGongleicat > $TMPC <<EOF
2348015a33bdSGonglei#include <sys/socket.h>
2349bff6cb72SMichael Tokarev#include <linux/ip.h>
2350015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2351015a33bdSGongleiEOF
2352015a33bdSGongleiif compile_prog "" "" ; then
2353015a33bdSGonglei  l2tpv3=yes
2354015a33bdSGongleielse
2355015a33bdSGonglei  l2tpv3=no
2356015a33bdSGongleifi
2357015a33bdSGonglei
2358195588ccSDavid CARLIERcat > $TMPC <<EOF
2359195588ccSDavid CARLIER#include <sys/mman.h>
2360195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2361195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2362195588ccSDavid CARLIER}
2363195588ccSDavid CARLIEREOF
2364195588ccSDavid CARLIERif compile_prog "" "" ; then
2365195588ccSDavid CARLIER  have_mlockall=yes
2366195588ccSDavid CARLIERelse
2367195588ccSDavid CARLIER  have_mlockall=no
2368195588ccSDavid CARLIERfi
2369195588ccSDavid CARLIER
2370299e6f19SPaolo Bonzini#########################################
2371299e6f19SPaolo Bonzini# vhost interdependencies and host support
2372299e6f19SPaolo Bonzini
2373299e6f19SPaolo Bonzini# vhost backends
2374d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2375d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
2376299e6f19SPaolo Bonzinifi
2377108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2378108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2379108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2380108a6481SCindy Lufi
2381299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2382299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2383299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2384299e6f19SPaolo Bonzinifi
2385299e6f19SPaolo Bonzini
2386299e6f19SPaolo Bonzini# vhost-kernel devices
2387299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2388299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2389299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2390299e6f19SPaolo Bonzinifi
2391299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2392299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2393299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2394299e6f19SPaolo Bonzinifi
2395299e6f19SPaolo Bonzini
2396299e6f19SPaolo Bonzini# vhost-user backends
2397299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2398299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2399299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2400299e6f19SPaolo Bonzinifi
2401299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2402299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2403299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2404299e6f19SPaolo Bonzinifi
240598fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
240698fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
240798fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
240898fc1adaSDr. David Alan Gilbertfi
2409108a6481SCindy Lu#vhost-vdpa backends
2410108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2411108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2412108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2413108a6481SCindy Lufi
2414299e6f19SPaolo Bonzini
241540bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
2416299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2417299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
241840bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
2419299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2420299e6f19SPaolo Bonzinifi
2421299e6f19SPaolo Bonzini
2422015a33bdSGonglei##########################################
2423779ab5e3SStefan Weil# pkg-config probe
2424779ab5e3SStefan Weil
2425779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
242676ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2427779ab5e3SStefan Weilfi
2428779ab5e3SStefan Weil
2429779ab5e3SStefan Weil##########################################
2430b0a47e79SJuan Quintela# NPTL probe
2431b0a47e79SJuan Quintela
243224cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2433bd0c5661Spbrook  cat > $TMPC <<EOF
2434bd0c5661Spbrook#include <sched.h>
243530813ceaSpbrook#include <linux/futex.h>
2436182eacc0SStefan Weilint main(void) {
2437bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2438bd0c5661Spbrook#error bork
2439bd0c5661Spbrook#endif
2440182eacc0SStefan Weil  return 0;
2441bd0c5661Spbrook}
2442bd0c5661SpbrookEOF
244324cb36a6SPeter Maydell  if ! compile_object ; then
244421684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2445b0a47e79SJuan Quintela  fi
2446bd0c5661Spbrookfi
2447bd0c5661Spbrook
2448ac62922eSbalrog##########################################
2449e37630caSaliguori# xen probe
2450e37630caSaliguori
24511badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
2452c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2453c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2454c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2455c1cdd9d5SJuergen Gross
2456c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2457c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2458c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2459c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
24601badb709SPaolo Bonzini    xen=enabled
24615b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2462c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
246358ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
246458ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
246558ea9a7aSAnthony PERARD    fi
2466582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2467582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2468c1cdd9d5SJuergen Gross  else
2469c1cdd9d5SJuergen Gross
24705b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
2471d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2472d5b93ddfSAnthony PERARD
247350ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
247450ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
247550ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
247650ced5b3SStefan Weil
247750ced5b3SStefan Weil    # Xen (any)
247850ced5b3SStefan Weil    cat > $TMPC <<EOF
247950ced5b3SStefan Weil#include <xenctrl.h>
248050ced5b3SStefan Weilint main(void) {
248150ced5b3SStefan Weil  return 0;
248250ced5b3SStefan Weil}
248350ced5b3SStefan WeilEOF
248450ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
248550ced5b3SStefan Weil      # Xen not found
24861badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
248721684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
248850ced5b3SStefan Weil      fi
24891badb709SPaolo Bonzini      xen=disabled
249050ced5b3SStefan Weil
2491d5b93ddfSAnthony PERARD    # Xen unstable
249269deef08SPeter Maydell    elif
249369deef08SPeter Maydell        cat > $TMPC <<EOF &&
24942cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
24952cbf8903SRoss Lagerwall#define __XEN_TOOLS__
24962cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2497d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
24982cbf8903SRoss Lagerwallint main(void) {
24992cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2500d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
25012cbf8903SRoss Lagerwall
25022cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
25032cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
25042cbf8903SRoss Lagerwall
2505d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2506d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2507d3c49ebbSPaul Durrant
25082cbf8903SRoss Lagerwall  return 0;
25092cbf8903SRoss Lagerwall}
25102cbf8903SRoss LagerwallEOF
25112cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25122cbf8903SRoss Lagerwall      then
25132cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25142cbf8903SRoss Lagerwall      xen_ctrl_version=41100
25151badb709SPaolo Bonzini      xen=enabled
25162cbf8903SRoss Lagerwall    elif
25172cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
25185ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
25195ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
252058ea9a7aSAnthony PERARD#include <xentoolcore.h>
25215ba3d756SIgor Druzhininint main(void) {
25225ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
25235ba3d756SIgor Druzhinin
25245ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
25255ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
252658ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
25275ba3d756SIgor Druzhinin
25285ba3d756SIgor Druzhinin  return 0;
25295ba3d756SIgor Druzhinin}
25305ba3d756SIgor DruzhininEOF
253158ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
25325ba3d756SIgor Druzhinin      then
253358ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
25345ba3d756SIgor Druzhinin      xen_ctrl_version=41000
25351badb709SPaolo Bonzini      xen=enabled
25365ba3d756SIgor Druzhinin    elif
25375ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2538da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2539da8090ccSPaul Durrant#define __XEN_TOOLS__
2540da8090ccSPaul Durrant#include <xendevicemodel.h>
2541da8090ccSPaul Durrantint main(void) {
2542da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2543da8090ccSPaul Durrant
2544da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2545da8090ccSPaul Durrant  xendevicemodel_close(xd);
2546da8090ccSPaul Durrant
2547da8090ccSPaul Durrant  return 0;
2548da8090ccSPaul Durrant}
2549da8090ccSPaul DurrantEOF
2550da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2551da8090ccSPaul Durrant      then
2552da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2553f1167ee6SJuergen Gross      xen_ctrl_version=40900
25541badb709SPaolo Bonzini      xen=enabled
2555da8090ccSPaul Durrant    elif
2556da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
25575eeb39c2SIan Campbell/*
25585eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
25595eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2560b6eb9b45SPaulina Szubarczyk *
2561b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2562b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2563b6eb9b45SPaulina Szubarczyk */
2564b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2565b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2566b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2567b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2568b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2569b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2570b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2571b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2572b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2573b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2574b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2575b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2576b6eb9b45SPaulina Szubarczyk#endif
2577b6eb9b45SPaulina Szubarczykint main(void) {
2578b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2579b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2580b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2581b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2582b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2583b6eb9b45SPaulina Szubarczyk
2584b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2585b6eb9b45SPaulina Szubarczyk
2586b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2587b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2588b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2589b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2590b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2591b6eb9b45SPaulina Szubarczyk
2592b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2593b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2594b6eb9b45SPaulina Szubarczyk
2595b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2596b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2597b6eb9b45SPaulina Szubarczyk
2598b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2599b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2600b6eb9b45SPaulina Szubarczyk
2601b6eb9b45SPaulina Szubarczyk  return 0;
2602b6eb9b45SPaulina Szubarczyk}
2603b6eb9b45SPaulina SzubarczykEOF
2604b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2605b6eb9b45SPaulina Szubarczyk      then
2606f1167ee6SJuergen Gross      xen_ctrl_version=40800
26071badb709SPaolo Bonzini      xen=enabled
2608b6eb9b45SPaulina Szubarczyk    elif
2609b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2610b6eb9b45SPaulina Szubarczyk/*
2611b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2612b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
26135eeb39c2SIan Campbell */
26145eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
26155eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
26165eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
26175eeb39c2SIan Campbell#include <xenctrl.h>
26185eeb39c2SIan Campbell#include <xenstore.h>
26195eeb39c2SIan Campbell#include <xenevtchn.h>
26205eeb39c2SIan Campbell#include <xengnttab.h>
26215eeb39c2SIan Campbell#include <xenforeignmemory.h>
26225eeb39c2SIan Campbell#include <stdint.h>
26235eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
26245eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
26255eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
26265eeb39c2SIan Campbell#endif
26275eeb39c2SIan Campbellint main(void) {
26285eeb39c2SIan Campbell  xc_interface *xc = NULL;
26295eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
26305eeb39c2SIan Campbell  xenevtchn_handle *xe;
26315eeb39c2SIan Campbell  xengnttab_handle *xg;
26325eeb39c2SIan Campbell
26335eeb39c2SIan Campbell  xs_daemon_open();
26345eeb39c2SIan Campbell
26355eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
26365eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
26375eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26385eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
26395eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
26405eeb39c2SIan Campbell
26415eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
26425eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
26435eeb39c2SIan Campbell
26445eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
26455eeb39c2SIan Campbell  xenevtchn_fd(xe);
26465eeb39c2SIan Campbell
26475eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
26485eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
26495eeb39c2SIan Campbell
26505eeb39c2SIan Campbell  return 0;
26515eeb39c2SIan Campbell}
26525eeb39c2SIan CampbellEOF
26535eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
26545eeb39c2SIan Campbell      then
2655f1167ee6SJuergen Gross      xen_ctrl_version=40701
26561badb709SPaolo Bonzini      xen=enabled
2657cdadde39SRoger Pau Monne
2658cdadde39SRoger Pau Monne    # Xen 4.6
2659cdadde39SRoger Pau Monne    elif
2660cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2661cdadde39SRoger Pau Monne#include <xenctrl.h>
2662e108a3c1SAnthony PERARD#include <xenstore.h>
2663d5b93ddfSAnthony PERARD#include <stdint.h>
2664d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2665d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2666d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2667d5b93ddfSAnthony PERARD#endif
2668d5b93ddfSAnthony PERARDint main(void) {
2669d5b93ddfSAnthony PERARD  xc_interface *xc;
2670d5b93ddfSAnthony PERARD  xs_daemon_open();
2671d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2672d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2673d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2674b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
26758688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2676d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
267720a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2678d8b441a3SJan Beulich  return 0;
2679d8b441a3SJan Beulich}
2680d8b441a3SJan BeulichEOF
2681d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2682d8b441a3SJan Beulich      then
2683f1167ee6SJuergen Gross      xen_ctrl_version=40600
26841badb709SPaolo Bonzini      xen=enabled
2685d8b441a3SJan Beulich
2686d8b441a3SJan Beulich    # Xen 4.5
2687d8b441a3SJan Beulich    elif
2688d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2689d8b441a3SJan Beulich#include <xenctrl.h>
2690d8b441a3SJan Beulich#include <xenstore.h>
2691d8b441a3SJan Beulich#include <stdint.h>
2692d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2693d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2694d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2695d8b441a3SJan Beulich#endif
2696d8b441a3SJan Beulichint main(void) {
2697d8b441a3SJan Beulich  xc_interface *xc;
2698d8b441a3SJan Beulich  xs_daemon_open();
2699d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2700d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2701d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2702d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2703d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27043996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
27053996e85cSPaul Durrant  return 0;
27063996e85cSPaul Durrant}
27073996e85cSPaul DurrantEOF
27083996e85cSPaul Durrant        compile_prog "" "$xen_libs"
27093996e85cSPaul Durrant      then
2710f1167ee6SJuergen Gross      xen_ctrl_version=40500
27111badb709SPaolo Bonzini      xen=enabled
27123996e85cSPaul Durrant
27133996e85cSPaul Durrant    elif
27143996e85cSPaul Durrant        cat > $TMPC <<EOF &&
27153996e85cSPaul Durrant#include <xenctrl.h>
27163996e85cSPaul Durrant#include <xenstore.h>
27173996e85cSPaul Durrant#include <stdint.h>
27183996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
27193996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
27203996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
27213996e85cSPaul Durrant#endif
27223996e85cSPaul Durrantint main(void) {
27233996e85cSPaul Durrant  xc_interface *xc;
27243996e85cSPaul Durrant  xs_daemon_open();
27253996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
27263996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27273996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
27283996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27293996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27308688e065SStefano Stabellini  return 0;
27318688e065SStefano Stabellini}
27328688e065SStefano StabelliniEOF
27338688e065SStefano Stabellini        compile_prog "" "$xen_libs"
273469deef08SPeter Maydell      then
2735f1167ee6SJuergen Gross      xen_ctrl_version=40200
27361badb709SPaolo Bonzini      xen=enabled
27378688e065SStefano Stabellini
2738e37630caSaliguori    else
27391badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2740edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2741edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2742fc321b4bSJuan Quintela      fi
27431badb709SPaolo Bonzini      xen=disabled
2744e37630caSaliguori    fi
2745d5b93ddfSAnthony PERARD
27461badb709SPaolo Bonzini    if test "$xen" = enabled; then
2747f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2748582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
27495eeb39c2SIan Campbell      fi
2750d5b93ddfSAnthony PERARD    fi
2751e37630caSaliguori  fi
2752c1cdd9d5SJuergen Grossfi
2753e37630caSaliguori
2754d661d9a4SJustin Terry (VM)##########################################
2755ddbb0d09SDaniel P. Berrange# GNUTLS probe
2756ddbb0d09SDaniel P. Berrange
2757ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
2758a73e82efSRichard Henderson    pass="no"
2759a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
276089138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
276189138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2762a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
2763a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
2764a73e82efSRichard Henderson        write_c_skeleton
2765a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
2766a73e82efSRichard Henderson            pass="yes"
2767a73e82efSRichard Henderson        fi
2768a73e82efSRichard Henderson    fi
2769a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
2770a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2771ddbb0d09SDaniel P. Berrange    else
2772a73e82efSRichard Henderson        gnutls="$pass"
2773ddbb0d09SDaniel P. Berrange    fi
2774ddbb0d09SDaniel P. Berrangefi
2775ddbb0d09SDaniel P. Berrange
277691bfcdb0SDaniel P. Berrange
277791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
277891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
2779a0722409SDaniel P. Berrangé# explicitly
278091bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
278191bfcdb0SDaniel P. Berrangethen
2782a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
278391bfcdb0SDaniel P. Berrange    then
278491bfcdb0SDaniel P. Berrange        gcrypt="no"
278591bfcdb0SDaniel P. Berrange    fi
278691bfcdb0SDaniel P. Berrangefi
278791bfcdb0SDaniel P. Berrange
278891bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
278991bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
2790a0722409SDaniel P. Berrangé# explicitly
279191bfcdb0SDaniel P. Berrangeif test -z "$nettle"
279291bfcdb0SDaniel P. Berrangethen
2793a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
279491bfcdb0SDaniel P. Berrange    then
279591bfcdb0SDaniel P. Berrange        nettle="no"
279691bfcdb0SDaniel P. Berrange    fi
279791bfcdb0SDaniel P. Berrangefi
279891bfcdb0SDaniel P. Berrange
2799dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
280091bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
280191bfcdb0SDaniel P. Berrange    then
280291bfcdb0SDaniel P. Berrange	return 1
280391bfcdb0SDaniel P. Berrange    fi
280491bfcdb0SDaniel P. Berrange
280591bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
280691bfcdb0SDaniel P. Berrange    then
280789138857SStefan Weil	host=$(libgcrypt-config --host)
280891bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
280991bfcdb0SDaniel P. Berrange	then
281091bfcdb0SDaniel P. Berrange	    return 1
281191bfcdb0SDaniel P. Berrange	fi
281291bfcdb0SDaniel P. Berrange    fi
281391bfcdb0SDaniel P. Berrange
2814dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2815dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
2816dea7a64eSDaniel P. Berrangé
2817dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
2818dea7a64eSDaniel P. Berrangé    then
2819dea7a64eSDaniel P. Berrangé       return 1
2820dea7a64eSDaniel P. Berrangé    fi
2821dea7a64eSDaniel P. Berrangé
282291bfcdb0SDaniel P. Berrange    return 0
282391bfcdb0SDaniel P. Berrange}
282491bfcdb0SDaniel P. Berrange
2825a0722409SDaniel P. Berrangé
2826a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
2827a73e82efSRichard Henderson    pass="no"
282864dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
2829a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
2830a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
2831a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
2832a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2833a73e82efSRichard Henderson        write_c_skeleton
2834a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
2835a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
2836a0722409SDaniel P. Berrangé               gcrypt="no"
2837a0722409SDaniel P. Berrangé            fi
2838a73e82efSRichard Henderson            pass="yes"
2839a73e82efSRichard Henderson        fi
2840a73e82efSRichard Henderson    fi
2841dc2207afSDaniel P. Berrangé    if test "$pass" = "yes"
2842dc2207afSDaniel P. Berrangé    then
2843dc2207afSDaniel P. Berrangé        cat > $TMPC << EOF
2844dc2207afSDaniel P. Berrangé#include <nettle/xts.h>
2845dc2207afSDaniel P. Berrangéint main(void) {
2846dc2207afSDaniel P. Berrangé  return 0;
2847dc2207afSDaniel P. Berrangé}
2848dc2207afSDaniel P. BerrangéEOF
2849dc2207afSDaniel P. Berrangé        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2850dc2207afSDaniel P. Berrangé            nettle_xts=yes
2851dc2207afSDaniel P. Berrangé            qemu_private_xts=no
2852dc2207afSDaniel P. Berrangé        fi
2853dc2207afSDaniel P. Berrangé    fi
2854a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
285564dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
2856a0722409SDaniel P. Berrangé    else
2857a73e82efSRichard Henderson        nettle="$pass"
2858a0722409SDaniel P. Berrangé    fi
2859a0722409SDaniel P. Berrangéfi
2860a0722409SDaniel P. Berrangé
286191bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
2862a73e82efSRichard Henderson    pass="no"
2863dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
286489138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
286589138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
2866a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
286791bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
286891bfcdb0SDaniel P. Berrange        # turn breaks static builds...
286991bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
287091bfcdb0SDaniel P. Berrange        then
287191bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
287291bfcdb0SDaniel P. Berrange        fi
28731f923c70SLongpeng(Mike)
2874a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2875a73e82efSRichard Henderson        write_c_skeleton
2876a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
2877a73e82efSRichard Henderson            pass="yes"
2878a73e82efSRichard Henderson        fi
2879a73e82efSRichard Henderson    fi
2880a73e82efSRichard Henderson    if test "$pass" = "yes"; then
288137788f25SDaniel P. Berrange        gcrypt="yes"
28821f923c70SLongpeng(Mike)        cat > $TMPC << EOF
28831f923c70SLongpeng(Mike)#include <gcrypt.h>
28841f923c70SLongpeng(Mike)int main(void) {
28851f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
28861f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
28871f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
28881f923c70SLongpeng(Mike)  return 0;
28891f923c70SLongpeng(Mike)}
28901f923c70SLongpeng(Mike)EOF
28911f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
28921f923c70SLongpeng(Mike)            gcrypt_hmac=yes
28931f923c70SLongpeng(Mike)        fi
2894e0576942SDaniel P. Berrangé        cat > $TMPC << EOF
2895e0576942SDaniel P. Berrangé#include <gcrypt.h>
2896e0576942SDaniel P. Berrangéint main(void) {
2897e0576942SDaniel P. Berrangé  gcry_cipher_hd_t handle;
2898e0576942SDaniel P. Berrangé  gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
2899e0576942SDaniel P. Berrangé  return 0;
2900e0576942SDaniel P. Berrangé}
2901e0576942SDaniel P. BerrangéEOF
2902e0576942SDaniel P. Berrangé        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
2903e0576942SDaniel P. Berrangé            gcrypt_xts=yes
2904e0576942SDaniel P. Berrangé            qemu_private_xts=no
2905e0576942SDaniel P. Berrangé        fi
2906a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
2907dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
290891bfcdb0SDaniel P. Berrange    else
290991bfcdb0SDaniel P. Berrange        gcrypt="no"
291091bfcdb0SDaniel P. Berrange    fi
291162893b67SDaniel P. Berrangefi
291262893b67SDaniel P. Berrange
2913ddbb0d09SDaniel P. Berrange
291491bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
291591bfcdb0SDaniel P. Berrangethen
291691bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
291791bfcdb0SDaniel P. Berrangefi
2918ed754746SDaniel P. Berrange
29199a2fd434SDaniel P. Berrange##########################################
29209a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
29219a2fd434SDaniel P. Berrange
29229a2fd434SDaniel P. Berrangetasn1=yes
292390246037SDaniel P. Berrangetasn1_cflags=""
292490246037SDaniel P. Berrangetasn1_libs=""
29259a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
292689138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
292789138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
29289a2fd434SDaniel P. Berrangeelse
29299a2fd434SDaniel P. Berrange    tasn1=no
29309a2fd434SDaniel P. Berrangefi
29319a2fd434SDaniel P. Berrange
2932ed754746SDaniel P. Berrange
2933bbbf9bfbSStefan Weil##########################################
29348953caf3SDaniel P. Berrange# PAM probe
29358953caf3SDaniel P. Berrange
29368953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
29378953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
29388953caf3SDaniel P. Berrange#include <security/pam_appl.h>
29398953caf3SDaniel P. Berrange#include <stdio.h>
29408953caf3SDaniel P. Berrangeint main(void) {
29418953caf3SDaniel P. Berrange   const char *service_name = "qemu";
29428953caf3SDaniel P. Berrange   const char *user = "frank";
29439c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
29448953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
29459c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
29468953caf3SDaniel P. Berrange   return 0;
29478953caf3SDaniel P. Berrange}
29488953caf3SDaniel P. BerrangeEOF
29498953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
29508953caf3SDaniel P. Berrange        auth_pam=yes
29518953caf3SDaniel P. Berrange    else
29528953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
29538953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
29548953caf3SDaniel P. Berrange        else
29558953caf3SDaniel P. Berrange            auth_pam=no
29568953caf3SDaniel P. Berrange        fi
29578953caf3SDaniel P. Berrange    fi
29588953caf3SDaniel P. Berrangefi
29598953caf3SDaniel P. Berrange
2960559607eaSDaniel P. Berrange##########################################
2961bbbf9bfbSStefan Weil# VTE probe
2962bbbf9bfbSStefan Weil
2963bbbf9bfbSStefan Weilif test "$vte" != "no"; then
2964c6feff9eSCole Robinson    vteminversion="0.32.0"
2965c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
2966c6feff9eSCole Robinson      vtepackage="vte-2.91"
2967c6feff9eSCole Robinson    else
2968528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
2969c6feff9eSCole Robinson    fi
2970c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
297189138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
297289138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
297389138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
2974bbbf9bfbSStefan Weil        vte="yes"
2975bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
2976c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
29779e04c683SStefan Weil    else
2978bbbf9bfbSStefan Weil        vte="no"
2979a4ccabcfSAnthony Liguori    fi
2980a4ccabcfSAnthony Liguorifi
2981a4ccabcfSAnthony Liguori
2982a4ccabcfSAnthony Liguori##########################################
29832da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
29842da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
29852da776dbSMichael R. Hines  cat > $TMPC <<EOF
29862da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
29872da776dbSMichael R. Hinesint main(void) { return 0; }
29882da776dbSMichael R. HinesEOF
2989ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
29902da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
29912da776dbSMichael R. Hines    rdma="yes"
29922da776dbSMichael R. Hines  else
29932da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
29942da776dbSMichael R. Hines        error_exit \
2995ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
29962da776dbSMichael R. Hines            " Your options:" \
2997ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
29982da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
29992da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
30002da776dbSMichael R. Hines    fi
30012da776dbSMichael R. Hines    rdma="no"
30022da776dbSMichael R. Hines  fi
30032da776dbSMichael R. Hinesfi
30042da776dbSMichael R. Hines
300521ab34c9SMarcel Apfelbaum##########################################
300621ab34c9SMarcel Apfelbaum# PVRDMA detection
300721ab34c9SMarcel Apfelbaum
300821ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
300921ab34c9SMarcel Apfelbaum#include <sys/mman.h>
301021ab34c9SMarcel Apfelbaum
301121ab34c9SMarcel Apfelbaumint
301221ab34c9SMarcel Apfelbaummain(void)
301321ab34c9SMarcel Apfelbaum{
301421ab34c9SMarcel Apfelbaum    char buf = 0;
301521ab34c9SMarcel Apfelbaum    void *addr = &buf;
301621ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
301721ab34c9SMarcel Apfelbaum
301821ab34c9SMarcel Apfelbaum    return 0;
301921ab34c9SMarcel Apfelbaum}
302021ab34c9SMarcel ApfelbaumEOF
302121ab34c9SMarcel Apfelbaum
302221ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
302321ab34c9SMarcel Apfelbaum    case "$pvrdma" in
302421ab34c9SMarcel Apfelbaum    "")
302521ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
302621ab34c9SMarcel Apfelbaum            pvrdma="yes"
302721ab34c9SMarcel Apfelbaum        else
302821ab34c9SMarcel Apfelbaum            pvrdma="no"
302921ab34c9SMarcel Apfelbaum        fi
303021ab34c9SMarcel Apfelbaum        ;;
303121ab34c9SMarcel Apfelbaum    "yes")
303221ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
303321ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
303421ab34c9SMarcel Apfelbaum        fi
303521ab34c9SMarcel Apfelbaum        pvrdma="yes"
303621ab34c9SMarcel Apfelbaum        ;;
303721ab34c9SMarcel Apfelbaum    "no")
303821ab34c9SMarcel Apfelbaum        pvrdma="no"
303921ab34c9SMarcel Apfelbaum        ;;
304021ab34c9SMarcel Apfelbaum    esac
304121ab34c9SMarcel Apfelbaumelse
304221ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
304321ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
304421ab34c9SMarcel Apfelbaum    fi
304521ab34c9SMarcel Apfelbaum    pvrdma="no"
304621ab34c9SMarcel Apfelbaumfi
304795c6bff3SBenoît Canet
3048ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
3049ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
3050ee108585SYuval Shaia
3051ee108585SYuval Shaiacat > $TMPC <<EOF &&
3052ee108585SYuval Shaia#include <infiniband/verbs.h>
3053ee108585SYuval Shaia
3054ee108585SYuval Shaiaint
3055ee108585SYuval Shaiamain(void)
3056ee108585SYuval Shaia{
3057ee108585SYuval Shaia    struct ibv_mr *mr;
3058ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
3059ee108585SYuval Shaia    size_t length = 10;
3060ee108585SYuval Shaia    uint64_t iova = 0;
3061ee108585SYuval Shaia    int access = 0;
3062ee108585SYuval Shaia    void *addr = NULL;
3063ee108585SYuval Shaia
3064ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3065ee108585SYuval Shaia
3066ee108585SYuval Shaia    ibv_dereg_mr(mr);
3067ee108585SYuval Shaia
3068ee108585SYuval Shaia    return 0;
3069ee108585SYuval Shaia}
3070ee108585SYuval ShaiaEOF
3071ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
3072ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3073ee108585SYuval Shaia    fi
3074ee108585SYuval Shaiafi
3075ee108585SYuval Shaia
307695c6bff3SBenoît Canet##########################################
3077c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3078dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3079dce512deSChristoph Hellwig  cat > $TMPC << EOF
3080ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3081dce512deSChristoph Hellwig#include <xfs/xfs.h>
3082dce512deSChristoph Hellwigint main(void)
3083dce512deSChristoph Hellwig{
3084dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3085dce512deSChristoph Hellwig    return 0;
3086dce512deSChristoph Hellwig}
3087dce512deSChristoph HellwigEOF
3088dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3089dce512deSChristoph Hellwig    xfs="yes"
3090dce512deSChristoph Hellwig  else
3091dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
3092e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
3093dce512deSChristoph Hellwig    fi
3094dce512deSChristoph Hellwig    xfs=no
3095dce512deSChristoph Hellwig  fi
3096dce512deSChristoph Hellwigfi
3097dce512deSChristoph Hellwig
3098dce512deSChristoph Hellwig##########################################
30998a16d273Sths# vde libraries probe
3100dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
31014baae0acSJuan Quintela  vde_libs="-lvdeplug"
31028a16d273Sths  cat > $TMPC << EOF
31038a16d273Sths#include <libvdeplug.h>
31044a7f0e06Spbrookint main(void)
31054a7f0e06Spbrook{
31064a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3107fea08e08SPeter Maydell    char s[] = "";
3108fea08e08SPeter Maydell    vde_open(s, s, &a);
31094a7f0e06Spbrook    return 0;
31104a7f0e06Spbrook}
31118a16d273SthsEOF
311252166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
31134baae0acSJuan Quintela    vde=yes
3114dfb278bdSJuan Quintela  else
3115dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
311621684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3117dfb278bdSJuan Quintela    fi
3118dfb278bdSJuan Quintela    vde=no
31198a16d273Sths  fi
31208a16d273Sthsfi
31218a16d273Sths
31228a16d273Sths##########################################
31230a985b37SVincenzo Maffione# netmap support probe
31240a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
31250a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
31260a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
31270a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
31280a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
312958952137SVincenzo Maffioneif test "$netmap" != "no" ; then
313058952137SVincenzo Maffione  cat > $TMPC << EOF
313158952137SVincenzo Maffione#include <inttypes.h>
313258952137SVincenzo Maffione#include <net/if.h>
313358952137SVincenzo Maffione#include <net/netmap.h>
313458952137SVincenzo Maffione#include <net/netmap_user.h>
31350a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
31360a985b37SVincenzo Maffione#error
31370a985b37SVincenzo Maffione#endif
313858952137SVincenzo Maffioneint main(void) { return 0; }
313958952137SVincenzo MaffioneEOF
314058952137SVincenzo Maffione  if compile_prog "" "" ; then
314158952137SVincenzo Maffione    netmap=yes
314258952137SVincenzo Maffione  else
314358952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
314458952137SVincenzo Maffione      feature_not_found "netmap"
314558952137SVincenzo Maffione    fi
314658952137SVincenzo Maffione    netmap=no
314758952137SVincenzo Maffione  fi
314858952137SVincenzo Maffionefi
314958952137SVincenzo Maffione
315058952137SVincenzo Maffione##########################################
3151c2de5c91Smalc# Sound support libraries probe
31528f28f3fbSths
315389138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3154c2de5c91Smalcfor drv in $audio_drv_list; do
3155c2de5c91Smalc    case $drv in
3156e42975a1SGerd Hoffmann    alsa | try-alsa)
3157c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3158c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3159478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
3160478e943fSPaolo Bonzini        alsa=yes
3161e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3162e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3163e42975a1SGerd Hoffmann        fi
3164e42975a1SGerd Hoffmann    else
3165e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3166e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3167c80a867fSGerd Hoffmann        else
3168c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3169c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3170c80a867fSGerd Hoffmann        fi
3171e42975a1SGerd Hoffmann    fi
3172c2de5c91Smalc    ;;
3173c2de5c91Smalc
3174e42975a1SGerd Hoffmann    pa | try-pa)
3175c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3176478e943fSPaolo Bonzini        libpulse=yes
3177c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3178478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3179e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3180e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3181e42975a1SGerd Hoffmann        fi
3182e42975a1SGerd Hoffmann    else
3183e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3184e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3185c80a867fSGerd Hoffmann        else
3186c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3187c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3188c80a867fSGerd Hoffmann        fi
3189e42975a1SGerd Hoffmann    fi
3190b8e59f18Smalc    ;;
3191b8e59f18Smalc
3192373967b2SGerd Hoffmann    sdl)
3193373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3194373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3195373967b2SGerd Hoffmann    fi
3196373967b2SGerd Hoffmann    ;;
3197373967b2SGerd Hoffmann
3198e42975a1SGerd Hoffmann    try-sdl)
3199e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3200e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3201e42975a1SGerd Hoffmann    else
3202e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3203e42975a1SGerd Hoffmann    fi
3204e42975a1SGerd Hoffmann    ;;
3205e42975a1SGerd Hoffmann
3206997e690aSJuan Quintela    coreaudio)
3207b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3208997e690aSJuan Quintela    ;;
3209997e690aSJuan Quintela
3210a4bf6780SJuan Quintela    dsound)
3211b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3212d5631638Smalc      audio_win_int="yes"
3213a4bf6780SJuan Quintela    ;;
3214a4bf6780SJuan Quintela
3215a4bf6780SJuan Quintela    oss)
3216b1149911SFam Zheng      oss_libs="$oss_lib"
3217a4bf6780SJuan Quintela    ;;
3218a4bf6780SJuan Quintela
32192e445703SGeoffrey McRae    jack | try-jack)
32202e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3221478e943fSPaolo Bonzini        libjack=yes
32222e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
32232e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
32242e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
32252e445703SGeoffrey McRae        fi
32262e445703SGeoffrey McRae    else
32272e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
32282e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
32292e445703SGeoffrey McRae        else
32302e445703SGeoffrey McRae            error_exit "$drv check failed" \
32312e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
32322e445703SGeoffrey McRae        fi
32332e445703SGeoffrey McRae    fi
32342e445703SGeoffrey McRae    ;;
32352e445703SGeoffrey McRae
3236e4c63a6aSmalc    *)
32371c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
323876ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
323976ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3240e4c63a6aSmalc    }
3241e4c63a6aSmalc    ;;
3242c2de5c91Smalc    esac
3243c2de5c91Smalcdone
32448f28f3fbSths
32454d3b6f6eSbalrog##########################################
3246e18df141SAnthony Liguori# glib support probe
3247a52d28afSPaolo Bonzini
324800f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
3249aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3250aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3251a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3252aa0d1f44SPaolo Bonzinifi
325354cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
325454cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
325554cb65d8SEmilio G. Cotafi
3256e26110cfSFam Zheng
3257aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3258e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
325989138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
326089138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
3261e18df141SAnthony Liguori    else
3262e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3263e26110cfSFam Zheng    fi
3264e26110cfSFam Zhengdone
3265e26110cfSFam Zheng
3266215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
3267215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3268215b0c2fSPaolo Bonzini
3269215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
3270215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
3271215b0c2fSPaolo Bonzinifi
3272215b0c2fSPaolo Bonzini
3273f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3274f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
3275f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
327625a97a56SMarc-André Lureau    gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
32770dba4897SMarc-André Lureau    if [ ! -x "$gdbus_codegen" ]; then
32780dba4897SMarc-André Lureau        gdbus_codegen=
32790dba4897SMarc-André Lureau    fi
328076346b62SPeter Maydell    # Check that the libraries actually work -- Ubuntu 18.04 ships
328176346b62SPeter Maydell    # with pkg-config --static --libs data for gio-2.0 that is missing
328276346b62SPeter Maydell    # -lblkid and will give a link error.
328313ceae66SPeter Maydell    cat > $TMPC <<EOF
328413ceae66SPeter Maydell#include <gio/gio.h>
328513ceae66SPeter Maydellint main(void)
328613ceae66SPeter Maydell{
328713ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
328813ceae66SPeter Maydell    return 0;
328913ceae66SPeter Maydell}
329013ceae66SPeter MaydellEOF
329113ceae66SPeter Maydell    if compile_prog "$gio_cflags" "$gio_libs" ; then
329276346b62SPeter Maydell        gio=yes
329376346b62SPeter Maydell    else
329476346b62SPeter Maydell        gio=no
329576346b62SPeter Maydell    fi
3296f876b765SMarc-André Lureauelse
3297f876b765SMarc-André Lureau    gio=no
3298f876b765SMarc-André Lureaufi
3299f876b765SMarc-André Lureau
330025a97a56SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
330125a97a56SMarc-André Lureau    gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
330225a97a56SMarc-André Lureau    gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
330325a97a56SMarc-André Lureaufi
330425a97a56SMarc-André Lureau
3305977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3306977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3307977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3308977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3309977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3310977a82abSDaniel P. Berrange#include <glib.h>
3311977a82abSDaniel P. Berrange#include <unistd.h>
3312977a82abSDaniel P. Berrange
3313977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3314977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3315977a82abSDaniel P. Berrange
3316977a82abSDaniel P. Berrangeint main(void) {
3317977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3318977a82abSDaniel P. Berrange   return 0;
3319977a82abSDaniel P. Berrange}
3320977a82abSDaniel P. BerrangeEOF
3321977a82abSDaniel P. Berrange
3322215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3323977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3324977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3325977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3326977a82abSDaniel P. Berrange	       "build target"
3327977a82abSDaniel P. Berrangefi
3328977a82abSDaniel P. Berrange
3329bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3330bbbf2e04SJohn Snowcat > $TMPC << EOF
3331bbbf2e04SJohn Snow#include <glib.h>
3332bbbf2e04SJohn Snowint main(void) { return 0; }
3333bbbf2e04SJohn SnowEOF
3334bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3335bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3336bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
33375770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="-Wno-unknown-attributes $CONFIGURE_CFLAGS"
3338bbbf2e04SJohn Snow    fi
3339bbbf2e04SJohn Snowfi
3340bbbf2e04SJohn Snow
33419bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
33429bda600bSEric Blakecat > $TMPC << EOF
33439bda600bSEric Blake#include <glib.h>
33449bda600bSEric Blaketypedef struct Foo {
33459bda600bSEric Blake    int i;
33469bda600bSEric Blake} Foo;
33479bda600bSEric Blakestatic void foo_free(Foo *f)
33489bda600bSEric Blake{
33499bda600bSEric Blake    g_free(f);
33509bda600bSEric Blake}
33519bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
33529bda600bSEric Blakeint main(void) { return 0; }
33539bda600bSEric BlakeEOF
33549bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
33559bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
33569bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
33575770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
33589bda600bSEric Blake    fi
33599bda600bSEric Blakefi
33609bda600bSEric Blake
3361e26110cfSFam Zheng##########################################
3362e26110cfSFam Zheng# SHA command probe for modules
3363e26110cfSFam Zhengif test "$modules" = yes; then
3364e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3365e26110cfSFam Zheng    for c in $shacmd_probe; do
33668ccefb91SFam Zheng        if has $c; then
3367e26110cfSFam Zheng            shacmd="$c"
3368e26110cfSFam Zheng            break
3369e26110cfSFam Zheng        fi
3370e26110cfSFam Zheng    done
3371e26110cfSFam Zheng    if test "$shacmd" = ""; then
3372e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3373e26110cfSFam Zheng    fi
3374e18df141SAnthony Liguorifi
3375e18df141SAnthony Liguori
3376e18df141SAnthony Liguori##########################################
3377e5d355d1Saliguori# pthread probe
33784b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
33793c529d93Saliguori
3380e5d355d1Saliguoripthread=no
3381414f0dabSblueswir1cat > $TMPC << EOF
33823c529d93Saliguori#include <pthread.h>
33837a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
33847a42bbe4SStefan Weilint main(void) {
33857a42bbe4SStefan Weil  pthread_t thread;
33867a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
33877a42bbe4SStefan Weil  return 0;
33887a42bbe4SStefan Weil}
3389414f0dabSblueswir1EOF
3390bd00d539SAndreas Färberif compile_prog "" "" ; then
3391bd00d539SAndreas Färber  pthread=yes
3392bd00d539SAndreas Färberelse
3393de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
339452166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3395e5d355d1Saliguori      pthread=yes
3396de65fe0fSSebastian Herbszt      break
3397414f0dabSblueswir1    fi
3398de65fe0fSSebastian Herbszt  done
3399bd00d539SAndreas Färberfi
3400414f0dabSblueswir1
3401e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
340276ad07a4SPeter Maydell  error_exit "pthread check failed" \
340376ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3404e5d355d1Saliguorifi
3405e5d355d1Saliguori
3406479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3407479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
34085c312079SDr. David Alan Gilbertcat > $TMPC << EOF
34095c312079SDr. David Alan Gilbert#include <pthread.h>
34105c312079SDr. David Alan Gilbert
34115c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
34125c312079SDr. David Alan Gilbertint main(void)
34135c312079SDr. David Alan Gilbert{
34145c312079SDr. David Alan Gilbert    pthread_t thread;
34155c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
34165c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
34175c312079SDr. David Alan Gilbert    return 0;
34185c312079SDr. David Alan Gilbert}
34195c312079SDr. David Alan GilbertEOF
34205c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3421479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3422479a5747SRoman Bolshakovfi
3423479a5747SRoman Bolshakov
3424479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3425479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3426479a5747SRoman Bolshakovcat > $TMPC << EOF
3427479a5747SRoman Bolshakov#include <pthread.h>
3428479a5747SRoman Bolshakov
342912a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3430479a5747SRoman Bolshakovint main(void)
3431479a5747SRoman Bolshakov{
3432479a5747SRoman Bolshakov    pthread_t thread;
3433479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3434479a5747SRoman Bolshakov    return 0;
3435479a5747SRoman Bolshakov}
3436479a5747SRoman BolshakovEOF
3437479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3438479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
34395c312079SDr. David Alan Gilbertfi
34405c312079SDr. David Alan Gilbert
3441bf9298b9Saliguori##########################################
3442b10d49d7SPino Toscano# libssh probe
3443b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3444b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
3445b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3446b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3447b10d49d7SPino Toscano    libssh=yes
34480a12ec87SRichard W.M. Jones  else
3449b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3450b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
34510a12ec87SRichard W.M. Jones    fi
3452b10d49d7SPino Toscano    libssh=no
34530a12ec87SRichard W.M. Jones  fi
34540a12ec87SRichard W.M. Jonesfi
34550a12ec87SRichard W.M. Jones
34560a12ec87SRichard W.M. Jones##########################################
3457b10d49d7SPino Toscano# Check for libssh 0.8
3458b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
3459b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
3460b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
3461b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
34629a2d462eSRichard W.M. Jones
3463b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
34649a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
3465b10d49d7SPino Toscano#include <libssh/libssh.h>
3466b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
34679a2d462eSRichard W.M. JonesEOF
3468b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
3469b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
34709a2d462eSRichard W.M. Jones  fi
34719a2d462eSRichard W.M. Jonesfi
34729a2d462eSRichard W.M. Jones
34739a2d462eSRichard W.M. Jones##########################################
34745c6c3a6cSChristoph Hellwig# linux-aio probe
34755c6c3a6cSChristoph Hellwig
34765c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
34775c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
34785c6c3a6cSChristoph Hellwig#include <libaio.h>
34795c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3480832ce9c2SScott Wood#include <stddef.h>
34815c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
34825c6c3a6cSChristoph HellwigEOF
34835c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
34845c6c3a6cSChristoph Hellwig    linux_aio=yes
34855c6c3a6cSChristoph Hellwig  else
34865c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
348721684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
34885c6c3a6cSChristoph Hellwig    fi
34893cfcae3cSLuiz Capitulino    linux_aio=no
34905c6c3a6cSChristoph Hellwig  fi
34915c6c3a6cSChristoph Hellwigfi
3492c10dd856SAarushi Mehta##########################################
3493c10dd856SAarushi Mehta# linux-io-uring probe
3494c10dd856SAarushi Mehta
3495c10dd856SAarushi Mehtaif test "$linux_io_uring" != "no" ; then
3496c10dd856SAarushi Mehta  if $pkg_config liburing; then
3497c10dd856SAarushi Mehta    linux_io_uring_cflags=$($pkg_config --cflags liburing)
3498c10dd856SAarushi Mehta    linux_io_uring_libs=$($pkg_config --libs liburing)
3499c10dd856SAarushi Mehta    linux_io_uring=yes
3500c10dd856SAarushi Mehta  else
3501c10dd856SAarushi Mehta    if test "$linux_io_uring" = "yes" ; then
3502c10dd856SAarushi Mehta      feature_not_found "linux io_uring" "Install liburing devel"
3503c10dd856SAarushi Mehta    fi
3504c10dd856SAarushi Mehta    linux_io_uring=no
3505c10dd856SAarushi Mehta  fi
3506c10dd856SAarushi Mehtafi
35075c6c3a6cSChristoph Hellwig
35085c6c3a6cSChristoph Hellwig##########################################
35097aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
35103b8acc11SPaolo Bonzini
35117aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
35127aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
35137aaa6a16SPaolo Bonzini    tpm=no
35143b8acc11SPaolo Bonzini  else
35157aaa6a16SPaolo Bonzini    tpm=yes
35167aaa6a16SPaolo Bonzini  fi
35177aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
35187aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
35197aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
35207aaa6a16SPaolo Bonzini  fi
35213b8acc11SPaolo Bonzinifi
35223b8acc11SPaolo Bonzini
35233b8acc11SPaolo Bonzini##########################################
3524bf9298b9Saliguori# iovec probe
3525bf9298b9Saliguoricat > $TMPC <<EOF
3526db34f0b3Sblueswir1#include <sys/types.h>
3527bf9298b9Saliguori#include <sys/uio.h>
3528db34f0b3Sblueswir1#include <unistd.h>
3529f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3530bf9298b9SaliguoriEOF
3531bf9298b9Saliguoriiovec=no
353252166aa0SJuan Quintelaif compile_prog "" "" ; then
3533bf9298b9Saliguori  iovec=yes
3534bf9298b9Saliguorifi
3535bf9298b9Saliguori
3536f652e6afSaurel32##########################################
3537f652e6afSaurel32# fdt probe
3538e169e1e1SPeter Maydell
3539fbb4121dSPaolo Bonzinicase "$fdt" in
3540fbb4121dSPaolo Bonzini  auto | enabled | internal)
3541fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
3542fbb4121dSPaolo Bonzini    if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
3543aef45d51SDaniel P. Berrange      git_submodules="${git_submodules} dtc"
3544aef45d51SDaniel P. Berrange    fi
3545fbb4121dSPaolo Bonzini    ;;
3546fbb4121dSPaolo Bonziniesac
3547f652e6afSaurel32
354820ff075bSMichael Walle##########################################
3549fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3550b1546f32SGerd Hoffmann
3551d52c454aSMarc-André Lureaugbm="no"
3552d52c454aSMarc-André Lureauif $pkg_config gbm; then
3553d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
3554d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
3555d52c454aSMarc-André Lureau    gbm="yes"
3556d52c454aSMarc-André Lureaufi
3557d52c454aSMarc-André Lureau
3558da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
35594939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
35605f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
35615f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
35625f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
3563da076ffeSGerd Hoffmann    opengl=yes
356420ff075bSMichael Walle  else
3565da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3566dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
356720ff075bSMichael Walle    fi
3568f676c67eSJeremy White    opengl_cflags=""
3569da076ffeSGerd Hoffmann    opengl_libs=""
3570da076ffeSGerd Hoffmann    opengl=no
357120ff075bSMichael Walle  fi
357220ff075bSMichael Wallefi
357320ff075bSMichael Walle
3574014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3575014cb152SGerd Hoffmann  cat > $TMPC << EOF
3576014cb152SGerd Hoffmann#include <epoxy/egl.h>
3577014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3578014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3579014cb152SGerd Hoffmann#endif
3580014cb152SGerd Hoffmannint main(void) { return 0; }
3581014cb152SGerd HoffmannEOF
3582014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3583014cb152SGerd Hoffmann    opengl_dmabuf=yes
3584014cb152SGerd Hoffmann  fi
3585014cb152SGerd Hoffmannfi
3586c9a12e75SChrysostomos Nanakos
3587ed279a06SKlim Kireev##########################################
3588ed279a06SKlim Kireev# libxml2 probe
3589ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
3590ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
3591ed279a06SKlim Kireev        libxml2="yes"
3592ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3593ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
3594ed279a06SKlim Kireev    else
3595ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
3596ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
3597ed279a06SKlim Kireev        fi
3598ed279a06SKlim Kireev        libxml2="no"
3599ed279a06SKlim Kireev    fi
3600ed279a06SKlim Kireevfi
3601c9a12e75SChrysostomos Nanakos
360239386ac7Saurel32# Check for inotify functions when we are building linux-user
36033b3f24adSaurel32# emulator.  This is done because older glibc versions don't
36043b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
36053b3f24adSaurel32# don't provide them even if kernel supports them.
36063b3f24adSaurel32#
36073b3f24adSaurel32inotify=no
36083b3f24adSaurel32cat > $TMPC << EOF
36093b3f24adSaurel32#include <sys/inotify.h>
36103b3f24adSaurel32
36113b3f24adSaurel32int
36123b3f24adSaurel32main(void)
36133b3f24adSaurel32{
36143b3f24adSaurel32	/* try to start inotify */
36158690e420Saurel32	return inotify_init();
36163b3f24adSaurel32}
36173b3f24adSaurel32EOF
361852166aa0SJuan Quintelaif compile_prog "" "" ; then
36193b3f24adSaurel32  inotify=yes
36203b3f24adSaurel32fi
36213b3f24adSaurel32
3622c05c7a73SRiku Voipioinotify1=no
3623c05c7a73SRiku Voipiocat > $TMPC << EOF
3624c05c7a73SRiku Voipio#include <sys/inotify.h>
3625c05c7a73SRiku Voipio
3626c05c7a73SRiku Voipioint
3627c05c7a73SRiku Voipiomain(void)
3628c05c7a73SRiku Voipio{
3629c05c7a73SRiku Voipio    /* try to start inotify */
3630c05c7a73SRiku Voipio    return inotify_init1(0);
3631c05c7a73SRiku Voipio}
3632c05c7a73SRiku VoipioEOF
3633c05c7a73SRiku Voipioif compile_prog "" "" ; then
3634c05c7a73SRiku Voipio  inotify1=yes
3635c05c7a73SRiku Voipiofi
3636c05c7a73SRiku Voipio
3637099d6b0fSRiku Voipio# check if pipe2 is there
3638099d6b0fSRiku Voipiopipe2=no
3639099d6b0fSRiku Voipiocat > $TMPC << EOF
3640099d6b0fSRiku Voipio#include <unistd.h>
3641099d6b0fSRiku Voipio#include <fcntl.h>
3642099d6b0fSRiku Voipio
3643099d6b0fSRiku Voipioint main(void)
3644099d6b0fSRiku Voipio{
3645099d6b0fSRiku Voipio    int pipefd[2];
36469bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
3647099d6b0fSRiku Voipio}
3648099d6b0fSRiku VoipioEOF
364952166aa0SJuan Quintelaif compile_prog "" "" ; then
3650099d6b0fSRiku Voipio  pipe2=yes
3651099d6b0fSRiku Voipiofi
3652099d6b0fSRiku Voipio
365340ff6d7eSKevin Wolf# check if accept4 is there
365440ff6d7eSKevin Wolfaccept4=no
365540ff6d7eSKevin Wolfcat > $TMPC << EOF
365640ff6d7eSKevin Wolf#include <sys/socket.h>
365740ff6d7eSKevin Wolf#include <stddef.h>
365840ff6d7eSKevin Wolf
365940ff6d7eSKevin Wolfint main(void)
366040ff6d7eSKevin Wolf{
366140ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
366240ff6d7eSKevin Wolf    return 0;
366340ff6d7eSKevin Wolf}
366440ff6d7eSKevin WolfEOF
366540ff6d7eSKevin Wolfif compile_prog "" "" ; then
366640ff6d7eSKevin Wolf  accept4=yes
366740ff6d7eSKevin Wolffi
366840ff6d7eSKevin Wolf
36693ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
36703ce34dfbSvibisreenivasansplice=no
36713ce34dfbSvibisreenivasancat > $TMPC << EOF
36723ce34dfbSvibisreenivasan#include <unistd.h>
36733ce34dfbSvibisreenivasan#include <fcntl.h>
36743ce34dfbSvibisreenivasan#include <limits.h>
36753ce34dfbSvibisreenivasan
36763ce34dfbSvibisreenivasanint main(void)
36773ce34dfbSvibisreenivasan{
367866ea0f22SStefan Weil    int len, fd = 0;
36793ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
36803ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
36813ce34dfbSvibisreenivasan    return 0;
36823ce34dfbSvibisreenivasan}
36833ce34dfbSvibisreenivasanEOF
368452166aa0SJuan Quintelaif compile_prog "" "" ; then
36853ce34dfbSvibisreenivasan  splice=yes
36863ce34dfbSvibisreenivasanfi
36873ce34dfbSvibisreenivasan
3688dcc38d1cSMarcelo Tosatti##########################################
3689a99d57bbSWanlong Gao# libnuma probe
3690a99d57bbSWanlong Gao
3691a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
3692a99d57bbSWanlong Gao  cat > $TMPC << EOF
3693a99d57bbSWanlong Gao#include <numa.h>
3694a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
3695a99d57bbSWanlong GaoEOF
3696a99d57bbSWanlong Gao
3697a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
3698a99d57bbSWanlong Gao    numa=yes
3699ab318051SMarc-André Lureau    numa_libs="-lnuma"
3700a99d57bbSWanlong Gao  else
3701a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
3702a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
3703a99d57bbSWanlong Gao    fi
3704a99d57bbSWanlong Gao    numa=no
3705a99d57bbSWanlong Gao  fi
3706a99d57bbSWanlong Gaofi
3707a99d57bbSWanlong Gao
3708aa087962SPaolo Bonzinimalloc=system
37097b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
37107b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
37117b01cb97SAlexandre Derumier    exit 1
3712aa087962SPaolo Bonzinielif test "$tcmalloc" = "yes" ; then
3713aa087962SPaolo Bonzini    malloc=tcmalloc
3714aa087962SPaolo Bonzinielif test "$jemalloc" = "yes" ; then
3715aa087962SPaolo Bonzini    malloc=jemalloc
37167b01cb97SAlexandre Derumierfi
37177b01cb97SAlexandre Derumier
37187b01cb97SAlexandre Derumier##########################################
3719dcc38d1cSMarcelo Tosatti# signalfd probe
3720dcc38d1cSMarcelo Tosattisignalfd="no"
3721dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
3722dcc38d1cSMarcelo Tosatti#include <unistd.h>
3723dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
3724dcc38d1cSMarcelo Tosatti#include <signal.h>
3725dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
3726dcc38d1cSMarcelo TosattiEOF
3727dcc38d1cSMarcelo Tosatti
3728dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
3729dcc38d1cSMarcelo Tosatti  signalfd=yes
3730dcc38d1cSMarcelo Tosattifi
3731dcc38d1cSMarcelo Tosatti
3732d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
3733d339d766SRichard W.M. Jonesoptreset="no"
3734d339d766SRichard W.M. Jonescat > $TMPC << EOF
3735d339d766SRichard W.M. Jones#include <getopt.h>
3736d339d766SRichard W.M. Jonesint main(void) { return optreset; }
3737d339d766SRichard W.M. JonesEOF
3738d339d766SRichard W.M. Jones
3739d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
3740d339d766SRichard W.M. Jones  optreset=yes
3741d339d766SRichard W.M. Jonesfi
3742d339d766SRichard W.M. Jones
3743c2882b96SRiku Voipio# check if eventfd is supported
3744c2882b96SRiku Voipioeventfd=no
3745c2882b96SRiku Voipiocat > $TMPC << EOF
3746c2882b96SRiku Voipio#include <sys/eventfd.h>
3747c2882b96SRiku Voipio
3748c2882b96SRiku Voipioint main(void)
3749c2882b96SRiku Voipio{
375055cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
3751c2882b96SRiku Voipio}
3752c2882b96SRiku VoipioEOF
3753c2882b96SRiku Voipioif compile_prog "" "" ; then
3754c2882b96SRiku Voipio  eventfd=yes
3755c2882b96SRiku Voipiofi
3756c2882b96SRiku Voipio
3757751bcc39SMarc-André Lureau# check if memfd is supported
3758751bcc39SMarc-André Lureaumemfd=no
3759751bcc39SMarc-André Lureaucat > $TMPC << EOF
376075e5b70eSPaolo Bonzini#include <sys/mman.h>
3761751bcc39SMarc-André Lureau
3762751bcc39SMarc-André Lureauint main(void)
3763751bcc39SMarc-André Lureau{
3764751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
3765751bcc39SMarc-André Lureau}
3766751bcc39SMarc-André LureauEOF
3767751bcc39SMarc-André Lureauif compile_prog "" "" ; then
3768751bcc39SMarc-André Lureau  memfd=yes
3769751bcc39SMarc-André Lureaufi
3770751bcc39SMarc-André Lureau
3771955727d2SCortland Tölva# check for usbfs
3772955727d2SCortland Tölvahave_usbfs=no
3773955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
377496566d09SThomas Petazzoni  cat > $TMPC << EOF
377596566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
377696566d09SThomas Petazzoni
377796566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
377896566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
377996566d09SThomas Petazzoni#endif
378096566d09SThomas Petazzoni
378196566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
378296566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
378396566d09SThomas Petazzoni#endif
378496566d09SThomas Petazzoni
378596566d09SThomas Petazzoniint main(void)
378696566d09SThomas Petazzoni{
378796566d09SThomas Petazzoni    return 0;
378896566d09SThomas Petazzoni}
378996566d09SThomas PetazzoniEOF
379096566d09SThomas Petazzoni  if compile_prog "" ""; then
3791955727d2SCortland Tölva    have_usbfs=yes
3792955727d2SCortland Tölva  fi
3793955727d2SCortland Tölvafi
3794751bcc39SMarc-André Lureau
3795d0927938SUlrich Hecht# check for fallocate
3796d0927938SUlrich Hechtfallocate=no
3797d0927938SUlrich Hechtcat > $TMPC << EOF
3798d0927938SUlrich Hecht#include <fcntl.h>
3799d0927938SUlrich Hecht
3800d0927938SUlrich Hechtint main(void)
3801d0927938SUlrich Hecht{
3802d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
3803d0927938SUlrich Hecht    return 0;
3804d0927938SUlrich Hecht}
3805d0927938SUlrich HechtEOF
38068fb03151SPeter Maydellif compile_prog "" "" ; then
3807d0927938SUlrich Hecht  fallocate=yes
3808d0927938SUlrich Hechtfi
3809d0927938SUlrich Hecht
38103d4fa43eSKusanagi Kouichi# check for fallocate hole punching
38113d4fa43eSKusanagi Kouichifallocate_punch_hole=no
38123d4fa43eSKusanagi Kouichicat > $TMPC << EOF
38133d4fa43eSKusanagi Kouichi#include <fcntl.h>
38143d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
38153d4fa43eSKusanagi Kouichi
38163d4fa43eSKusanagi Kouichiint main(void)
38173d4fa43eSKusanagi Kouichi{
38183d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
38193d4fa43eSKusanagi Kouichi    return 0;
38203d4fa43eSKusanagi Kouichi}
38213d4fa43eSKusanagi KouichiEOF
38223d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
38233d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
38243d4fa43eSKusanagi Kouichifi
38253d4fa43eSKusanagi Kouichi
3826b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
3827b953f075SDenis V. Lunevfallocate_zero_range=no
3828b953f075SDenis V. Lunevcat > $TMPC << EOF
3829b953f075SDenis V. Lunev#include <fcntl.h>
3830b953f075SDenis V. Lunev#include <linux/falloc.h>
3831b953f075SDenis V. Lunev
3832b953f075SDenis V. Lunevint main(void)
3833b953f075SDenis V. Lunev{
3834b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
3835b953f075SDenis V. Lunev    return 0;
3836b953f075SDenis V. Lunev}
3837b953f075SDenis V. LunevEOF
3838b953f075SDenis V. Lunevif compile_prog "" "" ; then
3839b953f075SDenis V. Lunev  fallocate_zero_range=yes
3840b953f075SDenis V. Lunevfi
3841b953f075SDenis V. Lunev
3842ed911435SKevin Wolf# check for posix_fallocate
3843ed911435SKevin Wolfposix_fallocate=no
3844ed911435SKevin Wolfcat > $TMPC << EOF
3845ed911435SKevin Wolf#include <fcntl.h>
3846ed911435SKevin Wolf
3847ed911435SKevin Wolfint main(void)
3848ed911435SKevin Wolf{
3849ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
3850ed911435SKevin Wolf    return 0;
3851ed911435SKevin Wolf}
3852ed911435SKevin WolfEOF
3853ed911435SKevin Wolfif compile_prog "" "" ; then
3854ed911435SKevin Wolf    posix_fallocate=yes
3855ed911435SKevin Wolffi
3856ed911435SKevin Wolf
3857c727f47dSPeter Maydell# check for sync_file_range
3858c727f47dSPeter Maydellsync_file_range=no
3859c727f47dSPeter Maydellcat > $TMPC << EOF
3860c727f47dSPeter Maydell#include <fcntl.h>
3861c727f47dSPeter Maydell
3862c727f47dSPeter Maydellint main(void)
3863c727f47dSPeter Maydell{
3864c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
3865c727f47dSPeter Maydell    return 0;
3866c727f47dSPeter Maydell}
3867c727f47dSPeter MaydellEOF
38688fb03151SPeter Maydellif compile_prog "" "" ; then
3869c727f47dSPeter Maydell  sync_file_range=yes
3870c727f47dSPeter Maydellfi
3871c727f47dSPeter Maydell
3872dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
3873dace20dcSPeter Maydellfiemap=no
3874dace20dcSPeter Maydellcat > $TMPC << EOF
3875dace20dcSPeter Maydell#include <sys/ioctl.h>
3876dace20dcSPeter Maydell#include <linux/fs.h>
3877dace20dcSPeter Maydell#include <linux/fiemap.h>
3878dace20dcSPeter Maydell
3879dace20dcSPeter Maydellint main(void)
3880dace20dcSPeter Maydell{
3881dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
3882dace20dcSPeter Maydell    return 0;
3883dace20dcSPeter Maydell}
3884dace20dcSPeter MaydellEOF
38858fb03151SPeter Maydellif compile_prog "" "" ; then
3886dace20dcSPeter Maydell  fiemap=yes
3887dace20dcSPeter Maydellfi
3888dace20dcSPeter Maydell
3889d0927938SUlrich Hecht# check for dup3
3890d0927938SUlrich Hechtdup3=no
3891d0927938SUlrich Hechtcat > $TMPC << EOF
3892d0927938SUlrich Hecht#include <unistd.h>
3893d0927938SUlrich Hecht
3894d0927938SUlrich Hechtint main(void)
3895d0927938SUlrich Hecht{
3896d0927938SUlrich Hecht    dup3(0, 0, 0);
3897d0927938SUlrich Hecht    return 0;
3898d0927938SUlrich Hecht}
3899d0927938SUlrich HechtEOF
390078f5d726SJan Kiszkaif compile_prog "" "" ; then
3901d0927938SUlrich Hecht  dup3=yes
3902d0927938SUlrich Hechtfi
3903d0927938SUlrich Hecht
39044e0c6529SAlex Bligh# check for ppoll support
39054e0c6529SAlex Blighppoll=no
39064e0c6529SAlex Blighcat > $TMPC << EOF
39074e0c6529SAlex Bligh#include <poll.h>
39084e0c6529SAlex Bligh
39094e0c6529SAlex Blighint main(void)
39104e0c6529SAlex Bligh{
39114e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
39124e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
39134e0c6529SAlex Bligh    return 0;
39144e0c6529SAlex Bligh}
39154e0c6529SAlex BlighEOF
39164e0c6529SAlex Blighif compile_prog "" "" ; then
39174e0c6529SAlex Bligh  ppoll=yes
39184e0c6529SAlex Blighfi
39194e0c6529SAlex Bligh
3920cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
3921cd758dd0SAlex Blighprctl_pr_set_timerslack=no
3922cd758dd0SAlex Blighcat > $TMPC << EOF
3923cd758dd0SAlex Bligh#include <sys/prctl.h>
3924cd758dd0SAlex Bligh
3925cd758dd0SAlex Blighint main(void)
3926cd758dd0SAlex Bligh{
3927cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
3928cd758dd0SAlex Bligh    return 0;
3929cd758dd0SAlex Bligh}
3930cd758dd0SAlex BlighEOF
3931cd758dd0SAlex Blighif compile_prog "" "" ; then
3932cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
3933cd758dd0SAlex Blighfi
3934cd758dd0SAlex Bligh
39353b6edd16SPeter Maydell# check for epoll support
39363b6edd16SPeter Maydellepoll=no
39373b6edd16SPeter Maydellcat > $TMPC << EOF
39383b6edd16SPeter Maydell#include <sys/epoll.h>
39393b6edd16SPeter Maydell
39403b6edd16SPeter Maydellint main(void)
39413b6edd16SPeter Maydell{
39423b6edd16SPeter Maydell    epoll_create(0);
39433b6edd16SPeter Maydell    return 0;
39443b6edd16SPeter Maydell}
39453b6edd16SPeter MaydellEOF
39468fb03151SPeter Maydellif compile_prog "" "" ; then
39473b6edd16SPeter Maydell  epoll=yes
39483b6edd16SPeter Maydellfi
39493b6edd16SPeter Maydell
3950227f0214SPeter Maydell# epoll_create1 is a later addition
3951227f0214SPeter Maydell# so we must check separately for its presence
39523b6edd16SPeter Maydellepoll_create1=no
39533b6edd16SPeter Maydellcat > $TMPC << EOF
39543b6edd16SPeter Maydell#include <sys/epoll.h>
39553b6edd16SPeter Maydell
39563b6edd16SPeter Maydellint main(void)
39573b6edd16SPeter Maydell{
395819e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
395919e83f6bSPeter Maydell     * a function being called. This is necessary so that on
396019e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
396119e83f6bSPeter Maydell     * the library but not declared in the header file we will
396219e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
396319e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
396419e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
396519e83f6bSPeter Maydell     */
3966c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
39673b6edd16SPeter Maydell}
39683b6edd16SPeter MaydellEOF
39698fb03151SPeter Maydellif compile_prog "" "" ; then
39703b6edd16SPeter Maydell  epoll_create1=yes
39713b6edd16SPeter Maydellfi
39723b6edd16SPeter Maydell
3973a8fd1abaSPeter Maydell# check for sendfile support
3974a8fd1abaSPeter Maydellsendfile=no
3975a8fd1abaSPeter Maydellcat > $TMPC << EOF
3976a8fd1abaSPeter Maydell#include <sys/sendfile.h>
3977a8fd1abaSPeter Maydell
3978a8fd1abaSPeter Maydellint main(void)
3979a8fd1abaSPeter Maydell{
3980a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
3981a8fd1abaSPeter Maydell}
3982a8fd1abaSPeter MaydellEOF
3983a8fd1abaSPeter Maydellif compile_prog "" "" ; then
3984a8fd1abaSPeter Maydell  sendfile=yes
3985a8fd1abaSPeter Maydellfi
3986a8fd1abaSPeter Maydell
398751834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
398851834341SRiku Voipiotimerfd=no
398951834341SRiku Voipiocat > $TMPC << EOF
399051834341SRiku Voipio#include <sys/timerfd.h>
399151834341SRiku Voipio
399251834341SRiku Voipioint main(void)
399351834341SRiku Voipio{
399451834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
399551834341SRiku Voipio}
399651834341SRiku VoipioEOF
399751834341SRiku Voipioif compile_prog "" "" ; then
399851834341SRiku Voipio  timerfd=yes
399951834341SRiku Voipiofi
400051834341SRiku Voipio
40019af5c906SRiku Voipio# check for setns and unshare support
40029af5c906SRiku Voipiosetns=no
40039af5c906SRiku Voipiocat > $TMPC << EOF
40049af5c906SRiku Voipio#include <sched.h>
40059af5c906SRiku Voipio
40069af5c906SRiku Voipioint main(void)
40079af5c906SRiku Voipio{
40089af5c906SRiku Voipio    int ret;
40099af5c906SRiku Voipio    ret = setns(0, 0);
40109af5c906SRiku Voipio    ret = unshare(0);
40119af5c906SRiku Voipio    return ret;
40129af5c906SRiku Voipio}
40139af5c906SRiku VoipioEOF
40149af5c906SRiku Voipioif compile_prog "" "" ; then
40159af5c906SRiku Voipio  setns=yes
40169af5c906SRiku Voipiofi
40179af5c906SRiku Voipio
401838860a03SAleksandar Markovic# clock_adjtime probe
401938860a03SAleksandar Markovicclock_adjtime=no
402038860a03SAleksandar Markoviccat > $TMPC <<EOF
402138860a03SAleksandar Markovic#include <time.h>
4022cd5d20efSJiaxun Yang#include <sys/timex.h>
402338860a03SAleksandar Markovic
402438860a03SAleksandar Markovicint main(void)
402538860a03SAleksandar Markovic{
402638860a03SAleksandar Markovic    return clock_adjtime(0, 0);
402738860a03SAleksandar Markovic}
402838860a03SAleksandar MarkovicEOF
402938860a03SAleksandar Markovicclock_adjtime=no
403038860a03SAleksandar Markovicif compile_prog "" "" ; then
403138860a03SAleksandar Markovic  clock_adjtime=yes
403238860a03SAleksandar Markovicfi
403338860a03SAleksandar Markovic
40345a03cd00SAleksandar Markovic# syncfs probe
40355a03cd00SAleksandar Markovicsyncfs=no
40365a03cd00SAleksandar Markoviccat > $TMPC <<EOF
40375a03cd00SAleksandar Markovic#include <unistd.h>
40385a03cd00SAleksandar Markovic
40395a03cd00SAleksandar Markovicint main(void)
40405a03cd00SAleksandar Markovic{
40415a03cd00SAleksandar Markovic    return syncfs(0);
40425a03cd00SAleksandar Markovic}
40435a03cd00SAleksandar MarkovicEOF
40445a03cd00SAleksandar Markovicsyncfs=no
40455a03cd00SAleksandar Markovicif compile_prog "" "" ; then
40465a03cd00SAleksandar Markovic  syncfs=yes
40475a03cd00SAleksandar Markovicfi
40485a03cd00SAleksandar Markovic
4049f514f41cSStefan Weil# Search for bswap_32 function
40506ae9a1f4SJuan Quintelabyteswap_h=no
40516ae9a1f4SJuan Quintelacat > $TMPC << EOF
40526ae9a1f4SJuan Quintela#include <byteswap.h>
40536ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
40546ae9a1f4SJuan QuintelaEOF
405552166aa0SJuan Quintelaif compile_prog "" "" ; then
40566ae9a1f4SJuan Quintela  byteswap_h=yes
40576ae9a1f4SJuan Quintelafi
40586ae9a1f4SJuan Quintela
405975f13596SStefan Weil# Search for bswap32 function
40606ae9a1f4SJuan Quintelabswap_h=no
40616ae9a1f4SJuan Quintelacat > $TMPC << EOF
40626ae9a1f4SJuan Quintela#include <sys/endian.h>
40636ae9a1f4SJuan Quintela#include <sys/types.h>
40646ae9a1f4SJuan Quintela#include <machine/bswap.h>
40656ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
40666ae9a1f4SJuan QuintelaEOF
406752166aa0SJuan Quintelaif compile_prog "" "" ; then
40686ae9a1f4SJuan Quintela  bswap_h=yes
40696ae9a1f4SJuan Quintelafi
40706ae9a1f4SJuan Quintela
4071f2995ee4SPaolo Bonzini# Check whether we have openpty() in either libc or libutil
4072d99e97e6SThomas Huthcat > $TMPC << EOF
4073d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4074d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
4075d99e97e6SThomas HuthEOF
4076d99e97e6SThomas Huth
40779df8b20dSThomas Huthhave_openpty="no"
40789df8b20dSThomas Huthif compile_prog "" "" ; then
40799df8b20dSThomas Huth  have_openpty="yes"
40809df8b20dSThomas Huthelse
4081d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
40829df8b20dSThomas Huth    have_openpty="yes"
4083d99e97e6SThomas Huth  fi
40846362a53fSJuan Quintelafi
40856362a53fSJuan Quintela
4086de5071c5SBlue Swirl##########################################
4087cd4ec0b4SGerd Hoffmann# spice probe
4088cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4089cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4090cd4ec0b4SGerd Hoffmann#include <spice.h>
4091cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4092cd4ec0b4SGerd HoffmannEOF
4093710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4094710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
40951b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
409665d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4097cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4098cd4ec0b4SGerd Hoffmann    spice="yes"
4099cd4ec0b4SGerd Hoffmann  else
4100cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
41018efc9363SHu Tao      feature_not_found "spice" \
41021b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4103cd4ec0b4SGerd Hoffmann    fi
4104cd4ec0b4SGerd Hoffmann    spice="no"
4105cd4ec0b4SGerd Hoffmann  fi
4106cd4ec0b4SGerd Hoffmannfi
4107cd4ec0b4SGerd Hoffmann
41087b02f544SMarc-André Lureau# check for smartcard support
41097b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
41100f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
41117b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
41127b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
41137b02f544SMarc-André Lureau        smartcard="yes"
4114111a38b0SRobert Relyea    else
41157b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
41167b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4117111a38b0SRobert Relyea        fi
41187b02f544SMarc-André Lureau        smartcard="no"
4119111a38b0SRobert Relyea    fi
4120111a38b0SRobert Relyeafi
4121111a38b0SRobert Relyea
41222b2325ffSGerd Hoffmann# check for libusb
41232b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
412465d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
41252b2325ffSGerd Hoffmann        libusb="yes"
4126ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4127ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
41282b2325ffSGerd Hoffmann    else
41292b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
41308efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
41312b2325ffSGerd Hoffmann        fi
41322b2325ffSGerd Hoffmann        libusb="no"
41332b2325ffSGerd Hoffmann    fi
41342b2325ffSGerd Hoffmannfi
41352b2325ffSGerd Hoffmann
413669354a83SHans de Goede# check for usbredirparser for usb network redirection support
413769354a83SHans de Goedeif test "$usb_redir" != "no" ; then
413865d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
413969354a83SHans de Goede        usb_redir="yes"
4140ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4141ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
414269354a83SHans de Goede    else
414369354a83SHans de Goede        if test "$usb_redir" = "yes"; then
414421684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
414569354a83SHans de Goede        fi
414669354a83SHans de Goede        usb_redir="no"
414769354a83SHans de Goede    fi
414869354a83SHans de Goedefi
414969354a83SHans de Goede
4150cd4ec0b4SGerd Hoffmann##########################################
4151d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4152d9840e25STomoki Sekiyama
4153e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4154e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
4155d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4156690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4157d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4158d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4159690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4160d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4161d9840e25STomoki Sekiyama	  ;;
4162690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4163d9840e25STomoki Sekiyama  esac
4164d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4165d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4166d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4167d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4168d9840e25STomoki SekiyamaEOF
4169d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4170d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4171d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4172315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4173f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4174d9840e25STomoki Sekiyama  else
4175d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4176d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4177d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4178d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4179d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4180d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4181d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4182d9840e25STomoki Sekiyama    fi
4183d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4184d9840e25STomoki Sekiyama  fi
4185d9840e25STomoki Sekiyamafi
4186d9840e25STomoki Sekiyama
4187d9840e25STomoki Sekiyama##########################################
4188d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4189d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4190d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4191d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4192d9840e25STomoki Sekiyama
4193e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4194e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
4195d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4196d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4197d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4198d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4199d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4200d9840e25STomoki Sekiyama    else
4201d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4202d9840e25STomoki Sekiyama    fi
4203d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4204d9840e25STomoki Sekiyama    win_sdk=""
4205d9840e25STomoki Sekiyama  fi
4206d9840e25STomoki Sekiyamafi
4207d9840e25STomoki Sekiyama
4208d9840e25STomoki Sekiyama##########################################
420950cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
4210e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
421150cbebb9SMichael Roth  cat > $TMPC << EOF
421250cbebb9SMichael Roth#include <windows.h>
421350cbebb9SMichael Roth#include <ntddscsi.h>
421450cbebb9SMichael Rothint main(void) {
421550cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
421650cbebb9SMichael Roth#error Missing required ioctl definitions
421750cbebb9SMichael Roth#endif
421850cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
421950cbebb9SMichael Roth  return addr.Lun;
422050cbebb9SMichael Roth}
422150cbebb9SMichael RothEOF
422250cbebb9SMichael Roth  if compile_prog "" "" ; then
422350cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4224996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
422550cbebb9SMichael Roth  fi
422650cbebb9SMichael Rothfi
422750cbebb9SMichael Roth
422850cbebb9SMichael Roth##########################################
42299d9e1521SGerd Hoffmann# virgl renderer probe
42309d9e1521SGerd Hoffmann
42319d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
42329d9e1521SGerd Hoffmann  cat > $TMPC << EOF
42339d9e1521SGerd Hoffmann#include <virglrenderer.h>
42349d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
42359d9e1521SGerd HoffmannEOF
42369d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
42379d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
423847479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
42399d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
42409d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
42419d9e1521SGerd Hoffmann    virglrenderer="yes"
42429d9e1521SGerd Hoffmann  else
42439d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
42449d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
42459d9e1521SGerd Hoffmann    fi
42469d9e1521SGerd Hoffmann    virglrenderer="no"
42479d9e1521SGerd Hoffmann  fi
42489d9e1521SGerd Hoffmannfi
42499d9e1521SGerd Hoffmann
42509d9e1521SGerd Hoffmann##########################################
42518ca80760SRichard Henderson# capstone
42528ca80760SRichard Henderson
4253e219c499SRichard Hendersoncase "$capstone" in
42548b18cdbfSRichard Henderson  auto | enabled | internal)
42558b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
42568b18cdbfSRichard Henderson    if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
4257e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4258e219c499SRichard Henderson    fi
4259e219c499SRichard Henderson    ;;
4260e219c499SRichard Hendersonesac
42618ca80760SRichard Henderson
42628ca80760SRichard Henderson##########################################
42635f6b9e8fSBlue Swirl# check if we have fdatasync
42645f6b9e8fSBlue Swirl
42655f6b9e8fSBlue Swirlfdatasync=no
42665f6b9e8fSBlue Swirlcat > $TMPC << EOF
42675f6b9e8fSBlue Swirl#include <unistd.h>
4268d1722a27SAlexandre Raymondint main(void) {
4269d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4270d1722a27SAlexandre Raymondreturn fdatasync(0);
4271d1722a27SAlexandre Raymond#else
4272e172fe11SStefan Weil#error Not supported
4273d1722a27SAlexandre Raymond#endif
4274d1722a27SAlexandre Raymond}
42755f6b9e8fSBlue SwirlEOF
42765f6b9e8fSBlue Swirlif compile_prog "" "" ; then
42775f6b9e8fSBlue Swirl    fdatasync=yes
42785f6b9e8fSBlue Swirlfi
42795f6b9e8fSBlue Swirl
428094a420b1SStefan Hajnoczi##########################################
4281e78815a5SAndreas Färber# check if we have madvise
4282e78815a5SAndreas Färber
4283e78815a5SAndreas Färbermadvise=no
4284e78815a5SAndreas Färbercat > $TMPC << EOF
4285e78815a5SAndreas Färber#include <sys/types.h>
4286e78815a5SAndreas Färber#include <sys/mman.h>
4287832ce9c2SScott Wood#include <stddef.h>
4288e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4289e78815a5SAndreas FärberEOF
4290e78815a5SAndreas Färberif compile_prog "" "" ; then
4291e78815a5SAndreas Färber    madvise=yes
4292e78815a5SAndreas Färberfi
4293e78815a5SAndreas Färber
4294e78815a5SAndreas Färber##########################################
4295e78815a5SAndreas Färber# check if we have posix_madvise
4296e78815a5SAndreas Färber
4297e78815a5SAndreas Färberposix_madvise=no
4298e78815a5SAndreas Färbercat > $TMPC << EOF
4299e78815a5SAndreas Färber#include <sys/mman.h>
4300832ce9c2SScott Wood#include <stddef.h>
4301e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4302e78815a5SAndreas FärberEOF
4303e78815a5SAndreas Färberif compile_prog "" "" ; then
4304e78815a5SAndreas Färber    posix_madvise=yes
4305e78815a5SAndreas Färberfi
4306e78815a5SAndreas Färber
4307e78815a5SAndreas Färber##########################################
43089bc5a719SAndreas Gustafsson# check if we have posix_memalign()
43099bc5a719SAndreas Gustafsson
43109bc5a719SAndreas Gustafssonposix_memalign=no
43119bc5a719SAndreas Gustafssoncat > $TMPC << EOF
43129bc5a719SAndreas Gustafsson#include <stdlib.h>
43139bc5a719SAndreas Gustafssonint main(void) {
43149bc5a719SAndreas Gustafsson    void *p;
43159bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
43169bc5a719SAndreas Gustafsson}
43179bc5a719SAndreas GustafssonEOF
43189bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
43199bc5a719SAndreas Gustafsson    posix_memalign=yes
43209bc5a719SAndreas Gustafssonfi
43219bc5a719SAndreas Gustafsson
43229bc5a719SAndreas Gustafsson##########################################
43230a852417SPaul Durrant# check if we have posix_syslog
43240a852417SPaul Durrant
43250a852417SPaul Durrantposix_syslog=no
43260a852417SPaul Durrantcat > $TMPC << EOF
43270a852417SPaul Durrant#include <syslog.h>
43280a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
43290a852417SPaul DurrantEOF
43300a852417SPaul Durrantif compile_prog "" "" ; then
43310a852417SPaul Durrant    posix_syslog=yes
43320a852417SPaul Durrantfi
43330a852417SPaul Durrant
43340a852417SPaul Durrant##########################################
4335401bc051SPeter Maydell# check if we have sem_timedwait
4336401bc051SPeter Maydell
4337401bc051SPeter Maydellsem_timedwait=no
4338401bc051SPeter Maydellcat > $TMPC << EOF
4339401bc051SPeter Maydell#include <semaphore.h>
4340811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
4341401bc051SPeter MaydellEOF
4342401bc051SPeter Maydellif compile_prog "" "" ; then
4343401bc051SPeter Maydell    sem_timedwait=yes
4344401bc051SPeter Maydellfi
4345401bc051SPeter Maydell
4346401bc051SPeter Maydell##########################################
43475c99fa37SKeno Fischer# check if we have strchrnul
43485c99fa37SKeno Fischer
43495c99fa37SKeno Fischerstrchrnul=no
43505c99fa37SKeno Fischercat > $TMPC << EOF
43515c99fa37SKeno Fischer#include <string.h>
43525c99fa37SKeno Fischerint main(void);
43535c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
43545c99fa37SKeno Fischerchar *haystack = (char*)&main;
43555c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
43565c99fa37SKeno FischerEOF
43575c99fa37SKeno Fischerif compile_prog "" "" ; then
43585c99fa37SKeno Fischer    strchrnul=yes
43595c99fa37SKeno Fischerfi
43605c99fa37SKeno Fischer
43618a792b03SJiufei Xue#########################################
43628a792b03SJiufei Xue# check if we have st_atim
43638a792b03SJiufei Xue
43648a792b03SJiufei Xuest_atim=no
43658a792b03SJiufei Xuecat > $TMPC << EOF
43668a792b03SJiufei Xue#include <sys/stat.h>
43678a792b03SJiufei Xue#include <stddef.h>
43688a792b03SJiufei Xueint main(void) { return offsetof(struct stat, st_atim); }
43698a792b03SJiufei XueEOF
43708a792b03SJiufei Xueif compile_prog "" "" ; then
43718a792b03SJiufei Xue    st_atim=yes
43728a792b03SJiufei Xuefi
43738a792b03SJiufei Xue
43745c99fa37SKeno Fischer##########################################
437594a420b1SStefan Hajnoczi# check if trace backend exists
437694a420b1SStefan Hajnoczi
43775b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
437894a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
43795b808275SLluís Vilanova  error_exit "invalid trace backends" \
43805b808275SLluís Vilanova      "Please choose supported trace backends."
438194a420b1SStefan Hajnoczifi
438294a420b1SStefan Hajnoczi
43837e24e92aSStefan Hajnoczi##########################################
43847e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
43855b808275SLluís Vilanovaif have_backend "ust"; then
43867e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4387bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
43887e24e92aSStefan Hajnocziint main(void) { return 0; }
43897e24e92aSStefan HajnocziEOF
4390c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4391bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
439289138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
43937e24e92aSStefan Hajnoczi    else
4394c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4395bf15f63cSMohamad Gebai    fi
4396bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
439789138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4398bf15f63cSMohamad Gebai    else
4399bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4400bf15f63cSMohamad Gebai    fi
4401bf15f63cSMohamad Gebai  else
4402bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
44037e24e92aSStefan Hajnoczi  fi
44047e24e92aSStefan Hajnoczifi
4405b3d08c02SDaniel P. Berrange
4406b3d08c02SDaniel P. Berrange##########################################
4407b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
44085b808275SLluís Vilanovaif have_backend "dtrace"; then
4409b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
441076ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4411b3d08c02SDaniel P. Berrange  fi
4412c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4413c276b17dSDaniel P. Berrange  if has 'stap' ; then
4414c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
44154b265c79SStefan Hajnoczi
44164b265c79SStefan Hajnoczi    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
44174b265c79SStefan Hajnoczi    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
44184b265c79SStefan Hajnoczi    # instead. QEMU --enable-modules depends on this because the SystemTap
44194b265c79SStefan Hajnoczi    # semaphores are linked into the main binary and not the module's shared
44204b265c79SStefan Hajnoczi    # object.
44214b265c79SStefan Hajnoczi    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
4422c276b17dSDaniel P. Berrange  fi
4423b3d08c02SDaniel P. Berrangefi
4424b3d08c02SDaniel P. Berrange
44257e24e92aSStefan Hajnoczi##########################################
4426519175a2SAlex Barcelo# check and set a backend for coroutine
4427d0e2fce5SAneesh Kumar K.V
44287c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
442933c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
443033c53c54SDaniel P. Berrange# specific one.
44317c2acc70SPeter Maydell
44327c2acc70SPeter Maydellucontext_works=no
4433d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4434d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4435d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4436cdf84806SPeter Maydell#ifdef __stub_makecontext
4437cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4438cdf84806SPeter Maydell#endif
443975cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4440d0e2fce5SAneesh Kumar K.VEOF
4441d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
44427c2acc70SPeter Maydell    ucontext_works=yes
4443d0e2fce5SAneesh Kumar K.V  fi
4444519175a2SAlex Barcelofi
44457c2acc70SPeter Maydell
44467c2acc70SPeter Maydellif test "$coroutine" = ""; then
44477c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
44487c2acc70SPeter Maydell    coroutine=win32
44497c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
44507c2acc70SPeter Maydell    coroutine=ucontext
4451519175a2SAlex Barcelo  else
44527c2acc70SPeter Maydell    coroutine=sigaltstack
44537c2acc70SPeter Maydell  fi
44547c2acc70SPeter Maydellelse
44557c2acc70SPeter Maydell  case $coroutine in
44567c2acc70SPeter Maydell  windows)
44577c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
44587c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
44597c2acc70SPeter Maydell    fi
44607c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
44617c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
44627c2acc70SPeter Maydell    coroutine=win32
44637c2acc70SPeter Maydell    ;;
44647c2acc70SPeter Maydell  ucontext)
44657c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
44667c2acc70SPeter Maydell      feature_not_found "ucontext"
44677c2acc70SPeter Maydell    fi
44687c2acc70SPeter Maydell    ;;
446933c53c54SDaniel P. Berrange  sigaltstack)
44707c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
44717c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
44727c2acc70SPeter Maydell    fi
44737c2acc70SPeter Maydell    ;;
44747c2acc70SPeter Maydell  *)
447576ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
44767c2acc70SPeter Maydell    ;;
44777c2acc70SPeter Maydell  esac
4478d0e2fce5SAneesh Kumar K.Vfi
4479d0e2fce5SAneesh Kumar K.V
448070c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
448170c60c08SStefan Hajnoczi  coroutine_pool=yes
448270c60c08SStefan Hajnoczifi
448370c60c08SStefan Hajnoczi
44847d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
44857d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
44867d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
44877d992e4dSPeter Lieven    coroutine_pool=no
44887d992e4dSPeter Lieven  fi
44897d992e4dSPeter Lievenfi
44907d992e4dSPeter Lieven
44911e4f6065SDaniele Buono##################################################
44921e4f6065SDaniele Buono# SafeStack
44931e4f6065SDaniele Buono
44941e4f6065SDaniele Buono
44951e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
44961e4f6065SDaniele Buonocat > $TMPC << EOF
44971e4f6065SDaniele Buonoint main(int argc, char *argv[])
44981e4f6065SDaniele Buono{
44991e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
45001e4f6065SDaniele Buono#error SafeStack Disabled
45011e4f6065SDaniele Buono#endif
45021e4f6065SDaniele Buono    return 0;
45031e4f6065SDaniele Buono}
45041e4f6065SDaniele BuonoEOF
45051e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
45061e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
45071e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
45081e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
45091e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
45101e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
45111e4f6065SDaniele Buono  else
45121e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
45131e4f6065SDaniele Buono  fi
45141e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
45151e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
45161e4f6065SDaniele Buono  fi
45171e4f6065SDaniele Buonoelse
45181e4f6065SDaniele Buonocat > $TMPC << EOF
45191e4f6065SDaniele Buonoint main(int argc, char *argv[])
45201e4f6065SDaniele Buono{
45211e4f6065SDaniele Buono#if defined(__has_feature)
45221e4f6065SDaniele Buono#if __has_feature(safe_stack)
45231e4f6065SDaniele Buono#error SafeStack Enabled
45241e4f6065SDaniele Buono#endif
45251e4f6065SDaniele Buono#endif
45261e4f6065SDaniele Buono    return 0;
45271e4f6065SDaniele Buono}
45281e4f6065SDaniele BuonoEOF
45291e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
45301e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
45311e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
45321e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
45331e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
45341e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
45351e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
45361e4f6065SDaniele Buono    fi
45371e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
45381e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
45391e4f6065SDaniele Buono  fi
45401e4f6065SDaniele Buonoelse # "$safe_stack" = ""
45411e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
45421e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
45431e4f6065SDaniele Buono    safe_stack="no"
45441e4f6065SDaniele Buono  else
45451e4f6065SDaniele Buono    safe_stack="yes"
45461e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
45471e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
45481e4f6065SDaniele Buono    fi
45491e4f6065SDaniele Buono  fi
45501e4f6065SDaniele Buonofi
45511e4f6065SDaniele Buonofi
45527d992e4dSPeter Lieven
4553d0e2fce5SAneesh Kumar K.V##########################################
4554d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4555d2042378SAneesh Kumar K.V
45564e1797f9SStefan Weilopen_by_handle_at=no
4557d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4558d2042378SAneesh Kumar K.V#include <fcntl.h>
4559acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4560acc55ba8SStefan Weil# error missing definition
4561acc55ba8SStefan Weil#else
456275cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4563acc55ba8SStefan Weil#endif
4564d2042378SAneesh Kumar K.VEOF
4565d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4566d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4567d2042378SAneesh Kumar K.Vfi
4568d2042378SAneesh Kumar K.V
4569e06a765eSHarsh Prateek Bora########################################
4570e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
4571e06a765eSHarsh Prateek Bora
4572e06a765eSHarsh Prateek Boralinux_magic_h=no
4573e06a765eSHarsh Prateek Boracat > $TMPC << EOF
4574e06a765eSHarsh Prateek Bora#include <linux/magic.h>
4575e06a765eSHarsh Prateek Boraint main(void) {
457675cafad7SStefan Weil  return 0;
4577e06a765eSHarsh Prateek Bora}
4578e06a765eSHarsh Prateek BoraEOF
4579e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
4580e06a765eSHarsh Prateek Bora    linux_magic_h=yes
4581e06a765eSHarsh Prateek Borafi
4582e06a765eSHarsh Prateek Bora
45838ab1bf12SLuiz Capitulino########################################
4584541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
45853f4349dcSKevin Wolf
45863f4349dcSKevin Wolfvalgrind_h=no
45873f4349dcSKevin Wolfcat > $TMPC << EOF
45883f4349dcSKevin Wolf#include <valgrind/valgrind.h>
45893f4349dcSKevin Wolfint main(void) {
45903f4349dcSKevin Wolf  return 0;
45913f4349dcSKevin Wolf}
45923f4349dcSKevin WolfEOF
45933f4349dcSKevin Wolfif compile_prog "" "" ; then
45943f4349dcSKevin Wolf    valgrind_h=yes
45953f4349dcSKevin Wolffi
45963f4349dcSKevin Wolf
45973f4349dcSKevin Wolf########################################
45988ab1bf12SLuiz Capitulino# check if environ is declared
45998ab1bf12SLuiz Capitulino
46008ab1bf12SLuiz Capitulinohas_environ=no
46018ab1bf12SLuiz Capitulinocat > $TMPC << EOF
46028ab1bf12SLuiz Capitulino#include <unistd.h>
46038ab1bf12SLuiz Capitulinoint main(void) {
4604c075a723SBlue Swirl    environ = 0;
46058ab1bf12SLuiz Capitulino    return 0;
46068ab1bf12SLuiz Capitulino}
46078ab1bf12SLuiz CapitulinoEOF
46088ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
46098ab1bf12SLuiz Capitulino    has_environ=yes
46108ab1bf12SLuiz Capitulinofi
46118ab1bf12SLuiz Capitulino
461276a347e1SRichard Henderson########################################
461376a347e1SRichard Henderson# check if cpuid.h is usable.
461476a347e1SRichard Henderson
461576a347e1SRichard Hendersoncat > $TMPC << EOF
461676a347e1SRichard Henderson#include <cpuid.h>
461776a347e1SRichard Hendersonint main(void) {
4618774d566cSPeter Maydell    unsigned a, b, c, d;
4619774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
4620774d566cSPeter Maydell
4621774d566cSPeter Maydell    if (max >= 1) {
4622774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
4623774d566cSPeter Maydell    }
4624774d566cSPeter Maydell
4625774d566cSPeter Maydell    if (max >= 7) {
4626774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
4627774d566cSPeter Maydell    }
4628774d566cSPeter Maydell
462976a347e1SRichard Henderson    return 0;
463076a347e1SRichard Henderson}
463176a347e1SRichard HendersonEOF
463276a347e1SRichard Hendersonif compile_prog "" "" ; then
463376a347e1SRichard Henderson    cpuid_h=yes
463476a347e1SRichard Hendersonfi
463576a347e1SRichard Henderson
46365dd89908SRichard Henderson##########################################
46375dd89908SRichard Henderson# avx2 optimization requirement check
46385dd89908SRichard Henderson#
46395dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
46405dd89908SRichard Henderson# since we won't be able to select the new routines.
46415dd89908SRichard Henderson
4642e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
46435dd89908SRichard Henderson  cat > $TMPC << EOF
46445dd89908SRichard Henderson#pragma GCC push_options
46455dd89908SRichard Henderson#pragma GCC target("avx2")
46465dd89908SRichard Henderson#include <cpuid.h>
46475dd89908SRichard Henderson#include <immintrin.h>
46485dd89908SRichard Hendersonstatic int bar(void *a) {
46495dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
46505dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
46515dd89908SRichard Henderson}
46525dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
46535dd89908SRichard HendersonEOF
46545dd89908SRichard Henderson  if compile_object "" ; then
46555dd89908SRichard Henderson    avx2_opt="yes"
465686583a07SLiam Merwick  else
465786583a07SLiam Merwick    avx2_opt="no"
46585dd89908SRichard Henderson  fi
46595dd89908SRichard Hendersonfi
46605dd89908SRichard Henderson
46616b8cd447SRobert Hoo##########################################
46626b8cd447SRobert Hoo# avx512f optimization requirement check
46636b8cd447SRobert Hoo#
46646b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
46656b8cd447SRobert Hoo# since we won't be able to select the new routines.
46666b8cd447SRobert Hoo# by default, it is turned off.
46676b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
46686b8cd447SRobert Hoo
46696b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
46706b8cd447SRobert Hoo  cat > $TMPC << EOF
46716b8cd447SRobert Hoo#pragma GCC push_options
46726b8cd447SRobert Hoo#pragma GCC target("avx512f")
46736b8cd447SRobert Hoo#include <cpuid.h>
46746b8cd447SRobert Hoo#include <immintrin.h>
46756b8cd447SRobert Hoostatic int bar(void *a) {
46766b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
46776b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
46786b8cd447SRobert Hoo}
46796b8cd447SRobert Hooint main(int argc, char *argv[])
46806b8cd447SRobert Hoo{
46816b8cd447SRobert Hoo	return bar(argv[0]);
46826b8cd447SRobert Hoo}
46836b8cd447SRobert HooEOF
46846b8cd447SRobert Hoo  if ! compile_object "" ; then
46856b8cd447SRobert Hoo    avx512f_opt="no"
46866b8cd447SRobert Hoo  fi
46876b8cd447SRobert Hooelse
46886b8cd447SRobert Hoo  avx512f_opt="no"
46896b8cd447SRobert Hoofi
46906b8cd447SRobert Hoo
4691f540166bSRichard Henderson########################################
4692f540166bSRichard Henderson# check if __[u]int128_t is usable.
4693f540166bSRichard Henderson
4694f540166bSRichard Hendersonint128=no
4695f540166bSRichard Hendersoncat > $TMPC << EOF
4696f540166bSRichard Henderson__int128_t a;
4697f540166bSRichard Henderson__uint128_t b;
4698f540166bSRichard Hendersonint main (void) {
4699f540166bSRichard Henderson  a = a + b;
4700f540166bSRichard Henderson  b = a * b;
4701464e3671SPeter Maydell  a = a * a;
4702f540166bSRichard Henderson  return 0;
4703f540166bSRichard Henderson}
4704f540166bSRichard HendersonEOF
4705f540166bSRichard Hendersonif compile_prog "" "" ; then
4706f540166bSRichard Henderson    int128=yes
4707f540166bSRichard Hendersonfi
470876a347e1SRichard Henderson
47097ebee43eSRichard Henderson#########################################
47107ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
47117ebee43eSRichard Henderson
47127ebee43eSRichard Hendersonatomic128=no
47137ebee43eSRichard Hendersonif test "$int128" = "yes"; then
47147ebee43eSRichard Henderson  cat > $TMPC << EOF
47157ebee43eSRichard Hendersonint main(void)
47167ebee43eSRichard Henderson{
47177ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
47187ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
47197ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
47207ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
47217ebee43eSRichard Henderson  return 0;
47227ebee43eSRichard Henderson}
47237ebee43eSRichard HendersonEOF
47247ebee43eSRichard Henderson  if compile_prog "" "" ; then
47257ebee43eSRichard Henderson    atomic128=yes
47267ebee43eSRichard Henderson  fi
47277ebee43eSRichard Hendersonfi
47287ebee43eSRichard Henderson
4729e6cd4bb5SRichard Hendersoncmpxchg128=no
4730e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
4731e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
4732e6cd4bb5SRichard Hendersonint main(void)
4733e6cd4bb5SRichard Henderson{
4734e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
4735e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
4736e6cd4bb5SRichard Henderson  return 0;
4737e6cd4bb5SRichard Henderson}
4738e6cd4bb5SRichard HendersonEOF
4739e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
4740e6cd4bb5SRichard Henderson    cmpxchg128=yes
4741e6cd4bb5SRichard Henderson  fi
4742e6cd4bb5SRichard Hendersonfi
4743e6cd4bb5SRichard Henderson
4744df79b996SRichard Henderson#########################################
4745df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
4746df79b996SRichard Henderson# Note that without __atomic builtins, we can only
4747df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
4748df79b996SRichard Henderson
4749df79b996SRichard Hendersoncat > $TMPC << EOF
4750df79b996SRichard Henderson#include <stdint.h>
4751df79b996SRichard Hendersonint main(void)
4752df79b996SRichard Henderson{
4753df79b996SRichard Henderson  uint64_t x = 0, y = 0;
4754df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
47555fe40765SThomas Huth  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
47565fe40765SThomas Huth  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
47575fe40765SThomas Huth  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
47585fe40765SThomas Huth  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
47595fe40765SThomas Huth  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
4760df79b996SRichard Henderson#else
4761df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
4762df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
4763df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
4764df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
4765df79b996SRichard Henderson#endif
4766df79b996SRichard Henderson  return 0;
4767df79b996SRichard Henderson}
4768df79b996SRichard HendersonEOF
4769df79b996SRichard Hendersonif compile_prog "" "" ; then
4770df79b996SRichard Henderson  atomic64=yes
4771df79b996SRichard Hendersonfi
4772df79b996SRichard Henderson
477326fffe29SEmilio G. Cota#########################################
477426fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
477526fffe29SEmilio G. Cotald_dynamic_list="no"
477626fffe29SEmilio G. Cotaif test "$static" = "no" ; then
477726fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
477826fffe29SEmilio G. Cota{
477926fffe29SEmilio G. Cota  foo;
478026fffe29SEmilio G. Cota};
478126fffe29SEmilio G. CotaEOF
478226fffe29SEmilio G. Cota
478326fffe29SEmilio G. Cota    cat > $TMPC <<EOF
478426fffe29SEmilio G. Cota#include <stdio.h>
478526fffe29SEmilio G. Cotavoid foo(void);
478626fffe29SEmilio G. Cota
478726fffe29SEmilio G. Cotavoid foo(void)
478826fffe29SEmilio G. Cota{
478926fffe29SEmilio G. Cota  printf("foo\n");
479026fffe29SEmilio G. Cota}
479126fffe29SEmilio G. Cota
479226fffe29SEmilio G. Cotaint main(void)
479326fffe29SEmilio G. Cota{
479426fffe29SEmilio G. Cota  foo();
479526fffe29SEmilio G. Cota  return 0;
479626fffe29SEmilio G. Cota}
479726fffe29SEmilio G. CotaEOF
479826fffe29SEmilio G. Cota
479926fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
480026fffe29SEmilio G. Cota        ld_dynamic_list="yes"
480126fffe29SEmilio G. Cota    fi
480226fffe29SEmilio G. Cotafi
480326fffe29SEmilio G. Cota
480426fffe29SEmilio G. Cota#########################################
480526fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
480626fffe29SEmilio G. Cota
480726fffe29SEmilio G. Cotald_exported_symbols_list="no"
480826fffe29SEmilio G. Cotaif test "$static" = "no" ; then
480926fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
481026fffe29SEmilio G. Cota  _foo
481126fffe29SEmilio G. CotaEOF
481226fffe29SEmilio G. Cota
481326fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
481426fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
481526fffe29SEmilio G. Cota    fi
481626fffe29SEmilio G. Cotafi
481726fffe29SEmilio G. Cota
481826fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
481926fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
482026fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
482126fffe29SEmilio G. Cota  error_exit \
482226fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
482326fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
482426fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
482526fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
482626fffe29SEmilio G. Cotafi
482726fffe29SEmilio G. Cota
48281e6e9acaSRichard Henderson########################################
4829db8aaae8SRichard Henderson# See if __attribute__((alias)) is supported.
4830db8aaae8SRichard Henderson# This false for Xcode 9, but has been remedied for Xcode 10.
4831db8aaae8SRichard Henderson# Unfortunately, travis uses Xcode 9 by default.
4832db8aaae8SRichard Henderson
4833db8aaae8SRichard Hendersonattralias=no
4834db8aaae8SRichard Hendersoncat > $TMPC << EOF
4835db8aaae8SRichard Hendersonint x = 1;
4836db8aaae8SRichard Hendersonextern const int y __attribute__((alias("x")));
4837db8aaae8SRichard Hendersonint main(void) { return 0; }
4838db8aaae8SRichard HendersonEOF
4839db8aaae8SRichard Hendersonif compile_prog "" "" ; then
4840db8aaae8SRichard Henderson    attralias=yes
4841db8aaae8SRichard Hendersonfi
4842db8aaae8SRichard Henderson
4843db8aaae8SRichard Henderson########################################
48441e6e9acaSRichard Henderson# check if getauxval is available.
48451e6e9acaSRichard Henderson
48461e6e9acaSRichard Hendersongetauxval=no
48471e6e9acaSRichard Hendersoncat > $TMPC << EOF
48481e6e9acaSRichard Henderson#include <sys/auxv.h>
48491e6e9acaSRichard Hendersonint main(void) {
48501e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
48511e6e9acaSRichard Henderson}
48521e6e9acaSRichard HendersonEOF
48531e6e9acaSRichard Hendersonif compile_prog "" "" ; then
48541e6e9acaSRichard Henderson    getauxval=yes
48551e6e9acaSRichard Hendersonfi
48561e6e9acaSRichard Henderson
4857fd0e6053SJohn Snow########################################
4858fd0e6053SJohn Snow# check if ccache is interfering with
4859fd0e6053SJohn Snow# semantic analysis of macros
4860fd0e6053SJohn Snow
48615e4dfd3dSJohn Snowunset CCACHE_CPP2
4862fd0e6053SJohn Snowccache_cpp2=no
4863fd0e6053SJohn Snowcat > $TMPC << EOF
4864fd0e6053SJohn Snowstatic const int Z = 1;
4865fd0e6053SJohn Snow#define fn() ({ Z; })
4866fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
4867fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
4868fd0e6053SJohn Snow#define ID(X) (X)
4869fd0e6053SJohn Snowint main(int argc, char *argv[])
4870fd0e6053SJohn Snow{
4871fd0e6053SJohn Snow    int x = 0, y = 0;
4872fd0e6053SJohn Snow    x = ID(x);
4873fd0e6053SJohn Snow    x = fn();
4874fd0e6053SJohn Snow    fn();
4875fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
4876fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
4877fd0e6053SJohn Snow    return 0;
4878fd0e6053SJohn Snow}
4879fd0e6053SJohn SnowEOF
4880fd0e6053SJohn Snow
4881fd0e6053SJohn Snowif ! compile_object "-Werror"; then
4882fd0e6053SJohn Snow    ccache_cpp2=yes
4883fd0e6053SJohn Snowfi
4884fd0e6053SJohn Snow
4885b553a042SJohn Snow#################################################
4886b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
4887b553a042SJohn Snow
4888b553a042SJohn Snowif test "$fortify_source" != "no"; then
4889b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
4890b553a042SJohn Snow    fortify_source="no";
4891e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
4892cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
4893b553a042SJohn Snow    fortify_source="no";
4894b553a042SJohn Snow  else
4895b553a042SJohn Snow    fortify_source="yes"
4896b553a042SJohn Snow  fi
4897b553a042SJohn Snowfi
4898b553a042SJohn Snow
48991efad060SFam Zheng###############################################
49001efad060SFam Zheng# Check if copy_file_range is provided by glibc
49011efad060SFam Zhenghave_copy_file_range=no
49021efad060SFam Zhengcat > $TMPC << EOF
49031efad060SFam Zheng#include <unistd.h>
49041efad060SFam Zhengint main(void) {
49051efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
49061efad060SFam Zheng  return 0;
49071efad060SFam Zheng}
49081efad060SFam ZhengEOF
49091efad060SFam Zhengif compile_prog "" "" ; then
49101efad060SFam Zheng    have_copy_file_range=yes
49111efad060SFam Zhengfi
49121efad060SFam Zheng
4913d2042378SAneesh Kumar K.V##########################################
4914277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
4915277abf15SJan Vesely
4916277abf15SJan Veselyhave_fsxattr=no
4917277abf15SJan Veselycat > $TMPC << EOF
4918277abf15SJan Vesely#include <linux/fs.h>
4919277abf15SJan Veselystruct fsxattr foo;
4920277abf15SJan Veselyint main(void) {
4921277abf15SJan Vesely  return 0;
4922277abf15SJan Vesely}
4923277abf15SJan VeselyEOF
4924277abf15SJan Veselyif compile_prog "" "" ; then
4925277abf15SJan Vesely    have_fsxattr=yes
4926277abf15SJan Veselyfi
4927277abf15SJan Vesely
4928b66e10e4SPeter Maydell##########################################
4929a40161cbSPaolo Bonzini# check for usable membarrier system call
4930a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
4931a40161cbSPaolo Bonzini    have_membarrier=no
4932a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
4933a40161cbSPaolo Bonzini        have_membarrier=yes
4934a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
4935a40161cbSPaolo Bonzini        cat > $TMPC << EOF
4936a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
4937a40161cbSPaolo Bonzini    #include <sys/syscall.h>
4938a40161cbSPaolo Bonzini    #include <unistd.h>
4939a40161cbSPaolo Bonzini    #include <stdlib.h>
4940a40161cbSPaolo Bonzini    int main(void) {
4941a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
4942a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
4943a40161cbSPaolo Bonzini	exit(0);
4944a40161cbSPaolo Bonzini    }
4945a40161cbSPaolo BonziniEOF
4946a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
4947a40161cbSPaolo Bonzini            have_membarrier=yes
4948a40161cbSPaolo Bonzini        fi
4949a40161cbSPaolo Bonzini    fi
4950a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
4951a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
4952a40161cbSPaolo Bonzini    fi
4953a40161cbSPaolo Bonzinielse
4954a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
4955a40161cbSPaolo Bonzini    # work on Wine.
4956a40161cbSPaolo Bonzini    membarrier=no
4957a40161cbSPaolo Bonzinifi
4958a40161cbSPaolo Bonzini
4959a40161cbSPaolo Bonzini##########################################
4960b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
4961575b22b1SLaurent Vivierhave_rtnetlink=no
4962575b22b1SLaurent Viviercat > $TMPC << EOF
4963575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
4964575b22b1SLaurent Vivierint main(void) {
4965575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
4966575b22b1SLaurent Vivier}
4967575b22b1SLaurent VivierEOF
4968575b22b1SLaurent Vivierif compile_prog "" "" ; then
4969575b22b1SLaurent Vivier    have_rtnetlink=yes
4970575b22b1SLaurent Vivierfi
4971575b22b1SLaurent Vivier
49726a02c806SStefan Hajnoczi##########################################
49736a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
49746a02c806SStefan Hajnoczihave_af_vsock=no
49756a02c806SStefan Hajnoczicat > $TMPC << EOF
49766a02c806SStefan Hajnoczi#include <errno.h>
49776a02c806SStefan Hajnoczi#include <sys/types.h>
49786a02c806SStefan Hajnoczi#include <sys/socket.h>
49796a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
49806a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
49816a02c806SStefan Hajnoczi#endif
49826a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
49836a02c806SStefan Hajnocziint main(void) {
49846a02c806SStefan Hajnoczi    int sock, ret;
49856a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
49866a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
49876a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
49886a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
49896a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
49906a02c806SStefan Hajnoczi        return 0;
49916a02c806SStefan Hajnoczi    }
49926a02c806SStefan Hajnoczi    return -1;
49936a02c806SStefan Hajnoczi}
49946a02c806SStefan HajnocziEOF
49956a02c806SStefan Hajnocziif compile_prog "" "" ; then
49966a02c806SStefan Hajnoczi    have_af_vsock=yes
49976a02c806SStefan Hajnoczifi
49986a02c806SStefan Hajnoczi
4999f0d92b56SLongpeng(Mike)##########################################
5000f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
50014f67366eSThomas Huthhave_afalg=no
5002f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5003f0d92b56SLongpeng(Mike)#include <errno.h>
5004f0d92b56SLongpeng(Mike)#include <sys/types.h>
5005f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5006f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5007f0d92b56SLongpeng(Mike)int main(void) {
5008f0d92b56SLongpeng(Mike)    int sock;
5009f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5010f0d92b56SLongpeng(Mike)    return sock;
5011f0d92b56SLongpeng(Mike)}
5012f0d92b56SLongpeng(Mike)EOF
5013f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5014f0d92b56SLongpeng(Mike)    have_afalg=yes
5015f0d92b56SLongpeng(Mike)fi
5016f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5017f0d92b56SLongpeng(Mike)then
5018f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5019f0d92b56SLongpeng(Mike)    then
5020f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5021f0d92b56SLongpeng(Mike)    fi
5022f0d92b56SLongpeng(Mike)fi
5023f0d92b56SLongpeng(Mike)
5024f0d92b56SLongpeng(Mike)
50256969ec6cSJames Clarke#################################################
50264d04351fSChristopher Covington# check for sysmacros.h
50274d04351fSChristopher Covington
50284d04351fSChristopher Covingtonhave_sysmacros=no
50294d04351fSChristopher Covingtoncat > $TMPC << EOF
50304d04351fSChristopher Covington#include <sys/sysmacros.h>
50314d04351fSChristopher Covingtonint main(void) {
50324d04351fSChristopher Covington    return makedev(0, 0);
50334d04351fSChristopher Covington}
50344d04351fSChristopher CovingtonEOF
50354d04351fSChristopher Covingtonif compile_prog "" "" ; then
50364d04351fSChristopher Covington    have_sysmacros=yes
50374d04351fSChristopher Covingtonfi
50384d04351fSChristopher Covington
50394d04351fSChristopher Covington##########################################
504049e00a18SAndreas Grapentin# check for _Static_assert()
504149e00a18SAndreas Grapentin
504249e00a18SAndreas Grapentinhave_static_assert=no
504349e00a18SAndreas Grapentincat > $TMPC << EOF
504449e00a18SAndreas Grapentin_Static_assert(1, "success");
504549e00a18SAndreas Grapentinint main(void) {
504649e00a18SAndreas Grapentin    return 0;
504749e00a18SAndreas Grapentin}
504849e00a18SAndreas GrapentinEOF
504949e00a18SAndreas Grapentinif compile_prog "" "" ; then
505049e00a18SAndreas Grapentin    have_static_assert=yes
505149e00a18SAndreas Grapentinfi
505249e00a18SAndreas Grapentin
505349e00a18SAndreas Grapentin##########################################
5054e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5055e674605fSTomáš Golembiovský
5056e674605fSTomáš Golembiovskýhave_utmpx=no
5057e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5058e674605fSTomáš Golembiovský#include <utmpx.h>
5059e674605fSTomáš Golembiovskýstruct utmpx user_info;
5060e674605fSTomáš Golembiovskýint main(void) {
5061e674605fSTomáš Golembiovský    return 0;
5062e674605fSTomáš Golembiovský}
5063e674605fSTomáš GolembiovskýEOF
5064e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5065e674605fSTomáš Golembiovský    have_utmpx=yes
5066e674605fSTomáš Golembiovskýfi
5067e674605fSTomáš Golembiovský
5068e674605fSTomáš Golembiovský##########################################
5069db1ed1abSRichard Henderson# check for getrandom()
5070db1ed1abSRichard Henderson
5071db1ed1abSRichard Hendersonhave_getrandom=no
5072db1ed1abSRichard Hendersoncat > $TMPC << EOF
5073db1ed1abSRichard Henderson#include <sys/random.h>
5074db1ed1abSRichard Hendersonint main(void) {
5075db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
5076db1ed1abSRichard Henderson}
5077db1ed1abSRichard HendersonEOF
5078db1ed1abSRichard Hendersonif compile_prog "" "" ; then
5079db1ed1abSRichard Henderson    have_getrandom=yes
5080db1ed1abSRichard Hendersonfi
5081db1ed1abSRichard Henderson
5082db1ed1abSRichard Henderson##########################################
5083247724cbSMarc-André Lureau# checks for sanitizers
5084247724cbSMarc-André Lureau
5085247724cbSMarc-André Lureauhave_asan=no
5086247724cbSMarc-André Lureauhave_ubsan=no
5087d83414e1SMarc-André Lureauhave_asan_iface_h=no
5088d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5089247724cbSMarc-André Lureau
5090247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5091b9f44da2SMarc-André Lureau  write_c_skeleton
5092247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5093247724cbSMarc-André Lureau      have_asan=yes
5094247724cbSMarc-André Lureau  fi
5095b9f44da2SMarc-André Lureau
5096b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5097b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5098b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5099b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5100b9f44da2SMarc-André Lureau#include <stdlib.h>
5101b9f44da2SMarc-André Lureauint main(void) {
5102b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5103f2dfe54cSLeonid Bloch    if (tmp != NULL) {
5104b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
5105b9f44da2SMarc-André Lureau    }
5106d1abf3fcSOlaf Hering    return 1;
5107f2dfe54cSLeonid Bloch}
5108b9f44da2SMarc-André LureauEOF
5109247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5110247724cbSMarc-André Lureau      have_ubsan=yes
5111247724cbSMarc-André Lureau  fi
5112d83414e1SMarc-André Lureau
5113d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5114d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5115d83414e1SMarc-André Lureau  fi
5116d83414e1SMarc-André Lureau
5117d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5118d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5119d83414e1SMarc-André Lureauint main(void) {
5120d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5121d83414e1SMarc-André Lureau  return 0;
5122d83414e1SMarc-André Lureau}
5123d83414e1SMarc-André LureauEOF
5124d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5125d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5126d83414e1SMarc-André Lureau  fi
5127247724cbSMarc-André Lureaufi
5128247724cbSMarc-André Lureau
5129247724cbSMarc-André Lureau##########################################
5130adc28027SAlexander Bulekov# checks for fuzzer
513154c9e41dSAlexander Bulekovif test "$fuzzing" = "yes" && test -z "${LIB_FUZZING_ENGINE+xxx}"; then
5132adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
5133dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
5134adc28027SAlexander Bulekov    have_fuzzer=yes
513564ed6f92SPaolo Bonzini  else
513664ed6f92SPaolo Bonzini    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
513764ed6f92SPaolo Bonzini    exit 1
5138adc28027SAlexander Bulekov  fi
5139adc28027SAlexander Bulekovfi
5140adc28027SAlexander Bulekov
51410aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
51420aebab04SLingfeng Yang# keep it separate until that is not the case.
51430aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
51440aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
51450aebab04SLingfeng Yangfi
51460aebab04SLingfeng Yanghave_tsan=no
51470aebab04SLingfeng Yanghave_tsan_iface_fiber=no
51480aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
51490aebab04SLingfeng Yang  write_c_skeleton
51500aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
51510aebab04SLingfeng Yang      have_tsan=yes
51520aebab04SLingfeng Yang  fi
51530aebab04SLingfeng Yang  cat > $TMPC << EOF
51540aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
51550aebab04SLingfeng Yangint main(void) {
51560aebab04SLingfeng Yang  __tsan_create_fiber(0);
51570aebab04SLingfeng Yang  return 0;
51580aebab04SLingfeng Yang}
51590aebab04SLingfeng YangEOF
51600aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
51610aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
51620aebab04SLingfeng Yang  fi
51630aebab04SLingfeng Yangfi
51640aebab04SLingfeng Yang
5165adc28027SAlexander Bulekov##########################################
516617824406SJunyan He# check for libpmem
516717824406SJunyan He
516817824406SJunyan Heif test "$libpmem" != "no"; then
516917824406SJunyan He	if $pkg_config --exists "libpmem"; then
517017824406SJunyan He		libpmem="yes"
517117824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
517217824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
517317824406SJunyan He	else
517417824406SJunyan He		if test "$libpmem" = "yes" ; then
517517824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
517617824406SJunyan He		fi
517717824406SJunyan He		libpmem="no"
517817824406SJunyan He	fi
517917824406SJunyan Hefi
518017824406SJunyan He
518117824406SJunyan He##########################################
518221b2eca6SJingqi Liu# check for libdaxctl
518321b2eca6SJingqi Liu
518421b2eca6SJingqi Liuif test "$libdaxctl" != "no"; then
518521b2eca6SJingqi Liu	if $pkg_config --atleast-version=57 "libdaxctl"; then
518621b2eca6SJingqi Liu		libdaxctl="yes"
518721b2eca6SJingqi Liu		libdaxctl_libs=$($pkg_config --libs libdaxctl)
518821b2eca6SJingqi Liu		libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
518921b2eca6SJingqi Liu	else
519021b2eca6SJingqi Liu		if test "$libdaxctl" = "yes" ; then
519121b2eca6SJingqi Liu			feature_not_found "libdaxctl" "Install libdaxctl"
519221b2eca6SJingqi Liu		fi
519321b2eca6SJingqi Liu		libdaxctl="no"
519421b2eca6SJingqi Liu	fi
519521b2eca6SJingqi Liufi
519621b2eca6SJingqi Liu
519721b2eca6SJingqi Liu##########################################
5198675b9b53SMarc-André Lureau# check for slirp
5199675b9b53SMarc-André Lureau
5200675b9b53SMarc-André Lureaucase "$slirp" in
52014d34a86bSPaolo Bonzini  auto | enabled | internal)
52024d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
52034d34a86bSPaolo Bonzini    if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
52047c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
52057c57bdd8SMarc-André Lureau    fi
5206675b9b53SMarc-André Lureau    ;;
5207675b9b53SMarc-André Lureauesac
5208675b9b53SMarc-André Lureau
520954e7aac0SAlexey Krasikov##########################################
521054e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
521154e7aac0SAlexey Krasikov
521254e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
521354e7aac0SAlexey Krasikov
521454e7aac0SAlexey Krasikov    have_keyring=no
521554e7aac0SAlexey Krasikov    cat > $TMPC << EOF
521654e7aac0SAlexey Krasikov#include <errno.h>
521754e7aac0SAlexey Krasikov#include <asm/unistd.h>
521854e7aac0SAlexey Krasikov#include <linux/keyctl.h>
521954e7aac0SAlexey Krasikov#include <unistd.h>
522054e7aac0SAlexey Krasikovint main(void) {
522154e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
522254e7aac0SAlexey Krasikov}
522354e7aac0SAlexey KrasikovEOF
522454e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
522554e7aac0SAlexey Krasikov        have_keyring=yes
522654e7aac0SAlexey Krasikov    fi
522754e7aac0SAlexey Krasikovfi
522854e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
522954e7aac0SAlexey Krasikovthen
5230b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
523154e7aac0SAlexey Krasikov    then
523254e7aac0SAlexey Krasikov	secret_keyring=yes
523354e7aac0SAlexey Krasikov    else
523454e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
523554e7aac0SAlexey Krasikov	then
523654e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
523754e7aac0SAlexey Krasikovbut not implemented on your system"
523854e7aac0SAlexey Krasikov	else
523954e7aac0SAlexey Krasikov	    secret_keyring=no
524054e7aac0SAlexey Krasikov	fi
524154e7aac0SAlexey Krasikov    fi
524254e7aac0SAlexey Krasikovfi
524354e7aac0SAlexey Krasikov
524492500362SAlexey Krasikov##########################################
5245e86ecd4bSJuan Quintela# End of CC checks
5246e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5247e86ecd4bSJuan Quintela
5248d83414e1SMarc-André Lureauwrite_c_skeleton
5249d83414e1SMarc-André Lureau
52501d728c39SBlue Swirlif test "$gcov" = "yes" ; then
5251bf0e56a3SMarc-André Lureau  :
5252b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5253086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
5254086d5f75SPaolo Bonzini  debug=no
5255086d5f75SPaolo Bonzinifi
5256086d5f75SPaolo Bonzini
5257086d5f75SPaolo Bonzinicase "$ARCH" in
5258086d5f75SPaolo Bonzinialpha)
5259086d5f75SPaolo Bonzini  # Ensure there's only a single GP
5260086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
5261086d5f75SPaolo Bonzini;;
5262086d5f75SPaolo Bonziniesac
5263086d5f75SPaolo Bonzini
5264086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
5265086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
5266086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
5267086d5f75SPaolo Bonzinifi
5268a316e378SJuan Quintela
5269247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5270db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
5271db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
5272d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5273d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5274d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5275d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5276d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5277d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5278d83414e1SMarc-André Lureau  fi
5279247724cbSMarc-André Lureaufi
52800aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
52810aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
52820aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
52830aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
52840aebab04SLingfeng Yang  else
52850aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
52860aebab04SLingfeng Yang  fi
52870aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
52880aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
52890aebab04SLingfeng Yangfi
5290247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5291db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
5292db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
5293247724cbSMarc-André Lureaufi
5294247724cbSMarc-André Lureau
52956542aa9cSPeter Lieven##########################################
52963efac6ebSTomáš Golembiovský
52970aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
52980aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
5299e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5300db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
5301e86ecd4bSJuan Quintela    fi
5302e86ecd4bSJuan Quintelafi
5303e86ecd4bSJuan Quintela
5304952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5305952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5306cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
5307cb8baa77SMark Cave-Ayland
5308cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
5309cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
5310cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
5311cb8baa77SMark Cave-Ayland    fi
5312cb8baa77SMark Cave-Ayland
5313cb8baa77SMark Cave-Ayland    for flag in $flags; do
5314e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5315db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
5316952afb71SBlue Swirl        fi
5317952afb71SBlue Swirl    done
5318952afb71SBlue Swirlfi
5319952afb71SBlue Swirl
5320e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5321e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5322e0580342SKamil Rytarowski  ivshmem=yes
5323e0580342SKamil Rytarowskifi
5324e0580342SKamil Rytarowski
53259d6bc27bSMichael Roth# Probe for guest agent support/options
53269d6bc27bSMichael Roth
5327e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5328a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
5329a5125905SLaurent Vivier      guest_agent=no
5330a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5331e8ef31a3SMichael Tokarev      guest_agent=yes
5332e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5333e8ef31a3SMichael Tokarev      guest_agent=no
5334e8ef31a3SMichael Tokarev  else
5335e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5336ca35f780SPaolo Bonzini  fi
53374b1c11fdSDaniel P. Berrangefi
5338ca35f780SPaolo Bonzini
5339b846ab7cSPaolo Bonzini# Guest agent Windows MSI package
53409d6bc27bSMichael Roth
53419d6bc27bSMichael Rothif test "$QEMU_GA_MANUFACTURER" = ""; then
53429d6bc27bSMichael Roth  QEMU_GA_MANUFACTURER=QEMU
53439d6bc27bSMichael Rothfi
53449d6bc27bSMichael Rothif test "$QEMU_GA_DISTRO" = ""; then
53459d6bc27bSMichael Roth  QEMU_GA_DISTRO=Linux
53469d6bc27bSMichael Rothfi
53479d6bc27bSMichael Rothif test "$QEMU_GA_VERSION" = ""; then
534889138857SStefan Weil    QEMU_GA_VERSION=$(cat $source_path/VERSION)
53499d6bc27bSMichael Rothfi
53509d6bc27bSMichael Roth
5351b846ab7cSPaolo BonziniQEMU_GA_MSI_MINGW_DLL_PATH="$($pkg_config --variable=prefix glib-2.0)/bin"
53529d6bc27bSMichael Roth
5353ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5354ca35f780SPaolo Bonziniroms=
5355e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
5356e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
53577000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
5358e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5359c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5360c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5361c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5362e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5363e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5364ca35f780SPaolo Bonzini            roms="optionrom"
5365e57218b6SPeter Maydell            break
5366e57218b6SPeter Maydell        fi
5367e57218b6SPeter Maydell    done
5368ca35f780SPaolo Bonzinifi
5369ca35f780SPaolo Bonzini
53702e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
53719933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
53722e33c3f8SThomas Huth  write_c_skeleton
53732e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
53749933c305SChristian Borntraeger    roms="$roms s390-ccw"
53751ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
53761ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
53771ef6bfc2SPhilippe Mathieu-Daudé    if test -e "${source_path}/.git" ; then
53781ef6bfc2SPhilippe Mathieu-Daudé      git_submodules="${git_submodules} roms/SLOF"
53791ef6bfc2SPhilippe Mathieu-Daudé    fi
53809933c305SChristian Borntraeger  fi
53812e33c3f8SThomas Huthfi
53829933c305SChristian Borntraeger
538311cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
538411cde1c8SBruno 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.
538511cde1c8SBruno Dominguezif has $cxx; then
538611cde1c8SBruno Dominguez    cat > $TMPC <<EOF
538711cde1c8SBruno Dominguezint c_function(void);
538811cde1c8SBruno Dominguezint main(void) { return c_function(); }
538911cde1c8SBruno DominguezEOF
539011cde1c8SBruno Dominguez
539111cde1c8SBruno Dominguez    compile_object
539211cde1c8SBruno Dominguez
539311cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
539411cde1c8SBruno Dominguezextern "C" {
539511cde1c8SBruno Dominguez   int c_function(void);
539611cde1c8SBruno Dominguez}
539711cde1c8SBruno Dominguezint c_function(void) { return 42; }
539811cde1c8SBruno DominguezEOF
539911cde1c8SBruno Dominguez
540011cde1c8SBruno Dominguez    update_cxxflags
540111cde1c8SBruno Dominguez
54025770e8afSPaolo Bonzini    if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
540311cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
540411cde1c8SBruno Dominguez        :
540511cde1c8SBruno Dominguez    else
540611cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
540711cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
540811cde1c8SBruno Dominguez        cxx=
540911cde1c8SBruno Dominguez    fi
541011cde1c8SBruno Dominguezelse
541111cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
541211cde1c8SBruno Dominguez    cxx=
541311cde1c8SBruno Dominguezfi
541411cde1c8SBruno Dominguez
54155d91a2edSYonggang Luoif test $git_update = 'yes' ; then
54165d91a2edSYonggang Luo    (cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
54175d91a2edSYonggang Luofi
54185d91a2edSYonggang Luo
541998ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
542097a847bcSbellard
542198ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
542298ec69acSJuan Quintelaecho >> $config_host_mak
542398ec69acSJuan Quintela
5424e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
5425cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
5426aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5427f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
5428804edf29SJuan Quintela
542998ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5430727e5283SPaolo Bonzini
5431f8393946Saurel32if test "$debug_tcg" = "yes" ; then
54322358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5433f8393946Saurel32fi
54341625af87Saliguoriif test "$strip_opt" = "yes" ; then
543552ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
54361625af87Saliguorifi
54377d13299dSbellardif test "$bigendian" = "yes" ; then
5438e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
543997a847bcSbellardfi
544067b915a5Sbellardif test "$mingw32" = "yes" ; then
544198ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
5442d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5443d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5444f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5445d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5446d9840e25STomoki Sekiyama  fi
544750cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
544876dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
544950cbebb9SMichael Roth  fi
54509dacf32dSYossi Hindin  echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
54519dacf32dSYossi Hindin  echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
54529dacf32dSYossi Hindin  echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
54539dacf32dSYossi Hindin  echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
5454210fa556Spbrookelse
545535f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5456210fa556Spbrookfi
5457128ab2ffSblueswir1
5458dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5459dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5460dffcb71cSMark McLoughlinfi
5461dffcb71cSMark McLoughlin
546283fb7adfSbellardif test "$darwin" = "yes" ; then
546398ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
546483fb7adfSbellardfi
5465b29fe3edSmalc
5466ec530c81Sbellardif test "$solaris" = "yes" ; then
546798ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5468ec530c81Sbellardfi
5469179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5470179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5471179cf400SAndreas Färberfi
547297a847bcSbellardif test "$static" = "yes" ; then
547398ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
547497a847bcSbellardfi
54751ba16968SStefan Weilif test "$profiler" = "yes" ; then
54762358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
547705c2a3e7Sbellardfi
5478c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
5479c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
5480c932ce31SPaolo Bonzinifi
5481f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
5482f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
5483f15bff25SPaolo Bonzinifi
5484e2d8830eSBradecho "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
54858a16d273Sthsif test "$vde" = "yes" ; then
548698ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
5487e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
54888a16d273Sthsfi
548958952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
549058952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
549158952137SVincenzo Maffionefi
5492015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
5493015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
5494015a33bdSGongleifi
54954cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
54964cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
54974cc600d2SPaolo Bonzinifi
54982358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
54990c58ac1cSmalcfor drv in $audio_drv_list; do
55001ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
5501484e2cc7SPaolo Bonzini    echo "$def=y" >> $config_host_mak
55020c58ac1cSmalcdone
5503478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
5504478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
5505478e943fSPaolo Bonzinifi
5506b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
5507478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
5508478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
5509478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
5510478e943fSPaolo Bonzinifi
5511b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
5512478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
5513b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
5514b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
5515b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
5516478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
5517478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
5518478e943fSPaolo Bonzinifi
55192e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
5520d5631638Smalcif test "$audio_win_int" = "yes" ; then
5521d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
5522d5631638Smalcfi
5523b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
5524b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
5525dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
5526dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
5527dce512deSChristoph Hellwigfi
552889138857SStefan Weilqemu_version=$(head $source_path/VERSION)
55292358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
553098ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
55312b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
553217969268SFam Zhengif test "$modules" = "yes"; then
5533e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
5534e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
553589138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
553617969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
553717969268SFam Zhengfi
5538bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
5539bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
5540bd83c861SChristian Ehrhardtfi
5541099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
55422358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
5543099d6b0fSRiku Voipiofi
554440ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
554540ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
554640ff6d7eSKevin Wolffi
55473ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
55482358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
55493ce34dfbSvibisreenivasanfi
5550c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
5551c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
5552c2882b96SRiku Voipiofi
5553751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
5554751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
5555751bcc39SMarc-André Lureaufi
5556955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
5557955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
5558955727d2SCortland Tölvafi
5559d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
5560d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
5561d0927938SUlrich Hechtfi
55623d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
55633d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
55643d4fa43eSKusanagi Kouichifi
5565b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
5566b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
5567b953f075SDenis V. Lunevfi
5568ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
5569ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
5570ed911435SKevin Wolffi
5571c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
5572c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
5573c727f47dSPeter Maydellfi
5574dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
5575dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
5576dace20dcSPeter Maydellfi
5577d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
5578d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
5579d0927938SUlrich Hechtfi
55804e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
55814e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
55824e0c6529SAlex Blighfi
5583cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
5584cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
5585cd758dd0SAlex Blighfi
55863b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
55873b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
55883b6edd16SPeter Maydellfi
55893b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
55903b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
55913b6edd16SPeter Maydellfi
5592a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
5593a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
5594a8fd1abaSPeter Maydellfi
559551834341SRiku Voipioif test "$timerfd" = "yes" ; then
559651834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
559751834341SRiku Voipiofi
55989af5c906SRiku Voipioif test "$setns" = "yes" ; then
55999af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
56009af5c906SRiku Voipiofi
560138860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
560238860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
560338860a03SAleksandar Markovicfi
56045a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
56055a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
56065a03cd00SAleksandar Markovicfi
56073b3f24adSaurel32if test "$inotify" = "yes" ; then
56082358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
56093b3f24adSaurel32fi
5610c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
5611c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
5612c05c7a73SRiku Voipiofi
5613401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
5614401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
5615401bc051SPeter Maydellfi
56165c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
56175c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
56185c99fa37SKeno Fischerfi
56198a792b03SJiufei Xueif test "$st_atim" = "yes" ; then
56208a792b03SJiufei Xue  echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
56218a792b03SJiufei Xuefi
56226ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
56236ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
56246ae9a1f4SJuan Quintelafi
56256ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
56266ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
56276ae9a1f4SJuan Quintelafi
5628f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
5629f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
5630f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
5631f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
563225a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
5633f876b765SMarc-André Lureaufi
5634a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
5635ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
5636ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
5637a81df1b6SPaolo Bonzini  echo "GNUTLS_CFLAGS=$gnutls_cflags" >> $config_host_mak
5638a81df1b6SPaolo Bonzini  echo "GNUTLS_LIBS=$gnutls_libs" >> $config_host_mak
5639ddbb0d09SDaniel P. Berrangefi
564091bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
564191bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
56421f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
56431f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
56441f923c70SLongpeng(Mike)  fi
564546859d93SDaniel P. Berrangé  echo "GCRYPT_CFLAGS=$gcrypt_cflags" >> $config_host_mak
564646859d93SDaniel P. Berrangé  echo "GCRYPT_LIBS=$gcrypt_libs" >> $config_host_mak
564762893b67SDaniel P. Berrangefi
564891bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
564991bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
5650becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
5651a81df1b6SPaolo Bonzini  echo "NETTLE_CFLAGS=$nettle_cflags" >> $config_host_mak
5652a81df1b6SPaolo Bonzini  echo "NETTLE_LIBS=$nettle_libs" >> $config_host_mak
5653ed754746SDaniel P. Berrangefi
5654e0576942SDaniel P. Berrangéif test "$qemu_private_xts" = "yes" ; then
5655e0576942SDaniel P. Berrangé  echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
5656e0576942SDaniel P. Berrangéfi
56579a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
56589a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
56599a2fd434SDaniel P. Berrangefi
56608953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
56618953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
56628953caf3SDaniel P. Berrangefi
56636b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
56646b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
56656b39b063SEric Blakefi
56669df8b20dSThomas Huthif test "$have_openpty" = "yes" ; then
56679df8b20dSThomas Huth    echo "HAVE_OPENPTY=y" >> $config_host_mak
56689df8b20dSThomas Huthfi
5669277abf15SJan Vesely
5670277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
5671277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
5672277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
5673277abf15SJan Vesely# if this macro is set.
5674277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
5675277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
5676277abf15SJan Veselyfi
56771efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
56781efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
56791efad060SFam Zhengfi
5680bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
5681bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
5682a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
5683e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
5684a4ccabcfSAnthony Liguorifi
56859d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
56869d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
56879d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
56889d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
56899d9e1521SGerd Hoffmannfi
56901badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
56916dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
5692d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
5693582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
5694582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
5695e37630caSaliguorifi
56965c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
56975c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
56985c6c3a6cSChristoph Hellwigfi
5699c10dd856SAarushi Mehtaif test "$linux_io_uring" = "yes" ; then
5700c10dd856SAarushi Mehta  echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
5701c10dd856SAarushi Mehta  echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
5702c10dd856SAarushi Mehta  echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
5703c10dd856SAarushi Mehtafi
57045e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
57055e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
57065e9be92dSNicholas Bellingerfi
5707af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
5708af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
5709af3bba76SPaolo Bonzinifi
5710af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
571156f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
571203ce5744SNikolay Nikolaevfi
5713108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
5714108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
5715108a6481SCindy Lufi
5716042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
5717042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
5718042cea27SGongleifi
5719fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
5720fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
57215fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
57225fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
57235fe97d88SStefano Garzarella  fi
5724fc0b9b0eSStefan Hajnoczifi
5725299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
5726299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
5727299e6f19SPaolo Bonzinifi
5728e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
5729e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
5730e6a74868SMarc-André Lureaufi
5731108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
5732108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
5733108a6481SCindy Lufi
573498fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
573598fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
573698fc1adaSDr. David Alan Gilbertfi
5737bf9298b9Saliguoriif test "$iovec" = "yes" ; then
57382358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
5739bf9298b9Saliguorifi
5740a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
5741a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
5742a40161cbSPaolo Bonzinifi
5743dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
5744dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
5745dcc38d1cSMarcelo Tosattifi
5746d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
5747d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
5748d339d766SRichard W.M. Jonesfi
57495f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
57505f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
57515f6b9e8fSBlue Swirlfi
5752e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
5753e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
5754e78815a5SAndreas Färberfi
5755e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
5756e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
5757e78815a5SAndreas Färberfi
57589bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
57599bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
57609bc5a719SAndreas Gustafssonfi
5761cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
5762cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
57632634733cSPaolo Bonzini  echo "SPICE_CFLAGS=$spice_cflags" >> $config_host_mak
57642634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
5765cd4ec0b4SGerd Hoffmannfi
5766cd4ec0b4SGerd Hoffmann
57677b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
57687b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
57697b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
57707b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
5771111a38b0SRobert Relyeafi
5772111a38b0SRobert Relyea
57732b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
57742b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
5775b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
5776b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
57772b2325ffSGerd Hoffmannfi
57782b2325ffSGerd Hoffmann
577969354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
578069354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
5781cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
5782cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
578369354a83SHans de Goedefi
578469354a83SHans de Goede
5785da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
5786da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
5787de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
5788da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
5789014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
5790014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
5791014cb152SGerd Hoffmann  fi
579220ff075bSMichael Wallefi
579320ff075bSMichael Walle
5794d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
5795d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
5796d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
5797d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
5798d52c454aSMarc-André Lureaufi
5799d52c454aSMarc-André Lureau
5800d52c454aSMarc-André Lureau
580199f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
580299f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
580399f2dbd3SLiang Lifi
580499f2dbd3SLiang Li
58056b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
58066b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
58076b8cd447SRobert Hoofi
58086b8cd447SRobert Hoo
580983fb7adfSbellard# XXX: suppress that
58107d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
58112358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
58127d3505c5Sbellardfi
58137d3505c5Sbellard
58143556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
58153556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
58163556c233SPaolo Bonzinifi
581720ff6c80SAnthony Liguori
58187c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
581970c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
582070c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
582170c60c08SStefan Hajnoczielse
582270c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
582370c60c08SStefan Hajnoczifi
5824d0e2fce5SAneesh Kumar K.V
58257d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
58267d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
58277d992e4dSPeter Lievenfi
58287d992e4dSPeter Lieven
5829f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
5830f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
5831f0d92b56SLongpeng(Mike)fi
5832f0d92b56SLongpeng(Mike)
5833d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
5834d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
5835d2042378SAneesh Kumar K.Vfi
5836d2042378SAneesh Kumar K.V
5837e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
5838e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
5839e06a765eSHarsh Prateek Borafi
5840e06a765eSHarsh Prateek Bora
58413f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
58423f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
58433f4349dcSKevin Wolffi
58443f4349dcSKevin Wolf
5845d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
5846d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
5847d83414e1SMarc-André Lureaufi
5848d83414e1SMarc-André Lureau
58490aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
58500aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
58510aebab04SLingfeng Yangfi
58520aebab04SLingfeng Yang
58538ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
58548ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
58558ab1bf12SLuiz Capitulinofi
58568ab1bf12SLuiz Capitulino
585776a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
585876a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
585976a347e1SRichard Hendersonfi
586076a347e1SRichard Henderson
5861f540166bSRichard Hendersonif test "$int128" = "yes" ; then
5862f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
5863f540166bSRichard Hendersonfi
5864f540166bSRichard Henderson
58657ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
58667ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
58677ebee43eSRichard Hendersonfi
58687ebee43eSRichard Henderson
5869e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
5870e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
5871e6cd4bb5SRichard Hendersonfi
5872e6cd4bb5SRichard Henderson
5873df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
5874df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
5875df79b996SRichard Hendersonfi
5876df79b996SRichard Henderson
5877db8aaae8SRichard Hendersonif test "$attralias" = "yes" ; then
5878db8aaae8SRichard Henderson  echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
5879db8aaae8SRichard Hendersonfi
5880db8aaae8SRichard Henderson
58811e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
58821e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
58831e6e9acaSRichard Hendersonfi
58841e6e9acaSRichard Henderson
5885b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
5886484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
5887b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
5888b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
58890a12ec87SRichard W.M. Jonesfi
58900a12ec87SRichard W.M. Jones
5891ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
5892ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
5893ed1701c6SDr. David Alan Gilbertfi
5894ed1701c6SDr. David Alan Gilbert
58953b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
58963cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
58973b8acc11SPaolo Bonzinifi
58983b8acc11SPaolo Bonzini
58995b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
59005b808275SLluís Vilanovaif have_backend "nop"; then
59016d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
590222890ab5SPrerna Saxenafi
59035b808275SLluís Vilanovaif have_backend "simple"; then
59046d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
59056d8a764eSLluís  # Set the appropriate trace file.
5906953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
59079410b56cSPrerna Saxenafi
5908ed7f5f1dSPaolo Bonziniif have_backend "log"; then
5909ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
59106d8a764eSLluísfi
59115b808275SLluís Vilanovaif have_backend "ust"; then
59126d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
5913a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
5914a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
59156d8a764eSLluísfi
59165b808275SLluís Vilanovaif have_backend "dtrace"; then
59176d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
59186d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
59196d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
59206d8a764eSLluís  fi
5921c276b17dSDaniel P. Berrangefi
59225b808275SLluís Vilanovaif have_backend "ftrace"; then
5923781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
5924781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
5925781e9545SEiichi Tsukata  else
592621684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
5927781e9545SEiichi Tsukata  fi
5928781e9545SEiichi Tsukatafi
59290a852417SPaul Durrantif have_backend "syslog"; then
59300a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
59310a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
59320a852417SPaul Durrant  else
59330a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
59340a852417SPaul Durrant  fi
59350a852417SPaul Durrantfi
59369410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
59379410b56cSPrerna Saxena
59382da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
59392da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
5940392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
59412da776dbSMichael R. Hinesfi
59422da776dbSMichael R. Hines
594321ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
594421ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
594521ab34c9SMarcel Apfelbaumfi
594621ab34c9SMarcel Apfelbaum
5947575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
5948575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
5949575b22b1SLaurent Vivierfi
5950575b22b1SLaurent Vivier
5951ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
5952ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
5953ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
5954ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
5955ed279a06SKlim Kireevfi
5956ed279a06SKlim Kireev
5957a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
5958a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
5959a6b1d4c0SChanglong Xiefi
5960a6b1d4c0SChanglong Xie
59616a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
59626a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
59636a02c806SStefan Hajnoczifi
59646a02c806SStefan Hajnoczi
59654d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
59664d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
59674d04351fSChristopher Covingtonfi
59684d04351fSChristopher Covington
596949e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
597049e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
597149e00a18SAndreas Grapentinfi
597249e00a18SAndreas Grapentin
5973e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
5974e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
5975e674605fSTomáš Golembiovskýfi
5976db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
5977db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
5978db1ed1abSRichard Hendersonfi
5979e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
5980e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
5981e0580342SKamil Rytarowskifi
5982ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
5983ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
5984ba59fb77SPaolo Bonzinifi
5985e0580342SKamil Rytarowski
59865c312079SDr. David Alan Gilbert# Hold two types of flag:
59875c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
59885c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
5989479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
59905c312079SDr. David Alan Gilbert#                                     platform
5991479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
59925c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5993479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
5994479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
5995479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
5996479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
59975c312079SDr. David Alan Gilbertfi
59985c312079SDr. David Alan Gilbert
599917824406SJunyan Heif test "$libpmem" = "yes" ; then
600017824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
6001c9322ab5SMarc-André Lureau  echo "LIBPMEM_LIBS=$libpmem_libs" >> $config_host_mak
6002c9322ab5SMarc-André Lureau  echo "LIBPMEM_CFLAGS=$libpmem_cflags" >> $config_host_mak
600317824406SJunyan Hefi
600417824406SJunyan He
600521b2eca6SJingqi Liuif test "$libdaxctl" = "yes" ; then
600621b2eca6SJingqi Liu  echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
6007c7c91a74SBruce Rogers  echo "LIBDAXCTL_LIBS=$libdaxctl_libs" >> $config_host_mak
600821b2eca6SJingqi Liufi
600921b2eca6SJingqi Liu
60102f740136SJeff Codyif test "$bochs" = "yes" ; then
60112f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
60122f740136SJeff Codyfi
60132f740136SJeff Codyif test "$cloop" = "yes" ; then
60142f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
60152f740136SJeff Codyfi
60162f740136SJeff Codyif test "$dmg" = "yes" ; then
60172f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
60182f740136SJeff Codyfi
60192f740136SJeff Codyif test "$qcow1" = "yes" ; then
60202f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
60212f740136SJeff Codyfi
60222f740136SJeff Codyif test "$vdi" = "yes" ; then
60232f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
60242f740136SJeff Codyfi
60252f740136SJeff Codyif test "$vvfat" = "yes" ; then
60262f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
60272f740136SJeff Codyfi
60282f740136SJeff Codyif test "$qed" = "yes" ; then
60292f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
60302f740136SJeff Codyfi
60312f740136SJeff Codyif test "$parallels" = "yes" ; then
60322f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
60332f740136SJeff Codyfi
60342f740136SJeff Codyif test "$sheepdog" = "yes" ; then
6035e1c42697SDaniel P. Berrangé  add_to deprecated_features "sheepdog"
60362f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
60372f740136SJeff Codyfi
6038195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
6039195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
6040195588ccSDavid CARLIERfi
6041adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
604254c9e41dSAlexander Bulekov  # If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the
604354c9e41dSAlexander Bulekov  # needed CFLAGS have already been provided
604454c9e41dSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
6045086d5f75SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
604654c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
604754c9e41dSAlexander Bulekov  else
604854c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
604954c9e41dSAlexander Bulekov  fi
6050adc28027SAlexander Bulekovfi
60512f740136SJeff Cody
605240e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
605340e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
605426fffe29SEmilio G. Cota    # Copy the export object list to the build dir
605526fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
605626fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
605726fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
605826fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
605926fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
606026fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
606126fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
606226fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
606326fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
606426fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
606526fffe29SEmilio G. Cota    else
606626fffe29SEmilio G. Cota	error_exit \
606726fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
606826fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
606926fffe29SEmilio G. Cota    fi
607040e8c6f4SAlex Bennéefi
607140e8c6f4SAlex Bennée
6072f48e590aSAlex Bennéeif test -n "$gdb_bin"; then
6073b1863cccSAlex Bennée    gdb_version=$($gdb_bin --version | head -n 1)
6074b1863cccSAlex Bennée    if version_ge ${gdb_version##* } 8.3.1; then
6075f48e590aSAlex Bennée        echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
6076f48e590aSAlex Bennée    fi
6077b1863cccSAlex Bennéefi
6078f48e590aSAlex Bennée
607954e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
608054e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
608154e7aac0SAlexey Krasikovfi
608254e7aac0SAlexey Krasikov
608398ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6084804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6085c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
608639d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
6087a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
608809e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
6089804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6090a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6091859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
6092a31a8642SMichael S. Tsirkinfi
609383f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
60943c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6095804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
609645d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6097cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
60985f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
60993dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6100804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6101804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
61029f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
61034852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
6104daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
61059fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
610646eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6107a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
610811cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6109a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
6110a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
61118a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
6112e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
6113804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
6114484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
6115f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
611690246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
611790246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
61181d728c39SBlue Swirlif test "$gcov" = "yes" ; then
61191d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
61201d728c39SBlue Swirlfi
6121804edf29SJuan Quintela
6122adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
6123adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
6124adc28027SAlexander Bulekovfi
612554c9e41dSAlexander Bulekovecho "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
61263efac6ebSTomáš Golembiovský
6127b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
6128b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
6129b767d257SMarek Marczykowski-Góreckifi
6130b767d257SMarek Marczykowski-Górecki
61316efd7517SPeter Maydell# use included Linux headers
61326efd7517SPeter Maydellif test "$linux" = "yes" ; then
6133a307beb6SAndreas Färber  mkdir -p linux-headers
61346efd7517SPeter Maydell  case "$cpu" in
6135c72b26ecSRichard Henderson  i386|x86_64|x32)
613608312a63SPeter Maydell    linux_arch=x86
61376efd7517SPeter Maydell    ;;
6138f8378accSRichard Henderson  ppc|ppc64|ppc64le)
613908312a63SPeter Maydell    linux_arch=powerpc
61406efd7517SPeter Maydell    ;;
61416efd7517SPeter Maydell  s390x)
614208312a63SPeter Maydell    linux_arch=s390
614308312a63SPeter Maydell    ;;
61441f080313SClaudio Fontana  aarch64)
61451f080313SClaudio Fontana    linux_arch=arm64
61461f080313SClaudio Fontana    ;;
6147222e7d11SSanjay Lal  mips64)
6148222e7d11SSanjay Lal    linux_arch=mips
6149222e7d11SSanjay Lal    ;;
615008312a63SPeter Maydell  *)
615108312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
615208312a63SPeter Maydell    linux_arch="$cpu"
61536efd7517SPeter Maydell    ;;
61546efd7517SPeter Maydell  esac
615508312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
615608312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
615708312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
615808312a63SPeter Maydell    fi
61596efd7517SPeter Maydellfi
61606efd7517SPeter Maydell
616197a847bcSbellardfor target in $target_list; do
616297a847bcSbellard    target_dir="$target"
616389138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
616497a847bcSbellard    mkdir -p $target_dir
6165fdb75aefSPaolo Bonzini    case $target in
6166fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
6167fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
61682408a527Saurel32    esac
616956aebc89Spbrookdone
61707d13299dSbellard
6171765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
6172fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
6173fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
6174fdb75aefSPaolo Bonzinifi
6175a540f158SPeter Crosthwaite
6176a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6177a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6178ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
6179a99d57bbSWanlong Gaofi
6180a99d57bbSWanlong Gao
6181fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6182fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6183fd0e6053SJohn Snowfi
6184fd0e6053SJohn Snow
61851e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
61861e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
61871e4f6065SDaniele Buonofi
61881e4f6065SDaniele Buono
6189e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
6190e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
6191e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
6192e29e5c6eSPeter Maydell# (these can be both files and directories).
6193e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
6194e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
6195e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
6196e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
6197e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
6198e29e5c6eSPeter Maydell# directory and symlink the directory instead.
619909db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
620009db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
620109db9b9dSGerd Hoffmann# a "make distclean" in between.
62021cf4323eSThomas HuthDIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
62031cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
6204b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
6205744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
62068db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
6207c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
62082038f8c8SPaolo BonziniLINKS="Makefile"
6209e8f3bd71SMarc-André LureauLINKS="$LINKS tests/tcg/lm32/Makefile"
62103941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
6211ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
6212e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
62138db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
6214e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
6215e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
621639950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
621739950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
62188f8fd9edSCleber RosaLINKS="$LINKS python"
6219c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
622009db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
6221753d11f2SRichard Hendersonfor bios_file in \
6222753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
62233a631b8eSBin Meng    $source_path/pc-bios/*.elf \
6224225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
6225753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6226753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6227e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6228753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
62294e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
623026ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
6231753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6232753d11f2SRichard Hendersondo
6233e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
62347ea78b74SJan Kiszkadone
6235d1807a4fSPaolo Bonzinimkdir -p $DIRS
6236e29e5c6eSPeter Maydellfor f in $LINKS ; do
62370f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
6238f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6239f9245e10SPeter Maydell    fi
62407d13299dSbellarddone
624109db9b9dSGerd Hoffmannfor f in $UNLINK ; do
624209db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
624309db9b9dSGerd Hoffmann        rm -f "$f"
624409db9b9dSGerd Hoffmann    fi
624509db9b9dSGerd Hoffmanndone
62461ad2134fSPaul Brook
62472038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
62482038f8c8SPaolo Bonzini  export $i
62492038f8c8SPaolo Bonzinidone
6250afc3a8f9SAlex Bennéeexport target_list source_path use_containers
62512038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
62522038f8c8SPaolo Bonzini
6253c34ebfdcSAnthony Liguori# temporary config to build submodules
62548db2a4fdSGerd Hoffmannfor rom in seabios; do
6255c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
625637116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6257c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6258cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
62595f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6260c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6261c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
62623dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6263c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6264a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6265c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
62669f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
6267c34ebfdcSAnthony Liguoridone
6268c34ebfdcSAnthony Liguori
6269a5665051SPaolo Bonziniif test "$skip_meson" = no; then
6270fc929892SMarc-André Lureaucross="config-meson.cross.new"
6271fc929892SMarc-André Lureaumeson_quote() {
627247b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
6273fc929892SMarc-André Lureau}
6274fc929892SMarc-André Lureau
6275fc929892SMarc-André Lureauecho "# Automatically generated by configure - do not modify" > $cross
6276fc929892SMarc-André Lureauecho "[properties]" >> $cross
6277fc929892SMarc-André Lureautest -z "$cxx" && echo "link_language = 'c'" >> $cross
627847b30835SPaolo Bonziniecho "[built-in options]" >> $cross
627947b30835SPaolo Bonziniecho "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
628047b30835SPaolo Bonziniecho "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
628147b30835SPaolo Bonziniecho "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
628247b30835SPaolo Bonziniecho "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
6283fc929892SMarc-André Lureauecho "[binaries]" >> $cross
628447b30835SPaolo Bonziniecho "c = [$(meson_quote $cc)]" >> $cross
628547b30835SPaolo Bonzinitest -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
628647b30835SPaolo Bonziniecho "ar = [$(meson_quote $ar)]" >> $cross
628747b30835SPaolo Bonziniecho "nm = [$(meson_quote $nm)]" >> $cross
628847b30835SPaolo Bonziniecho "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
628947b30835SPaolo Bonziniecho "ranlib = [$(meson_quote $ranlib)]" >> $cross
6290e8178514SPaolo Bonziniif has $sdl2_config; then
629147b30835SPaolo Bonzini  echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
6292e8178514SPaolo Bonzinifi
629347b30835SPaolo Bonziniecho "strip = [$(meson_quote $strip)]" >> $cross
629447b30835SPaolo Bonziniecho "windres = [$(meson_quote $windres)]" >> $cross
6295*3812c0c4SJoelle van Dyneif test "$cross_compile" = "yes"; then
6296fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
6297fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
6298fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
6299fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
6300fc929892SMarc-André Lureau    fi
6301853b4bafSThomas Huth    if test "$linux" = "yes" ; then
6302853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
6303853b4bafSThomas Huth    fi
6304fc929892SMarc-André Lureau    case "$ARCH" in
6305fc929892SMarc-André Lureau        i386|x86_64)
6306fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
6307fc929892SMarc-André Lureau            ;;
6308fc929892SMarc-André Lureau        ppc64le)
6309fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
6310fc929892SMarc-André Lureau            ;;
6311fc929892SMarc-André Lureau        *)
6312fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
6313fc929892SMarc-André Lureau            ;;
6314fc929892SMarc-André Lureau    esac
6315fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
6316fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
6317fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
6318fc929892SMarc-André Lureau    else
6319fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
6320fc929892SMarc-André Lureau    fi
6321fc929892SMarc-André Lureauelse
6322fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
6323fc929892SMarc-André Lureaufi
6324fc929892SMarc-André Lureaumv $cross config-meson.cross
6325fc929892SMarc-André Lureau
6326a5665051SPaolo Bonzinirm -rf meson-private meson-info meson-logs
6327a5cb7c5aSPaolo Bonziniunset staticpic
6328a5cb7c5aSPaolo Bonziniif ! version_ge "$($meson --version)" 0.56.0; then
6329a5cb7c5aSPaolo Bonzini  staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
6330a5cb7c5aSPaolo Bonzinifi
633109e93326SPaolo BonziniNINJA=$ninja $meson setup \
6332d17f305aSPaolo Bonzini        --prefix "$prefix" \
6333d17f305aSPaolo Bonzini        --libdir "$libdir" \
6334d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
6335d17f305aSPaolo Bonzini        --bindir "$bindir" \
6336d17f305aSPaolo Bonzini        --includedir "$includedir" \
6337d17f305aSPaolo Bonzini        --datadir "$datadir" \
6338d17f305aSPaolo Bonzini        --mandir "$mandir" \
6339d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
634016bf7a33SPaolo Bonzini        --localedir "$localedir" \
6341d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
6342d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
634316bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
634473f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
6345a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
6346a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
6347a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
6348a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
6349da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
6350a5cb7c5aSPaolo Bonzini        ${staticpic:+-Db_staticpic=$staticpic} \
6351bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
63529e62ba48SDaniele Buono        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
6353deb62371SPaolo Bonzini        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
63541badb709SPaolo Bonzini        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf \
63551badb709SPaolo Bonzini        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
63561b695471SPaolo Bonzini        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
6357a0b93237SPaolo Bonzini        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
6358cece116cSMisono Tomohiro        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
63598c6d4ff4SPaolo Bonzini        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
63609db405a3SPaolo Bonzini        -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
636130045c05SPaolo Bonzini        -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
6362ecea3696SPaolo Bonzini        -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse \
6363727c8bb8SPaolo Bonzini        -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
63647bc3ca7fSPaolo Bonzini        -Dattr=$attr -Ddefault_devices=$default_devices \
6365c8d5450bSPaolo Bonzini        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
6366e5e856c1SStefan Hajnoczi        -Dvhost_user_blk_server=$vhost_user_blk_server \
6367b846ab7cSPaolo Bonzini        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi \
6368c87ea116SAlex Bennée        $(if test "$default_features" = no; then echo "-Dauto_features=disabled"; fi) \
6369fc929892SMarc-André Lureau        $cross_arg \
6370a5665051SPaolo Bonzini        "$PWD" "$source_path"
6371a5665051SPaolo Bonzini
6372a5665051SPaolo Bonziniif test "$?" -ne 0 ; then
6373a5665051SPaolo Bonzini    error_exit "meson setup failed"
6374a5665051SPaolo Bonzinifi
6375a5665051SPaolo Bonzinifi
6376a5665051SPaolo Bonzini
63772d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
63782d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
63792d838d9bSAlex Bennée    echo "Please see docs/system/deprecated.rst"
63802d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
63812d838d9bSAlex Bennéefi
63822d838d9bSAlex Bennée
6383dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
6384dc655404SMichael S. Tsirkincat <<EOD >config.status
6385dc655404SMichael S. Tsirkin#!/bin/sh
6386dc655404SMichael S. Tsirkin# Generated by configure.
6387dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
6388dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
6389dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
6390dc655404SMichael S. TsirkinEOD
6391e811da7fSDaniel P. Berrangé
6392e811da7fSDaniel P. Berrangépreserve_env() {
6393e811da7fSDaniel P. Berrangé    envname=$1
6394e811da7fSDaniel P. Berrangé
6395e811da7fSDaniel P. Berrangé    eval envval=\$$envname
6396e811da7fSDaniel P. Berrangé
6397e811da7fSDaniel P. Berrangé    if test -n "$envval"
6398e811da7fSDaniel P. Berrangé    then
6399e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
6400e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
6401e811da7fSDaniel P. Berrangé    else
6402e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
6403e811da7fSDaniel P. Berrangé    fi
6404e811da7fSDaniel P. Berrangé}
6405e811da7fSDaniel P. Berrangé
6406e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
6407e811da7fSDaniel P. Berrangé# features/build target configure will detect
6408e811da7fSDaniel P. Berrangépreserve_env AR
6409e811da7fSDaniel P. Berrangépreserve_env AS
6410e811da7fSDaniel P. Berrangépreserve_env CC
6411e811da7fSDaniel P. Berrangépreserve_env CPP
6412e811da7fSDaniel P. Berrangépreserve_env CXX
6413e811da7fSDaniel P. Berrangépreserve_env INSTALL
6414e811da7fSDaniel P. Berrangépreserve_env LD
6415e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
6416e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
6417e811da7fSDaniel P. Berrangépreserve_env MAKE
6418e811da7fSDaniel P. Berrangépreserve_env NM
6419e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
6420e811da7fSDaniel P. Berrangépreserve_env PATH
6421e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
6422e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
6423e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
6424e811da7fSDaniel P. Berrangépreserve_env PYTHON
6425e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
6426e811da7fSDaniel P. Berrangépreserve_env SMBD
6427e811da7fSDaniel P. Berrangépreserve_env STRIP
6428e811da7fSDaniel P. Berrangépreserve_env WINDRES
6429e811da7fSDaniel P. Berrangé
6430dc655404SMichael S. Tsirkinprintf "exec" >>config.status
6431a5665051SPaolo Bonzinifor i in "$0" "$@"; do
6432835af899SPaolo Bonzini  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
6433a5665051SPaolo Bonzinidone
6434cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
6435dc655404SMichael S. Tsirkinchmod +x config.status
6436dc655404SMichael S. Tsirkin
64378cd05ab6SPeter Maydellrm -r "$TMPDIR1"
6438