xref: /openbmc/qemu/configure (revision 215b0c2f)
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"
158086d5f75SPaolo Bonzini    CXXFLAGS=$(echo "$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"
173086d5f75SPaolo Bonzini  do_cc $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"
179086d5f75SPaolo Bonzini  do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $QEMU_LDFLAGS $local_ldflags
18052166aa0SJuan Quintela}
18152166aa0SJuan Quintela
18211568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
18311568d6dSPaolo Bonzinisymlink() {
18472b8b5a1SStefan Weil  rm -rf "$2"
185ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
18672b8b5a1SStefan Weil  ln -s "$1" "$2"
18711568d6dSPaolo Bonzini}
18811568d6dSPaolo Bonzini
1890dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1900dba6195SLoïc Minier# executable or a builtin)
1910dba6195SLoïc Minierhas() {
1920dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1930dba6195SLoïc Minier}
1940dba6195SLoïc Minier
1950a01d76fSMarc-André Lureauversion_ge () {
1960a01d76fSMarc-André Lureau    local_ver1=`echo $1 | tr . ' '`
1970a01d76fSMarc-André Lureau    local_ver2=`echo $2 | tr . ' '`
1980a01d76fSMarc-André Lureau    while true; do
1990a01d76fSMarc-André Lureau        set x $local_ver1
2000a01d76fSMarc-André Lureau        local_first=${2-0}
201c44a33e2SStefano Garzarella        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
202c44a33e2SStefano Garzarella        shift ${2:+2}
2030a01d76fSMarc-André Lureau        local_ver1=$*
2040a01d76fSMarc-André Lureau        set x $local_ver2
2050a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2060a01d76fSMarc-André Lureau        test $# = 1 && return 0
2070a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2080a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
209c44a33e2SStefano Garzarella        shift ${2:+2}
2100a01d76fSMarc-André Lureau        local_ver2=$*
2110a01d76fSMarc-André Lureau    done
2120a01d76fSMarc-André Lureau}
2130a01d76fSMarc-André Lureau
2145b808275SLluís Vilanovahave_backend () {
2155b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2165b808275SLluís Vilanova}
2175b808275SLluís Vilanova
2183b6b7550SPaolo Bonziniglob() {
2193b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2203b6b7550SPaolo Bonzini}
2213b6b7550SPaolo Bonzini
2223b6b7550SPaolo Bonzinisupported_hax_target() {
2233b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
2243b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
2253b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
2263b6b7550SPaolo Bonzini        i386|x86_64)
2273b6b7550SPaolo Bonzini            return 0
2283b6b7550SPaolo Bonzini        ;;
2293b6b7550SPaolo Bonzini    esac
2303b6b7550SPaolo Bonzini    return 1
2313b6b7550SPaolo Bonzini}
2323b6b7550SPaolo Bonzini
2333b6b7550SPaolo Bonzinisupported_kvm_target() {
2343b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
2353b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
2363b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
2373b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
2383b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
2393b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
240aa2953fdSHuacai Chen        mips:mips | mipsel:mips | mips64:mips | mips64el:mips | \
241f8378accSRichard Henderson        ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | ppc64:ppc64le | \
2423b6b7550SPaolo Bonzini        s390x:s390x)
2433b6b7550SPaolo Bonzini            return 0
2443b6b7550SPaolo Bonzini        ;;
2453b6b7550SPaolo Bonzini    esac
2463b6b7550SPaolo Bonzini    return 1
2473b6b7550SPaolo Bonzini}
2483b6b7550SPaolo Bonzini
2493b6b7550SPaolo Bonzinisupported_xen_target() {
2503b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2513b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
252b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
253b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
254b5ed2e11SPaolo Bonzini        i386|x86_64)
2553b6b7550SPaolo Bonzini            return 0
2563b6b7550SPaolo Bonzini        ;;
2573b6b7550SPaolo Bonzini    esac
2583b6b7550SPaolo Bonzini    return 1
2593b6b7550SPaolo Bonzini}
2603b6b7550SPaolo Bonzini
261c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
262c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
263c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
264c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
265c97d6d2cSSergio Andres Gomez Del Real        x86_64)
266c97d6d2cSSergio Andres Gomez Del Real            return 0
267c97d6d2cSSergio Andres Gomez Del Real        ;;
268c97d6d2cSSergio Andres Gomez Del Real    esac
269c97d6d2cSSergio Andres Gomez Del Real    return 1
270c97d6d2cSSergio Andres Gomez Del Real}
271c97d6d2cSSergio Andres Gomez Del Real
272d661d9a4SJustin Terry (VM)supported_whpx_target() {
273d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
274d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
275d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
276d661d9a4SJustin Terry (VM)        i386|x86_64)
277d661d9a4SJustin Terry (VM)            return 0
278d661d9a4SJustin Terry (VM)        ;;
279d661d9a4SJustin Terry (VM)    esac
280d661d9a4SJustin Terry (VM)    return 1
281d661d9a4SJustin Terry (VM)}
282d661d9a4SJustin Terry (VM)
283d880a3baSPaolo Bonzinisupported_target() {
284d880a3baSPaolo Bonzini    case "$1" in
285d880a3baSPaolo Bonzini        *-softmmu)
286d880a3baSPaolo Bonzini            ;;
287d880a3baSPaolo Bonzini        *-linux-user)
288d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
289d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
290d880a3baSPaolo Bonzini                return 1
291d880a3baSPaolo Bonzini            fi
292d880a3baSPaolo Bonzini            ;;
293d880a3baSPaolo Bonzini        *-bsd-user)
294d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
295d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
296d880a3baSPaolo Bonzini                return 1
297d880a3baSPaolo Bonzini            fi
298d880a3baSPaolo Bonzini            ;;
299d880a3baSPaolo Bonzini        *)
300d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
301d880a3baSPaolo Bonzini            return 1
302d880a3baSPaolo Bonzini            ;;
303d880a3baSPaolo Bonzini    esac
304b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
305b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
306b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
307b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
308c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
309d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
310b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
311b3f6ea7eSPaolo Bonzini    return 1
312d880a3baSPaolo Bonzini}
313d880a3baSPaolo Bonzini
314e9a3591fSChristian Borntraeger
315e9a3591fSChristian Borntraegerld_has() {
316e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
317e9a3591fSChristian Borntraeger}
318e9a3591fSChristian Borntraeger
3194ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
3204ace32e2SAntonio Ospitethen
3214ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
3224ace32e2SAntonio Ospitefi
3234ace32e2SAntonio Ospite
32414211825SAntonio Ospite# default parameters
3252ff6b91eSJuan Quintelacpu=""
326a31a8642SMichael S. Tsirkiniasl="iasl"
3271e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
32843ce4dfeSbellardstatic="no"
3297d13299dSbellardcross_prefix=""
3300c58ac1cSmalcaudio_drv_list=""
331b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
332b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
333e49d021eSPeter Maydellhost_cc="cc"
3343e2e0e6bSJuan Quintelalibs_tools=""
335d5631638Smalcaudio_win_int=""
336957f1f99SMichael Rothlibs_qga=""
3375bc62e01SGerd Hoffmanndebug_info="yes"
33863678e17SSteven Noonanstack_protector=""
3391e4f6065SDaniele Buonosafe_stack=""
340afc3a8f9SAlex Bennéeuse_containers="yes"
341f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
342ac0df51dSaliguori
34392712822SDaniel P. Berrangeif test -e "$source_path/.git"
34492712822SDaniel P. Berrangethen
345f62bbee5SDaniel P. Berrange    git_update=yes
34692712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
3473ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
3483ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
34992712822SDaniel P. Berrangeelse
350f62bbee5SDaniel P. Berrange    git_update=no
351aef45d51SDaniel P. Berrange    git_submodules=""
3525c0ef67aSDaniel P. Berrangé
3535c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
3545c0ef67aSDaniel P. Berrangé    then
3555c0ef67aSDaniel P. Berrangé        echo
3565c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
3575c0ef67aSDaniel P. Berrangé        echo
3585c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
3595c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
3605c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
3615c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
3625c0ef67aSDaniel P. Berrangé        echo
363a3e3b521SPeter Maydell        echo "  https://www.qemu.org/download/#source"
3645c0ef67aSDaniel P. Berrangé        echo
3655c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
3665c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
3675c0ef67aSDaniel P. Berrangé        echo
3685c0ef67aSDaniel P. Berrangé        exit 1
3695c0ef67aSDaniel P. Berrangé    fi
37092712822SDaniel P. Berrangefi
371cc84d63aSDaniel P. Berrangegit="git"
372ac0df51dSaliguori
373afb63ebdSStefan Weil# Don't accept a target_list environment variable.
374afb63ebdSStefan Weilunset target_list
375447e133fSAlex Bennéeunset target_list_exclude
376377529c0SPaolo Bonzini
377377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
378377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
379377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
380377529c0SPaolo Bonzini#              unless --disable-foo is given
381377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
382377529c0SPaolo Bonzini#              feature will searched for,
383377529c0SPaolo Bonzini#              if not found, configure exits with error
384377529c0SPaolo Bonzini#
385377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
386377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
387377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
388377529c0SPaolo Bonzini
389377529c0SPaolo Bonzinibrlapi=""
390377529c0SPaolo Bonzinicurl=""
391377529c0SPaolo Bonzinicurses=""
392377529c0SPaolo Bonzinidocs=""
393377529c0SPaolo Bonzinifdt=""
39458952137SVincenzo Maffionenetmap="no"
39535be72baSPaolo Bonzinisdl="auto"
39635be72baSPaolo Bonzinisdl_image="auto"
397983eef5aSMeador Ingevirtfs=""
398fe8fc5aeSPaolo Bonzinimpath=""
399a0b93237SPaolo Bonzinivnc="enabled"
400377529c0SPaolo Bonzinisparse="no"
401377529c0SPaolo Bonzinivde=""
402a0b93237SPaolo Bonzinivnc_sasl="auto"
403a0b93237SPaolo Bonzinivnc_jpeg="auto"
404a0b93237SPaolo Bonzinivnc_png="auto"
4054113f4cfSLaurent Vivierxkbcommon="auto"
406377529c0SPaolo Bonzinixen=""
407d5b93ddfSAnthony PERARDxen_ctrl_version=""
408eb6fda0fSAnthony PERARDxen_pci_passthrough=""
409377529c0SPaolo Bonzinilinux_aio=""
410c10dd856SAarushi Mehtalinux_io_uring=""
41147e98658SCorey Bryantcap_ng=""
412377529c0SPaolo Bonziniattr=""
4134f26f2b6SAvi Kivitylibattr=""
414377529c0SPaolo Bonzinixfs=""
415b3f6ea7eSPaolo Bonzinitcg="yes"
416a40161cbSPaolo Bonzinimembarrier=""
417299e6f19SPaolo Bonzinivhost_net=""
418299e6f19SPaolo Bonzinivhost_crypto=""
419299e6f19SPaolo Bonzinivhost_scsi=""
420299e6f19SPaolo Bonzinivhost_vsock=""
421e6a74868SMarc-André Lureauvhost_user=""
42298fc1adaSDr. David Alan Gilbertvhost_user_fs=""
423d41a75a2SBradkvm="no"
424b0cb0a66SVincent Palatinhax="no"
425c97d6d2cSSergio Andres Gomez Del Realhvf="no"
426d661d9a4SJustin Terry (VM)whpx="no"
4272da776dbSMichael R. Hinesrdma=""
42821ab34c9SMarcel Apfelbaumpvrdma=""
429377529c0SPaolo Bonzinigprof="no"
430377529c0SPaolo Bonzinidebug_tcg="no"
431377529c0SPaolo Bonzinidebug="no"
432247724cbSMarc-André Lureausanitizers="no"
4330aebab04SLingfeng Yangtsan="no"
434b553a042SJohn Snowfortify_source=""
435377529c0SPaolo Bonzinistrip_opt="yes"
4369195b2c2SStefan Weiltcg_interpreter="no"
437377529c0SPaolo Bonzinibigendian="no"
438377529c0SPaolo Bonzinimingw32="no"
4391d728c39SBlue Swirlgcov="no"
440377529c0SPaolo BonziniEXESUF=""
441484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
44217969268SFam ZhengLDFLAGS_SHARED="-shared"
44317969268SFam Zhengmodules="no"
444bd83c861SChristian Ehrhardtmodule_upgrades="no"
445377529c0SPaolo Bonziniprefix="/usr/local"
44610ff82d1SMarc-André Lureauqemu_suffix="qemu"
447675b9b53SMarc-André Lureauslirp=""
448377529c0SPaolo Bonzinioss_lib=""
449377529c0SPaolo Bonzinibsd="no"
450377529c0SPaolo Bonzinilinux="no"
451377529c0SPaolo Bonzinisolaris="no"
452377529c0SPaolo Bonziniprofiler="no"
453377529c0SPaolo Bonzinicocoa="no"
454377529c0SPaolo Bonzinisoftmmu="yes"
455377529c0SPaolo Bonzinilinux_user="no"
456377529c0SPaolo Bonzinibsd_user="no"
457377529c0SPaolo Bonziniblobs="yes"
45805dfa22bSPhilippe Mathieu-Daudéedk2_blobs="no"
459377529c0SPaolo Bonzinipkgversion=""
46040d6444eSAvi Kivitypie=""
4613556c233SPaolo Bonziniqom_cast_debug="yes"
462baf86d6bSPaolo Bonzinitrace_backends="log"
463377529c0SPaolo Bonzinitrace_file="trace"
464377529c0SPaolo Bonzinispice=""
465377529c0SPaolo Bonzinirbd=""
4667b02f544SMarc-André Lureausmartcard=""
4670a40bcb7SCésar Belleyu2f="auto"
4682b2325ffSGerd Hoffmannlibusb=""
46969354a83SHans de Goedeusb_redir=""
470da076ffeSGerd Hoffmannopengl=""
471014cb152SGerd Hoffmannopengl_dmabuf="no"
4725dd89908SRichard Hendersoncpuid_h="no"
47386583a07SLiam Merwickavx2_opt=""
4748ca80760SRichard Hendersoncapstone=""
475b25c9dffSStefan Weillzo=""
476b25c9dffSStefan Weilsnappy=""
4776b383c08SPeter Wubzip2=""
47883bc1f97SJulio Faraccolzfse=""
4793a678481SJuan Quintelazstd=""
480e8ef31a3SMichael Tokarevguest_agent=""
481d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
48250cbebb9SMichael Rothguest_agent_ntddscsi="no"
4839dacf32dSYossi Hindinguest_agent_msi=""
484d9840e25STomoki Sekiyamavss_win32_sdk=""
485d9840e25STomoki Sekiyamawin_sdk="no"
486e10ee3f5SPhilippe Mathieu-Daudéwant_tools=""
487c589b249SRonnie Sahlberglibiscsi=""
4886542aa9cSPeter Lievenlibnfs=""
489519175a2SAlex Barcelocoroutine=""
49070c60c08SStefan Hajnoczicoroutine_pool=""
4917d992e4dSPeter Lievendebug_stack_usage="no"
492f0d92b56SLongpeng(Mike)crypto_afalg="no"
493f794573eSEduardo Otuboseccomp=""
494eb100396SBharata B Raoglusterfs=""
495d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
4960c14fb47SBharata B Raoglusterfs_discard="no"
497df3a429aSNiels de Vosglusterfs_fallocate="no"
4987c815372SBharata B Raoglusterfs_zerofill="no"
499e014dbe7SPrasanna Kumar Kaleverglusterfs_ftruncate_has_stat="no"
5000e3b891fSNiels de Vosglusterfs_iocb_has_stat="no"
501a4ccabcfSAnthony Liguorigtk=""
502925a0400SGerd Hoffmanngtk_gl="no"
503a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
504ddbb0d09SDaniel P. Berrangegnutls=""
50591bfcdb0SDaniel P. Berrangenettle=""
506dc2207afSDaniel P. Berrangénettle_xts="no"
50791bfcdb0SDaniel P. Berrangegcrypt=""
5081f923c70SLongpeng(Mike)gcrypt_hmac="no"
509e0576942SDaniel P. Berrangégcrypt_xts="no"
510e0576942SDaniel P. Berrangéqemu_private_xts="yes"
5118953caf3SDaniel P. Berrangeauth_pam=""
512bbbf9bfbSStefan Weilvte=""
5139d9e1521SGerd Hoffmannvirglrenderer=""
5147aaa6a16SPaolo Bonzinitpm=""
515b10d49d7SPino Toscanolibssh=""
516ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
517a99d57bbSWanlong Gaonuma=""
5182847b469SFam Zhengtcmalloc="no"
5197b01cb97SAlexandre Derumierjemalloc="no"
520a6b1d4c0SChanglong Xiereplication="yes"
5212f740136SJeff Codybochs="yes"
5222f740136SJeff Codycloop="yes"
5232f740136SJeff Codydmg="yes"
5242f740136SJeff Codyqcow1="yes"
5252f740136SJeff Codyvdi="yes"
5262f740136SJeff Codyvvfat="yes"
5272f740136SJeff Codyqed="yes"
5282f740136SJeff Codyparallels="yes"
5292f740136SJeff Codysheepdog="yes"
530ed279a06SKlim Kireevlibxml2=""
531ba59fb77SPaolo Bonzinidebug_mutex="no"
53217824406SJunyan Helibpmem=""
533f3494749SPaolo Bonzinidefault_devices="yes"
53440e8c6f4SAlex Bennéeplugins="no"
535adc28027SAlexander Bulekovfuzzing="no"
536b767d257SMarek Marczykowski-Góreckirng_none="no"
53754e7aac0SAlexey Krasikovsecret_keyring=""
53821b2eca6SJingqi Liulibdaxctl=""
539a5665051SPaolo Bonzinimeson=""
54048328880SPaolo Bonzinininja=""
541a5665051SPaolo Bonziniskip_meson=no
542e8f3bd71SMarc-André Lureaugettext=""
543377529c0SPaolo Bonzini
544fb59dabdSPeter Maydellbogus_os="no"
5455a22ab71SYang Zhongmalloc_trim=""
546898be3e0SPeter Maydell
547ac0df51dSaliguori# parse CC options first
548ac0df51dSaliguorifor opt do
54989138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
550ac0df51dSaliguori  case "$opt" in
551ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
552ac0df51dSaliguori  ;;
5533d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
554ac0df51dSaliguori  ;;
55583f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
55683f73fceSTomoki Sekiyama  ;;
5572ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
5582ff6b91eSJuan Quintela  ;;
559de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
560db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
561e2a2ed06SJuan Quintela  ;;
56211cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
56311cde1c8SBruno Dominguez  ;;
564db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
565f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
566e2a2ed06SJuan Quintela  ;;
5675bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
5685bc62e01SGerd Hoffmann  ;;
5695bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
5705bc62e01SGerd Hoffmann  ;;
571d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
572d75402b5SAlex Bennée  ;;
573d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
574d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
5752038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
576d422b2bcSAlex Bennée  ;;
577d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
5782038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
579d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
5802038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
581d75402b5SAlex Bennée  ;;
582ac0df51dSaliguori  esac
583ac0df51dSaliguoridone
584ac0df51dSaliguori# OS specific
585ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
58693148aa5SStefan Weil# we can eliminate its usage altogether.
587ac0df51dSaliguori
588e49d021eSPeter Maydell# Preferred compiler:
589e49d021eSPeter Maydell#  ${CC} (if set)
590e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
591e49d021eSPeter Maydell#  system compiler
592e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
593e49d021eSPeter Maydell  cc="$host_cc"
594e49d021eSPeter Maydellelse
595b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
596e49d021eSPeter Maydellfi
597e49d021eSPeter Maydell
59883f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
59983f73fceSTomoki Sekiyama  cxx="c++"
60083f73fceSTomoki Sekiyamaelse
60183f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
60283f73fceSTomoki Sekiyamafi
60383f73fceSTomoki Sekiyama
604b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
605cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
6065f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
6073dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
608b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
609b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
6109f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
6114852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
612b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
613b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
61417884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
61517884d7bSSergei Trofimovichquery_pkg_config() {
61617884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
61717884d7bSSergei Trofimovich}
61817884d7bSSergei Trofimovichpkg_config=query_pkg_config
61947c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
620ac0df51dSaliguori
62145d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
62245d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
62345d285abSPeter Maydell
624be17dc90SMichael S. Tsirkin# default flags for all hosts
6252d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
6262d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
6272d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
6282d31515bSPeter Maydell# provides these semantics.)
629086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
630086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
631c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
632be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
63325211446SPaolo BonziniQEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote ${source_path}/accel/tcg -iquote ${source_path}/include"
63425211446SPaolo BonziniQEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
635086d5f75SPaolo BonziniCFLAGS="-std=gnu99 -Wall"
636086d5f75SPaolo Bonzini
637be17dc90SMichael S. Tsirkin
638ac0df51dSaliguoricheck_define() {
639ac0df51dSaliguoricat > $TMPC <<EOF
640ac0df51dSaliguori#if !defined($1)
641fd786e1aSPeter Maydell#error $1 not defined
642ac0df51dSaliguori#endif
643ac0df51dSaliguoriint main(void) { return 0; }
644ac0df51dSaliguoriEOF
64552166aa0SJuan Quintela  compile_object
646ac0df51dSaliguori}
647ac0df51dSaliguori
648307119e7SGerd Hoffmanncheck_include() {
649307119e7SGerd Hoffmanncat > $TMPC <<EOF
650307119e7SGerd Hoffmann#include <$1>
651307119e7SGerd Hoffmannint main(void) { return 0; }
652307119e7SGerd HoffmannEOF
653307119e7SGerd Hoffmann  compile_object
654307119e7SGerd Hoffmann}
655307119e7SGerd Hoffmann
65693b25869SJohn Snowwrite_c_skeleton() {
65793b25869SJohn Snow    cat > $TMPC <<EOF
65893b25869SJohn Snowint main(void) { return 0; }
65993b25869SJohn SnowEOF
66093b25869SJohn Snow}
66193b25869SJohn Snow
662adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
663adc28027SAlexander Bulekov    cat > $TMPC <<EOF
664adc28027SAlexander Bulekov#include <stdint.h>
665adc28027SAlexander Bulekov#include <sys/types.h>
666adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
667adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
668adc28027SAlexander BulekovEOF
669adc28027SAlexander Bulekov}
670adc28027SAlexander Bulekov
671bbea4050SPeter Maydellif check_define __linux__ ; then
672bbea4050SPeter Maydell  targetos="Linux"
673bbea4050SPeter Maydellelif check_define _WIN32 ; then
674bbea4050SPeter Maydell  targetos='MINGW32'
675bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
676bbea4050SPeter Maydell  targetos='OpenBSD'
677bbea4050SPeter Maydellelif check_define __sun__ ; then
678bbea4050SPeter Maydell  targetos='SunOS'
679bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
680bbea4050SPeter Maydell  targetos='Haiku'
681951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
682951fedfcSPeter Maydell  targetos='FreeBSD'
683951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
684951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
685951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
686951fedfcSPeter Maydell  targetos='DragonFly'
687951fedfcSPeter Maydellelif check_define __NetBSD__; then
688951fedfcSPeter Maydell  targetos='NetBSD'
689951fedfcSPeter Maydellelif check_define __APPLE__; then
690951fedfcSPeter Maydell  targetos='Darwin'
691bbea4050SPeter Maydellelse
692951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
693951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
694951fedfcSPeter Maydell  # be the result of a missing compiler.
695951fedfcSPeter Maydell  targetos='bogus'
696951fedfcSPeter Maydell  bogus_os='yes'
697bbea4050SPeter Maydellfi
698bbea4050SPeter Maydell
699bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
700bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
701bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
702bbea4050SPeter Maydell# the correct CPU with the --cpu option.
703bbea4050SPeter Maydellcase $targetos in
704bbea4050SPeter MaydellDarwin)
705bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
706bbea4050SPeter Maydell  # run 64-bit userspace code.
707bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
708bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
709bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
710bbea4050SPeter Maydell    cpu="x86_64"
711bbea4050SPeter Maydell  fi
712bbea4050SPeter Maydell  ;;
713bbea4050SPeter MaydellSunOS)
71489138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
715bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
716bbea4050SPeter Maydell    cpu="x86_64"
717bbea4050SPeter Maydell  fi
718bbea4050SPeter Maydellesac
719bbea4050SPeter Maydell
7202ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
7212ff6b91eSJuan Quintela  # command line argument
7222ff6b91eSJuan Quintela  :
7232ff6b91eSJuan Quintelaelif check_define __i386__ ; then
724ac0df51dSaliguori  cpu="i386"
725ac0df51dSaliguorielif check_define __x86_64__ ; then
726c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
727c72b26ecSRichard Henderson    cpu="x32"
728c72b26ecSRichard Henderson  else
729ac0df51dSaliguori    cpu="x86_64"
730c72b26ecSRichard Henderson  fi
7313aa9bd6cSblueswir1elif check_define __sparc__ ; then
7323aa9bd6cSblueswir1  if check_define __arch64__ ; then
7333aa9bd6cSblueswir1    cpu="sparc64"
7343aa9bd6cSblueswir1  else
7353aa9bd6cSblueswir1    cpu="sparc"
7363aa9bd6cSblueswir1  fi
737fdf7ed96Smalcelif check_define _ARCH_PPC ; then
738fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
739f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
740f8378accSRichard Henderson      cpu="ppc64le"
741f8378accSRichard Henderson    else
742fdf7ed96Smalc      cpu="ppc64"
743f8378accSRichard Henderson    fi
744ac0df51dSaliguori  else
745fdf7ed96Smalc    cpu="ppc"
746fdf7ed96Smalc  fi
747afa05235SAurelien Jarnoelif check_define __mips__ ; then
748afa05235SAurelien Jarno  cpu="mips"
749d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
750d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
751d66ed0eaSAurelien Jarno    cpu="s390x"
752d66ed0eaSAurelien Jarno  else
753d66ed0eaSAurelien Jarno    cpu="s390"
754d66ed0eaSAurelien Jarno  fi
755c4f80543SAlistair Franciselif check_define __riscv ; then
756c4f80543SAlistair Francis  if check_define _LP64 ; then
757c4f80543SAlistair Francis    cpu="riscv64"
758c4f80543SAlistair Francis  else
759c4f80543SAlistair Francis    cpu="riscv32"
760c4f80543SAlistair Francis  fi
76121d89f84SPeter Maydellelif check_define __arm__ ; then
76221d89f84SPeter Maydell  cpu="arm"
7631f080313SClaudio Fontanaelif check_define __aarch64__ ; then
7641f080313SClaudio Fontana  cpu="aarch64"
765fdf7ed96Smalcelse
76689138857SStefan Weil  cpu=$(uname -m)
767ac0df51dSaliguorifi
768ac0df51dSaliguori
769359bc95dSPeter MaydellARCH=
770359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
771359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
7727d13299dSbellardcase "$cpu" in
773ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
774898be3e0SPeter Maydell  ;;
775f8378accSRichard Henderson  ppc64le)
776f8378accSRichard Henderson    ARCH="ppc64"
777f8378accSRichard Henderson  ;;
7787d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
77997a847bcSbellard    cpu="i386"
7807d13299dSbellard  ;;
781aaa5fa14Saurel32  x86_64|amd64)
782aaa5fa14Saurel32    cpu="x86_64"
783aaa5fa14Saurel32  ;;
78421d89f84SPeter Maydell  armv*b|armv*l|arm)
78521d89f84SPeter Maydell    cpu="arm"
7867d13299dSbellard  ;;
7871f080313SClaudio Fontana  aarch64)
7881f080313SClaudio Fontana    cpu="aarch64"
7891f080313SClaudio Fontana  ;;
790afa05235SAurelien Jarno  mips*)
791afa05235SAurelien Jarno    cpu="mips"
792afa05235SAurelien Jarno  ;;
7933142255cSblueswir1  sparc|sun4[cdmuv])
794ae228531Sbellard    cpu="sparc"
795ae228531Sbellard  ;;
7967d13299dSbellard  *)
797359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
798359bc95dSPeter Maydell    ARCH=unknown
7997d13299dSbellard  ;;
8007d13299dSbellardesac
801359bc95dSPeter Maydellif test -z "$ARCH"; then
802359bc95dSPeter Maydell  ARCH="$cpu"
803359bc95dSPeter Maydellfi
804e2d52ad3SJuan Quintela
8057d13299dSbellard# OS specific
8060dbfc675SJuan Quintela
807adfc3e91SStacey Son# host *BSD for user mode
808adfc3e91SStacey SonHOST_VARIANT_DIR=""
809adfc3e91SStacey Son
8107d13299dSbellardcase $targetos in
81167b915a5SbellardMINGW32*)
81267b915a5Sbellard  mingw32="yes"
813b0cb0a66SVincent Palatin  hax="yes"
814e7a222aeSThomas Huth  whpx=""
815299e6f19SPaolo Bonzini  vhost_user="no"
8163cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
817307119e7SGerd Hoffmann  if check_include dsound.h; then
8183cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
819307119e7SGerd Hoffmann  else
820307119e7SGerd Hoffmann    audio_drv_list=""
821307119e7SGerd Hoffmann  fi
822898be3e0SPeter Maydell  supported_os="yes"
823fb648e9cSDaniel P. Berrangé  pie="no"
82467b915a5Sbellard;;
8255c40d2bdSthsGNU/kFreeBSD)
826a167ba50SAurelien Jarno  bsd="yes"
8276a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8280bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
8295c40d2bdSths;;
8307d3505c5SbellardFreeBSD)
8317d3505c5Sbellard  bsd="yes"
8320db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8336a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8340bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
835f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
836f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
83758952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
838adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
8397d3505c5Sbellard;;
840c5e97233Sblueswir1DragonFly)
841c5e97233Sblueswir1  bsd="yes"
8420db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8436a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8440bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
845adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
846c5e97233Sblueswir1;;
8477d3505c5SbellardNetBSD)
8487d3505c5Sbellard  bsd="yes"
849604a5b99SKamil Rytarowski  hax="yes"
8500db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8516a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8520bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8538ef92a88Sblueswir1  oss_lib="-lossaudio"
854adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8557d3505c5Sbellard;;
8567d3505c5SbellardOpenBSD)
8577d3505c5Sbellard  bsd="yes"
8580db4a067SPaolo Bonzini  make="${MAKE-gmake}"
859f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
8600bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
861adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
8627d3505c5Sbellard;;
86383fb7adfSbellardDarwin)
86483fb7adfSbellard  bsd="yes"
86583fb7adfSbellard  darwin="yes"
866b0cb0a66SVincent Palatin  hax="yes"
867c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
86817969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
8691b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
870a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
871db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
8721b0f9cc2Saliguori  fi
873fd677642Sths  cocoa="yes"
8746a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
87514382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
876db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
877a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
878a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
879a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
880adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
88183fb7adfSbellard;;
882ec530c81SbellardSunOS)
883ec530c81Sbellard  solaris="yes"
8840db4a067SPaolo Bonzini  make="${MAKE-gmake}"
885e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
8866b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
8876a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
8886b4d2ba1Sths  fi
889c2de5c91Smalc  audio_possible_drivers="oss sdl"
890d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
891d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
892d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
893d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
894560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
895560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
896ec530c81Sbellard;;
897179cf400SAndreas FärberHaiku)
898179cf400SAndreas Färber  haiku="yes"
899fc433430SDavid CARLIER  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -DBSD_SOURCE $QEMU_CFLAGS"
900fc433430SDavid CARLIER  LIBS="-lposix_error_mapper -lnetwork -lbsd $LIBS"
901179cf400SAndreas Färber;;
902898be3e0SPeter MaydellLinux)
9037183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
9040bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
9055327cf48Sbellard  linux="yes"
906831b7825Sths  linux_user="yes"
907af2be207SJan Kiszka  kvm="yes"
90858683d07SPaolo Bonzini  QEMU_INCLUDES="-isystem ${source_path}/linux-headers -Ilinux-headers $QEMU_INCLUDES"
9093efac6ebSTomáš Golembiovský  libudev="yes"
910898be3e0SPeter Maydell;;
9117d13299dSbellardesac
9127d13299dSbellard
9137d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
914b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
91584778508Sblueswir1    bsd_user="yes"
9167d3505c5Sbellard  fi
91708de3949SAndreas Färberfi
9187d3505c5Sbellard
9190db4a067SPaolo Bonzini: ${make=${MAKE-make}}
920b6daf4d3SPaolo Bonzini
921faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
922faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
923ddf90699SEduardo Habkost# we check that too
924faf44142SDaniel P. Berrangépython=
9250a01d76fSMarc-André Lureauexplicit_python=no
926ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
927faf44142SDaniel P. Berrangédo
928faf44142SDaniel P. Berrangé    if has "$binary"
929faf44142SDaniel P. Berrangé    then
93095c5f2deSPaolo Bonzini        python=$(command -v "$binary")
931faf44142SDaniel P. Berrangé        break
932faf44142SDaniel P. Berrangé    fi
933faf44142SDaniel P. Berrangédone
934903458c8SMarkus Armbruster
935903458c8SMarkus Armbrustersphinx_build=
936903458c8SMarkus Armbrusterfor binary in sphinx-build-3 sphinx-build
937903458c8SMarkus Armbrusterdo
938903458c8SMarkus Armbruster    if has "$binary"
939903458c8SMarkus Armbruster    then
940903458c8SMarkus Armbruster        sphinx_build=$(command -v "$binary")
941903458c8SMarkus Armbruster        break
942903458c8SMarkus Armbruster    fi
943903458c8SMarkus Armbrusterdone
944903458c8SMarkus Armbruster
94539d87c8cSAlex Bennée# Check for ancillary tools used in testing
94639d87c8cSAlex Bennéegenisoimage=
9473df437c7SAlex Bennéefor binary in genisoimage mkisofs
94839d87c8cSAlex Bennéedo
94939d87c8cSAlex Bennée    if has $binary
95039d87c8cSAlex Bennée    then
95139d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
95239d87c8cSAlex Bennée        break
95339d87c8cSAlex Bennée    fi
95439d87c8cSAlex Bennéedone
95539d87c8cSAlex Bennée
956e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
9570db4a067SPaolo Bonzini
9583c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
9593c4a4d0dSPeter Maydellif has clang; then
9603c4a4d0dSPeter Maydell  objcc=clang
9613c4a4d0dSPeter Maydellelse
9623c4a4d0dSPeter Maydell  objcc="$cc"
9633c4a4d0dSPeter Maydellfi
9643c4a4d0dSPeter Maydell
9653457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
9663457a3f8SJuan Quintela  EXESUF=".exe"
967484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
96878e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
969086d5f75SPaolo Bonzini  CFLAGS="-mthreads $CFLAGS"
970b965e8c5SPaolo Bonzini  LIBS="-lwinmm -lws2_32 $LIBS"
97193b25869SJohn Snow  write_c_skeleton;
972f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
973f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
974f7cf5d5bSStefan Weil  fi
975c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
97677433a5fSMarc-André Lureau  qemu_suffix=""
977105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
9783457a3f8SJuan Quintelafi
9793457a3f8SJuan Quintela
980487fefdbSAnthony Liguoriwerror=""
98185aa5189Sbellard
9827d13299dSbellardfor opt do
98389138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
9847d13299dSbellard  case "$opt" in
9852efc3265Sbellard  --help|-h) show_help=yes
9862efc3265Sbellard  ;;
98799123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
98899123e13SMike Frysinger  ;;
989b1a550a0Spbrook  --prefix=*) prefix="$optarg"
9907d13299dSbellard  ;;
991b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
99232ce6337Sbellard  ;;
993ac0df51dSaliguori  --cross-prefix=*)
9947d13299dSbellard  ;;
995ac0df51dSaliguori  --cc=*)
9967d13299dSbellard  ;;
997b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
99883469015Sbellard  ;;
99983f73fceSTomoki Sekiyama  --cxx=*)
100083f73fceSTomoki Sekiyama  ;;
1001e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
1002e007dbecSMichael S. Tsirkin  ;;
10033c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
10043c4a4d0dSPeter Maydell  ;;
1005b1a550a0Spbrook  --make=*) make="$optarg"
10067d13299dSbellard  ;;
1007b6daf4d3SPaolo Bonzini  --install=*)
10086a882643Spbrook  ;;
10090a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
1010c886edfbSBlue Swirl  ;;
10112eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
10122eb054c2SPeter Maydell  ;;
1013a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
1014a5665051SPaolo Bonzini  ;;
1015a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
1016a5665051SPaolo Bonzini  ;;
101748328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
101848328880SPaolo Bonzini  ;;
1019e2d8830eSBrad  --smbd=*) smbd="$optarg"
1020e2d8830eSBrad  ;;
1021e2a2ed06SJuan Quintela  --extra-cflags=*)
10227d13299dSbellard  ;;
102311cde1c8SBruno Dominguez  --extra-cxxflags=*)
102411cde1c8SBruno Dominguez  ;;
1025e2a2ed06SJuan Quintela  --extra-ldflags=*)
10267d13299dSbellard  ;;
10275bc62e01SGerd Hoffmann  --enable-debug-info)
10285bc62e01SGerd Hoffmann  ;;
10295bc62e01SGerd Hoffmann  --disable-debug-info)
10305bc62e01SGerd Hoffmann  ;;
1031d75402b5SAlex Bennée  --cross-cc-*)
1032d75402b5SAlex Bennée  ;;
103317969268SFam Zheng  --enable-modules)
103417969268SFam Zheng      modules="yes"
103517969268SFam Zheng  ;;
10363aa88b31SStefan Hajnoczi  --disable-modules)
10373aa88b31SStefan Hajnoczi      modules="no"
10383aa88b31SStefan Hajnoczi  ;;
1039bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
1040bd83c861SChristian Ehrhardt  ;;
1041bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
1042bd83c861SChristian Ehrhardt  ;;
10432ff6b91eSJuan Quintela  --cpu=*)
10447d13299dSbellard  ;;
1045b1a550a0Spbrook  --target-list=*) target_list="$optarg"
1046447e133fSAlex Bennée                   if test "$target_list_exclude"; then
1047447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
1048447e133fSAlex Bennée                   fi
1049447e133fSAlex Bennée  ;;
1050447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
1051447e133fSAlex Bennée                   if test "$target_list"; then
1052447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
1053447e133fSAlex Bennée                   fi
1054de83cd02Sbellard  ;;
10555b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
10565b808275SLluís Vilanova  ;;
10575b808275SLluís Vilanova  # XXX: backwards compatibility
10585b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
105994a420b1SStefan Hajnoczi  ;;
106074242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
10619410b56cSPrerna Saxena  ;;
1062f3494749SPaolo Bonzini  --with-default-devices) default_devices="yes"
1063f3494749SPaolo Bonzini  ;;
1064f3494749SPaolo Bonzini  --without-default-devices) default_devices="no"
1065f3494749SPaolo Bonzini  ;;
10667d13299dSbellard  --enable-gprof) gprof="yes"
10677d13299dSbellard  ;;
10681d728c39SBlue Swirl  --enable-gcov) gcov="yes"
10691d728c39SBlue Swirl  ;;
107079427693SLoïc Minier  --static)
107179427693SLoïc Minier    static="yes"
107217884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
107343ce4dfeSbellard  ;;
10740b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
10750b24e75fSPaolo Bonzini  ;;
10760b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
10770b24e75fSPaolo Bonzini  ;;
10783aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
10793aa5d2beSAlon Levy  ;;
10808bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
10818bf188aaSMichael Tokarev  ;;
10820f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
10830f94d6daSAlon Levy  ;;
1084528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
10850b24e75fSPaolo Bonzini  ;;
108677433a5fSMarc-André Lureau  --with-suffix=*) qemu_suffix="$optarg"
1087023d3d67SEduardo Habkost  ;;
1088850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
10890b24e75fSPaolo Bonzini  ;;
1090ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
109107381cc1SAnthony Liguori  ;;
1092785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1093785c23aeSLuiz Capitulino  ;;
10943d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
10953d5eecabSGerd Hoffmann  ;;
1096181ce1d0SOlaf Hering  --host=*|--build=*|\
1097181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1098785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1099023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1100023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1101023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1102023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1103023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1104023ddd74SMax Filippov    # lots of directory switches by default.
1105023ddd74SMax Filippov  ;;
110635be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
110797a847bcSbellard  ;;
110835be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
1109c4198157SJuan Quintela  ;;
111035be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
1111a442fe2fSDaniel P. Berrangé  ;;
111235be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
1113a442fe2fSDaniel P. Berrangé  ;;
11143556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
11153556c233SPaolo Bonzini  ;;
11163556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
11173556c233SPaolo Bonzini  ;;
1118983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1119983eef5aSMeador Inge  ;;
1120983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1121983eef5aSMeador Inge  ;;
1122fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1123fe8fc5aeSPaolo Bonzini  ;;
1124fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1125fe8fc5aeSPaolo Bonzini  ;;
1126a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
1127821601eaSJes Sorensen  ;;
1128a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
1129821601eaSJes Sorensen  ;;
1130e8f3bd71SMarc-André Lureau  --disable-gettext) gettext="false"
1131e8f3bd71SMarc-André Lureau  ;;
1132e8f3bd71SMarc-André Lureau  --enable-gettext) gettext="true"
1133e8f3bd71SMarc-André Lureau  ;;
11342f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
11352f6a1ab0Sblueswir1  ;;
11360c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
11370c58ac1cSmalc  ;;
113889138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1139b64ec4e4SFam Zheng  ;;
114089138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1141eb852011SMarkus Armbruster  ;;
1142f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1143f8393946Saurel32  ;;
1144f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1145f8393946Saurel32  ;;
1146f3d08ee6SPaul Brook  --enable-debug)
1147f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1148f3d08ee6SPaul Brook      debug_tcg="yes"
11491fcc6d42SPeter Xu      debug_mutex="yes"
1150f3d08ee6SPaul Brook      debug="yes"
1151f3d08ee6SPaul Brook      strip_opt="no"
1152b553a042SJohn Snow      fortify_source="no"
1153f3d08ee6SPaul Brook  ;;
1154247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1155247724cbSMarc-André Lureau  ;;
1156247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1157247724cbSMarc-André Lureau  ;;
11580aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
11590aebab04SLingfeng Yang  ;;
11600aebab04SLingfeng Yang  --disable-tsan) tsan="no"
11610aebab04SLingfeng Yang  ;;
116203b4fe7dSaliguori  --enable-sparse) sparse="yes"
116303b4fe7dSaliguori  ;;
116403b4fe7dSaliguori  --disable-sparse) sparse="no"
116503b4fe7dSaliguori  ;;
11661625af87Saliguori  --disable-strip) strip_opt="no"
11671625af87Saliguori  ;;
1168a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
11692f9606b3Saliguori  ;;
1170a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1171ea784e3bSJuan Quintela  ;;
1172a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
11732f6f5c7aSCorentin Chary  ;;
1174a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
11752f6f5c7aSCorentin Chary  ;;
1176a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1177efe556adSCorentin Chary  ;;
1178a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1179efe556adSCorentin Chary  ;;
1180443f1376Sbellard  --disable-slirp) slirp="no"
1181c20709aaSbellard  ;;
11827c57bdd8SMarc-André Lureau  --enable-slirp=git) slirp="git"
11837c57bdd8SMarc-André Lureau  ;;
1184675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1185675b9b53SMarc-André Lureau  ;;
1186e0e6c8c0Saliguori  --disable-vde) vde="no"
11878a16d273Sths  ;;
1188dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1189dfb278bdSJuan Quintela  ;;
119058952137SVincenzo Maffione  --disable-netmap) netmap="no"
119158952137SVincenzo Maffione  ;;
119258952137SVincenzo Maffione  --enable-netmap) netmap="yes"
119358952137SVincenzo Maffione  ;;
1194e37630caSaliguori  --disable-xen) xen="no"
1195e37630caSaliguori  ;;
1196fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1197fc321b4bSJuan Quintela  ;;
1198eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1199eb6fda0fSAnthony PERARD  ;;
1200eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1201eb6fda0fSAnthony PERARD  ;;
12022e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
12032e4d9fb1Saurel32  ;;
12044ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
12054ffcedb6SJuan Quintela  ;;
12067ba1e619Saliguori  --disable-kvm) kvm="no"
12077ba1e619Saliguori  ;;
1208b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1209b31a0277SJuan Quintela  ;;
1210b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1211180fb750Szhanghailiang  ;;
1212b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1213180fb750Szhanghailiang  ;;
1214c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1215c97d6d2cSSergio Andres Gomez Del Real  ;;
1216c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1217c97d6d2cSSergio Andres Gomez Del Real  ;;
1218d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1219d661d9a4SJustin Terry (VM)  ;;
1220d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1221d661d9a4SJustin Terry (VM)  ;;
12229195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
12239195b2c2SStefan Weil  ;;
12249195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
12259195b2c2SStefan Weil  ;;
122647e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
122747e98658SCorey Bryant  ;;
122847e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
122947e98658SCorey Bryant  ;;
1230b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1231b3f6ea7eSPaolo Bonzini  ;;
1232b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1233b3f6ea7eSPaolo Bonzini  ;;
12345a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
12355a22ab71SYang Zhong  ;;
12365a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
12375a22ab71SYang Zhong  ;;
1238cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1239cd4ec0b4SGerd Hoffmann  ;;
1240cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1241cd4ec0b4SGerd Hoffmann  ;;
1242c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1243c589b249SRonnie Sahlberg  ;;
1244c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1245c589b249SRonnie Sahlberg  ;;
12466542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
12476542aa9cSPeter Lieven  ;;
12486542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
12496542aa9cSPeter Lieven  ;;
125005c2a3e7Sbellard  --enable-profiler) profiler="yes"
125105c2a3e7Sbellard  ;;
125214821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
125314821030SPavel Borzenkov  ;;
1254c2de5c91Smalc  --enable-cocoa)
1255c2de5c91Smalc      cocoa="yes" ;
125689138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
12575b0753e0Sbellard  ;;
1258cad25d69Spbrook  --disable-system) softmmu="no"
12590a8e90f4Spbrook  ;;
1260cad25d69Spbrook  --enable-system) softmmu="yes"
12610a8e90f4Spbrook  ;;
12620953a80fSZachary Amsden  --disable-user)
12630953a80fSZachary Amsden      linux_user="no" ;
12640953a80fSZachary Amsden      bsd_user="no" ;
12650953a80fSZachary Amsden  ;;
12660953a80fSZachary Amsden  --enable-user) ;;
1267831b7825Sths  --disable-linux-user) linux_user="no"
12680a8e90f4Spbrook  ;;
1269831b7825Sths  --enable-linux-user) linux_user="yes"
1270831b7825Sths  ;;
127184778508Sblueswir1  --disable-bsd-user) bsd_user="no"
127284778508Sblueswir1  ;;
127384778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
127484778508Sblueswir1  ;;
127540d6444eSAvi Kivity  --enable-pie) pie="yes"
127634005a00SKirill A. Shutemov  ;;
127740d6444eSAvi Kivity  --disable-pie) pie="no"
127834005a00SKirill A. Shutemov  ;;
127985aa5189Sbellard  --enable-werror) werror="yes"
128085aa5189Sbellard  ;;
128185aa5189Sbellard  --disable-werror) werror="no"
128285aa5189Sbellard  ;;
128363678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
128463678e17SSteven Noonan  ;;
128563678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
128663678e17SSteven Noonan  ;;
12871e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
12881e4f6065SDaniele Buono  ;;
12891e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
12901e4f6065SDaniele Buono  ;;
12914d3b6f6eSbalrog  --disable-curses) curses="no"
12924d3b6f6eSbalrog  ;;
1293c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1294c584a6d0SJuan Quintela  ;;
1295e08bb301SSamuel Thibault  --disable-iconv) iconv="no"
1296e08bb301SSamuel Thibault  ;;
1297e08bb301SSamuel Thibault  --enable-iconv) iconv="yes"
1298e08bb301SSamuel Thibault  ;;
1299769ce76dSAlexander Graf  --disable-curl) curl="no"
1300769ce76dSAlexander Graf  ;;
1301788c8196SJuan Quintela  --enable-curl) curl="yes"
1302788c8196SJuan Quintela  ;;
13032df87df7SJuan Quintela  --disable-fdt) fdt="no"
13042df87df7SJuan Quintela  ;;
13052df87df7SJuan Quintela  --enable-fdt) fdt="yes"
13062df87df7SJuan Quintela  ;;
13075c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
13085c6c3a6cSChristoph Hellwig  ;;
13095c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
13105c6c3a6cSChristoph Hellwig  ;;
1311c10dd856SAarushi Mehta  --disable-linux-io-uring) linux_io_uring="no"
1312c10dd856SAarushi Mehta  ;;
1313c10dd856SAarushi Mehta  --enable-linux-io-uring) linux_io_uring="yes"
1314c10dd856SAarushi Mehta  ;;
1315758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1316758e8e38SVenkateswararao Jujjuri (JV)  ;;
1317758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1318758e8e38SVenkateswararao Jujjuri (JV)  ;;
1319a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1320a40161cbSPaolo Bonzini  ;;
1321a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1322a40161cbSPaolo Bonzini  ;;
132377755340Sths  --disable-blobs) blobs="no"
132477755340Sths  ;;
13257e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
13264a19f1ecSpbrook  ;;
1327519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1328519175a2SAlex Barcelo  ;;
132970c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
133070c60c08SStefan Hajnoczi  ;;
133170c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
133270c60c08SStefan Hajnoczi  ;;
13337d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
13347d992e4dSPeter Lieven  ;;
1335f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1336f0d92b56SLongpeng(Mike)  ;;
1337f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1338f0d92b56SLongpeng(Mike)  ;;
1339a25dba17SJuan Quintela  --disable-docs) docs="no"
134070ec5dc0SAnthony Liguori  ;;
1341a25dba17SJuan Quintela  --enable-docs) docs="yes"
134283a3ab8bSJuan Quintela  ;;
1343d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1344d5970055SMichael S. Tsirkin  ;;
1345d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1346d5970055SMichael S. Tsirkin  ;;
1347042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1348042cea27SGonglei  ;;
1349299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1350042cea27SGonglei  ;;
13515e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
13525e9be92dSNicholas Bellinger  ;;
13535e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
13545e9be92dSNicholas Bellinger  ;;
1355fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1356fc0b9b0eSStefan Hajnoczi  ;;
1357fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1358fc0b9b0eSStefan Hajnoczi  ;;
135998fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
136098fc1adaSDr. David Alan Gilbert  ;;
136198fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
136298fc1adaSDr. David Alan Gilbert  ;;
1363da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
136420ff075bSMichael Walle  ;;
1365da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
136620ff075bSMichael Walle  ;;
1367f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1368f27aaf4bSChristian Brunner  ;;
1369f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1370f27aaf4bSChristian Brunner  ;;
13718c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
13728c84cf11SSergei Trofimovich  ;;
13738c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
13748c84cf11SSergei Trofimovich  ;;
13757b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1376111a38b0SRobert Relyea  ;;
13777b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1378111a38b0SRobert Relyea  ;;
13790a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
13800a40bcb7SCésar Belley  ;;
13810a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
13820a40bcb7SCésar Belley  ;;
13832b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
13842b2325ffSGerd Hoffmann  ;;
13852b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
13862b2325ffSGerd Hoffmann  ;;
138769354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
138869354a83SHans de Goede  ;;
138969354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
139069354a83SHans de Goede  ;;
13911ffb3bbbSPaolo Bonzini  --disable-zlib-test)
13921ece9905SAlon Levy  ;;
1393b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1394b25c9dffSStefan Weil  ;;
1395607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1396607dacd0Sqiaonuohan  ;;
1397b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1398b25c9dffSStefan Weil  ;;
1399607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1400607dacd0Sqiaonuohan  ;;
14016b383c08SPeter Wu  --disable-bzip2) bzip2="no"
14026b383c08SPeter Wu  ;;
14036b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
14046b383c08SPeter Wu  ;;
140583bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
140683bc1f97SJulio Faracco  ;;
140783bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
140883bc1f97SJulio Faracco  ;;
14093a678481SJuan Quintela  --disable-zstd) zstd="no"
14103a678481SJuan Quintela  ;;
14113a678481SJuan Quintela  --enable-zstd) zstd="yes"
14123a678481SJuan Quintela  ;;
1413d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1414d138cee9SMichael Roth  ;;
1415d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1416d138cee9SMichael Roth  ;;
14179dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
14189dacf32dSYossi Hindin  ;;
14199dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
14209dacf32dSYossi Hindin  ;;
1421d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1422d9840e25STomoki Sekiyama  ;;
1423d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1424d9840e25STomoki Sekiyama  ;;
1425d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1426d9840e25STomoki Sekiyama  ;;
1427d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1428d9840e25STomoki Sekiyama  ;;
1429d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1430d9840e25STomoki Sekiyama  ;;
1431d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1432d9840e25STomoki Sekiyama  ;;
14334b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
14344b1c11fdSDaniel P. Berrange  ;;
14354b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
14364b1c11fdSDaniel P. Berrange  ;;
1437f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1438f794573eSEduardo Otubo  ;;
1439f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1440f794573eSEduardo Otubo  ;;
1441eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1442eb100396SBharata B Rao  ;;
144386583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
144486583a07SLiam Merwick  ;;
144586583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
144686583a07SLiam Merwick  ;;
14476b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
14486b8cd447SRobert Hoo  ;;
14496b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
14506b8cd447SRobert Hoo  ;;
14516b8cd447SRobert Hoo
1452eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1453eb100396SBharata B Rao  ;;
145452b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
145552b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1456583f6e7bSStefan Hajnoczi  ;;
1457cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1458cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1459cb6414dfSFam Zheng  ;;
1460315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1461315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1462315d3184SFam Zheng  ;;
1463a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1464a4ccabcfSAnthony Liguori  ;;
1465a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1466a4ccabcfSAnthony Liguori  ;;
1467a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1468a1c5e949SDaniel P. Berrange  ;;
1469ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1470ddbb0d09SDaniel P. Berrange  ;;
1471ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1472ddbb0d09SDaniel P. Berrange  ;;
147391bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
147491bfcdb0SDaniel P. Berrange  ;;
147591bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
147691bfcdb0SDaniel P. Berrange  ;;
147791bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
147891bfcdb0SDaniel P. Berrange  ;;
147991bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
148091bfcdb0SDaniel P. Berrange  ;;
14818953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
14828953caf3SDaniel P. Berrange  ;;
14838953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
14848953caf3SDaniel P. Berrange  ;;
14852da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
14862da776dbSMichael R. Hines  ;;
14872da776dbSMichael R. Hines  --disable-rdma) rdma="no"
14882da776dbSMichael R. Hines  ;;
148921ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
149021ab34c9SMarcel Apfelbaum  ;;
149121ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
149221ab34c9SMarcel Apfelbaum  ;;
1493bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1494bbbf9bfbSStefan Weil  ;;
1495bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1496bbbf9bfbSStefan Weil  ;;
14979d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
14989d9e1521SGerd Hoffmann  ;;
14999d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
15009d9e1521SGerd Hoffmann  ;;
1501e91c793cSCole Robinson  --disable-tpm) tpm="no"
1502e91c793cSCole Robinson  ;;
1503ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1504ab214c29SStefan Berger  ;;
1505b10d49d7SPino Toscano  --disable-libssh) libssh="no"
15060a12ec87SRichard W.M. Jones  ;;
1507b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
15080a12ec87SRichard W.M. Jones  ;;
1509ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1510ed1701c6SDr. David Alan Gilbert  ;;
1511ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1512ed1701c6SDr. David Alan Gilbert  ;;
1513a99d57bbSWanlong Gao  --disable-numa) numa="no"
1514a99d57bbSWanlong Gao  ;;
1515a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1516a99d57bbSWanlong Gao  ;;
1517ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1518ed279a06SKlim Kireev  ;;
1519ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1520ed279a06SKlim Kireev  ;;
15212847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
15222847b469SFam Zheng  ;;
15232847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
15242847b469SFam Zheng  ;;
15257b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
15267b01cb97SAlexandre Derumier  ;;
15277b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
15287b01cb97SAlexandre Derumier  ;;
1529a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1530a6b1d4c0SChanglong Xie  ;;
1531a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1532a6b1d4c0SChanglong Xie  ;;
15332f740136SJeff Cody  --disable-bochs) bochs="no"
15342f740136SJeff Cody  ;;
15352f740136SJeff Cody  --enable-bochs) bochs="yes"
15362f740136SJeff Cody  ;;
15372f740136SJeff Cody  --disable-cloop) cloop="no"
15382f740136SJeff Cody  ;;
15392f740136SJeff Cody  --enable-cloop) cloop="yes"
15402f740136SJeff Cody  ;;
15412f740136SJeff Cody  --disable-dmg) dmg="no"
15422f740136SJeff Cody  ;;
15432f740136SJeff Cody  --enable-dmg) dmg="yes"
15442f740136SJeff Cody  ;;
15452f740136SJeff Cody  --disable-qcow1) qcow1="no"
15462f740136SJeff Cody  ;;
15472f740136SJeff Cody  --enable-qcow1) qcow1="yes"
15482f740136SJeff Cody  ;;
15492f740136SJeff Cody  --disable-vdi) vdi="no"
15502f740136SJeff Cody  ;;
15512f740136SJeff Cody  --enable-vdi) vdi="yes"
15522f740136SJeff Cody  ;;
15532f740136SJeff Cody  --disable-vvfat) vvfat="no"
15542f740136SJeff Cody  ;;
15552f740136SJeff Cody  --enable-vvfat) vvfat="yes"
15562f740136SJeff Cody  ;;
15572f740136SJeff Cody  --disable-qed) qed="no"
15582f740136SJeff Cody  ;;
15592f740136SJeff Cody  --enable-qed) qed="yes"
15602f740136SJeff Cody  ;;
15612f740136SJeff Cody  --disable-parallels) parallels="no"
15622f740136SJeff Cody  ;;
15632f740136SJeff Cody  --enable-parallels) parallels="yes"
15642f740136SJeff Cody  ;;
15652f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
15662f740136SJeff Cody  ;;
15672f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
15682f740136SJeff Cody  ;;
1569e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1570e6a74868SMarc-André Lureau  ;;
1571299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1572299e6f19SPaolo Bonzini  ;;
1573108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1574108a6481SCindy Lu  ;;
1575108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1576108a6481SCindy Lu  ;;
1577299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1578299e6f19SPaolo Bonzini  ;;
1579299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1580e6a74868SMarc-André Lureau  ;;
15818ca80760SRichard Henderson  --disable-capstone) capstone="no"
15828ca80760SRichard Henderson  ;;
15838ca80760SRichard Henderson  --enable-capstone) capstone="yes"
15848ca80760SRichard Henderson  ;;
1585e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1586e219c499SRichard Henderson  ;;
1587e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1588e219c499SRichard Henderson  ;;
1589cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1590cc84d63aSDaniel P. Berrange  ;;
1591f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1592f62bbee5SDaniel P. Berrange  ;;
1593f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1594f62bbee5SDaniel P. Berrange  ;;
1595ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1596ba59fb77SPaolo Bonzini  ;;
1597ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1598ba59fb77SPaolo Bonzini  ;;
159917824406SJunyan He  --enable-libpmem) libpmem=yes
160017824406SJunyan He  ;;
160117824406SJunyan He  --disable-libpmem) libpmem=no
160217824406SJunyan He  ;;
16034113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
160475411919SJames Le Cuirot  ;;
16054113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
160675411919SJames Le Cuirot  ;;
160740e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
160840e8c6f4SAlex Bennée  ;;
160940e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
161040e8c6f4SAlex Bennée  ;;
1611afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1612afc3a8f9SAlex Bennée  ;;
1613afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1614afc3a8f9SAlex Bennée  ;;
1615adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1616adc28027SAlexander Bulekov  ;;
1617adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1618adc28027SAlexander Bulekov  ;;
1619f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1620f48e590aSAlex Bennée  ;;
1621b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1622b767d257SMarek Marczykowski-Górecki  ;;
1623b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1624b767d257SMarek Marczykowski-Górecki  ;;
162554e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
162654e7aac0SAlexey Krasikov  ;;
162754e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
162854e7aac0SAlexey Krasikov  ;;
162921b2eca6SJingqi Liu  --enable-libdaxctl) libdaxctl=yes
163021b2eca6SJingqi Liu  ;;
163121b2eca6SJingqi Liu  --disable-libdaxctl) libdaxctl=no
163221b2eca6SJingqi Liu  ;;
16332d2ad6d0SFam Zheng  *)
16342d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
16352d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
16362d2ad6d0SFam Zheng      exit 1
16377f1559c6Sbalrog  ;;
16387d13299dSbellard  esac
16397d13299dSbellarddone
16407d13299dSbellard
164187727cb1SPaolo Bonzinifirmwarepath="${firmwarepath:-$prefix/share/qemu-firmware}"
164222a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
164322a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
164422a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
164522a87800SMarc-André Lureau
164622a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
164722a87800SMarc-André Lureau    mandir="$prefix"
164822a87800SMarc-André Lureau    datadir="$prefix"
1649ca8c0909SMarc-André Lureau    docdir="$prefix"
165022a87800SMarc-André Lureau    bindir="$prefix"
165122a87800SMarc-André Lureau    sysconfdir="$prefix"
165222a87800SMarc-André Lureau    local_statedir=
165322a87800SMarc-André Lureauelse
165422a87800SMarc-André Lureau    mandir="${mandir:-$prefix/share/man}"
165522a87800SMarc-André Lureau    datadir="${datadir:-$prefix/share}"
1656ca8c0909SMarc-André Lureau    docdir="${docdir:-$prefix/share/doc}"
165722a87800SMarc-André Lureau    bindir="${bindir:-$prefix/bin}"
165822a87800SMarc-André Lureau    sysconfdir="${sysconfdir:-$prefix/etc}"
165922a87800SMarc-André Lureau    local_statedir="${local_statedir:-$prefix/var}"
166022a87800SMarc-André Lureaufi
166122a87800SMarc-André Lureau
166240293e58Sbellardcase "$cpu" in
1663e3608d66SRichard Henderson    ppc)
1664e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1665db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1666e3608d66SRichard Henderson           ;;
1667e3608d66SRichard Henderson    ppc64)
1668e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1669db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1670e3608d66SRichard Henderson           ;;
16719b9c37c3SRichard Henderson    sparc)
1672f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1673db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
16743142255cSblueswir1           ;;
1675ed968ff1SJuan Quintela    sparc64)
167679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1677db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
16783142255cSblueswir1           ;;
167976d83bdeSths    s390)
1680061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1681db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
168228d7cc49SRichard Henderson           ;;
168328d7cc49SRichard Henderson    s390x)
1684061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1685db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
168676d83bdeSths           ;;
168740293e58Sbellard    i386)
168879f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1689db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
169040293e58Sbellard           ;;
169140293e58Sbellard    x86_64)
16927ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
16937ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
16947ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
16957ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1696db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1697379f6698SPaul Brook           ;;
1698c72b26ecSRichard Henderson    x32)
1699c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1700db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1701c72b26ecSRichard Henderson           ;;
170230163d89SPeter Maydell    # No special flags required for other host CPUs
17033142255cSblueswir1esac
17043142255cSblueswir1
17052038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
17062038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
170779f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
170879f3b12fSPeter Crosthwaite
1709affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1710affc88ccSPeter Maydell# support, even if we're using TCI.
1711affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1712affc88ccSPeter Maydell  bsd_user="no"
1713affc88ccSPeter Maydell  linux_user="no"
1714affc88ccSPeter Maydellfi
1715affc88ccSPeter Maydell
17161cf295beSPhilippe Mathieu-Daudéif [ "$bsd_user" = "no" -a "$linux_user" = "no" -a "$softmmu" = "no" ] ; then
17171cf295beSPhilippe Mathieu-Daudé  tcg="no"
17181cf295beSPhilippe Mathieu-Daudéfi
17191cf295beSPhilippe Mathieu-Daudé
172060e0df25SPeter Maydelldefault_target_list=""
172160e0df25SPeter Maydell
17226e92f823SPeter Maydellmak_wilds=""
17236e92f823SPeter Maydell
172460e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
17256e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
172660e0df25SPeter Maydellfi
172760e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
17286e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
172960e0df25SPeter Maydellfi
173060e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
17316e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
173260e0df25SPeter Maydellfi
173360e0df25SPeter Maydell
1734447e133fSAlex Bennéeif test -z "$target_list_exclude"; then
17356e92f823SPeter Maydell    for config in $mak_wilds; do
17366e92f823SPeter Maydell        default_target_list="${default_target_list} $(basename "$config" .mak)"
17376e92f823SPeter Maydell    done
1738447e133fSAlex Bennéeelse
1739447e133fSAlex Bennée    exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1740447e133fSAlex Bennée    for config in $mak_wilds; do
1741447e133fSAlex Bennée        target="$(basename "$config" .mak)"
1742447e133fSAlex Bennée        exclude="no"
1743447e133fSAlex Bennée        for excl in $exclude_list; do
1744447e133fSAlex Bennée            if test "$excl" = "$target"; then
1745447e133fSAlex Bennée                exclude="yes"
1746447e133fSAlex Bennée                break;
1747447e133fSAlex Bennée            fi
1748447e133fSAlex Bennée        done
1749447e133fSAlex Bennée        if test "$exclude" = "no"; then
1750447e133fSAlex Bennée            default_target_list="${default_target_list} $target"
1751447e133fSAlex Bennée        fi
1752447e133fSAlex Bennée    done
1753447e133fSAlex Bennéefi
17546e92f823SPeter Maydell
1755c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
175664a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1757c53eeaf7SStefan Hajnoczi
1758af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1759af5db58eSpbrookcat << EOF
1760af5db58eSpbrook
1761af5db58eSpbrookUsage: configure [options]
1762af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1763af5db58eSpbrook
176408fb77edSStefan WeilStandard options:
176508fb77edSStefan Weil  --help                   print this message
176608fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
176708fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
176808fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
176908fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
177008fb77edSStefan Weil$(echo Available targets: $default_target_list | \
177108fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
1772447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
177308fb77edSStefan Weil
177408fb77edSStefan WeilAdvanced options (experts only):
177508fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
177608fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
177708fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
177808fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
177908fb77edSStefan Weil                           build time
178008fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
178108fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
178208fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
178311cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
178408fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1785d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1786d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
178708fb77edSStefan Weil  --make=MAKE              use specified make [$make]
178808fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
17892eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1790a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
179148328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
179208fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1793db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
179408fb77edSStefan Weil  --static                 enable static build [$static]
179508fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
179610ff82d1SMarc-André Lureau  --datadir=PATH           install firmware in PATH/$qemu_suffix
179710ff82d1SMarc-André Lureau  --docdir=PATH            install documentation in PATH/$qemu_suffix
179808fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
179908fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1800db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
180110ff82d1SMarc-André Lureau  --sysconfdir=PATH        install config in PATH/$qemu_suffix
180208fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
18033d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
180413336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1805ca8c0909SMarc-André Lureau  --with-suffix=SUFFIX     suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
1806db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
180708fb77edSStefan Weil  --enable-debug           enable common debug build options
1808247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
18090aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
181008fb77edSStefan Weil  --disable-strip          disable stripping binaries
181108fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
181263678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
181308fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
181408fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
181508fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
181608fb77edSStefan Weil  --block-drv-rw-whitelist=L
181708fb77edSStefan Weil                           set block driver read-write whitelist
181808fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
181908fb77edSStefan Weil  --block-drv-ro-whitelist=L
182008fb77edSStefan Weil                           set block driver read-only whitelist
182108fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
18225b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1823c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
182408fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
182508fb77edSStefan Weil                           Default:trace-<pid>
1826c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1827c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
18285a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1829c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1830c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
183108fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
183233c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
183308fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1834c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1835c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1836c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1837a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1838c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1839c12d66aaSLin Ma  --enable-profiler        profiler support
1840c12d66aaSLin Ma  --enable-debug-stack-usage
1841c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
184240e8c6f4SAlex Bennée  --enable-plugins
184340e8c6f4SAlex Bennée                           enable plugins via shared library loading
1844afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1845f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1846c23f23b9SMichael Tokarev
1847c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1848c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1849c23f23b9SMichael Tokarev
1850c23f23b9SMichael Tokarev  system          all system emulation targets
1851c23f23b9SMichael Tokarev  user            supported user emulation targets
1852c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1853c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1854c23f23b9SMichael Tokarev  docs            build documentation
1855c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1856c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1857c23f23b9SMichael Tokarev  pie             Position Independent Executables
185821e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1859bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1860c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1861c23f23b9SMichael Tokarev  debug-info      debugging information
1862c23f23b9SMichael Tokarev  sparse          sparse checker
18631e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18641e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
1865c23f23b9SMichael Tokarev
1866ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
186791bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
186891bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18698953caf3SDaniel P. Berrange  auth-pam        PAM access control
1870c23f23b9SMichael Tokarev  sdl             SDL UI
187104c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1872c23f23b9SMichael Tokarev  gtk             gtk UI
1873c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1874c23f23b9SMichael Tokarev  curses          curses UI
1875e08bb301SSamuel Thibault  iconv           font glyph conversion support
1876c23f23b9SMichael Tokarev  vnc             VNC UI support
1877c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1878c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1879c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1880c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1881c23f23b9SMichael Tokarev  virtfs          VirtFS
1882fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1883c23f23b9SMichael Tokarev  xen             xen backend driver support
188470c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1885c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1886c23f23b9SMichael Tokarev  curl            curl connectivity
1887a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1888c23f23b9SMichael Tokarev  fdt             fdt device tree
1889c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1890b0cb0a66SVincent Palatin  hax             HAX acceleration support
1891c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1892d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
189321ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
189421ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1895c23f23b9SMichael Tokarev  vde             support for vde network
1896c23f23b9SMichael Tokarev  netmap          support for netmap network
1897c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1898c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1899c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1900c23f23b9SMichael Tokarev  attr            attr and xattr support
1901299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1902299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1903299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1904299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1905299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1906299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1907108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
1908c23f23b9SMichael Tokarev  spice           spice
1909c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1910c23f23b9SMichael Tokarev  libiscsi        iscsi support
1911c23f23b9SMichael Tokarev  libnfs          nfs support
19127b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
19130a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1914c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1915ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1916c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1917c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1918c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1919c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1920c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
192183bc1f97SJulio Faracco  lzfse           support of lzfse compression library
192283bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
19233a678481SJuan Quintela  zstd            support for zstd compression library
1924d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1925c23f23b9SMichael Tokarev  seccomp         seccomp support
1926c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1927c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1928c23f23b9SMichael Tokarev  tpm             TPM support
1929b10d49d7SPino Toscano  libssh          ssh block device support
1930c23f23b9SMichael Tokarev  numa            libnuma support
1931ed279a06SKlim Kireev  libxml2         for Parallels image format
1932c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19337b01cb97SAlexandre Derumier  jemalloc        jemalloc support
193486583a07SLiam Merwick  avx2            AVX2 optimization support
19356b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1936a6b1d4c0SChanglong Xie  replication     replication support
1937c12d66aaSLin Ma  opengl          opengl support
1938c12d66aaSLin Ma  virglrenderer   virgl rendering support
1939c12d66aaSLin Ma  xfsctl          xfsctl support
1940c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19418de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19422f740136SJeff Cody  bochs           bochs image format support
19432f740136SJeff Cody  cloop           cloop image format support
19442f740136SJeff Cody  dmg             dmg image format support
19452f740136SJeff Cody  qcow1           qcow v1 image format support
19462f740136SJeff Cody  vdi             vdi image format support
19472f740136SJeff Cody  vvfat           vvfat image format support
19482f740136SJeff Cody  qed             qed image format support
19492f740136SJeff Cody  parallels       parallels image format support
19502f740136SJeff Cody  sheepdog        sheepdog block driver support
1951f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19528ca80760SRichard Henderson  capstone        capstone disassembler support
1953ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
195417824406SJunyan He  libpmem         libpmem support
195575411919SJames Le Cuirot  xkbcommon       xkbcommon support
1956b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
195721b2eca6SJingqi Liu  libdaxctl       libdaxctl support
195808fb77edSStefan Weil
195908fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1960af5db58eSpbrookEOF
19612d2ad6d0SFam Zhengexit 0
1962af5db58eSpbrookfi
1963af5db58eSpbrook
19649c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1965bb768f71SThomas Huthrm -f */config-devices.mak.d
19669c790242SThomas Huth
1967faf44142SDaniel P. Berrangéif test -z "$python"
1968faf44142SDaniel P. Berrangéthen
1969c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
1970c53eeaf7SStefan Hajnoczifi
1971c53eeaf7SStefan Hajnoczi
1972c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
1973c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
1974ddf90699SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (3,5))'; then
1975ddf90699SEduardo Habkost  error_exit "Cannot use '$python', Python >= 3.5 is required." \
1976c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
1977c53eeaf7SStefan Hajnoczifi
1978c53eeaf7SStefan Hajnoczi
1979755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
1980406ab2f3SCleber 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)
1981755ee70fSCleber Rosa
1982c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
1983c53eeaf7SStefan Hajnoczipython="$python -B"
1984c53eeaf7SStefan Hajnoczi
19850a01d76fSMarc-André Lureauif test -z "$meson"; then
198646504430SPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.1; then
19870a01d76fSMarc-André Lureau        meson=meson
19880a01d76fSMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
19890a01d76fSMarc-André Lureau        meson=git
19900a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
19910a01d76fSMarc-André Lureau        meson=internal
19920a01d76fSMarc-André Lureau    else
19930a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
19940a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
19950a01d76fSMarc-André Lureau        else
1996a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
1997a5665051SPaolo Bonzini        fi
19980a01d76fSMarc-André Lureau    fi
19990a01d76fSMarc-André Lureauelse
20000a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
20010a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
20020a01d76fSMarc-André Lureau    #
20030a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
20040a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
20050a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
20060a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
20070a01d76fSMarc-André Lureau        case "$meson" in
20080a01d76fSMarc-André Lureau            git | internal) ;;
20090a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
20100a01d76fSMarc-André Lureau        esac
20110a01d76fSMarc-André Lureau    fi
20120a01d76fSMarc-André Lureaufi
2013a5665051SPaolo Bonzini
20140a01d76fSMarc-André Lureauif test "$meson" = git; then
20150a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
20160a01d76fSMarc-André Lureaufi
20170a01d76fSMarc-André Lureauif test "$git_update" = yes; then
20180a01d76fSMarc-André Lureau    (cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
20190a01d76fSMarc-André Lureaufi
20200a01d76fSMarc-André Lureau
20210a01d76fSMarc-André Lureaucase "$meson" in
20220a01d76fSMarc-André Lureau    git | internal)
2023a5665051SPaolo Bonzini        if ! $python -c 'import pkg_resources' > /dev/null 2>&1; then
2024a5665051SPaolo Bonzini            error_exit "Python setuptools not found"
2025a5665051SPaolo Bonzini        fi
20260a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20270a01d76fSMarc-André Lureau        ;;
20280a01d76fSMarc-André Lureau    *) meson=$(command -v meson) ;;
20290a01d76fSMarc-André Lureauesac
20300a01d76fSMarc-André Lureau
203148328880SPaolo Bonzini# Probe for ninja (used for compdb)
203248328880SPaolo Bonzini
203348328880SPaolo Bonziniif test -z "$ninja"; then
203448328880SPaolo Bonzini    for c in ninja ninja-build samu; do
203548328880SPaolo Bonzini        if has $c; then
203648328880SPaolo Bonzini            ninja=$(command -v "$c")
203748328880SPaolo Bonzini            break
203848328880SPaolo Bonzini        fi
203948328880SPaolo Bonzini    done
204048328880SPaolo Bonzinifi
2041a5665051SPaolo Bonzini
20429aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20439aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20449aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20459aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20469aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20479aae6e54SDaniel Henrique Barbozaif compile_object ; then
20489aae6e54SDaniel Henrique Barboza  : C compiler works ok
20499aae6e54SDaniel Henrique Barbozaelse
20509aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20519aae6e54SDaniel Henrique Barbozafi
20529aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20539aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20549aae6e54SDaniel Henrique Barbozafi
20559aae6e54SDaniel Henrique Barboza
2056359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
2057359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
2058359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
2059359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
2060359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
2061359bc95dSPeter Maydell    else
206276ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
2063359bc95dSPeter Maydell    fi
2064359bc95dSPeter Maydellfi
2065359bc95dSPeter Maydell
20669c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20679c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
20689c83ffd8SPeter Maydellif test -z "$werror" ; then
2069fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
2070e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
20719c83ffd8SPeter Maydell        werror="yes"
20729c83ffd8SPeter Maydell    else
20739c83ffd8SPeter Maydell        werror="no"
20749c83ffd8SPeter Maydell    fi
20759c83ffd8SPeter Maydellfi
20769c83ffd8SPeter Maydell
2077fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
2078fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2079fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2080fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2081fb59dabdSPeter Maydell    # host OS we should stop now.
2082951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2083fb59dabdSPeter Maydellfi
2084fb59dabdSPeter Maydell
2085efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2086efc6c070SThomas Huthcat > $TMPC << EOF
2087efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2088efc6c070SThomas Huth# ifdef __apple_build_version__
2089efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
2090efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
2091efc6c070SThomas Huth#  endif
2092efc6c070SThomas Huth# else
2093efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
2094efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
2095efc6c070SThomas Huth#  endif
2096efc6c070SThomas Huth# endif
2097efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2098efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
2099efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
2100efc6c070SThomas Huth# endif
2101efc6c070SThomas Huth#else
2102efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2103efc6c070SThomas Huth#endif
2104efc6c070SThomas Huthint main (void) { return 0; }
2105efc6c070SThomas HuthEOF
2106efc6c070SThomas Huthif ! compile_prog "" "" ; then
2107efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2108efc6c070SThomas Huthfi
2109efc6c070SThomas Huth
211000849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
211100849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
211200849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
211300849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
211400849b92SRichard Henderson# just silently disable some features, so it's too error prone.
211500849b92SRichard Henderson
211600849b92SRichard Hendersonwarn_flags=
211700849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
211800849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
211900849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
212000849b92SRichard Hendersonadd_to warn_flags -Wformat-security
212100849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
212200849b92SRichard Hendersonadd_to warn_flags -Winit-self
212300849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
212400849b92SRichard Hendersonadd_to warn_flags -Wempty-body
212500849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
212600849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
212700849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
212800849b92SRichard Henderson
212900849b92SRichard Hendersonnowarn_flags=
213000849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
213100849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
213200849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
213300849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
213400849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2135aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2136bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
213700849b92SRichard Henderson
213800849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
213993b25869SJohn Snow
214093b25869SJohn Snowcc_has_warning_flag() {
214193b25869SJohn Snow    write_c_skeleton;
214293b25869SJohn Snow
2143a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2144a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2145a1d29d6cSPeter Maydell    # warning options).
214693b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
214793b25869SJohn Snow    compile_prog "-Werror $optflag" ""
214893b25869SJohn Snow}
214993b25869SJohn Snow
215093b25869SJohn Snowfor flag in $gcc_flags; do
215193b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21528d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21538d05095cSPaolo Bonzini    fi
21548d05095cSPaolo Bonzinidone
21558d05095cSPaolo Bonzini
215663678e17SSteven Noonanif test "$stack_protector" != "no"; then
2157fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2158fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2159fccd35a0SRodrigo Rebello{
2160fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2161fccd35a0SRodrigo Rebello    while (*c) {
2162fccd35a0SRodrigo Rebello        *p++ = *c++;
2163fccd35a0SRodrigo Rebello    }
2164fccd35a0SRodrigo Rebello    return 0;
2165fccd35a0SRodrigo Rebello}
2166fccd35a0SRodrigo RebelloEOF
216763678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
21683b463a3fSMiroslav Rezanina  sp_on=0
216963678e17SSteven Noonan  for flag in $gcc_flags; do
2170590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2171590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2172086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2173590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
217463678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2175db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
21763b463a3fSMiroslav Rezanina      sp_on=1
217763678e17SSteven Noonan      break
217863678e17SSteven Noonan    fi
217963678e17SSteven Noonan  done
21803b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
21813b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
21823b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
21833b463a3fSMiroslav Rezanina    fi
21843b463a3fSMiroslav Rezanina  fi
218537746c5eSMarc-André Lureaufi
218637746c5eSMarc-André Lureau
218720bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
218820bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
218920bc94a2SPaolo Bonzinicat > $TMPC << EOF
219020bc94a2SPaolo Bonzinistruct {
219120bc94a2SPaolo Bonzini  int a[2];
219220bc94a2SPaolo Bonzini} x = {0};
219320bc94a2SPaolo BonziniEOF
219420bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
219520bc94a2SPaolo Bonzini  :
219620bc94a2SPaolo Bonzinielse
219720bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
219820bc94a2SPaolo Bonzinifi
219920bc94a2SPaolo Bonzini
220021e709aaSMarc-André Lureau# Our module code doesn't support Windows
220121e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
220221e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
220321e709aaSMarc-André Lureaufi
220421e709aaSMarc-André Lureau
2205bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2206bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2207bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2208bd83c861SChristian Ehrhardtfi
2209bd83c861SChristian Ehrhardt
2210d376e9deSThomas Huth# Static linking is not possible with modules or PIE
221140d6444eSAvi Kivityif test "$static" = "yes" ; then
2212aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2213aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2214aa0d1f44SPaolo Bonzini  fi
221540d6444eSAvi Kivityfi
221640d6444eSAvi Kivity
2217768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2218768b7855SEmilio G. Cota  cat > $TMPC << EOF
2219768b7855SEmilio G. Cotastatic __thread int tls_var;
2220768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2221768b7855SEmilio G. CotaEOF
2222768b7855SEmilio G. Cota
2223768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2224768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2225768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2226768b7855SEmilio G. Cotafi
2227768b7855SEmilio G. Cota
222840d6444eSAvi Kivitycat > $TMPC << EOF
222921d4a791SAvi Kivity
223021d4a791SAvi Kivity#ifdef __linux__
223121d4a791SAvi Kivity#  define THREAD __thread
223221d4a791SAvi Kivity#else
223321d4a791SAvi Kivity#  define THREAD
223421d4a791SAvi Kivity#endif
223521d4a791SAvi Kivitystatic THREAD int tls_var;
223621d4a791SAvi Kivityint main(void) { return tls_var; }
223740d6444eSAvi KivityEOF
2238b2634124SRichard Henderson
2239b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2240412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2241412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2242b2634124SRichard Henderson  LDFLAGS_NOPIE="-no-pie"
2243412aeacdSAlex Bennéefi
2244412aeacdSAlex Bennée
224512781462SRichard Hendersonif test "$static" = "yes"; then
2246eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
2247086d5f75SPaolo Bonzini    CFLAGS="-fPIE -DPIE $CFLAGS"
224812781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
224912781462SRichard Henderson    pie="yes"
225012781462SRichard Henderson  elif test "$pie" = "yes"; then
225112781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
225212781462SRichard Henderson  else
225312781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
225412781462SRichard Henderson    pie="no"
225512781462SRichard Henderson  fi
225612781462SRichard Hendersonelif test "$pie" = "no"; then
2257086d5f75SPaolo Bonzini  CFLAGS="$CFLAGS_NOPIE $CFLAGS"
2258086d5f75SPaolo Bonzini  LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
2259eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
2260086d5f75SPaolo Bonzini  CFLAGS="-fPIE -DPIE $CFLAGS"
2261086d5f75SPaolo Bonzini  LDFLAGS="-pie $LDFLAGS"
226240d6444eSAvi Kivity  pie="yes"
22632c674109SRichard Hendersonelif test "$pie" = "yes"; then
226476ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
226540d6444eSAvi Kivityelse
226640d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
226740d6444eSAvi Kivity  pie="no"
226840d6444eSAvi Kivityfi
226940d6444eSAvi Kivity
2270e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2271e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2272e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2273e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2274e6cbd751SRichard Hendersonfi
2275e6cbd751SRichard Henderson
227609dada40SPaolo Bonzini##########################################
227709dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
227809dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
227909dada40SPaolo Bonzini# specification is necessary
228009dada40SPaolo Bonzini
228109dada40SPaolo Bonziniif test "$cpu" = "i386"; then
228209dada40SPaolo Bonzini  cat > $TMPC << EOF
228309dada40SPaolo Bonzinistatic int sfaa(int *ptr)
228409dada40SPaolo Bonzini{
228509dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
228609dada40SPaolo Bonzini}
228709dada40SPaolo Bonzini
228809dada40SPaolo Bonziniint main(void)
228909dada40SPaolo Bonzini{
229009dada40SPaolo Bonzini  int val = 42;
22911405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
229209dada40SPaolo Bonzini  sfaa(&val);
229309dada40SPaolo Bonzini  return val;
229409dada40SPaolo Bonzini}
229509dada40SPaolo BonziniEOF
229609dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
229709dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
229809dada40SPaolo Bonzini  fi
229909dada40SPaolo Bonzinifi
230009dada40SPaolo Bonzini
230109dada40SPaolo Bonzini#########################################
2302ec530c81Sbellard# Solaris specific configure tool chain decisions
230309dada40SPaolo Bonzini
2304ec530c81Sbellardif test "$solaris" = "yes" ; then
23056792aa11SLoïc Minier  if has ar; then
23066792aa11SLoïc Minier    :
23076792aa11SLoïc Minier  else
2308ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
230976ad07a4SPeter Maydell      error_exit "No path includes ar" \
231076ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2311ec530c81Sbellard    fi
231276ad07a4SPeter Maydell    error_exit "No path includes ar"
2313ec530c81Sbellard  fi
2314ec530c81Sbellardfi
2315ec530c81Sbellard
2316afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2317d880a3baSPaolo Bonzini    for target in $default_target_list; do
2318d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2319d880a3baSPaolo Bonzini            target_list="$target_list $target"
2320d880a3baSPaolo Bonzini    done
2321d880a3baSPaolo Bonzini    target_list="${target_list# }"
2322121afa9eSAnthony Liguorielse
232389138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2324d880a3baSPaolo Bonzini    for target in $target_list; do
232525b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
232625b48338SPeter Maydell        # friendly error message than if we let it fall through.
232725b48338SPeter Maydell        case " $default_target_list " in
232825b48338SPeter Maydell            *" $target "*)
232925b48338SPeter Maydell                ;;
233025b48338SPeter Maydell            *)
233125b48338SPeter Maydell                error_exit "Unknown target name '$target'"
233225b48338SPeter Maydell                ;;
233325b48338SPeter Maydell        esac
2334d880a3baSPaolo Bonzini        supported_target $target || exit 1
233525b48338SPeter Maydell    done
2336d880a3baSPaolo Bonzinifi
233725b48338SPeter Maydell
2338f55fe278SPaolo Bonzini# see if system emulation was really requested
2339f55fe278SPaolo Bonzinicase " $target_list " in
2340f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2341f55fe278SPaolo Bonzini  ;;
2342f55fe278SPaolo Bonzini  *) softmmu=no
2343f55fe278SPaolo Bonzini  ;;
2344f55fe278SPaolo Bonziniesac
23455327cf48Sbellard
234605dfa22bSPhilippe Mathieu-Daudéfor target in $target_list; do
234705dfa22bSPhilippe Mathieu-Daudé  case "$target" in
234805dfa22bSPhilippe Mathieu-Daudé    arm-softmmu | aarch64-softmmu | i386-softmmu | x86_64-softmmu)
234905dfa22bSPhilippe Mathieu-Daudé      edk2_blobs="yes"
235005dfa22bSPhilippe Mathieu-Daudé      ;;
235105dfa22bSPhilippe Mathieu-Daudé  esac
235205dfa22bSPhilippe Mathieu-Daudédone
2353623ef637SPhilippe Mathieu-Daudé# The EDK2 binaries are compressed with bzip2
2354623ef637SPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" && ! has bzip2; then
2355623ef637SPhilippe Mathieu-Daudé  error_exit "The bzip2 program is required for building QEMU"
2356623ef637SPhilippe Mathieu-Daudéfi
235705dfa22bSPhilippe Mathieu-Daudé
2358249247c9SJuan Quintelafeature_not_found() {
2359249247c9SJuan Quintela  feature=$1
236021684af0SStewart Smith  remedy=$2
2361249247c9SJuan Quintela
236276ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
236321684af0SStewart Smith      "configure was not able to find it." \
236421684af0SStewart Smith      "$remedy"
2365249247c9SJuan Quintela}
2366249247c9SJuan Quintela
23677d13299dSbellard# ---
23687d13299dSbellard# big/little endian test
23697d13299dSbellardcat > $TMPC << EOF
237061cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
237161cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
237261cc919fSMike Frysingerextern int foo(short *, short *);
237361cc919fSMike Frysingerint main(int argc, char *argv[]) {
237461cc919fSMike Frysinger    return foo(big_endian, little_endian);
23757d13299dSbellard}
23767d13299dSbellardEOF
23777d13299dSbellard
237861cc919fSMike Frysingerif compile_object ; then
237912f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
238061cc919fSMike Frysinger        bigendian="yes"
238112f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
238261cc919fSMike Frysinger        bigendian="no"
23837d13299dSbellard    else
23847d13299dSbellard        echo big/little test failed
23857d13299dSbellard    fi
23867d13299dSbellardelse
238761cc919fSMike Frysinger    echo big/little test failed
23887d13299dSbellardfi
23897d13299dSbellard
2390b0a47e79SJuan Quintela##########################################
2391e10ee3f5SPhilippe Mathieu-Daudé# system tools
2392e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2393e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2394e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2395e10ee3f5SPhilippe Mathieu-Daudé    else
2396e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2397e10ee3f5SPhilippe Mathieu-Daudé    fi
2398e10ee3f5SPhilippe Mathieu-Daudéfi
2399e10ee3f5SPhilippe Mathieu-Daudé
2400e10ee3f5SPhilippe Mathieu-Daudé##########################################
2401a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2402a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2403a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2404a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2405a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2406a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2407a30878e7SPeter Maydell    fi
2408a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2409a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2410a30878e7SPeter Maydell    fi
2411a30878e7SPeter Maydell    gtk=no
241235be72baSPaolo Bonzini    sdl=disabled
2413a30878e7SPeter Maydellfi
2414a30878e7SPeter Maydell
24156b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
24166b39b063SEric Blakecat > $TMPC << EOF
24176b39b063SEric Blake#include <stdint.h>
24186b39b063SEric Blake#include <stdio.h>
24196b39b063SEric Blakeint main(int argc, char *argv[]) {
24206b39b063SEric Blake    return printf("%zu", SIZE_MAX);
24216b39b063SEric Blake}
24226b39b063SEric BlakeEOF
24236b39b063SEric Blakehave_broken_size_max=no
24246b39b063SEric Blakeif ! compile_object -Werror ; then
24256b39b063SEric Blake    have_broken_size_max=yes
24266b39b063SEric Blakefi
24276b39b063SEric Blake
2428a30878e7SPeter Maydell##########################################
2429015a33bdSGonglei# L2TPV3 probe
2430015a33bdSGonglei
2431015a33bdSGongleicat > $TMPC <<EOF
2432015a33bdSGonglei#include <sys/socket.h>
2433bff6cb72SMichael Tokarev#include <linux/ip.h>
2434015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2435015a33bdSGongleiEOF
2436015a33bdSGongleiif compile_prog "" "" ; then
2437015a33bdSGonglei  l2tpv3=yes
2438015a33bdSGongleielse
2439015a33bdSGonglei  l2tpv3=no
2440015a33bdSGongleifi
2441015a33bdSGonglei
2442c9c8b88fSDavid CARLIERif check_include "pty.h" ; then
2443c9c8b88fSDavid CARLIER  pty_h=yes
2444c9c8b88fSDavid CARLIERelse
2445c9c8b88fSDavid CARLIER  pty_h=no
2446c9c8b88fSDavid CARLIERfi
2447c9c8b88fSDavid CARLIER
2448195588ccSDavid CARLIERcat > $TMPC <<EOF
2449195588ccSDavid CARLIER#include <sys/mman.h>
2450195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2451195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2452195588ccSDavid CARLIER}
2453195588ccSDavid CARLIEREOF
2454195588ccSDavid CARLIERif compile_prog "" "" ; then
2455195588ccSDavid CARLIER  have_mlockall=yes
2456195588ccSDavid CARLIERelse
2457195588ccSDavid CARLIER  have_mlockall=no
2458195588ccSDavid CARLIERfi
2459195588ccSDavid CARLIER
2460299e6f19SPaolo Bonzini#########################################
2461299e6f19SPaolo Bonzini# vhost interdependencies and host support
2462299e6f19SPaolo Bonzini
2463299e6f19SPaolo Bonzini# vhost backends
2464299e6f19SPaolo Bonzinitest "$vhost_user" = "" && vhost_user=yes
2465299e6f19SPaolo Bonziniif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2466299e6f19SPaolo Bonzini  error_exit "vhost-user isn't available on win32"
2467299e6f19SPaolo Bonzinifi
2468108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2469108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2470108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2471108a6481SCindy Lufi
2472299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2473299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2474299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2475299e6f19SPaolo Bonzinifi
2476299e6f19SPaolo Bonzini
2477299e6f19SPaolo Bonzini# vhost-kernel devices
2478299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2479299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2480299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2481299e6f19SPaolo Bonzinifi
2482299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2483299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2484299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2485299e6f19SPaolo Bonzinifi
2486299e6f19SPaolo Bonzini
2487299e6f19SPaolo Bonzini# vhost-user backends
2488299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2489299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2490299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2491299e6f19SPaolo Bonzinifi
2492299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2493299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2494299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2495299e6f19SPaolo Bonzinifi
249698fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
249798fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
249898fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
249998fc1adaSDr. David Alan Gilbertfi
2500108a6481SCindy Lu#vhost-vdpa backends
2501108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2502108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2503108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2504108a6481SCindy Lufi
2505299e6f19SPaolo Bonzini
2506299e6f19SPaolo Bonzini# OR the vhost-kernel and vhost-user values for simplicity
2507299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2508299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
2509299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2510299e6f19SPaolo Bonzinifi
2511299e6f19SPaolo Bonzini
2512015a33bdSGonglei##########################################
25134d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
25144d9310f4SDaniel P. Berrange
25154d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
25164d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
25174d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
25184d9310f4SDaniel P. Berrange    #
25194d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
25204d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
25214d9310f4SDaniel P. Berrange    #
25224d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
25234d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
25244d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
25254d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
25264d9310f4SDaniel P. Berrange    # that for you.
25274d9310f4SDaniel P. Berrange    #
25284d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
25294d9310f4SDaniel P. Berrange    # are not in fact redundant.
25304d9310f4SDaniel P. Berrangecat > $TMPC << EOF
25314d9310f4SDaniel P. Berrange#include <unistd.h>
25324d9310f4SDaniel P. Berrange#include <time.h>
25334d9310f4SDaniel P. Berrange#undef localtime_r
25344d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
25354d9310f4SDaniel P. BerrangeEOF
25364d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
25374d9310f4SDaniel P. Berrange        localtime_r="yes"
25384d9310f4SDaniel P. Berrange    else
25394d9310f4SDaniel P. Berrange        localtime_r="no"
25404d9310f4SDaniel P. Berrange    fi
25414d9310f4SDaniel P. Berrangefi
25424d9310f4SDaniel P. Berrange
25434d9310f4SDaniel P. Berrange##########################################
2544779ab5e3SStefan Weil# pkg-config probe
2545779ab5e3SStefan Weil
2546779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
254776ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2548779ab5e3SStefan Weilfi
2549779ab5e3SStefan Weil
2550779ab5e3SStefan Weil##########################################
2551b0a47e79SJuan Quintela# NPTL probe
2552b0a47e79SJuan Quintela
255324cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2554bd0c5661Spbrook  cat > $TMPC <<EOF
2555bd0c5661Spbrook#include <sched.h>
255630813ceaSpbrook#include <linux/futex.h>
2557182eacc0SStefan Weilint main(void) {
2558bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2559bd0c5661Spbrook#error bork
2560bd0c5661Spbrook#endif
2561182eacc0SStefan Weil  return 0;
2562bd0c5661Spbrook}
2563bd0c5661SpbrookEOF
256424cb36a6SPeter Maydell  if ! compile_object ; then
256521684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2566b0a47e79SJuan Quintela  fi
2567bd0c5661Spbrookfi
2568bd0c5661Spbrook
2569ac62922eSbalrog##########################################
2570607dacd0Sqiaonuohan# lzo check
2571607dacd0Sqiaonuohan
2572607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2573607dacd0Sqiaonuohan    cat > $TMPC << EOF
2574607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2575607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2576607dacd0SqiaonuohanEOF
2577607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2578708eab42SMarc-André Lureau        lzo_libs="-llzo2"
2579b25c9dffSStefan Weil        lzo="yes"
2580b25c9dffSStefan Weil    else
2581b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2582b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2583b25c9dffSStefan Weil        fi
2584b25c9dffSStefan Weil        lzo="no"
2585b25c9dffSStefan Weil    fi
2586607dacd0Sqiaonuohanfi
2587607dacd0Sqiaonuohan
2588607dacd0Sqiaonuohan##########################################
2589607dacd0Sqiaonuohan# snappy check
2590607dacd0Sqiaonuohan
2591607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2592607dacd0Sqiaonuohan    cat > $TMPC << EOF
2593607dacd0Sqiaonuohan#include <snappy-c.h>
2594607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2595607dacd0SqiaonuohanEOF
2596607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2597708eab42SMarc-André Lureau        snappy_libs='-lsnappy'
2598b25c9dffSStefan Weil        snappy="yes"
2599b25c9dffSStefan Weil    else
2600b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2601b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2602b25c9dffSStefan Weil        fi
2603b25c9dffSStefan Weil        snappy="no"
2604b25c9dffSStefan Weil    fi
2605607dacd0Sqiaonuohanfi
2606607dacd0Sqiaonuohan
2607607dacd0Sqiaonuohan##########################################
26086b383c08SPeter Wu# bzip2 check
26096b383c08SPeter Wu
26106b383c08SPeter Wuif test "$bzip2" != "no" ; then
26116b383c08SPeter Wu    cat > $TMPC << EOF
26126b383c08SPeter Wu#include <bzlib.h>
26136b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
26146b383c08SPeter WuEOF
26156b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
26166b383c08SPeter Wu        bzip2="yes"
26176b383c08SPeter Wu    else
26186b383c08SPeter Wu        if test "$bzip2" = "yes"; then
26196b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
26206b383c08SPeter Wu        fi
26216b383c08SPeter Wu        bzip2="no"
26226b383c08SPeter Wu    fi
26236b383c08SPeter Wufi
26246b383c08SPeter Wu
26256b383c08SPeter Wu##########################################
262683bc1f97SJulio Faracco# lzfse check
262783bc1f97SJulio Faracco
262883bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
262983bc1f97SJulio Faracco    cat > $TMPC << EOF
263083bc1f97SJulio Faracco#include <lzfse.h>
263183bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
263283bc1f97SJulio FaraccoEOF
263383bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
263483bc1f97SJulio Faracco        lzfse="yes"
263583bc1f97SJulio Faracco    else
263683bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
263783bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
263883bc1f97SJulio Faracco        fi
263983bc1f97SJulio Faracco        lzfse="no"
264083bc1f97SJulio Faracco    fi
264183bc1f97SJulio Faraccofi
264283bc1f97SJulio Faracco
264383bc1f97SJulio Faracco##########################################
26443a678481SJuan Quintela# zstd check
26453a678481SJuan Quintela
26463a678481SJuan Quintelaif test "$zstd" != "no" ; then
2647297254c7SJuan Quintela    libzstd_minver="1.4.0"
2648297254c7SJuan Quintela    if $pkg_config --atleast-version=$libzstd_minver libzstd ; then
26493a678481SJuan Quintela        zstd_cflags="$($pkg_config --cflags libzstd)"
26503a678481SJuan Quintela        zstd_libs="$($pkg_config --libs libzstd)"
26513a678481SJuan Quintela        zstd="yes"
26523a678481SJuan Quintela    else
26533a678481SJuan Quintela        if test "$zstd" = "yes" ; then
26543a678481SJuan Quintela            feature_not_found "libzstd" "Install libzstd devel"
26553a678481SJuan Quintela        fi
26563a678481SJuan Quintela        zstd="no"
26573a678481SJuan Quintela    fi
26583a678481SJuan Quintelafi
26593a678481SJuan Quintela
26603a678481SJuan Quintela##########################################
2661f794573eSEduardo Otubo# libseccomp check
2662f794573eSEduardo Otubo
2663f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
26643e684455SMichael Strosaker    libseccomp_minver="2.3.0"
266525ed0eccSHelge Deller    if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2666c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2667c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2668f794573eSEduardo Otubo        seccomp="yes"
2669f794573eSEduardo Otubo    else
2670f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2671693e5910SAndrew Jones            feature_not_found "libseccomp" \
2672693e5910SAndrew Jones                 "Install libseccomp devel >= $libseccomp_minver"
2673896848f0SEduardo Otubo        fi
2674e84d5956SYann E. MORIN        seccomp="no"
2675f794573eSEduardo Otubo    fi
2676f794573eSEduardo Otubofi
2677f794573eSEduardo Otubo##########################################
2678e37630caSaliguori# xen probe
2679e37630caSaliguori
2680fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2681c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2682c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2683c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2684c1cdd9d5SJuergen Gross
2685c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2686c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2687c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2688c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2689c1cdd9d5SJuergen Gross    xen=yes
2690c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2691c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
269258ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
269358ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
269458ea9a7aSAnthony PERARD    fi
2695c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2696582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2697582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2698c1cdd9d5SJuergen Gross  else
2699c1cdd9d5SJuergen Gross
2700b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2701d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2702d5b93ddfSAnthony PERARD
270350ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
270450ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
270550ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
270650ced5b3SStefan Weil
270750ced5b3SStefan Weil    # Xen (any)
270850ced5b3SStefan Weil    cat > $TMPC <<EOF
270950ced5b3SStefan Weil#include <xenctrl.h>
271050ced5b3SStefan Weilint main(void) {
271150ced5b3SStefan Weil  return 0;
271250ced5b3SStefan Weil}
271350ced5b3SStefan WeilEOF
271450ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
271550ced5b3SStefan Weil      # Xen not found
271650ced5b3SStefan Weil      if test "$xen" = "yes" ; then
271721684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
271850ced5b3SStefan Weil      fi
271950ced5b3SStefan Weil      xen=no
272050ced5b3SStefan Weil
2721d5b93ddfSAnthony PERARD    # Xen unstable
272269deef08SPeter Maydell    elif
272369deef08SPeter Maydell        cat > $TMPC <<EOF &&
27242cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
27252cbf8903SRoss Lagerwall#define __XEN_TOOLS__
27262cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2727d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
27282cbf8903SRoss Lagerwallint main(void) {
27292cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2730d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
27312cbf8903SRoss Lagerwall
27322cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
27332cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
27342cbf8903SRoss Lagerwall
2735d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2736d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2737d3c49ebbSPaul Durrant
27382cbf8903SRoss Lagerwall  return 0;
27392cbf8903SRoss Lagerwall}
27402cbf8903SRoss LagerwallEOF
27412cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
27422cbf8903SRoss Lagerwall      then
27432cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
27442cbf8903SRoss Lagerwall      xen_ctrl_version=41100
27452cbf8903SRoss Lagerwall      xen=yes
27462cbf8903SRoss Lagerwall    elif
27472cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
27485ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
27495ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
275058ea9a7aSAnthony PERARD#include <xentoolcore.h>
27515ba3d756SIgor Druzhininint main(void) {
27525ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
27535ba3d756SIgor Druzhinin
27545ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
27555ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
275658ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
27575ba3d756SIgor Druzhinin
27585ba3d756SIgor Druzhinin  return 0;
27595ba3d756SIgor Druzhinin}
27605ba3d756SIgor DruzhininEOF
276158ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
27625ba3d756SIgor Druzhinin      then
276358ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
27645ba3d756SIgor Druzhinin      xen_ctrl_version=41000
27655ba3d756SIgor Druzhinin      xen=yes
27665ba3d756SIgor Druzhinin    elif
27675ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2768da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2769da8090ccSPaul Durrant#define __XEN_TOOLS__
2770da8090ccSPaul Durrant#include <xendevicemodel.h>
2771da8090ccSPaul Durrantint main(void) {
2772da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2773da8090ccSPaul Durrant
2774da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2775da8090ccSPaul Durrant  xendevicemodel_close(xd);
2776da8090ccSPaul Durrant
2777da8090ccSPaul Durrant  return 0;
2778da8090ccSPaul Durrant}
2779da8090ccSPaul DurrantEOF
2780da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2781da8090ccSPaul Durrant      then
2782da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2783f1167ee6SJuergen Gross      xen_ctrl_version=40900
2784da8090ccSPaul Durrant      xen=yes
2785da8090ccSPaul Durrant    elif
2786da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
27875eeb39c2SIan Campbell/*
27885eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
27895eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2790b6eb9b45SPaulina Szubarczyk *
2791b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2792b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2793b6eb9b45SPaulina Szubarczyk */
2794b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2795b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2796b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2797b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2798b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2799b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2800b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2801b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2802b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2803b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2804b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2805b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2806b6eb9b45SPaulina Szubarczyk#endif
2807b6eb9b45SPaulina Szubarczykint main(void) {
2808b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2809b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2810b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2811b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2812b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2813b6eb9b45SPaulina Szubarczyk
2814b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2815b6eb9b45SPaulina Szubarczyk
2816b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2817b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2818b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2819b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2820b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2821b6eb9b45SPaulina Szubarczyk
2822b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2823b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2824b6eb9b45SPaulina Szubarczyk
2825b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2826b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2827b6eb9b45SPaulina Szubarczyk
2828b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2829b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2830b6eb9b45SPaulina Szubarczyk
2831b6eb9b45SPaulina Szubarczyk  return 0;
2832b6eb9b45SPaulina Szubarczyk}
2833b6eb9b45SPaulina SzubarczykEOF
2834b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2835b6eb9b45SPaulina Szubarczyk      then
2836f1167ee6SJuergen Gross      xen_ctrl_version=40800
2837b6eb9b45SPaulina Szubarczyk      xen=yes
2838b6eb9b45SPaulina Szubarczyk    elif
2839b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2840b6eb9b45SPaulina Szubarczyk/*
2841b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2842b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
28435eeb39c2SIan Campbell */
28445eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
28455eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
28465eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
28475eeb39c2SIan Campbell#include <xenctrl.h>
28485eeb39c2SIan Campbell#include <xenstore.h>
28495eeb39c2SIan Campbell#include <xenevtchn.h>
28505eeb39c2SIan Campbell#include <xengnttab.h>
28515eeb39c2SIan Campbell#include <xenforeignmemory.h>
28525eeb39c2SIan Campbell#include <stdint.h>
28535eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
28545eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
28555eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
28565eeb39c2SIan Campbell#endif
28575eeb39c2SIan Campbellint main(void) {
28585eeb39c2SIan Campbell  xc_interface *xc = NULL;
28595eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
28605eeb39c2SIan Campbell  xenevtchn_handle *xe;
28615eeb39c2SIan Campbell  xengnttab_handle *xg;
28625eeb39c2SIan Campbell
28635eeb39c2SIan Campbell  xs_daemon_open();
28645eeb39c2SIan Campbell
28655eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
28665eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
28675eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
28685eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
28695eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
28705eeb39c2SIan Campbell
28715eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
28725eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
28735eeb39c2SIan Campbell
28745eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
28755eeb39c2SIan Campbell  xenevtchn_fd(xe);
28765eeb39c2SIan Campbell
28775eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
28785eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
28795eeb39c2SIan Campbell
28805eeb39c2SIan Campbell  return 0;
28815eeb39c2SIan Campbell}
28825eeb39c2SIan CampbellEOF
28835eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
28845eeb39c2SIan Campbell      then
2885f1167ee6SJuergen Gross      xen_ctrl_version=40701
28865eeb39c2SIan Campbell      xen=yes
2887cdadde39SRoger Pau Monne
2888cdadde39SRoger Pau Monne    # Xen 4.6
2889cdadde39SRoger Pau Monne    elif
2890cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2891cdadde39SRoger Pau Monne#include <xenctrl.h>
2892e108a3c1SAnthony PERARD#include <xenstore.h>
2893d5b93ddfSAnthony PERARD#include <stdint.h>
2894d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2895d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2896d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2897d5b93ddfSAnthony PERARD#endif
2898d5b93ddfSAnthony PERARDint main(void) {
2899d5b93ddfSAnthony PERARD  xc_interface *xc;
2900d5b93ddfSAnthony PERARD  xs_daemon_open();
2901d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2902d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2903d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2904b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29058688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2906d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
290720a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2908d8b441a3SJan Beulich  return 0;
2909d8b441a3SJan Beulich}
2910d8b441a3SJan BeulichEOF
2911d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2912d8b441a3SJan Beulich      then
2913f1167ee6SJuergen Gross      xen_ctrl_version=40600
2914d8b441a3SJan Beulich      xen=yes
2915d8b441a3SJan Beulich
2916d8b441a3SJan Beulich    # Xen 4.5
2917d8b441a3SJan Beulich    elif
2918d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2919d8b441a3SJan Beulich#include <xenctrl.h>
2920d8b441a3SJan Beulich#include <xenstore.h>
2921d8b441a3SJan Beulich#include <stdint.h>
2922d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2923d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2924d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2925d8b441a3SJan Beulich#endif
2926d8b441a3SJan Beulichint main(void) {
2927d8b441a3SJan Beulich  xc_interface *xc;
2928d8b441a3SJan Beulich  xs_daemon_open();
2929d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2930d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2931d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2932d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2933d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29343996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
29353996e85cSPaul Durrant  return 0;
29363996e85cSPaul Durrant}
29373996e85cSPaul DurrantEOF
29383996e85cSPaul Durrant        compile_prog "" "$xen_libs"
29393996e85cSPaul Durrant      then
2940f1167ee6SJuergen Gross      xen_ctrl_version=40500
29413996e85cSPaul Durrant      xen=yes
29423996e85cSPaul Durrant
29433996e85cSPaul Durrant    elif
29443996e85cSPaul Durrant        cat > $TMPC <<EOF &&
29453996e85cSPaul Durrant#include <xenctrl.h>
29463996e85cSPaul Durrant#include <xenstore.h>
29473996e85cSPaul Durrant#include <stdint.h>
29483996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
29493996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
29503996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
29513996e85cSPaul Durrant#endif
29523996e85cSPaul Durrantint main(void) {
29533996e85cSPaul Durrant  xc_interface *xc;
29543996e85cSPaul Durrant  xs_daemon_open();
29553996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
29563996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
29573996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
29583996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29593996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29608688e065SStefano Stabellini  return 0;
29618688e065SStefano Stabellini}
29628688e065SStefano StabelliniEOF
29638688e065SStefano Stabellini        compile_prog "" "$xen_libs"
296469deef08SPeter Maydell      then
2965f1167ee6SJuergen Gross      xen_ctrl_version=40200
29668688e065SStefano Stabellini      xen=yes
29678688e065SStefano Stabellini
2968e37630caSaliguori    else
2969fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
2970edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
2971edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
2972fc321b4bSJuan Quintela      fi
2973fc321b4bSJuan Quintela      xen=no
2974e37630caSaliguori    fi
2975d5b93ddfSAnthony PERARD
2976d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
2977f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
2978582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
29795eeb39c2SIan Campbell      fi
2980d5b93ddfSAnthony PERARD    fi
2981e37630caSaliguori  fi
2982c1cdd9d5SJuergen Grossfi
2983e37630caSaliguori
2984eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
2985edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
2986eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
2987eb6fda0fSAnthony PERARD  else
2988eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
298976ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
299076ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
2991eb6fda0fSAnthony PERARD    fi
2992eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
2993eb6fda0fSAnthony PERARD  fi
2994eb6fda0fSAnthony PERARDfi
2995eb6fda0fSAnthony PERARD
2996e37630caSaliguori##########################################
2997d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
2998d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
2999327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
3000d661d9a4SJustin Terry (VM)        whpx="yes"
3001d661d9a4SJustin Terry (VM)    else
3002d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
300353537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
3004d661d9a4SJustin Terry (VM)        fi
3005d661d9a4SJustin Terry (VM)        whpx="no"
3006d661d9a4SJustin Terry (VM)    fi
3007d661d9a4SJustin Terry (VM)fi
3008d661d9a4SJustin Terry (VM)
3009d661d9a4SJustin Terry (VM)##########################################
3010e8f3bd71SMarc-André Lureau# gettext probe
3011e8f3bd71SMarc-André Lureauif test "$gettext" != "false" ; then
3012e8f3bd71SMarc-André Lureau  if has xgettext; then
3013e8f3bd71SMarc-André Lureau    gettext=true
3014e8f3bd71SMarc-André Lureau  else
3015e8f3bd71SMarc-André Lureau    if test "$gettext" = "true" ; then
3016e8f3bd71SMarc-André Lureau      feature_not_found "gettext" "Install xgettext binary"
3017e8f3bd71SMarc-André Lureau    fi
3018e8f3bd71SMarc-André Lureau    gettext=false
3019e8f3bd71SMarc-André Lureau  fi
3020e8f3bd71SMarc-André Lureaufi
3021e8f3bd71SMarc-André Lureau
3022e8f3bd71SMarc-André Lureau##########################################
3023dfffc653SJuan Quintela# Sparse probe
3024dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
3025968b4db3SPaolo Bonzini  if has sparse; then
3026dfffc653SJuan Quintela    sparse=yes
3027dfffc653SJuan Quintela  else
3028dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
302921684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
3030dfffc653SJuan Quintela    fi
3031dfffc653SJuan Quintela    sparse=no
3032dfffc653SJuan Quintela  fi
3033dfffc653SJuan Quintelafi
3034dfffc653SJuan Quintela
3035dfffc653SJuan Quintela##########################################
3036f676c67eSJeremy White# X11 probe
3037f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
30388781595bSGerd Hoffmann    have_x11=yes
303989138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
304089138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
3041f676c67eSJeremy Whitefi
3042f676c67eSJeremy White
3043f676c67eSJeremy White##########################################
3044a4ccabcfSAnthony Liguori# GTK probe
3045a4ccabcfSAnthony Liguori
30465a464e6cSPeter Xuif test "$gtk" != "no"; then
304789d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
304889d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
30497b23d121SVolker Rümelin    gtkversion="3.22.0"
3050bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
305189138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
305289138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
305389138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
30540a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
30558781595bSGerd Hoffmann            need_x11=yes
3056f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
3057f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
30580a337ed0SGerd Hoffmann        fi
3059bbbf9bfbSStefan Weil        gtk="yes"
3060bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
30615fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
3062bbbf9bfbSStefan Weil    else
3063bbbf9bfbSStefan Weil        gtk="no"
3064bbbf9bfbSStefan Weil    fi
3065bbbf9bfbSStefan Weilfi
3066bbbf9bfbSStefan Weil
3067ddbb0d09SDaniel P. Berrange
3068ddbb0d09SDaniel P. Berrange##########################################
3069ddbb0d09SDaniel P. Berrange# GNUTLS probe
3070ddbb0d09SDaniel P. Berrange
3071ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
3072a73e82efSRichard Henderson    pass="no"
3073a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
307489138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
307589138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
3076a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
3077a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
3078a73e82efSRichard Henderson        write_c_skeleton
3079a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
3080243dc2cfSRichard Henderson            LIBS="$gnutls_libs $LIBS"
3081ddbb0d09SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
3082a73e82efSRichard Henderson            pass="yes"
3083a73e82efSRichard Henderson        fi
3084a73e82efSRichard Henderson    fi
3085a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
3086a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
3087ddbb0d09SDaniel P. Berrange    else
3088a73e82efSRichard Henderson        gnutls="$pass"
3089ddbb0d09SDaniel P. Berrange    fi
3090ddbb0d09SDaniel P. Berrangefi
3091ddbb0d09SDaniel P. Berrange
309291bfcdb0SDaniel P. Berrange
309391bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
309491bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
3095a0722409SDaniel P. Berrangé# explicitly
309691bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
309791bfcdb0SDaniel P. Berrangethen
3098a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
309991bfcdb0SDaniel P. Berrange    then
310091bfcdb0SDaniel P. Berrange        gcrypt="no"
310191bfcdb0SDaniel P. Berrange    fi
310291bfcdb0SDaniel P. Berrangefi
310391bfcdb0SDaniel P. Berrange
310491bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
310591bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
3106a0722409SDaniel P. Berrangé# explicitly
310791bfcdb0SDaniel P. Berrangeif test -z "$nettle"
310891bfcdb0SDaniel P. Berrangethen
3109a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
311091bfcdb0SDaniel P. Berrange    then
311191bfcdb0SDaniel P. Berrange        nettle="no"
311291bfcdb0SDaniel P. Berrange    fi
311391bfcdb0SDaniel P. Berrangefi
311491bfcdb0SDaniel P. Berrange
3115dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
311691bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
311791bfcdb0SDaniel P. Berrange    then
311891bfcdb0SDaniel P. Berrange	return 1
311991bfcdb0SDaniel P. Berrange    fi
312091bfcdb0SDaniel P. Berrange
312191bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
312291bfcdb0SDaniel P. Berrange    then
312389138857SStefan Weil	host=$(libgcrypt-config --host)
312491bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
312591bfcdb0SDaniel P. Berrange	then
312691bfcdb0SDaniel P. Berrange	    return 1
312791bfcdb0SDaniel P. Berrange	fi
312891bfcdb0SDaniel P. Berrange    fi
312991bfcdb0SDaniel P. Berrange
3130dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
3131dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
3132dea7a64eSDaniel P. Berrangé
3133dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
3134dea7a64eSDaniel P. Berrangé    then
3135dea7a64eSDaniel P. Berrangé       return 1
3136dea7a64eSDaniel P. Berrangé    fi
3137dea7a64eSDaniel P. Berrangé
313891bfcdb0SDaniel P. Berrange    return 0
313991bfcdb0SDaniel P. Berrange}
314091bfcdb0SDaniel P. Berrange
3141a0722409SDaniel P. Berrangé
3142a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
3143a73e82efSRichard Henderson    pass="no"
314464dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
3145a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
3146a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
3147a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
3148a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3149a73e82efSRichard Henderson        write_c_skeleton
3150a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
3151243dc2cfSRichard Henderson            LIBS="$nettle_libs $LIBS"
3152a0722409SDaniel P. Berrangé            QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
3153a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
3154a0722409SDaniel P. Berrangé               gcrypt="no"
3155a0722409SDaniel P. Berrangé            fi
3156a73e82efSRichard Henderson            pass="yes"
3157a73e82efSRichard Henderson        fi
3158a73e82efSRichard Henderson    fi
3159dc2207afSDaniel P. Berrangé    if test "$pass" = "yes"
3160dc2207afSDaniel P. Berrangé    then
3161dc2207afSDaniel P. Berrangé        cat > $TMPC << EOF
3162dc2207afSDaniel P. Berrangé#include <nettle/xts.h>
3163dc2207afSDaniel P. Berrangéint main(void) {
3164dc2207afSDaniel P. Berrangé  return 0;
3165dc2207afSDaniel P. Berrangé}
3166dc2207afSDaniel P. BerrangéEOF
3167dc2207afSDaniel P. Berrangé        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
3168dc2207afSDaniel P. Berrangé            nettle_xts=yes
3169dc2207afSDaniel P. Berrangé            qemu_private_xts=no
3170dc2207afSDaniel P. Berrangé        fi
3171dc2207afSDaniel P. Berrangé    fi
3172a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
317364dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
3174a0722409SDaniel P. Berrangé    else
3175a73e82efSRichard Henderson        nettle="$pass"
3176a0722409SDaniel P. Berrangé    fi
3177a0722409SDaniel P. Berrangéfi
3178a0722409SDaniel P. Berrangé
317991bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
3180a73e82efSRichard Henderson    pass="no"
3181dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
318289138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
318389138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
3184a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
318591bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
318691bfcdb0SDaniel P. Berrange        # turn breaks static builds...
318791bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
318891bfcdb0SDaniel P. Berrange        then
318991bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
319091bfcdb0SDaniel P. Berrange        fi
31911f923c70SLongpeng(Mike)
3192a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3193a73e82efSRichard Henderson        write_c_skeleton
3194a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
3195243dc2cfSRichard Henderson            LIBS="$gcrypt_libs $LIBS"
319637788f25SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
3197a73e82efSRichard Henderson            pass="yes"
3198a73e82efSRichard Henderson        fi
3199a73e82efSRichard Henderson    fi
3200a73e82efSRichard Henderson    if test "$pass" = "yes"; then
320137788f25SDaniel P. Berrange        gcrypt="yes"
32021f923c70SLongpeng(Mike)        cat > $TMPC << EOF
32031f923c70SLongpeng(Mike)#include <gcrypt.h>
32041f923c70SLongpeng(Mike)int main(void) {
32051f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
32061f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
32071f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
32081f923c70SLongpeng(Mike)  return 0;
32091f923c70SLongpeng(Mike)}
32101f923c70SLongpeng(Mike)EOF
32111f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
32121f923c70SLongpeng(Mike)            gcrypt_hmac=yes
32131f923c70SLongpeng(Mike)        fi
3214e0576942SDaniel P. Berrangé        cat > $TMPC << EOF
3215e0576942SDaniel P. Berrangé#include <gcrypt.h>
3216e0576942SDaniel P. Berrangéint main(void) {
3217e0576942SDaniel P. Berrangé  gcry_cipher_hd_t handle;
3218e0576942SDaniel P. Berrangé  gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
3219e0576942SDaniel P. Berrangé  return 0;
3220e0576942SDaniel P. Berrangé}
3221e0576942SDaniel P. BerrangéEOF
3222e0576942SDaniel P. Berrangé        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3223e0576942SDaniel P. Berrangé            gcrypt_xts=yes
3224e0576942SDaniel P. Berrangé            qemu_private_xts=no
3225e0576942SDaniel P. Berrangé        fi
3226a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
3227dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
322891bfcdb0SDaniel P. Berrange    else
322991bfcdb0SDaniel P. Berrange        gcrypt="no"
323091bfcdb0SDaniel P. Berrange    fi
323162893b67SDaniel P. Berrangefi
323262893b67SDaniel P. Berrange
3233ddbb0d09SDaniel P. Berrange
323491bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
323591bfcdb0SDaniel P. Berrangethen
323691bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
323791bfcdb0SDaniel P. Berrangefi
3238ed754746SDaniel P. Berrange
32399a2fd434SDaniel P. Berrange##########################################
32409a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
32419a2fd434SDaniel P. Berrange
32429a2fd434SDaniel P. Berrangetasn1=yes
324390246037SDaniel P. Berrangetasn1_cflags=""
324490246037SDaniel P. Berrangetasn1_libs=""
32459a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
324689138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
324789138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
32489a2fd434SDaniel P. Berrangeelse
32499a2fd434SDaniel P. Berrange    tasn1=no
32509a2fd434SDaniel P. Berrangefi
32519a2fd434SDaniel P. Berrange
3252ed754746SDaniel P. Berrange
3253bbbf9bfbSStefan Weil##########################################
32548953caf3SDaniel P. Berrange# PAM probe
32558953caf3SDaniel P. Berrange
32568953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
32578953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
32588953caf3SDaniel P. Berrange#include <security/pam_appl.h>
32598953caf3SDaniel P. Berrange#include <stdio.h>
32608953caf3SDaniel P. Berrangeint main(void) {
32618953caf3SDaniel P. Berrange   const char *service_name = "qemu";
32628953caf3SDaniel P. Berrange   const char *user = "frank";
32639c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
32648953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
32659c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
32668953caf3SDaniel P. Berrange   return 0;
32678953caf3SDaniel P. Berrange}
32688953caf3SDaniel P. BerrangeEOF
32698953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
32708953caf3SDaniel P. Berrange        auth_pam=yes
32718953caf3SDaniel P. Berrange    else
32728953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
32738953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
32748953caf3SDaniel P. Berrange        else
32758953caf3SDaniel P. Berrange            auth_pam=no
32768953caf3SDaniel P. Berrange        fi
32778953caf3SDaniel P. Berrange    fi
32788953caf3SDaniel P. Berrangefi
32798953caf3SDaniel P. Berrange
32808953caf3SDaniel P. Berrange##########################################
3281559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
3282559607eaSDaniel P. Berrange
3283559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
3284559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
3285559607eaSDaniel P. Berrange  have_ifaddrs_h=no
3286559607eaSDaniel P. Berrangefi
3287559607eaSDaniel P. Berrange
3288e865b97fSChen Gang#########################################
3289e865b97fSChen Gang# libdrm check
3290e865b97fSChen Ganghave_drm_h=no
3291e865b97fSChen Gangif check_include "libdrm/drm.h" ; then
3292e865b97fSChen Gang    have_drm_h=yes
3293e865b97fSChen Gangfi
3294e865b97fSChen Gang
32952a4b472cSDavid CARLIER#########################################
32962a4b472cSDavid CARLIER# sys/signal.h check
32972a4b472cSDavid CARLIERhave_sys_signal_h=no
32982a4b472cSDavid CARLIERif check_include "sys/signal.h" ; then
32992a4b472cSDavid CARLIER  have_sys_signal_h=yes
33002a4b472cSDavid CARLIERfi
33012a4b472cSDavid CARLIER
3302559607eaSDaniel P. Berrange##########################################
3303bbbf9bfbSStefan Weil# VTE probe
3304bbbf9bfbSStefan Weil
3305bbbf9bfbSStefan Weilif test "$vte" != "no"; then
3306c6feff9eSCole Robinson    vteminversion="0.32.0"
3307c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
3308c6feff9eSCole Robinson      vtepackage="vte-2.91"
3309c6feff9eSCole Robinson    else
3310528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
3311c6feff9eSCole Robinson    fi
3312c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
331389138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
331489138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
331589138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
3316bbbf9bfbSStefan Weil        vte="yes"
3317bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
3318c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
33199e04c683SStefan Weil    else
3320bbbf9bfbSStefan Weil        vte="no"
3321a4ccabcfSAnthony Liguori    fi
3322a4ccabcfSAnthony Liguorifi
3323a4ccabcfSAnthony Liguori
3324a4ccabcfSAnthony Liguori##########################################
33252da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
33262da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
33272da776dbSMichael R. Hines  cat > $TMPC <<EOF
33282da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
33292da776dbSMichael R. Hinesint main(void) { return 0; }
33302da776dbSMichael R. HinesEOF
3331ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
33322da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
33332da776dbSMichael R. Hines    rdma="yes"
33342da776dbSMichael R. Hines  else
33352da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
33362da776dbSMichael R. Hines        error_exit \
3337ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
33382da776dbSMichael R. Hines            " Your options:" \
3339ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
33402da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
33412da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
33422da776dbSMichael R. Hines    fi
33432da776dbSMichael R. Hines    rdma="no"
33442da776dbSMichael R. Hines  fi
33452da776dbSMichael R. Hinesfi
33462da776dbSMichael R. Hines
334721ab34c9SMarcel Apfelbaum##########################################
334821ab34c9SMarcel Apfelbaum# PVRDMA detection
334921ab34c9SMarcel Apfelbaum
335021ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
335121ab34c9SMarcel Apfelbaum#include <sys/mman.h>
335221ab34c9SMarcel Apfelbaum
335321ab34c9SMarcel Apfelbaumint
335421ab34c9SMarcel Apfelbaummain(void)
335521ab34c9SMarcel Apfelbaum{
335621ab34c9SMarcel Apfelbaum    char buf = 0;
335721ab34c9SMarcel Apfelbaum    void *addr = &buf;
335821ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
335921ab34c9SMarcel Apfelbaum
336021ab34c9SMarcel Apfelbaum    return 0;
336121ab34c9SMarcel Apfelbaum}
336221ab34c9SMarcel ApfelbaumEOF
336321ab34c9SMarcel Apfelbaum
336421ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
336521ab34c9SMarcel Apfelbaum    case "$pvrdma" in
336621ab34c9SMarcel Apfelbaum    "")
336721ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
336821ab34c9SMarcel Apfelbaum            pvrdma="yes"
336921ab34c9SMarcel Apfelbaum        else
337021ab34c9SMarcel Apfelbaum            pvrdma="no"
337121ab34c9SMarcel Apfelbaum        fi
337221ab34c9SMarcel Apfelbaum        ;;
337321ab34c9SMarcel Apfelbaum    "yes")
337421ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
337521ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
337621ab34c9SMarcel Apfelbaum        fi
337721ab34c9SMarcel Apfelbaum        pvrdma="yes"
337821ab34c9SMarcel Apfelbaum        ;;
337921ab34c9SMarcel Apfelbaum    "no")
338021ab34c9SMarcel Apfelbaum        pvrdma="no"
338121ab34c9SMarcel Apfelbaum        ;;
338221ab34c9SMarcel Apfelbaum    esac
338321ab34c9SMarcel Apfelbaumelse
338421ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
338521ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
338621ab34c9SMarcel Apfelbaum    fi
338721ab34c9SMarcel Apfelbaum    pvrdma="no"
338821ab34c9SMarcel Apfelbaumfi
338995c6bff3SBenoît Canet
3390ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
3391ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
3392ee108585SYuval Shaia
3393ee108585SYuval Shaiacat > $TMPC <<EOF &&
3394ee108585SYuval Shaia#include <infiniband/verbs.h>
3395ee108585SYuval Shaia
3396ee108585SYuval Shaiaint
3397ee108585SYuval Shaiamain(void)
3398ee108585SYuval Shaia{
3399ee108585SYuval Shaia    struct ibv_mr *mr;
3400ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
3401ee108585SYuval Shaia    size_t length = 10;
3402ee108585SYuval Shaia    uint64_t iova = 0;
3403ee108585SYuval Shaia    int access = 0;
3404ee108585SYuval Shaia    void *addr = NULL;
3405ee108585SYuval Shaia
3406ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3407ee108585SYuval Shaia
3408ee108585SYuval Shaia    ibv_dereg_mr(mr);
3409ee108585SYuval Shaia
3410ee108585SYuval Shaia    return 0;
3411ee108585SYuval Shaia}
3412ee108585SYuval ShaiaEOF
3413ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
3414ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3415ee108585SYuval Shaia    fi
3416ee108585SYuval Shaiafi
3417ee108585SYuval Shaia
341895c6bff3SBenoît Canet##########################################
3419c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3420dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3421dce512deSChristoph Hellwig  cat > $TMPC << EOF
3422ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3423dce512deSChristoph Hellwig#include <xfs/xfs.h>
3424dce512deSChristoph Hellwigint main(void)
3425dce512deSChristoph Hellwig{
3426dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3427dce512deSChristoph Hellwig    return 0;
3428dce512deSChristoph Hellwig}
3429dce512deSChristoph HellwigEOF
3430dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3431dce512deSChristoph Hellwig    xfs="yes"
3432dce512deSChristoph Hellwig  else
3433dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
343421684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3435dce512deSChristoph Hellwig    fi
3436dce512deSChristoph Hellwig    xfs=no
3437dce512deSChristoph Hellwig  fi
3438dce512deSChristoph Hellwigfi
3439dce512deSChristoph Hellwig
3440dce512deSChristoph Hellwig##########################################
34418a16d273Sths# vde libraries probe
3442dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
34434baae0acSJuan Quintela  vde_libs="-lvdeplug"
34448a16d273Sths  cat > $TMPC << EOF
34458a16d273Sths#include <libvdeplug.h>
34464a7f0e06Spbrookint main(void)
34474a7f0e06Spbrook{
34484a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3449fea08e08SPeter Maydell    char s[] = "";
3450fea08e08SPeter Maydell    vde_open(s, s, &a);
34514a7f0e06Spbrook    return 0;
34524a7f0e06Spbrook}
34538a16d273SthsEOF
345452166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
34554baae0acSJuan Quintela    vde=yes
3456dfb278bdSJuan Quintela  else
3457dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
345821684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3459dfb278bdSJuan Quintela    fi
3460dfb278bdSJuan Quintela    vde=no
34618a16d273Sths  fi
34628a16d273Sthsfi
34638a16d273Sths
34648a16d273Sths##########################################
34650a985b37SVincenzo Maffione# netmap support probe
34660a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
34670a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
34680a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
34690a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
34700a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
347158952137SVincenzo Maffioneif test "$netmap" != "no" ; then
347258952137SVincenzo Maffione  cat > $TMPC << EOF
347358952137SVincenzo Maffione#include <inttypes.h>
347458952137SVincenzo Maffione#include <net/if.h>
347558952137SVincenzo Maffione#include <net/netmap.h>
347658952137SVincenzo Maffione#include <net/netmap_user.h>
34770a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
34780a985b37SVincenzo Maffione#error
34790a985b37SVincenzo Maffione#endif
348058952137SVincenzo Maffioneint main(void) { return 0; }
348158952137SVincenzo MaffioneEOF
348258952137SVincenzo Maffione  if compile_prog "" "" ; then
348358952137SVincenzo Maffione    netmap=yes
348458952137SVincenzo Maffione  else
348558952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
348658952137SVincenzo Maffione      feature_not_found "netmap"
348758952137SVincenzo Maffione    fi
348858952137SVincenzo Maffione    netmap=no
348958952137SVincenzo Maffione  fi
349058952137SVincenzo Maffionefi
349158952137SVincenzo Maffione
349258952137SVincenzo Maffione##########################################
349347e98658SCorey Bryant# libcap-ng library probe
349447e98658SCorey Bryantif test "$cap_ng" != "no" ; then
349547e98658SCorey Bryant  cap_libs="-lcap-ng"
349647e98658SCorey Bryant  cat > $TMPC << EOF
349747e98658SCorey Bryant#include <cap-ng.h>
349847e98658SCorey Bryantint main(void)
349947e98658SCorey Bryant{
350047e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
350147e98658SCorey Bryant    return 0;
350247e98658SCorey Bryant}
350347e98658SCorey BryantEOF
350447e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
350547e98658SCorey Bryant    cap_ng=yes
350647e98658SCorey Bryant  else
350747e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
350821684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
350947e98658SCorey Bryant    fi
351047e98658SCorey Bryant    cap_ng=no
351147e98658SCorey Bryant  fi
351247e98658SCorey Bryantfi
351347e98658SCorey Bryant
351447e98658SCorey Bryant##########################################
3515c2de5c91Smalc# Sound support libraries probe
35168f28f3fbSths
351789138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3518c2de5c91Smalcfor drv in $audio_drv_list; do
3519c2de5c91Smalc    case $drv in
3520e42975a1SGerd Hoffmann    alsa | try-alsa)
3521c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3522c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3523478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
3524478e943fSPaolo Bonzini        alsa=yes
3525e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3526e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3527e42975a1SGerd Hoffmann        fi
3528e42975a1SGerd Hoffmann    else
3529e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3530e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3531c80a867fSGerd Hoffmann        else
3532c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3533c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3534c80a867fSGerd Hoffmann        fi
3535e42975a1SGerd Hoffmann    fi
3536c2de5c91Smalc    ;;
3537c2de5c91Smalc
3538e42975a1SGerd Hoffmann    pa | try-pa)
3539c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3540478e943fSPaolo Bonzini        libpulse=yes
3541c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3542478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3543e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3544e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3545e42975a1SGerd Hoffmann        fi
3546e42975a1SGerd Hoffmann    else
3547e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3548e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3549c80a867fSGerd Hoffmann        else
3550c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3551c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3552c80a867fSGerd Hoffmann        fi
3553e42975a1SGerd Hoffmann    fi
3554b8e59f18Smalc    ;;
3555b8e59f18Smalc
3556373967b2SGerd Hoffmann    sdl)
3557373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3558373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3559373967b2SGerd Hoffmann    fi
3560373967b2SGerd Hoffmann    ;;
3561373967b2SGerd Hoffmann
3562e42975a1SGerd Hoffmann    try-sdl)
3563e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3564e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3565e42975a1SGerd Hoffmann    else
3566e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3567e42975a1SGerd Hoffmann    fi
3568e42975a1SGerd Hoffmann    ;;
3569e42975a1SGerd Hoffmann
3570997e690aSJuan Quintela    coreaudio)
3571b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3572997e690aSJuan Quintela    ;;
3573997e690aSJuan Quintela
3574a4bf6780SJuan Quintela    dsound)
3575b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3576d5631638Smalc      audio_win_int="yes"
3577a4bf6780SJuan Quintela    ;;
3578a4bf6780SJuan Quintela
3579a4bf6780SJuan Quintela    oss)
3580b1149911SFam Zheng      oss_libs="$oss_lib"
3581a4bf6780SJuan Quintela    ;;
3582a4bf6780SJuan Quintela
35832e445703SGeoffrey McRae    jack | try-jack)
35842e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3585478e943fSPaolo Bonzini        libjack=yes
35862e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
35872e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
35882e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
35892e445703SGeoffrey McRae        fi
35902e445703SGeoffrey McRae    else
35912e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
35922e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
35932e445703SGeoffrey McRae        else
35942e445703SGeoffrey McRae            error_exit "$drv check failed" \
35952e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
35962e445703SGeoffrey McRae        fi
35972e445703SGeoffrey McRae    fi
35982e445703SGeoffrey McRae    ;;
35992e445703SGeoffrey McRae
3600e4c63a6aSmalc    *)
36011c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
360276ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
360376ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3604e4c63a6aSmalc    }
3605e4c63a6aSmalc    ;;
3606c2de5c91Smalc    esac
3607c2de5c91Smalcdone
36088f28f3fbSths
36094d3b6f6eSbalrog##########################################
36102e4d9fb1Saurel32# BrlAPI probe
36112e4d9fb1Saurel32
36124ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3613eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
36142e4d9fb1Saurel32  cat > $TMPC << EOF
36152e4d9fb1Saurel32#include <brlapi.h>
3616832ce9c2SScott Wood#include <stddef.h>
36172e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
36182e4d9fb1Saurel32EOF
361952166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
36202e4d9fb1Saurel32    brlapi=yes
36214ffcedb6SJuan Quintela  else
36224ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
362321684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
36244ffcedb6SJuan Quintela    fi
36254ffcedb6SJuan Quintela    brlapi=no
3626eb82284fSJuan Quintela  fi
3627eb82284fSJuan Quintelafi
36282e4d9fb1Saurel32
36292e4d9fb1Saurel32##########################################
3630e08bb301SSamuel Thibault# iconv probe
3631e08bb301SSamuel Thibaultif test "$iconv" != "no" ; then
3632e08bb301SSamuel Thibault  cat > $TMPC << EOF
3633e08bb301SSamuel Thibault#include <iconv.h>
3634e08bb301SSamuel Thibaultint main(void) {
3635e08bb301SSamuel Thibault  iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3636e08bb301SSamuel Thibault  return conv != (iconv_t) -1;
3637e08bb301SSamuel Thibault}
3638e08bb301SSamuel ThibaultEOF
3639e08bb301SSamuel Thibault  iconv_prefix_list="/usr/local:/usr"
3640e08bb301SSamuel Thibault  iconv_lib_list=":-liconv"
3641e08bb301SSamuel Thibault  IFS=:
3642e08bb301SSamuel Thibault  for iconv_prefix in $iconv_prefix_list; do
3643e08bb301SSamuel Thibault    IFS=:
3644e08bb301SSamuel Thibault    iconv_cflags="-I$iconv_prefix/include"
3645e08bb301SSamuel Thibault    iconv_ldflags="-L$iconv_prefix/lib"
3646e08bb301SSamuel Thibault    for iconv_link in $iconv_lib_list; do
3647e08bb301SSamuel Thibault      unset IFS
3648e08bb301SSamuel Thibault      iconv_lib="$iconv_ldflags $iconv_link"
3649e08bb301SSamuel Thibault      echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3650e08bb301SSamuel Thibault      if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3651e08bb301SSamuel Thibault        iconv_found=yes
3652e08bb301SSamuel Thibault        break
3653e08bb301SSamuel Thibault      fi
3654e08bb301SSamuel Thibault    done
3655e08bb301SSamuel Thibault    if test "$iconv_found" = yes ; then
3656e08bb301SSamuel Thibault      break
3657e08bb301SSamuel Thibault    fi
3658e08bb301SSamuel Thibault  done
3659e08bb301SSamuel Thibault  if test "$iconv_found" = "yes" ; then
3660e08bb301SSamuel Thibault    iconv=yes
3661e08bb301SSamuel Thibault  else
3662e08bb301SSamuel Thibault    if test "$iconv" = "yes" ; then
3663e08bb301SSamuel Thibault      feature_not_found "iconv" "Install iconv devel"
3664e08bb301SSamuel Thibault    fi
3665e08bb301SSamuel Thibault    iconv=no
3666e08bb301SSamuel Thibault  fi
3667e08bb301SSamuel Thibaultfi
3668e08bb301SSamuel Thibault
3669e08bb301SSamuel Thibault##########################################
36704d3b6f6eSbalrog# curses probe
3671e08bb301SSamuel Thibaultif test "$iconv" = "no" ; then
3672e08bb301SSamuel Thibault  # curses will need iconv
3673e08bb301SSamuel Thibault  curses=no
3674e08bb301SSamuel Thibaultfi
3675a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3676e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
36778ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
36788ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3679e095e2f3SStefan Weil  else
36807c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
36818ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3682e095e2f3SStefan Weil  fi
3683c584a6d0SJuan Quintela  curses_found=no
36844d3b6f6eSbalrog  cat > $TMPC << EOF
36858ddc5bf9SSamuel Thibault#include <locale.h>
36864d3b6f6eSbalrog#include <curses.h>
36878ddc5bf9SSamuel Thibault#include <wchar.h>
36882f8b7cd5SSamuel Thibault#include <langinfo.h>
3689ef9a2524SStefan Weilint main(void) {
36902f8b7cd5SSamuel Thibault  const char *codeset;
36918ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
36928ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3693ef9a2524SStefan Weil  resize_term(0, 0);
36948ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
36958ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
36967c703002SSamuel Thibault  add_wch(WACS_DEGREE);
36972f8b7cd5SSamuel Thibault  codeset = nl_langinfo(CODESET);
36982f8b7cd5SSamuel Thibault  return codeset != 0;
3699ef9a2524SStefan Weil}
37004d3b6f6eSbalrogEOF
3701ecbe251fSVadim Evard  IFS=:
37028ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3703b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3704b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
37057c703002SSamuel Thibault    IFS=:
37068ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3707ecbe251fSVadim Evard      unset IFS
37088ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3709c584a6d0SJuan Quintela        curses_found=yes
37104f78ef9aSJuan Quintela        break
37114d3b6f6eSbalrog      fi
37124f78ef9aSJuan Quintela    done
37137c703002SSamuel Thibault    if test "$curses_found" = yes ; then
37147c703002SSamuel Thibault      break
37157c703002SSamuel Thibault    fi
37168ddc5bf9SSamuel Thibault  done
3717ecbe251fSVadim Evard  unset IFS
3718c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3719c584a6d0SJuan Quintela    curses=yes
3720c584a6d0SJuan Quintela  else
3721c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
372221684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3723c584a6d0SJuan Quintela    fi
3724c584a6d0SJuan Quintela    curses=no
3725c584a6d0SJuan Quintela  fi
37264f78ef9aSJuan Quintelafi
37274d3b6f6eSbalrog
3728414f0dabSblueswir1##########################################
3729769ce76dSAlexander Graf# curl probe
3730a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
373165d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3732a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
37334e2b0658SPaolo Bonzini  else
37344e2b0658SPaolo Bonzini    curlconfig=curl-config
37354e2b0658SPaolo Bonzini  fi
3736769ce76dSAlexander Graf  cat > $TMPC << EOF
3737769ce76dSAlexander Graf#include <curl/curl.h>
37380b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3739769ce76dSAlexander GrafEOF
374089138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
374189138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3742b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3743769ce76dSAlexander Graf    curl=yes
3744788c8196SJuan Quintela  else
3745788c8196SJuan Quintela    if test "$curl" = "yes" ; then
374621684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3747788c8196SJuan Quintela    fi
3748788c8196SJuan Quintela    curl=no
3749769ce76dSAlexander Graf  fi
3750769ce76dSAlexander Graffi # test "$curl"
3751769ce76dSAlexander Graf
3752769ce76dSAlexander Graf##########################################
3753e18df141SAnthony Liguori# glib support probe
3754a52d28afSPaolo Bonzini
375500f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
3756aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3757aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3758a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3759aa0d1f44SPaolo Bonzinifi
376054cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
376154cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
376254cb65d8SEmilio G. Cotafi
3763e26110cfSFam Zheng
3764aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3765e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
376689138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
376789138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
376814015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3769e18df141SAnthony Liguori    else
3770e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3771e26110cfSFam Zheng    fi
3772e26110cfSFam Zhengdone
3773e26110cfSFam Zheng
3774*215b0c2fSPaolo Bonzini# This workaround is required due to a bug in pkg-config file for glib as it
3775*215b0c2fSPaolo Bonzini# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
3776*215b0c2fSPaolo Bonzini
3777*215b0c2fSPaolo Bonziniif test "$static" = yes && test "$mingw32" = yes; then
3778*215b0c2fSPaolo Bonzini    glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
3779*215b0c2fSPaolo Bonzinifi
3780*215b0c2fSPaolo Bonzini
3781f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3782f876b765SMarc-André Lureau    gio=yes
3783f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
3784f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
378525a97a56SMarc-André Lureau    gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
37860dba4897SMarc-André Lureau    if [ ! -x "$gdbus_codegen" ]; then
37870dba4897SMarc-André Lureau        gdbus_codegen=
37880dba4897SMarc-André Lureau    fi
3789f876b765SMarc-André Lureauelse
3790f876b765SMarc-André Lureau    gio=no
3791f876b765SMarc-André Lureaufi
3792f876b765SMarc-André Lureau
379325a97a56SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
379425a97a56SMarc-André Lureau    gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
379525a97a56SMarc-André Lureau    gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
379625a97a56SMarc-André Lureaufi
379725a97a56SMarc-André Lureau
3798977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3799977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3800977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3801977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3802977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3803977a82abSDaniel P. Berrange#include <glib.h>
3804977a82abSDaniel P. Berrange#include <unistd.h>
3805977a82abSDaniel P. Berrange
3806977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3807977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3808977a82abSDaniel P. Berrange
3809977a82abSDaniel P. Berrangeint main(void) {
3810977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3811977a82abSDaniel P. Berrange   return 0;
3812977a82abSDaniel P. Berrange}
3813977a82abSDaniel P. BerrangeEOF
3814977a82abSDaniel P. Berrange
3815*215b0c2fSPaolo Bonziniif ! compile_prog "$glib_cflags" "$glib_libs" ; then
3816977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3817977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3818977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3819977a82abSDaniel P. Berrange	       "build target"
3820977a82abSDaniel P. Berrangefi
3821977a82abSDaniel P. Berrange
3822bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3823bbbf2e04SJohn Snowcat > $TMPC << EOF
3824bbbf2e04SJohn Snow#include <glib.h>
3825bbbf2e04SJohn Snowint main(void) { return 0; }
3826bbbf2e04SJohn SnowEOF
3827bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3828bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3829bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3830*215b0c2fSPaolo Bonzini        CFLAGS="-Wno-unknown-attributes $CFLAGS"
3831bbbf2e04SJohn Snow    fi
3832bbbf2e04SJohn Snowfi
3833bbbf2e04SJohn Snow
38349bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
38359bda600bSEric Blakecat > $TMPC << EOF
38369bda600bSEric Blake#include <glib.h>
38379bda600bSEric Blaketypedef struct Foo {
38389bda600bSEric Blake    int i;
38399bda600bSEric Blake} Foo;
38409bda600bSEric Blakestatic void foo_free(Foo *f)
38419bda600bSEric Blake{
38429bda600bSEric Blake    g_free(f);
38439bda600bSEric Blake}
38449bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
38459bda600bSEric Blakeint main(void) { return 0; }
38469bda600bSEric BlakeEOF
38479bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
38489bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
38499bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
38509bda600bSEric Blake        CFLAGS="$CFLAGS -Wno-unused-function"
38519bda600bSEric Blake    fi
38529bda600bSEric Blakefi
38539bda600bSEric Blake
3854e26110cfSFam Zheng##########################################
3855e26110cfSFam Zheng# SHA command probe for modules
3856e26110cfSFam Zhengif test "$modules" = yes; then
3857e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3858e26110cfSFam Zheng    for c in $shacmd_probe; do
38598ccefb91SFam Zheng        if has $c; then
3860e26110cfSFam Zheng            shacmd="$c"
3861e26110cfSFam Zheng            break
3862e26110cfSFam Zheng        fi
3863e26110cfSFam Zheng    done
3864e26110cfSFam Zheng    if test "$shacmd" = ""; then
3865e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3866e26110cfSFam Zheng    fi
3867e18df141SAnthony Liguorifi
3868e18df141SAnthony Liguori
3869e18df141SAnthony Liguori##########################################
3870fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3871fe8fc5aeSPaolo Bonzini
3872fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
38731b0578f5SMurilo Opsfelder Araujo  # probe for the new API
3874fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3875fe8fc5aeSPaolo Bonzini#include <libudev.h>
3876fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3877fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3878fe8fc5aeSPaolo Bonziniint logsink;
3879b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3880b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3881b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3882b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3883b3f1c8c4SPaolo Bonzinistruct udev *udev;
3884b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3885b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3886b3f1c8c4SPaolo Bonzini
3887fe8fc5aeSPaolo Bonziniint main(void) {
3888b3f1c8c4SPaolo Bonzini    udev = udev_new();
3889b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3890fe8fc5aeSPaolo Bonzini    return 0;
3891fe8fc5aeSPaolo Bonzini}
3892fe8fc5aeSPaolo BonziniEOF
3893fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3894fe8fc5aeSPaolo Bonzini    mpathpersist=yes
38951b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
38961b0578f5SMurilo Opsfelder Araujo  else
38971b0578f5SMurilo Opsfelder Araujo    # probe for the old API
38981b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
38991b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
39001b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
39011b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
39021b0578f5SMurilo Opsfelder Araujoint logsink;
39031b0578f5SMurilo Opsfelder Araujoint main(void) {
39041b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
39051b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
39061b0578f5SMurilo Opsfelder Araujo    return 0;
39071b0578f5SMurilo Opsfelder Araujo}
39081b0578f5SMurilo Opsfelder AraujoEOF
39091b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
39101b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
39111b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
3912fe8fc5aeSPaolo Bonzini    else
3913fe8fc5aeSPaolo Bonzini      mpathpersist=no
3914fe8fc5aeSPaolo Bonzini    fi
39151b0578f5SMurilo Opsfelder Araujo  fi
3916fe8fc5aeSPaolo Bonzinielse
3917fe8fc5aeSPaolo Bonzini  mpathpersist=no
3918fe8fc5aeSPaolo Bonzinifi
3919fe8fc5aeSPaolo Bonzini
3920fe8fc5aeSPaolo Bonzini##########################################
3921e5d355d1Saliguori# pthread probe
39224b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
39233c529d93Saliguori
3924e5d355d1Saliguoripthread=no
3925414f0dabSblueswir1cat > $TMPC << EOF
39263c529d93Saliguori#include <pthread.h>
39277a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
39287a42bbe4SStefan Weilint main(void) {
39297a42bbe4SStefan Weil  pthread_t thread;
39307a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
39317a42bbe4SStefan Weil  return 0;
39327a42bbe4SStefan Weil}
3933414f0dabSblueswir1EOF
3934bd00d539SAndreas Färberif compile_prog "" "" ; then
3935bd00d539SAndreas Färber  pthread=yes
3936bd00d539SAndreas Färberelse
3937de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
393852166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3939e5d355d1Saliguori      pthread=yes
3940e3c56761SPeter Portante      found=no
3941e3c56761SPeter Portante      for lib_entry in $LIBS; do
3942e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3943e3c56761SPeter Portante          found=yes
3944e3c56761SPeter Portante          break
3945e3c56761SPeter Portante        fi
3946e3c56761SPeter Portante      done
3947e3c56761SPeter Portante      if test "$found" = "no"; then
39485572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
3949e3c56761SPeter Portante      fi
3950409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
3951de65fe0fSSebastian Herbszt      break
3952414f0dabSblueswir1    fi
3953de65fe0fSSebastian Herbszt  done
3954bd00d539SAndreas Färberfi
3955414f0dabSblueswir1
3956e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
395776ad07a4SPeter Maydell  error_exit "pthread check failed" \
395876ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
3959e5d355d1Saliguorifi
3960e5d355d1Saliguori
3961479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
3962479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
39635c312079SDr. David Alan Gilbertcat > $TMPC << EOF
39645c312079SDr. David Alan Gilbert#include <pthread.h>
39655c312079SDr. David Alan Gilbert
39665c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
39675c312079SDr. David Alan Gilbertint main(void)
39685c312079SDr. David Alan Gilbert{
39695c312079SDr. David Alan Gilbert    pthread_t thread;
39705c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
39715c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
39725c312079SDr. David Alan Gilbert    return 0;
39735c312079SDr. David Alan Gilbert}
39745c312079SDr. David Alan GilbertEOF
39755c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
3976479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
3977479a5747SRoman Bolshakovfi
3978479a5747SRoman Bolshakov
3979479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
3980479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
3981479a5747SRoman Bolshakovcat > $TMPC << EOF
3982479a5747SRoman Bolshakov#include <pthread.h>
3983479a5747SRoman Bolshakov
398412a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
3985479a5747SRoman Bolshakovint main(void)
3986479a5747SRoman Bolshakov{
3987479a5747SRoman Bolshakov    pthread_t thread;
3988479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
3989479a5747SRoman Bolshakov    return 0;
3990479a5747SRoman Bolshakov}
3991479a5747SRoman BolshakovEOF
3992479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
3993479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
39945c312079SDr. David Alan Gilbertfi
39955c312079SDr. David Alan Gilbert
3996bf9298b9Saliguori##########################################
3997f27aaf4bSChristian Brunner# rbd probe
3998f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
3999f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
4000f27aaf4bSChristian Brunner#include <stdio.h>
4001ad32e9c0SJosh Durgin#include <rbd/librbd.h>
4002f27aaf4bSChristian Brunnerint main(void) {
4003ad32e9c0SJosh Durgin    rados_t cluster;
4004ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
4005f27aaf4bSChristian Brunner    return 0;
4006f27aaf4bSChristian Brunner}
4007f27aaf4bSChristian BrunnerEOF
4008ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
4009f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
4010f27aaf4bSChristian Brunner    rbd=yes
4011f27aaf4bSChristian Brunner  else
4012f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
401321684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
4014f27aaf4bSChristian Brunner    fi
4015f27aaf4bSChristian Brunner    rbd=no
4016f27aaf4bSChristian Brunner  fi
4017f27aaf4bSChristian Brunnerfi
4018f27aaf4bSChristian Brunner
4019f27aaf4bSChristian Brunner##########################################
4020b10d49d7SPino Toscano# libssh probe
4021b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
4022b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
4023b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
4024b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
4025b10d49d7SPino Toscano    libssh=yes
40260a12ec87SRichard W.M. Jones  else
4027b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
4028b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
40290a12ec87SRichard W.M. Jones    fi
4030b10d49d7SPino Toscano    libssh=no
40310a12ec87SRichard W.M. Jones  fi
40320a12ec87SRichard W.M. Jonesfi
40330a12ec87SRichard W.M. Jones
40340a12ec87SRichard W.M. Jones##########################################
4035b10d49d7SPino Toscano# Check for libssh 0.8
4036b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
4037b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
4038b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
4039b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
40409a2d462eSRichard W.M. Jones
4041b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
40429a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
4043b10d49d7SPino Toscano#include <libssh/libssh.h>
4044b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
40459a2d462eSRichard W.M. JonesEOF
4046b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
4047b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
40489a2d462eSRichard W.M. Jones  fi
40499a2d462eSRichard W.M. Jonesfi
40509a2d462eSRichard W.M. Jones
40519a2d462eSRichard W.M. Jones##########################################
40525c6c3a6cSChristoph Hellwig# linux-aio probe
40535c6c3a6cSChristoph Hellwig
40545c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
40555c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
40565c6c3a6cSChristoph Hellwig#include <libaio.h>
40575c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
4058832ce9c2SScott Wood#include <stddef.h>
40595c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
40605c6c3a6cSChristoph HellwigEOF
40615c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
40625c6c3a6cSChristoph Hellwig    linux_aio=yes
40635c6c3a6cSChristoph Hellwig  else
40645c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
406521684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
40665c6c3a6cSChristoph Hellwig    fi
40673cfcae3cSLuiz Capitulino    linux_aio=no
40685c6c3a6cSChristoph Hellwig  fi
40695c6c3a6cSChristoph Hellwigfi
4070c10dd856SAarushi Mehta##########################################
4071c10dd856SAarushi Mehta# linux-io-uring probe
4072c10dd856SAarushi Mehta
4073c10dd856SAarushi Mehtaif test "$linux_io_uring" != "no" ; then
4074c10dd856SAarushi Mehta  if $pkg_config liburing; then
4075c10dd856SAarushi Mehta    linux_io_uring_cflags=$($pkg_config --cflags liburing)
4076c10dd856SAarushi Mehta    linux_io_uring_libs=$($pkg_config --libs liburing)
4077c10dd856SAarushi Mehta    linux_io_uring=yes
407873fd282eSStefan Hajnoczi
407973fd282eSStefan Hajnoczi    # io_uring is used in libqemuutil.a where per-file -libs variables are not
408073fd282eSStefan Hajnoczi    # seen by programs linking the archive.  It's not ideal, but just add the
408173fd282eSStefan Hajnoczi    # library dependency globally.
408273fd282eSStefan Hajnoczi    LIBS="$linux_io_uring_libs $LIBS"
4083c10dd856SAarushi Mehta  else
4084c10dd856SAarushi Mehta    if test "$linux_io_uring" = "yes" ; then
4085c10dd856SAarushi Mehta      feature_not_found "linux io_uring" "Install liburing devel"
4086c10dd856SAarushi Mehta    fi
4087c10dd856SAarushi Mehta    linux_io_uring=no
4088c10dd856SAarushi Mehta  fi
4089c10dd856SAarushi Mehtafi
40905c6c3a6cSChristoph Hellwig
40915c6c3a6cSChristoph Hellwig##########################################
40927aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
40933b8acc11SPaolo Bonzini
40947aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
40957aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
40967aaa6a16SPaolo Bonzini    tpm=no
40973b8acc11SPaolo Bonzini  else
40987aaa6a16SPaolo Bonzini    tpm=yes
40997aaa6a16SPaolo Bonzini  fi
41007aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
41017aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
41027aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
41037aaa6a16SPaolo Bonzini  fi
41043b8acc11SPaolo Bonzinifi
41053b8acc11SPaolo Bonzini
41063b8acc11SPaolo Bonzini##########################################
4107758e8e38SVenkateswararao Jujjuri (JV)# attr probe
4108758e8e38SVenkateswararao Jujjuri (JV)
4109ec0d5893SMarc-André Lureaulibattr_libs=
4110758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
4111758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
4112758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
4113758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
4114f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
4115f2338fb4SPavel Borzenkov#include <attr/xattr.h>
4116f2338fb4SPavel Borzenkov#else
41174f26f2b6SAvi Kivity#include <sys/xattr.h>
4118f2338fb4SPavel Borzenkov#endif
4119758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
4120758e8e38SVenkateswararao Jujjuri (JV)EOF
41214f26f2b6SAvi Kivity  if compile_prog "" "" ; then
41224f26f2b6SAvi Kivity    attr=yes
41234f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
4124f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
4125758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
4126ec0d5893SMarc-André Lureau    libattr_libs="-lattr"
4127ec0d5893SMarc-André Lureau    LIBS="$libattr_libs $LIBS"
41284f26f2b6SAvi Kivity    libattr=yes
4129758e8e38SVenkateswararao Jujjuri (JV)  else
4130758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
413121684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
4132758e8e38SVenkateswararao Jujjuri (JV)    fi
4133758e8e38SVenkateswararao Jujjuri (JV)    attr=no
4134758e8e38SVenkateswararao Jujjuri (JV)  fi
4135758e8e38SVenkateswararao Jujjuri (JV)fi
4136758e8e38SVenkateswararao Jujjuri (JV)
4137758e8e38SVenkateswararao Jujjuri (JV)##########################################
4138bf9298b9Saliguori# iovec probe
4139bf9298b9Saliguoricat > $TMPC <<EOF
4140db34f0b3Sblueswir1#include <sys/types.h>
4141bf9298b9Saliguori#include <sys/uio.h>
4142db34f0b3Sblueswir1#include <unistd.h>
4143f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
4144bf9298b9SaliguoriEOF
4145bf9298b9Saliguoriiovec=no
414652166aa0SJuan Quintelaif compile_prog "" "" ; then
4147bf9298b9Saliguori  iovec=yes
4148bf9298b9Saliguorifi
4149bf9298b9Saliguori
4150f652e6afSaurel32##########################################
4151ceb42de8Saliguori# preadv probe
4152ceb42de8Saliguoricat > $TMPC <<EOF
4153ceb42de8Saliguori#include <sys/types.h>
4154ceb42de8Saliguori#include <sys/uio.h>
4155ceb42de8Saliguori#include <unistd.h>
4156c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
4157ceb42de8SaliguoriEOF
4158ceb42de8Saliguoripreadv=no
415952166aa0SJuan Quintelaif compile_prog "" "" ; then
4160ceb42de8Saliguori  preadv=yes
4161ceb42de8Saliguorifi
4162ceb42de8Saliguori
4163ceb42de8Saliguori##########################################
4164f652e6afSaurel32# fdt probe
4165e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
4166e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
4167e169e1e1SPeter Maydellfdt_required=no
4168e169e1e1SPeter Maydellfor target in $target_list; do
4169e169e1e1SPeter Maydell  case $target in
4170c8c35e5fSYoshinori Sato    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu|rx-softmmu)
4171e169e1e1SPeter Maydell      fdt_required=yes
4172e169e1e1SPeter Maydell    ;;
4173e169e1e1SPeter Maydell  esac
4174e169e1e1SPeter Maydelldone
4175e169e1e1SPeter Maydell
4176e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
4177e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
4178e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
4179e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
4180e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
4181e169e1e1SPeter Maydell  fi
4182e169e1e1SPeter Maydell  fdt=yes
41837ba4a4d3SPhilippe Mathieu-Daudéelif test "$fdt" != "yes" ; then
41847ba4a4d3SPhilippe Mathieu-Daudé  fdt=no
4185e169e1e1SPeter Maydellfi
4186e169e1e1SPeter Maydell
4187d599938aSLaurent Vivier# fdt is only required when building softmmu targets
4188d599938aSLaurent Vivierif test -z "$fdt" -a "$softmmu" != "yes" ; then
4189d599938aSLaurent Vivier    fdt="no"
4190d599938aSLaurent Vivierfi
4191d599938aSLaurent Vivier
41922df87df7SJuan Quintelaif test "$fdt" != "no" ; then
4193b41af4baSJuan Quintela  fdt_libs="-lfdt"
419496ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
41956e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
4196f652e6afSaurel32  cat > $TMPC << EOF
419731ce0adbSThomas Huth#include <libfdt.h>
419896ce6545SPeter Crosthwaite#include <libfdt_env.h>
4199fea35ca4SAlexey Kardashevskiyint main(void) { fdt_check_full(NULL, 0); return 0; }
4200f652e6afSaurel32EOF
420152166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
4202a540f158SPeter Crosthwaite    # system DTC is good - use it
4203e3971d61SPhilippe Mathieu-Daudé    fdt=system
4204aef45d51SDaniel P. Berrange  else
4205aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
4206aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
4207aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
4208aef45d51SDaniel P. Berrange      fi
4209aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4210e3971d61SPhilippe Mathieu-Daudé          fdt=git
4211a540f158SPeter Crosthwaite          mkdir -p dtc
4212a540f158SPeter Crosthwaite          symlink "$source_path/dtc/Makefile" "dtc/Makefile"
421325211446SPaolo Bonzini          fdt_cflags="-I${source_path}/dtc/libfdt"
421458683d07SPaolo Bonzini          fdt_ldflags="-Ldtc/libfdt"
42158a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
4216a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
4217aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
4218aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4219aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
4220a540f158SPeter Crosthwaite      else
4221a540f158SPeter Crosthwaite          # don't have and don't want
4222de3a354aSMichael Walle          fdt_libs=
42232df87df7SJuan Quintela          fdt=no
4224f652e6afSaurel32      fi
4225f652e6afSaurel32  fi
4226aef45d51SDaniel P. Berrangefi
4227f652e6afSaurel32
422820ff075bSMichael Walle##########################################
4229fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
4230b1546f32SGerd Hoffmann
4231d52c454aSMarc-André Lureaugbm="no"
4232d52c454aSMarc-André Lureauif $pkg_config gbm; then
4233d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
4234d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
4235d52c454aSMarc-André Lureau    gbm="yes"
4236d52c454aSMarc-André Lureaufi
4237d52c454aSMarc-André Lureau
4238da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
42394939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
42405f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
42415f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
42425f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4243da076ffeSGerd Hoffmann    opengl=yes
4244925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4245925a0400SGerd Hoffmann        gtk_gl="yes"
4246925a0400SGerd Hoffmann    fi
4247cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
424820ff075bSMichael Walle  else
4249da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
4250dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
425120ff075bSMichael Walle    fi
4252f676c67eSJeremy White    opengl_cflags=""
4253da076ffeSGerd Hoffmann    opengl_libs=""
4254da076ffeSGerd Hoffmann    opengl=no
425520ff075bSMichael Walle  fi
425620ff075bSMichael Wallefi
425720ff075bSMichael Walle
4258014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
4259014cb152SGerd Hoffmann  cat > $TMPC << EOF
4260014cb152SGerd Hoffmann#include <epoxy/egl.h>
4261014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
4262014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4263014cb152SGerd Hoffmann#endif
4264014cb152SGerd Hoffmannint main(void) { return 0; }
4265014cb152SGerd HoffmannEOF
4266014cb152SGerd Hoffmann  if compile_prog "" "" ; then
4267014cb152SGerd Hoffmann    opengl_dmabuf=yes
4268014cb152SGerd Hoffmann  fi
4269014cb152SGerd Hoffmannfi
4270c9a12e75SChrysostomos Nanakos
4271e633a5c6SEric Blakeif test "$opengl" = "yes" && test "$have_x11" = "yes"; then
427299e1a93bSPhilippe Mathieu-Daudé  for target in $target_list; do
427399e1a93bSPhilippe Mathieu-Daudé    case $target in
427499e1a93bSPhilippe Mathieu-Daudé      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
427599e1a93bSPhilippe Mathieu-Daudé        need_x11=yes
427699e1a93bSPhilippe Mathieu-Daudé      ;;
427799e1a93bSPhilippe Mathieu-Daudé    esac
427899e1a93bSPhilippe Mathieu-Daudé  done
427999e1a93bSPhilippe Mathieu-Daudéfi
428099e1a93bSPhilippe Mathieu-Daudé
4281ed279a06SKlim Kireev##########################################
4282ed279a06SKlim Kireev# libxml2 probe
4283ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
4284ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
4285ed279a06SKlim Kireev        libxml2="yes"
4286ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4287ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
4288ed279a06SKlim Kireev    else
4289ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4290ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4291ed279a06SKlim Kireev        fi
4292ed279a06SKlim Kireev        libxml2="no"
4293ed279a06SKlim Kireev    fi
4294ed279a06SKlim Kireevfi
4295c9a12e75SChrysostomos Nanakos
4296eb100396SBharata B Rao##########################################
4297eb100396SBharata B Rao# glusterfs probe
4298eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
429965d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4300e01bee08SBharata B Rao    glusterfs="yes"
430189138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
430289138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4303d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4304d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4305d85fa9ebSJeff Cody    fi
430665d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
43070c14fb47SBharata B Rao      glusterfs_discard="yes"
43080c14fb47SBharata B Rao    fi
43097c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4310df3a429aSNiels de Vos      glusterfs_fallocate="yes"
43117c815372SBharata B Rao      glusterfs_zerofill="yes"
43127c815372SBharata B Rao    fi
4313e014dbe7SPrasanna Kumar Kalever    cat > $TMPC << EOF
4314e014dbe7SPrasanna Kumar Kalever#include <glusterfs/api/glfs.h>
4315e014dbe7SPrasanna Kumar Kalever
4316e014dbe7SPrasanna Kumar Kaleverint
4317e014dbe7SPrasanna Kumar Kalevermain(void)
4318e014dbe7SPrasanna Kumar Kalever{
4319e014dbe7SPrasanna Kumar Kalever	/* new glfs_ftruncate() passes two additional args */
4320e014dbe7SPrasanna Kumar Kalever	return glfs_ftruncate(NULL, 0, NULL, NULL);
4321e014dbe7SPrasanna Kumar Kalever}
4322e014dbe7SPrasanna Kumar KaleverEOF
4323e014dbe7SPrasanna Kumar Kalever    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4324e014dbe7SPrasanna Kumar Kalever      glusterfs_ftruncate_has_stat="yes"
4325e014dbe7SPrasanna Kumar Kalever    fi
43260e3b891fSNiels de Vos    cat > $TMPC << EOF
43270e3b891fSNiels de Vos#include <glusterfs/api/glfs.h>
43280e3b891fSNiels de Vos
43290e3b891fSNiels de Vos/* new glfs_io_cbk() passes two additional glfs_stat structs */
43300e3b891fSNiels de Vosstatic void
43310e3b891fSNiels de Vosglusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
43320e3b891fSNiels de Vos{}
43330e3b891fSNiels de Vos
43340e3b891fSNiels de Vosint
43350e3b891fSNiels de Vosmain(void)
43360e3b891fSNiels de Vos{
43370e3b891fSNiels de Vos	glfs_io_cbk iocb = &glusterfs_iocb;
43380e3b891fSNiels de Vos	iocb(NULL, 0 , NULL, NULL, NULL);
43390e3b891fSNiels de Vos	return 0;
43400e3b891fSNiels de Vos}
43410e3b891fSNiels de VosEOF
43420e3b891fSNiels de Vos    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
43430e3b891fSNiels de Vos      glusterfs_iocb_has_stat="yes"
43440e3b891fSNiels de Vos    fi
4345eb100396SBharata B Rao  else
4346eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
43478efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
43488efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4349eb100396SBharata B Rao    fi
4350e01bee08SBharata B Rao    glusterfs="no"
4351eb100396SBharata B Rao  fi
4352eb100396SBharata B Raofi
4353eb100396SBharata B Rao
435439386ac7Saurel32# Check for inotify functions when we are building linux-user
43553b3f24adSaurel32# emulator.  This is done because older glibc versions don't
43563b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
43573b3f24adSaurel32# don't provide them even if kernel supports them.
43583b3f24adSaurel32#
43593b3f24adSaurel32inotify=no
43603b3f24adSaurel32cat > $TMPC << EOF
43613b3f24adSaurel32#include <sys/inotify.h>
43623b3f24adSaurel32
43633b3f24adSaurel32int
43643b3f24adSaurel32main(void)
43653b3f24adSaurel32{
43663b3f24adSaurel32	/* try to start inotify */
43678690e420Saurel32	return inotify_init();
43683b3f24adSaurel32}
43693b3f24adSaurel32EOF
437052166aa0SJuan Quintelaif compile_prog "" "" ; then
43713b3f24adSaurel32  inotify=yes
43723b3f24adSaurel32fi
43733b3f24adSaurel32
4374c05c7a73SRiku Voipioinotify1=no
4375c05c7a73SRiku Voipiocat > $TMPC << EOF
4376c05c7a73SRiku Voipio#include <sys/inotify.h>
4377c05c7a73SRiku Voipio
4378c05c7a73SRiku Voipioint
4379c05c7a73SRiku Voipiomain(void)
4380c05c7a73SRiku Voipio{
4381c05c7a73SRiku Voipio    /* try to start inotify */
4382c05c7a73SRiku Voipio    return inotify_init1(0);
4383c05c7a73SRiku Voipio}
4384c05c7a73SRiku VoipioEOF
4385c05c7a73SRiku Voipioif compile_prog "" "" ; then
4386c05c7a73SRiku Voipio  inotify1=yes
4387c05c7a73SRiku Voipiofi
4388c05c7a73SRiku Voipio
4389099d6b0fSRiku Voipio# check if pipe2 is there
4390099d6b0fSRiku Voipiopipe2=no
4391099d6b0fSRiku Voipiocat > $TMPC << EOF
4392099d6b0fSRiku Voipio#include <unistd.h>
4393099d6b0fSRiku Voipio#include <fcntl.h>
4394099d6b0fSRiku Voipio
4395099d6b0fSRiku Voipioint main(void)
4396099d6b0fSRiku Voipio{
4397099d6b0fSRiku Voipio    int pipefd[2];
43989bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4399099d6b0fSRiku Voipio}
4400099d6b0fSRiku VoipioEOF
440152166aa0SJuan Quintelaif compile_prog "" "" ; then
4402099d6b0fSRiku Voipio  pipe2=yes
4403099d6b0fSRiku Voipiofi
4404099d6b0fSRiku Voipio
440540ff6d7eSKevin Wolf# check if accept4 is there
440640ff6d7eSKevin Wolfaccept4=no
440740ff6d7eSKevin Wolfcat > $TMPC << EOF
440840ff6d7eSKevin Wolf#include <sys/socket.h>
440940ff6d7eSKevin Wolf#include <stddef.h>
441040ff6d7eSKevin Wolf
441140ff6d7eSKevin Wolfint main(void)
441240ff6d7eSKevin Wolf{
441340ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
441440ff6d7eSKevin Wolf    return 0;
441540ff6d7eSKevin Wolf}
441640ff6d7eSKevin WolfEOF
441740ff6d7eSKevin Wolfif compile_prog "" "" ; then
441840ff6d7eSKevin Wolf  accept4=yes
441940ff6d7eSKevin Wolffi
442040ff6d7eSKevin Wolf
44213ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
44223ce34dfbSvibisreenivasansplice=no
44233ce34dfbSvibisreenivasancat > $TMPC << EOF
44243ce34dfbSvibisreenivasan#include <unistd.h>
44253ce34dfbSvibisreenivasan#include <fcntl.h>
44263ce34dfbSvibisreenivasan#include <limits.h>
44273ce34dfbSvibisreenivasan
44283ce34dfbSvibisreenivasanint main(void)
44293ce34dfbSvibisreenivasan{
443066ea0f22SStefan Weil    int len, fd = 0;
44313ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
44323ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
44333ce34dfbSvibisreenivasan    return 0;
44343ce34dfbSvibisreenivasan}
44353ce34dfbSvibisreenivasanEOF
443652166aa0SJuan Quintelaif compile_prog "" "" ; then
44373ce34dfbSvibisreenivasan  splice=yes
44383ce34dfbSvibisreenivasanfi
44393ce34dfbSvibisreenivasan
4440dcc38d1cSMarcelo Tosatti##########################################
4441a99d57bbSWanlong Gao# libnuma probe
4442a99d57bbSWanlong Gao
4443a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4444a99d57bbSWanlong Gao  cat > $TMPC << EOF
4445a99d57bbSWanlong Gao#include <numa.h>
4446a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4447a99d57bbSWanlong GaoEOF
4448a99d57bbSWanlong Gao
4449a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4450a99d57bbSWanlong Gao    numa=yes
4451ab318051SMarc-André Lureau    numa_libs="-lnuma"
4452a99d57bbSWanlong Gao  else
4453a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4454a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4455a99d57bbSWanlong Gao    fi
4456a99d57bbSWanlong Gao    numa=no
4457a99d57bbSWanlong Gao  fi
4458a99d57bbSWanlong Gaofi
4459a99d57bbSWanlong Gao
44607b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
44617b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
44627b01cb97SAlexandre Derumier    exit 1
44637b01cb97SAlexandre Derumierfi
44647b01cb97SAlexandre Derumier
44655a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
44665a22ab71SYang Zhong# do not support it.
44675a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
44685a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
44695a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
44705a22ab71SYang Zhong    fi
44715a22ab71SYang Zhong    malloc_trim="no"
44725a22ab71SYang Zhongfi
44735a22ab71SYang Zhong
44745a22ab71SYang Zhong#######################################
44755a22ab71SYang Zhong# malloc_trim
44765a22ab71SYang Zhong
44775a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
44785a22ab71SYang Zhong    cat > $TMPC << EOF
44795a22ab71SYang Zhong#include <malloc.h>
44805a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
44815a22ab71SYang ZhongEOF
44825a22ab71SYang Zhong    if compile_prog "" "" ; then
44835a22ab71SYang Zhong        malloc_trim="yes"
44845a22ab71SYang Zhong    else
44855a22ab71SYang Zhong        malloc_trim="no"
44865a22ab71SYang Zhong    fi
44875a22ab71SYang Zhongfi
44885a22ab71SYang Zhong
4489a99d57bbSWanlong Gao##########################################
44902847b469SFam Zheng# tcmalloc probe
44912847b469SFam Zheng
44922847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
44932847b469SFam Zheng  cat > $TMPC << EOF
44942847b469SFam Zheng#include <stdlib.h>
4495f2dfe54cSLeonid Blochint main(void) {
4496f2dfe54cSLeonid Bloch    void *tmp = malloc(1);
4497f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4498f2dfe54cSLeonid Bloch        return 0;
4499f2dfe54cSLeonid Bloch    }
4500f2dfe54cSLeonid Bloch    return 1;
4501f2dfe54cSLeonid Bloch}
45022847b469SFam ZhengEOF
45032847b469SFam Zheng
45042847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
45052847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
45062847b469SFam Zheng  else
45072847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
45082847b469SFam Zheng  fi
45092847b469SFam Zhengfi
45102847b469SFam Zheng
45112847b469SFam Zheng##########################################
45127b01cb97SAlexandre Derumier# jemalloc probe
45137b01cb97SAlexandre Derumier
45147b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
45157b01cb97SAlexandre Derumier  cat > $TMPC << EOF
45167b01cb97SAlexandre Derumier#include <stdlib.h>
4517f2dfe54cSLeonid Blochint main(void) {
4518f2dfe54cSLeonid Bloch    void *tmp = malloc(1);
4519f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4520f2dfe54cSLeonid Bloch        return 0;
4521f2dfe54cSLeonid Bloch    }
4522f2dfe54cSLeonid Bloch    return 1;
4523f2dfe54cSLeonid Bloch}
45247b01cb97SAlexandre DerumierEOF
45257b01cb97SAlexandre Derumier
45267b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
45277b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
45287b01cb97SAlexandre Derumier  else
45297b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
45307b01cb97SAlexandre Derumier  fi
45317b01cb97SAlexandre Derumierfi
45327b01cb97SAlexandre Derumier
45337b01cb97SAlexandre Derumier##########################################
4534dcc38d1cSMarcelo Tosatti# signalfd probe
4535dcc38d1cSMarcelo Tosattisignalfd="no"
4536dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4537dcc38d1cSMarcelo Tosatti#include <unistd.h>
4538dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4539dcc38d1cSMarcelo Tosatti#include <signal.h>
4540dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4541dcc38d1cSMarcelo TosattiEOF
4542dcc38d1cSMarcelo Tosatti
4543dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4544dcc38d1cSMarcelo Tosatti  signalfd=yes
4545dcc38d1cSMarcelo Tosattifi
4546dcc38d1cSMarcelo Tosatti
4547d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4548d339d766SRichard W.M. Jonesoptreset="no"
4549d339d766SRichard W.M. Jonescat > $TMPC << EOF
4550d339d766SRichard W.M. Jones#include <getopt.h>
4551d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4552d339d766SRichard W.M. JonesEOF
4553d339d766SRichard W.M. Jones
4554d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4555d339d766SRichard W.M. Jones  optreset=yes
4556d339d766SRichard W.M. Jonesfi
4557d339d766SRichard W.M. Jones
4558c2882b96SRiku Voipio# check if eventfd is supported
4559c2882b96SRiku Voipioeventfd=no
4560c2882b96SRiku Voipiocat > $TMPC << EOF
4561c2882b96SRiku Voipio#include <sys/eventfd.h>
4562c2882b96SRiku Voipio
4563c2882b96SRiku Voipioint main(void)
4564c2882b96SRiku Voipio{
456555cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4566c2882b96SRiku Voipio}
4567c2882b96SRiku VoipioEOF
4568c2882b96SRiku Voipioif compile_prog "" "" ; then
4569c2882b96SRiku Voipio  eventfd=yes
4570c2882b96SRiku Voipiofi
4571c2882b96SRiku Voipio
4572751bcc39SMarc-André Lureau# check if memfd is supported
4573751bcc39SMarc-André Lureaumemfd=no
4574751bcc39SMarc-André Lureaucat > $TMPC << EOF
457575e5b70eSPaolo Bonzini#include <sys/mman.h>
4576751bcc39SMarc-André Lureau
4577751bcc39SMarc-André Lureauint main(void)
4578751bcc39SMarc-André Lureau{
4579751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4580751bcc39SMarc-André Lureau}
4581751bcc39SMarc-André LureauEOF
4582751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4583751bcc39SMarc-André Lureau  memfd=yes
4584751bcc39SMarc-André Lureaufi
4585751bcc39SMarc-André Lureau
4586955727d2SCortland Tölva# check for usbfs
4587955727d2SCortland Tölvahave_usbfs=no
4588955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
458996566d09SThomas Petazzoni  cat > $TMPC << EOF
459096566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
459196566d09SThomas Petazzoni
459296566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
459396566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
459496566d09SThomas Petazzoni#endif
459596566d09SThomas Petazzoni
459696566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
459796566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
459896566d09SThomas Petazzoni#endif
459996566d09SThomas Petazzoni
460096566d09SThomas Petazzoniint main(void)
460196566d09SThomas Petazzoni{
460296566d09SThomas Petazzoni    return 0;
460396566d09SThomas Petazzoni}
460496566d09SThomas PetazzoniEOF
460596566d09SThomas Petazzoni  if compile_prog "" ""; then
4606955727d2SCortland Tölva    have_usbfs=yes
4607955727d2SCortland Tölva  fi
4608955727d2SCortland Tölvafi
4609751bcc39SMarc-André Lureau
4610d0927938SUlrich Hecht# check for fallocate
4611d0927938SUlrich Hechtfallocate=no
4612d0927938SUlrich Hechtcat > $TMPC << EOF
4613d0927938SUlrich Hecht#include <fcntl.h>
4614d0927938SUlrich Hecht
4615d0927938SUlrich Hechtint main(void)
4616d0927938SUlrich Hecht{
4617d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4618d0927938SUlrich Hecht    return 0;
4619d0927938SUlrich Hecht}
4620d0927938SUlrich HechtEOF
46218fb03151SPeter Maydellif compile_prog "" "" ; then
4622d0927938SUlrich Hecht  fallocate=yes
4623d0927938SUlrich Hechtfi
4624d0927938SUlrich Hecht
46253d4fa43eSKusanagi Kouichi# check for fallocate hole punching
46263d4fa43eSKusanagi Kouichifallocate_punch_hole=no
46273d4fa43eSKusanagi Kouichicat > $TMPC << EOF
46283d4fa43eSKusanagi Kouichi#include <fcntl.h>
46293d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
46303d4fa43eSKusanagi Kouichi
46313d4fa43eSKusanagi Kouichiint main(void)
46323d4fa43eSKusanagi Kouichi{
46333d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
46343d4fa43eSKusanagi Kouichi    return 0;
46353d4fa43eSKusanagi Kouichi}
46363d4fa43eSKusanagi KouichiEOF
46373d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
46383d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
46393d4fa43eSKusanagi Kouichifi
46403d4fa43eSKusanagi Kouichi
4641b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4642b953f075SDenis V. Lunevfallocate_zero_range=no
4643b953f075SDenis V. Lunevcat > $TMPC << EOF
4644b953f075SDenis V. Lunev#include <fcntl.h>
4645b953f075SDenis V. Lunev#include <linux/falloc.h>
4646b953f075SDenis V. Lunev
4647b953f075SDenis V. Lunevint main(void)
4648b953f075SDenis V. Lunev{
4649b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4650b953f075SDenis V. Lunev    return 0;
4651b953f075SDenis V. Lunev}
4652b953f075SDenis V. LunevEOF
4653b953f075SDenis V. Lunevif compile_prog "" "" ; then
4654b953f075SDenis V. Lunev  fallocate_zero_range=yes
4655b953f075SDenis V. Lunevfi
4656b953f075SDenis V. Lunev
4657ed911435SKevin Wolf# check for posix_fallocate
4658ed911435SKevin Wolfposix_fallocate=no
4659ed911435SKevin Wolfcat > $TMPC << EOF
4660ed911435SKevin Wolf#include <fcntl.h>
4661ed911435SKevin Wolf
4662ed911435SKevin Wolfint main(void)
4663ed911435SKevin Wolf{
4664ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4665ed911435SKevin Wolf    return 0;
4666ed911435SKevin Wolf}
4667ed911435SKevin WolfEOF
4668ed911435SKevin Wolfif compile_prog "" "" ; then
4669ed911435SKevin Wolf    posix_fallocate=yes
4670ed911435SKevin Wolffi
4671ed911435SKevin Wolf
4672c727f47dSPeter Maydell# check for sync_file_range
4673c727f47dSPeter Maydellsync_file_range=no
4674c727f47dSPeter Maydellcat > $TMPC << EOF
4675c727f47dSPeter Maydell#include <fcntl.h>
4676c727f47dSPeter Maydell
4677c727f47dSPeter Maydellint main(void)
4678c727f47dSPeter Maydell{
4679c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4680c727f47dSPeter Maydell    return 0;
4681c727f47dSPeter Maydell}
4682c727f47dSPeter MaydellEOF
46838fb03151SPeter Maydellif compile_prog "" "" ; then
4684c727f47dSPeter Maydell  sync_file_range=yes
4685c727f47dSPeter Maydellfi
4686c727f47dSPeter Maydell
4687dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4688dace20dcSPeter Maydellfiemap=no
4689dace20dcSPeter Maydellcat > $TMPC << EOF
4690dace20dcSPeter Maydell#include <sys/ioctl.h>
4691dace20dcSPeter Maydell#include <linux/fs.h>
4692dace20dcSPeter Maydell#include <linux/fiemap.h>
4693dace20dcSPeter Maydell
4694dace20dcSPeter Maydellint main(void)
4695dace20dcSPeter Maydell{
4696dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4697dace20dcSPeter Maydell    return 0;
4698dace20dcSPeter Maydell}
4699dace20dcSPeter MaydellEOF
47008fb03151SPeter Maydellif compile_prog "" "" ; then
4701dace20dcSPeter Maydell  fiemap=yes
4702dace20dcSPeter Maydellfi
4703dace20dcSPeter Maydell
4704d0927938SUlrich Hecht# check for dup3
4705d0927938SUlrich Hechtdup3=no
4706d0927938SUlrich Hechtcat > $TMPC << EOF
4707d0927938SUlrich Hecht#include <unistd.h>
4708d0927938SUlrich Hecht
4709d0927938SUlrich Hechtint main(void)
4710d0927938SUlrich Hecht{
4711d0927938SUlrich Hecht    dup3(0, 0, 0);
4712d0927938SUlrich Hecht    return 0;
4713d0927938SUlrich Hecht}
4714d0927938SUlrich HechtEOF
471578f5d726SJan Kiszkaif compile_prog "" "" ; then
4716d0927938SUlrich Hecht  dup3=yes
4717d0927938SUlrich Hechtfi
4718d0927938SUlrich Hecht
47194e0c6529SAlex Bligh# check for ppoll support
47204e0c6529SAlex Blighppoll=no
47214e0c6529SAlex Blighcat > $TMPC << EOF
47224e0c6529SAlex Bligh#include <poll.h>
47234e0c6529SAlex Bligh
47244e0c6529SAlex Blighint main(void)
47254e0c6529SAlex Bligh{
47264e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
47274e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
47284e0c6529SAlex Bligh    return 0;
47294e0c6529SAlex Bligh}
47304e0c6529SAlex BlighEOF
47314e0c6529SAlex Blighif compile_prog "" "" ; then
47324e0c6529SAlex Bligh  ppoll=yes
47334e0c6529SAlex Blighfi
47344e0c6529SAlex Bligh
4735cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4736cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4737cd758dd0SAlex Blighcat > $TMPC << EOF
4738cd758dd0SAlex Bligh#include <sys/prctl.h>
4739cd758dd0SAlex Bligh
4740cd758dd0SAlex Blighint main(void)
4741cd758dd0SAlex Bligh{
4742cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4743cd758dd0SAlex Bligh    return 0;
4744cd758dd0SAlex Bligh}
4745cd758dd0SAlex BlighEOF
4746cd758dd0SAlex Blighif compile_prog "" "" ; then
4747cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4748cd758dd0SAlex Blighfi
4749cd758dd0SAlex Bligh
47503b6edd16SPeter Maydell# check for epoll support
47513b6edd16SPeter Maydellepoll=no
47523b6edd16SPeter Maydellcat > $TMPC << EOF
47533b6edd16SPeter Maydell#include <sys/epoll.h>
47543b6edd16SPeter Maydell
47553b6edd16SPeter Maydellint main(void)
47563b6edd16SPeter Maydell{
47573b6edd16SPeter Maydell    epoll_create(0);
47583b6edd16SPeter Maydell    return 0;
47593b6edd16SPeter Maydell}
47603b6edd16SPeter MaydellEOF
47618fb03151SPeter Maydellif compile_prog "" "" ; then
47623b6edd16SPeter Maydell  epoll=yes
47633b6edd16SPeter Maydellfi
47643b6edd16SPeter Maydell
4765227f0214SPeter Maydell# epoll_create1 is a later addition
4766227f0214SPeter Maydell# so we must check separately for its presence
47673b6edd16SPeter Maydellepoll_create1=no
47683b6edd16SPeter Maydellcat > $TMPC << EOF
47693b6edd16SPeter Maydell#include <sys/epoll.h>
47703b6edd16SPeter Maydell
47713b6edd16SPeter Maydellint main(void)
47723b6edd16SPeter Maydell{
477319e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
477419e83f6bSPeter Maydell     * a function being called. This is necessary so that on
477519e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
477619e83f6bSPeter Maydell     * the library but not declared in the header file we will
477719e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
477819e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
477919e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
478019e83f6bSPeter Maydell     */
4781c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
47823b6edd16SPeter Maydell}
47833b6edd16SPeter MaydellEOF
47848fb03151SPeter Maydellif compile_prog "" "" ; then
47853b6edd16SPeter Maydell  epoll_create1=yes
47863b6edd16SPeter Maydellfi
47873b6edd16SPeter Maydell
4788a8fd1abaSPeter Maydell# check for sendfile support
4789a8fd1abaSPeter Maydellsendfile=no
4790a8fd1abaSPeter Maydellcat > $TMPC << EOF
4791a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4792a8fd1abaSPeter Maydell
4793a8fd1abaSPeter Maydellint main(void)
4794a8fd1abaSPeter Maydell{
4795a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4796a8fd1abaSPeter Maydell}
4797a8fd1abaSPeter MaydellEOF
4798a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4799a8fd1abaSPeter Maydell  sendfile=yes
4800a8fd1abaSPeter Maydellfi
4801a8fd1abaSPeter Maydell
480251834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
480351834341SRiku Voipiotimerfd=no
480451834341SRiku Voipiocat > $TMPC << EOF
480551834341SRiku Voipio#include <sys/timerfd.h>
480651834341SRiku Voipio
480751834341SRiku Voipioint main(void)
480851834341SRiku Voipio{
480951834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
481051834341SRiku Voipio}
481151834341SRiku VoipioEOF
481251834341SRiku Voipioif compile_prog "" "" ; then
481351834341SRiku Voipio  timerfd=yes
481451834341SRiku Voipiofi
481551834341SRiku Voipio
48169af5c906SRiku Voipio# check for setns and unshare support
48179af5c906SRiku Voipiosetns=no
48189af5c906SRiku Voipiocat > $TMPC << EOF
48199af5c906SRiku Voipio#include <sched.h>
48209af5c906SRiku Voipio
48219af5c906SRiku Voipioint main(void)
48229af5c906SRiku Voipio{
48239af5c906SRiku Voipio    int ret;
48249af5c906SRiku Voipio    ret = setns(0, 0);
48259af5c906SRiku Voipio    ret = unshare(0);
48269af5c906SRiku Voipio    return ret;
48279af5c906SRiku Voipio}
48289af5c906SRiku VoipioEOF
48299af5c906SRiku Voipioif compile_prog "" "" ; then
48309af5c906SRiku Voipio  setns=yes
48319af5c906SRiku Voipiofi
48329af5c906SRiku Voipio
483338860a03SAleksandar Markovic# clock_adjtime probe
483438860a03SAleksandar Markovicclock_adjtime=no
483538860a03SAleksandar Markoviccat > $TMPC <<EOF
483638860a03SAleksandar Markovic#include <time.h>
483738860a03SAleksandar Markovic
483838860a03SAleksandar Markovicint main(void)
483938860a03SAleksandar Markovic{
484038860a03SAleksandar Markovic    return clock_adjtime(0, 0);
484138860a03SAleksandar Markovic}
484238860a03SAleksandar MarkovicEOF
484338860a03SAleksandar Markovicclock_adjtime=no
484438860a03SAleksandar Markovicif compile_prog "" "" ; then
484538860a03SAleksandar Markovic  clock_adjtime=yes
484638860a03SAleksandar Markovicfi
484738860a03SAleksandar Markovic
48485a03cd00SAleksandar Markovic# syncfs probe
48495a03cd00SAleksandar Markovicsyncfs=no
48505a03cd00SAleksandar Markoviccat > $TMPC <<EOF
48515a03cd00SAleksandar Markovic#include <unistd.h>
48525a03cd00SAleksandar Markovic
48535a03cd00SAleksandar Markovicint main(void)
48545a03cd00SAleksandar Markovic{
48555a03cd00SAleksandar Markovic    return syncfs(0);
48565a03cd00SAleksandar Markovic}
48575a03cd00SAleksandar MarkovicEOF
48585a03cd00SAleksandar Markovicsyncfs=no
48595a03cd00SAleksandar Markovicif compile_prog "" "" ; then
48605a03cd00SAleksandar Markovic  syncfs=yes
48615a03cd00SAleksandar Markovicfi
48625a03cd00SAleksandar Markovic
4863db37dd89SAleksandar Markovic# check for kcov support (kernel must be 4.4+, compiled with certain options)
4864db37dd89SAleksandar Markovickcov=no
4865db37dd89SAleksandar Markovicif check_include sys/kcov.h ; then
4866db37dd89SAleksandar Markovic    kcov=yes
4867db37dd89SAleksandar Markovicfi
4868db37dd89SAleksandar Markovic
4869d6092e08SFilip Bozuta# check for btrfs filesystem support (kernel must be 3.9+)
4870d6092e08SFilip Bozutabtrfs=no
4871d6092e08SFilip Bozutaif check_include linux/btrfs.h ; then
4872d6092e08SFilip Bozuta    btrfs=yes
4873d6092e08SFilip Bozutafi
4874d6092e08SFilip Bozuta
4875516e8b7dSPeter Maydell# If we're making warnings fatal, apply this to Sphinx runs as well
4876516e8b7dSPeter Maydellsphinx_werror=""
4877516e8b7dSPeter Maydellif test "$werror" = "yes"; then
4878516e8b7dSPeter Maydell    sphinx_werror="-W"
4879516e8b7dSPeter Maydellfi
4880516e8b7dSPeter Maydell
48815f71eac0SPeter Maydell# Check we have a new enough version of sphinx-build
48825f71eac0SPeter Maydellhas_sphinx_build() {
48835f71eac0SPeter Maydell    # This is a bit awkward but works: create a trivial document and
48845f71eac0SPeter Maydell    # try to run it with our configuration file (which enforces a
48855f71eac0SPeter Maydell    # version requirement). This will fail if either
48865f71eac0SPeter Maydell    # sphinx-build doesn't exist at all or if it is too old.
48875f71eac0SPeter Maydell    mkdir -p "$TMPDIR1/sphinx"
48885f71eac0SPeter Maydell    touch "$TMPDIR1/sphinx/index.rst"
4889988ae6c3SAlex Bennée    "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
4890988ae6c3SAlex Bennée                    -b html "$TMPDIR1/sphinx" \
4891988ae6c3SAlex Bennée                    "$TMPDIR1/sphinx/out"  >> config.log 2>&1
48925f71eac0SPeter Maydell}
48935f71eac0SPeter Maydell
4894cc8ae6deSpbrook# Check if tools are available to build documentation.
4895a25dba17SJuan Quintelaif test "$docs" != "no" ; then
4896758b617aSPeter Maydell  if has_sphinx_build; then
4897758b617aSPeter Maydell    sphinx_ok=yes
4898758b617aSPeter Maydell  else
4899758b617aSPeter Maydell    sphinx_ok=no
4900758b617aSPeter Maydell  fi
4901758b617aSPeter Maydell  if has makeinfo && has pod2man && test "$sphinx_ok" = "yes"; then
4902a25dba17SJuan Quintela    docs=yes
490383a3ab8bSJuan Quintela  else
4904a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
4905758b617aSPeter Maydell      if has $sphinx_build && test "$sphinx_ok" != "yes"; then
4906758b617aSPeter Maydell        echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
4907758b617aSPeter Maydell      fi
4908758b617aSPeter Maydell      feature_not_found "docs" "Install texinfo, Perl/perl-podlators and a Python 3 version of python-sphinx"
490983a3ab8bSJuan Quintela    fi
4910a25dba17SJuan Quintela    docs=no
491183a3ab8bSJuan Quintela  fi
4912cc8ae6deSpbrookfi
4913cc8ae6deSpbrook
4914f514f41cSStefan Weil# Search for bswap_32 function
49156ae9a1f4SJuan Quintelabyteswap_h=no
49166ae9a1f4SJuan Quintelacat > $TMPC << EOF
49176ae9a1f4SJuan Quintela#include <byteswap.h>
49186ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
49196ae9a1f4SJuan QuintelaEOF
492052166aa0SJuan Quintelaif compile_prog "" "" ; then
49216ae9a1f4SJuan Quintela  byteswap_h=yes
49226ae9a1f4SJuan Quintelafi
49236ae9a1f4SJuan Quintela
492475f13596SStefan Weil# Search for bswap32 function
49256ae9a1f4SJuan Quintelabswap_h=no
49266ae9a1f4SJuan Quintelacat > $TMPC << EOF
49276ae9a1f4SJuan Quintela#include <sys/endian.h>
49286ae9a1f4SJuan Quintela#include <sys/types.h>
49296ae9a1f4SJuan Quintela#include <machine/bswap.h>
49306ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
49316ae9a1f4SJuan QuintelaEOF
493252166aa0SJuan Quintelaif compile_prog "" "" ; then
49336ae9a1f4SJuan Quintela  bswap_h=yes
49346ae9a1f4SJuan Quintelafi
49356ae9a1f4SJuan Quintela
4936da93a1fdSaliguori##########################################
4937e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4938c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4939e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
49403c33ea96SPaolo Bonzini    libiscsi="yes"
4941ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4942ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4943c589b249SRonnie Sahlberg  else
4944c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4945e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4946c589b249SRonnie Sahlberg    fi
4947c589b249SRonnie Sahlberg    libiscsi="no"
4948c589b249SRonnie Sahlberg  fi
4949c589b249SRonnie Sahlbergfi
4950c589b249SRonnie Sahlberg
4951c589b249SRonnie Sahlberg##########################################
4952da93a1fdSaliguori# Do we need librt
49538bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
49548bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
49558bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
49568bacde8dSNatanael Copa# function in addition.
4957da93a1fdSaliguoricat > $TMPC <<EOF
4958da93a1fdSaliguori#include <signal.h>
4959da93a1fdSaliguori#include <time.h>
49608bacde8dSNatanael Copaint main(void) {
49618bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
49628bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
49638bacde8dSNatanael Copa}
4964da93a1fdSaliguoriEOF
4965da93a1fdSaliguori
496652166aa0SJuan Quintelaif compile_prog "" "" ; then
496707ffa4bdSJuan Quintela  :
49688bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
496918e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
497018e588b1SRick Liu  LIBS="$LIBS -lrt"
4971da93a1fdSaliguorifi
4972da93a1fdSaliguori
4973d99e97e6SThomas Huth# Check whether we need to link libutil for openpty()
4974d99e97e6SThomas Huthcat > $TMPC << EOF
4975d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
4976d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
4977d99e97e6SThomas HuthEOF
4978d99e97e6SThomas Huth
49799df8b20dSThomas Huthhave_openpty="no"
49809df8b20dSThomas Huthif compile_prog "" "" ; then
49819df8b20dSThomas Huth  have_openpty="yes"
49829df8b20dSThomas Huthelse
4983d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
4984d99e97e6SThomas Huth    libs_tools="-lutil $libs_tools"
49859df8b20dSThomas Huth    have_openpty="yes"
4986d99e97e6SThomas Huth  fi
49876362a53fSJuan Quintelafi
49886362a53fSJuan Quintela
4989de5071c5SBlue Swirl##########################################
4990cd4ec0b4SGerd Hoffmann# spice probe
4991cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
4992cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
4993cd4ec0b4SGerd Hoffmann#include <spice.h>
4994cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
4995cd4ec0b4SGerd HoffmannEOF
4996710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
4997710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
49981b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
499965d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
5000cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
5001cd4ec0b4SGerd Hoffmann    spice="yes"
5002cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
5003cd4ec0b4SGerd Hoffmann  else
5004cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
50058efc9363SHu Tao      feature_not_found "spice" \
50061b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
5007cd4ec0b4SGerd Hoffmann    fi
5008cd4ec0b4SGerd Hoffmann    spice="no"
5009cd4ec0b4SGerd Hoffmann  fi
5010cd4ec0b4SGerd Hoffmannfi
5011cd4ec0b4SGerd Hoffmann
50127b02f544SMarc-André Lureau# check for smartcard support
50137b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
50140f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
50157b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
50167b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
50177b02f544SMarc-André Lureau        smartcard="yes"
5018111a38b0SRobert Relyea    else
50197b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
50207b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
5021111a38b0SRobert Relyea        fi
50227b02f544SMarc-André Lureau        smartcard="no"
5023111a38b0SRobert Relyea    fi
5024111a38b0SRobert Relyeafi
5025111a38b0SRobert Relyea
50262b2325ffSGerd Hoffmann# check for libusb
50272b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
502865d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
50292b2325ffSGerd Hoffmann        libusb="yes"
5030ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
5031ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
50322b2325ffSGerd Hoffmann    else
50332b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
50348efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
50352b2325ffSGerd Hoffmann        fi
50362b2325ffSGerd Hoffmann        libusb="no"
50372b2325ffSGerd Hoffmann    fi
50382b2325ffSGerd Hoffmannfi
50392b2325ffSGerd Hoffmann
504069354a83SHans de Goede# check for usbredirparser for usb network redirection support
504169354a83SHans de Goedeif test "$usb_redir" != "no" ; then
504265d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
504369354a83SHans de Goede        usb_redir="yes"
5044ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
5045ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
504669354a83SHans de Goede    else
504769354a83SHans de Goede        if test "$usb_redir" = "yes"; then
504821684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
504969354a83SHans de Goede        fi
505069354a83SHans de Goede        usb_redir="no"
505169354a83SHans de Goede    fi
505269354a83SHans de Goedefi
505369354a83SHans de Goede
5054cd4ec0b4SGerd Hoffmann##########################################
5055d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
5056d9840e25STomoki Sekiyama
5057e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5058e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
5059d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
5060690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
5061d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
5062d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
5063690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
5064d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
5065d9840e25STomoki Sekiyama	  ;;
5066690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
5067d9840e25STomoki Sekiyama  esac
5068d9840e25STomoki Sekiyama  cat > $TMPC << EOF
5069d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
5070d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
5071d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
5072d9840e25STomoki SekiyamaEOF
5073d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
5074d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
5075d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
5076315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
5077f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
5078d9840e25STomoki Sekiyama  else
5079d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
5080d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
5081d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
5082d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
5083d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
5084d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
5085d9840e25STomoki Sekiyama      feature_not_found "VSS support"
5086d9840e25STomoki Sekiyama    fi
5087d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
5088d9840e25STomoki Sekiyama  fi
5089d9840e25STomoki Sekiyamafi
5090d9840e25STomoki Sekiyama
5091d9840e25STomoki Sekiyama##########################################
5092d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
5093d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
5094d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
5095d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
5096d9840e25STomoki Sekiyama
5097e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5098e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
5099d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
5100d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
5101d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
5102d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
5103d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
5104d9840e25STomoki Sekiyama    else
5105d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
5106d9840e25STomoki Sekiyama    fi
5107d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
5108d9840e25STomoki Sekiyama    win_sdk=""
5109d9840e25STomoki Sekiyama  fi
5110d9840e25STomoki Sekiyamafi
5111d9840e25STomoki Sekiyama
5112d9840e25STomoki Sekiyama##########################################
511350cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
5114e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
511550cbebb9SMichael Roth  cat > $TMPC << EOF
511650cbebb9SMichael Roth#include <windows.h>
511750cbebb9SMichael Roth#include <ntddscsi.h>
511850cbebb9SMichael Rothint main(void) {
511950cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
512050cbebb9SMichael Roth#error Missing required ioctl definitions
512150cbebb9SMichael Roth#endif
512250cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
512350cbebb9SMichael Roth  return addr.Lun;
512450cbebb9SMichael Roth}
512550cbebb9SMichael RothEOF
512650cbebb9SMichael Roth  if compile_prog "" "" ; then
512750cbebb9SMichael Roth    guest_agent_ntddscsi=yes
5128996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
512950cbebb9SMichael Roth  fi
513050cbebb9SMichael Rothfi
513150cbebb9SMichael Roth
513250cbebb9SMichael Roth##########################################
51339d9e1521SGerd Hoffmann# virgl renderer probe
51349d9e1521SGerd Hoffmann
51359d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
51369d9e1521SGerd Hoffmann  cat > $TMPC << EOF
51379d9e1521SGerd Hoffmann#include <virglrenderer.h>
51389d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
51399d9e1521SGerd HoffmannEOF
51409d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
51419d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
514247479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
51439d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
51449d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
51459d9e1521SGerd Hoffmann    virglrenderer="yes"
51469d9e1521SGerd Hoffmann  else
51479d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
51489d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
51499d9e1521SGerd Hoffmann    fi
51509d9e1521SGerd Hoffmann    virglrenderer="no"
51519d9e1521SGerd Hoffmann  fi
51529d9e1521SGerd Hoffmannfi
51539d9e1521SGerd Hoffmann
51549d9e1521SGerd Hoffmann##########################################
51558ca80760SRichard Henderson# capstone
51568ca80760SRichard Henderson
5157e219c499SRichard Hendersoncase "$capstone" in
5158e219c499SRichard Henderson  "" | yes)
51598ca80760SRichard Henderson    if $pkg_config capstone; then
5160e219c499SRichard Henderson      capstone=system
5161e633a5c6SEric Blake    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5162e219c499SRichard Henderson      capstone=git
5163e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
5164e219c499SRichard Henderson      capstone=internal
5165e219c499SRichard Henderson    elif test -z "$capstone" ; then
5166e219c499SRichard Henderson      capstone=no
5167e219c499SRichard Henderson    else
5168e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
5169e219c499SRichard Henderson    fi
5170e219c499SRichard Henderson    ;;
5171e219c499SRichard Henderson
5172e219c499SRichard Henderson  system)
5173e219c499SRichard Henderson    if ! $pkg_config capstone; then
5174e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
5175e219c499SRichard Henderson    fi
5176e219c499SRichard Henderson    ;;
5177e219c499SRichard Hendersonesac
5178e219c499SRichard Henderson
5179e219c499SRichard Hendersoncase "$capstone" in
5180e219c499SRichard Henderson  git | internal)
5181e219c499SRichard Henderson    if test "$capstone" = git; then
5182e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
5183e219c499SRichard Henderson    fi
5184e219c499SRichard Henderson    mkdir -p capstone
518525211446SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -I${source_path}/capstone/include"
5186e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
5187e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
5188e219c499SRichard Henderson    else
5189e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
5190e219c499SRichard Henderson    fi
519158683d07SPaolo Bonzini    capstone_libs="-Lcapstone -lcapstone"
5192c9322ab5SMarc-André Lureau    capstone_cflags="-I${source_path}/capstone/include"
5193e219c499SRichard Henderson    ;;
5194e219c499SRichard Henderson
5195e219c499SRichard Henderson  system)
5196c9322ab5SMarc-André Lureau    capstone_libs="$($pkg_config --libs capstone)"
5197c9322ab5SMarc-André Lureau    capstone_cflags="$($pkg_config --cflags capstone)"
51988ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
5199e219c499SRichard Henderson    ;;
5200e219c499SRichard Henderson
5201e219c499SRichard Henderson  no)
5202e219c499SRichard Henderson    ;;
5203e219c499SRichard Henderson  *)
5204e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
5205e219c499SRichard Henderson    ;;
5206e219c499SRichard Hendersonesac
52078ca80760SRichard Henderson
52088ca80760SRichard Henderson##########################################
52095f6b9e8fSBlue Swirl# check if we have fdatasync
52105f6b9e8fSBlue Swirl
52115f6b9e8fSBlue Swirlfdatasync=no
52125f6b9e8fSBlue Swirlcat > $TMPC << EOF
52135f6b9e8fSBlue Swirl#include <unistd.h>
5214d1722a27SAlexandre Raymondint main(void) {
5215d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5216d1722a27SAlexandre Raymondreturn fdatasync(0);
5217d1722a27SAlexandre Raymond#else
5218e172fe11SStefan Weil#error Not supported
5219d1722a27SAlexandre Raymond#endif
5220d1722a27SAlexandre Raymond}
52215f6b9e8fSBlue SwirlEOF
52225f6b9e8fSBlue Swirlif compile_prog "" "" ; then
52235f6b9e8fSBlue Swirl    fdatasync=yes
52245f6b9e8fSBlue Swirlfi
52255f6b9e8fSBlue Swirl
522694a420b1SStefan Hajnoczi##########################################
5227e78815a5SAndreas Färber# check if we have madvise
5228e78815a5SAndreas Färber
5229e78815a5SAndreas Färbermadvise=no
5230e78815a5SAndreas Färbercat > $TMPC << EOF
5231e78815a5SAndreas Färber#include <sys/types.h>
5232e78815a5SAndreas Färber#include <sys/mman.h>
5233832ce9c2SScott Wood#include <stddef.h>
5234e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5235e78815a5SAndreas FärberEOF
5236e78815a5SAndreas Färberif compile_prog "" "" ; then
5237e78815a5SAndreas Färber    madvise=yes
5238e78815a5SAndreas Färberfi
5239e78815a5SAndreas Färber
5240e78815a5SAndreas Färber##########################################
5241e78815a5SAndreas Färber# check if we have posix_madvise
5242e78815a5SAndreas Färber
5243e78815a5SAndreas Färberposix_madvise=no
5244e78815a5SAndreas Färbercat > $TMPC << EOF
5245e78815a5SAndreas Färber#include <sys/mman.h>
5246832ce9c2SScott Wood#include <stddef.h>
5247e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5248e78815a5SAndreas FärberEOF
5249e78815a5SAndreas Färberif compile_prog "" "" ; then
5250e78815a5SAndreas Färber    posix_madvise=yes
5251e78815a5SAndreas Färberfi
5252e78815a5SAndreas Färber
5253e78815a5SAndreas Färber##########################################
52549bc5a719SAndreas Gustafsson# check if we have posix_memalign()
52559bc5a719SAndreas Gustafsson
52569bc5a719SAndreas Gustafssonposix_memalign=no
52579bc5a719SAndreas Gustafssoncat > $TMPC << EOF
52589bc5a719SAndreas Gustafsson#include <stdlib.h>
52599bc5a719SAndreas Gustafssonint main(void) {
52609bc5a719SAndreas Gustafsson    void *p;
52619bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
52629bc5a719SAndreas Gustafsson}
52639bc5a719SAndreas GustafssonEOF
52649bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
52659bc5a719SAndreas Gustafsson    posix_memalign=yes
52669bc5a719SAndreas Gustafssonfi
52679bc5a719SAndreas Gustafsson
52689bc5a719SAndreas Gustafsson##########################################
52690a852417SPaul Durrant# check if we have posix_syslog
52700a852417SPaul Durrant
52710a852417SPaul Durrantposix_syslog=no
52720a852417SPaul Durrantcat > $TMPC << EOF
52730a852417SPaul Durrant#include <syslog.h>
52740a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
52750a852417SPaul DurrantEOF
52760a852417SPaul Durrantif compile_prog "" "" ; then
52770a852417SPaul Durrant    posix_syslog=yes
52780a852417SPaul Durrantfi
52790a852417SPaul Durrant
52800a852417SPaul Durrant##########################################
5281401bc051SPeter Maydell# check if we have sem_timedwait
5282401bc051SPeter Maydell
5283401bc051SPeter Maydellsem_timedwait=no
5284401bc051SPeter Maydellcat > $TMPC << EOF
5285401bc051SPeter Maydell#include <semaphore.h>
5286811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5287401bc051SPeter MaydellEOF
5288401bc051SPeter Maydellif compile_prog "" "" ; then
5289401bc051SPeter Maydell    sem_timedwait=yes
5290401bc051SPeter Maydellfi
5291401bc051SPeter Maydell
5292401bc051SPeter Maydell##########################################
52935c99fa37SKeno Fischer# check if we have strchrnul
52945c99fa37SKeno Fischer
52955c99fa37SKeno Fischerstrchrnul=no
52965c99fa37SKeno Fischercat > $TMPC << EOF
52975c99fa37SKeno Fischer#include <string.h>
52985c99fa37SKeno Fischerint main(void);
52995c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
53005c99fa37SKeno Fischerchar *haystack = (char*)&main;
53015c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
53025c99fa37SKeno FischerEOF
53035c99fa37SKeno Fischerif compile_prog "" "" ; then
53045c99fa37SKeno Fischer    strchrnul=yes
53055c99fa37SKeno Fischerfi
53065c99fa37SKeno Fischer
53078a792b03SJiufei Xue#########################################
53088a792b03SJiufei Xue# check if we have st_atim
53098a792b03SJiufei Xue
53108a792b03SJiufei Xuest_atim=no
53118a792b03SJiufei Xuecat > $TMPC << EOF
53128a792b03SJiufei Xue#include <sys/stat.h>
53138a792b03SJiufei Xue#include <stddef.h>
53148a792b03SJiufei Xueint main(void) { return offsetof(struct stat, st_atim); }
53158a792b03SJiufei XueEOF
53168a792b03SJiufei Xueif compile_prog "" "" ; then
53178a792b03SJiufei Xue    st_atim=yes
53188a792b03SJiufei Xuefi
53198a792b03SJiufei Xue
53205c99fa37SKeno Fischer##########################################
532194a420b1SStefan Hajnoczi# check if trace backend exists
532294a420b1SStefan Hajnoczi
53235b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
532494a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
53255b808275SLluís Vilanova  error_exit "invalid trace backends" \
53265b808275SLluís Vilanova      "Please choose supported trace backends."
532794a420b1SStefan Hajnoczifi
532894a420b1SStefan Hajnoczi
53297e24e92aSStefan Hajnoczi##########################################
53307e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
53315b808275SLluís Vilanovaif have_backend "ust"; then
53327e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
5333bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
53347e24e92aSStefan Hajnocziint main(void) { return 0; }
53357e24e92aSStefan HajnocziEOF
5336c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5337bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
533889138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
53397e24e92aSStefan Hajnoczi    else
5340c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
5341bf15f63cSMohamad Gebai    fi
5342bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
534389138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5344bf15f63cSMohamad Gebai    else
5345bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
5346bf15f63cSMohamad Gebai    fi
5347bf15f63cSMohamad Gebai
5348bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5349bf15f63cSMohamad Gebai  else
5350bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
53517e24e92aSStefan Hajnoczi  fi
53527e24e92aSStefan Hajnoczifi
5353b3d08c02SDaniel P. Berrange
5354b3d08c02SDaniel P. Berrange##########################################
5355b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
53565b808275SLluís Vilanovaif have_backend "dtrace"; then
5357b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
535876ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
5359b3d08c02SDaniel P. Berrange  fi
5360c276b17dSDaniel P. Berrange  trace_backend_stap="no"
5361c276b17dSDaniel P. Berrange  if has 'stap' ; then
5362c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
5363c276b17dSDaniel P. Berrange  fi
5364b3d08c02SDaniel P. Berrangefi
5365b3d08c02SDaniel P. Berrange
53667e24e92aSStefan Hajnoczi##########################################
5367519175a2SAlex Barcelo# check and set a backend for coroutine
5368d0e2fce5SAneesh Kumar K.V
53697c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
537033c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
537133c53c54SDaniel P. Berrange# specific one.
53727c2acc70SPeter Maydell
53737c2acc70SPeter Maydellucontext_works=no
5374d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
5375d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
5376d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
5377cdf84806SPeter Maydell#ifdef __stub_makecontext
5378cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
5379cdf84806SPeter Maydell#endif
538075cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
5381d0e2fce5SAneesh Kumar K.VEOF
5382d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
53837c2acc70SPeter Maydell    ucontext_works=yes
5384d0e2fce5SAneesh Kumar K.V  fi
5385519175a2SAlex Barcelofi
53867c2acc70SPeter Maydell
53877c2acc70SPeter Maydellif test "$coroutine" = ""; then
53887c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
53897c2acc70SPeter Maydell    coroutine=win32
53907c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
53917c2acc70SPeter Maydell    coroutine=ucontext
5392519175a2SAlex Barcelo  else
53937c2acc70SPeter Maydell    coroutine=sigaltstack
53947c2acc70SPeter Maydell  fi
53957c2acc70SPeter Maydellelse
53967c2acc70SPeter Maydell  case $coroutine in
53977c2acc70SPeter Maydell  windows)
53987c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
53997c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
54007c2acc70SPeter Maydell    fi
54017c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
54027c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
54037c2acc70SPeter Maydell    coroutine=win32
54047c2acc70SPeter Maydell    ;;
54057c2acc70SPeter Maydell  ucontext)
54067c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
54077c2acc70SPeter Maydell      feature_not_found "ucontext"
54087c2acc70SPeter Maydell    fi
54097c2acc70SPeter Maydell    ;;
541033c53c54SDaniel P. Berrange  sigaltstack)
54117c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
54127c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
54137c2acc70SPeter Maydell    fi
54147c2acc70SPeter Maydell    ;;
54157c2acc70SPeter Maydell  *)
541676ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
54177c2acc70SPeter Maydell    ;;
54187c2acc70SPeter Maydell  esac
5419d0e2fce5SAneesh Kumar K.Vfi
5420d0e2fce5SAneesh Kumar K.V
542170c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
542270c60c08SStefan Hajnoczi  coroutine_pool=yes
542370c60c08SStefan Hajnoczifi
542470c60c08SStefan Hajnoczi
54257d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
54267d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
54277d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
54287d992e4dSPeter Lieven    coroutine_pool=no
54297d992e4dSPeter Lieven  fi
54307d992e4dSPeter Lievenfi
54317d992e4dSPeter Lieven
54321e4f6065SDaniele Buono##################################################
54331e4f6065SDaniele Buono# SafeStack
54341e4f6065SDaniele Buono
54351e4f6065SDaniele Buono
54361e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
54371e4f6065SDaniele Buonocat > $TMPC << EOF
54381e4f6065SDaniele Buonoint main(int argc, char *argv[])
54391e4f6065SDaniele Buono{
54401e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
54411e4f6065SDaniele Buono#error SafeStack Disabled
54421e4f6065SDaniele Buono#endif
54431e4f6065SDaniele Buono    return 0;
54441e4f6065SDaniele Buono}
54451e4f6065SDaniele BuonoEOF
54461e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
54471e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
54481e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
54491e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
54501e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
54511e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
54521e4f6065SDaniele Buono  else
54531e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
54541e4f6065SDaniele Buono  fi
54551e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
54561e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
54571e4f6065SDaniele Buono  fi
54581e4f6065SDaniele Buonoelse
54591e4f6065SDaniele Buonocat > $TMPC << EOF
54601e4f6065SDaniele Buonoint main(int argc, char *argv[])
54611e4f6065SDaniele Buono{
54621e4f6065SDaniele Buono#if defined(__has_feature)
54631e4f6065SDaniele Buono#if __has_feature(safe_stack)
54641e4f6065SDaniele Buono#error SafeStack Enabled
54651e4f6065SDaniele Buono#endif
54661e4f6065SDaniele Buono#endif
54671e4f6065SDaniele Buono    return 0;
54681e4f6065SDaniele Buono}
54691e4f6065SDaniele BuonoEOF
54701e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
54711e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
54721e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
54731e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
54741e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
54751e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
54761e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
54771e4f6065SDaniele Buono    fi
54781e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
54791e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
54801e4f6065SDaniele Buono  fi
54811e4f6065SDaniele Buonoelse # "$safe_stack" = ""
54821e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
54831e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
54841e4f6065SDaniele Buono    safe_stack="no"
54851e4f6065SDaniele Buono  else
54861e4f6065SDaniele Buono    safe_stack="yes"
54871e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
54881e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
54891e4f6065SDaniele Buono    fi
54901e4f6065SDaniele Buono  fi
54911e4f6065SDaniele Buonofi
54921e4f6065SDaniele Buonofi
54937d992e4dSPeter Lieven
5494d0e2fce5SAneesh Kumar K.V##########################################
5495d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5496d2042378SAneesh Kumar K.V
54974e1797f9SStefan Weilopen_by_handle_at=no
5498d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5499d2042378SAneesh Kumar K.V#include <fcntl.h>
5500acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5501acc55ba8SStefan Weil# error missing definition
5502acc55ba8SStefan Weil#else
550375cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5504acc55ba8SStefan Weil#endif
5505d2042378SAneesh Kumar K.VEOF
5506d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5507d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5508d2042378SAneesh Kumar K.Vfi
5509d2042378SAneesh Kumar K.V
5510e06a765eSHarsh Prateek Bora########################################
5511e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5512e06a765eSHarsh Prateek Bora
5513e06a765eSHarsh Prateek Boralinux_magic_h=no
5514e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5515e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5516e06a765eSHarsh Prateek Boraint main(void) {
551775cafad7SStefan Weil  return 0;
5518e06a765eSHarsh Prateek Bora}
5519e06a765eSHarsh Prateek BoraEOF
5520e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5521e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5522e06a765eSHarsh Prateek Borafi
5523e06a765eSHarsh Prateek Bora
55248ab1bf12SLuiz Capitulino########################################
5525541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
55263f4349dcSKevin Wolf
55273f4349dcSKevin Wolfvalgrind_h=no
55283f4349dcSKevin Wolfcat > $TMPC << EOF
55293f4349dcSKevin Wolf#include <valgrind/valgrind.h>
55303f4349dcSKevin Wolfint main(void) {
55313f4349dcSKevin Wolf  return 0;
55323f4349dcSKevin Wolf}
55333f4349dcSKevin WolfEOF
55343f4349dcSKevin Wolfif compile_prog "" "" ; then
55353f4349dcSKevin Wolf    valgrind_h=yes
55363f4349dcSKevin Wolffi
55373f4349dcSKevin Wolf
55383f4349dcSKevin Wolf########################################
55398ab1bf12SLuiz Capitulino# check if environ is declared
55408ab1bf12SLuiz Capitulino
55418ab1bf12SLuiz Capitulinohas_environ=no
55428ab1bf12SLuiz Capitulinocat > $TMPC << EOF
55438ab1bf12SLuiz Capitulino#include <unistd.h>
55448ab1bf12SLuiz Capitulinoint main(void) {
5545c075a723SBlue Swirl    environ = 0;
55468ab1bf12SLuiz Capitulino    return 0;
55478ab1bf12SLuiz Capitulino}
55488ab1bf12SLuiz CapitulinoEOF
55498ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
55508ab1bf12SLuiz Capitulino    has_environ=yes
55518ab1bf12SLuiz Capitulinofi
55528ab1bf12SLuiz Capitulino
555376a347e1SRichard Henderson########################################
555476a347e1SRichard Henderson# check if cpuid.h is usable.
555576a347e1SRichard Henderson
555676a347e1SRichard Hendersoncat > $TMPC << EOF
555776a347e1SRichard Henderson#include <cpuid.h>
555876a347e1SRichard Hendersonint main(void) {
5559774d566cSPeter Maydell    unsigned a, b, c, d;
5560774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5561774d566cSPeter Maydell
5562774d566cSPeter Maydell    if (max >= 1) {
5563774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5564774d566cSPeter Maydell    }
5565774d566cSPeter Maydell
5566774d566cSPeter Maydell    if (max >= 7) {
5567774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5568774d566cSPeter Maydell    }
5569774d566cSPeter Maydell
557076a347e1SRichard Henderson    return 0;
557176a347e1SRichard Henderson}
557276a347e1SRichard HendersonEOF
557376a347e1SRichard Hendersonif compile_prog "" "" ; then
557476a347e1SRichard Henderson    cpuid_h=yes
557576a347e1SRichard Hendersonfi
557676a347e1SRichard Henderson
55775dd89908SRichard Henderson##########################################
55785dd89908SRichard Henderson# avx2 optimization requirement check
55795dd89908SRichard Henderson#
55805dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
55815dd89908SRichard Henderson# since we won't be able to select the new routines.
55825dd89908SRichard Henderson
5583e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
55845dd89908SRichard Henderson  cat > $TMPC << EOF
55855dd89908SRichard Henderson#pragma GCC push_options
55865dd89908SRichard Henderson#pragma GCC target("avx2")
55875dd89908SRichard Henderson#include <cpuid.h>
55885dd89908SRichard Henderson#include <immintrin.h>
55895dd89908SRichard Hendersonstatic int bar(void *a) {
55905dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
55915dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
55925dd89908SRichard Henderson}
55935dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
55945dd89908SRichard HendersonEOF
55955dd89908SRichard Henderson  if compile_object "" ; then
55965dd89908SRichard Henderson    avx2_opt="yes"
559786583a07SLiam Merwick  else
559886583a07SLiam Merwick    avx2_opt="no"
55995dd89908SRichard Henderson  fi
56005dd89908SRichard Hendersonfi
56015dd89908SRichard Henderson
56026b8cd447SRobert Hoo##########################################
56036b8cd447SRobert Hoo# avx512f optimization requirement check
56046b8cd447SRobert Hoo#
56056b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
56066b8cd447SRobert Hoo# since we won't be able to select the new routines.
56076b8cd447SRobert Hoo# by default, it is turned off.
56086b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
56096b8cd447SRobert Hoo
56106b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
56116b8cd447SRobert Hoo  cat > $TMPC << EOF
56126b8cd447SRobert Hoo#pragma GCC push_options
56136b8cd447SRobert Hoo#pragma GCC target("avx512f")
56146b8cd447SRobert Hoo#include <cpuid.h>
56156b8cd447SRobert Hoo#include <immintrin.h>
56166b8cd447SRobert Hoostatic int bar(void *a) {
56176b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
56186b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
56196b8cd447SRobert Hoo}
56206b8cd447SRobert Hooint main(int argc, char *argv[])
56216b8cd447SRobert Hoo{
56226b8cd447SRobert Hoo	return bar(argv[0]);
56236b8cd447SRobert Hoo}
56246b8cd447SRobert HooEOF
56256b8cd447SRobert Hoo  if ! compile_object "" ; then
56266b8cd447SRobert Hoo    avx512f_opt="no"
56276b8cd447SRobert Hoo  fi
56286b8cd447SRobert Hooelse
56296b8cd447SRobert Hoo  avx512f_opt="no"
56306b8cd447SRobert Hoofi
56316b8cd447SRobert Hoo
5632f540166bSRichard Henderson########################################
5633f540166bSRichard Henderson# check if __[u]int128_t is usable.
5634f540166bSRichard Henderson
5635f540166bSRichard Hendersonint128=no
5636f540166bSRichard Hendersoncat > $TMPC << EOF
5637f540166bSRichard Henderson__int128_t a;
5638f540166bSRichard Henderson__uint128_t b;
5639f540166bSRichard Hendersonint main (void) {
5640f540166bSRichard Henderson  a = a + b;
5641f540166bSRichard Henderson  b = a * b;
5642464e3671SPeter Maydell  a = a * a;
5643f540166bSRichard Henderson  return 0;
5644f540166bSRichard Henderson}
5645f540166bSRichard HendersonEOF
5646f540166bSRichard Hendersonif compile_prog "" "" ; then
5647f540166bSRichard Henderson    int128=yes
5648f540166bSRichard Hendersonfi
564976a347e1SRichard Henderson
56507ebee43eSRichard Henderson#########################################
56517ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
56527ebee43eSRichard Henderson
56537ebee43eSRichard Hendersonatomic128=no
56547ebee43eSRichard Hendersonif test "$int128" = "yes"; then
56557ebee43eSRichard Henderson  cat > $TMPC << EOF
56567ebee43eSRichard Hendersonint main(void)
56577ebee43eSRichard Henderson{
56587ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
56597ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
56607ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
56617ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
56627ebee43eSRichard Henderson  return 0;
56637ebee43eSRichard Henderson}
56647ebee43eSRichard HendersonEOF
56657ebee43eSRichard Henderson  if compile_prog "" "" ; then
56667ebee43eSRichard Henderson    atomic128=yes
56677ebee43eSRichard Henderson  fi
56687ebee43eSRichard Hendersonfi
56697ebee43eSRichard Henderson
5670e6cd4bb5SRichard Hendersoncmpxchg128=no
5671e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
5672e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5673e6cd4bb5SRichard Hendersonint main(void)
5674e6cd4bb5SRichard Henderson{
5675e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5676e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5677e6cd4bb5SRichard Henderson  return 0;
5678e6cd4bb5SRichard Henderson}
5679e6cd4bb5SRichard HendersonEOF
5680e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5681e6cd4bb5SRichard Henderson    cmpxchg128=yes
5682e6cd4bb5SRichard Henderson  fi
5683e6cd4bb5SRichard Hendersonfi
5684e6cd4bb5SRichard Henderson
5685df79b996SRichard Henderson#########################################
5686df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5687df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5688df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5689df79b996SRichard Henderson
5690df79b996SRichard Hendersoncat > $TMPC << EOF
5691df79b996SRichard Henderson#include <stdint.h>
5692df79b996SRichard Hendersonint main(void)
5693df79b996SRichard Henderson{
5694df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5695df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
56965fe40765SThomas Huth  y = __atomic_load_n(&x, __ATOMIC_RELAXED);
56975fe40765SThomas Huth  __atomic_store_n(&x, y, __ATOMIC_RELAXED);
56985fe40765SThomas Huth  __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
56995fe40765SThomas Huth  __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
57005fe40765SThomas Huth  __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
5701df79b996SRichard Henderson#else
5702df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5703df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5704df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5705df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5706df79b996SRichard Henderson#endif
5707df79b996SRichard Henderson  return 0;
5708df79b996SRichard Henderson}
5709df79b996SRichard HendersonEOF
5710df79b996SRichard Hendersonif compile_prog "" "" ; then
5711df79b996SRichard Henderson  atomic64=yes
5712df79b996SRichard Hendersonfi
5713df79b996SRichard Henderson
571426fffe29SEmilio G. Cota#########################################
571526fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
571626fffe29SEmilio G. Cotald_dynamic_list="no"
571726fffe29SEmilio G. Cotaif test "$static" = "no" ; then
571826fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
571926fffe29SEmilio G. Cota{
572026fffe29SEmilio G. Cota  foo;
572126fffe29SEmilio G. Cota};
572226fffe29SEmilio G. CotaEOF
572326fffe29SEmilio G. Cota
572426fffe29SEmilio G. Cota    cat > $TMPC <<EOF
572526fffe29SEmilio G. Cota#include <stdio.h>
572626fffe29SEmilio G. Cotavoid foo(void);
572726fffe29SEmilio G. Cota
572826fffe29SEmilio G. Cotavoid foo(void)
572926fffe29SEmilio G. Cota{
573026fffe29SEmilio G. Cota  printf("foo\n");
573126fffe29SEmilio G. Cota}
573226fffe29SEmilio G. Cota
573326fffe29SEmilio G. Cotaint main(void)
573426fffe29SEmilio G. Cota{
573526fffe29SEmilio G. Cota  foo();
573626fffe29SEmilio G. Cota  return 0;
573726fffe29SEmilio G. Cota}
573826fffe29SEmilio G. CotaEOF
573926fffe29SEmilio G. Cota
574026fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
574126fffe29SEmilio G. Cota        ld_dynamic_list="yes"
574226fffe29SEmilio G. Cota    fi
574326fffe29SEmilio G. Cotafi
574426fffe29SEmilio G. Cota
574526fffe29SEmilio G. Cota#########################################
574626fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
574726fffe29SEmilio G. Cota
574826fffe29SEmilio G. Cotald_exported_symbols_list="no"
574926fffe29SEmilio G. Cotaif test "$static" = "no" ; then
575026fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
575126fffe29SEmilio G. Cota  _foo
575226fffe29SEmilio G. CotaEOF
575326fffe29SEmilio G. Cota
575426fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
575526fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
575626fffe29SEmilio G. Cota    fi
575726fffe29SEmilio G. Cotafi
575826fffe29SEmilio G. Cota
575926fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
576026fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
576126fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
576226fffe29SEmilio G. Cota  error_exit \
576326fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
576426fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
576526fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
576626fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
576726fffe29SEmilio G. Cotafi
576826fffe29SEmilio G. Cota
57691e6e9acaSRichard Henderson########################################
5770db8aaae8SRichard Henderson# See if __attribute__((alias)) is supported.
5771db8aaae8SRichard Henderson# This false for Xcode 9, but has been remedied for Xcode 10.
5772db8aaae8SRichard Henderson# Unfortunately, travis uses Xcode 9 by default.
5773db8aaae8SRichard Henderson
5774db8aaae8SRichard Hendersonattralias=no
5775db8aaae8SRichard Hendersoncat > $TMPC << EOF
5776db8aaae8SRichard Hendersonint x = 1;
5777db8aaae8SRichard Hendersonextern const int y __attribute__((alias("x")));
5778db8aaae8SRichard Hendersonint main(void) { return 0; }
5779db8aaae8SRichard HendersonEOF
5780db8aaae8SRichard Hendersonif compile_prog "" "" ; then
5781db8aaae8SRichard Henderson    attralias=yes
5782db8aaae8SRichard Hendersonfi
5783db8aaae8SRichard Henderson
5784db8aaae8SRichard Henderson########################################
57851e6e9acaSRichard Henderson# check if getauxval is available.
57861e6e9acaSRichard Henderson
57871e6e9acaSRichard Hendersongetauxval=no
57881e6e9acaSRichard Hendersoncat > $TMPC << EOF
57891e6e9acaSRichard Henderson#include <sys/auxv.h>
57901e6e9acaSRichard Hendersonint main(void) {
57911e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
57921e6e9acaSRichard Henderson}
57931e6e9acaSRichard HendersonEOF
57941e6e9acaSRichard Hendersonif compile_prog "" "" ; then
57951e6e9acaSRichard Henderson    getauxval=yes
57961e6e9acaSRichard Hendersonfi
57971e6e9acaSRichard Henderson
5798fd0e6053SJohn Snow########################################
5799fd0e6053SJohn Snow# check if ccache is interfering with
5800fd0e6053SJohn Snow# semantic analysis of macros
5801fd0e6053SJohn Snow
58025e4dfd3dSJohn Snowunset CCACHE_CPP2
5803fd0e6053SJohn Snowccache_cpp2=no
5804fd0e6053SJohn Snowcat > $TMPC << EOF
5805fd0e6053SJohn Snowstatic const int Z = 1;
5806fd0e6053SJohn Snow#define fn() ({ Z; })
5807fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5808fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5809fd0e6053SJohn Snow#define ID(X) (X)
5810fd0e6053SJohn Snowint main(int argc, char *argv[])
5811fd0e6053SJohn Snow{
5812fd0e6053SJohn Snow    int x = 0, y = 0;
5813fd0e6053SJohn Snow    x = ID(x);
5814fd0e6053SJohn Snow    x = fn();
5815fd0e6053SJohn Snow    fn();
5816fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5817fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5818fd0e6053SJohn Snow    return 0;
5819fd0e6053SJohn Snow}
5820fd0e6053SJohn SnowEOF
5821fd0e6053SJohn Snow
5822fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5823fd0e6053SJohn Snow    ccache_cpp2=yes
5824fd0e6053SJohn Snowfi
5825fd0e6053SJohn Snow
5826b553a042SJohn Snow#################################################
5827b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5828b553a042SJohn Snow
5829b553a042SJohn Snowif test "$fortify_source" != "no"; then
5830b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5831b553a042SJohn Snow    fortify_source="no";
5832e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5833cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5834b553a042SJohn Snow    fortify_source="no";
5835b553a042SJohn Snow  else
5836b553a042SJohn Snow    fortify_source="yes"
5837b553a042SJohn Snow  fi
5838b553a042SJohn Snowfi
5839b553a042SJohn Snow
58401efad060SFam Zheng###############################################
58411efad060SFam Zheng# Check if copy_file_range is provided by glibc
58421efad060SFam Zhenghave_copy_file_range=no
58431efad060SFam Zhengcat > $TMPC << EOF
58441efad060SFam Zheng#include <unistd.h>
58451efad060SFam Zhengint main(void) {
58461efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
58471efad060SFam Zheng  return 0;
58481efad060SFam Zheng}
58491efad060SFam ZhengEOF
58501efad060SFam Zhengif compile_prog "" "" ; then
58511efad060SFam Zheng    have_copy_file_range=yes
58521efad060SFam Zhengfi
58531efad060SFam Zheng
5854d2042378SAneesh Kumar K.V##########################################
5855277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5856277abf15SJan Vesely
5857277abf15SJan Veselyhave_fsxattr=no
5858277abf15SJan Veselycat > $TMPC << EOF
5859277abf15SJan Vesely#include <linux/fs.h>
5860277abf15SJan Veselystruct fsxattr foo;
5861277abf15SJan Veselyint main(void) {
5862277abf15SJan Vesely  return 0;
5863277abf15SJan Vesely}
5864277abf15SJan VeselyEOF
5865277abf15SJan Veselyif compile_prog "" "" ; then
5866277abf15SJan Vesely    have_fsxattr=yes
5867277abf15SJan Veselyfi
5868277abf15SJan Vesely
5869b66e10e4SPeter Maydell##########################################
5870a40161cbSPaolo Bonzini# check for usable membarrier system call
5871a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5872a40161cbSPaolo Bonzini    have_membarrier=no
5873a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5874a40161cbSPaolo Bonzini        have_membarrier=yes
5875a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5876a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5877a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5878a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5879a40161cbSPaolo Bonzini    #include <unistd.h>
5880a40161cbSPaolo Bonzini    #include <stdlib.h>
5881a40161cbSPaolo Bonzini    int main(void) {
5882a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5883a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5884a40161cbSPaolo Bonzini	exit(0);
5885a40161cbSPaolo Bonzini    }
5886a40161cbSPaolo BonziniEOF
5887a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5888a40161cbSPaolo Bonzini            have_membarrier=yes
5889a40161cbSPaolo Bonzini        fi
5890a40161cbSPaolo Bonzini    fi
5891a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5892a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5893a40161cbSPaolo Bonzini    fi
5894a40161cbSPaolo Bonzinielse
5895a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5896a40161cbSPaolo Bonzini    # work on Wine.
5897a40161cbSPaolo Bonzini    membarrier=no
5898a40161cbSPaolo Bonzinifi
5899a40161cbSPaolo Bonzini
5900a40161cbSPaolo Bonzini##########################################
5901b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5902575b22b1SLaurent Vivierhave_rtnetlink=no
5903575b22b1SLaurent Viviercat > $TMPC << EOF
5904575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5905575b22b1SLaurent Vivierint main(void) {
5906575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5907575b22b1SLaurent Vivier}
5908575b22b1SLaurent VivierEOF
5909575b22b1SLaurent Vivierif compile_prog "" "" ; then
5910575b22b1SLaurent Vivier    have_rtnetlink=yes
5911575b22b1SLaurent Vivierfi
5912575b22b1SLaurent Vivier
59136a02c806SStefan Hajnoczi##########################################
59146a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
59156a02c806SStefan Hajnoczihave_af_vsock=no
59166a02c806SStefan Hajnoczicat > $TMPC << EOF
59176a02c806SStefan Hajnoczi#include <errno.h>
59186a02c806SStefan Hajnoczi#include <sys/types.h>
59196a02c806SStefan Hajnoczi#include <sys/socket.h>
59206a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
59216a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
59226a02c806SStefan Hajnoczi#endif
59236a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
59246a02c806SStefan Hajnocziint main(void) {
59256a02c806SStefan Hajnoczi    int sock, ret;
59266a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
59276a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
59286a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
59296a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
59306a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
59316a02c806SStefan Hajnoczi        return 0;
59326a02c806SStefan Hajnoczi    }
59336a02c806SStefan Hajnoczi    return -1;
59346a02c806SStefan Hajnoczi}
59356a02c806SStefan HajnocziEOF
59366a02c806SStefan Hajnocziif compile_prog "" "" ; then
59376a02c806SStefan Hajnoczi    have_af_vsock=yes
59386a02c806SStefan Hajnoczifi
59396a02c806SStefan Hajnoczi
5940f0d92b56SLongpeng(Mike)##########################################
5941f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
59424f67366eSThomas Huthhave_afalg=no
5943f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
5944f0d92b56SLongpeng(Mike)#include <errno.h>
5945f0d92b56SLongpeng(Mike)#include <sys/types.h>
5946f0d92b56SLongpeng(Mike)#include <sys/socket.h>
5947f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
5948f0d92b56SLongpeng(Mike)int main(void) {
5949f0d92b56SLongpeng(Mike)    int sock;
5950f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
5951f0d92b56SLongpeng(Mike)    return sock;
5952f0d92b56SLongpeng(Mike)}
5953f0d92b56SLongpeng(Mike)EOF
5954f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
5955f0d92b56SLongpeng(Mike)    have_afalg=yes
5956f0d92b56SLongpeng(Mike)fi
5957f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
5958f0d92b56SLongpeng(Mike)then
5959f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
5960f0d92b56SLongpeng(Mike)    then
5961f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
5962f0d92b56SLongpeng(Mike)    fi
5963f0d92b56SLongpeng(Mike)fi
5964f0d92b56SLongpeng(Mike)
5965f0d92b56SLongpeng(Mike)
59666969ec6cSJames Clarke#################################################
5967c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
5968d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
5969c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
5970c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
5971c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
5972c97d6d2cSSergio Andres Gomez Del RealEOF
5973c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
5974c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
5975c97d6d2cSSergio Andres Gomez Del Real  else
5976c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
5977db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-framework Hypervisor $QEMU_LDFLAGS"
5978c97d6d2cSSergio Andres Gomez Del Real  fi
5979c97d6d2cSSergio Andres Gomez Del Realfi
5980c97d6d2cSSergio Andres Gomez Del Real
5981277abf15SJan Vesely##########################################
59824d04351fSChristopher Covington# check for sysmacros.h
59834d04351fSChristopher Covington
59844d04351fSChristopher Covingtonhave_sysmacros=no
59854d04351fSChristopher Covingtoncat > $TMPC << EOF
59864d04351fSChristopher Covington#include <sys/sysmacros.h>
59874d04351fSChristopher Covingtonint main(void) {
59884d04351fSChristopher Covington    return makedev(0, 0);
59894d04351fSChristopher Covington}
59904d04351fSChristopher CovingtonEOF
59914d04351fSChristopher Covingtonif compile_prog "" "" ; then
59924d04351fSChristopher Covington    have_sysmacros=yes
59934d04351fSChristopher Covingtonfi
59944d04351fSChristopher Covington
59954d04351fSChristopher Covington##########################################
599649e00a18SAndreas Grapentin# check for _Static_assert()
599749e00a18SAndreas Grapentin
599849e00a18SAndreas Grapentinhave_static_assert=no
599949e00a18SAndreas Grapentincat > $TMPC << EOF
600049e00a18SAndreas Grapentin_Static_assert(1, "success");
600149e00a18SAndreas Grapentinint main(void) {
600249e00a18SAndreas Grapentin    return 0;
600349e00a18SAndreas Grapentin}
600449e00a18SAndreas GrapentinEOF
600549e00a18SAndreas Grapentinif compile_prog "" "" ; then
600649e00a18SAndreas Grapentin    have_static_assert=yes
600749e00a18SAndreas Grapentinfi
600849e00a18SAndreas Grapentin
600949e00a18SAndreas Grapentin##########################################
6010e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
6011e674605fSTomáš Golembiovský
6012e674605fSTomáš Golembiovskýhave_utmpx=no
6013e674605fSTomáš Golembiovskýcat > $TMPC << EOF
6014e674605fSTomáš Golembiovský#include <utmpx.h>
6015e674605fSTomáš Golembiovskýstruct utmpx user_info;
6016e674605fSTomáš Golembiovskýint main(void) {
6017e674605fSTomáš Golembiovský    return 0;
6018e674605fSTomáš Golembiovský}
6019e674605fSTomáš GolembiovskýEOF
6020e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
6021e674605fSTomáš Golembiovský    have_utmpx=yes
6022e674605fSTomáš Golembiovskýfi
6023e674605fSTomáš Golembiovský
6024e674605fSTomáš Golembiovský##########################################
6025db1ed1abSRichard Henderson# check for getrandom()
6026db1ed1abSRichard Henderson
6027db1ed1abSRichard Hendersonhave_getrandom=no
6028db1ed1abSRichard Hendersoncat > $TMPC << EOF
6029db1ed1abSRichard Henderson#include <sys/random.h>
6030db1ed1abSRichard Hendersonint main(void) {
6031db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
6032db1ed1abSRichard Henderson}
6033db1ed1abSRichard HendersonEOF
6034db1ed1abSRichard Hendersonif compile_prog "" "" ; then
6035db1ed1abSRichard Henderson    have_getrandom=yes
6036db1ed1abSRichard Hendersonfi
6037db1ed1abSRichard Henderson
6038db1ed1abSRichard Henderson##########################################
6039247724cbSMarc-André Lureau# checks for sanitizers
6040247724cbSMarc-André Lureau
6041247724cbSMarc-André Lureauhave_asan=no
6042247724cbSMarc-André Lureauhave_ubsan=no
6043d83414e1SMarc-André Lureauhave_asan_iface_h=no
6044d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
6045247724cbSMarc-André Lureau
6046247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
6047b9f44da2SMarc-André Lureau  write_c_skeleton
6048247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
6049247724cbSMarc-André Lureau      have_asan=yes
6050247724cbSMarc-André Lureau  fi
6051b9f44da2SMarc-André Lureau
6052b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
6053b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
6054b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
6055b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
6056b9f44da2SMarc-André Lureau#include <stdlib.h>
6057b9f44da2SMarc-André Lureauint main(void) {
6058b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
6059f2dfe54cSLeonid Bloch    if (tmp != NULL) {
6060b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
6061b9f44da2SMarc-André Lureau    }
6062d1abf3fcSOlaf Hering    return 1;
6063f2dfe54cSLeonid Bloch}
6064b9f44da2SMarc-André LureauEOF
6065247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
6066247724cbSMarc-André Lureau      have_ubsan=yes
6067247724cbSMarc-André Lureau  fi
6068d83414e1SMarc-André Lureau
6069d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
6070d83414e1SMarc-André Lureau      have_asan_iface_h=yes
6071d83414e1SMarc-André Lureau  fi
6072d83414e1SMarc-André Lureau
6073d83414e1SMarc-André Lureau  cat > $TMPC << EOF
6074d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
6075d83414e1SMarc-André Lureauint main(void) {
6076d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
6077d83414e1SMarc-André Lureau  return 0;
6078d83414e1SMarc-André Lureau}
6079d83414e1SMarc-André LureauEOF
6080d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
6081d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
6082d83414e1SMarc-André Lureau  fi
6083247724cbSMarc-André Lureaufi
6084247724cbSMarc-André Lureau
6085247724cbSMarc-André Lureau##########################################
6086adc28027SAlexander Bulekov# checks for fuzzer
6087adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
6088adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
6089dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
6090adc28027SAlexander Bulekov    have_fuzzer=yes
609164ed6f92SPaolo Bonzini  else
609264ed6f92SPaolo Bonzini    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
609364ed6f92SPaolo Bonzini    exit 1
6094adc28027SAlexander Bulekov  fi
6095adc28027SAlexander Bulekovfi
6096adc28027SAlexander Bulekov
60970aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
60980aebab04SLingfeng Yang# keep it separate until that is not the case.
60990aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
61000aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
61010aebab04SLingfeng Yangfi
61020aebab04SLingfeng Yanghave_tsan=no
61030aebab04SLingfeng Yanghave_tsan_iface_fiber=no
61040aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
61050aebab04SLingfeng Yang  write_c_skeleton
61060aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
61070aebab04SLingfeng Yang      have_tsan=yes
61080aebab04SLingfeng Yang  fi
61090aebab04SLingfeng Yang  cat > $TMPC << EOF
61100aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
61110aebab04SLingfeng Yangint main(void) {
61120aebab04SLingfeng Yang  __tsan_create_fiber(0);
61130aebab04SLingfeng Yang  return 0;
61140aebab04SLingfeng Yang}
61150aebab04SLingfeng YangEOF
61160aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
61170aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
61180aebab04SLingfeng Yang  fi
61190aebab04SLingfeng Yangfi
61200aebab04SLingfeng Yang
6121adc28027SAlexander Bulekov##########################################
612217824406SJunyan He# check for libpmem
612317824406SJunyan He
612417824406SJunyan Heif test "$libpmem" != "no"; then
612517824406SJunyan He	if $pkg_config --exists "libpmem"; then
612617824406SJunyan He		libpmem="yes"
612717824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
612817824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
612917824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
613017824406SJunyan He	else
613117824406SJunyan He		if test "$libpmem" = "yes" ; then
613217824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
613317824406SJunyan He		fi
613417824406SJunyan He		libpmem="no"
613517824406SJunyan He	fi
613617824406SJunyan Hefi
613717824406SJunyan He
613817824406SJunyan He##########################################
613921b2eca6SJingqi Liu# check for libdaxctl
614021b2eca6SJingqi Liu
614121b2eca6SJingqi Liuif test "$libdaxctl" != "no"; then
614221b2eca6SJingqi Liu	if $pkg_config --atleast-version=57 "libdaxctl"; then
614321b2eca6SJingqi Liu		libdaxctl="yes"
614421b2eca6SJingqi Liu		libdaxctl_libs=$($pkg_config --libs libdaxctl)
614521b2eca6SJingqi Liu		libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
614621b2eca6SJingqi Liu		QEMU_CFLAGS="$QEMU_CFLAGS $libdaxctl_cflags"
614721b2eca6SJingqi Liu	else
614821b2eca6SJingqi Liu		if test "$libdaxctl" = "yes" ; then
614921b2eca6SJingqi Liu			feature_not_found "libdaxctl" "Install libdaxctl"
615021b2eca6SJingqi Liu		fi
615121b2eca6SJingqi Liu		libdaxctl="no"
615221b2eca6SJingqi Liu	fi
615321b2eca6SJingqi Liufi
615421b2eca6SJingqi Liu
615521b2eca6SJingqi Liu##########################################
6156675b9b53SMarc-André Lureau# check for slirp
6157675b9b53SMarc-André Lureau
6158d599938aSLaurent Vivier# slirp is only required when building softmmu targets
6159d599938aSLaurent Vivierif test -z "$slirp" -a "$softmmu" != "yes" ; then
6160d599938aSLaurent Vivier    slirp="no"
6161d599938aSLaurent Vivierfi
6162d599938aSLaurent Vivier
6163675b9b53SMarc-André Lureaucase "$slirp" in
6164675b9b53SMarc-André Lureau  "" | yes)
6165675b9b53SMarc-André Lureau    if $pkg_config slirp; then
6166675b9b53SMarc-André Lureau      slirp=system
61677c57bdd8SMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
61687c57bdd8SMarc-André Lureau      slirp=git
6169675b9b53SMarc-André Lureau    elif test -e "${source_path}/slirp/Makefile" ; then
6170675b9b53SMarc-André Lureau      slirp=internal
6171675b9b53SMarc-André Lureau    elif test -z "$slirp" ; then
6172675b9b53SMarc-André Lureau      slirp=no
6173675b9b53SMarc-André Lureau    else
6174675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel or git submodule"
6175675b9b53SMarc-André Lureau    fi
6176675b9b53SMarc-André Lureau    ;;
6177675b9b53SMarc-André Lureau
6178675b9b53SMarc-André Lureau  system)
6179675b9b53SMarc-André Lureau    if ! $pkg_config slirp; then
6180675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel"
6181675b9b53SMarc-André Lureau    fi
6182675b9b53SMarc-André Lureau    ;;
6183675b9b53SMarc-André Lureauesac
6184675b9b53SMarc-André Lureau
6185675b9b53SMarc-André Lureaucase "$slirp" in
61867c57bdd8SMarc-André Lureau  git | internal)
61877c57bdd8SMarc-André Lureau    if test "$slirp" = git; then
61887c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
61897c57bdd8SMarc-André Lureau    fi
6190675b9b53SMarc-André Lureau    mkdir -p slirp
619158683d07SPaolo Bonzini    slirp_cflags="-I${source_path}/slirp/src -Islirp/src"
619258683d07SPaolo Bonzini    slirp_libs="-Lslirp -lslirp"
6193b965e8c5SPaolo Bonzini    if test "$mingw32" = "yes" ; then
6194b965e8c5SPaolo Bonzini      slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
6195b965e8c5SPaolo Bonzini    fi
6196675b9b53SMarc-André Lureau    ;;
6197675b9b53SMarc-André Lureau
6198675b9b53SMarc-André Lureau  system)
6199675b9b53SMarc-André Lureau    slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
6200675b9b53SMarc-André Lureau    slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
6201675b9b53SMarc-André Lureau    slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
6202675b9b53SMarc-André Lureau    ;;
6203675b9b53SMarc-André Lureau
6204675b9b53SMarc-André Lureau  no)
6205675b9b53SMarc-André Lureau    ;;
6206675b9b53SMarc-André Lureau  *)
6207675b9b53SMarc-André Lureau    error_exit "Unknown state for slirp: $slirp"
6208675b9b53SMarc-André Lureau    ;;
6209675b9b53SMarc-André Lureauesac
6210675b9b53SMarc-André Lureau
621154e7aac0SAlexey Krasikov##########################################
621254e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
621354e7aac0SAlexey Krasikov
621454e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
621554e7aac0SAlexey Krasikov
621654e7aac0SAlexey Krasikov    have_keyring=no
621754e7aac0SAlexey Krasikov    cat > $TMPC << EOF
621854e7aac0SAlexey Krasikov#include <errno.h>
621954e7aac0SAlexey Krasikov#include <asm/unistd.h>
622054e7aac0SAlexey Krasikov#include <linux/keyctl.h>
622154e7aac0SAlexey Krasikov#include <unistd.h>
622254e7aac0SAlexey Krasikovint main(void) {
622354e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
622454e7aac0SAlexey Krasikov}
622554e7aac0SAlexey KrasikovEOF
622654e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
622754e7aac0SAlexey Krasikov        have_keyring=yes
622854e7aac0SAlexey Krasikov    fi
622954e7aac0SAlexey Krasikovfi
623054e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
623154e7aac0SAlexey Krasikovthen
6232b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
623354e7aac0SAlexey Krasikov    then
623454e7aac0SAlexey Krasikov	secret_keyring=yes
623554e7aac0SAlexey Krasikov    else
623654e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
623754e7aac0SAlexey Krasikov	then
623854e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
623954e7aac0SAlexey Krasikovbut not implemented on your system"
624054e7aac0SAlexey Krasikov	else
624154e7aac0SAlexey Krasikov	    secret_keyring=no
624254e7aac0SAlexey Krasikov	fi
624354e7aac0SAlexey Krasikov    fi
624454e7aac0SAlexey Krasikovfi
624554e7aac0SAlexey Krasikov
624692500362SAlexey Krasikov##########################################
6247e86ecd4bSJuan Quintela# End of CC checks
6248e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
6249e86ecd4bSJuan Quintela
6250d83414e1SMarc-André Lureauwrite_c_skeleton
6251d83414e1SMarc-André Lureau
62521d728c39SBlue Swirlif test "$gcov" = "yes" ; then
6253bf0e56a3SMarc-André Lureau  :
6254b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
6255086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
6256086d5f75SPaolo Bonzini  debug=no
6257086d5f75SPaolo Bonzinifi
6258086d5f75SPaolo Bonziniif test "$debug_info" = "yes"; then
6259086d5f75SPaolo Bonzini  CFLAGS="-g $CFLAGS"
6260086d5f75SPaolo Bonzini  LDFLAGS="-g $LDFLAGS"
6261086d5f75SPaolo Bonzinifi
6262a5665051SPaolo Bonziniif test "$debug" = "no"; then
6263a5665051SPaolo Bonzini  CFLAGS="-O2 $CFLAGS"
6264a5665051SPaolo Bonzinifi
6265086d5f75SPaolo Bonzini
6266086d5f75SPaolo Bonzinicase "$ARCH" in
6267086d5f75SPaolo Bonzinialpha)
6268086d5f75SPaolo Bonzini  # Ensure there's only a single GP
6269086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
6270086d5f75SPaolo Bonzini;;
6271086d5f75SPaolo Bonziniesac
6272086d5f75SPaolo Bonzini
6273086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
6274086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
6275086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
6276086d5f75SPaolo Bonzinifi
6277a316e378SJuan Quintela
6278247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
6279db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
6280db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
6281d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
6282d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
6283d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6284d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
6285d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
6286d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6287d83414e1SMarc-André Lureau  fi
6288247724cbSMarc-André Lureaufi
62890aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
62900aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
62910aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
62920aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
62930aebab04SLingfeng Yang  else
62940aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
62950aebab04SLingfeng Yang  fi
62960aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
62970aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
62980aebab04SLingfeng Yangfi
6299247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
6300db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
6301db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
6302247724cbSMarc-André Lureaufi
6303247724cbSMarc-André Lureau
63046542aa9cSPeter Lieven##########################################
63056542aa9cSPeter Lieven# Do we have libnfs
63066542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
6307b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
63086542aa9cSPeter Lieven    libnfs="yes"
63096542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
63106542aa9cSPeter Lieven  else
63116542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
63128efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
63136542aa9cSPeter Lieven    fi
63146542aa9cSPeter Lieven    libnfs="no"
63156542aa9cSPeter Lieven  fi
63166542aa9cSPeter Lievenfi
63171d728c39SBlue Swirl
63183efac6ebSTomáš Golembiovský##########################################
63193efac6ebSTomáš Golembiovský# Do we have libudev
63203efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
63213efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
63223efac6ebSTomáš Golembiovský    libudev="yes"
63233efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
63243efac6ebSTomáš Golembiovský  else
63253efac6ebSTomáš Golembiovský    libudev="no"
63263efac6ebSTomáš Golembiovský  fi
63273efac6ebSTomáš Golembiovskýfi
63283efac6ebSTomáš Golembiovský
63296ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
63306ca026cbSPeter Maydellif test "$werror" = "yes"; then
63316ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
63326ca026cbSPeter Maydellfi
63336ca026cbSPeter Maydell
63340aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
63350aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
6336e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
6337db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
6338e86ecd4bSJuan Quintela    fi
6339e86ecd4bSJuan Quintelafi
6340e86ecd4bSJuan Quintela
634194dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
634294dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
634394dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
634494dd53c5SGerd Hoffmannelse
634594dd53c5SGerd Hoffmann    POD2MAN="pod2man"
634694dd53c5SGerd Hoffmannfi
634794dd53c5SGerd Hoffmann
6348952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
6349952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
6350952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
6351e9a3591fSChristian Borntraeger        if ld_has $flag ; then
6352db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
6353952afb71SBlue Swirl        fi
6354952afb71SBlue Swirl    done
6355952afb71SBlue Swirlfi
6356952afb71SBlue Swirl
63577776ea6bSPhilippe Mathieu-Daudé# Disable OpenBSD W^X if available
63587776ea6bSPhilippe Mathieu-Daudéif test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
63597776ea6bSPhilippe Mathieu-Daudé    cat > $TMPC <<EOF
63607776ea6bSPhilippe Mathieu-Daudé    int main(void) { return 0; }
63617776ea6bSPhilippe Mathieu-DaudéEOF
63627776ea6bSPhilippe Mathieu-Daudé    wx_ldflags="-Wl,-z,wxneeded"
63637776ea6bSPhilippe Mathieu-Daudé    if compile_prog "" "$wx_ldflags"; then
63647776ea6bSPhilippe Mathieu-Daudé        QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
63657776ea6bSPhilippe Mathieu-Daudé    fi
63667776ea6bSPhilippe Mathieu-Daudéfi
63677776ea6bSPhilippe Mathieu-Daudé
636810ff82d1SMarc-André Lureauqemu_confdir="$sysconfdir/$qemu_suffix"
636910ff82d1SMarc-André Lureauqemu_moddir="$libdir/$qemu_suffix"
637010ff82d1SMarc-André Lureauqemu_datadir="$datadir/$qemu_suffix"
6371ca8c0909SMarc-André Lureauqemu_docdir="$docdir/$qemu_suffix"
6372834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
6373a8260d38SDaniel P. Berrangéqemu_icondir="$datadir/icons"
637467ea9546SDaniel P. Berrangéqemu_desktopdir="$datadir/applications"
63755a67135aSbellard
6376e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
6377e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
6378e0580342SKamil Rytarowski  ivshmem=yes
6379e0580342SKamil Rytarowskifi
6380e0580342SKamil Rytarowski
63814b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
6382b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
63837e462613SPaolo Bonzini    if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
6384983eef5aSMeador Inge      virtfs=yes
6385983eef5aSMeador Inge    else
6386983eef5aSMeador Inge      if test "$virtfs" = yes; then
63877e462613SPaolo Bonzini        error_exit "VirtFS requires libcap-ng devel and libattr devel"
6388983eef5aSMeador Inge      fi
638917500370SAndreas Färber      virtfs=no
6390983eef5aSMeador Inge    fi
6391fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
6392fe8fc5aeSPaolo Bonzini      mpath=yes
6393fe8fc5aeSPaolo Bonzini    else
6394fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
6395fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
6396fe8fc5aeSPaolo Bonzini      fi
6397fe8fc5aeSPaolo Bonzini      mpath=no
6398fe8fc5aeSPaolo Bonzini    fi
6399b855f8d1SPaolo Bonzini  else
6400b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
6401b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
6402b855f8d1SPaolo Bonzini    fi
6403b855f8d1SPaolo Bonzini    virtfs=no
6404fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
6405fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
6406fe8fc5aeSPaolo Bonzini    fi
6407fe8fc5aeSPaolo Bonzini    mpath=no
640817bff52bSM. Mohan Kumar  fi
6409ff69fd8cSLaurent Vivierfi
64109d6bc27bSMichael Roth
64119d6bc27bSMichael Roth# Probe for guest agent support/options
64129d6bc27bSMichael Roth
6413e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
6414a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6415a5125905SLaurent Vivier      guest_agent=no
6416a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
6417e8ef31a3SMichael Tokarev      guest_agent=yes
6418e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
6419e8ef31a3SMichael Tokarev      guest_agent=no
6420e8ef31a3SMichael Tokarev  else
6421e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
6422ca35f780SPaolo Bonzini  fi
64234b1c11fdSDaniel P. Berrangefi
6424ca35f780SPaolo Bonzini
64259d6bc27bSMichael Roth# Guest agent Window MSI  package
64269d6bc27bSMichael Roth
64279d6bc27bSMichael Rothif test "$guest_agent" != yes; then
64289d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
64299d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
64309d6bc27bSMichael Roth  fi
64319d6bc27bSMichael Roth  guest_agent_msi=no
64329d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
64339d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
64349d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
64359d6bc27bSMichael Roth  fi
64369d6bc27bSMichael Roth  guest_agent_msi=no
64379d6bc27bSMichael Rothelif ! has wixl; then
64389d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
64399d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
64409d6bc27bSMichael Roth  fi
64419d6bc27bSMichael Roth  guest_agent_msi=no
64421a34904eSMichael Rothelse
64431a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
64441a34904eSMichael Roth  # disabled explicitly
64451a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
64461a34904eSMichael Roth    guest_agent_msi=yes
64471a34904eSMichael Roth  fi
64489d6bc27bSMichael Rothfi
64499d6bc27bSMichael Roth
64501a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
64519d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
64529d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
64539d6bc27bSMichael Roth  fi
64549d6bc27bSMichael Roth
64559d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
64569d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
64579d6bc27bSMichael Roth  fi
64589d6bc27bSMichael Roth
64599d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
64609d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
64619d6bc27bSMichael Roth  fi
64629d6bc27bSMichael Roth
64639d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
646489138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
64659d6bc27bSMichael Roth  fi
64669d6bc27bSMichael Roth
646789138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
64689d6bc27bSMichael Roth
64699d6bc27bSMichael Roth  case "$cpu" in
64709d6bc27bSMichael Roth  x86_64)
64719d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
64729d6bc27bSMichael Roth    ;;
64739d6bc27bSMichael Roth  i386)
64749d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
64759d6bc27bSMichael Roth    ;;
64769d6bc27bSMichael Roth  *)
64779d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
64789d6bc27bSMichael Roth    ;;
64799d6bc27bSMichael Roth  esac
64809d6bc27bSMichael Rothfi
64819d6bc27bSMichael Roth
6482ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
6483ca35f780SPaolo Bonziniroms=
6484e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6485e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6486e633a5c6SEric Blake        test "$softmmu" = yes ; then
6487e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
6488c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6489c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6490c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6491e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6492e57218b6SPeter Maydell            ld_i386_emulation="$emu"
6493ca35f780SPaolo Bonzini            roms="optionrom"
6494e57218b6SPeter Maydell            break
6495e57218b6SPeter Maydell        fi
6496e57218b6SPeter Maydell    done
6497ca35f780SPaolo Bonzinifi
6498ca35f780SPaolo Bonzini
64992e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
65009933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
65012e33c3f8SThomas Huth  write_c_skeleton
65022e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
65039933c305SChristian Borntraeger    roms="$roms s390-ccw"
65041ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
65051ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
65061ef6bfc2SPhilippe Mathieu-Daudé    if test -e "${source_path}/.git" ; then
65071ef6bfc2SPhilippe Mathieu-Daudé      git_submodules="${git_submodules} roms/SLOF"
65081ef6bfc2SPhilippe Mathieu-Daudé    fi
65099933c305SChristian Borntraeger  fi
65102e33c3f8SThomas Huthfi
65119933c305SChristian Borntraeger
651211cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
651311cde1c8SBruno 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.
651411cde1c8SBruno Dominguezif has $cxx; then
651511cde1c8SBruno Dominguez    cat > $TMPC <<EOF
651611cde1c8SBruno Dominguezint c_function(void);
651711cde1c8SBruno Dominguezint main(void) { return c_function(); }
651811cde1c8SBruno DominguezEOF
651911cde1c8SBruno Dominguez
652011cde1c8SBruno Dominguez    compile_object
652111cde1c8SBruno Dominguez
652211cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
652311cde1c8SBruno Dominguezextern "C" {
652411cde1c8SBruno Dominguez   int c_function(void);
652511cde1c8SBruno Dominguez}
652611cde1c8SBruno Dominguezint c_function(void) { return 42; }
652711cde1c8SBruno DominguezEOF
652811cde1c8SBruno Dominguez
652911cde1c8SBruno Dominguez    update_cxxflags
653011cde1c8SBruno Dominguez
6531086d5f75SPaolo Bonzini    if do_cxx $CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
653211cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
653311cde1c8SBruno Dominguez        :
653411cde1c8SBruno Dominguez    else
653511cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
653611cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
653711cde1c8SBruno Dominguez        cxx=
653811cde1c8SBruno Dominguez    fi
653911cde1c8SBruno Dominguezelse
654011cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
654111cde1c8SBruno Dominguez    cxx=
654211cde1c8SBruno Dominguezfi
654311cde1c8SBruno Dominguez
654402d34f62SCole Robinsonecho_version() {
654502d34f62SCole Robinson    if test "$1" = "yes" ; then
654602d34f62SCole Robinson        echo "($2)"
654702d34f62SCole Robinson    fi
654802d34f62SCole Robinson}
654902d34f62SCole Robinson
6550b7612f45SPaolo Bonzini# prepend ftd flags after all config tests are done
6551b7612f45SPaolo BonziniQEMU_CFLAGS="$fdt_cflags $QEMU_CFLAGS"
65528a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
65535ca9388aSGerd Hoffmann
655498ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
655597a847bcSbellard
655698ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
655798ec69acSJuan Quintelaecho >> $config_host_mak
655898ec69acSJuan Quintela
6559e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
656099d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
656199d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
65623aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
65638bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
65640f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
656599d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
656622d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
65679afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
65683d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
6569e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
65705a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6571785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
65725a699bbbSLaszlo Ersekfi
6573f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6574834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6575a8260d38SDaniel P. Berrangéecho "qemu_icondir=$qemu_icondir" >> $config_host_mak
657667ea9546SDaniel P. Berrangéecho "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
6577cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6578aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6579f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6580804edf29SJuan Quintela
658198ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6582727e5283SPaolo Bonzini
6583f3494749SPaolo Bonziniif test "$default_devices" = "yes" ; then
6584f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6585f3494749SPaolo Bonzinielse
6586f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6587f3494749SPaolo Bonzinifi
6588f8393946Saurel32if test "$debug_tcg" = "yes" ; then
65892358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6590f8393946Saurel32fi
65911625af87Saliguoriif test "$strip_opt" = "yes" ; then
659252ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
65931625af87Saliguorifi
65947d13299dSbellardif test "$bigendian" = "yes" ; then
6595e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
659697a847bcSbellardfi
659767b915a5Sbellardif test "$mingw32" = "yes" ; then
659898ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
659989138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
66009fe6de94SBlue Swirl  version_major=${rc_version%%.*}
66019fe6de94SBlue Swirl  rc_version=${rc_version#*.}
66029fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
66039fe6de94SBlue Swirl  rc_version=${rc_version#*.}
66049fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
66059fe6de94SBlue Swirl  version_micro=0
66069fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
66079fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6608d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6609d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6610f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6611d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6612d9840e25STomoki Sekiyama  fi
661350cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
661476dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
661550cbebb9SMichael Roth  fi
66161a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
66179dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
66189dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
66199dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
66209dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
66219dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
66229dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
66239dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
66249dacf32dSYossi Hindin  fi
6625210fa556Spbrookelse
662635f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6627210fa556Spbrookfi
6628128ab2ffSblueswir1
6629dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6630dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6631dffcb71cSMark McLoughlinfi
6632dffcb71cSMark McLoughlin
663383fb7adfSbellardif test "$darwin" = "yes" ; then
663498ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
663583fb7adfSbellardfi
6636b29fe3edSmalc
6637ec530c81Sbellardif test "$solaris" = "yes" ; then
663898ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6639ec530c81Sbellardfi
6640179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6641179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6642179cf400SAndreas Färberfi
664397a847bcSbellardif test "$static" = "yes" ; then
664498ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
664597a847bcSbellardfi
66461ba16968SStefan Weilif test "$profiler" = "yes" ; then
66472358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
664805c2a3e7Sbellardfi
6649c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
6650c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
6651c932ce31SPaolo Bonzinifi
6652f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
6653f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
6654f15bff25SPaolo Bonzinifi
6655675b9b53SMarc-André Lureauif test "$slirp" != "no"; then
665698ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6657e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6658675b9b53SMarc-André Lureau  echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
6659675b9b53SMarc-André Lureau  echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
6660675b9b53SMarc-André Lureaufi
6661859aef02SPaolo Bonzinisubdirs=
66627c57bdd8SMarc-André Lureauif [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
6663859aef02SPaolo Bonzini  subdirs="$subdirs slirp"
6664c20709aaSbellardfi
66658a16d273Sthsif test "$vde" = "yes" ; then
666698ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6667e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
66688a16d273Sthsfi
666958952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
667058952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
667158952137SVincenzo Maffionefi
6672015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6673015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6674015a33bdSGongleifi
66754cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
66764cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
66774cc600d2SPaolo Bonzinifi
667847e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
6679a358bca2SPaolo Bonzini  echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak
66803f99cf57SPaolo Bonzini  echo "LIBCAP_NG_LIBS=$cap_libs" >> $config_host_mak
668147e98658SCorey Bryantfi
66822358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
66830c58ac1cSmalcfor drv in $audio_drv_list; do
66841ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6685484e2cc7SPaolo Bonzini    echo "$def=y" >> $config_host_mak
66860c58ac1cSmalcdone
6687478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
6688478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
6689478e943fSPaolo Bonzinifi
6690b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6691478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
6692478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
6693478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
6694478e943fSPaolo Bonzinifi
6695b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6696478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
6697b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6698b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6699b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
6700478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
6701478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
6702478e943fSPaolo Bonzinifi
67032e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
6704d5631638Smalcif test "$audio_win_int" = "yes" ; then
6705d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6706d5631638Smalcfi
6707b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6708b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6709dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6710dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6711dce512deSChristoph Hellwigfi
671289138857SStefan Weilqemu_version=$(head $source_path/VERSION)
67132358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
671498ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
67152b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6716a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
671798ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6718cc8ae6deSpbrookfi
671917969268SFam Zhengif test "$modules" = "yes"; then
6720e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6721e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
672289138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
672317969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
672417969268SFam Zhengfi
6725bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
6726bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
6727bd83c861SChristian Ehrhardtfi
6728e633a5c6SEric Blakeif test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
67298781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
67308781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
67318781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
67328781595bSGerd Hoffmannfi
673349ecc3faSbellardif test "$cocoa" = "yes" ; then
673498ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
673549ecc3faSbellardfi
6736e08bb301SSamuel Thibaultif test "$iconv" = "yes" ; then
6737e08bb301SSamuel Thibault  echo "CONFIG_ICONV=y" >> $config_host_mak
6738e08bb301SSamuel Thibault  echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
6739e08bb301SSamuel Thibault  echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
6740e08bb301SSamuel Thibaultfi
67414d3b6f6eSbalrogif test "$curses" = "yes" ; then
6742484e2cc7SPaolo Bonzini  echo "CONFIG_CURSES=y" >> $config_host_mak
67432373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
67442373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6745ab4e5602SJan Kiszkafi
6746099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
67472358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6748099d6b0fSRiku Voipiofi
674940ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
675040ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
675140ff6d7eSKevin Wolffi
67523ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
67532358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
67543ce34dfbSvibisreenivasanfi
6755c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6756c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6757c2882b96SRiku Voipiofi
6758751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6759751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6760751bcc39SMarc-André Lureaufi
6761955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6762955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6763955727d2SCortland Tölvafi
6764d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6765d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6766d0927938SUlrich Hechtfi
67673d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
67683d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
67693d4fa43eSKusanagi Kouichifi
6770b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6771b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6772b953f075SDenis V. Lunevfi
6773ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6774ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6775ed911435SKevin Wolffi
6776c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6777c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6778c727f47dSPeter Maydellfi
6779dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6780dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6781dace20dcSPeter Maydellfi
6782d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6783d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6784d0927938SUlrich Hechtfi
67854e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
67864e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
67874e0c6529SAlex Blighfi
6788cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6789cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6790cd758dd0SAlex Blighfi
67913b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
67923b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
67933b6edd16SPeter Maydellfi
67943b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
67953b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
67963b6edd16SPeter Maydellfi
6797a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6798a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6799a8fd1abaSPeter Maydellfi
680051834341SRiku Voipioif test "$timerfd" = "yes" ; then
680151834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
680251834341SRiku Voipiofi
68039af5c906SRiku Voipioif test "$setns" = "yes" ; then
68049af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
68059af5c906SRiku Voipiofi
680638860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
680738860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
680838860a03SAleksandar Markovicfi
68095a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
68105a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
68115a03cd00SAleksandar Markovicfi
6812db37dd89SAleksandar Markovicif test "$kcov" = "yes" ; then
6813db37dd89SAleksandar Markovic  echo "CONFIG_KCOV=y" >> $config_host_mak
6814db37dd89SAleksandar Markovicfi
6815d6092e08SFilip Bozutaif test "$btrfs" = "yes" ; then
6816d6092e08SFilip Bozuta  echo "CONFIG_BTRFS=y" >> $config_host_mak
6817d6092e08SFilip Bozutafi
68183b3f24adSaurel32if test "$inotify" = "yes" ; then
68192358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
68203b3f24adSaurel32fi
6821c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6822c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6823c05c7a73SRiku Voipiofi
6824401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6825401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6826401bc051SPeter Maydellfi
68275c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
68285c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
68295c99fa37SKeno Fischerfi
68308a792b03SJiufei Xueif test "$st_atim" = "yes" ; then
68318a792b03SJiufei Xue  echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
68328a792b03SJiufei Xuefi
68336ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
68346ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
68356ae9a1f4SJuan Quintelafi
68366ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
68376ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
68386ae9a1f4SJuan Quintelafi
6839769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6840484e2cc7SPaolo Bonzini  echo "CONFIG_CURL=y" >> $config_host_mak
6841b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
68426ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6843769ce76dSAlexander Graffi
68442e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
684598ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
68468eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
68472e4d9fb1Saurel32fi
6848a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6849484e2cc7SPaolo Bonzini  echo "CONFIG_GTK=y" >> $config_host_mak
6850a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6851014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6852925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6853925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6854925a0400SGerd Hoffmann  fi
6855bbbf9bfbSStefan Weilfi
6856f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
6857f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
6858f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
6859f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
686025a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
6861f876b765SMarc-André Lureaufi
6862a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6863ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6864ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6865a81df1b6SPaolo Bonzini  echo "GNUTLS_CFLAGS=$gnutls_cflags" >> $config_host_mak
6866a81df1b6SPaolo Bonzini  echo "GNUTLS_LIBS=$gnutls_libs" >> $config_host_mak
6867ddbb0d09SDaniel P. Berrangefi
686891bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
686991bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
68701f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
68711f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
68721f923c70SLongpeng(Mike)  fi
687346859d93SDaniel P. Berrangé  echo "GCRYPT_CFLAGS=$gcrypt_cflags" >> $config_host_mak
687446859d93SDaniel P. Berrangé  echo "GCRYPT_LIBS=$gcrypt_libs" >> $config_host_mak
687562893b67SDaniel P. Berrangefi
687691bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
687791bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6878becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6879a81df1b6SPaolo Bonzini  echo "NETTLE_CFLAGS=$nettle_cflags" >> $config_host_mak
6880a81df1b6SPaolo Bonzini  echo "NETTLE_LIBS=$nettle_libs" >> $config_host_mak
6881ed754746SDaniel P. Berrangefi
6882e0576942SDaniel P. Berrangéif test "$qemu_private_xts" = "yes" ; then
6883e0576942SDaniel P. Berrangé  echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
6884e0576942SDaniel P. Berrangéfi
68859a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
68869a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
68879a2fd434SDaniel P. Berrangefi
68888953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
68898953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
68908953caf3SDaniel P. Berrangefi
6891559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6892559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6893559607eaSDaniel P. Berrangefi
6894e865b97fSChen Gangif test "$have_drm_h" = "yes" ; then
6895e865b97fSChen Gang  echo "HAVE_DRM_H=y" >> $config_host_mak
6896e865b97fSChen Gangfi
68976b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
68986b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
68996b39b063SEric Blakefi
69009df8b20dSThomas Huthif test "$have_openpty" = "yes" ; then
69019df8b20dSThomas Huth    echo "HAVE_OPENPTY=y" >> $config_host_mak
69029df8b20dSThomas Huthfi
69032a4b472cSDavid CARLIERif test "$have_sys_signal_h" = "yes" ; then
69042a4b472cSDavid CARLIER    echo "HAVE_SYS_SIGNAL_H=y" >> $config_host_mak
69052a4b472cSDavid CARLIERfi
6906277abf15SJan Vesely
6907277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6908277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6909277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6910277abf15SJan Vesely# if this macro is set.
6911277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6912277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6913277abf15SJan Veselyfi
69141efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
69151efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
69161efad060SFam Zhengfi
6917bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
6918bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
6919a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
6920e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
6921a4ccabcfSAnthony Liguorifi
69229d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
69239d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
69249d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
69259d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
69269d9e1521SGerd Hoffmannfi
6927e37630caSaliguoriif test "$xen" = "yes" ; then
69286dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
6929d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
6930582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
6931582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
6932e37630caSaliguorifi
69335c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
69345c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
69355c6c3a6cSChristoph Hellwigfi
6936c10dd856SAarushi Mehtaif test "$linux_io_uring" = "yes" ; then
6937c10dd856SAarushi Mehta  echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
6938c10dd856SAarushi Mehta  echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
6939c10dd856SAarushi Mehta  echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
6940c10dd856SAarushi Mehtafi
6941758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
6942758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
6943ec0d5893SMarc-André Lureau  echo "LIBATTR_LIBS=$libattr_libs" >> $config_host_mak
6944758e8e38SVenkateswararao Jujjuri (JV)fi
69454f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
69464f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
69474f26f2b6SAvi Kivityfi
6948983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
6949758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
6950758e8e38SVenkateswararao Jujjuri (JV)fi
6951fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
6952fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
69531b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
69541b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
69551b0578f5SMurilo Opsfelder Araujo  fi
6956fe8fc5aeSPaolo Bonzinifi
69575e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
69585e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
69595e9be92dSNicholas Bellingerfi
6960af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
6961af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
6962af3bba76SPaolo Bonzinifi
6963af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
696456f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
696503ce5744SNikolay Nikolaevfi
6966108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
6967108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
6968108a6481SCindy Lufi
6969042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
6970042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
6971042cea27SGongleifi
6972fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
6973fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
69745fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
69755fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
69765fe97d88SStefano Garzarella  fi
6977fc0b9b0eSStefan Hajnoczifi
6978299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
6979299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
6980299e6f19SPaolo Bonzinifi
6981e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
6982e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
6983e6a74868SMarc-André Lureaufi
6984108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
6985108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
6986108a6481SCindy Lufi
698798fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
698898fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
698998fc1adaSDr. David Alan Gilbertfi
699077755340Sthsif test "$blobs" = "yes" ; then
699198ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
699277755340Sthsfi
6993bf9298b9Saliguoriif test "$iovec" = "yes" ; then
69942358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
6995bf9298b9Saliguorifi
6996ceb42de8Saliguoriif test "$preadv" = "yes" ; then
69972358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
6998ceb42de8Saliguorifi
6999e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
70003f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
70014a96337dSPaolo Bonzini  echo "FDT_CFLAGS=$fdt_cflags" >> $config_host_mak
70024a96337dSPaolo Bonzini  echo "FDT_LIBS=$fdt_ldflags $fdt_libs" >> $config_host_mak
7003f652e6afSaurel32fi
7004a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
7005a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
7006a40161cbSPaolo Bonzinifi
7007dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
7008dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
7009dcc38d1cSMarcelo Tosattifi
7010d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
7011d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
7012d339d766SRichard W.M. Jonesfi
7013b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
7014b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
70159195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
70169195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
70179195b2c2SStefan Weil  fi
7018b3f6ea7eSPaolo Bonzinifi
70195f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
70205f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
70215f6b9e8fSBlue Swirlfi
7022e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
7023e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
7024e78815a5SAndreas Färberfi
7025e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
7026e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
7027e78815a5SAndreas Färberfi
70289bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
70299bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
70309bc5a719SAndreas Gustafssonfi
7031cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
7032cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
70332634733cSPaolo Bonzini  echo "SPICE_CFLAGS=$spice_cflags" >> $config_host_mak
70342634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
7035cd4ec0b4SGerd Hoffmannfi
7036cd4ec0b4SGerd Hoffmann
70377b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
70387b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
70397b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
70407b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
7041111a38b0SRobert Relyeafi
7042111a38b0SRobert Relyea
70432b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
70442b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
7045b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
7046b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
70472b2325ffSGerd Hoffmannfi
70482b2325ffSGerd Hoffmann
704969354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
705069354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
7051cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
7052cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
705369354a83SHans de Goedefi
705469354a83SHans de Goede
7055da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
7056da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
7057da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
7058014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
7059014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
7060014cb152SGerd Hoffmann  fi
706120ff075bSMichael Wallefi
706220ff075bSMichael Walle
7063d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
7064d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
7065d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
7066d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
7067d52c454aSMarc-André Lureaufi
7068d52c454aSMarc-André Lureau
7069d52c454aSMarc-André Lureau
70705a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
70715a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
70725a22ab71SYang Zhongfi
70735a22ab71SYang Zhong
707499f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
707599f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
707699f2dbd3SLiang Lifi
707799f2dbd3SLiang Li
70786b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
70796b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
70806b8cd447SRobert Hoofi
70816b8cd447SRobert Hoo
7082607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
7083607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
7084708eab42SMarc-André Lureau  echo "LZO_LIBS=$lzo_libs" >> $config_host_mak
7085607dacd0Sqiaonuohanfi
7086607dacd0Sqiaonuohan
7087607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
7088607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
7089708eab42SMarc-André Lureau  echo "SNAPPY_LIBS=$snappy_libs" >> $config_host_mak
7090607dacd0Sqiaonuohanfi
7091607dacd0Sqiaonuohan
70926b383c08SPeter Wuif test "$bzip2" = "yes" ; then
70936b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
70946b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
70956b383c08SPeter Wufi
70966b383c08SPeter Wu
709783bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
709883bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
709983bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
710083bc1f97SJulio Faraccofi
710183bc1f97SJulio Faracco
71023a678481SJuan Quintelaif test "$zstd" = "yes" ; then
71033a678481SJuan Quintela  echo "CONFIG_ZSTD=y" >> $config_host_mak
71045e5733e5SMarc-André Lureau  echo "ZSTD_CFLAGS=$zstd_cflags" >> $config_host_mak
71055e5733e5SMarc-André Lureau  echo "ZSTD_LIBS=$zstd_libs" >> $config_host_mak
71063a678481SJuan Quintelafi
71073a678481SJuan Quintela
7108c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
7109484e2cc7SPaolo Bonzini  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
71106ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
71116ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
7112c589b249SRonnie Sahlbergfi
7113c589b249SRonnie Sahlberg
71146542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
7115484e2cc7SPaolo Bonzini  echo "CONFIG_LIBNFS=y" >> $config_host_mak
71164be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
71176542aa9cSPeter Lievenfi
71186542aa9cSPeter Lieven
7119f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
7120f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
7121c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7122c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7123f794573eSEduardo Otubofi
7124f794573eSEduardo Otubo
712583fb7adfSbellard# XXX: suppress that
71267d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
71272358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
71287d3505c5Sbellardfi
71297d3505c5Sbellard
71304d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
71314d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
71324d9310f4SDaniel P. Berrangefi
71333556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
71343556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
71353556c233SPaolo Bonzinifi
7136f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
7137484e2cc7SPaolo Bonzini  echo "CONFIG_RBD=y" >> $config_host_mak
71386ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7139f27aaf4bSChristian Brunnerfi
714020ff6c80SAnthony Liguori
71417c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
714270c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
714370c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
714470c60c08SStefan Hajnoczielse
714570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
714670c60c08SStefan Hajnoczifi
7147d0e2fce5SAneesh Kumar K.V
71487d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
71497d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
71507d992e4dSPeter Lievenfi
71517d992e4dSPeter Lieven
7152f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
7153f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
7154f0d92b56SLongpeng(Mike)fi
7155f0d92b56SLongpeng(Mike)
7156d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
7157d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7158d2042378SAneesh Kumar K.Vfi
7159d2042378SAneesh Kumar K.V
7160e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
7161e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7162e06a765eSHarsh Prateek Borafi
7163e06a765eSHarsh Prateek Bora
71643f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
71653f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
71663f4349dcSKevin Wolffi
71673f4349dcSKevin Wolf
7168d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
7169d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7170d83414e1SMarc-André Lureaufi
7171d83414e1SMarc-André Lureau
71720aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
71730aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
71740aebab04SLingfeng Yangfi
71750aebab04SLingfeng Yang
71768ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
71778ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
71788ab1bf12SLuiz Capitulinofi
71798ab1bf12SLuiz Capitulino
718076a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
718176a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
718276a347e1SRichard Hendersonfi
718376a347e1SRichard Henderson
7184f540166bSRichard Hendersonif test "$int128" = "yes" ; then
7185f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
7186f540166bSRichard Hendersonfi
7187f540166bSRichard Henderson
71887ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
71897ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
71907ebee43eSRichard Hendersonfi
71917ebee43eSRichard Henderson
7192e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
7193e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7194e6cd4bb5SRichard Hendersonfi
7195e6cd4bb5SRichard Henderson
7196df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
7197df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7198df79b996SRichard Hendersonfi
7199df79b996SRichard Henderson
7200db8aaae8SRichard Hendersonif test "$attralias" = "yes" ; then
7201db8aaae8SRichard Henderson  echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
7202db8aaae8SRichard Hendersonfi
7203db8aaae8SRichard Henderson
72041e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
72051e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
72061e6e9acaSRichard Hendersonfi
72071e6e9acaSRichard Henderson
7208eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
7209484e2cc7SPaolo Bonzini  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
72106ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
72116ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7212eb100396SBharata B Raofi
7213eb100396SBharata B Rao
7214d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
7215d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7216d85fa9ebSJeff Codyfi
7217d85fa9ebSJeff Cody
72180c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
72190c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
72200c14fb47SBharata B Raofi
72210c14fb47SBharata B Rao
7222df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
7223df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7224df3a429aSNiels de Vosfi
7225df3a429aSNiels de Vos
72267c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
72277c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
72287c815372SBharata B Raofi
72297c815372SBharata B Rao
7230e014dbe7SPrasanna Kumar Kaleverif test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7231e014dbe7SPrasanna Kumar Kalever  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7232e014dbe7SPrasanna Kumar Kaleverfi
7233e014dbe7SPrasanna Kumar Kalever
72340e3b891fSNiels de Vosif test "$glusterfs_iocb_has_stat" = "yes" ; then
72350e3b891fSNiels de Vos  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
72360e3b891fSNiels de Vosfi
72370e3b891fSNiels de Vos
7238b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
7239484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
7240b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7241b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
72420a12ec87SRichard W.M. Jonesfi
72430a12ec87SRichard W.M. Jones
7244ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
7245ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7246ed1701c6SDr. David Alan Gilbertfi
7247ed1701c6SDr. David Alan Gilbert
72483b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
72493cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
72503b8acc11SPaolo Bonzinifi
72513b8acc11SPaolo Bonzini
72525b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
72535b808275SLluís Vilanovaif have_backend "nop"; then
72546d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
725522890ab5SPrerna Saxenafi
72565b808275SLluís Vilanovaif have_backend "simple"; then
72576d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
72586d8a764eSLluís  # Set the appropriate trace file.
7259953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
72609410b56cSPrerna Saxenafi
7261ed7f5f1dSPaolo Bonziniif have_backend "log"; then
7262ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
72636d8a764eSLluísfi
72645b808275SLluís Vilanovaif have_backend "ust"; then
72656d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
7266a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
7267a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
72686d8a764eSLluísfi
72695b808275SLluís Vilanovaif have_backend "dtrace"; then
72706d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
72716d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
72726d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
72736d8a764eSLluís  fi
7274c276b17dSDaniel P. Berrangefi
72755b808275SLluís Vilanovaif have_backend "ftrace"; then
7276781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
7277781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7278781e9545SEiichi Tsukata  else
727921684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7280781e9545SEiichi Tsukata  fi
7281781e9545SEiichi Tsukatafi
72820a852417SPaul Durrantif have_backend "syslog"; then
72830a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
72840a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
72850a852417SPaul Durrant  else
72860a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
72870a852417SPaul Durrant  fi
72880a852417SPaul Durrantfi
72899410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
72909410b56cSPrerna Saxena
72912da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
72922da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
7293392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
72942da776dbSMichael R. Hinesfi
72952da776dbSMichael R. Hines
729621ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
729721ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
729821ab34c9SMarcel Apfelbaumfi
729921ab34c9SMarcel Apfelbaum
7300575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
7301575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7302575b22b1SLaurent Vivierfi
7303575b22b1SLaurent Vivier
7304ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
7305ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
7306ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7307ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7308ed279a06SKlim Kireevfi
7309ed279a06SKlim Kireev
7310a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
7311a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
7312a6b1d4c0SChanglong Xiefi
7313a6b1d4c0SChanglong Xie
73146a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
73156a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
73166a02c806SStefan Hajnoczifi
73176a02c806SStefan Hajnoczi
73184d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
73194d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
73204d04351fSChristopher Covingtonfi
73214d04351fSChristopher Covington
732249e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
732349e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
732449e00a18SAndreas Grapentinfi
732549e00a18SAndreas Grapentin
7326e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
7327e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
7328e674605fSTomáš Golembiovskýfi
7329db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
7330db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7331db1ed1abSRichard Hendersonfi
7332e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
7333e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7334e0580342SKamil Rytarowskifi
7335e219c499SRichard Hendersonif test "$capstone" != "no" ; then
73368ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
7337c9322ab5SMarc-André Lureau  echo "CAPSTONE_CFLAGS=$capstone_cflags" >> $config_host_mak
7338c9322ab5SMarc-André Lureau  echo "CAPSTONE_LIBS=$capstone_libs" >> $config_host_mak
73398ca80760SRichard Hendersonfi
7340ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
7341ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7342ba59fb77SPaolo Bonzinifi
7343e0580342SKamil Rytarowski
73445c312079SDr. David Alan Gilbert# Hold two types of flag:
73455c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
73465c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
7347479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
73485c312079SDr. David Alan Gilbert#                                     platform
7349479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
73505c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7351479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7352479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
7353479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7354479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
73555c312079SDr. David Alan Gilbertfi
73565c312079SDr. David Alan Gilbert
735717824406SJunyan Heif test "$libpmem" = "yes" ; then
735817824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
7359c9322ab5SMarc-André Lureau  echo "LIBPMEM_LIBS=$libpmem_libs" >> $config_host_mak
7360c9322ab5SMarc-André Lureau  echo "LIBPMEM_CFLAGS=$libpmem_cflags" >> $config_host_mak
736117824406SJunyan Hefi
736217824406SJunyan He
736321b2eca6SJingqi Liuif test "$libdaxctl" = "yes" ; then
736421b2eca6SJingqi Liu  echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
7365c7c91a74SBruce Rogers  echo "LIBDAXCTL_LIBS=$libdaxctl_libs" >> $config_host_mak
736621b2eca6SJingqi Liufi
736721b2eca6SJingqi Liu
73682f740136SJeff Codyif test "$bochs" = "yes" ; then
73692f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
73702f740136SJeff Codyfi
73712f740136SJeff Codyif test "$cloop" = "yes" ; then
73722f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
73732f740136SJeff Codyfi
73742f740136SJeff Codyif test "$dmg" = "yes" ; then
73752f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
73762f740136SJeff Codyfi
73772f740136SJeff Codyif test "$qcow1" = "yes" ; then
73782f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
73792f740136SJeff Codyfi
73802f740136SJeff Codyif test "$vdi" = "yes" ; then
73812f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
73822f740136SJeff Codyfi
73832f740136SJeff Codyif test "$vvfat" = "yes" ; then
73842f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
73852f740136SJeff Codyfi
73862f740136SJeff Codyif test "$qed" = "yes" ; then
73872f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
73882f740136SJeff Codyfi
73892f740136SJeff Codyif test "$parallels" = "yes" ; then
73902f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
73912f740136SJeff Codyfi
73922f740136SJeff Codyif test "$sheepdog" = "yes" ; then
73932f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
73942f740136SJeff Codyfi
7395c9c8b88fSDavid CARLIERif test "$pty_h" = "yes" ; then
7396c9c8b88fSDavid CARLIER  echo "HAVE_PTY_H=y" >> $config_host_mak
7397c9c8b88fSDavid CARLIERfi
7398195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
7399195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
7400195588ccSDavid CARLIERfi
7401adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
7402086d5f75SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
7403adc28027SAlexander Bulekovfi
74042f740136SJeff Cody
740540e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
740640e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
740726fffe29SEmilio G. Cota    # Copy the export object list to the build dir
740826fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
740926fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
741026fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
741126fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
741226fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
741326fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
741426fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
741526fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
741626fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
741726fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
741826fffe29SEmilio G. Cota    else
741926fffe29SEmilio G. Cota	error_exit \
742026fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
742126fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
742226fffe29SEmilio G. Cota    fi
742340e8c6f4SAlex Bennéefi
742440e8c6f4SAlex Bennée
7425f48e590aSAlex Bennéeif test -n "$gdb_bin" ; then
7426f48e590aSAlex Bennée    echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
7427f48e590aSAlex Bennéefi
7428f48e590aSAlex Bennée
742954e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
743054e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
743154e7aac0SAlexey Krasikovfi
743254e7aac0SAlexey Krasikov
74335b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
743425211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
74355b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
743625211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/sparc $QEMU_INCLUDES"
74375b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
743825211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/s390 $QEMU_INCLUDES"
7439e633a5c6SEric Blakeelif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
744025211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/i386 $QEMU_INCLUDES"
744140d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
744225211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/ppc $QEMU_INCLUDES"
7443e633a5c6SEric Blakeelif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
744425211446SPaolo Bonzini  QEMU_INCLUDES="-I${source_path}/tcg/riscv $QEMU_INCLUDES"
74455b5e3037SPaolo Bonzinielse
744625211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/${ARCH} $QEMU_INCLUDES"
74475b5e3037SPaolo Bonzinifi
74485b5e3037SPaolo Bonzini
744998ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
7450804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
7451c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
74522eb054c2SPeter Maydellecho "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
745339d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
7454a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
7455804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
7456a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
7457859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
7458a31a8642SMichael S. Tsirkinfi
745983f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
74603c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
7461804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
746245d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
7463cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
74645f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
74653dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
7466804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
7467804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
74689f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
74694852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
7470daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
74719fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
7472e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
7473086d5f75SPaolo Bonziniecho "CXXFLAGS=$CXXFLAGS" >> $config_host_mak
747446eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7475a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
747611cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7477f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7478a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
7479a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
7480e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
7481968b4db3SPaolo Bonzini  echo "SPARSE_CFLAGS = -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7482e39f0062SPaolo Bonzinifi
74838a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
7484db5adeaaSPaolo Bonziniecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
74856969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7486e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
748773da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
74883e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7489409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7490804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
7491484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
749217969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7493f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
749490246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
749590246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
749694dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
74971d728c39SBlue Swirlif test "$gcov" = "yes" ; then
74981d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
74991d728c39SBlue Swirlfi
7500804edf29SJuan Quintela
75013efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
75023efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
75033efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
75043efac6ebSTomáš Golembiovskýfi
7505adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
7506adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
7507adc28027SAlexander Bulekovfi
75083efac6ebSTomáš Golembiovský
750905dfa22bSPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" ; then
751005dfa22bSPhilippe Mathieu-Daudé  echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
751105dfa22bSPhilippe Mathieu-Daudéfi
751205dfa22bSPhilippe Mathieu-Daudé
7513b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
7514b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
7515b767d257SMarek Marczykowski-Góreckifi
7516b767d257SMarek Marczykowski-Górecki
75176efd7517SPeter Maydell# use included Linux headers
75186efd7517SPeter Maydellif test "$linux" = "yes" ; then
7519a307beb6SAndreas Färber  mkdir -p linux-headers
75206efd7517SPeter Maydell  case "$cpu" in
7521c72b26ecSRichard Henderson  i386|x86_64|x32)
752208312a63SPeter Maydell    linux_arch=x86
75236efd7517SPeter Maydell    ;;
7524f8378accSRichard Henderson  ppc|ppc64|ppc64le)
752508312a63SPeter Maydell    linux_arch=powerpc
75266efd7517SPeter Maydell    ;;
75276efd7517SPeter Maydell  s390x)
752808312a63SPeter Maydell    linux_arch=s390
752908312a63SPeter Maydell    ;;
75301f080313SClaudio Fontana  aarch64)
75311f080313SClaudio Fontana    linux_arch=arm64
75321f080313SClaudio Fontana    ;;
7533222e7d11SSanjay Lal  mips64)
7534222e7d11SSanjay Lal    linux_arch=mips
7535222e7d11SSanjay Lal    ;;
753608312a63SPeter Maydell  *)
753708312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
753808312a63SPeter Maydell    linux_arch="$cpu"
75396efd7517SPeter Maydell    ;;
75406efd7517SPeter Maydell  esac
754108312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
754208312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
754308312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
754408312a63SPeter Maydell    fi
75456efd7517SPeter Maydellfi
75466efd7517SPeter Maydell
754797a847bcSbellardfor target in $target_list; do
754897a847bcSbellardtarget_dir="$target"
754925be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
755089138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
755152bf9771Stony.nguyen@bt.comtarget_aligned_only="no"
755252bf9771Stony.nguyen@bt.comcase "$target_name" in
755352bf9771Stony.nguyen@bt.com  alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
755452bf9771Stony.nguyen@bt.com  target_aligned_only="yes"
755552bf9771Stony.nguyen@bt.com  ;;
755652bf9771Stony.nguyen@bt.comesac
755797a847bcSbellardtarget_bigendian="no"
7558c1799a84SPaolo Bonzinicase "$target_name" in
7559a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
756052bf9771Stony.nguyen@bt.com  target_bigendian="yes"
7561ea2d6a39SJuan Quintela  ;;
7562ea2d6a39SJuan Quintelaesac
756397a847bcSbellardtarget_softmmu="no"
7564997344f3Sbellardtarget_user_only="no"
7565831b7825Sthstarget_linux_user="no"
756684778508Sblueswir1target_bsd_user="no"
75679e407a85Spbrookcase "$target" in
7568c1799a84SPaolo Bonzini  ${target_name}-softmmu)
75699e407a85Spbrook    target_softmmu="yes"
75709e407a85Spbrook    ;;
7571c1799a84SPaolo Bonzini  ${target_name}-linux-user)
75729e407a85Spbrook    target_user_only="yes"
75739e407a85Spbrook    target_linux_user="yes"
75749e407a85Spbrook    ;;
7575c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
757684778508Sblueswir1    target_user_only="yes"
757784778508Sblueswir1    target_bsd_user="yes"
757884778508Sblueswir1    ;;
75799e407a85Spbrook  *)
758076ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
75819e407a85Spbrook    exit 1
75829e407a85Spbrook    ;;
75839e407a85Spbrookesac
7584831b7825Sths
758597a847bcSbellardmkdir -p $target_dir
758625be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
758797a847bcSbellard
7588e5fe0c52Spbrookbflt="no"
7589ca759f9eSAlex Bennéemttcg="no"
759089138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
759156aebc89Spbrookgdb_xml_files=""
75927ba1e619Saliguori
7593c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
75946acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7595e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
75963a30446aSMarc-André LureauTARGET_SYSTBL_ABI=""
75973a30446aSMarc-André LureauTARGET_SYSTBL=""
7598e73aae67SJuan Quintela
7599c1799a84SPaolo Bonzinicase "$target_name" in
76002408a527Saurel32  i386)
76010a7fa00aSEmilio G. Cota    mttcg="yes"
76027b0f97baSDoug Gale	gdb_xml_files="i386-32bit.xml"
760328988117SLaurent Vivier    TARGET_SYSTBL_ABI=i386
76043a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_32.tbl
76052408a527Saurel32  ;;
76062408a527Saurel32  x86_64)
76076acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
76088d62f35aSLaurent Vivier    TARGET_SYSTBL_ABI=common,64
76093a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_64.tbl
76100a7fa00aSEmilio G. Cota    mttcg="yes"
76117b0f97baSDoug Gale    gdb_xml_files="i386-64bit.xml"
76122408a527Saurel32  ;;
76132408a527Saurel32  alpha)
76145ee4f3c2SRichard Henderson    mttcg="yes"
76156116aea9SLaurent Vivier    TARGET_SYSTBL_ABI=common
76162408a527Saurel32  ;;
76172408a527Saurel32  arm|armeb)
7618b498c8a0SJuan Quintela    TARGET_ARCH=arm
76195bcb4986SLaurent Vivier    TARGET_SYSTBL_ABI=common,oabi
7620e5fe0c52Spbrook    bflt="yes"
7621ca759f9eSAlex Bennée    mttcg="yes"
7622c888f7e0SPeter Maydell    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
76232408a527Saurel32  ;;
7624722dd7beSMichael Weiser  aarch64|aarch64_be)
7625722dd7beSMichael Weiser    TARGET_ARCH=aarch64
76266a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
76276a49fa95SAlexander Graf    bflt="yes"
7628ca759f9eSAlex Bennée    mttcg="yes"
7629c888f7e0SPeter Maydell    gdb_xml_files="aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
76306a49fa95SAlexander Graf  ;;
763142f3ff00SMichael Rolnik  avr)
763242f3ff00SMichael Rolnik    gdb_xml_files="avr-cpu.xml"
763342f3ff00SMichael Rolnik    target_compiler=$cross_cc_avr
763442f3ff00SMichael Rolnik  ;;
76352408a527Saurel32  cris)
76362408a527Saurel32  ;;
763761766fe9SRichard Henderson  hppa)
76387b93dab5SRichard Henderson    mttcg="yes"
76399566f4c6SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
764061766fe9SRichard Henderson  ;;
7641613a22c9SMichael Walle  lm32)
7642613a22c9SMichael Walle  ;;
76432408a527Saurel32  m68k)
76440938cda5Saurel32    bflt="yes"
7645a976ed3fSKONRAD Frederic    gdb_xml_files="cf-core.xml cf-fp.xml m68k-core.xml m68k-fp.xml"
76465b85cae9SLaurent Vivier    TARGET_SYSTBL_ABI=common
76472408a527Saurel32  ;;
7648877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7649877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
7650ddf0c4cdSLaurent Vivier    TARGET_SYSTBL_ABI=common
7651d449561bSEdgar E. Iglesias    mttcg="yes"
765272b675caSEdgar E. Iglesias    bflt="yes"
7653be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
765472b675caSEdgar E. Iglesias  ;;
76552408a527Saurel32  mips|mipsel)
76560454728cSAleksandar Markovic    mttcg="yes"
7657b498c8a0SJuan Quintela    TARGET_ARCH=mips
765825be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
7659c59716fcSLaurent Vivier    TARGET_SYSTBL_ABI=o32
76603a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_o32.tbl
76612408a527Saurel32  ;;
76622408a527Saurel32  mipsn32|mipsn32el)
76630454728cSAleksandar Markovic    mttcg="yes"
7664597e2cecSRichard Henderson    TARGET_ARCH=mips64
76656acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
766625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7667597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
7668686a0fe4SLaurent Vivier    TARGET_SYSTBL_ABI=n32
76693a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_n32.tbl
76702408a527Saurel32  ;;
76712408a527Saurel32  mips64|mips64el)
7672a092a955SAlex Bennée    mttcg="no"
7673b498c8a0SJuan Quintela    TARGET_ARCH=mips64
76746acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
767525be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
7676686a0fe4SLaurent Vivier    TARGET_SYSTBL_ABI=n64
76773a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_n64.tbl
76782408a527Saurel32  ;;
7679d15a9c23SAnthony Green  moxie)
7680d15a9c23SAnthony Green  ;;
7681e671711cSMarek Vasut  nios2)
7682e671711cSMarek Vasut  ;;
76834a09d0bbSRichard Henderson  or1k)
7684e67db06eSJia Liu    TARGET_ARCH=openrisc
7685e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7686e67db06eSJia Liu  ;;
76872408a527Saurel32  ppc)
7688c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
768976a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,32
76902408a527Saurel32  ;;
76912408a527Saurel32  ppc64)
76926acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7693e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
769476a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,64
7695f0b0685dSNikunj A Dadhania    mttcg=yes
76961438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
76972408a527Saurel32  ;;
76989c35126cSDoug Kwan  ppc64le)
76999c35126cSDoug Kwan    TARGET_ARCH=ppc64
77009c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
77019c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
770276a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,64
7703f0b0685dSNikunj A Dadhania    mttcg=yes
77041438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
77059c35126cSDoug Kwan  ;;
77062408a527Saurel32  ppc64abi32)
7707b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
77086acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7709e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
771076a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,32
771125be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
77121438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
77132408a527Saurel32  ;;
771425fa194bSMichael Clark  riscv32)
771525fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
771625fa194bSMichael Clark    TARGET_ABI_DIR=riscv
771725fa194bSMichael Clark    mttcg=yes
7718ae4a70c0SKeith Packard    gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-32bit-csr.xml riscv-32bit-virtual.xml"
771925fa194bSMichael Clark  ;;
772025fa194bSMichael Clark  riscv64)
772125fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
772225fa194bSMichael Clark    TARGET_ABI_DIR=riscv
772325fa194bSMichael Clark    mttcg=yes
7724ae4a70c0SKeith Packard    gdb_xml_files="riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml"
772525fa194bSMichael Clark  ;;
7726c8c35e5fSYoshinori Sato  rx)
7727c8c35e5fSYoshinori Sato    TARGET_ARCH=rx
7728c8c35e5fSYoshinori Sato    bflt="yes"
7729c8c35e5fSYoshinori Sato    target_compiler=$cross_cc_rx
7730c8c35e5fSYoshinori Sato    gdb_xml_files="rx-core.xml"
7731c8c35e5fSYoshinori Sato  ;;
77322408a527Saurel32  sh4|sh4eb)
7733b498c8a0SJuan Quintela    TARGET_ARCH=sh4
7734d0c832f6SLaurent Vivier    TARGET_SYSTBL_ABI=common
77354dbed897Spbrook    bflt="yes"
77362408a527Saurel32  ;;
77372408a527Saurel32  sparc)
7738bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
77392408a527Saurel32  ;;
77402408a527Saurel32  sparc64)
77416acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7742bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,64
77432408a527Saurel32  ;;
77442408a527Saurel32  sparc32plus)
7745b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
77466acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7747e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
7748bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
774925be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
77502408a527Saurel32  ;;
775124e804ecSAlexander Graf  s390x)
7752318f371dSLaurent Vivier    TARGET_SYSTBL_ABI=common,64
775363685bc4SDavid Hildenbrand    mttcg=yes
775486158a2aSChristian Borntraeger    gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-gs.xml"
775524e804ecSAlexander Graf  ;;
7756444e06b1SChen Gang  tilegx)
7757444e06b1SChen Gang  ;;
77585ecaa4edSPeter Crosthwaite  tricore)
77595ecaa4edSPeter Crosthwaite  ;;
7760d2fbca94SGuan Xuetao  unicore32)
7761d2fbca94SGuan Xuetao  ;;
7762cfa550c6SMax Filippov  xtensa|xtensaeb)
7763cfa550c6SMax Filippov    TARGET_ARCH=xtensa
7764a4a93592SLaurent Vivier    TARGET_SYSTBL_ABI=common
776502e33e9fSMax Filippov    bflt="yes"
77669fb40342SMax Filippov    mttcg="yes"
7767cfa550c6SMax Filippov  ;;
77682408a527Saurel32  *)
776976ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
77702408a527Saurel32  ;;
77712408a527Saurel32esac
77725e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
77735e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
77745e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
77755e8861a0SPaolo Bonzinifi
77763a30446aSMarc-André Lureauif [ "$TARGET_SYSTBL_ABI" != "" ] && [ "$TARGET_SYSTBL" = "" ]; then
77773a30446aSMarc-André Lureau  TARGET_SYSTBL=syscall.tbl
77783a30446aSMarc-André Lureaufi
77795e8861a0SPaolo Bonzini
778099afc91dSDaniel P. Berrangeupper() {
778199afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
778299afc91dSDaniel P. Berrange}
778399afc91dSDaniel P. Berrange
778489138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
778525be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7786c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
778725be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7788e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7789e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7790e6e91b9cSJuan Quintelafi
779125be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7792adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7793adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7794adfc3e91SStacey Sonfi
77954d6a835dSLaurent Vivierif [ "$TARGET_SYSTBL_ABI" != "" ]; then
77964d6a835dSLaurent Vivier    echo "TARGET_SYSTBL_ABI=$TARGET_SYSTBL_ABI" >> $config_target_mak
77973a30446aSMarc-André Lureau    echo "TARGET_SYSTBL=$TARGET_SYSTBL" >> $config_target_mak
77984d6a835dSLaurent Vivierfi
77993b6b7550SPaolo Bonzini
78003b6b7550SPaolo Bonziniif supported_xen_target $target; then
780125be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7802eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7803eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7804eb6fda0fSAnthony PERARD    fi
7805432d268cSJun Nakajimafi
78063b6b7550SPaolo Bonziniif supported_kvm_target $target; then
780725be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
7808c59249f9SJuan Quintelafi
78093b6b7550SPaolo Bonziniif supported_hax_target $target; then
7810b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7811b0cb0a66SVincent Palatinfi
7812c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7813c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7814c97d6d2cSSergio Andres Gomez Del Realfi
7815d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7816d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7817d661d9a4SJustin Terry (VM)fi
781852bf9771Stony.nguyen@bt.comif test "$target_aligned_only" = "yes" ; then
781952bf9771Stony.nguyen@bt.com  echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
782052bf9771Stony.nguyen@bt.comfi
7821de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
782225be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
782397a847bcSbellardfi
782497a847bcSbellardif test "$target_softmmu" = "yes" ; then
782525be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7826ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7827ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7828ca759f9eSAlex Bennée  fi
7829de83cd02Sbellardfi
7830997344f3Sbellardif test "$target_user_only" = "yes" ; then
783125be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7832a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
78332898503cSPaolo Bonzini  symlink "../qemu-$target_name" "$target_dir/qemu-$target_name"
78342898503cSPaolo Bonzinielse
78352898503cSPaolo Bonzini  symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name"
7836997344f3Sbellardfi
7837831b7825Sthsif test "$target_linux_user" = "yes" ; then
783825be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7839831b7825Sthsfi
784056aebc89Spbrooklist=""
784156aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
784256aebc89Spbrook  for x in $gdb_xml_files; do
7843c9322ab5SMarc-André Lureau    list="$list gdb-xml/$x"
784456aebc89Spbrook  done
784525be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
78463d0f1517SJuan Quintelafi
7847de83cd02Sbellard
7848e633a5c6SEric Blakeif test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
784925be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7850e5fe0c52Spbrookfi
785184778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
785225be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
785384778508Sblueswir1fi
78545b0753e0Sbellard
785597a847bcSbellarddone # for target in $targets
78567d13299dSbellard
7857e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
7858859aef02SPaolo Bonzini  subdirs="$subdirs dtc"
7859a540f158SPeter Crosthwaitefi
7860e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
7861859aef02SPaolo Bonzini  subdirs="$subdirs capstone"
7862e219c499SRichard Hendersonfi
7863859aef02SPaolo Bonziniecho "SUBDIRS=$subdirs" >> $config_host_mak
7864e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
7865e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
7866e219c499SRichard Hendersonfi
7867a540f158SPeter Crosthwaite
7868a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
7869a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
7870ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
7871a99d57bbSWanlong Gaofi
7872a99d57bbSWanlong Gao
7873fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
7874fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
7875fd0e6053SJohn Snowfi
7876fd0e6053SJohn Snow
78771e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
78781e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
78791e4f6065SDaniele Buonofi
78801e4f6065SDaniele Buono
7881e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
7882e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
7883e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
7884e29e5c6eSPeter Maydell# (these can be both files and directories).
7885e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
7886e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
7887e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
7888e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
7889e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
7890e29e5c6eSPeter Maydell# directory and symlink the directory instead.
789109db9b9dSGerd Hoffmann# UNLINK is used to remove symlinks from older development versions
789209db9b9dSGerd Hoffmann# that might get into the way when doing "git update" without doing
789309db9b9dSGerd Hoffmann# a "make distclean" in between.
78941cf4323eSThomas HuthDIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
78951cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
7896b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
7897744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
78988db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
78992038f8c8SPaolo BonziniLINKS="Makefile"
7900e8f3bd71SMarc-André LureauLINKS="$LINKS tests/tcg/lm32/Makefile"
79013941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
7902ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
7903e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
79048db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
7905e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
7906e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
790739950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
790839950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
79098f8fd9edSCleber RosaLINKS="$LINKS python"
791009db9b9dSGerd HoffmannUNLINK="pc-bios/keymaps"
7911753d11f2SRichard Hendersonfor bios_file in \
7912753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
79133a631b8eSBin Meng    $source_path/pc-bios/*.elf \
7914225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
7915753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
7916753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
7917e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
7918753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
79194e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
792026ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
7921753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
7922753d11f2SRichard Hendersondo
7923e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
79247ea78b74SJan Kiszkadone
7925d1807a4fSPaolo Bonzinimkdir -p $DIRS
7926e29e5c6eSPeter Maydellfor f in $LINKS ; do
79270f4d8894SPaolo Bonzini    if [ -e "$source_path/$f" ]; then
7928f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
7929f9245e10SPeter Maydell    fi
79307d13299dSbellarddone
793109db9b9dSGerd Hoffmannfor f in $UNLINK ; do
793209db9b9dSGerd Hoffmann    if [ -L "$f" ]; then
793309db9b9dSGerd Hoffmann        rm -f "$f"
793409db9b9dSGerd Hoffmann    fi
793509db9b9dSGerd Hoffmanndone
79361ad2134fSPaul Brook
79372038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
79382038f8c8SPaolo Bonzini  export $i
79392038f8c8SPaolo Bonzinidone
7940afc3a8f9SAlex Bennéeexport target_list source_path use_containers
79412038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
79422038f8c8SPaolo Bonzini
7943c34ebfdcSAnthony Liguori# temporary config to build submodules
79448db2a4fdSGerd Hoffmannfor rom in seabios; do
7945c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
794637116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
7947c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
7948cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
79495f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
7950c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
7951c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
79523dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
7953c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
7954a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
7955c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
79569f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
7957c34ebfdcSAnthony Liguoridone
7958c34ebfdcSAnthony Liguori
795976c7560aSMax Reitz# set up qemu-iotests in this build directory
796076c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
796176c7560aSMax Reitz
796276c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
796376c7560aSMax Reitzecho >> "$iotests_common_env"
796476c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
796576c7560aSMax Reitz
7966a5665051SPaolo Bonziniif test "$skip_meson" = no; then
7967fc929892SMarc-André Lureaucross="config-meson.cross.new"
7968fc929892SMarc-André Lureaumeson_quote() {
7969fc929892SMarc-André Lureau    echo "['$(echo $* | sed "s/ /','/g")']"
7970fc929892SMarc-André Lureau}
7971fc929892SMarc-André Lureau
7972fc929892SMarc-André Lureauecho "# Automatically generated by configure - do not modify" > $cross
7973fc929892SMarc-André Lureauecho "[properties]" >> $cross
7974fc929892SMarc-André Lureautest -z "$cxx" && echo "link_language = 'c'" >> $cross
7975fc929892SMarc-André Lureauecho "[binaries]" >> $cross
7976fc929892SMarc-André Lureauecho "c = $(meson_quote $cc)" >> $cross
7977fc929892SMarc-André Lureautest -n "$cxx" && echo "cpp = $(meson_quote $cxx)" >> $cross
7978fc929892SMarc-André Lureauecho "ar = $(meson_quote $ar)" >> $cross
7979fc929892SMarc-André Lureauecho "nm = $(meson_quote $nm)" >> $cross
7980fc929892SMarc-André Lureauecho "pkgconfig = $(meson_quote $pkg_config_exe)" >> $cross
7981fc929892SMarc-André Lureauecho "ranlib = $(meson_quote $ranlib)" >> $cross
7982e8178514SPaolo Bonziniif has $sdl2_config; then
7983e8178514SPaolo Bonzini  echo "sdl2-config = $(meson_quote $sdl2_config)" >> $cross
7984e8178514SPaolo Bonzinifi
7985fc929892SMarc-André Lureauecho "strip = $(meson_quote $strip)" >> $cross
7986fc929892SMarc-André Lureauecho "windres = $(meson_quote $windres)" >> $cross
7987fc929892SMarc-André Lureauif test -n "$cross_prefix"; then
7988fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
7989fc929892SMarc-André Lureau    # Hack: Meson expects an absolute path for the *build* machine
7990fc929892SMarc-André Lureau    # for the prefix, so add a slash in front of a Windows path that
7991fc929892SMarc-André Lureau    # includes a drive letter.
7992fc929892SMarc-André Lureau    #
7993fc929892SMarc-André Lureau    # See https://github.com/mesonbuild/meson/issues/7577.
7994fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
7995fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
7996fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
7997fc929892SMarc-André Lureau        case $prefix in
7998fc929892SMarc-André Lureau            ?:*) pre_prefix=/ ;;
7999fc929892SMarc-André Lureau        esac
8000fc929892SMarc-André Lureau    fi
8001853b4bafSThomas Huth    if test "$linux" = "yes" ; then
8002853b4bafSThomas Huth        echo "system = 'linux'" >> $cross
8003853b4bafSThomas Huth    fi
8004fc929892SMarc-André Lureau    case "$ARCH" in
8005fc929892SMarc-André Lureau        i386|x86_64)
8006fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
8007fc929892SMarc-André Lureau            ;;
8008fc929892SMarc-André Lureau        ppc64le)
8009fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
8010fc929892SMarc-André Lureau            ;;
8011fc929892SMarc-André Lureau        *)
8012fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
8013fc929892SMarc-André Lureau            ;;
8014fc929892SMarc-André Lureau    esac
8015fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
8016fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
8017fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
8018fc929892SMarc-André Lureau    else
8019fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
8020fc929892SMarc-André Lureau    fi
8021fc929892SMarc-André Lureauelse
8022fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
8023fc929892SMarc-André Lureaufi
8024fc929892SMarc-André Lureaumv $cross config-meson.cross
8025fc929892SMarc-André Lureau
8026a5665051SPaolo Bonzinirm -rf meson-private meson-info meson-logs
802748328880SPaolo BonziniNINJA=${ninja:-$PWD/ninjatool} $meson setup \
8028fc929892SMarc-André Lureau        --prefix "${pre_prefix}$prefix" \
8029fc929892SMarc-André Lureau        --libdir "${pre_prefix}$libdir" \
8030fc929892SMarc-André Lureau        --libexecdir "${pre_prefix}$libexecdir" \
8031fc929892SMarc-André Lureau        --bindir "${pre_prefix}$bindir" \
8032fc929892SMarc-André Lureau        --includedir "${pre_prefix}$includedir" \
8033fc929892SMarc-André Lureau        --datadir "${pre_prefix}$datadir" \
8034fc929892SMarc-André Lureau        --mandir "${pre_prefix}$mandir" \
8035fc929892SMarc-André Lureau        --sysconfdir "${pre_prefix}$sysconfdir" \
8036fc929892SMarc-André Lureau        --localstatedir "${pre_prefix}$local_statedir" \
8037491e74c1SMarc-André Lureau        -Ddocdir="${pre_prefix}$docdir" \
803873f3aa37SMarc-André Lureau        -Dqemu_suffix="$qemu_suffix" \
8039a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
8040a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
8041a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
8042a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
8043da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
8044bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
804535be72baSPaolo Bonzini	-Dsdl=$sdl -Dsdl_image=$sdl_image \
8046a0b93237SPaolo Bonzini	-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
80470a40bcb7SCésar Belley	-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f\
8048fc929892SMarc-André Lureau        $cross_arg \
8049a5665051SPaolo Bonzini        "$PWD" "$source_path"
8050a5665051SPaolo Bonzini
8051a5665051SPaolo Bonziniif test "$?" -ne 0 ; then
8052a5665051SPaolo Bonzini    error_exit "meson setup failed"
8053a5665051SPaolo Bonzinifi
8054a5665051SPaolo Bonzinitouch ninjatool.stamp
8055a5665051SPaolo Bonzinifi
8056a5665051SPaolo Bonzini
8057dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
8058dc655404SMichael S. Tsirkincat <<EOD >config.status
8059dc655404SMichael S. Tsirkin#!/bin/sh
8060dc655404SMichael S. Tsirkin# Generated by configure.
8061dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
8062dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
8063dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
8064dc655404SMichael S. TsirkinEOD
8065e811da7fSDaniel P. Berrangé
8066e811da7fSDaniel P. Berrangépreserve_env() {
8067e811da7fSDaniel P. Berrangé    envname=$1
8068e811da7fSDaniel P. Berrangé
8069e811da7fSDaniel P. Berrangé    eval envval=\$$envname
8070e811da7fSDaniel P. Berrangé
8071e811da7fSDaniel P. Berrangé    if test -n "$envval"
8072e811da7fSDaniel P. Berrangé    then
8073e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
8074e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
8075e811da7fSDaniel P. Berrangé    else
8076e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
8077e811da7fSDaniel P. Berrangé    fi
8078e811da7fSDaniel P. Berrangé}
8079e811da7fSDaniel P. Berrangé
8080e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
8081e811da7fSDaniel P. Berrangé# features/build target configure will detect
8082e811da7fSDaniel P. Berrangépreserve_env AR
8083e811da7fSDaniel P. Berrangépreserve_env AS
8084e811da7fSDaniel P. Berrangépreserve_env CC
8085e811da7fSDaniel P. Berrangépreserve_env CPP
8086e811da7fSDaniel P. Berrangépreserve_env CXX
8087e811da7fSDaniel P. Berrangépreserve_env INSTALL
8088e811da7fSDaniel P. Berrangépreserve_env LD
8089e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
8090e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
8091e811da7fSDaniel P. Berrangépreserve_env MAKE
8092e811da7fSDaniel P. Berrangépreserve_env NM
8093e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
8094e811da7fSDaniel P. Berrangépreserve_env PATH
8095e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
8096e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
8097e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
8098e811da7fSDaniel P. Berrangépreserve_env PYTHON
8099e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
8100e811da7fSDaniel P. Berrangépreserve_env SMBD
8101e811da7fSDaniel P. Berrangépreserve_env STRIP
8102e811da7fSDaniel P. Berrangépreserve_env WINDRES
8103e811da7fSDaniel P. Berrangé
8104dc655404SMichael S. Tsirkinprintf "exec" >>config.status
8105a5665051SPaolo Bonzinifor i in "$0" "$@"; do
8106a5665051SPaolo Bonzini  test "$i" = --skip-meson || printf " '%s'" "$i" >>config.status
8107a5665051SPaolo Bonzinidone
8108cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
8109dc655404SMichael S. Tsirkinchmod +x config.status
8110dc655404SMichael S. Tsirkin
81118cd05ab6SPeter Maydellrm -r "$TMPDIR1"
8112