xref: /openbmc/qemu/configure (revision ab318051)
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"
816969ec6cSJames ClarkeTMPMO="${TMPDIR1}/${TMPB}.mo"
8226fffe29SEmilio G. CotaTMPTXT="${TMPDIR1}/${TMPB}.txt"
837d13299dSbellard
84da1d85e3SGerd Hoffmannrm -f config.log
859ac81bbbSmalc
86b48e3611SPeter Maydell# Print a helpful header at the top of config.log
87b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
88979ae168SPeter Maydellprintf "# Configured with:" >> config.log
89979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
90979ae168SPeter Maydellecho >> config.log
91b48e3611SPeter Maydellecho "#" >> config.log
92b48e3611SPeter Maydell
93d880a3baSPaolo Bonziniprint_error() {
94d880a3baSPaolo Bonzini    (echo
9576ad07a4SPeter Maydell    echo "ERROR: $1"
9676ad07a4SPeter Maydell    while test -n "$2"; do
9776ad07a4SPeter Maydell        echo "       $2"
9876ad07a4SPeter Maydell        shift
9976ad07a4SPeter Maydell    done
100d880a3baSPaolo Bonzini    echo) >&2
101d880a3baSPaolo Bonzini}
102d880a3baSPaolo Bonzini
103d880a3baSPaolo Bonzinierror_exit() {
104d880a3baSPaolo Bonzini    print_error "$@"
10576ad07a4SPeter Maydell    exit 1
10676ad07a4SPeter Maydell}
10776ad07a4SPeter Maydell
1089c83ffd8SPeter Maydelldo_compiler() {
1099c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
1109c83ffd8SPeter Maydell    # is compiler binary to execute.
1119c83ffd8SPeter Maydell    local compiler="$1"
1129c83ffd8SPeter Maydell    shift
1138bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
1148bbe05d7SIan Jackson        echo >>config.log "
1158bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
1168bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
1178bbe05d7SIan Jackson    '; fi
1189c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
1199c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
1208dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
1218dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
1228dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
1238dc38a78SPeter Maydell    # obvious to developers.
1248dc38a78SPeter Maydell    if test "$werror" != "yes"; then
1258dc38a78SPeter Maydell        return 0
1268dc38a78SPeter Maydell    fi
1278dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
1288dc38a78SPeter Maydell    case "$*" in
1298dc38a78SPeter Maydell        *-Werror*)
1308dc38a78SPeter Maydell           return 0
1318dc38a78SPeter Maydell        ;;
1328dc38a78SPeter Maydell    esac
1339c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
1349c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
13576ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
13676ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
13776ad07a4SPeter Maydell        "will be at the bottom of config.log." \
13876ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
1398dc38a78SPeter Maydell}
1408dc38a78SPeter Maydell
1419c83ffd8SPeter Maydelldo_cc() {
1429c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
1439c83ffd8SPeter Maydell}
1449c83ffd8SPeter Maydell
1459c83ffd8SPeter Maydelldo_cxx() {
1469c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
1479c83ffd8SPeter Maydell}
1489c83ffd8SPeter Maydell
14900849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
15000849b92SRichard Hendersonadd_to() {
15100849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15200849b92SRichard Henderson}
15300849b92SRichard Henderson
1549c83ffd8SPeter Maydellupdate_cxxflags() {
1559c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1569c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1579c83ffd8SPeter Maydell    # because they only make sense for C programs.
15853422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
159086d5f75SPaolo Bonzini    CXXFLAGS=$(echo "$CFLAGS" | sed s/-std=gnu99/-std=gnu++11/)
1609c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1619c83ffd8SPeter Maydell        case $arg in
1629c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1639c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1649c83ffd8SPeter Maydell                ;;
1659c83ffd8SPeter Maydell            *)
1669c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1679c83ffd8SPeter Maydell                ;;
1689c83ffd8SPeter Maydell        esac
1699c83ffd8SPeter Maydell    done
1709c83ffd8SPeter Maydell}
1719c83ffd8SPeter Maydell
17252166aa0SJuan Quintelacompile_object() {
173fd0e6053SJohn Snow  local_cflags="$1"
174086d5f75SPaolo Bonzini  do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
17552166aa0SJuan Quintela}
17652166aa0SJuan Quintela
17752166aa0SJuan Quintelacompile_prog() {
17852166aa0SJuan Quintela  local_cflags="$1"
17952166aa0SJuan Quintela  local_ldflags="$2"
180086d5f75SPaolo Bonzini  do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $QEMU_LDFLAGS $local_ldflags
18152166aa0SJuan Quintela}
18252166aa0SJuan Quintela
18311568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
18411568d6dSPaolo Bonzinisymlink() {
18572b8b5a1SStefan Weil  rm -rf "$2"
186ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
18772b8b5a1SStefan Weil  ln -s "$1" "$2"
18811568d6dSPaolo Bonzini}
18911568d6dSPaolo Bonzini
1900dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1910dba6195SLoïc Minier# executable or a builtin)
1920dba6195SLoïc Minierhas() {
1930dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1940dba6195SLoïc Minier}
1950dba6195SLoïc Minier
1960dba6195SLoïc Minier# search for an executable in PATH
1970dba6195SLoïc Minierpath_of() {
1980dba6195SLoïc Minier    local_command="$1"
1990dba6195SLoïc Minier    local_ifs="$IFS"
2000dba6195SLoïc Minier    local_dir=""
2010dba6195SLoïc Minier
2020dba6195SLoïc Minier    # pathname has a dir component?
2030dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
2040dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
2050dba6195SLoïc Minier            echo "$local_command"
2060dba6195SLoïc Minier            return 0
2070dba6195SLoïc Minier        fi
2080dba6195SLoïc Minier    fi
2090dba6195SLoïc Minier    if [ -z "$local_command" ]; then
2100dba6195SLoïc Minier        return 1
2110dba6195SLoïc Minier    fi
2120dba6195SLoïc Minier
2130dba6195SLoïc Minier    IFS=:
2140dba6195SLoïc Minier    for local_dir in $PATH; do
2150dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
2160dba6195SLoïc Minier            echo "$local_dir/$local_command"
2170dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
2180dba6195SLoïc Minier            return 0
2190dba6195SLoïc Minier        fi
2200dba6195SLoïc Minier    done
2210dba6195SLoïc Minier    # not found
2220dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
2230dba6195SLoïc Minier    return 1
2240dba6195SLoïc Minier}
2250dba6195SLoïc Minier
2260a01d76fSMarc-André Lureauversion_ge () {
2270a01d76fSMarc-André Lureau    local_ver1=`echo $1 | tr . ' '`
2280a01d76fSMarc-André Lureau    local_ver2=`echo $2 | tr . ' '`
2290a01d76fSMarc-André Lureau    while true; do
2300a01d76fSMarc-André Lureau        set x $local_ver1
2310a01d76fSMarc-André Lureau        local_first=${2-0}
2320a01d76fSMarc-André Lureau        # shift 2 does nothing if there are less than 2 arguments
2330a01d76fSMarc-André Lureau        shift; shift
2340a01d76fSMarc-André Lureau        local_ver1=$*
2350a01d76fSMarc-André Lureau        set x $local_ver2
2360a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2370a01d76fSMarc-André Lureau        test $# = 1 && return 0
2380a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2390a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
2400a01d76fSMarc-André Lureau        shift; shift
2410a01d76fSMarc-André Lureau        local_ver2=$*
2420a01d76fSMarc-André Lureau    done
2430a01d76fSMarc-André Lureau}
2440a01d76fSMarc-André Lureau
2455b808275SLluís Vilanovahave_backend () {
2465b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2475b808275SLluís Vilanova}
2485b808275SLluís Vilanova
2493b6b7550SPaolo Bonziniglob() {
2503b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2513b6b7550SPaolo Bonzini}
2523b6b7550SPaolo Bonzini
2533b6b7550SPaolo Bonzinisupported_hax_target() {
2543b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
2553b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
2563b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
2573b6b7550SPaolo Bonzini        i386|x86_64)
2583b6b7550SPaolo Bonzini            return 0
2593b6b7550SPaolo Bonzini        ;;
2603b6b7550SPaolo Bonzini    esac
2613b6b7550SPaolo Bonzini    return 1
2623b6b7550SPaolo Bonzini}
2633b6b7550SPaolo Bonzini
2643b6b7550SPaolo Bonzinisupported_kvm_target() {
2653b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
2663b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
2673b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
2683b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
2693b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
2703b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
271aa2953fdSHuacai Chen        mips:mips | mipsel:mips | mips64:mips | mips64el:mips | \
272f8378accSRichard Henderson        ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | ppc64:ppc64le | \
2733b6b7550SPaolo Bonzini        s390x:s390x)
2743b6b7550SPaolo Bonzini            return 0
2753b6b7550SPaolo Bonzini        ;;
2763b6b7550SPaolo Bonzini    esac
2773b6b7550SPaolo Bonzini    return 1
2783b6b7550SPaolo Bonzini}
2793b6b7550SPaolo Bonzini
2803b6b7550SPaolo Bonzinisupported_xen_target() {
2813b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2823b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
283b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
284b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
285b5ed2e11SPaolo Bonzini        i386|x86_64)
2863b6b7550SPaolo Bonzini            return 0
2873b6b7550SPaolo Bonzini        ;;
2883b6b7550SPaolo Bonzini    esac
2893b6b7550SPaolo Bonzini    return 1
2903b6b7550SPaolo Bonzini}
2913b6b7550SPaolo Bonzini
292c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
293c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
294c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
295c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
296c97d6d2cSSergio Andres Gomez Del Real        x86_64)
297c97d6d2cSSergio Andres Gomez Del Real            return 0
298c97d6d2cSSergio Andres Gomez Del Real        ;;
299c97d6d2cSSergio Andres Gomez Del Real    esac
300c97d6d2cSSergio Andres Gomez Del Real    return 1
301c97d6d2cSSergio Andres Gomez Del Real}
302c97d6d2cSSergio Andres Gomez Del Real
303d661d9a4SJustin Terry (VM)supported_whpx_target() {
304d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
305d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
306d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
307d661d9a4SJustin Terry (VM)        i386|x86_64)
308d661d9a4SJustin Terry (VM)            return 0
309d661d9a4SJustin Terry (VM)        ;;
310d661d9a4SJustin Terry (VM)    esac
311d661d9a4SJustin Terry (VM)    return 1
312d661d9a4SJustin Terry (VM)}
313d661d9a4SJustin Terry (VM)
314d880a3baSPaolo Bonzinisupported_target() {
315d880a3baSPaolo Bonzini    case "$1" in
316d880a3baSPaolo Bonzini        *-softmmu)
317d880a3baSPaolo Bonzini            ;;
318d880a3baSPaolo Bonzini        *-linux-user)
319d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
320d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
321d880a3baSPaolo Bonzini                return 1
322d880a3baSPaolo Bonzini            fi
323d880a3baSPaolo Bonzini            ;;
324d880a3baSPaolo Bonzini        *-bsd-user)
325d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
326d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
327d880a3baSPaolo Bonzini                return 1
328d880a3baSPaolo Bonzini            fi
329d880a3baSPaolo Bonzini            ;;
330d880a3baSPaolo Bonzini        *)
331d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
332d880a3baSPaolo Bonzini            return 1
333d880a3baSPaolo Bonzini            ;;
334d880a3baSPaolo Bonzini    esac
335b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
336b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
337b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
338b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
339c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
340d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
341b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
342b3f6ea7eSPaolo Bonzini    return 1
343d880a3baSPaolo Bonzini}
344d880a3baSPaolo Bonzini
345e9a3591fSChristian Borntraeger
346e9a3591fSChristian Borntraegerld_has() {
347e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
348e9a3591fSChristian Borntraeger}
349e9a3591fSChristian Borntraeger
3504ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
3514ace32e2SAntonio Ospitethen
3524ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
3534ace32e2SAntonio Ospitefi
3544ace32e2SAntonio Ospite
35514211825SAntonio Ospite# default parameters
3562ff6b91eSJuan Quintelacpu=""
357a31a8642SMichael S. Tsirkiniasl="iasl"
3581e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
35943ce4dfeSbellardstatic="no"
3607d13299dSbellardcross_prefix=""
3610c58ac1cSmalcaudio_drv_list=""
362b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
363b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
364e49d021eSPeter Maydellhost_cc="cc"
36502f9135bSDaniel P. Berrangélibs_cpu=""
36673da375eSJuan Quintelalibs_softmmu=""
3673e2e0e6bSJuan Quintelalibs_tools=""
368d5631638Smalcaudio_win_int=""
369957f1f99SMichael Rothlibs_qga=""
3705bc62e01SGerd Hoffmanndebug_info="yes"
37163678e17SSteven Noonanstack_protector=""
3721e4f6065SDaniele Buonosafe_stack=""
373afc3a8f9SAlex Bennéeuse_containers="yes"
374f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
375ac0df51dSaliguori
37692712822SDaniel P. Berrangeif test -e "$source_path/.git"
37792712822SDaniel P. Berrangethen
378f62bbee5SDaniel P. Berrange    git_update=yes
37992712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
3803ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
3813ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
38292712822SDaniel P. Berrangeelse
383f62bbee5SDaniel P. Berrange    git_update=no
384aef45d51SDaniel P. Berrange    git_submodules=""
3855c0ef67aSDaniel P. Berrangé
3865c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
3875c0ef67aSDaniel P. Berrangé    then
3885c0ef67aSDaniel P. Berrangé        echo
3895c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
3905c0ef67aSDaniel P. Berrangé        echo
3915c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
3925c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
3935c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
3945c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
3955c0ef67aSDaniel P. Berrangé        echo
396a3e3b521SPeter Maydell        echo "  https://www.qemu.org/download/#source"
3975c0ef67aSDaniel P. Berrangé        echo
3985c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
3995c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
4005c0ef67aSDaniel P. Berrangé        echo
4015c0ef67aSDaniel P. Berrangé        exit 1
4025c0ef67aSDaniel P. Berrangé    fi
40392712822SDaniel P. Berrangefi
404cc84d63aSDaniel P. Berrangegit="git"
405ac0df51dSaliguori
406afb63ebdSStefan Weil# Don't accept a target_list environment variable.
407afb63ebdSStefan Weilunset target_list
408447e133fSAlex Bennéeunset target_list_exclude
409377529c0SPaolo Bonzini
410377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
411377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
412377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
413377529c0SPaolo Bonzini#              unless --disable-foo is given
414377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
415377529c0SPaolo Bonzini#              feature will searched for,
416377529c0SPaolo Bonzini#              if not found, configure exits with error
417377529c0SPaolo Bonzini#
418377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
419377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
420377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
421377529c0SPaolo Bonzini
422377529c0SPaolo Bonzinibrlapi=""
423377529c0SPaolo Bonzinicurl=""
424377529c0SPaolo Bonzinicurses=""
425377529c0SPaolo Bonzinidocs=""
426377529c0SPaolo Bonzinifdt=""
42758952137SVincenzo Maffionenetmap="no"
428377529c0SPaolo Bonzinisdl=""
429a442fe2fSDaniel P. Berrangésdl_image=""
430983eef5aSMeador Ingevirtfs=""
431fe8fc5aeSPaolo Bonzinimpath=""
432821601eaSJes Sorensenvnc="yes"
433377529c0SPaolo Bonzinisparse="no"
434377529c0SPaolo Bonzinivde=""
435377529c0SPaolo Bonzinivnc_sasl=""
436377529c0SPaolo Bonzinivnc_jpeg=""
437377529c0SPaolo Bonzinivnc_png=""
4386a021536SGerd Hoffmannxkbcommon=""
439377529c0SPaolo Bonzinixen=""
440d5b93ddfSAnthony PERARDxen_ctrl_version=""
441eb6fda0fSAnthony PERARDxen_pci_passthrough=""
442377529c0SPaolo Bonzinilinux_aio=""
443c10dd856SAarushi Mehtalinux_io_uring=""
44447e98658SCorey Bryantcap_ng=""
445377529c0SPaolo Bonziniattr=""
4464f26f2b6SAvi Kivitylibattr=""
447377529c0SPaolo Bonzinixfs=""
448b3f6ea7eSPaolo Bonzinitcg="yes"
449a40161cbSPaolo Bonzinimembarrier=""
450299e6f19SPaolo Bonzinivhost_net=""
451299e6f19SPaolo Bonzinivhost_crypto=""
452299e6f19SPaolo Bonzinivhost_scsi=""
453299e6f19SPaolo Bonzinivhost_vsock=""
454e6a74868SMarc-André Lureauvhost_user=""
45598fc1adaSDr. David Alan Gilbertvhost_user_fs=""
456d41a75a2SBradkvm="no"
457b0cb0a66SVincent Palatinhax="no"
458c97d6d2cSSergio Andres Gomez Del Realhvf="no"
459d661d9a4SJustin Terry (VM)whpx="no"
4602da776dbSMichael R. Hinesrdma=""
46121ab34c9SMarcel Apfelbaumpvrdma=""
462377529c0SPaolo Bonzinigprof="no"
463377529c0SPaolo Bonzinidebug_tcg="no"
464377529c0SPaolo Bonzinidebug="no"
465247724cbSMarc-André Lureausanitizers="no"
4660aebab04SLingfeng Yangtsan="no"
467b553a042SJohn Snowfortify_source=""
468377529c0SPaolo Bonzinistrip_opt="yes"
4699195b2c2SStefan Weiltcg_interpreter="no"
470377529c0SPaolo Bonzinibigendian="no"
471377529c0SPaolo Bonzinimingw32="no"
4721d728c39SBlue Swirlgcov="no"
473377529c0SPaolo BonziniEXESUF=""
47417969268SFam ZhengDSOSUF=".so"
47517969268SFam ZhengLDFLAGS_SHARED="-shared"
47617969268SFam Zhengmodules="no"
477bd83c861SChristian Ehrhardtmodule_upgrades="no"
478377529c0SPaolo Bonziniprefix="/usr/local"
4793d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
480377529c0SPaolo Bonziniconfsuffix="/qemu"
481675b9b53SMarc-André Lureauslirp=""
482377529c0SPaolo Bonzinioss_lib=""
483377529c0SPaolo Bonzinibsd="no"
484377529c0SPaolo Bonzinilinux="no"
485377529c0SPaolo Bonzinisolaris="no"
486377529c0SPaolo Bonziniprofiler="no"
487377529c0SPaolo Bonzinicocoa="no"
488377529c0SPaolo Bonzinisoftmmu="yes"
489377529c0SPaolo Bonzinilinux_user="no"
490377529c0SPaolo Bonzinibsd_user="no"
491377529c0SPaolo Bonziniblobs="yes"
49205dfa22bSPhilippe Mathieu-Daudéedk2_blobs="no"
493377529c0SPaolo Bonzinipkgversion=""
49440d6444eSAvi Kivitypie=""
4953556c233SPaolo Bonziniqom_cast_debug="yes"
496baf86d6bSPaolo Bonzinitrace_backends="log"
497377529c0SPaolo Bonzinitrace_file="trace"
498377529c0SPaolo Bonzinispice=""
499377529c0SPaolo Bonzinirbd=""
5007b02f544SMarc-André Lureausmartcard=""
5012b2325ffSGerd Hoffmannlibusb=""
50269354a83SHans de Goedeusb_redir=""
503da076ffeSGerd Hoffmannopengl=""
504014cb152SGerd Hoffmannopengl_dmabuf="no"
5055dd89908SRichard Hendersoncpuid_h="no"
50686583a07SLiam Merwickavx2_opt=""
5071ece9905SAlon Levyzlib="yes"
5088ca80760SRichard Hendersoncapstone=""
509b25c9dffSStefan Weillzo=""
510b25c9dffSStefan Weilsnappy=""
5116b383c08SPeter Wubzip2=""
51283bc1f97SJulio Faraccolzfse=""
5133a678481SJuan Quintelazstd=""
514e8ef31a3SMichael Tokarevguest_agent=""
515d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
51650cbebb9SMichael Rothguest_agent_ntddscsi="no"
5179dacf32dSYossi Hindinguest_agent_msi=""
518d9840e25STomoki Sekiyamavss_win32_sdk=""
519d9840e25STomoki Sekiyamawin_sdk="no"
520e10ee3f5SPhilippe Mathieu-Daudéwant_tools=""
521c589b249SRonnie Sahlberglibiscsi=""
5226542aa9cSPeter Lievenlibnfs=""
523519175a2SAlex Barcelocoroutine=""
52470c60c08SStefan Hajnoczicoroutine_pool=""
5257d992e4dSPeter Lievendebug_stack_usage="no"
526f0d92b56SLongpeng(Mike)crypto_afalg="no"
527f794573eSEduardo Otuboseccomp=""
528eb100396SBharata B Raoglusterfs=""
529d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
5300c14fb47SBharata B Raoglusterfs_discard="no"
531df3a429aSNiels de Vosglusterfs_fallocate="no"
5327c815372SBharata B Raoglusterfs_zerofill="no"
533e014dbe7SPrasanna Kumar Kaleverglusterfs_ftruncate_has_stat="no"
5340e3b891fSNiels de Vosglusterfs_iocb_has_stat="no"
535a4ccabcfSAnthony Liguorigtk=""
536925a0400SGerd Hoffmanngtk_gl="no"
537a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
538ddbb0d09SDaniel P. Berrangegnutls=""
53991bfcdb0SDaniel P. Berrangenettle=""
540dc2207afSDaniel P. Berrangénettle_xts="no"
54191bfcdb0SDaniel P. Berrangegcrypt=""
5421f923c70SLongpeng(Mike)gcrypt_hmac="no"
543e0576942SDaniel P. Berrangégcrypt_xts="no"
544e0576942SDaniel P. Berrangéqemu_private_xts="yes"
5458953caf3SDaniel P. Berrangeauth_pam=""
546bbbf9bfbSStefan Weilvte=""
5479d9e1521SGerd Hoffmannvirglrenderer=""
5487aaa6a16SPaolo Bonzinitpm=""
549b10d49d7SPino Toscanolibssh=""
550ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
551a99d57bbSWanlong Gaonuma=""
5522847b469SFam Zhengtcmalloc="no"
5537b01cb97SAlexandre Derumierjemalloc="no"
554a6b1d4c0SChanglong Xiereplication="yes"
5552f740136SJeff Codybochs="yes"
5562f740136SJeff Codycloop="yes"
5572f740136SJeff Codydmg="yes"
5582f740136SJeff Codyqcow1="yes"
5592f740136SJeff Codyvdi="yes"
5602f740136SJeff Codyvvfat="yes"
5612f740136SJeff Codyqed="yes"
5622f740136SJeff Codyparallels="yes"
5632f740136SJeff Codysheepdog="yes"
564ed279a06SKlim Kireevlibxml2=""
565ba59fb77SPaolo Bonzinidebug_mutex="no"
56617824406SJunyan Helibpmem=""
567f3494749SPaolo Bonzinidefault_devices="yes"
56840e8c6f4SAlex Bennéeplugins="no"
569adc28027SAlexander Bulekovfuzzing="no"
570b767d257SMarek Marczykowski-Góreckirng_none="no"
57154e7aac0SAlexey Krasikovsecret_keyring=""
57221b2eca6SJingqi Liulibdaxctl=""
573a5665051SPaolo Bonzinimeson=""
574a5665051SPaolo Bonziniskip_meson=no
575377529c0SPaolo Bonzini
576fb59dabdSPeter Maydellbogus_os="no"
5775a22ab71SYang Zhongmalloc_trim=""
578898be3e0SPeter Maydell
579ac0df51dSaliguori# parse CC options first
580ac0df51dSaliguorifor opt do
58189138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
582ac0df51dSaliguori  case "$opt" in
583ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
584ac0df51dSaliguori  ;;
5853d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
586ac0df51dSaliguori  ;;
58783f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
58883f73fceSTomoki Sekiyama  ;;
5892ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
5902ff6b91eSJuan Quintela  ;;
591de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
592db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
593e2a2ed06SJuan Quintela  ;;
59411cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
59511cde1c8SBruno Dominguez  ;;
596db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
597f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
598e2a2ed06SJuan Quintela  ;;
5995bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
6005bc62e01SGerd Hoffmann  ;;
6015bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
6025bc62e01SGerd Hoffmann  ;;
603d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
604d75402b5SAlex Bennée  ;;
605d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
606d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
6072038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
608d422b2bcSAlex Bennée  ;;
609d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
6102038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
611d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
6122038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
613d75402b5SAlex Bennée  ;;
614ac0df51dSaliguori  esac
615ac0df51dSaliguoridone
616ac0df51dSaliguori# OS specific
617ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
61893148aa5SStefan Weil# we can eliminate its usage altogether.
619ac0df51dSaliguori
620e49d021eSPeter Maydell# Preferred compiler:
621e49d021eSPeter Maydell#  ${CC} (if set)
622e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
623e49d021eSPeter Maydell#  system compiler
624e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
625e49d021eSPeter Maydell  cc="$host_cc"
626e49d021eSPeter Maydellelse
627b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
628e49d021eSPeter Maydellfi
629e49d021eSPeter Maydell
63083f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
63183f73fceSTomoki Sekiyama  cxx="c++"
63283f73fceSTomoki Sekiyamaelse
63383f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
63483f73fceSTomoki Sekiyamafi
63583f73fceSTomoki Sekiyama
636b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
637cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
6385f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
6393dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
640b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
641b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
6429f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
6434852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
644b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
645b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
64617884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
64717884d7bSSergei Trofimovichquery_pkg_config() {
64817884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
64917884d7bSSergei Trofimovich}
65017884d7bSSergei Trofimovichpkg_config=query_pkg_config
65147c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
652ac0df51dSaliguori
65345d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
65445d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
65545d285abSPeter Maydell
656be17dc90SMichael S. Tsirkin# default flags for all hosts
6572d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
6582d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
6592d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
6602d31515bSPeter Maydell# provides these semantics.)
661086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
662086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
663c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
664be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
66525211446SPaolo BonziniQEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote ${source_path}/accel/tcg -iquote ${source_path}/include"
66625211446SPaolo BonziniQEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
667086d5f75SPaolo BonziniCFLAGS="-std=gnu99 -Wall"
668086d5f75SPaolo Bonzini
669be17dc90SMichael S. Tsirkin
670cab00a5aSMichael S. Tsirkin# running configure in the source tree?
671cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
672cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
673cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
674cab00a5aSMichael S. Tsirkinelse
675cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
676cab00a5aSMichael S. Tsirkinfi
677cab00a5aSMichael S. Tsirkin
678ac0df51dSaliguoricheck_define() {
679ac0df51dSaliguoricat > $TMPC <<EOF
680ac0df51dSaliguori#if !defined($1)
681fd786e1aSPeter Maydell#error $1 not defined
682ac0df51dSaliguori#endif
683ac0df51dSaliguoriint main(void) { return 0; }
684ac0df51dSaliguoriEOF
68552166aa0SJuan Quintela  compile_object
686ac0df51dSaliguori}
687ac0df51dSaliguori
688307119e7SGerd Hoffmanncheck_include() {
689307119e7SGerd Hoffmanncat > $TMPC <<EOF
690307119e7SGerd Hoffmann#include <$1>
691307119e7SGerd Hoffmannint main(void) { return 0; }
692307119e7SGerd HoffmannEOF
693307119e7SGerd Hoffmann  compile_object
694307119e7SGerd Hoffmann}
695307119e7SGerd Hoffmann
69693b25869SJohn Snowwrite_c_skeleton() {
69793b25869SJohn Snow    cat > $TMPC <<EOF
69893b25869SJohn Snowint main(void) { return 0; }
69993b25869SJohn SnowEOF
70093b25869SJohn Snow}
70193b25869SJohn Snow
702adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
703adc28027SAlexander Bulekov    cat > $TMPC <<EOF
704adc28027SAlexander Bulekov#include <stdint.h>
705adc28027SAlexander Bulekov#include <sys/types.h>
706adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
707adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
708adc28027SAlexander BulekovEOF
709adc28027SAlexander Bulekov}
710adc28027SAlexander Bulekov
711bbea4050SPeter Maydellif check_define __linux__ ; then
712bbea4050SPeter Maydell  targetos="Linux"
713bbea4050SPeter Maydellelif check_define _WIN32 ; then
714bbea4050SPeter Maydell  targetos='MINGW32'
715bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
716bbea4050SPeter Maydell  targetos='OpenBSD'
717bbea4050SPeter Maydellelif check_define __sun__ ; then
718bbea4050SPeter Maydell  targetos='SunOS'
719bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
720bbea4050SPeter Maydell  targetos='Haiku'
721951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
722951fedfcSPeter Maydell  targetos='FreeBSD'
723951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
724951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
725951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
726951fedfcSPeter Maydell  targetos='DragonFly'
727951fedfcSPeter Maydellelif check_define __NetBSD__; then
728951fedfcSPeter Maydell  targetos='NetBSD'
729951fedfcSPeter Maydellelif check_define __APPLE__; then
730951fedfcSPeter Maydell  targetos='Darwin'
731bbea4050SPeter Maydellelse
732951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
733951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
734951fedfcSPeter Maydell  # be the result of a missing compiler.
735951fedfcSPeter Maydell  targetos='bogus'
736951fedfcSPeter Maydell  bogus_os='yes'
737bbea4050SPeter Maydellfi
738bbea4050SPeter Maydell
739bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
740bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
741bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
742bbea4050SPeter Maydell# the correct CPU with the --cpu option.
743bbea4050SPeter Maydellcase $targetos in
744bbea4050SPeter MaydellDarwin)
745bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
746bbea4050SPeter Maydell  # run 64-bit userspace code.
747bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
748bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
749bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
750bbea4050SPeter Maydell    cpu="x86_64"
751bbea4050SPeter Maydell  fi
752bbea4050SPeter Maydell  ;;
753bbea4050SPeter MaydellSunOS)
75489138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
755bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
756bbea4050SPeter Maydell    cpu="x86_64"
757bbea4050SPeter Maydell  fi
758bbea4050SPeter Maydellesac
759bbea4050SPeter Maydell
7602ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
7612ff6b91eSJuan Quintela  # command line argument
7622ff6b91eSJuan Quintela  :
7632ff6b91eSJuan Quintelaelif check_define __i386__ ; then
764ac0df51dSaliguori  cpu="i386"
765ac0df51dSaliguorielif check_define __x86_64__ ; then
766c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
767c72b26ecSRichard Henderson    cpu="x32"
768c72b26ecSRichard Henderson  else
769ac0df51dSaliguori    cpu="x86_64"
770c72b26ecSRichard Henderson  fi
7713aa9bd6cSblueswir1elif check_define __sparc__ ; then
7723aa9bd6cSblueswir1  if check_define __arch64__ ; then
7733aa9bd6cSblueswir1    cpu="sparc64"
7743aa9bd6cSblueswir1  else
7753aa9bd6cSblueswir1    cpu="sparc"
7763aa9bd6cSblueswir1  fi
777fdf7ed96Smalcelif check_define _ARCH_PPC ; then
778fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
779f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
780f8378accSRichard Henderson      cpu="ppc64le"
781f8378accSRichard Henderson    else
782fdf7ed96Smalc      cpu="ppc64"
783f8378accSRichard Henderson    fi
784ac0df51dSaliguori  else
785fdf7ed96Smalc    cpu="ppc"
786fdf7ed96Smalc  fi
787afa05235SAurelien Jarnoelif check_define __mips__ ; then
788afa05235SAurelien Jarno  cpu="mips"
789d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
790d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
791d66ed0eaSAurelien Jarno    cpu="s390x"
792d66ed0eaSAurelien Jarno  else
793d66ed0eaSAurelien Jarno    cpu="s390"
794d66ed0eaSAurelien Jarno  fi
795c4f80543SAlistair Franciselif check_define __riscv ; then
796c4f80543SAlistair Francis  if check_define _LP64 ; then
797c4f80543SAlistair Francis    cpu="riscv64"
798c4f80543SAlistair Francis  else
799c4f80543SAlistair Francis    cpu="riscv32"
800c4f80543SAlistair Francis  fi
80121d89f84SPeter Maydellelif check_define __arm__ ; then
80221d89f84SPeter Maydell  cpu="arm"
8031f080313SClaudio Fontanaelif check_define __aarch64__ ; then
8041f080313SClaudio Fontana  cpu="aarch64"
805fdf7ed96Smalcelse
80689138857SStefan Weil  cpu=$(uname -m)
807ac0df51dSaliguorifi
808ac0df51dSaliguori
809359bc95dSPeter MaydellARCH=
810359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
811359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
8127d13299dSbellardcase "$cpu" in
813ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
814898be3e0SPeter Maydell  ;;
815f8378accSRichard Henderson  ppc64le)
816f8378accSRichard Henderson    ARCH="ppc64"
817f8378accSRichard Henderson  ;;
8187d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
81997a847bcSbellard    cpu="i386"
8207d13299dSbellard  ;;
821aaa5fa14Saurel32  x86_64|amd64)
822aaa5fa14Saurel32    cpu="x86_64"
823aaa5fa14Saurel32  ;;
82421d89f84SPeter Maydell  armv*b|armv*l|arm)
82521d89f84SPeter Maydell    cpu="arm"
8267d13299dSbellard  ;;
8271f080313SClaudio Fontana  aarch64)
8281f080313SClaudio Fontana    cpu="aarch64"
8291f080313SClaudio Fontana  ;;
830afa05235SAurelien Jarno  mips*)
831afa05235SAurelien Jarno    cpu="mips"
832afa05235SAurelien Jarno  ;;
8333142255cSblueswir1  sparc|sun4[cdmuv])
834ae228531Sbellard    cpu="sparc"
835ae228531Sbellard  ;;
8367d13299dSbellard  *)
837359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
838359bc95dSPeter Maydell    ARCH=unknown
8397d13299dSbellard  ;;
8407d13299dSbellardesac
841359bc95dSPeter Maydellif test -z "$ARCH"; then
842359bc95dSPeter Maydell  ARCH="$cpu"
843359bc95dSPeter Maydellfi
844e2d52ad3SJuan Quintela
8457d13299dSbellard# OS specific
8460dbfc675SJuan Quintela
847adfc3e91SStacey Son# host *BSD for user mode
848adfc3e91SStacey SonHOST_VARIANT_DIR=""
849adfc3e91SStacey Son
8507d13299dSbellardcase $targetos in
85167b915a5SbellardMINGW32*)
85267b915a5Sbellard  mingw32="yes"
853b0cb0a66SVincent Palatin  hax="yes"
854299e6f19SPaolo Bonzini  vhost_user="no"
8553cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
856307119e7SGerd Hoffmann  if check_include dsound.h; then
8573cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
858307119e7SGerd Hoffmann  else
859307119e7SGerd Hoffmann    audio_drv_list=""
860307119e7SGerd Hoffmann  fi
861898be3e0SPeter Maydell  supported_os="yes"
86267b915a5Sbellard;;
8635c40d2bdSthsGNU/kFreeBSD)
864a167ba50SAurelien Jarno  bsd="yes"
8656a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8660bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
8675c40d2bdSths;;
8687d3505c5SbellardFreeBSD)
8697d3505c5Sbellard  bsd="yes"
8700db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8716a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8720bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
873f01576f1SJuergen Lock  # needed for kinfo_getvmmap(3) in libutil.h
874f01576f1SJuergen Lock  LIBS="-lutil $LIBS"
87558952137SVincenzo Maffione  netmap=""  # enable netmap autodetect
876adfc3e91SStacey Son  HOST_VARIANT_DIR="freebsd"
8777d3505c5Sbellard;;
878c5e97233Sblueswir1DragonFly)
879c5e97233Sblueswir1  bsd="yes"
8800db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8816a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8820bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl pa"
883adfc3e91SStacey Son  HOST_VARIANT_DIR="dragonfly"
884c5e97233Sblueswir1;;
8857d3505c5SbellardNetBSD)
8867d3505c5Sbellard  bsd="yes"
887604a5b99SKamil Rytarowski  hax="yes"
8880db4a067SPaolo Bonzini  make="${MAKE-gmake}"
8896a485418SGerd Hoffmann  audio_drv_list="oss try-sdl"
8900bac1111SKővágó, Zoltán  audio_possible_drivers="oss sdl"
8918ef92a88Sblueswir1  oss_lib="-lossaudio"
892adfc3e91SStacey Son  HOST_VARIANT_DIR="netbsd"
8937d3505c5Sbellard;;
8947d3505c5SbellardOpenBSD)
8957d3505c5Sbellard  bsd="yes"
8960db4a067SPaolo Bonzini  make="${MAKE-gmake}"
897f92c7168SGerd Hoffmann  audio_drv_list="try-sdl"
8980bac1111SKővágó, Zoltán  audio_possible_drivers="sdl"
899adfc3e91SStacey Son  HOST_VARIANT_DIR="openbsd"
9007d3505c5Sbellard;;
90183fb7adfSbellardDarwin)
90283fb7adfSbellard  bsd="yes"
90383fb7adfSbellard  darwin="yes"
904b0cb0a66SVincent Palatin  hax="yes"
905c97d6d2cSSergio Andres Gomez Del Real  hvf="yes"
90617969268SFam Zheng  LDFLAGS_SHARED="-bundle -undefined dynamic_lookup"
9071b0f9cc2Saliguori  if [ "$cpu" = "x86_64" ] ; then
908a558ee17SJuan Quintela    QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
909db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
9101b0f9cc2Saliguori  fi
911fd677642Sths  cocoa="yes"
9126a485418SGerd Hoffmann  audio_drv_list="coreaudio try-sdl"
91314382605SKővágó, Zoltán  audio_possible_drivers="coreaudio sdl"
914db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
9157973f21cSJuan Quintela  libs_softmmu="-F/System/Library/Frameworks -framework Cocoa -framework IOKit $libs_softmmu"
916a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
917a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
918a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
919adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
92083fb7adfSbellard;;
921ec530c81SbellardSunOS)
922ec530c81Sbellard  solaris="yes"
9230db4a067SPaolo Bonzini  make="${MAKE-gmake}"
9240db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
925e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
9266b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
9276a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
9286b4d2ba1Sths  fi
929c2de5c91Smalc  audio_possible_drivers="oss sdl"
930d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
931d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
932d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
933d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
934560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
935560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
936ec530c81Sbellard;;
937179cf400SAndreas FärberHaiku)
938179cf400SAndreas Färber  haiku="yes"
939fc433430SDavid CARLIER  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -DBSD_SOURCE $QEMU_CFLAGS"
940fc433430SDavid CARLIER  LIBS="-lposix_error_mapper -lnetwork -lbsd $LIBS"
941179cf400SAndreas Färber;;
942898be3e0SPeter MaydellLinux)
9437183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
9440bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
9455327cf48Sbellard  linux="yes"
946831b7825Sths  linux_user="yes"
947af2be207SJan Kiszka  kvm="yes"
94825211446SPaolo Bonzini  QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
9493efac6ebSTomáš Golembiovský  libudev="yes"
950898be3e0SPeter Maydell;;
9517d13299dSbellardesac
9527d13299dSbellard
9537d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
954b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
95584778508Sblueswir1    bsd_user="yes"
9567d3505c5Sbellard  fi
95708de3949SAndreas Färberfi
9587d3505c5Sbellard
9590db4a067SPaolo Bonzini: ${make=${MAKE-make}}
9600db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
961faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
962faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
963ddf90699SEduardo Habkost# we check that too
964faf44142SDaniel P. Berrangépython=
9650a01d76fSMarc-André Lureauexplicit_python=no
966ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
967faf44142SDaniel P. Berrangédo
968faf44142SDaniel P. Berrangé    if has "$binary"
969faf44142SDaniel P. Berrangé    then
97095c5f2deSPaolo Bonzini        python=$(command -v "$binary")
971faf44142SDaniel P. Berrangé        break
972faf44142SDaniel P. Berrangé    fi
973faf44142SDaniel P. Berrangédone
974903458c8SMarkus Armbruster
975903458c8SMarkus Armbrustersphinx_build=
976903458c8SMarkus Armbrusterfor binary in sphinx-build-3 sphinx-build
977903458c8SMarkus Armbrusterdo
978903458c8SMarkus Armbruster    if has "$binary"
979903458c8SMarkus Armbruster    then
980903458c8SMarkus Armbruster        sphinx_build=$(command -v "$binary")
981903458c8SMarkus Armbruster        break
982903458c8SMarkus Armbruster    fi
983903458c8SMarkus Armbrusterdone
984903458c8SMarkus Armbruster
98539d87c8cSAlex Bennée# Check for ancillary tools used in testing
98639d87c8cSAlex Bennéegenisoimage=
9873df437c7SAlex Bennéefor binary in genisoimage mkisofs
98839d87c8cSAlex Bennéedo
98939d87c8cSAlex Bennée    if has $binary
99039d87c8cSAlex Bennée    then
99139d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
99239d87c8cSAlex Bennée        break
99339d87c8cSAlex Bennée    fi
99439d87c8cSAlex Bennéedone
99539d87c8cSAlex Bennée
996e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
9970db4a067SPaolo Bonzini
9983c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
9993c4a4d0dSPeter Maydellif has clang; then
10003c4a4d0dSPeter Maydell  objcc=clang
10013c4a4d0dSPeter Maydellelse
10023c4a4d0dSPeter Maydell  objcc="$cc"
10033c4a4d0dSPeter Maydellfi
10043c4a4d0dSPeter Maydell
10053457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
10063457a3f8SJuan Quintela  EXESUF=".exe"
100717969268SFam Zheng  DSOSUF=".dll"
100878e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
1009086d5f75SPaolo Bonzini  CFLAGS="-mthreads $CFLAGS"
1010b965e8c5SPaolo Bonzini  LIBS="-lwinmm -lws2_32 $LIBS"
101193b25869SJohn Snow  write_c_skeleton;
1012f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
1013f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
1014f7cf5d5bSStefan Weil  fi
1015c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
1016683035deSPaolo Bonzini  confsuffix=""
1017105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
10183457a3f8SJuan Quintelafi
10193457a3f8SJuan Quintela
1020487fefdbSAnthony Liguoriwerror=""
102185aa5189Sbellard
10227d13299dSbellardfor opt do
102389138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
10247d13299dSbellard  case "$opt" in
10252efc3265Sbellard  --help|-h) show_help=yes
10262efc3265Sbellard  ;;
102799123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
102899123e13SMike Frysinger  ;;
1029b1a550a0Spbrook  --prefix=*) prefix="$optarg"
10307d13299dSbellard  ;;
1031b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
103232ce6337Sbellard  ;;
1033ac0df51dSaliguori  --cross-prefix=*)
10347d13299dSbellard  ;;
1035ac0df51dSaliguori  --cc=*)
10367d13299dSbellard  ;;
1037b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
103883469015Sbellard  ;;
103983f73fceSTomoki Sekiyama  --cxx=*)
104083f73fceSTomoki Sekiyama  ;;
1041e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
1042e007dbecSMichael S. Tsirkin  ;;
10433c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
10443c4a4d0dSPeter Maydell  ;;
1045b1a550a0Spbrook  --make=*) make="$optarg"
10467d13299dSbellard  ;;
10476a882643Spbrook  --install=*) install="$optarg"
10486a882643Spbrook  ;;
10490a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
1050c886edfbSBlue Swirl  ;;
10512eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
10522eb054c2SPeter Maydell  ;;
1053a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
1054a5665051SPaolo Bonzini  ;;
1055a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
1056a5665051SPaolo Bonzini  ;;
1057e2d8830eSBrad  --smbd=*) smbd="$optarg"
1058e2d8830eSBrad  ;;
1059e2a2ed06SJuan Quintela  --extra-cflags=*)
10607d13299dSbellard  ;;
106111cde1c8SBruno Dominguez  --extra-cxxflags=*)
106211cde1c8SBruno Dominguez  ;;
1063e2a2ed06SJuan Quintela  --extra-ldflags=*)
10647d13299dSbellard  ;;
10655bc62e01SGerd Hoffmann  --enable-debug-info)
10665bc62e01SGerd Hoffmann  ;;
10675bc62e01SGerd Hoffmann  --disable-debug-info)
10685bc62e01SGerd Hoffmann  ;;
1069d75402b5SAlex Bennée  --cross-cc-*)
1070d75402b5SAlex Bennée  ;;
107117969268SFam Zheng  --enable-modules)
107217969268SFam Zheng      modules="yes"
107317969268SFam Zheng  ;;
10743aa88b31SStefan Hajnoczi  --disable-modules)
10753aa88b31SStefan Hajnoczi      modules="no"
10763aa88b31SStefan Hajnoczi  ;;
1077bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
1078bd83c861SChristian Ehrhardt  ;;
1079bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
1080bd83c861SChristian Ehrhardt  ;;
10812ff6b91eSJuan Quintela  --cpu=*)
10827d13299dSbellard  ;;
1083b1a550a0Spbrook  --target-list=*) target_list="$optarg"
1084447e133fSAlex Bennée                   if test "$target_list_exclude"; then
1085447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
1086447e133fSAlex Bennée                   fi
1087447e133fSAlex Bennée  ;;
1088447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
1089447e133fSAlex Bennée                   if test "$target_list"; then
1090447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
1091447e133fSAlex Bennée                   fi
1092de83cd02Sbellard  ;;
10935b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
10945b808275SLluís Vilanova  ;;
10955b808275SLluís Vilanova  # XXX: backwards compatibility
10965b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
109794a420b1SStefan Hajnoczi  ;;
109874242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
10999410b56cSPrerna Saxena  ;;
1100f3494749SPaolo Bonzini  --with-default-devices) default_devices="yes"
1101f3494749SPaolo Bonzini  ;;
1102f3494749SPaolo Bonzini  --without-default-devices) default_devices="no"
1103f3494749SPaolo Bonzini  ;;
11047d13299dSbellard  --enable-gprof) gprof="yes"
11057d13299dSbellard  ;;
11061d728c39SBlue Swirl  --enable-gcov) gcov="yes"
11071d728c39SBlue Swirl  ;;
110879427693SLoïc Minier  --static)
110979427693SLoïc Minier    static="yes"
111017884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
111143ce4dfeSbellard  ;;
11120b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
11130b24e75fSPaolo Bonzini  ;;
11140b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
11150b24e75fSPaolo Bonzini  ;;
11163aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
11173aa5d2beSAlon Levy  ;;
11188bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
11198bf188aaSMichael Tokarev  ;;
11200f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
11210f94d6daSAlon Levy  ;;
1122528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
11230b24e75fSPaolo Bonzini  ;;
1124023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1125023d3d67SEduardo Habkost  ;;
1126850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
11270b24e75fSPaolo Bonzini  ;;
1128ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
112907381cc1SAnthony Liguori  ;;
1130785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1131785c23aeSLuiz Capitulino  ;;
11323d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
11333d5eecabSGerd Hoffmann  ;;
1134181ce1d0SOlaf Hering  --host=*|--build=*|\
1135181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1136785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1137023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1138023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1139023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1140023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1141023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1142023ddd74SMax Filippov    # lots of directory switches by default.
1143023ddd74SMax Filippov  ;;
114497a847bcSbellard  --disable-sdl) sdl="no"
114597a847bcSbellard  ;;
1146c4198157SJuan Quintela  --enable-sdl) sdl="yes"
1147c4198157SJuan Quintela  ;;
1148a442fe2fSDaniel P. Berrangé  --disable-sdl-image) sdl_image="no"
1149a442fe2fSDaniel P. Berrangé  ;;
1150a442fe2fSDaniel P. Berrangé  --enable-sdl-image) sdl_image="yes"
1151a442fe2fSDaniel P. Berrangé  ;;
11523556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
11533556c233SPaolo Bonzini  ;;
11543556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
11553556c233SPaolo Bonzini  ;;
1156983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1157983eef5aSMeador Inge  ;;
1158983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1159983eef5aSMeador Inge  ;;
1160fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1161fe8fc5aeSPaolo Bonzini  ;;
1162fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1163fe8fc5aeSPaolo Bonzini  ;;
1164821601eaSJes Sorensen  --disable-vnc) vnc="no"
1165821601eaSJes Sorensen  ;;
1166821601eaSJes Sorensen  --enable-vnc) vnc="yes"
1167821601eaSJes Sorensen  ;;
11682f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
11692f6a1ab0Sblueswir1  ;;
11700c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
11710c58ac1cSmalc  ;;
117289138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1173b64ec4e4SFam Zheng  ;;
117489138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1175eb852011SMarkus Armbruster  ;;
1176f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1177f8393946Saurel32  ;;
1178f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1179f8393946Saurel32  ;;
1180f3d08ee6SPaul Brook  --enable-debug)
1181f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1182f3d08ee6SPaul Brook      debug_tcg="yes"
11831fcc6d42SPeter Xu      debug_mutex="yes"
1184f3d08ee6SPaul Brook      debug="yes"
1185f3d08ee6SPaul Brook      strip_opt="no"
1186b553a042SJohn Snow      fortify_source="no"
1187f3d08ee6SPaul Brook  ;;
1188247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1189247724cbSMarc-André Lureau  ;;
1190247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1191247724cbSMarc-André Lureau  ;;
11920aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
11930aebab04SLingfeng Yang  ;;
11940aebab04SLingfeng Yang  --disable-tsan) tsan="no"
11950aebab04SLingfeng Yang  ;;
119603b4fe7dSaliguori  --enable-sparse) sparse="yes"
119703b4fe7dSaliguori  ;;
119803b4fe7dSaliguori  --disable-sparse) sparse="no"
119903b4fe7dSaliguori  ;;
12001625af87Saliguori  --disable-strip) strip_opt="no"
12011625af87Saliguori  ;;
12022f9606b3Saliguori  --disable-vnc-sasl) vnc_sasl="no"
12032f9606b3Saliguori  ;;
1204ea784e3bSJuan Quintela  --enable-vnc-sasl) vnc_sasl="yes"
1205ea784e3bSJuan Quintela  ;;
12062f6f5c7aSCorentin Chary  --disable-vnc-jpeg) vnc_jpeg="no"
12072f6f5c7aSCorentin Chary  ;;
12082f6f5c7aSCorentin Chary  --enable-vnc-jpeg) vnc_jpeg="yes"
12092f6f5c7aSCorentin Chary  ;;
1210efe556adSCorentin Chary  --disable-vnc-png) vnc_png="no"
1211efe556adSCorentin Chary  ;;
1212efe556adSCorentin Chary  --enable-vnc-png) vnc_png="yes"
1213efe556adSCorentin Chary  ;;
1214443f1376Sbellard  --disable-slirp) slirp="no"
1215c20709aaSbellard  ;;
12167c57bdd8SMarc-André Lureau  --enable-slirp=git) slirp="git"
12177c57bdd8SMarc-André Lureau  ;;
1218675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1219675b9b53SMarc-André Lureau  ;;
1220e0e6c8c0Saliguori  --disable-vde) vde="no"
12218a16d273Sths  ;;
1222dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1223dfb278bdSJuan Quintela  ;;
122458952137SVincenzo Maffione  --disable-netmap) netmap="no"
122558952137SVincenzo Maffione  ;;
122658952137SVincenzo Maffione  --enable-netmap) netmap="yes"
122758952137SVincenzo Maffione  ;;
1228e37630caSaliguori  --disable-xen) xen="no"
1229e37630caSaliguori  ;;
1230fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1231fc321b4bSJuan Quintela  ;;
1232eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1233eb6fda0fSAnthony PERARD  ;;
1234eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1235eb6fda0fSAnthony PERARD  ;;
12362e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
12372e4d9fb1Saurel32  ;;
12384ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
12394ffcedb6SJuan Quintela  ;;
12407ba1e619Saliguori  --disable-kvm) kvm="no"
12417ba1e619Saliguori  ;;
1242b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1243b31a0277SJuan Quintela  ;;
1244b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1245180fb750Szhanghailiang  ;;
1246b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1247180fb750Szhanghailiang  ;;
1248c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1249c97d6d2cSSergio Andres Gomez Del Real  ;;
1250c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1251c97d6d2cSSergio Andres Gomez Del Real  ;;
1252d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1253d661d9a4SJustin Terry (VM)  ;;
1254d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1255d661d9a4SJustin Terry (VM)  ;;
12569195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
12579195b2c2SStefan Weil  ;;
12589195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
12599195b2c2SStefan Weil  ;;
126047e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
126147e98658SCorey Bryant  ;;
126247e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
126347e98658SCorey Bryant  ;;
1264b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1265b3f6ea7eSPaolo Bonzini  ;;
1266b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1267b3f6ea7eSPaolo Bonzini  ;;
12685a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
12695a22ab71SYang Zhong  ;;
12705a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
12715a22ab71SYang Zhong  ;;
1272cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1273cd4ec0b4SGerd Hoffmann  ;;
1274cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1275cd4ec0b4SGerd Hoffmann  ;;
1276c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1277c589b249SRonnie Sahlberg  ;;
1278c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1279c589b249SRonnie Sahlberg  ;;
12806542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
12816542aa9cSPeter Lieven  ;;
12826542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
12836542aa9cSPeter Lieven  ;;
128405c2a3e7Sbellard  --enable-profiler) profiler="yes"
128505c2a3e7Sbellard  ;;
128614821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
128714821030SPavel Borzenkov  ;;
1288c2de5c91Smalc  --enable-cocoa)
1289c2de5c91Smalc      cocoa="yes" ;
129089138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
12915b0753e0Sbellard  ;;
1292cad25d69Spbrook  --disable-system) softmmu="no"
12930a8e90f4Spbrook  ;;
1294cad25d69Spbrook  --enable-system) softmmu="yes"
12950a8e90f4Spbrook  ;;
12960953a80fSZachary Amsden  --disable-user)
12970953a80fSZachary Amsden      linux_user="no" ;
12980953a80fSZachary Amsden      bsd_user="no" ;
12990953a80fSZachary Amsden  ;;
13000953a80fSZachary Amsden  --enable-user) ;;
1301831b7825Sths  --disable-linux-user) linux_user="no"
13020a8e90f4Spbrook  ;;
1303831b7825Sths  --enable-linux-user) linux_user="yes"
1304831b7825Sths  ;;
130584778508Sblueswir1  --disable-bsd-user) bsd_user="no"
130684778508Sblueswir1  ;;
130784778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
130884778508Sblueswir1  ;;
130940d6444eSAvi Kivity  --enable-pie) pie="yes"
131034005a00SKirill A. Shutemov  ;;
131140d6444eSAvi Kivity  --disable-pie) pie="no"
131234005a00SKirill A. Shutemov  ;;
131385aa5189Sbellard  --enable-werror) werror="yes"
131485aa5189Sbellard  ;;
131585aa5189Sbellard  --disable-werror) werror="no"
131685aa5189Sbellard  ;;
131763678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
131863678e17SSteven Noonan  ;;
131963678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
132063678e17SSteven Noonan  ;;
13211e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
13221e4f6065SDaniele Buono  ;;
13231e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
13241e4f6065SDaniele Buono  ;;
13254d3b6f6eSbalrog  --disable-curses) curses="no"
13264d3b6f6eSbalrog  ;;
1327c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1328c584a6d0SJuan Quintela  ;;
1329e08bb301SSamuel Thibault  --disable-iconv) iconv="no"
1330e08bb301SSamuel Thibault  ;;
1331e08bb301SSamuel Thibault  --enable-iconv) iconv="yes"
1332e08bb301SSamuel Thibault  ;;
1333769ce76dSAlexander Graf  --disable-curl) curl="no"
1334769ce76dSAlexander Graf  ;;
1335788c8196SJuan Quintela  --enable-curl) curl="yes"
1336788c8196SJuan Quintela  ;;
13372df87df7SJuan Quintela  --disable-fdt) fdt="no"
13382df87df7SJuan Quintela  ;;
13392df87df7SJuan Quintela  --enable-fdt) fdt="yes"
13402df87df7SJuan Quintela  ;;
13415c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
13425c6c3a6cSChristoph Hellwig  ;;
13435c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
13445c6c3a6cSChristoph Hellwig  ;;
1345c10dd856SAarushi Mehta  --disable-linux-io-uring) linux_io_uring="no"
1346c10dd856SAarushi Mehta  ;;
1347c10dd856SAarushi Mehta  --enable-linux-io-uring) linux_io_uring="yes"
1348c10dd856SAarushi Mehta  ;;
1349758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1350758e8e38SVenkateswararao Jujjuri (JV)  ;;
1351758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1352758e8e38SVenkateswararao Jujjuri (JV)  ;;
1353a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1354a40161cbSPaolo Bonzini  ;;
1355a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1356a40161cbSPaolo Bonzini  ;;
135777755340Sths  --disable-blobs) blobs="no"
135877755340Sths  ;;
13597e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
13604a19f1ecSpbrook  ;;
1361519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1362519175a2SAlex Barcelo  ;;
136370c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
136470c60c08SStefan Hajnoczi  ;;
136570c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
136670c60c08SStefan Hajnoczi  ;;
13677d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
13687d992e4dSPeter Lieven  ;;
1369f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1370f0d92b56SLongpeng(Mike)  ;;
1371f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1372f0d92b56SLongpeng(Mike)  ;;
1373a25dba17SJuan Quintela  --disable-docs) docs="no"
137470ec5dc0SAnthony Liguori  ;;
1375a25dba17SJuan Quintela  --enable-docs) docs="yes"
137683a3ab8bSJuan Quintela  ;;
1377d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1378d5970055SMichael S. Tsirkin  ;;
1379d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1380d5970055SMichael S. Tsirkin  ;;
1381042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1382042cea27SGonglei  ;;
1383299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1384042cea27SGonglei  ;;
13855e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
13865e9be92dSNicholas Bellinger  ;;
13875e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
13885e9be92dSNicholas Bellinger  ;;
1389fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1390fc0b9b0eSStefan Hajnoczi  ;;
1391fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1392fc0b9b0eSStefan Hajnoczi  ;;
139398fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
139498fc1adaSDr. David Alan Gilbert  ;;
139598fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
139698fc1adaSDr. David Alan Gilbert  ;;
1397da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
139820ff075bSMichael Walle  ;;
1399da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
140020ff075bSMichael Walle  ;;
1401f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1402f27aaf4bSChristian Brunner  ;;
1403f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1404f27aaf4bSChristian Brunner  ;;
14058c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
14068c84cf11SSergei Trofimovich  ;;
14078c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
14088c84cf11SSergei Trofimovich  ;;
14097b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1410111a38b0SRobert Relyea  ;;
14117b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1412111a38b0SRobert Relyea  ;;
14132b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
14142b2325ffSGerd Hoffmann  ;;
14152b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
14162b2325ffSGerd Hoffmann  ;;
141769354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
141869354a83SHans de Goede  ;;
141969354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
142069354a83SHans de Goede  ;;
14211ece9905SAlon Levy  --disable-zlib-test) zlib="no"
14221ece9905SAlon Levy  ;;
1423b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1424b25c9dffSStefan Weil  ;;
1425607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1426607dacd0Sqiaonuohan  ;;
1427b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1428b25c9dffSStefan Weil  ;;
1429607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1430607dacd0Sqiaonuohan  ;;
14316b383c08SPeter Wu  --disable-bzip2) bzip2="no"
14326b383c08SPeter Wu  ;;
14336b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
14346b383c08SPeter Wu  ;;
143583bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
143683bc1f97SJulio Faracco  ;;
143783bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
143883bc1f97SJulio Faracco  ;;
14393a678481SJuan Quintela  --disable-zstd) zstd="no"
14403a678481SJuan Quintela  ;;
14413a678481SJuan Quintela  --enable-zstd) zstd="yes"
14423a678481SJuan Quintela  ;;
1443d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1444d138cee9SMichael Roth  ;;
1445d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1446d138cee9SMichael Roth  ;;
14479dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
14489dacf32dSYossi Hindin  ;;
14499dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
14509dacf32dSYossi Hindin  ;;
1451d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1452d9840e25STomoki Sekiyama  ;;
1453d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1454d9840e25STomoki Sekiyama  ;;
1455d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1456d9840e25STomoki Sekiyama  ;;
1457d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1458d9840e25STomoki Sekiyama  ;;
1459d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1460d9840e25STomoki Sekiyama  ;;
1461d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1462d9840e25STomoki Sekiyama  ;;
14634b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
14644b1c11fdSDaniel P. Berrange  ;;
14654b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
14664b1c11fdSDaniel P. Berrange  ;;
1467f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1468f794573eSEduardo Otubo  ;;
1469f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1470f794573eSEduardo Otubo  ;;
1471eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1472eb100396SBharata B Rao  ;;
147386583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
147486583a07SLiam Merwick  ;;
147586583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
147686583a07SLiam Merwick  ;;
14776b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
14786b8cd447SRobert Hoo  ;;
14796b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
14806b8cd447SRobert Hoo  ;;
14816b8cd447SRobert Hoo
1482eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1483eb100396SBharata B Rao  ;;
148452b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
148552b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1486583f6e7bSStefan Hajnoczi  ;;
1487cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1488cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1489cb6414dfSFam Zheng  ;;
1490315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1491315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1492315d3184SFam Zheng  ;;
1493a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1494a4ccabcfSAnthony Liguori  ;;
1495a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1496a4ccabcfSAnthony Liguori  ;;
1497a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1498a1c5e949SDaniel P. Berrange  ;;
1499ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1500ddbb0d09SDaniel P. Berrange  ;;
1501ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1502ddbb0d09SDaniel P. Berrange  ;;
150391bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
150491bfcdb0SDaniel P. Berrange  ;;
150591bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
150691bfcdb0SDaniel P. Berrange  ;;
150791bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
150891bfcdb0SDaniel P. Berrange  ;;
150991bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
151091bfcdb0SDaniel P. Berrange  ;;
15118953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
15128953caf3SDaniel P. Berrange  ;;
15138953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
15148953caf3SDaniel P. Berrange  ;;
15152da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
15162da776dbSMichael R. Hines  ;;
15172da776dbSMichael R. Hines  --disable-rdma) rdma="no"
15182da776dbSMichael R. Hines  ;;
151921ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
152021ab34c9SMarcel Apfelbaum  ;;
152121ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
152221ab34c9SMarcel Apfelbaum  ;;
1523bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1524bbbf9bfbSStefan Weil  ;;
1525bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1526bbbf9bfbSStefan Weil  ;;
15279d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
15289d9e1521SGerd Hoffmann  ;;
15299d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
15309d9e1521SGerd Hoffmann  ;;
1531e91c793cSCole Robinson  --disable-tpm) tpm="no"
1532e91c793cSCole Robinson  ;;
1533ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1534ab214c29SStefan Berger  ;;
1535b10d49d7SPino Toscano  --disable-libssh) libssh="no"
15360a12ec87SRichard W.M. Jones  ;;
1537b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
15380a12ec87SRichard W.M. Jones  ;;
1539ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1540ed1701c6SDr. David Alan Gilbert  ;;
1541ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1542ed1701c6SDr. David Alan Gilbert  ;;
1543a99d57bbSWanlong Gao  --disable-numa) numa="no"
1544a99d57bbSWanlong Gao  ;;
1545a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1546a99d57bbSWanlong Gao  ;;
1547ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1548ed279a06SKlim Kireev  ;;
1549ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1550ed279a06SKlim Kireev  ;;
15512847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
15522847b469SFam Zheng  ;;
15532847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
15542847b469SFam Zheng  ;;
15557b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
15567b01cb97SAlexandre Derumier  ;;
15577b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
15587b01cb97SAlexandre Derumier  ;;
1559a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1560a6b1d4c0SChanglong Xie  ;;
1561a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1562a6b1d4c0SChanglong Xie  ;;
15632f740136SJeff Cody  --disable-bochs) bochs="no"
15642f740136SJeff Cody  ;;
15652f740136SJeff Cody  --enable-bochs) bochs="yes"
15662f740136SJeff Cody  ;;
15672f740136SJeff Cody  --disable-cloop) cloop="no"
15682f740136SJeff Cody  ;;
15692f740136SJeff Cody  --enable-cloop) cloop="yes"
15702f740136SJeff Cody  ;;
15712f740136SJeff Cody  --disable-dmg) dmg="no"
15722f740136SJeff Cody  ;;
15732f740136SJeff Cody  --enable-dmg) dmg="yes"
15742f740136SJeff Cody  ;;
15752f740136SJeff Cody  --disable-qcow1) qcow1="no"
15762f740136SJeff Cody  ;;
15772f740136SJeff Cody  --enable-qcow1) qcow1="yes"
15782f740136SJeff Cody  ;;
15792f740136SJeff Cody  --disable-vdi) vdi="no"
15802f740136SJeff Cody  ;;
15812f740136SJeff Cody  --enable-vdi) vdi="yes"
15822f740136SJeff Cody  ;;
15832f740136SJeff Cody  --disable-vvfat) vvfat="no"
15842f740136SJeff Cody  ;;
15852f740136SJeff Cody  --enable-vvfat) vvfat="yes"
15862f740136SJeff Cody  ;;
15872f740136SJeff Cody  --disable-qed) qed="no"
15882f740136SJeff Cody  ;;
15892f740136SJeff Cody  --enable-qed) qed="yes"
15902f740136SJeff Cody  ;;
15912f740136SJeff Cody  --disable-parallels) parallels="no"
15922f740136SJeff Cody  ;;
15932f740136SJeff Cody  --enable-parallels) parallels="yes"
15942f740136SJeff Cody  ;;
15952f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
15962f740136SJeff Cody  ;;
15972f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
15982f740136SJeff Cody  ;;
1599e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1600e6a74868SMarc-André Lureau  ;;
1601299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1602299e6f19SPaolo Bonzini  ;;
1603108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1604108a6481SCindy Lu  ;;
1605108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1606108a6481SCindy Lu  ;;
1607299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1608299e6f19SPaolo Bonzini  ;;
1609299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1610e6a74868SMarc-André Lureau  ;;
16118ca80760SRichard Henderson  --disable-capstone) capstone="no"
16128ca80760SRichard Henderson  ;;
16138ca80760SRichard Henderson  --enable-capstone) capstone="yes"
16148ca80760SRichard Henderson  ;;
1615e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1616e219c499SRichard Henderson  ;;
1617e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1618e219c499SRichard Henderson  ;;
1619cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1620cc84d63aSDaniel P. Berrange  ;;
1621f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1622f62bbee5SDaniel P. Berrange  ;;
1623f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1624f62bbee5SDaniel P. Berrange  ;;
1625ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1626ba59fb77SPaolo Bonzini  ;;
1627ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1628ba59fb77SPaolo Bonzini  ;;
162917824406SJunyan He  --enable-libpmem) libpmem=yes
163017824406SJunyan He  ;;
163117824406SJunyan He  --disable-libpmem) libpmem=no
163217824406SJunyan He  ;;
163375411919SJames Le Cuirot  --enable-xkbcommon) xkbcommon=yes
163475411919SJames Le Cuirot  ;;
163575411919SJames Le Cuirot  --disable-xkbcommon) xkbcommon=no
163675411919SJames Le Cuirot  ;;
163740e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
163840e8c6f4SAlex Bennée  ;;
163940e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
164040e8c6f4SAlex Bennée  ;;
1641afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1642afc3a8f9SAlex Bennée  ;;
1643afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1644afc3a8f9SAlex Bennée  ;;
1645adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1646adc28027SAlexander Bulekov  ;;
1647adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1648adc28027SAlexander Bulekov  ;;
1649f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1650f48e590aSAlex Bennée  ;;
1651b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1652b767d257SMarek Marczykowski-Górecki  ;;
1653b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1654b767d257SMarek Marczykowski-Górecki  ;;
165554e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
165654e7aac0SAlexey Krasikov  ;;
165754e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
165854e7aac0SAlexey Krasikov  ;;
165921b2eca6SJingqi Liu  --enable-libdaxctl) libdaxctl=yes
166021b2eca6SJingqi Liu  ;;
166121b2eca6SJingqi Liu  --disable-libdaxctl) libdaxctl=no
166221b2eca6SJingqi Liu  ;;
16632d2ad6d0SFam Zheng  *)
16642d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
16652d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
16662d2ad6d0SFam Zheng      exit 1
16677f1559c6Sbalrog  ;;
16687d13299dSbellard  esac
16697d13299dSbellarddone
16707d13299dSbellard
167122a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
167222a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
167322a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
167422a87800SMarc-André Lureau
167522a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
167622a87800SMarc-André Lureau    mandir="$prefix"
167722a87800SMarc-André Lureau    datadir="$prefix"
167822a87800SMarc-André Lureau    qemu_docdir="$prefix"
167922a87800SMarc-André Lureau    bindir="$prefix"
168022a87800SMarc-André Lureau    sysconfdir="$prefix"
168122a87800SMarc-André Lureau    local_statedir=
168222a87800SMarc-André Lureauelse
168322a87800SMarc-André Lureau    mandir="${mandir:-$prefix/share/man}"
168422a87800SMarc-André Lureau    datadir="${datadir:-$prefix/share}"
168522a87800SMarc-André Lureau    qemu_docdir="${qemu_docdir:-$prefix/share/doc/qemu}"
168622a87800SMarc-André Lureau    bindir="${bindir:-$prefix/bin}"
168722a87800SMarc-André Lureau    sysconfdir="${sysconfdir:-$prefix/etc}"
168822a87800SMarc-André Lureau    local_statedir="${local_statedir:-$prefix/var}"
168922a87800SMarc-André Lureaufi
169022a87800SMarc-André Lureau
169140293e58Sbellardcase "$cpu" in
1692e3608d66SRichard Henderson    ppc)
1693e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1694db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1695e3608d66SRichard Henderson           ;;
1696e3608d66SRichard Henderson    ppc64)
1697e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1698db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1699e3608d66SRichard Henderson           ;;
17009b9c37c3SRichard Henderson    sparc)
1701f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1702db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
17033142255cSblueswir1           ;;
1704ed968ff1SJuan Quintela    sparc64)
170579f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1706db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
17073142255cSblueswir1           ;;
170876d83bdeSths    s390)
1709061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1710db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
171128d7cc49SRichard Henderson           ;;
171228d7cc49SRichard Henderson    s390x)
1713061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1714db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
171576d83bdeSths           ;;
171640293e58Sbellard    i386)
171779f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1718db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
171940293e58Sbellard           ;;
172040293e58Sbellard    x86_64)
17217ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
17227ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
17237ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
17247ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1725db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1726379f6698SPaul Brook           ;;
1727c72b26ecSRichard Henderson    x32)
1728c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1729db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1730c72b26ecSRichard Henderson           ;;
173130163d89SPeter Maydell    # No special flags required for other host CPUs
17323142255cSblueswir1esac
17333142255cSblueswir1
17342038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
17352038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
173679f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
173779f3b12fSPeter Crosthwaite
1738affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1739affc88ccSPeter Maydell# support, even if we're using TCI.
1740affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1741affc88ccSPeter Maydell  bsd_user="no"
1742affc88ccSPeter Maydell  linux_user="no"
1743affc88ccSPeter Maydellfi
1744affc88ccSPeter Maydell
17451cf295beSPhilippe Mathieu-Daudéif [ "$bsd_user" = "no" -a "$linux_user" = "no" -a "$softmmu" = "no" ] ; then
17461cf295beSPhilippe Mathieu-Daudé  tcg="no"
17471cf295beSPhilippe Mathieu-Daudéfi
17481cf295beSPhilippe Mathieu-Daudé
174960e0df25SPeter Maydelldefault_target_list=""
175060e0df25SPeter Maydell
17516e92f823SPeter Maydellmak_wilds=""
17526e92f823SPeter Maydell
175360e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
17546e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
175560e0df25SPeter Maydellfi
175660e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
17576e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
175860e0df25SPeter Maydellfi
175960e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
17606e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
176160e0df25SPeter Maydellfi
176260e0df25SPeter Maydell
1763447e133fSAlex Bennéeif test -z "$target_list_exclude"; then
17646e92f823SPeter Maydell    for config in $mak_wilds; do
17656e92f823SPeter Maydell        default_target_list="${default_target_list} $(basename "$config" .mak)"
17666e92f823SPeter Maydell    done
1767447e133fSAlex Bennéeelse
1768447e133fSAlex Bennée    exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1769447e133fSAlex Bennée    for config in $mak_wilds; do
1770447e133fSAlex Bennée        target="$(basename "$config" .mak)"
1771447e133fSAlex Bennée        exclude="no"
1772447e133fSAlex Bennée        for excl in $exclude_list; do
1773447e133fSAlex Bennée            if test "$excl" = "$target"; then
1774447e133fSAlex Bennée                exclude="yes"
1775447e133fSAlex Bennée                break;
1776447e133fSAlex Bennée            fi
1777447e133fSAlex Bennée        done
1778447e133fSAlex Bennée        if test "$exclude" = "no"; then
1779447e133fSAlex Bennée            default_target_list="${default_target_list} $target"
1780447e133fSAlex Bennée        fi
1781447e133fSAlex Bennée    done
1782447e133fSAlex Bennéefi
17836e92f823SPeter Maydell
1784c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
178564a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1786c53eeaf7SStefan Hajnoczi
1787af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1788af5db58eSpbrookcat << EOF
1789af5db58eSpbrook
1790af5db58eSpbrookUsage: configure [options]
1791af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1792af5db58eSpbrook
179308fb77edSStefan WeilStandard options:
179408fb77edSStefan Weil  --help                   print this message
179508fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
179608fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
179708fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
179808fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
179908fb77edSStefan Weil$(echo Available targets: $default_target_list | \
180008fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
1801447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
180208fb77edSStefan Weil
180308fb77edSStefan WeilAdvanced options (experts only):
180408fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
180508fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
180608fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
180708fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
180808fb77edSStefan Weil                           build time
180908fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
181008fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
181108fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
181211cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
181308fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1814d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1815d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
181608fb77edSStefan Weil  --make=MAKE              use specified make [$make]
181708fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
181808fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
18192eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1820a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
182108fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1822db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
182308fb77edSStefan Weil  --static                 enable static build [$static]
182408fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
182508fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
182608fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
182708fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
182808fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1829db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
183008fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
183108fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
18323d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
183313336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1834e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1835db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
183608fb77edSStefan Weil  --enable-debug           enable common debug build options
1837247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
18380aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
183908fb77edSStefan Weil  --disable-strip          disable stripping binaries
184008fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
184163678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
184208fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
184308fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
184408fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
184508fb77edSStefan Weil  --block-drv-rw-whitelist=L
184608fb77edSStefan Weil                           set block driver read-write whitelist
184708fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
184808fb77edSStefan Weil  --block-drv-ro-whitelist=L
184908fb77edSStefan Weil                           set block driver read-only whitelist
185008fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
18515b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1852c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
185308fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
185408fb77edSStefan Weil                           Default:trace-<pid>
1855c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1856c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
18575a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1858c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1859c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
186008fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
186133c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
186208fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1863c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1864c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1865c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1866a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1867c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1868c12d66aaSLin Ma  --enable-profiler        profiler support
1869c12d66aaSLin Ma  --enable-debug-stack-usage
1870c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
187140e8c6f4SAlex Bennée  --enable-plugins
187240e8c6f4SAlex Bennée                           enable plugins via shared library loading
1873afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1874f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1875c23f23b9SMichael Tokarev
1876c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1877c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1878c23f23b9SMichael Tokarev
1879c23f23b9SMichael Tokarev  system          all system emulation targets
1880c23f23b9SMichael Tokarev  user            supported user emulation targets
1881c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1882c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1883c23f23b9SMichael Tokarev  docs            build documentation
1884c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1885c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1886c23f23b9SMichael Tokarev  pie             Position Independent Executables
188721e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1888bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1889c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1890c23f23b9SMichael Tokarev  debug-info      debugging information
1891c23f23b9SMichael Tokarev  sparse          sparse checker
18921e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
18931e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
1894c23f23b9SMichael Tokarev
1895ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
189691bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
189791bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
18988953caf3SDaniel P. Berrange  auth-pam        PAM access control
1899c23f23b9SMichael Tokarev  sdl             SDL UI
190004c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1901c23f23b9SMichael Tokarev  gtk             gtk UI
1902c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1903c23f23b9SMichael Tokarev  curses          curses UI
1904e08bb301SSamuel Thibault  iconv           font glyph conversion support
1905c23f23b9SMichael Tokarev  vnc             VNC UI support
1906c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1907c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1908c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1909c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1910c23f23b9SMichael Tokarev  virtfs          VirtFS
1911fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1912c23f23b9SMichael Tokarev  xen             xen backend driver support
191370c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1914c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1915c23f23b9SMichael Tokarev  curl            curl connectivity
1916a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1917c23f23b9SMichael Tokarev  fdt             fdt device tree
1918c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1919b0cb0a66SVincent Palatin  hax             HAX acceleration support
1920c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1921d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
192221ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
192321ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1924c23f23b9SMichael Tokarev  vde             support for vde network
1925c23f23b9SMichael Tokarev  netmap          support for netmap network
1926c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1927c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1928c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1929c23f23b9SMichael Tokarev  attr            attr and xattr support
1930299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1931299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1932299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1933299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1934299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1935299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1936108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
1937c23f23b9SMichael Tokarev  spice           spice
1938c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1939c23f23b9SMichael Tokarev  libiscsi        iscsi support
1940c23f23b9SMichael Tokarev  libnfs          nfs support
19417b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
1942c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1943ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1944c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1945c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1946c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1947c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1948c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
194983bc1f97SJulio Faracco  lzfse           support of lzfse compression library
195083bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
19513a678481SJuan Quintela  zstd            support for zstd compression library
1952d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1953c23f23b9SMichael Tokarev  seccomp         seccomp support
1954c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1955c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1956c23f23b9SMichael Tokarev  tpm             TPM support
1957b10d49d7SPino Toscano  libssh          ssh block device support
1958c23f23b9SMichael Tokarev  numa            libnuma support
1959ed279a06SKlim Kireev  libxml2         for Parallels image format
1960c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19617b01cb97SAlexandre Derumier  jemalloc        jemalloc support
196286583a07SLiam Merwick  avx2            AVX2 optimization support
19636b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1964a6b1d4c0SChanglong Xie  replication     replication support
1965c12d66aaSLin Ma  opengl          opengl support
1966c12d66aaSLin Ma  virglrenderer   virgl rendering support
1967c12d66aaSLin Ma  xfsctl          xfsctl support
1968c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19698de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19702f740136SJeff Cody  bochs           bochs image format support
19712f740136SJeff Cody  cloop           cloop image format support
19722f740136SJeff Cody  dmg             dmg image format support
19732f740136SJeff Cody  qcow1           qcow v1 image format support
19742f740136SJeff Cody  vdi             vdi image format support
19752f740136SJeff Cody  vvfat           vvfat image format support
19762f740136SJeff Cody  qed             qed image format support
19772f740136SJeff Cody  parallels       parallels image format support
19782f740136SJeff Cody  sheepdog        sheepdog block driver support
1979f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19808ca80760SRichard Henderson  capstone        capstone disassembler support
1981ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
198217824406SJunyan He  libpmem         libpmem support
198375411919SJames Le Cuirot  xkbcommon       xkbcommon support
1984b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
198521b2eca6SJingqi Liu  libdaxctl       libdaxctl support
198608fb77edSStefan Weil
198708fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1988af5db58eSpbrookEOF
19892d2ad6d0SFam Zhengexit 0
1990af5db58eSpbrookfi
1991af5db58eSpbrook
19929c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
1993bb768f71SThomas Huthrm -f */config-devices.mak.d
19949c790242SThomas Huth
19954d6a835dSLaurent Vivier# Remove syscall_nr.h to be sure they will be regenerated in the build
19964d6a835dSLaurent Vivier# directory, not in the source directory
1997bb0cdc03SLaurent Vivierfor arch in alpha hppa m68k xtensa sh4 microblaze arm ppc s390x sparc sparc64 \
1998686a0fe4SLaurent Vivier    i386 x86_64 mips mips64 ; do
19994d6a835dSLaurent Vivier    # remove the file if it has been generated in the source directory
20004d6a835dSLaurent Vivier    rm -f "${source_path}/linux-user/${arch}/syscall_nr.h"
20014d6a835dSLaurent Vivier    # remove the dependency files
200291e5998fSLaurent Vivier    for target in ${arch}*-linux-user ; do
200391e5998fSLaurent Vivier        test -d "${target}" && find "${target}" -type f -name "*.d" \
20044d6a835dSLaurent Vivier             -exec grep -q "${source_path}/linux-user/${arch}/syscall_nr.h" {} \; \
200591e5998fSLaurent Vivier             -print | while read file ; do rm "${file}" "${file%.d}.o" ; done
200691e5998fSLaurent Vivier    done
20074d6a835dSLaurent Vivierdone
20084d6a835dSLaurent Vivier
2009faf44142SDaniel P. Berrangéif test -z "$python"
2010faf44142SDaniel P. Berrangéthen
2011c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
2012c53eeaf7SStefan Hajnoczifi
2013c53eeaf7SStefan Hajnoczi
2014c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
2015c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
2016ddf90699SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (3,5))'; then
2017ddf90699SEduardo Habkost  error_exit "Cannot use '$python', Python >= 3.5 is required." \
2018c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
2019c53eeaf7SStefan Hajnoczifi
2020c53eeaf7SStefan Hajnoczi
2021755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
2022406ab2f3SCleber 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)
2023755ee70fSCleber Rosa
2024c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
2025c53eeaf7SStefan Hajnoczipython="$python -B"
2026c53eeaf7SStefan Hajnoczi
20270a01d76fSMarc-André Lureauif test -z "$meson"; then
20280a01d76fSMarc-André Lureau    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.0; then
20290a01d76fSMarc-André Lureau        meson=meson
20300a01d76fSMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
20310a01d76fSMarc-André Lureau        meson=git
20320a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
20330a01d76fSMarc-André Lureau        meson=internal
20340a01d76fSMarc-André Lureau    else
20350a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
20360a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
20370a01d76fSMarc-André Lureau        else
2038a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
2039a5665051SPaolo Bonzini        fi
20400a01d76fSMarc-André Lureau    fi
20410a01d76fSMarc-André Lureauelse
20420a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
20430a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
20440a01d76fSMarc-André Lureau    #
20450a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
20460a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
20470a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
20480a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
20490a01d76fSMarc-André Lureau        case "$meson" in
20500a01d76fSMarc-André Lureau            git | internal) ;;
20510a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
20520a01d76fSMarc-André Lureau        esac
20530a01d76fSMarc-André Lureau    fi
20540a01d76fSMarc-André Lureaufi
2055a5665051SPaolo Bonzini
20560a01d76fSMarc-André Lureauif test "$meson" = git; then
20570a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
20580a01d76fSMarc-André Lureaufi
20590a01d76fSMarc-André Lureauif test "$git_update" = yes; then
20600a01d76fSMarc-André Lureau    (cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
20610a01d76fSMarc-André Lureaufi
20620a01d76fSMarc-André Lureau
20630a01d76fSMarc-André Lureaucase "$meson" in
20640a01d76fSMarc-André Lureau    git | internal)
2065a5665051SPaolo Bonzini        if ! $python -c 'import pkg_resources' > /dev/null 2>&1; then
2066a5665051SPaolo Bonzini            error_exit "Python setuptools not found"
2067a5665051SPaolo Bonzini        fi
20680a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20690a01d76fSMarc-André Lureau        ;;
20700a01d76fSMarc-André Lureau    *) meson=$(command -v meson) ;;
20710a01d76fSMarc-André Lureauesac
20720a01d76fSMarc-André Lureau
2073a5665051SPaolo Bonzini
20749aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20759aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20769aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20779aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20789aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20799aae6e54SDaniel Henrique Barbozaif compile_object ; then
20809aae6e54SDaniel Henrique Barboza  : C compiler works ok
20819aae6e54SDaniel Henrique Barbozaelse
20829aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20839aae6e54SDaniel Henrique Barbozafi
20849aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20859aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20869aae6e54SDaniel Henrique Barbozafi
20879aae6e54SDaniel Henrique Barboza
2088359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
2089359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
2090359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
2091359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
2092359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
2093359bc95dSPeter Maydell    else
209476ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
2095359bc95dSPeter Maydell    fi
2096359bc95dSPeter Maydellfi
2097359bc95dSPeter Maydell
20989c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
20999c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
21009c83ffd8SPeter Maydellif test -z "$werror" ; then
2101fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
2102e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
21039c83ffd8SPeter Maydell        werror="yes"
21049c83ffd8SPeter Maydell    else
21059c83ffd8SPeter Maydell        werror="no"
21069c83ffd8SPeter Maydell    fi
21079c83ffd8SPeter Maydellfi
21089c83ffd8SPeter Maydell
2109fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
2110fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2111fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2112fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2113fb59dabdSPeter Maydell    # host OS we should stop now.
2114951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2115fb59dabdSPeter Maydellfi
2116fb59dabdSPeter Maydell
2117efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2118efc6c070SThomas Huthcat > $TMPC << EOF
2119efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2120efc6c070SThomas Huth# ifdef __apple_build_version__
2121efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
2122efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
2123efc6c070SThomas Huth#  endif
2124efc6c070SThomas Huth# else
2125efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
2126efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
2127efc6c070SThomas Huth#  endif
2128efc6c070SThomas Huth# endif
2129efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2130efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
2131efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
2132efc6c070SThomas Huth# endif
2133efc6c070SThomas Huth#else
2134efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2135efc6c070SThomas Huth#endif
2136efc6c070SThomas Huthint main (void) { return 0; }
2137efc6c070SThomas HuthEOF
2138efc6c070SThomas Huthif ! compile_prog "" "" ; then
2139efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2140efc6c070SThomas Huthfi
2141efc6c070SThomas Huth
214200849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
214300849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
214400849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
214500849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
214600849b92SRichard Henderson# just silently disable some features, so it's too error prone.
214700849b92SRichard Henderson
214800849b92SRichard Hendersonwarn_flags=
214900849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
215000849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
215100849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
215200849b92SRichard Hendersonadd_to warn_flags -Wformat-security
215300849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
215400849b92SRichard Hendersonadd_to warn_flags -Winit-self
215500849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
215600849b92SRichard Hendersonadd_to warn_flags -Wempty-body
215700849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
215800849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
215900849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
216000849b92SRichard Henderson
216100849b92SRichard Hendersonnowarn_flags=
216200849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
216300849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
216400849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
216500849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
216600849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2167aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2168bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
216900849b92SRichard Henderson
217000849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
217193b25869SJohn Snow
217293b25869SJohn Snowcc_has_warning_flag() {
217393b25869SJohn Snow    write_c_skeleton;
217493b25869SJohn Snow
2175a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2176a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2177a1d29d6cSPeter Maydell    # warning options).
217893b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
217993b25869SJohn Snow    compile_prog "-Werror $optflag" ""
218093b25869SJohn Snow}
218193b25869SJohn Snow
218293b25869SJohn Snowfor flag in $gcc_flags; do
218393b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21848d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21858d05095cSPaolo Bonzini    fi
21868d05095cSPaolo Bonzinidone
21878d05095cSPaolo Bonzini
218863678e17SSteven Noonanif test "$stack_protector" != "no"; then
2189fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2190fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2191fccd35a0SRodrigo Rebello{
2192fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2193fccd35a0SRodrigo Rebello    while (*c) {
2194fccd35a0SRodrigo Rebello        *p++ = *c++;
2195fccd35a0SRodrigo Rebello    }
2196fccd35a0SRodrigo Rebello    return 0;
2197fccd35a0SRodrigo Rebello}
2198fccd35a0SRodrigo RebelloEOF
219963678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
22003b463a3fSMiroslav Rezanina  sp_on=0
220163678e17SSteven Noonan  for flag in $gcc_flags; do
2202590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2203590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2204086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2205590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
220663678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2207db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
22083b463a3fSMiroslav Rezanina      sp_on=1
220963678e17SSteven Noonan      break
221063678e17SSteven Noonan    fi
221163678e17SSteven Noonan  done
22123b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
22133b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
22143b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
22153b463a3fSMiroslav Rezanina    fi
22163b463a3fSMiroslav Rezanina  fi
221737746c5eSMarc-André Lureaufi
221837746c5eSMarc-André Lureau
221920bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
222020bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
222120bc94a2SPaolo Bonzinicat > $TMPC << EOF
222220bc94a2SPaolo Bonzinistruct {
222320bc94a2SPaolo Bonzini  int a[2];
222420bc94a2SPaolo Bonzini} x = {0};
222520bc94a2SPaolo BonziniEOF
222620bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
222720bc94a2SPaolo Bonzini  :
222820bc94a2SPaolo Bonzinielse
222920bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
223020bc94a2SPaolo Bonzinifi
223120bc94a2SPaolo Bonzini
223221e709aaSMarc-André Lureau# Our module code doesn't support Windows
223321e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
223421e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
223521e709aaSMarc-André Lureaufi
223621e709aaSMarc-André Lureau
2237bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2238bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2239bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2240bd83c861SChristian Ehrhardtfi
2241bd83c861SChristian Ehrhardt
2242d376e9deSThomas Huth# Static linking is not possible with modules or PIE
224340d6444eSAvi Kivityif test "$static" = "yes" ; then
2244aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2245aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2246aa0d1f44SPaolo Bonzini  fi
224740d6444eSAvi Kivityfi
224840d6444eSAvi Kivity
2249768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2250768b7855SEmilio G. Cota  cat > $TMPC << EOF
2251768b7855SEmilio G. Cotastatic __thread int tls_var;
2252768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2253768b7855SEmilio G. CotaEOF
2254768b7855SEmilio G. Cota
2255768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2256768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2257768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2258768b7855SEmilio G. Cotafi
2259768b7855SEmilio G. Cota
226040d6444eSAvi Kivitycat > $TMPC << EOF
226121d4a791SAvi Kivity
226221d4a791SAvi Kivity#ifdef __linux__
226321d4a791SAvi Kivity#  define THREAD __thread
226421d4a791SAvi Kivity#else
226521d4a791SAvi Kivity#  define THREAD
226621d4a791SAvi Kivity#endif
226721d4a791SAvi Kivitystatic THREAD int tls_var;
226821d4a791SAvi Kivityint main(void) { return tls_var; }
226940d6444eSAvi KivityEOF
2270b2634124SRichard Henderson
2271b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2272412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2273412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2274b2634124SRichard Henderson  LDFLAGS_NOPIE="-no-pie"
2275412aeacdSAlex Bennéefi
2276412aeacdSAlex Bennée
227712781462SRichard Hendersonif test "$static" = "yes"; then
2278eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
2279086d5f75SPaolo Bonzini    CFLAGS="-fPIE -DPIE $CFLAGS"
228012781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
228112781462SRichard Henderson    pie="yes"
228212781462SRichard Henderson  elif test "$pie" = "yes"; then
228312781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
228412781462SRichard Henderson  else
228512781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
228612781462SRichard Henderson    pie="no"
228712781462SRichard Henderson  fi
228812781462SRichard Hendersonelif test "$pie" = "no"; then
2289086d5f75SPaolo Bonzini  CFLAGS="$CFLAGS_NOPIE $CFLAGS"
2290086d5f75SPaolo Bonzini  LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
2291eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
2292086d5f75SPaolo Bonzini  CFLAGS="-fPIE -DPIE $CFLAGS"
2293086d5f75SPaolo Bonzini  LDFLAGS="-pie $LDFLAGS"
229440d6444eSAvi Kivity  pie="yes"
22952c674109SRichard Hendersonelif test "$pie" = "yes"; then
229676ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
229740d6444eSAvi Kivityelse
229840d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
229940d6444eSAvi Kivity  pie="no"
230040d6444eSAvi Kivityfi
230140d6444eSAvi Kivity
2302e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2303e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2304e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2305e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2306e6cbd751SRichard Hendersonfi
2307e6cbd751SRichard Henderson
230809dada40SPaolo Bonzini##########################################
230909dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
231009dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
231109dada40SPaolo Bonzini# specification is necessary
231209dada40SPaolo Bonzini
231309dada40SPaolo Bonziniif test "$cpu" = "i386"; then
231409dada40SPaolo Bonzini  cat > $TMPC << EOF
231509dada40SPaolo Bonzinistatic int sfaa(int *ptr)
231609dada40SPaolo Bonzini{
231709dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
231809dada40SPaolo Bonzini}
231909dada40SPaolo Bonzini
232009dada40SPaolo Bonziniint main(void)
232109dada40SPaolo Bonzini{
232209dada40SPaolo Bonzini  int val = 42;
23231405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
232409dada40SPaolo Bonzini  sfaa(&val);
232509dada40SPaolo Bonzini  return val;
232609dada40SPaolo Bonzini}
232709dada40SPaolo BonziniEOF
232809dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
232909dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
233009dada40SPaolo Bonzini  fi
233109dada40SPaolo Bonzinifi
233209dada40SPaolo Bonzini
233309dada40SPaolo Bonzini#########################################
2334ec530c81Sbellard# Solaris specific configure tool chain decisions
233509dada40SPaolo Bonzini
2336ec530c81Sbellardif test "$solaris" = "yes" ; then
23376792aa11SLoïc Minier  if has $install; then
23386792aa11SLoïc Minier    :
23396792aa11SLoïc Minier  else
234076ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
234176ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
234276ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2343ec530c81Sbellard  fi
234489138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
234576ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
234676ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
234776ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2348ec530c81Sbellard  fi
23496792aa11SLoïc Minier  if has ar; then
23506792aa11SLoïc Minier    :
23516792aa11SLoïc Minier  else
2352ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
235376ad07a4SPeter Maydell      error_exit "No path includes ar" \
235476ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2355ec530c81Sbellard    fi
235676ad07a4SPeter Maydell    error_exit "No path includes ar"
2357ec530c81Sbellard  fi
2358ec530c81Sbellardfi
2359ec530c81Sbellard
2360afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2361d880a3baSPaolo Bonzini    for target in $default_target_list; do
2362d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2363d880a3baSPaolo Bonzini            target_list="$target_list $target"
2364d880a3baSPaolo Bonzini    done
2365d880a3baSPaolo Bonzini    target_list="${target_list# }"
2366121afa9eSAnthony Liguorielse
236789138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2368d880a3baSPaolo Bonzini    for target in $target_list; do
236925b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
237025b48338SPeter Maydell        # friendly error message than if we let it fall through.
237125b48338SPeter Maydell        case " $default_target_list " in
237225b48338SPeter Maydell            *" $target "*)
237325b48338SPeter Maydell                ;;
237425b48338SPeter Maydell            *)
237525b48338SPeter Maydell                error_exit "Unknown target name '$target'"
237625b48338SPeter Maydell                ;;
237725b48338SPeter Maydell        esac
2378d880a3baSPaolo Bonzini        supported_target $target || exit 1
237925b48338SPeter Maydell    done
2380d880a3baSPaolo Bonzinifi
238125b48338SPeter Maydell
2382f55fe278SPaolo Bonzini# see if system emulation was really requested
2383f55fe278SPaolo Bonzinicase " $target_list " in
2384f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2385f55fe278SPaolo Bonzini  ;;
2386f55fe278SPaolo Bonzini  *) softmmu=no
2387f55fe278SPaolo Bonzini  ;;
2388f55fe278SPaolo Bonziniesac
23895327cf48Sbellard
239005dfa22bSPhilippe Mathieu-Daudéfor target in $target_list; do
239105dfa22bSPhilippe Mathieu-Daudé  case "$target" in
239205dfa22bSPhilippe Mathieu-Daudé    arm-softmmu | aarch64-softmmu | i386-softmmu | x86_64-softmmu)
239305dfa22bSPhilippe Mathieu-Daudé      edk2_blobs="yes"
239405dfa22bSPhilippe Mathieu-Daudé      ;;
239505dfa22bSPhilippe Mathieu-Daudé  esac
239605dfa22bSPhilippe Mathieu-Daudédone
2397623ef637SPhilippe Mathieu-Daudé# The EDK2 binaries are compressed with bzip2
2398623ef637SPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" && ! has bzip2; then
2399623ef637SPhilippe Mathieu-Daudé  error_exit "The bzip2 program is required for building QEMU"
2400623ef637SPhilippe Mathieu-Daudéfi
240105dfa22bSPhilippe Mathieu-Daudé
2402249247c9SJuan Quintelafeature_not_found() {
2403249247c9SJuan Quintela  feature=$1
240421684af0SStewart Smith  remedy=$2
2405249247c9SJuan Quintela
240676ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
240721684af0SStewart Smith      "configure was not able to find it." \
240821684af0SStewart Smith      "$remedy"
2409249247c9SJuan Quintela}
2410249247c9SJuan Quintela
24117d13299dSbellard# ---
24127d13299dSbellard# big/little endian test
24137d13299dSbellardcat > $TMPC << EOF
241461cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
241561cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
241661cc919fSMike Frysingerextern int foo(short *, short *);
241761cc919fSMike Frysingerint main(int argc, char *argv[]) {
241861cc919fSMike Frysinger    return foo(big_endian, little_endian);
24197d13299dSbellard}
24207d13299dSbellardEOF
24217d13299dSbellard
242261cc919fSMike Frysingerif compile_object ; then
242312f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
242461cc919fSMike Frysinger        bigendian="yes"
242512f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
242661cc919fSMike Frysinger        bigendian="no"
24277d13299dSbellard    else
24287d13299dSbellard        echo big/little test failed
24297d13299dSbellard    fi
24307d13299dSbellardelse
243161cc919fSMike Frysinger    echo big/little test failed
24327d13299dSbellardfi
24337d13299dSbellard
2434b0a47e79SJuan Quintela##########################################
2435e10ee3f5SPhilippe Mathieu-Daudé# system tools
2436e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2437e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2438e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2439e10ee3f5SPhilippe Mathieu-Daudé    else
2440e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2441e10ee3f5SPhilippe Mathieu-Daudé    fi
2442e10ee3f5SPhilippe Mathieu-Daudéfi
2443e10ee3f5SPhilippe Mathieu-Daudé
2444e10ee3f5SPhilippe Mathieu-Daudé##########################################
2445a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2446a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2447a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2448a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2449a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2450a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2451a30878e7SPeter Maydell    fi
2452a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2453a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2454a30878e7SPeter Maydell    fi
2455a30878e7SPeter Maydell    gtk=no
2456a30878e7SPeter Maydell    sdl=no
2457a30878e7SPeter Maydellfi
2458a30878e7SPeter Maydell
24596b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
24606b39b063SEric Blakecat > $TMPC << EOF
24616b39b063SEric Blake#include <stdint.h>
24626b39b063SEric Blake#include <stdio.h>
24636b39b063SEric Blakeint main(int argc, char *argv[]) {
24646b39b063SEric Blake    return printf("%zu", SIZE_MAX);
24656b39b063SEric Blake}
24666b39b063SEric BlakeEOF
24676b39b063SEric Blakehave_broken_size_max=no
24686b39b063SEric Blakeif ! compile_object -Werror ; then
24696b39b063SEric Blake    have_broken_size_max=yes
24706b39b063SEric Blakefi
24716b39b063SEric Blake
2472a30878e7SPeter Maydell##########################################
2473015a33bdSGonglei# L2TPV3 probe
2474015a33bdSGonglei
2475015a33bdSGongleicat > $TMPC <<EOF
2476015a33bdSGonglei#include <sys/socket.h>
2477bff6cb72SMichael Tokarev#include <linux/ip.h>
2478015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2479015a33bdSGongleiEOF
2480015a33bdSGongleiif compile_prog "" "" ; then
2481015a33bdSGonglei  l2tpv3=yes
2482015a33bdSGongleielse
2483015a33bdSGonglei  l2tpv3=no
2484015a33bdSGongleifi
2485015a33bdSGonglei
2486c9c8b88fSDavid CARLIERif check_include "pty.h" ; then
2487c9c8b88fSDavid CARLIER  pty_h=yes
2488c9c8b88fSDavid CARLIERelse
2489c9c8b88fSDavid CARLIER  pty_h=no
2490c9c8b88fSDavid CARLIERfi
2491c9c8b88fSDavid CARLIER
2492195588ccSDavid CARLIERcat > $TMPC <<EOF
2493195588ccSDavid CARLIER#include <sys/mman.h>
2494195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2495195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2496195588ccSDavid CARLIER}
2497195588ccSDavid CARLIEREOF
2498195588ccSDavid CARLIERif compile_prog "" "" ; then
2499195588ccSDavid CARLIER  have_mlockall=yes
2500195588ccSDavid CARLIERelse
2501195588ccSDavid CARLIER  have_mlockall=no
2502195588ccSDavid CARLIERfi
2503195588ccSDavid CARLIER
2504299e6f19SPaolo Bonzini#########################################
2505299e6f19SPaolo Bonzini# vhost interdependencies and host support
2506299e6f19SPaolo Bonzini
2507299e6f19SPaolo Bonzini# vhost backends
2508299e6f19SPaolo Bonzinitest "$vhost_user" = "" && vhost_user=yes
2509299e6f19SPaolo Bonziniif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2510299e6f19SPaolo Bonzini  error_exit "vhost-user isn't available on win32"
2511299e6f19SPaolo Bonzinifi
2512108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2513108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2514108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2515108a6481SCindy Lufi
2516299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2517299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2518299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2519299e6f19SPaolo Bonzinifi
2520299e6f19SPaolo Bonzini
2521299e6f19SPaolo Bonzini# vhost-kernel devices
2522299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2523299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2524299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2525299e6f19SPaolo Bonzinifi
2526299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2527299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2528299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2529299e6f19SPaolo Bonzinifi
2530299e6f19SPaolo Bonzini
2531299e6f19SPaolo Bonzini# vhost-user backends
2532299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2533299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2534299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2535299e6f19SPaolo Bonzinifi
2536299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2537299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2538299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2539299e6f19SPaolo Bonzinifi
254098fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
254198fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
254298fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
254398fc1adaSDr. David Alan Gilbertfi
2544108a6481SCindy Lu#vhost-vdpa backends
2545108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2546108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2547108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2548108a6481SCindy Lufi
2549299e6f19SPaolo Bonzini
2550299e6f19SPaolo Bonzini# OR the vhost-kernel and vhost-user values for simplicity
2551299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2552299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
2553299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2554299e6f19SPaolo Bonzinifi
2555299e6f19SPaolo Bonzini
2556015a33bdSGonglei##########################################
25574d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
25584d9310f4SDaniel P. Berrange
25594d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
25604d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
25614d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
25624d9310f4SDaniel P. Berrange    #
25634d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
25644d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
25654d9310f4SDaniel P. Berrange    #
25664d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
25674d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
25684d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
25694d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
25704d9310f4SDaniel P. Berrange    # that for you.
25714d9310f4SDaniel P. Berrange    #
25724d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
25734d9310f4SDaniel P. Berrange    # are not in fact redundant.
25744d9310f4SDaniel P. Berrangecat > $TMPC << EOF
25754d9310f4SDaniel P. Berrange#include <unistd.h>
25764d9310f4SDaniel P. Berrange#include <time.h>
25774d9310f4SDaniel P. Berrange#undef localtime_r
25784d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
25794d9310f4SDaniel P. BerrangeEOF
25804d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
25814d9310f4SDaniel P. Berrange        localtime_r="yes"
25824d9310f4SDaniel P. Berrange    else
25834d9310f4SDaniel P. Berrange        localtime_r="no"
25844d9310f4SDaniel P. Berrange    fi
25854d9310f4SDaniel P. Berrangefi
25864d9310f4SDaniel P. Berrange
25874d9310f4SDaniel P. Berrange##########################################
2588779ab5e3SStefan Weil# pkg-config probe
2589779ab5e3SStefan Weil
2590779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
259176ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2592779ab5e3SStefan Weilfi
2593779ab5e3SStefan Weil
2594779ab5e3SStefan Weil##########################################
2595b0a47e79SJuan Quintela# NPTL probe
2596b0a47e79SJuan Quintela
259724cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2598bd0c5661Spbrook  cat > $TMPC <<EOF
2599bd0c5661Spbrook#include <sched.h>
260030813ceaSpbrook#include <linux/futex.h>
2601182eacc0SStefan Weilint main(void) {
2602bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2603bd0c5661Spbrook#error bork
2604bd0c5661Spbrook#endif
2605182eacc0SStefan Weil  return 0;
2606bd0c5661Spbrook}
2607bd0c5661SpbrookEOF
260824cb36a6SPeter Maydell  if ! compile_object ; then
260921684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2610b0a47e79SJuan Quintela  fi
2611bd0c5661Spbrookfi
2612bd0c5661Spbrook
2613ac62922eSbalrog##########################################
2614607dacd0Sqiaonuohan# lzo check
2615607dacd0Sqiaonuohan
2616607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2617607dacd0Sqiaonuohan    cat > $TMPC << EOF
2618607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2619607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2620607dacd0SqiaonuohanEOF
2621607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2622607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -llzo2"
2623708eab42SMarc-André Lureau        lzo_libs="-llzo2"
2624b25c9dffSStefan Weil        lzo="yes"
2625b25c9dffSStefan Weil    else
2626b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2627b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2628b25c9dffSStefan Weil        fi
2629b25c9dffSStefan Weil        lzo="no"
2630b25c9dffSStefan Weil    fi
2631607dacd0Sqiaonuohanfi
2632607dacd0Sqiaonuohan
2633607dacd0Sqiaonuohan##########################################
2634607dacd0Sqiaonuohan# snappy check
2635607dacd0Sqiaonuohan
2636607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2637607dacd0Sqiaonuohan    cat > $TMPC << EOF
2638607dacd0Sqiaonuohan#include <snappy-c.h>
2639607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2640607dacd0SqiaonuohanEOF
2641607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2642607dacd0Sqiaonuohan        libs_softmmu="$libs_softmmu -lsnappy"
2643708eab42SMarc-André Lureau        snappy_libs='-lsnappy'
2644b25c9dffSStefan Weil        snappy="yes"
2645b25c9dffSStefan Weil    else
2646b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2647b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2648b25c9dffSStefan Weil        fi
2649b25c9dffSStefan Weil        snappy="no"
2650b25c9dffSStefan Weil    fi
2651607dacd0Sqiaonuohanfi
2652607dacd0Sqiaonuohan
2653607dacd0Sqiaonuohan##########################################
26546b383c08SPeter Wu# bzip2 check
26556b383c08SPeter Wu
26566b383c08SPeter Wuif test "$bzip2" != "no" ; then
26576b383c08SPeter Wu    cat > $TMPC << EOF
26586b383c08SPeter Wu#include <bzlib.h>
26596b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
26606b383c08SPeter WuEOF
26616b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
26626b383c08SPeter Wu        bzip2="yes"
26636b383c08SPeter Wu    else
26646b383c08SPeter Wu        if test "$bzip2" = "yes"; then
26656b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
26666b383c08SPeter Wu        fi
26676b383c08SPeter Wu        bzip2="no"
26686b383c08SPeter Wu    fi
26696b383c08SPeter Wufi
26706b383c08SPeter Wu
26716b383c08SPeter Wu##########################################
267283bc1f97SJulio Faracco# lzfse check
267383bc1f97SJulio Faracco
267483bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
267583bc1f97SJulio Faracco    cat > $TMPC << EOF
267683bc1f97SJulio Faracco#include <lzfse.h>
267783bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
267883bc1f97SJulio FaraccoEOF
267983bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
268083bc1f97SJulio Faracco        lzfse="yes"
268183bc1f97SJulio Faracco    else
268283bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
268383bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
268483bc1f97SJulio Faracco        fi
268583bc1f97SJulio Faracco        lzfse="no"
268683bc1f97SJulio Faracco    fi
268783bc1f97SJulio Faraccofi
268883bc1f97SJulio Faracco
268983bc1f97SJulio Faracco##########################################
26903a678481SJuan Quintela# zstd check
26913a678481SJuan Quintela
26923a678481SJuan Quintelaif test "$zstd" != "no" ; then
2693297254c7SJuan Quintela    libzstd_minver="1.4.0"
2694297254c7SJuan Quintela    if $pkg_config --atleast-version=$libzstd_minver libzstd ; then
26953a678481SJuan Quintela        zstd_cflags="$($pkg_config --cflags libzstd)"
26963a678481SJuan Quintela        zstd_libs="$($pkg_config --libs libzstd)"
26973a678481SJuan Quintela        zstd="yes"
26983a678481SJuan Quintela    else
26993a678481SJuan Quintela        if test "$zstd" = "yes" ; then
27003a678481SJuan Quintela            feature_not_found "libzstd" "Install libzstd devel"
27013a678481SJuan Quintela        fi
27023a678481SJuan Quintela        zstd="no"
27033a678481SJuan Quintela    fi
27043a678481SJuan Quintelafi
27053a678481SJuan Quintela
27063a678481SJuan Quintela##########################################
2707f794573eSEduardo Otubo# libseccomp check
2708f794573eSEduardo Otubo
2709f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
27103e684455SMichael Strosaker    libseccomp_minver="2.3.0"
271125ed0eccSHelge Deller    if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2712c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2713c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2714f794573eSEduardo Otubo        seccomp="yes"
2715f794573eSEduardo Otubo    else
2716f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2717693e5910SAndrew Jones            feature_not_found "libseccomp" \
2718693e5910SAndrew Jones                 "Install libseccomp devel >= $libseccomp_minver"
2719896848f0SEduardo Otubo        fi
2720e84d5956SYann E. MORIN        seccomp="no"
2721f794573eSEduardo Otubo    fi
2722f794573eSEduardo Otubofi
2723f794573eSEduardo Otubo##########################################
2724e37630caSaliguori# xen probe
2725e37630caSaliguori
2726fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2727c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2728c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2729c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2730c1cdd9d5SJuergen Gross
2731c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2732c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2733c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2734c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2735c1cdd9d5SJuergen Gross    xen=yes
2736c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2737c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
273858ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
273958ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
274058ea9a7aSAnthony PERARD    fi
2741c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2742c1cdd9d5SJuergen Gross    libs_softmmu="$($pkg_config --libs $xen_pc) $libs_softmmu"
2743c1cdd9d5SJuergen Gross  else
2744c1cdd9d5SJuergen Gross
2745b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2746d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2747d5b93ddfSAnthony PERARD
274850ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
274950ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
275050ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
275150ced5b3SStefan Weil
275250ced5b3SStefan Weil    # Xen (any)
275350ced5b3SStefan Weil    cat > $TMPC <<EOF
275450ced5b3SStefan Weil#include <xenctrl.h>
275550ced5b3SStefan Weilint main(void) {
275650ced5b3SStefan Weil  return 0;
275750ced5b3SStefan Weil}
275850ced5b3SStefan WeilEOF
275950ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
276050ced5b3SStefan Weil      # Xen not found
276150ced5b3SStefan Weil      if test "$xen" = "yes" ; then
276221684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
276350ced5b3SStefan Weil      fi
276450ced5b3SStefan Weil      xen=no
276550ced5b3SStefan Weil
2766d5b93ddfSAnthony PERARD    # Xen unstable
276769deef08SPeter Maydell    elif
276869deef08SPeter Maydell        cat > $TMPC <<EOF &&
27692cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
27702cbf8903SRoss Lagerwall#define __XEN_TOOLS__
27712cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2772d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
27732cbf8903SRoss Lagerwallint main(void) {
27742cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2775d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
27762cbf8903SRoss Lagerwall
27772cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
27782cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
27792cbf8903SRoss Lagerwall
2780d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2781d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2782d3c49ebbSPaul Durrant
27832cbf8903SRoss Lagerwall  return 0;
27842cbf8903SRoss Lagerwall}
27852cbf8903SRoss LagerwallEOF
27862cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
27872cbf8903SRoss Lagerwall      then
27882cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
27892cbf8903SRoss Lagerwall      xen_ctrl_version=41100
27902cbf8903SRoss Lagerwall      xen=yes
27912cbf8903SRoss Lagerwall    elif
27922cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
27935ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
27945ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
279558ea9a7aSAnthony PERARD#include <xentoolcore.h>
27965ba3d756SIgor Druzhininint main(void) {
27975ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
27985ba3d756SIgor Druzhinin
27995ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
28005ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
280158ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
28025ba3d756SIgor Druzhinin
28035ba3d756SIgor Druzhinin  return 0;
28045ba3d756SIgor Druzhinin}
28055ba3d756SIgor DruzhininEOF
280658ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
28075ba3d756SIgor Druzhinin      then
280858ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
28095ba3d756SIgor Druzhinin      xen_ctrl_version=41000
28105ba3d756SIgor Druzhinin      xen=yes
28115ba3d756SIgor Druzhinin    elif
28125ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2813da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2814da8090ccSPaul Durrant#define __XEN_TOOLS__
2815da8090ccSPaul Durrant#include <xendevicemodel.h>
2816da8090ccSPaul Durrantint main(void) {
2817da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2818da8090ccSPaul Durrant
2819da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2820da8090ccSPaul Durrant  xendevicemodel_close(xd);
2821da8090ccSPaul Durrant
2822da8090ccSPaul Durrant  return 0;
2823da8090ccSPaul Durrant}
2824da8090ccSPaul DurrantEOF
2825da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2826da8090ccSPaul Durrant      then
2827da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2828f1167ee6SJuergen Gross      xen_ctrl_version=40900
2829da8090ccSPaul Durrant      xen=yes
2830da8090ccSPaul Durrant    elif
2831da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
28325eeb39c2SIan Campbell/*
28335eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
28345eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2835b6eb9b45SPaulina Szubarczyk *
2836b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2837b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2838b6eb9b45SPaulina Szubarczyk */
2839b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2840b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2841b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2842b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2843b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2844b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2845b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2846b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2847b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2848b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2849b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2850b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2851b6eb9b45SPaulina Szubarczyk#endif
2852b6eb9b45SPaulina Szubarczykint main(void) {
2853b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2854b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2855b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2856b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2857b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2858b6eb9b45SPaulina Szubarczyk
2859b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2860b6eb9b45SPaulina Szubarczyk
2861b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2862b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2863b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2864b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2865b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2866b6eb9b45SPaulina Szubarczyk
2867b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2868b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2869b6eb9b45SPaulina Szubarczyk
2870b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2871b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2872b6eb9b45SPaulina Szubarczyk
2873b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2874b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2875b6eb9b45SPaulina Szubarczyk
2876b6eb9b45SPaulina Szubarczyk  return 0;
2877b6eb9b45SPaulina Szubarczyk}
2878b6eb9b45SPaulina SzubarczykEOF
2879b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2880b6eb9b45SPaulina Szubarczyk      then
2881f1167ee6SJuergen Gross      xen_ctrl_version=40800
2882b6eb9b45SPaulina Szubarczyk      xen=yes
2883b6eb9b45SPaulina Szubarczyk    elif
2884b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2885b6eb9b45SPaulina Szubarczyk/*
2886b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2887b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
28885eeb39c2SIan Campbell */
28895eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
28905eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
28915eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
28925eeb39c2SIan Campbell#include <xenctrl.h>
28935eeb39c2SIan Campbell#include <xenstore.h>
28945eeb39c2SIan Campbell#include <xenevtchn.h>
28955eeb39c2SIan Campbell#include <xengnttab.h>
28965eeb39c2SIan Campbell#include <xenforeignmemory.h>
28975eeb39c2SIan Campbell#include <stdint.h>
28985eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
28995eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
29005eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
29015eeb39c2SIan Campbell#endif
29025eeb39c2SIan Campbellint main(void) {
29035eeb39c2SIan Campbell  xc_interface *xc = NULL;
29045eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
29055eeb39c2SIan Campbell  xenevtchn_handle *xe;
29065eeb39c2SIan Campbell  xengnttab_handle *xg;
29075eeb39c2SIan Campbell
29085eeb39c2SIan Campbell  xs_daemon_open();
29095eeb39c2SIan Campbell
29105eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
29115eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
29125eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29135eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29145eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
29155eeb39c2SIan Campbell
29165eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
29175eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
29185eeb39c2SIan Campbell
29195eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
29205eeb39c2SIan Campbell  xenevtchn_fd(xe);
29215eeb39c2SIan Campbell
29225eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
29235eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
29245eeb39c2SIan Campbell
29255eeb39c2SIan Campbell  return 0;
29265eeb39c2SIan Campbell}
29275eeb39c2SIan CampbellEOF
29285eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
29295eeb39c2SIan Campbell      then
2930f1167ee6SJuergen Gross      xen_ctrl_version=40701
29315eeb39c2SIan Campbell      xen=yes
2932cdadde39SRoger Pau Monne
2933cdadde39SRoger Pau Monne    # Xen 4.6
2934cdadde39SRoger Pau Monne    elif
2935cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2936cdadde39SRoger Pau Monne#include <xenctrl.h>
2937e108a3c1SAnthony PERARD#include <xenstore.h>
2938d5b93ddfSAnthony PERARD#include <stdint.h>
2939d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2940d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2941d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2942d5b93ddfSAnthony PERARD#endif
2943d5b93ddfSAnthony PERARDint main(void) {
2944d5b93ddfSAnthony PERARD  xc_interface *xc;
2945d5b93ddfSAnthony PERARD  xs_daemon_open();
2946d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2947d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2948d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2949b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29508688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2951d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
295220a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2953d8b441a3SJan Beulich  return 0;
2954d8b441a3SJan Beulich}
2955d8b441a3SJan BeulichEOF
2956d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2957d8b441a3SJan Beulich      then
2958f1167ee6SJuergen Gross      xen_ctrl_version=40600
2959d8b441a3SJan Beulich      xen=yes
2960d8b441a3SJan Beulich
2961d8b441a3SJan Beulich    # Xen 4.5
2962d8b441a3SJan Beulich    elif
2963d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2964d8b441a3SJan Beulich#include <xenctrl.h>
2965d8b441a3SJan Beulich#include <xenstore.h>
2966d8b441a3SJan Beulich#include <stdint.h>
2967d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2968d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2969d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2970d8b441a3SJan Beulich#endif
2971d8b441a3SJan Beulichint main(void) {
2972d8b441a3SJan Beulich  xc_interface *xc;
2973d8b441a3SJan Beulich  xs_daemon_open();
2974d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2975d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2976d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2977d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2978d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29793996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
29803996e85cSPaul Durrant  return 0;
29813996e85cSPaul Durrant}
29823996e85cSPaul DurrantEOF
29833996e85cSPaul Durrant        compile_prog "" "$xen_libs"
29843996e85cSPaul Durrant      then
2985f1167ee6SJuergen Gross      xen_ctrl_version=40500
29863996e85cSPaul Durrant      xen=yes
29873996e85cSPaul Durrant
29883996e85cSPaul Durrant    elif
29893996e85cSPaul Durrant        cat > $TMPC <<EOF &&
29903996e85cSPaul Durrant#include <xenctrl.h>
29913996e85cSPaul Durrant#include <xenstore.h>
29923996e85cSPaul Durrant#include <stdint.h>
29933996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
29943996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
29953996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
29963996e85cSPaul Durrant#endif
29973996e85cSPaul Durrantint main(void) {
29983996e85cSPaul Durrant  xc_interface *xc;
29993996e85cSPaul Durrant  xs_daemon_open();
30003996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
30013996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
30023996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
30033996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
30043996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
30058688e065SStefano Stabellini  return 0;
30068688e065SStefano Stabellini}
30078688e065SStefano StabelliniEOF
30088688e065SStefano Stabellini        compile_prog "" "$xen_libs"
300969deef08SPeter Maydell      then
3010f1167ee6SJuergen Gross      xen_ctrl_version=40200
30118688e065SStefano Stabellini      xen=yes
30128688e065SStefano Stabellini
3013e37630caSaliguori    else
3014fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
3015edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
3016edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
3017fc321b4bSJuan Quintela      fi
3018fc321b4bSJuan Quintela      xen=no
3019e37630caSaliguori    fi
3020d5b93ddfSAnthony PERARD
3021d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
3022f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
30235eeb39c2SIan Campbell        libs_softmmu="$xen_stable_libs $libs_softmmu"
30245eeb39c2SIan Campbell      fi
3025d5b93ddfSAnthony PERARD      libs_softmmu="$xen_libs $libs_softmmu"
3026d5b93ddfSAnthony PERARD    fi
3027e37630caSaliguori  fi
3028c1cdd9d5SJuergen Grossfi
3029e37630caSaliguori
3030eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
3031edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
3032eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
3033eb6fda0fSAnthony PERARD  else
3034eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
303576ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
303676ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
3037eb6fda0fSAnthony PERARD    fi
3038eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
3039eb6fda0fSAnthony PERARD  fi
3040eb6fda0fSAnthony PERARDfi
3041eb6fda0fSAnthony PERARD
3042e37630caSaliguori##########################################
3043d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
3044d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
3045327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
3046d661d9a4SJustin Terry (VM)        whpx="yes"
3047d661d9a4SJustin Terry (VM)    else
3048d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
304953537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
3050d661d9a4SJustin Terry (VM)        fi
3051d661d9a4SJustin Terry (VM)        whpx="no"
3052d661d9a4SJustin Terry (VM)    fi
3053d661d9a4SJustin Terry (VM)fi
3054d661d9a4SJustin Terry (VM)
3055d661d9a4SJustin Terry (VM)##########################################
3056dfffc653SJuan Quintela# Sparse probe
3057dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
3058968b4db3SPaolo Bonzini  if has sparse; then
3059dfffc653SJuan Quintela    sparse=yes
3060dfffc653SJuan Quintela  else
3061dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
306221684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
3063dfffc653SJuan Quintela    fi
3064dfffc653SJuan Quintela    sparse=no
3065dfffc653SJuan Quintela  fi
3066dfffc653SJuan Quintelafi
3067dfffc653SJuan Quintela
3068dfffc653SJuan Quintela##########################################
3069f676c67eSJeremy White# X11 probe
3070f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
30718781595bSGerd Hoffmann    have_x11=yes
307289138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
307389138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
3074f676c67eSJeremy Whitefi
3075f676c67eSJeremy White
3076f676c67eSJeremy White##########################################
3077a4ccabcfSAnthony Liguori# GTK probe
3078a4ccabcfSAnthony Liguori
30795a464e6cSPeter Xuif test "$gtk" != "no"; then
308089d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
308189d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
30827b23d121SVolker Rümelin    gtkversion="3.22.0"
3083bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
308489138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
308589138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
308689138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
30870a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
30888781595bSGerd Hoffmann            need_x11=yes
3089f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
3090f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
30910a337ed0SGerd Hoffmann        fi
3092bbbf9bfbSStefan Weil        gtk="yes"
3093bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
30945fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
3095bbbf9bfbSStefan Weil    else
3096bbbf9bfbSStefan Weil        gtk="no"
3097bbbf9bfbSStefan Weil    fi
3098bbbf9bfbSStefan Weilfi
3099bbbf9bfbSStefan Weil
3100ddbb0d09SDaniel P. Berrange
3101ddbb0d09SDaniel P. Berrange##########################################
3102ddbb0d09SDaniel P. Berrange# GNUTLS probe
3103ddbb0d09SDaniel P. Berrange
3104ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
3105a73e82efSRichard Henderson    pass="no"
3106a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
310789138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
310889138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
3109a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
3110a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
3111a73e82efSRichard Henderson        write_c_skeleton
3112a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
3113243dc2cfSRichard Henderson            LIBS="$gnutls_libs $LIBS"
3114ddbb0d09SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
3115a73e82efSRichard Henderson            pass="yes"
3116a73e82efSRichard Henderson        fi
3117a73e82efSRichard Henderson    fi
3118a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
3119a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
3120ddbb0d09SDaniel P. Berrange    else
3121a73e82efSRichard Henderson        gnutls="$pass"
3122ddbb0d09SDaniel P. Berrange    fi
3123ddbb0d09SDaniel P. Berrangefi
3124ddbb0d09SDaniel P. Berrange
312591bfcdb0SDaniel P. Berrange
312691bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
312791bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
3128a0722409SDaniel P. Berrangé# explicitly
312991bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
313091bfcdb0SDaniel P. Berrangethen
3131a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
313291bfcdb0SDaniel P. Berrange    then
313391bfcdb0SDaniel P. Berrange        gcrypt="no"
313491bfcdb0SDaniel P. Berrange    fi
313591bfcdb0SDaniel P. Berrangefi
313691bfcdb0SDaniel P. Berrange
313791bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
313891bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
3139a0722409SDaniel P. Berrangé# explicitly
314091bfcdb0SDaniel P. Berrangeif test -z "$nettle"
314191bfcdb0SDaniel P. Berrangethen
3142a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
314391bfcdb0SDaniel P. Berrange    then
314491bfcdb0SDaniel P. Berrange        nettle="no"
314591bfcdb0SDaniel P. Berrange    fi
314691bfcdb0SDaniel P. Berrangefi
314791bfcdb0SDaniel P. Berrange
3148dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
314991bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
315091bfcdb0SDaniel P. Berrange    then
315191bfcdb0SDaniel P. Berrange	return 1
315291bfcdb0SDaniel P. Berrange    fi
315391bfcdb0SDaniel P. Berrange
315491bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
315591bfcdb0SDaniel P. Berrange    then
315689138857SStefan Weil	host=$(libgcrypt-config --host)
315791bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
315891bfcdb0SDaniel P. Berrange	then
315991bfcdb0SDaniel P. Berrange	    return 1
316091bfcdb0SDaniel P. Berrange	fi
316191bfcdb0SDaniel P. Berrange    fi
316291bfcdb0SDaniel P. Berrange
3163dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
3164dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
3165dea7a64eSDaniel P. Berrangé
3166dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
3167dea7a64eSDaniel P. Berrangé    then
3168dea7a64eSDaniel P. Berrangé       return 1
3169dea7a64eSDaniel P. Berrangé    fi
3170dea7a64eSDaniel P. Berrangé
317191bfcdb0SDaniel P. Berrange    return 0
317291bfcdb0SDaniel P. Berrange}
317391bfcdb0SDaniel P. Berrange
3174a0722409SDaniel P. Berrangé
3175a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
3176a73e82efSRichard Henderson    pass="no"
317764dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
3178a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
3179a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
3180a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
3181a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3182a73e82efSRichard Henderson        write_c_skeleton
3183a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
3184243dc2cfSRichard Henderson            LIBS="$nettle_libs $LIBS"
3185a0722409SDaniel P. Berrangé            QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
3186a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
3187a0722409SDaniel P. Berrangé               gcrypt="no"
3188a0722409SDaniel P. Berrangé            fi
3189a73e82efSRichard Henderson            pass="yes"
3190a73e82efSRichard Henderson        fi
3191a73e82efSRichard Henderson    fi
3192dc2207afSDaniel P. Berrangé    if test "$pass" = "yes"
3193dc2207afSDaniel P. Berrangé    then
3194dc2207afSDaniel P. Berrangé        cat > $TMPC << EOF
3195dc2207afSDaniel P. Berrangé#include <nettle/xts.h>
3196dc2207afSDaniel P. Berrangéint main(void) {
3197dc2207afSDaniel P. Berrangé  return 0;
3198dc2207afSDaniel P. Berrangé}
3199dc2207afSDaniel P. BerrangéEOF
3200dc2207afSDaniel P. Berrangé        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
3201dc2207afSDaniel P. Berrangé            nettle_xts=yes
3202dc2207afSDaniel P. Berrangé            qemu_private_xts=no
3203dc2207afSDaniel P. Berrangé        fi
3204dc2207afSDaniel P. Berrangé    fi
3205a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
320664dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
3207a0722409SDaniel P. Berrangé    else
3208a73e82efSRichard Henderson        nettle="$pass"
3209a0722409SDaniel P. Berrangé    fi
3210a0722409SDaniel P. Berrangéfi
3211a0722409SDaniel P. Berrangé
321291bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
3213a73e82efSRichard Henderson    pass="no"
3214dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
321589138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
321689138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
3217a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
321891bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
321991bfcdb0SDaniel P. Berrange        # turn breaks static builds...
322091bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
322191bfcdb0SDaniel P. Berrange        then
322291bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
322391bfcdb0SDaniel P. Berrange        fi
32241f923c70SLongpeng(Mike)
3225a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3226a73e82efSRichard Henderson        write_c_skeleton
3227a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
3228243dc2cfSRichard Henderson            LIBS="$gcrypt_libs $LIBS"
322937788f25SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
3230a73e82efSRichard Henderson            pass="yes"
3231a73e82efSRichard Henderson        fi
3232a73e82efSRichard Henderson    fi
3233a73e82efSRichard Henderson    if test "$pass" = "yes"; then
323437788f25SDaniel P. Berrange        gcrypt="yes"
32351f923c70SLongpeng(Mike)        cat > $TMPC << EOF
32361f923c70SLongpeng(Mike)#include <gcrypt.h>
32371f923c70SLongpeng(Mike)int main(void) {
32381f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
32391f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
32401f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
32411f923c70SLongpeng(Mike)  return 0;
32421f923c70SLongpeng(Mike)}
32431f923c70SLongpeng(Mike)EOF
32441f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
32451f923c70SLongpeng(Mike)            gcrypt_hmac=yes
32461f923c70SLongpeng(Mike)        fi
3247e0576942SDaniel P. Berrangé        cat > $TMPC << EOF
3248e0576942SDaniel P. Berrangé#include <gcrypt.h>
3249e0576942SDaniel P. Berrangéint main(void) {
3250e0576942SDaniel P. Berrangé  gcry_cipher_hd_t handle;
3251e0576942SDaniel P. Berrangé  gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
3252e0576942SDaniel P. Berrangé  return 0;
3253e0576942SDaniel P. Berrangé}
3254e0576942SDaniel P. BerrangéEOF
3255e0576942SDaniel P. Berrangé        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3256e0576942SDaniel P. Berrangé            gcrypt_xts=yes
3257e0576942SDaniel P. Berrangé            qemu_private_xts=no
3258e0576942SDaniel P. Berrangé        fi
3259a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
3260dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
326191bfcdb0SDaniel P. Berrange    else
326291bfcdb0SDaniel P. Berrange        gcrypt="no"
326391bfcdb0SDaniel P. Berrange    fi
326462893b67SDaniel P. Berrangefi
326562893b67SDaniel P. Berrange
3266ddbb0d09SDaniel P. Berrange
326791bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
326891bfcdb0SDaniel P. Berrangethen
326991bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
327091bfcdb0SDaniel P. Berrangefi
3271ed754746SDaniel P. Berrange
32729a2fd434SDaniel P. Berrange##########################################
32739a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
32749a2fd434SDaniel P. Berrange
32759a2fd434SDaniel P. Berrangetasn1=yes
327690246037SDaniel P. Berrangetasn1_cflags=""
327790246037SDaniel P. Berrangetasn1_libs=""
32789a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
327989138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
328089138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
32819a2fd434SDaniel P. Berrangeelse
32829a2fd434SDaniel P. Berrange    tasn1=no
32839a2fd434SDaniel P. Berrangefi
32849a2fd434SDaniel P. Berrange
3285ed754746SDaniel P. Berrange
3286bbbf9bfbSStefan Weil##########################################
32878953caf3SDaniel P. Berrange# PAM probe
32888953caf3SDaniel P. Berrange
32898953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
32908953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
32918953caf3SDaniel P. Berrange#include <security/pam_appl.h>
32928953caf3SDaniel P. Berrange#include <stdio.h>
32938953caf3SDaniel P. Berrangeint main(void) {
32948953caf3SDaniel P. Berrange   const char *service_name = "qemu";
32958953caf3SDaniel P. Berrange   const char *user = "frank";
32969c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
32978953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
32989c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
32998953caf3SDaniel P. Berrange   return 0;
33008953caf3SDaniel P. Berrange}
33018953caf3SDaniel P. BerrangeEOF
33028953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
33038953caf3SDaniel P. Berrange        auth_pam=yes
33048953caf3SDaniel P. Berrange    else
33058953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
33068953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
33078953caf3SDaniel P. Berrange        else
33088953caf3SDaniel P. Berrange            auth_pam=no
33098953caf3SDaniel P. Berrange        fi
33108953caf3SDaniel P. Berrange    fi
33118953caf3SDaniel P. Berrangefi
33128953caf3SDaniel P. Berrange
33138953caf3SDaniel P. Berrange##########################################
3314559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
3315559607eaSDaniel P. Berrange
3316559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
3317559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
3318559607eaSDaniel P. Berrange  have_ifaddrs_h=no
3319559607eaSDaniel P. Berrangefi
3320559607eaSDaniel P. Berrange
3321e865b97fSChen Gang#########################################
3322e865b97fSChen Gang# libdrm check
3323e865b97fSChen Ganghave_drm_h=no
3324e865b97fSChen Gangif check_include "libdrm/drm.h" ; then
3325e865b97fSChen Gang    have_drm_h=yes
3326e865b97fSChen Gangfi
3327e865b97fSChen Gang
33282a4b472cSDavid CARLIER#########################################
33292a4b472cSDavid CARLIER# sys/signal.h check
33302a4b472cSDavid CARLIERhave_sys_signal_h=no
33312a4b472cSDavid CARLIERif check_include "sys/signal.h" ; then
33322a4b472cSDavid CARLIER  have_sys_signal_h=yes
33332a4b472cSDavid CARLIERfi
33342a4b472cSDavid CARLIER
3335559607eaSDaniel P. Berrange##########################################
3336bbbf9bfbSStefan Weil# VTE probe
3337bbbf9bfbSStefan Weil
3338bbbf9bfbSStefan Weilif test "$vte" != "no"; then
3339c6feff9eSCole Robinson    vteminversion="0.32.0"
3340c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
3341c6feff9eSCole Robinson      vtepackage="vte-2.91"
3342c6feff9eSCole Robinson    else
3343528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
3344c6feff9eSCole Robinson    fi
3345c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
334689138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
334789138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
334889138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
3349bbbf9bfbSStefan Weil        vte="yes"
3350bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
3351c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
33529e04c683SStefan Weil    else
3353bbbf9bfbSStefan Weil        vte="no"
3354a4ccabcfSAnthony Liguori    fi
3355a4ccabcfSAnthony Liguorifi
3356a4ccabcfSAnthony Liguori
3357a4ccabcfSAnthony Liguori##########################################
335811d9f695Sbellard# SDL probe
335911d9f695Sbellard
3360aee8a619SCarlo Marcelo Arenas Belón# Look for sdl configuration program (pkg-config or sdl2-config).  Try
3361aee8a619SCarlo Marcelo Arenas Belón# sdl2-config even without cross prefix, and favour pkg-config over sdl2-config.
336247c03744SDave Airlie
3363c6093a05SPeter Xusdl_probe ()
3364c6093a05SPeter Xu{
33650015ca5cSDaniel P. Berrangé  if $pkg_config sdl2 --exists; then
33660015ca5cSDaniel P. Berrangé    sdlconfig="$pkg_config sdl2"
336789138857SStefan Weil    sdlversion=$($sdlconfig --modversion 2>/dev/null)
3368aee8a619SCarlo Marcelo Arenas Belón  elif has "$sdl2_config"; then
33690015ca5cSDaniel P. Berrangé    sdlconfig="$sdl2_config"
337089138857SStefan Weil    sdlversion=$($sdlconfig --version)
3371a0dfd8a4SLoïc Minier  else
3372a0dfd8a4SLoïc Minier    if test "$sdl" = "yes" ; then
33738f4ea9cdSGerd Hoffmann      feature_not_found "sdl" "Install SDL2-devel"
3374a0dfd8a4SLoïc Minier    fi
3375a0dfd8a4SLoïc Minier    sdl=no
3376c6093a05SPeter Xu    # no need to do the rest
3377c6093a05SPeter Xu    return
33789316f803SPaolo Bonzini  fi
3379aee8a619SCarlo Marcelo Arenas Belón  if test -n "$cross_prefix" && test "$(basename "$sdlconfig")" = sdl2-config; then
33803ec87ffeSPaolo Bonzini    echo warning: using "\"$sdlconfig\"" to detect cross-compiled sdl >&2
33813ec87ffeSPaolo Bonzini  fi
338211d9f695Sbellard
338311d9f695Sbellard  cat > $TMPC << EOF
338411d9f695Sbellard#include <SDL.h>
338511d9f695Sbellard#undef main /* We don't want SDL to override our main() */
338611d9f695Sbellardint main( void ) { return SDL_Init (SDL_INIT_VIDEO); }
338711d9f695SbellardEOF
338889138857SStefan Weil  sdl_cflags=$($sdlconfig --cflags 2>/dev/null)
33892ca5c430SGerd Hoffmann  sdl_cflags="$sdl_cflags -Wno-undef"  # workaround 2.0.8 bug
339074f42e18STeLeMan  if test "$static" = "yes" ; then
33910015ca5cSDaniel P. Berrangé    if $pkg_config sdl2 --exists; then
33920015ca5cSDaniel P. Berrangé      sdl_libs=$($pkg_config sdl2 --static --libs 2>/dev/null)
33935f37e6d4SThomas Huth    else
339489138857SStefan Weil      sdl_libs=$($sdlconfig --static-libs 2>/dev/null)
33955f37e6d4SThomas Huth    fi
339674f42e18STeLeMan  else
339789138857SStefan Weil    sdl_libs=$($sdlconfig --libs 2>/dev/null)
339874f42e18STeLeMan  fi
339952166aa0SJuan Quintela  if compile_prog "$sdl_cflags" "$sdl_libs" ; then
340011d9f695Sbellard    sdl=yes
34017c1f25b4Sbellard
340267c274d3SPaolo Bonzini    # static link with sdl ? (note: sdl.pc's --static --libs is broken)
3403e633a5c6SEric Blake    if test "$sdl" = "yes" && test "$static" = "yes" ; then
340467c274d3SPaolo Bonzini      if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then
340589138857SStefan Weil         sdl_libs="$sdl_libs $(aalib-config --static-libs 2>/dev/null)"
340689138857SStefan Weil         sdl_cflags="$sdl_cflags $(aalib-config --cflags 2>/dev/null)"
340711d9f695Sbellard      fi
340852166aa0SJuan Quintela      if compile_prog "$sdl_cflags" "$sdl_libs" ; then
34091ac88f28SJuan Quintela	:
34101ac88f28SJuan Quintela      else
34111ac88f28SJuan Quintela        sdl=no
34127c1f25b4Sbellard      fi
34137c1f25b4Sbellard    fi # static link
3414c4198157SJuan Quintela  else # sdl not found
3415c4198157SJuan Quintela    if test "$sdl" = "yes" ; then
34160015ca5cSDaniel P. Berrangé      feature_not_found "sdl" "Install SDL2 devel"
3417c4198157SJuan Quintela    fi
3418c4198157SJuan Quintela    sdl=no
34197c1f25b4Sbellard  fi # sdl compile test
3420c6093a05SPeter Xu}
3421c6093a05SPeter Xu
3422a442fe2fSDaniel P. Berrangésdl_image_probe ()
3423a442fe2fSDaniel P. Berrangé{
3424a442fe2fSDaniel P. Berrangé    if test "$sdl_image" != "no" ; then
3425a442fe2fSDaniel P. Berrangé        if $pkg_config SDL2_image --exists; then
3426a442fe2fSDaniel P. Berrangé            if test "$static" = "yes"; then
3427a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs --static 2>/dev/null)
3428a442fe2fSDaniel P. Berrangé            else
3429a442fe2fSDaniel P. Berrangé                sdl_image_libs=$($pkg_config SDL2_image --libs 2>/dev/null)
3430a442fe2fSDaniel P. Berrangé            fi
3431a442fe2fSDaniel P. Berrangé            sdl_image_cflags=$($pkg_config SDL2_image --cflags 2>/dev/null)
3432a442fe2fSDaniel P. Berrangé            sdl_image=yes
3433a442fe2fSDaniel P. Berrangé
3434a442fe2fSDaniel P. Berrangé            sdl_cflags="$sdl_cflags $sdl_image_cflags"
3435a442fe2fSDaniel P. Berrangé            sdl_libs="$sdl_libs $sdl_image_libs"
3436a442fe2fSDaniel P. Berrangé        else
3437a442fe2fSDaniel P. Berrangé            if test "$sdl_image" = "yes" ; then
3438a442fe2fSDaniel P. Berrangé                feature_not_found "sdl_image" "Install SDL Image devel"
3439a442fe2fSDaniel P. Berrangé            else
3440a442fe2fSDaniel P. Berrangé                sdl_image=no
3441a442fe2fSDaniel P. Berrangé            fi
3442a442fe2fSDaniel P. Berrangé        fi
3443a442fe2fSDaniel P. Berrangé    fi
3444a442fe2fSDaniel P. Berrangé}
3445a442fe2fSDaniel P. Berrangé
3446c6093a05SPeter Xuif test "$sdl" != "no" ; then
3447c6093a05SPeter Xu  sdl_probe
3448fd677642Sthsfi
344911d9f695Sbellard
34505368a422Saliguoriif test "$sdl" = "yes" ; then
3451a442fe2fSDaniel P. Berrangé  sdl_image_probe
3452a442fe2fSDaniel P. Berrangéelse
3453a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes"; then
3454a442fe2fSDaniel P. Berrangé    echo "warning: SDL Image requested, but SDL is not available, disabling"
3455a442fe2fSDaniel P. Berrangé  fi
3456a442fe2fSDaniel P. Berrangé  sdl_image=no
3457a442fe2fSDaniel P. Berrangéfi
3458a442fe2fSDaniel P. Berrangé
3459a442fe2fSDaniel P. Berrangéif test "$sdl" = "yes" ; then
34605368a422Saliguori  cat > $TMPC <<EOF
34615368a422Saliguori#include <SDL.h>
34625368a422Saliguori#if defined(SDL_VIDEO_DRIVER_X11)
34635368a422Saliguori#include <X11/XKBlib.h>
34645368a422Saliguori#else
34655368a422Saliguori#error No x11 support
34665368a422Saliguori#endif
34675368a422Saliguoriint main(void) { return 0; }
34685368a422SaliguoriEOF
3469f676c67eSJeremy White  if compile_prog "$sdl_cflags $x11_cflags" "$sdl_libs $x11_libs" ; then
34708781595bSGerd Hoffmann    need_x11=yes
3471f676c67eSJeremy White    sdl_cflags="$sdl_cflags $x11_cflags"
3472f676c67eSJeremy White    sdl_libs="$sdl_libs $x11_libs"
34735368a422Saliguori  fi
34745368a422Saliguorifi
34755368a422Saliguori
34768f28f3fbSths##########################################
34772da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
34782da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
34792da776dbSMichael R. Hines  cat > $TMPC <<EOF
34802da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
34812da776dbSMichael R. Hinesint main(void) { return 0; }
34822da776dbSMichael R. HinesEOF
3483ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
34842da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
34852da776dbSMichael R. Hines    rdma="yes"
3486ef6d4ccdSYuval Shaia    libs_softmmu="$libs_softmmu $rdma_libs"
34872da776dbSMichael R. Hines  else
34882da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
34892da776dbSMichael R. Hines        error_exit \
3490ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
34912da776dbSMichael R. Hines            " Your options:" \
3492ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
34932da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
34942da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
34952da776dbSMichael R. Hines    fi
34962da776dbSMichael R. Hines    rdma="no"
34972da776dbSMichael R. Hines  fi
34982da776dbSMichael R. Hinesfi
34992da776dbSMichael R. Hines
350021ab34c9SMarcel Apfelbaum##########################################
350121ab34c9SMarcel Apfelbaum# PVRDMA detection
350221ab34c9SMarcel Apfelbaum
350321ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
350421ab34c9SMarcel Apfelbaum#include <sys/mman.h>
350521ab34c9SMarcel Apfelbaum
350621ab34c9SMarcel Apfelbaumint
350721ab34c9SMarcel Apfelbaummain(void)
350821ab34c9SMarcel Apfelbaum{
350921ab34c9SMarcel Apfelbaum    char buf = 0;
351021ab34c9SMarcel Apfelbaum    void *addr = &buf;
351121ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
351221ab34c9SMarcel Apfelbaum
351321ab34c9SMarcel Apfelbaum    return 0;
351421ab34c9SMarcel Apfelbaum}
351521ab34c9SMarcel ApfelbaumEOF
351621ab34c9SMarcel Apfelbaum
351721ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
351821ab34c9SMarcel Apfelbaum    case "$pvrdma" in
351921ab34c9SMarcel Apfelbaum    "")
352021ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
352121ab34c9SMarcel Apfelbaum            pvrdma="yes"
352221ab34c9SMarcel Apfelbaum        else
352321ab34c9SMarcel Apfelbaum            pvrdma="no"
352421ab34c9SMarcel Apfelbaum        fi
352521ab34c9SMarcel Apfelbaum        ;;
352621ab34c9SMarcel Apfelbaum    "yes")
352721ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
352821ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
352921ab34c9SMarcel Apfelbaum        fi
353021ab34c9SMarcel Apfelbaum        pvrdma="yes"
353121ab34c9SMarcel Apfelbaum        ;;
353221ab34c9SMarcel Apfelbaum    "no")
353321ab34c9SMarcel Apfelbaum        pvrdma="no"
353421ab34c9SMarcel Apfelbaum        ;;
353521ab34c9SMarcel Apfelbaum    esac
353621ab34c9SMarcel Apfelbaumelse
353721ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
353821ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
353921ab34c9SMarcel Apfelbaum    fi
354021ab34c9SMarcel Apfelbaum    pvrdma="no"
354121ab34c9SMarcel Apfelbaumfi
354295c6bff3SBenoît Canet
3543ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
3544ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
3545ee108585SYuval Shaia
3546ee108585SYuval Shaiacat > $TMPC <<EOF &&
3547ee108585SYuval Shaia#include <infiniband/verbs.h>
3548ee108585SYuval Shaia
3549ee108585SYuval Shaiaint
3550ee108585SYuval Shaiamain(void)
3551ee108585SYuval Shaia{
3552ee108585SYuval Shaia    struct ibv_mr *mr;
3553ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
3554ee108585SYuval Shaia    size_t length = 10;
3555ee108585SYuval Shaia    uint64_t iova = 0;
3556ee108585SYuval Shaia    int access = 0;
3557ee108585SYuval Shaia    void *addr = NULL;
3558ee108585SYuval Shaia
3559ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3560ee108585SYuval Shaia
3561ee108585SYuval Shaia    ibv_dereg_mr(mr);
3562ee108585SYuval Shaia
3563ee108585SYuval Shaia    return 0;
3564ee108585SYuval Shaia}
3565ee108585SYuval ShaiaEOF
3566ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
3567ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3568ee108585SYuval Shaia    fi
3569ee108585SYuval Shaiafi
3570ee108585SYuval Shaia
357195c6bff3SBenoît Canet##########################################
35722f9606b3Saliguori# VNC SASL detection
3573e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_sasl" != "no" ; then
35742f9606b3Saliguori  cat > $TMPC <<EOF
35752f9606b3Saliguori#include <sasl/sasl.h>
35762f9606b3Saliguori#include <stdio.h>
35772f9606b3Saliguoriint main(void) { sasl_server_init(NULL, "qemu"); return 0; }
35782f9606b3SaliguoriEOF
35792f9606b3Saliguori  # Assuming Cyrus-SASL installed in /usr prefix
3580bd702ffcSPhilippe Mathieu-Daudé  # QEMU defines struct iovec in "qemu/osdep.h",
3581bd702ffcSPhilippe Mathieu-Daudé  # we don't want libsasl to redefine it in <sasl/sasl.h>.
3582bd702ffcSPhilippe Mathieu-Daudé  vnc_sasl_cflags="-DSTRUCT_IOVEC_DEFINED"
35832f9606b3Saliguori  vnc_sasl_libs="-lsasl2"
358452166aa0SJuan Quintela  if compile_prog "$vnc_sasl_cflags" "$vnc_sasl_libs" ; then
3585ea784e3bSJuan Quintela    vnc_sasl=yes
3586fa838301SJuan Quintela    libs_softmmu="$vnc_sasl_libs $libs_softmmu"
3587ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_sasl_cflags"
35882f9606b3Saliguori  else
3589ea784e3bSJuan Quintela    if test "$vnc_sasl" = "yes" ; then
359021684af0SStewart Smith      feature_not_found "vnc-sasl" "Install Cyrus SASL devel"
3591ea784e3bSJuan Quintela    fi
3592ea784e3bSJuan Quintela    vnc_sasl=no
35932f9606b3Saliguori  fi
35942f9606b3Saliguorifi
35952f9606b3Saliguori
35962f9606b3Saliguori##########################################
35972f6f5c7aSCorentin Chary# VNC JPEG detection
3598e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_jpeg" != "no" ; then
35992f6f5c7aSCorentin Charycat > $TMPC <<EOF
36002f6f5c7aSCorentin Chary#include <stdio.h>
36012f6f5c7aSCorentin Chary#include <jpeglib.h>
36022f6f5c7aSCorentin Charyint main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; }
36032f6f5c7aSCorentin CharyEOF
36042f6f5c7aSCorentin Chary    vnc_jpeg_cflags=""
36052f6f5c7aSCorentin Chary    vnc_jpeg_libs="-ljpeg"
36062f6f5c7aSCorentin Chary  if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then
36072f6f5c7aSCorentin Chary    vnc_jpeg=yes
36082f6f5c7aSCorentin Chary    libs_softmmu="$vnc_jpeg_libs $libs_softmmu"
3609ca273d58SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_jpeg_cflags"
36102f6f5c7aSCorentin Chary  else
36112f6f5c7aSCorentin Chary    if test "$vnc_jpeg" = "yes" ; then
361221684af0SStewart Smith      feature_not_found "vnc-jpeg" "Install libjpeg-turbo devel"
36132f6f5c7aSCorentin Chary    fi
36142f6f5c7aSCorentin Chary    vnc_jpeg=no
36152f6f5c7aSCorentin Chary  fi
36162f6f5c7aSCorentin Charyfi
36172f6f5c7aSCorentin Chary
36182f6f5c7aSCorentin Chary##########################################
3619efe556adSCorentin Chary# VNC PNG detection
3620e633a5c6SEric Blakeif test "$vnc" = "yes" && test "$vnc_png" != "no" ; then
3621efe556adSCorentin Charycat > $TMPC <<EOF
3622efe556adSCorentin Chary//#include <stdio.h>
3623efe556adSCorentin Chary#include <png.h>
3624832ce9c2SScott Wood#include <stddef.h>
3625efe556adSCorentin Charyint main(void) {
3626efe556adSCorentin Chary    png_structp png_ptr;
3627efe556adSCorentin Chary    png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
36287edc3fedSPeter Maydell    return png_ptr != 0;
3629efe556adSCorentin Chary}
3630efe556adSCorentin CharyEOF
363165d5d3f9SStefan Weil  if $pkg_config libpng --exists; then
363289138857SStefan Weil    vnc_png_cflags=$($pkg_config libpng --cflags)
363389138857SStefan Weil    vnc_png_libs=$($pkg_config libpng --libs)
36349af8025eSBrad  else
3635efe556adSCorentin Chary    vnc_png_cflags=""
3636efe556adSCorentin Chary    vnc_png_libs="-lpng"
36379af8025eSBrad  fi
3638efe556adSCorentin Chary  if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
3639efe556adSCorentin Chary    vnc_png=yes
3640efe556adSCorentin Chary    libs_softmmu="$vnc_png_libs $libs_softmmu"
36419af8025eSBrad    QEMU_CFLAGS="$QEMU_CFLAGS $vnc_png_cflags"
3642efe556adSCorentin Chary  else
3643efe556adSCorentin Chary    if test "$vnc_png" = "yes" ; then
364421684af0SStewart Smith      feature_not_found "vnc-png" "Install libpng devel"
3645efe556adSCorentin Chary    fi
3646efe556adSCorentin Chary    vnc_png=no
3647efe556adSCorentin Chary  fi
3648efe556adSCorentin Charyfi
3649efe556adSCorentin Chary
3650efe556adSCorentin Chary##########################################
36516a021536SGerd Hoffmann# xkbcommon probe
36526a021536SGerd Hoffmannif test "$xkbcommon" != "no" ; then
36536a021536SGerd Hoffmann  if $pkg_config xkbcommon --exists; then
36546a021536SGerd Hoffmann    xkbcommon_cflags=$($pkg_config xkbcommon --cflags)
36556a021536SGerd Hoffmann    xkbcommon_libs=$($pkg_config xkbcommon --libs)
36566a021536SGerd Hoffmann    xkbcommon=yes
36576a021536SGerd Hoffmann  else
36586a021536SGerd Hoffmann    if test "$xkbcommon" = "yes" ; then
36596a021536SGerd Hoffmann      feature_not_found "xkbcommon" "Install libxkbcommon-devel"
36606a021536SGerd Hoffmann    fi
36616a021536SGerd Hoffmann    xkbcommon=no
36626a021536SGerd Hoffmann  fi
36636a021536SGerd Hoffmannfi
36646a021536SGerd Hoffmann
366576655d6dSaliguori
366676655d6dSaliguori##########################################
3667c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3668dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3669dce512deSChristoph Hellwig  cat > $TMPC << EOF
3670ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3671dce512deSChristoph Hellwig#include <xfs/xfs.h>
3672dce512deSChristoph Hellwigint main(void)
3673dce512deSChristoph Hellwig{
3674dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3675dce512deSChristoph Hellwig    return 0;
3676dce512deSChristoph Hellwig}
3677dce512deSChristoph HellwigEOF
3678dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3679dce512deSChristoph Hellwig    xfs="yes"
3680dce512deSChristoph Hellwig  else
3681dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
368221684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3683dce512deSChristoph Hellwig    fi
3684dce512deSChristoph Hellwig    xfs=no
3685dce512deSChristoph Hellwig  fi
3686dce512deSChristoph Hellwigfi
3687dce512deSChristoph Hellwig
3688dce512deSChristoph Hellwig##########################################
36898a16d273Sths# vde libraries probe
3690dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
36914baae0acSJuan Quintela  vde_libs="-lvdeplug"
36928a16d273Sths  cat > $TMPC << EOF
36938a16d273Sths#include <libvdeplug.h>
36944a7f0e06Spbrookint main(void)
36954a7f0e06Spbrook{
36964a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3697fea08e08SPeter Maydell    char s[] = "";
3698fea08e08SPeter Maydell    vde_open(s, s, &a);
36994a7f0e06Spbrook    return 0;
37004a7f0e06Spbrook}
37018a16d273SthsEOF
370252166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
37034baae0acSJuan Quintela    vde=yes
3704dfb278bdSJuan Quintela  else
3705dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
370621684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3707dfb278bdSJuan Quintela    fi
3708dfb278bdSJuan Quintela    vde=no
37098a16d273Sths  fi
37108a16d273Sthsfi
37118a16d273Sths
37128a16d273Sths##########################################
37130a985b37SVincenzo Maffione# netmap support probe
37140a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
37150a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
37160a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
37170a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
37180a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
371958952137SVincenzo Maffioneif test "$netmap" != "no" ; then
372058952137SVincenzo Maffione  cat > $TMPC << EOF
372158952137SVincenzo Maffione#include <inttypes.h>
372258952137SVincenzo Maffione#include <net/if.h>
372358952137SVincenzo Maffione#include <net/netmap.h>
372458952137SVincenzo Maffione#include <net/netmap_user.h>
37250a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
37260a985b37SVincenzo Maffione#error
37270a985b37SVincenzo Maffione#endif
372858952137SVincenzo Maffioneint main(void) { return 0; }
372958952137SVincenzo MaffioneEOF
373058952137SVincenzo Maffione  if compile_prog "" "" ; then
373158952137SVincenzo Maffione    netmap=yes
373258952137SVincenzo Maffione  else
373358952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
373458952137SVincenzo Maffione      feature_not_found "netmap"
373558952137SVincenzo Maffione    fi
373658952137SVincenzo Maffione    netmap=no
373758952137SVincenzo Maffione  fi
373858952137SVincenzo Maffionefi
373958952137SVincenzo Maffione
374058952137SVincenzo Maffione##########################################
374147e98658SCorey Bryant# libcap-ng library probe
374247e98658SCorey Bryantif test "$cap_ng" != "no" ; then
374347e98658SCorey Bryant  cap_libs="-lcap-ng"
374447e98658SCorey Bryant  cat > $TMPC << EOF
374547e98658SCorey Bryant#include <cap-ng.h>
374647e98658SCorey Bryantint main(void)
374747e98658SCorey Bryant{
374847e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
374947e98658SCorey Bryant    return 0;
375047e98658SCorey Bryant}
375147e98658SCorey BryantEOF
375247e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
375347e98658SCorey Bryant    cap_ng=yes
375447e98658SCorey Bryant    libs_tools="$cap_libs $libs_tools"
375547e98658SCorey Bryant  else
375647e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
375721684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
375847e98658SCorey Bryant    fi
375947e98658SCorey Bryant    cap_ng=no
376047e98658SCorey Bryant  fi
376147e98658SCorey Bryantfi
376247e98658SCorey Bryant
376347e98658SCorey Bryant##########################################
3764c2de5c91Smalc# Sound support libraries probe
37658f28f3fbSths
376689138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3767c2de5c91Smalcfor drv in $audio_drv_list; do
3768c2de5c91Smalc    case $drv in
3769e42975a1SGerd Hoffmann    alsa | try-alsa)
3770c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3771c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3772478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
3773478e943fSPaolo Bonzini        alsa=yes
3774e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3775e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3776e42975a1SGerd Hoffmann        fi
3777e42975a1SGerd Hoffmann    else
3778e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3779e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3780c80a867fSGerd Hoffmann        else
3781c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3782c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3783c80a867fSGerd Hoffmann        fi
3784e42975a1SGerd Hoffmann    fi
3785c2de5c91Smalc    ;;
3786c2de5c91Smalc
3787e42975a1SGerd Hoffmann    pa | try-pa)
3788c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3789478e943fSPaolo Bonzini        libpulse=yes
3790c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3791478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3792e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3793e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3794e42975a1SGerd Hoffmann        fi
3795e42975a1SGerd Hoffmann    else
3796e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3797e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3798c80a867fSGerd Hoffmann        else
3799c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3800c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3801c80a867fSGerd Hoffmann        fi
3802e42975a1SGerd Hoffmann    fi
3803b8e59f18Smalc    ;;
3804b8e59f18Smalc
3805373967b2SGerd Hoffmann    sdl)
3806373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3807373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3808373967b2SGerd Hoffmann    fi
3809373967b2SGerd Hoffmann    ;;
3810373967b2SGerd Hoffmann
3811e42975a1SGerd Hoffmann    try-sdl)
3812e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3813e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3814e42975a1SGerd Hoffmann    else
3815e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3816e42975a1SGerd Hoffmann    fi
3817e42975a1SGerd Hoffmann    ;;
3818e42975a1SGerd Hoffmann
3819997e690aSJuan Quintela    coreaudio)
3820b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3821997e690aSJuan Quintela    ;;
3822997e690aSJuan Quintela
3823a4bf6780SJuan Quintela    dsound)
3824b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3825d5631638Smalc      audio_win_int="yes"
3826a4bf6780SJuan Quintela    ;;
3827a4bf6780SJuan Quintela
3828a4bf6780SJuan Quintela    oss)
3829b1149911SFam Zheng      oss_libs="$oss_lib"
3830a4bf6780SJuan Quintela    ;;
3831a4bf6780SJuan Quintela
38322e445703SGeoffrey McRae    jack | try-jack)
38332e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3834478e943fSPaolo Bonzini        libjack=yes
38352e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
38362e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
38372e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
38382e445703SGeoffrey McRae        fi
38392e445703SGeoffrey McRae    else
38402e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
38412e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
38422e445703SGeoffrey McRae        else
38432e445703SGeoffrey McRae            error_exit "$drv check failed" \
38442e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
38452e445703SGeoffrey McRae        fi
38462e445703SGeoffrey McRae    fi
38472e445703SGeoffrey McRae    ;;
38482e445703SGeoffrey McRae
3849e4c63a6aSmalc    *)
38501c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
385176ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
385276ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3853e4c63a6aSmalc    }
3854e4c63a6aSmalc    ;;
3855c2de5c91Smalc    esac
3856c2de5c91Smalcdone
38578f28f3fbSths
38584d3b6f6eSbalrog##########################################
38592e4d9fb1Saurel32# BrlAPI probe
38602e4d9fb1Saurel32
38614ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3862eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
38632e4d9fb1Saurel32  cat > $TMPC << EOF
38642e4d9fb1Saurel32#include <brlapi.h>
3865832ce9c2SScott Wood#include <stddef.h>
38662e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
38672e4d9fb1Saurel32EOF
386852166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
38692e4d9fb1Saurel32    brlapi=yes
38704ffcedb6SJuan Quintela  else
38714ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
387221684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
38734ffcedb6SJuan Quintela    fi
38744ffcedb6SJuan Quintela    brlapi=no
3875eb82284fSJuan Quintela  fi
3876eb82284fSJuan Quintelafi
38772e4d9fb1Saurel32
38782e4d9fb1Saurel32##########################################
3879e08bb301SSamuel Thibault# iconv probe
3880e08bb301SSamuel Thibaultif test "$iconv" != "no" ; then
3881e08bb301SSamuel Thibault  cat > $TMPC << EOF
3882e08bb301SSamuel Thibault#include <iconv.h>
3883e08bb301SSamuel Thibaultint main(void) {
3884e08bb301SSamuel Thibault  iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3885e08bb301SSamuel Thibault  return conv != (iconv_t) -1;
3886e08bb301SSamuel Thibault}
3887e08bb301SSamuel ThibaultEOF
3888e08bb301SSamuel Thibault  iconv_prefix_list="/usr/local:/usr"
3889e08bb301SSamuel Thibault  iconv_lib_list=":-liconv"
3890e08bb301SSamuel Thibault  IFS=:
3891e08bb301SSamuel Thibault  for iconv_prefix in $iconv_prefix_list; do
3892e08bb301SSamuel Thibault    IFS=:
3893e08bb301SSamuel Thibault    iconv_cflags="-I$iconv_prefix/include"
3894e08bb301SSamuel Thibault    iconv_ldflags="-L$iconv_prefix/lib"
3895e08bb301SSamuel Thibault    for iconv_link in $iconv_lib_list; do
3896e08bb301SSamuel Thibault      unset IFS
3897e08bb301SSamuel Thibault      iconv_lib="$iconv_ldflags $iconv_link"
3898e08bb301SSamuel Thibault      echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3899e08bb301SSamuel Thibault      if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3900e08bb301SSamuel Thibault        iconv_found=yes
3901e08bb301SSamuel Thibault        break
3902e08bb301SSamuel Thibault      fi
3903e08bb301SSamuel Thibault    done
3904e08bb301SSamuel Thibault    if test "$iconv_found" = yes ; then
3905e08bb301SSamuel Thibault      break
3906e08bb301SSamuel Thibault    fi
3907e08bb301SSamuel Thibault  done
3908e08bb301SSamuel Thibault  if test "$iconv_found" = "yes" ; then
3909e08bb301SSamuel Thibault    iconv=yes
3910e08bb301SSamuel Thibault  else
3911e08bb301SSamuel Thibault    if test "$iconv" = "yes" ; then
3912e08bb301SSamuel Thibault      feature_not_found "iconv" "Install iconv devel"
3913e08bb301SSamuel Thibault    fi
3914e08bb301SSamuel Thibault    iconv=no
3915e08bb301SSamuel Thibault  fi
3916e08bb301SSamuel Thibaultfi
3917e08bb301SSamuel Thibault
3918e08bb301SSamuel Thibault##########################################
39194d3b6f6eSbalrog# curses probe
3920e08bb301SSamuel Thibaultif test "$iconv" = "no" ; then
3921e08bb301SSamuel Thibault  # curses will need iconv
3922e08bb301SSamuel Thibault  curses=no
3923e08bb301SSamuel Thibaultfi
3924a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3925e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
39268ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
39278ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3928e095e2f3SStefan Weil  else
39297c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
39308ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3931e095e2f3SStefan Weil  fi
3932c584a6d0SJuan Quintela  curses_found=no
39334d3b6f6eSbalrog  cat > $TMPC << EOF
39348ddc5bf9SSamuel Thibault#include <locale.h>
39354d3b6f6eSbalrog#include <curses.h>
39368ddc5bf9SSamuel Thibault#include <wchar.h>
39372f8b7cd5SSamuel Thibault#include <langinfo.h>
3938ef9a2524SStefan Weilint main(void) {
39392f8b7cd5SSamuel Thibault  const char *codeset;
39408ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
39418ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3942ef9a2524SStefan Weil  resize_term(0, 0);
39438ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
39448ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
39457c703002SSamuel Thibault  add_wch(WACS_DEGREE);
39462f8b7cd5SSamuel Thibault  codeset = nl_langinfo(CODESET);
39472f8b7cd5SSamuel Thibault  return codeset != 0;
3948ef9a2524SStefan Weil}
39494d3b6f6eSbalrogEOF
3950ecbe251fSVadim Evard  IFS=:
39518ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3952b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3953b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
39547c703002SSamuel Thibault    IFS=:
39558ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3956ecbe251fSVadim Evard      unset IFS
39578ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3958c584a6d0SJuan Quintela        curses_found=yes
39594f78ef9aSJuan Quintela        break
39604d3b6f6eSbalrog      fi
39614f78ef9aSJuan Quintela    done
39627c703002SSamuel Thibault    if test "$curses_found" = yes ; then
39637c703002SSamuel Thibault      break
39647c703002SSamuel Thibault    fi
39658ddc5bf9SSamuel Thibault  done
3966ecbe251fSVadim Evard  unset IFS
3967c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3968c584a6d0SJuan Quintela    curses=yes
3969c584a6d0SJuan Quintela  else
3970c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
397121684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3972c584a6d0SJuan Quintela    fi
3973c584a6d0SJuan Quintela    curses=no
3974c584a6d0SJuan Quintela  fi
39754f78ef9aSJuan Quintelafi
39764d3b6f6eSbalrog
3977414f0dabSblueswir1##########################################
3978769ce76dSAlexander Graf# curl probe
3979a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
398065d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3981a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
39824e2b0658SPaolo Bonzini  else
39834e2b0658SPaolo Bonzini    curlconfig=curl-config
39844e2b0658SPaolo Bonzini  fi
3985769ce76dSAlexander Graf  cat > $TMPC << EOF
3986769ce76dSAlexander Graf#include <curl/curl.h>
39870b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3988769ce76dSAlexander GrafEOF
398989138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
399089138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3991b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3992769ce76dSAlexander Graf    curl=yes
3993788c8196SJuan Quintela  else
3994788c8196SJuan Quintela    if test "$curl" = "yes" ; then
399521684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3996788c8196SJuan Quintela    fi
3997788c8196SJuan Quintela    curl=no
3998769ce76dSAlexander Graf  fi
3999769ce76dSAlexander Graffi # test "$curl"
4000769ce76dSAlexander Graf
4001769ce76dSAlexander Graf##########################################
4002e18df141SAnthony Liguori# glib support probe
4003a52d28afSPaolo Bonzini
400400f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
4005aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
4006aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
4007a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
4008aa0d1f44SPaolo Bonzinifi
400954cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
401054cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
401154cb65d8SEmilio G. Cotafi
4012e26110cfSFam Zheng
40134eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
40144eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
40154eaf7202SSameeh Jubran
4016e633a5c6SEric Blakeif test "$static" = yes && test "$mingw32" = yes; then
40174eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
40184eaf7202SSameeh Jubranfi
40194eaf7202SSameeh Jubran
4020aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
4021e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
402289138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
402389138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
40244a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
402514015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
4026e18df141SAnthony Liguori    else
4027e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
4028e26110cfSFam Zheng    fi
4029e26110cfSFam Zhengdone
4030e26110cfSFam Zheng
4031f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
4032f876b765SMarc-André Lureau    gio=yes
4033f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
4034f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
403525a97a56SMarc-André Lureau    gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
40360dba4897SMarc-André Lureau    if [ ! -x "$gdbus_codegen" ]; then
40370dba4897SMarc-André Lureau        gdbus_codegen=
40380dba4897SMarc-André Lureau    fi
4039f876b765SMarc-André Lureauelse
4040f876b765SMarc-André Lureau    gio=no
4041f876b765SMarc-André Lureaufi
4042f876b765SMarc-André Lureau
404325a97a56SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
404425a97a56SMarc-André Lureau    gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
404525a97a56SMarc-André Lureau    gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
404625a97a56SMarc-André Lureaufi
404725a97a56SMarc-André Lureau
4048977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
4049977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
4050977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
4051977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
4052977a82abSDaniel P. Berrangecat > $TMPC <<EOF
4053977a82abSDaniel P. Berrange#include <glib.h>
4054977a82abSDaniel P. Berrange#include <unistd.h>
4055977a82abSDaniel P. Berrange
4056977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
4057977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
4058977a82abSDaniel P. Berrange
4059977a82abSDaniel P. Berrangeint main(void) {
4060977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
4061977a82abSDaniel P. Berrange   return 0;
4062977a82abSDaniel P. Berrange}
4063977a82abSDaniel P. BerrangeEOF
4064977a82abSDaniel P. Berrange
40655919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
4066977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
4067977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
4068977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
4069977a82abSDaniel P. Berrange	       "build target"
4070977a82abSDaniel P. Berrangefi
4071977a82abSDaniel P. Berrange
4072bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
4073bbbf2e04SJohn Snowcat > $TMPC << EOF
4074bbbf2e04SJohn Snow#include <glib.h>
4075bbbf2e04SJohn Snowint main(void) { return 0; }
4076bbbf2e04SJohn SnowEOF
4077bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
4078bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
4079bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
4080086d5f75SPaolo Bonzini        QEMU_CFLAGS="-Wno-unknown-attributes $CFLAGS"
4081bbbf2e04SJohn Snow    fi
4082bbbf2e04SJohn Snowfi
4083bbbf2e04SJohn Snow
40849bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
40859bda600bSEric Blakecat > $TMPC << EOF
40869bda600bSEric Blake#include <glib.h>
40879bda600bSEric Blaketypedef struct Foo {
40889bda600bSEric Blake    int i;
40899bda600bSEric Blake} Foo;
40909bda600bSEric Blakestatic void foo_free(Foo *f)
40919bda600bSEric Blake{
40929bda600bSEric Blake    g_free(f);
40939bda600bSEric Blake}
40949bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
40959bda600bSEric Blakeint main(void) { return 0; }
40969bda600bSEric BlakeEOF
40979bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
40989bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
40999bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
41009bda600bSEric Blake        CFLAGS="$CFLAGS -Wno-unused-function"
41019bda600bSEric Blake    fi
41029bda600bSEric Blakefi
41039bda600bSEric Blake
41046a1f42bdSStefan Weil#########################################
41056a1f42bdSStefan Weil# zlib check
41066a1f42bdSStefan Weil
41076a1f42bdSStefan Weilif test "$zlib" != "no" ; then
41086a1f42bdSStefan Weil    if $pkg_config --exists zlib; then
41096a1f42bdSStefan Weil        zlib_cflags=$($pkg_config --cflags zlib)
41106a1f42bdSStefan Weil        zlib_libs=$($pkg_config --libs zlib)
41116a1f42bdSStefan Weil        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
41126a1f42bdSStefan Weil        LIBS="$zlib_libs $LIBS"
41136a1f42bdSStefan Weil    else
41146a1f42bdSStefan Weil        cat > $TMPC << EOF
41156a1f42bdSStefan Weil#include <zlib.h>
41166a1f42bdSStefan Weilint main(void) { zlibVersion(); return 0; }
41176a1f42bdSStefan WeilEOF
41186a1f42bdSStefan Weil        if compile_prog "" "-lz" ; then
41195e5733e5SMarc-André Lureau            zlib_libs=-lz
41205e5733e5SMarc-André Lureau            LIBS="$LIBS $zlib_libs"
41216a1f42bdSStefan Weil        else
41226a1f42bdSStefan Weil            error_exit "zlib check failed" \
41236a1f42bdSStefan Weil                "Make sure to have the zlib libs and headers installed."
41246a1f42bdSStefan Weil        fi
41256a1f42bdSStefan Weil    fi
41266a1f42bdSStefan Weilfi
41276a1f42bdSStefan Weil
4128e26110cfSFam Zheng##########################################
4129e26110cfSFam Zheng# SHA command probe for modules
4130e26110cfSFam Zhengif test "$modules" = yes; then
4131e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
4132e26110cfSFam Zheng    for c in $shacmd_probe; do
41338ccefb91SFam Zheng        if has $c; then
4134e26110cfSFam Zheng            shacmd="$c"
4135e26110cfSFam Zheng            break
4136e26110cfSFam Zheng        fi
4137e26110cfSFam Zheng    done
4138e26110cfSFam Zheng    if test "$shacmd" = ""; then
4139e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
4140e26110cfSFam Zheng    fi
4141e18df141SAnthony Liguorifi
4142e18df141SAnthony Liguori
4143e18df141SAnthony Liguori##########################################
4144e2134eb9SGerd Hoffmann# pixman support probe
4145e2134eb9SGerd Hoffmann
41469b52b17bSThomas Huthif test "$softmmu" = "no"; then
414774880fe2SRobert Schiele  pixman_cflags=
414874880fe2SRobert Schiele  pixman_libs=
414935c4e86cSGerd Hoffmannelif $pkg_config --atleast-version=0.21.8 pixman-1 > /dev/null 2>&1; then
415089138857SStefan Weil  pixman_cflags=$($pkg_config --cflags pixman-1)
415189138857SStefan Weil  pixman_libs=$($pkg_config --libs pixman-1)
4152e2134eb9SGerd Hoffmannelse
4153c12b6d70SGerd Hoffmann  error_exit "pixman >= 0.21.8 not present." \
4154c12b6d70SGerd Hoffmann      "Please install the pixman devel package."
4155e2134eb9SGerd Hoffmannfi
4156e2134eb9SGerd Hoffmann
4157e2134eb9SGerd Hoffmann##########################################
4158fe8fc5aeSPaolo Bonzini# libmpathpersist probe
4159fe8fc5aeSPaolo Bonzini
4160fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
41611b0578f5SMurilo Opsfelder Araujo  # probe for the new API
4162fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
4163fe8fc5aeSPaolo Bonzini#include <libudev.h>
4164fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
4165fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
4166fe8fc5aeSPaolo Bonziniint logsink;
4167b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
4168b3f1c8c4SPaolo Bonziniextern struct udev *udev;
4169b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
4170b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
4171b3f1c8c4SPaolo Bonzinistruct udev *udev;
4172b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
4173b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
4174b3f1c8c4SPaolo Bonzini
4175fe8fc5aeSPaolo Bonziniint main(void) {
4176b3f1c8c4SPaolo Bonzini    udev = udev_new();
4177b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
4178fe8fc5aeSPaolo Bonzini    return 0;
4179fe8fc5aeSPaolo Bonzini}
4180fe8fc5aeSPaolo BonziniEOF
4181fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
4182fe8fc5aeSPaolo Bonzini    mpathpersist=yes
41831b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
41841b0578f5SMurilo Opsfelder Araujo  else
41851b0578f5SMurilo Opsfelder Araujo    # probe for the old API
41861b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
41871b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
41881b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
41891b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
41901b0578f5SMurilo Opsfelder Araujoint logsink;
41911b0578f5SMurilo Opsfelder Araujoint main(void) {
41921b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
41931b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
41941b0578f5SMurilo Opsfelder Araujo    return 0;
41951b0578f5SMurilo Opsfelder Araujo}
41961b0578f5SMurilo Opsfelder AraujoEOF
41971b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
41981b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
41991b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
4200fe8fc5aeSPaolo Bonzini    else
4201fe8fc5aeSPaolo Bonzini      mpathpersist=no
4202fe8fc5aeSPaolo Bonzini    fi
42031b0578f5SMurilo Opsfelder Araujo  fi
4204fe8fc5aeSPaolo Bonzinielse
4205fe8fc5aeSPaolo Bonzini  mpathpersist=no
4206fe8fc5aeSPaolo Bonzinifi
4207fe8fc5aeSPaolo Bonzini
4208fe8fc5aeSPaolo Bonzini##########################################
4209e5d355d1Saliguori# pthread probe
42104b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
42113c529d93Saliguori
4212e5d355d1Saliguoripthread=no
4213414f0dabSblueswir1cat > $TMPC << EOF
42143c529d93Saliguori#include <pthread.h>
42157a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
42167a42bbe4SStefan Weilint main(void) {
42177a42bbe4SStefan Weil  pthread_t thread;
42187a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
42197a42bbe4SStefan Weil  return 0;
42207a42bbe4SStefan Weil}
4221414f0dabSblueswir1EOF
4222bd00d539SAndreas Färberif compile_prog "" "" ; then
4223bd00d539SAndreas Färber  pthread=yes
4224bd00d539SAndreas Färberelse
4225de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
422652166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
4227e5d355d1Saliguori      pthread=yes
4228e3c56761SPeter Portante      found=no
4229e3c56761SPeter Portante      for lib_entry in $LIBS; do
4230e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
4231e3c56761SPeter Portante          found=yes
4232e3c56761SPeter Portante          break
4233e3c56761SPeter Portante        fi
4234e3c56761SPeter Portante      done
4235e3c56761SPeter Portante      if test "$found" = "no"; then
42365572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
4237e3c56761SPeter Portante      fi
4238409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
4239de65fe0fSSebastian Herbszt      break
4240414f0dabSblueswir1    fi
4241de65fe0fSSebastian Herbszt  done
4242bd00d539SAndreas Färberfi
4243414f0dabSblueswir1
4244e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
424576ad07a4SPeter Maydell  error_exit "pthread check failed" \
424676ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
4247e5d355d1Saliguorifi
4248e5d355d1Saliguori
4249479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
4250479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
42515c312079SDr. David Alan Gilbertcat > $TMPC << EOF
42525c312079SDr. David Alan Gilbert#include <pthread.h>
42535c312079SDr. David Alan Gilbert
42545c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
42555c312079SDr. David Alan Gilbertint main(void)
42565c312079SDr. David Alan Gilbert{
42575c312079SDr. David Alan Gilbert    pthread_t thread;
42585c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
42595c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
42605c312079SDr. David Alan Gilbert    return 0;
42615c312079SDr. David Alan Gilbert}
42625c312079SDr. David Alan GilbertEOF
42635c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
4264479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
4265479a5747SRoman Bolshakovfi
4266479a5747SRoman Bolshakov
4267479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
4268479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
4269479a5747SRoman Bolshakovcat > $TMPC << EOF
4270479a5747SRoman Bolshakov#include <pthread.h>
4271479a5747SRoman Bolshakov
427212a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
4273479a5747SRoman Bolshakovint main(void)
4274479a5747SRoman Bolshakov{
4275479a5747SRoman Bolshakov    pthread_t thread;
4276479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
4277479a5747SRoman Bolshakov    return 0;
4278479a5747SRoman Bolshakov}
4279479a5747SRoman BolshakovEOF
4280479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
4281479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
42825c312079SDr. David Alan Gilbertfi
42835c312079SDr. David Alan Gilbert
4284bf9298b9Saliguori##########################################
4285f27aaf4bSChristian Brunner# rbd probe
4286f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
4287f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
4288f27aaf4bSChristian Brunner#include <stdio.h>
4289ad32e9c0SJosh Durgin#include <rbd/librbd.h>
4290f27aaf4bSChristian Brunnerint main(void) {
4291ad32e9c0SJosh Durgin    rados_t cluster;
4292ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
4293f27aaf4bSChristian Brunner    return 0;
4294f27aaf4bSChristian Brunner}
4295f27aaf4bSChristian BrunnerEOF
4296ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
4297f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
4298f27aaf4bSChristian Brunner    rbd=yes
4299f27aaf4bSChristian Brunner  else
4300f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
430121684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
4302f27aaf4bSChristian Brunner    fi
4303f27aaf4bSChristian Brunner    rbd=no
4304f27aaf4bSChristian Brunner  fi
4305f27aaf4bSChristian Brunnerfi
4306f27aaf4bSChristian Brunner
4307f27aaf4bSChristian Brunner##########################################
4308b10d49d7SPino Toscano# libssh probe
4309b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
4310b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
4311b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
4312b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
4313b10d49d7SPino Toscano    libssh=yes
43140a12ec87SRichard W.M. Jones  else
4315b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
4316b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
43170a12ec87SRichard W.M. Jones    fi
4318b10d49d7SPino Toscano    libssh=no
43190a12ec87SRichard W.M. Jones  fi
43200a12ec87SRichard W.M. Jonesfi
43210a12ec87SRichard W.M. Jones
43220a12ec87SRichard W.M. Jones##########################################
4323b10d49d7SPino Toscano# Check for libssh 0.8
4324b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
4325b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
4326b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
4327b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
43289a2d462eSRichard W.M. Jones
4329b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
43309a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
4331b10d49d7SPino Toscano#include <libssh/libssh.h>
4332b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
43339a2d462eSRichard W.M. JonesEOF
4334b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
4335b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
43369a2d462eSRichard W.M. Jones  fi
43379a2d462eSRichard W.M. Jonesfi
43389a2d462eSRichard W.M. Jones
43399a2d462eSRichard W.M. Jones##########################################
43405c6c3a6cSChristoph Hellwig# linux-aio probe
43415c6c3a6cSChristoph Hellwig
43425c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
43435c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
43445c6c3a6cSChristoph Hellwig#include <libaio.h>
43455c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
4346832ce9c2SScott Wood#include <stddef.h>
43475c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
43485c6c3a6cSChristoph HellwigEOF
43495c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
43505c6c3a6cSChristoph Hellwig    linux_aio=yes
43515c6c3a6cSChristoph Hellwig  else
43525c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
435321684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
43545c6c3a6cSChristoph Hellwig    fi
43553cfcae3cSLuiz Capitulino    linux_aio=no
43565c6c3a6cSChristoph Hellwig  fi
43575c6c3a6cSChristoph Hellwigfi
4358c10dd856SAarushi Mehta##########################################
4359c10dd856SAarushi Mehta# linux-io-uring probe
4360c10dd856SAarushi Mehta
4361c10dd856SAarushi Mehtaif test "$linux_io_uring" != "no" ; then
4362c10dd856SAarushi Mehta  if $pkg_config liburing; then
4363c10dd856SAarushi Mehta    linux_io_uring_cflags=$($pkg_config --cflags liburing)
4364c10dd856SAarushi Mehta    linux_io_uring_libs=$($pkg_config --libs liburing)
4365c10dd856SAarushi Mehta    linux_io_uring=yes
436673fd282eSStefan Hajnoczi
436773fd282eSStefan Hajnoczi    # io_uring is used in libqemuutil.a where per-file -libs variables are not
436873fd282eSStefan Hajnoczi    # seen by programs linking the archive.  It's not ideal, but just add the
436973fd282eSStefan Hajnoczi    # library dependency globally.
437073fd282eSStefan Hajnoczi    LIBS="$linux_io_uring_libs $LIBS"
4371c10dd856SAarushi Mehta  else
4372c10dd856SAarushi Mehta    if test "$linux_io_uring" = "yes" ; then
4373c10dd856SAarushi Mehta      feature_not_found "linux io_uring" "Install liburing devel"
4374c10dd856SAarushi Mehta    fi
4375c10dd856SAarushi Mehta    linux_io_uring=no
4376c10dd856SAarushi Mehta  fi
4377c10dd856SAarushi Mehtafi
43785c6c3a6cSChristoph Hellwig
43795c6c3a6cSChristoph Hellwig##########################################
43807aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
43813b8acc11SPaolo Bonzini
43827aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
43837aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
43847aaa6a16SPaolo Bonzini    tpm=no
43853b8acc11SPaolo Bonzini  else
43867aaa6a16SPaolo Bonzini    tpm=yes
43877aaa6a16SPaolo Bonzini  fi
43887aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
43897aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
43907aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
43917aaa6a16SPaolo Bonzini  fi
43923b8acc11SPaolo Bonzinifi
43933b8acc11SPaolo Bonzini
43943b8acc11SPaolo Bonzini##########################################
4395758e8e38SVenkateswararao Jujjuri (JV)# attr probe
4396758e8e38SVenkateswararao Jujjuri (JV)
4397ec0d5893SMarc-André Lureaulibattr_libs=
4398758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
4399758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
4400758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
4401758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
4402f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
4403f2338fb4SPavel Borzenkov#include <attr/xattr.h>
4404f2338fb4SPavel Borzenkov#else
44054f26f2b6SAvi Kivity#include <sys/xattr.h>
4406f2338fb4SPavel Borzenkov#endif
4407758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
4408758e8e38SVenkateswararao Jujjuri (JV)EOF
44094f26f2b6SAvi Kivity  if compile_prog "" "" ; then
44104f26f2b6SAvi Kivity    attr=yes
44114f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
4412f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
4413758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
4414ec0d5893SMarc-André Lureau    libattr_libs="-lattr"
4415ec0d5893SMarc-André Lureau    LIBS="$libattr_libs $LIBS"
44164f26f2b6SAvi Kivity    libattr=yes
4417758e8e38SVenkateswararao Jujjuri (JV)  else
4418758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
441921684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
4420758e8e38SVenkateswararao Jujjuri (JV)    fi
4421758e8e38SVenkateswararao Jujjuri (JV)    attr=no
4422758e8e38SVenkateswararao Jujjuri (JV)  fi
4423758e8e38SVenkateswararao Jujjuri (JV)fi
4424758e8e38SVenkateswararao Jujjuri (JV)
4425758e8e38SVenkateswararao Jujjuri (JV)##########################################
4426bf9298b9Saliguori# iovec probe
4427bf9298b9Saliguoricat > $TMPC <<EOF
4428db34f0b3Sblueswir1#include <sys/types.h>
4429bf9298b9Saliguori#include <sys/uio.h>
4430db34f0b3Sblueswir1#include <unistd.h>
4431f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
4432bf9298b9SaliguoriEOF
4433bf9298b9Saliguoriiovec=no
443452166aa0SJuan Quintelaif compile_prog "" "" ; then
4435bf9298b9Saliguori  iovec=yes
4436bf9298b9Saliguorifi
4437bf9298b9Saliguori
4438f652e6afSaurel32##########################################
4439ceb42de8Saliguori# preadv probe
4440ceb42de8Saliguoricat > $TMPC <<EOF
4441ceb42de8Saliguori#include <sys/types.h>
4442ceb42de8Saliguori#include <sys/uio.h>
4443ceb42de8Saliguori#include <unistd.h>
4444c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
4445ceb42de8SaliguoriEOF
4446ceb42de8Saliguoripreadv=no
444752166aa0SJuan Quintelaif compile_prog "" "" ; then
4448ceb42de8Saliguori  preadv=yes
4449ceb42de8Saliguorifi
4450ceb42de8Saliguori
4451ceb42de8Saliguori##########################################
4452f652e6afSaurel32# fdt probe
4453e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
4454e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
4455e169e1e1SPeter Maydellfdt_required=no
4456e169e1e1SPeter Maydellfor target in $target_list; do
4457e169e1e1SPeter Maydell  case $target in
4458c8c35e5fSYoshinori Sato    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu|rx-softmmu)
4459e169e1e1SPeter Maydell      fdt_required=yes
4460e169e1e1SPeter Maydell    ;;
4461e169e1e1SPeter Maydell  esac
4462e169e1e1SPeter Maydelldone
4463e169e1e1SPeter Maydell
4464e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
4465e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
4466e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
4467e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
4468e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
4469e169e1e1SPeter Maydell  fi
4470e169e1e1SPeter Maydell  fdt=yes
44717ba4a4d3SPhilippe Mathieu-Daudéelif test "$fdt" != "yes" ; then
44727ba4a4d3SPhilippe Mathieu-Daudé  fdt=no
4473e169e1e1SPeter Maydellfi
4474e169e1e1SPeter Maydell
4475d599938aSLaurent Vivier# fdt is only required when building softmmu targets
4476d599938aSLaurent Vivierif test -z "$fdt" -a "$softmmu" != "yes" ; then
4477d599938aSLaurent Vivier    fdt="no"
4478d599938aSLaurent Vivierfi
4479d599938aSLaurent Vivier
44802df87df7SJuan Quintelaif test "$fdt" != "no" ; then
4481b41af4baSJuan Quintela  fdt_libs="-lfdt"
448296ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
44836e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
4484f652e6afSaurel32  cat > $TMPC << EOF
448531ce0adbSThomas Huth#include <libfdt.h>
448696ce6545SPeter Crosthwaite#include <libfdt_env.h>
4487fea35ca4SAlexey Kardashevskiyint main(void) { fdt_check_full(NULL, 0); return 0; }
4488f652e6afSaurel32EOF
448952166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
4490a540f158SPeter Crosthwaite    # system DTC is good - use it
4491e3971d61SPhilippe Mathieu-Daudé    fdt=system
4492aef45d51SDaniel P. Berrange  else
4493aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
4494aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
4495aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
4496aef45d51SDaniel P. Berrange      fi
4497aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4498e3971d61SPhilippe Mathieu-Daudé          fdt=git
4499a540f158SPeter Crosthwaite          mkdir -p dtc
4500cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
4501a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
45022df87df7SJuan Quintela          fi
450325211446SPaolo Bonzini          fdt_cflags="-I${source_path}/dtc/libfdt"
450425211446SPaolo Bonzini          fdt_ldflags="-L$PWD/dtc/libfdt"
45058a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
4506a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
4507aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
4508aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4509aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
4510a540f158SPeter Crosthwaite      else
4511a540f158SPeter Crosthwaite          # don't have and don't want
4512de3a354aSMichael Walle          fdt_libs=
45132df87df7SJuan Quintela          fdt=no
4514f652e6afSaurel32      fi
4515f652e6afSaurel32  fi
4516aef45d51SDaniel P. Berrangefi
4517f652e6afSaurel32
4518a540f158SPeter Crosthwaitelibs_softmmu="$libs_softmmu $fdt_libs"
4519a540f158SPeter Crosthwaite
452020ff075bSMichael Walle##########################################
4521fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
4522b1546f32SGerd Hoffmann
4523d52c454aSMarc-André Lureaugbm="no"
4524d52c454aSMarc-André Lureauif $pkg_config gbm; then
4525d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
4526d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
4527d52c454aSMarc-André Lureau    gbm="yes"
4528d52c454aSMarc-André Lureaufi
4529d52c454aSMarc-André Lureau
4530da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
45314939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
45325f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
45335f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
45345f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4535da076ffeSGerd Hoffmann    opengl=yes
4536925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4537925a0400SGerd Hoffmann        gtk_gl="yes"
4538925a0400SGerd Hoffmann    fi
4539cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
454020ff075bSMichael Walle  else
4541da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
4542dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
454320ff075bSMichael Walle    fi
4544f676c67eSJeremy White    opengl_cflags=""
4545da076ffeSGerd Hoffmann    opengl_libs=""
4546da076ffeSGerd Hoffmann    opengl=no
454720ff075bSMichael Walle  fi
454820ff075bSMichael Wallefi
454920ff075bSMichael Walle
4550014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
4551014cb152SGerd Hoffmann  cat > $TMPC << EOF
4552014cb152SGerd Hoffmann#include <epoxy/egl.h>
4553014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
4554014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4555014cb152SGerd Hoffmann#endif
4556014cb152SGerd Hoffmannint main(void) { return 0; }
4557014cb152SGerd HoffmannEOF
4558014cb152SGerd Hoffmann  if compile_prog "" "" ; then
4559014cb152SGerd Hoffmann    opengl_dmabuf=yes
4560014cb152SGerd Hoffmann  fi
4561014cb152SGerd Hoffmannfi
4562c9a12e75SChrysostomos Nanakos
4563e633a5c6SEric Blakeif test "$opengl" = "yes" && test "$have_x11" = "yes"; then
456499e1a93bSPhilippe Mathieu-Daudé  for target in $target_list; do
456599e1a93bSPhilippe Mathieu-Daudé    case $target in
456699e1a93bSPhilippe Mathieu-Daudé      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
456799e1a93bSPhilippe Mathieu-Daudé        need_x11=yes
456899e1a93bSPhilippe Mathieu-Daudé      ;;
456999e1a93bSPhilippe Mathieu-Daudé    esac
457099e1a93bSPhilippe Mathieu-Daudé  done
457199e1a93bSPhilippe Mathieu-Daudéfi
457299e1a93bSPhilippe Mathieu-Daudé
4573ed279a06SKlim Kireev##########################################
4574ed279a06SKlim Kireev# libxml2 probe
4575ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
4576ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
4577ed279a06SKlim Kireev        libxml2="yes"
4578ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4579ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
4580ed279a06SKlim Kireev    else
4581ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4582ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4583ed279a06SKlim Kireev        fi
4584ed279a06SKlim Kireev        libxml2="no"
4585ed279a06SKlim Kireev    fi
4586ed279a06SKlim Kireevfi
4587c9a12e75SChrysostomos Nanakos
4588eb100396SBharata B Rao##########################################
4589eb100396SBharata B Rao# glusterfs probe
4590eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
459165d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4592e01bee08SBharata B Rao    glusterfs="yes"
459389138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
459489138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4595d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4596d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4597d85fa9ebSJeff Cody    fi
459865d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
45990c14fb47SBharata B Rao      glusterfs_discard="yes"
46000c14fb47SBharata B Rao    fi
46017c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4602df3a429aSNiels de Vos      glusterfs_fallocate="yes"
46037c815372SBharata B Rao      glusterfs_zerofill="yes"
46047c815372SBharata B Rao    fi
4605e014dbe7SPrasanna Kumar Kalever    cat > $TMPC << EOF
4606e014dbe7SPrasanna Kumar Kalever#include <glusterfs/api/glfs.h>
4607e014dbe7SPrasanna Kumar Kalever
4608e014dbe7SPrasanna Kumar Kaleverint
4609e014dbe7SPrasanna Kumar Kalevermain(void)
4610e014dbe7SPrasanna Kumar Kalever{
4611e014dbe7SPrasanna Kumar Kalever	/* new glfs_ftruncate() passes two additional args */
4612e014dbe7SPrasanna Kumar Kalever	return glfs_ftruncate(NULL, 0, NULL, NULL);
4613e014dbe7SPrasanna Kumar Kalever}
4614e014dbe7SPrasanna Kumar KaleverEOF
4615e014dbe7SPrasanna Kumar Kalever    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4616e014dbe7SPrasanna Kumar Kalever      glusterfs_ftruncate_has_stat="yes"
4617e014dbe7SPrasanna Kumar Kalever    fi
46180e3b891fSNiels de Vos    cat > $TMPC << EOF
46190e3b891fSNiels de Vos#include <glusterfs/api/glfs.h>
46200e3b891fSNiels de Vos
46210e3b891fSNiels de Vos/* new glfs_io_cbk() passes two additional glfs_stat structs */
46220e3b891fSNiels de Vosstatic void
46230e3b891fSNiels de Vosglusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
46240e3b891fSNiels de Vos{}
46250e3b891fSNiels de Vos
46260e3b891fSNiels de Vosint
46270e3b891fSNiels de Vosmain(void)
46280e3b891fSNiels de Vos{
46290e3b891fSNiels de Vos	glfs_io_cbk iocb = &glusterfs_iocb;
46300e3b891fSNiels de Vos	iocb(NULL, 0 , NULL, NULL, NULL);
46310e3b891fSNiels de Vos	return 0;
46320e3b891fSNiels de Vos}
46330e3b891fSNiels de VosEOF
46340e3b891fSNiels de Vos    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
46350e3b891fSNiels de Vos      glusterfs_iocb_has_stat="yes"
46360e3b891fSNiels de Vos    fi
4637eb100396SBharata B Rao  else
4638eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
46398efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
46408efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4641eb100396SBharata B Rao    fi
4642e01bee08SBharata B Rao    glusterfs="no"
4643eb100396SBharata B Rao  fi
4644eb100396SBharata B Raofi
4645eb100396SBharata B Rao
464639386ac7Saurel32# Check for inotify functions when we are building linux-user
46473b3f24adSaurel32# emulator.  This is done because older glibc versions don't
46483b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
46493b3f24adSaurel32# don't provide them even if kernel supports them.
46503b3f24adSaurel32#
46513b3f24adSaurel32inotify=no
46523b3f24adSaurel32cat > $TMPC << EOF
46533b3f24adSaurel32#include <sys/inotify.h>
46543b3f24adSaurel32
46553b3f24adSaurel32int
46563b3f24adSaurel32main(void)
46573b3f24adSaurel32{
46583b3f24adSaurel32	/* try to start inotify */
46598690e420Saurel32	return inotify_init();
46603b3f24adSaurel32}
46613b3f24adSaurel32EOF
466252166aa0SJuan Quintelaif compile_prog "" "" ; then
46633b3f24adSaurel32  inotify=yes
46643b3f24adSaurel32fi
46653b3f24adSaurel32
4666c05c7a73SRiku Voipioinotify1=no
4667c05c7a73SRiku Voipiocat > $TMPC << EOF
4668c05c7a73SRiku Voipio#include <sys/inotify.h>
4669c05c7a73SRiku Voipio
4670c05c7a73SRiku Voipioint
4671c05c7a73SRiku Voipiomain(void)
4672c05c7a73SRiku Voipio{
4673c05c7a73SRiku Voipio    /* try to start inotify */
4674c05c7a73SRiku Voipio    return inotify_init1(0);
4675c05c7a73SRiku Voipio}
4676c05c7a73SRiku VoipioEOF
4677c05c7a73SRiku Voipioif compile_prog "" "" ; then
4678c05c7a73SRiku Voipio  inotify1=yes
4679c05c7a73SRiku Voipiofi
4680c05c7a73SRiku Voipio
4681099d6b0fSRiku Voipio# check if pipe2 is there
4682099d6b0fSRiku Voipiopipe2=no
4683099d6b0fSRiku Voipiocat > $TMPC << EOF
4684099d6b0fSRiku Voipio#include <unistd.h>
4685099d6b0fSRiku Voipio#include <fcntl.h>
4686099d6b0fSRiku Voipio
4687099d6b0fSRiku Voipioint main(void)
4688099d6b0fSRiku Voipio{
4689099d6b0fSRiku Voipio    int pipefd[2];
46909bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4691099d6b0fSRiku Voipio}
4692099d6b0fSRiku VoipioEOF
469352166aa0SJuan Quintelaif compile_prog "" "" ; then
4694099d6b0fSRiku Voipio  pipe2=yes
4695099d6b0fSRiku Voipiofi
4696099d6b0fSRiku Voipio
469740ff6d7eSKevin Wolf# check if accept4 is there
469840ff6d7eSKevin Wolfaccept4=no
469940ff6d7eSKevin Wolfcat > $TMPC << EOF
470040ff6d7eSKevin Wolf#include <sys/socket.h>
470140ff6d7eSKevin Wolf#include <stddef.h>
470240ff6d7eSKevin Wolf
470340ff6d7eSKevin Wolfint main(void)
470440ff6d7eSKevin Wolf{
470540ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
470640ff6d7eSKevin Wolf    return 0;
470740ff6d7eSKevin Wolf}
470840ff6d7eSKevin WolfEOF
470940ff6d7eSKevin Wolfif compile_prog "" "" ; then
471040ff6d7eSKevin Wolf  accept4=yes
471140ff6d7eSKevin Wolffi
471240ff6d7eSKevin Wolf
47133ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
47143ce34dfbSvibisreenivasansplice=no
47153ce34dfbSvibisreenivasancat > $TMPC << EOF
47163ce34dfbSvibisreenivasan#include <unistd.h>
47173ce34dfbSvibisreenivasan#include <fcntl.h>
47183ce34dfbSvibisreenivasan#include <limits.h>
47193ce34dfbSvibisreenivasan
47203ce34dfbSvibisreenivasanint main(void)
47213ce34dfbSvibisreenivasan{
472266ea0f22SStefan Weil    int len, fd = 0;
47233ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
47243ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
47253ce34dfbSvibisreenivasan    return 0;
47263ce34dfbSvibisreenivasan}
47273ce34dfbSvibisreenivasanEOF
472852166aa0SJuan Quintelaif compile_prog "" "" ; then
47293ce34dfbSvibisreenivasan  splice=yes
47303ce34dfbSvibisreenivasanfi
47313ce34dfbSvibisreenivasan
4732dcc38d1cSMarcelo Tosatti##########################################
4733a99d57bbSWanlong Gao# libnuma probe
4734a99d57bbSWanlong Gao
4735a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4736a99d57bbSWanlong Gao  cat > $TMPC << EOF
4737a99d57bbSWanlong Gao#include <numa.h>
4738a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4739a99d57bbSWanlong GaoEOF
4740a99d57bbSWanlong Gao
4741a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4742a99d57bbSWanlong Gao    numa=yes
4743a99d57bbSWanlong Gao    libs_softmmu="-lnuma $libs_softmmu"
4744*ab318051SMarc-André Lureau    numa_libs="-lnuma"
4745a99d57bbSWanlong Gao  else
4746a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4747a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4748a99d57bbSWanlong Gao    fi
4749a99d57bbSWanlong Gao    numa=no
4750a99d57bbSWanlong Gao  fi
4751a99d57bbSWanlong Gaofi
4752a99d57bbSWanlong Gao
47537b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
47547b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
47557b01cb97SAlexandre Derumier    exit 1
47567b01cb97SAlexandre Derumierfi
47577b01cb97SAlexandre Derumier
47585a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
47595a22ab71SYang Zhong# do not support it.
47605a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
47615a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
47625a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
47635a22ab71SYang Zhong    fi
47645a22ab71SYang Zhong    malloc_trim="no"
47655a22ab71SYang Zhongfi
47665a22ab71SYang Zhong
47675a22ab71SYang Zhong#######################################
47685a22ab71SYang Zhong# malloc_trim
47695a22ab71SYang Zhong
47705a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
47715a22ab71SYang Zhong    cat > $TMPC << EOF
47725a22ab71SYang Zhong#include <malloc.h>
47735a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
47745a22ab71SYang ZhongEOF
47755a22ab71SYang Zhong    if compile_prog "" "" ; then
47765a22ab71SYang Zhong        malloc_trim="yes"
47775a22ab71SYang Zhong    else
47785a22ab71SYang Zhong        malloc_trim="no"
47795a22ab71SYang Zhong    fi
47805a22ab71SYang Zhongfi
47815a22ab71SYang Zhong
4782a99d57bbSWanlong Gao##########################################
47832847b469SFam Zheng# tcmalloc probe
47842847b469SFam Zheng
47852847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
47862847b469SFam Zheng  cat > $TMPC << EOF
47872847b469SFam Zheng#include <stdlib.h>
4788f2dfe54cSLeonid Blochint main(void) {
4789f2dfe54cSLeonid Bloch    void *tmp = malloc(1);
4790f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4791f2dfe54cSLeonid Bloch        return 0;
4792f2dfe54cSLeonid Bloch    }
4793f2dfe54cSLeonid Bloch    return 1;
4794f2dfe54cSLeonid Bloch}
47952847b469SFam ZhengEOF
47962847b469SFam Zheng
47972847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
47982847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
47992847b469SFam Zheng  else
48002847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
48012847b469SFam Zheng  fi
48022847b469SFam Zhengfi
48032847b469SFam Zheng
48042847b469SFam Zheng##########################################
48057b01cb97SAlexandre Derumier# jemalloc probe
48067b01cb97SAlexandre Derumier
48077b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
48087b01cb97SAlexandre Derumier  cat > $TMPC << EOF
48097b01cb97SAlexandre Derumier#include <stdlib.h>
4810f2dfe54cSLeonid Blochint main(void) {
4811f2dfe54cSLeonid Bloch    void *tmp = malloc(1);
4812f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4813f2dfe54cSLeonid Bloch        return 0;
4814f2dfe54cSLeonid Bloch    }
4815f2dfe54cSLeonid Bloch    return 1;
4816f2dfe54cSLeonid Bloch}
48177b01cb97SAlexandre DerumierEOF
48187b01cb97SAlexandre Derumier
48197b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
48207b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
48217b01cb97SAlexandre Derumier  else
48227b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
48237b01cb97SAlexandre Derumier  fi
48247b01cb97SAlexandre Derumierfi
48257b01cb97SAlexandre Derumier
48267b01cb97SAlexandre Derumier##########################################
4827dcc38d1cSMarcelo Tosatti# signalfd probe
4828dcc38d1cSMarcelo Tosattisignalfd="no"
4829dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4830dcc38d1cSMarcelo Tosatti#include <unistd.h>
4831dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4832dcc38d1cSMarcelo Tosatti#include <signal.h>
4833dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4834dcc38d1cSMarcelo TosattiEOF
4835dcc38d1cSMarcelo Tosatti
4836dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4837dcc38d1cSMarcelo Tosatti  signalfd=yes
4838dcc38d1cSMarcelo Tosattifi
4839dcc38d1cSMarcelo Tosatti
4840d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4841d339d766SRichard W.M. Jonesoptreset="no"
4842d339d766SRichard W.M. Jonescat > $TMPC << EOF
4843d339d766SRichard W.M. Jones#include <getopt.h>
4844d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4845d339d766SRichard W.M. JonesEOF
4846d339d766SRichard W.M. Jones
4847d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4848d339d766SRichard W.M. Jones  optreset=yes
4849d339d766SRichard W.M. Jonesfi
4850d339d766SRichard W.M. Jones
4851c2882b96SRiku Voipio# check if eventfd is supported
4852c2882b96SRiku Voipioeventfd=no
4853c2882b96SRiku Voipiocat > $TMPC << EOF
4854c2882b96SRiku Voipio#include <sys/eventfd.h>
4855c2882b96SRiku Voipio
4856c2882b96SRiku Voipioint main(void)
4857c2882b96SRiku Voipio{
485855cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4859c2882b96SRiku Voipio}
4860c2882b96SRiku VoipioEOF
4861c2882b96SRiku Voipioif compile_prog "" "" ; then
4862c2882b96SRiku Voipio  eventfd=yes
4863c2882b96SRiku Voipiofi
4864c2882b96SRiku Voipio
4865751bcc39SMarc-André Lureau# check if memfd is supported
4866751bcc39SMarc-André Lureaumemfd=no
4867751bcc39SMarc-André Lureaucat > $TMPC << EOF
486875e5b70eSPaolo Bonzini#include <sys/mman.h>
4869751bcc39SMarc-André Lureau
4870751bcc39SMarc-André Lureauint main(void)
4871751bcc39SMarc-André Lureau{
4872751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4873751bcc39SMarc-André Lureau}
4874751bcc39SMarc-André LureauEOF
4875751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4876751bcc39SMarc-André Lureau  memfd=yes
4877751bcc39SMarc-André Lureaufi
4878751bcc39SMarc-André Lureau
4879955727d2SCortland Tölva# check for usbfs
4880955727d2SCortland Tölvahave_usbfs=no
4881955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
488296566d09SThomas Petazzoni  cat > $TMPC << EOF
488396566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
488496566d09SThomas Petazzoni
488596566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
488696566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
488796566d09SThomas Petazzoni#endif
488896566d09SThomas Petazzoni
488996566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
489096566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
489196566d09SThomas Petazzoni#endif
489296566d09SThomas Petazzoni
489396566d09SThomas Petazzoniint main(void)
489496566d09SThomas Petazzoni{
489596566d09SThomas Petazzoni    return 0;
489696566d09SThomas Petazzoni}
489796566d09SThomas PetazzoniEOF
489896566d09SThomas Petazzoni  if compile_prog "" ""; then
4899955727d2SCortland Tölva    have_usbfs=yes
4900955727d2SCortland Tölva  fi
4901955727d2SCortland Tölvafi
4902751bcc39SMarc-André Lureau
4903d0927938SUlrich Hecht# check for fallocate
4904d0927938SUlrich Hechtfallocate=no
4905d0927938SUlrich Hechtcat > $TMPC << EOF
4906d0927938SUlrich Hecht#include <fcntl.h>
4907d0927938SUlrich Hecht
4908d0927938SUlrich Hechtint main(void)
4909d0927938SUlrich Hecht{
4910d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4911d0927938SUlrich Hecht    return 0;
4912d0927938SUlrich Hecht}
4913d0927938SUlrich HechtEOF
49148fb03151SPeter Maydellif compile_prog "" "" ; then
4915d0927938SUlrich Hecht  fallocate=yes
4916d0927938SUlrich Hechtfi
4917d0927938SUlrich Hecht
49183d4fa43eSKusanagi Kouichi# check for fallocate hole punching
49193d4fa43eSKusanagi Kouichifallocate_punch_hole=no
49203d4fa43eSKusanagi Kouichicat > $TMPC << EOF
49213d4fa43eSKusanagi Kouichi#include <fcntl.h>
49223d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
49233d4fa43eSKusanagi Kouichi
49243d4fa43eSKusanagi Kouichiint main(void)
49253d4fa43eSKusanagi Kouichi{
49263d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
49273d4fa43eSKusanagi Kouichi    return 0;
49283d4fa43eSKusanagi Kouichi}
49293d4fa43eSKusanagi KouichiEOF
49303d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
49313d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
49323d4fa43eSKusanagi Kouichifi
49333d4fa43eSKusanagi Kouichi
4934b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4935b953f075SDenis V. Lunevfallocate_zero_range=no
4936b953f075SDenis V. Lunevcat > $TMPC << EOF
4937b953f075SDenis V. Lunev#include <fcntl.h>
4938b953f075SDenis V. Lunev#include <linux/falloc.h>
4939b953f075SDenis V. Lunev
4940b953f075SDenis V. Lunevint main(void)
4941b953f075SDenis V. Lunev{
4942b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4943b953f075SDenis V. Lunev    return 0;
4944b953f075SDenis V. Lunev}
4945b953f075SDenis V. LunevEOF
4946b953f075SDenis V. Lunevif compile_prog "" "" ; then
4947b953f075SDenis V. Lunev  fallocate_zero_range=yes
4948b953f075SDenis V. Lunevfi
4949b953f075SDenis V. Lunev
4950ed911435SKevin Wolf# check for posix_fallocate
4951ed911435SKevin Wolfposix_fallocate=no
4952ed911435SKevin Wolfcat > $TMPC << EOF
4953ed911435SKevin Wolf#include <fcntl.h>
4954ed911435SKevin Wolf
4955ed911435SKevin Wolfint main(void)
4956ed911435SKevin Wolf{
4957ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4958ed911435SKevin Wolf    return 0;
4959ed911435SKevin Wolf}
4960ed911435SKevin WolfEOF
4961ed911435SKevin Wolfif compile_prog "" "" ; then
4962ed911435SKevin Wolf    posix_fallocate=yes
4963ed911435SKevin Wolffi
4964ed911435SKevin Wolf
4965c727f47dSPeter Maydell# check for sync_file_range
4966c727f47dSPeter Maydellsync_file_range=no
4967c727f47dSPeter Maydellcat > $TMPC << EOF
4968c727f47dSPeter Maydell#include <fcntl.h>
4969c727f47dSPeter Maydell
4970c727f47dSPeter Maydellint main(void)
4971c727f47dSPeter Maydell{
4972c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4973c727f47dSPeter Maydell    return 0;
4974c727f47dSPeter Maydell}
4975c727f47dSPeter MaydellEOF
49768fb03151SPeter Maydellif compile_prog "" "" ; then
4977c727f47dSPeter Maydell  sync_file_range=yes
4978c727f47dSPeter Maydellfi
4979c727f47dSPeter Maydell
4980dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4981dace20dcSPeter Maydellfiemap=no
4982dace20dcSPeter Maydellcat > $TMPC << EOF
4983dace20dcSPeter Maydell#include <sys/ioctl.h>
4984dace20dcSPeter Maydell#include <linux/fs.h>
4985dace20dcSPeter Maydell#include <linux/fiemap.h>
4986dace20dcSPeter Maydell
4987dace20dcSPeter Maydellint main(void)
4988dace20dcSPeter Maydell{
4989dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4990dace20dcSPeter Maydell    return 0;
4991dace20dcSPeter Maydell}
4992dace20dcSPeter MaydellEOF
49938fb03151SPeter Maydellif compile_prog "" "" ; then
4994dace20dcSPeter Maydell  fiemap=yes
4995dace20dcSPeter Maydellfi
4996dace20dcSPeter Maydell
4997d0927938SUlrich Hecht# check for dup3
4998d0927938SUlrich Hechtdup3=no
4999d0927938SUlrich Hechtcat > $TMPC << EOF
5000d0927938SUlrich Hecht#include <unistd.h>
5001d0927938SUlrich Hecht
5002d0927938SUlrich Hechtint main(void)
5003d0927938SUlrich Hecht{
5004d0927938SUlrich Hecht    dup3(0, 0, 0);
5005d0927938SUlrich Hecht    return 0;
5006d0927938SUlrich Hecht}
5007d0927938SUlrich HechtEOF
500878f5d726SJan Kiszkaif compile_prog "" "" ; then
5009d0927938SUlrich Hecht  dup3=yes
5010d0927938SUlrich Hechtfi
5011d0927938SUlrich Hecht
50124e0c6529SAlex Bligh# check for ppoll support
50134e0c6529SAlex Blighppoll=no
50144e0c6529SAlex Blighcat > $TMPC << EOF
50154e0c6529SAlex Bligh#include <poll.h>
50164e0c6529SAlex Bligh
50174e0c6529SAlex Blighint main(void)
50184e0c6529SAlex Bligh{
50194e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
50204e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
50214e0c6529SAlex Bligh    return 0;
50224e0c6529SAlex Bligh}
50234e0c6529SAlex BlighEOF
50244e0c6529SAlex Blighif compile_prog "" "" ; then
50254e0c6529SAlex Bligh  ppoll=yes
50264e0c6529SAlex Blighfi
50274e0c6529SAlex Bligh
5028cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
5029cd758dd0SAlex Blighprctl_pr_set_timerslack=no
5030cd758dd0SAlex Blighcat > $TMPC << EOF
5031cd758dd0SAlex Bligh#include <sys/prctl.h>
5032cd758dd0SAlex Bligh
5033cd758dd0SAlex Blighint main(void)
5034cd758dd0SAlex Bligh{
5035cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
5036cd758dd0SAlex Bligh    return 0;
5037cd758dd0SAlex Bligh}
5038cd758dd0SAlex BlighEOF
5039cd758dd0SAlex Blighif compile_prog "" "" ; then
5040cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
5041cd758dd0SAlex Blighfi
5042cd758dd0SAlex Bligh
50433b6edd16SPeter Maydell# check for epoll support
50443b6edd16SPeter Maydellepoll=no
50453b6edd16SPeter Maydellcat > $TMPC << EOF
50463b6edd16SPeter Maydell#include <sys/epoll.h>
50473b6edd16SPeter Maydell
50483b6edd16SPeter Maydellint main(void)
50493b6edd16SPeter Maydell{
50503b6edd16SPeter Maydell    epoll_create(0);
50513b6edd16SPeter Maydell    return 0;
50523b6edd16SPeter Maydell}
50533b6edd16SPeter MaydellEOF
50548fb03151SPeter Maydellif compile_prog "" "" ; then
50553b6edd16SPeter Maydell  epoll=yes
50563b6edd16SPeter Maydellfi
50573b6edd16SPeter Maydell
5058227f0214SPeter Maydell# epoll_create1 is a later addition
5059227f0214SPeter Maydell# so we must check separately for its presence
50603b6edd16SPeter Maydellepoll_create1=no
50613b6edd16SPeter Maydellcat > $TMPC << EOF
50623b6edd16SPeter Maydell#include <sys/epoll.h>
50633b6edd16SPeter Maydell
50643b6edd16SPeter Maydellint main(void)
50653b6edd16SPeter Maydell{
506619e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
506719e83f6bSPeter Maydell     * a function being called. This is necessary so that on
506819e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
506919e83f6bSPeter Maydell     * the library but not declared in the header file we will
507019e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
507119e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
507219e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
507319e83f6bSPeter Maydell     */
5074c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
50753b6edd16SPeter Maydell}
50763b6edd16SPeter MaydellEOF
50778fb03151SPeter Maydellif compile_prog "" "" ; then
50783b6edd16SPeter Maydell  epoll_create1=yes
50793b6edd16SPeter Maydellfi
50803b6edd16SPeter Maydell
5081a8fd1abaSPeter Maydell# check for sendfile support
5082a8fd1abaSPeter Maydellsendfile=no
5083a8fd1abaSPeter Maydellcat > $TMPC << EOF
5084a8fd1abaSPeter Maydell#include <sys/sendfile.h>
5085a8fd1abaSPeter Maydell
5086a8fd1abaSPeter Maydellint main(void)
5087a8fd1abaSPeter Maydell{
5088a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
5089a8fd1abaSPeter Maydell}
5090a8fd1abaSPeter MaydellEOF
5091a8fd1abaSPeter Maydellif compile_prog "" "" ; then
5092a8fd1abaSPeter Maydell  sendfile=yes
5093a8fd1abaSPeter Maydellfi
5094a8fd1abaSPeter Maydell
509551834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
509651834341SRiku Voipiotimerfd=no
509751834341SRiku Voipiocat > $TMPC << EOF
509851834341SRiku Voipio#include <sys/timerfd.h>
509951834341SRiku Voipio
510051834341SRiku Voipioint main(void)
510151834341SRiku Voipio{
510251834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
510351834341SRiku Voipio}
510451834341SRiku VoipioEOF
510551834341SRiku Voipioif compile_prog "" "" ; then
510651834341SRiku Voipio  timerfd=yes
510751834341SRiku Voipiofi
510851834341SRiku Voipio
51099af5c906SRiku Voipio# check for setns and unshare support
51109af5c906SRiku Voipiosetns=no
51119af5c906SRiku Voipiocat > $TMPC << EOF
51129af5c906SRiku Voipio#include <sched.h>
51139af5c906SRiku Voipio
51149af5c906SRiku Voipioint main(void)
51159af5c906SRiku Voipio{
51169af5c906SRiku Voipio    int ret;
51179af5c906SRiku Voipio    ret = setns(0, 0);
51189af5c906SRiku Voipio    ret = unshare(0);
51199af5c906SRiku Voipio    return ret;
51209af5c906SRiku Voipio}
51219af5c906SRiku VoipioEOF
51229af5c906SRiku Voipioif compile_prog "" "" ; then
51239af5c906SRiku Voipio  setns=yes
51249af5c906SRiku Voipiofi
51259af5c906SRiku Voipio
512638860a03SAleksandar Markovic# clock_adjtime probe
512738860a03SAleksandar Markovicclock_adjtime=no
512838860a03SAleksandar Markoviccat > $TMPC <<EOF
512938860a03SAleksandar Markovic#include <time.h>
513038860a03SAleksandar Markovic
513138860a03SAleksandar Markovicint main(void)
513238860a03SAleksandar Markovic{
513338860a03SAleksandar Markovic    return clock_adjtime(0, 0);
513438860a03SAleksandar Markovic}
513538860a03SAleksandar MarkovicEOF
513638860a03SAleksandar Markovicclock_adjtime=no
513738860a03SAleksandar Markovicif compile_prog "" "" ; then
513838860a03SAleksandar Markovic  clock_adjtime=yes
513938860a03SAleksandar Markovicfi
514038860a03SAleksandar Markovic
51415a03cd00SAleksandar Markovic# syncfs probe
51425a03cd00SAleksandar Markovicsyncfs=no
51435a03cd00SAleksandar Markoviccat > $TMPC <<EOF
51445a03cd00SAleksandar Markovic#include <unistd.h>
51455a03cd00SAleksandar Markovic
51465a03cd00SAleksandar Markovicint main(void)
51475a03cd00SAleksandar Markovic{
51485a03cd00SAleksandar Markovic    return syncfs(0);
51495a03cd00SAleksandar Markovic}
51505a03cd00SAleksandar MarkovicEOF
51515a03cd00SAleksandar Markovicsyncfs=no
51525a03cd00SAleksandar Markovicif compile_prog "" "" ; then
51535a03cd00SAleksandar Markovic  syncfs=yes
51545a03cd00SAleksandar Markovicfi
51555a03cd00SAleksandar Markovic
5156db37dd89SAleksandar Markovic# check for kcov support (kernel must be 4.4+, compiled with certain options)
5157db37dd89SAleksandar Markovickcov=no
5158db37dd89SAleksandar Markovicif check_include sys/kcov.h ; then
5159db37dd89SAleksandar Markovic    kcov=yes
5160db37dd89SAleksandar Markovicfi
5161db37dd89SAleksandar Markovic
5162516e8b7dSPeter Maydell# If we're making warnings fatal, apply this to Sphinx runs as well
5163516e8b7dSPeter Maydellsphinx_werror=""
5164516e8b7dSPeter Maydellif test "$werror" = "yes"; then
5165516e8b7dSPeter Maydell    sphinx_werror="-W"
5166516e8b7dSPeter Maydellfi
5167516e8b7dSPeter Maydell
51685f71eac0SPeter Maydell# Check we have a new enough version of sphinx-build
51695f71eac0SPeter Maydellhas_sphinx_build() {
51705f71eac0SPeter Maydell    # This is a bit awkward but works: create a trivial document and
51715f71eac0SPeter Maydell    # try to run it with our configuration file (which enforces a
51725f71eac0SPeter Maydell    # version requirement). This will fail if either
51735f71eac0SPeter Maydell    # sphinx-build doesn't exist at all or if it is too old.
51745f71eac0SPeter Maydell    mkdir -p "$TMPDIR1/sphinx"
51755f71eac0SPeter Maydell    touch "$TMPDIR1/sphinx/index.rst"
5176988ae6c3SAlex Bennée    "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
5177988ae6c3SAlex Bennée                    -b html "$TMPDIR1/sphinx" \
5178988ae6c3SAlex Bennée                    "$TMPDIR1/sphinx/out"  >> config.log 2>&1
51795f71eac0SPeter Maydell}
51805f71eac0SPeter Maydell
5181cc8ae6deSpbrook# Check if tools are available to build documentation.
5182a25dba17SJuan Quintelaif test "$docs" != "no" ; then
5183758b617aSPeter Maydell  if has_sphinx_build; then
5184758b617aSPeter Maydell    sphinx_ok=yes
5185758b617aSPeter Maydell  else
5186758b617aSPeter Maydell    sphinx_ok=no
5187758b617aSPeter Maydell  fi
5188758b617aSPeter Maydell  if has makeinfo && has pod2man && test "$sphinx_ok" = "yes"; then
5189a25dba17SJuan Quintela    docs=yes
519083a3ab8bSJuan Quintela  else
5191a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
5192758b617aSPeter Maydell      if has $sphinx_build && test "$sphinx_ok" != "yes"; then
5193758b617aSPeter Maydell        echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
5194758b617aSPeter Maydell      fi
5195758b617aSPeter Maydell      feature_not_found "docs" "Install texinfo, Perl/perl-podlators and a Python 3 version of python-sphinx"
519683a3ab8bSJuan Quintela    fi
5197a25dba17SJuan Quintela    docs=no
519883a3ab8bSJuan Quintela  fi
5199cc8ae6deSpbrookfi
5200cc8ae6deSpbrook
5201f514f41cSStefan Weil# Search for bswap_32 function
52026ae9a1f4SJuan Quintelabyteswap_h=no
52036ae9a1f4SJuan Quintelacat > $TMPC << EOF
52046ae9a1f4SJuan Quintela#include <byteswap.h>
52056ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
52066ae9a1f4SJuan QuintelaEOF
520752166aa0SJuan Quintelaif compile_prog "" "" ; then
52086ae9a1f4SJuan Quintela  byteswap_h=yes
52096ae9a1f4SJuan Quintelafi
52106ae9a1f4SJuan Quintela
521175f13596SStefan Weil# Search for bswap32 function
52126ae9a1f4SJuan Quintelabswap_h=no
52136ae9a1f4SJuan Quintelacat > $TMPC << EOF
52146ae9a1f4SJuan Quintela#include <sys/endian.h>
52156ae9a1f4SJuan Quintela#include <sys/types.h>
52166ae9a1f4SJuan Quintela#include <machine/bswap.h>
52176ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
52186ae9a1f4SJuan QuintelaEOF
521952166aa0SJuan Quintelaif compile_prog "" "" ; then
52206ae9a1f4SJuan Quintela  bswap_h=yes
52216ae9a1f4SJuan Quintelafi
52226ae9a1f4SJuan Quintela
5223da93a1fdSaliguori##########################################
5224e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
5225c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
5226e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
52273c33ea96SPaolo Bonzini    libiscsi="yes"
5228ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
5229ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
5230c589b249SRonnie Sahlberg  else
5231c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
5232e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
5233c589b249SRonnie Sahlberg    fi
5234c589b249SRonnie Sahlberg    libiscsi="no"
5235c589b249SRonnie Sahlberg  fi
5236c589b249SRonnie Sahlbergfi
5237c589b249SRonnie Sahlberg
5238c589b249SRonnie Sahlberg##########################################
52398bacde8dSNatanael Copa# Do we need libm
52408bacde8dSNatanael Copacat > $TMPC << EOF
52418bacde8dSNatanael Copa#include <math.h>
5242f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
52438bacde8dSNatanael CopaEOF
52448bacde8dSNatanael Copaif compile_prog "" "" ; then
52458bacde8dSNatanael Copa  :
52468bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
52478bacde8dSNatanael Copa  LIBS="-lm $LIBS"
52488bacde8dSNatanael Copaelse
524976ad07a4SPeter Maydell  error_exit "libm check failed"
52508bacde8dSNatanael Copafi
52518bacde8dSNatanael Copa
52528bacde8dSNatanael Copa##########################################
5253da93a1fdSaliguori# Do we need librt
52548bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
52558bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
52568bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
52578bacde8dSNatanael Copa# function in addition.
5258da93a1fdSaliguoricat > $TMPC <<EOF
5259da93a1fdSaliguori#include <signal.h>
5260da93a1fdSaliguori#include <time.h>
52618bacde8dSNatanael Copaint main(void) {
52628bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
52638bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
52648bacde8dSNatanael Copa}
5265da93a1fdSaliguoriEOF
5266da93a1fdSaliguori
526752166aa0SJuan Quintelaif compile_prog "" "" ; then
526807ffa4bdSJuan Quintela  :
52698bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
527018e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
527118e588b1SRick Liu  LIBS="$LIBS -lrt"
5272da93a1fdSaliguorifi
5273da93a1fdSaliguori
5274d99e97e6SThomas Huth# Check whether we need to link libutil for openpty()
5275d99e97e6SThomas Huthcat > $TMPC << EOF
5276d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
5277d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
5278d99e97e6SThomas HuthEOF
5279d99e97e6SThomas Huth
52809df8b20dSThomas Huthhave_openpty="no"
52819df8b20dSThomas Huthif compile_prog "" "" ; then
52829df8b20dSThomas Huth  have_openpty="yes"
52839df8b20dSThomas Huthelse
5284d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
52856362a53fSJuan Quintela    libs_softmmu="-lutil $libs_softmmu"
5286d99e97e6SThomas Huth    libs_tools="-lutil $libs_tools"
52879df8b20dSThomas Huth    have_openpty="yes"
5288d99e97e6SThomas Huth  fi
52896362a53fSJuan Quintelafi
52906362a53fSJuan Quintela
5291de5071c5SBlue Swirl##########################################
5292cd4ec0b4SGerd Hoffmann# spice probe
5293cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
5294cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
5295cd4ec0b4SGerd Hoffmann#include <spice.h>
5296cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
5297cd4ec0b4SGerd HoffmannEOF
5298710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
5299710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
53001b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
530165d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
5302cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
5303cd4ec0b4SGerd Hoffmann    spice="yes"
5304cd4ec0b4SGerd Hoffmann    libs_softmmu="$libs_softmmu $spice_libs"
5305cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
5306cd4ec0b4SGerd Hoffmann  else
5307cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
53088efc9363SHu Tao      feature_not_found "spice" \
53091b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
5310cd4ec0b4SGerd Hoffmann    fi
5311cd4ec0b4SGerd Hoffmann    spice="no"
5312cd4ec0b4SGerd Hoffmann  fi
5313cd4ec0b4SGerd Hoffmannfi
5314cd4ec0b4SGerd Hoffmann
53157b02f544SMarc-André Lureau# check for smartcard support
53167b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
53170f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
53187b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
53197b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
53207b02f544SMarc-André Lureau        smartcard="yes"
5321111a38b0SRobert Relyea    else
53227b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
53237b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
5324111a38b0SRobert Relyea        fi
53257b02f544SMarc-André Lureau        smartcard="no"
5326111a38b0SRobert Relyea    fi
5327111a38b0SRobert Relyeafi
5328111a38b0SRobert Relyea
53292b2325ffSGerd Hoffmann# check for libusb
53302b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
533165d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
53322b2325ffSGerd Hoffmann        libusb="yes"
5333ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
5334ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
53352b2325ffSGerd Hoffmann    else
53362b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
53378efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
53382b2325ffSGerd Hoffmann        fi
53392b2325ffSGerd Hoffmann        libusb="no"
53402b2325ffSGerd Hoffmann    fi
53412b2325ffSGerd Hoffmannfi
53422b2325ffSGerd Hoffmann
534369354a83SHans de Goede# check for usbredirparser for usb network redirection support
534469354a83SHans de Goedeif test "$usb_redir" != "no" ; then
534565d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
534669354a83SHans de Goede        usb_redir="yes"
5347ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
5348ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
534969354a83SHans de Goede    else
535069354a83SHans de Goede        if test "$usb_redir" = "yes"; then
535121684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
535269354a83SHans de Goede        fi
535369354a83SHans de Goede        usb_redir="no"
535469354a83SHans de Goede    fi
535569354a83SHans de Goedefi
535669354a83SHans de Goede
5357cd4ec0b4SGerd Hoffmann##########################################
5358d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
5359d9840e25STomoki Sekiyama
5360e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5361e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
5362d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
5363690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
5364d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
5365d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
5366690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
5367d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
5368d9840e25STomoki Sekiyama	  ;;
5369690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
5370d9840e25STomoki Sekiyama  esac
5371d9840e25STomoki Sekiyama  cat > $TMPC << EOF
5372d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
5373d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
5374d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
5375d9840e25STomoki SekiyamaEOF
5376d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
5377d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
5378d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
5379315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
5380f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
5381d9840e25STomoki Sekiyama  else
5382d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
5383d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
5384d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
5385d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
5386d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
5387d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
5388d9840e25STomoki Sekiyama      feature_not_found "VSS support"
5389d9840e25STomoki Sekiyama    fi
5390d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
5391d9840e25STomoki Sekiyama  fi
5392d9840e25STomoki Sekiyamafi
5393d9840e25STomoki Sekiyama
5394d9840e25STomoki Sekiyama##########################################
5395d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
5396d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
5397d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
5398d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
5399d9840e25STomoki Sekiyama
5400e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5401e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
5402d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
5403d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
5404d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
5405d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
5406d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
5407d9840e25STomoki Sekiyama    else
5408d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
5409d9840e25STomoki Sekiyama    fi
5410d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
5411d9840e25STomoki Sekiyama    win_sdk=""
5412d9840e25STomoki Sekiyama  fi
5413d9840e25STomoki Sekiyamafi
5414d9840e25STomoki Sekiyama
5415d9840e25STomoki Sekiyama##########################################
541650cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
5417e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
541850cbebb9SMichael Roth  cat > $TMPC << EOF
541950cbebb9SMichael Roth#include <windows.h>
542050cbebb9SMichael Roth#include <ntddscsi.h>
542150cbebb9SMichael Rothint main(void) {
542250cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
542350cbebb9SMichael Roth#error Missing required ioctl definitions
542450cbebb9SMichael Roth#endif
542550cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
542650cbebb9SMichael Roth  return addr.Lun;
542750cbebb9SMichael Roth}
542850cbebb9SMichael RothEOF
542950cbebb9SMichael Roth  if compile_prog "" "" ; then
543050cbebb9SMichael Roth    guest_agent_ntddscsi=yes
5431996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
543250cbebb9SMichael Roth  fi
543350cbebb9SMichael Rothfi
543450cbebb9SMichael Roth
543550cbebb9SMichael Roth##########################################
54369d9e1521SGerd Hoffmann# virgl renderer probe
54379d9e1521SGerd Hoffmann
54389d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
54399d9e1521SGerd Hoffmann  cat > $TMPC << EOF
54409d9e1521SGerd Hoffmann#include <virglrenderer.h>
54419d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
54429d9e1521SGerd HoffmannEOF
54439d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
54449d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
544547479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
54469d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
54479d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
54489d9e1521SGerd Hoffmann    virglrenderer="yes"
54499d9e1521SGerd Hoffmann  else
54509d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
54519d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
54529d9e1521SGerd Hoffmann    fi
54539d9e1521SGerd Hoffmann    virglrenderer="no"
54549d9e1521SGerd Hoffmann  fi
54559d9e1521SGerd Hoffmannfi
54569d9e1521SGerd Hoffmann
54579d9e1521SGerd Hoffmann##########################################
54588ca80760SRichard Henderson# capstone
54598ca80760SRichard Henderson
5460e219c499SRichard Hendersoncase "$capstone" in
5461e219c499SRichard Henderson  "" | yes)
54628ca80760SRichard Henderson    if $pkg_config capstone; then
5463e219c499SRichard Henderson      capstone=system
5464e633a5c6SEric Blake    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5465e219c499SRichard Henderson      capstone=git
5466e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
5467e219c499SRichard Henderson      capstone=internal
5468e219c499SRichard Henderson    elif test -z "$capstone" ; then
5469e219c499SRichard Henderson      capstone=no
5470e219c499SRichard Henderson    else
5471e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
5472e219c499SRichard Henderson    fi
5473e219c499SRichard Henderson    ;;
5474e219c499SRichard Henderson
5475e219c499SRichard Henderson  system)
5476e219c499SRichard Henderson    if ! $pkg_config capstone; then
5477e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
5478e219c499SRichard Henderson    fi
5479e219c499SRichard Henderson    ;;
5480e219c499SRichard Hendersonesac
5481e219c499SRichard Henderson
5482e219c499SRichard Hendersoncase "$capstone" in
5483e219c499SRichard Henderson  git | internal)
5484e219c499SRichard Henderson    if test "$capstone" = git; then
5485e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
5486e219c499SRichard Henderson    fi
5487e219c499SRichard Henderson    mkdir -p capstone
548825211446SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -I${source_path}/capstone/include"
5489e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
5490e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
5491e219c499SRichard Henderson    else
5492e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
5493e219c499SRichard Henderson    fi
549425211446SPaolo Bonzini    libs_cpu="-L$PWD/capstone -lcapstone $libs_cpu"
5495e219c499SRichard Henderson    ;;
5496e219c499SRichard Henderson
5497e219c499SRichard Henderson  system)
54988ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
549902f9135bSDaniel P. Berrangé    libs_cpu="$($pkg_config --libs capstone) $libs_cpu"
5500e219c499SRichard Henderson    ;;
5501e219c499SRichard Henderson
5502e219c499SRichard Henderson  no)
5503e219c499SRichard Henderson    ;;
5504e219c499SRichard Henderson  *)
5505e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
5506e219c499SRichard Henderson    ;;
5507e219c499SRichard Hendersonesac
55088ca80760SRichard Henderson
55098ca80760SRichard Henderson##########################################
55105f6b9e8fSBlue Swirl# check if we have fdatasync
55115f6b9e8fSBlue Swirl
55125f6b9e8fSBlue Swirlfdatasync=no
55135f6b9e8fSBlue Swirlcat > $TMPC << EOF
55145f6b9e8fSBlue Swirl#include <unistd.h>
5515d1722a27SAlexandre Raymondint main(void) {
5516d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5517d1722a27SAlexandre Raymondreturn fdatasync(0);
5518d1722a27SAlexandre Raymond#else
5519e172fe11SStefan Weil#error Not supported
5520d1722a27SAlexandre Raymond#endif
5521d1722a27SAlexandre Raymond}
55225f6b9e8fSBlue SwirlEOF
55235f6b9e8fSBlue Swirlif compile_prog "" "" ; then
55245f6b9e8fSBlue Swirl    fdatasync=yes
55255f6b9e8fSBlue Swirlfi
55265f6b9e8fSBlue Swirl
552794a420b1SStefan Hajnoczi##########################################
5528e78815a5SAndreas Färber# check if we have madvise
5529e78815a5SAndreas Färber
5530e78815a5SAndreas Färbermadvise=no
5531e78815a5SAndreas Färbercat > $TMPC << EOF
5532e78815a5SAndreas Färber#include <sys/types.h>
5533e78815a5SAndreas Färber#include <sys/mman.h>
5534832ce9c2SScott Wood#include <stddef.h>
5535e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5536e78815a5SAndreas FärberEOF
5537e78815a5SAndreas Färberif compile_prog "" "" ; then
5538e78815a5SAndreas Färber    madvise=yes
5539e78815a5SAndreas Färberfi
5540e78815a5SAndreas Färber
5541e78815a5SAndreas Färber##########################################
5542e78815a5SAndreas Färber# check if we have posix_madvise
5543e78815a5SAndreas Färber
5544e78815a5SAndreas Färberposix_madvise=no
5545e78815a5SAndreas Färbercat > $TMPC << EOF
5546e78815a5SAndreas Färber#include <sys/mman.h>
5547832ce9c2SScott Wood#include <stddef.h>
5548e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5549e78815a5SAndreas FärberEOF
5550e78815a5SAndreas Färberif compile_prog "" "" ; then
5551e78815a5SAndreas Färber    posix_madvise=yes
5552e78815a5SAndreas Färberfi
5553e78815a5SAndreas Färber
5554e78815a5SAndreas Färber##########################################
55559bc5a719SAndreas Gustafsson# check if we have posix_memalign()
55569bc5a719SAndreas Gustafsson
55579bc5a719SAndreas Gustafssonposix_memalign=no
55589bc5a719SAndreas Gustafssoncat > $TMPC << EOF
55599bc5a719SAndreas Gustafsson#include <stdlib.h>
55609bc5a719SAndreas Gustafssonint main(void) {
55619bc5a719SAndreas Gustafsson    void *p;
55629bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
55639bc5a719SAndreas Gustafsson}
55649bc5a719SAndreas GustafssonEOF
55659bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
55669bc5a719SAndreas Gustafsson    posix_memalign=yes
55679bc5a719SAndreas Gustafssonfi
55689bc5a719SAndreas Gustafsson
55699bc5a719SAndreas Gustafsson##########################################
55700a852417SPaul Durrant# check if we have posix_syslog
55710a852417SPaul Durrant
55720a852417SPaul Durrantposix_syslog=no
55730a852417SPaul Durrantcat > $TMPC << EOF
55740a852417SPaul Durrant#include <syslog.h>
55750a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
55760a852417SPaul DurrantEOF
55770a852417SPaul Durrantif compile_prog "" "" ; then
55780a852417SPaul Durrant    posix_syslog=yes
55790a852417SPaul Durrantfi
55800a852417SPaul Durrant
55810a852417SPaul Durrant##########################################
5582401bc051SPeter Maydell# check if we have sem_timedwait
5583401bc051SPeter Maydell
5584401bc051SPeter Maydellsem_timedwait=no
5585401bc051SPeter Maydellcat > $TMPC << EOF
5586401bc051SPeter Maydell#include <semaphore.h>
5587811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5588401bc051SPeter MaydellEOF
5589401bc051SPeter Maydellif compile_prog "" "" ; then
5590401bc051SPeter Maydell    sem_timedwait=yes
5591401bc051SPeter Maydellfi
5592401bc051SPeter Maydell
5593401bc051SPeter Maydell##########################################
55945c99fa37SKeno Fischer# check if we have strchrnul
55955c99fa37SKeno Fischer
55965c99fa37SKeno Fischerstrchrnul=no
55975c99fa37SKeno Fischercat > $TMPC << EOF
55985c99fa37SKeno Fischer#include <string.h>
55995c99fa37SKeno Fischerint main(void);
56005c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
56015c99fa37SKeno Fischerchar *haystack = (char*)&main;
56025c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
56035c99fa37SKeno FischerEOF
56045c99fa37SKeno Fischerif compile_prog "" "" ; then
56055c99fa37SKeno Fischer    strchrnul=yes
56065c99fa37SKeno Fischerfi
56075c99fa37SKeno Fischer
56088a792b03SJiufei Xue#########################################
56098a792b03SJiufei Xue# check if we have st_atim
56108a792b03SJiufei Xue
56118a792b03SJiufei Xuest_atim=no
56128a792b03SJiufei Xuecat > $TMPC << EOF
56138a792b03SJiufei Xue#include <sys/stat.h>
56148a792b03SJiufei Xue#include <stddef.h>
56158a792b03SJiufei Xueint main(void) { return offsetof(struct stat, st_atim); }
56168a792b03SJiufei XueEOF
56178a792b03SJiufei Xueif compile_prog "" "" ; then
56188a792b03SJiufei Xue    st_atim=yes
56198a792b03SJiufei Xuefi
56208a792b03SJiufei Xue
56215c99fa37SKeno Fischer##########################################
562294a420b1SStefan Hajnoczi# check if trace backend exists
562394a420b1SStefan Hajnoczi
56245b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
562594a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
56265b808275SLluís Vilanova  error_exit "invalid trace backends" \
56275b808275SLluís Vilanova      "Please choose supported trace backends."
562894a420b1SStefan Hajnoczifi
562994a420b1SStefan Hajnoczi
56307e24e92aSStefan Hajnoczi##########################################
56317e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
56325b808275SLluís Vilanovaif have_backend "ust"; then
56337e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
5634bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
56357e24e92aSStefan Hajnocziint main(void) { return 0; }
56367e24e92aSStefan HajnocziEOF
5637c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5638bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
563989138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
56407e24e92aSStefan Hajnoczi    else
5641c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
5642bf15f63cSMohamad Gebai    fi
5643bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
564489138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5645bf15f63cSMohamad Gebai    else
5646bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
5647bf15f63cSMohamad Gebai    fi
5648bf15f63cSMohamad Gebai
5649bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5650bf15f63cSMohamad Gebai  else
5651bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
56527e24e92aSStefan Hajnoczi  fi
56537e24e92aSStefan Hajnoczifi
5654b3d08c02SDaniel P. Berrange
5655b3d08c02SDaniel P. Berrange##########################################
5656b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
56575b808275SLluís Vilanovaif have_backend "dtrace"; then
5658b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
565976ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
5660b3d08c02SDaniel P. Berrange  fi
5661c276b17dSDaniel P. Berrange  trace_backend_stap="no"
5662c276b17dSDaniel P. Berrange  if has 'stap' ; then
5663c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
5664c276b17dSDaniel P. Berrange  fi
5665b3d08c02SDaniel P. Berrangefi
5666b3d08c02SDaniel P. Berrange
56677e24e92aSStefan Hajnoczi##########################################
5668519175a2SAlex Barcelo# check and set a backend for coroutine
5669d0e2fce5SAneesh Kumar K.V
56707c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
567133c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
567233c53c54SDaniel P. Berrange# specific one.
56737c2acc70SPeter Maydell
56747c2acc70SPeter Maydellucontext_works=no
5675d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
5676d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
5677d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
5678cdf84806SPeter Maydell#ifdef __stub_makecontext
5679cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
5680cdf84806SPeter Maydell#endif
568175cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
5682d0e2fce5SAneesh Kumar K.VEOF
5683d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
56847c2acc70SPeter Maydell    ucontext_works=yes
5685d0e2fce5SAneesh Kumar K.V  fi
5686519175a2SAlex Barcelofi
56877c2acc70SPeter Maydell
56887c2acc70SPeter Maydellif test "$coroutine" = ""; then
56897c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
56907c2acc70SPeter Maydell    coroutine=win32
56917c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
56927c2acc70SPeter Maydell    coroutine=ucontext
5693519175a2SAlex Barcelo  else
56947c2acc70SPeter Maydell    coroutine=sigaltstack
56957c2acc70SPeter Maydell  fi
56967c2acc70SPeter Maydellelse
56977c2acc70SPeter Maydell  case $coroutine in
56987c2acc70SPeter Maydell  windows)
56997c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
57007c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
57017c2acc70SPeter Maydell    fi
57027c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
57037c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
57047c2acc70SPeter Maydell    coroutine=win32
57057c2acc70SPeter Maydell    ;;
57067c2acc70SPeter Maydell  ucontext)
57077c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
57087c2acc70SPeter Maydell      feature_not_found "ucontext"
57097c2acc70SPeter Maydell    fi
57107c2acc70SPeter Maydell    ;;
571133c53c54SDaniel P. Berrange  sigaltstack)
57127c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
57137c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
57147c2acc70SPeter Maydell    fi
57157c2acc70SPeter Maydell    ;;
57167c2acc70SPeter Maydell  *)
571776ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
57187c2acc70SPeter Maydell    ;;
57197c2acc70SPeter Maydell  esac
5720d0e2fce5SAneesh Kumar K.Vfi
5721d0e2fce5SAneesh Kumar K.V
572270c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
572370c60c08SStefan Hajnoczi  coroutine_pool=yes
572470c60c08SStefan Hajnoczifi
572570c60c08SStefan Hajnoczi
57267d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
57277d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
57287d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
57297d992e4dSPeter Lieven    coroutine_pool=no
57307d992e4dSPeter Lieven  fi
57317d992e4dSPeter Lievenfi
57327d992e4dSPeter Lieven
57331e4f6065SDaniele Buono##################################################
57341e4f6065SDaniele Buono# SafeStack
57351e4f6065SDaniele Buono
57361e4f6065SDaniele Buono
57371e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
57381e4f6065SDaniele Buonocat > $TMPC << EOF
57391e4f6065SDaniele Buonoint main(int argc, char *argv[])
57401e4f6065SDaniele Buono{
57411e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
57421e4f6065SDaniele Buono#error SafeStack Disabled
57431e4f6065SDaniele Buono#endif
57441e4f6065SDaniele Buono    return 0;
57451e4f6065SDaniele Buono}
57461e4f6065SDaniele BuonoEOF
57471e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
57481e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
57491e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
57501e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
57511e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
57521e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
57531e4f6065SDaniele Buono  else
57541e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
57551e4f6065SDaniele Buono  fi
57561e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
57571e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
57581e4f6065SDaniele Buono  fi
57591e4f6065SDaniele Buonoelse
57601e4f6065SDaniele Buonocat > $TMPC << EOF
57611e4f6065SDaniele Buonoint main(int argc, char *argv[])
57621e4f6065SDaniele Buono{
57631e4f6065SDaniele Buono#if defined(__has_feature)
57641e4f6065SDaniele Buono#if __has_feature(safe_stack)
57651e4f6065SDaniele Buono#error SafeStack Enabled
57661e4f6065SDaniele Buono#endif
57671e4f6065SDaniele Buono#endif
57681e4f6065SDaniele Buono    return 0;
57691e4f6065SDaniele Buono}
57701e4f6065SDaniele BuonoEOF
57711e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
57721e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
57731e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
57741e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
57751e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
57761e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
57771e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
57781e4f6065SDaniele Buono    fi
57791e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
57801e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
57811e4f6065SDaniele Buono  fi
57821e4f6065SDaniele Buonoelse # "$safe_stack" = ""
57831e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
57841e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
57851e4f6065SDaniele Buono    safe_stack="no"
57861e4f6065SDaniele Buono  else
57871e4f6065SDaniele Buono    safe_stack="yes"
57881e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
57891e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
57901e4f6065SDaniele Buono    fi
57911e4f6065SDaniele Buono  fi
57921e4f6065SDaniele Buonofi
57931e4f6065SDaniele Buonofi
57947d992e4dSPeter Lieven
5795d0e2fce5SAneesh Kumar K.V##########################################
5796d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5797d2042378SAneesh Kumar K.V
57984e1797f9SStefan Weilopen_by_handle_at=no
5799d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5800d2042378SAneesh Kumar K.V#include <fcntl.h>
5801acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5802acc55ba8SStefan Weil# error missing definition
5803acc55ba8SStefan Weil#else
580475cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5805acc55ba8SStefan Weil#endif
5806d2042378SAneesh Kumar K.VEOF
5807d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5808d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5809d2042378SAneesh Kumar K.Vfi
5810d2042378SAneesh Kumar K.V
5811e06a765eSHarsh Prateek Bora########################################
5812e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5813e06a765eSHarsh Prateek Bora
5814e06a765eSHarsh Prateek Boralinux_magic_h=no
5815e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5816e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5817e06a765eSHarsh Prateek Boraint main(void) {
581875cafad7SStefan Weil  return 0;
5819e06a765eSHarsh Prateek Bora}
5820e06a765eSHarsh Prateek BoraEOF
5821e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5822e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5823e06a765eSHarsh Prateek Borafi
5824e06a765eSHarsh Prateek Bora
58258ab1bf12SLuiz Capitulino########################################
5826541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
58273f4349dcSKevin Wolf
58283f4349dcSKevin Wolfvalgrind_h=no
58293f4349dcSKevin Wolfcat > $TMPC << EOF
58303f4349dcSKevin Wolf#include <valgrind/valgrind.h>
58313f4349dcSKevin Wolfint main(void) {
58323f4349dcSKevin Wolf  return 0;
58333f4349dcSKevin Wolf}
58343f4349dcSKevin WolfEOF
58353f4349dcSKevin Wolfif compile_prog "" "" ; then
58363f4349dcSKevin Wolf    valgrind_h=yes
58373f4349dcSKevin Wolffi
58383f4349dcSKevin Wolf
58393f4349dcSKevin Wolf########################################
58408ab1bf12SLuiz Capitulino# check if environ is declared
58418ab1bf12SLuiz Capitulino
58428ab1bf12SLuiz Capitulinohas_environ=no
58438ab1bf12SLuiz Capitulinocat > $TMPC << EOF
58448ab1bf12SLuiz Capitulino#include <unistd.h>
58458ab1bf12SLuiz Capitulinoint main(void) {
5846c075a723SBlue Swirl    environ = 0;
58478ab1bf12SLuiz Capitulino    return 0;
58488ab1bf12SLuiz Capitulino}
58498ab1bf12SLuiz CapitulinoEOF
58508ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
58518ab1bf12SLuiz Capitulino    has_environ=yes
58528ab1bf12SLuiz Capitulinofi
58538ab1bf12SLuiz Capitulino
585476a347e1SRichard Henderson########################################
585576a347e1SRichard Henderson# check if cpuid.h is usable.
585676a347e1SRichard Henderson
585776a347e1SRichard Hendersoncat > $TMPC << EOF
585876a347e1SRichard Henderson#include <cpuid.h>
585976a347e1SRichard Hendersonint main(void) {
5860774d566cSPeter Maydell    unsigned a, b, c, d;
5861774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5862774d566cSPeter Maydell
5863774d566cSPeter Maydell    if (max >= 1) {
5864774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5865774d566cSPeter Maydell    }
5866774d566cSPeter Maydell
5867774d566cSPeter Maydell    if (max >= 7) {
5868774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5869774d566cSPeter Maydell    }
5870774d566cSPeter Maydell
587176a347e1SRichard Henderson    return 0;
587276a347e1SRichard Henderson}
587376a347e1SRichard HendersonEOF
587476a347e1SRichard Hendersonif compile_prog "" "" ; then
587576a347e1SRichard Henderson    cpuid_h=yes
587676a347e1SRichard Hendersonfi
587776a347e1SRichard Henderson
58785dd89908SRichard Henderson##########################################
58795dd89908SRichard Henderson# avx2 optimization requirement check
58805dd89908SRichard Henderson#
58815dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
58825dd89908SRichard Henderson# since we won't be able to select the new routines.
58835dd89908SRichard Henderson
5884e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
58855dd89908SRichard Henderson  cat > $TMPC << EOF
58865dd89908SRichard Henderson#pragma GCC push_options
58875dd89908SRichard Henderson#pragma GCC target("avx2")
58885dd89908SRichard Henderson#include <cpuid.h>
58895dd89908SRichard Henderson#include <immintrin.h>
58905dd89908SRichard Hendersonstatic int bar(void *a) {
58915dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
58925dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
58935dd89908SRichard Henderson}
58945dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
58955dd89908SRichard HendersonEOF
58965dd89908SRichard Henderson  if compile_object "" ; then
58975dd89908SRichard Henderson    avx2_opt="yes"
589886583a07SLiam Merwick  else
589986583a07SLiam Merwick    avx2_opt="no"
59005dd89908SRichard Henderson  fi
59015dd89908SRichard Hendersonfi
59025dd89908SRichard Henderson
59036b8cd447SRobert Hoo##########################################
59046b8cd447SRobert Hoo# avx512f optimization requirement check
59056b8cd447SRobert Hoo#
59066b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
59076b8cd447SRobert Hoo# since we won't be able to select the new routines.
59086b8cd447SRobert Hoo# by default, it is turned off.
59096b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
59106b8cd447SRobert Hoo
59116b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
59126b8cd447SRobert Hoo  cat > $TMPC << EOF
59136b8cd447SRobert Hoo#pragma GCC push_options
59146b8cd447SRobert Hoo#pragma GCC target("avx512f")
59156b8cd447SRobert Hoo#include <cpuid.h>
59166b8cd447SRobert Hoo#include <immintrin.h>
59176b8cd447SRobert Hoostatic int bar(void *a) {
59186b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
59196b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
59206b8cd447SRobert Hoo}
59216b8cd447SRobert Hooint main(int argc, char *argv[])
59226b8cd447SRobert Hoo{
59236b8cd447SRobert Hoo	return bar(argv[0]);
59246b8cd447SRobert Hoo}
59256b8cd447SRobert HooEOF
59266b8cd447SRobert Hoo  if ! compile_object "" ; then
59276b8cd447SRobert Hoo    avx512f_opt="no"
59286b8cd447SRobert Hoo  fi
59296b8cd447SRobert Hooelse
59306b8cd447SRobert Hoo  avx512f_opt="no"
59316b8cd447SRobert Hoofi
59326b8cd447SRobert Hoo
5933f540166bSRichard Henderson########################################
5934f540166bSRichard Henderson# check if __[u]int128_t is usable.
5935f540166bSRichard Henderson
5936f540166bSRichard Hendersonint128=no
5937f540166bSRichard Hendersoncat > $TMPC << EOF
5938f540166bSRichard Henderson__int128_t a;
5939f540166bSRichard Henderson__uint128_t b;
5940f540166bSRichard Hendersonint main (void) {
5941f540166bSRichard Henderson  a = a + b;
5942f540166bSRichard Henderson  b = a * b;
5943464e3671SPeter Maydell  a = a * a;
5944f540166bSRichard Henderson  return 0;
5945f540166bSRichard Henderson}
5946f540166bSRichard HendersonEOF
5947f540166bSRichard Hendersonif compile_prog "" "" ; then
5948f540166bSRichard Henderson    int128=yes
5949f540166bSRichard Hendersonfi
595076a347e1SRichard Henderson
59517ebee43eSRichard Henderson#########################################
59527ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
59537ebee43eSRichard Henderson
59547ebee43eSRichard Hendersonatomic128=no
59557ebee43eSRichard Hendersonif test "$int128" = "yes"; then
59567ebee43eSRichard Henderson  cat > $TMPC << EOF
59577ebee43eSRichard Hendersonint main(void)
59587ebee43eSRichard Henderson{
59597ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
59607ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
59617ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
59627ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
59637ebee43eSRichard Henderson  return 0;
59647ebee43eSRichard Henderson}
59657ebee43eSRichard HendersonEOF
59667ebee43eSRichard Henderson  if compile_prog "" "" ; then
59677ebee43eSRichard Henderson    atomic128=yes
59687ebee43eSRichard Henderson  fi
59697ebee43eSRichard Hendersonfi
59707ebee43eSRichard Henderson
5971e6cd4bb5SRichard Hendersoncmpxchg128=no
5972e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
5973e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5974e6cd4bb5SRichard Hendersonint main(void)
5975e6cd4bb5SRichard Henderson{
5976e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5977e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5978e6cd4bb5SRichard Henderson  return 0;
5979e6cd4bb5SRichard Henderson}
5980e6cd4bb5SRichard HendersonEOF
5981e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5982e6cd4bb5SRichard Henderson    cmpxchg128=yes
5983e6cd4bb5SRichard Henderson  fi
5984e6cd4bb5SRichard Hendersonfi
5985e6cd4bb5SRichard Henderson
5986df79b996SRichard Henderson#########################################
5987df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5988df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5989df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5990df79b996SRichard Henderson
5991df79b996SRichard Hendersoncat > $TMPC << EOF
5992df79b996SRichard Henderson#include <stdint.h>
5993df79b996SRichard Hendersonint main(void)
5994df79b996SRichard Henderson{
5995df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5996df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5997df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5998df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5999df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
6000df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
6001df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
6002df79b996SRichard Henderson#else
6003df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
6004df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
6005df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
6006df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
6007df79b996SRichard Henderson#endif
6008df79b996SRichard Henderson  return 0;
6009df79b996SRichard Henderson}
6010df79b996SRichard HendersonEOF
6011df79b996SRichard Hendersonif compile_prog "" "" ; then
6012df79b996SRichard Henderson  atomic64=yes
6013df79b996SRichard Hendersonfi
6014df79b996SRichard Henderson
601526fffe29SEmilio G. Cota#########################################
601626fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
601726fffe29SEmilio G. Cotald_dynamic_list="no"
601826fffe29SEmilio G. Cotaif test "$static" = "no" ; then
601926fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
602026fffe29SEmilio G. Cota{
602126fffe29SEmilio G. Cota  foo;
602226fffe29SEmilio G. Cota};
602326fffe29SEmilio G. CotaEOF
602426fffe29SEmilio G. Cota
602526fffe29SEmilio G. Cota    cat > $TMPC <<EOF
602626fffe29SEmilio G. Cota#include <stdio.h>
602726fffe29SEmilio G. Cotavoid foo(void);
602826fffe29SEmilio G. Cota
602926fffe29SEmilio G. Cotavoid foo(void)
603026fffe29SEmilio G. Cota{
603126fffe29SEmilio G. Cota  printf("foo\n");
603226fffe29SEmilio G. Cota}
603326fffe29SEmilio G. Cota
603426fffe29SEmilio G. Cotaint main(void)
603526fffe29SEmilio G. Cota{
603626fffe29SEmilio G. Cota  foo();
603726fffe29SEmilio G. Cota  return 0;
603826fffe29SEmilio G. Cota}
603926fffe29SEmilio G. CotaEOF
604026fffe29SEmilio G. Cota
604126fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
604226fffe29SEmilio G. Cota        ld_dynamic_list="yes"
604326fffe29SEmilio G. Cota    fi
604426fffe29SEmilio G. Cotafi
604526fffe29SEmilio G. Cota
604626fffe29SEmilio G. Cota#########################################
604726fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
604826fffe29SEmilio G. Cota
604926fffe29SEmilio G. Cotald_exported_symbols_list="no"
605026fffe29SEmilio G. Cotaif test "$static" = "no" ; then
605126fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
605226fffe29SEmilio G. Cota  _foo
605326fffe29SEmilio G. CotaEOF
605426fffe29SEmilio G. Cota
605526fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
605626fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
605726fffe29SEmilio G. Cota    fi
605826fffe29SEmilio G. Cotafi
605926fffe29SEmilio G. Cota
606026fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
606126fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
606226fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
606326fffe29SEmilio G. Cota  error_exit \
606426fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
606526fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
606626fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
606726fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
606826fffe29SEmilio G. Cotafi
606926fffe29SEmilio G. Cota
60701e6e9acaSRichard Henderson########################################
6071db8aaae8SRichard Henderson# See if __attribute__((alias)) is supported.
6072db8aaae8SRichard Henderson# This false for Xcode 9, but has been remedied for Xcode 10.
6073db8aaae8SRichard Henderson# Unfortunately, travis uses Xcode 9 by default.
6074db8aaae8SRichard Henderson
6075db8aaae8SRichard Hendersonattralias=no
6076db8aaae8SRichard Hendersoncat > $TMPC << EOF
6077db8aaae8SRichard Hendersonint x = 1;
6078db8aaae8SRichard Hendersonextern const int y __attribute__((alias("x")));
6079db8aaae8SRichard Hendersonint main(void) { return 0; }
6080db8aaae8SRichard HendersonEOF
6081db8aaae8SRichard Hendersonif compile_prog "" "" ; then
6082db8aaae8SRichard Henderson    attralias=yes
6083db8aaae8SRichard Hendersonfi
6084db8aaae8SRichard Henderson
6085db8aaae8SRichard Henderson########################################
60861e6e9acaSRichard Henderson# check if getauxval is available.
60871e6e9acaSRichard Henderson
60881e6e9acaSRichard Hendersongetauxval=no
60891e6e9acaSRichard Hendersoncat > $TMPC << EOF
60901e6e9acaSRichard Henderson#include <sys/auxv.h>
60911e6e9acaSRichard Hendersonint main(void) {
60921e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
60931e6e9acaSRichard Henderson}
60941e6e9acaSRichard HendersonEOF
60951e6e9acaSRichard Hendersonif compile_prog "" "" ; then
60961e6e9acaSRichard Henderson    getauxval=yes
60971e6e9acaSRichard Hendersonfi
60981e6e9acaSRichard Henderson
6099fd0e6053SJohn Snow########################################
6100fd0e6053SJohn Snow# check if ccache is interfering with
6101fd0e6053SJohn Snow# semantic analysis of macros
6102fd0e6053SJohn Snow
61035e4dfd3dSJohn Snowunset CCACHE_CPP2
6104fd0e6053SJohn Snowccache_cpp2=no
6105fd0e6053SJohn Snowcat > $TMPC << EOF
6106fd0e6053SJohn Snowstatic const int Z = 1;
6107fd0e6053SJohn Snow#define fn() ({ Z; })
6108fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
6109fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
6110fd0e6053SJohn Snow#define ID(X) (X)
6111fd0e6053SJohn Snowint main(int argc, char *argv[])
6112fd0e6053SJohn Snow{
6113fd0e6053SJohn Snow    int x = 0, y = 0;
6114fd0e6053SJohn Snow    x = ID(x);
6115fd0e6053SJohn Snow    x = fn();
6116fd0e6053SJohn Snow    fn();
6117fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
6118fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
6119fd0e6053SJohn Snow    return 0;
6120fd0e6053SJohn Snow}
6121fd0e6053SJohn SnowEOF
6122fd0e6053SJohn Snow
6123fd0e6053SJohn Snowif ! compile_object "-Werror"; then
6124fd0e6053SJohn Snow    ccache_cpp2=yes
6125fd0e6053SJohn Snowfi
6126fd0e6053SJohn Snow
6127b553a042SJohn Snow#################################################
6128b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
6129b553a042SJohn Snow
6130b553a042SJohn Snowif test "$fortify_source" != "no"; then
6131b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
6132b553a042SJohn Snow    fortify_source="no";
6133e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
6134cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
6135b553a042SJohn Snow    fortify_source="no";
6136b553a042SJohn Snow  else
6137b553a042SJohn Snow    fortify_source="yes"
6138b553a042SJohn Snow  fi
6139b553a042SJohn Snowfi
6140b553a042SJohn Snow
61411efad060SFam Zheng###############################################
61421efad060SFam Zheng# Check if copy_file_range is provided by glibc
61431efad060SFam Zhenghave_copy_file_range=no
61441efad060SFam Zhengcat > $TMPC << EOF
61451efad060SFam Zheng#include <unistd.h>
61461efad060SFam Zhengint main(void) {
61471efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
61481efad060SFam Zheng  return 0;
61491efad060SFam Zheng}
61501efad060SFam ZhengEOF
61511efad060SFam Zhengif compile_prog "" "" ; then
61521efad060SFam Zheng    have_copy_file_range=yes
61531efad060SFam Zhengfi
61541efad060SFam Zheng
6155d2042378SAneesh Kumar K.V##########################################
6156277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
6157277abf15SJan Vesely
6158277abf15SJan Veselyhave_fsxattr=no
6159277abf15SJan Veselycat > $TMPC << EOF
6160277abf15SJan Vesely#include <linux/fs.h>
6161277abf15SJan Veselystruct fsxattr foo;
6162277abf15SJan Veselyint main(void) {
6163277abf15SJan Vesely  return 0;
6164277abf15SJan Vesely}
6165277abf15SJan VeselyEOF
6166277abf15SJan Veselyif compile_prog "" "" ; then
6167277abf15SJan Vesely    have_fsxattr=yes
6168277abf15SJan Veselyfi
6169277abf15SJan Vesely
6170b66e10e4SPeter Maydell##########################################
6171a40161cbSPaolo Bonzini# check for usable membarrier system call
6172a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
6173a40161cbSPaolo Bonzini    have_membarrier=no
6174a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
6175a40161cbSPaolo Bonzini        have_membarrier=yes
6176a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
6177a40161cbSPaolo Bonzini        cat > $TMPC << EOF
6178a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
6179a40161cbSPaolo Bonzini    #include <sys/syscall.h>
6180a40161cbSPaolo Bonzini    #include <unistd.h>
6181a40161cbSPaolo Bonzini    #include <stdlib.h>
6182a40161cbSPaolo Bonzini    int main(void) {
6183a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
6184a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
6185a40161cbSPaolo Bonzini	exit(0);
6186a40161cbSPaolo Bonzini    }
6187a40161cbSPaolo BonziniEOF
6188a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
6189a40161cbSPaolo Bonzini            have_membarrier=yes
6190a40161cbSPaolo Bonzini        fi
6191a40161cbSPaolo Bonzini    fi
6192a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
6193a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
6194a40161cbSPaolo Bonzini    fi
6195a40161cbSPaolo Bonzinielse
6196a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
6197a40161cbSPaolo Bonzini    # work on Wine.
6198a40161cbSPaolo Bonzini    membarrier=no
6199a40161cbSPaolo Bonzinifi
6200a40161cbSPaolo Bonzini
6201a40161cbSPaolo Bonzini##########################################
6202b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
6203575b22b1SLaurent Vivierhave_rtnetlink=no
6204575b22b1SLaurent Viviercat > $TMPC << EOF
6205575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
6206575b22b1SLaurent Vivierint main(void) {
6207575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
6208575b22b1SLaurent Vivier}
6209575b22b1SLaurent VivierEOF
6210575b22b1SLaurent Vivierif compile_prog "" "" ; then
6211575b22b1SLaurent Vivier    have_rtnetlink=yes
6212575b22b1SLaurent Vivierfi
6213575b22b1SLaurent Vivier
62146a02c806SStefan Hajnoczi##########################################
62156a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
62166a02c806SStefan Hajnoczihave_af_vsock=no
62176a02c806SStefan Hajnoczicat > $TMPC << EOF
62186a02c806SStefan Hajnoczi#include <errno.h>
62196a02c806SStefan Hajnoczi#include <sys/types.h>
62206a02c806SStefan Hajnoczi#include <sys/socket.h>
62216a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
62226a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
62236a02c806SStefan Hajnoczi#endif
62246a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
62256a02c806SStefan Hajnocziint main(void) {
62266a02c806SStefan Hajnoczi    int sock, ret;
62276a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
62286a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
62296a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
62306a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
62316a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
62326a02c806SStefan Hajnoczi        return 0;
62336a02c806SStefan Hajnoczi    }
62346a02c806SStefan Hajnoczi    return -1;
62356a02c806SStefan Hajnoczi}
62366a02c806SStefan HajnocziEOF
62376a02c806SStefan Hajnocziif compile_prog "" "" ; then
62386a02c806SStefan Hajnoczi    have_af_vsock=yes
62396a02c806SStefan Hajnoczifi
62406a02c806SStefan Hajnoczi
6241f0d92b56SLongpeng(Mike)##########################################
6242f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
62434f67366eSThomas Huthhave_afalg=no
6244f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
6245f0d92b56SLongpeng(Mike)#include <errno.h>
6246f0d92b56SLongpeng(Mike)#include <sys/types.h>
6247f0d92b56SLongpeng(Mike)#include <sys/socket.h>
6248f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
6249f0d92b56SLongpeng(Mike)int main(void) {
6250f0d92b56SLongpeng(Mike)    int sock;
6251f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
6252f0d92b56SLongpeng(Mike)    return sock;
6253f0d92b56SLongpeng(Mike)}
6254f0d92b56SLongpeng(Mike)EOF
6255f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
6256f0d92b56SLongpeng(Mike)    have_afalg=yes
6257f0d92b56SLongpeng(Mike)fi
6258f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
6259f0d92b56SLongpeng(Mike)then
6260f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
6261f0d92b56SLongpeng(Mike)    then
6262f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
6263f0d92b56SLongpeng(Mike)    fi
6264f0d92b56SLongpeng(Mike)fi
6265f0d92b56SLongpeng(Mike)
6266f0d92b56SLongpeng(Mike)
62676969ec6cSJames Clarke#################################################
6268c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
6269d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
6270c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
6271c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
6272c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
6273c97d6d2cSSergio Andres Gomez Del RealEOF
6274c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
6275c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
6276c97d6d2cSSergio Andres Gomez Del Real  else
6277c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
6278db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-framework Hypervisor $QEMU_LDFLAGS"
6279c97d6d2cSSergio Andres Gomez Del Real  fi
6280c97d6d2cSSergio Andres Gomez Del Realfi
6281c97d6d2cSSergio Andres Gomez Del Real
6282c97d6d2cSSergio Andres Gomez Del Real#################################################
62836969ec6cSJames Clarke# Sparc implicitly links with --relax, which is
62846969ec6cSJames Clarke# incompatible with -r, so --no-relax should be
62856969ec6cSJames Clarke# given. It does no harm to give it on other
62866969ec6cSJames Clarke# platforms too.
62876969ec6cSJames Clarke
62886969ec6cSJames Clarke# Note: the prototype is needed since QEMU_CFLAGS
62896969ec6cSJames Clarke#       contains -Wmissing-prototypes
62906969ec6cSJames Clarkecat > $TMPC << EOF
62916969ec6cSJames Clarkeextern int foo(void);
62926969ec6cSJames Clarkeint foo(void) { return 0; }
62936969ec6cSJames ClarkeEOF
62946969ec6cSJames Clarkeif ! compile_object ""; then
62956969ec6cSJames Clarke  error_exit "Failed to compile object file for LD_REL_FLAGS test"
62966969ec6cSJames Clarkefi
62977ecf44a5SPaolo Bonzinifor i in '-Wl,-r -Wl,--no-relax' -Wl,-r -r; do
62987ecf44a5SPaolo Bonzini  if do_cc -nostdlib $i -o $TMPMO $TMPO; then
62997ecf44a5SPaolo Bonzini    LD_REL_FLAGS=$i
63007ecf44a5SPaolo Bonzini    break
63017ecf44a5SPaolo Bonzini  fi
63027ecf44a5SPaolo Bonzinidone
63037ecf44a5SPaolo Bonziniif test "$modules" = "yes" && test "$LD_REL_FLAGS" = ""; then
63047ecf44a5SPaolo Bonzini  feature_not_found "modules" "Cannot find how to build relocatable objects"
63056969ec6cSJames Clarkefi
63066969ec6cSJames Clarke
6307277abf15SJan Vesely##########################################
63084d04351fSChristopher Covington# check for sysmacros.h
63094d04351fSChristopher Covington
63104d04351fSChristopher Covingtonhave_sysmacros=no
63114d04351fSChristopher Covingtoncat > $TMPC << EOF
63124d04351fSChristopher Covington#include <sys/sysmacros.h>
63134d04351fSChristopher Covingtonint main(void) {
63144d04351fSChristopher Covington    return makedev(0, 0);
63154d04351fSChristopher Covington}
63164d04351fSChristopher CovingtonEOF
63174d04351fSChristopher Covingtonif compile_prog "" "" ; then
63184d04351fSChristopher Covington    have_sysmacros=yes
63194d04351fSChristopher Covingtonfi
63204d04351fSChristopher Covington
63214d04351fSChristopher Covington##########################################
632249e00a18SAndreas Grapentin# check for _Static_assert()
632349e00a18SAndreas Grapentin
632449e00a18SAndreas Grapentinhave_static_assert=no
632549e00a18SAndreas Grapentincat > $TMPC << EOF
632649e00a18SAndreas Grapentin_Static_assert(1, "success");
632749e00a18SAndreas Grapentinint main(void) {
632849e00a18SAndreas Grapentin    return 0;
632949e00a18SAndreas Grapentin}
633049e00a18SAndreas GrapentinEOF
633149e00a18SAndreas Grapentinif compile_prog "" "" ; then
633249e00a18SAndreas Grapentin    have_static_assert=yes
633349e00a18SAndreas Grapentinfi
633449e00a18SAndreas Grapentin
633549e00a18SAndreas Grapentin##########################################
6336e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
6337e674605fSTomáš Golembiovský
6338e674605fSTomáš Golembiovskýhave_utmpx=no
6339e674605fSTomáš Golembiovskýcat > $TMPC << EOF
6340e674605fSTomáš Golembiovský#include <utmpx.h>
6341e674605fSTomáš Golembiovskýstruct utmpx user_info;
6342e674605fSTomáš Golembiovskýint main(void) {
6343e674605fSTomáš Golembiovský    return 0;
6344e674605fSTomáš Golembiovský}
6345e674605fSTomáš GolembiovskýEOF
6346e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
6347e674605fSTomáš Golembiovský    have_utmpx=yes
6348e674605fSTomáš Golembiovskýfi
6349e674605fSTomáš Golembiovský
6350e674605fSTomáš Golembiovský##########################################
6351db1ed1abSRichard Henderson# check for getrandom()
6352db1ed1abSRichard Henderson
6353db1ed1abSRichard Hendersonhave_getrandom=no
6354db1ed1abSRichard Hendersoncat > $TMPC << EOF
6355db1ed1abSRichard Henderson#include <sys/random.h>
6356db1ed1abSRichard Hendersonint main(void) {
6357db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
6358db1ed1abSRichard Henderson}
6359db1ed1abSRichard HendersonEOF
6360db1ed1abSRichard Hendersonif compile_prog "" "" ; then
6361db1ed1abSRichard Henderson    have_getrandom=yes
6362db1ed1abSRichard Hendersonfi
6363db1ed1abSRichard Henderson
6364db1ed1abSRichard Henderson##########################################
6365247724cbSMarc-André Lureau# checks for sanitizers
6366247724cbSMarc-André Lureau
6367247724cbSMarc-André Lureauhave_asan=no
6368247724cbSMarc-André Lureauhave_ubsan=no
6369d83414e1SMarc-André Lureauhave_asan_iface_h=no
6370d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
6371247724cbSMarc-André Lureau
6372247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
6373b9f44da2SMarc-André Lureau  write_c_skeleton
6374247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
6375247724cbSMarc-André Lureau      have_asan=yes
6376247724cbSMarc-André Lureau  fi
6377b9f44da2SMarc-André Lureau
6378b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
6379b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
6380b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
6381b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
6382b9f44da2SMarc-André Lureau#include <stdlib.h>
6383b9f44da2SMarc-André Lureauint main(void) {
6384b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
6385f2dfe54cSLeonid Bloch    if (tmp != NULL) {
6386b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
6387b9f44da2SMarc-André Lureau    }
6388d1abf3fcSOlaf Hering    return 1;
6389f2dfe54cSLeonid Bloch}
6390b9f44da2SMarc-André LureauEOF
6391247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
6392247724cbSMarc-André Lureau      have_ubsan=yes
6393247724cbSMarc-André Lureau  fi
6394d83414e1SMarc-André Lureau
6395d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
6396d83414e1SMarc-André Lureau      have_asan_iface_h=yes
6397d83414e1SMarc-André Lureau  fi
6398d83414e1SMarc-André Lureau
6399d83414e1SMarc-André Lureau  cat > $TMPC << EOF
6400d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
6401d83414e1SMarc-André Lureauint main(void) {
6402d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
6403d83414e1SMarc-André Lureau  return 0;
6404d83414e1SMarc-André Lureau}
6405d83414e1SMarc-André LureauEOF
6406d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
6407d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
6408d83414e1SMarc-André Lureau  fi
6409247724cbSMarc-André Lureaufi
6410247724cbSMarc-André Lureau
6411247724cbSMarc-André Lureau##########################################
6412adc28027SAlexander Bulekov# checks for fuzzer
6413adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
6414adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
6415dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
6416adc28027SAlexander Bulekov      have_fuzzer=yes
6417adc28027SAlexander Bulekov  fi
6418adc28027SAlexander Bulekovfi
6419adc28027SAlexander Bulekov
64200aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
64210aebab04SLingfeng Yang# keep it separate until that is not the case.
64220aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
64230aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
64240aebab04SLingfeng Yangfi
64250aebab04SLingfeng Yanghave_tsan=no
64260aebab04SLingfeng Yanghave_tsan_iface_fiber=no
64270aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
64280aebab04SLingfeng Yang  write_c_skeleton
64290aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
64300aebab04SLingfeng Yang      have_tsan=yes
64310aebab04SLingfeng Yang  fi
64320aebab04SLingfeng Yang  cat > $TMPC << EOF
64330aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
64340aebab04SLingfeng Yangint main(void) {
64350aebab04SLingfeng Yang  __tsan_create_fiber(0);
64360aebab04SLingfeng Yang  return 0;
64370aebab04SLingfeng Yang}
64380aebab04SLingfeng YangEOF
64390aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
64400aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
64410aebab04SLingfeng Yang  fi
64420aebab04SLingfeng Yangfi
64430aebab04SLingfeng Yang
6444adc28027SAlexander Bulekov##########################################
644517824406SJunyan He# check for libpmem
644617824406SJunyan He
644717824406SJunyan Heif test "$libpmem" != "no"; then
644817824406SJunyan He	if $pkg_config --exists "libpmem"; then
644917824406SJunyan He		libpmem="yes"
645017824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
645117824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
645217824406SJunyan He		libs_softmmu="$libs_softmmu $libpmem_libs"
645317824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
645417824406SJunyan He	else
645517824406SJunyan He		if test "$libpmem" = "yes" ; then
645617824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
645717824406SJunyan He		fi
645817824406SJunyan He		libpmem="no"
645917824406SJunyan He	fi
646017824406SJunyan Hefi
646117824406SJunyan He
646217824406SJunyan He##########################################
646321b2eca6SJingqi Liu# check for libdaxctl
646421b2eca6SJingqi Liu
646521b2eca6SJingqi Liuif test "$libdaxctl" != "no"; then
646621b2eca6SJingqi Liu	if $pkg_config --atleast-version=57 "libdaxctl"; then
646721b2eca6SJingqi Liu		libdaxctl="yes"
646821b2eca6SJingqi Liu		libdaxctl_libs=$($pkg_config --libs libdaxctl)
646921b2eca6SJingqi Liu		libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
647021b2eca6SJingqi Liu		libs_softmmu="$libs_softmmu $libdaxctl_libs"
647121b2eca6SJingqi Liu		QEMU_CFLAGS="$QEMU_CFLAGS $libdaxctl_cflags"
647221b2eca6SJingqi Liu	else
647321b2eca6SJingqi Liu		if test "$libdaxctl" = "yes" ; then
647421b2eca6SJingqi Liu			feature_not_found "libdaxctl" "Install libdaxctl"
647521b2eca6SJingqi Liu		fi
647621b2eca6SJingqi Liu		libdaxctl="no"
647721b2eca6SJingqi Liu	fi
647821b2eca6SJingqi Liufi
647921b2eca6SJingqi Liu
648021b2eca6SJingqi Liu##########################################
6481675b9b53SMarc-André Lureau# check for slirp
6482675b9b53SMarc-André Lureau
6483d599938aSLaurent Vivier# slirp is only required when building softmmu targets
6484d599938aSLaurent Vivierif test -z "$slirp" -a "$softmmu" != "yes" ; then
6485d599938aSLaurent Vivier    slirp="no"
6486d599938aSLaurent Vivierfi
6487d599938aSLaurent Vivier
6488675b9b53SMarc-André Lureaucase "$slirp" in
6489675b9b53SMarc-André Lureau  "" | yes)
6490675b9b53SMarc-André Lureau    if $pkg_config slirp; then
6491675b9b53SMarc-André Lureau      slirp=system
64927c57bdd8SMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
64937c57bdd8SMarc-André Lureau      slirp=git
6494675b9b53SMarc-André Lureau    elif test -e "${source_path}/slirp/Makefile" ; then
6495675b9b53SMarc-André Lureau      slirp=internal
6496675b9b53SMarc-André Lureau    elif test -z "$slirp" ; then
6497675b9b53SMarc-André Lureau      slirp=no
6498675b9b53SMarc-André Lureau    else
6499675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel or git submodule"
6500675b9b53SMarc-André Lureau    fi
6501675b9b53SMarc-André Lureau    ;;
6502675b9b53SMarc-André Lureau
6503675b9b53SMarc-André Lureau  system)
6504675b9b53SMarc-André Lureau    if ! $pkg_config slirp; then
6505675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel"
6506675b9b53SMarc-André Lureau    fi
6507675b9b53SMarc-André Lureau    ;;
6508675b9b53SMarc-André Lureauesac
6509675b9b53SMarc-André Lureau
6510675b9b53SMarc-André Lureaucase "$slirp" in
65117c57bdd8SMarc-André Lureau  git | internal)
65127c57bdd8SMarc-André Lureau    if test "$slirp" = git; then
65137c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
65147c57bdd8SMarc-André Lureau    fi
6515675b9b53SMarc-André Lureau    mkdir -p slirp
651625211446SPaolo Bonzini    slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
651725211446SPaolo Bonzini    slirp_libs="-L$PWD/slirp -lslirp"
6518b965e8c5SPaolo Bonzini    if test "$mingw32" = "yes" ; then
6519b965e8c5SPaolo Bonzini      slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
6520b965e8c5SPaolo Bonzini    fi
6521675b9b53SMarc-André Lureau    ;;
6522675b9b53SMarc-André Lureau
6523675b9b53SMarc-André Lureau  system)
6524675b9b53SMarc-André Lureau    slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
6525675b9b53SMarc-André Lureau    slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
6526675b9b53SMarc-André Lureau    slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
6527675b9b53SMarc-André Lureau    ;;
6528675b9b53SMarc-André Lureau
6529675b9b53SMarc-André Lureau  no)
6530675b9b53SMarc-André Lureau    ;;
6531675b9b53SMarc-André Lureau  *)
6532675b9b53SMarc-André Lureau    error_exit "Unknown state for slirp: $slirp"
6533675b9b53SMarc-André Lureau    ;;
6534675b9b53SMarc-André Lureauesac
6535675b9b53SMarc-André Lureau
653654e7aac0SAlexey Krasikov##########################################
653754e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
653854e7aac0SAlexey Krasikov
653954e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
654054e7aac0SAlexey Krasikov
654154e7aac0SAlexey Krasikov    have_keyring=no
654254e7aac0SAlexey Krasikov    cat > $TMPC << EOF
654354e7aac0SAlexey Krasikov#include <errno.h>
654454e7aac0SAlexey Krasikov#include <asm/unistd.h>
654554e7aac0SAlexey Krasikov#include <linux/keyctl.h>
654654e7aac0SAlexey Krasikov#include <unistd.h>
654754e7aac0SAlexey Krasikovint main(void) {
654854e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
654954e7aac0SAlexey Krasikov}
655054e7aac0SAlexey KrasikovEOF
655154e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
655254e7aac0SAlexey Krasikov        have_keyring=yes
655354e7aac0SAlexey Krasikov    fi
655454e7aac0SAlexey Krasikovfi
655554e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
655654e7aac0SAlexey Krasikovthen
6557b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
655854e7aac0SAlexey Krasikov    then
655954e7aac0SAlexey Krasikov	secret_keyring=yes
656054e7aac0SAlexey Krasikov    else
656154e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
656254e7aac0SAlexey Krasikov	then
656354e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
656454e7aac0SAlexey Krasikovbut not implemented on your system"
656554e7aac0SAlexey Krasikov	else
656654e7aac0SAlexey Krasikov	    secret_keyring=no
656754e7aac0SAlexey Krasikov	fi
656854e7aac0SAlexey Krasikov    fi
656954e7aac0SAlexey Krasikovfi
657054e7aac0SAlexey Krasikov
657192500362SAlexey Krasikov##########################################
657292500362SAlexey Krasikov# check for usable keyutils.h
657392500362SAlexey Krasikov
657492500362SAlexey Krasikovif test "$linux" = "yes" ; then
657592500362SAlexey Krasikov
657692500362SAlexey Krasikov    have_keyutils=no
657792500362SAlexey Krasikov    cat > $TMPC << EOF
657892500362SAlexey Krasikov#include <errno.h>
657992500362SAlexey Krasikov#include <asm/unistd.h>
658092500362SAlexey Krasikov#include <unistd.h>
658192500362SAlexey Krasikov#include <sys/types.h>
658292500362SAlexey Krasikov#include <keyutils.h>
658392500362SAlexey Krasikovint main(void) {
658492500362SAlexey Krasikov    return request_key("user", NULL, NULL, 0);
658592500362SAlexey Krasikov}
658692500362SAlexey KrasikovEOF
658792500362SAlexey Krasikov    if compile_prog "" "-lkeyutils"; then
658892500362SAlexey Krasikov        have_keyutils=yes
658992500362SAlexey Krasikov    fi
659092500362SAlexey Krasikovfi
659192500362SAlexey Krasikov
6592675b9b53SMarc-André Lureau
6593675b9b53SMarc-André Lureau##########################################
6594e86ecd4bSJuan Quintela# End of CC checks
6595e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
6596e86ecd4bSJuan Quintela
6597d83414e1SMarc-André Lureauwrite_c_skeleton
6598d83414e1SMarc-André Lureau
65991d728c39SBlue Swirlif test "$gcov" = "yes" ; then
6600bf0e56a3SMarc-André Lureau  :
6601b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
6602086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
6603086d5f75SPaolo Bonzini  debug=no
6604086d5f75SPaolo Bonzinifi
6605086d5f75SPaolo Bonziniif test "$debug_info" = "yes"; then
6606086d5f75SPaolo Bonzini  CFLAGS="-g $CFLAGS"
6607086d5f75SPaolo Bonzini  LDFLAGS="-g $LDFLAGS"
6608086d5f75SPaolo Bonzinifi
6609a5665051SPaolo Bonziniif test "$debug" = "no"; then
6610a5665051SPaolo Bonzini  CFLAGS="-O2 $CFLAGS"
6611a5665051SPaolo Bonzinifi
6612086d5f75SPaolo Bonzini
6613086d5f75SPaolo Bonzinicase "$ARCH" in
6614086d5f75SPaolo Bonzinialpha)
6615086d5f75SPaolo Bonzini  # Ensure there's only a single GP
6616086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
6617086d5f75SPaolo Bonzini;;
6618086d5f75SPaolo Bonziniesac
6619086d5f75SPaolo Bonzini
6620086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
6621086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
6622086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
6623086d5f75SPaolo Bonzinifi
6624a316e378SJuan Quintela
6625247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
6626db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
6627db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
6628d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
6629d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
6630d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6631d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
6632d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
6633d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6634d83414e1SMarc-André Lureau  fi
6635247724cbSMarc-André Lureaufi
66360aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
66370aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
66380aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
66390aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
66400aebab04SLingfeng Yang  else
66410aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
66420aebab04SLingfeng Yang  fi
66430aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
66440aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
66450aebab04SLingfeng Yangfi
6646247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
6647db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
6648db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
6649247724cbSMarc-André Lureaufi
6650247724cbSMarc-André Lureau
66516542aa9cSPeter Lieven##########################################
66526542aa9cSPeter Lieven# Do we have libnfs
66536542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
6654b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
66556542aa9cSPeter Lieven    libnfs="yes"
66566542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
66576542aa9cSPeter Lieven  else
66586542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
66598efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
66606542aa9cSPeter Lieven    fi
66616542aa9cSPeter Lieven    libnfs="no"
66626542aa9cSPeter Lieven  fi
66636542aa9cSPeter Lievenfi
66641d728c39SBlue Swirl
66653efac6ebSTomáš Golembiovský##########################################
66663efac6ebSTomáš Golembiovský# Do we have libudev
66673efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
66683efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
66693efac6ebSTomáš Golembiovský    libudev="yes"
66703efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
66713efac6ebSTomáš Golembiovský  else
66723efac6ebSTomáš Golembiovský    libudev="no"
66733efac6ebSTomáš Golembiovský  fi
66743efac6ebSTomáš Golembiovskýfi
66753efac6ebSTomáš Golembiovský
66766ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
66776ca026cbSPeter Maydellif test "$werror" = "yes"; then
66786ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
66796ca026cbSPeter Maydellfi
66806ca026cbSPeter Maydell
66810aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
66820aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
6683e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
6684db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
6685e86ecd4bSJuan Quintela    fi
6686e86ecd4bSJuan Quintelafi
6687e86ecd4bSJuan Quintela
668894dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
668994dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
669094dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
669194dd53c5SGerd Hoffmannelse
669294dd53c5SGerd Hoffmann    POD2MAN="pod2man"
669394dd53c5SGerd Hoffmannfi
669494dd53c5SGerd Hoffmann
6695952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
6696952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
6697952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
6698e9a3591fSChristian Borntraeger        if ld_has $flag ; then
6699db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
6700952afb71SBlue Swirl        fi
6701952afb71SBlue Swirl    done
6702952afb71SBlue Swirlfi
6703952afb71SBlue Swirl
67047776ea6bSPhilippe Mathieu-Daudé# Disable OpenBSD W^X if available
67057776ea6bSPhilippe Mathieu-Daudéif test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
67067776ea6bSPhilippe Mathieu-Daudé    cat > $TMPC <<EOF
67077776ea6bSPhilippe Mathieu-Daudé    int main(void) { return 0; }
67087776ea6bSPhilippe Mathieu-DaudéEOF
67097776ea6bSPhilippe Mathieu-Daudé    wx_ldflags="-Wl,-z,wxneeded"
67107776ea6bSPhilippe Mathieu-Daudé    if compile_prog "" "$wx_ldflags"; then
67117776ea6bSPhilippe Mathieu-Daudé        QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
67127776ea6bSPhilippe Mathieu-Daudé    fi
67137776ea6bSPhilippe Mathieu-Daudéfi
67147776ea6bSPhilippe Mathieu-Daudé
671510ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
6716e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
6717528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
6718834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
6719a8260d38SDaniel P. Berrangéqemu_icondir="$datadir/icons"
672067ea9546SDaniel P. Berrangéqemu_desktopdir="$datadir/applications"
67215a67135aSbellard
6722e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
6723e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
6724e0580342SKamil Rytarowski  ivshmem=yes
6725e0580342SKamil Rytarowskifi
6726e0580342SKamil Rytarowski
67274b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
6728b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
67297e462613SPaolo Bonzini    if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
6730983eef5aSMeador Inge      virtfs=yes
6731983eef5aSMeador Inge    else
6732983eef5aSMeador Inge      if test "$virtfs" = yes; then
67337e462613SPaolo Bonzini        error_exit "VirtFS requires libcap-ng devel and libattr devel"
6734983eef5aSMeador Inge      fi
673517500370SAndreas Färber      virtfs=no
6736983eef5aSMeador Inge    fi
6737fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
6738fe8fc5aeSPaolo Bonzini      mpath=yes
6739fe8fc5aeSPaolo Bonzini    else
6740fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
6741fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
6742fe8fc5aeSPaolo Bonzini      fi
6743fe8fc5aeSPaolo Bonzini      mpath=no
6744fe8fc5aeSPaolo Bonzini    fi
6745b855f8d1SPaolo Bonzini  else
6746b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
6747b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
6748b855f8d1SPaolo Bonzini    fi
6749b855f8d1SPaolo Bonzini    virtfs=no
6750fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
6751fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
6752fe8fc5aeSPaolo Bonzini    fi
6753fe8fc5aeSPaolo Bonzini    mpath=no
675417bff52bSM. Mohan Kumar  fi
6755ff69fd8cSLaurent Vivierfi
67569d6bc27bSMichael Roth
67579d6bc27bSMichael Roth# Probe for guest agent support/options
67589d6bc27bSMichael Roth
6759e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
6760a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6761a5125905SLaurent Vivier      guest_agent=no
6762a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
6763e8ef31a3SMichael Tokarev      guest_agent=yes
6764e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
6765e8ef31a3SMichael Tokarev      guest_agent=no
6766e8ef31a3SMichael Tokarev  else
6767e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
6768ca35f780SPaolo Bonzini  fi
67694b1c11fdSDaniel P. Berrangefi
6770ca35f780SPaolo Bonzini
67719d6bc27bSMichael Roth# Guest agent Window MSI  package
67729d6bc27bSMichael Roth
67739d6bc27bSMichael Rothif test "$guest_agent" != yes; then
67749d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
67759d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
67769d6bc27bSMichael Roth  fi
67779d6bc27bSMichael Roth  guest_agent_msi=no
67789d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
67799d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
67809d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
67819d6bc27bSMichael Roth  fi
67829d6bc27bSMichael Roth  guest_agent_msi=no
67839d6bc27bSMichael Rothelif ! has wixl; then
67849d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
67859d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
67869d6bc27bSMichael Roth  fi
67879d6bc27bSMichael Roth  guest_agent_msi=no
67881a34904eSMichael Rothelse
67891a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
67901a34904eSMichael Roth  # disabled explicitly
67911a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
67921a34904eSMichael Roth    guest_agent_msi=yes
67931a34904eSMichael Roth  fi
67949d6bc27bSMichael Rothfi
67959d6bc27bSMichael Roth
67961a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
67979d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
67989d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
67999d6bc27bSMichael Roth  fi
68009d6bc27bSMichael Roth
68019d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
68029d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
68039d6bc27bSMichael Roth  fi
68049d6bc27bSMichael Roth
68059d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
68069d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
68079d6bc27bSMichael Roth  fi
68089d6bc27bSMichael Roth
68099d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
681089138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
68119d6bc27bSMichael Roth  fi
68129d6bc27bSMichael Roth
681389138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
68149d6bc27bSMichael Roth
68159d6bc27bSMichael Roth  case "$cpu" in
68169d6bc27bSMichael Roth  x86_64)
68179d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
68189d6bc27bSMichael Roth    ;;
68199d6bc27bSMichael Roth  i386)
68209d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
68219d6bc27bSMichael Roth    ;;
68229d6bc27bSMichael Roth  *)
68239d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
68249d6bc27bSMichael Roth    ;;
68259d6bc27bSMichael Roth  esac
68269d6bc27bSMichael Rothfi
68279d6bc27bSMichael Roth
6828ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
6829ca35f780SPaolo Bonziniroms=
6830e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6831e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6832e633a5c6SEric Blake        test "$softmmu" = yes ; then
6833e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
6834c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6835c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6836c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6837e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6838e57218b6SPeter Maydell            ld_i386_emulation="$emu"
6839ca35f780SPaolo Bonzini            roms="optionrom"
6840e57218b6SPeter Maydell            break
6841e57218b6SPeter Maydell        fi
6842e57218b6SPeter Maydell    done
6843ca35f780SPaolo Bonzinifi
6844ca35f780SPaolo Bonzini
68452e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
68469933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
68472e33c3f8SThomas Huth  write_c_skeleton
68482e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
68499933c305SChristian Borntraeger    roms="$roms s390-ccw"
68501ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
68511ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
68521ef6bfc2SPhilippe Mathieu-Daudé    if test -e "${source_path}/.git" ; then
68531ef6bfc2SPhilippe Mathieu-Daudé      git_submodules="${git_submodules} roms/SLOF"
68541ef6bfc2SPhilippe Mathieu-Daudé    fi
68559933c305SChristian Borntraeger  fi
68562e33c3f8SThomas Huthfi
68579933c305SChristian Borntraeger
685811cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
685911cde1c8SBruno 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.
686011cde1c8SBruno Dominguezif has $cxx; then
686111cde1c8SBruno Dominguez    cat > $TMPC <<EOF
686211cde1c8SBruno Dominguezint c_function(void);
686311cde1c8SBruno Dominguezint main(void) { return c_function(); }
686411cde1c8SBruno DominguezEOF
686511cde1c8SBruno Dominguez
686611cde1c8SBruno Dominguez    compile_object
686711cde1c8SBruno Dominguez
686811cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
686911cde1c8SBruno Dominguezextern "C" {
687011cde1c8SBruno Dominguez   int c_function(void);
687111cde1c8SBruno Dominguez}
687211cde1c8SBruno Dominguezint c_function(void) { return 42; }
687311cde1c8SBruno DominguezEOF
687411cde1c8SBruno Dominguez
687511cde1c8SBruno Dominguez    update_cxxflags
687611cde1c8SBruno Dominguez
6877086d5f75SPaolo Bonzini    if do_cxx $CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
687811cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
687911cde1c8SBruno Dominguez        :
688011cde1c8SBruno Dominguez    else
688111cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
688211cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
688311cde1c8SBruno Dominguez        cxx=
688411cde1c8SBruno Dominguez    fi
688511cde1c8SBruno Dominguezelse
688611cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
688711cde1c8SBruno Dominguez    cxx=
688811cde1c8SBruno Dominguezfi
688911cde1c8SBruno Dominguez
689002d34f62SCole Robinsonecho_version() {
689102d34f62SCole Robinson    if test "$1" = "yes" ; then
689202d34f62SCole Robinson        echo "($2)"
689302d34f62SCole Robinson    fi
689402d34f62SCole Robinson}
689502d34f62SCole Robinson
689650e12060SJan Kiszka# prepend pixman and ftd flags after all config tests are done
689750e12060SJan KiszkaQEMU_CFLAGS="$pixman_cflags $fdt_cflags $QEMU_CFLAGS"
68988a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
689950e12060SJan Kiszkalibs_softmmu="$pixman_libs $libs_softmmu"
69005ca9388aSGerd Hoffmann
690198ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
690297a847bcSbellard
6903dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6904dbd99ae3SStefan Weil
690598ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
690698ec69acSJuan Quintelaecho >> $config_host_mak
690798ec69acSJuan Quintela
6908e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
690999d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
691099d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
69113aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
69128bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
69130f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
691499d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
691599d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
691622d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
69179afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
69183d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
69199afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6920e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
69215a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6922785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
69235a699bbbSLaszlo Ersekfi
6924f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6925834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6926a8260d38SDaniel P. Berrangéecho "qemu_icondir=$qemu_icondir" >> $config_host_mak
692767ea9546SDaniel P. Berrangéecho "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
692802f9135bSDaniel P. Berrangéecho "libs_cpu=$libs_cpu" >> $config_host_mak
6929f544a488SPaolo Bonziniecho "libs_softmmu=$libs_softmmu" >> $config_host_mak
6930cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6931aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6932f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6933804edf29SJuan Quintela
693498ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6935727e5283SPaolo Bonzini
6936777dddc5SAlex Bennéeecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
6937777dddc5SAlex Bennéeecho "GLIB_LDFLAGS=$glib_ldflags" >> $config_host_mak
6938777dddc5SAlex Bennée
6939f3494749SPaolo Bonziniif test "$default_devices" = "yes" ; then
6940f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6941f3494749SPaolo Bonzinielse
6942f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6943f3494749SPaolo Bonzinifi
6944f8393946Saurel32if test "$debug_tcg" = "yes" ; then
69452358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6946f8393946Saurel32fi
69471625af87Saliguoriif test "$strip_opt" = "yes" ; then
694852ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
69491625af87Saliguorifi
69507d13299dSbellardif test "$bigendian" = "yes" ; then
6951e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
695297a847bcSbellardfi
695367b915a5Sbellardif test "$mingw32" = "yes" ; then
695498ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
695589138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
69569fe6de94SBlue Swirl  version_major=${rc_version%%.*}
69579fe6de94SBlue Swirl  rc_version=${rc_version#*.}
69589fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
69599fe6de94SBlue Swirl  rc_version=${rc_version#*.}
69609fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
69619fe6de94SBlue Swirl  version_micro=0
69629fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
69639fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6964d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6965d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6966f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6967d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6968d9840e25STomoki Sekiyama  fi
696950cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
697076dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
697150cbebb9SMichael Roth  fi
69721a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
69739dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
69749dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
69759dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
69769dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
69779dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
69789dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
69799dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
69809dacf32dSYossi Hindin  fi
6981210fa556Spbrookelse
698235f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6983210fa556Spbrookfi
6984128ab2ffSblueswir1
6985dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6986dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6987dffcb71cSMark McLoughlinfi
6988dffcb71cSMark McLoughlin
698983fb7adfSbellardif test "$darwin" = "yes" ; then
699098ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
699183fb7adfSbellardfi
6992b29fe3edSmalc
6993ec530c81Sbellardif test "$solaris" = "yes" ; then
699498ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6995ec530c81Sbellardfi
6996179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6997179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6998179cf400SAndreas Färberfi
699997a847bcSbellardif test "$static" = "yes" ; then
700098ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
700197a847bcSbellardfi
70021ba16968SStefan Weilif test "$profiler" = "yes" ; then
70032358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
700405c2a3e7Sbellardfi
7005c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
7006c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
7007c932ce31SPaolo Bonzinifi
7008f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
7009f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
7010f15bff25SPaolo Bonzinifi
7011675b9b53SMarc-André Lureauif test "$slirp" != "no"; then
701298ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
7013e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
7014675b9b53SMarc-André Lureau  echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
7015675b9b53SMarc-André Lureau  echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
7016675b9b53SMarc-André Lureaufi
70177c57bdd8SMarc-André Lureauif [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
70183b8593eeSMarkus Armbruster    echo "config-host.h: slirp/all" >> $config_host_mak
7019c20709aaSbellardfi
70208a16d273Sthsif test "$vde" = "yes" ; then
702198ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
7022e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
70238a16d273Sthsfi
702458952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
702558952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
702658952137SVincenzo Maffionefi
7027015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
7028015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
7029015a33bdSGongleifi
70304cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
70314cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
70324cc600d2SPaolo Bonzinifi
703347e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
7034a358bca2SPaolo Bonzini  echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak
70353f99cf57SPaolo Bonzini  echo "LIBCAP_NG_LIBS=$cap_libs" >> $config_host_mak
703647e98658SCorey Bryantfi
70372358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
70380c58ac1cSmalcfor drv in $audio_drv_list; do
70391ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
7040ce3dc033SGerd Hoffmann    case "$drv" in
7041051c7d5cSGerd Hoffmann	alsa | oss | pa | sdl)
7042ce3dc033SGerd Hoffmann	    echo "$def=m" >> $config_host_mak ;;
7043ce3dc033SGerd Hoffmann	*)
7044ce3dc033SGerd Hoffmann	    echo "$def=y" >> $config_host_mak ;;
7045ce3dc033SGerd Hoffmann    esac
70460c58ac1cSmalcdone
7047478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
7048478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
7049478e943fSPaolo Bonzinifi
7050b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
7051478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
7052478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
7053478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
7054478e943fSPaolo Bonzinifi
7055b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
7056478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
7057b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
7058b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
7059b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
7060478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
7061478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
7062478e943fSPaolo Bonzinifi
70632e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
7064d5631638Smalcif test "$audio_win_int" = "yes" ; then
7065d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
7066d5631638Smalcfi
7067b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
7068b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
7069821601eaSJes Sorensenif test "$vnc" = "yes" ; then
7070821601eaSJes Sorensen  echo "CONFIG_VNC=y" >> $config_host_mak
7071821601eaSJes Sorensenfi
70722f9606b3Saliguoriif test "$vnc_sasl" = "yes" ; then
707398ec69acSJuan Quintela  echo "CONFIG_VNC_SASL=y" >> $config_host_mak
70742f9606b3Saliguorifi
70752b1ccdf4SMarc-André Lureauecho "SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak
70762b1ccdf4SMarc-André Lureauecho "SASL_LIBS=$vnc_sasl_libs" >> $config_host_mak
7077821601eaSJes Sorensenif test "$vnc_jpeg" = "yes" ; then
70782f6f5c7aSCorentin Chary  echo "CONFIG_VNC_JPEG=y" >> $config_host_mak
70792f6f5c7aSCorentin Charyfi
70802b1ccdf4SMarc-André Lureauecho "JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak
70812b1ccdf4SMarc-André Lureauecho "JPEG_LIBS=$vnc_jpeg_libs" >> $config_host_mak
7082821601eaSJes Sorensenif test "$vnc_png" = "yes" ; then
7083efe556adSCorentin Chary  echo "CONFIG_VNC_PNG=y" >> $config_host_mak
7084efe556adSCorentin Charyfi
70852b1ccdf4SMarc-André Lureauecho "PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak
70862b1ccdf4SMarc-André Lureauecho "PNG_LIBS=$vnc_png_libs" >> $config_host_mak
70876a021536SGerd Hoffmannif test "$xkbcommon" = "yes" ; then
7088ade60d4fSMarc-André Lureau  echo "CONFIG_XKBCOMMON=y" >> $config_host_mak
70896a021536SGerd Hoffmann  echo "XKBCOMMON_CFLAGS=$xkbcommon_cflags" >> $config_host_mak
70906a021536SGerd Hoffmann  echo "XKBCOMMON_LIBS=$xkbcommon_libs" >> $config_host_mak
70916a021536SGerd Hoffmannfi
7092dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
7093dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
7094dce512deSChristoph Hellwigfi
709589138857SStefan Weilqemu_version=$(head $source_path/VERSION)
709698ec69acSJuan Quintelaecho "VERSION=$qemu_version" >>$config_host_mak
70972358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
709898ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
70992b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
7100a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
710198ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
7102cc8ae6deSpbrookfi
710317969268SFam Zhengif test "$modules" = "yes"; then
7104e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
7105e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
710689138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
710717969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
710817969268SFam Zhengfi
7109bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
7110bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
7111bd83c861SChristian Ehrhardtfi
7112e633a5c6SEric Blakeif test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
71138781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
71148781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
71158781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
71168781595bSGerd Hoffmannfi
71171ac88f28SJuan Quintelaif test "$sdl" = "yes" ; then
711896400a14SGerd Hoffmann  echo "CONFIG_SDL=m" >> $config_host_mak
71198ad3a7ddSJuan Quintela  echo "SDL_CFLAGS=$sdl_cflags" >> $config_host_mak
71208ecc89f6SFam Zheng  echo "SDL_LIBS=$sdl_libs" >> $config_host_mak
7121a442fe2fSDaniel P. Berrangé  if test "$sdl_image" = "yes" ; then
7122a442fe2fSDaniel P. Berrangé      echo "CONFIG_SDL_IMAGE=y" >> $config_host_mak
7123a442fe2fSDaniel P. Berrangé  fi
712449ecc3faSbellardfi
712549ecc3faSbellardif test "$cocoa" = "yes" ; then
712698ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
712749ecc3faSbellardfi
7128e08bb301SSamuel Thibaultif test "$iconv" = "yes" ; then
7129e08bb301SSamuel Thibault  echo "CONFIG_ICONV=y" >> $config_host_mak
7130e08bb301SSamuel Thibault  echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
7131e08bb301SSamuel Thibault  echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
7132e08bb301SSamuel Thibaultfi
71334d3b6f6eSbalrogif test "$curses" = "yes" ; then
71342373f7d5SGerd Hoffmann  echo "CONFIG_CURSES=m" >> $config_host_mak
71352373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
71362373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
7137ab4e5602SJan Kiszkafi
7138099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
71392358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
7140099d6b0fSRiku Voipiofi
714140ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
714240ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
714340ff6d7eSKevin Wolffi
71443ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
71452358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
71463ce34dfbSvibisreenivasanfi
7147c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
7148c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
7149c2882b96SRiku Voipiofi
7150751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
7151751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
7152751bcc39SMarc-André Lureaufi
7153955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
7154955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
7155955727d2SCortland Tölvafi
7156d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
7157d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
7158d0927938SUlrich Hechtfi
71593d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
71603d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
71613d4fa43eSKusanagi Kouichifi
7162b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
7163b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
7164b953f075SDenis V. Lunevfi
7165ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
7166ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
7167ed911435SKevin Wolffi
7168c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
7169c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
7170c727f47dSPeter Maydellfi
7171dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
7172dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
7173dace20dcSPeter Maydellfi
7174d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
7175d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
7176d0927938SUlrich Hechtfi
71774e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
71784e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
71794e0c6529SAlex Blighfi
7180cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
7181cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
7182cd758dd0SAlex Blighfi
71833b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
71843b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
71853b6edd16SPeter Maydellfi
71863b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
71873b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
71883b6edd16SPeter Maydellfi
7189a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
7190a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
7191a8fd1abaSPeter Maydellfi
719251834341SRiku Voipioif test "$timerfd" = "yes" ; then
719351834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
719451834341SRiku Voipiofi
71959af5c906SRiku Voipioif test "$setns" = "yes" ; then
71969af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
71979af5c906SRiku Voipiofi
719838860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
719938860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
720038860a03SAleksandar Markovicfi
72015a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
72025a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
72035a03cd00SAleksandar Markovicfi
7204db37dd89SAleksandar Markovicif test "$kcov" = "yes" ; then
7205db37dd89SAleksandar Markovic  echo "CONFIG_KCOV=y" >> $config_host_mak
7206db37dd89SAleksandar Markovicfi
72073b3f24adSaurel32if test "$inotify" = "yes" ; then
72082358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
72093b3f24adSaurel32fi
7210c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
7211c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
7212c05c7a73SRiku Voipiofi
7213401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
7214401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
7215401bc051SPeter Maydellfi
72165c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
72175c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
72185c99fa37SKeno Fischerfi
72198a792b03SJiufei Xueif test "$st_atim" = "yes" ; then
72208a792b03SJiufei Xue  echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
72218a792b03SJiufei Xuefi
72226ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
72236ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
72246ae9a1f4SJuan Quintelafi
72256ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
72266ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
72276ae9a1f4SJuan Quintelafi
7228769ce76dSAlexander Grafif test "$curl" = "yes" ; then
7229d3399d7cSFam Zheng  echo "CONFIG_CURL=m" >> $config_host_mak
7230b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
72316ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
7232769ce76dSAlexander Graffi
72332e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
723498ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
72358eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
72362e4d9fb1Saurel32fi
7237a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
7238e0fb129cSGerd Hoffmann  echo "CONFIG_GTK=m" >> $config_host_mak
7239a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
7240014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
7241925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
7242925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
7243925a0400SGerd Hoffmann  fi
7244bbbf9bfbSStefan Weilfi
7245f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
7246f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
7247f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
7248f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
724925a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
7250f876b765SMarc-André Lureaufi
7251a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
7252ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
7253ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
7254a81df1b6SPaolo Bonzini  echo "GNUTLS_CFLAGS=$gnutls_cflags" >> $config_host_mak
7255a81df1b6SPaolo Bonzini  echo "GNUTLS_LIBS=$gnutls_libs" >> $config_host_mak
7256ddbb0d09SDaniel P. Berrangefi
725791bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
725891bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
72591f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
72601f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
72611f923c70SLongpeng(Mike)  fi
726262893b67SDaniel P. Berrangefi
726391bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
726491bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
7265becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
7266a81df1b6SPaolo Bonzini  echo "NETTLE_CFLAGS=$nettle_cflags" >> $config_host_mak
7267a81df1b6SPaolo Bonzini  echo "NETTLE_LIBS=$nettle_libs" >> $config_host_mak
7268ed754746SDaniel P. Berrangefi
7269e0576942SDaniel P. Berrangéif test "$qemu_private_xts" = "yes" ; then
7270e0576942SDaniel P. Berrangé  echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
7271e0576942SDaniel P. Berrangéfi
72729a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
72739a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
72749a2fd434SDaniel P. Berrangefi
72758953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
72768953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
72778953caf3SDaniel P. Berrangefi
7278559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
7279559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
7280559607eaSDaniel P. Berrangefi
7281e865b97fSChen Gangif test "$have_drm_h" = "yes" ; then
7282e865b97fSChen Gang  echo "HAVE_DRM_H=y" >> $config_host_mak
7283e865b97fSChen Gangfi
72846b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
72856b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
72866b39b063SEric Blakefi
72879df8b20dSThomas Huthif test "$have_openpty" = "yes" ; then
72889df8b20dSThomas Huth    echo "HAVE_OPENPTY=y" >> $config_host_mak
72899df8b20dSThomas Huthfi
72902a4b472cSDavid CARLIERif test "$have_sys_signal_h" = "yes" ; then
72912a4b472cSDavid CARLIER    echo "HAVE_SYS_SIGNAL_H=y" >> $config_host_mak
72922a4b472cSDavid CARLIERfi
7293277abf15SJan Vesely
7294277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
7295277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
7296277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
7297277abf15SJan Vesely# if this macro is set.
7298277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
7299277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
7300277abf15SJan Veselyfi
73011efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
73021efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
73031efad060SFam Zhengfi
7304bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
7305bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
7306a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
7307e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
7308a4ccabcfSAnthony Liguorifi
73099d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
73109d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
73119d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
73129d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
73139d9e1521SGerd Hoffmannfi
7314e37630caSaliguoriif test "$xen" = "yes" ; then
73156dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
7316d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
7317e37630caSaliguorifi
73185c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
73195c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
73205c6c3a6cSChristoph Hellwigfi
7321c10dd856SAarushi Mehtaif test "$linux_io_uring" = "yes" ; then
7322c10dd856SAarushi Mehta  echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
7323c10dd856SAarushi Mehta  echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
7324c10dd856SAarushi Mehta  echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
7325c10dd856SAarushi Mehtafi
7326758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
7327758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
7328ec0d5893SMarc-André Lureau  echo "LIBATTR_LIBS=$libattr_libs" >> $config_host_mak
7329758e8e38SVenkateswararao Jujjuri (JV)fi
73304f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
73314f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
73324f26f2b6SAvi Kivityfi
7333983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
7334758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
7335758e8e38SVenkateswararao Jujjuri (JV)fi
7336fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
7337fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
73381b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
73391b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
73401b0578f5SMurilo Opsfelder Araujo  fi
7341fe8fc5aeSPaolo Bonzinifi
73425e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
73435e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
73445e9be92dSNicholas Bellingerfi
7345af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
7346af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
7347af3bba76SPaolo Bonzinifi
7348af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
734956f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
735003ce5744SNikolay Nikolaevfi
7351108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
7352108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
7353108a6481SCindy Lufi
7354042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
7355042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
7356042cea27SGongleifi
7357fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
7358fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
73595fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
73605fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
73615fe97d88SStefano Garzarella  fi
7362fc0b9b0eSStefan Hajnoczifi
7363299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
7364299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
7365299e6f19SPaolo Bonzinifi
7366e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
7367e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
7368e6a74868SMarc-André Lureaufi
7369108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
7370108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
7371108a6481SCindy Lufi
737298fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
737398fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
737498fc1adaSDr. David Alan Gilbertfi
737577755340Sthsif test "$blobs" = "yes" ; then
737698ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
737777755340Sthsfi
7378bf9298b9Saliguoriif test "$iovec" = "yes" ; then
73792358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
7380bf9298b9Saliguorifi
7381ceb42de8Saliguoriif test "$preadv" = "yes" ; then
73822358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
7383ceb42de8Saliguorifi
7384e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
73853f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
73864a96337dSPaolo Bonzini  echo "FDT_CFLAGS=$fdt_cflags" >> $config_host_mak
73874a96337dSPaolo Bonzini  echo "FDT_LIBS=$fdt_ldflags $fdt_libs" >> $config_host_mak
7388f652e6afSaurel32fi
7389a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
7390a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
7391a40161cbSPaolo Bonzinifi
7392dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
7393dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
7394dcc38d1cSMarcelo Tosattifi
7395d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
7396d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
7397d339d766SRichard W.M. Jonesfi
7398b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
7399b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
74009195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
74019195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
74029195b2c2SStefan Weil  fi
7403b3f6ea7eSPaolo Bonzinifi
74045f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
74055f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
74065f6b9e8fSBlue Swirlfi
7407e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
7408e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
7409e78815a5SAndreas Färberfi
7410e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
7411e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
7412e78815a5SAndreas Färberfi
74139bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
74149bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
74159bc5a719SAndreas Gustafssonfi
74165e5733e5SMarc-André Lureauif test "$zlib" != "no" ; then
74175e5733e5SMarc-André Lureau    echo "CONFIG_ZLIB=y" >> $config_host_mak
74185e5733e5SMarc-André Lureau    echo "ZLIB_CFLAGS=$zlib_cflags" >> $config_host_mak
74195e5733e5SMarc-André Lureau    echo "ZLIB_LIBS=$zlib_libs" >> $config_host_mak
74205e5733e5SMarc-André Lureaufi
7421cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
7422cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
74232634733cSPaolo Bonzini  echo "SPICE_CFLAGS=$spice_cflags" >> $config_host_mak
74242634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
7425cd4ec0b4SGerd Hoffmannfi
7426cd4ec0b4SGerd Hoffmann
74277b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
74287b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
74297b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
74307b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
7431111a38b0SRobert Relyeafi
7432111a38b0SRobert Relyea
74332b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
74342b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
7435b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
7436b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
74372b2325ffSGerd Hoffmannfi
74382b2325ffSGerd Hoffmann
743969354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
744069354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
7441cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
7442cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
744369354a83SHans de Goedefi
744469354a83SHans de Goede
7445da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
7446da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
7447da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
7448014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
7449014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
7450014cb152SGerd Hoffmann  fi
745120ff075bSMichael Wallefi
745220ff075bSMichael Walle
7453d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
7454d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
7455d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
7456d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
7457d52c454aSMarc-André Lureaufi
7458d52c454aSMarc-André Lureau
7459d52c454aSMarc-André Lureau
74605a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
74615a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
74625a22ab71SYang Zhongfi
74635a22ab71SYang Zhong
746499f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
746599f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
746699f2dbd3SLiang Lifi
746799f2dbd3SLiang Li
74686b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
74696b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
74706b8cd447SRobert Hoofi
74716b8cd447SRobert Hoo
7472607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
7473607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
7474708eab42SMarc-André Lureau  echo "LZO_LIBS=$lzo_libs" >> $config_host_mak
7475607dacd0Sqiaonuohanfi
7476607dacd0Sqiaonuohan
7477607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
7478607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
7479708eab42SMarc-André Lureau  echo "SNAPPY_LIBS=$snappy_libs" >> $config_host_mak
7480607dacd0Sqiaonuohanfi
7481607dacd0Sqiaonuohan
74826b383c08SPeter Wuif test "$bzip2" = "yes" ; then
74836b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
74846b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
74856b383c08SPeter Wufi
74866b383c08SPeter Wu
748783bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
748883bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
748983bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
749083bc1f97SJulio Faraccofi
749183bc1f97SJulio Faracco
74923a678481SJuan Quintelaif test "$zstd" = "yes" ; then
74933a678481SJuan Quintela  echo "CONFIG_ZSTD=y" >> $config_host_mak
74945e5733e5SMarc-André Lureau  echo "ZSTD_CFLAGS=$zstd_cflags" >> $config_host_mak
74955e5733e5SMarc-André Lureau  echo "ZSTD_LIBS=$zstd_libs" >> $config_host_mak
74963a678481SJuan Quintelafi
74973a678481SJuan Quintela
7498c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
7499d3399d7cSFam Zheng  echo "CONFIG_LIBISCSI=m" >> $config_host_mak
75006ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
75016ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
7502c589b249SRonnie Sahlbergfi
7503c589b249SRonnie Sahlberg
75046542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
75054be4879fSColin Lord  echo "CONFIG_LIBNFS=m" >> $config_host_mak
75064be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
75076542aa9cSPeter Lievenfi
75086542aa9cSPeter Lieven
7509f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
7510f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
7511c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7512c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7513f794573eSEduardo Otubofi
7514f794573eSEduardo Otubo
751583fb7adfSbellard# XXX: suppress that
75167d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
75172358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
75187d3505c5Sbellardfi
75197d3505c5Sbellard
75204d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
75214d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
75224d9310f4SDaniel P. Berrangefi
75233556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
75243556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
75253556c233SPaolo Bonzinifi
7526f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
7527d3399d7cSFam Zheng  echo "CONFIG_RBD=m" >> $config_host_mak
75286ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7529f27aaf4bSChristian Brunnerfi
753020ff6c80SAnthony Liguori
75317c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
753270c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
753370c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
753470c60c08SStefan Hajnoczielse
753570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
753670c60c08SStefan Hajnoczifi
7537d0e2fce5SAneesh Kumar K.V
75387d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
75397d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
75407d992e4dSPeter Lievenfi
75417d992e4dSPeter Lieven
7542f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
7543f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
7544f0d92b56SLongpeng(Mike)fi
7545f0d92b56SLongpeng(Mike)
7546d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
7547d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7548d2042378SAneesh Kumar K.Vfi
7549d2042378SAneesh Kumar K.V
7550e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
7551e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7552e06a765eSHarsh Prateek Borafi
7553e06a765eSHarsh Prateek Bora
75543f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
75553f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
75563f4349dcSKevin Wolffi
75573f4349dcSKevin Wolf
7558d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
7559d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7560d83414e1SMarc-André Lureaufi
7561d83414e1SMarc-André Lureau
75620aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
75630aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
75640aebab04SLingfeng Yangfi
75650aebab04SLingfeng Yang
75668ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
75678ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
75688ab1bf12SLuiz Capitulinofi
75698ab1bf12SLuiz Capitulino
757076a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
757176a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
757276a347e1SRichard Hendersonfi
757376a347e1SRichard Henderson
7574f540166bSRichard Hendersonif test "$int128" = "yes" ; then
7575f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
7576f540166bSRichard Hendersonfi
7577f540166bSRichard Henderson
75787ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
75797ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
75807ebee43eSRichard Hendersonfi
75817ebee43eSRichard Henderson
7582e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
7583e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7584e6cd4bb5SRichard Hendersonfi
7585e6cd4bb5SRichard Henderson
7586df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
7587df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7588df79b996SRichard Hendersonfi
7589df79b996SRichard Henderson
7590db8aaae8SRichard Hendersonif test "$attralias" = "yes" ; then
7591db8aaae8SRichard Henderson  echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
7592db8aaae8SRichard Hendersonfi
7593db8aaae8SRichard Henderson
75941e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
75951e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
75961e6e9acaSRichard Hendersonfi
75971e6e9acaSRichard Henderson
7598eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
7599d3399d7cSFam Zheng  echo "CONFIG_GLUSTERFS=m" >> $config_host_mak
76006ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
76016ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7602eb100396SBharata B Raofi
7603eb100396SBharata B Rao
7604d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
7605d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7606d85fa9ebSJeff Codyfi
7607d85fa9ebSJeff Cody
76080c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
76090c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
76100c14fb47SBharata B Raofi
76110c14fb47SBharata B Rao
7612df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
7613df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7614df3a429aSNiels de Vosfi
7615df3a429aSNiels de Vos
76167c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
76177c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
76187c815372SBharata B Raofi
76197c815372SBharata B Rao
7620e014dbe7SPrasanna Kumar Kaleverif test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7621e014dbe7SPrasanna Kumar Kalever  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7622e014dbe7SPrasanna Kumar Kaleverfi
7623e014dbe7SPrasanna Kumar Kalever
76240e3b891fSNiels de Vosif test "$glusterfs_iocb_has_stat" = "yes" ; then
76250e3b891fSNiels de Vos  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
76260e3b891fSNiels de Vosfi
76270e3b891fSNiels de Vos
7628b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
7629b10d49d7SPino Toscano  echo "CONFIG_LIBSSH=m" >> $config_host_mak
7630b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7631b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
76320a12ec87SRichard W.M. Jonesfi
76330a12ec87SRichard W.M. Jones
7634ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
7635ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7636ed1701c6SDr. David Alan Gilbertfi
7637ed1701c6SDr. David Alan Gilbert
76383b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
76393cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
76403b8acc11SPaolo Bonzinifi
76413b8acc11SPaolo Bonzini
76425b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
76435b808275SLluís Vilanovaif have_backend "nop"; then
76446d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
764522890ab5SPrerna Saxenafi
76465b808275SLluís Vilanovaif have_backend "simple"; then
76476d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
76486d8a764eSLluís  # Set the appropriate trace file.
7649953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
76509410b56cSPrerna Saxenafi
7651ed7f5f1dSPaolo Bonziniif have_backend "log"; then
7652ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
76536d8a764eSLluísfi
76545b808275SLluís Vilanovaif have_backend "ust"; then
76556d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
7656a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
7657a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
76586d8a764eSLluísfi
76595b808275SLluís Vilanovaif have_backend "dtrace"; then
76606d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
76616d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
76626d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
76636d8a764eSLluís  fi
7664c276b17dSDaniel P. Berrangefi
76655b808275SLluís Vilanovaif have_backend "ftrace"; then
7666781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
7667781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7668781e9545SEiichi Tsukata  else
766921684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7670781e9545SEiichi Tsukata  fi
7671781e9545SEiichi Tsukatafi
76720a852417SPaul Durrantif have_backend "syslog"; then
76730a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
76740a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
76750a852417SPaul Durrant  else
76760a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
76770a852417SPaul Durrant  fi
76780a852417SPaul Durrantfi
76799410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
76809410b56cSPrerna Saxena
76812da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
76822da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
7683392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
76842da776dbSMichael R. Hinesfi
76852da776dbSMichael R. Hines
768621ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
768721ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
768821ab34c9SMarcel Apfelbaumfi
768921ab34c9SMarcel Apfelbaum
7690575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
7691575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7692575b22b1SLaurent Vivierfi
7693575b22b1SLaurent Vivier
7694ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
7695ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
7696ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7697ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7698ed279a06SKlim Kireevfi
7699ed279a06SKlim Kireev
7700a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
7701a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
7702a6b1d4c0SChanglong Xiefi
7703a6b1d4c0SChanglong Xie
77046a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
77056a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
77066a02c806SStefan Hajnoczifi
77076a02c806SStefan Hajnoczi
77084d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
77094d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
77104d04351fSChristopher Covingtonfi
77114d04351fSChristopher Covington
771249e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
771349e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
771449e00a18SAndreas Grapentinfi
771549e00a18SAndreas Grapentin
7716e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
7717e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
7718e674605fSTomáš Golembiovskýfi
7719db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
7720db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7721db1ed1abSRichard Hendersonfi
7722e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
7723e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7724e0580342SKamil Rytarowskifi
7725e219c499SRichard Hendersonif test "$capstone" != "no" ; then
77268ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
77278ca80760SRichard Hendersonfi
7728ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
7729ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7730ba59fb77SPaolo Bonzinifi
7731e0580342SKamil Rytarowski
77325c312079SDr. David Alan Gilbert# Hold two types of flag:
77335c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
77345c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
7735479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
77365c312079SDr. David Alan Gilbert#                                     platform
7737479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
77385c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7739479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7740479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
7741479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7742479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
77435c312079SDr. David Alan Gilbertfi
77445c312079SDr. David Alan Gilbert
774517824406SJunyan Heif test "$libpmem" = "yes" ; then
774617824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
774717824406SJunyan Hefi
774817824406SJunyan He
774921b2eca6SJingqi Liuif test "$libdaxctl" = "yes" ; then
775021b2eca6SJingqi Liu  echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
775121b2eca6SJingqi Liufi
775221b2eca6SJingqi Liu
77532f740136SJeff Codyif test "$bochs" = "yes" ; then
77542f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
77552f740136SJeff Codyfi
77562f740136SJeff Codyif test "$cloop" = "yes" ; then
77572f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
77582f740136SJeff Codyfi
77592f740136SJeff Codyif test "$dmg" = "yes" ; then
77602f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
77612f740136SJeff Codyfi
77622f740136SJeff Codyif test "$qcow1" = "yes" ; then
77632f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
77642f740136SJeff Codyfi
77652f740136SJeff Codyif test "$vdi" = "yes" ; then
77662f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
77672f740136SJeff Codyfi
77682f740136SJeff Codyif test "$vvfat" = "yes" ; then
77692f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
77702f740136SJeff Codyfi
77712f740136SJeff Codyif test "$qed" = "yes" ; then
77722f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
77732f740136SJeff Codyfi
77742f740136SJeff Codyif test "$parallels" = "yes" ; then
77752f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
77762f740136SJeff Codyfi
77772f740136SJeff Codyif test "$sheepdog" = "yes" ; then
77782f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
77792f740136SJeff Codyfi
7780c9c8b88fSDavid CARLIERif test "$pty_h" = "yes" ; then
7781c9c8b88fSDavid CARLIER  echo "HAVE_PTY_H=y" >> $config_host_mak
7782c9c8b88fSDavid CARLIERfi
7783195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
7784195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
7785195588ccSDavid CARLIERfi
7786adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
7787adc28027SAlexander Bulekov  if test "$have_fuzzer" = "yes"; then
7788dd016265SAlexander Bulekov    FUZZ_LDFLAGS=" -fsanitize=fuzzer"
7789dd016265SAlexander Bulekov    FUZZ_CFLAGS=" -fsanitize=fuzzer"
7790086d5f75SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
7791adc28027SAlexander Bulekov  else
7792dd016265SAlexander Bulekov    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
7793adc28027SAlexander Bulekov    exit 1
7794adc28027SAlexander Bulekov  fi
7795adc28027SAlexander Bulekovfi
77962f740136SJeff Cody
779740e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
779840e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
779940e8c6f4SAlex Bennée    LIBS="-ldl $LIBS"
780026fffe29SEmilio G. Cota    # Copy the export object list to the build dir
780126fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
780226fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
780326fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
780426fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
780526fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
780626fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
780726fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
780826fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
780926fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
781026fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
781126fffe29SEmilio G. Cota    else
781226fffe29SEmilio G. Cota	error_exit \
781326fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
781426fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
781526fffe29SEmilio G. Cota    fi
781640e8c6f4SAlex Bennéefi
781740e8c6f4SAlex Bennée
7818f48e590aSAlex Bennéeif test -n "$gdb_bin" ; then
7819f48e590aSAlex Bennée    echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
7820f48e590aSAlex Bennéefi
7821f48e590aSAlex Bennée
782254e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
782354e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
782492500362SAlexey Krasikov  if test "$have_keyutils" = "yes" ; then
782592500362SAlexey Krasikov    echo "CONFIG_TEST_SECRET_KEYRING=y" >> $config_host_mak
782692500362SAlexey Krasikov  fi
782754e7aac0SAlexey Krasikovfi
782854e7aac0SAlexey Krasikov
78295b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
783025211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
78315b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
783225211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/sparc $QEMU_INCLUDES"
78335b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
783425211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/s390 $QEMU_INCLUDES"
7835e633a5c6SEric Blakeelif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
783625211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/i386 $QEMU_INCLUDES"
783740d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
783825211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/ppc $QEMU_INCLUDES"
7839e633a5c6SEric Blakeelif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
784025211446SPaolo Bonzini  QEMU_INCLUDES="-I${source_path}/tcg/riscv $QEMU_INCLUDES"
78415b5e3037SPaolo Bonzinielse
784225211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/${ARCH} $QEMU_INCLUDES"
78435b5e3037SPaolo Bonzinifi
78445b5e3037SPaolo Bonzini
784598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
7846804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
7847804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
78481901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
78491901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
78501901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
785121655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7852c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
78532eb054c2SPeter Maydellecho "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
7854516e8b7dSPeter Maydellecho "SPHINX_WERROR=$sphinx_werror" >> $config_host_mak
785539d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
7856a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
7857804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
7858a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
7859a31a8642SMichael S. Tsirkin  echo "IASL=$iasl" >> $config_host_mak
7860a31a8642SMichael S. Tsirkinfi
786183f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
78623c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
7863804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
786445d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
7865cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
78665f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
78673dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
7868804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
7869804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
78709f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
78714852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
7872daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
78739fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
7874e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
7875086d5f75SPaolo Bonziniecho "CXXFLAGS=$CXXFLAGS" >> $config_host_mak
787646eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7877a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
787811cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7879f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7880a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
7881a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
7882e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
7883968b4db3SPaolo Bonzini  echo "SPARSE_CFLAGS = -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7884e39f0062SPaolo Bonzinifi
78858a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
7886db5adeaaSPaolo Bonziniecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
78876969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7888e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
788973da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
78903e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7891409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7892804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
789317969268SFam Zhengecho "DSOSUF=$DSOSUF" >> $config_host_mak
789417969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7895f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
789690246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
789790246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
789894dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
78991d728c39SBlue Swirlif test "$gcov" = "yes" ; then
79001d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
79011d728c39SBlue Swirlfi
7902804edf29SJuan Quintela
79033efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
79043efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
79053efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
79063efac6ebSTomáš Golembiovskýfi
7907adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
7908adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
7909adc28027SAlexander Bulekov    echo "FUZZ_CFLAGS=$FUZZ_CFLAGS" >> $config_host_mak
7910adc28027SAlexander Bulekov    echo "FUZZ_LDFLAGS=$FUZZ_LDFLAGS" >> $config_host_mak
7911adc28027SAlexander Bulekovfi
79123efac6ebSTomáš Golembiovský
791305dfa22bSPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" ; then
791405dfa22bSPhilippe Mathieu-Daudé  echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
791505dfa22bSPhilippe Mathieu-Daudéfi
791605dfa22bSPhilippe Mathieu-Daudé
7917b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
7918b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
7919b767d257SMarek Marczykowski-Góreckifi
7920b767d257SMarek Marczykowski-Górecki
79216efd7517SPeter Maydell# use included Linux headers
79226efd7517SPeter Maydellif test "$linux" = "yes" ; then
7923a307beb6SAndreas Färber  mkdir -p linux-headers
79246efd7517SPeter Maydell  case "$cpu" in
7925c72b26ecSRichard Henderson  i386|x86_64|x32)
792608312a63SPeter Maydell    linux_arch=x86
79276efd7517SPeter Maydell    ;;
7928f8378accSRichard Henderson  ppc|ppc64|ppc64le)
792908312a63SPeter Maydell    linux_arch=powerpc
79306efd7517SPeter Maydell    ;;
79316efd7517SPeter Maydell  s390x)
793208312a63SPeter Maydell    linux_arch=s390
793308312a63SPeter Maydell    ;;
79341f080313SClaudio Fontana  aarch64)
79351f080313SClaudio Fontana    linux_arch=arm64
79361f080313SClaudio Fontana    ;;
7937222e7d11SSanjay Lal  mips64)
7938222e7d11SSanjay Lal    linux_arch=mips
7939222e7d11SSanjay Lal    ;;
794008312a63SPeter Maydell  *)
794108312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
794208312a63SPeter Maydell    linux_arch="$cpu"
79436efd7517SPeter Maydell    ;;
79446efd7517SPeter Maydell  esac
794508312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
794608312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
794708312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
794808312a63SPeter Maydell    fi
79496efd7517SPeter Maydellfi
79506efd7517SPeter Maydell
795197a847bcSbellardfor target in $target_list; do
795297a847bcSbellardtarget_dir="$target"
795325be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
795489138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
795552bf9771Stony.nguyen@bt.comtarget_aligned_only="no"
795652bf9771Stony.nguyen@bt.comcase "$target_name" in
795752bf9771Stony.nguyen@bt.com  alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
795852bf9771Stony.nguyen@bt.com  target_aligned_only="yes"
795952bf9771Stony.nguyen@bt.com  ;;
796052bf9771Stony.nguyen@bt.comesac
796197a847bcSbellardtarget_bigendian="no"
7962c1799a84SPaolo Bonzinicase "$target_name" in
7963a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
796452bf9771Stony.nguyen@bt.com  target_bigendian="yes"
7965ea2d6a39SJuan Quintela  ;;
7966ea2d6a39SJuan Quintelaesac
796797a847bcSbellardtarget_softmmu="no"
7968997344f3Sbellardtarget_user_only="no"
7969831b7825Sthstarget_linux_user="no"
797084778508Sblueswir1target_bsd_user="no"
79719e407a85Spbrookcase "$target" in
7972c1799a84SPaolo Bonzini  ${target_name}-softmmu)
79739e407a85Spbrook    target_softmmu="yes"
79749e407a85Spbrook    ;;
7975c1799a84SPaolo Bonzini  ${target_name}-linux-user)
79769e407a85Spbrook    target_user_only="yes"
79779e407a85Spbrook    target_linux_user="yes"
79789e407a85Spbrook    ;;
7979c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
798084778508Sblueswir1    target_user_only="yes"
798184778508Sblueswir1    target_bsd_user="yes"
798284778508Sblueswir1    ;;
79839e407a85Spbrook  *)
798476ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
79859e407a85Spbrook    exit 1
79869e407a85Spbrook    ;;
79879e407a85Spbrookesac
7988831b7825Sths
798997a847bcSbellardmkdir -p $target_dir
799025be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
799197a847bcSbellard
7992e5fe0c52Spbrookbflt="no"
7993ca759f9eSAlex Bennéemttcg="no"
799489138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
799556aebc89Spbrookgdb_xml_files=""
79967ba1e619Saliguori
7997c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
79986acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7999e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
8000e73aae67SJuan Quintela
8001c1799a84SPaolo Bonzinicase "$target_name" in
80022408a527Saurel32  i386)
80030a7fa00aSEmilio G. Cota    mttcg="yes"
80047b0f97baSDoug Gale	gdb_xml_files="i386-32bit.xml"
800528988117SLaurent Vivier    TARGET_SYSTBL_ABI=i386
80062408a527Saurel32  ;;
80072408a527Saurel32  x86_64)
80086acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
80098d62f35aSLaurent Vivier    TARGET_SYSTBL_ABI=common,64
80100a7fa00aSEmilio G. Cota    mttcg="yes"
80117b0f97baSDoug Gale	gdb_xml_files="i386-64bit.xml"
80122408a527Saurel32  ;;
80132408a527Saurel32  alpha)
80145ee4f3c2SRichard Henderson    mttcg="yes"
80156116aea9SLaurent Vivier    TARGET_SYSTBL_ABI=common
80162408a527Saurel32  ;;
80172408a527Saurel32  arm|armeb)
8018b498c8a0SJuan Quintela    TARGET_ARCH=arm
80195bcb4986SLaurent Vivier    TARGET_SYSTBL_ABI=common,oabi
8020e5fe0c52Spbrook    bflt="yes"
8021ca759f9eSAlex Bennée    mttcg="yes"
8022c888f7e0SPeter Maydell    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
80232408a527Saurel32  ;;
8024722dd7beSMichael Weiser  aarch64|aarch64_be)
8025722dd7beSMichael Weiser    TARGET_ARCH=aarch64
80266a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
80276a49fa95SAlexander Graf    bflt="yes"
8028ca759f9eSAlex Bennée    mttcg="yes"
8029c888f7e0SPeter 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"
80306a49fa95SAlexander Graf  ;;
803142f3ff00SMichael Rolnik  avr)
803242f3ff00SMichael Rolnik    gdb_xml_files="avr-cpu.xml"
803342f3ff00SMichael Rolnik    target_compiler=$cross_cc_avr
803442f3ff00SMichael Rolnik  ;;
80352408a527Saurel32  cris)
80362408a527Saurel32  ;;
803761766fe9SRichard Henderson  hppa)
80387b93dab5SRichard Henderson    mttcg="yes"
80399566f4c6SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
804061766fe9SRichard Henderson  ;;
8041613a22c9SMichael Walle  lm32)
8042613a22c9SMichael Walle  ;;
80432408a527Saurel32  m68k)
80440938cda5Saurel32    bflt="yes"
8045a976ed3fSKONRAD Frederic    gdb_xml_files="cf-core.xml cf-fp.xml m68k-core.xml m68k-fp.xml"
80465b85cae9SLaurent Vivier    TARGET_SYSTBL_ABI=common
80472408a527Saurel32  ;;
8048877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
8049877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
8050ddf0c4cdSLaurent Vivier    TARGET_SYSTBL_ABI=common
805172b675caSEdgar E. Iglesias    bflt="yes"
8052be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
805372b675caSEdgar E. Iglesias  ;;
80542408a527Saurel32  mips|mipsel)
80550454728cSAleksandar Markovic    mttcg="yes"
8056b498c8a0SJuan Quintela    TARGET_ARCH=mips
805725be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
8058c59716fcSLaurent Vivier    TARGET_SYSTBL_ABI=o32
80592408a527Saurel32  ;;
80602408a527Saurel32  mipsn32|mipsn32el)
80610454728cSAleksandar Markovic    mttcg="yes"
8062597e2cecSRichard Henderson    TARGET_ARCH=mips64
80636acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
806425be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
8065597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
8066686a0fe4SLaurent Vivier    TARGET_SYSTBL_ABI=n32
80672408a527Saurel32  ;;
80682408a527Saurel32  mips64|mips64el)
8069a092a955SAlex Bennée    mttcg="no"
8070b498c8a0SJuan Quintela    TARGET_ARCH=mips64
80716acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
807225be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
8073686a0fe4SLaurent Vivier    TARGET_SYSTBL_ABI=n64
80742408a527Saurel32  ;;
8075d15a9c23SAnthony Green  moxie)
8076d15a9c23SAnthony Green  ;;
8077e671711cSMarek Vasut  nios2)
8078e671711cSMarek Vasut  ;;
80794a09d0bbSRichard Henderson  or1k)
8080e67db06eSJia Liu    TARGET_ARCH=openrisc
8081e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
8082e67db06eSJia Liu  ;;
80832408a527Saurel32  ppc)
8084c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
808576a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,32
80862408a527Saurel32  ;;
80872408a527Saurel32  ppc64)
80886acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
8089e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
809076a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,64
8091f0b0685dSNikunj A Dadhania    mttcg=yes
80921438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
80932408a527Saurel32  ;;
80949c35126cSDoug Kwan  ppc64le)
80959c35126cSDoug Kwan    TARGET_ARCH=ppc64
80969c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
80979c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
809876a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,64
8099f0b0685dSNikunj A Dadhania    mttcg=yes
81001438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
81019c35126cSDoug Kwan  ;;
81022408a527Saurel32  ppc64abi32)
8103b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
81046acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
8105e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
810676a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,32
810725be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
81081438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
81092408a527Saurel32  ;;
811025fa194bSMichael Clark  riscv32)
811125fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
811225fa194bSMichael Clark    TARGET_ABI_DIR=riscv
811325fa194bSMichael Clark    mttcg=yes
8114ae4a70c0SKeith Packard    gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-32bit-csr.xml riscv-32bit-virtual.xml"
811525fa194bSMichael Clark  ;;
811625fa194bSMichael Clark  riscv64)
811725fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
811825fa194bSMichael Clark    TARGET_ABI_DIR=riscv
811925fa194bSMichael Clark    mttcg=yes
8120ae4a70c0SKeith Packard    gdb_xml_files="riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml"
812125fa194bSMichael Clark  ;;
8122c8c35e5fSYoshinori Sato  rx)
8123c8c35e5fSYoshinori Sato    TARGET_ARCH=rx
8124c8c35e5fSYoshinori Sato    bflt="yes"
8125c8c35e5fSYoshinori Sato    target_compiler=$cross_cc_rx
8126c8c35e5fSYoshinori Sato    gdb_xml_files="rx-core.xml"
8127c8c35e5fSYoshinori Sato  ;;
81282408a527Saurel32  sh4|sh4eb)
8129b498c8a0SJuan Quintela    TARGET_ARCH=sh4
8130d0c832f6SLaurent Vivier    TARGET_SYSTBL_ABI=common
81314dbed897Spbrook    bflt="yes"
81322408a527Saurel32  ;;
81332408a527Saurel32  sparc)
8134bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
81352408a527Saurel32  ;;
81362408a527Saurel32  sparc64)
81376acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
8138bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,64
81392408a527Saurel32  ;;
81402408a527Saurel32  sparc32plus)
8141b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
81426acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
8143e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
8144bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
814525be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
81462408a527Saurel32  ;;
814724e804ecSAlexander Graf  s390x)
8148318f371dSLaurent Vivier    TARGET_SYSTBL_ABI=common,64
814963685bc4SDavid Hildenbrand    mttcg=yes
815086158a2aSChristian 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"
815124e804ecSAlexander Graf  ;;
8152444e06b1SChen Gang  tilegx)
8153444e06b1SChen Gang  ;;
81545ecaa4edSPeter Crosthwaite  tricore)
81555ecaa4edSPeter Crosthwaite  ;;
8156d2fbca94SGuan Xuetao  unicore32)
8157d2fbca94SGuan Xuetao  ;;
8158cfa550c6SMax Filippov  xtensa|xtensaeb)
8159cfa550c6SMax Filippov    TARGET_ARCH=xtensa
8160a4a93592SLaurent Vivier    TARGET_SYSTBL_ABI=common
816102e33e9fSMax Filippov    bflt="yes"
81629fb40342SMax Filippov    mttcg="yes"
8163cfa550c6SMax Filippov  ;;
81642408a527Saurel32  *)
816576ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
81662408a527Saurel32  ;;
81672408a527Saurel32esac
81685e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
81695e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
81705e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
81715e8861a0SPaolo Bonzinifi
81725e8861a0SPaolo Bonzini
81735e8861a0SPaolo Bonzinisymlink "$source_path/Makefile.target" "$target_dir/Makefile"
81745e8861a0SPaolo Bonzini
817599afc91dSDaniel P. Berrangeupper() {
817699afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
817799afc91dSDaniel P. Berrange}
817899afc91dSDaniel P. Berrange
817989138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
818025be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
8181c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
818225be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
8183e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
8184e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
8185e6e91b9cSJuan Quintelafi
818625be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
8187adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
8188adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
8189adfc3e91SStacey Sonfi
81904d6a835dSLaurent Vivierif [ "$TARGET_SYSTBL_ABI" != "" ]; then
81914d6a835dSLaurent Vivier    echo "TARGET_SYSTBL_ABI=$TARGET_SYSTBL_ABI" >> $config_target_mak
81924d6a835dSLaurent Vivierfi
81933b6b7550SPaolo Bonzini
81943b6b7550SPaolo Bonziniif supported_xen_target $target; then
819525be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
8196eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
8197eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
8198eb6fda0fSAnthony PERARD    fi
8199432d268cSJun Nakajimafi
82003b6b7550SPaolo Bonziniif supported_kvm_target $target; then
820125be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
8202c59249f9SJuan Quintelafi
82033b6b7550SPaolo Bonziniif supported_hax_target $target; then
8204b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
8205b0cb0a66SVincent Palatinfi
8206c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
8207c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
8208c97d6d2cSSergio Andres Gomez Del Realfi
8209d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
8210d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
8211d661d9a4SJustin Terry (VM)fi
821252bf9771Stony.nguyen@bt.comif test "$target_aligned_only" = "yes" ; then
821352bf9771Stony.nguyen@bt.com  echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
821452bf9771Stony.nguyen@bt.comfi
8215de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
821625be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
821797a847bcSbellardfi
821897a847bcSbellardif test "$target_softmmu" = "yes" ; then
821925be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
8220ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
8221ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
8222ca759f9eSAlex Bennée  fi
8223de83cd02Sbellardfi
8224997344f3Sbellardif test "$target_user_only" = "yes" ; then
822525be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
8226a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
8227997344f3Sbellardfi
8228831b7825Sthsif test "$target_linux_user" = "yes" ; then
822925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
8230831b7825Sthsfi
823156aebc89Spbrooklist=""
823256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
823356aebc89Spbrook  for x in $gdb_xml_files; do
823456aebc89Spbrook    list="$list $source_path/gdb-xml/$x"
823556aebc89Spbrook  done
823625be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
82373d0f1517SJuan Quintelafi
8238de83cd02Sbellard
8239e633a5c6SEric Blakeif test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
824025be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
8241e5fe0c52Spbrookfi
824284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
824325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
824484778508Sblueswir1fi
82455b0753e0Sbellard
8246d75402b5SAlex Bennée
8247db5adeaaSPaolo Bonzini# generate QEMU_CFLAGS/QEMU_LDFLAGS for targets
8248fa282484SJuan Quintela
82494afddb55SJuan Quintelacflags=""
8250fa282484SJuan Quintelaldflags=""
82519b8e111fSJuan Quintela
8252c765fcacSPeter Crosthwaitedisas_config() {
8253c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
8254c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
8255c765fcacSPeter Crosthwaite}
8256c765fcacSPeter Crosthwaite
825764656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
825864656024SJuan Quintela  case "$i" in
825964656024SJuan Quintela  alpha)
8260c765fcacSPeter Crosthwaite    disas_config "ALPHA"
826164656024SJuan Quintela  ;;
826282295d8aSRichard Henderson  aarch64)
826382295d8aSRichard Henderson    if test -n "${cxx}"; then
8264c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
826582295d8aSRichard Henderson    fi
826682295d8aSRichard Henderson  ;;
826764656024SJuan Quintela  arm)
8268c765fcacSPeter Crosthwaite    disas_config "ARM"
8269999b53ecSClaudio Fontana    if test -n "${cxx}"; then
8270c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
8271999b53ecSClaudio Fontana    fi
827264656024SJuan Quintela  ;;
827342f3ff00SMichael Rolnik  avr)
827442f3ff00SMichael Rolnik    disas_config "AVR"
827542f3ff00SMichael Rolnik  ;;
827664656024SJuan Quintela  cris)
8277c765fcacSPeter Crosthwaite    disas_config "CRIS"
827864656024SJuan Quintela  ;;
8279429b31a2SRichard Henderson  hppa)
8280429b31a2SRichard Henderson    disas_config "HPPA"
8281429b31a2SRichard Henderson  ;;
8282c72b26ecSRichard Henderson  i386|x86_64|x32)
8283c765fcacSPeter Crosthwaite    disas_config "I386"
828464656024SJuan Quintela  ;;
828579368f49SMichael Walle  lm32)
8286c765fcacSPeter Crosthwaite    disas_config "LM32"
828779368f49SMichael Walle  ;;
828864656024SJuan Quintela  m68k)
8289c765fcacSPeter Crosthwaite    disas_config "M68K"
829064656024SJuan Quintela  ;;
8291877fdc12SEdgar E. Iglesias  microblaze*)
8292c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
829364656024SJuan Quintela  ;;
829464656024SJuan Quintela  mips*)
8295c765fcacSPeter Crosthwaite    disas_config "MIPS"
829689a955e8SAleksandar Markovic    if test -n "${cxx}"; then
829789a955e8SAleksandar Markovic      disas_config "NANOMIPS"
829889a955e8SAleksandar Markovic    fi
829964656024SJuan Quintela  ;;
8300d15a9c23SAnthony Green  moxie*)
8301c765fcacSPeter Crosthwaite    disas_config "MOXIE"
8302d15a9c23SAnthony Green  ;;
8303e671711cSMarek Vasut  nios2)
8304e671711cSMarek Vasut    disas_config "NIOS2"
8305e671711cSMarek Vasut  ;;
83064a09d0bbSRichard Henderson  or1k)
8307c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
8308e67db06eSJia Liu  ;;
830964656024SJuan Quintela  ppc*)
8310c765fcacSPeter Crosthwaite    disas_config "PPC"
831164656024SJuan Quintela  ;;
8312c4f80543SAlistair Francis  riscv*)
831325fa194bSMichael Clark    disas_config "RISCV"
831425fa194bSMichael Clark  ;;
8315c8c35e5fSYoshinori Sato  rx)
8316c8c35e5fSYoshinori Sato    disas_config "RX"
8317c8c35e5fSYoshinori Sato  ;;
831824e804ecSAlexander Graf  s390*)
8319c765fcacSPeter Crosthwaite    disas_config "S390"
832064656024SJuan Quintela  ;;
832164656024SJuan Quintela  sh4)
8322c765fcacSPeter Crosthwaite    disas_config "SH4"
832364656024SJuan Quintela  ;;
832464656024SJuan Quintela  sparc*)
8325c765fcacSPeter Crosthwaite    disas_config "SPARC"
832664656024SJuan Quintela  ;;
8327cfa550c6SMax Filippov  xtensa*)
8328c765fcacSPeter Crosthwaite    disas_config "XTENSA"
8329cfa550c6SMax Filippov  ;;
833064656024SJuan Quintela  esac
833164656024SJuan Quinteladone
83329195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
8333c765fcacSPeter Crosthwaite  disas_config "TCI"
83349195b2c2SStefan Weilfi
833564656024SJuan Quintela
8336e9a3591fSChristian Borntraeger# Newer kernels on s390 check for an S390_PGSTE program header and
8337e9a3591fSChristian Borntraeger# enable the pgste page table extensions in that case. This makes
8338e9a3591fSChristian Borntraeger# the vm.allocate_pgste sysctl unnecessary. We enable this program
8339e9a3591fSChristian Borntraeger# header if
8340e9a3591fSChristian Borntraeger#  - we build on s390x
8341e9a3591fSChristian Borntraeger#  - we build the system emulation for s390x (qemu-system-s390x)
8342e9a3591fSChristian Borntraeger#  - KVM is enabled
8343e9a3591fSChristian Borntraeger#  - the linker supports --s390-pgste
8344e633a5c6SEric Blakeif test "$TARGET_ARCH" = "s390x" && test "$target_softmmu" = "yes" && \
8345e633a5c6SEric Blake        test "$ARCH" = "s390x" && test "$kvm" = "yes"; then
8346e9a3591fSChristian Borntraeger    if ld_has --s390-pgste ; then
8347e9a3591fSChristian Borntraeger        ldflags="-Wl,--s390-pgste $ldflags"
8348e9a3591fSChristian Borntraeger    fi
8349e9a3591fSChristian Borntraegerfi
8350e9a3591fSChristian Borntraeger
8351db5adeaaSPaolo Bonziniecho "QEMU_LDFLAGS+=$ldflags" >> $config_target_mak
835225be210fSJuan Quintelaecho "QEMU_CFLAGS+=$cflags" >> $config_target_mak
8353fa282484SJuan Quintela
835497a847bcSbellarddone # for target in $targets
83557d13299dSbellard
8356d52c454aSMarc-André Lureauecho "PIXMAN_CFLAGS=$pixman_cflags" >> $config_host_mak
8357d52c454aSMarc-André Lureauecho "PIXMAN_LIBS=$pixman_libs" >> $config_host_mak
8358d52c454aSMarc-André Lureau
8359e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
83603b8593eeSMarkus Armbruster  echo "config-host.h: dtc/all" >> $config_host_mak
8361a540f158SPeter Crosthwaitefi
8362e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
83633b8593eeSMarkus Armbruster  echo "config-host.h: capstone/all" >> $config_host_mak
8364e219c499SRichard Hendersonfi
8365e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
8366e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
8367e219c499SRichard Hendersonfi
8368a540f158SPeter Crosthwaite
8369a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
8370a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
8371*ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
8372a99d57bbSWanlong Gaofi
8373a99d57bbSWanlong Gao
8374fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
8375fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
8376fd0e6053SJohn Snowfi
8377fd0e6053SJohn Snow
83781e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
83791e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
83801e4f6065SDaniele Buonofi
83811e4f6065SDaniele Buono
8382e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
8383e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
8384e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
8385e29e5c6eSPeter Maydell# (these can be both files and directories).
8386e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
8387e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
8388e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
8389e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
8390e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
8391e29e5c6eSPeter Maydell# directory and symlink the directory instead.
83921cf4323eSThomas HuthDIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
83931cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
8394b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
8395744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
83968db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
83972038f8c8SPaolo BonziniLINKS="Makefile"
83982038f8c8SPaolo BonziniLINKS="$LINKS tests/tcg/lm32/Makefile po/Makefile"
83993941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
8400671f760bSEmilio G. CotaLINKS="$LINKS tests/plugin/Makefile"
8401e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/optionrom/Makefile pc-bios/keymaps"
8402e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
84038db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
8404e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
8405e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
840639950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
840739950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
84088f8fd9edSCleber RosaLINKS="$LINKS python"
8409753d11f2SRichard Hendersonfor bios_file in \
8410753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
8411225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
8412753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
8413753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
8414e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
8415753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
84164e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
841726ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
8418753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
8419753d11f2SRichard Hendersondo
8420e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
84217ea78b74SJan Kiszkadone
8422d1807a4fSPaolo Bonzinimkdir -p $DIRS
8423e29e5c6eSPeter Maydellfor f in $LINKS ; do
8424cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
8425f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
8426f9245e10SPeter Maydell    fi
84277d13299dSbellarddone
84281ad2134fSPaul Brook
84292038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
84302038f8c8SPaolo Bonzini  export $i
84312038f8c8SPaolo Bonzinidone
8432afc3a8f9SAlex Bennéeexport target_list source_path use_containers
84332038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
84342038f8c8SPaolo Bonzini
8435c34ebfdcSAnthony Liguori# temporary config to build submodules
84368db2a4fdSGerd Hoffmannfor rom in seabios; do
8437c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
843837116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
8439c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
8440cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
84415f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
8442c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
8443c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
84443dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
8445c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
8446a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
8447c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
84489f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
8449c34ebfdcSAnthony Liguoridone
8450c34ebfdcSAnthony Liguori
845176c7560aSMax Reitz# set up qemu-iotests in this build directory
845276c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
845376c7560aSMax Reitz
845476c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
845576c7560aSMax Reitzecho >> "$iotests_common_env"
845676c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
845776c7560aSMax Reitz
8458a5665051SPaolo Bonziniif test "$skip_meson" = no; then
8459fc929892SMarc-André Lureaucross="config-meson.cross.new"
8460fc929892SMarc-André Lureaumeson_quote() {
8461fc929892SMarc-André Lureau    echo "['$(echo $* | sed "s/ /','/g")']"
8462fc929892SMarc-André Lureau}
8463fc929892SMarc-André Lureau
8464fc929892SMarc-André Lureauecho "# Automatically generated by configure - do not modify" > $cross
8465fc929892SMarc-André Lureauecho "[properties]" >> $cross
8466fc929892SMarc-André Lureautest -z "$cxx" && echo "link_language = 'c'" >> $cross
8467fc929892SMarc-André Lureauecho "[binaries]" >> $cross
8468fc929892SMarc-André Lureauecho "c = $(meson_quote $cc)" >> $cross
8469fc929892SMarc-André Lureautest -n "$cxx" && echo "cpp = $(meson_quote $cxx)" >> $cross
8470fc929892SMarc-André Lureauecho "ar = $(meson_quote $ar)" >> $cross
8471fc929892SMarc-André Lureauecho "nm = $(meson_quote $nm)" >> $cross
8472fc929892SMarc-André Lureauecho "pkgconfig = $(meson_quote $pkg_config_exe)" >> $cross
8473fc929892SMarc-André Lureauecho "ranlib = $(meson_quote $ranlib)" >> $cross
8474fc929892SMarc-André Lureauecho "strip = $(meson_quote $strip)" >> $cross
8475fc929892SMarc-André Lureauecho "windres = $(meson_quote $windres)" >> $cross
8476fc929892SMarc-André Lureauif test -n "$cross_prefix"; then
8477fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
8478fc929892SMarc-André Lureau    # Hack: Meson expects an absolute path for the *build* machine
8479fc929892SMarc-André Lureau    # for the prefix, so add a slash in front of a Windows path that
8480fc929892SMarc-André Lureau    # includes a drive letter.
8481fc929892SMarc-André Lureau    #
8482fc929892SMarc-André Lureau    # See https://github.com/mesonbuild/meson/issues/7577.
8483fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
8484fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
8485fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
8486fc929892SMarc-André Lureau        case $prefix in
8487fc929892SMarc-André Lureau            ?:*) pre_prefix=/ ;;
8488fc929892SMarc-André Lureau        esac
8489fc929892SMarc-André Lureau    fi
8490fc929892SMarc-André Lureau    case "$ARCH" in
8491fc929892SMarc-André Lureau        i386|x86_64)
8492fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
8493fc929892SMarc-André Lureau            ;;
8494fc929892SMarc-André Lureau        ppc64le)
8495fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
8496fc929892SMarc-André Lureau            ;;
8497fc929892SMarc-André Lureau        *)
8498fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
8499fc929892SMarc-André Lureau            ;;
8500fc929892SMarc-André Lureau    esac
8501fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
8502fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
8503fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
8504fc929892SMarc-André Lureau    else
8505fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
8506fc929892SMarc-André Lureau    fi
8507fc929892SMarc-André Lureauelse
8508fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
8509fc929892SMarc-André Lureaufi
8510fc929892SMarc-André Lureaumv $cross config-meson.cross
8511fc929892SMarc-André Lureau
8512a5665051SPaolo Bonzinirm -rf meson-private meson-info meson-logs
8513a5665051SPaolo BonziniNINJA=$PWD/ninjatool $meson setup \
8514fc929892SMarc-André Lureau        --prefix "${pre_prefix}$prefix" \
8515fc929892SMarc-André Lureau        --libdir "${pre_prefix}$libdir" \
8516fc929892SMarc-André Lureau        --libexecdir "${pre_prefix}$libexecdir" \
8517fc929892SMarc-André Lureau        --bindir "${pre_prefix}$bindir" \
8518fc929892SMarc-André Lureau        --includedir "${pre_prefix}$includedir" \
8519fc929892SMarc-André Lureau        --datadir "${pre_prefix}$datadir" \
8520fc929892SMarc-André Lureau        --mandir "${pre_prefix}$mandir" \
8521fc929892SMarc-André Lureau        --sysconfdir "${pre_prefix}$sysconfdir" \
8522fc929892SMarc-André Lureau        --localstatedir "${pre_prefix}$local_statedir" \
8523a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
8524a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
8525a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
8526a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
8527da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
8528bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
8529fc929892SMarc-André Lureau        $cross_arg \
8530a5665051SPaolo Bonzini        "$PWD" "$source_path"
8531a5665051SPaolo Bonzini
8532a5665051SPaolo Bonziniif test "$?" -ne 0 ; then
8533a5665051SPaolo Bonzini    error_exit "meson setup failed"
8534a5665051SPaolo Bonzinifi
8535a5665051SPaolo Bonzinitouch ninjatool.stamp
8536a5665051SPaolo Bonzinifi
8537a5665051SPaolo Bonzini
8538dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
8539dc655404SMichael S. Tsirkincat <<EOD >config.status
8540dc655404SMichael S. Tsirkin#!/bin/sh
8541dc655404SMichael S. Tsirkin# Generated by configure.
8542dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
8543dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
8544dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
8545dc655404SMichael S. TsirkinEOD
8546e811da7fSDaniel P. Berrangé
8547e811da7fSDaniel P. Berrangépreserve_env() {
8548e811da7fSDaniel P. Berrangé    envname=$1
8549e811da7fSDaniel P. Berrangé
8550e811da7fSDaniel P. Berrangé    eval envval=\$$envname
8551e811da7fSDaniel P. Berrangé
8552e811da7fSDaniel P. Berrangé    if test -n "$envval"
8553e811da7fSDaniel P. Berrangé    then
8554e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
8555e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
8556e811da7fSDaniel P. Berrangé    else
8557e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
8558e811da7fSDaniel P. Berrangé    fi
8559e811da7fSDaniel P. Berrangé}
8560e811da7fSDaniel P. Berrangé
8561e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
8562e811da7fSDaniel P. Berrangé# features/build target configure will detect
8563e811da7fSDaniel P. Berrangépreserve_env AR
8564e811da7fSDaniel P. Berrangépreserve_env AS
8565e811da7fSDaniel P. Berrangépreserve_env CC
8566e811da7fSDaniel P. Berrangépreserve_env CPP
8567e811da7fSDaniel P. Berrangépreserve_env CXX
8568e811da7fSDaniel P. Berrangépreserve_env INSTALL
8569e811da7fSDaniel P. Berrangépreserve_env LD
8570e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
8571e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
8572e811da7fSDaniel P. Berrangépreserve_env MAKE
8573e811da7fSDaniel P. Berrangépreserve_env NM
8574e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
8575e811da7fSDaniel P. Berrangépreserve_env PATH
8576e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
8577e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
8578e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
8579e811da7fSDaniel P. Berrangépreserve_env PYTHON
8580e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
8581e811da7fSDaniel P. Berrangépreserve_env SMBD
8582e811da7fSDaniel P. Berrangépreserve_env STRIP
8583e811da7fSDaniel P. Berrangépreserve_env WINDRES
8584e811da7fSDaniel P. Berrangé
8585dc655404SMichael S. Tsirkinprintf "exec" >>config.status
8586a5665051SPaolo Bonzinifor i in "$0" "$@"; do
8587a5665051SPaolo Bonzini  test "$i" = --skip-meson || printf " '%s'" "$i" >>config.status
8588a5665051SPaolo Bonzinidone
8589cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
8590dc655404SMichael S. Tsirkinchmod +x config.status
8591dc655404SMichael S. Tsirkin
85928cd05ab6SPeter Maydellrm -r "$TMPDIR1"
8593