xref: /openbmc/qemu/configure (revision df4ea709)
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
92d880a3baSPaolo Bonziniprint_error() {
93d880a3baSPaolo Bonzini    (echo
9476ad07a4SPeter Maydell    echo "ERROR: $1"
9576ad07a4SPeter Maydell    while test -n "$2"; do
9676ad07a4SPeter Maydell        echo "       $2"
9776ad07a4SPeter Maydell        shift
9876ad07a4SPeter Maydell    done
99d880a3baSPaolo Bonzini    echo) >&2
100d880a3baSPaolo Bonzini}
101d880a3baSPaolo Bonzini
102d880a3baSPaolo Bonzinierror_exit() {
103d880a3baSPaolo Bonzini    print_error "$@"
10476ad07a4SPeter Maydell    exit 1
10576ad07a4SPeter Maydell}
10676ad07a4SPeter Maydell
1079c83ffd8SPeter Maydelldo_compiler() {
1089c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
1099c83ffd8SPeter Maydell    # is compiler binary to execute.
1109c83ffd8SPeter Maydell    local compiler="$1"
1119c83ffd8SPeter Maydell    shift
1128bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
1138bbe05d7SIan Jackson        echo >>config.log "
1148bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
1158bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
1168bbe05d7SIan Jackson    '; fi
1179c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
1189c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
1198dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
1208dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
1218dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
1228dc38a78SPeter Maydell    # obvious to developers.
1238dc38a78SPeter Maydell    if test "$werror" != "yes"; then
1248dc38a78SPeter Maydell        return 0
1258dc38a78SPeter Maydell    fi
1268dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
1278dc38a78SPeter Maydell    case "$*" in
1288dc38a78SPeter Maydell        *-Werror*)
1298dc38a78SPeter Maydell           return 0
1308dc38a78SPeter Maydell        ;;
1318dc38a78SPeter Maydell    esac
1329c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
1339c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
13476ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
13576ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
13676ad07a4SPeter Maydell        "will be at the bottom of config.log." \
13776ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
1388dc38a78SPeter Maydell}
1398dc38a78SPeter Maydell
1409c83ffd8SPeter Maydelldo_cc() {
1419c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
1429c83ffd8SPeter Maydell}
1439c83ffd8SPeter Maydell
1449c83ffd8SPeter Maydelldo_cxx() {
1459c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
14800849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
14900849b92SRichard Hendersonadd_to() {
15000849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15100849b92SRichard Henderson}
15200849b92SRichard Henderson
1539c83ffd8SPeter Maydellupdate_cxxflags() {
1549c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1559c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1569c83ffd8SPeter Maydell    # because they only make sense for C programs.
15753422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
1585770e8afSPaolo Bonzini    CONFIGURE_CXXFLAGS=$(echo "$CONFIGURE_CFLAGS" | sed s/-std=gnu99/-std=gnu++11/)
1599c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1609c83ffd8SPeter Maydell        case $arg in
1619c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1629c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1639c83ffd8SPeter Maydell                ;;
1649c83ffd8SPeter Maydell            *)
1659c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1669c83ffd8SPeter Maydell                ;;
1679c83ffd8SPeter Maydell        esac
1689c83ffd8SPeter Maydell    done
1699c83ffd8SPeter Maydell}
1709c83ffd8SPeter Maydell
17152166aa0SJuan Quintelacompile_object() {
172fd0e6053SJohn Snow  local_cflags="$1"
1735770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
17452166aa0SJuan Quintela}
17552166aa0SJuan Quintela
17652166aa0SJuan Quintelacompile_prog() {
17752166aa0SJuan Quintela  local_cflags="$1"
17852166aa0SJuan Quintela  local_ldflags="$2"
1795770e8afSPaolo Bonzini  do_cc $CFLAGS $CONFIGURE_CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC \
1805770e8afSPaolo Bonzini      $LDFLAGS $CONFIGURE_LDFLAGS $QEMU_LDFLAGS $local_ldflags
18152166aa0SJuan Quintela}
18252166aa0SJuan Quintela
18311568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
18411568d6dSPaolo Bonzinisymlink() {
18572b8b5a1SStefan Weil  rm -rf "$2"
186ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
18772b8b5a1SStefan Weil  ln -s "$1" "$2"
18811568d6dSPaolo Bonzini}
18911568d6dSPaolo Bonzini
1900dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1910dba6195SLoïc Minier# executable or a builtin)
1920dba6195SLoïc Minierhas() {
1930dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1940dba6195SLoïc Minier}
1950dba6195SLoïc Minier
1960a01d76fSMarc-André Lureauversion_ge () {
1970a01d76fSMarc-André Lureau    local_ver1=`echo $1 | tr . ' '`
1980a01d76fSMarc-André Lureau    local_ver2=`echo $2 | tr . ' '`
1990a01d76fSMarc-André Lureau    while true; do
2000a01d76fSMarc-André Lureau        set x $local_ver1
2010a01d76fSMarc-André Lureau        local_first=${2-0}
202c44a33e2SStefano Garzarella        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
203c44a33e2SStefano Garzarella        shift ${2:+2}
2040a01d76fSMarc-André Lureau        local_ver1=$*
2050a01d76fSMarc-André Lureau        set x $local_ver2
2060a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2070a01d76fSMarc-André Lureau        test $# = 1 && return 0
2080a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2090a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
210c44a33e2SStefano Garzarella        shift ${2:+2}
2110a01d76fSMarc-André Lureau        local_ver2=$*
2120a01d76fSMarc-André Lureau    done
2130a01d76fSMarc-André Lureau}
2140a01d76fSMarc-André Lureau
2155b808275SLluís Vilanovahave_backend () {
2165b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2175b808275SLluís Vilanova}
2185b808275SLluís Vilanova
2193b6b7550SPaolo Bonziniglob() {
2203b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2213b6b7550SPaolo Bonzini}
2223b6b7550SPaolo Bonzini
223e9a3591fSChristian Borntraegerld_has() {
224e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
225e9a3591fSChristian Borntraeger}
226e9a3591fSChristian Borntraeger
2274ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
2284ace32e2SAntonio Ospitethen
2294ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
2304ace32e2SAntonio Ospitefi
2314ace32e2SAntonio Ospite
23214211825SAntonio Ospite# default parameters
2332ff6b91eSJuan Quintelacpu=""
234a31a8642SMichael S. Tsirkiniasl="iasl"
2351e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
23643ce4dfeSbellardstatic="no"
2377d13299dSbellardcross_prefix=""
2380c58ac1cSmalcaudio_drv_list=""
239b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
240b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
241e49d021eSPeter Maydellhost_cc="cc"
242d5631638Smalcaudio_win_int=""
243957f1f99SMichael Rothlibs_qga=""
2445bc62e01SGerd Hoffmanndebug_info="yes"
24563678e17SSteven Noonanstack_protector=""
2461e4f6065SDaniele Buonosafe_stack=""
247afc3a8f9SAlex Bennéeuse_containers="yes"
248f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
249ac0df51dSaliguori
25092712822SDaniel P. Berrangeif test -e "$source_path/.git"
25192712822SDaniel P. Berrangethen
252f62bbee5SDaniel P. Berrange    git_update=yes
25392712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
2543ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
2553ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
25692712822SDaniel P. Berrangeelse
257f62bbee5SDaniel P. Berrange    git_update=no
258aef45d51SDaniel P. Berrange    git_submodules=""
2595c0ef67aSDaniel P. Berrangé
2605c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
2615c0ef67aSDaniel P. Berrangé    then
2625c0ef67aSDaniel P. Berrangé        echo
2635c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
2645c0ef67aSDaniel P. Berrangé        echo
2655c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
2665c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
2675c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
2685c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
2695c0ef67aSDaniel P. Berrangé        echo
270a3e3b521SPeter Maydell        echo "  https://www.qemu.org/download/#source"
2715c0ef67aSDaniel P. Berrangé        echo
2725c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
2735c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
2745c0ef67aSDaniel P. Berrangé        echo
2755c0ef67aSDaniel P. Berrangé        exit 1
2765c0ef67aSDaniel P. Berrangé    fi
27792712822SDaniel P. Berrangefi
278cc84d63aSDaniel P. Berrangegit="git"
279ac0df51dSaliguori
280afb63ebdSStefan Weil# Don't accept a target_list environment variable.
281afb63ebdSStefan Weilunset target_list
282447e133fSAlex Bennéeunset target_list_exclude
283377529c0SPaolo Bonzini
284377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
285377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
286377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
287377529c0SPaolo Bonzini#              unless --disable-foo is given
288377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
289377529c0SPaolo Bonzini#              feature will searched for,
290377529c0SPaolo Bonzini#              if not found, configure exits with error
291377529c0SPaolo Bonzini#
292377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
293377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
294377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
295377529c0SPaolo Bonzini
296377529c0SPaolo Bonzinibrlapi=""
297377529c0SPaolo Bonzinicurl=""
2985285e593SYonggang Luoiconv="auto"
2995285e593SYonggang Luocurses="auto"
300e3667660SYonggang Luodocs="auto"
301fbb4121dSPaolo Bonzinifdt="auto"
30258952137SVincenzo Maffionenetmap="no"
30335be72baSPaolo Bonzinisdl="auto"
30435be72baSPaolo Bonzinisdl_image="auto"
305cece116cSMisono Tomohirovirtiofsd="auto"
306983eef5aSMeador Ingevirtfs=""
3075c53015aSPaolo Bonzinilibudev="auto"
3086ec0e15dSPaolo Bonzinimpath="auto"
309a0b93237SPaolo Bonzinivnc="enabled"
310deb62371SPaolo Bonzinisparse="auto"
311377529c0SPaolo Bonzinivde=""
312a0b93237SPaolo Bonzinivnc_sasl="auto"
313a0b93237SPaolo Bonzinivnc_jpeg="auto"
314a0b93237SPaolo Bonzinivnc_png="auto"
3154113f4cfSLaurent Vivierxkbcommon="auto"
316377529c0SPaolo Bonzinixen=""
317d5b93ddfSAnthony PERARDxen_ctrl_version=""
3181badb709SPaolo Bonzinixen_pci_passthrough="auto"
319377529c0SPaolo Bonzinilinux_aio=""
320c10dd856SAarushi Mehtalinux_io_uring=""
32147e98658SCorey Bryantcap_ng=""
322377529c0SPaolo Bonziniattr=""
3234f26f2b6SAvi Kivitylibattr=""
324377529c0SPaolo Bonzinixfs=""
3251badb709SPaolo Bonzinitcg="enabled"
326a40161cbSPaolo Bonzinimembarrier=""
327299e6f19SPaolo Bonzinivhost_net=""
328299e6f19SPaolo Bonzinivhost_crypto=""
329299e6f19SPaolo Bonzinivhost_scsi=""
330299e6f19SPaolo Bonzinivhost_vsock=""
331d88618f7SStefan Hajnoczivhost_user="no"
332e5e856c1SStefan Hajnoczivhost_user_blk_server="auto"
33398fc1adaSDr. David Alan Gilbertvhost_user_fs=""
3343bd40ec7SPaolo Bonzinikvm="auto"
3353bd40ec7SPaolo Bonzinihax="auto"
3363bd40ec7SPaolo Bonzinihvf="auto"
3373bd40ec7SPaolo Bonziniwhpx="auto"
3382da776dbSMichael R. Hinesrdma=""
33921ab34c9SMarcel Apfelbaumpvrdma=""
340377529c0SPaolo Bonzinigprof="no"
341377529c0SPaolo Bonzinidebug_tcg="no"
342377529c0SPaolo Bonzinidebug="no"
343247724cbSMarc-André Lureausanitizers="no"
3440aebab04SLingfeng Yangtsan="no"
345b553a042SJohn Snowfortify_source=""
346377529c0SPaolo Bonzinistrip_opt="yes"
3479195b2c2SStefan Weiltcg_interpreter="no"
348377529c0SPaolo Bonzinibigendian="no"
349377529c0SPaolo Bonzinimingw32="no"
3501d728c39SBlue Swirlgcov="no"
351377529c0SPaolo BonziniEXESUF=""
352484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
35317969268SFam Zhengmodules="no"
354bd83c861SChristian Ehrhardtmodule_upgrades="no"
355377529c0SPaolo Bonziniprefix="/usr/local"
35610ff82d1SMarc-André Lureauqemu_suffix="qemu"
3574d34a86bSPaolo Bonzinislirp="auto"
358377529c0SPaolo Bonzinioss_lib=""
359377529c0SPaolo Bonzinibsd="no"
360377529c0SPaolo Bonzinilinux="no"
361377529c0SPaolo Bonzinisolaris="no"
362377529c0SPaolo Bonziniprofiler="no"
363b4e312e9SPaolo Bonzinicocoa="auto"
364377529c0SPaolo Bonzinisoftmmu="yes"
365377529c0SPaolo Bonzinilinux_user="no"
366377529c0SPaolo Bonzinibsd_user="no"
367c8d5450bSPaolo Bonziniblobs="true"
368377529c0SPaolo Bonzinipkgversion=""
36940d6444eSAvi Kivitypie=""
3703556c233SPaolo Bonziniqom_cast_debug="yes"
371baf86d6bSPaolo Bonzinitrace_backends="log"
372377529c0SPaolo Bonzinitrace_file="trace"
373377529c0SPaolo Bonzinispice=""
374377529c0SPaolo Bonzinirbd=""
3757b02f544SMarc-André Lureausmartcard=""
3760a40bcb7SCésar Belleyu2f="auto"
3772b2325ffSGerd Hoffmannlibusb=""
37869354a83SHans de Goedeusb_redir=""
379da076ffeSGerd Hoffmannopengl=""
380014cb152SGerd Hoffmannopengl_dmabuf="no"
3815dd89908SRichard Hendersoncpuid_h="no"
38286583a07SLiam Merwickavx2_opt=""
3838b18cdbfSRichard Hendersoncapstone="auto"
384b25c9dffSStefan Weillzo=""
385b25c9dffSStefan Weilsnappy=""
3866b383c08SPeter Wubzip2=""
38783bc1f97SJulio Faraccolzfse=""
3883a678481SJuan Quintelazstd=""
389e8ef31a3SMichael Tokarevguest_agent=""
390d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
39150cbebb9SMichael Rothguest_agent_ntddscsi="no"
3929dacf32dSYossi Hindinguest_agent_msi=""
393d9840e25STomoki Sekiyamavss_win32_sdk=""
394d9840e25STomoki Sekiyamawin_sdk="no"
395e10ee3f5SPhilippe Mathieu-Daudéwant_tools=""
396c589b249SRonnie Sahlberglibiscsi=""
3976542aa9cSPeter Lievenlibnfs=""
398519175a2SAlex Barcelocoroutine=""
39970c60c08SStefan Hajnoczicoroutine_pool=""
4007d992e4dSPeter Lievendebug_stack_usage="no"
401f0d92b56SLongpeng(Mike)crypto_afalg="no"
402f794573eSEduardo Otuboseccomp=""
403eb100396SBharata B Raoglusterfs=""
404d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4050c14fb47SBharata B Raoglusterfs_discard="no"
406df3a429aSNiels de Vosglusterfs_fallocate="no"
4077c815372SBharata B Raoglusterfs_zerofill="no"
408e014dbe7SPrasanna Kumar Kaleverglusterfs_ftruncate_has_stat="no"
4090e3b891fSNiels de Vosglusterfs_iocb_has_stat="no"
410a4ccabcfSAnthony Liguorigtk=""
411925a0400SGerd Hoffmanngtk_gl="no"
412a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
413ddbb0d09SDaniel P. Berrangegnutls=""
41491bfcdb0SDaniel P. Berrangenettle=""
415dc2207afSDaniel P. Berrangénettle_xts="no"
41691bfcdb0SDaniel P. Berrangegcrypt=""
4171f923c70SLongpeng(Mike)gcrypt_hmac="no"
418e0576942SDaniel P. Berrangégcrypt_xts="no"
419e0576942SDaniel P. Berrangéqemu_private_xts="yes"
4208953caf3SDaniel P. Berrangeauth_pam=""
421bbbf9bfbSStefan Weilvte=""
4229d9e1521SGerd Hoffmannvirglrenderer=""
4237aaa6a16SPaolo Bonzinitpm=""
424b10d49d7SPino Toscanolibssh=""
425ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
426a99d57bbSWanlong Gaonuma=""
4272847b469SFam Zhengtcmalloc="no"
4287b01cb97SAlexandre Derumierjemalloc="no"
429a6b1d4c0SChanglong Xiereplication="yes"
4302f740136SJeff Codybochs="yes"
4312f740136SJeff Codycloop="yes"
4322f740136SJeff Codydmg="yes"
4332f740136SJeff Codyqcow1="yes"
4342f740136SJeff Codyvdi="yes"
4352f740136SJeff Codyvvfat="yes"
4362f740136SJeff Codyqed="yes"
4372f740136SJeff Codyparallels="yes"
438e1c42697SDaniel P. Berrangésheepdog="no"
439ed279a06SKlim Kireevlibxml2=""
440ba59fb77SPaolo Bonzinidebug_mutex="no"
44117824406SJunyan Helibpmem=""
442f3494749SPaolo Bonzinidefault_devices="yes"
44340e8c6f4SAlex Bennéeplugins="no"
444adc28027SAlexander Bulekovfuzzing="no"
445b767d257SMarek Marczykowski-Góreckirng_none="no"
44654e7aac0SAlexey Krasikovsecret_keyring=""
44721b2eca6SJingqi Liulibdaxctl=""
448a5665051SPaolo Bonzinimeson=""
44948328880SPaolo Bonzinininja=""
450a5665051SPaolo Bonziniskip_meson=no
451e8f3bd71SMarc-André Lureaugettext=""
452a484a719SMax Reitzfuse="auto"
453*df4ea709SMax Reitzfuse_lseek="auto"
454377529c0SPaolo Bonzini
455fb59dabdSPeter Maydellbogus_os="no"
456aa087962SPaolo Bonzinimalloc_trim="auto"
457898be3e0SPeter Maydell
458ac0df51dSaliguori# parse CC options first
459ac0df51dSaliguorifor opt do
46089138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
461ac0df51dSaliguori  case "$opt" in
462ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
463ac0df51dSaliguori  ;;
4643d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
465ac0df51dSaliguori  ;;
46683f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
46783f73fceSTomoki Sekiyama  ;;
4682ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
4692ff6b91eSJuan Quintela  ;;
470de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
471db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
472e2a2ed06SJuan Quintela  ;;
47311cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
47411cde1c8SBruno Dominguez  ;;
475db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
476f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
477e2a2ed06SJuan Quintela  ;;
4785bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
4795bc62e01SGerd Hoffmann  ;;
4805bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
4815bc62e01SGerd Hoffmann  ;;
482d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
483d75402b5SAlex Bennée  ;;
484d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
485d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
4862038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
487d422b2bcSAlex Bennée  ;;
488d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
4892038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
490d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
4912038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
492d75402b5SAlex Bennée  ;;
493ac0df51dSaliguori  esac
494ac0df51dSaliguoridone
495ac0df51dSaliguori# OS specific
496ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
49793148aa5SStefan Weil# we can eliminate its usage altogether.
498ac0df51dSaliguori
499e49d021eSPeter Maydell# Preferred compiler:
500e49d021eSPeter Maydell#  ${CC} (if set)
501e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
502e49d021eSPeter Maydell#  system compiler
503e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
504e49d021eSPeter Maydell  cc="$host_cc"
505e49d021eSPeter Maydellelse
506b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
507e49d021eSPeter Maydellfi
508e49d021eSPeter Maydell
50983f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
51083f73fceSTomoki Sekiyama  cxx="c++"
51183f73fceSTomoki Sekiyamaelse
51283f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
51383f73fceSTomoki Sekiyamafi
51483f73fceSTomoki Sekiyama
515b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
516cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
5175f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
5183dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
519b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
520b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
5219f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
5224852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
523b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
524b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
52517884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
52617884d7bSSergei Trofimovichquery_pkg_config() {
52717884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
52817884d7bSSergei Trofimovich}
52917884d7bSSergei Trofimovichpkg_config=query_pkg_config
53047c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
531ac0df51dSaliguori
53245d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
53345d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
53445d285abSPeter Maydell
535be17dc90SMichael S. Tsirkin# default flags for all hosts
5362d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
5372d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
5382d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
5392d31515bSPeter Maydell# provides these semantics.)
540086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
541086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
542c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
543be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
5445770e8afSPaolo Bonzini
5455770e8afSPaolo Bonzini# Flags that are needed during configure but later taken care of by Meson
5465770e8afSPaolo BonziniCONFIGURE_CFLAGS="-std=gnu99 -Wall"
5475770e8afSPaolo BonziniCONFIGURE_LDFLAGS=
548086d5f75SPaolo Bonzini
549be17dc90SMichael S. Tsirkin
550ac0df51dSaliguoricheck_define() {
551ac0df51dSaliguoricat > $TMPC <<EOF
552ac0df51dSaliguori#if !defined($1)
553fd786e1aSPeter Maydell#error $1 not defined
554ac0df51dSaliguori#endif
555ac0df51dSaliguoriint main(void) { return 0; }
556ac0df51dSaliguoriEOF
55752166aa0SJuan Quintela  compile_object
558ac0df51dSaliguori}
559ac0df51dSaliguori
560307119e7SGerd Hoffmanncheck_include() {
561307119e7SGerd Hoffmanncat > $TMPC <<EOF
562307119e7SGerd Hoffmann#include <$1>
563307119e7SGerd Hoffmannint main(void) { return 0; }
564307119e7SGerd HoffmannEOF
565307119e7SGerd Hoffmann  compile_object
566307119e7SGerd Hoffmann}
567307119e7SGerd Hoffmann
56893b25869SJohn Snowwrite_c_skeleton() {
56993b25869SJohn Snow    cat > $TMPC <<EOF
57093b25869SJohn Snowint main(void) { return 0; }
57193b25869SJohn SnowEOF
57293b25869SJohn Snow}
57393b25869SJohn Snow
574adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
575adc28027SAlexander Bulekov    cat > $TMPC <<EOF
576adc28027SAlexander Bulekov#include <stdint.h>
577adc28027SAlexander Bulekov#include <sys/types.h>
578adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
579adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
580adc28027SAlexander BulekovEOF
581adc28027SAlexander Bulekov}
582adc28027SAlexander Bulekov
583bbea4050SPeter Maydellif check_define __linux__ ; then
584bbea4050SPeter Maydell  targetos="Linux"
585bbea4050SPeter Maydellelif check_define _WIN32 ; then
586bbea4050SPeter Maydell  targetos='MINGW32'
587bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
588bbea4050SPeter Maydell  targetos='OpenBSD'
589bbea4050SPeter Maydellelif check_define __sun__ ; then
590bbea4050SPeter Maydell  targetos='SunOS'
591bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
592bbea4050SPeter Maydell  targetos='Haiku'
593951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
594951fedfcSPeter Maydell  targetos='FreeBSD'
595951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
596951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
597951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
598951fedfcSPeter Maydell  targetos='DragonFly'
599951fedfcSPeter Maydellelif check_define __NetBSD__; then
600951fedfcSPeter Maydell  targetos='NetBSD'
601951fedfcSPeter Maydellelif check_define __APPLE__; then
602951fedfcSPeter Maydell  targetos='Darwin'
603bbea4050SPeter Maydellelse
604951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
605951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
606951fedfcSPeter Maydell  # be the result of a missing compiler.
607951fedfcSPeter Maydell  targetos='bogus'
608951fedfcSPeter Maydell  bogus_os='yes'
609bbea4050SPeter Maydellfi
610bbea4050SPeter Maydell
611bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
612bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
613bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
614bbea4050SPeter Maydell# the correct CPU with the --cpu option.
615bbea4050SPeter Maydellcase $targetos in
616bbea4050SPeter MaydellDarwin)
617bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
618bbea4050SPeter Maydell  # run 64-bit userspace code.
619bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
620bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
621bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
622bbea4050SPeter Maydell    cpu="x86_64"
623bbea4050SPeter Maydell  fi
6245869f8ddSGerd Hoffmann  HOST_DSOSUF=".dylib"
625bbea4050SPeter Maydell  ;;
626bbea4050SPeter MaydellSunOS)
62789138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
628bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
629bbea4050SPeter Maydell    cpu="x86_64"
630bbea4050SPeter Maydell  fi
631bbea4050SPeter Maydellesac
632bbea4050SPeter Maydell
6332ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
6342ff6b91eSJuan Quintela  # command line argument
6352ff6b91eSJuan Quintela  :
6362ff6b91eSJuan Quintelaelif check_define __i386__ ; then
637ac0df51dSaliguori  cpu="i386"
638ac0df51dSaliguorielif check_define __x86_64__ ; then
639c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
640c72b26ecSRichard Henderson    cpu="x32"
641c72b26ecSRichard Henderson  else
642ac0df51dSaliguori    cpu="x86_64"
643c72b26ecSRichard Henderson  fi
6443aa9bd6cSblueswir1elif check_define __sparc__ ; then
6453aa9bd6cSblueswir1  if check_define __arch64__ ; then
6463aa9bd6cSblueswir1    cpu="sparc64"
6473aa9bd6cSblueswir1  else
6483aa9bd6cSblueswir1    cpu="sparc"
6493aa9bd6cSblueswir1  fi
650fdf7ed96Smalcelif check_define _ARCH_PPC ; then
651fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
652f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
653f8378accSRichard Henderson      cpu="ppc64le"
654f8378accSRichard Henderson    else
655fdf7ed96Smalc      cpu="ppc64"
656f8378accSRichard Henderson    fi
657ac0df51dSaliguori  else
658fdf7ed96Smalc    cpu="ppc"
659fdf7ed96Smalc  fi
660afa05235SAurelien Jarnoelif check_define __mips__ ; then
661afa05235SAurelien Jarno  cpu="mips"
662d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
663d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
664d66ed0eaSAurelien Jarno    cpu="s390x"
665d66ed0eaSAurelien Jarno  else
666d66ed0eaSAurelien Jarno    cpu="s390"
667d66ed0eaSAurelien Jarno  fi
668c4f80543SAlistair Franciselif check_define __riscv ; then
669c4f80543SAlistair Francis  if check_define _LP64 ; then
670c4f80543SAlistair Francis    cpu="riscv64"
671c4f80543SAlistair Francis  else
672c4f80543SAlistair Francis    cpu="riscv32"
673c4f80543SAlistair Francis  fi
67421d89f84SPeter Maydellelif check_define __arm__ ; then
67521d89f84SPeter Maydell  cpu="arm"
6761f080313SClaudio Fontanaelif check_define __aarch64__ ; then
6771f080313SClaudio Fontana  cpu="aarch64"
678fdf7ed96Smalcelse
67989138857SStefan Weil  cpu=$(uname -m)
680ac0df51dSaliguorifi
681ac0df51dSaliguori
682359bc95dSPeter MaydellARCH=
683359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
684359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
6857d13299dSbellardcase "$cpu" in
686ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
687898be3e0SPeter Maydell  ;;
688f8378accSRichard Henderson  ppc64le)
689f8378accSRichard Henderson    ARCH="ppc64"
690f8378accSRichard Henderson  ;;
6917d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
69297a847bcSbellard    cpu="i386"
6937d13299dSbellard  ;;
694aaa5fa14Saurel32  x86_64|amd64)
695aaa5fa14Saurel32    cpu="x86_64"
696aaa5fa14Saurel32  ;;
69721d89f84SPeter Maydell  armv*b|armv*l|arm)
69821d89f84SPeter Maydell    cpu="arm"
6997d13299dSbellard  ;;
7001f080313SClaudio Fontana  aarch64)
7011f080313SClaudio Fontana    cpu="aarch64"
7021f080313SClaudio Fontana  ;;
703afa05235SAurelien Jarno  mips*)
704afa05235SAurelien Jarno    cpu="mips"
705afa05235SAurelien Jarno  ;;
7063142255cSblueswir1  sparc|sun4[cdmuv])
707ae228531Sbellard    cpu="sparc"
708ae228531Sbellard  ;;
7097d13299dSbellard  *)
710359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
711359bc95dSPeter Maydell    ARCH=unknown
7127d13299dSbellard  ;;
7137d13299dSbellardesac
714359bc95dSPeter Maydellif test -z "$ARCH"; then
715359bc95dSPeter Maydell  ARCH="$cpu"
716359bc95dSPeter Maydellfi
717e2d52ad3SJuan Quintela
7187d13299dSbellard# OS specific
7190dbfc675SJuan Quintela
7207d13299dSbellardcase $targetos in
72167b915a5SbellardMINGW32*)
72267b915a5Sbellard  mingw32="yes"
7233cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
724307119e7SGerd Hoffmann  if check_include dsound.h; then
7253cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
726307119e7SGerd Hoffmann  else
727307119e7SGerd Hoffmann    audio_drv_list=""
728307119e7SGerd Hoffmann  fi
729898be3e0SPeter Maydell  supported_os="yes"
730fb648e9cSDaniel P. Berrangé  pie="no"
73167b915a5Sbellard;;
7325c40d2bdSthsGNU/kFreeBSD)
733a167ba50SAurelien Jarno  bsd="yes"
7346a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7350bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
7365c40d2bdSths;;
7377d3505c5SbellardFreeBSD)
7387d3505c5Sbellard  bsd="yes"
7390db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7406a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7410bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
742f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
74358952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
7447d3505c5Sbellard;;
745c5e97233Sblueswir1DragonFly)
746c5e97233Sblueswir1  bsd="yes"
7470db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7486a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7490bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
750c5e97233Sblueswir1;;
7517d3505c5SbellardNetBSD)
7527d3505c5Sbellard  bsd="yes"
7530db4a067SPaolo Bonzini  make="${MAKE-gmake}"
7546a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
7550bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
7568ef92a88Sblueswir1  oss_lib="-lossaudio"
7577d3505c5Sbellard;;
7587d3505c5SbellardOpenBSD)
7597d3505c5Sbellard  bsd="yes"
7600db4a067SPaolo Bonzini  make="${MAKE-gmake}"
761f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
7620bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
7637d3505c5Sbellard;;
76483fb7adfSbellardDarwin)
76583fb7adfSbellard  bsd="yes"
76683fb7adfSbellard  darwin="yes"
7671b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
768a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
769db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
7701b0f9cc2Saliguori  fi
771b4e312e9SPaolo Bonzini  cocoa="enabled"
7726a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
77314382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
774db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
775a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
776a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
777a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
77883fb7adfSbellard;;
779ec530c81SbellardSunOS)
780ec530c81Sbellard  solaris="yes"
7810db4a067SPaolo Bonzini  make="${MAKE-gmake}"
782e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
7836b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
7846a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
7856b4d2ba1Sths  fi
786c2de5c91Smalc  audio_possible_drivers="oss sdl"
787d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
788d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
789d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
790d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
791ec530c81Sbellard;;
792179cf400SAndreas FärberHaiku)
793179cf400SAndreas Färber  haiku="yes"
794cde99253SThomas Huth  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE $QEMU_CFLAGS"
795179cf400SAndreas Färber;;
796898be3e0SPeter MaydellLinux)
7977183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
7980bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
7995327cf48Sbellard  linux="yes"
800831b7825Sths  linux_user="yes"
801d88618f7SStefan Hajnoczi  vhost_user="yes"
802898be3e0SPeter Maydell;;
8037d13299dSbellardesac
8047d13299dSbellard
8057d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
806b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
80784778508Sblueswir1    bsd_user="yes"
8087d3505c5Sbellard  fi
80908de3949SAndreas Färberfi
8107d3505c5Sbellard
8110db4a067SPaolo Bonzini: ${make=${MAKE-make}}
812b6daf4d3SPaolo Bonzini
813faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
814faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
815ddf90699SEduardo Habkost# we check that too
816faf44142SDaniel P. Berrangépython=
8170a01d76fSMarc-André Lureauexplicit_python=no
818ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
819faf44142SDaniel P. Berrangédo
820faf44142SDaniel P. Berrangé    if has "$binary"
821faf44142SDaniel P. Berrangé    then
82295c5f2deSPaolo Bonzini        python=$(command -v "$binary")
823faf44142SDaniel P. Berrangé        break
824faf44142SDaniel P. Berrangé    fi
825faf44142SDaniel P. Berrangédone
826903458c8SMarkus Armbruster
827903458c8SMarkus Armbruster
82839d87c8cSAlex Bennée# Check for ancillary tools used in testing
82939d87c8cSAlex Bennéegenisoimage=
8303df437c7SAlex Bennéefor binary in genisoimage mkisofs
83139d87c8cSAlex Bennéedo
83239d87c8cSAlex Bennée    if has $binary
83339d87c8cSAlex Bennée    then
83439d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
83539d87c8cSAlex Bennée        break
83639d87c8cSAlex Bennée    fi
83739d87c8cSAlex Bennéedone
83839d87c8cSAlex Bennée
839e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
8400db4a067SPaolo Bonzini
8413c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
8423c4a4d0dSPeter Maydellif has clang; then
8433c4a4d0dSPeter Maydell  objcc=clang
8443c4a4d0dSPeter Maydellelse
8453c4a4d0dSPeter Maydell  objcc="$cc"
8463c4a4d0dSPeter Maydellfi
8473c4a4d0dSPeter Maydell
8483457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
8493457a3f8SJuan Quintela  EXESUF=".exe"
850484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
85178e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
8525770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-mthreads $CONFIGURE_CFLAGS"
85393b25869SJohn Snow  write_c_skeleton;
854d17f305aSPaolo Bonzini  prefix="/qemu"
85577433a5fSMarc-André Lureau  qemu_suffix=""
856105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
8573457a3f8SJuan Quintelafi
8583457a3f8SJuan Quintela
859487fefdbSAnthony Liguoriwerror=""
86085aa5189Sbellard
8617d13299dSbellardfor opt do
86289138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
8637d13299dSbellard  case "$opt" in
8642efc3265Sbellard  --help|-h) show_help=yes
8652efc3265Sbellard  ;;
86699123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
86799123e13SMike Frysinger  ;;
868b1a550a0Spbrook  --prefix=*) prefix="$optarg"
8697d13299dSbellard  ;;
870b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
87132ce6337Sbellard  ;;
872ac0df51dSaliguori  --cross-prefix=*)
8737d13299dSbellard  ;;
874ac0df51dSaliguori  --cc=*)
8757d13299dSbellard  ;;
876b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
87783469015Sbellard  ;;
87883f73fceSTomoki Sekiyama  --cxx=*)
87983f73fceSTomoki Sekiyama  ;;
880e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
881e007dbecSMichael S. Tsirkin  ;;
8823c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
8833c4a4d0dSPeter Maydell  ;;
884b1a550a0Spbrook  --make=*) make="$optarg"
8857d13299dSbellard  ;;
886b6daf4d3SPaolo Bonzini  --install=*)
8876a882643Spbrook  ;;
8880a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
889c886edfbSBlue Swirl  ;;
8902eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
8912eb054c2SPeter Maydell  ;;
892a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
893a5665051SPaolo Bonzini  ;;
894a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
895a5665051SPaolo Bonzini  ;;
89648328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
89748328880SPaolo Bonzini  ;;
898e2d8830eSBrad  --smbd=*) smbd="$optarg"
899e2d8830eSBrad  ;;
900e2a2ed06SJuan Quintela  --extra-cflags=*)
9017d13299dSbellard  ;;
90211cde1c8SBruno Dominguez  --extra-cxxflags=*)
90311cde1c8SBruno Dominguez  ;;
904e2a2ed06SJuan Quintela  --extra-ldflags=*)
9057d13299dSbellard  ;;
9065bc62e01SGerd Hoffmann  --enable-debug-info)
9075bc62e01SGerd Hoffmann  ;;
9085bc62e01SGerd Hoffmann  --disable-debug-info)
9095bc62e01SGerd Hoffmann  ;;
910d75402b5SAlex Bennée  --cross-cc-*)
911d75402b5SAlex Bennée  ;;
91217969268SFam Zheng  --enable-modules)
91317969268SFam Zheng      modules="yes"
91417969268SFam Zheng  ;;
9153aa88b31SStefan Hajnoczi  --disable-modules)
9163aa88b31SStefan Hajnoczi      modules="no"
9173aa88b31SStefan Hajnoczi  ;;
918bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
919bd83c861SChristian Ehrhardt  ;;
920bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
921bd83c861SChristian Ehrhardt  ;;
9222ff6b91eSJuan Quintela  --cpu=*)
9237d13299dSbellard  ;;
924b1a550a0Spbrook  --target-list=*) target_list="$optarg"
925447e133fSAlex Bennée                   if test "$target_list_exclude"; then
926447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
927447e133fSAlex Bennée                   fi
928447e133fSAlex Bennée  ;;
929447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
930447e133fSAlex Bennée                   if test "$target_list"; then
931447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
932447e133fSAlex Bennée                   fi
933de83cd02Sbellard  ;;
9345b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
9355b808275SLluís Vilanova  ;;
9365b808275SLluís Vilanova  # XXX: backwards compatibility
9375b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
93894a420b1SStefan Hajnoczi  ;;
93974242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
9409410b56cSPrerna Saxena  ;;
941f3494749SPaolo Bonzini  --with-default-devices) default_devices="yes"
942f3494749SPaolo Bonzini  ;;
943f3494749SPaolo Bonzini  --without-default-devices) default_devices="no"
944f3494749SPaolo Bonzini  ;;
9457d13299dSbellard  --enable-gprof) gprof="yes"
9467d13299dSbellard  ;;
9471d728c39SBlue Swirl  --enable-gcov) gcov="yes"
9481d728c39SBlue Swirl  ;;
94979427693SLoïc Minier  --static)
95079427693SLoïc Minier    static="yes"
95117884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
95243ce4dfeSbellard  ;;
9530b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
9540b24e75fSPaolo Bonzini  ;;
9550b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
9560b24e75fSPaolo Bonzini  ;;
9573aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
9583aa5d2beSAlon Levy  ;;
9598bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
9608bf188aaSMichael Tokarev  ;;
9610f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
9620f94d6daSAlon Levy  ;;
963528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
9640b24e75fSPaolo Bonzini  ;;
96577433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
966023d3d67SEduardo Habkost  ;;
967c6502638SBruce Rogers  --docdir=*) docdir="$optarg"
9680b24e75fSPaolo Bonzini  ;;
969fe0038beSPaolo Bonzini  --localedir=*) localedir="$optarg"
970fe0038beSPaolo Bonzini  ;;
971ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
97207381cc1SAnthony Liguori  ;;
973785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
974785c23aeSLuiz Capitulino  ;;
9753d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
9763d5eecabSGerd Hoffmann  ;;
977181ce1d0SOlaf Hering  --host=*|--build=*|\
978181ce1d0SOlaf Hering  --disable-dependency-tracking|\
979785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
980fe0038beSPaolo Bonzini  --oldincludedir=*|--datarootdir=*|--infodir=*|\
981023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
982023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
983023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
984023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
985023ddd74SMax Filippov    # lots of directory switches by default.
986023ddd74SMax Filippov  ;;
98735be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
98897a847bcSbellard  ;;
98935be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
990c4198157SJuan Quintela  ;;
99135be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
992a442fe2fSDaniel P. Berrangé  ;;
99335be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
994a442fe2fSDaniel P. Berrangé  ;;
9953556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
9963556c233SPaolo Bonzini  ;;
9973556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
9983556c233SPaolo Bonzini  ;;
999983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1000983eef5aSMeador Inge  ;;
1001983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1002983eef5aSMeador Inge  ;;
10035c53015aSPaolo Bonzini  --disable-libudev) libudev="disabled"
10045c53015aSPaolo Bonzini  ;;
10055c53015aSPaolo Bonzini  --enable-libudev) libudev="enabled"
10065c53015aSPaolo Bonzini  ;;
1007cece116cSMisono Tomohiro  --disable-virtiofsd) virtiofsd="disabled"
1008cece116cSMisono Tomohiro  ;;
1009cece116cSMisono Tomohiro  --enable-virtiofsd) virtiofsd="enabled"
1010cece116cSMisono Tomohiro  ;;
10116ec0e15dSPaolo Bonzini  --disable-mpath) mpath="disabled"
1012fe8fc5aeSPaolo Bonzini  ;;
10136ec0e15dSPaolo Bonzini  --enable-mpath) mpath="enabled"
1014fe8fc5aeSPaolo Bonzini  ;;
1015a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
1016821601eaSJes Sorensen  ;;
1017a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
1018821601eaSJes Sorensen  ;;
1019e8f3bd71SMarc-André Lureau  --disable-gettext) gettext="false"
1020e8f3bd71SMarc-André Lureau  ;;
1021e8f3bd71SMarc-André Lureau  --enable-gettext) gettext="true"
1022e8f3bd71SMarc-André Lureau  ;;
10232f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
10242f6a1ab0Sblueswir1  ;;
10250c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
10260c58ac1cSmalc  ;;
102789138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1028b64ec4e4SFam Zheng  ;;
102989138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1030eb852011SMarkus Armbruster  ;;
1031f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1032f8393946Saurel32  ;;
1033f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1034f8393946Saurel32  ;;
1035f3d08ee6SPaul Brook  --enable-debug)
1036f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1037f3d08ee6SPaul Brook      debug_tcg="yes"
10381fcc6d42SPeter Xu      debug_mutex="yes"
1039f3d08ee6SPaul Brook      debug="yes"
1040f3d08ee6SPaul Brook      strip_opt="no"
1041b553a042SJohn Snow      fortify_source="no"
1042f3d08ee6SPaul Brook  ;;
1043247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1044247724cbSMarc-André Lureau  ;;
1045247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1046247724cbSMarc-André Lureau  ;;
10470aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
10480aebab04SLingfeng Yang  ;;
10490aebab04SLingfeng Yang  --disable-tsan) tsan="no"
10500aebab04SLingfeng Yang  ;;
1051deb62371SPaolo Bonzini  --enable-sparse) sparse="enabled"
105203b4fe7dSaliguori  ;;
1053deb62371SPaolo Bonzini  --disable-sparse) sparse="disabled"
105403b4fe7dSaliguori  ;;
10551625af87Saliguori  --disable-strip) strip_opt="no"
10561625af87Saliguori  ;;
1057a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
10582f9606b3Saliguori  ;;
1059a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1060ea784e3bSJuan Quintela  ;;
1061a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
10622f6f5c7aSCorentin Chary  ;;
1063a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
10642f6f5c7aSCorentin Chary  ;;
1065a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1066efe556adSCorentin Chary  ;;
1067a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1068efe556adSCorentin Chary  ;;
10694d34a86bSPaolo Bonzini  --disable-slirp) slirp="disabled"
1070c20709aaSbellard  ;;
10714d34a86bSPaolo Bonzini  --enable-slirp=git) slirp="internal"
10727c57bdd8SMarc-André Lureau  ;;
1073675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1074675b9b53SMarc-André Lureau  ;;
1075e0e6c8c0Saliguori  --disable-vde) vde="no"
10768a16d273Sths  ;;
1077dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1078dfb278bdSJuan Quintela  ;;
107958952137SVincenzo Maffione  --disable-netmap) netmap="no"
108058952137SVincenzo Maffione  ;;
108158952137SVincenzo Maffione  --enable-netmap) netmap="yes"
108258952137SVincenzo Maffione  ;;
10831badb709SPaolo Bonzini  --disable-xen) xen="disabled"
1084e37630caSaliguori  ;;
10851badb709SPaolo Bonzini  --enable-xen) xen="enabled"
1086fc321b4bSJuan Quintela  ;;
10871badb709SPaolo Bonzini  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
1088eb6fda0fSAnthony PERARD  ;;
10891badb709SPaolo Bonzini  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
1090eb6fda0fSAnthony PERARD  ;;
10912e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
10922e4d9fb1Saurel32  ;;
10934ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
10944ffcedb6SJuan Quintela  ;;
10951badb709SPaolo Bonzini  --disable-kvm) kvm="disabled"
10967ba1e619Saliguori  ;;
10971badb709SPaolo Bonzini  --enable-kvm) kvm="enabled"
1098b31a0277SJuan Quintela  ;;
10991badb709SPaolo Bonzini  --disable-hax) hax="disabled"
1100180fb750Szhanghailiang  ;;
11011badb709SPaolo Bonzini  --enable-hax) hax="enabled"
1102180fb750Szhanghailiang  ;;
11031badb709SPaolo Bonzini  --disable-hvf) hvf="disabled"
1104c97d6d2cSSergio Andres Gomez Del Real  ;;
11051badb709SPaolo Bonzini  --enable-hvf) hvf="enabled"
1106c97d6d2cSSergio Andres Gomez Del Real  ;;
11071badb709SPaolo Bonzini  --disable-whpx) whpx="disabled"
1108d661d9a4SJustin Terry (VM)  ;;
11091badb709SPaolo Bonzini  --enable-whpx) whpx="enabled"
1110d661d9a4SJustin Terry (VM)  ;;
11119195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
11129195b2c2SStefan Weil  ;;
11139195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
11149195b2c2SStefan Weil  ;;
111547e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
111647e98658SCorey Bryant  ;;
111747e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
111847e98658SCorey Bryant  ;;
11191badb709SPaolo Bonzini  --disable-tcg) tcg="disabled"
1120b3f6ea7eSPaolo Bonzini  ;;
11211badb709SPaolo Bonzini  --enable-tcg) tcg="enabled"
1122b3f6ea7eSPaolo Bonzini  ;;
1123aa087962SPaolo Bonzini  --disable-malloc-trim) malloc_trim="disabled"
11245a22ab71SYang Zhong  ;;
1125aa087962SPaolo Bonzini  --enable-malloc-trim) malloc_trim="enabled"
11265a22ab71SYang Zhong  ;;
1127cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1128cd4ec0b4SGerd Hoffmann  ;;
1129cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1130cd4ec0b4SGerd Hoffmann  ;;
1131c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1132c589b249SRonnie Sahlberg  ;;
1133c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1134c589b249SRonnie Sahlberg  ;;
11356542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
11366542aa9cSPeter Lieven  ;;
11376542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
11386542aa9cSPeter Lieven  ;;
113905c2a3e7Sbellard  --enable-profiler) profiler="yes"
114005c2a3e7Sbellard  ;;
1141b4e312e9SPaolo Bonzini  --disable-cocoa) cocoa="disabled"
114214821030SPavel Borzenkov  ;;
1143c2de5c91Smalc  --enable-cocoa)
1144b4e312e9SPaolo Bonzini      cocoa="enabled" ;
114589138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
11465b0753e0Sbellard  ;;
1147cad25d69Spbrook  --disable-system) softmmu="no"
11480a8e90f4Spbrook  ;;
1149cad25d69Spbrook  --enable-system) softmmu="yes"
11500a8e90f4Spbrook  ;;
11510953a80fSZachary Amsden  --disable-user)
11520953a80fSZachary Amsden      linux_user="no" ;
11530953a80fSZachary Amsden      bsd_user="no" ;
11540953a80fSZachary Amsden  ;;
11550953a80fSZachary Amsden  --enable-user) ;;
1156831b7825Sths  --disable-linux-user) linux_user="no"
11570a8e90f4Spbrook  ;;
1158831b7825Sths  --enable-linux-user) linux_user="yes"
1159831b7825Sths  ;;
116084778508Sblueswir1  --disable-bsd-user) bsd_user="no"
116184778508Sblueswir1  ;;
116284778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
116384778508Sblueswir1  ;;
116440d6444eSAvi Kivity  --enable-pie) pie="yes"
116534005a00SKirill A. Shutemov  ;;
116640d6444eSAvi Kivity  --disable-pie) pie="no"
116734005a00SKirill A. Shutemov  ;;
116885aa5189Sbellard  --enable-werror) werror="yes"
116985aa5189Sbellard  ;;
117085aa5189Sbellard  --disable-werror) werror="no"
117185aa5189Sbellard  ;;
117263678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
117363678e17SSteven Noonan  ;;
117463678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
117563678e17SSteven Noonan  ;;
11761e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
11771e4f6065SDaniele Buono  ;;
11781e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
11791e4f6065SDaniele Buono  ;;
11805285e593SYonggang Luo  --disable-curses) curses="disabled"
11814d3b6f6eSbalrog  ;;
11825285e593SYonggang Luo  --enable-curses) curses="enabled"
1183c584a6d0SJuan Quintela  ;;
11845285e593SYonggang Luo  --disable-iconv) iconv="disabled"
1185e08bb301SSamuel Thibault  ;;
11865285e593SYonggang Luo  --enable-iconv) iconv="enabled"
1187e08bb301SSamuel Thibault  ;;
1188769ce76dSAlexander Graf  --disable-curl) curl="no"
1189769ce76dSAlexander Graf  ;;
1190788c8196SJuan Quintela  --enable-curl) curl="yes"
1191788c8196SJuan Quintela  ;;
1192fbb4121dSPaolo Bonzini  --disable-fdt) fdt="disabled"
11932df87df7SJuan Quintela  ;;
1194fbb4121dSPaolo Bonzini  --enable-fdt) fdt="enabled"
1195fbb4121dSPaolo Bonzini  ;;
1196fbb4121dSPaolo Bonzini  --enable-fdt=git) fdt="internal"
1197fbb4121dSPaolo Bonzini  ;;
1198fbb4121dSPaolo Bonzini  --enable-fdt=system) fdt="system"
11992df87df7SJuan Quintela  ;;
12005c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
12015c6c3a6cSChristoph Hellwig  ;;
12025c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
12035c6c3a6cSChristoph Hellwig  ;;
1204c10dd856SAarushi Mehta  --disable-linux-io-uring) linux_io_uring="no"
1205c10dd856SAarushi Mehta  ;;
1206c10dd856SAarushi Mehta  --enable-linux-io-uring) linux_io_uring="yes"
1207c10dd856SAarushi Mehta  ;;
1208758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1209758e8e38SVenkateswararao Jujjuri (JV)  ;;
1210758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1211758e8e38SVenkateswararao Jujjuri (JV)  ;;
1212a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1213a40161cbSPaolo Bonzini  ;;
1214a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1215a40161cbSPaolo Bonzini  ;;
1216c8d5450bSPaolo Bonzini  --disable-blobs) blobs="false"
121777755340Sths  ;;
12187e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
12194a19f1ecSpbrook  ;;
1220519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1221519175a2SAlex Barcelo  ;;
122270c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
122370c60c08SStefan Hajnoczi  ;;
122470c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
122570c60c08SStefan Hajnoczi  ;;
12267d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
12277d992e4dSPeter Lieven  ;;
1228f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1229f0d92b56SLongpeng(Mike)  ;;
1230f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1231f0d92b56SLongpeng(Mike)  ;;
1232e3667660SYonggang Luo  --disable-docs) docs="disabled"
123370ec5dc0SAnthony Liguori  ;;
1234e3667660SYonggang Luo  --enable-docs) docs="enabled"
123583a3ab8bSJuan Quintela  ;;
1236d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1237d5970055SMichael S. Tsirkin  ;;
1238d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1239d5970055SMichael S. Tsirkin  ;;
1240042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1241042cea27SGonglei  ;;
1242299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1243042cea27SGonglei  ;;
12445e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
12455e9be92dSNicholas Bellinger  ;;
12465e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
12475e9be92dSNicholas Bellinger  ;;
1248fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1249fc0b9b0eSStefan Hajnoczi  ;;
1250fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1251fc0b9b0eSStefan Hajnoczi  ;;
1252e5e856c1SStefan Hajnoczi  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
1253bc15e44cSStefan Hajnoczi  ;;
1254e5e856c1SStefan Hajnoczi  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
1255bc15e44cSStefan Hajnoczi  ;;
125698fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
125798fc1adaSDr. David Alan Gilbert  ;;
125898fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
125998fc1adaSDr. David Alan Gilbert  ;;
1260da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
126120ff075bSMichael Walle  ;;
1262da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
126320ff075bSMichael Walle  ;;
1264f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1265f27aaf4bSChristian Brunner  ;;
1266f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1267f27aaf4bSChristian Brunner  ;;
12688c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
12698c84cf11SSergei Trofimovich  ;;
12708c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
12718c84cf11SSergei Trofimovich  ;;
12727b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1273111a38b0SRobert Relyea  ;;
12747b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1275111a38b0SRobert Relyea  ;;
12760a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
12770a40bcb7SCésar Belley  ;;
12780a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
12790a40bcb7SCésar Belley  ;;
12802b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
12812b2325ffSGerd Hoffmann  ;;
12822b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
12832b2325ffSGerd Hoffmann  ;;
128469354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
128569354a83SHans de Goede  ;;
128669354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
128769354a83SHans de Goede  ;;
12881ffb3bbbSPaolo Bonzini  --disable-zlib-test)
12891ece9905SAlon Levy  ;;
1290b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1291b25c9dffSStefan Weil  ;;
1292607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1293607dacd0Sqiaonuohan  ;;
1294b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1295b25c9dffSStefan Weil  ;;
1296607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1297607dacd0Sqiaonuohan  ;;
12986b383c08SPeter Wu  --disable-bzip2) bzip2="no"
12996b383c08SPeter Wu  ;;
13006b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
13016b383c08SPeter Wu  ;;
130283bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
130383bc1f97SJulio Faracco  ;;
130483bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
130583bc1f97SJulio Faracco  ;;
13063a678481SJuan Quintela  --disable-zstd) zstd="no"
13073a678481SJuan Quintela  ;;
13083a678481SJuan Quintela  --enable-zstd) zstd="yes"
13093a678481SJuan Quintela  ;;
1310d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1311d138cee9SMichael Roth  ;;
1312d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1313d138cee9SMichael Roth  ;;
13149dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
13159dacf32dSYossi Hindin  ;;
13169dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
13179dacf32dSYossi Hindin  ;;
1318d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1319d9840e25STomoki Sekiyama  ;;
1320d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1321d9840e25STomoki Sekiyama  ;;
1322d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1323d9840e25STomoki Sekiyama  ;;
1324d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1325d9840e25STomoki Sekiyama  ;;
1326d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1327d9840e25STomoki Sekiyama  ;;
1328d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1329d9840e25STomoki Sekiyama  ;;
13304b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
13314b1c11fdSDaniel P. Berrange  ;;
13324b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
13334b1c11fdSDaniel P. Berrange  ;;
1334f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1335f794573eSEduardo Otubo  ;;
1336f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1337f794573eSEduardo Otubo  ;;
1338eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1339eb100396SBharata B Rao  ;;
134086583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
134186583a07SLiam Merwick  ;;
134286583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
134386583a07SLiam Merwick  ;;
13446b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
13456b8cd447SRobert Hoo  ;;
13466b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
13476b8cd447SRobert Hoo  ;;
13486b8cd447SRobert Hoo
1349eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1350eb100396SBharata B Rao  ;;
135152b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
135252b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1353583f6e7bSStefan Hajnoczi  ;;
1354cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1355cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1356cb6414dfSFam Zheng  ;;
1357315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1358315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1359315d3184SFam Zheng  ;;
1360a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1361a4ccabcfSAnthony Liguori  ;;
1362a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1363a4ccabcfSAnthony Liguori  ;;
1364a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1365a1c5e949SDaniel P. Berrange  ;;
1366ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1367ddbb0d09SDaniel P. Berrange  ;;
1368ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1369ddbb0d09SDaniel P. Berrange  ;;
137091bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
137191bfcdb0SDaniel P. Berrange  ;;
137291bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
137391bfcdb0SDaniel P. Berrange  ;;
137491bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
137591bfcdb0SDaniel P. Berrange  ;;
137691bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
137791bfcdb0SDaniel P. Berrange  ;;
13788953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
13798953caf3SDaniel P. Berrange  ;;
13808953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
13818953caf3SDaniel P. Berrange  ;;
13822da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
13832da776dbSMichael R. Hines  ;;
13842da776dbSMichael R. Hines  --disable-rdma) rdma="no"
13852da776dbSMichael R. Hines  ;;
138621ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
138721ab34c9SMarcel Apfelbaum  ;;
138821ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
138921ab34c9SMarcel Apfelbaum  ;;
1390bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1391bbbf9bfbSStefan Weil  ;;
1392bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1393bbbf9bfbSStefan Weil  ;;
13949d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
13959d9e1521SGerd Hoffmann  ;;
13969d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
13979d9e1521SGerd Hoffmann  ;;
1398e91c793cSCole Robinson  --disable-tpm) tpm="no"
1399e91c793cSCole Robinson  ;;
1400ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1401ab214c29SStefan Berger  ;;
1402b10d49d7SPino Toscano  --disable-libssh) libssh="no"
14030a12ec87SRichard W.M. Jones  ;;
1404b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
14050a12ec87SRichard W.M. Jones  ;;
1406ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1407ed1701c6SDr. David Alan Gilbert  ;;
1408ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1409ed1701c6SDr. David Alan Gilbert  ;;
1410a99d57bbSWanlong Gao  --disable-numa) numa="no"
1411a99d57bbSWanlong Gao  ;;
1412a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1413a99d57bbSWanlong Gao  ;;
1414ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1415ed279a06SKlim Kireev  ;;
1416ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1417ed279a06SKlim Kireev  ;;
14182847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
14192847b469SFam Zheng  ;;
14202847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
14212847b469SFam Zheng  ;;
14227b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
14237b01cb97SAlexandre Derumier  ;;
14247b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
14257b01cb97SAlexandre Derumier  ;;
1426a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1427a6b1d4c0SChanglong Xie  ;;
1428a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1429a6b1d4c0SChanglong Xie  ;;
14302f740136SJeff Cody  --disable-bochs) bochs="no"
14312f740136SJeff Cody  ;;
14322f740136SJeff Cody  --enable-bochs) bochs="yes"
14332f740136SJeff Cody  ;;
14342f740136SJeff Cody  --disable-cloop) cloop="no"
14352f740136SJeff Cody  ;;
14362f740136SJeff Cody  --enable-cloop) cloop="yes"
14372f740136SJeff Cody  ;;
14382f740136SJeff Cody  --disable-dmg) dmg="no"
14392f740136SJeff Cody  ;;
14402f740136SJeff Cody  --enable-dmg) dmg="yes"
14412f740136SJeff Cody  ;;
14422f740136SJeff Cody  --disable-qcow1) qcow1="no"
14432f740136SJeff Cody  ;;
14442f740136SJeff Cody  --enable-qcow1) qcow1="yes"
14452f740136SJeff Cody  ;;
14462f740136SJeff Cody  --disable-vdi) vdi="no"
14472f740136SJeff Cody  ;;
14482f740136SJeff Cody  --enable-vdi) vdi="yes"
14492f740136SJeff Cody  ;;
14502f740136SJeff Cody  --disable-vvfat) vvfat="no"
14512f740136SJeff Cody  ;;
14522f740136SJeff Cody  --enable-vvfat) vvfat="yes"
14532f740136SJeff Cody  ;;
14542f740136SJeff Cody  --disable-qed) qed="no"
14552f740136SJeff Cody  ;;
14562f740136SJeff Cody  --enable-qed) qed="yes"
14572f740136SJeff Cody  ;;
14582f740136SJeff Cody  --disable-parallels) parallels="no"
14592f740136SJeff Cody  ;;
14602f740136SJeff Cody  --enable-parallels) parallels="yes"
14612f740136SJeff Cody  ;;
14622f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
14632f740136SJeff Cody  ;;
14642f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
14652f740136SJeff Cody  ;;
1466e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1467e6a74868SMarc-André Lureau  ;;
1468299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1469299e6f19SPaolo Bonzini  ;;
1470108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1471108a6481SCindy Lu  ;;
1472108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1473108a6481SCindy Lu  ;;
1474299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1475299e6f19SPaolo Bonzini  ;;
1476299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1477e6a74868SMarc-André Lureau  ;;
14788b18cdbfSRichard Henderson  --disable-capstone) capstone="disabled"
14798ca80760SRichard Henderson  ;;
14808b18cdbfSRichard Henderson  --enable-capstone) capstone="enabled"
14818ca80760SRichard Henderson  ;;
14828b18cdbfSRichard Henderson  --enable-capstone=git) capstone="internal"
1483e219c499SRichard Henderson  ;;
1484e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1485e219c499SRichard Henderson  ;;
1486cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1487cc84d63aSDaniel P. Berrange  ;;
1488f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1489f62bbee5SDaniel P. Berrange  ;;
1490f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1491f62bbee5SDaniel P. Berrange  ;;
1492ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1493ba59fb77SPaolo Bonzini  ;;
1494ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1495ba59fb77SPaolo Bonzini  ;;
149617824406SJunyan He  --enable-libpmem) libpmem=yes
149717824406SJunyan He  ;;
149817824406SJunyan He  --disable-libpmem) libpmem=no
149917824406SJunyan He  ;;
15004113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
150175411919SJames Le Cuirot  ;;
15024113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
150375411919SJames Le Cuirot  ;;
150440e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
150540e8c6f4SAlex Bennée  ;;
150640e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
150740e8c6f4SAlex Bennée  ;;
1508afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1509afc3a8f9SAlex Bennée  ;;
1510afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1511afc3a8f9SAlex Bennée  ;;
1512adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1513adc28027SAlexander Bulekov  ;;
1514adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1515adc28027SAlexander Bulekov  ;;
1516f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1517f48e590aSAlex Bennée  ;;
1518b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1519b767d257SMarek Marczykowski-Górecki  ;;
1520b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1521b767d257SMarek Marczykowski-Górecki  ;;
152254e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
152354e7aac0SAlexey Krasikov  ;;
152454e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
152554e7aac0SAlexey Krasikov  ;;
152621b2eca6SJingqi Liu  --enable-libdaxctl) libdaxctl=yes
152721b2eca6SJingqi Liu  ;;
152821b2eca6SJingqi Liu  --disable-libdaxctl) libdaxctl=no
152921b2eca6SJingqi Liu  ;;
1530a484a719SMax Reitz  --enable-fuse) fuse="enabled"
1531a484a719SMax Reitz  ;;
1532a484a719SMax Reitz  --disable-fuse) fuse="disabled"
1533a484a719SMax Reitz  ;;
1534*df4ea709SMax Reitz  --enable-fuse-lseek) fuse_lseek="enabled"
1535*df4ea709SMax Reitz  ;;
1536*df4ea709SMax Reitz  --disable-fuse-lseek) fuse_lseek="disabled"
1537*df4ea709SMax Reitz  ;;
15382d2ad6d0SFam Zheng  *)
15392d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
15402d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
15412d2ad6d0SFam Zheng      exit 1
15427f1559c6Sbalrog  ;;
15437d13299dSbellard  esac
15447d13299dSbellarddone
15457d13299dSbellard
154622a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
154722a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
154822a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
154922a87800SMarc-André Lureau
155022a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
155122a87800SMarc-André Lureau    mandir="$prefix"
155222a87800SMarc-André Lureau    datadir="$prefix"
1553ca8c0909SMarc-André Lureau    docdir="$prefix"
155422a87800SMarc-André Lureau    bindir="$prefix"
155522a87800SMarc-André Lureau    sysconfdir="$prefix"
155616bf7a33SPaolo Bonzini    local_statedir="$prefix"
155722a87800SMarc-André Lureauelse
155822a87800SMarc-André Lureau    mandir="${mandir:-$prefix/share/man}"
155922a87800SMarc-André Lureau    datadir="${datadir:-$prefix/share}"
1560ca8c0909SMarc-André Lureau    docdir="${docdir:-$prefix/share/doc}"
156122a87800SMarc-André Lureau    bindir="${bindir:-$prefix/bin}"
156222a87800SMarc-André Lureau    sysconfdir="${sysconfdir:-$prefix/etc}"
156322a87800SMarc-André Lureau    local_statedir="${local_statedir:-$prefix/var}"
156422a87800SMarc-André Lureaufi
156516bf7a33SPaolo Bonzinifirmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
156616bf7a33SPaolo Bonzinilocaledir="${localedir:-$datadir/locale}"
156722a87800SMarc-André Lureau
156840293e58Sbellardcase "$cpu" in
1569e3608d66SRichard Henderson    ppc)
1570e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1571db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1572e3608d66SRichard Henderson           ;;
1573e3608d66SRichard Henderson    ppc64)
1574e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1575db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1576e3608d66SRichard Henderson           ;;
15779b9c37c3SRichard Henderson    sparc)
1578f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1579db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
15803142255cSblueswir1           ;;
1581ed968ff1SJuan Quintela    sparc64)
158279f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1583db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
15843142255cSblueswir1           ;;
158576d83bdeSths    s390)
1586061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1587db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
158828d7cc49SRichard Henderson           ;;
158928d7cc49SRichard Henderson    s390x)
1590061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1591db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
159276d83bdeSths           ;;
159340293e58Sbellard    i386)
159479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1595db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
159640293e58Sbellard           ;;
159740293e58Sbellard    x86_64)
15987ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
15997ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16007ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16017ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1602db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1603379f6698SPaul Brook           ;;
1604c72b26ecSRichard Henderson    x32)
1605c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1606db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1607c72b26ecSRichard Henderson           ;;
160830163d89SPeter Maydell    # No special flags required for other host CPUs
16093142255cSblueswir1esac
16103142255cSblueswir1
16112038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
16122038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
161379f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
161479f3b12fSPeter Crosthwaite
1615affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1616affc88ccSPeter Maydell# support, even if we're using TCI.
1617affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1618affc88ccSPeter Maydell  bsd_user="no"
1619affc88ccSPeter Maydell  linux_user="no"
1620affc88ccSPeter Maydellfi
1621affc88ccSPeter Maydell
162260e0df25SPeter Maydelldefault_target_list=""
1623fdb75aefSPaolo Bonzinideprecated_targets_list=ppc64abi32-linux-user,tilegx-linux-user,lm32-softmmu,unicore32-softmmu
1624fdb75aefSPaolo Bonzinideprecated_features=""
16256e92f823SPeter Maydellmak_wilds=""
16266e92f823SPeter Maydell
162760e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
162873362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-softmmu.mak"
162960e0df25SPeter Maydellfi
163060e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
163173362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-linux-user.mak"
163260e0df25SPeter Maydellfi
163360e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
163473362fc0SPaolo Bonzini    mak_wilds="${mak_wilds} $source_path/default-configs/targets/*-bsd-user.mak"
163560e0df25SPeter Maydellfi
163660e0df25SPeter Maydell
16373a5ae4a9SAlex Bennée# If the user doesn't explicitly specify a deprecated target we will
16383a5ae4a9SAlex Bennée# skip it.
16393a5ae4a9SAlex Bennéeif test -z "$target_list"; then
16403a5ae4a9SAlex Bennée    if test -z "$target_list_exclude"; then
16413a5ae4a9SAlex Bennée        target_list_exclude="$deprecated_targets_list"
16423a5ae4a9SAlex Bennée    else
16433a5ae4a9SAlex Bennée        target_list_exclude="$target_list_exclude,$deprecated_targets_list"
16443a5ae4a9SAlex Bennée    fi
16452d838d9bSAlex Bennéefi
16462d838d9bSAlex Bennée
1647447e133fSAlex Bennéefor config in $mak_wilds; do
1648447e133fSAlex Bennée    target="$(basename "$config" .mak)"
164998db9a06SAlex Bennée    if echo "$target_list_exclude" | grep -vq "$target"; then
1650447e133fSAlex Bennée        default_target_list="${default_target_list} $target"
1651447e133fSAlex Bennée    fi
1652447e133fSAlex Bennéedone
16536e92f823SPeter Maydell
1654c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
165564a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1656c53eeaf7SStefan Hajnoczi
1657af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1658af5db58eSpbrookcat << EOF
1659af5db58eSpbrook
1660af5db58eSpbrookUsage: configure [options]
1661af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1662af5db58eSpbrook
166308fb77edSStefan WeilStandard options:
166408fb77edSStefan Weil  --help                   print this message
166508fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
166608fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
166708fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
16682deca810SAlex Bennée  --target-list=LIST       set target list (default: build all non-deprecated)
166908fb77edSStefan Weil$(echo Available targets: $default_target_list | \
167008fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
16712deca810SAlex Bennée$(echo Deprecated targets: $deprecated_targets_list | \
16722deca810SAlex Bennée  fold -s -w 53 | sed -e 's/^/                           /')
1673447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
167408fb77edSStefan Weil
167508fb77edSStefan WeilAdvanced options (experts only):
167608fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
167708fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
167808fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
167908fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
168008fb77edSStefan Weil                           build time
168108fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
168208fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
168308fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
168411cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
168508fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1686d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1687d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
168808fb77edSStefan Weil  --make=MAKE              use specified make [$make]
168908fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
16902eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1691a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
169248328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
169308fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1694db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
169508fb77edSStefan Weil  --static                 enable static build [$static]
169608fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
169710ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
1698fe0038beSPaolo Bonzini  --localedir=PATH         install translation in PATH/$qemu_suffix
169910ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
170008fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
170108fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1702db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
170310ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
170408fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
17053d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
170613336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1707ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1708db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
170908fb77edSStefan Weil  --enable-debug           enable common debug build options
1710247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
17110aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
171208fb77edSStefan Weil  --disable-strip          disable stripping binaries
171308fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
171463678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
171508fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
171608fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
171708fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
171808fb77edSStefan Weil  --block-drv-rw-whitelist=L
171908fb77edSStefan Weil                           set block driver read-write whitelist
172008fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
172108fb77edSStefan Weil  --block-drv-ro-whitelist=L
172208fb77edSStefan Weil                           set block driver read-only whitelist
172308fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
17245b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1725c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
172608fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
172708fb77edSStefan Weil                           Default:trace-<pid>
1728c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1729c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
17305a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1731c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1732c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
173308fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
173433c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
173508fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1736c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1737c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1738c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1739a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1740c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1741c12d66aaSLin Ma  --enable-profiler        profiler support
1742c12d66aaSLin Ma  --enable-debug-stack-usage
1743c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
174440e8c6f4SAlex Bennée  --enable-plugins
174540e8c6f4SAlex Bennée                           enable plugins via shared library loading
1746afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1747f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1748c23f23b9SMichael Tokarev
1749c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1750c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1751c23f23b9SMichael Tokarev
1752c23f23b9SMichael Tokarev  system          all system emulation targets
1753c23f23b9SMichael Tokarev  user            supported user emulation targets
1754c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1755c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1756c23f23b9SMichael Tokarev  docs            build documentation
1757c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1758c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1759c23f23b9SMichael Tokarev  pie             Position Independent Executables
176021e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1761bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1762c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1763c23f23b9SMichael Tokarev  debug-info      debugging information
1764c23f23b9SMichael Tokarev  sparse          sparse checker
17651e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
17661e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
1767c23f23b9SMichael Tokarev
1768ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
176991bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
177091bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
17718953caf3SDaniel P. Berrange  auth-pam        PAM access control
1772c23f23b9SMichael Tokarev  sdl             SDL UI
177304c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1774c23f23b9SMichael Tokarev  gtk             gtk UI
1775c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1776c23f23b9SMichael Tokarev  curses          curses UI
1777e08bb301SSamuel Thibault  iconv           font glyph conversion support
1778c23f23b9SMichael Tokarev  vnc             VNC UI support
1779c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1780c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1781c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1782c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1783c23f23b9SMichael Tokarev  virtfs          VirtFS
1784cece116cSMisono Tomohiro  virtiofsd       build virtiofs daemon (virtiofsd)
17855c53015aSPaolo Bonzini  libudev         Use libudev to enumerate host devices
1786fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1787c23f23b9SMichael Tokarev  xen             xen backend driver support
178870c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1789c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1790c23f23b9SMichael Tokarev  curl            curl connectivity
1791a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1792c23f23b9SMichael Tokarev  fdt             fdt device tree
1793c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1794b0cb0a66SVincent Palatin  hax             HAX acceleration support
1795c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1796d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
179721ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
179821ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1799c23f23b9SMichael Tokarev  vde             support for vde network
1800c23f23b9SMichael Tokarev  netmap          support for netmap network
1801c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1802c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1803c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1804c23f23b9SMichael Tokarev  attr            attr and xattr support
1805299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1806299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1807299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1808299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1809299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1810299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1811bc15e44cSStefan Hajnoczi  vhost-user-blk-server    vhost-user-blk server support
1812108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
1813c23f23b9SMichael Tokarev  spice           spice
1814c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1815c23f23b9SMichael Tokarev  libiscsi        iscsi support
1816c23f23b9SMichael Tokarev  libnfs          nfs support
18177b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
18180a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1819c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1820ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1821c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1822c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1823c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1824c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1825c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
182683bc1f97SJulio Faracco  lzfse           support of lzfse compression library
182783bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
18283a678481SJuan Quintela  zstd            support for zstd compression library
1829d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1830c23f23b9SMichael Tokarev  seccomp         seccomp support
1831c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1832c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1833c23f23b9SMichael Tokarev  tpm             TPM support
1834b10d49d7SPino Toscano  libssh          ssh block device support
1835c23f23b9SMichael Tokarev  numa            libnuma support
1836ed279a06SKlim Kireev  libxml2         for Parallels image format
1837c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
18387b01cb97SAlexandre Derumier  jemalloc        jemalloc support
183986583a07SLiam Merwick  avx2            AVX2 optimization support
18406b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1841a6b1d4c0SChanglong Xie  replication     replication support
1842c12d66aaSLin Ma  opengl          opengl support
1843c12d66aaSLin Ma  virglrenderer   virgl rendering support
1844c12d66aaSLin Ma  xfsctl          xfsctl support
1845c12d66aaSLin Ma  qom-cast-debug  cast debugging support
18468de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
18472f740136SJeff Cody  bochs           bochs image format support
18482f740136SJeff Cody  cloop           cloop image format support
18492f740136SJeff Cody  dmg             dmg image format support
18502f740136SJeff Cody  qcow1           qcow v1 image format support
18512f740136SJeff Cody  vdi             vdi image format support
18522f740136SJeff Cody  vvfat           vvfat image format support
18532f740136SJeff Cody  qed             qed image format support
18542f740136SJeff Cody  parallels       parallels image format support
1855e1c42697SDaniel P. Berrangé  sheepdog        sheepdog block driver support (deprecated)
1856f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
18578ca80760SRichard Henderson  capstone        capstone disassembler support
1858ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
185917824406SJunyan He  libpmem         libpmem support
186075411919SJames Le Cuirot  xkbcommon       xkbcommon support
1861b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
186221b2eca6SJingqi Liu  libdaxctl       libdaxctl support
1863a484a719SMax Reitz  fuse            FUSE block device export
1864*df4ea709SMax Reitz  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
186508fb77edSStefan Weil
186608fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1867af5db58eSpbrookEOF
18682d2ad6d0SFam Zhengexit 0
1869af5db58eSpbrookfi
1870af5db58eSpbrook
18719c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1872bb768f71SThomas Huthrm -f */config-devices.mak.d
18739c790242SThomas Huth
1874faf44142SDaniel P. Berrangéif test -z "$python"
1875faf44142SDaniel P. Berrangéthen
1876c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1877c53eeaf7SStefan Hajnoczifi
1878c53eeaf7SStefan Hajnoczi
1879c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1880c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
18811b11f28dSThomas Huthif ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
18821b11f28dSThomas Huth  error_exit "Cannot use '$python', Python >= 3.6 is required." \
1883c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1884c53eeaf7SStefan Hajnoczifi
1885c53eeaf7SStefan Hajnoczi
1886755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1887406ab2f3SCleber 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)
1888755ee70fSCleber Rosa
1889c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1890c53eeaf7SStefan Hajnoczipython="$python -B"
1891c53eeaf7SStefan Hajnoczi
18920a01d76fSMarc-André Lureauif test -z "$meson"; then
18936ebd89cfSPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
18940a01d76fSMarc-André Lureau        meson=meson
18950a01d76fSMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
18960a01d76fSMarc-André Lureau        meson=git
18970a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
18980a01d76fSMarc-André Lureau        meson=internal
18990a01d76fSMarc-André Lureau    else
19000a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
19010a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
19020a01d76fSMarc-André Lureau        else
1903a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1904a5665051SPaolo Bonzini        fi
19050a01d76fSMarc-André Lureau    fi
19060a01d76fSMarc-André Lureauelse
19070a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
19080a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
19090a01d76fSMarc-André Lureau    #
19100a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
19110a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
19120a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
19130a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
19140a01d76fSMarc-André Lureau        case "$meson" in
19150a01d76fSMarc-André Lureau            git | internal) ;;
19160a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
19170a01d76fSMarc-André Lureau        esac
19180a01d76fSMarc-André Lureau    fi
19190a01d76fSMarc-André Lureaufi
1920a5665051SPaolo Bonzini
19210a01d76fSMarc-André Lureauif test "$meson" = git; then
19220a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
19230a01d76fSMarc-André Lureaufi
19240a01d76fSMarc-André Lureau
19250a01d76fSMarc-André Lureaucase "$meson" in
19260a01d76fSMarc-André Lureau    git | internal)
19270a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
19280a01d76fSMarc-André Lureau        ;;
192984ec0c24SPaolo Bonzini    *) meson=$(command -v "$meson") ;;
19300a01d76fSMarc-André Lureauesac
19310a01d76fSMarc-André Lureau
193209e93326SPaolo Bonzini# Probe for ninja
193348328880SPaolo Bonzini
193448328880SPaolo Bonziniif test -z "$ninja"; then
193548328880SPaolo Bonzini    for c in ninja ninja-build samu; do
193648328880SPaolo Bonzini        if has $c; then
193748328880SPaolo Bonzini            ninja=$(command -v "$c")
193848328880SPaolo Bonzini            break
193948328880SPaolo Bonzini        fi
194048328880SPaolo Bonzini    done
194109e93326SPaolo Bonzini    if test -z "$ninja"; then
194209e93326SPaolo Bonzini      error_exit "Cannot find Ninja"
194309e93326SPaolo Bonzini    fi
194448328880SPaolo Bonzinifi
1945a5665051SPaolo Bonzini
19469aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
19479aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
19489aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
19499aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
19509aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
19519aae6e54SDaniel Henrique Barbozaif compile_object ; then
19529aae6e54SDaniel Henrique Barboza  : C compiler works ok
19539aae6e54SDaniel Henrique Barbozaelse
19549aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
19559aae6e54SDaniel Henrique Barbozafi
19569aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
19579aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
19589aae6e54SDaniel Henrique Barbozafi
19599aae6e54SDaniel Henrique Barboza
19609c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
19619c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
19629c83ffd8SPeter Maydellif test -z "$werror" ; then
1963fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
1964e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
19659c83ffd8SPeter Maydell        werror="yes"
19669c83ffd8SPeter Maydell    else
19679c83ffd8SPeter Maydell        werror="no"
19689c83ffd8SPeter Maydell    fi
19699c83ffd8SPeter Maydellfi
19709c83ffd8SPeter Maydell
1971fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
1972fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
1973fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
1974fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
1975fb59dabdSPeter Maydell    # host OS we should stop now.
1976951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
1977fb59dabdSPeter Maydellfi
1978fb59dabdSPeter Maydell
1979efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
1980efc6c070SThomas Huthcat > $TMPC << EOF
1981efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
1982efc6c070SThomas Huth# ifdef __apple_build_version__
1983efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
1984efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
1985efc6c070SThomas Huth#  endif
1986efc6c070SThomas Huth# else
1987efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
1988efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
1989efc6c070SThomas Huth#  endif
1990efc6c070SThomas Huth# endif
1991efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
1992efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
1993efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
1994efc6c070SThomas Huth# endif
1995efc6c070SThomas Huth#else
1996efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
1997efc6c070SThomas Huth#endif
1998efc6c070SThomas Huthint main (void) { return 0; }
1999efc6c070SThomas HuthEOF
2000efc6c070SThomas Huthif ! compile_prog "" "" ; then
2001efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2002efc6c070SThomas Huthfi
2003efc6c070SThomas Huth
200400849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
200500849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
200600849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
200700849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
200800849b92SRichard Henderson# just silently disable some features, so it's too error prone.
200900849b92SRichard Henderson
201000849b92SRichard Hendersonwarn_flags=
201100849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
201200849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
201300849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
201400849b92SRichard Hendersonadd_to warn_flags -Wformat-security
201500849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
201600849b92SRichard Hendersonadd_to warn_flags -Winit-self
201700849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
201800849b92SRichard Hendersonadd_to warn_flags -Wempty-body
201900849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
202000849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
202100849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
202200849b92SRichard Henderson
202300849b92SRichard Hendersonnowarn_flags=
202400849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
202500849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
202600849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
202700849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
202800849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2029aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2030bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
203100849b92SRichard Henderson
203200849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
203393b25869SJohn Snow
203493b25869SJohn Snowcc_has_warning_flag() {
203593b25869SJohn Snow    write_c_skeleton;
203693b25869SJohn Snow
2037a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2038a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2039a1d29d6cSPeter Maydell    # warning options).
204093b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
204193b25869SJohn Snow    compile_prog "-Werror $optflag" ""
204293b25869SJohn Snow}
204393b25869SJohn Snow
204493b25869SJohn Snowfor flag in $gcc_flags; do
204593b25869SJohn Snow    if cc_has_warning_flag $flag ; then
20468d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
20478d05095cSPaolo Bonzini    fi
20488d05095cSPaolo Bonzinidone
20498d05095cSPaolo Bonzini
205063678e17SSteven Noonanif test "$stack_protector" != "no"; then
2051fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2052fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2053fccd35a0SRodrigo Rebello{
2054fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2055fccd35a0SRodrigo Rebello    while (*c) {
2056fccd35a0SRodrigo Rebello        *p++ = *c++;
2057fccd35a0SRodrigo Rebello    }
2058fccd35a0SRodrigo Rebello    return 0;
2059fccd35a0SRodrigo Rebello}
2060fccd35a0SRodrigo RebelloEOF
206163678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
20623b463a3fSMiroslav Rezanina  sp_on=0
206363678e17SSteven Noonan  for flag in $gcc_flags; do
2064590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2065590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2066086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2067590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
206863678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2069db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
20703b463a3fSMiroslav Rezanina      sp_on=1
207163678e17SSteven Noonan      break
207263678e17SSteven Noonan    fi
207363678e17SSteven Noonan  done
20743b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
20753b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
20763b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
20773b463a3fSMiroslav Rezanina    fi
20783b463a3fSMiroslav Rezanina  fi
207937746c5eSMarc-André Lureaufi
208037746c5eSMarc-André Lureau
208120bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
208220bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
208320bc94a2SPaolo Bonzinicat > $TMPC << EOF
208420bc94a2SPaolo Bonzinistruct {
208520bc94a2SPaolo Bonzini  int a[2];
208620bc94a2SPaolo Bonzini} x = {0};
208720bc94a2SPaolo BonziniEOF
208820bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
208920bc94a2SPaolo Bonzini  :
209020bc94a2SPaolo Bonzinielse
209120bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
209220bc94a2SPaolo Bonzinifi
209320bc94a2SPaolo Bonzini
209421e709aaSMarc-André Lureau# Our module code doesn't support Windows
209521e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
209621e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
209721e709aaSMarc-André Lureaufi
209821e709aaSMarc-André Lureau
2099bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2100bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2101bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2102bd83c861SChristian Ehrhardtfi
2103bd83c861SChristian Ehrhardt
2104d376e9deSThomas Huth# Static linking is not possible with modules or PIE
210540d6444eSAvi Kivityif test "$static" = "yes" ; then
2106aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2107aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2108aa0d1f44SPaolo Bonzini  fi
210940d6444eSAvi Kivityfi
211040d6444eSAvi Kivity
2111768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2112768b7855SEmilio G. Cota  cat > $TMPC << EOF
2113768b7855SEmilio G. Cotastatic __thread int tls_var;
2114768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2115768b7855SEmilio G. CotaEOF
2116768b7855SEmilio G. Cota
2117768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2118768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2119768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2120768b7855SEmilio G. Cotafi
2121768b7855SEmilio G. Cota
212240d6444eSAvi Kivitycat > $TMPC << EOF
212321d4a791SAvi Kivity
212421d4a791SAvi Kivity#ifdef __linux__
212521d4a791SAvi Kivity#  define THREAD __thread
212621d4a791SAvi Kivity#else
212721d4a791SAvi Kivity#  define THREAD
212821d4a791SAvi Kivity#endif
212921d4a791SAvi Kivitystatic THREAD int tls_var;
213021d4a791SAvi Kivityint main(void) { return tls_var; }
213140d6444eSAvi KivityEOF
2132b2634124SRichard Henderson
2133b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2134412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2135412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2136b2634124SRichard Henderson  LDFLAGS_NOPIE="-no-pie"
2137412aeacdSAlex Bennéefi
2138412aeacdSAlex Bennée
213912781462SRichard Hendersonif test "$static" = "yes"; then
2140eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
21415770e8afSPaolo Bonzini    CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
214212781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
214312781462SRichard Henderson    pie="yes"
214412781462SRichard Henderson  elif test "$pie" = "yes"; then
214512781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
214612781462SRichard Henderson  else
214712781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
214812781462SRichard Henderson    pie="no"
214912781462SRichard Henderson  fi
215012781462SRichard Hendersonelif test "$pie" = "no"; then
21515770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS"
21525770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS"
2153eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
21545770e8afSPaolo Bonzini  CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS"
21555770e8afSPaolo Bonzini  CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS"
215640d6444eSAvi Kivity  pie="yes"
21572c674109SRichard Hendersonelif test "$pie" = "yes"; then
215876ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
215940d6444eSAvi Kivityelse
216040d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
216140d6444eSAvi Kivity  pie="no"
216240d6444eSAvi Kivityfi
216340d6444eSAvi Kivity
2164e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2165e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2166e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2167e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2168e6cbd751SRichard Hendersonfi
2169e6cbd751SRichard Henderson
217009dada40SPaolo Bonzini##########################################
217109dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
217209dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
217309dada40SPaolo Bonzini# specification is necessary
217409dada40SPaolo Bonzini
217509dada40SPaolo Bonziniif test "$cpu" = "i386"; then
217609dada40SPaolo Bonzini  cat > $TMPC << EOF
217709dada40SPaolo Bonzinistatic int sfaa(int *ptr)
217809dada40SPaolo Bonzini{
217909dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
218009dada40SPaolo Bonzini}
218109dada40SPaolo Bonzini
218209dada40SPaolo Bonziniint main(void)
218309dada40SPaolo Bonzini{
218409dada40SPaolo Bonzini  int val = 42;
21851405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
218609dada40SPaolo Bonzini  sfaa(&val);
218709dada40SPaolo Bonzini  return val;
218809dada40SPaolo Bonzini}
218909dada40SPaolo BonziniEOF
219009dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
219109dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
219209dada40SPaolo Bonzini  fi
219309dada40SPaolo Bonzinifi
219409dada40SPaolo Bonzini
219509dada40SPaolo Bonzini#########################################
2196ec530c81Sbellard# Solaris specific configure tool chain decisions
219709dada40SPaolo Bonzini
2198ec530c81Sbellardif test "$solaris" = "yes" ; then
21996792aa11SLoïc Minier  if has ar; then
22006792aa11SLoïc Minier    :
22016792aa11SLoïc Minier  else
2202ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
220376ad07a4SPeter Maydell      error_exit "No path includes ar" \
220476ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2205ec530c81Sbellard    fi
220676ad07a4SPeter Maydell    error_exit "No path includes ar"
2207ec530c81Sbellard  fi
2208ec530c81Sbellardfi
2209ec530c81Sbellard
2210afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2211fdb75aefSPaolo Bonzini    default_targets=yes
2212d880a3baSPaolo Bonzini    for target in $default_target_list; do
2213d880a3baSPaolo Bonzini        target_list="$target_list $target"
2214d880a3baSPaolo Bonzini    done
2215d880a3baSPaolo Bonzini    target_list="${target_list# }"
2216121afa9eSAnthony Liguorielse
2217fdb75aefSPaolo Bonzini    default_targets=no
221889138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2219d880a3baSPaolo Bonzini    for target in $target_list; do
222025b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
222125b48338SPeter Maydell        # friendly error message than if we let it fall through.
222225b48338SPeter Maydell        case " $default_target_list " in
222325b48338SPeter Maydell            *" $target "*)
222425b48338SPeter Maydell                ;;
222525b48338SPeter Maydell            *)
222625b48338SPeter Maydell                error_exit "Unknown target name '$target'"
222725b48338SPeter Maydell                ;;
222825b48338SPeter Maydell        esac
222925b48338SPeter Maydell    done
2230d880a3baSPaolo Bonzinifi
223125b48338SPeter Maydell
2232fdb75aefSPaolo Bonzinifor target in $target_list; do
2233fdb75aefSPaolo Bonzini    # if a deprecated target is enabled we note it here
2234fdb75aefSPaolo Bonzini    if echo "$deprecated_targets_list" | grep -q "$target"; then
2235fdb75aefSPaolo Bonzini        add_to deprecated_features $target
2236fdb75aefSPaolo Bonzini    fi
2237fdb75aefSPaolo Bonzinidone
2238fdb75aefSPaolo Bonzini
2239f55fe278SPaolo Bonzini# see if system emulation was really requested
2240f55fe278SPaolo Bonzinicase " $target_list " in
2241f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2242f55fe278SPaolo Bonzini  ;;
2243f55fe278SPaolo Bonzini  *) softmmu=no
2244f55fe278SPaolo Bonzini  ;;
2245f55fe278SPaolo Bonziniesac
22465327cf48Sbellard
2247249247c9SJuan Quintelafeature_not_found() {
2248249247c9SJuan Quintela  feature=$1
224921684af0SStewart Smith  remedy=$2
2250249247c9SJuan Quintela
225176ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
225221684af0SStewart Smith      "configure was not able to find it." \
225321684af0SStewart Smith      "$remedy"
2254249247c9SJuan Quintela}
2255249247c9SJuan Quintela
22567d13299dSbellard# ---
22577d13299dSbellard# big/little endian test
22587d13299dSbellardcat > $TMPC << EOF
225961cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
226061cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
226161cc919fSMike Frysingerextern int foo(short *, short *);
226261cc919fSMike Frysingerint main(int argc, char *argv[]) {
226361cc919fSMike Frysinger    return foo(big_endian, little_endian);
22647d13299dSbellard}
22657d13299dSbellardEOF
22667d13299dSbellard
226761cc919fSMike Frysingerif compile_object ; then
226812f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
226961cc919fSMike Frysinger        bigendian="yes"
227012f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
227161cc919fSMike Frysinger        bigendian="no"
22727d13299dSbellard    else
22737d13299dSbellard        echo big/little test failed
22747d13299dSbellard    fi
22757d13299dSbellardelse
227661cc919fSMike Frysinger    echo big/little test failed
22777d13299dSbellardfi
22787d13299dSbellard
2279b0a47e79SJuan Quintela##########################################
2280e10ee3f5SPhilippe Mathieu-Daudé# system tools
2281e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2282e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2283e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2284e10ee3f5SPhilippe Mathieu-Daudé    else
2285e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2286e10ee3f5SPhilippe Mathieu-Daudé    fi
2287e10ee3f5SPhilippe Mathieu-Daudéfi
2288e10ee3f5SPhilippe Mathieu-Daudé
2289e10ee3f5SPhilippe Mathieu-Daudé##########################################
2290a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2291a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2292a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2293b4e312e9SPaolo Bonziniif test "$cocoa" = "enabled"; then
2294b4e312e9SPaolo Bonzini    if test "$sdl" = "enabled"; then
2295a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2296a30878e7SPeter Maydell    fi
2297a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2298a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2299a30878e7SPeter Maydell    fi
2300a30878e7SPeter Maydell    gtk=no
230135be72baSPaolo Bonzini    sdl=disabled
2302a30878e7SPeter Maydellfi
2303a30878e7SPeter Maydell
23046b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
23056b39b063SEric Blakecat > $TMPC << EOF
23066b39b063SEric Blake#include <stdint.h>
23076b39b063SEric Blake#include <stdio.h>
23086b39b063SEric Blakeint main(int argc, char *argv[]) {
23096b39b063SEric Blake    return printf("%zu", SIZE_MAX);
23106b39b063SEric Blake}
23116b39b063SEric BlakeEOF
23126b39b063SEric Blakehave_broken_size_max=no
23136b39b063SEric Blakeif ! compile_object -Werror ; then
23146b39b063SEric Blake    have_broken_size_max=yes
23156b39b063SEric Blakefi
23166b39b063SEric Blake
2317a30878e7SPeter Maydell##########################################
2318015a33bdSGonglei# L2TPV3 probe
2319015a33bdSGonglei
2320015a33bdSGongleicat > $TMPC <<EOF
2321015a33bdSGonglei#include <sys/socket.h>
2322bff6cb72SMichael Tokarev#include <linux/ip.h>
2323015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2324015a33bdSGongleiEOF
2325015a33bdSGongleiif compile_prog "" "" ; then
2326015a33bdSGonglei  l2tpv3=yes
2327015a33bdSGongleielse
2328015a33bdSGonglei  l2tpv3=no
2329015a33bdSGongleifi
2330015a33bdSGonglei
2331c9c8b88fSDavid CARLIERif check_include "pty.h" ; then
2332c9c8b88fSDavid CARLIER  pty_h=yes
2333c9c8b88fSDavid CARLIERelse
2334c9c8b88fSDavid CARLIER  pty_h=no
2335c9c8b88fSDavid CARLIERfi
2336c9c8b88fSDavid CARLIER
2337195588ccSDavid CARLIERcat > $TMPC <<EOF
2338195588ccSDavid CARLIER#include <sys/mman.h>
2339195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2340195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2341195588ccSDavid CARLIER}
2342195588ccSDavid CARLIEREOF
2343195588ccSDavid CARLIERif compile_prog "" "" ; then
2344195588ccSDavid CARLIER  have_mlockall=yes
2345195588ccSDavid CARLIERelse
2346195588ccSDavid CARLIER  have_mlockall=no
2347195588ccSDavid CARLIERfi
2348195588ccSDavid CARLIER
2349299e6f19SPaolo Bonzini#########################################
2350299e6f19SPaolo Bonzini# vhost interdependencies and host support
2351299e6f19SPaolo Bonzini
2352299e6f19SPaolo Bonzini# vhost backends
2353d88618f7SStefan Hajnocziif test "$vhost_user" = "yes" && test "$linux" != "yes"; then
2354d88618f7SStefan Hajnoczi  error_exit "vhost-user is only available on Linux"
2355299e6f19SPaolo Bonzinifi
2356108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2357108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2358108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2359108a6481SCindy Lufi
2360299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2361299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2362299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2363299e6f19SPaolo Bonzinifi
2364299e6f19SPaolo Bonzini
2365299e6f19SPaolo Bonzini# vhost-kernel devices
2366299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2367299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2368299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2369299e6f19SPaolo Bonzinifi
2370299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2371299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2372299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2373299e6f19SPaolo Bonzinifi
2374299e6f19SPaolo Bonzini
2375299e6f19SPaolo Bonzini# vhost-user backends
2376299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2377299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2378299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2379299e6f19SPaolo Bonzinifi
2380299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2381299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2382299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2383299e6f19SPaolo Bonzinifi
238498fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
238598fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
238698fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
238798fc1adaSDr. David Alan Gilbertfi
2388108a6481SCindy Lu#vhost-vdpa backends
2389108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2390108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2391108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2392108a6481SCindy Lufi
2393299e6f19SPaolo Bonzini
239440bc0ca9SLaurent Vivier# OR the vhost-kernel, vhost-vdpa and vhost-user values for simplicity
2395299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2396299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
239740bc0ca9SLaurent Vivier  test "$vhost_net_vdpa" = "yes" && vhost_net=yes
2398299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2399299e6f19SPaolo Bonzinifi
2400299e6f19SPaolo Bonzini
2401015a33bdSGonglei##########################################
2402779ab5e3SStefan Weil# pkg-config probe
2403779ab5e3SStefan Weil
2404779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
240576ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2406779ab5e3SStefan Weilfi
2407779ab5e3SStefan Weil
2408779ab5e3SStefan Weil##########################################
2409b0a47e79SJuan Quintela# NPTL probe
2410b0a47e79SJuan Quintela
241124cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2412bd0c5661Spbrook  cat > $TMPC <<EOF
2413bd0c5661Spbrook#include <sched.h>
241430813ceaSpbrook#include <linux/futex.h>
2415182eacc0SStefan Weilint main(void) {
2416bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2417bd0c5661Spbrook#error bork
2418bd0c5661Spbrook#endif
2419182eacc0SStefan Weil  return 0;
2420bd0c5661Spbrook}
2421bd0c5661SpbrookEOF
242224cb36a6SPeter Maydell  if ! compile_object ; then
242321684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2424b0a47e79SJuan Quintela  fi
2425bd0c5661Spbrookfi
2426bd0c5661Spbrook
2427ac62922eSbalrog##########################################
2428607dacd0Sqiaonuohan# lzo check
2429607dacd0Sqiaonuohan
2430607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2431607dacd0Sqiaonuohan    cat > $TMPC << EOF
2432607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2433607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2434607dacd0SqiaonuohanEOF
2435607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2436708eab42SMarc-André Lureau        lzo_libs="-llzo2"
2437b25c9dffSStefan Weil        lzo="yes"
2438b25c9dffSStefan Weil    else
2439b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2440b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2441b25c9dffSStefan Weil        fi
2442b25c9dffSStefan Weil        lzo="no"
2443b25c9dffSStefan Weil    fi
2444607dacd0Sqiaonuohanfi
2445607dacd0Sqiaonuohan
2446607dacd0Sqiaonuohan##########################################
2447607dacd0Sqiaonuohan# snappy check
2448607dacd0Sqiaonuohan
2449607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2450607dacd0Sqiaonuohan    cat > $TMPC << EOF
2451607dacd0Sqiaonuohan#include <snappy-c.h>
2452607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2453607dacd0SqiaonuohanEOF
2454607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2455708eab42SMarc-André Lureau        snappy_libs='-lsnappy'
2456b25c9dffSStefan Weil        snappy="yes"
2457b25c9dffSStefan Weil    else
2458b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2459b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2460b25c9dffSStefan Weil        fi
2461b25c9dffSStefan Weil        snappy="no"
2462b25c9dffSStefan Weil    fi
2463607dacd0Sqiaonuohanfi
2464607dacd0Sqiaonuohan
2465607dacd0Sqiaonuohan##########################################
24666b383c08SPeter Wu# bzip2 check
24676b383c08SPeter Wu
24686b383c08SPeter Wuif test "$bzip2" != "no" ; then
24696b383c08SPeter Wu    cat > $TMPC << EOF
24706b383c08SPeter Wu#include <bzlib.h>
24716b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
24726b383c08SPeter WuEOF
24736b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
24746b383c08SPeter Wu        bzip2="yes"
24756b383c08SPeter Wu    else
24766b383c08SPeter Wu        if test "$bzip2" = "yes"; then
24776b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
24786b383c08SPeter Wu        fi
24796b383c08SPeter Wu        bzip2="no"
24806b383c08SPeter Wu    fi
24816b383c08SPeter Wufi
24826b383c08SPeter Wu
24836b383c08SPeter Wu##########################################
248483bc1f97SJulio Faracco# lzfse check
248583bc1f97SJulio Faracco
248683bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
248783bc1f97SJulio Faracco    cat > $TMPC << EOF
248883bc1f97SJulio Faracco#include <lzfse.h>
248983bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
249083bc1f97SJulio FaraccoEOF
249183bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
249283bc1f97SJulio Faracco        lzfse="yes"
249383bc1f97SJulio Faracco    else
249483bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
249583bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
249683bc1f97SJulio Faracco        fi
249783bc1f97SJulio Faracco        lzfse="no"
249883bc1f97SJulio Faracco    fi
249983bc1f97SJulio Faraccofi
250083bc1f97SJulio Faracco
250183bc1f97SJulio Faracco##########################################
25023a678481SJuan Quintela# zstd check
25033a678481SJuan Quintela
25043a678481SJuan Quintelaif test "$zstd" != "no" ; then
2505297254c7SJuan Quintela    libzstd_minver="1.4.0"
2506297254c7SJuan Quintela    if $pkg_config --atleast-version=$libzstd_minver libzstd ; then
25073a678481SJuan Quintela        zstd_cflags="$($pkg_config --cflags libzstd)"
25083a678481SJuan Quintela        zstd_libs="$($pkg_config --libs libzstd)"
25093a678481SJuan Quintela        zstd="yes"
25103a678481SJuan Quintela    else
25113a678481SJuan Quintela        if test "$zstd" = "yes" ; then
25123a678481SJuan Quintela            feature_not_found "libzstd" "Install libzstd devel"
25133a678481SJuan Quintela        fi
25143a678481SJuan Quintela        zstd="no"
25153a678481SJuan Quintela    fi
25163a678481SJuan Quintelafi
25173a678481SJuan Quintela
25183a678481SJuan Quintela##########################################
2519f794573eSEduardo Otubo# libseccomp check
2520f794573eSEduardo Otubo
2521f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
25223e684455SMichael Strosaker    libseccomp_minver="2.3.0"
252325ed0eccSHelge Deller    if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2524c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2525c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2526f794573eSEduardo Otubo        seccomp="yes"
2527f794573eSEduardo Otubo    else
2528f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2529693e5910SAndrew Jones            feature_not_found "libseccomp" \
2530693e5910SAndrew Jones                 "Install libseccomp devel >= $libseccomp_minver"
2531896848f0SEduardo Otubo        fi
2532e84d5956SYann E. MORIN        seccomp="no"
2533f794573eSEduardo Otubo    fi
2534f794573eSEduardo Otubofi
25353bd40ec7SPaolo Bonzini
2536f794573eSEduardo Otubo##########################################
2537e37630caSaliguori# xen probe
2538e37630caSaliguori
25391badb709SPaolo Bonziniif test "$xen" != "disabled" ; then
2540c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2541c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2542c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2543c1cdd9d5SJuergen Gross
2544c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2545c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2546c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2547c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
25481badb709SPaolo Bonzini    xen=enabled
25495b6a8f43SMichael Tokarev    xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
2550c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
255158ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
255258ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
255358ea9a7aSAnthony PERARD    fi
2554582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2555582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2556c1cdd9d5SJuergen Gross  else
2557c1cdd9d5SJuergen Gross
25585b6a8f43SMichael Tokarev    xen_libs="-lxenstore -lxenctrl"
2559d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2560d5b93ddfSAnthony PERARD
256150ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
256250ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
256350ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
256450ced5b3SStefan Weil
256550ced5b3SStefan Weil    # Xen (any)
256650ced5b3SStefan Weil    cat > $TMPC <<EOF
256750ced5b3SStefan Weil#include <xenctrl.h>
256850ced5b3SStefan Weilint main(void) {
256950ced5b3SStefan Weil  return 0;
257050ced5b3SStefan Weil}
257150ced5b3SStefan WeilEOF
257250ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
257350ced5b3SStefan Weil      # Xen not found
25741badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
257521684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
257650ced5b3SStefan Weil      fi
25771badb709SPaolo Bonzini      xen=disabled
257850ced5b3SStefan Weil
2579d5b93ddfSAnthony PERARD    # Xen unstable
258069deef08SPeter Maydell    elif
258169deef08SPeter Maydell        cat > $TMPC <<EOF &&
25822cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
25832cbf8903SRoss Lagerwall#define __XEN_TOOLS__
25842cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2585d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
25862cbf8903SRoss Lagerwallint main(void) {
25872cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2588d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
25892cbf8903SRoss Lagerwall
25902cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
25912cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
25922cbf8903SRoss Lagerwall
2593d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2594d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2595d3c49ebbSPaul Durrant
25962cbf8903SRoss Lagerwall  return 0;
25972cbf8903SRoss Lagerwall}
25982cbf8903SRoss LagerwallEOF
25992cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
26002cbf8903SRoss Lagerwall      then
26012cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
26022cbf8903SRoss Lagerwall      xen_ctrl_version=41100
26031badb709SPaolo Bonzini      xen=enabled
26042cbf8903SRoss Lagerwall    elif
26052cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
26065ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
26075ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
260858ea9a7aSAnthony PERARD#include <xentoolcore.h>
26095ba3d756SIgor Druzhininint main(void) {
26105ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
26115ba3d756SIgor Druzhinin
26125ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
26135ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
261458ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
26155ba3d756SIgor Druzhinin
26165ba3d756SIgor Druzhinin  return 0;
26175ba3d756SIgor Druzhinin}
26185ba3d756SIgor DruzhininEOF
261958ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
26205ba3d756SIgor Druzhinin      then
262158ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
26225ba3d756SIgor Druzhinin      xen_ctrl_version=41000
26231badb709SPaolo Bonzini      xen=enabled
26245ba3d756SIgor Druzhinin    elif
26255ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2626da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2627da8090ccSPaul Durrant#define __XEN_TOOLS__
2628da8090ccSPaul Durrant#include <xendevicemodel.h>
2629da8090ccSPaul Durrantint main(void) {
2630da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2631da8090ccSPaul Durrant
2632da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2633da8090ccSPaul Durrant  xendevicemodel_close(xd);
2634da8090ccSPaul Durrant
2635da8090ccSPaul Durrant  return 0;
2636da8090ccSPaul Durrant}
2637da8090ccSPaul DurrantEOF
2638da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2639da8090ccSPaul Durrant      then
2640da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2641f1167ee6SJuergen Gross      xen_ctrl_version=40900
26421badb709SPaolo Bonzini      xen=enabled
2643da8090ccSPaul Durrant    elif
2644da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
26455eeb39c2SIan Campbell/*
26465eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
26475eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2648b6eb9b45SPaulina Szubarczyk *
2649b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2650b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2651b6eb9b45SPaulina Szubarczyk */
2652b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2653b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2654b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2655b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2656b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2657b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2658b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2659b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2660b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2661b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2662b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2663b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2664b6eb9b45SPaulina Szubarczyk#endif
2665b6eb9b45SPaulina Szubarczykint main(void) {
2666b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2667b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2668b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2669b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2670b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2671b6eb9b45SPaulina Szubarczyk
2672b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2673b6eb9b45SPaulina Szubarczyk
2674b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2675b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2676b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2677b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2678b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2679b6eb9b45SPaulina Szubarczyk
2680b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2681b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2682b6eb9b45SPaulina Szubarczyk
2683b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2684b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2685b6eb9b45SPaulina Szubarczyk
2686b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2687b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2688b6eb9b45SPaulina Szubarczyk
2689b6eb9b45SPaulina Szubarczyk  return 0;
2690b6eb9b45SPaulina Szubarczyk}
2691b6eb9b45SPaulina SzubarczykEOF
2692b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2693b6eb9b45SPaulina Szubarczyk      then
2694f1167ee6SJuergen Gross      xen_ctrl_version=40800
26951badb709SPaolo Bonzini      xen=enabled
2696b6eb9b45SPaulina Szubarczyk    elif
2697b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2698b6eb9b45SPaulina Szubarczyk/*
2699b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2700b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
27015eeb39c2SIan Campbell */
27025eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
27035eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
27045eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
27055eeb39c2SIan Campbell#include <xenctrl.h>
27065eeb39c2SIan Campbell#include <xenstore.h>
27075eeb39c2SIan Campbell#include <xenevtchn.h>
27085eeb39c2SIan Campbell#include <xengnttab.h>
27095eeb39c2SIan Campbell#include <xenforeignmemory.h>
27105eeb39c2SIan Campbell#include <stdint.h>
27115eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
27125eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
27135eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
27145eeb39c2SIan Campbell#endif
27155eeb39c2SIan Campbellint main(void) {
27165eeb39c2SIan Campbell  xc_interface *xc = NULL;
27175eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
27185eeb39c2SIan Campbell  xenevtchn_handle *xe;
27195eeb39c2SIan Campbell  xengnttab_handle *xg;
27205eeb39c2SIan Campbell
27215eeb39c2SIan Campbell  xs_daemon_open();
27225eeb39c2SIan Campbell
27235eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
27245eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
27255eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27265eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27275eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
27285eeb39c2SIan Campbell
27295eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
27305eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
27315eeb39c2SIan Campbell
27325eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
27335eeb39c2SIan Campbell  xenevtchn_fd(xe);
27345eeb39c2SIan Campbell
27355eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
27365eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
27375eeb39c2SIan Campbell
27385eeb39c2SIan Campbell  return 0;
27395eeb39c2SIan Campbell}
27405eeb39c2SIan CampbellEOF
27415eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
27425eeb39c2SIan Campbell      then
2743f1167ee6SJuergen Gross      xen_ctrl_version=40701
27441badb709SPaolo Bonzini      xen=enabled
2745cdadde39SRoger Pau Monne
2746cdadde39SRoger Pau Monne    # Xen 4.6
2747cdadde39SRoger Pau Monne    elif
2748cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2749cdadde39SRoger Pau Monne#include <xenctrl.h>
2750e108a3c1SAnthony PERARD#include <xenstore.h>
2751d5b93ddfSAnthony PERARD#include <stdint.h>
2752d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2753d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2754d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2755d5b93ddfSAnthony PERARD#endif
2756d5b93ddfSAnthony PERARDint main(void) {
2757d5b93ddfSAnthony PERARD  xc_interface *xc;
2758d5b93ddfSAnthony PERARD  xs_daemon_open();
2759d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2760d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2761d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2762b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
27638688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2764d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
276520a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2766d8b441a3SJan Beulich  return 0;
2767d8b441a3SJan Beulich}
2768d8b441a3SJan BeulichEOF
2769d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2770d8b441a3SJan Beulich      then
2771f1167ee6SJuergen Gross      xen_ctrl_version=40600
27721badb709SPaolo Bonzini      xen=enabled
2773d8b441a3SJan Beulich
2774d8b441a3SJan Beulich    # Xen 4.5
2775d8b441a3SJan Beulich    elif
2776d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2777d8b441a3SJan Beulich#include <xenctrl.h>
2778d8b441a3SJan Beulich#include <xenstore.h>
2779d8b441a3SJan Beulich#include <stdint.h>
2780d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2781d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2782d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2783d8b441a3SJan Beulich#endif
2784d8b441a3SJan Beulichint main(void) {
2785d8b441a3SJan Beulich  xc_interface *xc;
2786d8b441a3SJan Beulich  xs_daemon_open();
2787d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2788d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2789d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2790d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2791d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
27923996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
27933996e85cSPaul Durrant  return 0;
27943996e85cSPaul Durrant}
27953996e85cSPaul DurrantEOF
27963996e85cSPaul Durrant        compile_prog "" "$xen_libs"
27973996e85cSPaul Durrant      then
2798f1167ee6SJuergen Gross      xen_ctrl_version=40500
27991badb709SPaolo Bonzini      xen=enabled
28003996e85cSPaul Durrant
28013996e85cSPaul Durrant    elif
28023996e85cSPaul Durrant        cat > $TMPC <<EOF &&
28033996e85cSPaul Durrant#include <xenctrl.h>
28043996e85cSPaul Durrant#include <xenstore.h>
28053996e85cSPaul Durrant#include <stdint.h>
28063996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
28073996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
28083996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
28093996e85cSPaul Durrant#endif
28103996e85cSPaul Durrantint main(void) {
28113996e85cSPaul Durrant  xc_interface *xc;
28123996e85cSPaul Durrant  xs_daemon_open();
28133996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
28143996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
28153996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
28163996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
28173996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
28188688e065SStefano Stabellini  return 0;
28198688e065SStefano Stabellini}
28208688e065SStefano StabelliniEOF
28218688e065SStefano Stabellini        compile_prog "" "$xen_libs"
282269deef08SPeter Maydell      then
2823f1167ee6SJuergen Gross      xen_ctrl_version=40200
28241badb709SPaolo Bonzini      xen=enabled
28258688e065SStefano Stabellini
2826e37630caSaliguori    else
28271badb709SPaolo Bonzini      if test "$xen" = "enabled" ; then
2828edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2829edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2830fc321b4bSJuan Quintela      fi
28311badb709SPaolo Bonzini      xen=disabled
2832e37630caSaliguori    fi
2833d5b93ddfSAnthony PERARD
28341badb709SPaolo Bonzini    if test "$xen" = enabled; then
2835f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2836582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
28375eeb39c2SIan Campbell      fi
2838d5b93ddfSAnthony PERARD    fi
2839e37630caSaliguori  fi
2840c1cdd9d5SJuergen Grossfi
2841e37630caSaliguori
28421badb709SPaolo Bonziniif test "$xen_pci_passthrough" != "disabled"; then
28431badb709SPaolo Bonzini  if test "$xen" = "enabled" && test "$linux" = "yes"; then
28441badb709SPaolo Bonzini    xen_pci_passthrough=enabled
2845eb6fda0fSAnthony PERARD  else
28461badb709SPaolo Bonzini    if test "$xen_pci_passthrough" = "enabled"; then
284776ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
284876ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2849eb6fda0fSAnthony PERARD    fi
28501badb709SPaolo Bonzini    xen_pci_passthrough=disabled
2851d661d9a4SJustin Terry (VM)  fi
2852d661d9a4SJustin Terry (VM)fi
2853d661d9a4SJustin Terry (VM)
2854d661d9a4SJustin Terry (VM)##########################################
2855e8f3bd71SMarc-André Lureau# gettext probe
2856e8f3bd71SMarc-André Lureauif test "$gettext" != "false" ; then
2857e8f3bd71SMarc-André Lureau  if has xgettext; then
2858e8f3bd71SMarc-André Lureau    gettext=true
2859e8f3bd71SMarc-André Lureau  else
2860e8f3bd71SMarc-André Lureau    if test "$gettext" = "true" ; then
2861e8f3bd71SMarc-André Lureau      feature_not_found "gettext" "Install xgettext binary"
2862e8f3bd71SMarc-André Lureau    fi
2863e8f3bd71SMarc-André Lureau    gettext=false
2864e8f3bd71SMarc-André Lureau  fi
2865e8f3bd71SMarc-André Lureaufi
2866e8f3bd71SMarc-André Lureau
2867e8f3bd71SMarc-André Lureau##########################################
2868f676c67eSJeremy White# X11 probe
2869f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
28708781595bSGerd Hoffmann    have_x11=yes
287189138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
287289138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
2873f676c67eSJeremy Whitefi
2874f676c67eSJeremy White
2875f676c67eSJeremy White##########################################
2876a4ccabcfSAnthony Liguori# GTK probe
2877a4ccabcfSAnthony Liguori
28785a464e6cSPeter Xuif test "$gtk" != "no"; then
287989d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
288089d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
28817b23d121SVolker Rümelin    gtkversion="3.22.0"
2882bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
288389138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
288489138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
288589138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
28860a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
28878781595bSGerd Hoffmann            need_x11=yes
2888f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
2889f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
28900a337ed0SGerd Hoffmann        fi
2891bbbf9bfbSStefan Weil        gtk="yes"
2892bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
28935fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
2894bbbf9bfbSStefan Weil    else
2895bbbf9bfbSStefan Weil        gtk="no"
2896bbbf9bfbSStefan Weil    fi
2897bbbf9bfbSStefan Weilfi
2898bbbf9bfbSStefan Weil
2899ddbb0d09SDaniel P. Berrange
2900ddbb0d09SDaniel P. Berrange##########################################
2901ddbb0d09SDaniel P. Berrange# GNUTLS probe
2902ddbb0d09SDaniel P. Berrange
2903ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
2904a73e82efSRichard Henderson    pass="no"
2905a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
290689138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
290789138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
2908a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
2909a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
2910a73e82efSRichard Henderson        write_c_skeleton
2911a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
2912a73e82efSRichard Henderson            pass="yes"
2913a73e82efSRichard Henderson        fi
2914a73e82efSRichard Henderson    fi
2915a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
2916a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
2917ddbb0d09SDaniel P. Berrange    else
2918a73e82efSRichard Henderson        gnutls="$pass"
2919ddbb0d09SDaniel P. Berrange    fi
2920ddbb0d09SDaniel P. Berrangefi
2921ddbb0d09SDaniel P. Berrange
292291bfcdb0SDaniel P. Berrange
292391bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
292491bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
2925a0722409SDaniel P. Berrangé# explicitly
292691bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
292791bfcdb0SDaniel P. Berrangethen
2928a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
292991bfcdb0SDaniel P. Berrange    then
293091bfcdb0SDaniel P. Berrange        gcrypt="no"
293191bfcdb0SDaniel P. Berrange    fi
293291bfcdb0SDaniel P. Berrangefi
293391bfcdb0SDaniel P. Berrange
293491bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
293591bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
2936a0722409SDaniel P. Berrangé# explicitly
293791bfcdb0SDaniel P. Berrangeif test -z "$nettle"
293891bfcdb0SDaniel P. Berrangethen
2939a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
294091bfcdb0SDaniel P. Berrange    then
294191bfcdb0SDaniel P. Berrange        nettle="no"
294291bfcdb0SDaniel P. Berrange    fi
294391bfcdb0SDaniel P. Berrangefi
294491bfcdb0SDaniel P. Berrange
2945dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
294691bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
294791bfcdb0SDaniel P. Berrange    then
294891bfcdb0SDaniel P. Berrange	return 1
294991bfcdb0SDaniel P. Berrange    fi
295091bfcdb0SDaniel P. Berrange
295191bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
295291bfcdb0SDaniel P. Berrange    then
295389138857SStefan Weil	host=$(libgcrypt-config --host)
295491bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
295591bfcdb0SDaniel P. Berrange	then
295691bfcdb0SDaniel P. Berrange	    return 1
295791bfcdb0SDaniel P. Berrange	fi
295891bfcdb0SDaniel P. Berrange    fi
295991bfcdb0SDaniel P. Berrange
2960dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
2961dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
2962dea7a64eSDaniel P. Berrangé
2963dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
2964dea7a64eSDaniel P. Berrangé    then
2965dea7a64eSDaniel P. Berrangé       return 1
2966dea7a64eSDaniel P. Berrangé    fi
2967dea7a64eSDaniel P. Berrangé
296891bfcdb0SDaniel P. Berrange    return 0
296991bfcdb0SDaniel P. Berrange}
297091bfcdb0SDaniel P. Berrange
2971a0722409SDaniel P. Berrangé
2972a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
2973a73e82efSRichard Henderson    pass="no"
297464dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
2975a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
2976a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
2977a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
2978a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
2979a73e82efSRichard Henderson        write_c_skeleton
2980a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
2981a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
2982a0722409SDaniel P. Berrangé               gcrypt="no"
2983a0722409SDaniel P. Berrangé            fi
2984a73e82efSRichard Henderson            pass="yes"
2985a73e82efSRichard Henderson        fi
2986a73e82efSRichard Henderson    fi
2987dc2207afSDaniel P. Berrangé    if test "$pass" = "yes"
2988dc2207afSDaniel P. Berrangé    then
2989dc2207afSDaniel P. Berrangé        cat > $TMPC << EOF
2990dc2207afSDaniel P. Berrangé#include <nettle/xts.h>
2991dc2207afSDaniel P. Berrangéint main(void) {
2992dc2207afSDaniel P. Berrangé  return 0;
2993dc2207afSDaniel P. Berrangé}
2994dc2207afSDaniel P. BerrangéEOF
2995dc2207afSDaniel P. Berrangé        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
2996dc2207afSDaniel P. Berrangé            nettle_xts=yes
2997dc2207afSDaniel P. Berrangé            qemu_private_xts=no
2998dc2207afSDaniel P. Berrangé        fi
2999dc2207afSDaniel P. Berrangé    fi
3000a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
300164dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
3002a0722409SDaniel P. Berrangé    else
3003a73e82efSRichard Henderson        nettle="$pass"
3004a0722409SDaniel P. Berrangé    fi
3005a0722409SDaniel P. Berrangéfi
3006a0722409SDaniel P. Berrangé
300791bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
3008a73e82efSRichard Henderson    pass="no"
3009dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
301089138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
301189138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
3012a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
301391bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
301491bfcdb0SDaniel P. Berrange        # turn breaks static builds...
301591bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
301691bfcdb0SDaniel P. Berrange        then
301791bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
301891bfcdb0SDaniel P. Berrange        fi
30191f923c70SLongpeng(Mike)
3020a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3021a73e82efSRichard Henderson        write_c_skeleton
3022a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
3023a73e82efSRichard Henderson            pass="yes"
3024a73e82efSRichard Henderson        fi
3025a73e82efSRichard Henderson    fi
3026a73e82efSRichard Henderson    if test "$pass" = "yes"; then
302737788f25SDaniel P. Berrange        gcrypt="yes"
30281f923c70SLongpeng(Mike)        cat > $TMPC << EOF
30291f923c70SLongpeng(Mike)#include <gcrypt.h>
30301f923c70SLongpeng(Mike)int main(void) {
30311f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
30321f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
30331f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
30341f923c70SLongpeng(Mike)  return 0;
30351f923c70SLongpeng(Mike)}
30361f923c70SLongpeng(Mike)EOF
30371f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
30381f923c70SLongpeng(Mike)            gcrypt_hmac=yes
30391f923c70SLongpeng(Mike)        fi
3040e0576942SDaniel P. Berrangé        cat > $TMPC << EOF
3041e0576942SDaniel P. Berrangé#include <gcrypt.h>
3042e0576942SDaniel P. Berrangéint main(void) {
3043e0576942SDaniel P. Berrangé  gcry_cipher_hd_t handle;
3044e0576942SDaniel P. Berrangé  gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
3045e0576942SDaniel P. Berrangé  return 0;
3046e0576942SDaniel P. Berrangé}
3047e0576942SDaniel P. BerrangéEOF
3048e0576942SDaniel P. Berrangé        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3049e0576942SDaniel P. Berrangé            gcrypt_xts=yes
3050e0576942SDaniel P. Berrangé            qemu_private_xts=no
3051e0576942SDaniel P. Berrangé        fi
3052a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
3053dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
305491bfcdb0SDaniel P. Berrange    else
305591bfcdb0SDaniel P. Berrange        gcrypt="no"
305691bfcdb0SDaniel P. Berrange    fi
305762893b67SDaniel P. Berrangefi
305862893b67SDaniel P. Berrange
3059ddbb0d09SDaniel P. Berrange
306091bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
306191bfcdb0SDaniel P. Berrangethen
306291bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
306391bfcdb0SDaniel P. Berrangefi
3064ed754746SDaniel P. Berrange
30659a2fd434SDaniel P. Berrange##########################################
30669a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
30679a2fd434SDaniel P. Berrange
30689a2fd434SDaniel P. Berrangetasn1=yes
306990246037SDaniel P. Berrangetasn1_cflags=""
307090246037SDaniel P. Berrangetasn1_libs=""
30719a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
307289138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
307389138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
30749a2fd434SDaniel P. Berrangeelse
30759a2fd434SDaniel P. Berrange    tasn1=no
30769a2fd434SDaniel P. Berrangefi
30779a2fd434SDaniel P. Berrange
3078ed754746SDaniel P. Berrange
3079bbbf9bfbSStefan Weil##########################################
30808953caf3SDaniel P. Berrange# PAM probe
30818953caf3SDaniel P. Berrange
30828953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
30838953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
30848953caf3SDaniel P. Berrange#include <security/pam_appl.h>
30858953caf3SDaniel P. Berrange#include <stdio.h>
30868953caf3SDaniel P. Berrangeint main(void) {
30878953caf3SDaniel P. Berrange   const char *service_name = "qemu";
30888953caf3SDaniel P. Berrange   const char *user = "frank";
30899c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
30908953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
30919c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
30928953caf3SDaniel P. Berrange   return 0;
30938953caf3SDaniel P. Berrange}
30948953caf3SDaniel P. BerrangeEOF
30958953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
30968953caf3SDaniel P. Berrange        auth_pam=yes
30978953caf3SDaniel P. Berrange    else
30988953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
30998953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
31008953caf3SDaniel P. Berrange        else
31018953caf3SDaniel P. Berrange            auth_pam=no
31028953caf3SDaniel P. Berrange        fi
31038953caf3SDaniel P. Berrange    fi
31048953caf3SDaniel P. Berrangefi
31058953caf3SDaniel P. Berrange
31068953caf3SDaniel P. Berrange##########################################
3107559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
3108559607eaSDaniel P. Berrange
3109559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
3110559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
3111559607eaSDaniel P. Berrange  have_ifaddrs_h=no
3112559607eaSDaniel P. Berrangefi
3113559607eaSDaniel P. Berrange
3114e865b97fSChen Gang#########################################
3115e865b97fSChen Gang# libdrm check
3116e865b97fSChen Ganghave_drm_h=no
3117e865b97fSChen Gangif check_include "libdrm/drm.h" ; then
3118e865b97fSChen Gang    have_drm_h=yes
3119e865b97fSChen Gangfi
3120e865b97fSChen Gang
31212a4b472cSDavid CARLIER#########################################
31222a4b472cSDavid CARLIER# sys/signal.h check
31232a4b472cSDavid CARLIERhave_sys_signal_h=no
31242a4b472cSDavid CARLIERif check_include "sys/signal.h" ; then
31252a4b472cSDavid CARLIER  have_sys_signal_h=yes
31262a4b472cSDavid CARLIERfi
31272a4b472cSDavid CARLIER
3128559607eaSDaniel P. Berrange##########################################
3129bbbf9bfbSStefan Weil# VTE probe
3130bbbf9bfbSStefan Weil
3131bbbf9bfbSStefan Weilif test "$vte" != "no"; then
3132c6feff9eSCole Robinson    vteminversion="0.32.0"
3133c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
3134c6feff9eSCole Robinson      vtepackage="vte-2.91"
3135c6feff9eSCole Robinson    else
3136528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
3137c6feff9eSCole Robinson    fi
3138c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
313989138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
314089138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
314189138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
3142bbbf9bfbSStefan Weil        vte="yes"
3143bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
3144c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
31459e04c683SStefan Weil    else
3146bbbf9bfbSStefan Weil        vte="no"
3147a4ccabcfSAnthony Liguori    fi
3148a4ccabcfSAnthony Liguorifi
3149a4ccabcfSAnthony Liguori
3150a4ccabcfSAnthony Liguori##########################################
31512da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
31522da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
31532da776dbSMichael R. Hines  cat > $TMPC <<EOF
31542da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
31552da776dbSMichael R. Hinesint main(void) { return 0; }
31562da776dbSMichael R. HinesEOF
3157ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
31582da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
31592da776dbSMichael R. Hines    rdma="yes"
31602da776dbSMichael R. Hines  else
31612da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
31622da776dbSMichael R. Hines        error_exit \
3163ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
31642da776dbSMichael R. Hines            " Your options:" \
3165ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
31662da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
31672da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
31682da776dbSMichael R. Hines    fi
31692da776dbSMichael R. Hines    rdma="no"
31702da776dbSMichael R. Hines  fi
31712da776dbSMichael R. Hinesfi
31722da776dbSMichael R. Hines
317321ab34c9SMarcel Apfelbaum##########################################
317421ab34c9SMarcel Apfelbaum# PVRDMA detection
317521ab34c9SMarcel Apfelbaum
317621ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
317721ab34c9SMarcel Apfelbaum#include <sys/mman.h>
317821ab34c9SMarcel Apfelbaum
317921ab34c9SMarcel Apfelbaumint
318021ab34c9SMarcel Apfelbaummain(void)
318121ab34c9SMarcel Apfelbaum{
318221ab34c9SMarcel Apfelbaum    char buf = 0;
318321ab34c9SMarcel Apfelbaum    void *addr = &buf;
318421ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
318521ab34c9SMarcel Apfelbaum
318621ab34c9SMarcel Apfelbaum    return 0;
318721ab34c9SMarcel Apfelbaum}
318821ab34c9SMarcel ApfelbaumEOF
318921ab34c9SMarcel Apfelbaum
319021ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
319121ab34c9SMarcel Apfelbaum    case "$pvrdma" in
319221ab34c9SMarcel Apfelbaum    "")
319321ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
319421ab34c9SMarcel Apfelbaum            pvrdma="yes"
319521ab34c9SMarcel Apfelbaum        else
319621ab34c9SMarcel Apfelbaum            pvrdma="no"
319721ab34c9SMarcel Apfelbaum        fi
319821ab34c9SMarcel Apfelbaum        ;;
319921ab34c9SMarcel Apfelbaum    "yes")
320021ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
320121ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
320221ab34c9SMarcel Apfelbaum        fi
320321ab34c9SMarcel Apfelbaum        pvrdma="yes"
320421ab34c9SMarcel Apfelbaum        ;;
320521ab34c9SMarcel Apfelbaum    "no")
320621ab34c9SMarcel Apfelbaum        pvrdma="no"
320721ab34c9SMarcel Apfelbaum        ;;
320821ab34c9SMarcel Apfelbaum    esac
320921ab34c9SMarcel Apfelbaumelse
321021ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
321121ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
321221ab34c9SMarcel Apfelbaum    fi
321321ab34c9SMarcel Apfelbaum    pvrdma="no"
321421ab34c9SMarcel Apfelbaumfi
321595c6bff3SBenoît Canet
3216ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
3217ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
3218ee108585SYuval Shaia
3219ee108585SYuval Shaiacat > $TMPC <<EOF &&
3220ee108585SYuval Shaia#include <infiniband/verbs.h>
3221ee108585SYuval Shaia
3222ee108585SYuval Shaiaint
3223ee108585SYuval Shaiamain(void)
3224ee108585SYuval Shaia{
3225ee108585SYuval Shaia    struct ibv_mr *mr;
3226ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
3227ee108585SYuval Shaia    size_t length = 10;
3228ee108585SYuval Shaia    uint64_t iova = 0;
3229ee108585SYuval Shaia    int access = 0;
3230ee108585SYuval Shaia    void *addr = NULL;
3231ee108585SYuval Shaia
3232ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3233ee108585SYuval Shaia
3234ee108585SYuval Shaia    ibv_dereg_mr(mr);
3235ee108585SYuval Shaia
3236ee108585SYuval Shaia    return 0;
3237ee108585SYuval Shaia}
3238ee108585SYuval ShaiaEOF
3239ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
3240ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3241ee108585SYuval Shaia    fi
3242ee108585SYuval Shaiafi
3243ee108585SYuval Shaia
324495c6bff3SBenoît Canet##########################################
3245c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3246dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3247dce512deSChristoph Hellwig  cat > $TMPC << EOF
3248ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3249dce512deSChristoph Hellwig#include <xfs/xfs.h>
3250dce512deSChristoph Hellwigint main(void)
3251dce512deSChristoph Hellwig{
3252dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3253dce512deSChristoph Hellwig    return 0;
3254dce512deSChristoph Hellwig}
3255dce512deSChristoph HellwigEOF
3256dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3257dce512deSChristoph Hellwig    xfs="yes"
3258dce512deSChristoph Hellwig  else
3259dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
3260e3a6e0daSzhaolichang      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
3261dce512deSChristoph Hellwig    fi
3262dce512deSChristoph Hellwig    xfs=no
3263dce512deSChristoph Hellwig  fi
3264dce512deSChristoph Hellwigfi
3265dce512deSChristoph Hellwig
3266dce512deSChristoph Hellwig##########################################
32678a16d273Sths# vde libraries probe
3268dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
32694baae0acSJuan Quintela  vde_libs="-lvdeplug"
32708a16d273Sths  cat > $TMPC << EOF
32718a16d273Sths#include <libvdeplug.h>
32724a7f0e06Spbrookint main(void)
32734a7f0e06Spbrook{
32744a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3275fea08e08SPeter Maydell    char s[] = "";
3276fea08e08SPeter Maydell    vde_open(s, s, &a);
32774a7f0e06Spbrook    return 0;
32784a7f0e06Spbrook}
32798a16d273SthsEOF
328052166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
32814baae0acSJuan Quintela    vde=yes
3282dfb278bdSJuan Quintela  else
3283dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
328421684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3285dfb278bdSJuan Quintela    fi
3286dfb278bdSJuan Quintela    vde=no
32878a16d273Sths  fi
32888a16d273Sthsfi
32898a16d273Sths
32908a16d273Sths##########################################
32910a985b37SVincenzo Maffione# netmap support probe
32920a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
32930a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
32940a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
32950a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
32960a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
329758952137SVincenzo Maffioneif test "$netmap" != "no" ; then
329858952137SVincenzo Maffione  cat > $TMPC << EOF
329958952137SVincenzo Maffione#include <inttypes.h>
330058952137SVincenzo Maffione#include <net/if.h>
330158952137SVincenzo Maffione#include <net/netmap.h>
330258952137SVincenzo Maffione#include <net/netmap_user.h>
33030a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
33040a985b37SVincenzo Maffione#error
33050a985b37SVincenzo Maffione#endif
330658952137SVincenzo Maffioneint main(void) { return 0; }
330758952137SVincenzo MaffioneEOF
330858952137SVincenzo Maffione  if compile_prog "" "" ; then
330958952137SVincenzo Maffione    netmap=yes
331058952137SVincenzo Maffione  else
331158952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
331258952137SVincenzo Maffione      feature_not_found "netmap"
331358952137SVincenzo Maffione    fi
331458952137SVincenzo Maffione    netmap=no
331558952137SVincenzo Maffione  fi
331658952137SVincenzo Maffionefi
331758952137SVincenzo Maffione
331858952137SVincenzo Maffione##########################################
331947e98658SCorey Bryant# libcap-ng library probe
332047e98658SCorey Bryantif test "$cap_ng" != "no" ; then
332147e98658SCorey Bryant  cap_libs="-lcap-ng"
332247e98658SCorey Bryant  cat > $TMPC << EOF
332347e98658SCorey Bryant#include <cap-ng.h>
332447e98658SCorey Bryantint main(void)
332547e98658SCorey Bryant{
332647e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
332747e98658SCorey Bryant    return 0;
332847e98658SCorey Bryant}
332947e98658SCorey BryantEOF
333047e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
333147e98658SCorey Bryant    cap_ng=yes
333247e98658SCorey Bryant  else
333347e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
333421684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
333547e98658SCorey Bryant    fi
333647e98658SCorey Bryant    cap_ng=no
333747e98658SCorey Bryant  fi
333847e98658SCorey Bryantfi
333947e98658SCorey Bryant
334047e98658SCorey Bryant##########################################
3341c2de5c91Smalc# Sound support libraries probe
33428f28f3fbSths
334389138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3344c2de5c91Smalcfor drv in $audio_drv_list; do
3345c2de5c91Smalc    case $drv in
3346e42975a1SGerd Hoffmann    alsa | try-alsa)
3347c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3348c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3349478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
3350478e943fSPaolo Bonzini        alsa=yes
3351e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3352e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3353e42975a1SGerd Hoffmann        fi
3354e42975a1SGerd Hoffmann    else
3355e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3356e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3357c80a867fSGerd Hoffmann        else
3358c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3359c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3360c80a867fSGerd Hoffmann        fi
3361e42975a1SGerd Hoffmann    fi
3362c2de5c91Smalc    ;;
3363c2de5c91Smalc
3364e42975a1SGerd Hoffmann    pa | try-pa)
3365c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3366478e943fSPaolo Bonzini        libpulse=yes
3367c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3368478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3369e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3370e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3371e42975a1SGerd Hoffmann        fi
3372e42975a1SGerd Hoffmann    else
3373e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3374e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3375c80a867fSGerd Hoffmann        else
3376c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3377c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3378c80a867fSGerd Hoffmann        fi
3379e42975a1SGerd Hoffmann    fi
3380b8e59f18Smalc    ;;
3381b8e59f18Smalc
3382373967b2SGerd Hoffmann    sdl)
3383373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3384373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3385373967b2SGerd Hoffmann    fi
3386373967b2SGerd Hoffmann    ;;
3387373967b2SGerd Hoffmann
3388e42975a1SGerd Hoffmann    try-sdl)
3389e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3390e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3391e42975a1SGerd Hoffmann    else
3392e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3393e42975a1SGerd Hoffmann    fi
3394e42975a1SGerd Hoffmann    ;;
3395e42975a1SGerd Hoffmann
3396997e690aSJuan Quintela    coreaudio)
3397b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3398997e690aSJuan Quintela    ;;
3399997e690aSJuan Quintela
3400a4bf6780SJuan Quintela    dsound)
3401b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3402d5631638Smalc      audio_win_int="yes"
3403a4bf6780SJuan Quintela    ;;
3404a4bf6780SJuan Quintela
3405a4bf6780SJuan Quintela    oss)
3406b1149911SFam Zheng      oss_libs="$oss_lib"
3407a4bf6780SJuan Quintela    ;;
3408a4bf6780SJuan Quintela
34092e445703SGeoffrey McRae    jack | try-jack)
34102e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3411478e943fSPaolo Bonzini        libjack=yes
34122e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
34132e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
34142e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
34152e445703SGeoffrey McRae        fi
34162e445703SGeoffrey McRae    else
34172e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
34182e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
34192e445703SGeoffrey McRae        else
34202e445703SGeoffrey McRae            error_exit "$drv check failed" \
34212e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
34222e445703SGeoffrey McRae        fi
34232e445703SGeoffrey McRae    fi
34242e445703SGeoffrey McRae    ;;
34252e445703SGeoffrey McRae
3426e4c63a6aSmalc    *)
34271c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
342876ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
342976ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3430e4c63a6aSmalc    }
3431e4c63a6aSmalc    ;;
3432c2de5c91Smalc    esac
3433c2de5c91Smalcdone
34348f28f3fbSths
34354d3b6f6eSbalrog##########################################
34362e4d9fb1Saurel32# BrlAPI probe
34372e4d9fb1Saurel32
34384ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3439eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
34402e4d9fb1Saurel32  cat > $TMPC << EOF
34412e4d9fb1Saurel32#include <brlapi.h>
3442832ce9c2SScott Wood#include <stddef.h>
34432e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
34442e4d9fb1Saurel32EOF
344552166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
34462e4d9fb1Saurel32    brlapi=yes
34474ffcedb6SJuan Quintela  else
34484ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
344921684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
34504ffcedb6SJuan Quintela    fi
34514ffcedb6SJuan Quintela    brlapi=no
3452eb82284fSJuan Quintela  fi
3453eb82284fSJuan Quintelafi
34542e4d9fb1Saurel32
34552e4d9fb1Saurel32##########################################
3456769ce76dSAlexander Graf# curl probe
3457a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
345865d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3459a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
34604e2b0658SPaolo Bonzini  else
34614e2b0658SPaolo Bonzini    curlconfig=curl-config
34624e2b0658SPaolo Bonzini  fi
3463769ce76dSAlexander Graf  cat > $TMPC << EOF
3464769ce76dSAlexander Graf#include <curl/curl.h>
34650b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3466769ce76dSAlexander GrafEOF
346789138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
346889138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3469b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3470769ce76dSAlexander Graf    curl=yes
3471788c8196SJuan Quintela  else
3472788c8196SJuan Quintela    if test "$curl" = "yes" ; then
347321684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3474788c8196SJuan Quintela    fi
3475788c8196SJuan Quintela    curl=no
3476769ce76dSAlexander Graf  fi
3477769ce76dSAlexander Graffi # test "$curl"
3478769ce76dSAlexander Graf
3479769ce76dSAlexander Graf##########################################
3480e18df141SAnthony Liguori# glib support probe
3481a52d28afSPaolo Bonzini
348200f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
3483aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3484aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3485a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3486aa0d1f44SPaolo Bonzinifi
348754cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
348854cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
348954cb65d8SEmilio G. Cotafi
3490e26110cfSFam Zheng
3491aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3492e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
349389138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
349489138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
3495e18df141SAnthony Liguori    else
3496e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3497e26110cfSFam Zheng    fi
3498e26110cfSFam Zhengdone
3499e26110cfSFam Zheng
3500215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
3501215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3502215b0c2fSPaolo Bonzini
3503215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
3504215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
3505215b0c2fSPaolo Bonzinifi
3506215b0c2fSPaolo Bonzini
3507f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3508f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
3509f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
351025a97a56SMarc-André Lureau    gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
35110dba4897SMarc-André Lureau    if [ ! -x "$gdbus_codegen" ]; then
35120dba4897SMarc-André Lureau        gdbus_codegen=
35130dba4897SMarc-André Lureau    fi
351476346b62SPeter Maydell    # Check that the libraries actually work -- Ubuntu 18.04 ships
351576346b62SPeter Maydell    # with pkg-config --static --libs data for gio-2.0 that is missing
351676346b62SPeter Maydell    # -lblkid and will give a link error.
351713ceae66SPeter Maydell    cat > $TMPC <<EOF
351813ceae66SPeter Maydell#include <gio/gio.h>
351913ceae66SPeter Maydellint main(void)
352013ceae66SPeter Maydell{
352113ceae66SPeter Maydell    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
352213ceae66SPeter Maydell    return 0;
352313ceae66SPeter Maydell}
352413ceae66SPeter MaydellEOF
352513ceae66SPeter Maydell    if compile_prog "$gio_cflags" "$gio_libs" ; then
352676346b62SPeter Maydell        gio=yes
352776346b62SPeter Maydell    else
352876346b62SPeter Maydell        gio=no
352976346b62SPeter Maydell    fi
3530f876b765SMarc-André Lureauelse
3531f876b765SMarc-André Lureau    gio=no
3532f876b765SMarc-André Lureaufi
3533f876b765SMarc-André Lureau
353425a97a56SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
353525a97a56SMarc-André Lureau    gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
353625a97a56SMarc-André Lureau    gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
353725a97a56SMarc-André Lureaufi
353825a97a56SMarc-André Lureau
3539977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3540977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3541977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3542977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3543977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3544977a82abSDaniel P. Berrange#include <glib.h>
3545977a82abSDaniel P. Berrange#include <unistd.h>
3546977a82abSDaniel P. Berrange
3547977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3548977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3549977a82abSDaniel P. Berrange
3550977a82abSDaniel P. Berrangeint main(void) {
3551977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3552977a82abSDaniel P. Berrange   return 0;
3553977a82abSDaniel P. Berrange}
3554977a82abSDaniel P. BerrangeEOF
3555977a82abSDaniel P. Berrange
3556215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3557977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3558977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3559977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3560977a82abSDaniel P. Berrange	       "build target"
3561977a82abSDaniel P. Berrangefi
3562977a82abSDaniel P. Berrange
3563bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3564bbbf2e04SJohn Snowcat > $TMPC << EOF
3565bbbf2e04SJohn Snow#include <glib.h>
3566bbbf2e04SJohn Snowint main(void) { return 0; }
3567bbbf2e04SJohn SnowEOF
3568bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3569bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3570bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
35715770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="-Wno-unknown-attributes $CONFIGURE_CFLAGS"
3572bbbf2e04SJohn Snow    fi
3573bbbf2e04SJohn Snowfi
3574bbbf2e04SJohn Snow
35759bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
35769bda600bSEric Blakecat > $TMPC << EOF
35779bda600bSEric Blake#include <glib.h>
35789bda600bSEric Blaketypedef struct Foo {
35799bda600bSEric Blake    int i;
35809bda600bSEric Blake} Foo;
35819bda600bSEric Blakestatic void foo_free(Foo *f)
35829bda600bSEric Blake{
35839bda600bSEric Blake    g_free(f);
35849bda600bSEric Blake}
35859bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
35869bda600bSEric Blakeint main(void) { return 0; }
35879bda600bSEric BlakeEOF
35889bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
35899bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
35909bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
35915770e8afSPaolo Bonzini        CONFIGURE_CFLAGS="$CONFIGURE_CFLAGS -Wno-unused-function"
35929bda600bSEric Blake    fi
35939bda600bSEric Blakefi
35949bda600bSEric Blake
3595e26110cfSFam Zheng##########################################
3596e26110cfSFam Zheng# SHA command probe for modules
3597e26110cfSFam Zhengif test "$modules" = yes; then
3598e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3599e26110cfSFam Zheng    for c in $shacmd_probe; do
36008ccefb91SFam Zheng        if has $c; then
3601e26110cfSFam Zheng            shacmd="$c"
3602e26110cfSFam Zheng            break
3603e26110cfSFam Zheng        fi
3604e26110cfSFam Zheng    done
3605e26110cfSFam Zheng    if test "$shacmd" = ""; then
3606e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3607e26110cfSFam Zheng    fi
3608e18df141SAnthony Liguorifi
3609e18df141SAnthony Liguori
3610e18df141SAnthony Liguori##########################################
3611e5d355d1Saliguori# pthread probe
36124b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
36133c529d93Saliguori
3614e5d355d1Saliguoripthread=no
3615414f0dabSblueswir1cat > $TMPC << EOF
36163c529d93Saliguori#include <pthread.h>
36177a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
36187a42bbe4SStefan Weilint main(void) {
36197a42bbe4SStefan Weil  pthread_t thread;
36207a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
36217a42bbe4SStefan Weil  return 0;
36227a42bbe4SStefan Weil}
3623414f0dabSblueswir1EOF
3624bd00d539SAndreas Färberif compile_prog "" "" ; then
3625bd00d539SAndreas Färber  pthread=yes
3626bd00d539SAndreas Färberelse
3627de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
362852166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3629e5d355d1Saliguori      pthread=yes
3630e3c56761SPeter Portante      found=no
3631e3c56761SPeter Portante      for lib_entry in $LIBS; do
3632e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3633e3c56761SPeter Portante          found=yes
3634e3c56761SPeter Portante          break
3635e3c56761SPeter Portante        fi
3636e3c56761SPeter Portante      done
3637e3c56761SPeter Portante      if test "$found" = "no"; then
36385572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3639e3c56761SPeter Portante      fi
3640de65fe0fSSebastian Herbszt      break
3641414f0dabSblueswir1    fi
3642de65fe0fSSebastian Herbszt  done
3643bd00d539SAndreas Färberfi
3644414f0dabSblueswir1
3645e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
364676ad07a4SPeter Maydell  error_exit "pthread check failed" \
364776ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3648e5d355d1Saliguorifi
3649e5d355d1Saliguori
3650479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3651479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
36525c312079SDr. David Alan Gilbertcat > $TMPC << EOF
36535c312079SDr. David Alan Gilbert#include <pthread.h>
36545c312079SDr. David Alan Gilbert
36555c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
36565c312079SDr. David Alan Gilbertint main(void)
36575c312079SDr. David Alan Gilbert{
36585c312079SDr. David Alan Gilbert    pthread_t thread;
36595c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
36605c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
36615c312079SDr. David Alan Gilbert    return 0;
36625c312079SDr. David Alan Gilbert}
36635c312079SDr. David Alan GilbertEOF
36645c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3665479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3666479a5747SRoman Bolshakovfi
3667479a5747SRoman Bolshakov
3668479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3669479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3670479a5747SRoman Bolshakovcat > $TMPC << EOF
3671479a5747SRoman Bolshakov#include <pthread.h>
3672479a5747SRoman Bolshakov
367312a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3674479a5747SRoman Bolshakovint main(void)
3675479a5747SRoman Bolshakov{
3676479a5747SRoman Bolshakov    pthread_t thread;
3677479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3678479a5747SRoman Bolshakov    return 0;
3679479a5747SRoman Bolshakov}
3680479a5747SRoman BolshakovEOF
3681479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3682479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
36835c312079SDr. David Alan Gilbertfi
36845c312079SDr. David Alan Gilbert
3685bf9298b9Saliguori##########################################
3686f27aaf4bSChristian Brunner# rbd probe
3687f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3688f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
3689f27aaf4bSChristian Brunner#include <stdio.h>
3690ad32e9c0SJosh Durgin#include <rbd/librbd.h>
3691f27aaf4bSChristian Brunnerint main(void) {
3692ad32e9c0SJosh Durgin    rados_t cluster;
3693ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
3694f27aaf4bSChristian Brunner    return 0;
3695f27aaf4bSChristian Brunner}
3696f27aaf4bSChristian BrunnerEOF
3697ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
3698f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
3699f27aaf4bSChristian Brunner    rbd=yes
3700f27aaf4bSChristian Brunner  else
3701f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
370221684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
3703f27aaf4bSChristian Brunner    fi
3704f27aaf4bSChristian Brunner    rbd=no
3705f27aaf4bSChristian Brunner  fi
3706f27aaf4bSChristian Brunnerfi
3707f27aaf4bSChristian Brunner
3708f27aaf4bSChristian Brunner##########################################
3709b10d49d7SPino Toscano# libssh probe
3710b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
3711b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
3712b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
3713b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
3714b10d49d7SPino Toscano    libssh=yes
37150a12ec87SRichard W.M. Jones  else
3716b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
3717b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
37180a12ec87SRichard W.M. Jones    fi
3719b10d49d7SPino Toscano    libssh=no
37200a12ec87SRichard W.M. Jones  fi
37210a12ec87SRichard W.M. Jonesfi
37220a12ec87SRichard W.M. Jones
37230a12ec87SRichard W.M. Jones##########################################
3724b10d49d7SPino Toscano# Check for libssh 0.8
3725b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
3726b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
3727b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
3728b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
37299a2d462eSRichard W.M. Jones
3730b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
37319a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
3732b10d49d7SPino Toscano#include <libssh/libssh.h>
3733b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
37349a2d462eSRichard W.M. JonesEOF
3735b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
3736b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
37379a2d462eSRichard W.M. Jones  fi
37389a2d462eSRichard W.M. Jonesfi
37399a2d462eSRichard W.M. Jones
37409a2d462eSRichard W.M. Jones##########################################
37415c6c3a6cSChristoph Hellwig# linux-aio probe
37425c6c3a6cSChristoph Hellwig
37435c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
37445c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
37455c6c3a6cSChristoph Hellwig#include <libaio.h>
37465c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
3747832ce9c2SScott Wood#include <stddef.h>
37485c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
37495c6c3a6cSChristoph HellwigEOF
37505c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
37515c6c3a6cSChristoph Hellwig    linux_aio=yes
37525c6c3a6cSChristoph Hellwig  else
37535c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
375421684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
37555c6c3a6cSChristoph Hellwig    fi
37563cfcae3cSLuiz Capitulino    linux_aio=no
37575c6c3a6cSChristoph Hellwig  fi
37585c6c3a6cSChristoph Hellwigfi
3759c10dd856SAarushi Mehta##########################################
3760c10dd856SAarushi Mehta# linux-io-uring probe
3761c10dd856SAarushi Mehta
3762c10dd856SAarushi Mehtaif test "$linux_io_uring" != "no" ; then
3763c10dd856SAarushi Mehta  if $pkg_config liburing; then
3764c10dd856SAarushi Mehta    linux_io_uring_cflags=$($pkg_config --cflags liburing)
3765c10dd856SAarushi Mehta    linux_io_uring_libs=$($pkg_config --libs liburing)
3766c10dd856SAarushi Mehta    linux_io_uring=yes
3767c10dd856SAarushi Mehta  else
3768c10dd856SAarushi Mehta    if test "$linux_io_uring" = "yes" ; then
3769c10dd856SAarushi Mehta      feature_not_found "linux io_uring" "Install liburing devel"
3770c10dd856SAarushi Mehta    fi
3771c10dd856SAarushi Mehta    linux_io_uring=no
3772c10dd856SAarushi Mehta  fi
3773c10dd856SAarushi Mehtafi
37745c6c3a6cSChristoph Hellwig
37755c6c3a6cSChristoph Hellwig##########################################
37767aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
37773b8acc11SPaolo Bonzini
37787aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
37797aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
37807aaa6a16SPaolo Bonzini    tpm=no
37813b8acc11SPaolo Bonzini  else
37827aaa6a16SPaolo Bonzini    tpm=yes
37837aaa6a16SPaolo Bonzini  fi
37847aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
37857aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
37867aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
37877aaa6a16SPaolo Bonzini  fi
37883b8acc11SPaolo Bonzinifi
37893b8acc11SPaolo Bonzini
37903b8acc11SPaolo Bonzini##########################################
3791758e8e38SVenkateswararao Jujjuri (JV)# attr probe
3792758e8e38SVenkateswararao Jujjuri (JV)
3793ec0d5893SMarc-André Lureaulibattr_libs=
3794758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
3795758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
3796758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
3797758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
3798f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
3799f2338fb4SPavel Borzenkov#include <attr/xattr.h>
3800f2338fb4SPavel Borzenkov#else
38014f26f2b6SAvi Kivity#include <sys/xattr.h>
3802f2338fb4SPavel Borzenkov#endif
3803758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
3804758e8e38SVenkateswararao Jujjuri (JV)EOF
38054f26f2b6SAvi Kivity  if compile_prog "" "" ; then
38064f26f2b6SAvi Kivity    attr=yes
38074f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
3808f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
3809758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
3810ec0d5893SMarc-André Lureau    libattr_libs="-lattr"
38114f26f2b6SAvi Kivity    libattr=yes
3812758e8e38SVenkateswararao Jujjuri (JV)  else
3813758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
381421684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
3815758e8e38SVenkateswararao Jujjuri (JV)    fi
3816758e8e38SVenkateswararao Jujjuri (JV)    attr=no
3817758e8e38SVenkateswararao Jujjuri (JV)  fi
3818758e8e38SVenkateswararao Jujjuri (JV)fi
3819758e8e38SVenkateswararao Jujjuri (JV)
3820758e8e38SVenkateswararao Jujjuri (JV)##########################################
3821bf9298b9Saliguori# iovec probe
3822bf9298b9Saliguoricat > $TMPC <<EOF
3823db34f0b3Sblueswir1#include <sys/types.h>
3824bf9298b9Saliguori#include <sys/uio.h>
3825db34f0b3Sblueswir1#include <unistd.h>
3826f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
3827bf9298b9SaliguoriEOF
3828bf9298b9Saliguoriiovec=no
382952166aa0SJuan Quintelaif compile_prog "" "" ; then
3830bf9298b9Saliguori  iovec=yes
3831bf9298b9Saliguorifi
3832bf9298b9Saliguori
3833f652e6afSaurel32##########################################
3834ceb42de8Saliguori# preadv probe
3835ceb42de8Saliguoricat > $TMPC <<EOF
3836ceb42de8Saliguori#include <sys/types.h>
3837ceb42de8Saliguori#include <sys/uio.h>
3838ceb42de8Saliguori#include <unistd.h>
3839c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
3840ceb42de8SaliguoriEOF
3841ceb42de8Saliguoripreadv=no
384252166aa0SJuan Quintelaif compile_prog "" "" ; then
3843ceb42de8Saliguori  preadv=yes
3844ceb42de8Saliguorifi
3845ceb42de8Saliguori
3846ceb42de8Saliguori##########################################
3847f652e6afSaurel32# fdt probe
3848e169e1e1SPeter Maydell
3849fbb4121dSPaolo Bonzinicase "$fdt" in
3850fbb4121dSPaolo Bonzini  auto | enabled | internal)
3851fbb4121dSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
3852fbb4121dSPaolo Bonzini    if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
3853aef45d51SDaniel P. Berrange      git_submodules="${git_submodules} dtc"
3854aef45d51SDaniel P. Berrange    fi
3855fbb4121dSPaolo Bonzini    ;;
3856fbb4121dSPaolo Bonziniesac
3857f652e6afSaurel32
385820ff075bSMichael Walle##########################################
3859fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
3860b1546f32SGerd Hoffmann
3861d52c454aSMarc-André Lureaugbm="no"
3862d52c454aSMarc-André Lureauif $pkg_config gbm; then
3863d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
3864d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
3865d52c454aSMarc-André Lureau    gbm="yes"
3866d52c454aSMarc-André Lureaufi
3867d52c454aSMarc-André Lureau
3868da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
38694939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
38705f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
38715f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
38725f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
3873da076ffeSGerd Hoffmann    opengl=yes
3874925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
3875925a0400SGerd Hoffmann        gtk_gl="yes"
3876925a0400SGerd Hoffmann    fi
387720ff075bSMichael Walle  else
3878da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
3879dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
388020ff075bSMichael Walle    fi
3881f676c67eSJeremy White    opengl_cflags=""
3882da076ffeSGerd Hoffmann    opengl_libs=""
3883da076ffeSGerd Hoffmann    opengl=no
388420ff075bSMichael Walle  fi
388520ff075bSMichael Wallefi
388620ff075bSMichael Walle
3887014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
3888014cb152SGerd Hoffmann  cat > $TMPC << EOF
3889014cb152SGerd Hoffmann#include <epoxy/egl.h>
3890014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
3891014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
3892014cb152SGerd Hoffmann#endif
3893014cb152SGerd Hoffmannint main(void) { return 0; }
3894014cb152SGerd HoffmannEOF
3895014cb152SGerd Hoffmann  if compile_prog "" "" ; then
3896014cb152SGerd Hoffmann    opengl_dmabuf=yes
3897014cb152SGerd Hoffmann  fi
3898014cb152SGerd Hoffmannfi
3899c9a12e75SChrysostomos Nanakos
3900e633a5c6SEric Blakeif test "$opengl" = "yes" && test "$have_x11" = "yes"; then
390199e1a93bSPhilippe Mathieu-Daudé  for target in $target_list; do
390299e1a93bSPhilippe Mathieu-Daudé    case $target in
390399e1a93bSPhilippe Mathieu-Daudé      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
390499e1a93bSPhilippe Mathieu-Daudé        need_x11=yes
390599e1a93bSPhilippe Mathieu-Daudé      ;;
390699e1a93bSPhilippe Mathieu-Daudé    esac
390799e1a93bSPhilippe Mathieu-Daudé  done
390899e1a93bSPhilippe Mathieu-Daudéfi
390999e1a93bSPhilippe Mathieu-Daudé
3910ed279a06SKlim Kireev##########################################
3911ed279a06SKlim Kireev# libxml2 probe
3912ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
3913ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
3914ed279a06SKlim Kireev        libxml2="yes"
3915ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
3916ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
3917ed279a06SKlim Kireev    else
3918ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
3919ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
3920ed279a06SKlim Kireev        fi
3921ed279a06SKlim Kireev        libxml2="no"
3922ed279a06SKlim Kireev    fi
3923ed279a06SKlim Kireevfi
3924c9a12e75SChrysostomos Nanakos
3925eb100396SBharata B Rao##########################################
3926eb100396SBharata B Rao# glusterfs probe
3927eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
392865d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
3929e01bee08SBharata B Rao    glusterfs="yes"
393089138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
393189138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
3932d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
3933d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
3934d85fa9ebSJeff Cody    fi
393565d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
39360c14fb47SBharata B Rao      glusterfs_discard="yes"
39370c14fb47SBharata B Rao    fi
39387c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
3939df3a429aSNiels de Vos      glusterfs_fallocate="yes"
39407c815372SBharata B Rao      glusterfs_zerofill="yes"
39417c815372SBharata B Rao    fi
3942e014dbe7SPrasanna Kumar Kalever    cat > $TMPC << EOF
3943e014dbe7SPrasanna Kumar Kalever#include <glusterfs/api/glfs.h>
3944e014dbe7SPrasanna Kumar Kalever
3945e014dbe7SPrasanna Kumar Kaleverint
3946e014dbe7SPrasanna Kumar Kalevermain(void)
3947e014dbe7SPrasanna Kumar Kalever{
3948e014dbe7SPrasanna Kumar Kalever	/* new glfs_ftruncate() passes two additional args */
3949e014dbe7SPrasanna Kumar Kalever	return glfs_ftruncate(NULL, 0, NULL, NULL);
3950e014dbe7SPrasanna Kumar Kalever}
3951e014dbe7SPrasanna Kumar KaleverEOF
3952e014dbe7SPrasanna Kumar Kalever    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
3953e014dbe7SPrasanna Kumar Kalever      glusterfs_ftruncate_has_stat="yes"
3954e014dbe7SPrasanna Kumar Kalever    fi
39550e3b891fSNiels de Vos    cat > $TMPC << EOF
39560e3b891fSNiels de Vos#include <glusterfs/api/glfs.h>
39570e3b891fSNiels de Vos
39580e3b891fSNiels de Vos/* new glfs_io_cbk() passes two additional glfs_stat structs */
39590e3b891fSNiels de Vosstatic void
39600e3b891fSNiels de Vosglusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
39610e3b891fSNiels de Vos{}
39620e3b891fSNiels de Vos
39630e3b891fSNiels de Vosint
39640e3b891fSNiels de Vosmain(void)
39650e3b891fSNiels de Vos{
39660e3b891fSNiels de Vos	glfs_io_cbk iocb = &glusterfs_iocb;
39670e3b891fSNiels de Vos	iocb(NULL, 0 , NULL, NULL, NULL);
39680e3b891fSNiels de Vos	return 0;
39690e3b891fSNiels de Vos}
39700e3b891fSNiels de VosEOF
39710e3b891fSNiels de Vos    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
39720e3b891fSNiels de Vos      glusterfs_iocb_has_stat="yes"
39730e3b891fSNiels de Vos    fi
3974eb100396SBharata B Rao  else
3975eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
39768efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
39778efc9363SHu Tao          "Install glusterfs-api devel >= 3"
3978eb100396SBharata B Rao    fi
3979e01bee08SBharata B Rao    glusterfs="no"
3980eb100396SBharata B Rao  fi
3981eb100396SBharata B Raofi
3982eb100396SBharata B Rao
398339386ac7Saurel32# Check for inotify functions when we are building linux-user
39843b3f24adSaurel32# emulator.  This is done because older glibc versions don't
39853b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
39863b3f24adSaurel32# don't provide them even if kernel supports them.
39873b3f24adSaurel32#
39883b3f24adSaurel32inotify=no
39893b3f24adSaurel32cat > $TMPC << EOF
39903b3f24adSaurel32#include <sys/inotify.h>
39913b3f24adSaurel32
39923b3f24adSaurel32int
39933b3f24adSaurel32main(void)
39943b3f24adSaurel32{
39953b3f24adSaurel32	/* try to start inotify */
39968690e420Saurel32	return inotify_init();
39973b3f24adSaurel32}
39983b3f24adSaurel32EOF
399952166aa0SJuan Quintelaif compile_prog "" "" ; then
40003b3f24adSaurel32  inotify=yes
40013b3f24adSaurel32fi
40023b3f24adSaurel32
4003c05c7a73SRiku Voipioinotify1=no
4004c05c7a73SRiku Voipiocat > $TMPC << EOF
4005c05c7a73SRiku Voipio#include <sys/inotify.h>
4006c05c7a73SRiku Voipio
4007c05c7a73SRiku Voipioint
4008c05c7a73SRiku Voipiomain(void)
4009c05c7a73SRiku Voipio{
4010c05c7a73SRiku Voipio    /* try to start inotify */
4011c05c7a73SRiku Voipio    return inotify_init1(0);
4012c05c7a73SRiku Voipio}
4013c05c7a73SRiku VoipioEOF
4014c05c7a73SRiku Voipioif compile_prog "" "" ; then
4015c05c7a73SRiku Voipio  inotify1=yes
4016c05c7a73SRiku Voipiofi
4017c05c7a73SRiku Voipio
4018099d6b0fSRiku Voipio# check if pipe2 is there
4019099d6b0fSRiku Voipiopipe2=no
4020099d6b0fSRiku Voipiocat > $TMPC << EOF
4021099d6b0fSRiku Voipio#include <unistd.h>
4022099d6b0fSRiku Voipio#include <fcntl.h>
4023099d6b0fSRiku Voipio
4024099d6b0fSRiku Voipioint main(void)
4025099d6b0fSRiku Voipio{
4026099d6b0fSRiku Voipio    int pipefd[2];
40279bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4028099d6b0fSRiku Voipio}
4029099d6b0fSRiku VoipioEOF
403052166aa0SJuan Quintelaif compile_prog "" "" ; then
4031099d6b0fSRiku Voipio  pipe2=yes
4032099d6b0fSRiku Voipiofi
4033099d6b0fSRiku Voipio
403440ff6d7eSKevin Wolf# check if accept4 is there
403540ff6d7eSKevin Wolfaccept4=no
403640ff6d7eSKevin Wolfcat > $TMPC << EOF
403740ff6d7eSKevin Wolf#include <sys/socket.h>
403840ff6d7eSKevin Wolf#include <stddef.h>
403940ff6d7eSKevin Wolf
404040ff6d7eSKevin Wolfint main(void)
404140ff6d7eSKevin Wolf{
404240ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
404340ff6d7eSKevin Wolf    return 0;
404440ff6d7eSKevin Wolf}
404540ff6d7eSKevin WolfEOF
404640ff6d7eSKevin Wolfif compile_prog "" "" ; then
404740ff6d7eSKevin Wolf  accept4=yes
404840ff6d7eSKevin Wolffi
404940ff6d7eSKevin Wolf
40503ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
40513ce34dfbSvibisreenivasansplice=no
40523ce34dfbSvibisreenivasancat > $TMPC << EOF
40533ce34dfbSvibisreenivasan#include <unistd.h>
40543ce34dfbSvibisreenivasan#include <fcntl.h>
40553ce34dfbSvibisreenivasan#include <limits.h>
40563ce34dfbSvibisreenivasan
40573ce34dfbSvibisreenivasanint main(void)
40583ce34dfbSvibisreenivasan{
405966ea0f22SStefan Weil    int len, fd = 0;
40603ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
40613ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
40623ce34dfbSvibisreenivasan    return 0;
40633ce34dfbSvibisreenivasan}
40643ce34dfbSvibisreenivasanEOF
406552166aa0SJuan Quintelaif compile_prog "" "" ; then
40663ce34dfbSvibisreenivasan  splice=yes
40673ce34dfbSvibisreenivasanfi
40683ce34dfbSvibisreenivasan
4069dcc38d1cSMarcelo Tosatti##########################################
4070a99d57bbSWanlong Gao# libnuma probe
4071a99d57bbSWanlong Gao
4072a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4073a99d57bbSWanlong Gao  cat > $TMPC << EOF
4074a99d57bbSWanlong Gao#include <numa.h>
4075a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4076a99d57bbSWanlong GaoEOF
4077a99d57bbSWanlong Gao
4078a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4079a99d57bbSWanlong Gao    numa=yes
4080ab318051SMarc-André Lureau    numa_libs="-lnuma"
4081a99d57bbSWanlong Gao  else
4082a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4083a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4084a99d57bbSWanlong Gao    fi
4085a99d57bbSWanlong Gao    numa=no
4086a99d57bbSWanlong Gao  fi
4087a99d57bbSWanlong Gaofi
4088a99d57bbSWanlong Gao
4089aa087962SPaolo Bonzinimalloc=system
40907b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
40917b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
40927b01cb97SAlexandre Derumier    exit 1
4093aa087962SPaolo Bonzinielif test "$tcmalloc" = "yes" ; then
4094aa087962SPaolo Bonzini    malloc=tcmalloc
4095aa087962SPaolo Bonzinielif test "$jemalloc" = "yes" ; then
4096aa087962SPaolo Bonzini    malloc=jemalloc
40977b01cb97SAlexandre Derumierfi
40987b01cb97SAlexandre Derumier
40997b01cb97SAlexandre Derumier##########################################
4100dcc38d1cSMarcelo Tosatti# signalfd probe
4101dcc38d1cSMarcelo Tosattisignalfd="no"
4102dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4103dcc38d1cSMarcelo Tosatti#include <unistd.h>
4104dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4105dcc38d1cSMarcelo Tosatti#include <signal.h>
4106dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4107dcc38d1cSMarcelo TosattiEOF
4108dcc38d1cSMarcelo Tosatti
4109dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4110dcc38d1cSMarcelo Tosatti  signalfd=yes
4111dcc38d1cSMarcelo Tosattifi
4112dcc38d1cSMarcelo Tosatti
4113d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4114d339d766SRichard W.M. Jonesoptreset="no"
4115d339d766SRichard W.M. Jonescat > $TMPC << EOF
4116d339d766SRichard W.M. Jones#include <getopt.h>
4117d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4118d339d766SRichard W.M. JonesEOF
4119d339d766SRichard W.M. Jones
4120d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4121d339d766SRichard W.M. Jones  optreset=yes
4122d339d766SRichard W.M. Jonesfi
4123d339d766SRichard W.M. Jones
4124c2882b96SRiku Voipio# check if eventfd is supported
4125c2882b96SRiku Voipioeventfd=no
4126c2882b96SRiku Voipiocat > $TMPC << EOF
4127c2882b96SRiku Voipio#include <sys/eventfd.h>
4128c2882b96SRiku Voipio
4129c2882b96SRiku Voipioint main(void)
4130c2882b96SRiku Voipio{
413155cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4132c2882b96SRiku Voipio}
4133c2882b96SRiku VoipioEOF
4134c2882b96SRiku Voipioif compile_prog "" "" ; then
4135c2882b96SRiku Voipio  eventfd=yes
4136c2882b96SRiku Voipiofi
4137c2882b96SRiku Voipio
4138751bcc39SMarc-André Lureau# check if memfd is supported
4139751bcc39SMarc-André Lureaumemfd=no
4140751bcc39SMarc-André Lureaucat > $TMPC << EOF
414175e5b70eSPaolo Bonzini#include <sys/mman.h>
4142751bcc39SMarc-André Lureau
4143751bcc39SMarc-André Lureauint main(void)
4144751bcc39SMarc-André Lureau{
4145751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4146751bcc39SMarc-André Lureau}
4147751bcc39SMarc-André LureauEOF
4148751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4149751bcc39SMarc-André Lureau  memfd=yes
4150751bcc39SMarc-André Lureaufi
4151751bcc39SMarc-André Lureau
4152955727d2SCortland Tölva# check for usbfs
4153955727d2SCortland Tölvahave_usbfs=no
4154955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
415596566d09SThomas Petazzoni  cat > $TMPC << EOF
415696566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
415796566d09SThomas Petazzoni
415896566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
415996566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
416096566d09SThomas Petazzoni#endif
416196566d09SThomas Petazzoni
416296566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
416396566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
416496566d09SThomas Petazzoni#endif
416596566d09SThomas Petazzoni
416696566d09SThomas Petazzoniint main(void)
416796566d09SThomas Petazzoni{
416896566d09SThomas Petazzoni    return 0;
416996566d09SThomas Petazzoni}
417096566d09SThomas PetazzoniEOF
417196566d09SThomas Petazzoni  if compile_prog "" ""; then
4172955727d2SCortland Tölva    have_usbfs=yes
4173955727d2SCortland Tölva  fi
4174955727d2SCortland Tölvafi
4175751bcc39SMarc-André Lureau
4176d0927938SUlrich Hecht# check for fallocate
4177d0927938SUlrich Hechtfallocate=no
4178d0927938SUlrich Hechtcat > $TMPC << EOF
4179d0927938SUlrich Hecht#include <fcntl.h>
4180d0927938SUlrich Hecht
4181d0927938SUlrich Hechtint main(void)
4182d0927938SUlrich Hecht{
4183d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4184d0927938SUlrich Hecht    return 0;
4185d0927938SUlrich Hecht}
4186d0927938SUlrich HechtEOF
41878fb03151SPeter Maydellif compile_prog "" "" ; then
4188d0927938SUlrich Hecht  fallocate=yes
4189d0927938SUlrich Hechtfi
4190d0927938SUlrich Hecht
41913d4fa43eSKusanagi Kouichi# check for fallocate hole punching
41923d4fa43eSKusanagi Kouichifallocate_punch_hole=no
41933d4fa43eSKusanagi Kouichicat > $TMPC << EOF
41943d4fa43eSKusanagi Kouichi#include <fcntl.h>
41953d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
41963d4fa43eSKusanagi Kouichi
41973d4fa43eSKusanagi Kouichiint main(void)
41983d4fa43eSKusanagi Kouichi{
41993d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
42003d4fa43eSKusanagi Kouichi    return 0;
42013d4fa43eSKusanagi Kouichi}
42023d4fa43eSKusanagi KouichiEOF
42033d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
42043d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
42053d4fa43eSKusanagi Kouichifi
42063d4fa43eSKusanagi Kouichi
4207b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4208b953f075SDenis V. Lunevfallocate_zero_range=no
4209b953f075SDenis V. Lunevcat > $TMPC << EOF
4210b953f075SDenis V. Lunev#include <fcntl.h>
4211b953f075SDenis V. Lunev#include <linux/falloc.h>
4212b953f075SDenis V. Lunev
4213b953f075SDenis V. Lunevint main(void)
4214b953f075SDenis V. Lunev{
4215b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4216b953f075SDenis V. Lunev    return 0;
4217b953f075SDenis V. Lunev}
4218b953f075SDenis V. LunevEOF
4219b953f075SDenis V. Lunevif compile_prog "" "" ; then
4220b953f075SDenis V. Lunev  fallocate_zero_range=yes
4221b953f075SDenis V. Lunevfi
4222b953f075SDenis V. Lunev
4223ed911435SKevin Wolf# check for posix_fallocate
4224ed911435SKevin Wolfposix_fallocate=no
4225ed911435SKevin Wolfcat > $TMPC << EOF
4226ed911435SKevin Wolf#include <fcntl.h>
4227ed911435SKevin Wolf
4228ed911435SKevin Wolfint main(void)
4229ed911435SKevin Wolf{
4230ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4231ed911435SKevin Wolf    return 0;
4232ed911435SKevin Wolf}
4233ed911435SKevin WolfEOF
4234ed911435SKevin Wolfif compile_prog "" "" ; then
4235ed911435SKevin Wolf    posix_fallocate=yes
4236ed911435SKevin Wolffi
4237ed911435SKevin Wolf
4238c727f47dSPeter Maydell# check for sync_file_range
4239c727f47dSPeter Maydellsync_file_range=no
4240c727f47dSPeter Maydellcat > $TMPC << EOF
4241c727f47dSPeter Maydell#include <fcntl.h>
4242c727f47dSPeter Maydell
4243c727f47dSPeter Maydellint main(void)
4244c727f47dSPeter Maydell{
4245c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4246c727f47dSPeter Maydell    return 0;
4247c727f47dSPeter Maydell}
4248c727f47dSPeter MaydellEOF
42498fb03151SPeter Maydellif compile_prog "" "" ; then
4250c727f47dSPeter Maydell  sync_file_range=yes
4251c727f47dSPeter Maydellfi
4252c727f47dSPeter Maydell
4253dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4254dace20dcSPeter Maydellfiemap=no
4255dace20dcSPeter Maydellcat > $TMPC << EOF
4256dace20dcSPeter Maydell#include <sys/ioctl.h>
4257dace20dcSPeter Maydell#include <linux/fs.h>
4258dace20dcSPeter Maydell#include <linux/fiemap.h>
4259dace20dcSPeter Maydell
4260dace20dcSPeter Maydellint main(void)
4261dace20dcSPeter Maydell{
4262dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4263dace20dcSPeter Maydell    return 0;
4264dace20dcSPeter Maydell}
4265dace20dcSPeter MaydellEOF
42668fb03151SPeter Maydellif compile_prog "" "" ; then
4267dace20dcSPeter Maydell  fiemap=yes
4268dace20dcSPeter Maydellfi
4269dace20dcSPeter Maydell
4270d0927938SUlrich Hecht# check for dup3
4271d0927938SUlrich Hechtdup3=no
4272d0927938SUlrich Hechtcat > $TMPC << EOF
4273d0927938SUlrich Hecht#include <unistd.h>
4274d0927938SUlrich Hecht
4275d0927938SUlrich Hechtint main(void)
4276d0927938SUlrich Hecht{
4277d0927938SUlrich Hecht    dup3(0, 0, 0);
4278d0927938SUlrich Hecht    return 0;
4279d0927938SUlrich Hecht}
4280d0927938SUlrich HechtEOF
428178f5d726SJan Kiszkaif compile_prog "" "" ; then
4282d0927938SUlrich Hecht  dup3=yes
4283d0927938SUlrich Hechtfi
4284d0927938SUlrich Hecht
42854e0c6529SAlex Bligh# check for ppoll support
42864e0c6529SAlex Blighppoll=no
42874e0c6529SAlex Blighcat > $TMPC << EOF
42884e0c6529SAlex Bligh#include <poll.h>
42894e0c6529SAlex Bligh
42904e0c6529SAlex Blighint main(void)
42914e0c6529SAlex Bligh{
42924e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
42934e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
42944e0c6529SAlex Bligh    return 0;
42954e0c6529SAlex Bligh}
42964e0c6529SAlex BlighEOF
42974e0c6529SAlex Blighif compile_prog "" "" ; then
42984e0c6529SAlex Bligh  ppoll=yes
42994e0c6529SAlex Blighfi
43004e0c6529SAlex Bligh
4301cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4302cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4303cd758dd0SAlex Blighcat > $TMPC << EOF
4304cd758dd0SAlex Bligh#include <sys/prctl.h>
4305cd758dd0SAlex Bligh
4306cd758dd0SAlex Blighint main(void)
4307cd758dd0SAlex Bligh{
4308cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4309cd758dd0SAlex Bligh    return 0;
4310cd758dd0SAlex Bligh}
4311cd758dd0SAlex BlighEOF
4312cd758dd0SAlex Blighif compile_prog "" "" ; then
4313cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4314cd758dd0SAlex Blighfi
4315cd758dd0SAlex Bligh
43163b6edd16SPeter Maydell# check for epoll support
43173b6edd16SPeter Maydellepoll=no
43183b6edd16SPeter Maydellcat > $TMPC << EOF
43193b6edd16SPeter Maydell#include <sys/epoll.h>
43203b6edd16SPeter Maydell
43213b6edd16SPeter Maydellint main(void)
43223b6edd16SPeter Maydell{
43233b6edd16SPeter Maydell    epoll_create(0);
43243b6edd16SPeter Maydell    return 0;
43253b6edd16SPeter Maydell}
43263b6edd16SPeter MaydellEOF
43278fb03151SPeter Maydellif compile_prog "" "" ; then
43283b6edd16SPeter Maydell  epoll=yes
43293b6edd16SPeter Maydellfi
43303b6edd16SPeter Maydell
4331227f0214SPeter Maydell# epoll_create1 is a later addition
4332227f0214SPeter Maydell# so we must check separately for its presence
43333b6edd16SPeter Maydellepoll_create1=no
43343b6edd16SPeter Maydellcat > $TMPC << EOF
43353b6edd16SPeter Maydell#include <sys/epoll.h>
43363b6edd16SPeter Maydell
43373b6edd16SPeter Maydellint main(void)
43383b6edd16SPeter Maydell{
433919e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
434019e83f6bSPeter Maydell     * a function being called. This is necessary so that on
434119e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
434219e83f6bSPeter Maydell     * the library but not declared in the header file we will
434319e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
434419e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
434519e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
434619e83f6bSPeter Maydell     */
4347c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
43483b6edd16SPeter Maydell}
43493b6edd16SPeter MaydellEOF
43508fb03151SPeter Maydellif compile_prog "" "" ; then
43513b6edd16SPeter Maydell  epoll_create1=yes
43523b6edd16SPeter Maydellfi
43533b6edd16SPeter Maydell
4354a8fd1abaSPeter Maydell# check for sendfile support
4355a8fd1abaSPeter Maydellsendfile=no
4356a8fd1abaSPeter Maydellcat > $TMPC << EOF
4357a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4358a8fd1abaSPeter Maydell
4359a8fd1abaSPeter Maydellint main(void)
4360a8fd1abaSPeter Maydell{
4361a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4362a8fd1abaSPeter Maydell}
4363a8fd1abaSPeter MaydellEOF
4364a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4365a8fd1abaSPeter Maydell  sendfile=yes
4366a8fd1abaSPeter Maydellfi
4367a8fd1abaSPeter Maydell
436851834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
436951834341SRiku Voipiotimerfd=no
437051834341SRiku Voipiocat > $TMPC << EOF
437151834341SRiku Voipio#include <sys/timerfd.h>
437251834341SRiku Voipio
437351834341SRiku Voipioint main(void)
437451834341SRiku Voipio{
437551834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
437651834341SRiku Voipio}
437751834341SRiku VoipioEOF
437851834341SRiku Voipioif compile_prog "" "" ; then
437951834341SRiku Voipio  timerfd=yes
438051834341SRiku Voipiofi
438151834341SRiku Voipio
43829af5c906SRiku Voipio# check for setns and unshare support
43839af5c906SRiku Voipiosetns=no
43849af5c906SRiku Voipiocat > $TMPC << EOF
43859af5c906SRiku Voipio#include <sched.h>
43869af5c906SRiku Voipio
43879af5c906SRiku Voipioint main(void)
43889af5c906SRiku Voipio{
43899af5c906SRiku Voipio    int ret;
43909af5c906SRiku Voipio    ret = setns(0, 0);
43919af5c906SRiku Voipio    ret = unshare(0);
43929af5c906SRiku Voipio    return ret;
43939af5c906SRiku Voipio}
43949af5c906SRiku VoipioEOF
43959af5c906SRiku Voipioif compile_prog "" "" ; then
43969af5c906SRiku Voipio  setns=yes
43979af5c906SRiku Voipiofi
43989af5c906SRiku Voipio
439938860a03SAleksandar Markovic# clock_adjtime probe
440038860a03SAleksandar Markovicclock_adjtime=no
440138860a03SAleksandar Markoviccat > $TMPC <<EOF
440238860a03SAleksandar Markovic#include <time.h>
440338860a03SAleksandar Markovic
440438860a03SAleksandar Markovicint main(void)
440538860a03SAleksandar Markovic{
440638860a03SAleksandar Markovic    return clock_adjtime(0, 0);
440738860a03SAleksandar Markovic}
440838860a03SAleksandar MarkovicEOF
440938860a03SAleksandar Markovicclock_adjtime=no
441038860a03SAleksandar Markovicif compile_prog "" "" ; then
441138860a03SAleksandar Markovic  clock_adjtime=yes
441238860a03SAleksandar Markovicfi
441338860a03SAleksandar Markovic
44145a03cd00SAleksandar Markovic# syncfs probe
44155a03cd00SAleksandar Markovicsyncfs=no
44165a03cd00SAleksandar Markoviccat > $TMPC <<EOF
44175a03cd00SAleksandar Markovic#include <unistd.h>
44185a03cd00SAleksandar Markovic
44195a03cd00SAleksandar Markovicint main(void)
44205a03cd00SAleksandar Markovic{
44215a03cd00SAleksandar Markovic    return syncfs(0);
44225a03cd00SAleksandar Markovic}
44235a03cd00SAleksandar MarkovicEOF
44245a03cd00SAleksandar Markovicsyncfs=no
44255a03cd00SAleksandar Markovicif compile_prog "" "" ; then
44265a03cd00SAleksandar Markovic  syncfs=yes
44275a03cd00SAleksandar Markovicfi
44285a03cd00SAleksandar Markovic
4429db37dd89SAleksandar Markovic# check for kcov support (kernel must be 4.4+, compiled with certain options)
4430db37dd89SAleksandar Markovickcov=no
4431db37dd89SAleksandar Markovicif check_include sys/kcov.h ; then
4432db37dd89SAleksandar Markovic    kcov=yes
4433db37dd89SAleksandar Markovicfi
4434db37dd89SAleksandar Markovic
4435d6092e08SFilip Bozuta# check for btrfs filesystem support (kernel must be 3.9+)
4436d6092e08SFilip Bozutabtrfs=no
4437d6092e08SFilip Bozutaif check_include linux/btrfs.h ; then
4438d6092e08SFilip Bozuta    btrfs=yes
4439d6092e08SFilip Bozutafi
4440d6092e08SFilip Bozuta
4441f514f41cSStefan Weil# Search for bswap_32 function
44426ae9a1f4SJuan Quintelabyteswap_h=no
44436ae9a1f4SJuan Quintelacat > $TMPC << EOF
44446ae9a1f4SJuan Quintela#include <byteswap.h>
44456ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
44466ae9a1f4SJuan QuintelaEOF
444752166aa0SJuan Quintelaif compile_prog "" "" ; then
44486ae9a1f4SJuan Quintela  byteswap_h=yes
44496ae9a1f4SJuan Quintelafi
44506ae9a1f4SJuan Quintela
445175f13596SStefan Weil# Search for bswap32 function
44526ae9a1f4SJuan Quintelabswap_h=no
44536ae9a1f4SJuan Quintelacat > $TMPC << EOF
44546ae9a1f4SJuan Quintela#include <sys/endian.h>
44556ae9a1f4SJuan Quintela#include <sys/types.h>
44566ae9a1f4SJuan Quintela#include <machine/bswap.h>
44576ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
44586ae9a1f4SJuan QuintelaEOF
445952166aa0SJuan Quintelaif compile_prog "" "" ; then
44606ae9a1f4SJuan Quintela  bswap_h=yes
44616ae9a1f4SJuan Quintelafi
44626ae9a1f4SJuan Quintela
4463da93a1fdSaliguori##########################################
4464e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4465c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4466e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
44673c33ea96SPaolo Bonzini    libiscsi="yes"
4468ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4469ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4470c589b249SRonnie Sahlberg  else
4471c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4472e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4473c589b249SRonnie Sahlberg    fi
4474c589b249SRonnie Sahlberg    libiscsi="no"
4475c589b249SRonnie Sahlberg  fi
4476c589b249SRonnie Sahlbergfi
4477c589b249SRonnie Sahlberg
4478c589b249SRonnie Sahlberg##########################################
4479da93a1fdSaliguori# Do we need librt
44808bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
44818bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
44828bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
44838bacde8dSNatanael Copa# function in addition.
4484da93a1fdSaliguoricat > $TMPC <<EOF
4485da93a1fdSaliguori#include <signal.h>
4486da93a1fdSaliguori#include <time.h>
44878bacde8dSNatanael Copaint main(void) {
44888bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
44898bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
44908bacde8dSNatanael Copa}
4491da93a1fdSaliguoriEOF
4492da93a1fdSaliguori
449352166aa0SJuan Quintelaif compile_prog "" "" ; then
449407ffa4bdSJuan Quintela  :
44958bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
449618e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
449718e588b1SRick Liu  LIBS="$LIBS -lrt"
4498da93a1fdSaliguorifi
4499da93a1fdSaliguori
4500f2995ee4SPaolo Bonzini# Check whether we have openpty() in either libc or libutil
4501d99e97e6SThomas Huthcat > $TMPC << EOF
4502d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4503d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
4504d99e97e6SThomas HuthEOF
4505d99e97e6SThomas Huth
45069df8b20dSThomas Huthhave_openpty="no"
45079df8b20dSThomas Huthif compile_prog "" "" ; then
45089df8b20dSThomas Huth  have_openpty="yes"
45099df8b20dSThomas Huthelse
4510d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
45119df8b20dSThomas Huth    have_openpty="yes"
4512d99e97e6SThomas Huth  fi
45136362a53fSJuan Quintelafi
45146362a53fSJuan Quintela
4515de5071c5SBlue Swirl##########################################
4516cd4ec0b4SGerd Hoffmann# spice probe
4517cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4518cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4519cd4ec0b4SGerd Hoffmann#include <spice.h>
4520cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4521cd4ec0b4SGerd HoffmannEOF
4522710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4523710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
45241b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
452565d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
4526cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
4527cd4ec0b4SGerd Hoffmann    spice="yes"
4528cd4ec0b4SGerd Hoffmann  else
4529cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
45308efc9363SHu Tao      feature_not_found "spice" \
45311b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
4532cd4ec0b4SGerd Hoffmann    fi
4533cd4ec0b4SGerd Hoffmann    spice="no"
4534cd4ec0b4SGerd Hoffmann  fi
4535cd4ec0b4SGerd Hoffmannfi
4536cd4ec0b4SGerd Hoffmann
45377b02f544SMarc-André Lureau# check for smartcard support
45387b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
45390f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
45407b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
45417b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
45427b02f544SMarc-André Lureau        smartcard="yes"
4543111a38b0SRobert Relyea    else
45447b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
45457b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
4546111a38b0SRobert Relyea        fi
45477b02f544SMarc-André Lureau        smartcard="no"
4548111a38b0SRobert Relyea    fi
4549111a38b0SRobert Relyeafi
4550111a38b0SRobert Relyea
45512b2325ffSGerd Hoffmann# check for libusb
45522b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
455365d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
45542b2325ffSGerd Hoffmann        libusb="yes"
4555ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
4556ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
45572b2325ffSGerd Hoffmann    else
45582b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
45598efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
45602b2325ffSGerd Hoffmann        fi
45612b2325ffSGerd Hoffmann        libusb="no"
45622b2325ffSGerd Hoffmann    fi
45632b2325ffSGerd Hoffmannfi
45642b2325ffSGerd Hoffmann
456569354a83SHans de Goede# check for usbredirparser for usb network redirection support
456669354a83SHans de Goedeif test "$usb_redir" != "no" ; then
456765d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
456869354a83SHans de Goede        usb_redir="yes"
4569ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
4570ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
457169354a83SHans de Goede    else
457269354a83SHans de Goede        if test "$usb_redir" = "yes"; then
457321684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
457469354a83SHans de Goede        fi
457569354a83SHans de Goede        usb_redir="no"
457669354a83SHans de Goede    fi
457769354a83SHans de Goedefi
457869354a83SHans de Goede
4579cd4ec0b4SGerd Hoffmann##########################################
4580d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
4581d9840e25STomoki Sekiyama
4582e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4583e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
4584d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
4585690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
4586d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
4587d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
4588690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
4589d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
4590d9840e25STomoki Sekiyama	  ;;
4591690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
4592d9840e25STomoki Sekiyama  esac
4593d9840e25STomoki Sekiyama  cat > $TMPC << EOF
4594d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
4595d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
4596d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
4597d9840e25STomoki SekiyamaEOF
4598d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
4599d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
4600d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
4601315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
4602f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
4603d9840e25STomoki Sekiyama  else
4604d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
4605d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
4606d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
4607d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
4608d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
4609d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
4610d9840e25STomoki Sekiyama      feature_not_found "VSS support"
4611d9840e25STomoki Sekiyama    fi
4612d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
4613d9840e25STomoki Sekiyama  fi
4614d9840e25STomoki Sekiyamafi
4615d9840e25STomoki Sekiyama
4616d9840e25STomoki Sekiyama##########################################
4617d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
4618d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
4619d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
4620d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
4621d9840e25STomoki Sekiyama
4622e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
4623e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
4624d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
4625d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
4626d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
4627d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
4628d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
4629d9840e25STomoki Sekiyama    else
4630d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
4631d9840e25STomoki Sekiyama    fi
4632d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
4633d9840e25STomoki Sekiyama    win_sdk=""
4634d9840e25STomoki Sekiyama  fi
4635d9840e25STomoki Sekiyamafi
4636d9840e25STomoki Sekiyama
4637d9840e25STomoki Sekiyama##########################################
463850cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
4639e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
464050cbebb9SMichael Roth  cat > $TMPC << EOF
464150cbebb9SMichael Roth#include <windows.h>
464250cbebb9SMichael Roth#include <ntddscsi.h>
464350cbebb9SMichael Rothint main(void) {
464450cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
464550cbebb9SMichael Roth#error Missing required ioctl definitions
464650cbebb9SMichael Roth#endif
464750cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
464850cbebb9SMichael Roth  return addr.Lun;
464950cbebb9SMichael Roth}
465050cbebb9SMichael RothEOF
465150cbebb9SMichael Roth  if compile_prog "" "" ; then
465250cbebb9SMichael Roth    guest_agent_ntddscsi=yes
4653996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
465450cbebb9SMichael Roth  fi
465550cbebb9SMichael Rothfi
465650cbebb9SMichael Roth
465750cbebb9SMichael Roth##########################################
46589d9e1521SGerd Hoffmann# virgl renderer probe
46599d9e1521SGerd Hoffmann
46609d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
46619d9e1521SGerd Hoffmann  cat > $TMPC << EOF
46629d9e1521SGerd Hoffmann#include <virglrenderer.h>
46639d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
46649d9e1521SGerd HoffmannEOF
46659d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
46669d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
466747479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
46689d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
46699d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
46709d9e1521SGerd Hoffmann    virglrenderer="yes"
46719d9e1521SGerd Hoffmann  else
46729d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
46739d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
46749d9e1521SGerd Hoffmann    fi
46759d9e1521SGerd Hoffmann    virglrenderer="no"
46769d9e1521SGerd Hoffmann  fi
46779d9e1521SGerd Hoffmannfi
46789d9e1521SGerd Hoffmann
46799d9e1521SGerd Hoffmann##########################################
46808ca80760SRichard Henderson# capstone
46818ca80760SRichard Henderson
4682e219c499SRichard Hendersoncase "$capstone" in
46838b18cdbfSRichard Henderson  auto | enabled | internal)
46848b18cdbfSRichard Henderson    # Simpler to always update submodule, even if not needed.
46858b18cdbfSRichard Henderson    if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
4686e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
4687e219c499SRichard Henderson    fi
4688e219c499SRichard Henderson    ;;
4689e219c499SRichard Hendersonesac
46908ca80760SRichard Henderson
46918ca80760SRichard Henderson##########################################
46925f6b9e8fSBlue Swirl# check if we have fdatasync
46935f6b9e8fSBlue Swirl
46945f6b9e8fSBlue Swirlfdatasync=no
46955f6b9e8fSBlue Swirlcat > $TMPC << EOF
46965f6b9e8fSBlue Swirl#include <unistd.h>
4697d1722a27SAlexandre Raymondint main(void) {
4698d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
4699d1722a27SAlexandre Raymondreturn fdatasync(0);
4700d1722a27SAlexandre Raymond#else
4701e172fe11SStefan Weil#error Not supported
4702d1722a27SAlexandre Raymond#endif
4703d1722a27SAlexandre Raymond}
47045f6b9e8fSBlue SwirlEOF
47055f6b9e8fSBlue Swirlif compile_prog "" "" ; then
47065f6b9e8fSBlue Swirl    fdatasync=yes
47075f6b9e8fSBlue Swirlfi
47085f6b9e8fSBlue Swirl
470994a420b1SStefan Hajnoczi##########################################
4710e78815a5SAndreas Färber# check if we have madvise
4711e78815a5SAndreas Färber
4712e78815a5SAndreas Färbermadvise=no
4713e78815a5SAndreas Färbercat > $TMPC << EOF
4714e78815a5SAndreas Färber#include <sys/types.h>
4715e78815a5SAndreas Färber#include <sys/mman.h>
4716832ce9c2SScott Wood#include <stddef.h>
4717e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
4718e78815a5SAndreas FärberEOF
4719e78815a5SAndreas Färberif compile_prog "" "" ; then
4720e78815a5SAndreas Färber    madvise=yes
4721e78815a5SAndreas Färberfi
4722e78815a5SAndreas Färber
4723e78815a5SAndreas Färber##########################################
4724e78815a5SAndreas Färber# check if we have posix_madvise
4725e78815a5SAndreas Färber
4726e78815a5SAndreas Färberposix_madvise=no
4727e78815a5SAndreas Färbercat > $TMPC << EOF
4728e78815a5SAndreas Färber#include <sys/mman.h>
4729832ce9c2SScott Wood#include <stddef.h>
4730e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
4731e78815a5SAndreas FärberEOF
4732e78815a5SAndreas Färberif compile_prog "" "" ; then
4733e78815a5SAndreas Färber    posix_madvise=yes
4734e78815a5SAndreas Färberfi
4735e78815a5SAndreas Färber
4736e78815a5SAndreas Färber##########################################
47379bc5a719SAndreas Gustafsson# check if we have posix_memalign()
47389bc5a719SAndreas Gustafsson
47399bc5a719SAndreas Gustafssonposix_memalign=no
47409bc5a719SAndreas Gustafssoncat > $TMPC << EOF
47419bc5a719SAndreas Gustafsson#include <stdlib.h>
47429bc5a719SAndreas Gustafssonint main(void) {
47439bc5a719SAndreas Gustafsson    void *p;
47449bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
47459bc5a719SAndreas Gustafsson}
47469bc5a719SAndreas GustafssonEOF
47479bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
47489bc5a719SAndreas Gustafsson    posix_memalign=yes
47499bc5a719SAndreas Gustafssonfi
47509bc5a719SAndreas Gustafsson
47519bc5a719SAndreas Gustafsson##########################################
47520a852417SPaul Durrant# check if we have posix_syslog
47530a852417SPaul Durrant
47540a852417SPaul Durrantposix_syslog=no
47550a852417SPaul Durrantcat > $TMPC << EOF
47560a852417SPaul Durrant#include <syslog.h>
47570a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
47580a852417SPaul DurrantEOF
47590a852417SPaul Durrantif compile_prog "" "" ; then
47600a852417SPaul Durrant    posix_syslog=yes
47610a852417SPaul Durrantfi
47620a852417SPaul Durrant
47630a852417SPaul Durrant##########################################
4764401bc051SPeter Maydell# check if we have sem_timedwait
4765401bc051SPeter Maydell
4766401bc051SPeter Maydellsem_timedwait=no
4767401bc051SPeter Maydellcat > $TMPC << EOF
4768401bc051SPeter Maydell#include <semaphore.h>
4769811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
4770401bc051SPeter MaydellEOF
4771401bc051SPeter Maydellif compile_prog "" "" ; then
4772401bc051SPeter Maydell    sem_timedwait=yes
4773401bc051SPeter Maydellfi
4774401bc051SPeter Maydell
4775401bc051SPeter Maydell##########################################
47765c99fa37SKeno Fischer# check if we have strchrnul
47775c99fa37SKeno Fischer
47785c99fa37SKeno Fischerstrchrnul=no
47795c99fa37SKeno Fischercat > $TMPC << EOF
47805c99fa37SKeno Fischer#include <string.h>
47815c99fa37SKeno Fischerint main(void);
47825c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
47835c99fa37SKeno Fischerchar *haystack = (char*)&main;
47845c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
47855c99fa37SKeno FischerEOF
47865c99fa37SKeno Fischerif compile_prog "" "" ; then
47875c99fa37SKeno Fischer    strchrnul=yes
47885c99fa37SKeno Fischerfi
47895c99fa37SKeno Fischer
47908a792b03SJiufei Xue#########################################
47918a792b03SJiufei Xue# check if we have st_atim
47928a792b03SJiufei Xue
47938a792b03SJiufei Xuest_atim=no
47948a792b03SJiufei Xuecat > $TMPC << EOF
47958a792b03SJiufei Xue#include <sys/stat.h>
47968a792b03SJiufei Xue#include <stddef.h>
47978a792b03SJiufei Xueint main(void) { return offsetof(struct stat, st_atim); }
47988a792b03SJiufei XueEOF
47998a792b03SJiufei Xueif compile_prog "" "" ; then
48008a792b03SJiufei Xue    st_atim=yes
48018a792b03SJiufei Xuefi
48028a792b03SJiufei Xue
48035c99fa37SKeno Fischer##########################################
480494a420b1SStefan Hajnoczi# check if trace backend exists
480594a420b1SStefan Hajnoczi
48065b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
480794a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
48085b808275SLluís Vilanova  error_exit "invalid trace backends" \
48095b808275SLluís Vilanova      "Please choose supported trace backends."
481094a420b1SStefan Hajnoczifi
481194a420b1SStefan Hajnoczi
48127e24e92aSStefan Hajnoczi##########################################
48137e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
48145b808275SLluís Vilanovaif have_backend "ust"; then
48157e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
4816bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
48177e24e92aSStefan Hajnocziint main(void) { return 0; }
48187e24e92aSStefan HajnocziEOF
4819c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
4820bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
482189138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
48227e24e92aSStefan Hajnoczi    else
4823c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
4824bf15f63cSMohamad Gebai    fi
4825bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
482689138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
4827bf15f63cSMohamad Gebai    else
4828bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
4829bf15f63cSMohamad Gebai    fi
4830bf15f63cSMohamad Gebai  else
4831bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
48327e24e92aSStefan Hajnoczi  fi
48337e24e92aSStefan Hajnoczifi
4834b3d08c02SDaniel P. Berrange
4835b3d08c02SDaniel P. Berrange##########################################
4836b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
48375b808275SLluís Vilanovaif have_backend "dtrace"; then
4838b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
483976ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
4840b3d08c02SDaniel P. Berrange  fi
4841c276b17dSDaniel P. Berrange  trace_backend_stap="no"
4842c276b17dSDaniel P. Berrange  if has 'stap' ; then
4843c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
48444b265c79SStefan Hajnoczi
48454b265c79SStefan Hajnoczi    # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
48464b265c79SStefan Hajnoczi    # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
48474b265c79SStefan Hajnoczi    # instead. QEMU --enable-modules depends on this because the SystemTap
48484b265c79SStefan Hajnoczi    # semaphores are linked into the main binary and not the module's shared
48494b265c79SStefan Hajnoczi    # object.
48504b265c79SStefan Hajnoczi    QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
4851c276b17dSDaniel P. Berrange  fi
4852b3d08c02SDaniel P. Berrangefi
4853b3d08c02SDaniel P. Berrange
48547e24e92aSStefan Hajnoczi##########################################
4855519175a2SAlex Barcelo# check and set a backend for coroutine
4856d0e2fce5SAneesh Kumar K.V
48577c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
485833c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
485933c53c54SDaniel P. Berrange# specific one.
48607c2acc70SPeter Maydell
48617c2acc70SPeter Maydellucontext_works=no
4862d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
4863d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
4864d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
4865cdf84806SPeter Maydell#ifdef __stub_makecontext
4866cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
4867cdf84806SPeter Maydell#endif
486875cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
4869d0e2fce5SAneesh Kumar K.VEOF
4870d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
48717c2acc70SPeter Maydell    ucontext_works=yes
4872d0e2fce5SAneesh Kumar K.V  fi
4873519175a2SAlex Barcelofi
48747c2acc70SPeter Maydell
48757c2acc70SPeter Maydellif test "$coroutine" = ""; then
48767c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
48777c2acc70SPeter Maydell    coroutine=win32
48787c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
48797c2acc70SPeter Maydell    coroutine=ucontext
4880519175a2SAlex Barcelo  else
48817c2acc70SPeter Maydell    coroutine=sigaltstack
48827c2acc70SPeter Maydell  fi
48837c2acc70SPeter Maydellelse
48847c2acc70SPeter Maydell  case $coroutine in
48857c2acc70SPeter Maydell  windows)
48867c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
48877c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
48887c2acc70SPeter Maydell    fi
48897c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
48907c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
48917c2acc70SPeter Maydell    coroutine=win32
48927c2acc70SPeter Maydell    ;;
48937c2acc70SPeter Maydell  ucontext)
48947c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
48957c2acc70SPeter Maydell      feature_not_found "ucontext"
48967c2acc70SPeter Maydell    fi
48977c2acc70SPeter Maydell    ;;
489833c53c54SDaniel P. Berrange  sigaltstack)
48997c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
49007c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
49017c2acc70SPeter Maydell    fi
49027c2acc70SPeter Maydell    ;;
49037c2acc70SPeter Maydell  *)
490476ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
49057c2acc70SPeter Maydell    ;;
49067c2acc70SPeter Maydell  esac
4907d0e2fce5SAneesh Kumar K.Vfi
4908d0e2fce5SAneesh Kumar K.V
490970c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
491070c60c08SStefan Hajnoczi  coroutine_pool=yes
491170c60c08SStefan Hajnoczifi
491270c60c08SStefan Hajnoczi
49137d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
49147d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
49157d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
49167d992e4dSPeter Lieven    coroutine_pool=no
49177d992e4dSPeter Lieven  fi
49187d992e4dSPeter Lievenfi
49197d992e4dSPeter Lieven
49201e4f6065SDaniele Buono##################################################
49211e4f6065SDaniele Buono# SafeStack
49221e4f6065SDaniele Buono
49231e4f6065SDaniele Buono
49241e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
49251e4f6065SDaniele Buonocat > $TMPC << EOF
49261e4f6065SDaniele Buonoint main(int argc, char *argv[])
49271e4f6065SDaniele Buono{
49281e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
49291e4f6065SDaniele Buono#error SafeStack Disabled
49301e4f6065SDaniele Buono#endif
49311e4f6065SDaniele Buono    return 0;
49321e4f6065SDaniele Buono}
49331e4f6065SDaniele BuonoEOF
49341e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
49351e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
49361e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
49371e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
49381e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
49391e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
49401e4f6065SDaniele Buono  else
49411e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
49421e4f6065SDaniele Buono  fi
49431e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
49441e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
49451e4f6065SDaniele Buono  fi
49461e4f6065SDaniele Buonoelse
49471e4f6065SDaniele Buonocat > $TMPC << EOF
49481e4f6065SDaniele Buonoint main(int argc, char *argv[])
49491e4f6065SDaniele Buono{
49501e4f6065SDaniele Buono#if defined(__has_feature)
49511e4f6065SDaniele Buono#if __has_feature(safe_stack)
49521e4f6065SDaniele Buono#error SafeStack Enabled
49531e4f6065SDaniele Buono#endif
49541e4f6065SDaniele Buono#endif
49551e4f6065SDaniele Buono    return 0;
49561e4f6065SDaniele Buono}
49571e4f6065SDaniele BuonoEOF
49581e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
49591e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
49601e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
49611e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
49621e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
49631e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
49641e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
49651e4f6065SDaniele Buono    fi
49661e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
49671e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
49681e4f6065SDaniele Buono  fi
49691e4f6065SDaniele Buonoelse # "$safe_stack" = ""
49701e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
49711e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
49721e4f6065SDaniele Buono    safe_stack="no"
49731e4f6065SDaniele Buono  else
49741e4f6065SDaniele Buono    safe_stack="yes"
49751e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
49761e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
49771e4f6065SDaniele Buono    fi
49781e4f6065SDaniele Buono  fi
49791e4f6065SDaniele Buonofi
49801e4f6065SDaniele Buonofi
49817d992e4dSPeter Lieven
4982d0e2fce5SAneesh Kumar K.V##########################################
4983d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
4984d2042378SAneesh Kumar K.V
49854e1797f9SStefan Weilopen_by_handle_at=no
4986d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
4987d2042378SAneesh Kumar K.V#include <fcntl.h>
4988acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
4989acc55ba8SStefan Weil# error missing definition
4990acc55ba8SStefan Weil#else
499175cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
4992acc55ba8SStefan Weil#endif
4993d2042378SAneesh Kumar K.VEOF
4994d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
4995d2042378SAneesh Kumar K.V    open_by_handle_at=yes
4996d2042378SAneesh Kumar K.Vfi
4997d2042378SAneesh Kumar K.V
4998e06a765eSHarsh Prateek Bora########################################
4999e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5000e06a765eSHarsh Prateek Bora
5001e06a765eSHarsh Prateek Boralinux_magic_h=no
5002e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5003e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5004e06a765eSHarsh Prateek Boraint main(void) {
500575cafad7SStefan Weil  return 0;
5006e06a765eSHarsh Prateek Bora}
5007e06a765eSHarsh Prateek BoraEOF
5008e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5009e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5010e06a765eSHarsh Prateek Borafi
5011e06a765eSHarsh Prateek Bora
50128ab1bf12SLuiz Capitulino########################################
5013541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
50143f4349dcSKevin Wolf
50153f4349dcSKevin Wolfvalgrind_h=no
50163f4349dcSKevin Wolfcat > $TMPC << EOF
50173f4349dcSKevin Wolf#include <valgrind/valgrind.h>
50183f4349dcSKevin Wolfint main(void) {
50193f4349dcSKevin Wolf  return 0;
50203f4349dcSKevin Wolf}
50213f4349dcSKevin WolfEOF
50223f4349dcSKevin Wolfif compile_prog "" "" ; then
50233f4349dcSKevin Wolf    valgrind_h=yes
50243f4349dcSKevin Wolffi
50253f4349dcSKevin Wolf
50263f4349dcSKevin Wolf########################################
50278ab1bf12SLuiz Capitulino# check if environ is declared
50288ab1bf12SLuiz Capitulino
50298ab1bf12SLuiz Capitulinohas_environ=no
50308ab1bf12SLuiz Capitulinocat > $TMPC << EOF
50318ab1bf12SLuiz Capitulino#include <unistd.h>
50328ab1bf12SLuiz Capitulinoint main(void) {
5033c075a723SBlue Swirl    environ = 0;
50348ab1bf12SLuiz Capitulino    return 0;
50358ab1bf12SLuiz Capitulino}
50368ab1bf12SLuiz CapitulinoEOF
50378ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
50388ab1bf12SLuiz Capitulino    has_environ=yes
50398ab1bf12SLuiz Capitulinofi
50408ab1bf12SLuiz Capitulino
504176a347e1SRichard Henderson########################################
504276a347e1SRichard Henderson# check if cpuid.h is usable.
504376a347e1SRichard Henderson
504476a347e1SRichard Hendersoncat > $TMPC << EOF
504576a347e1SRichard Henderson#include <cpuid.h>
504676a347e1SRichard Hendersonint main(void) {
5047774d566cSPeter Maydell    unsigned a, b, c, d;
5048774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5049774d566cSPeter Maydell
5050774d566cSPeter Maydell    if (max >= 1) {
5051774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5052774d566cSPeter Maydell    }
5053774d566cSPeter Maydell
5054774d566cSPeter Maydell    if (max >= 7) {
5055774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5056774d566cSPeter Maydell    }
5057774d566cSPeter Maydell
505876a347e1SRichard Henderson    return 0;
505976a347e1SRichard Henderson}
506076a347e1SRichard HendersonEOF
506176a347e1SRichard Hendersonif compile_prog "" "" ; then
506276a347e1SRichard Henderson    cpuid_h=yes
506376a347e1SRichard Hendersonfi
506476a347e1SRichard Henderson
50655dd89908SRichard Henderson##########################################
50665dd89908SRichard Henderson# avx2 optimization requirement check
50675dd89908SRichard Henderson#
50685dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
50695dd89908SRichard Henderson# since we won't be able to select the new routines.
50705dd89908SRichard Henderson
5071e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
50725dd89908SRichard Henderson  cat > $TMPC << EOF
50735dd89908SRichard Henderson#pragma GCC push_options
50745dd89908SRichard Henderson#pragma GCC target("avx2")
50755dd89908SRichard Henderson#include <cpuid.h>
50765dd89908SRichard Henderson#include <immintrin.h>
50775dd89908SRichard Hendersonstatic int bar(void *a) {
50785dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
50795dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
50805dd89908SRichard Henderson}
50815dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
50825dd89908SRichard HendersonEOF
50835dd89908SRichard Henderson  if compile_object "" ; then
50845dd89908SRichard Henderson    avx2_opt="yes"
508586583a07SLiam Merwick  else
508686583a07SLiam Merwick    avx2_opt="no"
50875dd89908SRichard Henderson  fi
50885dd89908SRichard Hendersonfi
50895dd89908SRichard Henderson
50906b8cd447SRobert Hoo##########################################
50916b8cd447SRobert Hoo# avx512f optimization requirement check
50926b8cd447SRobert Hoo#
50936b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
50946b8cd447SRobert Hoo# since we won't be able to select the new routines.
50956b8cd447SRobert Hoo# by default, it is turned off.
50966b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
50976b8cd447SRobert Hoo
50986b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
50996b8cd447SRobert Hoo  cat > $TMPC << EOF
51006b8cd447SRobert Hoo#pragma GCC push_options
51016b8cd447SRobert Hoo#pragma GCC target("avx512f")
51026b8cd447SRobert Hoo#include <cpuid.h>
51036b8cd447SRobert Hoo#include <immintrin.h>
51046b8cd447SRobert Hoostatic int bar(void *a) {
51056b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
51066b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
51076b8cd447SRobert Hoo}
51086b8cd447SRobert Hooint main(int argc, char *argv[])
51096b8cd447SRobert Hoo{
51106b8cd447SRobert Hoo	return bar(argv[0]);
51116b8cd447SRobert Hoo}
51126b8cd447SRobert HooEOF
51136b8cd447SRobert Hoo  if ! compile_object "" ; then
51146b8cd447SRobert Hoo    avx512f_opt="no"
51156b8cd447SRobert Hoo  fi
51166b8cd447SRobert Hooelse
51176b8cd447SRobert Hoo  avx512f_opt="no"
51186b8cd447SRobert Hoofi
51196b8cd447SRobert Hoo
5120f540166bSRichard Henderson########################################
5121f540166bSRichard Henderson# check if __[u]int128_t is usable.
5122f540166bSRichard Henderson
5123f540166bSRichard Hendersonint128=no
5124f540166bSRichard Hendersoncat > $TMPC << EOF
5125f540166bSRichard Henderson__int128_t a;
5126f540166bSRichard Henderson__uint128_t b;
5127f540166bSRichard Hendersonint main (void) {
5128f540166bSRichard Henderson  a = a + b;
5129f540166bSRichard Henderson  b = a * b;
5130464e3671SPeter Maydell  a = a * a;
5131f540166bSRichard Henderson  return 0;
5132f540166bSRichard Henderson}
5133f540166bSRichard HendersonEOF
5134f540166bSRichard Hendersonif compile_prog "" "" ; then
5135f540166bSRichard Henderson    int128=yes
5136f540166bSRichard Hendersonfi
513776a347e1SRichard Henderson
51387ebee43eSRichard Henderson#########################################
51397ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
51407ebee43eSRichard Henderson
51417ebee43eSRichard Hendersonatomic128=no
51427ebee43eSRichard Hendersonif test "$int128" = "yes"; then
51437ebee43eSRichard Henderson  cat > $TMPC << EOF
51447ebee43eSRichard Hendersonint main(void)
51457ebee43eSRichard Henderson{
51467ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
51477ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
51487ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
51497ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
51507ebee43eSRichard Henderson  return 0;
51517ebee43eSRichard Henderson}
51527ebee43eSRichard HendersonEOF
51537ebee43eSRichard Henderson  if compile_prog "" "" ; then
51547ebee43eSRichard Henderson    atomic128=yes
51557ebee43eSRichard Henderson  fi
51567ebee43eSRichard Hendersonfi
51577ebee43eSRichard Henderson
5158e6cd4bb5SRichard Hendersoncmpxchg128=no
5159e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
5160e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5161e6cd4bb5SRichard Hendersonint main(void)
5162e6cd4bb5SRichard Henderson{
5163e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5164e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5165e6cd4bb5SRichard Henderson  return 0;
5166e6cd4bb5SRichard Henderson}
5167e6cd4bb5SRichard HendersonEOF
5168e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5169e6cd4bb5SRichard Henderson    cmpxchg128=yes
5170e6cd4bb5SRichard Henderson  fi
5171e6cd4bb5SRichard Hendersonfi
5172e6cd4bb5SRichard Henderson
5173df79b996SRichard Henderson#########################################
5174df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5175df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5176df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5177df79b996SRichard Henderson
5178df79b996SRichard Hendersoncat > $TMPC << EOF
5179df79b996SRichard Henderson#include <stdint.h>
5180df79b996SRichard Hendersonint main(void)
5181df79b996SRichard Henderson{
5182df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5183df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
51845fe40765SThomas Huth  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
51855fe40765SThomas Huth  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
51865fe40765SThomas Huth  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
51875fe40765SThomas Huth  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
51885fe40765SThomas Huth  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
5189df79b996SRichard Henderson#else
5190df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5191df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5192df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5193df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5194df79b996SRichard Henderson#endif
5195df79b996SRichard Henderson  return 0;
5196df79b996SRichard Henderson}
5197df79b996SRichard HendersonEOF
5198df79b996SRichard Hendersonif compile_prog "" "" ; then
5199df79b996SRichard Henderson  atomic64=yes
5200df79b996SRichard Hendersonfi
5201df79b996SRichard Henderson
520226fffe29SEmilio G. Cota#########################################
520326fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
520426fffe29SEmilio G. Cotald_dynamic_list="no"
520526fffe29SEmilio G. Cotaif test "$static" = "no" ; then
520626fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
520726fffe29SEmilio G. Cota{
520826fffe29SEmilio G. Cota  foo;
520926fffe29SEmilio G. Cota};
521026fffe29SEmilio G. CotaEOF
521126fffe29SEmilio G. Cota
521226fffe29SEmilio G. Cota    cat > $TMPC <<EOF
521326fffe29SEmilio G. Cota#include <stdio.h>
521426fffe29SEmilio G. Cotavoid foo(void);
521526fffe29SEmilio G. Cota
521626fffe29SEmilio G. Cotavoid foo(void)
521726fffe29SEmilio G. Cota{
521826fffe29SEmilio G. Cota  printf("foo\n");
521926fffe29SEmilio G. Cota}
522026fffe29SEmilio G. Cota
522126fffe29SEmilio G. Cotaint main(void)
522226fffe29SEmilio G. Cota{
522326fffe29SEmilio G. Cota  foo();
522426fffe29SEmilio G. Cota  return 0;
522526fffe29SEmilio G. Cota}
522626fffe29SEmilio G. CotaEOF
522726fffe29SEmilio G. Cota
522826fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
522926fffe29SEmilio G. Cota        ld_dynamic_list="yes"
523026fffe29SEmilio G. Cota    fi
523126fffe29SEmilio G. Cotafi
523226fffe29SEmilio G. Cota
523326fffe29SEmilio G. Cota#########################################
523426fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
523526fffe29SEmilio G. Cota
523626fffe29SEmilio G. Cotald_exported_symbols_list="no"
523726fffe29SEmilio G. Cotaif test "$static" = "no" ; then
523826fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
523926fffe29SEmilio G. Cota  _foo
524026fffe29SEmilio G. CotaEOF
524126fffe29SEmilio G. Cota
524226fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
524326fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
524426fffe29SEmilio G. Cota    fi
524526fffe29SEmilio G. Cotafi
524626fffe29SEmilio G. Cota
524726fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
524826fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
524926fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
525026fffe29SEmilio G. Cota  error_exit \
525126fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
525226fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
525326fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
525426fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
525526fffe29SEmilio G. Cotafi
525626fffe29SEmilio G. Cota
52571e6e9acaSRichard Henderson########################################
5258db8aaae8SRichard Henderson# See if __attribute__((alias)) is supported.
5259db8aaae8SRichard Henderson# This false for Xcode 9, but has been remedied for Xcode 10.
5260db8aaae8SRichard Henderson# Unfortunately, travis uses Xcode 9 by default.
5261db8aaae8SRichard Henderson
5262db8aaae8SRichard Hendersonattralias=no
5263db8aaae8SRichard Hendersoncat > $TMPC << EOF
5264db8aaae8SRichard Hendersonint x = 1;
5265db8aaae8SRichard Hendersonextern const int y __attribute__((alias("x")));
5266db8aaae8SRichard Hendersonint main(void) { return 0; }
5267db8aaae8SRichard HendersonEOF
5268db8aaae8SRichard Hendersonif compile_prog "" "" ; then
5269db8aaae8SRichard Henderson    attralias=yes
5270db8aaae8SRichard Hendersonfi
5271db8aaae8SRichard Henderson
5272db8aaae8SRichard Henderson########################################
52731e6e9acaSRichard Henderson# check if getauxval is available.
52741e6e9acaSRichard Henderson
52751e6e9acaSRichard Hendersongetauxval=no
52761e6e9acaSRichard Hendersoncat > $TMPC << EOF
52771e6e9acaSRichard Henderson#include <sys/auxv.h>
52781e6e9acaSRichard Hendersonint main(void) {
52791e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
52801e6e9acaSRichard Henderson}
52811e6e9acaSRichard HendersonEOF
52821e6e9acaSRichard Hendersonif compile_prog "" "" ; then
52831e6e9acaSRichard Henderson    getauxval=yes
52841e6e9acaSRichard Hendersonfi
52851e6e9acaSRichard Henderson
5286fd0e6053SJohn Snow########################################
5287fd0e6053SJohn Snow# check if ccache is interfering with
5288fd0e6053SJohn Snow# semantic analysis of macros
5289fd0e6053SJohn Snow
52905e4dfd3dSJohn Snowunset CCACHE_CPP2
5291fd0e6053SJohn Snowccache_cpp2=no
5292fd0e6053SJohn Snowcat > $TMPC << EOF
5293fd0e6053SJohn Snowstatic const int Z = 1;
5294fd0e6053SJohn Snow#define fn() ({ Z; })
5295fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5296fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5297fd0e6053SJohn Snow#define ID(X) (X)
5298fd0e6053SJohn Snowint main(int argc, char *argv[])
5299fd0e6053SJohn Snow{
5300fd0e6053SJohn Snow    int x = 0, y = 0;
5301fd0e6053SJohn Snow    x = ID(x);
5302fd0e6053SJohn Snow    x = fn();
5303fd0e6053SJohn Snow    fn();
5304fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5305fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5306fd0e6053SJohn Snow    return 0;
5307fd0e6053SJohn Snow}
5308fd0e6053SJohn SnowEOF
5309fd0e6053SJohn Snow
5310fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5311fd0e6053SJohn Snow    ccache_cpp2=yes
5312fd0e6053SJohn Snowfi
5313fd0e6053SJohn Snow
5314b553a042SJohn Snow#################################################
5315b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5316b553a042SJohn Snow
5317b553a042SJohn Snowif test "$fortify_source" != "no"; then
5318b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5319b553a042SJohn Snow    fortify_source="no";
5320e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5321cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5322b553a042SJohn Snow    fortify_source="no";
5323b553a042SJohn Snow  else
5324b553a042SJohn Snow    fortify_source="yes"
5325b553a042SJohn Snow  fi
5326b553a042SJohn Snowfi
5327b553a042SJohn Snow
53281efad060SFam Zheng###############################################
53291efad060SFam Zheng# Check if copy_file_range is provided by glibc
53301efad060SFam Zhenghave_copy_file_range=no
53311efad060SFam Zhengcat > $TMPC << EOF
53321efad060SFam Zheng#include <unistd.h>
53331efad060SFam Zhengint main(void) {
53341efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
53351efad060SFam Zheng  return 0;
53361efad060SFam Zheng}
53371efad060SFam ZhengEOF
53381efad060SFam Zhengif compile_prog "" "" ; then
53391efad060SFam Zheng    have_copy_file_range=yes
53401efad060SFam Zhengfi
53411efad060SFam Zheng
5342d2042378SAneesh Kumar K.V##########################################
5343277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5344277abf15SJan Vesely
5345277abf15SJan Veselyhave_fsxattr=no
5346277abf15SJan Veselycat > $TMPC << EOF
5347277abf15SJan Vesely#include <linux/fs.h>
5348277abf15SJan Veselystruct fsxattr foo;
5349277abf15SJan Veselyint main(void) {
5350277abf15SJan Vesely  return 0;
5351277abf15SJan Vesely}
5352277abf15SJan VeselyEOF
5353277abf15SJan Veselyif compile_prog "" "" ; then
5354277abf15SJan Vesely    have_fsxattr=yes
5355277abf15SJan Veselyfi
5356277abf15SJan Vesely
5357b66e10e4SPeter Maydell##########################################
5358a40161cbSPaolo Bonzini# check for usable membarrier system call
5359a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5360a40161cbSPaolo Bonzini    have_membarrier=no
5361a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5362a40161cbSPaolo Bonzini        have_membarrier=yes
5363a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5364a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5365a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5366a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5367a40161cbSPaolo Bonzini    #include <unistd.h>
5368a40161cbSPaolo Bonzini    #include <stdlib.h>
5369a40161cbSPaolo Bonzini    int main(void) {
5370a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5371a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5372a40161cbSPaolo Bonzini	exit(0);
5373a40161cbSPaolo Bonzini    }
5374a40161cbSPaolo BonziniEOF
5375a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5376a40161cbSPaolo Bonzini            have_membarrier=yes
5377a40161cbSPaolo Bonzini        fi
5378a40161cbSPaolo Bonzini    fi
5379a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5380a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5381a40161cbSPaolo Bonzini    fi
5382a40161cbSPaolo Bonzinielse
5383a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5384a40161cbSPaolo Bonzini    # work on Wine.
5385a40161cbSPaolo Bonzini    membarrier=no
5386a40161cbSPaolo Bonzinifi
5387a40161cbSPaolo Bonzini
5388a40161cbSPaolo Bonzini##########################################
5389b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5390575b22b1SLaurent Vivierhave_rtnetlink=no
5391575b22b1SLaurent Viviercat > $TMPC << EOF
5392575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5393575b22b1SLaurent Vivierint main(void) {
5394575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5395575b22b1SLaurent Vivier}
5396575b22b1SLaurent VivierEOF
5397575b22b1SLaurent Vivierif compile_prog "" "" ; then
5398575b22b1SLaurent Vivier    have_rtnetlink=yes
5399575b22b1SLaurent Vivierfi
5400575b22b1SLaurent Vivier
54016a02c806SStefan Hajnoczi##########################################
54026a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
54036a02c806SStefan Hajnoczihave_af_vsock=no
54046a02c806SStefan Hajnoczicat > $TMPC << EOF
54056a02c806SStefan Hajnoczi#include <errno.h>
54066a02c806SStefan Hajnoczi#include <sys/types.h>
54076a02c806SStefan Hajnoczi#include <sys/socket.h>
54086a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
54096a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
54106a02c806SStefan Hajnoczi#endif
54116a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
54126a02c806SStefan Hajnocziint main(void) {
54136a02c806SStefan Hajnoczi    int sock, ret;
54146a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
54156a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
54166a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
54176a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
54186a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
54196a02c806SStefan Hajnoczi        return 0;
54206a02c806SStefan Hajnoczi    }
54216a02c806SStefan Hajnoczi    return -1;
54226a02c806SStefan Hajnoczi}
54236a02c806SStefan HajnocziEOF
54246a02c806SStefan Hajnocziif compile_prog "" "" ; then
54256a02c806SStefan Hajnoczi    have_af_vsock=yes
54266a02c806SStefan Hajnoczifi
54276a02c806SStefan Hajnoczi
5428f0d92b56SLongpeng(Mike)##########################################
5429f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
54304f67366eSThomas Huthhave_afalg=no
5431f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5432f0d92b56SLongpeng(Mike)#include <errno.h>
5433f0d92b56SLongpeng(Mike)#include <sys/types.h>
5434f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5435f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5436f0d92b56SLongpeng(Mike)int main(void) {
5437f0d92b56SLongpeng(Mike)    int sock;
5438f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5439f0d92b56SLongpeng(Mike)    return sock;
5440f0d92b56SLongpeng(Mike)}
5441f0d92b56SLongpeng(Mike)EOF
5442f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5443f0d92b56SLongpeng(Mike)    have_afalg=yes
5444f0d92b56SLongpeng(Mike)fi
5445f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5446f0d92b56SLongpeng(Mike)then
5447f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5448f0d92b56SLongpeng(Mike)    then
5449f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5450f0d92b56SLongpeng(Mike)    fi
5451f0d92b56SLongpeng(Mike)fi
5452f0d92b56SLongpeng(Mike)
5453f0d92b56SLongpeng(Mike)
54546969ec6cSJames Clarke#################################################
54554d04351fSChristopher Covington# check for sysmacros.h
54564d04351fSChristopher Covington
54574d04351fSChristopher Covingtonhave_sysmacros=no
54584d04351fSChristopher Covingtoncat > $TMPC << EOF
54594d04351fSChristopher Covington#include <sys/sysmacros.h>
54604d04351fSChristopher Covingtonint main(void) {
54614d04351fSChristopher Covington    return makedev(0, 0);
54624d04351fSChristopher Covington}
54634d04351fSChristopher CovingtonEOF
54644d04351fSChristopher Covingtonif compile_prog "" "" ; then
54654d04351fSChristopher Covington    have_sysmacros=yes
54664d04351fSChristopher Covingtonfi
54674d04351fSChristopher Covington
54684d04351fSChristopher Covington##########################################
546949e00a18SAndreas Grapentin# check for _Static_assert()
547049e00a18SAndreas Grapentin
547149e00a18SAndreas Grapentinhave_static_assert=no
547249e00a18SAndreas Grapentincat > $TMPC << EOF
547349e00a18SAndreas Grapentin_Static_assert(1, "success");
547449e00a18SAndreas Grapentinint main(void) {
547549e00a18SAndreas Grapentin    return 0;
547649e00a18SAndreas Grapentin}
547749e00a18SAndreas GrapentinEOF
547849e00a18SAndreas Grapentinif compile_prog "" "" ; then
547949e00a18SAndreas Grapentin    have_static_assert=yes
548049e00a18SAndreas Grapentinfi
548149e00a18SAndreas Grapentin
548249e00a18SAndreas Grapentin##########################################
5483e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
5484e674605fSTomáš Golembiovský
5485e674605fSTomáš Golembiovskýhave_utmpx=no
5486e674605fSTomáš Golembiovskýcat > $TMPC << EOF
5487e674605fSTomáš Golembiovský#include <utmpx.h>
5488e674605fSTomáš Golembiovskýstruct utmpx user_info;
5489e674605fSTomáš Golembiovskýint main(void) {
5490e674605fSTomáš Golembiovský    return 0;
5491e674605fSTomáš Golembiovský}
5492e674605fSTomáš GolembiovskýEOF
5493e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
5494e674605fSTomáš Golembiovský    have_utmpx=yes
5495e674605fSTomáš Golembiovskýfi
5496e674605fSTomáš Golembiovský
5497e674605fSTomáš Golembiovský##########################################
5498db1ed1abSRichard Henderson# check for getrandom()
5499db1ed1abSRichard Henderson
5500db1ed1abSRichard Hendersonhave_getrandom=no
5501db1ed1abSRichard Hendersoncat > $TMPC << EOF
5502db1ed1abSRichard Henderson#include <sys/random.h>
5503db1ed1abSRichard Hendersonint main(void) {
5504db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
5505db1ed1abSRichard Henderson}
5506db1ed1abSRichard HendersonEOF
5507db1ed1abSRichard Hendersonif compile_prog "" "" ; then
5508db1ed1abSRichard Henderson    have_getrandom=yes
5509db1ed1abSRichard Hendersonfi
5510db1ed1abSRichard Henderson
5511db1ed1abSRichard Henderson##########################################
5512247724cbSMarc-André Lureau# checks for sanitizers
5513247724cbSMarc-André Lureau
5514247724cbSMarc-André Lureauhave_asan=no
5515247724cbSMarc-André Lureauhave_ubsan=no
5516d83414e1SMarc-André Lureauhave_asan_iface_h=no
5517d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
5518247724cbSMarc-André Lureau
5519247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
5520b9f44da2SMarc-André Lureau  write_c_skeleton
5521247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
5522247724cbSMarc-André Lureau      have_asan=yes
5523247724cbSMarc-André Lureau  fi
5524b9f44da2SMarc-André Lureau
5525b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
5526b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
5527b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
5528b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
5529b9f44da2SMarc-André Lureau#include <stdlib.h>
5530b9f44da2SMarc-André Lureauint main(void) {
5531b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
5532f2dfe54cSLeonid Bloch    if (tmp != NULL) {
5533b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
5534b9f44da2SMarc-André Lureau    }
5535d1abf3fcSOlaf Hering    return 1;
5536f2dfe54cSLeonid Bloch}
5537b9f44da2SMarc-André LureauEOF
5538247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
5539247724cbSMarc-André Lureau      have_ubsan=yes
5540247724cbSMarc-André Lureau  fi
5541d83414e1SMarc-André Lureau
5542d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
5543d83414e1SMarc-André Lureau      have_asan_iface_h=yes
5544d83414e1SMarc-André Lureau  fi
5545d83414e1SMarc-André Lureau
5546d83414e1SMarc-André Lureau  cat > $TMPC << EOF
5547d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
5548d83414e1SMarc-André Lureauint main(void) {
5549d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
5550d83414e1SMarc-André Lureau  return 0;
5551d83414e1SMarc-André Lureau}
5552d83414e1SMarc-André LureauEOF
5553d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
5554d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
5555d83414e1SMarc-André Lureau  fi
5556247724cbSMarc-André Lureaufi
5557247724cbSMarc-André Lureau
5558247724cbSMarc-André Lureau##########################################
5559adc28027SAlexander Bulekov# checks for fuzzer
556054c9e41dSAlexander Bulekovif test "$fuzzing" = "yes" && test -z "${LIB_FUZZING_ENGINE+xxx}"; then
5561adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
5562dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
5563adc28027SAlexander Bulekov    have_fuzzer=yes
556464ed6f92SPaolo Bonzini  else
556564ed6f92SPaolo Bonzini    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
556664ed6f92SPaolo Bonzini    exit 1
5567adc28027SAlexander Bulekov  fi
5568adc28027SAlexander Bulekovfi
5569adc28027SAlexander Bulekov
55700aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
55710aebab04SLingfeng Yang# keep it separate until that is not the case.
55720aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
55730aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
55740aebab04SLingfeng Yangfi
55750aebab04SLingfeng Yanghave_tsan=no
55760aebab04SLingfeng Yanghave_tsan_iface_fiber=no
55770aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
55780aebab04SLingfeng Yang  write_c_skeleton
55790aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
55800aebab04SLingfeng Yang      have_tsan=yes
55810aebab04SLingfeng Yang  fi
55820aebab04SLingfeng Yang  cat > $TMPC << EOF
55830aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
55840aebab04SLingfeng Yangint main(void) {
55850aebab04SLingfeng Yang  __tsan_create_fiber(0);
55860aebab04SLingfeng Yang  return 0;
55870aebab04SLingfeng Yang}
55880aebab04SLingfeng YangEOF
55890aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
55900aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
55910aebab04SLingfeng Yang  fi
55920aebab04SLingfeng Yangfi
55930aebab04SLingfeng Yang
5594adc28027SAlexander Bulekov##########################################
559517824406SJunyan He# check for libpmem
559617824406SJunyan He
559717824406SJunyan Heif test "$libpmem" != "no"; then
559817824406SJunyan He	if $pkg_config --exists "libpmem"; then
559917824406SJunyan He		libpmem="yes"
560017824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
560117824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
560217824406SJunyan He	else
560317824406SJunyan He		if test "$libpmem" = "yes" ; then
560417824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
560517824406SJunyan He		fi
560617824406SJunyan He		libpmem="no"
560717824406SJunyan He	fi
560817824406SJunyan Hefi
560917824406SJunyan He
561017824406SJunyan He##########################################
561121b2eca6SJingqi Liu# check for libdaxctl
561221b2eca6SJingqi Liu
561321b2eca6SJingqi Liuif test "$libdaxctl" != "no"; then
561421b2eca6SJingqi Liu	if $pkg_config --atleast-version=57 "libdaxctl"; then
561521b2eca6SJingqi Liu		libdaxctl="yes"
561621b2eca6SJingqi Liu		libdaxctl_libs=$($pkg_config --libs libdaxctl)
561721b2eca6SJingqi Liu		libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
561821b2eca6SJingqi Liu	else
561921b2eca6SJingqi Liu		if test "$libdaxctl" = "yes" ; then
562021b2eca6SJingqi Liu			feature_not_found "libdaxctl" "Install libdaxctl"
562121b2eca6SJingqi Liu		fi
562221b2eca6SJingqi Liu		libdaxctl="no"
562321b2eca6SJingqi Liu	fi
562421b2eca6SJingqi Liufi
562521b2eca6SJingqi Liu
562621b2eca6SJingqi Liu##########################################
5627675b9b53SMarc-André Lureau# check for slirp
5628675b9b53SMarc-André Lureau
5629675b9b53SMarc-André Lureaucase "$slirp" in
56304d34a86bSPaolo Bonzini  auto | enabled | internal)
56314d34a86bSPaolo Bonzini    # Simpler to always update submodule, even if not needed.
56324d34a86bSPaolo Bonzini    if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
56337c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
56347c57bdd8SMarc-André Lureau    fi
5635675b9b53SMarc-André Lureau    ;;
5636675b9b53SMarc-André Lureauesac
5637675b9b53SMarc-André Lureau
563854e7aac0SAlexey Krasikov##########################################
563954e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
564054e7aac0SAlexey Krasikov
564154e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
564254e7aac0SAlexey Krasikov
564354e7aac0SAlexey Krasikov    have_keyring=no
564454e7aac0SAlexey Krasikov    cat > $TMPC << EOF
564554e7aac0SAlexey Krasikov#include <errno.h>
564654e7aac0SAlexey Krasikov#include <asm/unistd.h>
564754e7aac0SAlexey Krasikov#include <linux/keyctl.h>
564854e7aac0SAlexey Krasikov#include <unistd.h>
564954e7aac0SAlexey Krasikovint main(void) {
565054e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
565154e7aac0SAlexey Krasikov}
565254e7aac0SAlexey KrasikovEOF
565354e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
565454e7aac0SAlexey Krasikov        have_keyring=yes
565554e7aac0SAlexey Krasikov    fi
565654e7aac0SAlexey Krasikovfi
565754e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
565854e7aac0SAlexey Krasikovthen
5659b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
566054e7aac0SAlexey Krasikov    then
566154e7aac0SAlexey Krasikov	secret_keyring=yes
566254e7aac0SAlexey Krasikov    else
566354e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
566454e7aac0SAlexey Krasikov	then
566554e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
566654e7aac0SAlexey Krasikovbut not implemented on your system"
566754e7aac0SAlexey Krasikov	else
566854e7aac0SAlexey Krasikov	    secret_keyring=no
566954e7aac0SAlexey Krasikov	fi
567054e7aac0SAlexey Krasikov    fi
567154e7aac0SAlexey Krasikovfi
567254e7aac0SAlexey Krasikov
567392500362SAlexey Krasikov##########################################
5674e86ecd4bSJuan Quintela# End of CC checks
5675e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
5676e86ecd4bSJuan Quintela
5677d83414e1SMarc-André Lureauwrite_c_skeleton
5678d83414e1SMarc-André Lureau
56791d728c39SBlue Swirlif test "$gcov" = "yes" ; then
5680bf0e56a3SMarc-André Lureau  :
5681b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
5682086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
5683086d5f75SPaolo Bonzini  debug=no
5684086d5f75SPaolo Bonzinifi
5685086d5f75SPaolo Bonzini
5686086d5f75SPaolo Bonzinicase "$ARCH" in
5687086d5f75SPaolo Bonzinialpha)
5688086d5f75SPaolo Bonzini  # Ensure there's only a single GP
5689086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
5690086d5f75SPaolo Bonzini;;
5691086d5f75SPaolo Bonziniesac
5692086d5f75SPaolo Bonzini
5693086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
5694086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
5695086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
5696086d5f75SPaolo Bonzinifi
5697a316e378SJuan Quintela
5698247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
5699db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
5700db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
5701d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
5702d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
5703d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5704d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
5705d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
5706d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
5707d83414e1SMarc-André Lureau  fi
5708247724cbSMarc-André Lureaufi
57090aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
57100aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
57110aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
57120aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
57130aebab04SLingfeng Yang  else
57140aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
57150aebab04SLingfeng Yang  fi
57160aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
57170aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
57180aebab04SLingfeng Yangfi
5719247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
5720db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
5721db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
5722247724cbSMarc-André Lureaufi
5723247724cbSMarc-André Lureau
57246542aa9cSPeter Lieven##########################################
57256542aa9cSPeter Lieven# Do we have libnfs
57266542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
5727b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
57286542aa9cSPeter Lieven    libnfs="yes"
57296542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
57306542aa9cSPeter Lieven  else
57316542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
57328efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
57336542aa9cSPeter Lieven    fi
57346542aa9cSPeter Lieven    libnfs="no"
57356542aa9cSPeter Lieven  fi
57366542aa9cSPeter Lievenfi
57371d728c39SBlue Swirl
57383efac6ebSTomáš Golembiovský##########################################
57393efac6ebSTomáš Golembiovský
57400aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
57410aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
5742e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
5743db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
5744e86ecd4bSJuan Quintela    fi
5745e86ecd4bSJuan Quintelafi
5746e86ecd4bSJuan Quintela
5747952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
5748952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
5749cb8baa77SMark Cave-Ayland    flags="--no-seh --nxcompat"
5750cb8baa77SMark Cave-Ayland
5751cb8baa77SMark Cave-Ayland    # Disable ASLR for debug builds to allow debugging with gdb
5752cb8baa77SMark Cave-Ayland    if test "$debug" = "no" ; then
5753cb8baa77SMark Cave-Ayland        flags="--dynamicbase $flags"
5754cb8baa77SMark Cave-Ayland    fi
5755cb8baa77SMark Cave-Ayland
5756cb8baa77SMark Cave-Ayland    for flag in $flags; do
5757e9a3591fSChristian Borntraeger        if ld_has $flag ; then
5758db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
5759952afb71SBlue Swirl        fi
5760952afb71SBlue Swirl    done
5761952afb71SBlue Swirlfi
5762952afb71SBlue Swirl
5763e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
5764e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
5765e0580342SKamil Rytarowski  ivshmem=yes
5766e0580342SKamil Rytarowskifi
5767e0580342SKamil Rytarowski
57684b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
5769b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
57707e462613SPaolo Bonzini    if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
5771983eef5aSMeador Inge      virtfs=yes
5772983eef5aSMeador Inge    else
5773983eef5aSMeador Inge      if test "$virtfs" = yes; then
57747e462613SPaolo Bonzini        error_exit "VirtFS requires libcap-ng devel and libattr devel"
5775983eef5aSMeador Inge      fi
577617500370SAndreas Färber      virtfs=no
5777983eef5aSMeador Inge    fi
5778b855f8d1SPaolo Bonzini  else
5779b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
5780b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
5781b855f8d1SPaolo Bonzini    fi
5782b855f8d1SPaolo Bonzini    virtfs=no
578317bff52bSM. Mohan Kumar  fi
5784ff69fd8cSLaurent Vivierfi
57859d6bc27bSMichael Roth
57869d6bc27bSMichael Roth# Probe for guest agent support/options
57879d6bc27bSMichael Roth
5788e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
5789a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
5790a5125905SLaurent Vivier      guest_agent=no
5791a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
5792e8ef31a3SMichael Tokarev      guest_agent=yes
5793e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
5794e8ef31a3SMichael Tokarev      guest_agent=no
5795e8ef31a3SMichael Tokarev  else
5796e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
5797ca35f780SPaolo Bonzini  fi
57984b1c11fdSDaniel P. Berrangefi
5799ca35f780SPaolo Bonzini
58009d6bc27bSMichael Roth# Guest agent Window MSI  package
58019d6bc27bSMichael Roth
58029d6bc27bSMichael Rothif test "$guest_agent" != yes; then
58039d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
58049d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
58059d6bc27bSMichael Roth  fi
58069d6bc27bSMichael Roth  guest_agent_msi=no
58079d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
58089d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
58099d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
58109d6bc27bSMichael Roth  fi
58119d6bc27bSMichael Roth  guest_agent_msi=no
58129d6bc27bSMichael Rothelif ! has wixl; then
58139d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
58149d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
58159d6bc27bSMichael Roth  fi
58169d6bc27bSMichael Roth  guest_agent_msi=no
58171a34904eSMichael Rothelse
58181a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
58191a34904eSMichael Roth  # disabled explicitly
58201a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
58211a34904eSMichael Roth    guest_agent_msi=yes
58221a34904eSMichael Roth  fi
58239d6bc27bSMichael Rothfi
58249d6bc27bSMichael Roth
58251a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
58269d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
58279d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
58289d6bc27bSMichael Roth  fi
58299d6bc27bSMichael Roth
58309d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
58319d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
58329d6bc27bSMichael Roth  fi
58339d6bc27bSMichael Roth
58349d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
58359d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
58369d6bc27bSMichael Roth  fi
58379d6bc27bSMichael Roth
58389d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
583989138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
58409d6bc27bSMichael Roth  fi
58419d6bc27bSMichael Roth
584289138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
58439d6bc27bSMichael Roth
58449d6bc27bSMichael Roth  case "$cpu" in
58459d6bc27bSMichael Roth  x86_64)
58469d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
58479d6bc27bSMichael Roth    ;;
58489d6bc27bSMichael Roth  i386)
58499d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
58509d6bc27bSMichael Roth    ;;
58519d6bc27bSMichael Roth  *)
58529d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
58539d6bc27bSMichael Roth    ;;
58549d6bc27bSMichael Roth  esac
58559d6bc27bSMichael Rothfi
58569d6bc27bSMichael Roth
5857ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
5858ca35f780SPaolo Bonziniroms=
5859e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
5860e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
58617000a12eSThomas Huth        test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
5862e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
5863c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
5864c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
5865c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
5866e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
5867e57218b6SPeter Maydell            ld_i386_emulation="$emu"
5868ca35f780SPaolo Bonzini            roms="optionrom"
5869e57218b6SPeter Maydell            break
5870e57218b6SPeter Maydell        fi
5871e57218b6SPeter Maydell    done
5872ca35f780SPaolo Bonzinifi
5873ca35f780SPaolo Bonzini
58742e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
58759933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
58762e33c3f8SThomas Huth  write_c_skeleton
58772e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
58789933c305SChristian Borntraeger    roms="$roms s390-ccw"
58791ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
58801ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
58811ef6bfc2SPhilippe Mathieu-Daudé    if test -e "${source_path}/.git" ; then
58821ef6bfc2SPhilippe Mathieu-Daudé      git_submodules="${git_submodules} roms/SLOF"
58831ef6bfc2SPhilippe Mathieu-Daudé    fi
58849933c305SChristian Borntraeger  fi
58852e33c3f8SThomas Huthfi
58869933c305SChristian Borntraeger
588711cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
588811cde1c8SBruno 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.
588911cde1c8SBruno Dominguezif has $cxx; then
589011cde1c8SBruno Dominguez    cat > $TMPC <<EOF
589111cde1c8SBruno Dominguezint c_function(void);
589211cde1c8SBruno Dominguezint main(void) { return c_function(); }
589311cde1c8SBruno DominguezEOF
589411cde1c8SBruno Dominguez
589511cde1c8SBruno Dominguez    compile_object
589611cde1c8SBruno Dominguez
589711cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
589811cde1c8SBruno Dominguezextern "C" {
589911cde1c8SBruno Dominguez   int c_function(void);
590011cde1c8SBruno Dominguez}
590111cde1c8SBruno Dominguezint c_function(void) { return 42; }
590211cde1c8SBruno DominguezEOF
590311cde1c8SBruno Dominguez
590411cde1c8SBruno Dominguez    update_cxxflags
590511cde1c8SBruno Dominguez
59065770e8afSPaolo Bonzini    if do_cxx $CXXFLAGS $CONFIGURE_CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
590711cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
590811cde1c8SBruno Dominguez        :
590911cde1c8SBruno Dominguez    else
591011cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
591111cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
591211cde1c8SBruno Dominguez        cxx=
591311cde1c8SBruno Dominguez    fi
591411cde1c8SBruno Dominguezelse
591511cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
591611cde1c8SBruno Dominguez    cxx=
591711cde1c8SBruno Dominguezfi
591811cde1c8SBruno Dominguez
59195d91a2edSYonggang Luoif test $git_update = 'yes' ; then
59205d91a2edSYonggang Luo    (cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
59215d91a2edSYonggang Luofi
59225d91a2edSYonggang Luo
592398ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
592497a847bcSbellard
592598ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
592698ec69acSJuan Quintelaecho >> $config_host_mak
592798ec69acSJuan Quintela
5928e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
5929cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
5930aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5931f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
5932804edf29SJuan Quintela
593398ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
5934727e5283SPaolo Bonzini
5935f3494749SPaolo Bonziniif test "$default_devices" = "yes" ; then
5936f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
5937f3494749SPaolo Bonzinielse
5938f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
5939f3494749SPaolo Bonzinifi
5940f8393946Saurel32if test "$debug_tcg" = "yes" ; then
59412358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
5942f8393946Saurel32fi
59431625af87Saliguoriif test "$strip_opt" = "yes" ; then
594452ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
59451625af87Saliguorifi
59467d13299dSbellardif test "$bigendian" = "yes" ; then
5947e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
594897a847bcSbellardfi
594967b915a5Sbellardif test "$mingw32" = "yes" ; then
595098ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
595189138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
59529fe6de94SBlue Swirl  version_major=${rc_version%%.*}
59539fe6de94SBlue Swirl  rc_version=${rc_version#*.}
59549fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
59559fe6de94SBlue Swirl  rc_version=${rc_version#*.}
59569fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
59579fe6de94SBlue Swirl  version_micro=0
59589fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
59599fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
5960d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
5961d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
5962f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
5963d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
5964d9840e25STomoki Sekiyama  fi
596550cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
596676dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
596750cbebb9SMichael Roth  fi
59681a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
59694bad7c3bSStefan Hajnoczi    echo "CONFIG_QGA_MSI=y" >> $config_host_mak
59709dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
59719dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
59729dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
59739dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
59749dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
59759dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
59769dacf32dSYossi Hindin  fi
5977210fa556Spbrookelse
597835f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
5979210fa556Spbrookfi
5980128ab2ffSblueswir1
5981dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
5982dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
5983dffcb71cSMark McLoughlinfi
5984dffcb71cSMark McLoughlin
598583fb7adfSbellardif test "$darwin" = "yes" ; then
598698ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
598783fb7adfSbellardfi
5988b29fe3edSmalc
5989ec530c81Sbellardif test "$solaris" = "yes" ; then
599098ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
5991ec530c81Sbellardfi
5992179cf400SAndreas Färberif test "$haiku" = "yes" ; then
5993179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
5994179cf400SAndreas Färberfi
599597a847bcSbellardif test "$static" = "yes" ; then
599698ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
599797a847bcSbellardfi
59981ba16968SStefan Weilif test "$profiler" = "yes" ; then
59992358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
600005c2a3e7Sbellardfi
6001c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
6002c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
6003c932ce31SPaolo Bonzinifi
6004f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
6005f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
6006f15bff25SPaolo Bonzinifi
6007e2d8830eSBradecho "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
60088a16d273Sthsif test "$vde" = "yes" ; then
600998ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6010e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
60118a16d273Sthsfi
601258952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
601358952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
601458952137SVincenzo Maffionefi
6015015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6016015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6017015a33bdSGongleifi
60184cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
60194cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
60204cc600d2SPaolo Bonzinifi
602147e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
6022a358bca2SPaolo Bonzini  echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak
60233f99cf57SPaolo Bonzini  echo "LIBCAP_NG_LIBS=$cap_libs" >> $config_host_mak
602447e98658SCorey Bryantfi
60252358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
60260c58ac1cSmalcfor drv in $audio_drv_list; do
60271ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6028484e2cc7SPaolo Bonzini    echo "$def=y" >> $config_host_mak
60290c58ac1cSmalcdone
6030478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
6031478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
6032478e943fSPaolo Bonzinifi
6033b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6034478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
6035478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
6036478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
6037478e943fSPaolo Bonzinifi
6038b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6039478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
6040b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6041b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6042b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
6043478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
6044478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
6045478e943fSPaolo Bonzinifi
60462e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
6047d5631638Smalcif test "$audio_win_int" = "yes" ; then
6048d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6049d5631638Smalcfi
6050b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6051b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6052dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6053dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6054dce512deSChristoph Hellwigfi
605589138857SStefan Weilqemu_version=$(head $source_path/VERSION)
60562358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
605798ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
60582b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
605917969268SFam Zhengif test "$modules" = "yes"; then
6060e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6061e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
606289138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
606317969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
606417969268SFam Zhengfi
6065bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
6066bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
6067bd83c861SChristian Ehrhardtfi
6068e633a5c6SEric Blakeif test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
60698781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
60708781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
60718781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
60728781595bSGerd Hoffmannfi
6073099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
60742358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6075099d6b0fSRiku Voipiofi
607640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
607740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
607840ff6d7eSKevin Wolffi
60793ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
60802358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
60813ce34dfbSvibisreenivasanfi
6082c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6083c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6084c2882b96SRiku Voipiofi
6085751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6086751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6087751bcc39SMarc-André Lureaufi
6088955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6089955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6090955727d2SCortland Tölvafi
6091d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6092d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6093d0927938SUlrich Hechtfi
60943d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
60953d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
60963d4fa43eSKusanagi Kouichifi
6097b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6098b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6099b953f075SDenis V. Lunevfi
6100ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6101ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6102ed911435SKevin Wolffi
6103c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6104c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6105c727f47dSPeter Maydellfi
6106dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6107dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6108dace20dcSPeter Maydellfi
6109d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6110d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6111d0927938SUlrich Hechtfi
61124e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
61134e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
61144e0c6529SAlex Blighfi
6115cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6116cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6117cd758dd0SAlex Blighfi
61183b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
61193b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
61203b6edd16SPeter Maydellfi
61213b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
61223b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
61233b6edd16SPeter Maydellfi
6124a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6125a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6126a8fd1abaSPeter Maydellfi
612751834341SRiku Voipioif test "$timerfd" = "yes" ; then
612851834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
612951834341SRiku Voipiofi
61309af5c906SRiku Voipioif test "$setns" = "yes" ; then
61319af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
61329af5c906SRiku Voipiofi
613338860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
613438860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
613538860a03SAleksandar Markovicfi
61365a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
61375a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
61385a03cd00SAleksandar Markovicfi
6139db37dd89SAleksandar Markovicif test "$kcov" = "yes" ; then
6140db37dd89SAleksandar Markovic  echo "CONFIG_KCOV=y" >> $config_host_mak
6141db37dd89SAleksandar Markovicfi
6142d6092e08SFilip Bozutaif test "$btrfs" = "yes" ; then
6143d6092e08SFilip Bozuta  echo "CONFIG_BTRFS=y" >> $config_host_mak
6144d6092e08SFilip Bozutafi
61453b3f24adSaurel32if test "$inotify" = "yes" ; then
61462358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
61473b3f24adSaurel32fi
6148c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6149c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6150c05c7a73SRiku Voipiofi
6151401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6152401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6153401bc051SPeter Maydellfi
61545c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
61555c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
61565c99fa37SKeno Fischerfi
61578a792b03SJiufei Xueif test "$st_atim" = "yes" ; then
61588a792b03SJiufei Xue  echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
61598a792b03SJiufei Xuefi
61606ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
61616ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
61626ae9a1f4SJuan Quintelafi
61636ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
61646ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
61656ae9a1f4SJuan Quintelafi
6166769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6167484e2cc7SPaolo Bonzini  echo "CONFIG_CURL=y" >> $config_host_mak
6168b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
61696ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6170769ce76dSAlexander Graffi
61712e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
617298ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
61738eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
61742e4d9fb1Saurel32fi
6175a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6176484e2cc7SPaolo Bonzini  echo "CONFIG_GTK=y" >> $config_host_mak
6177a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6178014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6179925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6180925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6181925a0400SGerd Hoffmann  fi
6182bbbf9bfbSStefan Weilfi
6183f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
6184f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
6185f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
6186f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
618725a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
6188f876b765SMarc-André Lureaufi
6189a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6190ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6191ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6192a81df1b6SPaolo Bonzini  echo "GNUTLS_CFLAGS=$gnutls_cflags" >> $config_host_mak
6193a81df1b6SPaolo Bonzini  echo "GNUTLS_LIBS=$gnutls_libs" >> $config_host_mak
6194ddbb0d09SDaniel P. Berrangefi
619591bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
619691bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
61971f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
61981f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
61991f923c70SLongpeng(Mike)  fi
620046859d93SDaniel P. Berrangé  echo "GCRYPT_CFLAGS=$gcrypt_cflags" >> $config_host_mak
620146859d93SDaniel P. Berrangé  echo "GCRYPT_LIBS=$gcrypt_libs" >> $config_host_mak
620262893b67SDaniel P. Berrangefi
620391bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
620491bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6205becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6206a81df1b6SPaolo Bonzini  echo "NETTLE_CFLAGS=$nettle_cflags" >> $config_host_mak
6207a81df1b6SPaolo Bonzini  echo "NETTLE_LIBS=$nettle_libs" >> $config_host_mak
6208ed754746SDaniel P. Berrangefi
6209e0576942SDaniel P. Berrangéif test "$qemu_private_xts" = "yes" ; then
6210e0576942SDaniel P. Berrangé  echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
6211e0576942SDaniel P. Berrangéfi
62129a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
62139a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
62149a2fd434SDaniel P. Berrangefi
62158953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
62168953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
62178953caf3SDaniel P. Berrangefi
6218559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6219559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6220559607eaSDaniel P. Berrangefi
6221e865b97fSChen Gangif test "$have_drm_h" = "yes" ; then
6222e865b97fSChen Gang  echo "HAVE_DRM_H=y" >> $config_host_mak
6223e865b97fSChen Gangfi
62246b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
62256b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
62266b39b063SEric Blakefi
62279df8b20dSThomas Huthif test "$have_openpty" = "yes" ; then
62289df8b20dSThomas Huth    echo "HAVE_OPENPTY=y" >> $config_host_mak
62299df8b20dSThomas Huthfi
62302a4b472cSDavid CARLIERif test "$have_sys_signal_h" = "yes" ; then
62312a4b472cSDavid CARLIER    echo "HAVE_SYS_SIGNAL_H=y" >> $config_host_mak
62322a4b472cSDavid CARLIERfi
6233277abf15SJan Vesely
6234277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6235277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6236277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6237277abf15SJan Vesely# if this macro is set.
6238277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6239277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6240277abf15SJan Veselyfi
62411efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
62421efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
62431efad060SFam Zhengfi
6244bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6245bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6246a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6247e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6248a4ccabcfSAnthony Liguorifi
62499d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
62509d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
62519d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
62529d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
62539d9e1521SGerd Hoffmannfi
62541badb709SPaolo Bonziniif test "$xen" = "enabled" ; then
62556dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6256d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6257582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
6258582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
6259e37630caSaliguorifi
62605c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
62615c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
62625c6c3a6cSChristoph Hellwigfi
6263c10dd856SAarushi Mehtaif test "$linux_io_uring" = "yes" ; then
6264c10dd856SAarushi Mehta  echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
6265c10dd856SAarushi Mehta  echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
6266c10dd856SAarushi Mehta  echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
6267c10dd856SAarushi Mehtafi
6268758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6269758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6270ec0d5893SMarc-André Lureau  echo "LIBATTR_LIBS=$libattr_libs" >> $config_host_mak
6271758e8e38SVenkateswararao Jujjuri (JV)fi
62724f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
62734f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
62744f26f2b6SAvi Kivityfi
6275983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6276758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6277758e8e38SVenkateswararao Jujjuri (JV)fi
62785e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
62795e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
62805e9be92dSNicholas Bellingerfi
6281af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
6282af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
6283af3bba76SPaolo Bonzinifi
6284af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
628556f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
628603ce5744SNikolay Nikolaevfi
6287108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
6288108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
6289108a6481SCindy Lufi
6290042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6291042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6292042cea27SGongleifi
6293fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6294fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
62955fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
62965fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
62975fe97d88SStefano Garzarella  fi
6298fc0b9b0eSStefan Hajnoczifi
6299299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
6300299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
6301299e6f19SPaolo Bonzinifi
6302e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6303e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6304e6a74868SMarc-André Lureaufi
6305108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
6306108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
6307108a6481SCindy Lufi
630898fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
630998fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
631098fc1adaSDr. David Alan Gilbertfi
6311bf9298b9Saliguoriif test "$iovec" = "yes" ; then
63122358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6313bf9298b9Saliguorifi
6314ceb42de8Saliguoriif test "$preadv" = "yes" ; then
63152358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6316ceb42de8Saliguorifi
6317a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
6318a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
6319a40161cbSPaolo Bonzinifi
6320dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
6321dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
6322dcc38d1cSMarcelo Tosattifi
6323d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
6324d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
6325d339d766SRichard W.M. Jonesfi
63261badb709SPaolo Bonziniif test "$tcg" = "enabled"; then
63279195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
63289195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
63299195b2c2SStefan Weil  fi
6330b3f6ea7eSPaolo Bonzinifi
63315f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
63325f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
63335f6b9e8fSBlue Swirlfi
6334e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
6335e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
6336e78815a5SAndreas Färberfi
6337e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
6338e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
6339e78815a5SAndreas Färberfi
63409bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
63419bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
63429bc5a719SAndreas Gustafssonfi
6343cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
6344cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
63452634733cSPaolo Bonzini  echo "SPICE_CFLAGS=$spice_cflags" >> $config_host_mak
63462634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
6347cd4ec0b4SGerd Hoffmannfi
6348cd4ec0b4SGerd Hoffmann
63497b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
63507b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
63517b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
63527b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
6353111a38b0SRobert Relyeafi
6354111a38b0SRobert Relyea
63552b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
63562b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
6357b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
6358b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
63592b2325ffSGerd Hoffmannfi
63602b2325ffSGerd Hoffmann
636169354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
636269354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
6363cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
6364cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
636569354a83SHans de Goedefi
636669354a83SHans de Goede
6367da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
6368da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
6369de2d3005SPaolo Bonzini  echo "OPENGL_CFLAGS=$opengl_cflags" >> $config_host_mak
6370da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
6371014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
6372014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
6373014cb152SGerd Hoffmann  fi
637420ff075bSMichael Wallefi
637520ff075bSMichael Walle
6376d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
6377d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
6378d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
6379d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
6380d52c454aSMarc-André Lureaufi
6381d52c454aSMarc-André Lureau
6382d52c454aSMarc-André Lureau
638399f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
638499f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
638599f2dbd3SLiang Lifi
638699f2dbd3SLiang Li
63876b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
63886b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
63896b8cd447SRobert Hoofi
63906b8cd447SRobert Hoo
6391607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
6392607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
6393708eab42SMarc-André Lureau  echo "LZO_LIBS=$lzo_libs" >> $config_host_mak
6394607dacd0Sqiaonuohanfi
6395607dacd0Sqiaonuohan
6396607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
6397607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
6398708eab42SMarc-André Lureau  echo "SNAPPY_LIBS=$snappy_libs" >> $config_host_mak
6399607dacd0Sqiaonuohanfi
6400607dacd0Sqiaonuohan
64016b383c08SPeter Wuif test "$bzip2" = "yes" ; then
64026b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
64036b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
64046b383c08SPeter Wufi
64056b383c08SPeter Wu
640683bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
640783bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
640883bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
640983bc1f97SJulio Faraccofi
641083bc1f97SJulio Faracco
64113a678481SJuan Quintelaif test "$zstd" = "yes" ; then
64123a678481SJuan Quintela  echo "CONFIG_ZSTD=y" >> $config_host_mak
64135e5733e5SMarc-André Lureau  echo "ZSTD_CFLAGS=$zstd_cflags" >> $config_host_mak
64145e5733e5SMarc-André Lureau  echo "ZSTD_LIBS=$zstd_libs" >> $config_host_mak
64153a678481SJuan Quintelafi
64163a678481SJuan Quintela
6417c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
6418484e2cc7SPaolo Bonzini  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
64196ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
64206ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
6421c589b249SRonnie Sahlbergfi
6422c589b249SRonnie Sahlberg
64236542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
6424484e2cc7SPaolo Bonzini  echo "CONFIG_LIBNFS=y" >> $config_host_mak
64254be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
64266542aa9cSPeter Lievenfi
64276542aa9cSPeter Lieven
6428f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
6429f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
6430c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
6431c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
6432f794573eSEduardo Otubofi
6433f794573eSEduardo Otubo
643483fb7adfSbellard# XXX: suppress that
64357d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
64362358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
64377d3505c5Sbellardfi
64387d3505c5Sbellard
64393556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
64403556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
64413556c233SPaolo Bonzinifi
6442f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
6443484e2cc7SPaolo Bonzini  echo "CONFIG_RBD=y" >> $config_host_mak
64446ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
6445f27aaf4bSChristian Brunnerfi
644620ff6c80SAnthony Liguori
64477c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
644870c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
644970c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
645070c60c08SStefan Hajnoczielse
645170c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
645270c60c08SStefan Hajnoczifi
6453d0e2fce5SAneesh Kumar K.V
64547d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
64557d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
64567d992e4dSPeter Lievenfi
64577d992e4dSPeter Lieven
6458f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
6459f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
6460f0d92b56SLongpeng(Mike)fi
6461f0d92b56SLongpeng(Mike)
6462d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
6463d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
6464d2042378SAneesh Kumar K.Vfi
6465d2042378SAneesh Kumar K.V
6466e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
6467e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
6468e06a765eSHarsh Prateek Borafi
6469e06a765eSHarsh Prateek Bora
64703f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
64713f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
64723f4349dcSKevin Wolffi
64733f4349dcSKevin Wolf
6474d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
6475d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
6476d83414e1SMarc-André Lureaufi
6477d83414e1SMarc-André Lureau
64780aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
64790aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
64800aebab04SLingfeng Yangfi
64810aebab04SLingfeng Yang
64828ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
64838ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
64848ab1bf12SLuiz Capitulinofi
64858ab1bf12SLuiz Capitulino
648676a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
648776a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
648876a347e1SRichard Hendersonfi
648976a347e1SRichard Henderson
6490f540166bSRichard Hendersonif test "$int128" = "yes" ; then
6491f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
6492f540166bSRichard Hendersonfi
6493f540166bSRichard Henderson
64947ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
64957ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
64967ebee43eSRichard Hendersonfi
64977ebee43eSRichard Henderson
6498e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
6499e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
6500e6cd4bb5SRichard Hendersonfi
6501e6cd4bb5SRichard Henderson
6502df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
6503df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
6504df79b996SRichard Hendersonfi
6505df79b996SRichard Henderson
6506db8aaae8SRichard Hendersonif test "$attralias" = "yes" ; then
6507db8aaae8SRichard Henderson  echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
6508db8aaae8SRichard Hendersonfi
6509db8aaae8SRichard Henderson
65101e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
65111e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
65121e6e9acaSRichard Hendersonfi
65131e6e9acaSRichard Henderson
6514eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
6515484e2cc7SPaolo Bonzini  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
65166ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
65176ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
6518eb100396SBharata B Raofi
6519eb100396SBharata B Rao
6520d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
6521d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
6522d85fa9ebSJeff Codyfi
6523d85fa9ebSJeff Cody
65240c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
65250c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
65260c14fb47SBharata B Raofi
65270c14fb47SBharata B Rao
6528df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
6529df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
6530df3a429aSNiels de Vosfi
6531df3a429aSNiels de Vos
65327c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
65337c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
65347c815372SBharata B Raofi
65357c815372SBharata B Rao
6536e014dbe7SPrasanna Kumar Kaleverif test "$glusterfs_ftruncate_has_stat" = "yes" ; then
6537e014dbe7SPrasanna Kumar Kalever  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
6538e014dbe7SPrasanna Kumar Kaleverfi
6539e014dbe7SPrasanna Kumar Kalever
65400e3b891fSNiels de Vosif test "$glusterfs_iocb_has_stat" = "yes" ; then
65410e3b891fSNiels de Vos  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
65420e3b891fSNiels de Vosfi
65430e3b891fSNiels de Vos
6544b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
6545484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
6546b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
6547b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
65480a12ec87SRichard W.M. Jonesfi
65490a12ec87SRichard W.M. Jones
6550ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
6551ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
6552ed1701c6SDr. David Alan Gilbertfi
6553ed1701c6SDr. David Alan Gilbert
65543b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
65553cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
65563b8acc11SPaolo Bonzinifi
65573b8acc11SPaolo Bonzini
65585b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
65595b808275SLluís Vilanovaif have_backend "nop"; then
65606d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
656122890ab5SPrerna Saxenafi
65625b808275SLluís Vilanovaif have_backend "simple"; then
65636d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
65646d8a764eSLluís  # Set the appropriate trace file.
6565953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
65669410b56cSPrerna Saxenafi
6567ed7f5f1dSPaolo Bonziniif have_backend "log"; then
6568ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
65696d8a764eSLluísfi
65705b808275SLluís Vilanovaif have_backend "ust"; then
65716d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
6572a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
6573a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
65746d8a764eSLluísfi
65755b808275SLluís Vilanovaif have_backend "dtrace"; then
65766d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
65776d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
65786d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
65796d8a764eSLluís  fi
6580c276b17dSDaniel P. Berrangefi
65815b808275SLluís Vilanovaif have_backend "ftrace"; then
6582781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
6583781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
6584781e9545SEiichi Tsukata  else
658521684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
6586781e9545SEiichi Tsukata  fi
6587781e9545SEiichi Tsukatafi
65880a852417SPaul Durrantif have_backend "syslog"; then
65890a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
65900a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
65910a852417SPaul Durrant  else
65920a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
65930a852417SPaul Durrant  fi
65940a852417SPaul Durrantfi
65959410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
65969410b56cSPrerna Saxena
65972da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
65982da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
6599392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
66002da776dbSMichael R. Hinesfi
66012da776dbSMichael R. Hines
660221ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
660321ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
660421ab34c9SMarcel Apfelbaumfi
660521ab34c9SMarcel Apfelbaum
6606575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
6607575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
6608575b22b1SLaurent Vivierfi
6609575b22b1SLaurent Vivier
6610ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
6611ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
6612ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
6613ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
6614ed279a06SKlim Kireevfi
6615ed279a06SKlim Kireev
6616a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
6617a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
6618a6b1d4c0SChanglong Xiefi
6619a6b1d4c0SChanglong Xie
66206a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
66216a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
66226a02c806SStefan Hajnoczifi
66236a02c806SStefan Hajnoczi
66244d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
66254d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
66264d04351fSChristopher Covingtonfi
66274d04351fSChristopher Covington
662849e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
662949e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
663049e00a18SAndreas Grapentinfi
663149e00a18SAndreas Grapentin
6632e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
6633e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
6634e674605fSTomáš Golembiovskýfi
6635db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
6636db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
6637db1ed1abSRichard Hendersonfi
6638e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
6639e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
6640e0580342SKamil Rytarowskifi
6641ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
6642ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
6643ba59fb77SPaolo Bonzinifi
6644e0580342SKamil Rytarowski
66455c312079SDr. David Alan Gilbert# Hold two types of flag:
66465c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
66475c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
6648479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
66495c312079SDr. David Alan Gilbert#                                     platform
6650479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
66515c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6652479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
6653479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
6654479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
6655479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
66565c312079SDr. David Alan Gilbertfi
66575c312079SDr. David Alan Gilbert
665817824406SJunyan Heif test "$libpmem" = "yes" ; then
665917824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
6660c9322ab5SMarc-André Lureau  echo "LIBPMEM_LIBS=$libpmem_libs" >> $config_host_mak
6661c9322ab5SMarc-André Lureau  echo "LIBPMEM_CFLAGS=$libpmem_cflags" >> $config_host_mak
666217824406SJunyan Hefi
666317824406SJunyan He
666421b2eca6SJingqi Liuif test "$libdaxctl" = "yes" ; then
666521b2eca6SJingqi Liu  echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
6666c7c91a74SBruce Rogers  echo "LIBDAXCTL_LIBS=$libdaxctl_libs" >> $config_host_mak
666721b2eca6SJingqi Liufi
666821b2eca6SJingqi Liu
66692f740136SJeff Codyif test "$bochs" = "yes" ; then
66702f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
66712f740136SJeff Codyfi
66722f740136SJeff Codyif test "$cloop" = "yes" ; then
66732f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
66742f740136SJeff Codyfi
66752f740136SJeff Codyif test "$dmg" = "yes" ; then
66762f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
66772f740136SJeff Codyfi
66782f740136SJeff Codyif test "$qcow1" = "yes" ; then
66792f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
66802f740136SJeff Codyfi
66812f740136SJeff Codyif test "$vdi" = "yes" ; then
66822f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
66832f740136SJeff Codyfi
66842f740136SJeff Codyif test "$vvfat" = "yes" ; then
66852f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
66862f740136SJeff Codyfi
66872f740136SJeff Codyif test "$qed" = "yes" ; then
66882f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
66892f740136SJeff Codyfi
66902f740136SJeff Codyif test "$parallels" = "yes" ; then
66912f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
66922f740136SJeff Codyfi
66932f740136SJeff Codyif test "$sheepdog" = "yes" ; then
6694e1c42697SDaniel P. Berrangé  add_to deprecated_features "sheepdog"
66952f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
66962f740136SJeff Codyfi
6697c9c8b88fSDavid CARLIERif test "$pty_h" = "yes" ; then
6698c9c8b88fSDavid CARLIER  echo "HAVE_PTY_H=y" >> $config_host_mak
6699c9c8b88fSDavid CARLIERfi
6700195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
6701195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
6702195588ccSDavid CARLIERfi
6703adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
670454c9e41dSAlexander Bulekov  # If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the
670554c9e41dSAlexander Bulekov  # needed CFLAGS have already been provided
670654c9e41dSAlexander Bulekov  if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
6707086d5f75SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
670854c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
670954c9e41dSAlexander Bulekov  else
671054c9e41dSAlexander Bulekov    FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
671154c9e41dSAlexander Bulekov  fi
6712adc28027SAlexander Bulekovfi
67132f740136SJeff Cody
671440e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
671540e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
671626fffe29SEmilio G. Cota    # Copy the export object list to the build dir
671726fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
671826fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
671926fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
672026fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
672126fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
672226fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
672326fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
672426fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
672526fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
672626fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
672726fffe29SEmilio G. Cota    else
672826fffe29SEmilio G. Cota	error_exit \
672926fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
673026fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
673126fffe29SEmilio G. Cota    fi
673240e8c6f4SAlex Bennéefi
673340e8c6f4SAlex Bennée
6734f48e590aSAlex Bennéeif test -n "$gdb_bin" ; then
6735f48e590aSAlex Bennée    echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
6736f48e590aSAlex Bennéefi
6737f48e590aSAlex Bennée
673854e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
673954e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
674054e7aac0SAlexey Krasikovfi
674154e7aac0SAlexey Krasikov
674298ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
6743804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
6744c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
674539d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
6746a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
674709e93326SPaolo Bonziniecho "NINJA=$ninja" >> $config_host_mak
6748804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
6749a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
6750859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
6751a31a8642SMichael S. Tsirkinfi
675283f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
67533c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
6754804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
675545d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
6756cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
67575f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
67583dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
6759804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
6760804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
67619f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
67624852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
6763daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
67649fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
676546eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
6766a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
676711cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
6768a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
6769a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
67708a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
6771db5adeaaSPaolo Bonziniecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
6772e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
6773804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
6774484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
6775f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
677690246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
677790246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
67781d728c39SBlue Swirlif test "$gcov" = "yes" ; then
67791d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
67801d728c39SBlue Swirlfi
6781804edf29SJuan Quintela
6782adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
6783adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
6784adc28027SAlexander Bulekovfi
678554c9e41dSAlexander Bulekovecho "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
67863efac6ebSTomáš Golembiovský
6787b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
6788b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
6789b767d257SMarek Marczykowski-Góreckifi
6790b767d257SMarek Marczykowski-Górecki
67916efd7517SPeter Maydell# use included Linux headers
67926efd7517SPeter Maydellif test "$linux" = "yes" ; then
6793a307beb6SAndreas Färber  mkdir -p linux-headers
67946efd7517SPeter Maydell  case "$cpu" in
6795c72b26ecSRichard Henderson  i386|x86_64|x32)
679608312a63SPeter Maydell    linux_arch=x86
67976efd7517SPeter Maydell    ;;
6798f8378accSRichard Henderson  ppc|ppc64|ppc64le)
679908312a63SPeter Maydell    linux_arch=powerpc
68006efd7517SPeter Maydell    ;;
68016efd7517SPeter Maydell  s390x)
680208312a63SPeter Maydell    linux_arch=s390
680308312a63SPeter Maydell    ;;
68041f080313SClaudio Fontana  aarch64)
68051f080313SClaudio Fontana    linux_arch=arm64
68061f080313SClaudio Fontana    ;;
6807222e7d11SSanjay Lal  mips64)
6808222e7d11SSanjay Lal    linux_arch=mips
6809222e7d11SSanjay Lal    ;;
681008312a63SPeter Maydell  *)
681108312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
681208312a63SPeter Maydell    linux_arch="$cpu"
68136efd7517SPeter Maydell    ;;
68146efd7517SPeter Maydell  esac
681508312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
681608312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
681708312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
681808312a63SPeter Maydell    fi
68196efd7517SPeter Maydellfi
68206efd7517SPeter Maydell
682197a847bcSbellardfor target in $target_list; do
682297a847bcSbellard    target_dir="$target"
682389138857SStefan Weil    target_name=$(echo $target | cut -d '-' -f 1)
682497a847bcSbellard    mkdir -p $target_dir
6825fdb75aefSPaolo Bonzini    case $target in
6826fdb75aefSPaolo Bonzini        *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
6827fdb75aefSPaolo Bonzini        *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
68282408a527Saurel32    esac
682956aebc89Spbrookdone
68307d13299dSbellard
6831765686d6SPaolo Bonziniecho "CONFIG_QEMU_INTERP_PREFIX=$interp_prefix" | sed 's/%M/@0@/' >> $config_host_mak
6832fdb75aefSPaolo Bonziniif test "$default_targets" = "yes"; then
6833fdb75aefSPaolo Bonzini  echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak
6834fdb75aefSPaolo Bonzinifi
6835a540f158SPeter Crosthwaite
6836a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
6837a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
6838ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
6839a99d57bbSWanlong Gaofi
6840a99d57bbSWanlong Gao
6841fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
6842fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
6843fd0e6053SJohn Snowfi
6844fd0e6053SJohn Snow
68451e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
68461e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
68471e4f6065SDaniele Buonofi
68481e4f6065SDaniele Buono
6849e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
6850e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
6851e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
6852e29e5c6eSPeter Maydell# (these can be both files and directories).
6853e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
6854e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
6855e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
6856e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
6857e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
6858e29e5c6eSPeter Maydell# directory and symlink the directory instead.
685909db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
686009db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
686109db9b9dSGerd Hoffmann# a "make distclean" in between.
68621cf4323eSThomas HuthDIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
68631cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
6864b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
6865744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
68668db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
6867c17a386bSAlex BennéeDIRS="$DIRS contrib/plugins/"
68682038f8c8SPaolo BonziniLINKS="Makefile"
6869e8f3bd71SMarc-André LureauLINKS="$LINKS tests/tcg/lm32/Makefile"
68703941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
6871ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
6872e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
68738db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
6874e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
6875e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
687639950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
687739950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
68788f8fd9edSCleber RosaLINKS="$LINKS python"
6879c17a386bSAlex BennéeLINKS="$LINKS contrib/plugins/Makefile "
688009db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
6881753d11f2SRichard Hendersonfor bios_file in \
6882753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
68833a631b8eSBin Meng    $source_path/pc-bios/*.elf \
6884225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
6885753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
6886753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
6887e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
6888753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
68894e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
689026ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
6891753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
6892753d11f2SRichard Hendersondo
6893e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
68947ea78b74SJan Kiszkadone
6895d1807a4fSPaolo Bonzinimkdir -p $DIRS
6896e29e5c6eSPeter Maydellfor f in $LINKS ; do
68970f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
6898f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
6899f9245e10SPeter Maydell    fi
69007d13299dSbellarddone
690109db9b9dSGerd Hoffmannfor f in $UNLINK ; do
690209db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
690309db9b9dSGerd Hoffmann        rm -f "$f"
690409db9b9dSGerd Hoffmann    fi
690509db9b9dSGerd Hoffmanndone
69061ad2134fSPaul Brook
69072038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
69082038f8c8SPaolo Bonzini  export $i
69092038f8c8SPaolo Bonzinidone
6910afc3a8f9SAlex Bennéeexport target_list source_path use_containers
69112038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
69122038f8c8SPaolo Bonzini
6913c34ebfdcSAnthony Liguori# temporary config to build submodules
69148db2a4fdSGerd Hoffmannfor rom in seabios; do
6915c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
691637116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
6917c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
6918cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
69195f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
6920c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
6921c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
69223dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
6923c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
6924a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
6925c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
69269f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
6927c34ebfdcSAnthony Liguoridone
6928c34ebfdcSAnthony Liguori
692976c7560aSMax Reitz# set up qemu-iotests in this build directory
693076c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
693176c7560aSMax Reitz
693276c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
693376c7560aSMax Reitzecho >> "$iotests_common_env"
693476c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
693576c7560aSMax Reitz
6936a5665051SPaolo Bonziniif test "$skip_meson" = no; then
6937fc929892SMarc-André Lureaucross="config-meson.cross.new"
6938fc929892SMarc-André Lureaumeson_quote() {
693947b30835SPaolo Bonzini    echo "'$(echo $* | sed "s/ /','/g")'"
6940fc929892SMarc-André Lureau}
6941fc929892SMarc-André Lureau
6942fc929892SMarc-André Lureauecho "# Automatically generated by configure - do not modify" > $cross
6943fc929892SMarc-André Lureauecho "[properties]" >> $cross
6944fc929892SMarc-André Lureautest -z "$cxx" && echo "link_language = 'c'" >> $cross
694547b30835SPaolo Bonziniecho "[built-in options]" >> $cross
694647b30835SPaolo Bonziniecho "c_args = [${CFLAGS:+$(meson_quote $CFLAGS)}]" >> $cross
694747b30835SPaolo Bonziniecho "cpp_args = [${CXXFLAGS:+$(meson_quote $CXXFLAGS)}]" >> $cross
694847b30835SPaolo Bonziniecho "c_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
694947b30835SPaolo Bonziniecho "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
6950fc929892SMarc-André Lureauecho "[binaries]" >> $cross
695147b30835SPaolo Bonziniecho "c = [$(meson_quote $cc)]" >> $cross
695247b30835SPaolo Bonzinitest -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
695347b30835SPaolo Bonziniecho "ar = [$(meson_quote $ar)]" >> $cross
695447b30835SPaolo Bonziniecho "nm = [$(meson_quote $nm)]" >> $cross
695547b30835SPaolo Bonziniecho "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
695647b30835SPaolo Bonziniecho "ranlib = [$(meson_quote $ranlib)]" >> $cross
6957e8178514SPaolo Bonziniif has $sdl2_config; then
695847b30835SPaolo Bonzini  echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
6959e8178514SPaolo Bonzinifi
696047b30835SPaolo Bonziniecho "strip = [$(meson_quote $strip)]" >> $cross
696147b30835SPaolo Bonziniecho "windres = [$(meson_quote $windres)]" >> $cross
6962fc929892SMarc-André Lureauif test -n "$cross_prefix"; then
6963fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
6964fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
6965fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
6966fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
6967fc929892SMarc-André Lureau    fi
6968853b4bafSThomas Huth    if test "$linux" = "yes" ; then
6969853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
6970853b4bafSThomas Huth    fi
6971fc929892SMarc-André Lureau    case "$ARCH" in
6972fc929892SMarc-André Lureau        i386|x86_64)
6973fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
6974fc929892SMarc-André Lureau            ;;
6975fc929892SMarc-André Lureau        ppc64le)
6976fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
6977fc929892SMarc-André Lureau            ;;
6978fc929892SMarc-André Lureau        *)
6979fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
6980fc929892SMarc-André Lureau            ;;
6981fc929892SMarc-André Lureau    esac
6982fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
6983fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
6984fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
6985fc929892SMarc-André Lureau    else
6986fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
6987fc929892SMarc-André Lureau    fi
6988fc929892SMarc-André Lureauelse
6989fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
6990fc929892SMarc-André Lureaufi
6991fc929892SMarc-André Lureaumv $cross config-meson.cross
6992fc929892SMarc-André Lureau
6993a5665051SPaolo Bonzinirm -rf meson-private meson-info meson-logs
6994a5cb7c5aSPaolo Bonziniunset staticpic
6995a5cb7c5aSPaolo Bonziniif ! version_ge "$($meson --version)" 0.56.0; then
6996a5cb7c5aSPaolo Bonzini  staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
6997a5cb7c5aSPaolo Bonzinifi
699809e93326SPaolo BonziniNINJA=$ninja $meson setup \
6999d17f305aSPaolo Bonzini        --prefix "$prefix" \
7000d17f305aSPaolo Bonzini        --libdir "$libdir" \
7001d17f305aSPaolo Bonzini        --libexecdir "$libexecdir" \
7002d17f305aSPaolo Bonzini        --bindir "$bindir" \
7003d17f305aSPaolo Bonzini        --includedir "$includedir" \
7004d17f305aSPaolo Bonzini        --datadir "$datadir" \
7005d17f305aSPaolo Bonzini        --mandir "$mandir" \
7006d17f305aSPaolo Bonzini        --sysconfdir "$sysconfdir" \
700716bf7a33SPaolo Bonzini        --localedir "$localedir" \
7008d17f305aSPaolo Bonzini        --localstatedir "$local_statedir" \
7009d17f305aSPaolo Bonzini        -Ddocdir="$docdir" \
701016bf7a33SPaolo Bonzini        -Dqemu_firmwarepath="$firmwarepath" \
701173f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
7012a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
7013a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
7014a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
7015a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
7016da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
7017a5cb7c5aSPaolo Bonzini        ${staticpic:+-Db_staticpic=$staticpic} \
7018bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
7019deb62371SPaolo Bonzini        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
70201badb709SPaolo Bonzini        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf \
70211badb709SPaolo Bonzini        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
7022b4e312e9SPaolo Bonzini        -Dcocoa=$cocoa -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
7023a0b93237SPaolo Bonzini        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
7024cece116cSMisono Tomohiro        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
7025fbb4121dSPaolo Bonzini        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
70265c53015aSPaolo Bonzini        -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
7027c8d5450bSPaolo Bonzini        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
7028e5e856c1SStefan Hajnoczi        -Dvhost_user_blk_server=$vhost_user_blk_server \
7029*df4ea709SMax Reitz        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek \
7030fc929892SMarc-André Lureau        $cross_arg \
7031a5665051SPaolo Bonzini        "$PWD" "$source_path"
7032a5665051SPaolo Bonzini
7033a5665051SPaolo Bonziniif test "$?" -ne 0 ; then
7034a5665051SPaolo Bonzini    error_exit "meson setup failed"
7035a5665051SPaolo Bonzinifi
7036a5665051SPaolo Bonzinifi
7037a5665051SPaolo Bonzini
70382d838d9bSAlex Bennéeif test -n "${deprecated_features}"; then
70392d838d9bSAlex Bennée    echo "Warning, deprecated features enabled."
70402d838d9bSAlex Bennée    echo "Please see docs/system/deprecated.rst"
70412d838d9bSAlex Bennée    echo "  features: ${deprecated_features}"
70422d838d9bSAlex Bennéefi
70432d838d9bSAlex Bennée
7044dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
7045dc655404SMichael S. Tsirkincat <<EOD >config.status
7046dc655404SMichael S. Tsirkin#!/bin/sh
7047dc655404SMichael S. Tsirkin# Generated by configure.
7048dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
7049dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
7050dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
7051dc655404SMichael S. TsirkinEOD
7052e811da7fSDaniel P. Berrangé
7053e811da7fSDaniel P. Berrangépreserve_env() {
7054e811da7fSDaniel P. Berrangé    envname=$1
7055e811da7fSDaniel P. Berrangé
7056e811da7fSDaniel P. Berrangé    eval envval=\$$envname
7057e811da7fSDaniel P. Berrangé
7058e811da7fSDaniel P. Berrangé    if test -n "$envval"
7059e811da7fSDaniel P. Berrangé    then
7060e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
7061e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
7062e811da7fSDaniel P. Berrangé    else
7063e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
7064e811da7fSDaniel P. Berrangé    fi
7065e811da7fSDaniel P. Berrangé}
7066e811da7fSDaniel P. Berrangé
7067e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
7068e811da7fSDaniel P. Berrangé# features/build target configure will detect
7069e811da7fSDaniel P. Berrangépreserve_env AR
7070e811da7fSDaniel P. Berrangépreserve_env AS
7071e811da7fSDaniel P. Berrangépreserve_env CC
7072e811da7fSDaniel P. Berrangépreserve_env CPP
7073e811da7fSDaniel P. Berrangépreserve_env CXX
7074e811da7fSDaniel P. Berrangépreserve_env INSTALL
7075e811da7fSDaniel P. Berrangépreserve_env LD
7076e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
7077e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
7078e811da7fSDaniel P. Berrangépreserve_env MAKE
7079e811da7fSDaniel P. Berrangépreserve_env NM
7080e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
7081e811da7fSDaniel P. Berrangépreserve_env PATH
7082e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
7083e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
7084e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
7085e811da7fSDaniel P. Berrangépreserve_env PYTHON
7086e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
7087e811da7fSDaniel P. Berrangépreserve_env SMBD
7088e811da7fSDaniel P. Berrangépreserve_env STRIP
7089e811da7fSDaniel P. Berrangépreserve_env WINDRES
7090e811da7fSDaniel P. Berrangé
7091dc655404SMichael S. Tsirkinprintf "exec" >>config.status
7092a5665051SPaolo Bonzinifor i in "$0" "$@"; do
7093a5665051SPaolo Bonzini  test "$i" = --skip-meson || printf " '%s'" "$i" >>config.status
7094a5665051SPaolo Bonzinidone
7095cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
7096dc655404SMichael S. Tsirkinchmod +x config.status
7097dc655404SMichael S. Tsirkin
70988cd05ab6SPeter Maydellrm -r "$TMPDIR1"
7099