xref: /openbmc/qemu/configure (revision 1ffb3bbb)
17d13299dSbellard#!/bin/sh
27d13299dSbellard#
33ef693a0Sbellard# qemu configure script (c) 2003 Fabrice Bellard
47d13299dSbellard#
58cd05ab6SPeter Maydell
699519e67SCornelia Huck# Unset some variables known to interfere with behavior of common tools,
799519e67SCornelia Huck# just as autoconf does.
899519e67SCornelia HuckCLICOLOR_FORCE= GREP_OPTIONS=
999519e67SCornelia Huckunset CLICOLOR_FORCE GREP_OPTIONS
1099519e67SCornelia Huck
115e4dfd3dSJohn Snow# Don't allow CCACHE, if present, to use cached results of compile tests!
125e4dfd3dSJohn Snowexport CCACHE_RECACHE=yes
135e4dfd3dSJohn Snow
14dedad027SDaniel P. Berrangé# make source path absolute
15dedad027SDaniel P. Berrangésource_path=$(cd "$(dirname -- "$0")"; pwd)
16dedad027SDaniel P. Berrangé
17dedad027SDaniel P. Berrangéif test "$PWD" = "$source_path"
18dedad027SDaniel P. Berrangéthen
19dedad027SDaniel P. Berrangé    echo "Using './build' as the directory for build output"
20dedad027SDaniel P. Berrangé
21dedad027SDaniel P. Berrangé    MARKER=build/auto-created-by-configure
22dedad027SDaniel P. Berrangé
23dedad027SDaniel P. Berrangé    if test -e build
24dedad027SDaniel P. Berrangé    then
25dedad027SDaniel P. Berrangé        if test -f $MARKER
26dedad027SDaniel P. Berrangé        then
27dedad027SDaniel P. Berrangé           rm -rf build
28dedad027SDaniel P. Berrangé        else
29dedad027SDaniel P. Berrangé            echo "ERROR: ./build dir already exists and was not previously created by configure"
30dedad027SDaniel P. Berrangé            exit 1
31dedad027SDaniel P. Berrangé        fi
32dedad027SDaniel P. Berrangé    fi
33dedad027SDaniel P. Berrangé
34dedad027SDaniel P. Berrangé    mkdir build
35dedad027SDaniel P. Berrangé    touch $MARKER
36dedad027SDaniel P. Berrangé
37dedad027SDaniel P. Berrangé    cat > GNUmakefile <<'EOF'
38dedad027SDaniel P. Berrangé# This file is auto-generated by configure to support in-source tree
39dedad027SDaniel P. Berrangé# 'make' command invocation
40dedad027SDaniel P. Berrangé
41dedad027SDaniel P. Berrangéifeq ($(MAKECMDGOALS),)
42dedad027SDaniel P. Berrangérecurse: all
43dedad027SDaniel P. Berrangéendif
44dedad027SDaniel P. Berrangé
45dedad027SDaniel P. Berrangé.NOTPARALLEL: %
46dedad027SDaniel P. Berrangé%: force
47dedad027SDaniel P. Berrangé	@echo 'changing dir to build for $(MAKE) "$(MAKECMDGOALS)"...'
48dedad027SDaniel P. Berrangé	@$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
49dedad027SDaniel P. Berrangé	@if test "$(MAKECMDGOALS)" = "distclean" && \
50dedad027SDaniel P. Berrangé	    test -e build/auto-created-by-configure ; \
51dedad027SDaniel P. Berrangé	then \
52dedad027SDaniel P. Berrangé	    rm -rf build GNUmakefile ; \
53dedad027SDaniel P. Berrangé	fi
54dedad027SDaniel P. Berrangéforce: ;
55dedad027SDaniel P. Berrangé.PHONY: force
56dedad027SDaniel P. BerrangéGNUmakefile: ;
57dedad027SDaniel P. Berrangé
58dedad027SDaniel P. BerrangéEOF
59dedad027SDaniel P. Berrangé    cd build
60dedad027SDaniel P. Berrangé    exec $source_path/configure "$@"
61dedad027SDaniel P. Berrangéfi
62dedad027SDaniel P. Berrangé
638cd05ab6SPeter Maydell# Temporary directory used for files created while
648cd05ab6SPeter Maydell# configure runs. Since it is in the build directory
658cd05ab6SPeter Maydell# we can safely blow away any previous version of it
668cd05ab6SPeter Maydell# (and we need not jump through hoops to try to delete
678cd05ab6SPeter Maydell# it when configure exits.)
688cd05ab6SPeter MaydellTMPDIR1="config-temp"
698cd05ab6SPeter Maydellrm -rf "${TMPDIR1}"
708cd05ab6SPeter Maydellmkdir -p "${TMPDIR1}"
718cd05ab6SPeter Maydellif [ $? -ne 0 ]; then
728cd05ab6SPeter Maydell    echo "ERROR: failed to create temporary directory"
738cd05ab6SPeter Maydell    exit 1
747d13299dSbellardfi
757d13299dSbellard
768cd05ab6SPeter MaydellTMPB="qemu-conf"
778cd05ab6SPeter MaydellTMPC="${TMPDIR1}/${TMPB}.c"
7866518bf6SDon SlutzTMPO="${TMPDIR1}/${TMPB}.o"
799c83ffd8SPeter MaydellTMPCXX="${TMPDIR1}/${TMPB}.cxx"
808cd05ab6SPeter MaydellTMPE="${TMPDIR1}/${TMPB}.exe"
8126fffe29SEmilio G. CotaTMPTXT="${TMPDIR1}/${TMPB}.txt"
827d13299dSbellard
83da1d85e3SGerd Hoffmannrm -f config.log
849ac81bbbSmalc
85b48e3611SPeter Maydell# Print a helpful header at the top of config.log
86b48e3611SPeter Maydellecho "# QEMU configure log $(date)" >> config.log
87979ae168SPeter Maydellprintf "# Configured with:" >> config.log
88979ae168SPeter Maydellprintf " '%s'" "$0" "$@" >> config.log
89979ae168SPeter Maydellecho >> config.log
90b48e3611SPeter Maydellecho "#" >> config.log
91b48e3611SPeter Maydell
92d880a3baSPaolo Bonziniprint_error() {
93d880a3baSPaolo Bonzini    (echo
9476ad07a4SPeter Maydell    echo "ERROR: $1"
9576ad07a4SPeter Maydell    while test -n "$2"; do
9676ad07a4SPeter Maydell        echo "       $2"
9776ad07a4SPeter Maydell        shift
9876ad07a4SPeter Maydell    done
99d880a3baSPaolo Bonzini    echo) >&2
100d880a3baSPaolo Bonzini}
101d880a3baSPaolo Bonzini
102d880a3baSPaolo Bonzinierror_exit() {
103d880a3baSPaolo Bonzini    print_error "$@"
10476ad07a4SPeter Maydell    exit 1
10576ad07a4SPeter Maydell}
10676ad07a4SPeter Maydell
1079c83ffd8SPeter Maydelldo_compiler() {
1089c83ffd8SPeter Maydell    # Run the compiler, capturing its output to the log. First argument
1099c83ffd8SPeter Maydell    # is compiler binary to execute.
1109c83ffd8SPeter Maydell    local compiler="$1"
1119c83ffd8SPeter Maydell    shift
1128bbe05d7SIan Jackson    if test -n "$BASH_VERSION"; then eval '
1138bbe05d7SIan Jackson        echo >>config.log "
1148bbe05d7SIan Jacksonfuncs: ${FUNCNAME[*]}
1158bbe05d7SIan Jacksonlines: ${BASH_LINENO[*]}"
1168bbe05d7SIan Jackson    '; fi
1179c83ffd8SPeter Maydell    echo $compiler "$@" >> config.log
1189c83ffd8SPeter Maydell    $compiler "$@" >> config.log 2>&1 || return $?
1198dc38a78SPeter Maydell    # Test passed. If this is an --enable-werror build, rerun
1208dc38a78SPeter Maydell    # the test with -Werror and bail out if it fails. This
1218dc38a78SPeter Maydell    # makes warning-generating-errors in configure test code
1228dc38a78SPeter Maydell    # obvious to developers.
1238dc38a78SPeter Maydell    if test "$werror" != "yes"; then
1248dc38a78SPeter Maydell        return 0
1258dc38a78SPeter Maydell    fi
1268dc38a78SPeter Maydell    # Don't bother rerunning the compile if we were already using -Werror
1278dc38a78SPeter Maydell    case "$*" in
1288dc38a78SPeter Maydell        *-Werror*)
1298dc38a78SPeter Maydell           return 0
1308dc38a78SPeter Maydell        ;;
1318dc38a78SPeter Maydell    esac
1329c83ffd8SPeter Maydell    echo $compiler -Werror "$@" >> config.log
1339c83ffd8SPeter Maydell    $compiler -Werror "$@" >> config.log 2>&1 && return $?
13476ad07a4SPeter Maydell    error_exit "configure test passed without -Werror but failed with -Werror." \
13576ad07a4SPeter Maydell        "This is probably a bug in the configure script. The failing command" \
13676ad07a4SPeter Maydell        "will be at the bottom of config.log." \
13776ad07a4SPeter Maydell        "You can run configure with --disable-werror to bypass this check."
1388dc38a78SPeter Maydell}
1398dc38a78SPeter Maydell
1409c83ffd8SPeter Maydelldo_cc() {
1419c83ffd8SPeter Maydell    do_compiler "$cc" "$@"
1429c83ffd8SPeter Maydell}
1439c83ffd8SPeter Maydell
1449c83ffd8SPeter Maydelldo_cxx() {
1459c83ffd8SPeter Maydell    do_compiler "$cxx" "$@"
1469c83ffd8SPeter Maydell}
1479c83ffd8SPeter Maydell
14800849b92SRichard Henderson# Append $2 to the variable named $1, with space separation
14900849b92SRichard Hendersonadd_to() {
15000849b92SRichard Henderson    eval $1=\${$1:+\"\$$1 \"}\$2
15100849b92SRichard Henderson}
15200849b92SRichard Henderson
1539c83ffd8SPeter Maydellupdate_cxxflags() {
1549c83ffd8SPeter Maydell    # Set QEMU_CXXFLAGS from QEMU_CFLAGS by filtering out those
1559c83ffd8SPeter Maydell    # options which some versions of GCC's C++ compiler complain about
1569c83ffd8SPeter Maydell    # because they only make sense for C programs.
15753422040SPaolo Bonzini    QEMU_CXXFLAGS="$QEMU_CXXFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS"
158086d5f75SPaolo Bonzini    CXXFLAGS=$(echo "$CFLAGS" | sed s/-std=gnu99/-std=gnu++11/)
1599c83ffd8SPeter Maydell    for arg in $QEMU_CFLAGS; do
1609c83ffd8SPeter Maydell        case $arg in
1619c83ffd8SPeter Maydell            -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\
1629c83ffd8SPeter Maydell            -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls)
1639c83ffd8SPeter Maydell                ;;
1649c83ffd8SPeter Maydell            *)
1659c83ffd8SPeter Maydell                QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg
1669c83ffd8SPeter Maydell                ;;
1679c83ffd8SPeter Maydell        esac
1689c83ffd8SPeter Maydell    done
1699c83ffd8SPeter Maydell}
1709c83ffd8SPeter Maydell
17152166aa0SJuan Quintelacompile_object() {
172fd0e6053SJohn Snow  local_cflags="$1"
173086d5f75SPaolo Bonzini  do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -c -o $TMPO $TMPC
17452166aa0SJuan Quintela}
17552166aa0SJuan Quintela
17652166aa0SJuan Quintelacompile_prog() {
17752166aa0SJuan Quintela  local_cflags="$1"
17852166aa0SJuan Quintela  local_ldflags="$2"
179086d5f75SPaolo Bonzini  do_cc $CFLAGS $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $QEMU_LDFLAGS $local_ldflags
18052166aa0SJuan Quintela}
18152166aa0SJuan Quintela
18211568d6dSPaolo Bonzini# symbolically link $1 to $2.  Portable version of "ln -sf".
18311568d6dSPaolo Bonzinisymlink() {
18472b8b5a1SStefan Weil  rm -rf "$2"
185ec5b06d7SAnthony Liguori  mkdir -p "$(dirname "$2")"
18672b8b5a1SStefan Weil  ln -s "$1" "$2"
18711568d6dSPaolo Bonzini}
18811568d6dSPaolo Bonzini
1890dba6195SLoïc Minier# check whether a command is available to this shell (may be either an
1900dba6195SLoïc Minier# executable or a builtin)
1910dba6195SLoïc Minierhas() {
1920dba6195SLoïc Minier    type "$1" >/dev/null 2>&1
1930dba6195SLoïc Minier}
1940dba6195SLoïc Minier
1950dba6195SLoïc Minier# search for an executable in PATH
1960dba6195SLoïc Minierpath_of() {
1970dba6195SLoïc Minier    local_command="$1"
1980dba6195SLoïc Minier    local_ifs="$IFS"
1990dba6195SLoïc Minier    local_dir=""
2000dba6195SLoïc Minier
2010dba6195SLoïc Minier    # pathname has a dir component?
2020dba6195SLoïc Minier    if [ "${local_command#*/}" != "$local_command" ]; then
2030dba6195SLoïc Minier        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
2040dba6195SLoïc Minier            echo "$local_command"
2050dba6195SLoïc Minier            return 0
2060dba6195SLoïc Minier        fi
2070dba6195SLoïc Minier    fi
2080dba6195SLoïc Minier    if [ -z "$local_command" ]; then
2090dba6195SLoïc Minier        return 1
2100dba6195SLoïc Minier    fi
2110dba6195SLoïc Minier
2120dba6195SLoïc Minier    IFS=:
2130dba6195SLoïc Minier    for local_dir in $PATH; do
2140dba6195SLoïc Minier        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
2150dba6195SLoïc Minier            echo "$local_dir/$local_command"
2160dba6195SLoïc Minier            IFS="${local_ifs:-$(printf ' \t\n')}"
2170dba6195SLoïc Minier            return 0
2180dba6195SLoïc Minier        fi
2190dba6195SLoïc Minier    done
2200dba6195SLoïc Minier    # not found
2210dba6195SLoïc Minier    IFS="${local_ifs:-$(printf ' \t\n')}"
2220dba6195SLoïc Minier    return 1
2230dba6195SLoïc Minier}
2240dba6195SLoïc Minier
2250a01d76fSMarc-André Lureauversion_ge () {
2260a01d76fSMarc-André Lureau    local_ver1=`echo $1 | tr . ' '`
2270a01d76fSMarc-André Lureau    local_ver2=`echo $2 | tr . ' '`
2280a01d76fSMarc-André Lureau    while true; do
2290a01d76fSMarc-André Lureau        set x $local_ver1
2300a01d76fSMarc-André Lureau        local_first=${2-0}
231c44a33e2SStefano Garzarella        # 'shift 2' if $2 is set, or 'shift' if $2 is not set
232c44a33e2SStefano Garzarella        shift ${2:+2}
2330a01d76fSMarc-André Lureau        local_ver1=$*
2340a01d76fSMarc-André Lureau        set x $local_ver2
2350a01d76fSMarc-André Lureau        # the second argument finished, the first must be greater or equal
2360a01d76fSMarc-André Lureau        test $# = 1 && return 0
2370a01d76fSMarc-André Lureau        test $local_first -lt $2 && return 1
2380a01d76fSMarc-André Lureau        test $local_first -gt $2 && return 0
239c44a33e2SStefano Garzarella        shift ${2:+2}
2400a01d76fSMarc-André Lureau        local_ver2=$*
2410a01d76fSMarc-André Lureau    done
2420a01d76fSMarc-André Lureau}
2430a01d76fSMarc-André Lureau
2445b808275SLluís Vilanovahave_backend () {
2455b808275SLluís Vilanova    echo "$trace_backends" | grep "$1" >/dev/null
2465b808275SLluís Vilanova}
2475b808275SLluís Vilanova
2483b6b7550SPaolo Bonziniglob() {
2493b6b7550SPaolo Bonzini    eval test -z '"${1#'"$2"'}"'
2503b6b7550SPaolo Bonzini}
2513b6b7550SPaolo Bonzini
2523b6b7550SPaolo Bonzinisupported_hax_target() {
2533b6b7550SPaolo Bonzini    test "$hax" = "yes" || return 1
2543b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
2553b6b7550SPaolo Bonzini    case "${1%-softmmu}" in
2563b6b7550SPaolo Bonzini        i386|x86_64)
2573b6b7550SPaolo Bonzini            return 0
2583b6b7550SPaolo Bonzini        ;;
2593b6b7550SPaolo Bonzini    esac
2603b6b7550SPaolo Bonzini    return 1
2613b6b7550SPaolo Bonzini}
2623b6b7550SPaolo Bonzini
2633b6b7550SPaolo Bonzinisupported_kvm_target() {
2643b6b7550SPaolo Bonzini    test "$kvm" = "yes" || return 1
2653b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
2663b6b7550SPaolo Bonzini    case "${1%-softmmu}:$cpu" in
2673b6b7550SPaolo Bonzini        arm:arm | aarch64:aarch64 | \
2683b6b7550SPaolo Bonzini        i386:i386 | i386:x86_64 | i386:x32 | \
2693b6b7550SPaolo Bonzini        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
270aa2953fdSHuacai Chen        mips:mips | mipsel:mips | mips64:mips | mips64el:mips | \
271f8378accSRichard Henderson        ppc:ppc | ppc64:ppc | ppc:ppc64 | ppc64:ppc64 | ppc64:ppc64le | \
2723b6b7550SPaolo Bonzini        s390x:s390x)
2733b6b7550SPaolo Bonzini            return 0
2743b6b7550SPaolo Bonzini        ;;
2753b6b7550SPaolo Bonzini    esac
2763b6b7550SPaolo Bonzini    return 1
2773b6b7550SPaolo Bonzini}
2783b6b7550SPaolo Bonzini
2793b6b7550SPaolo Bonzinisupported_xen_target() {
2803b6b7550SPaolo Bonzini    test "$xen" = "yes" || return 1
2813b6b7550SPaolo Bonzini    glob "$1" "*-softmmu" || return 1
282b5ed2e11SPaolo Bonzini    # Only i386 and x86_64 provide the xenpv machine.
283b5ed2e11SPaolo Bonzini    case "${1%-softmmu}" in
284b5ed2e11SPaolo Bonzini        i386|x86_64)
2853b6b7550SPaolo Bonzini            return 0
2863b6b7550SPaolo Bonzini        ;;
2873b6b7550SPaolo Bonzini    esac
2883b6b7550SPaolo Bonzini    return 1
2893b6b7550SPaolo Bonzini}
2903b6b7550SPaolo Bonzini
291c97d6d2cSSergio Andres Gomez Del Realsupported_hvf_target() {
292c97d6d2cSSergio Andres Gomez Del Real    test "$hvf" = "yes" || return 1
293c97d6d2cSSergio Andres Gomez Del Real    glob "$1" "*-softmmu" || return 1
294c97d6d2cSSergio Andres Gomez Del Real    case "${1%-softmmu}" in
295c97d6d2cSSergio Andres Gomez Del Real        x86_64)
296c97d6d2cSSergio Andres Gomez Del Real            return 0
297c97d6d2cSSergio Andres Gomez Del Real        ;;
298c97d6d2cSSergio Andres Gomez Del Real    esac
299c97d6d2cSSergio Andres Gomez Del Real    return 1
300c97d6d2cSSergio Andres Gomez Del Real}
301c97d6d2cSSergio Andres Gomez Del Real
302d661d9a4SJustin Terry (VM)supported_whpx_target() {
303d661d9a4SJustin Terry (VM)    test "$whpx" = "yes" || return 1
304d661d9a4SJustin Terry (VM)    glob "$1" "*-softmmu" || return 1
305d661d9a4SJustin Terry (VM)    case "${1%-softmmu}" in
306d661d9a4SJustin Terry (VM)        i386|x86_64)
307d661d9a4SJustin Terry (VM)            return 0
308d661d9a4SJustin Terry (VM)        ;;
309d661d9a4SJustin Terry (VM)    esac
310d661d9a4SJustin Terry (VM)    return 1
311d661d9a4SJustin Terry (VM)}
312d661d9a4SJustin Terry (VM)
313d880a3baSPaolo Bonzinisupported_target() {
314d880a3baSPaolo Bonzini    case "$1" in
315d880a3baSPaolo Bonzini        *-softmmu)
316d880a3baSPaolo Bonzini            ;;
317d880a3baSPaolo Bonzini        *-linux-user)
318d880a3baSPaolo Bonzini            if test "$linux" != "yes"; then
319d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a Linux host"
320d880a3baSPaolo Bonzini                return 1
321d880a3baSPaolo Bonzini            fi
322d880a3baSPaolo Bonzini            ;;
323d880a3baSPaolo Bonzini        *-bsd-user)
324d880a3baSPaolo Bonzini            if test "$bsd" != "yes"; then
325d880a3baSPaolo Bonzini                print_error "Target '$target' is only available on a BSD host"
326d880a3baSPaolo Bonzini                return 1
327d880a3baSPaolo Bonzini            fi
328d880a3baSPaolo Bonzini            ;;
329d880a3baSPaolo Bonzini        *)
330d880a3baSPaolo Bonzini            print_error "Invalid target name '$target'"
331d880a3baSPaolo Bonzini            return 1
332d880a3baSPaolo Bonzini            ;;
333d880a3baSPaolo Bonzini    esac
334b3f6ea7eSPaolo Bonzini    test "$tcg" = "yes" && return 0
335b3f6ea7eSPaolo Bonzini    supported_kvm_target "$1" && return 0
336b3f6ea7eSPaolo Bonzini    supported_xen_target "$1" && return 0
337b3f6ea7eSPaolo Bonzini    supported_hax_target "$1" && return 0
338c97d6d2cSSergio Andres Gomez Del Real    supported_hvf_target "$1" && return 0
339d661d9a4SJustin Terry (VM)    supported_whpx_target "$1" && return 0
340b3f6ea7eSPaolo Bonzini    print_error "TCG disabled, but hardware accelerator not available for '$target'"
341b3f6ea7eSPaolo Bonzini    return 1
342d880a3baSPaolo Bonzini}
343d880a3baSPaolo Bonzini
344e9a3591fSChristian Borntraeger
345e9a3591fSChristian Borntraegerld_has() {
346e9a3591fSChristian Borntraeger    $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
347e9a3591fSChristian Borntraeger}
348e9a3591fSChristian Borntraeger
3494ace32e2SAntonio Ospiteif printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
3504ace32e2SAntonio Ospitethen
3514ace32e2SAntonio Ospite  error_exit "main directory cannot contain spaces nor colons"
3524ace32e2SAntonio Ospitefi
3534ace32e2SAntonio Ospite
35414211825SAntonio Ospite# default parameters
3552ff6b91eSJuan Quintelacpu=""
356a31a8642SMichael S. Tsirkiniasl="iasl"
3571e43adfcSbellardinterp_prefix="/usr/gnemul/qemu-%M"
35843ce4dfeSbellardstatic="no"
3597d13299dSbellardcross_prefix=""
3600c58ac1cSmalcaudio_drv_list=""
361b64ec4e4SFam Zhengblock_drv_rw_whitelist=""
362b64ec4e4SFam Zhengblock_drv_ro_whitelist=""
363e49d021eSPeter Maydellhost_cc="cc"
3643e2e0e6bSJuan Quintelalibs_tools=""
365d5631638Smalcaudio_win_int=""
366957f1f99SMichael Rothlibs_qga=""
3675bc62e01SGerd Hoffmanndebug_info="yes"
36863678e17SSteven Noonanstack_protector=""
3691e4f6065SDaniele Buonosafe_stack=""
370afc3a8f9SAlex Bennéeuse_containers="yes"
371f2385398SAlex Bennéegdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
372ac0df51dSaliguori
37392712822SDaniel P. Berrangeif test -e "$source_path/.git"
37492712822SDaniel P. Berrangethen
375f62bbee5SDaniel P. Berrange    git_update=yes
37692712822SDaniel P. Berrange    git_submodules="ui/keycodemapdb"
3773ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
3783ac1f813SEmilio G. Cota    git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
37992712822SDaniel P. Berrangeelse
380f62bbee5SDaniel P. Berrange    git_update=no
381aef45d51SDaniel P. Berrange    git_submodules=""
3825c0ef67aSDaniel P. Berrangé
3835c0ef67aSDaniel P. Berrangé    if ! test -f "$source_path/ui/keycodemapdb/README"
3845c0ef67aSDaniel P. Berrangé    then
3855c0ef67aSDaniel P. Berrangé        echo
3865c0ef67aSDaniel P. Berrangé        echo "ERROR: missing file $source_path/ui/keycodemapdb/README"
3875c0ef67aSDaniel P. Berrangé        echo
3885c0ef67aSDaniel P. Berrangé        echo "This is not a GIT checkout but module content appears to"
3895c0ef67aSDaniel P. Berrangé        echo "be missing. Do not use 'git archive' or GitHub download links"
3905c0ef67aSDaniel P. Berrangé        echo "to acquire QEMU source archives. Non-GIT builds are only"
3915c0ef67aSDaniel P. Berrangé        echo "supported with source archives linked from:"
3925c0ef67aSDaniel P. Berrangé        echo
393a3e3b521SPeter Maydell        echo "  https://www.qemu.org/download/#source"
3945c0ef67aSDaniel P. Berrangé        echo
3955c0ef67aSDaniel P. Berrangé        echo "Developers working with GIT can use scripts/archive-source.sh"
3965c0ef67aSDaniel P. Berrangé        echo "if they need to create valid source archives."
3975c0ef67aSDaniel P. Berrangé        echo
3985c0ef67aSDaniel P. Berrangé        exit 1
3995c0ef67aSDaniel P. Berrangé    fi
40092712822SDaniel P. Berrangefi
401cc84d63aSDaniel P. Berrangegit="git"
402ac0df51dSaliguori
403afb63ebdSStefan Weil# Don't accept a target_list environment variable.
404afb63ebdSStefan Weilunset target_list
405447e133fSAlex Bennéeunset target_list_exclude
406377529c0SPaolo Bonzini
407377529c0SPaolo Bonzini# Default value for a variable defining feature "foo".
408377529c0SPaolo Bonzini#  * foo="no"  feature will only be used if --enable-foo arg is given
409377529c0SPaolo Bonzini#  * foo=""    feature will be searched for, and if found, will be used
410377529c0SPaolo Bonzini#              unless --disable-foo is given
411377529c0SPaolo Bonzini#  * foo="yes" this value will only be set by --enable-foo flag.
412377529c0SPaolo Bonzini#              feature will searched for,
413377529c0SPaolo Bonzini#              if not found, configure exits with error
414377529c0SPaolo Bonzini#
415377529c0SPaolo Bonzini# Always add --enable-foo and --disable-foo command line args.
416377529c0SPaolo Bonzini# Distributions want to ensure that several features are compiled in, and it
417377529c0SPaolo Bonzini# is impossible without a --enable-foo that exits if a feature is not found.
418377529c0SPaolo Bonzini
419377529c0SPaolo Bonzinibrlapi=""
420377529c0SPaolo Bonzinicurl=""
421377529c0SPaolo Bonzinicurses=""
422377529c0SPaolo Bonzinidocs=""
423377529c0SPaolo Bonzinifdt=""
42458952137SVincenzo Maffionenetmap="no"
42535be72baSPaolo Bonzinisdl="auto"
42635be72baSPaolo Bonzinisdl_image="auto"
427983eef5aSMeador Ingevirtfs=""
428fe8fc5aeSPaolo Bonzinimpath=""
429a0b93237SPaolo Bonzinivnc="enabled"
430377529c0SPaolo Bonzinisparse="no"
431377529c0SPaolo Bonzinivde=""
432a0b93237SPaolo Bonzinivnc_sasl="auto"
433a0b93237SPaolo Bonzinivnc_jpeg="auto"
434a0b93237SPaolo Bonzinivnc_png="auto"
4354113f4cfSLaurent Vivierxkbcommon="auto"
436377529c0SPaolo Bonzinixen=""
437d5b93ddfSAnthony PERARDxen_ctrl_version=""
438eb6fda0fSAnthony PERARDxen_pci_passthrough=""
439377529c0SPaolo Bonzinilinux_aio=""
440c10dd856SAarushi Mehtalinux_io_uring=""
44147e98658SCorey Bryantcap_ng=""
442377529c0SPaolo Bonziniattr=""
4434f26f2b6SAvi Kivitylibattr=""
444377529c0SPaolo Bonzinixfs=""
445b3f6ea7eSPaolo Bonzinitcg="yes"
446a40161cbSPaolo Bonzinimembarrier=""
447299e6f19SPaolo Bonzinivhost_net=""
448299e6f19SPaolo Bonzinivhost_crypto=""
449299e6f19SPaolo Bonzinivhost_scsi=""
450299e6f19SPaolo Bonzinivhost_vsock=""
451e6a74868SMarc-André Lureauvhost_user=""
45298fc1adaSDr. David Alan Gilbertvhost_user_fs=""
453d41a75a2SBradkvm="no"
454b0cb0a66SVincent Palatinhax="no"
455c97d6d2cSSergio Andres Gomez Del Realhvf="no"
456d661d9a4SJustin Terry (VM)whpx="no"
4572da776dbSMichael R. Hinesrdma=""
45821ab34c9SMarcel Apfelbaumpvrdma=""
459377529c0SPaolo Bonzinigprof="no"
460377529c0SPaolo Bonzinidebug_tcg="no"
461377529c0SPaolo Bonzinidebug="no"
462247724cbSMarc-André Lureausanitizers="no"
4630aebab04SLingfeng Yangtsan="no"
464b553a042SJohn Snowfortify_source=""
465377529c0SPaolo Bonzinistrip_opt="yes"
4669195b2c2SStefan Weiltcg_interpreter="no"
467377529c0SPaolo Bonzinibigendian="no"
468377529c0SPaolo Bonzinimingw32="no"
4691d728c39SBlue Swirlgcov="no"
470377529c0SPaolo BonziniEXESUF=""
471484e2cc7SPaolo BonziniHOST_DSOSUF=".so"
47217969268SFam ZhengLDFLAGS_SHARED="-shared"
47317969268SFam Zhengmodules="no"
474bd83c861SChristian Ehrhardtmodule_upgrades="no"
475377529c0SPaolo Bonziniprefix="/usr/local"
4763d5eecabSGerd Hoffmannfirmwarepath="\${prefix}/share/qemu-firmware"
477377529c0SPaolo Bonziniconfsuffix="/qemu"
478675b9b53SMarc-André Lureauslirp=""
479377529c0SPaolo Bonzinioss_lib=""
480377529c0SPaolo Bonzinibsd="no"
481377529c0SPaolo Bonzinilinux="no"
482377529c0SPaolo Bonzinisolaris="no"
483377529c0SPaolo Bonziniprofiler="no"
484377529c0SPaolo Bonzinicocoa="no"
485377529c0SPaolo Bonzinisoftmmu="yes"
486377529c0SPaolo Bonzinilinux_user="no"
487377529c0SPaolo Bonzinibsd_user="no"
488377529c0SPaolo Bonziniblobs="yes"
48905dfa22bSPhilippe Mathieu-Daudéedk2_blobs="no"
490377529c0SPaolo Bonzinipkgversion=""
49140d6444eSAvi Kivitypie=""
4923556c233SPaolo Bonziniqom_cast_debug="yes"
493baf86d6bSPaolo Bonzinitrace_backends="log"
494377529c0SPaolo Bonzinitrace_file="trace"
495377529c0SPaolo Bonzinispice=""
496377529c0SPaolo Bonzinirbd=""
4977b02f544SMarc-André Lureausmartcard=""
4980a40bcb7SCésar Belleyu2f="auto"
4992b2325ffSGerd Hoffmannlibusb=""
50069354a83SHans de Goedeusb_redir=""
501da076ffeSGerd Hoffmannopengl=""
502014cb152SGerd Hoffmannopengl_dmabuf="no"
5035dd89908SRichard Hendersoncpuid_h="no"
50486583a07SLiam Merwickavx2_opt=""
5058ca80760SRichard Hendersoncapstone=""
506b25c9dffSStefan Weillzo=""
507b25c9dffSStefan Weilsnappy=""
5086b383c08SPeter Wubzip2=""
50983bc1f97SJulio Faraccolzfse=""
5103a678481SJuan Quintelazstd=""
511e8ef31a3SMichael Tokarevguest_agent=""
512d9840e25STomoki Sekiyamaguest_agent_with_vss="no"
51350cbebb9SMichael Rothguest_agent_ntddscsi="no"
5149dacf32dSYossi Hindinguest_agent_msi=""
515d9840e25STomoki Sekiyamavss_win32_sdk=""
516d9840e25STomoki Sekiyamawin_sdk="no"
517e10ee3f5SPhilippe Mathieu-Daudéwant_tools=""
518c589b249SRonnie Sahlberglibiscsi=""
5196542aa9cSPeter Lievenlibnfs=""
520519175a2SAlex Barcelocoroutine=""
52170c60c08SStefan Hajnoczicoroutine_pool=""
5227d992e4dSPeter Lievendebug_stack_usage="no"
523f0d92b56SLongpeng(Mike)crypto_afalg="no"
524f794573eSEduardo Otuboseccomp=""
525eb100396SBharata B Raoglusterfs=""
526d85fa9ebSJeff Codyglusterfs_xlator_opt="no"
5270c14fb47SBharata B Raoglusterfs_discard="no"
528df3a429aSNiels de Vosglusterfs_fallocate="no"
5297c815372SBharata B Raoglusterfs_zerofill="no"
530e014dbe7SPrasanna Kumar Kaleverglusterfs_ftruncate_has_stat="no"
5310e3b891fSNiels de Vosglusterfs_iocb_has_stat="no"
532a4ccabcfSAnthony Liguorigtk=""
533925a0400SGerd Hoffmanngtk_gl="no"
534a1c5e949SDaniel P. Berrangetls_priority="NORMAL"
535ddbb0d09SDaniel P. Berrangegnutls=""
53691bfcdb0SDaniel P. Berrangenettle=""
537dc2207afSDaniel P. Berrangénettle_xts="no"
53891bfcdb0SDaniel P. Berrangegcrypt=""
5391f923c70SLongpeng(Mike)gcrypt_hmac="no"
540e0576942SDaniel P. Berrangégcrypt_xts="no"
541e0576942SDaniel P. Berrangéqemu_private_xts="yes"
5428953caf3SDaniel P. Berrangeauth_pam=""
543bbbf9bfbSStefan Weilvte=""
5449d9e1521SGerd Hoffmannvirglrenderer=""
5457aaa6a16SPaolo Bonzinitpm=""
546b10d49d7SPino Toscanolibssh=""
547ed1701c6SDr. David Alan Gilbertlive_block_migration="yes"
548a99d57bbSWanlong Gaonuma=""
5492847b469SFam Zhengtcmalloc="no"
5507b01cb97SAlexandre Derumierjemalloc="no"
551a6b1d4c0SChanglong Xiereplication="yes"
5522f740136SJeff Codybochs="yes"
5532f740136SJeff Codycloop="yes"
5542f740136SJeff Codydmg="yes"
5552f740136SJeff Codyqcow1="yes"
5562f740136SJeff Codyvdi="yes"
5572f740136SJeff Codyvvfat="yes"
5582f740136SJeff Codyqed="yes"
5592f740136SJeff Codyparallels="yes"
5602f740136SJeff Codysheepdog="yes"
561ed279a06SKlim Kireevlibxml2=""
562ba59fb77SPaolo Bonzinidebug_mutex="no"
56317824406SJunyan Helibpmem=""
564f3494749SPaolo Bonzinidefault_devices="yes"
56540e8c6f4SAlex Bennéeplugins="no"
566adc28027SAlexander Bulekovfuzzing="no"
567b767d257SMarek Marczykowski-Góreckirng_none="no"
56854e7aac0SAlexey Krasikovsecret_keyring=""
56921b2eca6SJingqi Liulibdaxctl=""
570a5665051SPaolo Bonzinimeson=""
57148328880SPaolo Bonzinininja=""
572a5665051SPaolo Bonziniskip_meson=no
573e8f3bd71SMarc-André Lureaugettext=""
574377529c0SPaolo Bonzini
575fb59dabdSPeter Maydellbogus_os="no"
5765a22ab71SYang Zhongmalloc_trim=""
577898be3e0SPeter Maydell
578ac0df51dSaliguori# parse CC options first
579ac0df51dSaliguorifor opt do
58089138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
581ac0df51dSaliguori  case "$opt" in
582ac0df51dSaliguori  --cross-prefix=*) cross_prefix="$optarg"
583ac0df51dSaliguori  ;;
5843d8df640SPaolo Bonzini  --cc=*) CC="$optarg"
585ac0df51dSaliguori  ;;
58683f73fceSTomoki Sekiyama  --cxx=*) CXX="$optarg"
58783f73fceSTomoki Sekiyama  ;;
5882ff6b91eSJuan Quintela  --cpu=*) cpu="$optarg"
5892ff6b91eSJuan Quintela  ;;
590de385287SAlex Bennée  --extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
591db5adeaaSPaolo Bonzini                    QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
592e2a2ed06SJuan Quintela  ;;
59311cde1c8SBruno Dominguez  --extra-cxxflags=*) QEMU_CXXFLAGS="$QEMU_CXXFLAGS $optarg"
59411cde1c8SBruno Dominguez  ;;
595db5adeaaSPaolo Bonzini  --extra-ldflags=*) QEMU_LDFLAGS="$QEMU_LDFLAGS $optarg"
596f9943cd5SGerd Hoffmann                     EXTRA_LDFLAGS="$optarg"
597e2a2ed06SJuan Quintela  ;;
5985bc62e01SGerd Hoffmann  --enable-debug-info) debug_info="yes"
5995bc62e01SGerd Hoffmann  ;;
6005bc62e01SGerd Hoffmann  --disable-debug-info) debug_info="no"
6015bc62e01SGerd Hoffmann  ;;
602d75402b5SAlex Bennée  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
603d75402b5SAlex Bennée  ;;
604d422b2bcSAlex Bennée  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-flags-}; cc_arch=${cc_arch%%=*}
605d422b2bcSAlex Bennée                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
6062038f8c8SPaolo Bonzini                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
607d422b2bcSAlex Bennée  ;;
608d75402b5SAlex Bennée  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
6092038f8c8SPaolo Bonzini                cc_archs="$cc_archs $cc_arch"
610d75402b5SAlex Bennée                eval "cross_cc_${cc_arch}=\$optarg"
6112038f8c8SPaolo Bonzini                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
612d75402b5SAlex Bennée  ;;
613ac0df51dSaliguori  esac
614ac0df51dSaliguoridone
615ac0df51dSaliguori# OS specific
616ac0df51dSaliguori# Using uname is really, really broken.  Once we have the right set of checks
61793148aa5SStefan Weil# we can eliminate its usage altogether.
618ac0df51dSaliguori
619e49d021eSPeter Maydell# Preferred compiler:
620e49d021eSPeter Maydell#  ${CC} (if set)
621e49d021eSPeter Maydell#  ${cross_prefix}gcc (if cross-prefix specified)
622e49d021eSPeter Maydell#  system compiler
623e49d021eSPeter Maydellif test -z "${CC}${cross_prefix}"; then
624e49d021eSPeter Maydell  cc="$host_cc"
625e49d021eSPeter Maydellelse
626b3198cc2SStuart Yoder  cc="${CC-${cross_prefix}gcc}"
627e49d021eSPeter Maydellfi
628e49d021eSPeter Maydell
62983f73fceSTomoki Sekiyamaif test -z "${CXX}${cross_prefix}"; then
63083f73fceSTomoki Sekiyama  cxx="c++"
63183f73fceSTomoki Sekiyamaelse
63283f73fceSTomoki Sekiyama  cxx="${CXX-${cross_prefix}g++}"
63383f73fceSTomoki Sekiyamafi
63483f73fceSTomoki Sekiyama
635b3198cc2SStuart Yoderar="${AR-${cross_prefix}ar}"
636cdbd727cSRichard Hendersonas="${AS-${cross_prefix}as}"
6375f6f0e27SRichard Hendersonccas="${CCAS-$cc}"
6383dd46c78SBlue Swirlcpp="${CPP-$cc -E}"
639b3198cc2SStuart Yoderobjcopy="${OBJCOPY-${cross_prefix}objcopy}"
640b3198cc2SStuart Yoderld="${LD-${cross_prefix}ld}"
6419f81aeb5SAlistair Francisranlib="${RANLIB-${cross_prefix}ranlib}"
6424852ee95SStefan Weilnm="${NM-${cross_prefix}nm}"
643b3198cc2SStuart Yoderstrip="${STRIP-${cross_prefix}strip}"
644b3198cc2SStuart Yoderwindres="${WINDRES-${cross_prefix}windres}"
64517884d7bSSergei Trofimovichpkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
64617884d7bSSergei Trofimovichquery_pkg_config() {
64717884d7bSSergei Trofimovich    "${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
64817884d7bSSergei Trofimovich}
64917884d7bSSergei Trofimovichpkg_config=query_pkg_config
65047c03744SDave Airliesdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
651ac0df51dSaliguori
65245d285abSPeter Maydell# If the user hasn't specified ARFLAGS, default to 'rv', just as make does.
65345d285abSPeter MaydellARFLAGS="${ARFLAGS-rv}"
65445d285abSPeter Maydell
655be17dc90SMichael S. Tsirkin# default flags for all hosts
6562d31515bSPeter Maydell# We use -fwrapv to tell the compiler that we require a C dialect where
6572d31515bSPeter Maydell# left shift of signed integers is well defined and has the expected
6582d31515bSPeter Maydell# 2s-complement style results. (Both clang and gcc agree that it
6592d31515bSPeter Maydell# provides these semantics.)
660086d5f75SPaolo BonziniQEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
661086d5f75SPaolo BonziniQEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
662c95e3080SKevin WolfQEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
663be17dc90SMichael S. TsirkinQEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
66425211446SPaolo BonziniQEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote ${source_path}/accel/tcg -iquote ${source_path}/include"
66525211446SPaolo BonziniQEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
666086d5f75SPaolo BonziniCFLAGS="-std=gnu99 -Wall"
667086d5f75SPaolo Bonzini
668be17dc90SMichael S. Tsirkin
669cab00a5aSMichael S. Tsirkin# running configure in the source tree?
670cab00a5aSMichael S. Tsirkin# we know that's the case if configure is there.
671cab00a5aSMichael S. Tsirkinif test -f "./configure"; then
672cab00a5aSMichael S. Tsirkin    pwd_is_source_path="y"
673cab00a5aSMichael S. Tsirkinelse
674cab00a5aSMichael S. Tsirkin    pwd_is_source_path="n"
675cab00a5aSMichael S. Tsirkinfi
676cab00a5aSMichael S. Tsirkin
677ac0df51dSaliguoricheck_define() {
678ac0df51dSaliguoricat > $TMPC <<EOF
679ac0df51dSaliguori#if !defined($1)
680fd786e1aSPeter Maydell#error $1 not defined
681ac0df51dSaliguori#endif
682ac0df51dSaliguoriint main(void) { return 0; }
683ac0df51dSaliguoriEOF
68452166aa0SJuan Quintela  compile_object
685ac0df51dSaliguori}
686ac0df51dSaliguori
687307119e7SGerd Hoffmanncheck_include() {
688307119e7SGerd Hoffmanncat > $TMPC <<EOF
689307119e7SGerd Hoffmann#include <$1>
690307119e7SGerd Hoffmannint main(void) { return 0; }
691307119e7SGerd HoffmannEOF
692307119e7SGerd Hoffmann  compile_object
693307119e7SGerd Hoffmann}
694307119e7SGerd Hoffmann
69593b25869SJohn Snowwrite_c_skeleton() {
69693b25869SJohn Snow    cat > $TMPC <<EOF
69793b25869SJohn Snowint main(void) { return 0; }
69893b25869SJohn SnowEOF
69993b25869SJohn Snow}
70093b25869SJohn Snow
701adc28027SAlexander Bulekovwrite_c_fuzzer_skeleton() {
702adc28027SAlexander Bulekov    cat > $TMPC <<EOF
703adc28027SAlexander Bulekov#include <stdint.h>
704adc28027SAlexander Bulekov#include <sys/types.h>
705adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
706adc28027SAlexander Bulekovint LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
707adc28027SAlexander BulekovEOF
708adc28027SAlexander Bulekov}
709adc28027SAlexander Bulekov
710bbea4050SPeter Maydellif check_define __linux__ ; then
711bbea4050SPeter Maydell  targetos="Linux"
712bbea4050SPeter Maydellelif check_define _WIN32 ; then
713bbea4050SPeter Maydell  targetos='MINGW32'
714bbea4050SPeter Maydellelif check_define __OpenBSD__ ; then
715bbea4050SPeter Maydell  targetos='OpenBSD'
716bbea4050SPeter Maydellelif check_define __sun__ ; then
717bbea4050SPeter Maydell  targetos='SunOS'
718bbea4050SPeter Maydellelif check_define __HAIKU__ ; then
719bbea4050SPeter Maydell  targetos='Haiku'
720951fedfcSPeter Maydellelif check_define __FreeBSD__ ; then
721951fedfcSPeter Maydell  targetos='FreeBSD'
722951fedfcSPeter Maydellelif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
723951fedfcSPeter Maydell  targetos='GNU/kFreeBSD'
724951fedfcSPeter Maydellelif check_define __DragonFly__ ; then
725951fedfcSPeter Maydell  targetos='DragonFly'
726951fedfcSPeter Maydellelif check_define __NetBSD__; then
727951fedfcSPeter Maydell  targetos='NetBSD'
728951fedfcSPeter Maydellelif check_define __APPLE__; then
729951fedfcSPeter Maydell  targetos='Darwin'
730bbea4050SPeter Maydellelse
731951fedfcSPeter Maydell  # This is a fatal error, but don't report it yet, because we
732951fedfcSPeter Maydell  # might be going to just print the --help text, or it might
733951fedfcSPeter Maydell  # be the result of a missing compiler.
734951fedfcSPeter Maydell  targetos='bogus'
735951fedfcSPeter Maydell  bogus_os='yes'
736bbea4050SPeter Maydellfi
737bbea4050SPeter Maydell
738bbea4050SPeter Maydell# Some host OSes need non-standard checks for which CPU to use.
739bbea4050SPeter Maydell# Note that these checks are broken for cross-compilation: if you're
740bbea4050SPeter Maydell# cross-compiling to one of these OSes then you'll need to specify
741bbea4050SPeter Maydell# the correct CPU with the --cpu option.
742bbea4050SPeter Maydellcase $targetos in
743bbea4050SPeter MaydellDarwin)
744bbea4050SPeter Maydell  # on Leopard most of the system is 32-bit, so we have to ask the kernel if we can
745bbea4050SPeter Maydell  # run 64-bit userspace code.
746bbea4050SPeter Maydell  # If the user didn't specify a CPU explicitly and the kernel says this is
747bbea4050SPeter Maydell  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual detection code.
748bbea4050SPeter Maydell  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
749bbea4050SPeter Maydell    cpu="x86_64"
750bbea4050SPeter Maydell  fi
751bbea4050SPeter Maydell  ;;
752bbea4050SPeter MaydellSunOS)
75389138857SStefan Weil  # $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
754bbea4050SPeter Maydell  if test -z "$cpu" && test "$(isainfo -k)" = "amd64"; then
755bbea4050SPeter Maydell    cpu="x86_64"
756bbea4050SPeter Maydell  fi
757bbea4050SPeter Maydellesac
758bbea4050SPeter Maydell
7592ff6b91eSJuan Quintelaif test ! -z "$cpu" ; then
7602ff6b91eSJuan Quintela  # command line argument
7612ff6b91eSJuan Quintela  :
7622ff6b91eSJuan Quintelaelif check_define __i386__ ; then
763ac0df51dSaliguori  cpu="i386"
764ac0df51dSaliguorielif check_define __x86_64__ ; then
765c72b26ecSRichard Henderson  if check_define __ILP32__ ; then
766c72b26ecSRichard Henderson    cpu="x32"
767c72b26ecSRichard Henderson  else
768ac0df51dSaliguori    cpu="x86_64"
769c72b26ecSRichard Henderson  fi
7703aa9bd6cSblueswir1elif check_define __sparc__ ; then
7713aa9bd6cSblueswir1  if check_define __arch64__ ; then
7723aa9bd6cSblueswir1    cpu="sparc64"
7733aa9bd6cSblueswir1  else
7743aa9bd6cSblueswir1    cpu="sparc"
7753aa9bd6cSblueswir1  fi
776fdf7ed96Smalcelif check_define _ARCH_PPC ; then
777fdf7ed96Smalc  if check_define _ARCH_PPC64 ; then
778f8378accSRichard Henderson    if check_define _LITTLE_ENDIAN ; then
779f8378accSRichard Henderson      cpu="ppc64le"
780f8378accSRichard Henderson    else
781fdf7ed96Smalc      cpu="ppc64"
782f8378accSRichard Henderson    fi
783ac0df51dSaliguori  else
784fdf7ed96Smalc    cpu="ppc"
785fdf7ed96Smalc  fi
786afa05235SAurelien Jarnoelif check_define __mips__ ; then
787afa05235SAurelien Jarno  cpu="mips"
788d66ed0eaSAurelien Jarnoelif check_define __s390__ ; then
789d66ed0eaSAurelien Jarno  if check_define __s390x__ ; then
790d66ed0eaSAurelien Jarno    cpu="s390x"
791d66ed0eaSAurelien Jarno  else
792d66ed0eaSAurelien Jarno    cpu="s390"
793d66ed0eaSAurelien Jarno  fi
794c4f80543SAlistair Franciselif check_define __riscv ; then
795c4f80543SAlistair Francis  if check_define _LP64 ; then
796c4f80543SAlistair Francis    cpu="riscv64"
797c4f80543SAlistair Francis  else
798c4f80543SAlistair Francis    cpu="riscv32"
799c4f80543SAlistair Francis  fi
80021d89f84SPeter Maydellelif check_define __arm__ ; then
80121d89f84SPeter Maydell  cpu="arm"
8021f080313SClaudio Fontanaelif check_define __aarch64__ ; then
8031f080313SClaudio Fontana  cpu="aarch64"
804fdf7ed96Smalcelse
80589138857SStefan Weil  cpu=$(uname -m)
806ac0df51dSaliguorifi
807ac0df51dSaliguori
808359bc95dSPeter MaydellARCH=
809359bc95dSPeter Maydell# Normalise host CPU name and set ARCH.
810359bc95dSPeter Maydell# Note that this case should only have supported host CPUs, not guests.
8117d13299dSbellardcase "$cpu" in
812ee35e968SThomas Huth  ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64)
813898be3e0SPeter Maydell  ;;
814f8378accSRichard Henderson  ppc64le)
815f8378accSRichard Henderson    ARCH="ppc64"
816f8378accSRichard Henderson  ;;
8177d13299dSbellard  i386|i486|i586|i686|i86pc|BePC)
81897a847bcSbellard    cpu="i386"
8197d13299dSbellard  ;;
820aaa5fa14Saurel32  x86_64|amd64)
821aaa5fa14Saurel32    cpu="x86_64"
822aaa5fa14Saurel32  ;;
82321d89f84SPeter Maydell  armv*b|armv*l|arm)
82421d89f84SPeter Maydell    cpu="arm"
8257d13299dSbellard  ;;
8261f080313SClaudio Fontana  aarch64)
8271f080313SClaudio Fontana    cpu="aarch64"
8281f080313SClaudio Fontana  ;;
829afa05235SAurelien Jarno  mips*)
830afa05235SAurelien Jarno    cpu="mips"
831afa05235SAurelien Jarno  ;;
8323142255cSblueswir1  sparc|sun4[cdmuv])
833ae228531Sbellard    cpu="sparc"
834ae228531Sbellard  ;;
8357d13299dSbellard  *)
836359bc95dSPeter Maydell    # This will result in either an error or falling back to TCI later
837359bc95dSPeter Maydell    ARCH=unknown
8387d13299dSbellard  ;;
8397d13299dSbellardesac
840359bc95dSPeter Maydellif test -z "$ARCH"; then
841359bc95dSPeter Maydell  ARCH="$cpu"
842359bc95dSPeter Maydellfi
843e2d52ad3SJuan Quintela
8447d13299dSbellard# OS specific
8450dbfc675SJuan Quintela
846adfc3e91SStacey Son# host *BSD for user mode
847adfc3e91SStacey SonHOST_VARIANT_DIR=""
848adfc3e91SStacey Son
8497d13299dSbellardcase $targetos in
85067b915a5SbellardMINGW32*)
85167b915a5Sbellard  mingw32="yes"
852b0cb0a66SVincent Palatin  hax="yes"
853299e6f19SPaolo Bonzini  vhost_user="no"
8543cec7cc2SKővágó, Zoltán  audio_possible_drivers="dsound sdl"
855307119e7SGerd Hoffmann  if check_include dsound.h; then
8563cec7cc2SKővágó, Zoltán    audio_drv_list="dsound"
857307119e7SGerd Hoffmann  else
858307119e7SGerd Hoffmann    audio_drv_list=""
859307119e7SGerd Hoffmann  fi
860898be3e0SPeter Maydell  supported_os="yes"
861fb648e9cSDaniel P. Berrangé  pie="no"
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"
915a0b7cf6bSPeter Maydell  # Disable attempts to use ObjectiveC features in os/object.h since they
916a0b7cf6bSPeter Maydell  # won't work when we're compiling with gcc as a C compiler.
917a0b7cf6bSPeter Maydell  QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
918adfc3e91SStacey Son  HOST_VARIANT_DIR="darwin"
91983fb7adfSbellard;;
920ec530c81SbellardSunOS)
921ec530c81Sbellard  solaris="yes"
9220db4a067SPaolo Bonzini  make="${MAKE-gmake}"
9230db4a067SPaolo Bonzini  install="${INSTALL-ginstall}"
924e2d8830eSBrad  smbd="${SMBD-/usr/sfw/sbin/smbd}"
9256b4d2ba1Sths  if test -f /usr/include/sys/soundcard.h ; then
9266a485418SGerd Hoffmann    audio_drv_list="oss try-sdl"
9276b4d2ba1Sths  fi
928c2de5c91Smalc  audio_possible_drivers="oss sdl"
929d741429aSBlue Swirl# needed for CMSG_ macros in sys/socket.h
930d741429aSBlue Swirl  QEMU_CFLAGS="-D_XOPEN_SOURCE=600 $QEMU_CFLAGS"
931d741429aSBlue Swirl# needed for TIOCWIN* defines in termios.h
932d741429aSBlue Swirl  QEMU_CFLAGS="-D__EXTENSIONS__ $QEMU_CFLAGS"
933560d375fSAndreas Färber  solarisnetlibs="-lsocket -lnsl -lresolv"
934560d375fSAndreas Färber  LIBS="$solarisnetlibs $LIBS"
935ec530c81Sbellard;;
936179cf400SAndreas FärberHaiku)
937179cf400SAndreas Färber  haiku="yes"
938fc433430SDavid CARLIER  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -DBSD_SOURCE $QEMU_CFLAGS"
939fc433430SDavid CARLIER  LIBS="-lposix_error_mapper -lnetwork -lbsd $LIBS"
940179cf400SAndreas Färber;;
941898be3e0SPeter MaydellLinux)
9427183834aSGerd Hoffmann  audio_drv_list="try-pa oss"
9430bac1111SKővágó, Zoltán  audio_possible_drivers="oss alsa sdl pa"
9445327cf48Sbellard  linux="yes"
945831b7825Sths  linux_user="yes"
946af2be207SJan Kiszka  kvm="yes"
94725211446SPaolo Bonzini  QEMU_INCLUDES="-isystem ${source_path}/linux-headers -I$PWD/linux-headers $QEMU_INCLUDES"
9483efac6ebSTomáš Golembiovský  libudev="yes"
949898be3e0SPeter Maydell;;
9507d13299dSbellardesac
9517d13299dSbellard
9527d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
953b1a550a0Spbrook  if [ "$darwin" != "yes" ] ; then
95484778508Sblueswir1    bsd_user="yes"
9557d3505c5Sbellard  fi
95608de3949SAndreas Färberfi
9577d3505c5Sbellard
9580db4a067SPaolo Bonzini: ${make=${MAKE-make}}
9590db4a067SPaolo Bonzini: ${install=${INSTALL-install}}
960faf44142SDaniel P. Berrangé# We prefer python 3.x. A bare 'python' is traditionally
961faf44142SDaniel P. Berrangé# python 2.x, but some distros have it as python 3.x, so
962ddf90699SEduardo Habkost# we check that too
963faf44142SDaniel P. Berrangépython=
9640a01d76fSMarc-André Lureauexplicit_python=no
965ddf90699SEduardo Habkostfor binary in "${PYTHON-python3}" python
966faf44142SDaniel P. Berrangédo
967faf44142SDaniel P. Berrangé    if has "$binary"
968faf44142SDaniel P. Berrangé    then
96995c5f2deSPaolo Bonzini        python=$(command -v "$binary")
970faf44142SDaniel P. Berrangé        break
971faf44142SDaniel P. Berrangé    fi
972faf44142SDaniel P. Berrangédone
973903458c8SMarkus Armbruster
974903458c8SMarkus Armbrustersphinx_build=
975903458c8SMarkus Armbrusterfor binary in sphinx-build-3 sphinx-build
976903458c8SMarkus Armbrusterdo
977903458c8SMarkus Armbruster    if has "$binary"
978903458c8SMarkus Armbruster    then
979903458c8SMarkus Armbruster        sphinx_build=$(command -v "$binary")
980903458c8SMarkus Armbruster        break
981903458c8SMarkus Armbruster    fi
982903458c8SMarkus Armbrusterdone
983903458c8SMarkus Armbruster
98439d87c8cSAlex Bennée# Check for ancillary tools used in testing
98539d87c8cSAlex Bennéegenisoimage=
9863df437c7SAlex Bennéefor binary in genisoimage mkisofs
98739d87c8cSAlex Bennéedo
98839d87c8cSAlex Bennée    if has $binary
98939d87c8cSAlex Bennée    then
99039d87c8cSAlex Bennée        genisoimage=$(command -v "$binary")
99139d87c8cSAlex Bennée        break
99239d87c8cSAlex Bennée    fi
99339d87c8cSAlex Bennéedone
99439d87c8cSAlex Bennée
995e2d8830eSBrad: ${smbd=${SMBD-/usr/sbin/smbd}}
9960db4a067SPaolo Bonzini
9973c4a4d0dSPeter Maydell# Default objcc to clang if available, otherwise use CC
9983c4a4d0dSPeter Maydellif has clang; then
9993c4a4d0dSPeter Maydell  objcc=clang
10003c4a4d0dSPeter Maydellelse
10013c4a4d0dSPeter Maydell  objcc="$cc"
10023c4a4d0dSPeter Maydellfi
10033c4a4d0dSPeter Maydell
10043457a3f8SJuan Quintelaif test "$mingw32" = "yes" ; then
10053457a3f8SJuan Quintela  EXESUF=".exe"
1006484e2cc7SPaolo Bonzini  HOST_DSOSUF=".dll"
100778e9d4adSStefan Weil  # MinGW needs -mthreads for TLS and macro _MT.
1008086d5f75SPaolo Bonzini  CFLAGS="-mthreads $CFLAGS"
1009b965e8c5SPaolo Bonzini  LIBS="-lwinmm -lws2_32 $LIBS"
101093b25869SJohn Snow  write_c_skeleton;
1011f7cf5d5bSStefan Weil  if compile_prog "" "-liberty" ; then
1012f7cf5d5bSStefan Weil    LIBS="-liberty $LIBS"
1013f7cf5d5bSStefan Weil  fi
1014c5ec15eaSStefan Weil  prefix="c:/Program Files/QEMU"
1015683035deSPaolo Bonzini  confsuffix=""
1016105fad6bSBishara AbuHattoum  libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
10173457a3f8SJuan Quintelafi
10183457a3f8SJuan Quintela
1019487fefdbSAnthony Liguoriwerror=""
102085aa5189Sbellard
10217d13299dSbellardfor opt do
102289138857SStefan Weil  optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
10237d13299dSbellard  case "$opt" in
10242efc3265Sbellard  --help|-h) show_help=yes
10252efc3265Sbellard  ;;
102699123e13SMike Frysinger  --version|-V) exec cat $source_path/VERSION
102799123e13SMike Frysinger  ;;
1028b1a550a0Spbrook  --prefix=*) prefix="$optarg"
10297d13299dSbellard  ;;
1030b1a550a0Spbrook  --interp-prefix=*) interp_prefix="$optarg"
103132ce6337Sbellard  ;;
1032ac0df51dSaliguori  --cross-prefix=*)
10337d13299dSbellard  ;;
1034ac0df51dSaliguori  --cc=*)
10357d13299dSbellard  ;;
1036b1a550a0Spbrook  --host-cc=*) host_cc="$optarg"
103783469015Sbellard  ;;
103883f73fceSTomoki Sekiyama  --cxx=*)
103983f73fceSTomoki Sekiyama  ;;
1040e007dbecSMichael S. Tsirkin  --iasl=*) iasl="$optarg"
1041e007dbecSMichael S. Tsirkin  ;;
10423c4a4d0dSPeter Maydell  --objcc=*) objcc="$optarg"
10433c4a4d0dSPeter Maydell  ;;
1044b1a550a0Spbrook  --make=*) make="$optarg"
10457d13299dSbellard  ;;
10466a882643Spbrook  --install=*) install="$optarg"
10476a882643Spbrook  ;;
10480a01d76fSMarc-André Lureau  --python=*) python="$optarg" ; explicit_python=yes
1049c886edfbSBlue Swirl  ;;
10502eb054c2SPeter Maydell  --sphinx-build=*) sphinx_build="$optarg"
10512eb054c2SPeter Maydell  ;;
1052a5665051SPaolo Bonzini  --skip-meson) skip_meson=yes
1053a5665051SPaolo Bonzini  ;;
1054a5665051SPaolo Bonzini  --meson=*) meson="$optarg"
1055a5665051SPaolo Bonzini  ;;
105648328880SPaolo Bonzini  --ninja=*) ninja="$optarg"
105748328880SPaolo Bonzini  ;;
1058e2d8830eSBrad  --smbd=*) smbd="$optarg"
1059e2d8830eSBrad  ;;
1060e2a2ed06SJuan Quintela  --extra-cflags=*)
10617d13299dSbellard  ;;
106211cde1c8SBruno Dominguez  --extra-cxxflags=*)
106311cde1c8SBruno Dominguez  ;;
1064e2a2ed06SJuan Quintela  --extra-ldflags=*)
10657d13299dSbellard  ;;
10665bc62e01SGerd Hoffmann  --enable-debug-info)
10675bc62e01SGerd Hoffmann  ;;
10685bc62e01SGerd Hoffmann  --disable-debug-info)
10695bc62e01SGerd Hoffmann  ;;
1070d75402b5SAlex Bennée  --cross-cc-*)
1071d75402b5SAlex Bennée  ;;
107217969268SFam Zheng  --enable-modules)
107317969268SFam Zheng      modules="yes"
107417969268SFam Zheng  ;;
10753aa88b31SStefan Hajnoczi  --disable-modules)
10763aa88b31SStefan Hajnoczi      modules="no"
10773aa88b31SStefan Hajnoczi  ;;
1078bd83c861SChristian Ehrhardt  --disable-module-upgrades) module_upgrades="no"
1079bd83c861SChristian Ehrhardt  ;;
1080bd83c861SChristian Ehrhardt  --enable-module-upgrades) module_upgrades="yes"
1081bd83c861SChristian Ehrhardt  ;;
10822ff6b91eSJuan Quintela  --cpu=*)
10837d13299dSbellard  ;;
1084b1a550a0Spbrook  --target-list=*) target_list="$optarg"
1085447e133fSAlex Bennée                   if test "$target_list_exclude"; then
1086447e133fSAlex Bennée                       error_exit "Can't mix --target-list with --target-list-exclude"
1087447e133fSAlex Bennée                   fi
1088447e133fSAlex Bennée  ;;
1089447e133fSAlex Bennée  --target-list-exclude=*) target_list_exclude="$optarg"
1090447e133fSAlex Bennée                   if test "$target_list"; then
1091447e133fSAlex Bennée                       error_exit "Can't mix --target-list-exclude with --target-list"
1092447e133fSAlex Bennée                   fi
1093de83cd02Sbellard  ;;
10945b808275SLluís Vilanova  --enable-trace-backends=*) trace_backends="$optarg"
10955b808275SLluís Vilanova  ;;
10965b808275SLluís Vilanova  # XXX: backwards compatibility
10975b808275SLluís Vilanova  --enable-trace-backend=*) trace_backends="$optarg"
109894a420b1SStefan Hajnoczi  ;;
109974242e0fSPaolo Bonzini  --with-trace-file=*) trace_file="$optarg"
11009410b56cSPrerna Saxena  ;;
1101f3494749SPaolo Bonzini  --with-default-devices) default_devices="yes"
1102f3494749SPaolo Bonzini  ;;
1103f3494749SPaolo Bonzini  --without-default-devices) default_devices="no"
1104f3494749SPaolo Bonzini  ;;
11057d13299dSbellard  --enable-gprof) gprof="yes"
11067d13299dSbellard  ;;
11071d728c39SBlue Swirl  --enable-gcov) gcov="yes"
11081d728c39SBlue Swirl  ;;
110979427693SLoïc Minier  --static)
111079427693SLoïc Minier    static="yes"
111117884d7bSSergei Trofimovich    QEMU_PKG_CONFIG_FLAGS="--static $QEMU_PKG_CONFIG_FLAGS"
111243ce4dfeSbellard  ;;
11130b24e75fSPaolo Bonzini  --mandir=*) mandir="$optarg"
11140b24e75fSPaolo Bonzini  ;;
11150b24e75fSPaolo Bonzini  --bindir=*) bindir="$optarg"
11160b24e75fSPaolo Bonzini  ;;
11173aa5d2beSAlon Levy  --libdir=*) libdir="$optarg"
11183aa5d2beSAlon Levy  ;;
11198bf188aaSMichael Tokarev  --libexecdir=*) libexecdir="$optarg"
11208bf188aaSMichael Tokarev  ;;
11210f94d6daSAlon Levy  --includedir=*) includedir="$optarg"
11220f94d6daSAlon Levy  ;;
1123528ae5b8SEduardo Habkost  --datadir=*) datadir="$optarg"
11240b24e75fSPaolo Bonzini  ;;
1125023d3d67SEduardo Habkost  --with-confsuffix=*) confsuffix="$optarg"
1126023d3d67SEduardo Habkost  ;;
1127850da188SEduardo Habkost  --docdir=*) qemu_docdir="$optarg"
11280b24e75fSPaolo Bonzini  ;;
1129ca2fb938SAndre Przywara  --sysconfdir=*) sysconfdir="$optarg"
113007381cc1SAnthony Liguori  ;;
1131785c23aeSLuiz Capitulino  --localstatedir=*) local_statedir="$optarg"
1132785c23aeSLuiz Capitulino  ;;
11333d5eecabSGerd Hoffmann  --firmwarepath=*) firmwarepath="$optarg"
11343d5eecabSGerd Hoffmann  ;;
1135181ce1d0SOlaf Hering  --host=*|--build=*|\
1136181ce1d0SOlaf Hering  --disable-dependency-tracking|\
1137785c23aeSLuiz Capitulino  --sbindir=*|--sharedstatedir=*|\
1138023ddd74SMax Filippov  --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
1139023ddd74SMax Filippov  --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
1140023ddd74SMax Filippov    # These switches are silently ignored, for compatibility with
1141023ddd74SMax Filippov    # autoconf-generated configure scripts. This allows QEMU's
1142023ddd74SMax Filippov    # configure to be used by RPM and similar macros that set
1143023ddd74SMax Filippov    # lots of directory switches by default.
1144023ddd74SMax Filippov  ;;
114535be72baSPaolo Bonzini  --disable-sdl) sdl="disabled"
114697a847bcSbellard  ;;
114735be72baSPaolo Bonzini  --enable-sdl) sdl="enabled"
1148c4198157SJuan Quintela  ;;
114935be72baSPaolo Bonzini  --disable-sdl-image) sdl_image="disabled"
1150a442fe2fSDaniel P. Berrangé  ;;
115135be72baSPaolo Bonzini  --enable-sdl-image) sdl_image="enabled"
1152a442fe2fSDaniel P. Berrangé  ;;
11533556c233SPaolo Bonzini  --disable-qom-cast-debug) qom_cast_debug="no"
11543556c233SPaolo Bonzini  ;;
11553556c233SPaolo Bonzini  --enable-qom-cast-debug) qom_cast_debug="yes"
11563556c233SPaolo Bonzini  ;;
1157983eef5aSMeador Inge  --disable-virtfs) virtfs="no"
1158983eef5aSMeador Inge  ;;
1159983eef5aSMeador Inge  --enable-virtfs) virtfs="yes"
1160983eef5aSMeador Inge  ;;
1161fe8fc5aeSPaolo Bonzini  --disable-mpath) mpath="no"
1162fe8fc5aeSPaolo Bonzini  ;;
1163fe8fc5aeSPaolo Bonzini  --enable-mpath) mpath="yes"
1164fe8fc5aeSPaolo Bonzini  ;;
1165a0b93237SPaolo Bonzini  --disable-vnc) vnc="disabled"
1166821601eaSJes Sorensen  ;;
1167a0b93237SPaolo Bonzini  --enable-vnc) vnc="enabled"
1168821601eaSJes Sorensen  ;;
1169e8f3bd71SMarc-André Lureau  --disable-gettext) gettext="false"
1170e8f3bd71SMarc-André Lureau  ;;
1171e8f3bd71SMarc-André Lureau  --enable-gettext) gettext="true"
1172e8f3bd71SMarc-André Lureau  ;;
11732f6a1ab0Sblueswir1  --oss-lib=*) oss_lib="$optarg"
11742f6a1ab0Sblueswir1  ;;
11750c58ac1cSmalc  --audio-drv-list=*) audio_drv_list="$optarg"
11760c58ac1cSmalc  ;;
117789138857SStefan Weil  --block-drv-rw-whitelist=*|--block-drv-whitelist=*) block_drv_rw_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1178b64ec4e4SFam Zheng  ;;
117989138857SStefan Weil  --block-drv-ro-whitelist=*) block_drv_ro_whitelist=$(echo "$optarg" | sed -e 's/,/ /g')
1180eb852011SMarkus Armbruster  ;;
1181f8393946Saurel32  --enable-debug-tcg) debug_tcg="yes"
1182f8393946Saurel32  ;;
1183f8393946Saurel32  --disable-debug-tcg) debug_tcg="no"
1184f8393946Saurel32  ;;
1185f3d08ee6SPaul Brook  --enable-debug)
1186f3d08ee6SPaul Brook      # Enable debugging options that aren't excessively noisy
1187f3d08ee6SPaul Brook      debug_tcg="yes"
11881fcc6d42SPeter Xu      debug_mutex="yes"
1189f3d08ee6SPaul Brook      debug="yes"
1190f3d08ee6SPaul Brook      strip_opt="no"
1191b553a042SJohn Snow      fortify_source="no"
1192f3d08ee6SPaul Brook  ;;
1193247724cbSMarc-André Lureau  --enable-sanitizers) sanitizers="yes"
1194247724cbSMarc-André Lureau  ;;
1195247724cbSMarc-André Lureau  --disable-sanitizers) sanitizers="no"
1196247724cbSMarc-André Lureau  ;;
11970aebab04SLingfeng Yang  --enable-tsan) tsan="yes"
11980aebab04SLingfeng Yang  ;;
11990aebab04SLingfeng Yang  --disable-tsan) tsan="no"
12000aebab04SLingfeng Yang  ;;
120103b4fe7dSaliguori  --enable-sparse) sparse="yes"
120203b4fe7dSaliguori  ;;
120303b4fe7dSaliguori  --disable-sparse) sparse="no"
120403b4fe7dSaliguori  ;;
12051625af87Saliguori  --disable-strip) strip_opt="no"
12061625af87Saliguori  ;;
1207a0b93237SPaolo Bonzini  --disable-vnc-sasl) vnc_sasl="disabled"
12082f9606b3Saliguori  ;;
1209a0b93237SPaolo Bonzini  --enable-vnc-sasl) vnc_sasl="enabled"
1210ea784e3bSJuan Quintela  ;;
1211a0b93237SPaolo Bonzini  --disable-vnc-jpeg) vnc_jpeg="disabled"
12122f6f5c7aSCorentin Chary  ;;
1213a0b93237SPaolo Bonzini  --enable-vnc-jpeg) vnc_jpeg="enabled"
12142f6f5c7aSCorentin Chary  ;;
1215a0b93237SPaolo Bonzini  --disable-vnc-png) vnc_png="disabled"
1216efe556adSCorentin Chary  ;;
1217a0b93237SPaolo Bonzini  --enable-vnc-png) vnc_png="enabled"
1218efe556adSCorentin Chary  ;;
1219443f1376Sbellard  --disable-slirp) slirp="no"
1220c20709aaSbellard  ;;
12217c57bdd8SMarc-André Lureau  --enable-slirp=git) slirp="git"
12227c57bdd8SMarc-André Lureau  ;;
1223675b9b53SMarc-André Lureau  --enable-slirp=system) slirp="system"
1224675b9b53SMarc-André Lureau  ;;
1225e0e6c8c0Saliguori  --disable-vde) vde="no"
12268a16d273Sths  ;;
1227dfb278bdSJuan Quintela  --enable-vde) vde="yes"
1228dfb278bdSJuan Quintela  ;;
122958952137SVincenzo Maffione  --disable-netmap) netmap="no"
123058952137SVincenzo Maffione  ;;
123158952137SVincenzo Maffione  --enable-netmap) netmap="yes"
123258952137SVincenzo Maffione  ;;
1233e37630caSaliguori  --disable-xen) xen="no"
1234e37630caSaliguori  ;;
1235fc321b4bSJuan Quintela  --enable-xen) xen="yes"
1236fc321b4bSJuan Quintela  ;;
1237eb6fda0fSAnthony PERARD  --disable-xen-pci-passthrough) xen_pci_passthrough="no"
1238eb6fda0fSAnthony PERARD  ;;
1239eb6fda0fSAnthony PERARD  --enable-xen-pci-passthrough) xen_pci_passthrough="yes"
1240eb6fda0fSAnthony PERARD  ;;
12412e4d9fb1Saurel32  --disable-brlapi) brlapi="no"
12422e4d9fb1Saurel32  ;;
12434ffcedb6SJuan Quintela  --enable-brlapi) brlapi="yes"
12444ffcedb6SJuan Quintela  ;;
12457ba1e619Saliguori  --disable-kvm) kvm="no"
12467ba1e619Saliguori  ;;
1247b31a0277SJuan Quintela  --enable-kvm) kvm="yes"
1248b31a0277SJuan Quintela  ;;
1249b0cb0a66SVincent Palatin  --disable-hax) hax="no"
1250180fb750Szhanghailiang  ;;
1251b0cb0a66SVincent Palatin  --enable-hax) hax="yes"
1252180fb750Szhanghailiang  ;;
1253c97d6d2cSSergio Andres Gomez Del Real  --disable-hvf) hvf="no"
1254c97d6d2cSSergio Andres Gomez Del Real  ;;
1255c97d6d2cSSergio Andres Gomez Del Real  --enable-hvf) hvf="yes"
1256c97d6d2cSSergio Andres Gomez Del Real  ;;
1257d661d9a4SJustin Terry (VM)  --disable-whpx) whpx="no"
1258d661d9a4SJustin Terry (VM)  ;;
1259d661d9a4SJustin Terry (VM)  --enable-whpx) whpx="yes"
1260d661d9a4SJustin Terry (VM)  ;;
12619195b2c2SStefan Weil  --disable-tcg-interpreter) tcg_interpreter="no"
12629195b2c2SStefan Weil  ;;
12639195b2c2SStefan Weil  --enable-tcg-interpreter) tcg_interpreter="yes"
12649195b2c2SStefan Weil  ;;
126547e98658SCorey Bryant  --disable-cap-ng)  cap_ng="no"
126647e98658SCorey Bryant  ;;
126747e98658SCorey Bryant  --enable-cap-ng) cap_ng="yes"
126847e98658SCorey Bryant  ;;
1269b3f6ea7eSPaolo Bonzini  --disable-tcg) tcg="no"
1270b3f6ea7eSPaolo Bonzini  ;;
1271b3f6ea7eSPaolo Bonzini  --enable-tcg) tcg="yes"
1272b3f6ea7eSPaolo Bonzini  ;;
12735a22ab71SYang Zhong  --disable-malloc-trim) malloc_trim="no"
12745a22ab71SYang Zhong  ;;
12755a22ab71SYang Zhong  --enable-malloc-trim) malloc_trim="yes"
12765a22ab71SYang Zhong  ;;
1277cd4ec0b4SGerd Hoffmann  --disable-spice) spice="no"
1278cd4ec0b4SGerd Hoffmann  ;;
1279cd4ec0b4SGerd Hoffmann  --enable-spice) spice="yes"
1280cd4ec0b4SGerd Hoffmann  ;;
1281c589b249SRonnie Sahlberg  --disable-libiscsi) libiscsi="no"
1282c589b249SRonnie Sahlberg  ;;
1283c589b249SRonnie Sahlberg  --enable-libiscsi) libiscsi="yes"
1284c589b249SRonnie Sahlberg  ;;
12856542aa9cSPeter Lieven  --disable-libnfs) libnfs="no"
12866542aa9cSPeter Lieven  ;;
12876542aa9cSPeter Lieven  --enable-libnfs) libnfs="yes"
12886542aa9cSPeter Lieven  ;;
128905c2a3e7Sbellard  --enable-profiler) profiler="yes"
129005c2a3e7Sbellard  ;;
129114821030SPavel Borzenkov  --disable-cocoa) cocoa="no"
129214821030SPavel Borzenkov  ;;
1293c2de5c91Smalc  --enable-cocoa)
1294c2de5c91Smalc      cocoa="yes" ;
129589138857SStefan Weil      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
12965b0753e0Sbellard  ;;
1297cad25d69Spbrook  --disable-system) softmmu="no"
12980a8e90f4Spbrook  ;;
1299cad25d69Spbrook  --enable-system) softmmu="yes"
13000a8e90f4Spbrook  ;;
13010953a80fSZachary Amsden  --disable-user)
13020953a80fSZachary Amsden      linux_user="no" ;
13030953a80fSZachary Amsden      bsd_user="no" ;
13040953a80fSZachary Amsden  ;;
13050953a80fSZachary Amsden  --enable-user) ;;
1306831b7825Sths  --disable-linux-user) linux_user="no"
13070a8e90f4Spbrook  ;;
1308831b7825Sths  --enable-linux-user) linux_user="yes"
1309831b7825Sths  ;;
131084778508Sblueswir1  --disable-bsd-user) bsd_user="no"
131184778508Sblueswir1  ;;
131284778508Sblueswir1  --enable-bsd-user) bsd_user="yes"
131384778508Sblueswir1  ;;
131440d6444eSAvi Kivity  --enable-pie) pie="yes"
131534005a00SKirill A. Shutemov  ;;
131640d6444eSAvi Kivity  --disable-pie) pie="no"
131734005a00SKirill A. Shutemov  ;;
131885aa5189Sbellard  --enable-werror) werror="yes"
131985aa5189Sbellard  ;;
132085aa5189Sbellard  --disable-werror) werror="no"
132185aa5189Sbellard  ;;
132263678e17SSteven Noonan  --enable-stack-protector) stack_protector="yes"
132363678e17SSteven Noonan  ;;
132463678e17SSteven Noonan  --disable-stack-protector) stack_protector="no"
132563678e17SSteven Noonan  ;;
13261e4f6065SDaniele Buono  --enable-safe-stack) safe_stack="yes"
13271e4f6065SDaniele Buono  ;;
13281e4f6065SDaniele Buono  --disable-safe-stack) safe_stack="no"
13291e4f6065SDaniele Buono  ;;
13304d3b6f6eSbalrog  --disable-curses) curses="no"
13314d3b6f6eSbalrog  ;;
1332c584a6d0SJuan Quintela  --enable-curses) curses="yes"
1333c584a6d0SJuan Quintela  ;;
1334e08bb301SSamuel Thibault  --disable-iconv) iconv="no"
1335e08bb301SSamuel Thibault  ;;
1336e08bb301SSamuel Thibault  --enable-iconv) iconv="yes"
1337e08bb301SSamuel Thibault  ;;
1338769ce76dSAlexander Graf  --disable-curl) curl="no"
1339769ce76dSAlexander Graf  ;;
1340788c8196SJuan Quintela  --enable-curl) curl="yes"
1341788c8196SJuan Quintela  ;;
13422df87df7SJuan Quintela  --disable-fdt) fdt="no"
13432df87df7SJuan Quintela  ;;
13442df87df7SJuan Quintela  --enable-fdt) fdt="yes"
13452df87df7SJuan Quintela  ;;
13465c6c3a6cSChristoph Hellwig  --disable-linux-aio) linux_aio="no"
13475c6c3a6cSChristoph Hellwig  ;;
13485c6c3a6cSChristoph Hellwig  --enable-linux-aio) linux_aio="yes"
13495c6c3a6cSChristoph Hellwig  ;;
1350c10dd856SAarushi Mehta  --disable-linux-io-uring) linux_io_uring="no"
1351c10dd856SAarushi Mehta  ;;
1352c10dd856SAarushi Mehta  --enable-linux-io-uring) linux_io_uring="yes"
1353c10dd856SAarushi Mehta  ;;
1354758e8e38SVenkateswararao Jujjuri (JV)  --disable-attr) attr="no"
1355758e8e38SVenkateswararao Jujjuri (JV)  ;;
1356758e8e38SVenkateswararao Jujjuri (JV)  --enable-attr) attr="yes"
1357758e8e38SVenkateswararao Jujjuri (JV)  ;;
1358a40161cbSPaolo Bonzini  --disable-membarrier) membarrier="no"
1359a40161cbSPaolo Bonzini  ;;
1360a40161cbSPaolo Bonzini  --enable-membarrier) membarrier="yes"
1361a40161cbSPaolo Bonzini  ;;
136277755340Sths  --disable-blobs) blobs="no"
136377755340Sths  ;;
13647e563bfbSThomas Huth  --with-pkgversion=*) pkgversion="$optarg"
13654a19f1ecSpbrook  ;;
1366519175a2SAlex Barcelo  --with-coroutine=*) coroutine="$optarg"
1367519175a2SAlex Barcelo  ;;
136870c60c08SStefan Hajnoczi  --disable-coroutine-pool) coroutine_pool="no"
136970c60c08SStefan Hajnoczi  ;;
137070c60c08SStefan Hajnoczi  --enable-coroutine-pool) coroutine_pool="yes"
137170c60c08SStefan Hajnoczi  ;;
13727d992e4dSPeter Lieven  --enable-debug-stack-usage) debug_stack_usage="yes"
13737d992e4dSPeter Lieven  ;;
1374f0d92b56SLongpeng(Mike)  --enable-crypto-afalg) crypto_afalg="yes"
1375f0d92b56SLongpeng(Mike)  ;;
1376f0d92b56SLongpeng(Mike)  --disable-crypto-afalg) crypto_afalg="no"
1377f0d92b56SLongpeng(Mike)  ;;
1378a25dba17SJuan Quintela  --disable-docs) docs="no"
137970ec5dc0SAnthony Liguori  ;;
1380a25dba17SJuan Quintela  --enable-docs) docs="yes"
138183a3ab8bSJuan Quintela  ;;
1382d5970055SMichael S. Tsirkin  --disable-vhost-net) vhost_net="no"
1383d5970055SMichael S. Tsirkin  ;;
1384d5970055SMichael S. Tsirkin  --enable-vhost-net) vhost_net="yes"
1385d5970055SMichael S. Tsirkin  ;;
1386042cea27SGonglei  --disable-vhost-crypto) vhost_crypto="no"
1387042cea27SGonglei  ;;
1388299e6f19SPaolo Bonzini  --enable-vhost-crypto) vhost_crypto="yes"
1389042cea27SGonglei  ;;
13905e9be92dSNicholas Bellinger  --disable-vhost-scsi) vhost_scsi="no"
13915e9be92dSNicholas Bellinger  ;;
13925e9be92dSNicholas Bellinger  --enable-vhost-scsi) vhost_scsi="yes"
13935e9be92dSNicholas Bellinger  ;;
1394fc0b9b0eSStefan Hajnoczi  --disable-vhost-vsock) vhost_vsock="no"
1395fc0b9b0eSStefan Hajnoczi  ;;
1396fc0b9b0eSStefan Hajnoczi  --enable-vhost-vsock) vhost_vsock="yes"
1397fc0b9b0eSStefan Hajnoczi  ;;
139898fc1adaSDr. David Alan Gilbert  --disable-vhost-user-fs) vhost_user_fs="no"
139998fc1adaSDr. David Alan Gilbert  ;;
140098fc1adaSDr. David Alan Gilbert  --enable-vhost-user-fs) vhost_user_fs="yes"
140198fc1adaSDr. David Alan Gilbert  ;;
1402da076ffeSGerd Hoffmann  --disable-opengl) opengl="no"
140320ff075bSMichael Walle  ;;
1404da076ffeSGerd Hoffmann  --enable-opengl) opengl="yes"
140520ff075bSMichael Walle  ;;
1406f27aaf4bSChristian Brunner  --disable-rbd) rbd="no"
1407f27aaf4bSChristian Brunner  ;;
1408f27aaf4bSChristian Brunner  --enable-rbd) rbd="yes"
1409f27aaf4bSChristian Brunner  ;;
14108c84cf11SSergei Trofimovich  --disable-xfsctl) xfs="no"
14118c84cf11SSergei Trofimovich  ;;
14128c84cf11SSergei Trofimovich  --enable-xfsctl) xfs="yes"
14138c84cf11SSergei Trofimovich  ;;
14147b02f544SMarc-André Lureau  --disable-smartcard) smartcard="no"
1415111a38b0SRobert Relyea  ;;
14167b02f544SMarc-André Lureau  --enable-smartcard) smartcard="yes"
1417111a38b0SRobert Relyea  ;;
14180a40bcb7SCésar Belley  --disable-u2f) u2f="disabled"
14190a40bcb7SCésar Belley  ;;
14200a40bcb7SCésar Belley  --enable-u2f) u2f="enabled"
14210a40bcb7SCésar Belley  ;;
14222b2325ffSGerd Hoffmann  --disable-libusb) libusb="no"
14232b2325ffSGerd Hoffmann  ;;
14242b2325ffSGerd Hoffmann  --enable-libusb) libusb="yes"
14252b2325ffSGerd Hoffmann  ;;
142669354a83SHans de Goede  --disable-usb-redir) usb_redir="no"
142769354a83SHans de Goede  ;;
142869354a83SHans de Goede  --enable-usb-redir) usb_redir="yes"
142969354a83SHans de Goede  ;;
1430*1ffb3bbbSPaolo Bonzini  --disable-zlib-test)
14311ece9905SAlon Levy  ;;
1432b25c9dffSStefan Weil  --disable-lzo) lzo="no"
1433b25c9dffSStefan Weil  ;;
1434607dacd0Sqiaonuohan  --enable-lzo) lzo="yes"
1435607dacd0Sqiaonuohan  ;;
1436b25c9dffSStefan Weil  --disable-snappy) snappy="no"
1437b25c9dffSStefan Weil  ;;
1438607dacd0Sqiaonuohan  --enable-snappy) snappy="yes"
1439607dacd0Sqiaonuohan  ;;
14406b383c08SPeter Wu  --disable-bzip2) bzip2="no"
14416b383c08SPeter Wu  ;;
14426b383c08SPeter Wu  --enable-bzip2) bzip2="yes"
14436b383c08SPeter Wu  ;;
144483bc1f97SJulio Faracco  --enable-lzfse) lzfse="yes"
144583bc1f97SJulio Faracco  ;;
144683bc1f97SJulio Faracco  --disable-lzfse) lzfse="no"
144783bc1f97SJulio Faracco  ;;
14483a678481SJuan Quintela  --disable-zstd) zstd="no"
14493a678481SJuan Quintela  ;;
14503a678481SJuan Quintela  --enable-zstd) zstd="yes"
14513a678481SJuan Quintela  ;;
1452d138cee9SMichael Roth  --enable-guest-agent) guest_agent="yes"
1453d138cee9SMichael Roth  ;;
1454d138cee9SMichael Roth  --disable-guest-agent) guest_agent="no"
1455d138cee9SMichael Roth  ;;
14569dacf32dSYossi Hindin  --enable-guest-agent-msi) guest_agent_msi="yes"
14579dacf32dSYossi Hindin  ;;
14589dacf32dSYossi Hindin  --disable-guest-agent-msi) guest_agent_msi="no"
14599dacf32dSYossi Hindin  ;;
1460d9840e25STomoki Sekiyama  --with-vss-sdk) vss_win32_sdk=""
1461d9840e25STomoki Sekiyama  ;;
1462d9840e25STomoki Sekiyama  --with-vss-sdk=*) vss_win32_sdk="$optarg"
1463d9840e25STomoki Sekiyama  ;;
1464d9840e25STomoki Sekiyama  --without-vss-sdk) vss_win32_sdk="no"
1465d9840e25STomoki Sekiyama  ;;
1466d9840e25STomoki Sekiyama  --with-win-sdk) win_sdk=""
1467d9840e25STomoki Sekiyama  ;;
1468d9840e25STomoki Sekiyama  --with-win-sdk=*) win_sdk="$optarg"
1469d9840e25STomoki Sekiyama  ;;
1470d9840e25STomoki Sekiyama  --without-win-sdk) win_sdk="no"
1471d9840e25STomoki Sekiyama  ;;
14724b1c11fdSDaniel P. Berrange  --enable-tools) want_tools="yes"
14734b1c11fdSDaniel P. Berrange  ;;
14744b1c11fdSDaniel P. Berrange  --disable-tools) want_tools="no"
14754b1c11fdSDaniel P. Berrange  ;;
1476f794573eSEduardo Otubo  --enable-seccomp) seccomp="yes"
1477f794573eSEduardo Otubo  ;;
1478f794573eSEduardo Otubo  --disable-seccomp) seccomp="no"
1479f794573eSEduardo Otubo  ;;
1480eb100396SBharata B Rao  --disable-glusterfs) glusterfs="no"
1481eb100396SBharata B Rao  ;;
148286583a07SLiam Merwick  --disable-avx2) avx2_opt="no"
148386583a07SLiam Merwick  ;;
148486583a07SLiam Merwick  --enable-avx2) avx2_opt="yes"
148586583a07SLiam Merwick  ;;
14866b8cd447SRobert Hoo  --disable-avx512f) avx512f_opt="no"
14876b8cd447SRobert Hoo  ;;
14886b8cd447SRobert Hoo  --enable-avx512f) avx512f_opt="yes"
14896b8cd447SRobert Hoo  ;;
14906b8cd447SRobert Hoo
1491eb100396SBharata B Rao  --enable-glusterfs) glusterfs="yes"
1492eb100396SBharata B Rao  ;;
149352b53c04SFam Zheng  --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
149452b53c04SFam Zheng      echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
1495583f6e7bSStefan Hajnoczi  ;;
1496cb6414dfSFam Zheng  --enable-vhdx|--disable-vhdx)
1497cb6414dfSFam Zheng      echo "$0: $opt is obsolete, VHDX driver is always built" >&2
1498cb6414dfSFam Zheng  ;;
1499315d3184SFam Zheng  --enable-uuid|--disable-uuid)
1500315d3184SFam Zheng      echo "$0: $opt is obsolete, UUID support is always built" >&2
1501315d3184SFam Zheng  ;;
1502a4ccabcfSAnthony Liguori  --disable-gtk) gtk="no"
1503a4ccabcfSAnthony Liguori  ;;
1504a4ccabcfSAnthony Liguori  --enable-gtk) gtk="yes"
1505a4ccabcfSAnthony Liguori  ;;
1506a1c5e949SDaniel P. Berrange  --tls-priority=*) tls_priority="$optarg"
1507a1c5e949SDaniel P. Berrange  ;;
1508ddbb0d09SDaniel P. Berrange  --disable-gnutls) gnutls="no"
1509ddbb0d09SDaniel P. Berrange  ;;
1510ddbb0d09SDaniel P. Berrange  --enable-gnutls) gnutls="yes"
1511ddbb0d09SDaniel P. Berrange  ;;
151291bfcdb0SDaniel P. Berrange  --disable-nettle) nettle="no"
151391bfcdb0SDaniel P. Berrange  ;;
151491bfcdb0SDaniel P. Berrange  --enable-nettle) nettle="yes"
151591bfcdb0SDaniel P. Berrange  ;;
151691bfcdb0SDaniel P. Berrange  --disable-gcrypt) gcrypt="no"
151791bfcdb0SDaniel P. Berrange  ;;
151891bfcdb0SDaniel P. Berrange  --enable-gcrypt) gcrypt="yes"
151991bfcdb0SDaniel P. Berrange  ;;
15208953caf3SDaniel P. Berrange  --disable-auth-pam) auth_pam="no"
15218953caf3SDaniel P. Berrange  ;;
15228953caf3SDaniel P. Berrange  --enable-auth-pam) auth_pam="yes"
15238953caf3SDaniel P. Berrange  ;;
15242da776dbSMichael R. Hines  --enable-rdma) rdma="yes"
15252da776dbSMichael R. Hines  ;;
15262da776dbSMichael R. Hines  --disable-rdma) rdma="no"
15272da776dbSMichael R. Hines  ;;
152821ab34c9SMarcel Apfelbaum  --enable-pvrdma) pvrdma="yes"
152921ab34c9SMarcel Apfelbaum  ;;
153021ab34c9SMarcel Apfelbaum  --disable-pvrdma) pvrdma="no"
153121ab34c9SMarcel Apfelbaum  ;;
1532bbbf9bfbSStefan Weil  --disable-vte) vte="no"
1533bbbf9bfbSStefan Weil  ;;
1534bbbf9bfbSStefan Weil  --enable-vte) vte="yes"
1535bbbf9bfbSStefan Weil  ;;
15369d9e1521SGerd Hoffmann  --disable-virglrenderer) virglrenderer="no"
15379d9e1521SGerd Hoffmann  ;;
15389d9e1521SGerd Hoffmann  --enable-virglrenderer) virglrenderer="yes"
15399d9e1521SGerd Hoffmann  ;;
1540e91c793cSCole Robinson  --disable-tpm) tpm="no"
1541e91c793cSCole Robinson  ;;
1542ab214c29SStefan Berger  --enable-tpm) tpm="yes"
1543ab214c29SStefan Berger  ;;
1544b10d49d7SPino Toscano  --disable-libssh) libssh="no"
15450a12ec87SRichard W.M. Jones  ;;
1546b10d49d7SPino Toscano  --enable-libssh) libssh="yes"
15470a12ec87SRichard W.M. Jones  ;;
1548ed1701c6SDr. David Alan Gilbert  --disable-live-block-migration) live_block_migration="no"
1549ed1701c6SDr. David Alan Gilbert  ;;
1550ed1701c6SDr. David Alan Gilbert  --enable-live-block-migration) live_block_migration="yes"
1551ed1701c6SDr. David Alan Gilbert  ;;
1552a99d57bbSWanlong Gao  --disable-numa) numa="no"
1553a99d57bbSWanlong Gao  ;;
1554a99d57bbSWanlong Gao  --enable-numa) numa="yes"
1555a99d57bbSWanlong Gao  ;;
1556ed279a06SKlim Kireev  --disable-libxml2) libxml2="no"
1557ed279a06SKlim Kireev  ;;
1558ed279a06SKlim Kireev  --enable-libxml2) libxml2="yes"
1559ed279a06SKlim Kireev  ;;
15602847b469SFam Zheng  --disable-tcmalloc) tcmalloc="no"
15612847b469SFam Zheng  ;;
15622847b469SFam Zheng  --enable-tcmalloc) tcmalloc="yes"
15632847b469SFam Zheng  ;;
15647b01cb97SAlexandre Derumier  --disable-jemalloc) jemalloc="no"
15657b01cb97SAlexandre Derumier  ;;
15667b01cb97SAlexandre Derumier  --enable-jemalloc) jemalloc="yes"
15677b01cb97SAlexandre Derumier  ;;
1568a6b1d4c0SChanglong Xie  --disable-replication) replication="no"
1569a6b1d4c0SChanglong Xie  ;;
1570a6b1d4c0SChanglong Xie  --enable-replication) replication="yes"
1571a6b1d4c0SChanglong Xie  ;;
15722f740136SJeff Cody  --disable-bochs) bochs="no"
15732f740136SJeff Cody  ;;
15742f740136SJeff Cody  --enable-bochs) bochs="yes"
15752f740136SJeff Cody  ;;
15762f740136SJeff Cody  --disable-cloop) cloop="no"
15772f740136SJeff Cody  ;;
15782f740136SJeff Cody  --enable-cloop) cloop="yes"
15792f740136SJeff Cody  ;;
15802f740136SJeff Cody  --disable-dmg) dmg="no"
15812f740136SJeff Cody  ;;
15822f740136SJeff Cody  --enable-dmg) dmg="yes"
15832f740136SJeff Cody  ;;
15842f740136SJeff Cody  --disable-qcow1) qcow1="no"
15852f740136SJeff Cody  ;;
15862f740136SJeff Cody  --enable-qcow1) qcow1="yes"
15872f740136SJeff Cody  ;;
15882f740136SJeff Cody  --disable-vdi) vdi="no"
15892f740136SJeff Cody  ;;
15902f740136SJeff Cody  --enable-vdi) vdi="yes"
15912f740136SJeff Cody  ;;
15922f740136SJeff Cody  --disable-vvfat) vvfat="no"
15932f740136SJeff Cody  ;;
15942f740136SJeff Cody  --enable-vvfat) vvfat="yes"
15952f740136SJeff Cody  ;;
15962f740136SJeff Cody  --disable-qed) qed="no"
15972f740136SJeff Cody  ;;
15982f740136SJeff Cody  --enable-qed) qed="yes"
15992f740136SJeff Cody  ;;
16002f740136SJeff Cody  --disable-parallels) parallels="no"
16012f740136SJeff Cody  ;;
16022f740136SJeff Cody  --enable-parallels) parallels="yes"
16032f740136SJeff Cody  ;;
16042f740136SJeff Cody  --disable-sheepdog) sheepdog="no"
16052f740136SJeff Cody  ;;
16062f740136SJeff Cody  --enable-sheepdog) sheepdog="yes"
16072f740136SJeff Cody  ;;
1608e6a74868SMarc-André Lureau  --disable-vhost-user) vhost_user="no"
1609e6a74868SMarc-André Lureau  ;;
1610299e6f19SPaolo Bonzini  --enable-vhost-user) vhost_user="yes"
1611299e6f19SPaolo Bonzini  ;;
1612108a6481SCindy Lu  --disable-vhost-vdpa) vhost_vdpa="no"
1613108a6481SCindy Lu  ;;
1614108a6481SCindy Lu  --enable-vhost-vdpa) vhost_vdpa="yes"
1615108a6481SCindy Lu  ;;
1616299e6f19SPaolo Bonzini  --disable-vhost-kernel) vhost_kernel="no"
1617299e6f19SPaolo Bonzini  ;;
1618299e6f19SPaolo Bonzini  --enable-vhost-kernel) vhost_kernel="yes"
1619e6a74868SMarc-André Lureau  ;;
16208ca80760SRichard Henderson  --disable-capstone) capstone="no"
16218ca80760SRichard Henderson  ;;
16228ca80760SRichard Henderson  --enable-capstone) capstone="yes"
16238ca80760SRichard Henderson  ;;
1624e219c499SRichard Henderson  --enable-capstone=git) capstone="git"
1625e219c499SRichard Henderson  ;;
1626e219c499SRichard Henderson  --enable-capstone=system) capstone="system"
1627e219c499SRichard Henderson  ;;
1628cc84d63aSDaniel P. Berrange  --with-git=*) git="$optarg"
1629cc84d63aSDaniel P. Berrange  ;;
1630f62bbee5SDaniel P. Berrange  --enable-git-update) git_update=yes
1631f62bbee5SDaniel P. Berrange  ;;
1632f62bbee5SDaniel P. Berrange  --disable-git-update) git_update=no
1633f62bbee5SDaniel P. Berrange  ;;
1634ba59fb77SPaolo Bonzini  --enable-debug-mutex) debug_mutex=yes
1635ba59fb77SPaolo Bonzini  ;;
1636ba59fb77SPaolo Bonzini  --disable-debug-mutex) debug_mutex=no
1637ba59fb77SPaolo Bonzini  ;;
163817824406SJunyan He  --enable-libpmem) libpmem=yes
163917824406SJunyan He  ;;
164017824406SJunyan He  --disable-libpmem) libpmem=no
164117824406SJunyan He  ;;
16424113f4cfSLaurent Vivier  --enable-xkbcommon) xkbcommon="enabled"
164375411919SJames Le Cuirot  ;;
16444113f4cfSLaurent Vivier  --disable-xkbcommon) xkbcommon="disabled"
164575411919SJames Le Cuirot  ;;
164640e8c6f4SAlex Bennée  --enable-plugins) plugins="yes"
164740e8c6f4SAlex Bennée  ;;
164840e8c6f4SAlex Bennée  --disable-plugins) plugins="no"
164940e8c6f4SAlex Bennée  ;;
1650afc3a8f9SAlex Bennée  --enable-containers) use_containers="yes"
1651afc3a8f9SAlex Bennée  ;;
1652afc3a8f9SAlex Bennée  --disable-containers) use_containers="no"
1653afc3a8f9SAlex Bennée  ;;
1654adc28027SAlexander Bulekov  --enable-fuzzing) fuzzing=yes
1655adc28027SAlexander Bulekov  ;;
1656adc28027SAlexander Bulekov  --disable-fuzzing) fuzzing=no
1657adc28027SAlexander Bulekov  ;;
1658f48e590aSAlex Bennée  --gdb=*) gdb_bin="$optarg"
1659f48e590aSAlex Bennée  ;;
1660b767d257SMarek Marczykowski-Górecki  --enable-rng-none) rng_none=yes
1661b767d257SMarek Marczykowski-Górecki  ;;
1662b767d257SMarek Marczykowski-Górecki  --disable-rng-none) rng_none=no
1663b767d257SMarek Marczykowski-Górecki  ;;
166454e7aac0SAlexey Krasikov  --enable-keyring) secret_keyring="yes"
166554e7aac0SAlexey Krasikov  ;;
166654e7aac0SAlexey Krasikov  --disable-keyring) secret_keyring="no"
166754e7aac0SAlexey Krasikov  ;;
166821b2eca6SJingqi Liu  --enable-libdaxctl) libdaxctl=yes
166921b2eca6SJingqi Liu  ;;
167021b2eca6SJingqi Liu  --disable-libdaxctl) libdaxctl=no
167121b2eca6SJingqi Liu  ;;
16722d2ad6d0SFam Zheng  *)
16732d2ad6d0SFam Zheng      echo "ERROR: unknown option $opt"
16742d2ad6d0SFam Zheng      echo "Try '$0 --help' for more information"
16752d2ad6d0SFam Zheng      exit 1
16767f1559c6Sbalrog  ;;
16777d13299dSbellard  esac
16787d13299dSbellarddone
16797d13299dSbellard
168022a87800SMarc-André Lureaulibdir="${libdir:-$prefix/lib}"
168122a87800SMarc-André Lureaulibexecdir="${libexecdir:-$prefix/libexec}"
168222a87800SMarc-André Lureauincludedir="${includedir:-$prefix/include}"
168322a87800SMarc-André Lureau
168422a87800SMarc-André Lureauif test "$mingw32" = "yes" ; then
168522a87800SMarc-André Lureau    mandir="$prefix"
168622a87800SMarc-André Lureau    datadir="$prefix"
168722a87800SMarc-André Lureau    qemu_docdir="$prefix"
168822a87800SMarc-André Lureau    bindir="$prefix"
168922a87800SMarc-André Lureau    sysconfdir="$prefix"
169022a87800SMarc-André Lureau    local_statedir=
169122a87800SMarc-André Lureauelse
169222a87800SMarc-André Lureau    mandir="${mandir:-$prefix/share/man}"
169322a87800SMarc-André Lureau    datadir="${datadir:-$prefix/share}"
169422a87800SMarc-André Lureau    qemu_docdir="${qemu_docdir:-$prefix/share/doc/qemu}"
169522a87800SMarc-André Lureau    bindir="${bindir:-$prefix/bin}"
169622a87800SMarc-André Lureau    sysconfdir="${sysconfdir:-$prefix/etc}"
169722a87800SMarc-André Lureau    local_statedir="${local_statedir:-$prefix/var}"
169822a87800SMarc-André Lureaufi
169922a87800SMarc-André Lureau
170040293e58Sbellardcase "$cpu" in
1701e3608d66SRichard Henderson    ppc)
1702e3608d66SRichard Henderson           CPU_CFLAGS="-m32"
1703db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
1704e3608d66SRichard Henderson           ;;
1705e3608d66SRichard Henderson    ppc64)
1706e3608d66SRichard Henderson           CPU_CFLAGS="-m64"
1707db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1708e3608d66SRichard Henderson           ;;
17099b9c37c3SRichard Henderson    sparc)
1710f1079bb8SRichard Henderson           CPU_CFLAGS="-m32 -mv8plus -mcpu=ultrasparc"
1711db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 -mv8plus $QEMU_LDFLAGS"
17123142255cSblueswir1           ;;
1713ed968ff1SJuan Quintela    sparc64)
171479f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m64 -mcpu=ultrasparc"
1715db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
17163142255cSblueswir1           ;;
171776d83bdeSths    s390)
1718061cdd81SRichard Henderson           CPU_CFLAGS="-m31"
1719db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m31 $QEMU_LDFLAGS"
172028d7cc49SRichard Henderson           ;;
172128d7cc49SRichard Henderson    s390x)
1722061cdd81SRichard Henderson           CPU_CFLAGS="-m64"
1723db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
172476d83bdeSths           ;;
172540293e58Sbellard    i386)
172679f3b12fSPeter Crosthwaite           CPU_CFLAGS="-m32"
1727db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m32 $QEMU_LDFLAGS"
172840293e58Sbellard           ;;
172940293e58Sbellard    x86_64)
17307ebee43eSRichard Henderson           # ??? Only extremely old AMD cpus do not have cmpxchg16b.
17317ebee43eSRichard Henderson           # If we truly care, we should simply detect this case at
17327ebee43eSRichard Henderson           # runtime and generate the fallback to serial emulation.
17337ebee43eSRichard Henderson           CPU_CFLAGS="-m64 -mcx16"
1734db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-m64 $QEMU_LDFLAGS"
1735379f6698SPaul Brook           ;;
1736c72b26ecSRichard Henderson    x32)
1737c72b26ecSRichard Henderson           CPU_CFLAGS="-mx32"
1738db5adeaaSPaolo Bonzini           QEMU_LDFLAGS="-mx32 $QEMU_LDFLAGS"
1739c72b26ecSRichard Henderson           ;;
174030163d89SPeter Maydell    # No special flags required for other host CPUs
17413142255cSblueswir1esac
17423142255cSblueswir1
17432038f8c8SPaolo Bonzinieval "cross_cc_${cpu}=\$host_cc"
17442038f8c8SPaolo Bonzinicross_cc_vars="$cross_cc_vars cross_cc_${cpu}"
174579f3b12fSPeter CrosthwaiteQEMU_CFLAGS="$CPU_CFLAGS $QEMU_CFLAGS"
174679f3b12fSPeter Crosthwaite
1747affc88ccSPeter Maydell# For user-mode emulation the host arch has to be one we explicitly
1748affc88ccSPeter Maydell# support, even if we're using TCI.
1749affc88ccSPeter Maydellif [ "$ARCH" = "unknown" ]; then
1750affc88ccSPeter Maydell  bsd_user="no"
1751affc88ccSPeter Maydell  linux_user="no"
1752affc88ccSPeter Maydellfi
1753affc88ccSPeter Maydell
17541cf295beSPhilippe Mathieu-Daudéif [ "$bsd_user" = "no" -a "$linux_user" = "no" -a "$softmmu" = "no" ] ; then
17551cf295beSPhilippe Mathieu-Daudé  tcg="no"
17561cf295beSPhilippe Mathieu-Daudéfi
17571cf295beSPhilippe Mathieu-Daudé
175860e0df25SPeter Maydelldefault_target_list=""
175960e0df25SPeter Maydell
17606e92f823SPeter Maydellmak_wilds=""
17616e92f823SPeter Maydell
176260e0df25SPeter Maydellif [ "$softmmu" = "yes" ]; then
17636e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-softmmu.mak"
176460e0df25SPeter Maydellfi
176560e0df25SPeter Maydellif [ "$linux_user" = "yes" ]; then
17666e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-linux-user.mak"
176760e0df25SPeter Maydellfi
176860e0df25SPeter Maydellif [ "$bsd_user" = "yes" ]; then
17696e92f823SPeter Maydell    mak_wilds="${mak_wilds} $source_path/default-configs/*-bsd-user.mak"
177060e0df25SPeter Maydellfi
177160e0df25SPeter Maydell
1772447e133fSAlex Bennéeif test -z "$target_list_exclude"; then
17736e92f823SPeter Maydell    for config in $mak_wilds; do
17746e92f823SPeter Maydell        default_target_list="${default_target_list} $(basename "$config" .mak)"
17756e92f823SPeter Maydell    done
1776447e133fSAlex Bennéeelse
1777447e133fSAlex Bennée    exclude_list=$(echo "$target_list_exclude" | sed -e 's/,/ /g')
1778447e133fSAlex Bennée    for config in $mak_wilds; do
1779447e133fSAlex Bennée        target="$(basename "$config" .mak)"
1780447e133fSAlex Bennée        exclude="no"
1781447e133fSAlex Bennée        for excl in $exclude_list; do
1782447e133fSAlex Bennée            if test "$excl" = "$target"; then
1783447e133fSAlex Bennée                exclude="yes"
1784447e133fSAlex Bennée                break;
1785447e133fSAlex Bennée            fi
1786447e133fSAlex Bennée        done
1787447e133fSAlex Bennée        if test "$exclude" = "no"; then
1788447e133fSAlex Bennée            default_target_list="${default_target_list} $target"
1789447e133fSAlex Bennée        fi
1790447e133fSAlex Bennée    done
1791447e133fSAlex Bennéefi
17926e92f823SPeter Maydell
1793c53eeaf7SStefan Hajnoczi# Enumerate public trace backends for --help output
179464a6047dSGreg Kurztrace_backend_list=$(echo $(grep -le '^PUBLIC = True$' "$source_path"/scripts/tracetool/backend/*.py | sed -e 's/^.*\/\(.*\)\.py$/\1/'))
1795c53eeaf7SStefan Hajnoczi
1796af5db58eSpbrookif test x"$show_help" = x"yes" ; then
1797af5db58eSpbrookcat << EOF
1798af5db58eSpbrook
1799af5db58eSpbrookUsage: configure [options]
1800af5db58eSpbrookOptions: [defaults in brackets after descriptions]
1801af5db58eSpbrook
180208fb77edSStefan WeilStandard options:
180308fb77edSStefan Weil  --help                   print this message
180408fb77edSStefan Weil  --prefix=PREFIX          install in PREFIX [$prefix]
180508fb77edSStefan Weil  --interp-prefix=PREFIX   where to find shared libraries, etc.
180608fb77edSStefan Weil                           use %M for cpu name [$interp_prefix]
180708fb77edSStefan Weil  --target-list=LIST       set target list (default: build everything)
180808fb77edSStefan Weil$(echo Available targets: $default_target_list | \
180908fb77edSStefan Weil  fold -s -w 53 | sed -e 's/^/                           /')
1810447e133fSAlex Bennée  --target-list-exclude=LIST exclude a set of targets from the default target-list
181108fb77edSStefan Weil
181208fb77edSStefan WeilAdvanced options (experts only):
181308fb77edSStefan Weil  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]
181408fb77edSStefan Weil  --cc=CC                  use C compiler CC [$cc]
181508fb77edSStefan Weil  --iasl=IASL              use ACPI compiler IASL [$iasl]
181608fb77edSStefan Weil  --host-cc=CC             use C compiler CC [$host_cc] for code run at
181708fb77edSStefan Weil                           build time
181808fb77edSStefan Weil  --cxx=CXX                use C++ compiler CXX [$cxx]
181908fb77edSStefan Weil  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]
182008fb77edSStefan Weil  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS
182111cde1c8SBruno Dominguez  --extra-cxxflags=CXXFLAGS append extra C++ compiler flags QEMU_CXXFLAGS
182208fb77edSStefan Weil  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS
1823d75402b5SAlex Bennée  --cross-cc-ARCH=CC       use compiler when building ARCH guest test cases
1824d422b2bcSAlex Bennée  --cross-cc-flags-ARCH=   use compiler flags when building ARCH guest tests
182508fb77edSStefan Weil  --make=MAKE              use specified make [$make]
182608fb77edSStefan Weil  --install=INSTALL        use specified install [$install]
182708fb77edSStefan Weil  --python=PYTHON          use specified python [$python]
18282eb054c2SPeter Maydell  --sphinx-build=SPHINX    use specified sphinx-build [$sphinx_build]
1829a5665051SPaolo Bonzini  --meson=MESON            use specified meson [$meson]
183048328880SPaolo Bonzini  --ninja=NINJA            use specified ninja [$ninja]
183108fb77edSStefan Weil  --smbd=SMBD              use specified smbd [$smbd]
1832db1b5f13SThomas Huth  --with-git=GIT           use specified git [$git]
183308fb77edSStefan Weil  --static                 enable static build [$static]
183408fb77edSStefan Weil  --mandir=PATH            install man pages in PATH
183508fb77edSStefan Weil  --datadir=PATH           install firmware in PATH$confsuffix
183608fb77edSStefan Weil  --docdir=PATH            install documentation in PATH$confsuffix
183708fb77edSStefan Weil  --bindir=PATH            install binaries in PATH
183808fb77edSStefan Weil  --libdir=PATH            install libraries in PATH
1839db1b5f13SThomas Huth  --libexecdir=PATH        install helper binaries in PATH
184008fb77edSStefan Weil  --sysconfdir=PATH        install config in PATH$confsuffix
184108fb77edSStefan Weil  --localstatedir=PATH     install local state in PATH (set at runtime on win32)
18423d5eecabSGerd Hoffmann  --firmwarepath=PATH      search PATH for firmware files
184313336606SRobert Foley  --efi-aarch64=PATH       PATH of efi file to use for aarch64 VMs.
1844e26110cfSFam Zheng  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
1845db1b5f13SThomas Huth  --with-pkgversion=VERS   use specified string as sub-version of the package
184608fb77edSStefan Weil  --enable-debug           enable common debug build options
1847247724cbSMarc-André Lureau  --enable-sanitizers      enable default sanitizers
18480aebab04SLingfeng Yang  --enable-tsan            enable thread sanitizer
184908fb77edSStefan Weil  --disable-strip          disable stripping binaries
185008fb77edSStefan Weil  --disable-werror         disable compilation abort on warning
185163678e17SSteven Noonan  --disable-stack-protector disable compiler-provided stack protection
185208fb77edSStefan Weil  --audio-drv-list=LIST    set audio drivers list:
185308fb77edSStefan Weil                           Available drivers: $audio_possible_drivers
185408fb77edSStefan Weil  --block-drv-whitelist=L  Same as --block-drv-rw-whitelist=L
185508fb77edSStefan Weil  --block-drv-rw-whitelist=L
185608fb77edSStefan Weil                           set block driver read-write whitelist
185708fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
185808fb77edSStefan Weil  --block-drv-ro-whitelist=L
185908fb77edSStefan Weil                           set block driver read-only whitelist
186008fb77edSStefan Weil                           (affects only QEMU, not qemu-img)
18615b808275SLluís Vilanova  --enable-trace-backends=B Set trace backend
1862c53eeaf7SStefan Hajnoczi                           Available backends: $trace_backend_list
186308fb77edSStefan Weil  --with-trace-file=NAME   Full PATH,NAME of file to store traces
186408fb77edSStefan Weil                           Default:trace-<pid>
1865c23f23b9SMichael Tokarev  --disable-slirp          disable SLIRP userspace network connectivity
1866c23f23b9SMichael Tokarev  --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
18675a22ab71SYang Zhong  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
1868c23f23b9SMichael Tokarev  --oss-lib                path to OSS library
1869c23f23b9SMichael Tokarev  --cpu=CPU                Build for host CPU [$cpu]
187008fb77edSStefan Weil  --with-coroutine=BACKEND coroutine backend. Supported options:
187133c53c54SDaniel P. Berrange                           ucontext, sigaltstack, windows
187208fb77edSStefan Weil  --enable-gcov            enable test coverage analysis with gcov
1873c23f23b9SMichael Tokarev  --disable-blobs          disable installing provided firmware blobs
1874c23f23b9SMichael Tokarev  --with-vss-sdk=SDK-path  enable Windows VSS support in QEMU Guest Agent
1875c23f23b9SMichael Tokarev  --with-win-sdk=SDK-path  path to Windows Platform SDK (to build VSS .tlb)
1876a1c5e949SDaniel P. Berrange  --tls-priority           default TLS protocol/cipher priority string
1877c12d66aaSLin Ma  --enable-gprof           QEMU profiling with gprof
1878c12d66aaSLin Ma  --enable-profiler        profiler support
1879c12d66aaSLin Ma  --enable-debug-stack-usage
1880c12d66aaSLin Ma                           track the maximum stack usage of stacks created by qemu_alloc_stack
188140e8c6f4SAlex Bennée  --enable-plugins
188240e8c6f4SAlex Bennée                           enable plugins via shared library loading
1883afc3a8f9SAlex Bennée  --disable-containers     don't use containers for cross-building
1884f48e590aSAlex Bennée  --gdb=GDB-path           gdb to use for gdbstub tests [$gdb_bin]
1885c23f23b9SMichael Tokarev
1886c23f23b9SMichael TokarevOptional features, enabled with --enable-FEATURE and
1887c23f23b9SMichael Tokarevdisabled with --disable-FEATURE, default is enabled if available:
1888c23f23b9SMichael Tokarev
1889c23f23b9SMichael Tokarev  system          all system emulation targets
1890c23f23b9SMichael Tokarev  user            supported user emulation targets
1891c23f23b9SMichael Tokarev  linux-user      all linux usermode emulation targets
1892c23f23b9SMichael Tokarev  bsd-user        all BSD usermode emulation targets
1893c23f23b9SMichael Tokarev  docs            build documentation
1894c23f23b9SMichael Tokarev  guest-agent     build the QEMU Guest Agent
1895c23f23b9SMichael Tokarev  guest-agent-msi build guest agent Windows MSI installation package
1896c23f23b9SMichael Tokarev  pie             Position Independent Executables
189721e709aaSMarc-André Lureau  modules         modules support (non-Windows)
1898bd83c861SChristian Ehrhardt  module-upgrades try to load modules from alternate paths for upgrades
1899c23f23b9SMichael Tokarev  debug-tcg       TCG debugging (default is disabled)
1900c23f23b9SMichael Tokarev  debug-info      debugging information
1901c23f23b9SMichael Tokarev  sparse          sparse checker
19021e4f6065SDaniele Buono  safe-stack      SafeStack Stack Smash Protection. Depends on
19031e4f6065SDaniele Buono                  clang/llvm >= 3.7 and requires coroutine backend ucontext.
1904c23f23b9SMichael Tokarev
1905ddbb0d09SDaniel P. Berrange  gnutls          GNUTLS cryptography support
190691bfcdb0SDaniel P. Berrange  nettle          nettle cryptography support
190791bfcdb0SDaniel P. Berrange  gcrypt          libgcrypt cryptography support
19088953caf3SDaniel P. Berrange  auth-pam        PAM access control
1909c23f23b9SMichael Tokarev  sdl             SDL UI
191004c6e16fSMarkus Armbruster  sdl-image       SDL Image support for icons
1911c23f23b9SMichael Tokarev  gtk             gtk UI
1912c23f23b9SMichael Tokarev  vte             vte support for the gtk UI
1913c23f23b9SMichael Tokarev  curses          curses UI
1914e08bb301SSamuel Thibault  iconv           font glyph conversion support
1915c23f23b9SMichael Tokarev  vnc             VNC UI support
1916c23f23b9SMichael Tokarev  vnc-sasl        SASL encryption for VNC server
1917c23f23b9SMichael Tokarev  vnc-jpeg        JPEG lossy compression for VNC server
1918c23f23b9SMichael Tokarev  vnc-png         PNG compression for VNC server
1919c23f23b9SMichael Tokarev  cocoa           Cocoa UI (Mac OS X only)
1920c23f23b9SMichael Tokarev  virtfs          VirtFS
1921fe8fc5aeSPaolo Bonzini  mpath           Multipath persistent reservation passthrough
1922c23f23b9SMichael Tokarev  xen             xen backend driver support
192370c292afSAnthony PERARD  xen-pci-passthrough    PCI passthrough support for Xen
1924c23f23b9SMichael Tokarev  brlapi          BrlAPI (Braile)
1925c23f23b9SMichael Tokarev  curl            curl connectivity
1926a40161cbSPaolo Bonzini  membarrier      membarrier system call (for Linux 4.14+ or Windows)
1927c23f23b9SMichael Tokarev  fdt             fdt device tree
1928c23f23b9SMichael Tokarev  kvm             KVM acceleration support
1929b0cb0a66SVincent Palatin  hax             HAX acceleration support
1930c97d6d2cSSergio Andres Gomez Del Real  hvf             Hypervisor.framework acceleration support
1931d661d9a4SJustin Terry (VM)  whpx            Windows Hypervisor Platform acceleration support
193221ab34c9SMarcel Apfelbaum  rdma            Enable RDMA-based migration
193321ab34c9SMarcel Apfelbaum  pvrdma          Enable PVRDMA support
1934c23f23b9SMichael Tokarev  vde             support for vde network
1935c23f23b9SMichael Tokarev  netmap          support for netmap network
1936c23f23b9SMichael Tokarev  linux-aio       Linux AIO support
1937c10dd856SAarushi Mehta  linux-io-uring  Linux io_uring support
1938c23f23b9SMichael Tokarev  cap-ng          libcap-ng support
1939c23f23b9SMichael Tokarev  attr            attr and xattr support
1940299e6f19SPaolo Bonzini  vhost-net       vhost-net kernel acceleration support
1941299e6f19SPaolo Bonzini  vhost-vsock     virtio sockets device support
1942299e6f19SPaolo Bonzini  vhost-scsi      vhost-scsi kernel target support
1943299e6f19SPaolo Bonzini  vhost-crypto    vhost-user-crypto backend support
1944299e6f19SPaolo Bonzini  vhost-kernel    vhost kernel backend support
1945299e6f19SPaolo Bonzini  vhost-user      vhost-user backend support
1946108a6481SCindy Lu  vhost-vdpa      vhost-vdpa kernel backend support
1947c23f23b9SMichael Tokarev  spice           spice
1948c23f23b9SMichael Tokarev  rbd             rados block device (rbd)
1949c23f23b9SMichael Tokarev  libiscsi        iscsi support
1950c23f23b9SMichael Tokarev  libnfs          nfs support
19517b02f544SMarc-André Lureau  smartcard       smartcard support (libcacard)
19520a40bcb7SCésar Belley  u2f             U2F support (u2f-emu)
1953c23f23b9SMichael Tokarev  libusb          libusb (for usb passthrough)
1954ed1701c6SDr. David Alan Gilbert  live-block-migration   Block migration in the main migration stream
1955c23f23b9SMichael Tokarev  usb-redir       usb network redirection support
1956c23f23b9SMichael Tokarev  lzo             support of lzo compression library
1957c23f23b9SMichael Tokarev  snappy          support of snappy compression library
1958c23f23b9SMichael Tokarev  bzip2           support of bzip2 compression library
1959c23f23b9SMichael Tokarev                  (for reading bzip2-compressed dmg images)
196083bc1f97SJulio Faracco  lzfse           support of lzfse compression library
196183bc1f97SJulio Faracco                  (for reading lzfse-compressed dmg images)
19623a678481SJuan Quintela  zstd            support for zstd compression library
1963d298ac10SDenis Plotnikov                  (for migration compression and qcow2 cluster compression)
1964c23f23b9SMichael Tokarev  seccomp         seccomp support
1965c23f23b9SMichael Tokarev  coroutine-pool  coroutine freelist (better performance)
1966c23f23b9SMichael Tokarev  glusterfs       GlusterFS backend
1967c23f23b9SMichael Tokarev  tpm             TPM support
1968b10d49d7SPino Toscano  libssh          ssh block device support
1969c23f23b9SMichael Tokarev  numa            libnuma support
1970ed279a06SKlim Kireev  libxml2         for Parallels image format
1971c23f23b9SMichael Tokarev  tcmalloc        tcmalloc support
19727b01cb97SAlexandre Derumier  jemalloc        jemalloc support
197386583a07SLiam Merwick  avx2            AVX2 optimization support
19746b8cd447SRobert Hoo  avx512f         AVX512F optimization support
1975a6b1d4c0SChanglong Xie  replication     replication support
1976c12d66aaSLin Ma  opengl          opengl support
1977c12d66aaSLin Ma  virglrenderer   virgl rendering support
1978c12d66aaSLin Ma  xfsctl          xfsctl support
1979c12d66aaSLin Ma  qom-cast-debug  cast debugging support
19808de73fa8SCleber Rosa  tools           build qemu-io, qemu-nbd and qemu-img tools
19812f740136SJeff Cody  bochs           bochs image format support
19822f740136SJeff Cody  cloop           cloop image format support
19832f740136SJeff Cody  dmg             dmg image format support
19842f740136SJeff Cody  qcow1           qcow v1 image format support
19852f740136SJeff Cody  vdi             vdi image format support
19862f740136SJeff Cody  vvfat           vvfat image format support
19872f740136SJeff Cody  qed             qed image format support
19882f740136SJeff Cody  parallels       parallels image format support
19892f740136SJeff Cody  sheepdog        sheepdog block driver support
1990f0d92b56SLongpeng(Mike)  crypto-afalg    Linux AF_ALG crypto backend driver
19918ca80760SRichard Henderson  capstone        capstone disassembler support
1992ba59fb77SPaolo Bonzini  debug-mutex     mutex debugging support
199317824406SJunyan He  libpmem         libpmem support
199475411919SJames Le Cuirot  xkbcommon       xkbcommon support
1995b767d257SMarek Marczykowski-Górecki  rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
199621b2eca6SJingqi Liu  libdaxctl       libdaxctl support
199708fb77edSStefan Weil
199808fb77edSStefan WeilNOTE: The object files are built at the place where configure is launched
1999af5db58eSpbrookEOF
20002d2ad6d0SFam Zhengexit 0
2001af5db58eSpbrookfi
2002af5db58eSpbrook
20039c790242SThomas Huth# Remove old dependency files to make sure that they get properly regenerated
2004bb768f71SThomas Huthrm -f */config-devices.mak.d
20059c790242SThomas Huth
2006faf44142SDaniel P. Berrangéif test -z "$python"
2007faf44142SDaniel P. Berrangéthen
2008c53eeaf7SStefan Hajnoczi    error_exit "Python not found. Use --python=/path/to/python"
2009c53eeaf7SStefan Hajnoczifi
2010c53eeaf7SStefan Hajnoczi
2011c53eeaf7SStefan Hajnoczi# Note that if the Python conditional here evaluates True we will exit
2012c53eeaf7SStefan Hajnoczi# with status 1 which is a shell 'false' value.
2013ddf90699SEduardo Habkostif ! $python -c 'import sys; sys.exit(sys.version_info < (3,5))'; then
2014ddf90699SEduardo Habkost  error_exit "Cannot use '$python', Python >= 3.5 is required." \
2015c53eeaf7SStefan Hajnoczi      "Use --python=/path/to/python to specify a supported Python."
2016c53eeaf7SStefan Hajnoczifi
2017c53eeaf7SStefan Hajnoczi
2018755ee70fSCleber Rosa# Preserve python version since some functionality is dependent on it
2019406ab2f3SCleber 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)
2020755ee70fSCleber Rosa
2021c53eeaf7SStefan Hajnoczi# Suppress writing compiled files
2022c53eeaf7SStefan Hajnoczipython="$python -B"
2023c53eeaf7SStefan Hajnoczi
20240a01d76fSMarc-André Lureauif test -z "$meson"; then
202546504430SPaolo Bonzini    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.1; then
20260a01d76fSMarc-André Lureau        meson=meson
20270a01d76fSMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
20280a01d76fSMarc-André Lureau        meson=git
20290a01d76fSMarc-André Lureau    elif test -e "${source_path}/meson/meson.py" ; then
20300a01d76fSMarc-André Lureau        meson=internal
20310a01d76fSMarc-André Lureau    else
20320a01d76fSMarc-André Lureau        if test "$explicit_python" = yes; then
20330a01d76fSMarc-André Lureau            error_exit "--python requires using QEMU's embedded Meson distribution, but it was not found."
20340a01d76fSMarc-André Lureau        else
2035a5665051SPaolo Bonzini            error_exit "Meson not found.  Use --meson=/path/to/meson"
2036a5665051SPaolo Bonzini        fi
20370a01d76fSMarc-André Lureau    fi
20380a01d76fSMarc-André Lureauelse
20390a01d76fSMarc-André Lureau    # Meson uses its own Python interpreter to invoke other Python scripts,
20400a01d76fSMarc-André Lureau    # but the user wants to use the one they specified with --python.
20410a01d76fSMarc-André Lureau    #
20420a01d76fSMarc-André Lureau    # We do not want to override the distro Python interpreter (and sometimes
20430a01d76fSMarc-André Lureau    # cannot: for example in Homebrew /usr/bin/meson is a bash script), so
20440a01d76fSMarc-André Lureau    # just require --meson=git|internal together with --python.
20450a01d76fSMarc-André Lureau    if test "$explicit_python" = yes; then
20460a01d76fSMarc-André Lureau        case "$meson" in
20470a01d76fSMarc-André Lureau            git | internal) ;;
20480a01d76fSMarc-André Lureau            *) error_exit "--python requires using QEMU's embedded Meson distribution." ;;
20490a01d76fSMarc-André Lureau        esac
20500a01d76fSMarc-André Lureau    fi
20510a01d76fSMarc-André Lureaufi
2052a5665051SPaolo Bonzini
20530a01d76fSMarc-André Lureauif test "$meson" = git; then
20540a01d76fSMarc-André Lureau    git_submodules="${git_submodules} meson"
20550a01d76fSMarc-André Lureaufi
20560a01d76fSMarc-André Lureauif test "$git_update" = yes; then
20570a01d76fSMarc-André Lureau    (cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
20580a01d76fSMarc-André Lureaufi
20590a01d76fSMarc-André Lureau
20600a01d76fSMarc-André Lureaucase "$meson" in
20610a01d76fSMarc-André Lureau    git | internal)
2062a5665051SPaolo Bonzini        if ! $python -c 'import pkg_resources' > /dev/null 2>&1; then
2063a5665051SPaolo Bonzini            error_exit "Python setuptools not found"
2064a5665051SPaolo Bonzini        fi
20650a01d76fSMarc-André Lureau        meson="$python ${source_path}/meson/meson.py"
20660a01d76fSMarc-André Lureau        ;;
20670a01d76fSMarc-André Lureau    *) meson=$(command -v meson) ;;
20680a01d76fSMarc-André Lureauesac
20690a01d76fSMarc-André Lureau
207048328880SPaolo Bonzini# Probe for ninja (used for compdb)
207148328880SPaolo Bonzini
207248328880SPaolo Bonziniif test -z "$ninja"; then
207348328880SPaolo Bonzini    for c in ninja ninja-build samu; do
207448328880SPaolo Bonzini        if has $c; then
207548328880SPaolo Bonzini            ninja=$(command -v "$c")
207648328880SPaolo Bonzini            break
207748328880SPaolo Bonzini        fi
207848328880SPaolo Bonzini    done
207948328880SPaolo Bonzinifi
2080a5665051SPaolo Bonzini
20819aae6e54SDaniel Henrique Barboza# Check that the C compiler works. Doing this here before testing
20829aae6e54SDaniel Henrique Barboza# the host CPU ensures that we had a valid CC to autodetect the
20839aae6e54SDaniel Henrique Barboza# $cpu var (and we should bail right here if that's not the case).
20849aae6e54SDaniel Henrique Barboza# It also allows the help message to be printed without a CC.
20859aae6e54SDaniel Henrique Barbozawrite_c_skeleton;
20869aae6e54SDaniel Henrique Barbozaif compile_object ; then
20879aae6e54SDaniel Henrique Barboza  : C compiler works ok
20889aae6e54SDaniel Henrique Barbozaelse
20899aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" either does not exist or does not work"
20909aae6e54SDaniel Henrique Barbozafi
20919aae6e54SDaniel Henrique Barbozaif ! compile_prog ; then
20929aae6e54SDaniel Henrique Barboza    error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
20939aae6e54SDaniel Henrique Barbozafi
20949aae6e54SDaniel Henrique Barboza
2095359bc95dSPeter Maydell# Now we have handled --enable-tcg-interpreter and know we're not just
2096359bc95dSPeter Maydell# printing the help message, bail out if the host CPU isn't supported.
2097359bc95dSPeter Maydellif test "$ARCH" = "unknown"; then
2098359bc95dSPeter Maydell    if test "$tcg_interpreter" = "yes" ; then
2099359bc95dSPeter Maydell        echo "Unsupported CPU = $cpu, will use TCG with TCI (experimental)"
2100359bc95dSPeter Maydell    else
210176ad07a4SPeter Maydell        error_exit "Unsupported CPU = $cpu, try --enable-tcg-interpreter"
2102359bc95dSPeter Maydell    fi
2103359bc95dSPeter Maydellfi
2104359bc95dSPeter Maydell
21059c83ffd8SPeter Maydell# Consult white-list to determine whether to enable werror
21069c83ffd8SPeter Maydell# by default.  Only enable by default for git builds
21079c83ffd8SPeter Maydellif test -z "$werror" ; then
2108fd73745dSAlexey Kardashevskiy    if test -e "$source_path/.git" && \
2109e633a5c6SEric Blake        { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
21109c83ffd8SPeter Maydell        werror="yes"
21119c83ffd8SPeter Maydell    else
21129c83ffd8SPeter Maydell        werror="no"
21139c83ffd8SPeter Maydell    fi
21149c83ffd8SPeter Maydellfi
21159c83ffd8SPeter Maydell
2116fb59dabdSPeter Maydellif test "$bogus_os" = "yes"; then
2117fb59dabdSPeter Maydell    # Now that we know that we're not printing the help and that
2118fb59dabdSPeter Maydell    # the compiler works (so the results of the check_defines we used
2119fb59dabdSPeter Maydell    # to identify the OS are reliable), if we didn't recognize the
2120fb59dabdSPeter Maydell    # host OS we should stop now.
2121951fedfcSPeter Maydell    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
2122fb59dabdSPeter Maydellfi
2123fb59dabdSPeter Maydell
2124efc6c070SThomas Huth# Check whether the compiler matches our minimum requirements:
2125efc6c070SThomas Huthcat > $TMPC << EOF
2126efc6c070SThomas Huth#if defined(__clang_major__) && defined(__clang_minor__)
2127efc6c070SThomas Huth# ifdef __apple_build_version__
2128efc6c070SThomas Huth#  if __clang_major__ < 5 || (__clang_major__ == 5 && __clang_minor__ < 1)
2129efc6c070SThomas Huth#   error You need at least XCode Clang v5.1 to compile QEMU
2130efc6c070SThomas Huth#  endif
2131efc6c070SThomas Huth# else
2132efc6c070SThomas Huth#  if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
2133efc6c070SThomas Huth#   error You need at least Clang v3.4 to compile QEMU
2134efc6c070SThomas Huth#  endif
2135efc6c070SThomas Huth# endif
2136efc6c070SThomas Huth#elif defined(__GNUC__) && defined(__GNUC_MINOR__)
2137efc6c070SThomas Huth# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
2138efc6c070SThomas Huth#  error You need at least GCC v4.8 to compile QEMU
2139efc6c070SThomas Huth# endif
2140efc6c070SThomas Huth#else
2141efc6c070SThomas Huth# error You either need GCC or Clang to compiler QEMU
2142efc6c070SThomas Huth#endif
2143efc6c070SThomas Huthint main (void) { return 0; }
2144efc6c070SThomas HuthEOF
2145efc6c070SThomas Huthif ! compile_prog "" "" ; then
2146efc6c070SThomas Huth    error_exit "You need at least GCC v4.8 or Clang v3.4 (or XCode Clang v5.1)"
2147efc6c070SThomas Huthfi
2148efc6c070SThomas Huth
214900849b92SRichard Henderson# Accumulate -Wfoo and -Wno-bar separately.
215000849b92SRichard Henderson# We will list all of the enable flags first, and the disable flags second.
215100849b92SRichard Henderson# Note that we do not add -Werror, because that would enable it for all
215200849b92SRichard Henderson# configure tests. If a configure test failed due to -Werror this would
215300849b92SRichard Henderson# just silently disable some features, so it's too error prone.
215400849b92SRichard Henderson
215500849b92SRichard Hendersonwarn_flags=
215600849b92SRichard Hendersonadd_to warn_flags -Wold-style-declaration
215700849b92SRichard Hendersonadd_to warn_flags -Wold-style-definition
215800849b92SRichard Hendersonadd_to warn_flags -Wtype-limits
215900849b92SRichard Hendersonadd_to warn_flags -Wformat-security
216000849b92SRichard Hendersonadd_to warn_flags -Wformat-y2k
216100849b92SRichard Hendersonadd_to warn_flags -Winit-self
216200849b92SRichard Hendersonadd_to warn_flags -Wignored-qualifiers
216300849b92SRichard Hendersonadd_to warn_flags -Wempty-body
216400849b92SRichard Hendersonadd_to warn_flags -Wnested-externs
216500849b92SRichard Hendersonadd_to warn_flags -Wendif-labels
216600849b92SRichard Hendersonadd_to warn_flags -Wexpansion-to-defined
216700849b92SRichard Henderson
216800849b92SRichard Hendersonnowarn_flags=
216900849b92SRichard Hendersonadd_to nowarn_flags -Wno-initializer-overrides
217000849b92SRichard Hendersonadd_to nowarn_flags -Wno-missing-include-dirs
217100849b92SRichard Hendersonadd_to nowarn_flags -Wno-shift-negative-value
217200849b92SRichard Hendersonadd_to nowarn_flags -Wno-string-plus-int
217300849b92SRichard Hendersonadd_to nowarn_flags -Wno-typedef-redefinition
2174aabab967SRichard Hendersonadd_to nowarn_flags -Wno-tautological-type-limit-compare
2175bac8d222SRichard Hendersonadd_to nowarn_flags -Wno-psabi
217600849b92SRichard Henderson
217700849b92SRichard Hendersongcc_flags="$warn_flags $nowarn_flags"
217893b25869SJohn Snow
217993b25869SJohn Snowcc_has_warning_flag() {
218093b25869SJohn Snow    write_c_skeleton;
218193b25869SJohn Snow
2182a1d29d6cSPeter Maydell    # Use the positive sense of the flag when testing for -Wno-wombat
2183a1d29d6cSPeter Maydell    # support (gcc will happily accept the -Wno- form of unknown
2184a1d29d6cSPeter Maydell    # warning options).
218593b25869SJohn Snow    optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')"
218693b25869SJohn Snow    compile_prog "-Werror $optflag" ""
218793b25869SJohn Snow}
218893b25869SJohn Snow
218993b25869SJohn Snowfor flag in $gcc_flags; do
219093b25869SJohn Snow    if cc_has_warning_flag $flag ; then
21918d05095cSPaolo Bonzini        QEMU_CFLAGS="$QEMU_CFLAGS $flag"
21928d05095cSPaolo Bonzini    fi
21938d05095cSPaolo Bonzinidone
21948d05095cSPaolo Bonzini
219563678e17SSteven Noonanif test "$stack_protector" != "no"; then
2196fccd35a0SRodrigo Rebello  cat > $TMPC << EOF
2197fccd35a0SRodrigo Rebelloint main(int argc, char *argv[])
2198fccd35a0SRodrigo Rebello{
2199fccd35a0SRodrigo Rebello    char arr[64], *p = arr, *c = argv[0];
2200fccd35a0SRodrigo Rebello    while (*c) {
2201fccd35a0SRodrigo Rebello        *p++ = *c++;
2202fccd35a0SRodrigo Rebello    }
2203fccd35a0SRodrigo Rebello    return 0;
2204fccd35a0SRodrigo Rebello}
2205fccd35a0SRodrigo RebelloEOF
220663678e17SSteven Noonan  gcc_flags="-fstack-protector-strong -fstack-protector-all"
22073b463a3fSMiroslav Rezanina  sp_on=0
220863678e17SSteven Noonan  for flag in $gcc_flags; do
2209590e5dd9SPeter Maydell    # We need to check both a compile and a link, since some compiler
2210590e5dd9SPeter Maydell    # setups fail only on a .c->.o compile and some only at link time
2211086d5f75SPaolo Bonzini    if compile_object "-Werror $flag" &&
2212590e5dd9SPeter Maydell       compile_prog "-Werror $flag" ""; then
221363678e17SSteven Noonan      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
2214db5adeaaSPaolo Bonzini      QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
22153b463a3fSMiroslav Rezanina      sp_on=1
221663678e17SSteven Noonan      break
221763678e17SSteven Noonan    fi
221863678e17SSteven Noonan  done
22193b463a3fSMiroslav Rezanina  if test "$stack_protector" = yes; then
22203b463a3fSMiroslav Rezanina    if test $sp_on = 0; then
22213b463a3fSMiroslav Rezanina      error_exit "Stack protector not supported"
22223b463a3fSMiroslav Rezanina    fi
22233b463a3fSMiroslav Rezanina  fi
222437746c5eSMarc-André Lureaufi
222537746c5eSMarc-André Lureau
222620bc94a2SPaolo Bonzini# Disable -Wmissing-braces on older compilers that warn even for
222720bc94a2SPaolo Bonzini# the "universal" C zero initializer {0}.
222820bc94a2SPaolo Bonzinicat > $TMPC << EOF
222920bc94a2SPaolo Bonzinistruct {
223020bc94a2SPaolo Bonzini  int a[2];
223120bc94a2SPaolo Bonzini} x = {0};
223220bc94a2SPaolo BonziniEOF
223320bc94a2SPaolo Bonziniif compile_object "-Werror" "" ; then
223420bc94a2SPaolo Bonzini  :
223520bc94a2SPaolo Bonzinielse
223620bc94a2SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -Wno-missing-braces"
223720bc94a2SPaolo Bonzinifi
223820bc94a2SPaolo Bonzini
223921e709aaSMarc-André Lureau# Our module code doesn't support Windows
224021e709aaSMarc-André Lureauif test "$modules" = "yes" && test "$mingw32" = "yes" ; then
224121e709aaSMarc-André Lureau  error_exit "Modules are not available for Windows"
224221e709aaSMarc-André Lureaufi
224321e709aaSMarc-André Lureau
2244bd83c861SChristian Ehrhardt# module_upgrades is only reasonable if modules are enabled
2245bd83c861SChristian Ehrhardtif test "$modules" = "no" && test "$module_upgrades" = "yes" ; then
2246bd83c861SChristian Ehrhardt  error_exit "Can't enable module-upgrades as Modules are not enabled"
2247bd83c861SChristian Ehrhardtfi
2248bd83c861SChristian Ehrhardt
2249d376e9deSThomas Huth# Static linking is not possible with modules or PIE
225040d6444eSAvi Kivityif test "$static" = "yes" ; then
2251aa0d1f44SPaolo Bonzini  if test "$modules" = "yes" ; then
2252aa0d1f44SPaolo Bonzini    error_exit "static and modules are mutually incompatible"
2253aa0d1f44SPaolo Bonzini  fi
225440d6444eSAvi Kivityfi
225540d6444eSAvi Kivity
2256768b7855SEmilio G. Cota# Unconditional check for compiler __thread support
2257768b7855SEmilio G. Cota  cat > $TMPC << EOF
2258768b7855SEmilio G. Cotastatic __thread int tls_var;
2259768b7855SEmilio G. Cotaint main(void) { return tls_var; }
2260768b7855SEmilio G. CotaEOF
2261768b7855SEmilio G. Cota
2262768b7855SEmilio G. Cotaif ! compile_prog "-Werror" "" ; then
2263768b7855SEmilio G. Cota    error_exit "Your compiler does not support the __thread specifier for " \
2264768b7855SEmilio G. Cota	"Thread-Local Storage (TLS). Please upgrade to a version that does."
2265768b7855SEmilio G. Cotafi
2266768b7855SEmilio G. Cota
226740d6444eSAvi Kivitycat > $TMPC << EOF
226821d4a791SAvi Kivity
226921d4a791SAvi Kivity#ifdef __linux__
227021d4a791SAvi Kivity#  define THREAD __thread
227121d4a791SAvi Kivity#else
227221d4a791SAvi Kivity#  define THREAD
227321d4a791SAvi Kivity#endif
227421d4a791SAvi Kivitystatic THREAD int tls_var;
227521d4a791SAvi Kivityint main(void) { return tls_var; }
227640d6444eSAvi KivityEOF
2277b2634124SRichard Henderson
2278b2634124SRichard Henderson# Check we support --no-pie first; we will need this for building ROMs.
2279412aeacdSAlex Bennéeif compile_prog "-Werror -fno-pie" "-no-pie"; then
2280412aeacdSAlex Bennée  CFLAGS_NOPIE="-fno-pie"
2281b2634124SRichard Henderson  LDFLAGS_NOPIE="-no-pie"
2282412aeacdSAlex Bennéefi
2283412aeacdSAlex Bennée
228412781462SRichard Hendersonif test "$static" = "yes"; then
2285eca7a8e6SRichard Henderson  if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then
2286086d5f75SPaolo Bonzini    CFLAGS="-fPIE -DPIE $CFLAGS"
228712781462SRichard Henderson    QEMU_LDFLAGS="-static-pie $QEMU_LDFLAGS"
228812781462SRichard Henderson    pie="yes"
228912781462SRichard Henderson  elif test "$pie" = "yes"; then
229012781462SRichard Henderson    error_exit "-static-pie not available due to missing toolchain support"
229112781462SRichard Henderson  else
229212781462SRichard Henderson    QEMU_LDFLAGS="-static $QEMU_LDFLAGS"
229312781462SRichard Henderson    pie="no"
229412781462SRichard Henderson  fi
229512781462SRichard Hendersonelif test "$pie" = "no"; then
2296086d5f75SPaolo Bonzini  CFLAGS="$CFLAGS_NOPIE $CFLAGS"
2297086d5f75SPaolo Bonzini  LDFLAGS="$LDFLAGS_NOPIE $LDFLAGS"
2298eca7a8e6SRichard Hendersonelif compile_prog "-Werror -fPIE -DPIE" "-pie"; then
2299086d5f75SPaolo Bonzini  CFLAGS="-fPIE -DPIE $CFLAGS"
2300086d5f75SPaolo Bonzini  LDFLAGS="-pie $LDFLAGS"
230140d6444eSAvi Kivity  pie="yes"
23022c674109SRichard Hendersonelif test "$pie" = "yes"; then
230376ad07a4SPeter Maydell  error_exit "PIE not available due to missing toolchain support"
230440d6444eSAvi Kivityelse
230540d6444eSAvi Kivity  echo "Disabling PIE due to missing toolchain support"
230640d6444eSAvi Kivity  pie="no"
230740d6444eSAvi Kivityfi
230840d6444eSAvi Kivity
2309e6cbd751SRichard Henderson# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
2310e6cbd751SRichard Henderson# The combination is known as "full relro", because .got.plt is read-only too.
2311e6cbd751SRichard Hendersonif compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
2312e6cbd751SRichard Henderson  QEMU_LDFLAGS="-Wl,-z,relro -Wl,-z,now $QEMU_LDFLAGS"
2313e6cbd751SRichard Hendersonfi
2314e6cbd751SRichard Henderson
231509dada40SPaolo Bonzini##########################################
231609dada40SPaolo Bonzini# __sync_fetch_and_and requires at least -march=i486. Many toolchains
231709dada40SPaolo Bonzini# use i686 as default anyway, but for those that don't, an explicit
231809dada40SPaolo Bonzini# specification is necessary
231909dada40SPaolo Bonzini
232009dada40SPaolo Bonziniif test "$cpu" = "i386"; then
232109dada40SPaolo Bonzini  cat > $TMPC << EOF
232209dada40SPaolo Bonzinistatic int sfaa(int *ptr)
232309dada40SPaolo Bonzini{
232409dada40SPaolo Bonzini  return __sync_fetch_and_and(ptr, 0);
232509dada40SPaolo Bonzini}
232609dada40SPaolo Bonzini
232709dada40SPaolo Bonziniint main(void)
232809dada40SPaolo Bonzini{
232909dada40SPaolo Bonzini  int val = 42;
23301405b629SStefan Weil  val = __sync_val_compare_and_swap(&val, 0, 1);
233109dada40SPaolo Bonzini  sfaa(&val);
233209dada40SPaolo Bonzini  return val;
233309dada40SPaolo Bonzini}
233409dada40SPaolo BonziniEOF
233509dada40SPaolo Bonzini  if ! compile_prog "" "" ; then
233609dada40SPaolo Bonzini    QEMU_CFLAGS="-march=i486 $QEMU_CFLAGS"
233709dada40SPaolo Bonzini  fi
233809dada40SPaolo Bonzinifi
233909dada40SPaolo Bonzini
234009dada40SPaolo Bonzini#########################################
2341ec530c81Sbellard# Solaris specific configure tool chain decisions
234209dada40SPaolo Bonzini
2343ec530c81Sbellardif test "$solaris" = "yes" ; then
23446792aa11SLoïc Minier  if has $install; then
23456792aa11SLoïc Minier    :
23466792aa11SLoïc Minier  else
234776ad07a4SPeter Maydell    error_exit "Solaris install program not found. Use --install=/usr/ucb/install or" \
234876ad07a4SPeter Maydell        "install fileutils from www.blastwave.org using pkg-get -i fileutils" \
234976ad07a4SPeter Maydell        "to get ginstall which is used by default (which lives in /opt/csw/bin)"
2350ec530c81Sbellard  fi
235189138857SStefan Weil  if test "$(path_of $install)" = "/usr/sbin/install" ; then
235276ad07a4SPeter Maydell    error_exit "Solaris /usr/sbin/install is not an appropriate install program." \
235376ad07a4SPeter Maydell        "try ginstall from the GNU fileutils available from www.blastwave.org" \
235476ad07a4SPeter Maydell        "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
2355ec530c81Sbellard  fi
23566792aa11SLoïc Minier  if has ar; then
23576792aa11SLoïc Minier    :
23586792aa11SLoïc Minier  else
2359ec530c81Sbellard    if test -f /usr/ccs/bin/ar ; then
236076ad07a4SPeter Maydell      error_exit "No path includes ar" \
236176ad07a4SPeter Maydell          "Add /usr/ccs/bin to your path and rerun configure"
2362ec530c81Sbellard    fi
236376ad07a4SPeter Maydell    error_exit "No path includes ar"
2364ec530c81Sbellard  fi
2365ec530c81Sbellardfi
2366ec530c81Sbellard
2367afb63ebdSStefan Weilif test -z "${target_list+xxx}" ; then
2368d880a3baSPaolo Bonzini    for target in $default_target_list; do
2369d880a3baSPaolo Bonzini        supported_target $target 2>/dev/null && \
2370d880a3baSPaolo Bonzini            target_list="$target_list $target"
2371d880a3baSPaolo Bonzini    done
2372d880a3baSPaolo Bonzini    target_list="${target_list# }"
2373121afa9eSAnthony Liguorielse
237489138857SStefan Weil    target_list=$(echo "$target_list" | sed -e 's/,/ /g')
2375d880a3baSPaolo Bonzini    for target in $target_list; do
237625b48338SPeter Maydell        # Check that we recognised the target name; this allows a more
237725b48338SPeter Maydell        # friendly error message than if we let it fall through.
237825b48338SPeter Maydell        case " $default_target_list " in
237925b48338SPeter Maydell            *" $target "*)
238025b48338SPeter Maydell                ;;
238125b48338SPeter Maydell            *)
238225b48338SPeter Maydell                error_exit "Unknown target name '$target'"
238325b48338SPeter Maydell                ;;
238425b48338SPeter Maydell        esac
2385d880a3baSPaolo Bonzini        supported_target $target || exit 1
238625b48338SPeter Maydell    done
2387d880a3baSPaolo Bonzinifi
238825b48338SPeter Maydell
2389f55fe278SPaolo Bonzini# see if system emulation was really requested
2390f55fe278SPaolo Bonzinicase " $target_list " in
2391f55fe278SPaolo Bonzini  *"-softmmu "*) softmmu=yes
2392f55fe278SPaolo Bonzini  ;;
2393f55fe278SPaolo Bonzini  *) softmmu=no
2394f55fe278SPaolo Bonzini  ;;
2395f55fe278SPaolo Bonziniesac
23965327cf48Sbellard
239705dfa22bSPhilippe Mathieu-Daudéfor target in $target_list; do
239805dfa22bSPhilippe Mathieu-Daudé  case "$target" in
239905dfa22bSPhilippe Mathieu-Daudé    arm-softmmu | aarch64-softmmu | i386-softmmu | x86_64-softmmu)
240005dfa22bSPhilippe Mathieu-Daudé      edk2_blobs="yes"
240105dfa22bSPhilippe Mathieu-Daudé      ;;
240205dfa22bSPhilippe Mathieu-Daudé  esac
240305dfa22bSPhilippe Mathieu-Daudédone
2404623ef637SPhilippe Mathieu-Daudé# The EDK2 binaries are compressed with bzip2
2405623ef637SPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" && ! has bzip2; then
2406623ef637SPhilippe Mathieu-Daudé  error_exit "The bzip2 program is required for building QEMU"
2407623ef637SPhilippe Mathieu-Daudéfi
240805dfa22bSPhilippe Mathieu-Daudé
2409249247c9SJuan Quintelafeature_not_found() {
2410249247c9SJuan Quintela  feature=$1
241121684af0SStewart Smith  remedy=$2
2412249247c9SJuan Quintela
241376ad07a4SPeter Maydell  error_exit "User requested feature $feature" \
241421684af0SStewart Smith      "configure was not able to find it." \
241521684af0SStewart Smith      "$remedy"
2416249247c9SJuan Quintela}
2417249247c9SJuan Quintela
24187d13299dSbellard# ---
24197d13299dSbellard# big/little endian test
24207d13299dSbellardcat > $TMPC << EOF
242161cc919fSMike Frysingershort big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, };
242261cc919fSMike Frysingershort little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, };
242361cc919fSMike Frysingerextern int foo(short *, short *);
242461cc919fSMike Frysingerint main(int argc, char *argv[]) {
242561cc919fSMike Frysinger    return foo(big_endian, little_endian);
24267d13299dSbellard}
24277d13299dSbellardEOF
24287d13299dSbellard
242961cc919fSMike Frysingerif compile_object ; then
243012f15c91SAlice Frosi    if strings -a $TMPO | grep -q BiGeNdIaN ; then
243161cc919fSMike Frysinger        bigendian="yes"
243212f15c91SAlice Frosi    elif strings -a $TMPO | grep -q LiTtLeEnDiAn ; then
243361cc919fSMike Frysinger        bigendian="no"
24347d13299dSbellard    else
24357d13299dSbellard        echo big/little test failed
24367d13299dSbellard    fi
24377d13299dSbellardelse
243861cc919fSMike Frysinger    echo big/little test failed
24397d13299dSbellardfi
24407d13299dSbellard
2441b0a47e79SJuan Quintela##########################################
2442e10ee3f5SPhilippe Mathieu-Daudé# system tools
2443e10ee3f5SPhilippe Mathieu-Daudéif test -z "$want_tools"; then
2444e10ee3f5SPhilippe Mathieu-Daudé    if test "$softmmu" = "no"; then
2445e10ee3f5SPhilippe Mathieu-Daudé        want_tools=no
2446e10ee3f5SPhilippe Mathieu-Daudé    else
2447e10ee3f5SPhilippe Mathieu-Daudé        want_tools=yes
2448e10ee3f5SPhilippe Mathieu-Daudé    fi
2449e10ee3f5SPhilippe Mathieu-Daudéfi
2450e10ee3f5SPhilippe Mathieu-Daudé
2451e10ee3f5SPhilippe Mathieu-Daudé##########################################
2452a30878e7SPeter Maydell# cocoa implies not SDL or GTK
2453a30878e7SPeter Maydell# (the cocoa UI code currently assumes it is always the active UI
2454a30878e7SPeter Maydell# and doesn't interact well with other UI frontend code)
2455a30878e7SPeter Maydellif test "$cocoa" = "yes"; then
2456a30878e7SPeter Maydell    if test "$sdl" = "yes"; then
2457a30878e7SPeter Maydell        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
2458a30878e7SPeter Maydell    fi
2459a30878e7SPeter Maydell    if test "$gtk" = "yes"; then
2460a30878e7SPeter Maydell        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
2461a30878e7SPeter Maydell    fi
2462a30878e7SPeter Maydell    gtk=no
246335be72baSPaolo Bonzini    sdl=disabled
2464a30878e7SPeter Maydellfi
2465a30878e7SPeter Maydell
24666b39b063SEric Blake# Some versions of Mac OS X incorrectly define SIZE_MAX
24676b39b063SEric Blakecat > $TMPC << EOF
24686b39b063SEric Blake#include <stdint.h>
24696b39b063SEric Blake#include <stdio.h>
24706b39b063SEric Blakeint main(int argc, char *argv[]) {
24716b39b063SEric Blake    return printf("%zu", SIZE_MAX);
24726b39b063SEric Blake}
24736b39b063SEric BlakeEOF
24746b39b063SEric Blakehave_broken_size_max=no
24756b39b063SEric Blakeif ! compile_object -Werror ; then
24766b39b063SEric Blake    have_broken_size_max=yes
24776b39b063SEric Blakefi
24786b39b063SEric Blake
2479a30878e7SPeter Maydell##########################################
2480015a33bdSGonglei# L2TPV3 probe
2481015a33bdSGonglei
2482015a33bdSGongleicat > $TMPC <<EOF
2483015a33bdSGonglei#include <sys/socket.h>
2484bff6cb72SMichael Tokarev#include <linux/ip.h>
2485015a33bdSGongleiint main(void) { return sizeof(struct mmsghdr); }
2486015a33bdSGongleiEOF
2487015a33bdSGongleiif compile_prog "" "" ; then
2488015a33bdSGonglei  l2tpv3=yes
2489015a33bdSGongleielse
2490015a33bdSGonglei  l2tpv3=no
2491015a33bdSGongleifi
2492015a33bdSGonglei
2493c9c8b88fSDavid CARLIERif check_include "pty.h" ; then
2494c9c8b88fSDavid CARLIER  pty_h=yes
2495c9c8b88fSDavid CARLIERelse
2496c9c8b88fSDavid CARLIER  pty_h=no
2497c9c8b88fSDavid CARLIERfi
2498c9c8b88fSDavid CARLIER
2499195588ccSDavid CARLIERcat > $TMPC <<EOF
2500195588ccSDavid CARLIER#include <sys/mman.h>
2501195588ccSDavid CARLIERint main(int argc, char *argv[]) {
2502195588ccSDavid CARLIER    return mlockall(MCL_FUTURE);
2503195588ccSDavid CARLIER}
2504195588ccSDavid CARLIEREOF
2505195588ccSDavid CARLIERif compile_prog "" "" ; then
2506195588ccSDavid CARLIER  have_mlockall=yes
2507195588ccSDavid CARLIERelse
2508195588ccSDavid CARLIER  have_mlockall=no
2509195588ccSDavid CARLIERfi
2510195588ccSDavid CARLIER
2511299e6f19SPaolo Bonzini#########################################
2512299e6f19SPaolo Bonzini# vhost interdependencies and host support
2513299e6f19SPaolo Bonzini
2514299e6f19SPaolo Bonzini# vhost backends
2515299e6f19SPaolo Bonzinitest "$vhost_user" = "" && vhost_user=yes
2516299e6f19SPaolo Bonziniif test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
2517299e6f19SPaolo Bonzini  error_exit "vhost-user isn't available on win32"
2518299e6f19SPaolo Bonzinifi
2519108a6481SCindy Lutest "$vhost_vdpa" = "" && vhost_vdpa=$linux
2520108a6481SCindy Luif test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2521108a6481SCindy Lu  error_exit "vhost-vdpa is only available on Linux"
2522108a6481SCindy Lufi
2523299e6f19SPaolo Bonzinitest "$vhost_kernel" = "" && vhost_kernel=$linux
2524299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
2525299e6f19SPaolo Bonzini  error_exit "vhost-kernel is only available on Linux"
2526299e6f19SPaolo Bonzinifi
2527299e6f19SPaolo Bonzini
2528299e6f19SPaolo Bonzini# vhost-kernel devices
2529299e6f19SPaolo Bonzinitest "$vhost_scsi" = "" && vhost_scsi=$vhost_kernel
2530299e6f19SPaolo Bonziniif test "$vhost_scsi" = "yes" && test "$vhost_kernel" != "yes"; then
2531299e6f19SPaolo Bonzini  error_exit "--enable-vhost-scsi requires --enable-vhost-kernel"
2532299e6f19SPaolo Bonzinifi
2533299e6f19SPaolo Bonzinitest "$vhost_vsock" = "" && vhost_vsock=$vhost_kernel
2534299e6f19SPaolo Bonziniif test "$vhost_vsock" = "yes" && test "$vhost_kernel" != "yes"; then
2535299e6f19SPaolo Bonzini  error_exit "--enable-vhost-vsock requires --enable-vhost-kernel"
2536299e6f19SPaolo Bonzinifi
2537299e6f19SPaolo Bonzini
2538299e6f19SPaolo Bonzini# vhost-user backends
2539299e6f19SPaolo Bonzinitest "$vhost_net_user" = "" && vhost_net_user=$vhost_user
2540299e6f19SPaolo Bonziniif test "$vhost_net_user" = "yes" && test "$vhost_user" = "no"; then
2541299e6f19SPaolo Bonzini  error_exit "--enable-vhost-net-user requires --enable-vhost-user"
2542299e6f19SPaolo Bonzinifi
2543299e6f19SPaolo Bonzinitest "$vhost_crypto" = "" && vhost_crypto=$vhost_user
2544299e6f19SPaolo Bonziniif test "$vhost_crypto" = "yes" && test "$vhost_user" = "no"; then
2545299e6f19SPaolo Bonzini  error_exit "--enable-vhost-crypto requires --enable-vhost-user"
2546299e6f19SPaolo Bonzinifi
254798fc1adaSDr. David Alan Gilberttest "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
254898fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
254998fc1adaSDr. David Alan Gilbert  error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
255098fc1adaSDr. David Alan Gilbertfi
2551108a6481SCindy Lu#vhost-vdpa backends
2552108a6481SCindy Lutest "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2553108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2554108a6481SCindy Lu  error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2555108a6481SCindy Lufi
2556299e6f19SPaolo Bonzini
2557299e6f19SPaolo Bonzini# OR the vhost-kernel and vhost-user values for simplicity
2558299e6f19SPaolo Bonziniif test "$vhost_net" = ""; then
2559299e6f19SPaolo Bonzini  test "$vhost_net_user" = "yes" && vhost_net=yes
2560299e6f19SPaolo Bonzini  test "$vhost_kernel" = "yes" && vhost_net=yes
2561299e6f19SPaolo Bonzinifi
2562299e6f19SPaolo Bonzini
2563015a33bdSGonglei##########################################
25644d9310f4SDaniel P. Berrange# MinGW / Mingw-w64 localtime_r/gmtime_r check
25654d9310f4SDaniel P. Berrange
25664d9310f4SDaniel P. Berrangeif test "$mingw32" = "yes"; then
25674d9310f4SDaniel P. Berrange    # Some versions of MinGW / Mingw-w64 lack localtime_r
25684d9310f4SDaniel P. Berrange    # and gmtime_r entirely.
25694d9310f4SDaniel P. Berrange    #
25704d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 define a macro for
25714d9310f4SDaniel P. Berrange    # localtime_r/gmtime_r.
25724d9310f4SDaniel P. Berrange    #
25734d9310f4SDaniel P. Berrange    # Some versions of Mingw-w64 will define functions
25744d9310f4SDaniel P. Berrange    # for localtime_r/gmtime_r, but only if you have
25754d9310f4SDaniel P. Berrange    # _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
25764d9310f4SDaniel P. Berrange    # though, unistd.h and pthread.h both define
25774d9310f4SDaniel P. Berrange    # that for you.
25784d9310f4SDaniel P. Berrange    #
25794d9310f4SDaniel P. Berrange    # So this #undef localtime_r and #include <unistd.h>
25804d9310f4SDaniel P. Berrange    # are not in fact redundant.
25814d9310f4SDaniel P. Berrangecat > $TMPC << EOF
25824d9310f4SDaniel P. Berrange#include <unistd.h>
25834d9310f4SDaniel P. Berrange#include <time.h>
25844d9310f4SDaniel P. Berrange#undef localtime_r
25854d9310f4SDaniel P. Berrangeint main(void) { localtime_r(NULL, NULL); return 0; }
25864d9310f4SDaniel P. BerrangeEOF
25874d9310f4SDaniel P. Berrange    if compile_prog "" "" ; then
25884d9310f4SDaniel P. Berrange        localtime_r="yes"
25894d9310f4SDaniel P. Berrange    else
25904d9310f4SDaniel P. Berrange        localtime_r="no"
25914d9310f4SDaniel P. Berrange    fi
25924d9310f4SDaniel P. Berrangefi
25934d9310f4SDaniel P. Berrange
25944d9310f4SDaniel P. Berrange##########################################
2595779ab5e3SStefan Weil# pkg-config probe
2596779ab5e3SStefan Weil
2597779ab5e3SStefan Weilif ! has "$pkg_config_exe"; then
259876ad07a4SPeter Maydell  error_exit "pkg-config binary '$pkg_config_exe' not found"
2599779ab5e3SStefan Weilfi
2600779ab5e3SStefan Weil
2601779ab5e3SStefan Weil##########################################
2602b0a47e79SJuan Quintela# NPTL probe
2603b0a47e79SJuan Quintela
260424cb36a6SPeter Maydellif test "$linux_user" = "yes"; then
2605bd0c5661Spbrook  cat > $TMPC <<EOF
2606bd0c5661Spbrook#include <sched.h>
260730813ceaSpbrook#include <linux/futex.h>
2608182eacc0SStefan Weilint main(void) {
2609bd0c5661Spbrook#if !defined(CLONE_SETTLS) || !defined(FUTEX_WAIT)
2610bd0c5661Spbrook#error bork
2611bd0c5661Spbrook#endif
2612182eacc0SStefan Weil  return 0;
2613bd0c5661Spbrook}
2614bd0c5661SpbrookEOF
261524cb36a6SPeter Maydell  if ! compile_object ; then
261621684af0SStewart Smith    feature_not_found "nptl" "Install glibc and linux kernel headers."
2617b0a47e79SJuan Quintela  fi
2618bd0c5661Spbrookfi
2619bd0c5661Spbrook
2620ac62922eSbalrog##########################################
2621607dacd0Sqiaonuohan# lzo check
2622607dacd0Sqiaonuohan
2623607dacd0Sqiaonuohanif test "$lzo" != "no" ; then
2624607dacd0Sqiaonuohan    cat > $TMPC << EOF
2625607dacd0Sqiaonuohan#include <lzo/lzo1x.h>
2626607dacd0Sqiaonuohanint main(void) { lzo_version(); return 0; }
2627607dacd0SqiaonuohanEOF
2628607dacd0Sqiaonuohan    if compile_prog "" "-llzo2" ; then
2629708eab42SMarc-André Lureau        lzo_libs="-llzo2"
2630b25c9dffSStefan Weil        lzo="yes"
2631b25c9dffSStefan Weil    else
2632b25c9dffSStefan Weil        if test "$lzo" = "yes"; then
2633b25c9dffSStefan Weil            feature_not_found "liblzo2" "Install liblzo2 devel"
2634b25c9dffSStefan Weil        fi
2635b25c9dffSStefan Weil        lzo="no"
2636b25c9dffSStefan Weil    fi
2637607dacd0Sqiaonuohanfi
2638607dacd0Sqiaonuohan
2639607dacd0Sqiaonuohan##########################################
2640607dacd0Sqiaonuohan# snappy check
2641607dacd0Sqiaonuohan
2642607dacd0Sqiaonuohanif test "$snappy" != "no" ; then
2643607dacd0Sqiaonuohan    cat > $TMPC << EOF
2644607dacd0Sqiaonuohan#include <snappy-c.h>
2645607dacd0Sqiaonuohanint main(void) { snappy_max_compressed_length(4096); return 0; }
2646607dacd0SqiaonuohanEOF
2647607dacd0Sqiaonuohan    if compile_prog "" "-lsnappy" ; then
2648708eab42SMarc-André Lureau        snappy_libs='-lsnappy'
2649b25c9dffSStefan Weil        snappy="yes"
2650b25c9dffSStefan Weil    else
2651b25c9dffSStefan Weil        if test "$snappy" = "yes"; then
2652b25c9dffSStefan Weil            feature_not_found "libsnappy" "Install libsnappy devel"
2653b25c9dffSStefan Weil        fi
2654b25c9dffSStefan Weil        snappy="no"
2655b25c9dffSStefan Weil    fi
2656607dacd0Sqiaonuohanfi
2657607dacd0Sqiaonuohan
2658607dacd0Sqiaonuohan##########################################
26596b383c08SPeter Wu# bzip2 check
26606b383c08SPeter Wu
26616b383c08SPeter Wuif test "$bzip2" != "no" ; then
26626b383c08SPeter Wu    cat > $TMPC << EOF
26636b383c08SPeter Wu#include <bzlib.h>
26646b383c08SPeter Wuint main(void) { BZ2_bzlibVersion(); return 0; }
26656b383c08SPeter WuEOF
26666b383c08SPeter Wu    if compile_prog "" "-lbz2" ; then
26676b383c08SPeter Wu        bzip2="yes"
26686b383c08SPeter Wu    else
26696b383c08SPeter Wu        if test "$bzip2" = "yes"; then
26706b383c08SPeter Wu            feature_not_found "libbzip2" "Install libbzip2 devel"
26716b383c08SPeter Wu        fi
26726b383c08SPeter Wu        bzip2="no"
26736b383c08SPeter Wu    fi
26746b383c08SPeter Wufi
26756b383c08SPeter Wu
26766b383c08SPeter Wu##########################################
267783bc1f97SJulio Faracco# lzfse check
267883bc1f97SJulio Faracco
267983bc1f97SJulio Faraccoif test "$lzfse" != "no" ; then
268083bc1f97SJulio Faracco    cat > $TMPC << EOF
268183bc1f97SJulio Faracco#include <lzfse.h>
268283bc1f97SJulio Faraccoint main(void) { lzfse_decode_scratch_size(); return 0; }
268383bc1f97SJulio FaraccoEOF
268483bc1f97SJulio Faracco    if compile_prog "" "-llzfse" ; then
268583bc1f97SJulio Faracco        lzfse="yes"
268683bc1f97SJulio Faracco    else
268783bc1f97SJulio Faracco        if test "$lzfse" = "yes"; then
268883bc1f97SJulio Faracco            feature_not_found "lzfse" "Install lzfse devel"
268983bc1f97SJulio Faracco        fi
269083bc1f97SJulio Faracco        lzfse="no"
269183bc1f97SJulio Faracco    fi
269283bc1f97SJulio Faraccofi
269383bc1f97SJulio Faracco
269483bc1f97SJulio Faracco##########################################
26953a678481SJuan Quintela# zstd check
26963a678481SJuan Quintela
26973a678481SJuan Quintelaif test "$zstd" != "no" ; then
2698297254c7SJuan Quintela    libzstd_minver="1.4.0"
2699297254c7SJuan Quintela    if $pkg_config --atleast-version=$libzstd_minver libzstd ; then
27003a678481SJuan Quintela        zstd_cflags="$($pkg_config --cflags libzstd)"
27013a678481SJuan Quintela        zstd_libs="$($pkg_config --libs libzstd)"
27023a678481SJuan Quintela        zstd="yes"
27033a678481SJuan Quintela    else
27043a678481SJuan Quintela        if test "$zstd" = "yes" ; then
27053a678481SJuan Quintela            feature_not_found "libzstd" "Install libzstd devel"
27063a678481SJuan Quintela        fi
27073a678481SJuan Quintela        zstd="no"
27083a678481SJuan Quintela    fi
27093a678481SJuan Quintelafi
27103a678481SJuan Quintela
27113a678481SJuan Quintela##########################################
2712f794573eSEduardo Otubo# libseccomp check
2713f794573eSEduardo Otubo
2714f794573eSEduardo Otuboif test "$seccomp" != "no" ; then
27153e684455SMichael Strosaker    libseccomp_minver="2.3.0"
271625ed0eccSHelge Deller    if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then
2717c3883e1fSFam Zheng        seccomp_cflags="$($pkg_config --cflags libseccomp)"
2718c3883e1fSFam Zheng        seccomp_libs="$($pkg_config --libs libseccomp)"
2719f794573eSEduardo Otubo        seccomp="yes"
2720f794573eSEduardo Otubo    else
2721f794573eSEduardo Otubo        if test "$seccomp" = "yes" ; then
2722693e5910SAndrew Jones            feature_not_found "libseccomp" \
2723693e5910SAndrew Jones                 "Install libseccomp devel >= $libseccomp_minver"
2724896848f0SEduardo Otubo        fi
2725e84d5956SYann E. MORIN        seccomp="no"
2726f794573eSEduardo Otubo    fi
2727f794573eSEduardo Otubofi
2728f794573eSEduardo Otubo##########################################
2729e37630caSaliguori# xen probe
2730e37630caSaliguori
2731fc321b4bSJuan Quintelaif test "$xen" != "no" ; then
2732c1cdd9d5SJuergen Gross  # Check whether Xen library path is specified via --extra-ldflags to avoid
2733c1cdd9d5SJuergen Gross  # overriding this setting with pkg-config output. If not, try pkg-config
2734c1cdd9d5SJuergen Gross  # to obtain all needed flags.
2735c1cdd9d5SJuergen Gross
2736c1cdd9d5SJuergen Gross  if ! echo $EXTRA_LDFLAGS | grep tools/libxc > /dev/null && \
2737c1cdd9d5SJuergen Gross     $pkg_config --exists xencontrol ; then
2738c1cdd9d5SJuergen Gross    xen_ctrl_version="$(printf '%d%02d%02d' \
2739c1cdd9d5SJuergen Gross      $($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
2740c1cdd9d5SJuergen Gross    xen=yes
2741c1cdd9d5SJuergen Gross    xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
2742c1cdd9d5SJuergen Gross    xen_pc="$xen_pc xenevtchn xendevicemodel"
274358ea9a7aSAnthony PERARD    if $pkg_config --exists xentoolcore; then
274458ea9a7aSAnthony PERARD      xen_pc="$xen_pc xentoolcore"
274558ea9a7aSAnthony PERARD    fi
2746c1cdd9d5SJuergen Gross    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags $xen_pc)"
2747582ea95fSMarc-André Lureau    xen_cflags="$($pkg_config --cflags $xen_pc)"
2748582ea95fSMarc-André Lureau    xen_libs="$($pkg_config --libs $xen_pc)"
2749c1cdd9d5SJuergen Gross  else
2750c1cdd9d5SJuergen Gross
2751b2266beeSJuan Quintela    xen_libs="-lxenstore -lxenctrl -lxenguest"
2752d9506cabSAnthony PERARD    xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
2753d5b93ddfSAnthony PERARD
275450ced5b3SStefan Weil    # First we test whether Xen headers and libraries are available.
275550ced5b3SStefan Weil    # If no, we are done and there is no Xen support.
275650ced5b3SStefan Weil    # If yes, more tests are run to detect the Xen version.
275750ced5b3SStefan Weil
275850ced5b3SStefan Weil    # Xen (any)
275950ced5b3SStefan Weil    cat > $TMPC <<EOF
276050ced5b3SStefan Weil#include <xenctrl.h>
276150ced5b3SStefan Weilint main(void) {
276250ced5b3SStefan Weil  return 0;
276350ced5b3SStefan Weil}
276450ced5b3SStefan WeilEOF
276550ced5b3SStefan Weil    if ! compile_prog "" "$xen_libs" ; then
276650ced5b3SStefan Weil      # Xen not found
276750ced5b3SStefan Weil      if test "$xen" = "yes" ; then
276821684af0SStewart Smith        feature_not_found "xen" "Install xen devel"
276950ced5b3SStefan Weil      fi
277050ced5b3SStefan Weil      xen=no
277150ced5b3SStefan Weil
2772d5b93ddfSAnthony PERARD    # Xen unstable
277369deef08SPeter Maydell    elif
277469deef08SPeter Maydell        cat > $TMPC <<EOF &&
27752cbf8903SRoss Lagerwall#undef XC_WANT_COMPAT_DEVICEMODEL_API
27762cbf8903SRoss Lagerwall#define __XEN_TOOLS__
27772cbf8903SRoss Lagerwall#include <xendevicemodel.h>
2778d3c49ebbSPaul Durrant#include <xenforeignmemory.h>
27792cbf8903SRoss Lagerwallint main(void) {
27802cbf8903SRoss Lagerwall  xendevicemodel_handle *xd;
2781d3c49ebbSPaul Durrant  xenforeignmemory_handle *xfmem;
27822cbf8903SRoss Lagerwall
27832cbf8903SRoss Lagerwall  xd = xendevicemodel_open(0, 0);
27842cbf8903SRoss Lagerwall  xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
27852cbf8903SRoss Lagerwall
2786d3c49ebbSPaul Durrant  xfmem = xenforeignmemory_open(0, 0);
2787d3c49ebbSPaul Durrant  xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
2788d3c49ebbSPaul Durrant
27892cbf8903SRoss Lagerwall  return 0;
27902cbf8903SRoss Lagerwall}
27912cbf8903SRoss LagerwallEOF
27922cbf8903SRoss Lagerwall        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
27932cbf8903SRoss Lagerwall      then
27942cbf8903SRoss Lagerwall      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
27952cbf8903SRoss Lagerwall      xen_ctrl_version=41100
27962cbf8903SRoss Lagerwall      xen=yes
27972cbf8903SRoss Lagerwall    elif
27982cbf8903SRoss Lagerwall        cat > $TMPC <<EOF &&
27995ba3d756SIgor Druzhinin#undef XC_WANT_COMPAT_MAP_FOREIGN_API
28005ba3d756SIgor Druzhinin#include <xenforeignmemory.h>
280158ea9a7aSAnthony PERARD#include <xentoolcore.h>
28025ba3d756SIgor Druzhininint main(void) {
28035ba3d756SIgor Druzhinin  xenforeignmemory_handle *xfmem;
28045ba3d756SIgor Druzhinin
28055ba3d756SIgor Druzhinin  xfmem = xenforeignmemory_open(0, 0);
28065ba3d756SIgor Druzhinin  xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
280758ea9a7aSAnthony PERARD  xentoolcore_restrict_all(0);
28085ba3d756SIgor Druzhinin
28095ba3d756SIgor Druzhinin  return 0;
28105ba3d756SIgor Druzhinin}
28115ba3d756SIgor DruzhininEOF
281258ea9a7aSAnthony PERARD        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs -lxentoolcore"
28135ba3d756SIgor Druzhinin      then
281458ea9a7aSAnthony PERARD      xen_stable_libs="-lxendevicemodel $xen_stable_libs -lxentoolcore"
28155ba3d756SIgor Druzhinin      xen_ctrl_version=41000
28165ba3d756SIgor Druzhinin      xen=yes
28175ba3d756SIgor Druzhinin    elif
28185ba3d756SIgor Druzhinin        cat > $TMPC <<EOF &&
2819da8090ccSPaul Durrant#undef XC_WANT_COMPAT_DEVICEMODEL_API
2820da8090ccSPaul Durrant#define __XEN_TOOLS__
2821da8090ccSPaul Durrant#include <xendevicemodel.h>
2822da8090ccSPaul Durrantint main(void) {
2823da8090ccSPaul Durrant  xendevicemodel_handle *xd;
2824da8090ccSPaul Durrant
2825da8090ccSPaul Durrant  xd = xendevicemodel_open(0, 0);
2826da8090ccSPaul Durrant  xendevicemodel_close(xd);
2827da8090ccSPaul Durrant
2828da8090ccSPaul Durrant  return 0;
2829da8090ccSPaul Durrant}
2830da8090ccSPaul DurrantEOF
2831da8090ccSPaul Durrant        compile_prog "" "$xen_libs -lxendevicemodel $xen_stable_libs"
2832da8090ccSPaul Durrant      then
2833da8090ccSPaul Durrant      xen_stable_libs="-lxendevicemodel $xen_stable_libs"
2834f1167ee6SJuergen Gross      xen_ctrl_version=40900
2835da8090ccSPaul Durrant      xen=yes
2836da8090ccSPaul Durrant    elif
2837da8090ccSPaul Durrant        cat > $TMPC <<EOF &&
28385eeb39c2SIan Campbell/*
28395eeb39c2SIan Campbell * If we have stable libs the we don't want the libxc compat
28405eeb39c2SIan Campbell * layers, regardless of what CFLAGS we may have been given.
2841b6eb9b45SPaulina Szubarczyk *
2842b6eb9b45SPaulina Szubarczyk * Also, check if xengnttab_grant_copy_segment_t is defined and
2843b6eb9b45SPaulina Szubarczyk * grant copy operation is implemented.
2844b6eb9b45SPaulina Szubarczyk */
2845b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_EVTCHN_API
2846b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_GNTTAB_API
2847b6eb9b45SPaulina Szubarczyk#undef XC_WANT_COMPAT_MAP_FOREIGN_API
2848b6eb9b45SPaulina Szubarczyk#include <xenctrl.h>
2849b6eb9b45SPaulina Szubarczyk#include <xenstore.h>
2850b6eb9b45SPaulina Szubarczyk#include <xenevtchn.h>
2851b6eb9b45SPaulina Szubarczyk#include <xengnttab.h>
2852b6eb9b45SPaulina Szubarczyk#include <xenforeignmemory.h>
2853b6eb9b45SPaulina Szubarczyk#include <stdint.h>
2854b6eb9b45SPaulina Szubarczyk#include <xen/hvm/hvm_info_table.h>
2855b6eb9b45SPaulina Szubarczyk#if !defined(HVM_MAX_VCPUS)
2856b6eb9b45SPaulina Szubarczyk# error HVM_MAX_VCPUS not defined
2857b6eb9b45SPaulina Szubarczyk#endif
2858b6eb9b45SPaulina Szubarczykint main(void) {
2859b6eb9b45SPaulina Szubarczyk  xc_interface *xc = NULL;
2860b6eb9b45SPaulina Szubarczyk  xenforeignmemory_handle *xfmem;
2861b6eb9b45SPaulina Szubarczyk  xenevtchn_handle *xe;
2862b6eb9b45SPaulina Szubarczyk  xengnttab_handle *xg;
2863b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy_segment_t* seg = NULL;
2864b6eb9b45SPaulina Szubarczyk
2865b6eb9b45SPaulina Szubarczyk  xs_daemon_open();
2866b6eb9b45SPaulina Szubarczyk
2867b6eb9b45SPaulina Szubarczyk  xc = xc_interface_open(0, 0, 0);
2868b6eb9b45SPaulina Szubarczyk  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2869b6eb9b45SPaulina Szubarczyk  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2870b6eb9b45SPaulina Szubarczyk  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2871b6eb9b45SPaulina Szubarczyk  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
2872b6eb9b45SPaulina Szubarczyk
2873b6eb9b45SPaulina Szubarczyk  xfmem = xenforeignmemory_open(0, 0);
2874b6eb9b45SPaulina Szubarczyk  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
2875b6eb9b45SPaulina Szubarczyk
2876b6eb9b45SPaulina Szubarczyk  xe = xenevtchn_open(0, 0);
2877b6eb9b45SPaulina Szubarczyk  xenevtchn_fd(xe);
2878b6eb9b45SPaulina Szubarczyk
2879b6eb9b45SPaulina Szubarczyk  xg = xengnttab_open(0, 0);
2880b6eb9b45SPaulina Szubarczyk  xengnttab_grant_copy(xg, 0, seg);
2881b6eb9b45SPaulina Szubarczyk
2882b6eb9b45SPaulina Szubarczyk  return 0;
2883b6eb9b45SPaulina Szubarczyk}
2884b6eb9b45SPaulina SzubarczykEOF
2885b6eb9b45SPaulina Szubarczyk        compile_prog "" "$xen_libs $xen_stable_libs"
2886b6eb9b45SPaulina Szubarczyk      then
2887f1167ee6SJuergen Gross      xen_ctrl_version=40800
2888b6eb9b45SPaulina Szubarczyk      xen=yes
2889b6eb9b45SPaulina Szubarczyk    elif
2890b6eb9b45SPaulina Szubarczyk        cat > $TMPC <<EOF &&
2891b6eb9b45SPaulina Szubarczyk/*
2892b6eb9b45SPaulina Szubarczyk * If we have stable libs the we don't want the libxc compat
2893b6eb9b45SPaulina Szubarczyk * layers, regardless of what CFLAGS we may have been given.
28945eeb39c2SIan Campbell */
28955eeb39c2SIan Campbell#undef XC_WANT_COMPAT_EVTCHN_API
28965eeb39c2SIan Campbell#undef XC_WANT_COMPAT_GNTTAB_API
28975eeb39c2SIan Campbell#undef XC_WANT_COMPAT_MAP_FOREIGN_API
28985eeb39c2SIan Campbell#include <xenctrl.h>
28995eeb39c2SIan Campbell#include <xenstore.h>
29005eeb39c2SIan Campbell#include <xenevtchn.h>
29015eeb39c2SIan Campbell#include <xengnttab.h>
29025eeb39c2SIan Campbell#include <xenforeignmemory.h>
29035eeb39c2SIan Campbell#include <stdint.h>
29045eeb39c2SIan Campbell#include <xen/hvm/hvm_info_table.h>
29055eeb39c2SIan Campbell#if !defined(HVM_MAX_VCPUS)
29065eeb39c2SIan Campbell# error HVM_MAX_VCPUS not defined
29075eeb39c2SIan Campbell#endif
29085eeb39c2SIan Campbellint main(void) {
29095eeb39c2SIan Campbell  xc_interface *xc = NULL;
29105eeb39c2SIan Campbell  xenforeignmemory_handle *xfmem;
29115eeb39c2SIan Campbell  xenevtchn_handle *xe;
29125eeb39c2SIan Campbell  xengnttab_handle *xg;
29135eeb39c2SIan Campbell
29145eeb39c2SIan Campbell  xs_daemon_open();
29155eeb39c2SIan Campbell
29165eeb39c2SIan Campbell  xc = xc_interface_open(0, 0, 0);
29175eeb39c2SIan Campbell  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
29185eeb39c2SIan Campbell  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29195eeb39c2SIan Campbell  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29205eeb39c2SIan Campbell  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
29215eeb39c2SIan Campbell
29225eeb39c2SIan Campbell  xfmem = xenforeignmemory_open(0, 0);
29235eeb39c2SIan Campbell  xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
29245eeb39c2SIan Campbell
29255eeb39c2SIan Campbell  xe = xenevtchn_open(0, 0);
29265eeb39c2SIan Campbell  xenevtchn_fd(xe);
29275eeb39c2SIan Campbell
29285eeb39c2SIan Campbell  xg = xengnttab_open(0, 0);
29295eeb39c2SIan Campbell  xengnttab_map_grant_ref(xg, 0, 0, 0);
29305eeb39c2SIan Campbell
29315eeb39c2SIan Campbell  return 0;
29325eeb39c2SIan Campbell}
29335eeb39c2SIan CampbellEOF
29345eeb39c2SIan Campbell        compile_prog "" "$xen_libs $xen_stable_libs"
29355eeb39c2SIan Campbell      then
2936f1167ee6SJuergen Gross      xen_ctrl_version=40701
29375eeb39c2SIan Campbell      xen=yes
2938cdadde39SRoger Pau Monne
2939cdadde39SRoger Pau Monne    # Xen 4.6
2940cdadde39SRoger Pau Monne    elif
2941cdadde39SRoger Pau Monne        cat > $TMPC <<EOF &&
2942cdadde39SRoger Pau Monne#include <xenctrl.h>
2943e108a3c1SAnthony PERARD#include <xenstore.h>
2944d5b93ddfSAnthony PERARD#include <stdint.h>
2945d5b93ddfSAnthony PERARD#include <xen/hvm/hvm_info_table.h>
2946d5b93ddfSAnthony PERARD#if !defined(HVM_MAX_VCPUS)
2947d5b93ddfSAnthony PERARD# error HVM_MAX_VCPUS not defined
2948d5b93ddfSAnthony PERARD#endif
2949d5b93ddfSAnthony PERARDint main(void) {
2950d5b93ddfSAnthony PERARD  xc_interface *xc;
2951d5b93ddfSAnthony PERARD  xs_daemon_open();
2952d5b93ddfSAnthony PERARD  xc = xc_interface_open(0, 0, 0);
2953d5b93ddfSAnthony PERARD  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2954d5b93ddfSAnthony PERARD  xc_gnttab_open(NULL, 0);
2955b87de24eSAnthony PERARD  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
29568688e065SStefano Stabellini  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
2957d8b441a3SJan Beulich  xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
295820a544c7SKonrad Rzeszutek Wilk  xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
2959d8b441a3SJan Beulich  return 0;
2960d8b441a3SJan Beulich}
2961d8b441a3SJan BeulichEOF
2962d8b441a3SJan Beulich        compile_prog "" "$xen_libs"
2963d8b441a3SJan Beulich      then
2964f1167ee6SJuergen Gross      xen_ctrl_version=40600
2965d8b441a3SJan Beulich      xen=yes
2966d8b441a3SJan Beulich
2967d8b441a3SJan Beulich    # Xen 4.5
2968d8b441a3SJan Beulich    elif
2969d8b441a3SJan Beulich        cat > $TMPC <<EOF &&
2970d8b441a3SJan Beulich#include <xenctrl.h>
2971d8b441a3SJan Beulich#include <xenstore.h>
2972d8b441a3SJan Beulich#include <stdint.h>
2973d8b441a3SJan Beulich#include <xen/hvm/hvm_info_table.h>
2974d8b441a3SJan Beulich#if !defined(HVM_MAX_VCPUS)
2975d8b441a3SJan Beulich# error HVM_MAX_VCPUS not defined
2976d8b441a3SJan Beulich#endif
2977d8b441a3SJan Beulichint main(void) {
2978d8b441a3SJan Beulich  xc_interface *xc;
2979d8b441a3SJan Beulich  xs_daemon_open();
2980d8b441a3SJan Beulich  xc = xc_interface_open(0, 0, 0);
2981d8b441a3SJan Beulich  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
2982d8b441a3SJan Beulich  xc_gnttab_open(NULL, 0);
2983d8b441a3SJan Beulich  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
2984d8b441a3SJan Beulich  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
29853996e85cSPaul Durrant  xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
29863996e85cSPaul Durrant  return 0;
29873996e85cSPaul Durrant}
29883996e85cSPaul DurrantEOF
29893996e85cSPaul Durrant        compile_prog "" "$xen_libs"
29903996e85cSPaul Durrant      then
2991f1167ee6SJuergen Gross      xen_ctrl_version=40500
29923996e85cSPaul Durrant      xen=yes
29933996e85cSPaul Durrant
29943996e85cSPaul Durrant    elif
29953996e85cSPaul Durrant        cat > $TMPC <<EOF &&
29963996e85cSPaul Durrant#include <xenctrl.h>
29973996e85cSPaul Durrant#include <xenstore.h>
29983996e85cSPaul Durrant#include <stdint.h>
29993996e85cSPaul Durrant#include <xen/hvm/hvm_info_table.h>
30003996e85cSPaul Durrant#if !defined(HVM_MAX_VCPUS)
30013996e85cSPaul Durrant# error HVM_MAX_VCPUS not defined
30023996e85cSPaul Durrant#endif
30033996e85cSPaul Durrantint main(void) {
30043996e85cSPaul Durrant  xc_interface *xc;
30053996e85cSPaul Durrant  xs_daemon_open();
30063996e85cSPaul Durrant  xc = xc_interface_open(0, 0, 0);
30073996e85cSPaul Durrant  xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
30083996e85cSPaul Durrant  xc_gnttab_open(NULL, 0);
30093996e85cSPaul Durrant  xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
30103996e85cSPaul Durrant  xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
30118688e065SStefano Stabellini  return 0;
30128688e065SStefano Stabellini}
30138688e065SStefano StabelliniEOF
30148688e065SStefano Stabellini        compile_prog "" "$xen_libs"
301569deef08SPeter Maydell      then
3016f1167ee6SJuergen Gross      xen_ctrl_version=40200
30178688e065SStefano Stabellini      xen=yes
30188688e065SStefano Stabellini
3019e37630caSaliguori    else
3020fc321b4bSJuan Quintela      if test "$xen" = "yes" ; then
3021edfb07edSIan Campbell        feature_not_found "xen (unsupported version)" \
3022edfb07edSIan Campbell                          "Install a supported xen (xen 4.2 or newer)"
3023fc321b4bSJuan Quintela      fi
3024fc321b4bSJuan Quintela      xen=no
3025e37630caSaliguori    fi
3026d5b93ddfSAnthony PERARD
3027d5b93ddfSAnthony PERARD    if test "$xen" = yes; then
3028f1167ee6SJuergen Gross      if test $xen_ctrl_version -ge 40701  ; then
3029582ea95fSMarc-André Lureau        xen_libs="$xen_libs $xen_stable_libs "
30305eeb39c2SIan Campbell      fi
3031d5b93ddfSAnthony PERARD    fi
3032e37630caSaliguori  fi
3033c1cdd9d5SJuergen Grossfi
3034e37630caSaliguori
3035eb6fda0fSAnthony PERARDif test "$xen_pci_passthrough" != "no"; then
3036edfb07edSIan Campbell  if test "$xen" = "yes" && test "$linux" = "yes"; then
3037eb6fda0fSAnthony PERARD    xen_pci_passthrough=yes
3038eb6fda0fSAnthony PERARD  else
3039eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = "yes"; then
304076ad07a4SPeter Maydell      error_exit "User requested feature Xen PCI Passthrough" \
304176ad07a4SPeter Maydell          " but this feature requires /sys from Linux"
3042eb6fda0fSAnthony PERARD    fi
3043eb6fda0fSAnthony PERARD    xen_pci_passthrough=no
3044eb6fda0fSAnthony PERARD  fi
3045eb6fda0fSAnthony PERARDfi
3046eb6fda0fSAnthony PERARD
3047e37630caSaliguori##########################################
3048d661d9a4SJustin Terry (VM)# Windows Hypervisor Platform accelerator (WHPX) check
3049d661d9a4SJustin Terry (VM)if test "$whpx" != "no" ; then
3050327fccb2SLucian Petrut    if check_include "WinHvPlatform.h" && check_include "WinHvEmulation.h"; then
3051d661d9a4SJustin Terry (VM)        whpx="yes"
3052d661d9a4SJustin Terry (VM)    else
3053d661d9a4SJustin Terry (VM)        if test "$whpx" = "yes"; then
305453537bb1SJustin Terry (VM) via Qemu-devel            feature_not_found "WinHvPlatform" "WinHvEmulation is not installed"
3055d661d9a4SJustin Terry (VM)        fi
3056d661d9a4SJustin Terry (VM)        whpx="no"
3057d661d9a4SJustin Terry (VM)    fi
3058d661d9a4SJustin Terry (VM)fi
3059d661d9a4SJustin Terry (VM)
3060d661d9a4SJustin Terry (VM)##########################################
3061e8f3bd71SMarc-André Lureau# gettext probe
3062e8f3bd71SMarc-André Lureauif test "$gettext" != "false" ; then
3063e8f3bd71SMarc-André Lureau  if has xgettext; then
3064e8f3bd71SMarc-André Lureau    gettext=true
3065e8f3bd71SMarc-André Lureau  else
3066e8f3bd71SMarc-André Lureau    if test "$gettext" = "true" ; then
3067e8f3bd71SMarc-André Lureau      feature_not_found "gettext" "Install xgettext binary"
3068e8f3bd71SMarc-André Lureau    fi
3069e8f3bd71SMarc-André Lureau    gettext=false
3070e8f3bd71SMarc-André Lureau  fi
3071e8f3bd71SMarc-André Lureaufi
3072e8f3bd71SMarc-André Lureau
3073e8f3bd71SMarc-André Lureau##########################################
3074dfffc653SJuan Quintela# Sparse probe
3075dfffc653SJuan Quintelaif test "$sparse" != "no" ; then
3076968b4db3SPaolo Bonzini  if has sparse; then
3077dfffc653SJuan Quintela    sparse=yes
3078dfffc653SJuan Quintela  else
3079dfffc653SJuan Quintela    if test "$sparse" = "yes" ; then
308021684af0SStewart Smith      feature_not_found "sparse" "Install sparse binary"
3081dfffc653SJuan Quintela    fi
3082dfffc653SJuan Quintela    sparse=no
3083dfffc653SJuan Quintela  fi
3084dfffc653SJuan Quintelafi
3085dfffc653SJuan Quintela
3086dfffc653SJuan Quintela##########################################
3087f676c67eSJeremy White# X11 probe
3088f676c67eSJeremy Whiteif $pkg_config --exists "x11"; then
30898781595bSGerd Hoffmann    have_x11=yes
309089138857SStefan Weil    x11_cflags=$($pkg_config --cflags x11)
309189138857SStefan Weil    x11_libs=$($pkg_config --libs x11)
3092f676c67eSJeremy Whitefi
3093f676c67eSJeremy White
3094f676c67eSJeremy White##########################################
3095a4ccabcfSAnthony Liguori# GTK probe
3096a4ccabcfSAnthony Liguori
30975a464e6cSPeter Xuif test "$gtk" != "no"; then
309889d85cdeSDaniel P. Berrangé    gtkpackage="gtk+-3.0"
309989d85cdeSDaniel P. Berrangé    gtkx11package="gtk+-x11-3.0"
31007b23d121SVolker Rümelin    gtkversion="3.22.0"
3101bbbf9bfbSStefan Weil    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
310289138857SStefan Weil        gtk_cflags=$($pkg_config --cflags $gtkpackage)
310389138857SStefan Weil        gtk_libs=$($pkg_config --libs $gtkpackage)
310489138857SStefan Weil        gtk_version=$($pkg_config --modversion $gtkpackage)
31050a337ed0SGerd Hoffmann        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
31068781595bSGerd Hoffmann            need_x11=yes
3107f676c67eSJeremy White            gtk_cflags="$gtk_cflags $x11_cflags"
3108f676c67eSJeremy White            gtk_libs="$gtk_libs $x11_libs"
31090a337ed0SGerd Hoffmann        fi
3110bbbf9bfbSStefan Weil        gtk="yes"
3111bbbf9bfbSStefan Weil    elif test "$gtk" = "yes"; then
31125fe309ffSGerd Hoffmann        feature_not_found "gtk" "Install gtk3-devel"
3113bbbf9bfbSStefan Weil    else
3114bbbf9bfbSStefan Weil        gtk="no"
3115bbbf9bfbSStefan Weil    fi
3116bbbf9bfbSStefan Weilfi
3117bbbf9bfbSStefan Weil
3118ddbb0d09SDaniel P. Berrange
3119ddbb0d09SDaniel P. Berrange##########################################
3120ddbb0d09SDaniel P. Berrange# GNUTLS probe
3121ddbb0d09SDaniel P. Berrange
3122ddbb0d09SDaniel P. Berrangeif test "$gnutls" != "no"; then
3123a73e82efSRichard Henderson    pass="no"
3124a0722409SDaniel P. Berrangé    if $pkg_config --exists "gnutls >= 3.1.18"; then
312589138857SStefan Weil        gnutls_cflags=$($pkg_config --cflags gnutls)
312689138857SStefan Weil        gnutls_libs=$($pkg_config --libs gnutls)
3127a73e82efSRichard Henderson        # Packaging for the static libraries is not always correct.
3128a73e82efSRichard Henderson        # At least ubuntu 18.04 ships only shared libraries.
3129a73e82efSRichard Henderson        write_c_skeleton
3130a73e82efSRichard Henderson        if compile_prog "" "$gnutls_libs" ; then
3131243dc2cfSRichard Henderson            LIBS="$gnutls_libs $LIBS"
3132ddbb0d09SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gnutls_cflags"
3133a73e82efSRichard Henderson            pass="yes"
3134a73e82efSRichard Henderson        fi
3135a73e82efSRichard Henderson    fi
3136a73e82efSRichard Henderson    if test "$pass" = "no" && test "$gnutls" = "yes"; then
3137a0722409SDaniel P. Berrangé	feature_not_found "gnutls" "Install gnutls devel >= 3.1.18"
3138ddbb0d09SDaniel P. Berrange    else
3139a73e82efSRichard Henderson        gnutls="$pass"
3140ddbb0d09SDaniel P. Berrange    fi
3141ddbb0d09SDaniel P. Berrangefi
3142ddbb0d09SDaniel P. Berrange
314391bfcdb0SDaniel P. Berrange
314491bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-gcrypt flag,
314591bfcdb0SDaniel P. Berrange# then mark as disabled if user requested nettle
3146a0722409SDaniel P. Berrangé# explicitly
314791bfcdb0SDaniel P. Berrangeif test -z "$gcrypt"
314891bfcdb0SDaniel P. Berrangethen
3149a0722409SDaniel P. Berrangé    if test "$nettle" = "yes"
315091bfcdb0SDaniel P. Berrange    then
315191bfcdb0SDaniel P. Berrange        gcrypt="no"
315291bfcdb0SDaniel P. Berrange    fi
315391bfcdb0SDaniel P. Berrangefi
315491bfcdb0SDaniel P. Berrange
315591bfcdb0SDaniel P. Berrange# If user didn't give a --disable/enable-nettle flag,
315691bfcdb0SDaniel P. Berrange# then mark as disabled if user requested gcrypt
3157a0722409SDaniel P. Berrangé# explicitly
315891bfcdb0SDaniel P. Berrangeif test -z "$nettle"
315991bfcdb0SDaniel P. Berrangethen
3160a0722409SDaniel P. Berrangé    if test "$gcrypt" = "yes"
316191bfcdb0SDaniel P. Berrange    then
316291bfcdb0SDaniel P. Berrange        nettle="no"
316391bfcdb0SDaniel P. Berrange    fi
316491bfcdb0SDaniel P. Berrangefi
316591bfcdb0SDaniel P. Berrange
3166dea7a64eSDaniel P. Berrangéhas_libgcrypt() {
316791bfcdb0SDaniel P. Berrange    if ! has "libgcrypt-config"
316891bfcdb0SDaniel P. Berrange    then
316991bfcdb0SDaniel P. Berrange	return 1
317091bfcdb0SDaniel P. Berrange    fi
317191bfcdb0SDaniel P. Berrange
317291bfcdb0SDaniel P. Berrange    if test -n "$cross_prefix"
317391bfcdb0SDaniel P. Berrange    then
317489138857SStefan Weil	host=$(libgcrypt-config --host)
317591bfcdb0SDaniel P. Berrange	if test "$host-" != $cross_prefix
317691bfcdb0SDaniel P. Berrange	then
317791bfcdb0SDaniel P. Berrange	    return 1
317891bfcdb0SDaniel P. Berrange	fi
317991bfcdb0SDaniel P. Berrange    fi
318091bfcdb0SDaniel P. Berrange
3181dea7a64eSDaniel P. Berrangé    maj=`libgcrypt-config --version | awk -F . '{print $1}'`
3182dea7a64eSDaniel P. Berrangé    min=`libgcrypt-config --version | awk -F . '{print $2}'`
3183dea7a64eSDaniel P. Berrangé
3184dea7a64eSDaniel P. Berrangé    if test $maj != 1 || test $min -lt 5
3185dea7a64eSDaniel P. Berrangé    then
3186dea7a64eSDaniel P. Berrangé       return 1
3187dea7a64eSDaniel P. Berrangé    fi
3188dea7a64eSDaniel P. Berrangé
318991bfcdb0SDaniel P. Berrange    return 0
319091bfcdb0SDaniel P. Berrange}
319191bfcdb0SDaniel P. Berrange
3192a0722409SDaniel P. Berrangé
3193a0722409SDaniel P. Berrangéif test "$nettle" != "no"; then
3194a73e82efSRichard Henderson    pass="no"
319564dd2f3bSDaniel P. Berrangé    if $pkg_config --exists "nettle >= 2.7.1"; then
3196a0722409SDaniel P. Berrangé        nettle_cflags=$($pkg_config --cflags nettle)
3197a0722409SDaniel P. Berrangé        nettle_libs=$($pkg_config --libs nettle)
3198a0722409SDaniel P. Berrangé        nettle_version=$($pkg_config --modversion nettle)
3199a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3200a73e82efSRichard Henderson        write_c_skeleton
3201a73e82efSRichard Henderson        if compile_prog "" "$nettle_libs" ; then
3202243dc2cfSRichard Henderson            LIBS="$nettle_libs $LIBS"
3203a0722409SDaniel P. Berrangé            QEMU_CFLAGS="$QEMU_CFLAGS $nettle_cflags"
3204a0722409SDaniel P. Berrangé            if test -z "$gcrypt"; then
3205a0722409SDaniel P. Berrangé               gcrypt="no"
3206a0722409SDaniel P. Berrangé            fi
3207a73e82efSRichard Henderson            pass="yes"
3208a73e82efSRichard Henderson        fi
3209a73e82efSRichard Henderson    fi
3210dc2207afSDaniel P. Berrangé    if test "$pass" = "yes"
3211dc2207afSDaniel P. Berrangé    then
3212dc2207afSDaniel P. Berrangé        cat > $TMPC << EOF
3213dc2207afSDaniel P. Berrangé#include <nettle/xts.h>
3214dc2207afSDaniel P. Berrangéint main(void) {
3215dc2207afSDaniel P. Berrangé  return 0;
3216dc2207afSDaniel P. Berrangé}
3217dc2207afSDaniel P. BerrangéEOF
3218dc2207afSDaniel P. Berrangé        if compile_prog "$nettle_cflags" "$nettle_libs" ; then
3219dc2207afSDaniel P. Berrangé            nettle_xts=yes
3220dc2207afSDaniel P. Berrangé            qemu_private_xts=no
3221dc2207afSDaniel P. Berrangé        fi
3222dc2207afSDaniel P. Berrangé    fi
3223a73e82efSRichard Henderson    if test "$pass" = "no" && test "$nettle" = "yes"; then
322464dd2f3bSDaniel P. Berrangé        feature_not_found "nettle" "Install nettle devel >= 2.7.1"
3225a0722409SDaniel P. Berrangé    else
3226a73e82efSRichard Henderson        nettle="$pass"
3227a0722409SDaniel P. Berrangé    fi
3228a0722409SDaniel P. Berrangéfi
3229a0722409SDaniel P. Berrangé
323091bfcdb0SDaniel P. Berrangeif test "$gcrypt" != "no"; then
3231a73e82efSRichard Henderson    pass="no"
3232dea7a64eSDaniel P. Berrangé    if has_libgcrypt; then
323389138857SStefan Weil        gcrypt_cflags=$(libgcrypt-config --cflags)
323489138857SStefan Weil        gcrypt_libs=$(libgcrypt-config --libs)
3235a73e82efSRichard Henderson        # Debian has removed -lgpg-error from libgcrypt-config
323691bfcdb0SDaniel P. Berrange        # as it "spreads unnecessary dependencies" which in
323791bfcdb0SDaniel P. Berrange        # turn breaks static builds...
323891bfcdb0SDaniel P. Berrange        if test "$static" = "yes"
323991bfcdb0SDaniel P. Berrange        then
324091bfcdb0SDaniel P. Berrange            gcrypt_libs="$gcrypt_libs -lgpg-error"
324191bfcdb0SDaniel P. Berrange        fi
32421f923c70SLongpeng(Mike)
3243a73e82efSRichard Henderson        # Link test to make sure the given libraries work (e.g for static).
3244a73e82efSRichard Henderson        write_c_skeleton
3245a73e82efSRichard Henderson        if compile_prog "" "$gcrypt_libs" ; then
3246243dc2cfSRichard Henderson            LIBS="$gcrypt_libs $LIBS"
324737788f25SDaniel P. Berrange            QEMU_CFLAGS="$QEMU_CFLAGS $gcrypt_cflags"
3248a73e82efSRichard Henderson            pass="yes"
3249a73e82efSRichard Henderson        fi
3250a73e82efSRichard Henderson    fi
3251a73e82efSRichard Henderson    if test "$pass" = "yes"; then
325237788f25SDaniel P. Berrange        gcrypt="yes"
32531f923c70SLongpeng(Mike)        cat > $TMPC << EOF
32541f923c70SLongpeng(Mike)#include <gcrypt.h>
32551f923c70SLongpeng(Mike)int main(void) {
32561f923c70SLongpeng(Mike)  gcry_mac_hd_t handle;
32571f923c70SLongpeng(Mike)  gcry_mac_open(&handle, GCRY_MAC_HMAC_MD5,
32581f923c70SLongpeng(Mike)                GCRY_MAC_FLAG_SECURE, NULL);
32591f923c70SLongpeng(Mike)  return 0;
32601f923c70SLongpeng(Mike)}
32611f923c70SLongpeng(Mike)EOF
32621f923c70SLongpeng(Mike)        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
32631f923c70SLongpeng(Mike)            gcrypt_hmac=yes
32641f923c70SLongpeng(Mike)        fi
3265e0576942SDaniel P. Berrangé        cat > $TMPC << EOF
3266e0576942SDaniel P. Berrangé#include <gcrypt.h>
3267e0576942SDaniel P. Berrangéint main(void) {
3268e0576942SDaniel P. Berrangé  gcry_cipher_hd_t handle;
3269e0576942SDaniel P. Berrangé  gcry_cipher_open(&handle, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_XTS, 0);
3270e0576942SDaniel P. Berrangé  return 0;
3271e0576942SDaniel P. Berrangé}
3272e0576942SDaniel P. BerrangéEOF
3273e0576942SDaniel P. Berrangé        if compile_prog "$gcrypt_cflags" "$gcrypt_libs" ; then
3274e0576942SDaniel P. Berrangé            gcrypt_xts=yes
3275e0576942SDaniel P. Berrangé            qemu_private_xts=no
3276e0576942SDaniel P. Berrangé        fi
3277a73e82efSRichard Henderson    elif test "$gcrypt" = "yes"; then
3278dea7a64eSDaniel P. Berrangé        feature_not_found "gcrypt" "Install gcrypt devel >= 1.5.0"
327991bfcdb0SDaniel P. Berrange    else
328091bfcdb0SDaniel P. Berrange        gcrypt="no"
328191bfcdb0SDaniel P. Berrange    fi
328262893b67SDaniel P. Berrangefi
328362893b67SDaniel P. Berrange
3284ddbb0d09SDaniel P. Berrange
328591bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" && test "$nettle" = "yes"
328691bfcdb0SDaniel P. Berrangethen
328791bfcdb0SDaniel P. Berrange    error_exit "Only one of gcrypt & nettle can be enabled"
328891bfcdb0SDaniel P. Berrangefi
3289ed754746SDaniel P. Berrange
32909a2fd434SDaniel P. Berrange##########################################
32919a2fd434SDaniel P. Berrange# libtasn1 - only for the TLS creds/session test suite
32929a2fd434SDaniel P. Berrange
32939a2fd434SDaniel P. Berrangetasn1=yes
329490246037SDaniel P. Berrangetasn1_cflags=""
329590246037SDaniel P. Berrangetasn1_libs=""
32969a2fd434SDaniel P. Berrangeif $pkg_config --exists "libtasn1"; then
329789138857SStefan Weil    tasn1_cflags=$($pkg_config --cflags libtasn1)
329889138857SStefan Weil    tasn1_libs=$($pkg_config --libs libtasn1)
32999a2fd434SDaniel P. Berrangeelse
33009a2fd434SDaniel P. Berrange    tasn1=no
33019a2fd434SDaniel P. Berrangefi
33029a2fd434SDaniel P. Berrange
3303ed754746SDaniel P. Berrange
3304bbbf9bfbSStefan Weil##########################################
33058953caf3SDaniel P. Berrange# PAM probe
33068953caf3SDaniel P. Berrange
33078953caf3SDaniel P. Berrangeif test "$auth_pam" != "no"; then
33088953caf3SDaniel P. Berrange    cat > $TMPC <<EOF
33098953caf3SDaniel P. Berrange#include <security/pam_appl.h>
33108953caf3SDaniel P. Berrange#include <stdio.h>
33118953caf3SDaniel P. Berrangeint main(void) {
33128953caf3SDaniel P. Berrange   const char *service_name = "qemu";
33138953caf3SDaniel P. Berrange   const char *user = "frank";
33149c9642d0SDr. David Alan Gilbert   const struct pam_conv pam_conv = { 0 };
33158953caf3SDaniel P. Berrange   pam_handle_t *pamh = NULL;
33169c9642d0SDr. David Alan Gilbert   pam_start(service_name, user, &pam_conv, &pamh);
33178953caf3SDaniel P. Berrange   return 0;
33188953caf3SDaniel P. Berrange}
33198953caf3SDaniel P. BerrangeEOF
33208953caf3SDaniel P. Berrange    if compile_prog "" "-lpam" ; then
33218953caf3SDaniel P. Berrange        auth_pam=yes
33228953caf3SDaniel P. Berrange    else
33238953caf3SDaniel P. Berrange        if test "$auth_pam" = "yes"; then
33248953caf3SDaniel P. Berrange            feature_not_found "PAM" "Install PAM development package"
33258953caf3SDaniel P. Berrange        else
33268953caf3SDaniel P. Berrange            auth_pam=no
33278953caf3SDaniel P. Berrange        fi
33288953caf3SDaniel P. Berrange    fi
33298953caf3SDaniel P. Berrangefi
33308953caf3SDaniel P. Berrange
33318953caf3SDaniel P. Berrange##########################################
3332559607eaSDaniel P. Berrange# getifaddrs (for tests/test-io-channel-socket )
3333559607eaSDaniel P. Berrange
3334559607eaSDaniel P. Berrangehave_ifaddrs_h=yes
3335559607eaSDaniel P. Berrangeif ! check_include "ifaddrs.h" ; then
3336559607eaSDaniel P. Berrange  have_ifaddrs_h=no
3337559607eaSDaniel P. Berrangefi
3338559607eaSDaniel P. Berrange
3339e865b97fSChen Gang#########################################
3340e865b97fSChen Gang# libdrm check
3341e865b97fSChen Ganghave_drm_h=no
3342e865b97fSChen Gangif check_include "libdrm/drm.h" ; then
3343e865b97fSChen Gang    have_drm_h=yes
3344e865b97fSChen Gangfi
3345e865b97fSChen Gang
33462a4b472cSDavid CARLIER#########################################
33472a4b472cSDavid CARLIER# sys/signal.h check
33482a4b472cSDavid CARLIERhave_sys_signal_h=no
33492a4b472cSDavid CARLIERif check_include "sys/signal.h" ; then
33502a4b472cSDavid CARLIER  have_sys_signal_h=yes
33512a4b472cSDavid CARLIERfi
33522a4b472cSDavid CARLIER
3353559607eaSDaniel P. Berrange##########################################
3354bbbf9bfbSStefan Weil# VTE probe
3355bbbf9bfbSStefan Weil
3356bbbf9bfbSStefan Weilif test "$vte" != "no"; then
3357c6feff9eSCole Robinson    vteminversion="0.32.0"
3358c6feff9eSCole Robinson    if $pkg_config --exists "vte-2.91"; then
3359c6feff9eSCole Robinson      vtepackage="vte-2.91"
3360c6feff9eSCole Robinson    else
3361528de90aSDaniel P. Berrange      vtepackage="vte-2.90"
3362c6feff9eSCole Robinson    fi
3363c6feff9eSCole Robinson    if $pkg_config --exists "$vtepackage >= $vteminversion"; then
336489138857SStefan Weil        vte_cflags=$($pkg_config --cflags $vtepackage)
336589138857SStefan Weil        vte_libs=$($pkg_config --libs $vtepackage)
336689138857SStefan Weil        vteversion=$($pkg_config --modversion $vtepackage)
3367bbbf9bfbSStefan Weil        vte="yes"
3368bbbf9bfbSStefan Weil    elif test "$vte" = "yes"; then
3369c6feff9eSCole Robinson        feature_not_found "vte" "Install libvte-2.90/2.91 devel"
33709e04c683SStefan Weil    else
3371bbbf9bfbSStefan Weil        vte="no"
3372a4ccabcfSAnthony Liguori    fi
3373a4ccabcfSAnthony Liguorifi
3374a4ccabcfSAnthony Liguori
3375a4ccabcfSAnthony Liguori##########################################
33762da776dbSMichael R. Hines# RDMA needs OpenFabrics libraries
33772da776dbSMichael R. Hinesif test "$rdma" != "no" ; then
33782da776dbSMichael R. Hines  cat > $TMPC <<EOF
33792da776dbSMichael R. Hines#include <rdma/rdma_cma.h>
33802da776dbSMichael R. Hinesint main(void) { return 0; }
33812da776dbSMichael R. HinesEOF
3382ef6d4ccdSYuval Shaia  rdma_libs="-lrdmacm -libverbs -libumad"
33832da776dbSMichael R. Hines  if compile_prog "" "$rdma_libs" ; then
33842da776dbSMichael R. Hines    rdma="yes"
33852da776dbSMichael R. Hines  else
33862da776dbSMichael R. Hines    if test "$rdma" = "yes" ; then
33872da776dbSMichael R. Hines        error_exit \
3388ef6d4ccdSYuval Shaia            " OpenFabrics librdmacm/libibverbs/libibumad not present." \
33892da776dbSMichael R. Hines            " Your options:" \
3390ef6d4ccdSYuval Shaia            "  (1) Fast: Install infiniband packages (devel) from your distro." \
33912da776dbSMichael R. Hines            "  (2) Cleanest: Install libraries from www.openfabrics.org" \
33922da776dbSMichael R. Hines            "  (3) Also: Install softiwarp if you don't have RDMA hardware"
33932da776dbSMichael R. Hines    fi
33942da776dbSMichael R. Hines    rdma="no"
33952da776dbSMichael R. Hines  fi
33962da776dbSMichael R. Hinesfi
33972da776dbSMichael R. Hines
339821ab34c9SMarcel Apfelbaum##########################################
339921ab34c9SMarcel Apfelbaum# PVRDMA detection
340021ab34c9SMarcel Apfelbaum
340121ab34c9SMarcel Apfelbaumcat > $TMPC <<EOF &&
340221ab34c9SMarcel Apfelbaum#include <sys/mman.h>
340321ab34c9SMarcel Apfelbaum
340421ab34c9SMarcel Apfelbaumint
340521ab34c9SMarcel Apfelbaummain(void)
340621ab34c9SMarcel Apfelbaum{
340721ab34c9SMarcel Apfelbaum    char buf = 0;
340821ab34c9SMarcel Apfelbaum    void *addr = &buf;
340921ab34c9SMarcel Apfelbaum    addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
341021ab34c9SMarcel Apfelbaum
341121ab34c9SMarcel Apfelbaum    return 0;
341221ab34c9SMarcel Apfelbaum}
341321ab34c9SMarcel ApfelbaumEOF
341421ab34c9SMarcel Apfelbaum
341521ab34c9SMarcel Apfelbaumif test "$rdma" = "yes" ; then
341621ab34c9SMarcel Apfelbaum    case "$pvrdma" in
341721ab34c9SMarcel Apfelbaum    "")
341821ab34c9SMarcel Apfelbaum        if compile_prog "" ""; then
341921ab34c9SMarcel Apfelbaum            pvrdma="yes"
342021ab34c9SMarcel Apfelbaum        else
342121ab34c9SMarcel Apfelbaum            pvrdma="no"
342221ab34c9SMarcel Apfelbaum        fi
342321ab34c9SMarcel Apfelbaum        ;;
342421ab34c9SMarcel Apfelbaum    "yes")
342521ab34c9SMarcel Apfelbaum        if ! compile_prog "" ""; then
342621ab34c9SMarcel Apfelbaum            error_exit "PVRDMA is not supported since mremap is not implemented"
342721ab34c9SMarcel Apfelbaum        fi
342821ab34c9SMarcel Apfelbaum        pvrdma="yes"
342921ab34c9SMarcel Apfelbaum        ;;
343021ab34c9SMarcel Apfelbaum    "no")
343121ab34c9SMarcel Apfelbaum        pvrdma="no"
343221ab34c9SMarcel Apfelbaum        ;;
343321ab34c9SMarcel Apfelbaum    esac
343421ab34c9SMarcel Apfelbaumelse
343521ab34c9SMarcel Apfelbaum    if test "$pvrdma" = "yes" ; then
343621ab34c9SMarcel Apfelbaum        error_exit "PVRDMA requires rdma suppport"
343721ab34c9SMarcel Apfelbaum    fi
343821ab34c9SMarcel Apfelbaum    pvrdma="no"
343921ab34c9SMarcel Apfelbaumfi
344095c6bff3SBenoît Canet
3441ee108585SYuval Shaia# Let's see if enhanced reg_mr is supported
3442ee108585SYuval Shaiaif test "$pvrdma" = "yes" ; then
3443ee108585SYuval Shaia
3444ee108585SYuval Shaiacat > $TMPC <<EOF &&
3445ee108585SYuval Shaia#include <infiniband/verbs.h>
3446ee108585SYuval Shaia
3447ee108585SYuval Shaiaint
3448ee108585SYuval Shaiamain(void)
3449ee108585SYuval Shaia{
3450ee108585SYuval Shaia    struct ibv_mr *mr;
3451ee108585SYuval Shaia    struct ibv_pd *pd = NULL;
3452ee108585SYuval Shaia    size_t length = 10;
3453ee108585SYuval Shaia    uint64_t iova = 0;
3454ee108585SYuval Shaia    int access = 0;
3455ee108585SYuval Shaia    void *addr = NULL;
3456ee108585SYuval Shaia
3457ee108585SYuval Shaia    mr = ibv_reg_mr_iova(pd, addr, length, iova, access);
3458ee108585SYuval Shaia
3459ee108585SYuval Shaia    ibv_dereg_mr(mr);
3460ee108585SYuval Shaia
3461ee108585SYuval Shaia    return 0;
3462ee108585SYuval Shaia}
3463ee108585SYuval ShaiaEOF
3464ee108585SYuval Shaia    if ! compile_prog "" "-libverbs"; then
3465ee108585SYuval Shaia        QEMU_CFLAGS="$QEMU_CFLAGS -DLEGACY_RDMA_REG_MR"
3466ee108585SYuval Shaia    fi
3467ee108585SYuval Shaiafi
3468ee108585SYuval Shaia
346995c6bff3SBenoît Canet##########################################
3470c1bb86cdSEric Blake# xfsctl() probe, used for file-posix.c
3471dce512deSChristoph Hellwigif test "$xfs" != "no" ; then
3472dce512deSChristoph Hellwig  cat > $TMPC << EOF
3473ffc41d10SStefan Weil#include <stddef.h>  /* NULL */
3474dce512deSChristoph Hellwig#include <xfs/xfs.h>
3475dce512deSChristoph Hellwigint main(void)
3476dce512deSChristoph Hellwig{
3477dce512deSChristoph Hellwig    xfsctl(NULL, 0, 0, NULL);
3478dce512deSChristoph Hellwig    return 0;
3479dce512deSChristoph Hellwig}
3480dce512deSChristoph HellwigEOF
3481dce512deSChristoph Hellwig  if compile_prog "" "" ; then
3482dce512deSChristoph Hellwig    xfs="yes"
3483dce512deSChristoph Hellwig  else
3484dce512deSChristoph Hellwig    if test "$xfs" = "yes" ; then
348521684af0SStewart Smith      feature_not_found "xfs" "Instal xfsprogs/xfslibs devel"
3486dce512deSChristoph Hellwig    fi
3487dce512deSChristoph Hellwig    xfs=no
3488dce512deSChristoph Hellwig  fi
3489dce512deSChristoph Hellwigfi
3490dce512deSChristoph Hellwig
3491dce512deSChristoph Hellwig##########################################
34928a16d273Sths# vde libraries probe
3493dfb278bdSJuan Quintelaif test "$vde" != "no" ; then
34944baae0acSJuan Quintela  vde_libs="-lvdeplug"
34958a16d273Sths  cat > $TMPC << EOF
34968a16d273Sths#include <libvdeplug.h>
34974a7f0e06Spbrookint main(void)
34984a7f0e06Spbrook{
34994a7f0e06Spbrook    struct vde_open_args a = {0, 0, 0};
3500fea08e08SPeter Maydell    char s[] = "";
3501fea08e08SPeter Maydell    vde_open(s, s, &a);
35024a7f0e06Spbrook    return 0;
35034a7f0e06Spbrook}
35048a16d273SthsEOF
350552166aa0SJuan Quintela  if compile_prog "" "$vde_libs" ; then
35064baae0acSJuan Quintela    vde=yes
3507dfb278bdSJuan Quintela  else
3508dfb278bdSJuan Quintela    if test "$vde" = "yes" ; then
350921684af0SStewart Smith      feature_not_found "vde" "Install vde (Virtual Distributed Ethernet) devel"
3510dfb278bdSJuan Quintela    fi
3511dfb278bdSJuan Quintela    vde=no
35128a16d273Sths  fi
35138a16d273Sthsfi
35148a16d273Sths
35158a16d273Sths##########################################
35160a985b37SVincenzo Maffione# netmap support probe
35170a985b37SVincenzo Maffione# Apart from looking for netmap headers, we make sure that the host API version
35180a985b37SVincenzo Maffione# supports the netmap backend (>=11). The upper bound (15) is meant to simulate
35190a985b37SVincenzo Maffione# a minor/major version number. Minor new features will be marked with values up
35200a985b37SVincenzo Maffione# to 15, and if something happens that requires a change to the backend we will
35210a985b37SVincenzo Maffione# move above 15, submit the backend fixes and modify this two bounds.
352258952137SVincenzo Maffioneif test "$netmap" != "no" ; then
352358952137SVincenzo Maffione  cat > $TMPC << EOF
352458952137SVincenzo Maffione#include <inttypes.h>
352558952137SVincenzo Maffione#include <net/if.h>
352658952137SVincenzo Maffione#include <net/netmap.h>
352758952137SVincenzo Maffione#include <net/netmap_user.h>
35280a985b37SVincenzo Maffione#if (NETMAP_API < 11) || (NETMAP_API > 15)
35290a985b37SVincenzo Maffione#error
35300a985b37SVincenzo Maffione#endif
353158952137SVincenzo Maffioneint main(void) { return 0; }
353258952137SVincenzo MaffioneEOF
353358952137SVincenzo Maffione  if compile_prog "" "" ; then
353458952137SVincenzo Maffione    netmap=yes
353558952137SVincenzo Maffione  else
353658952137SVincenzo Maffione    if test "$netmap" = "yes" ; then
353758952137SVincenzo Maffione      feature_not_found "netmap"
353858952137SVincenzo Maffione    fi
353958952137SVincenzo Maffione    netmap=no
354058952137SVincenzo Maffione  fi
354158952137SVincenzo Maffionefi
354258952137SVincenzo Maffione
354358952137SVincenzo Maffione##########################################
354447e98658SCorey Bryant# libcap-ng library probe
354547e98658SCorey Bryantif test "$cap_ng" != "no" ; then
354647e98658SCorey Bryant  cap_libs="-lcap-ng"
354747e98658SCorey Bryant  cat > $TMPC << EOF
354847e98658SCorey Bryant#include <cap-ng.h>
354947e98658SCorey Bryantint main(void)
355047e98658SCorey Bryant{
355147e98658SCorey Bryant    capng_capability_to_name(CAPNG_EFFECTIVE);
355247e98658SCorey Bryant    return 0;
355347e98658SCorey Bryant}
355447e98658SCorey BryantEOF
355547e98658SCorey Bryant  if compile_prog "" "$cap_libs" ; then
355647e98658SCorey Bryant    cap_ng=yes
355747e98658SCorey Bryant  else
355847e98658SCorey Bryant    if test "$cap_ng" = "yes" ; then
355921684af0SStewart Smith      feature_not_found "cap_ng" "Install libcap-ng devel"
356047e98658SCorey Bryant    fi
356147e98658SCorey Bryant    cap_ng=no
356247e98658SCorey Bryant  fi
356347e98658SCorey Bryantfi
356447e98658SCorey Bryant
356547e98658SCorey Bryant##########################################
3566c2de5c91Smalc# Sound support libraries probe
35678f28f3fbSths
356889138857SStefan Weilaudio_drv_list=$(echo "$audio_drv_list" | sed -e 's/,/ /g')
3569c2de5c91Smalcfor drv in $audio_drv_list; do
3570c2de5c91Smalc    case $drv in
3571e42975a1SGerd Hoffmann    alsa | try-alsa)
3572c80a867fSGerd Hoffmann    if $pkg_config alsa --exists; then
3573c80a867fSGerd Hoffmann        alsa_libs=$($pkg_config alsa --libs)
3574478e943fSPaolo Bonzini        alsa_cflags=$($pkg_config alsa --cflags)
3575478e943fSPaolo Bonzini        alsa=yes
3576e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3577e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa/alsa/')
3578e42975a1SGerd Hoffmann        fi
3579e42975a1SGerd Hoffmann    else
3580e42975a1SGerd Hoffmann        if test "$drv" = "try-alsa"; then
3581e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-alsa//')
3582c80a867fSGerd Hoffmann        else
3583c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3584c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3585c80a867fSGerd Hoffmann        fi
3586e42975a1SGerd Hoffmann    fi
3587c2de5c91Smalc    ;;
3588c2de5c91Smalc
3589e42975a1SGerd Hoffmann    pa | try-pa)
3590c80a867fSGerd Hoffmann    if $pkg_config libpulse --exists; then
3591478e943fSPaolo Bonzini        libpulse=yes
3592c80a867fSGerd Hoffmann        pulse_libs=$($pkg_config libpulse --libs)
3593478e943fSPaolo Bonzini        pulse_cflags=$($pkg_config libpulse --cflags)
3594e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3595e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa/pa/')
3596e42975a1SGerd Hoffmann        fi
3597e42975a1SGerd Hoffmann    else
3598e42975a1SGerd Hoffmann        if test "$drv" = "try-pa"; then
3599e42975a1SGerd Hoffmann            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-pa//')
3600c80a867fSGerd Hoffmann        else
3601c80a867fSGerd Hoffmann            error_exit "$drv check failed" \
3602c80a867fSGerd Hoffmann                "Make sure to have the $drv libs and headers installed."
3603c80a867fSGerd Hoffmann        fi
3604e42975a1SGerd Hoffmann    fi
3605b8e59f18Smalc    ;;
3606b8e59f18Smalc
3607373967b2SGerd Hoffmann    sdl)
3608373967b2SGerd Hoffmann    if test "$sdl" = "no"; then
3609373967b2SGerd Hoffmann        error_exit "sdl not found or disabled, can not use sdl audio driver"
3610373967b2SGerd Hoffmann    fi
3611373967b2SGerd Hoffmann    ;;
3612373967b2SGerd Hoffmann
3613e42975a1SGerd Hoffmann    try-sdl)
3614e42975a1SGerd Hoffmann    if test "$sdl" = "no"; then
3615e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl//')
3616e42975a1SGerd Hoffmann    else
3617e42975a1SGerd Hoffmann        audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-sdl/sdl/')
3618e42975a1SGerd Hoffmann    fi
3619e42975a1SGerd Hoffmann    ;;
3620e42975a1SGerd Hoffmann
3621997e690aSJuan Quintela    coreaudio)
3622b1149911SFam Zheng      coreaudio_libs="-framework CoreAudio"
3623997e690aSJuan Quintela    ;;
3624997e690aSJuan Quintela
3625a4bf6780SJuan Quintela    dsound)
3626b1149911SFam Zheng      dsound_libs="-lole32 -ldxguid"
3627d5631638Smalc      audio_win_int="yes"
3628a4bf6780SJuan Quintela    ;;
3629a4bf6780SJuan Quintela
3630a4bf6780SJuan Quintela    oss)
3631b1149911SFam Zheng      oss_libs="$oss_lib"
3632a4bf6780SJuan Quintela    ;;
3633a4bf6780SJuan Quintela
36342e445703SGeoffrey McRae    jack | try-jack)
36352e445703SGeoffrey McRae    if $pkg_config jack --exists; then
3636478e943fSPaolo Bonzini        libjack=yes
36372e445703SGeoffrey McRae        jack_libs=$($pkg_config jack --libs)
36382e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
36392e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
36402e445703SGeoffrey McRae        fi
36412e445703SGeoffrey McRae    else
36422e445703SGeoffrey McRae        if test "$drv" = "try-jack"; then
36432e445703SGeoffrey McRae            audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
36442e445703SGeoffrey McRae        else
36452e445703SGeoffrey McRae            error_exit "$drv check failed" \
36462e445703SGeoffrey McRae                "Make sure to have the $drv libs and headers installed."
36472e445703SGeoffrey McRae        fi
36482e445703SGeoffrey McRae    fi
36492e445703SGeoffrey McRae    ;;
36502e445703SGeoffrey McRae
3651e4c63a6aSmalc    *)
36521c9b2a52Smalc    echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
365376ad07a4SPeter Maydell        error_exit "Unknown driver '$drv' selected" \
365476ad07a4SPeter Maydell            "Possible drivers are: $audio_possible_drivers"
3655e4c63a6aSmalc    }
3656e4c63a6aSmalc    ;;
3657c2de5c91Smalc    esac
3658c2de5c91Smalcdone
36598f28f3fbSths
36604d3b6f6eSbalrog##########################################
36612e4d9fb1Saurel32# BrlAPI probe
36622e4d9fb1Saurel32
36634ffcedb6SJuan Quintelaif test "$brlapi" != "no" ; then
3664eb82284fSJuan Quintela  brlapi_libs="-lbrlapi"
36652e4d9fb1Saurel32  cat > $TMPC << EOF
36662e4d9fb1Saurel32#include <brlapi.h>
3667832ce9c2SScott Wood#include <stddef.h>
36682e4d9fb1Saurel32int main( void ) { return brlapi__openConnection (NULL, NULL, NULL); }
36692e4d9fb1Saurel32EOF
367052166aa0SJuan Quintela  if compile_prog "" "$brlapi_libs" ; then
36712e4d9fb1Saurel32    brlapi=yes
36724ffcedb6SJuan Quintela  else
36734ffcedb6SJuan Quintela    if test "$brlapi" = "yes" ; then
367421684af0SStewart Smith      feature_not_found "brlapi" "Install brlapi devel"
36754ffcedb6SJuan Quintela    fi
36764ffcedb6SJuan Quintela    brlapi=no
3677eb82284fSJuan Quintela  fi
3678eb82284fSJuan Quintelafi
36792e4d9fb1Saurel32
36802e4d9fb1Saurel32##########################################
3681e08bb301SSamuel Thibault# iconv probe
3682e08bb301SSamuel Thibaultif test "$iconv" != "no" ; then
3683e08bb301SSamuel Thibault  cat > $TMPC << EOF
3684e08bb301SSamuel Thibault#include <iconv.h>
3685e08bb301SSamuel Thibaultint main(void) {
3686e08bb301SSamuel Thibault  iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
3687e08bb301SSamuel Thibault  return conv != (iconv_t) -1;
3688e08bb301SSamuel Thibault}
3689e08bb301SSamuel ThibaultEOF
3690e08bb301SSamuel Thibault  iconv_prefix_list="/usr/local:/usr"
3691e08bb301SSamuel Thibault  iconv_lib_list=":-liconv"
3692e08bb301SSamuel Thibault  IFS=:
3693e08bb301SSamuel Thibault  for iconv_prefix in $iconv_prefix_list; do
3694e08bb301SSamuel Thibault    IFS=:
3695e08bb301SSamuel Thibault    iconv_cflags="-I$iconv_prefix/include"
3696e08bb301SSamuel Thibault    iconv_ldflags="-L$iconv_prefix/lib"
3697e08bb301SSamuel Thibault    for iconv_link in $iconv_lib_list; do
3698e08bb301SSamuel Thibault      unset IFS
3699e08bb301SSamuel Thibault      iconv_lib="$iconv_ldflags $iconv_link"
3700e08bb301SSamuel Thibault      echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
3701e08bb301SSamuel Thibault      if compile_prog "$iconv_cflags" "$iconv_lib" ; then
3702e08bb301SSamuel Thibault        iconv_found=yes
3703e08bb301SSamuel Thibault        break
3704e08bb301SSamuel Thibault      fi
3705e08bb301SSamuel Thibault    done
3706e08bb301SSamuel Thibault    if test "$iconv_found" = yes ; then
3707e08bb301SSamuel Thibault      break
3708e08bb301SSamuel Thibault    fi
3709e08bb301SSamuel Thibault  done
3710e08bb301SSamuel Thibault  if test "$iconv_found" = "yes" ; then
3711e08bb301SSamuel Thibault    iconv=yes
3712e08bb301SSamuel Thibault  else
3713e08bb301SSamuel Thibault    if test "$iconv" = "yes" ; then
3714e08bb301SSamuel Thibault      feature_not_found "iconv" "Install iconv devel"
3715e08bb301SSamuel Thibault    fi
3716e08bb301SSamuel Thibault    iconv=no
3717e08bb301SSamuel Thibault  fi
3718e08bb301SSamuel Thibaultfi
3719e08bb301SSamuel Thibault
3720e08bb301SSamuel Thibault##########################################
37214d3b6f6eSbalrog# curses probe
3722e08bb301SSamuel Thibaultif test "$iconv" = "no" ; then
3723e08bb301SSamuel Thibault  # curses will need iconv
3724e08bb301SSamuel Thibault  curses=no
3725e08bb301SSamuel Thibaultfi
3726a3605bf6SMichael Tokarevif test "$curses" != "no" ; then
3727e095e2f3SStefan Weil  if test "$mingw32" = "yes" ; then
37288ddc5bf9SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
37298ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
3730e095e2f3SStefan Weil  else
37317c703002SSamuel Thibault    curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
37328ddc5bf9SSamuel Thibault    curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
3733e095e2f3SStefan Weil  fi
3734c584a6d0SJuan Quintela  curses_found=no
37354d3b6f6eSbalrog  cat > $TMPC << EOF
37368ddc5bf9SSamuel Thibault#include <locale.h>
37374d3b6f6eSbalrog#include <curses.h>
37388ddc5bf9SSamuel Thibault#include <wchar.h>
37392f8b7cd5SSamuel Thibault#include <langinfo.h>
3740ef9a2524SStefan Weilint main(void) {
37412f8b7cd5SSamuel Thibault  const char *codeset;
37428ddc5bf9SSamuel Thibault  wchar_t wch = L'w';
37438ddc5bf9SSamuel Thibault  setlocale(LC_ALL, "");
3744ef9a2524SStefan Weil  resize_term(0, 0);
37458ddc5bf9SSamuel Thibault  addwstr(L"wide chars\n");
37468ddc5bf9SSamuel Thibault  addnwstr(&wch, 1);
37477c703002SSamuel Thibault  add_wch(WACS_DEGREE);
37482f8b7cd5SSamuel Thibault  codeset = nl_langinfo(CODESET);
37492f8b7cd5SSamuel Thibault  return codeset != 0;
3750ef9a2524SStefan Weil}
37514d3b6f6eSbalrogEOF
3752ecbe251fSVadim Evard  IFS=:
37538ddc5bf9SSamuel Thibault  for curses_inc in $curses_inc_list; do
3754b01a4fd3SPeter Maydell    # Make sure we get the wide character prototypes
3755b01a4fd3SPeter Maydell    curses_inc="-DNCURSES_WIDECHAR $curses_inc"
37567c703002SSamuel Thibault    IFS=:
37578ddc5bf9SSamuel Thibault    for curses_lib in $curses_lib_list; do
3758ecbe251fSVadim Evard      unset IFS
37598ddc5bf9SSamuel Thibault      if compile_prog "$curses_inc" "$curses_lib" ; then
3760c584a6d0SJuan Quintela        curses_found=yes
37614f78ef9aSJuan Quintela        break
37624d3b6f6eSbalrog      fi
37634f78ef9aSJuan Quintela    done
37647c703002SSamuel Thibault    if test "$curses_found" = yes ; then
37657c703002SSamuel Thibault      break
37667c703002SSamuel Thibault    fi
37678ddc5bf9SSamuel Thibault  done
3768ecbe251fSVadim Evard  unset IFS
3769c584a6d0SJuan Quintela  if test "$curses_found" = "yes" ; then
3770c584a6d0SJuan Quintela    curses=yes
3771c584a6d0SJuan Quintela  else
3772c584a6d0SJuan Quintela    if test "$curses" = "yes" ; then
377321684af0SStewart Smith      feature_not_found "curses" "Install ncurses devel"
3774c584a6d0SJuan Quintela    fi
3775c584a6d0SJuan Quintela    curses=no
3776c584a6d0SJuan Quintela  fi
37774f78ef9aSJuan Quintelafi
37784d3b6f6eSbalrog
3779414f0dabSblueswir1##########################################
3780769ce76dSAlexander Graf# curl probe
3781a3605bf6SMichael Tokarevif test "$curl" != "no" ; then
378265d5d3f9SStefan Weil  if $pkg_config libcurl --exists; then
3783a8bd70adSPaolo Bonzini    curlconfig="$pkg_config libcurl"
37844e2b0658SPaolo Bonzini  else
37854e2b0658SPaolo Bonzini    curlconfig=curl-config
37864e2b0658SPaolo Bonzini  fi
3787769ce76dSAlexander Graf  cat > $TMPC << EOF
3788769ce76dSAlexander Graf#include <curl/curl.h>
37890b862cedSPeter Maydellint main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
3790769ce76dSAlexander GrafEOF
379189138857SStefan Weil  curl_cflags=$($curlconfig --cflags 2>/dev/null)
379289138857SStefan Weil  curl_libs=$($curlconfig --libs 2>/dev/null)
3793b1d5a277SJuan Quintela  if compile_prog "$curl_cflags" "$curl_libs" ; then
3794769ce76dSAlexander Graf    curl=yes
3795788c8196SJuan Quintela  else
3796788c8196SJuan Quintela    if test "$curl" = "yes" ; then
379721684af0SStewart Smith      feature_not_found "curl" "Install libcurl devel"
3798788c8196SJuan Quintela    fi
3799788c8196SJuan Quintela    curl=no
3800769ce76dSAlexander Graf  fi
3801769ce76dSAlexander Graffi # test "$curl"
3802769ce76dSAlexander Graf
3803769ce76dSAlexander Graf##########################################
3804e18df141SAnthony Liguori# glib support probe
3805a52d28afSPaolo Bonzini
380600f2cfbbSDaniel P. Berrangéglib_req_ver=2.48
3807aa0d1f44SPaolo Bonziniglib_modules=gthread-2.0
3808aa0d1f44SPaolo Bonziniif test "$modules" = yes; then
3809a88afc64SGerd Hoffmann    glib_modules="$glib_modules gmodule-export-2.0"
3810aa0d1f44SPaolo Bonzinifi
381154cb65d8SEmilio G. Cotaif test "$plugins" = yes; then
381254cb65d8SEmilio G. Cota    glib_modules="$glib_modules gmodule-2.0"
381354cb65d8SEmilio G. Cotafi
3814e26110cfSFam Zheng
38154eaf7202SSameeh Jubran# This workaround is required due to a bug in pkg-config file for glib as it
38164eaf7202SSameeh Jubran# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
38174eaf7202SSameeh Jubran
3818e633a5c6SEric Blakeif test "$static" = yes && test "$mingw32" = yes; then
38194eaf7202SSameeh Jubran    QEMU_CFLAGS="-DGLIB_STATIC_COMPILATION $QEMU_CFLAGS"
38204eaf7202SSameeh Jubranfi
38214eaf7202SSameeh Jubran
3822aa0d1f44SPaolo Bonzinifor i in $glib_modules; do
3823e26110cfSFam Zheng    if $pkg_config --atleast-version=$glib_req_ver $i; then
382489138857SStefan Weil        glib_cflags=$($pkg_config --cflags $i)
382589138857SStefan Weil        glib_libs=$($pkg_config --libs $i)
38264a058899SMarc-André Lureau        QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
382714015304SAnthony Liguori        LIBS="$glib_libs $LIBS"
3828e18df141SAnthony Liguori    else
3829e26110cfSFam Zheng        error_exit "glib-$glib_req_ver $i is required to compile QEMU"
3830e26110cfSFam Zheng    fi
3831e26110cfSFam Zhengdone
3832e26110cfSFam Zheng
3833f876b765SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
3834f876b765SMarc-André Lureau    gio=yes
3835f876b765SMarc-André Lureau    gio_cflags=$($pkg_config --cflags gio-2.0)
3836f876b765SMarc-André Lureau    gio_libs=$($pkg_config --libs gio-2.0)
383725a97a56SMarc-André Lureau    gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
38380dba4897SMarc-André Lureau    if [ ! -x "$gdbus_codegen" ]; then
38390dba4897SMarc-André Lureau        gdbus_codegen=
38400dba4897SMarc-André Lureau    fi
3841f876b765SMarc-André Lureauelse
3842f876b765SMarc-André Lureau    gio=no
3843f876b765SMarc-André Lureaufi
3844f876b765SMarc-André Lureau
384525a97a56SMarc-André Lureauif $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
384625a97a56SMarc-André Lureau    gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
384725a97a56SMarc-André Lureau    gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
384825a97a56SMarc-André Lureaufi
384925a97a56SMarc-André Lureau
3850977a82abSDaniel P. Berrange# Sanity check that the current size_t matches the
3851977a82abSDaniel P. Berrange# size that glib thinks it should be. This catches
3852977a82abSDaniel P. Berrange# problems on multi-arch where people try to build
3853977a82abSDaniel P. Berrange# 32-bit QEMU while pointing at 64-bit glib headers
3854977a82abSDaniel P. Berrangecat > $TMPC <<EOF
3855977a82abSDaniel P. Berrange#include <glib.h>
3856977a82abSDaniel P. Berrange#include <unistd.h>
3857977a82abSDaniel P. Berrange
3858977a82abSDaniel P. Berrange#define QEMU_BUILD_BUG_ON(x) \
3859977a82abSDaniel P. Berrange  typedef char qemu_build_bug_on[(x)?-1:1] __attribute__((unused));
3860977a82abSDaniel P. Berrange
3861977a82abSDaniel P. Berrangeint main(void) {
3862977a82abSDaniel P. Berrange   QEMU_BUILD_BUG_ON(sizeof(size_t) != GLIB_SIZEOF_SIZE_T);
3863977a82abSDaniel P. Berrange   return 0;
3864977a82abSDaniel P. Berrange}
3865977a82abSDaniel P. BerrangeEOF
3866977a82abSDaniel P. Berrange
38675919e032SStefan Weilif ! compile_prog "$CFLAGS" "$LIBS" ; then
3868977a82abSDaniel P. Berrange    error_exit "sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T."\
3869977a82abSDaniel P. Berrange               "You probably need to set PKG_CONFIG_LIBDIR"\
3870977a82abSDaniel P. Berrange	       "to point to the right pkg-config files for your"\
3871977a82abSDaniel P. Berrange	       "build target"
3872977a82abSDaniel P. Berrangefi
3873977a82abSDaniel P. Berrange
3874bbbf2e04SJohn Snow# Silence clang 3.5.0 warnings about glib attribute __alloc_size__ usage
3875bbbf2e04SJohn Snowcat > $TMPC << EOF
3876bbbf2e04SJohn Snow#include <glib.h>
3877bbbf2e04SJohn Snowint main(void) { return 0; }
3878bbbf2e04SJohn SnowEOF
3879bbbf2e04SJohn Snowif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
3880bbbf2e04SJohn Snow    if cc_has_warning_flag "-Wno-unknown-attributes"; then
3881bbbf2e04SJohn Snow        glib_cflags="-Wno-unknown-attributes $glib_cflags"
3882086d5f75SPaolo Bonzini        QEMU_CFLAGS="-Wno-unknown-attributes $CFLAGS"
3883bbbf2e04SJohn Snow    fi
3884bbbf2e04SJohn Snowfi
3885bbbf2e04SJohn Snow
38869bda600bSEric Blake# Silence clang warnings triggered by glib < 2.57.2
38879bda600bSEric Blakecat > $TMPC << EOF
38889bda600bSEric Blake#include <glib.h>
38899bda600bSEric Blaketypedef struct Foo {
38909bda600bSEric Blake    int i;
38919bda600bSEric Blake} Foo;
38929bda600bSEric Blakestatic void foo_free(Foo *f)
38939bda600bSEric Blake{
38949bda600bSEric Blake    g_free(f);
38959bda600bSEric Blake}
38969bda600bSEric BlakeG_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
38979bda600bSEric Blakeint main(void) { return 0; }
38989bda600bSEric BlakeEOF
38999bda600bSEric Blakeif ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
39009bda600bSEric Blake    if cc_has_warning_flag "-Wno-unused-function"; then
39019bda600bSEric Blake        glib_cflags="$glib_cflags -Wno-unused-function"
39029bda600bSEric Blake        CFLAGS="$CFLAGS -Wno-unused-function"
39039bda600bSEric Blake    fi
39049bda600bSEric Blakefi
39059bda600bSEric Blake
3906e26110cfSFam Zheng##########################################
3907e26110cfSFam Zheng# SHA command probe for modules
3908e26110cfSFam Zhengif test "$modules" = yes; then
3909e26110cfSFam Zheng    shacmd_probe="sha1sum sha1 shasum"
3910e26110cfSFam Zheng    for c in $shacmd_probe; do
39118ccefb91SFam Zheng        if has $c; then
3912e26110cfSFam Zheng            shacmd="$c"
3913e26110cfSFam Zheng            break
3914e26110cfSFam Zheng        fi
3915e26110cfSFam Zheng    done
3916e26110cfSFam Zheng    if test "$shacmd" = ""; then
3917e26110cfSFam Zheng        error_exit "one of the checksum commands is required to enable modules: $shacmd_probe"
3918e26110cfSFam Zheng    fi
3919e18df141SAnthony Liguorifi
3920e18df141SAnthony Liguori
3921e18df141SAnthony Liguori##########################################
3922fe8fc5aeSPaolo Bonzini# libmpathpersist probe
3923fe8fc5aeSPaolo Bonzini
3924fe8fc5aeSPaolo Bonziniif test "$mpath" != "no" ; then
39251b0578f5SMurilo Opsfelder Araujo  # probe for the new API
3926fe8fc5aeSPaolo Bonzini  cat > $TMPC <<EOF
3927fe8fc5aeSPaolo Bonzini#include <libudev.h>
3928fe8fc5aeSPaolo Bonzini#include <mpath_persist.h>
3929fe8fc5aeSPaolo Bonziniunsigned mpath_mx_alloc_len = 1024;
3930fe8fc5aeSPaolo Bonziniint logsink;
3931b3f1c8c4SPaolo Bonzinistatic struct config *multipath_conf;
3932b3f1c8c4SPaolo Bonziniextern struct udev *udev;
3933b3f1c8c4SPaolo Bonziniextern struct config *get_multipath_config(void);
3934b3f1c8c4SPaolo Bonziniextern void put_multipath_config(struct config *conf);
3935b3f1c8c4SPaolo Bonzinistruct udev *udev;
3936b3f1c8c4SPaolo Bonzinistruct config *get_multipath_config(void) { return multipath_conf; }
3937b3f1c8c4SPaolo Bonzinivoid put_multipath_config(struct config *conf) { }
3938b3f1c8c4SPaolo Bonzini
3939fe8fc5aeSPaolo Bonziniint main(void) {
3940b3f1c8c4SPaolo Bonzini    udev = udev_new();
3941b3f1c8c4SPaolo Bonzini    multipath_conf = mpath_lib_init();
3942fe8fc5aeSPaolo Bonzini    return 0;
3943fe8fc5aeSPaolo Bonzini}
3944fe8fc5aeSPaolo BonziniEOF
3945fe8fc5aeSPaolo Bonzini  if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
3946fe8fc5aeSPaolo Bonzini    mpathpersist=yes
39471b0578f5SMurilo Opsfelder Araujo    mpathpersist_new_api=yes
39481b0578f5SMurilo Opsfelder Araujo  else
39491b0578f5SMurilo Opsfelder Araujo    # probe for the old API
39501b0578f5SMurilo Opsfelder Araujo    cat > $TMPC <<EOF
39511b0578f5SMurilo Opsfelder Araujo#include <libudev.h>
39521b0578f5SMurilo Opsfelder Araujo#include <mpath_persist.h>
39531b0578f5SMurilo Opsfelder Araujounsigned mpath_mx_alloc_len = 1024;
39541b0578f5SMurilo Opsfelder Araujoint logsink;
39551b0578f5SMurilo Opsfelder Araujoint main(void) {
39561b0578f5SMurilo Opsfelder Araujo    struct udev *udev = udev_new();
39571b0578f5SMurilo Opsfelder Araujo    mpath_lib_init(udev);
39581b0578f5SMurilo Opsfelder Araujo    return 0;
39591b0578f5SMurilo Opsfelder Araujo}
39601b0578f5SMurilo Opsfelder AraujoEOF
39611b0578f5SMurilo Opsfelder Araujo    if compile_prog "" "-ludev -lmultipath -lmpathpersist" ; then
39621b0578f5SMurilo Opsfelder Araujo      mpathpersist=yes
39631b0578f5SMurilo Opsfelder Araujo      mpathpersist_new_api=no
3964fe8fc5aeSPaolo Bonzini    else
3965fe8fc5aeSPaolo Bonzini      mpathpersist=no
3966fe8fc5aeSPaolo Bonzini    fi
39671b0578f5SMurilo Opsfelder Araujo  fi
3968fe8fc5aeSPaolo Bonzinielse
3969fe8fc5aeSPaolo Bonzini  mpathpersist=no
3970fe8fc5aeSPaolo Bonzinifi
3971fe8fc5aeSPaolo Bonzini
3972fe8fc5aeSPaolo Bonzini##########################################
3973e5d355d1Saliguori# pthread probe
39744b29ec41SBradPTHREADLIBS_LIST="-pthread -lpthread -lpthreadGC2"
39753c529d93Saliguori
3976e5d355d1Saliguoripthread=no
3977414f0dabSblueswir1cat > $TMPC << EOF
39783c529d93Saliguori#include <pthread.h>
39797a42bbe4SStefan Weilstatic void *f(void *p) { return NULL; }
39807a42bbe4SStefan Weilint main(void) {
39817a42bbe4SStefan Weil  pthread_t thread;
39827a42bbe4SStefan Weil  pthread_create(&thread, 0, f, 0);
39837a42bbe4SStefan Weil  return 0;
39847a42bbe4SStefan Weil}
3985414f0dabSblueswir1EOF
3986bd00d539SAndreas Färberif compile_prog "" "" ; then
3987bd00d539SAndreas Färber  pthread=yes
3988bd00d539SAndreas Färberelse
3989de65fe0fSSebastian Herbszt  for pthread_lib in $PTHREADLIBS_LIST; do
399052166aa0SJuan Quintela    if compile_prog "" "$pthread_lib" ; then
3991e5d355d1Saliguori      pthread=yes
3992e3c56761SPeter Portante      found=no
3993e3c56761SPeter Portante      for lib_entry in $LIBS; do
3994e3c56761SPeter Portante        if test "$lib_entry" = "$pthread_lib"; then
3995e3c56761SPeter Portante          found=yes
3996e3c56761SPeter Portante          break
3997e3c56761SPeter Portante        fi
3998e3c56761SPeter Portante      done
3999e3c56761SPeter Portante      if test "$found" = "no"; then
40005572b539SJuan Quintela        LIBS="$pthread_lib $LIBS"
4001e3c56761SPeter Portante      fi
4002409437e1SDaniel P. Berrange      PTHREAD_LIB="$pthread_lib"
4003de65fe0fSSebastian Herbszt      break
4004414f0dabSblueswir1    fi
4005de65fe0fSSebastian Herbszt  done
4006bd00d539SAndreas Färberfi
4007414f0dabSblueswir1
4008e633a5c6SEric Blakeif test "$mingw32" != yes && test "$pthread" = no; then
400976ad07a4SPeter Maydell  error_exit "pthread check failed" \
401076ad07a4SPeter Maydell      "Make sure to have the pthread libs and headers installed."
4011e5d355d1Saliguorifi
4012e5d355d1Saliguori
4013479a5747SRoman Bolshakov# check for pthread_setname_np with thread id
4014479a5747SRoman Bolshakovpthread_setname_np_w_tid=no
40155c312079SDr. David Alan Gilbertcat > $TMPC << EOF
40165c312079SDr. David Alan Gilbert#include <pthread.h>
40175c312079SDr. David Alan Gilbert
40185c312079SDr. David Alan Gilbertstatic void *f(void *p) { return NULL; }
40195c312079SDr. David Alan Gilbertint main(void)
40205c312079SDr. David Alan Gilbert{
40215c312079SDr. David Alan Gilbert    pthread_t thread;
40225c312079SDr. David Alan Gilbert    pthread_create(&thread, 0, f, 0);
40235c312079SDr. David Alan Gilbert    pthread_setname_np(thread, "QEMU");
40245c312079SDr. David Alan Gilbert    return 0;
40255c312079SDr. David Alan Gilbert}
40265c312079SDr. David Alan GilbertEOF
40275c312079SDr. David Alan Gilbertif compile_prog "" "$pthread_lib" ; then
4028479a5747SRoman Bolshakov  pthread_setname_np_w_tid=yes
4029479a5747SRoman Bolshakovfi
4030479a5747SRoman Bolshakov
4031479a5747SRoman Bolshakov# check for pthread_setname_np without thread id
4032479a5747SRoman Bolshakovpthread_setname_np_wo_tid=no
4033479a5747SRoman Bolshakovcat > $TMPC << EOF
4034479a5747SRoman Bolshakov#include <pthread.h>
4035479a5747SRoman Bolshakov
403612a9b8d8SThomas Huthstatic void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
4037479a5747SRoman Bolshakovint main(void)
4038479a5747SRoman Bolshakov{
4039479a5747SRoman Bolshakov    pthread_t thread;
4040479a5747SRoman Bolshakov    pthread_create(&thread, 0, f, 0);
4041479a5747SRoman Bolshakov    return 0;
4042479a5747SRoman Bolshakov}
4043479a5747SRoman BolshakovEOF
4044479a5747SRoman Bolshakovif compile_prog "" "$pthread_lib" ; then
4045479a5747SRoman Bolshakov  pthread_setname_np_wo_tid=yes
40465c312079SDr. David Alan Gilbertfi
40475c312079SDr. David Alan Gilbert
4048bf9298b9Saliguori##########################################
4049f27aaf4bSChristian Brunner# rbd probe
4050f27aaf4bSChristian Brunnerif test "$rbd" != "no" ; then
4051f27aaf4bSChristian Brunner  cat > $TMPC <<EOF
4052f27aaf4bSChristian Brunner#include <stdio.h>
4053ad32e9c0SJosh Durgin#include <rbd/librbd.h>
4054f27aaf4bSChristian Brunnerint main(void) {
4055ad32e9c0SJosh Durgin    rados_t cluster;
4056ad32e9c0SJosh Durgin    rados_create(&cluster, NULL);
4057f27aaf4bSChristian Brunner    return 0;
4058f27aaf4bSChristian Brunner}
4059f27aaf4bSChristian BrunnerEOF
4060ad32e9c0SJosh Durgin  rbd_libs="-lrbd -lrados"
4061f27aaf4bSChristian Brunner  if compile_prog "" "$rbd_libs" ; then
4062f27aaf4bSChristian Brunner    rbd=yes
4063f27aaf4bSChristian Brunner  else
4064f27aaf4bSChristian Brunner    if test "$rbd" = "yes" ; then
406521684af0SStewart Smith      feature_not_found "rados block device" "Install librbd/ceph devel"
4066f27aaf4bSChristian Brunner    fi
4067f27aaf4bSChristian Brunner    rbd=no
4068f27aaf4bSChristian Brunner  fi
4069f27aaf4bSChristian Brunnerfi
4070f27aaf4bSChristian Brunner
4071f27aaf4bSChristian Brunner##########################################
4072b10d49d7SPino Toscano# libssh probe
4073b10d49d7SPino Toscanoif test "$libssh" != "no" ; then
4074b10d49d7SPino Toscano  if $pkg_config --exists libssh; then
4075b10d49d7SPino Toscano    libssh_cflags=$($pkg_config libssh --cflags)
4076b10d49d7SPino Toscano    libssh_libs=$($pkg_config libssh --libs)
4077b10d49d7SPino Toscano    libssh=yes
40780a12ec87SRichard W.M. Jones  else
4079b10d49d7SPino Toscano    if test "$libssh" = "yes" ; then
4080b10d49d7SPino Toscano      error_exit "libssh required for --enable-libssh"
40810a12ec87SRichard W.M. Jones    fi
4082b10d49d7SPino Toscano    libssh=no
40830a12ec87SRichard W.M. Jones  fi
40840a12ec87SRichard W.M. Jonesfi
40850a12ec87SRichard W.M. Jones
40860a12ec87SRichard W.M. Jones##########################################
4087b10d49d7SPino Toscano# Check for libssh 0.8
4088b10d49d7SPino Toscano# This is done like this instead of using the LIBSSH_VERSION_* and
4089b10d49d7SPino Toscano# SSH_VERSION_* macros because some distributions in the past shipped
4090b10d49d7SPino Toscano# snapshots of the future 0.8 from Git, and those snapshots did not
4091b10d49d7SPino Toscano# have updated version numbers (still referring to 0.7.0).
40929a2d462eSRichard W.M. Jones
4093b10d49d7SPino Toscanoif test "$libssh" = "yes"; then
40949a2d462eSRichard W.M. Jones  cat > $TMPC <<EOF
4095b10d49d7SPino Toscano#include <libssh/libssh.h>
4096b10d49d7SPino Toscanoint main(void) { return ssh_get_server_publickey(NULL, NULL); }
40979a2d462eSRichard W.M. JonesEOF
4098b10d49d7SPino Toscano  if compile_prog "$libssh_cflags" "$libssh_libs"; then
4099b10d49d7SPino Toscano    libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags"
41009a2d462eSRichard W.M. Jones  fi
41019a2d462eSRichard W.M. Jonesfi
41029a2d462eSRichard W.M. Jones
41039a2d462eSRichard W.M. Jones##########################################
41045c6c3a6cSChristoph Hellwig# linux-aio probe
41055c6c3a6cSChristoph Hellwig
41065c6c3a6cSChristoph Hellwigif test "$linux_aio" != "no" ; then
41075c6c3a6cSChristoph Hellwig  cat > $TMPC <<EOF
41085c6c3a6cSChristoph Hellwig#include <libaio.h>
41095c6c3a6cSChristoph Hellwig#include <sys/eventfd.h>
4110832ce9c2SScott Wood#include <stddef.h>
41115c6c3a6cSChristoph Hellwigint main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 0); eventfd(0, 0); return 0; }
41125c6c3a6cSChristoph HellwigEOF
41135c6c3a6cSChristoph Hellwig  if compile_prog "" "-laio" ; then
41145c6c3a6cSChristoph Hellwig    linux_aio=yes
41155c6c3a6cSChristoph Hellwig  else
41165c6c3a6cSChristoph Hellwig    if test "$linux_aio" = "yes" ; then
411721684af0SStewart Smith      feature_not_found "linux AIO" "Install libaio devel"
41185c6c3a6cSChristoph Hellwig    fi
41193cfcae3cSLuiz Capitulino    linux_aio=no
41205c6c3a6cSChristoph Hellwig  fi
41215c6c3a6cSChristoph Hellwigfi
4122c10dd856SAarushi Mehta##########################################
4123c10dd856SAarushi Mehta# linux-io-uring probe
4124c10dd856SAarushi Mehta
4125c10dd856SAarushi Mehtaif test "$linux_io_uring" != "no" ; then
4126c10dd856SAarushi Mehta  if $pkg_config liburing; then
4127c10dd856SAarushi Mehta    linux_io_uring_cflags=$($pkg_config --cflags liburing)
4128c10dd856SAarushi Mehta    linux_io_uring_libs=$($pkg_config --libs liburing)
4129c10dd856SAarushi Mehta    linux_io_uring=yes
413073fd282eSStefan Hajnoczi
413173fd282eSStefan Hajnoczi    # io_uring is used in libqemuutil.a where per-file -libs variables are not
413273fd282eSStefan Hajnoczi    # seen by programs linking the archive.  It's not ideal, but just add the
413373fd282eSStefan Hajnoczi    # library dependency globally.
413473fd282eSStefan Hajnoczi    LIBS="$linux_io_uring_libs $LIBS"
4135c10dd856SAarushi Mehta  else
4136c10dd856SAarushi Mehta    if test "$linux_io_uring" = "yes" ; then
4137c10dd856SAarushi Mehta      feature_not_found "linux io_uring" "Install liburing devel"
4138c10dd856SAarushi Mehta    fi
4139c10dd856SAarushi Mehta    linux_io_uring=no
4140c10dd856SAarushi Mehta  fi
4141c10dd856SAarushi Mehtafi
41425c6c3a6cSChristoph Hellwig
41435c6c3a6cSChristoph Hellwig##########################################
41447aaa6a16SPaolo Bonzini# TPM emulation is only on POSIX
41453b8acc11SPaolo Bonzini
41467aaa6a16SPaolo Bonziniif test "$tpm" = ""; then
41477aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes"; then
41487aaa6a16SPaolo Bonzini    tpm=no
41493b8acc11SPaolo Bonzini  else
41507aaa6a16SPaolo Bonzini    tpm=yes
41517aaa6a16SPaolo Bonzini  fi
41527aaa6a16SPaolo Bonzinielif test "$tpm" = "yes"; then
41537aaa6a16SPaolo Bonzini  if test "$mingw32" = "yes" ; then
41547aaa6a16SPaolo Bonzini    error_exit "TPM emulation only available on POSIX systems"
41557aaa6a16SPaolo Bonzini  fi
41563b8acc11SPaolo Bonzinifi
41573b8acc11SPaolo Bonzini
41583b8acc11SPaolo Bonzini##########################################
4159758e8e38SVenkateswararao Jujjuri (JV)# attr probe
4160758e8e38SVenkateswararao Jujjuri (JV)
4161ec0d5893SMarc-André Lureaulibattr_libs=
4162758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" != "no" ; then
4163758e8e38SVenkateswararao Jujjuri (JV)  cat > $TMPC <<EOF
4164758e8e38SVenkateswararao Jujjuri (JV)#include <stdio.h>
4165758e8e38SVenkateswararao Jujjuri (JV)#include <sys/types.h>
4166f2338fb4SPavel Borzenkov#ifdef CONFIG_LIBATTR
4167f2338fb4SPavel Borzenkov#include <attr/xattr.h>
4168f2338fb4SPavel Borzenkov#else
41694f26f2b6SAvi Kivity#include <sys/xattr.h>
4170f2338fb4SPavel Borzenkov#endif
4171758e8e38SVenkateswararao Jujjuri (JV)int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }
4172758e8e38SVenkateswararao Jujjuri (JV)EOF
41734f26f2b6SAvi Kivity  if compile_prog "" "" ; then
41744f26f2b6SAvi Kivity    attr=yes
41754f26f2b6SAvi Kivity  # Older distros have <attr/xattr.h>, and need -lattr:
4176f2338fb4SPavel Borzenkov  elif compile_prog "-DCONFIG_LIBATTR" "-lattr" ; then
4177758e8e38SVenkateswararao Jujjuri (JV)    attr=yes
4178ec0d5893SMarc-André Lureau    libattr_libs="-lattr"
4179ec0d5893SMarc-André Lureau    LIBS="$libattr_libs $LIBS"
41804f26f2b6SAvi Kivity    libattr=yes
4181758e8e38SVenkateswararao Jujjuri (JV)  else
4182758e8e38SVenkateswararao Jujjuri (JV)    if test "$attr" = "yes" ; then
418321684af0SStewart Smith      feature_not_found "ATTR" "Install libc6 or libattr devel"
4184758e8e38SVenkateswararao Jujjuri (JV)    fi
4185758e8e38SVenkateswararao Jujjuri (JV)    attr=no
4186758e8e38SVenkateswararao Jujjuri (JV)  fi
4187758e8e38SVenkateswararao Jujjuri (JV)fi
4188758e8e38SVenkateswararao Jujjuri (JV)
4189758e8e38SVenkateswararao Jujjuri (JV)##########################################
4190bf9298b9Saliguori# iovec probe
4191bf9298b9Saliguoricat > $TMPC <<EOF
4192db34f0b3Sblueswir1#include <sys/types.h>
4193bf9298b9Saliguori#include <sys/uio.h>
4194db34f0b3Sblueswir1#include <unistd.h>
4195f91f9beeSStefan Weilint main(void) { return sizeof(struct iovec); }
4196bf9298b9SaliguoriEOF
4197bf9298b9Saliguoriiovec=no
419852166aa0SJuan Quintelaif compile_prog "" "" ; then
4199bf9298b9Saliguori  iovec=yes
4200bf9298b9Saliguorifi
4201bf9298b9Saliguori
4202f652e6afSaurel32##########################################
4203ceb42de8Saliguori# preadv probe
4204ceb42de8Saliguoricat > $TMPC <<EOF
4205ceb42de8Saliguori#include <sys/types.h>
4206ceb42de8Saliguori#include <sys/uio.h>
4207ceb42de8Saliguori#include <unistd.h>
4208c075a723SBlue Swirlint main(void) { return preadv(0, 0, 0, 0); }
4209ceb42de8SaliguoriEOF
4210ceb42de8Saliguoripreadv=no
421152166aa0SJuan Quintelaif compile_prog "" "" ; then
4212ceb42de8Saliguori  preadv=yes
4213ceb42de8Saliguorifi
4214ceb42de8Saliguori
4215ceb42de8Saliguori##########################################
4216f652e6afSaurel32# fdt probe
4217e169e1e1SPeter Maydell# fdt support is mandatory for at least some target architectures,
4218e169e1e1SPeter Maydell# so insist on it if we're building those system emulators.
4219e169e1e1SPeter Maydellfdt_required=no
4220e169e1e1SPeter Maydellfor target in $target_list; do
4221e169e1e1SPeter Maydell  case $target in
4222c8c35e5fSYoshinori Sato    aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu|rx-softmmu)
4223e169e1e1SPeter Maydell      fdt_required=yes
4224e169e1e1SPeter Maydell    ;;
4225e169e1e1SPeter Maydell  esac
4226e169e1e1SPeter Maydelldone
4227e169e1e1SPeter Maydell
4228e169e1e1SPeter Maydellif test "$fdt_required" = "yes"; then
4229e169e1e1SPeter Maydell  if test "$fdt" = "no"; then
4230e169e1e1SPeter Maydell    error_exit "fdt disabled but some requested targets require it." \
4231e169e1e1SPeter Maydell      "You can turn off fdt only if you also disable all the system emulation" \
4232e169e1e1SPeter Maydell      "targets which need it (by specifying a cut down --target-list)."
4233e169e1e1SPeter Maydell  fi
4234e169e1e1SPeter Maydell  fdt=yes
42357ba4a4d3SPhilippe Mathieu-Daudéelif test "$fdt" != "yes" ; then
42367ba4a4d3SPhilippe Mathieu-Daudé  fdt=no
4237e169e1e1SPeter Maydellfi
4238e169e1e1SPeter Maydell
4239d599938aSLaurent Vivier# fdt is only required when building softmmu targets
4240d599938aSLaurent Vivierif test -z "$fdt" -a "$softmmu" != "yes" ; then
4241d599938aSLaurent Vivier    fdt="no"
4242d599938aSLaurent Vivierfi
4243d599938aSLaurent Vivier
42442df87df7SJuan Quintelaif test "$fdt" != "no" ; then
4245b41af4baSJuan Quintela  fdt_libs="-lfdt"
424696ce6545SPeter Crosthwaite  # explicitly check for libfdt_env.h as it is missing in some stable installs
42476e85fce0SPaul Burton  # and test for required functions to make sure we are on a version >= 1.4.2
4248f652e6afSaurel32  cat > $TMPC << EOF
424931ce0adbSThomas Huth#include <libfdt.h>
425096ce6545SPeter Crosthwaite#include <libfdt_env.h>
4251fea35ca4SAlexey Kardashevskiyint main(void) { fdt_check_full(NULL, 0); return 0; }
4252f652e6afSaurel32EOF
425352166aa0SJuan Quintela  if compile_prog "" "$fdt_libs" ; then
4254a540f158SPeter Crosthwaite    # system DTC is good - use it
4255e3971d61SPhilippe Mathieu-Daudé    fdt=system
4256aef45d51SDaniel P. Berrange  else
4257aef45d51SDaniel P. Berrange      # have GIT checkout, so activate dtc submodule
4258aef45d51SDaniel P. Berrange      if test -e "${source_path}/.git" ; then
4259aef45d51SDaniel P. Berrange          git_submodules="${git_submodules} dtc"
4260aef45d51SDaniel P. Berrange      fi
4261aef45d51SDaniel P. Berrange      if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
4262e3971d61SPhilippe Mathieu-Daudé          fdt=git
4263a540f158SPeter Crosthwaite          mkdir -p dtc
4264cab00a5aSMichael S. Tsirkin          if [ "$pwd_is_source_path" != "y" ] ; then
4265a540f158SPeter Crosthwaite              symlink "$source_path/dtc/Makefile" "dtc/Makefile"
42662df87df7SJuan Quintela          fi
426725211446SPaolo Bonzini          fdt_cflags="-I${source_path}/dtc/libfdt"
426825211446SPaolo Bonzini          fdt_ldflags="-L$PWD/dtc/libfdt"
42698a99e9a3SPhilippe Mathieu-Daudé          fdt_libs="$fdt_libs"
4270a540f158SPeter Crosthwaite      elif test "$fdt" = "yes" ; then
4271aef45d51SDaniel P. Berrange          # Not a git build & no libfdt found, prompt for system install
4272aef45d51SDaniel P. Berrange          error_exit "DTC (libfdt) version >= 1.4.2 not present." \
4273aef45d51SDaniel P. Berrange                     "Please install the DTC (libfdt) devel package"
4274a540f158SPeter Crosthwaite      else
4275a540f158SPeter Crosthwaite          # don't have and don't want
4276de3a354aSMichael Walle          fdt_libs=
42772df87df7SJuan Quintela          fdt=no
4278f652e6afSaurel32      fi
4279f652e6afSaurel32  fi
4280aef45d51SDaniel P. Berrangefi
4281f652e6afSaurel32
428220ff075bSMichael Walle##########################################
4283fb719563SOGAWA Hirofumi# opengl probe (for sdl2, gtk, milkymist-tmu2)
4284b1546f32SGerd Hoffmann
4285d52c454aSMarc-André Lureaugbm="no"
4286d52c454aSMarc-André Lureauif $pkg_config gbm; then
4287d52c454aSMarc-André Lureau    gbm_cflags="$($pkg_config --cflags gbm)"
4288d52c454aSMarc-André Lureau    gbm_libs="$($pkg_config --libs gbm)"
4289d52c454aSMarc-André Lureau    gbm="yes"
4290d52c454aSMarc-André Lureaufi
4291d52c454aSMarc-André Lureau
4292da076ffeSGerd Hoffmannif test "$opengl" != "no" ; then
42934939a1dfSMichael Tokarev  opengl_pkgs="epoxy gbm"
42945f9b1e35SGerd Hoffmann  if $pkg_config $opengl_pkgs; then
42955f9b1e35SGerd Hoffmann    opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
42965f9b1e35SGerd Hoffmann    opengl_libs="$($pkg_config --libs $opengl_pkgs)"
4297da076ffeSGerd Hoffmann    opengl=yes
4298925a0400SGerd Hoffmann    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
4299925a0400SGerd Hoffmann        gtk_gl="yes"
4300925a0400SGerd Hoffmann    fi
4301cc720a5dSGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $opengl_cflags"
430220ff075bSMichael Walle  else
4303da076ffeSGerd Hoffmann    if test "$opengl" = "yes" ; then
4304dcf30025SGerd Hoffmann      feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
430520ff075bSMichael Walle    fi
4306f676c67eSJeremy White    opengl_cflags=""
4307da076ffeSGerd Hoffmann    opengl_libs=""
4308da076ffeSGerd Hoffmann    opengl=no
430920ff075bSMichael Walle  fi
431020ff075bSMichael Wallefi
431120ff075bSMichael Walle
4312014cb152SGerd Hoffmannif test "$opengl" = "yes"; then
4313014cb152SGerd Hoffmann  cat > $TMPC << EOF
4314014cb152SGerd Hoffmann#include <epoxy/egl.h>
4315014cb152SGerd Hoffmann#ifndef EGL_MESA_image_dma_buf_export
4316014cb152SGerd Hoffmann# error mesa/epoxy lacks support for dmabufs (mesa 10.6+)
4317014cb152SGerd Hoffmann#endif
4318014cb152SGerd Hoffmannint main(void) { return 0; }
4319014cb152SGerd HoffmannEOF
4320014cb152SGerd Hoffmann  if compile_prog "" "" ; then
4321014cb152SGerd Hoffmann    opengl_dmabuf=yes
4322014cb152SGerd Hoffmann  fi
4323014cb152SGerd Hoffmannfi
4324c9a12e75SChrysostomos Nanakos
4325e633a5c6SEric Blakeif test "$opengl" = "yes" && test "$have_x11" = "yes"; then
432699e1a93bSPhilippe Mathieu-Daudé  for target in $target_list; do
432799e1a93bSPhilippe Mathieu-Daudé    case $target in
432899e1a93bSPhilippe Mathieu-Daudé      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
432999e1a93bSPhilippe Mathieu-Daudé        need_x11=yes
433099e1a93bSPhilippe Mathieu-Daudé      ;;
433199e1a93bSPhilippe Mathieu-Daudé    esac
433299e1a93bSPhilippe Mathieu-Daudé  done
433399e1a93bSPhilippe Mathieu-Daudéfi
433499e1a93bSPhilippe Mathieu-Daudé
4335ed279a06SKlim Kireev##########################################
4336ed279a06SKlim Kireev# libxml2 probe
4337ed279a06SKlim Kireevif test "$libxml2" != "no" ; then
4338ed279a06SKlim Kireev    if $pkg_config --exists libxml-2.0; then
4339ed279a06SKlim Kireev        libxml2="yes"
4340ed279a06SKlim Kireev        libxml2_cflags=$($pkg_config --cflags libxml-2.0)
4341ed279a06SKlim Kireev        libxml2_libs=$($pkg_config --libs libxml-2.0)
4342ed279a06SKlim Kireev    else
4343ed279a06SKlim Kireev        if test "$libxml2" = "yes"; then
4344ed279a06SKlim Kireev            feature_not_found "libxml2" "Install libxml2 devel"
4345ed279a06SKlim Kireev        fi
4346ed279a06SKlim Kireev        libxml2="no"
4347ed279a06SKlim Kireev    fi
4348ed279a06SKlim Kireevfi
4349c9a12e75SChrysostomos Nanakos
4350eb100396SBharata B Rao##########################################
4351eb100396SBharata B Rao# glusterfs probe
4352eb100396SBharata B Raoif test "$glusterfs" != "no" ; then
435365d5d3f9SStefan Weil  if $pkg_config --atleast-version=3 glusterfs-api; then
4354e01bee08SBharata B Rao    glusterfs="yes"
435589138857SStefan Weil    glusterfs_cflags=$($pkg_config --cflags glusterfs-api)
435689138857SStefan Weil    glusterfs_libs=$($pkg_config --libs glusterfs-api)
4357d85fa9ebSJeff Cody    if $pkg_config --atleast-version=4 glusterfs-api; then
4358d85fa9ebSJeff Cody      glusterfs_xlator_opt="yes"
4359d85fa9ebSJeff Cody    fi
436065d5d3f9SStefan Weil    if $pkg_config --atleast-version=5 glusterfs-api; then
43610c14fb47SBharata B Rao      glusterfs_discard="yes"
43620c14fb47SBharata B Rao    fi
43637c815372SBharata B Rao    if $pkg_config --atleast-version=6 glusterfs-api; then
4364df3a429aSNiels de Vos      glusterfs_fallocate="yes"
43657c815372SBharata B Rao      glusterfs_zerofill="yes"
43667c815372SBharata B Rao    fi
4367e014dbe7SPrasanna Kumar Kalever    cat > $TMPC << EOF
4368e014dbe7SPrasanna Kumar Kalever#include <glusterfs/api/glfs.h>
4369e014dbe7SPrasanna Kumar Kalever
4370e014dbe7SPrasanna Kumar Kaleverint
4371e014dbe7SPrasanna Kumar Kalevermain(void)
4372e014dbe7SPrasanna Kumar Kalever{
4373e014dbe7SPrasanna Kumar Kalever	/* new glfs_ftruncate() passes two additional args */
4374e014dbe7SPrasanna Kumar Kalever	return glfs_ftruncate(NULL, 0, NULL, NULL);
4375e014dbe7SPrasanna Kumar Kalever}
4376e014dbe7SPrasanna Kumar KaleverEOF
4377e014dbe7SPrasanna Kumar Kalever    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
4378e014dbe7SPrasanna Kumar Kalever      glusterfs_ftruncate_has_stat="yes"
4379e014dbe7SPrasanna Kumar Kalever    fi
43800e3b891fSNiels de Vos    cat > $TMPC << EOF
43810e3b891fSNiels de Vos#include <glusterfs/api/glfs.h>
43820e3b891fSNiels de Vos
43830e3b891fSNiels de Vos/* new glfs_io_cbk() passes two additional glfs_stat structs */
43840e3b891fSNiels de Vosstatic void
43850e3b891fSNiels de Vosglusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
43860e3b891fSNiels de Vos{}
43870e3b891fSNiels de Vos
43880e3b891fSNiels de Vosint
43890e3b891fSNiels de Vosmain(void)
43900e3b891fSNiels de Vos{
43910e3b891fSNiels de Vos	glfs_io_cbk iocb = &glusterfs_iocb;
43920e3b891fSNiels de Vos	iocb(NULL, 0 , NULL, NULL, NULL);
43930e3b891fSNiels de Vos	return 0;
43940e3b891fSNiels de Vos}
43950e3b891fSNiels de VosEOF
43960e3b891fSNiels de Vos    if compile_prog "$glusterfs_cflags" "$glusterfs_libs" ; then
43970e3b891fSNiels de Vos      glusterfs_iocb_has_stat="yes"
43980e3b891fSNiels de Vos    fi
4399eb100396SBharata B Rao  else
4400eb100396SBharata B Rao    if test "$glusterfs" = "yes" ; then
44018efc9363SHu Tao      feature_not_found "GlusterFS backend support" \
44028efc9363SHu Tao          "Install glusterfs-api devel >= 3"
4403eb100396SBharata B Rao    fi
4404e01bee08SBharata B Rao    glusterfs="no"
4405eb100396SBharata B Rao  fi
4406eb100396SBharata B Raofi
4407eb100396SBharata B Rao
440839386ac7Saurel32# Check for inotify functions when we are building linux-user
44093b3f24adSaurel32# emulator.  This is done because older glibc versions don't
44103b3f24adSaurel32# have syscall stubs for these implemented.  In that case we
44113b3f24adSaurel32# don't provide them even if kernel supports them.
44123b3f24adSaurel32#
44133b3f24adSaurel32inotify=no
44143b3f24adSaurel32cat > $TMPC << EOF
44153b3f24adSaurel32#include <sys/inotify.h>
44163b3f24adSaurel32
44173b3f24adSaurel32int
44183b3f24adSaurel32main(void)
44193b3f24adSaurel32{
44203b3f24adSaurel32	/* try to start inotify */
44218690e420Saurel32	return inotify_init();
44223b3f24adSaurel32}
44233b3f24adSaurel32EOF
442452166aa0SJuan Quintelaif compile_prog "" "" ; then
44253b3f24adSaurel32  inotify=yes
44263b3f24adSaurel32fi
44273b3f24adSaurel32
4428c05c7a73SRiku Voipioinotify1=no
4429c05c7a73SRiku Voipiocat > $TMPC << EOF
4430c05c7a73SRiku Voipio#include <sys/inotify.h>
4431c05c7a73SRiku Voipio
4432c05c7a73SRiku Voipioint
4433c05c7a73SRiku Voipiomain(void)
4434c05c7a73SRiku Voipio{
4435c05c7a73SRiku Voipio    /* try to start inotify */
4436c05c7a73SRiku Voipio    return inotify_init1(0);
4437c05c7a73SRiku Voipio}
4438c05c7a73SRiku VoipioEOF
4439c05c7a73SRiku Voipioif compile_prog "" "" ; then
4440c05c7a73SRiku Voipio  inotify1=yes
4441c05c7a73SRiku Voipiofi
4442c05c7a73SRiku Voipio
4443099d6b0fSRiku Voipio# check if pipe2 is there
4444099d6b0fSRiku Voipiopipe2=no
4445099d6b0fSRiku Voipiocat > $TMPC << EOF
4446099d6b0fSRiku Voipio#include <unistd.h>
4447099d6b0fSRiku Voipio#include <fcntl.h>
4448099d6b0fSRiku Voipio
4449099d6b0fSRiku Voipioint main(void)
4450099d6b0fSRiku Voipio{
4451099d6b0fSRiku Voipio    int pipefd[2];
44529bca8162SBruce Rogers    return pipe2(pipefd, O_CLOEXEC);
4453099d6b0fSRiku Voipio}
4454099d6b0fSRiku VoipioEOF
445552166aa0SJuan Quintelaif compile_prog "" "" ; then
4456099d6b0fSRiku Voipio  pipe2=yes
4457099d6b0fSRiku Voipiofi
4458099d6b0fSRiku Voipio
445940ff6d7eSKevin Wolf# check if accept4 is there
446040ff6d7eSKevin Wolfaccept4=no
446140ff6d7eSKevin Wolfcat > $TMPC << EOF
446240ff6d7eSKevin Wolf#include <sys/socket.h>
446340ff6d7eSKevin Wolf#include <stddef.h>
446440ff6d7eSKevin Wolf
446540ff6d7eSKevin Wolfint main(void)
446640ff6d7eSKevin Wolf{
446740ff6d7eSKevin Wolf    accept4(0, NULL, NULL, SOCK_CLOEXEC);
446840ff6d7eSKevin Wolf    return 0;
446940ff6d7eSKevin Wolf}
447040ff6d7eSKevin WolfEOF
447140ff6d7eSKevin Wolfif compile_prog "" "" ; then
447240ff6d7eSKevin Wolf  accept4=yes
447340ff6d7eSKevin Wolffi
447440ff6d7eSKevin Wolf
44753ce34dfbSvibisreenivasan# check if tee/splice is there. vmsplice was added same time.
44763ce34dfbSvibisreenivasansplice=no
44773ce34dfbSvibisreenivasancat > $TMPC << EOF
44783ce34dfbSvibisreenivasan#include <unistd.h>
44793ce34dfbSvibisreenivasan#include <fcntl.h>
44803ce34dfbSvibisreenivasan#include <limits.h>
44813ce34dfbSvibisreenivasan
44823ce34dfbSvibisreenivasanint main(void)
44833ce34dfbSvibisreenivasan{
448466ea0f22SStefan Weil    int len, fd = 0;
44853ce34dfbSvibisreenivasan    len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
44863ce34dfbSvibisreenivasan    splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
44873ce34dfbSvibisreenivasan    return 0;
44883ce34dfbSvibisreenivasan}
44893ce34dfbSvibisreenivasanEOF
449052166aa0SJuan Quintelaif compile_prog "" "" ; then
44913ce34dfbSvibisreenivasan  splice=yes
44923ce34dfbSvibisreenivasanfi
44933ce34dfbSvibisreenivasan
4494dcc38d1cSMarcelo Tosatti##########################################
4495a99d57bbSWanlong Gao# libnuma probe
4496a99d57bbSWanlong Gao
4497a99d57bbSWanlong Gaoif test "$numa" != "no" ; then
4498a99d57bbSWanlong Gao  cat > $TMPC << EOF
4499a99d57bbSWanlong Gao#include <numa.h>
4500a99d57bbSWanlong Gaoint main(void) { return numa_available(); }
4501a99d57bbSWanlong GaoEOF
4502a99d57bbSWanlong Gao
4503a99d57bbSWanlong Gao  if compile_prog "" "-lnuma" ; then
4504a99d57bbSWanlong Gao    numa=yes
4505ab318051SMarc-André Lureau    numa_libs="-lnuma"
4506a99d57bbSWanlong Gao  else
4507a99d57bbSWanlong Gao    if test "$numa" = "yes" ; then
4508a99d57bbSWanlong Gao      feature_not_found "numa" "install numactl devel"
4509a99d57bbSWanlong Gao    fi
4510a99d57bbSWanlong Gao    numa=no
4511a99d57bbSWanlong Gao  fi
4512a99d57bbSWanlong Gaofi
4513a99d57bbSWanlong Gao
45147b01cb97SAlexandre Derumierif test "$tcmalloc" = "yes" && test "$jemalloc" = "yes" ; then
45157b01cb97SAlexandre Derumier    echo "ERROR: tcmalloc && jemalloc can't be used at the same time"
45167b01cb97SAlexandre Derumier    exit 1
45177b01cb97SAlexandre Derumierfi
45187b01cb97SAlexandre Derumier
45195a22ab71SYang Zhong# Even if malloc_trim() is available, these non-libc memory allocators
45205a22ab71SYang Zhong# do not support it.
45215a22ab71SYang Zhongif test "$tcmalloc" = "yes" || test "$jemalloc" = "yes" ; then
45225a22ab71SYang Zhong    if test "$malloc_trim" = "yes" ; then
45235a22ab71SYang Zhong        echo "Disabling malloc_trim with non-libc memory allocator"
45245a22ab71SYang Zhong    fi
45255a22ab71SYang Zhong    malloc_trim="no"
45265a22ab71SYang Zhongfi
45275a22ab71SYang Zhong
45285a22ab71SYang Zhong#######################################
45295a22ab71SYang Zhong# malloc_trim
45305a22ab71SYang Zhong
45315a22ab71SYang Zhongif test "$malloc_trim" != "no" ; then
45325a22ab71SYang Zhong    cat > $TMPC << EOF
45335a22ab71SYang Zhong#include <malloc.h>
45345a22ab71SYang Zhongint main(void) { malloc_trim(0); return 0; }
45355a22ab71SYang ZhongEOF
45365a22ab71SYang Zhong    if compile_prog "" "" ; then
45375a22ab71SYang Zhong        malloc_trim="yes"
45385a22ab71SYang Zhong    else
45395a22ab71SYang Zhong        malloc_trim="no"
45405a22ab71SYang Zhong    fi
45415a22ab71SYang Zhongfi
45425a22ab71SYang Zhong
4543a99d57bbSWanlong Gao##########################################
45442847b469SFam Zheng# tcmalloc probe
45452847b469SFam Zheng
45462847b469SFam Zhengif test "$tcmalloc" = "yes" ; then
45472847b469SFam Zheng  cat > $TMPC << EOF
45482847b469SFam Zheng#include <stdlib.h>
4549f2dfe54cSLeonid Blochint main(void) {
4550f2dfe54cSLeonid Bloch    void *tmp = malloc(1);
4551f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4552f2dfe54cSLeonid Bloch        return 0;
4553f2dfe54cSLeonid Bloch    }
4554f2dfe54cSLeonid Bloch    return 1;
4555f2dfe54cSLeonid Bloch}
45562847b469SFam ZhengEOF
45572847b469SFam Zheng
45582847b469SFam Zheng  if compile_prog "" "-ltcmalloc" ; then
45592847b469SFam Zheng    LIBS="-ltcmalloc $LIBS"
45602847b469SFam Zheng  else
45612847b469SFam Zheng    feature_not_found "tcmalloc" "install gperftools devel"
45622847b469SFam Zheng  fi
45632847b469SFam Zhengfi
45642847b469SFam Zheng
45652847b469SFam Zheng##########################################
45667b01cb97SAlexandre Derumier# jemalloc probe
45677b01cb97SAlexandre Derumier
45687b01cb97SAlexandre Derumierif test "$jemalloc" = "yes" ; then
45697b01cb97SAlexandre Derumier  cat > $TMPC << EOF
45707b01cb97SAlexandre Derumier#include <stdlib.h>
4571f2dfe54cSLeonid Blochint main(void) {
4572f2dfe54cSLeonid Bloch    void *tmp = malloc(1);
4573f2dfe54cSLeonid Bloch    if (tmp != NULL) {
4574f2dfe54cSLeonid Bloch        return 0;
4575f2dfe54cSLeonid Bloch    }
4576f2dfe54cSLeonid Bloch    return 1;
4577f2dfe54cSLeonid Bloch}
45787b01cb97SAlexandre DerumierEOF
45797b01cb97SAlexandre Derumier
45807b01cb97SAlexandre Derumier  if compile_prog "" "-ljemalloc" ; then
45817b01cb97SAlexandre Derumier    LIBS="-ljemalloc $LIBS"
45827b01cb97SAlexandre Derumier  else
45837b01cb97SAlexandre Derumier    feature_not_found "jemalloc" "install jemalloc devel"
45847b01cb97SAlexandre Derumier  fi
45857b01cb97SAlexandre Derumierfi
45867b01cb97SAlexandre Derumier
45877b01cb97SAlexandre Derumier##########################################
4588dcc38d1cSMarcelo Tosatti# signalfd probe
4589dcc38d1cSMarcelo Tosattisignalfd="no"
4590dcc38d1cSMarcelo Tosatticat > $TMPC << EOF
4591dcc38d1cSMarcelo Tosatti#include <unistd.h>
4592dcc38d1cSMarcelo Tosatti#include <sys/syscall.h>
4593dcc38d1cSMarcelo Tosatti#include <signal.h>
4594dcc38d1cSMarcelo Tosattiint main(void) { return syscall(SYS_signalfd, -1, NULL, _NSIG / 8); }
4595dcc38d1cSMarcelo TosattiEOF
4596dcc38d1cSMarcelo Tosatti
4597dcc38d1cSMarcelo Tosattiif compile_prog "" "" ; then
4598dcc38d1cSMarcelo Tosatti  signalfd=yes
4599dcc38d1cSMarcelo Tosattifi
4600dcc38d1cSMarcelo Tosatti
4601d339d766SRichard W.M. Jones# check if optreset global is declared by <getopt.h>
4602d339d766SRichard W.M. Jonesoptreset="no"
4603d339d766SRichard W.M. Jonescat > $TMPC << EOF
4604d339d766SRichard W.M. Jones#include <getopt.h>
4605d339d766SRichard W.M. Jonesint main(void) { return optreset; }
4606d339d766SRichard W.M. JonesEOF
4607d339d766SRichard W.M. Jones
4608d339d766SRichard W.M. Jonesif compile_prog "" "" ; then
4609d339d766SRichard W.M. Jones  optreset=yes
4610d339d766SRichard W.M. Jonesfi
4611d339d766SRichard W.M. Jones
4612c2882b96SRiku Voipio# check if eventfd is supported
4613c2882b96SRiku Voipioeventfd=no
4614c2882b96SRiku Voipiocat > $TMPC << EOF
4615c2882b96SRiku Voipio#include <sys/eventfd.h>
4616c2882b96SRiku Voipio
4617c2882b96SRiku Voipioint main(void)
4618c2882b96SRiku Voipio{
461955cc7f3eSStefan Weil    return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
4620c2882b96SRiku Voipio}
4621c2882b96SRiku VoipioEOF
4622c2882b96SRiku Voipioif compile_prog "" "" ; then
4623c2882b96SRiku Voipio  eventfd=yes
4624c2882b96SRiku Voipiofi
4625c2882b96SRiku Voipio
4626751bcc39SMarc-André Lureau# check if memfd is supported
4627751bcc39SMarc-André Lureaumemfd=no
4628751bcc39SMarc-André Lureaucat > $TMPC << EOF
462975e5b70eSPaolo Bonzini#include <sys/mman.h>
4630751bcc39SMarc-André Lureau
4631751bcc39SMarc-André Lureauint main(void)
4632751bcc39SMarc-André Lureau{
4633751bcc39SMarc-André Lureau    return memfd_create("foo", MFD_ALLOW_SEALING);
4634751bcc39SMarc-André Lureau}
4635751bcc39SMarc-André LureauEOF
4636751bcc39SMarc-André Lureauif compile_prog "" "" ; then
4637751bcc39SMarc-André Lureau  memfd=yes
4638751bcc39SMarc-André Lureaufi
4639751bcc39SMarc-André Lureau
4640955727d2SCortland Tölva# check for usbfs
4641955727d2SCortland Tölvahave_usbfs=no
4642955727d2SCortland Tölvaif test "$linux_user" = "yes"; then
464396566d09SThomas Petazzoni  cat > $TMPC << EOF
464496566d09SThomas Petazzoni#include <linux/usbdevice_fs.h>
464596566d09SThomas Petazzoni
464696566d09SThomas Petazzoni#ifndef USBDEVFS_GET_CAPABILITIES
464796566d09SThomas Petazzoni#error "USBDEVFS_GET_CAPABILITIES undefined"
464896566d09SThomas Petazzoni#endif
464996566d09SThomas Petazzoni
465096566d09SThomas Petazzoni#ifndef USBDEVFS_DISCONNECT_CLAIM
465196566d09SThomas Petazzoni#error "USBDEVFS_DISCONNECT_CLAIM undefined"
465296566d09SThomas Petazzoni#endif
465396566d09SThomas Petazzoni
465496566d09SThomas Petazzoniint main(void)
465596566d09SThomas Petazzoni{
465696566d09SThomas Petazzoni    return 0;
465796566d09SThomas Petazzoni}
465896566d09SThomas PetazzoniEOF
465996566d09SThomas Petazzoni  if compile_prog "" ""; then
4660955727d2SCortland Tölva    have_usbfs=yes
4661955727d2SCortland Tölva  fi
4662955727d2SCortland Tölvafi
4663751bcc39SMarc-André Lureau
4664d0927938SUlrich Hecht# check for fallocate
4665d0927938SUlrich Hechtfallocate=no
4666d0927938SUlrich Hechtcat > $TMPC << EOF
4667d0927938SUlrich Hecht#include <fcntl.h>
4668d0927938SUlrich Hecht
4669d0927938SUlrich Hechtint main(void)
4670d0927938SUlrich Hecht{
4671d0927938SUlrich Hecht    fallocate(0, 0, 0, 0);
4672d0927938SUlrich Hecht    return 0;
4673d0927938SUlrich Hecht}
4674d0927938SUlrich HechtEOF
46758fb03151SPeter Maydellif compile_prog "" "" ; then
4676d0927938SUlrich Hecht  fallocate=yes
4677d0927938SUlrich Hechtfi
4678d0927938SUlrich Hecht
46793d4fa43eSKusanagi Kouichi# check for fallocate hole punching
46803d4fa43eSKusanagi Kouichifallocate_punch_hole=no
46813d4fa43eSKusanagi Kouichicat > $TMPC << EOF
46823d4fa43eSKusanagi Kouichi#include <fcntl.h>
46833d4fa43eSKusanagi Kouichi#include <linux/falloc.h>
46843d4fa43eSKusanagi Kouichi
46853d4fa43eSKusanagi Kouichiint main(void)
46863d4fa43eSKusanagi Kouichi{
46873d4fa43eSKusanagi Kouichi    fallocate(0, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 0);
46883d4fa43eSKusanagi Kouichi    return 0;
46893d4fa43eSKusanagi Kouichi}
46903d4fa43eSKusanagi KouichiEOF
46913d4fa43eSKusanagi Kouichiif compile_prog "" "" ; then
46923d4fa43eSKusanagi Kouichi  fallocate_punch_hole=yes
46933d4fa43eSKusanagi Kouichifi
46943d4fa43eSKusanagi Kouichi
4695b953f075SDenis V. Lunev# check that fallocate supports range zeroing inside the file
4696b953f075SDenis V. Lunevfallocate_zero_range=no
4697b953f075SDenis V. Lunevcat > $TMPC << EOF
4698b953f075SDenis V. Lunev#include <fcntl.h>
4699b953f075SDenis V. Lunev#include <linux/falloc.h>
4700b953f075SDenis V. Lunev
4701b953f075SDenis V. Lunevint main(void)
4702b953f075SDenis V. Lunev{
4703b953f075SDenis V. Lunev    fallocate(0, FALLOC_FL_ZERO_RANGE, 0, 0);
4704b953f075SDenis V. Lunev    return 0;
4705b953f075SDenis V. Lunev}
4706b953f075SDenis V. LunevEOF
4707b953f075SDenis V. Lunevif compile_prog "" "" ; then
4708b953f075SDenis V. Lunev  fallocate_zero_range=yes
4709b953f075SDenis V. Lunevfi
4710b953f075SDenis V. Lunev
4711ed911435SKevin Wolf# check for posix_fallocate
4712ed911435SKevin Wolfposix_fallocate=no
4713ed911435SKevin Wolfcat > $TMPC << EOF
4714ed911435SKevin Wolf#include <fcntl.h>
4715ed911435SKevin Wolf
4716ed911435SKevin Wolfint main(void)
4717ed911435SKevin Wolf{
4718ed911435SKevin Wolf    posix_fallocate(0, 0, 0);
4719ed911435SKevin Wolf    return 0;
4720ed911435SKevin Wolf}
4721ed911435SKevin WolfEOF
4722ed911435SKevin Wolfif compile_prog "" "" ; then
4723ed911435SKevin Wolf    posix_fallocate=yes
4724ed911435SKevin Wolffi
4725ed911435SKevin Wolf
4726c727f47dSPeter Maydell# check for sync_file_range
4727c727f47dSPeter Maydellsync_file_range=no
4728c727f47dSPeter Maydellcat > $TMPC << EOF
4729c727f47dSPeter Maydell#include <fcntl.h>
4730c727f47dSPeter Maydell
4731c727f47dSPeter Maydellint main(void)
4732c727f47dSPeter Maydell{
4733c727f47dSPeter Maydell    sync_file_range(0, 0, 0, 0);
4734c727f47dSPeter Maydell    return 0;
4735c727f47dSPeter Maydell}
4736c727f47dSPeter MaydellEOF
47378fb03151SPeter Maydellif compile_prog "" "" ; then
4738c727f47dSPeter Maydell  sync_file_range=yes
4739c727f47dSPeter Maydellfi
4740c727f47dSPeter Maydell
4741dace20dcSPeter Maydell# check for linux/fiemap.h and FS_IOC_FIEMAP
4742dace20dcSPeter Maydellfiemap=no
4743dace20dcSPeter Maydellcat > $TMPC << EOF
4744dace20dcSPeter Maydell#include <sys/ioctl.h>
4745dace20dcSPeter Maydell#include <linux/fs.h>
4746dace20dcSPeter Maydell#include <linux/fiemap.h>
4747dace20dcSPeter Maydell
4748dace20dcSPeter Maydellint main(void)
4749dace20dcSPeter Maydell{
4750dace20dcSPeter Maydell    ioctl(0, FS_IOC_FIEMAP, 0);
4751dace20dcSPeter Maydell    return 0;
4752dace20dcSPeter Maydell}
4753dace20dcSPeter MaydellEOF
47548fb03151SPeter Maydellif compile_prog "" "" ; then
4755dace20dcSPeter Maydell  fiemap=yes
4756dace20dcSPeter Maydellfi
4757dace20dcSPeter Maydell
4758d0927938SUlrich Hecht# check for dup3
4759d0927938SUlrich Hechtdup3=no
4760d0927938SUlrich Hechtcat > $TMPC << EOF
4761d0927938SUlrich Hecht#include <unistd.h>
4762d0927938SUlrich Hecht
4763d0927938SUlrich Hechtint main(void)
4764d0927938SUlrich Hecht{
4765d0927938SUlrich Hecht    dup3(0, 0, 0);
4766d0927938SUlrich Hecht    return 0;
4767d0927938SUlrich Hecht}
4768d0927938SUlrich HechtEOF
476978f5d726SJan Kiszkaif compile_prog "" "" ; then
4770d0927938SUlrich Hecht  dup3=yes
4771d0927938SUlrich Hechtfi
4772d0927938SUlrich Hecht
47734e0c6529SAlex Bligh# check for ppoll support
47744e0c6529SAlex Blighppoll=no
47754e0c6529SAlex Blighcat > $TMPC << EOF
47764e0c6529SAlex Bligh#include <poll.h>
47774e0c6529SAlex Bligh
47784e0c6529SAlex Blighint main(void)
47794e0c6529SAlex Bligh{
47804e0c6529SAlex Bligh    struct pollfd pfd = { .fd = 0, .events = 0, .revents = 0 };
47814e0c6529SAlex Bligh    ppoll(&pfd, 1, 0, 0);
47824e0c6529SAlex Bligh    return 0;
47834e0c6529SAlex Bligh}
47844e0c6529SAlex BlighEOF
47854e0c6529SAlex Blighif compile_prog "" "" ; then
47864e0c6529SAlex Bligh  ppoll=yes
47874e0c6529SAlex Blighfi
47884e0c6529SAlex Bligh
4789cd758dd0SAlex Bligh# check for prctl(PR_SET_TIMERSLACK , ... ) support
4790cd758dd0SAlex Blighprctl_pr_set_timerslack=no
4791cd758dd0SAlex Blighcat > $TMPC << EOF
4792cd758dd0SAlex Bligh#include <sys/prctl.h>
4793cd758dd0SAlex Bligh
4794cd758dd0SAlex Blighint main(void)
4795cd758dd0SAlex Bligh{
4796cd758dd0SAlex Bligh    prctl(PR_SET_TIMERSLACK, 1, 0, 0, 0);
4797cd758dd0SAlex Bligh    return 0;
4798cd758dd0SAlex Bligh}
4799cd758dd0SAlex BlighEOF
4800cd758dd0SAlex Blighif compile_prog "" "" ; then
4801cd758dd0SAlex Bligh  prctl_pr_set_timerslack=yes
4802cd758dd0SAlex Blighfi
4803cd758dd0SAlex Bligh
48043b6edd16SPeter Maydell# check for epoll support
48053b6edd16SPeter Maydellepoll=no
48063b6edd16SPeter Maydellcat > $TMPC << EOF
48073b6edd16SPeter Maydell#include <sys/epoll.h>
48083b6edd16SPeter Maydell
48093b6edd16SPeter Maydellint main(void)
48103b6edd16SPeter Maydell{
48113b6edd16SPeter Maydell    epoll_create(0);
48123b6edd16SPeter Maydell    return 0;
48133b6edd16SPeter Maydell}
48143b6edd16SPeter MaydellEOF
48158fb03151SPeter Maydellif compile_prog "" "" ; then
48163b6edd16SPeter Maydell  epoll=yes
48173b6edd16SPeter Maydellfi
48183b6edd16SPeter Maydell
4819227f0214SPeter Maydell# epoll_create1 is a later addition
4820227f0214SPeter Maydell# so we must check separately for its presence
48213b6edd16SPeter Maydellepoll_create1=no
48223b6edd16SPeter Maydellcat > $TMPC << EOF
48233b6edd16SPeter Maydell#include <sys/epoll.h>
48243b6edd16SPeter Maydell
48253b6edd16SPeter Maydellint main(void)
48263b6edd16SPeter Maydell{
482719e83f6bSPeter Maydell    /* Note that we use epoll_create1 as a value, not as
482819e83f6bSPeter Maydell     * a function being called. This is necessary so that on
482919e83f6bSPeter Maydell     * old SPARC glibc versions where the function was present in
483019e83f6bSPeter Maydell     * the library but not declared in the header file we will
483119e83f6bSPeter Maydell     * fail the configure check. (Otherwise we will get a compiler
483219e83f6bSPeter Maydell     * warning but not an error, and will proceed to fail the
483319e83f6bSPeter Maydell     * qemu compile where we compile with -Werror.)
483419e83f6bSPeter Maydell     */
4835c075a723SBlue Swirl    return (int)(uintptr_t)&epoll_create1;
48363b6edd16SPeter Maydell}
48373b6edd16SPeter MaydellEOF
48388fb03151SPeter Maydellif compile_prog "" "" ; then
48393b6edd16SPeter Maydell  epoll_create1=yes
48403b6edd16SPeter Maydellfi
48413b6edd16SPeter Maydell
4842a8fd1abaSPeter Maydell# check for sendfile support
4843a8fd1abaSPeter Maydellsendfile=no
4844a8fd1abaSPeter Maydellcat > $TMPC << EOF
4845a8fd1abaSPeter Maydell#include <sys/sendfile.h>
4846a8fd1abaSPeter Maydell
4847a8fd1abaSPeter Maydellint main(void)
4848a8fd1abaSPeter Maydell{
4849a8fd1abaSPeter Maydell    return sendfile(0, 0, 0, 0);
4850a8fd1abaSPeter Maydell}
4851a8fd1abaSPeter MaydellEOF
4852a8fd1abaSPeter Maydellif compile_prog "" "" ; then
4853a8fd1abaSPeter Maydell  sendfile=yes
4854a8fd1abaSPeter Maydellfi
4855a8fd1abaSPeter Maydell
485651834341SRiku Voipio# check for timerfd support (glibc 2.8 and newer)
485751834341SRiku Voipiotimerfd=no
485851834341SRiku Voipiocat > $TMPC << EOF
485951834341SRiku Voipio#include <sys/timerfd.h>
486051834341SRiku Voipio
486151834341SRiku Voipioint main(void)
486251834341SRiku Voipio{
486351834341SRiku Voipio    return(timerfd_create(CLOCK_REALTIME, 0));
486451834341SRiku Voipio}
486551834341SRiku VoipioEOF
486651834341SRiku Voipioif compile_prog "" "" ; then
486751834341SRiku Voipio  timerfd=yes
486851834341SRiku Voipiofi
486951834341SRiku Voipio
48709af5c906SRiku Voipio# check for setns and unshare support
48719af5c906SRiku Voipiosetns=no
48729af5c906SRiku Voipiocat > $TMPC << EOF
48739af5c906SRiku Voipio#include <sched.h>
48749af5c906SRiku Voipio
48759af5c906SRiku Voipioint main(void)
48769af5c906SRiku Voipio{
48779af5c906SRiku Voipio    int ret;
48789af5c906SRiku Voipio    ret = setns(0, 0);
48799af5c906SRiku Voipio    ret = unshare(0);
48809af5c906SRiku Voipio    return ret;
48819af5c906SRiku Voipio}
48829af5c906SRiku VoipioEOF
48839af5c906SRiku Voipioif compile_prog "" "" ; then
48849af5c906SRiku Voipio  setns=yes
48859af5c906SRiku Voipiofi
48869af5c906SRiku Voipio
488738860a03SAleksandar Markovic# clock_adjtime probe
488838860a03SAleksandar Markovicclock_adjtime=no
488938860a03SAleksandar Markoviccat > $TMPC <<EOF
489038860a03SAleksandar Markovic#include <time.h>
489138860a03SAleksandar Markovic
489238860a03SAleksandar Markovicint main(void)
489338860a03SAleksandar Markovic{
489438860a03SAleksandar Markovic    return clock_adjtime(0, 0);
489538860a03SAleksandar Markovic}
489638860a03SAleksandar MarkovicEOF
489738860a03SAleksandar Markovicclock_adjtime=no
489838860a03SAleksandar Markovicif compile_prog "" "" ; then
489938860a03SAleksandar Markovic  clock_adjtime=yes
490038860a03SAleksandar Markovicfi
490138860a03SAleksandar Markovic
49025a03cd00SAleksandar Markovic# syncfs probe
49035a03cd00SAleksandar Markovicsyncfs=no
49045a03cd00SAleksandar Markoviccat > $TMPC <<EOF
49055a03cd00SAleksandar Markovic#include <unistd.h>
49065a03cd00SAleksandar Markovic
49075a03cd00SAleksandar Markovicint main(void)
49085a03cd00SAleksandar Markovic{
49095a03cd00SAleksandar Markovic    return syncfs(0);
49105a03cd00SAleksandar Markovic}
49115a03cd00SAleksandar MarkovicEOF
49125a03cd00SAleksandar Markovicsyncfs=no
49135a03cd00SAleksandar Markovicif compile_prog "" "" ; then
49145a03cd00SAleksandar Markovic  syncfs=yes
49155a03cd00SAleksandar Markovicfi
49165a03cd00SAleksandar Markovic
4917db37dd89SAleksandar Markovic# check for kcov support (kernel must be 4.4+, compiled with certain options)
4918db37dd89SAleksandar Markovickcov=no
4919db37dd89SAleksandar Markovicif check_include sys/kcov.h ; then
4920db37dd89SAleksandar Markovic    kcov=yes
4921db37dd89SAleksandar Markovicfi
4922db37dd89SAleksandar Markovic
4923516e8b7dSPeter Maydell# If we're making warnings fatal, apply this to Sphinx runs as well
4924516e8b7dSPeter Maydellsphinx_werror=""
4925516e8b7dSPeter Maydellif test "$werror" = "yes"; then
4926516e8b7dSPeter Maydell    sphinx_werror="-W"
4927516e8b7dSPeter Maydellfi
4928516e8b7dSPeter Maydell
49295f71eac0SPeter Maydell# Check we have a new enough version of sphinx-build
49305f71eac0SPeter Maydellhas_sphinx_build() {
49315f71eac0SPeter Maydell    # This is a bit awkward but works: create a trivial document and
49325f71eac0SPeter Maydell    # try to run it with our configuration file (which enforces a
49335f71eac0SPeter Maydell    # version requirement). This will fail if either
49345f71eac0SPeter Maydell    # sphinx-build doesn't exist at all or if it is too old.
49355f71eac0SPeter Maydell    mkdir -p "$TMPDIR1/sphinx"
49365f71eac0SPeter Maydell    touch "$TMPDIR1/sphinx/index.rst"
4937988ae6c3SAlex Bennée    "$sphinx_build" $sphinx_werror -c "$source_path/docs" \
4938988ae6c3SAlex Bennée                    -b html "$TMPDIR1/sphinx" \
4939988ae6c3SAlex Bennée                    "$TMPDIR1/sphinx/out"  >> config.log 2>&1
49405f71eac0SPeter Maydell}
49415f71eac0SPeter Maydell
4942cc8ae6deSpbrook# Check if tools are available to build documentation.
4943a25dba17SJuan Quintelaif test "$docs" != "no" ; then
4944758b617aSPeter Maydell  if has_sphinx_build; then
4945758b617aSPeter Maydell    sphinx_ok=yes
4946758b617aSPeter Maydell  else
4947758b617aSPeter Maydell    sphinx_ok=no
4948758b617aSPeter Maydell  fi
4949758b617aSPeter Maydell  if has makeinfo && has pod2man && test "$sphinx_ok" = "yes"; then
4950a25dba17SJuan Quintela    docs=yes
495183a3ab8bSJuan Quintela  else
4952a25dba17SJuan Quintela    if test "$docs" = "yes" ; then
4953758b617aSPeter Maydell      if has $sphinx_build && test "$sphinx_ok" != "yes"; then
4954758b617aSPeter Maydell        echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
4955758b617aSPeter Maydell      fi
4956758b617aSPeter Maydell      feature_not_found "docs" "Install texinfo, Perl/perl-podlators and a Python 3 version of python-sphinx"
495783a3ab8bSJuan Quintela    fi
4958a25dba17SJuan Quintela    docs=no
495983a3ab8bSJuan Quintela  fi
4960cc8ae6deSpbrookfi
4961cc8ae6deSpbrook
4962f514f41cSStefan Weil# Search for bswap_32 function
49636ae9a1f4SJuan Quintelabyteswap_h=no
49646ae9a1f4SJuan Quintelacat > $TMPC << EOF
49656ae9a1f4SJuan Quintela#include <byteswap.h>
49666ae9a1f4SJuan Quintelaint main(void) { return bswap_32(0); }
49676ae9a1f4SJuan QuintelaEOF
496852166aa0SJuan Quintelaif compile_prog "" "" ; then
49696ae9a1f4SJuan Quintela  byteswap_h=yes
49706ae9a1f4SJuan Quintelafi
49716ae9a1f4SJuan Quintela
497275f13596SStefan Weil# Search for bswap32 function
49736ae9a1f4SJuan Quintelabswap_h=no
49746ae9a1f4SJuan Quintelacat > $TMPC << EOF
49756ae9a1f4SJuan Quintela#include <sys/endian.h>
49766ae9a1f4SJuan Quintela#include <sys/types.h>
49776ae9a1f4SJuan Quintela#include <machine/bswap.h>
49786ae9a1f4SJuan Quintelaint main(void) { return bswap32(0); }
49796ae9a1f4SJuan QuintelaEOF
498052166aa0SJuan Quintelaif compile_prog "" "" ; then
49816ae9a1f4SJuan Quintela  bswap_h=yes
49826ae9a1f4SJuan Quintelafi
49836ae9a1f4SJuan Quintela
4984da93a1fdSaliguori##########################################
4985e49ab19fSPeter Lieven# Do we have libiscsi >= 1.9.0
4986c589b249SRonnie Sahlbergif test "$libiscsi" != "no" ; then
4987e49ab19fSPeter Lieven  if $pkg_config --atleast-version=1.9.0 libiscsi; then
49883c33ea96SPaolo Bonzini    libiscsi="yes"
4989ca871ec8SStefan Weil    libiscsi_cflags=$($pkg_config --cflags libiscsi)
4990ca871ec8SStefan Weil    libiscsi_libs=$($pkg_config --libs libiscsi)
4991c589b249SRonnie Sahlberg  else
4992c589b249SRonnie Sahlberg    if test "$libiscsi" = "yes" ; then
4993e49ab19fSPeter Lieven      feature_not_found "libiscsi" "Install libiscsi >= 1.9.0"
4994c589b249SRonnie Sahlberg    fi
4995c589b249SRonnie Sahlberg    libiscsi="no"
4996c589b249SRonnie Sahlberg  fi
4997c589b249SRonnie Sahlbergfi
4998c589b249SRonnie Sahlberg
4999c589b249SRonnie Sahlberg##########################################
50008bacde8dSNatanael Copa# Do we need libm
50018bacde8dSNatanael Copacat > $TMPC << EOF
50028bacde8dSNatanael Copa#include <math.h>
5003f80ea986SAlexey Kardashevskiyint main(int argc, char **argv) { return isnan(sin((double)argc)); }
50048bacde8dSNatanael CopaEOF
50058bacde8dSNatanael Copaif compile_prog "" "" ; then
50068bacde8dSNatanael Copa  :
50078bacde8dSNatanael Copaelif compile_prog "" "-lm" ; then
50088bacde8dSNatanael Copa  LIBS="-lm $LIBS"
50098bacde8dSNatanael Copaelse
501076ad07a4SPeter Maydell  error_exit "libm check failed"
50118bacde8dSNatanael Copafi
50128bacde8dSNatanael Copa
50138bacde8dSNatanael Copa##########################################
5014da93a1fdSaliguori# Do we need librt
50158bacde8dSNatanael Copa# uClibc provides 2 versions of clock_gettime(), one with realtime
50168bacde8dSNatanael Copa# support and one without. This means that the clock_gettime() don't
50178bacde8dSNatanael Copa# need -lrt. We still need it for timer_create() so we check for this
50188bacde8dSNatanael Copa# function in addition.
5019da93a1fdSaliguoricat > $TMPC <<EOF
5020da93a1fdSaliguori#include <signal.h>
5021da93a1fdSaliguori#include <time.h>
50228bacde8dSNatanael Copaint main(void) {
50238bacde8dSNatanael Copa  timer_create(CLOCK_REALTIME, NULL, NULL);
50248bacde8dSNatanael Copa  return clock_gettime(CLOCK_REALTIME, NULL);
50258bacde8dSNatanael Copa}
5026da93a1fdSaliguoriEOF
5027da93a1fdSaliguori
502852166aa0SJuan Quintelaif compile_prog "" "" ; then
502907ffa4bdSJuan Quintela  :
50308bacde8dSNatanael Copa# we need pthread for static linking. use previous pthread test result
503118e588b1SRick Liuelif compile_prog "" "$pthread_lib -lrt" ; then
503218e588b1SRick Liu  LIBS="$LIBS -lrt"
5033da93a1fdSaliguorifi
5034da93a1fdSaliguori
5035d99e97e6SThomas Huth# Check whether we need to link libutil for openpty()
5036d99e97e6SThomas Huthcat > $TMPC << EOF
5037d99e97e6SThomas Huthextern int openpty(int *am, int *as, char *name, void *termp, void *winp);
5038d99e97e6SThomas Huthint main(void) { return openpty(0, 0, 0, 0, 0); }
5039d99e97e6SThomas HuthEOF
5040d99e97e6SThomas Huth
50419df8b20dSThomas Huthhave_openpty="no"
50429df8b20dSThomas Huthif compile_prog "" "" ; then
50439df8b20dSThomas Huth  have_openpty="yes"
50449df8b20dSThomas Huthelse
5045d99e97e6SThomas Huth  if compile_prog "" "-lutil" ; then
5046d99e97e6SThomas Huth    libs_tools="-lutil $libs_tools"
50479df8b20dSThomas Huth    have_openpty="yes"
5048d99e97e6SThomas Huth  fi
50496362a53fSJuan Quintelafi
50506362a53fSJuan Quintela
5051de5071c5SBlue Swirl##########################################
5052cd4ec0b4SGerd Hoffmann# spice probe
5053cd4ec0b4SGerd Hoffmannif test "$spice" != "no" ; then
5054cd4ec0b4SGerd Hoffmann  cat > $TMPC << EOF
5055cd4ec0b4SGerd Hoffmann#include <spice.h>
5056cd4ec0b4SGerd Hoffmannint main(void) { spice_server_new(); return 0; }
5057cd4ec0b4SGerd HoffmannEOF
5058710fc4f5SJiri Denemark  spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
5059710fc4f5SJiri Denemark  spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
50601b63665cSMarc-André Lureau  if $pkg_config --atleast-version=0.12.5 spice-server && \
506165d5d3f9SStefan Weil     $pkg_config --atleast-version=0.12.3 spice-protocol && \
5062cd4ec0b4SGerd Hoffmann     compile_prog "$spice_cflags" "$spice_libs" ; then
5063cd4ec0b4SGerd Hoffmann    spice="yes"
5064cd4ec0b4SGerd Hoffmann    QEMU_CFLAGS="$QEMU_CFLAGS $spice_cflags"
5065cd4ec0b4SGerd Hoffmann  else
5066cd4ec0b4SGerd Hoffmann    if test "$spice" = "yes" ; then
50678efc9363SHu Tao      feature_not_found "spice" \
50681b63665cSMarc-André Lureau          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
5069cd4ec0b4SGerd Hoffmann    fi
5070cd4ec0b4SGerd Hoffmann    spice="no"
5071cd4ec0b4SGerd Hoffmann  fi
5072cd4ec0b4SGerd Hoffmannfi
5073cd4ec0b4SGerd Hoffmann
50747b02f544SMarc-André Lureau# check for smartcard support
50757b02f544SMarc-André Lureauif test "$smartcard" != "no"; then
50760f5c642dSMichal Privoznik    if $pkg_config --atleast-version=2.5.1 libcacard; then
50777b02f544SMarc-André Lureau        libcacard_cflags=$($pkg_config --cflags libcacard)
50787b02f544SMarc-André Lureau        libcacard_libs=$($pkg_config --libs libcacard)
50797b02f544SMarc-André Lureau        smartcard="yes"
5080111a38b0SRobert Relyea    else
50817b02f544SMarc-André Lureau        if test "$smartcard" = "yes"; then
50827b02f544SMarc-André Lureau            feature_not_found "smartcard" "Install libcacard devel"
5083111a38b0SRobert Relyea        fi
50847b02f544SMarc-André Lureau        smartcard="no"
5085111a38b0SRobert Relyea    fi
5086111a38b0SRobert Relyeafi
5087111a38b0SRobert Relyea
50882b2325ffSGerd Hoffmann# check for libusb
50892b2325ffSGerd Hoffmannif test "$libusb" != "no" ; then
509065d5d3f9SStefan Weil    if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
50912b2325ffSGerd Hoffmann        libusb="yes"
5092ca871ec8SStefan Weil        libusb_cflags=$($pkg_config --cflags libusb-1.0)
5093ca871ec8SStefan Weil        libusb_libs=$($pkg_config --libs libusb-1.0)
50942b2325ffSGerd Hoffmann    else
50952b2325ffSGerd Hoffmann        if test "$libusb" = "yes"; then
50968efc9363SHu Tao            feature_not_found "libusb" "Install libusb devel >= 1.0.13"
50972b2325ffSGerd Hoffmann        fi
50982b2325ffSGerd Hoffmann        libusb="no"
50992b2325ffSGerd Hoffmann    fi
51002b2325ffSGerd Hoffmannfi
51012b2325ffSGerd Hoffmann
510269354a83SHans de Goede# check for usbredirparser for usb network redirection support
510369354a83SHans de Goedeif test "$usb_redir" != "no" ; then
510465d5d3f9SStefan Weil    if $pkg_config --atleast-version=0.6 libusbredirparser-0.5; then
510569354a83SHans de Goede        usb_redir="yes"
5106ca871ec8SStefan Weil        usb_redir_cflags=$($pkg_config --cflags libusbredirparser-0.5)
5107ca871ec8SStefan Weil        usb_redir_libs=$($pkg_config --libs libusbredirparser-0.5)
510869354a83SHans de Goede    else
510969354a83SHans de Goede        if test "$usb_redir" = "yes"; then
511021684af0SStewart Smith            feature_not_found "usb-redir" "Install usbredir devel"
511169354a83SHans de Goede        fi
511269354a83SHans de Goede        usb_redir="no"
511369354a83SHans de Goede    fi
511469354a83SHans de Goedefi
511569354a83SHans de Goede
5116cd4ec0b4SGerd Hoffmann##########################################
5117d9840e25STomoki Sekiyama# check if we have VSS SDK headers for win
5118d9840e25STomoki Sekiyama
5119e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5120e633a5c6SEric Blake        test "$vss_win32_sdk" != "no" ; then
5121d9840e25STomoki Sekiyama  case "$vss_win32_sdk" in
5122690604f6SMichael Roth    "")   vss_win32_include="-isystem $source_path" ;;
5123d9840e25STomoki Sekiyama    *\ *) # The SDK is installed in "Program Files" by default, but we cannot
5124d9840e25STomoki Sekiyama          # handle path with spaces. So we symlink the headers into ".sdk/vss".
5125690604f6SMichael Roth          vss_win32_include="-isystem $source_path/.sdk/vss"
5126d9840e25STomoki Sekiyama	  symlink "$vss_win32_sdk/inc" "$source_path/.sdk/vss/inc"
5127d9840e25STomoki Sekiyama	  ;;
5128690604f6SMichael Roth    *)    vss_win32_include="-isystem $vss_win32_sdk"
5129d9840e25STomoki Sekiyama  esac
5130d9840e25STomoki Sekiyama  cat > $TMPC << EOF
5131d9840e25STomoki Sekiyama#define __MIDL_user_allocate_free_DEFINED__
5132d9840e25STomoki Sekiyama#include <inc/win2003/vss.h>
5133d9840e25STomoki Sekiyamaint main(void) { return VSS_CTX_BACKUP; }
5134d9840e25STomoki SekiyamaEOF
5135d9840e25STomoki Sekiyama  if compile_prog "$vss_win32_include" "" ; then
5136d9840e25STomoki Sekiyama    guest_agent_with_vss="yes"
5137d9840e25STomoki Sekiyama    QEMU_CFLAGS="$QEMU_CFLAGS $vss_win32_include"
5138315d3184SFam Zheng    libs_qga="-lole32 -loleaut32 -lshlwapi -lstdc++ -Wl,--enable-stdcall-fixup $libs_qga"
5139f33ca81fSMichael Roth    qga_vss_provider="qga/vss-win32/qga-vss.dll qga/vss-win32/qga-vss.tlb"
5140d9840e25STomoki Sekiyama  else
5141d9840e25STomoki Sekiyama    if test "$vss_win32_sdk" != "" ; then
5142d9840e25STomoki Sekiyama      echo "ERROR: Please download and install Microsoft VSS SDK:"
5143d9840e25STomoki Sekiyama      echo "ERROR:   http://www.microsoft.com/en-us/download/details.aspx?id=23490"
5144d9840e25STomoki Sekiyama      echo "ERROR: On POSIX-systems, you can extract the SDK headers by:"
5145d9840e25STomoki Sekiyama      echo "ERROR:   scripts/extract-vsssdk-headers setup.exe"
5146d9840e25STomoki Sekiyama      echo "ERROR: The headers are extracted in the directory \`inc'."
5147d9840e25STomoki Sekiyama      feature_not_found "VSS support"
5148d9840e25STomoki Sekiyama    fi
5149d9840e25STomoki Sekiyama    guest_agent_with_vss="no"
5150d9840e25STomoki Sekiyama  fi
5151d9840e25STomoki Sekiyamafi
5152d9840e25STomoki Sekiyama
5153d9840e25STomoki Sekiyama##########################################
5154d9840e25STomoki Sekiyama# lookup Windows platform SDK (if not specified)
5155d9840e25STomoki Sekiyama# The SDK is needed only to build .tlb (type library) file of guest agent
5156d9840e25STomoki Sekiyama# VSS provider from the source. It is usually unnecessary because the
5157d9840e25STomoki Sekiyama# pre-compiled .tlb file is included.
5158d9840e25STomoki Sekiyama
5159e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no" && \
5160e633a5c6SEric Blake        test "$guest_agent_with_vss" = "yes" ; then
5161d9840e25STomoki Sekiyama  if test -z "$win_sdk"; then
5162d9840e25STomoki Sekiyama    programfiles="$PROGRAMFILES"
5163d9840e25STomoki Sekiyama    test -n "$PROGRAMW6432" && programfiles="$PROGRAMW6432"
5164d9840e25STomoki Sekiyama    if test -n "$programfiles"; then
5165d9840e25STomoki Sekiyama      win_sdk=$(ls -d "$programfiles/Microsoft SDKs/Windows/v"* | tail -1) 2>/dev/null
5166d9840e25STomoki Sekiyama    else
5167d9840e25STomoki Sekiyama      feature_not_found "Windows SDK"
5168d9840e25STomoki Sekiyama    fi
5169d9840e25STomoki Sekiyama  elif test "$win_sdk" = "no"; then
5170d9840e25STomoki Sekiyama    win_sdk=""
5171d9840e25STomoki Sekiyama  fi
5172d9840e25STomoki Sekiyamafi
5173d9840e25STomoki Sekiyama
5174d9840e25STomoki Sekiyama##########################################
517550cbebb9SMichael Roth# check if mingw environment provides a recent ntddscsi.h
5176e633a5c6SEric Blakeif test "$mingw32" = "yes" && test "$guest_agent" != "no"; then
517750cbebb9SMichael Roth  cat > $TMPC << EOF
517850cbebb9SMichael Roth#include <windows.h>
517950cbebb9SMichael Roth#include <ntddscsi.h>
518050cbebb9SMichael Rothint main(void) {
518150cbebb9SMichael Roth#if !defined(IOCTL_SCSI_GET_ADDRESS)
518250cbebb9SMichael Roth#error Missing required ioctl definitions
518350cbebb9SMichael Roth#endif
518450cbebb9SMichael Roth  SCSI_ADDRESS addr = { .Lun = 0, .TargetId = 0, .PathId = 0 };
518550cbebb9SMichael Roth  return addr.Lun;
518650cbebb9SMichael Roth}
518750cbebb9SMichael RothEOF
518850cbebb9SMichael Roth  if compile_prog "" "" ; then
518950cbebb9SMichael Roth    guest_agent_ntddscsi=yes
5190996b9cdcSMatt Hines    libs_qga="-lsetupapi -lcfgmgr32 $libs_qga"
519150cbebb9SMichael Roth  fi
519250cbebb9SMichael Rothfi
519350cbebb9SMichael Roth
519450cbebb9SMichael Roth##########################################
51959d9e1521SGerd Hoffmann# virgl renderer probe
51969d9e1521SGerd Hoffmann
51979d9e1521SGerd Hoffmannif test "$virglrenderer" != "no" ; then
51989d9e1521SGerd Hoffmann  cat > $TMPC << EOF
51999d9e1521SGerd Hoffmann#include <virglrenderer.h>
52009d9e1521SGerd Hoffmannint main(void) { virgl_renderer_poll(); return 0; }
52019d9e1521SGerd HoffmannEOF
52029d9e1521SGerd Hoffmann  virgl_cflags=$($pkg_config --cflags virglrenderer 2>/dev/null)
52039d9e1521SGerd Hoffmann  virgl_libs=$($pkg_config --libs virglrenderer 2>/dev/null)
520447479c55SMarc-André Lureau  virgl_version=$($pkg_config --modversion virglrenderer 2>/dev/null)
52059d9e1521SGerd Hoffmann  if $pkg_config virglrenderer >/dev/null 2>&1 && \
52069d9e1521SGerd Hoffmann     compile_prog "$virgl_cflags" "$virgl_libs" ; then
52079d9e1521SGerd Hoffmann    virglrenderer="yes"
52089d9e1521SGerd Hoffmann  else
52099d9e1521SGerd Hoffmann    if test "$virglrenderer" = "yes" ; then
52109d9e1521SGerd Hoffmann      feature_not_found "virglrenderer"
52119d9e1521SGerd Hoffmann    fi
52129d9e1521SGerd Hoffmann    virglrenderer="no"
52139d9e1521SGerd Hoffmann  fi
52149d9e1521SGerd Hoffmannfi
52159d9e1521SGerd Hoffmann
52169d9e1521SGerd Hoffmann##########################################
52178ca80760SRichard Henderson# capstone
52188ca80760SRichard Henderson
5219e219c499SRichard Hendersoncase "$capstone" in
5220e219c499SRichard Henderson  "" | yes)
52218ca80760SRichard Henderson    if $pkg_config capstone; then
5222e219c499SRichard Henderson      capstone=system
5223e633a5c6SEric Blake    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5224e219c499SRichard Henderson      capstone=git
5225e219c499SRichard Henderson    elif test -e "${source_path}/capstone/Makefile" ; then
5226e219c499SRichard Henderson      capstone=internal
5227e219c499SRichard Henderson    elif test -z "$capstone" ; then
5228e219c499SRichard Henderson      capstone=no
5229e219c499SRichard Henderson    else
5230e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel or git submodule"
5231e219c499SRichard Henderson    fi
5232e219c499SRichard Henderson    ;;
5233e219c499SRichard Henderson
5234e219c499SRichard Henderson  system)
5235e219c499SRichard Henderson    if ! $pkg_config capstone; then
5236e219c499SRichard Henderson      feature_not_found "capstone" "Install capstone devel"
5237e219c499SRichard Henderson    fi
5238e219c499SRichard Henderson    ;;
5239e219c499SRichard Hendersonesac
5240e219c499SRichard Henderson
5241e219c499SRichard Hendersoncase "$capstone" in
5242e219c499SRichard Henderson  git | internal)
5243e219c499SRichard Henderson    if test "$capstone" = git; then
5244e219c499SRichard Henderson      git_submodules="${git_submodules} capstone"
5245e219c499SRichard Henderson    fi
5246e219c499SRichard Henderson    mkdir -p capstone
524725211446SPaolo Bonzini    QEMU_CFLAGS="$QEMU_CFLAGS -I${source_path}/capstone/include"
5248e219c499SRichard Henderson    if test "$mingw32" = "yes"; then
5249e219c499SRichard Henderson      LIBCAPSTONE=capstone.lib
5250e219c499SRichard Henderson    else
5251e219c499SRichard Henderson      LIBCAPSTONE=libcapstone.a
5252e219c499SRichard Henderson    fi
5253c9322ab5SMarc-André Lureau    capstone_libs="-L$PWD/capstone -lcapstone"
5254c9322ab5SMarc-André Lureau    capstone_cflags="-I${source_path}/capstone/include"
5255e219c499SRichard Henderson    ;;
5256e219c499SRichard Henderson
5257e219c499SRichard Henderson  system)
5258c9322ab5SMarc-André Lureau    capstone_libs="$($pkg_config --libs capstone)"
5259c9322ab5SMarc-André Lureau    capstone_cflags="$($pkg_config --cflags capstone)"
52608ca80760SRichard Henderson    QEMU_CFLAGS="$QEMU_CFLAGS $($pkg_config --cflags capstone)"
5261e219c499SRichard Henderson    ;;
5262e219c499SRichard Henderson
5263e219c499SRichard Henderson  no)
5264e219c499SRichard Henderson    ;;
5265e219c499SRichard Henderson  *)
5266e219c499SRichard Henderson    error_exit "Unknown state for capstone: $capstone"
5267e219c499SRichard Henderson    ;;
5268e219c499SRichard Hendersonesac
52698ca80760SRichard Henderson
52708ca80760SRichard Henderson##########################################
52715f6b9e8fSBlue Swirl# check if we have fdatasync
52725f6b9e8fSBlue Swirl
52735f6b9e8fSBlue Swirlfdatasync=no
52745f6b9e8fSBlue Swirlcat > $TMPC << EOF
52755f6b9e8fSBlue Swirl#include <unistd.h>
5276d1722a27SAlexandre Raymondint main(void) {
5277d1722a27SAlexandre Raymond#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
5278d1722a27SAlexandre Raymondreturn fdatasync(0);
5279d1722a27SAlexandre Raymond#else
5280e172fe11SStefan Weil#error Not supported
5281d1722a27SAlexandre Raymond#endif
5282d1722a27SAlexandre Raymond}
52835f6b9e8fSBlue SwirlEOF
52845f6b9e8fSBlue Swirlif compile_prog "" "" ; then
52855f6b9e8fSBlue Swirl    fdatasync=yes
52865f6b9e8fSBlue Swirlfi
52875f6b9e8fSBlue Swirl
528894a420b1SStefan Hajnoczi##########################################
5289e78815a5SAndreas Färber# check if we have madvise
5290e78815a5SAndreas Färber
5291e78815a5SAndreas Färbermadvise=no
5292e78815a5SAndreas Färbercat > $TMPC << EOF
5293e78815a5SAndreas Färber#include <sys/types.h>
5294e78815a5SAndreas Färber#include <sys/mman.h>
5295832ce9c2SScott Wood#include <stddef.h>
5296e78815a5SAndreas Färberint main(void) { return madvise(NULL, 0, MADV_DONTNEED); }
5297e78815a5SAndreas FärberEOF
5298e78815a5SAndreas Färberif compile_prog "" "" ; then
5299e78815a5SAndreas Färber    madvise=yes
5300e78815a5SAndreas Färberfi
5301e78815a5SAndreas Färber
5302e78815a5SAndreas Färber##########################################
5303e78815a5SAndreas Färber# check if we have posix_madvise
5304e78815a5SAndreas Färber
5305e78815a5SAndreas Färberposix_madvise=no
5306e78815a5SAndreas Färbercat > $TMPC << EOF
5307e78815a5SAndreas Färber#include <sys/mman.h>
5308832ce9c2SScott Wood#include <stddef.h>
5309e78815a5SAndreas Färberint main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }
5310e78815a5SAndreas FärberEOF
5311e78815a5SAndreas Färberif compile_prog "" "" ; then
5312e78815a5SAndreas Färber    posix_madvise=yes
5313e78815a5SAndreas Färberfi
5314e78815a5SAndreas Färber
5315e78815a5SAndreas Färber##########################################
53169bc5a719SAndreas Gustafsson# check if we have posix_memalign()
53179bc5a719SAndreas Gustafsson
53189bc5a719SAndreas Gustafssonposix_memalign=no
53199bc5a719SAndreas Gustafssoncat > $TMPC << EOF
53209bc5a719SAndreas Gustafsson#include <stdlib.h>
53219bc5a719SAndreas Gustafssonint main(void) {
53229bc5a719SAndreas Gustafsson    void *p;
53239bc5a719SAndreas Gustafsson    return posix_memalign(&p, 8, 8);
53249bc5a719SAndreas Gustafsson}
53259bc5a719SAndreas GustafssonEOF
53269bc5a719SAndreas Gustafssonif compile_prog "" "" ; then
53279bc5a719SAndreas Gustafsson    posix_memalign=yes
53289bc5a719SAndreas Gustafssonfi
53299bc5a719SAndreas Gustafsson
53309bc5a719SAndreas Gustafsson##########################################
53310a852417SPaul Durrant# check if we have posix_syslog
53320a852417SPaul Durrant
53330a852417SPaul Durrantposix_syslog=no
53340a852417SPaul Durrantcat > $TMPC << EOF
53350a852417SPaul Durrant#include <syslog.h>
53360a852417SPaul Durrantint main(void) { openlog("qemu", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "configure"); return 0; }
53370a852417SPaul DurrantEOF
53380a852417SPaul Durrantif compile_prog "" "" ; then
53390a852417SPaul Durrant    posix_syslog=yes
53400a852417SPaul Durrantfi
53410a852417SPaul Durrant
53420a852417SPaul Durrant##########################################
5343401bc051SPeter Maydell# check if we have sem_timedwait
5344401bc051SPeter Maydell
5345401bc051SPeter Maydellsem_timedwait=no
5346401bc051SPeter Maydellcat > $TMPC << EOF
5347401bc051SPeter Maydell#include <semaphore.h>
5348811294b7SDaniel P. Berrangéint main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
5349401bc051SPeter MaydellEOF
5350401bc051SPeter Maydellif compile_prog "" "" ; then
5351401bc051SPeter Maydell    sem_timedwait=yes
5352401bc051SPeter Maydellfi
5353401bc051SPeter Maydell
5354401bc051SPeter Maydell##########################################
53555c99fa37SKeno Fischer# check if we have strchrnul
53565c99fa37SKeno Fischer
53575c99fa37SKeno Fischerstrchrnul=no
53585c99fa37SKeno Fischercat > $TMPC << EOF
53595c99fa37SKeno Fischer#include <string.h>
53605c99fa37SKeno Fischerint main(void);
53615c99fa37SKeno Fischer// Use a haystack that the compiler shouldn't be able to constant fold
53625c99fa37SKeno Fischerchar *haystack = (char*)&main;
53635c99fa37SKeno Fischerint main(void) { return strchrnul(haystack, 'x') != &haystack[6]; }
53645c99fa37SKeno FischerEOF
53655c99fa37SKeno Fischerif compile_prog "" "" ; then
53665c99fa37SKeno Fischer    strchrnul=yes
53675c99fa37SKeno Fischerfi
53685c99fa37SKeno Fischer
53698a792b03SJiufei Xue#########################################
53708a792b03SJiufei Xue# check if we have st_atim
53718a792b03SJiufei Xue
53728a792b03SJiufei Xuest_atim=no
53738a792b03SJiufei Xuecat > $TMPC << EOF
53748a792b03SJiufei Xue#include <sys/stat.h>
53758a792b03SJiufei Xue#include <stddef.h>
53768a792b03SJiufei Xueint main(void) { return offsetof(struct stat, st_atim); }
53778a792b03SJiufei XueEOF
53788a792b03SJiufei Xueif compile_prog "" "" ; then
53798a792b03SJiufei Xue    st_atim=yes
53808a792b03SJiufei Xuefi
53818a792b03SJiufei Xue
53825c99fa37SKeno Fischer##########################################
538394a420b1SStefan Hajnoczi# check if trace backend exists
538494a420b1SStefan Hajnoczi
53855b808275SLluís Vilanova$python "$source_path/scripts/tracetool.py" "--backends=$trace_backends" --check-backends  > /dev/null 2> /dev/null
538694a420b1SStefan Hajnocziif test "$?" -ne 0 ; then
53875b808275SLluís Vilanova  error_exit "invalid trace backends" \
53885b808275SLluís Vilanova      "Please choose supported trace backends."
538994a420b1SStefan Hajnoczifi
539094a420b1SStefan Hajnoczi
53917e24e92aSStefan Hajnoczi##########################################
53927e24e92aSStefan Hajnoczi# For 'ust' backend, test if ust headers are present
53935b808275SLluís Vilanovaif have_backend "ust"; then
53947e24e92aSStefan Hajnoczi  cat > $TMPC << EOF
5395bf15f63cSMohamad Gebai#include <lttng/tracepoint.h>
53967e24e92aSStefan Hajnocziint main(void) { return 0; }
53977e24e92aSStefan HajnocziEOF
5398c79ed23dSFrancis Deslauriers  if compile_prog "" "-Wl,--no-as-needed -ldl" ; then
5399bf15f63cSMohamad Gebai    if $pkg_config lttng-ust --exists; then
540089138857SStefan Weil      lttng_ust_libs=$($pkg_config --libs lttng-ust)
54017e24e92aSStefan Hajnoczi    else
5402c79ed23dSFrancis Deslauriers      lttng_ust_libs="-llttng-ust -ldl"
5403bf15f63cSMohamad Gebai    fi
5404bf15f63cSMohamad Gebai    if $pkg_config liburcu-bp --exists; then
540589138857SStefan Weil      urcu_bp_libs=$($pkg_config --libs liburcu-bp)
5406bf15f63cSMohamad Gebai    else
5407bf15f63cSMohamad Gebai      urcu_bp_libs="-lurcu-bp"
5408bf15f63cSMohamad Gebai    fi
5409bf15f63cSMohamad Gebai
5410bf15f63cSMohamad Gebai    LIBS="$lttng_ust_libs $urcu_bp_libs $LIBS"
5411bf15f63cSMohamad Gebai  else
5412bf15f63cSMohamad Gebai    error_exit "Trace backend 'ust' missing lttng-ust header files"
54137e24e92aSStefan Hajnoczi  fi
54147e24e92aSStefan Hajnoczifi
5415b3d08c02SDaniel P. Berrange
5416b3d08c02SDaniel P. Berrange##########################################
5417b3d08c02SDaniel P. Berrange# For 'dtrace' backend, test if 'dtrace' command is present
54185b808275SLluís Vilanovaif have_backend "dtrace"; then
5419b3d08c02SDaniel P. Berrange  if ! has 'dtrace' ; then
542076ad07a4SPeter Maydell    error_exit "dtrace command is not found in PATH $PATH"
5421b3d08c02SDaniel P. Berrange  fi
5422c276b17dSDaniel P. Berrange  trace_backend_stap="no"
5423c276b17dSDaniel P. Berrange  if has 'stap' ; then
5424c276b17dSDaniel P. Berrange    trace_backend_stap="yes"
5425c276b17dSDaniel P. Berrange  fi
5426b3d08c02SDaniel P. Berrangefi
5427b3d08c02SDaniel P. Berrange
54287e24e92aSStefan Hajnoczi##########################################
5429519175a2SAlex Barcelo# check and set a backend for coroutine
5430d0e2fce5SAneesh Kumar K.V
54317c2acc70SPeter Maydell# We prefer ucontext, but it's not always possible. The fallback
543233c53c54SDaniel P. Berrange# is sigcontext. On Windows the only valid backend is the Windows
543333c53c54SDaniel P. Berrange# specific one.
54347c2acc70SPeter Maydell
54357c2acc70SPeter Maydellucontext_works=no
5436d0e2fce5SAneesh Kumar K.Vif test "$darwin" != "yes"; then
5437d0e2fce5SAneesh Kumar K.V  cat > $TMPC << EOF
5438d0e2fce5SAneesh Kumar K.V#include <ucontext.h>
5439cdf84806SPeter Maydell#ifdef __stub_makecontext
5440cdf84806SPeter Maydell#error Ignoring glibc stub makecontext which will always fail
5441cdf84806SPeter Maydell#endif
544275cafad7SStefan Weilint main(void) { makecontext(0, 0, 0); return 0; }
5443d0e2fce5SAneesh Kumar K.VEOF
5444d0e2fce5SAneesh Kumar K.V  if compile_prog "" "" ; then
54457c2acc70SPeter Maydell    ucontext_works=yes
5446d0e2fce5SAneesh Kumar K.V  fi
5447519175a2SAlex Barcelofi
54487c2acc70SPeter Maydell
54497c2acc70SPeter Maydellif test "$coroutine" = ""; then
54507c2acc70SPeter Maydell  if test "$mingw32" = "yes"; then
54517c2acc70SPeter Maydell    coroutine=win32
54527c2acc70SPeter Maydell  elif test "$ucontext_works" = "yes"; then
54537c2acc70SPeter Maydell    coroutine=ucontext
5454519175a2SAlex Barcelo  else
54557c2acc70SPeter Maydell    coroutine=sigaltstack
54567c2acc70SPeter Maydell  fi
54577c2acc70SPeter Maydellelse
54587c2acc70SPeter Maydell  case $coroutine in
54597c2acc70SPeter Maydell  windows)
54607c2acc70SPeter Maydell    if test "$mingw32" != "yes"; then
54617c2acc70SPeter Maydell      error_exit "'windows' coroutine backend only valid for Windows"
54627c2acc70SPeter Maydell    fi
54637c2acc70SPeter Maydell    # Unfortunately the user visible backend name doesn't match the
54647c2acc70SPeter Maydell    # coroutine-*.c filename for this case, so we have to adjust it here.
54657c2acc70SPeter Maydell    coroutine=win32
54667c2acc70SPeter Maydell    ;;
54677c2acc70SPeter Maydell  ucontext)
54687c2acc70SPeter Maydell    if test "$ucontext_works" != "yes"; then
54697c2acc70SPeter Maydell      feature_not_found "ucontext"
54707c2acc70SPeter Maydell    fi
54717c2acc70SPeter Maydell    ;;
547233c53c54SDaniel P. Berrange  sigaltstack)
54737c2acc70SPeter Maydell    if test "$mingw32" = "yes"; then
54747c2acc70SPeter Maydell      error_exit "only the 'windows' coroutine backend is valid for Windows"
54757c2acc70SPeter Maydell    fi
54767c2acc70SPeter Maydell    ;;
54777c2acc70SPeter Maydell  *)
547876ad07a4SPeter Maydell    error_exit "unknown coroutine backend $coroutine"
54797c2acc70SPeter Maydell    ;;
54807c2acc70SPeter Maydell  esac
5481d0e2fce5SAneesh Kumar K.Vfi
5482d0e2fce5SAneesh Kumar K.V
548370c60c08SStefan Hajnocziif test "$coroutine_pool" = ""; then
548470c60c08SStefan Hajnoczi  coroutine_pool=yes
548570c60c08SStefan Hajnoczifi
548670c60c08SStefan Hajnoczi
54877d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes"; then
54887d992e4dSPeter Lieven  if test "$coroutine_pool" = "yes"; then
54897d992e4dSPeter Lieven    echo "WARN: disabling coroutine pool for stack usage debugging"
54907d992e4dSPeter Lieven    coroutine_pool=no
54917d992e4dSPeter Lieven  fi
54927d992e4dSPeter Lievenfi
54937d992e4dSPeter Lieven
54941e4f6065SDaniele Buono##################################################
54951e4f6065SDaniele Buono# SafeStack
54961e4f6065SDaniele Buono
54971e4f6065SDaniele Buono
54981e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
54991e4f6065SDaniele Buonocat > $TMPC << EOF
55001e4f6065SDaniele Buonoint main(int argc, char *argv[])
55011e4f6065SDaniele Buono{
55021e4f6065SDaniele Buono#if ! __has_feature(safe_stack)
55031e4f6065SDaniele Buono#error SafeStack Disabled
55041e4f6065SDaniele Buono#endif
55051e4f6065SDaniele Buono    return 0;
55061e4f6065SDaniele Buono}
55071e4f6065SDaniele BuonoEOF
55081e4f6065SDaniele Buono  flag="-fsanitize=safe-stack"
55091e4f6065SDaniele Buono  # Check that safe-stack is supported and enabled.
55101e4f6065SDaniele Buono  if compile_prog "-Werror $flag" "$flag"; then
55111e4f6065SDaniele Buono    # Flag needed both at compilation and at linking
55121e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
55131e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
55141e4f6065SDaniele Buono  else
55151e4f6065SDaniele Buono    error_exit "SafeStack not supported by your compiler"
55161e4f6065SDaniele Buono  fi
55171e4f6065SDaniele Buono  if test "$coroutine" != "ucontext"; then
55181e4f6065SDaniele Buono    error_exit "SafeStack is only supported by the coroutine backend ucontext"
55191e4f6065SDaniele Buono  fi
55201e4f6065SDaniele Buonoelse
55211e4f6065SDaniele Buonocat > $TMPC << EOF
55221e4f6065SDaniele Buonoint main(int argc, char *argv[])
55231e4f6065SDaniele Buono{
55241e4f6065SDaniele Buono#if defined(__has_feature)
55251e4f6065SDaniele Buono#if __has_feature(safe_stack)
55261e4f6065SDaniele Buono#error SafeStack Enabled
55271e4f6065SDaniele Buono#endif
55281e4f6065SDaniele Buono#endif
55291e4f6065SDaniele Buono    return 0;
55301e4f6065SDaniele Buono}
55311e4f6065SDaniele BuonoEOF
55321e4f6065SDaniele Buonoif test "$safe_stack" = "no"; then
55331e4f6065SDaniele Buono  # Make sure that safe-stack is disabled
55341e4f6065SDaniele Buono  if ! compile_prog "-Werror" ""; then
55351e4f6065SDaniele Buono    # SafeStack was already enabled, try to explicitly remove the feature
55361e4f6065SDaniele Buono    flag="-fno-sanitize=safe-stack"
55371e4f6065SDaniele Buono    if ! compile_prog "-Werror $flag" "$flag"; then
55381e4f6065SDaniele Buono      error_exit "Configure cannot disable SafeStack"
55391e4f6065SDaniele Buono    fi
55401e4f6065SDaniele Buono    QEMU_CFLAGS="$QEMU_CFLAGS $flag"
55411e4f6065SDaniele Buono    QEMU_LDFLAGS="$QEMU_LDFLAGS $flag"
55421e4f6065SDaniele Buono  fi
55431e4f6065SDaniele Buonoelse # "$safe_stack" = ""
55441e4f6065SDaniele Buono  # Set safe_stack to yes or no based on pre-existing flags
55451e4f6065SDaniele Buono  if compile_prog "-Werror" ""; then
55461e4f6065SDaniele Buono    safe_stack="no"
55471e4f6065SDaniele Buono  else
55481e4f6065SDaniele Buono    safe_stack="yes"
55491e4f6065SDaniele Buono    if test "$coroutine" != "ucontext"; then
55501e4f6065SDaniele Buono      error_exit "SafeStack is only supported by the coroutine backend ucontext"
55511e4f6065SDaniele Buono    fi
55521e4f6065SDaniele Buono  fi
55531e4f6065SDaniele Buonofi
55541e4f6065SDaniele Buonofi
55557d992e4dSPeter Lieven
5556d0e2fce5SAneesh Kumar K.V##########################################
5557d2042378SAneesh Kumar K.V# check if we have open_by_handle_at
5558d2042378SAneesh Kumar K.V
55594e1797f9SStefan Weilopen_by_handle_at=no
5560d2042378SAneesh Kumar K.Vcat > $TMPC << EOF
5561d2042378SAneesh Kumar K.V#include <fcntl.h>
5562acc55ba8SStefan Weil#if !defined(AT_EMPTY_PATH)
5563acc55ba8SStefan Weil# error missing definition
5564acc55ba8SStefan Weil#else
556575cafad7SStefan Weilint main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
5566acc55ba8SStefan Weil#endif
5567d2042378SAneesh Kumar K.VEOF
5568d2042378SAneesh Kumar K.Vif compile_prog "" "" ; then
5569d2042378SAneesh Kumar K.V    open_by_handle_at=yes
5570d2042378SAneesh Kumar K.Vfi
5571d2042378SAneesh Kumar K.V
5572e06a765eSHarsh Prateek Bora########################################
5573e06a765eSHarsh Prateek Bora# check if we have linux/magic.h
5574e06a765eSHarsh Prateek Bora
5575e06a765eSHarsh Prateek Boralinux_magic_h=no
5576e06a765eSHarsh Prateek Boracat > $TMPC << EOF
5577e06a765eSHarsh Prateek Bora#include <linux/magic.h>
5578e06a765eSHarsh Prateek Boraint main(void) {
557975cafad7SStefan Weil  return 0;
5580e06a765eSHarsh Prateek Bora}
5581e06a765eSHarsh Prateek BoraEOF
5582e06a765eSHarsh Prateek Boraif compile_prog "" "" ; then
5583e06a765eSHarsh Prateek Bora    linux_magic_h=yes
5584e06a765eSHarsh Prateek Borafi
5585e06a765eSHarsh Prateek Bora
55868ab1bf12SLuiz Capitulino########################################
5587541be927SChristian Borntraeger# check if we have valgrind/valgrind.h
55883f4349dcSKevin Wolf
55893f4349dcSKevin Wolfvalgrind_h=no
55903f4349dcSKevin Wolfcat > $TMPC << EOF
55913f4349dcSKevin Wolf#include <valgrind/valgrind.h>
55923f4349dcSKevin Wolfint main(void) {
55933f4349dcSKevin Wolf  return 0;
55943f4349dcSKevin Wolf}
55953f4349dcSKevin WolfEOF
55963f4349dcSKevin Wolfif compile_prog "" "" ; then
55973f4349dcSKevin Wolf    valgrind_h=yes
55983f4349dcSKevin Wolffi
55993f4349dcSKevin Wolf
56003f4349dcSKevin Wolf########################################
56018ab1bf12SLuiz Capitulino# check if environ is declared
56028ab1bf12SLuiz Capitulino
56038ab1bf12SLuiz Capitulinohas_environ=no
56048ab1bf12SLuiz Capitulinocat > $TMPC << EOF
56058ab1bf12SLuiz Capitulino#include <unistd.h>
56068ab1bf12SLuiz Capitulinoint main(void) {
5607c075a723SBlue Swirl    environ = 0;
56088ab1bf12SLuiz Capitulino    return 0;
56098ab1bf12SLuiz Capitulino}
56108ab1bf12SLuiz CapitulinoEOF
56118ab1bf12SLuiz Capitulinoif compile_prog "" "" ; then
56128ab1bf12SLuiz Capitulino    has_environ=yes
56138ab1bf12SLuiz Capitulinofi
56148ab1bf12SLuiz Capitulino
561576a347e1SRichard Henderson########################################
561676a347e1SRichard Henderson# check if cpuid.h is usable.
561776a347e1SRichard Henderson
561876a347e1SRichard Hendersoncat > $TMPC << EOF
561976a347e1SRichard Henderson#include <cpuid.h>
562076a347e1SRichard Hendersonint main(void) {
5621774d566cSPeter Maydell    unsigned a, b, c, d;
5622774d566cSPeter Maydell    int max = __get_cpuid_max(0, 0);
5623774d566cSPeter Maydell
5624774d566cSPeter Maydell    if (max >= 1) {
5625774d566cSPeter Maydell        __cpuid(1, a, b, c, d);
5626774d566cSPeter Maydell    }
5627774d566cSPeter Maydell
5628774d566cSPeter Maydell    if (max >= 7) {
5629774d566cSPeter Maydell        __cpuid_count(7, 0, a, b, c, d);
5630774d566cSPeter Maydell    }
5631774d566cSPeter Maydell
563276a347e1SRichard Henderson    return 0;
563376a347e1SRichard Henderson}
563476a347e1SRichard HendersonEOF
563576a347e1SRichard Hendersonif compile_prog "" "" ; then
563676a347e1SRichard Henderson    cpuid_h=yes
563776a347e1SRichard Hendersonfi
563876a347e1SRichard Henderson
56395dd89908SRichard Henderson##########################################
56405dd89908SRichard Henderson# avx2 optimization requirement check
56415dd89908SRichard Henderson#
56425dd89908SRichard Henderson# There is no point enabling this if cpuid.h is not usable,
56435dd89908SRichard Henderson# since we won't be able to select the new routines.
56445dd89908SRichard Henderson
5645e633a5c6SEric Blakeif test "$cpuid_h" = "yes" && test "$avx2_opt" != "no"; then
56465dd89908SRichard Henderson  cat > $TMPC << EOF
56475dd89908SRichard Henderson#pragma GCC push_options
56485dd89908SRichard Henderson#pragma GCC target("avx2")
56495dd89908SRichard Henderson#include <cpuid.h>
56505dd89908SRichard Henderson#include <immintrin.h>
56515dd89908SRichard Hendersonstatic int bar(void *a) {
56525dd89908SRichard Henderson    __m256i x = *(__m256i *)a;
56535dd89908SRichard Henderson    return _mm256_testz_si256(x, x);
56545dd89908SRichard Henderson}
56555dd89908SRichard Hendersonint main(int argc, char *argv[]) { return bar(argv[0]); }
56565dd89908SRichard HendersonEOF
56575dd89908SRichard Henderson  if compile_object "" ; then
56585dd89908SRichard Henderson    avx2_opt="yes"
565986583a07SLiam Merwick  else
566086583a07SLiam Merwick    avx2_opt="no"
56615dd89908SRichard Henderson  fi
56625dd89908SRichard Hendersonfi
56635dd89908SRichard Henderson
56646b8cd447SRobert Hoo##########################################
56656b8cd447SRobert Hoo# avx512f optimization requirement check
56666b8cd447SRobert Hoo#
56676b8cd447SRobert Hoo# There is no point enabling this if cpuid.h is not usable,
56686b8cd447SRobert Hoo# since we won't be able to select the new routines.
56696b8cd447SRobert Hoo# by default, it is turned off.
56706b8cd447SRobert Hoo# if user explicitly want to enable it, check environment
56716b8cd447SRobert Hoo
56726b8cd447SRobert Hooif test "$cpuid_h" = "yes" && test "$avx512f_opt" = "yes"; then
56736b8cd447SRobert Hoo  cat > $TMPC << EOF
56746b8cd447SRobert Hoo#pragma GCC push_options
56756b8cd447SRobert Hoo#pragma GCC target("avx512f")
56766b8cd447SRobert Hoo#include <cpuid.h>
56776b8cd447SRobert Hoo#include <immintrin.h>
56786b8cd447SRobert Hoostatic int bar(void *a) {
56796b8cd447SRobert Hoo    __m512i x = *(__m512i *)a;
56806b8cd447SRobert Hoo    return _mm512_test_epi64_mask(x, x);
56816b8cd447SRobert Hoo}
56826b8cd447SRobert Hooint main(int argc, char *argv[])
56836b8cd447SRobert Hoo{
56846b8cd447SRobert Hoo	return bar(argv[0]);
56856b8cd447SRobert Hoo}
56866b8cd447SRobert HooEOF
56876b8cd447SRobert Hoo  if ! compile_object "" ; then
56886b8cd447SRobert Hoo    avx512f_opt="no"
56896b8cd447SRobert Hoo  fi
56906b8cd447SRobert Hooelse
56916b8cd447SRobert Hoo  avx512f_opt="no"
56926b8cd447SRobert Hoofi
56936b8cd447SRobert Hoo
5694f540166bSRichard Henderson########################################
5695f540166bSRichard Henderson# check if __[u]int128_t is usable.
5696f540166bSRichard Henderson
5697f540166bSRichard Hendersonint128=no
5698f540166bSRichard Hendersoncat > $TMPC << EOF
5699f540166bSRichard Henderson__int128_t a;
5700f540166bSRichard Henderson__uint128_t b;
5701f540166bSRichard Hendersonint main (void) {
5702f540166bSRichard Henderson  a = a + b;
5703f540166bSRichard Henderson  b = a * b;
5704464e3671SPeter Maydell  a = a * a;
5705f540166bSRichard Henderson  return 0;
5706f540166bSRichard Henderson}
5707f540166bSRichard HendersonEOF
5708f540166bSRichard Hendersonif compile_prog "" "" ; then
5709f540166bSRichard Henderson    int128=yes
5710f540166bSRichard Hendersonfi
571176a347e1SRichard Henderson
57127ebee43eSRichard Henderson#########################################
57137ebee43eSRichard Henderson# See if 128-bit atomic operations are supported.
57147ebee43eSRichard Henderson
57157ebee43eSRichard Hendersonatomic128=no
57167ebee43eSRichard Hendersonif test "$int128" = "yes"; then
57177ebee43eSRichard Henderson  cat > $TMPC << EOF
57187ebee43eSRichard Hendersonint main(void)
57197ebee43eSRichard Henderson{
57207ebee43eSRichard Henderson  unsigned __int128 x = 0, y = 0;
57217ebee43eSRichard Henderson  y = __atomic_load_16(&x, 0);
57227ebee43eSRichard Henderson  __atomic_store_16(&x, y, 0);
57237ebee43eSRichard Henderson  __atomic_compare_exchange_16(&x, &y, x, 0, 0, 0);
57247ebee43eSRichard Henderson  return 0;
57257ebee43eSRichard Henderson}
57267ebee43eSRichard HendersonEOF
57277ebee43eSRichard Henderson  if compile_prog "" "" ; then
57287ebee43eSRichard Henderson    atomic128=yes
57297ebee43eSRichard Henderson  fi
57307ebee43eSRichard Hendersonfi
57317ebee43eSRichard Henderson
5732e6cd4bb5SRichard Hendersoncmpxchg128=no
5733e633a5c6SEric Blakeif test "$int128" = yes && test "$atomic128" = no; then
5734e6cd4bb5SRichard Henderson  cat > $TMPC << EOF
5735e6cd4bb5SRichard Hendersonint main(void)
5736e6cd4bb5SRichard Henderson{
5737e6cd4bb5SRichard Henderson  unsigned __int128 x = 0, y = 0;
5738e6cd4bb5SRichard Henderson  __sync_val_compare_and_swap_16(&x, y, x);
5739e6cd4bb5SRichard Henderson  return 0;
5740e6cd4bb5SRichard Henderson}
5741e6cd4bb5SRichard HendersonEOF
5742e6cd4bb5SRichard Henderson  if compile_prog "" "" ; then
5743e6cd4bb5SRichard Henderson    cmpxchg128=yes
5744e6cd4bb5SRichard Henderson  fi
5745e6cd4bb5SRichard Hendersonfi
5746e6cd4bb5SRichard Henderson
5747df79b996SRichard Henderson#########################################
5748df79b996SRichard Henderson# See if 64-bit atomic operations are supported.
5749df79b996SRichard Henderson# Note that without __atomic builtins, we can only
5750df79b996SRichard Henderson# assume atomic loads/stores max at pointer size.
5751df79b996SRichard Henderson
5752df79b996SRichard Hendersoncat > $TMPC << EOF
5753df79b996SRichard Henderson#include <stdint.h>
5754df79b996SRichard Hendersonint main(void)
5755df79b996SRichard Henderson{
5756df79b996SRichard Henderson  uint64_t x = 0, y = 0;
5757df79b996SRichard Henderson#ifdef __ATOMIC_RELAXED
5758df79b996SRichard Henderson  y = __atomic_load_8(&x, 0);
5759df79b996SRichard Henderson  __atomic_store_8(&x, y, 0);
5760df79b996SRichard Henderson  __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
5761df79b996SRichard Henderson  __atomic_exchange_8(&x, y, 0);
5762df79b996SRichard Henderson  __atomic_fetch_add_8(&x, y, 0);
5763df79b996SRichard Henderson#else
5764df79b996SRichard Henderson  typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
5765df79b996SRichard Henderson  __sync_lock_test_and_set(&x, y);
5766df79b996SRichard Henderson  __sync_val_compare_and_swap(&x, y, 0);
5767df79b996SRichard Henderson  __sync_fetch_and_add(&x, y);
5768df79b996SRichard Henderson#endif
5769df79b996SRichard Henderson  return 0;
5770df79b996SRichard Henderson}
5771df79b996SRichard HendersonEOF
5772df79b996SRichard Hendersonif compile_prog "" "" ; then
5773df79b996SRichard Henderson  atomic64=yes
5774df79b996SRichard Hendersonfi
5775df79b996SRichard Henderson
577626fffe29SEmilio G. Cota#########################################
577726fffe29SEmilio G. Cota# See if --dynamic-list is supported by the linker
577826fffe29SEmilio G. Cotald_dynamic_list="no"
577926fffe29SEmilio G. Cotaif test "$static" = "no" ; then
578026fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
578126fffe29SEmilio G. Cota{
578226fffe29SEmilio G. Cota  foo;
578326fffe29SEmilio G. Cota};
578426fffe29SEmilio G. CotaEOF
578526fffe29SEmilio G. Cota
578626fffe29SEmilio G. Cota    cat > $TMPC <<EOF
578726fffe29SEmilio G. Cota#include <stdio.h>
578826fffe29SEmilio G. Cotavoid foo(void);
578926fffe29SEmilio G. Cota
579026fffe29SEmilio G. Cotavoid foo(void)
579126fffe29SEmilio G. Cota{
579226fffe29SEmilio G. Cota  printf("foo\n");
579326fffe29SEmilio G. Cota}
579426fffe29SEmilio G. Cota
579526fffe29SEmilio G. Cotaint main(void)
579626fffe29SEmilio G. Cota{
579726fffe29SEmilio G. Cota  foo();
579826fffe29SEmilio G. Cota  return 0;
579926fffe29SEmilio G. Cota}
580026fffe29SEmilio G. CotaEOF
580126fffe29SEmilio G. Cota
580226fffe29SEmilio G. Cota    if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
580326fffe29SEmilio G. Cota        ld_dynamic_list="yes"
580426fffe29SEmilio G. Cota    fi
580526fffe29SEmilio G. Cotafi
580626fffe29SEmilio G. Cota
580726fffe29SEmilio G. Cota#########################################
580826fffe29SEmilio G. Cota# See if -exported_symbols_list is supported by the linker
580926fffe29SEmilio G. Cota
581026fffe29SEmilio G. Cotald_exported_symbols_list="no"
581126fffe29SEmilio G. Cotaif test "$static" = "no" ; then
581226fffe29SEmilio G. Cota    cat > $TMPTXT <<EOF
581326fffe29SEmilio G. Cota  _foo
581426fffe29SEmilio G. CotaEOF
581526fffe29SEmilio G. Cota
581626fffe29SEmilio G. Cota    if compile_prog "" "-Wl,-exported_symbols_list,$TMPTXT" ; then
581726fffe29SEmilio G. Cota        ld_exported_symbols_list="yes"
581826fffe29SEmilio G. Cota    fi
581926fffe29SEmilio G. Cotafi
582026fffe29SEmilio G. Cota
582126fffe29SEmilio G. Cotaif  test "$plugins" = "yes" &&
582226fffe29SEmilio G. Cota    test "$ld_dynamic_list" = "no" &&
582326fffe29SEmilio G. Cota    test "$ld_exported_symbols_list" = "no" ; then
582426fffe29SEmilio G. Cota  error_exit \
582526fffe29SEmilio G. Cota      "Plugin support requires dynamic linking and specifying a set of symbols " \
582626fffe29SEmilio G. Cota      "that are exported to plugins. Unfortunately your linker doesn't " \
582726fffe29SEmilio G. Cota      "support the flag (--dynamic-list or -exported_symbols_list) used " \
582826fffe29SEmilio G. Cota      "for this purpose. You can't build with --static."
582926fffe29SEmilio G. Cotafi
583026fffe29SEmilio G. Cota
58311e6e9acaSRichard Henderson########################################
5832db8aaae8SRichard Henderson# See if __attribute__((alias)) is supported.
5833db8aaae8SRichard Henderson# This false for Xcode 9, but has been remedied for Xcode 10.
5834db8aaae8SRichard Henderson# Unfortunately, travis uses Xcode 9 by default.
5835db8aaae8SRichard Henderson
5836db8aaae8SRichard Hendersonattralias=no
5837db8aaae8SRichard Hendersoncat > $TMPC << EOF
5838db8aaae8SRichard Hendersonint x = 1;
5839db8aaae8SRichard Hendersonextern const int y __attribute__((alias("x")));
5840db8aaae8SRichard Hendersonint main(void) { return 0; }
5841db8aaae8SRichard HendersonEOF
5842db8aaae8SRichard Hendersonif compile_prog "" "" ; then
5843db8aaae8SRichard Henderson    attralias=yes
5844db8aaae8SRichard Hendersonfi
5845db8aaae8SRichard Henderson
5846db8aaae8SRichard Henderson########################################
58471e6e9acaSRichard Henderson# check if getauxval is available.
58481e6e9acaSRichard Henderson
58491e6e9acaSRichard Hendersongetauxval=no
58501e6e9acaSRichard Hendersoncat > $TMPC << EOF
58511e6e9acaSRichard Henderson#include <sys/auxv.h>
58521e6e9acaSRichard Hendersonint main(void) {
58531e6e9acaSRichard Henderson  return getauxval(AT_HWCAP) == 0;
58541e6e9acaSRichard Henderson}
58551e6e9acaSRichard HendersonEOF
58561e6e9acaSRichard Hendersonif compile_prog "" "" ; then
58571e6e9acaSRichard Henderson    getauxval=yes
58581e6e9acaSRichard Hendersonfi
58591e6e9acaSRichard Henderson
5860fd0e6053SJohn Snow########################################
5861fd0e6053SJohn Snow# check if ccache is interfering with
5862fd0e6053SJohn Snow# semantic analysis of macros
5863fd0e6053SJohn Snow
58645e4dfd3dSJohn Snowunset CCACHE_CPP2
5865fd0e6053SJohn Snowccache_cpp2=no
5866fd0e6053SJohn Snowcat > $TMPC << EOF
5867fd0e6053SJohn Snowstatic const int Z = 1;
5868fd0e6053SJohn Snow#define fn() ({ Z; })
5869fd0e6053SJohn Snow#define TAUT(X) ((X) == Z)
5870fd0e6053SJohn Snow#define PAREN(X, Y) (X == Y)
5871fd0e6053SJohn Snow#define ID(X) (X)
5872fd0e6053SJohn Snowint main(int argc, char *argv[])
5873fd0e6053SJohn Snow{
5874fd0e6053SJohn Snow    int x = 0, y = 0;
5875fd0e6053SJohn Snow    x = ID(x);
5876fd0e6053SJohn Snow    x = fn();
5877fd0e6053SJohn Snow    fn();
5878fd0e6053SJohn Snow    if (PAREN(x, y)) return 0;
5879fd0e6053SJohn Snow    if (TAUT(Z)) return 0;
5880fd0e6053SJohn Snow    return 0;
5881fd0e6053SJohn Snow}
5882fd0e6053SJohn SnowEOF
5883fd0e6053SJohn Snow
5884fd0e6053SJohn Snowif ! compile_object "-Werror"; then
5885fd0e6053SJohn Snow    ccache_cpp2=yes
5886fd0e6053SJohn Snowfi
5887fd0e6053SJohn Snow
5888b553a042SJohn Snow#################################################
5889b553a042SJohn Snow# clang does not support glibc + FORTIFY_SOURCE.
5890b553a042SJohn Snow
5891b553a042SJohn Snowif test "$fortify_source" != "no"; then
5892b553a042SJohn Snow  if echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
5893b553a042SJohn Snow    fortify_source="no";
5894e189091fSPeter Maydell  elif test -n "$cxx" && has $cxx &&
5895cfcc7c14SJohn Snow       echo | $cxx -dM -E - | grep __clang__ >/dev/null 2>&1 ; then
5896b553a042SJohn Snow    fortify_source="no";
5897b553a042SJohn Snow  else
5898b553a042SJohn Snow    fortify_source="yes"
5899b553a042SJohn Snow  fi
5900b553a042SJohn Snowfi
5901b553a042SJohn Snow
59021efad060SFam Zheng###############################################
59031efad060SFam Zheng# Check if copy_file_range is provided by glibc
59041efad060SFam Zhenghave_copy_file_range=no
59051efad060SFam Zhengcat > $TMPC << EOF
59061efad060SFam Zheng#include <unistd.h>
59071efad060SFam Zhengint main(void) {
59081efad060SFam Zheng  copy_file_range(0, NULL, 0, NULL, 0, 0);
59091efad060SFam Zheng  return 0;
59101efad060SFam Zheng}
59111efad060SFam ZhengEOF
59121efad060SFam Zhengif compile_prog "" "" ; then
59131efad060SFam Zheng    have_copy_file_range=yes
59141efad060SFam Zhengfi
59151efad060SFam Zheng
5916d2042378SAneesh Kumar K.V##########################################
5917277abf15SJan Vesely# check if struct fsxattr is available via linux/fs.h
5918277abf15SJan Vesely
5919277abf15SJan Veselyhave_fsxattr=no
5920277abf15SJan Veselycat > $TMPC << EOF
5921277abf15SJan Vesely#include <linux/fs.h>
5922277abf15SJan Veselystruct fsxattr foo;
5923277abf15SJan Veselyint main(void) {
5924277abf15SJan Vesely  return 0;
5925277abf15SJan Vesely}
5926277abf15SJan VeselyEOF
5927277abf15SJan Veselyif compile_prog "" "" ; then
5928277abf15SJan Vesely    have_fsxattr=yes
5929277abf15SJan Veselyfi
5930277abf15SJan Vesely
5931b66e10e4SPeter Maydell##########################################
5932a40161cbSPaolo Bonzini# check for usable membarrier system call
5933a40161cbSPaolo Bonziniif test "$membarrier" = "yes"; then
5934a40161cbSPaolo Bonzini    have_membarrier=no
5935a40161cbSPaolo Bonzini    if test "$mingw32" = "yes" ; then
5936a40161cbSPaolo Bonzini        have_membarrier=yes
5937a40161cbSPaolo Bonzini    elif test "$linux" = "yes" ; then
5938a40161cbSPaolo Bonzini        cat > $TMPC << EOF
5939a40161cbSPaolo Bonzini    #include <linux/membarrier.h>
5940a40161cbSPaolo Bonzini    #include <sys/syscall.h>
5941a40161cbSPaolo Bonzini    #include <unistd.h>
5942a40161cbSPaolo Bonzini    #include <stdlib.h>
5943a40161cbSPaolo Bonzini    int main(void) {
5944a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
5945a40161cbSPaolo Bonzini        syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
5946a40161cbSPaolo Bonzini	exit(0);
5947a40161cbSPaolo Bonzini    }
5948a40161cbSPaolo BonziniEOF
5949a40161cbSPaolo Bonzini        if compile_prog "" "" ; then
5950a40161cbSPaolo Bonzini            have_membarrier=yes
5951a40161cbSPaolo Bonzini        fi
5952a40161cbSPaolo Bonzini    fi
5953a40161cbSPaolo Bonzini    if test "$have_membarrier" = "no"; then
5954a40161cbSPaolo Bonzini      feature_not_found "membarrier" "membarrier system call not available"
5955a40161cbSPaolo Bonzini    fi
5956a40161cbSPaolo Bonzinielse
5957a40161cbSPaolo Bonzini    # Do not enable it by default even for Mingw32, because it doesn't
5958a40161cbSPaolo Bonzini    # work on Wine.
5959a40161cbSPaolo Bonzini    membarrier=no
5960a40161cbSPaolo Bonzinifi
5961a40161cbSPaolo Bonzini
5962a40161cbSPaolo Bonzini##########################################
5963b66e10e4SPeter Maydell# check if rtnetlink.h exists and is useful
5964575b22b1SLaurent Vivierhave_rtnetlink=no
5965575b22b1SLaurent Viviercat > $TMPC << EOF
5966575b22b1SLaurent Vivier#include <linux/rtnetlink.h>
5967575b22b1SLaurent Vivierint main(void) {
5968575b22b1SLaurent Vivier  return IFLA_PROTO_DOWN;
5969575b22b1SLaurent Vivier}
5970575b22b1SLaurent VivierEOF
5971575b22b1SLaurent Vivierif compile_prog "" "" ; then
5972575b22b1SLaurent Vivier    have_rtnetlink=yes
5973575b22b1SLaurent Vivierfi
5974575b22b1SLaurent Vivier
59756a02c806SStefan Hajnoczi##########################################
59766a02c806SStefan Hajnoczi# check for usable AF_VSOCK environment
59776a02c806SStefan Hajnoczihave_af_vsock=no
59786a02c806SStefan Hajnoczicat > $TMPC << EOF
59796a02c806SStefan Hajnoczi#include <errno.h>
59806a02c806SStefan Hajnoczi#include <sys/types.h>
59816a02c806SStefan Hajnoczi#include <sys/socket.h>
59826a02c806SStefan Hajnoczi#if !defined(AF_VSOCK)
59836a02c806SStefan Hajnoczi# error missing AF_VSOCK flag
59846a02c806SStefan Hajnoczi#endif
59856a02c806SStefan Hajnoczi#include <linux/vm_sockets.h>
59866a02c806SStefan Hajnocziint main(void) {
59876a02c806SStefan Hajnoczi    int sock, ret;
59886a02c806SStefan Hajnoczi    struct sockaddr_vm svm;
59896a02c806SStefan Hajnoczi    socklen_t len = sizeof(svm);
59906a02c806SStefan Hajnoczi    sock = socket(AF_VSOCK, SOCK_STREAM, 0);
59916a02c806SStefan Hajnoczi    ret = getpeername(sock, (struct sockaddr *)&svm, &len);
59926a02c806SStefan Hajnoczi    if ((ret == -1) && (errno == ENOTCONN)) {
59936a02c806SStefan Hajnoczi        return 0;
59946a02c806SStefan Hajnoczi    }
59956a02c806SStefan Hajnoczi    return -1;
59966a02c806SStefan Hajnoczi}
59976a02c806SStefan HajnocziEOF
59986a02c806SStefan Hajnocziif compile_prog "" "" ; then
59996a02c806SStefan Hajnoczi    have_af_vsock=yes
60006a02c806SStefan Hajnoczifi
60016a02c806SStefan Hajnoczi
6002f0d92b56SLongpeng(Mike)##########################################
6003f0d92b56SLongpeng(Mike)# check for usable AF_ALG environment
60044f67366eSThomas Huthhave_afalg=no
6005f0d92b56SLongpeng(Mike)cat > $TMPC << EOF
6006f0d92b56SLongpeng(Mike)#include <errno.h>
6007f0d92b56SLongpeng(Mike)#include <sys/types.h>
6008f0d92b56SLongpeng(Mike)#include <sys/socket.h>
6009f0d92b56SLongpeng(Mike)#include <linux/if_alg.h>
6010f0d92b56SLongpeng(Mike)int main(void) {
6011f0d92b56SLongpeng(Mike)    int sock;
6012f0d92b56SLongpeng(Mike)    sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
6013f0d92b56SLongpeng(Mike)    return sock;
6014f0d92b56SLongpeng(Mike)}
6015f0d92b56SLongpeng(Mike)EOF
6016f0d92b56SLongpeng(Mike)if compile_prog "" "" ; then
6017f0d92b56SLongpeng(Mike)    have_afalg=yes
6018f0d92b56SLongpeng(Mike)fi
6019f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes"
6020f0d92b56SLongpeng(Mike)then
6021f0d92b56SLongpeng(Mike)    if test "$have_afalg" != "yes"
6022f0d92b56SLongpeng(Mike)    then
6023f0d92b56SLongpeng(Mike)	error_exit "AF_ALG requested but could not be detected"
6024f0d92b56SLongpeng(Mike)    fi
6025f0d92b56SLongpeng(Mike)fi
6026f0d92b56SLongpeng(Mike)
6027f0d92b56SLongpeng(Mike)
60286969ec6cSJames Clarke#################################################
6029c97d6d2cSSergio Andres Gomez Del Real# Check to see if we have the Hypervisor framework
6030d2d08522SPeter Maydellif [ "$darwin" = "yes" ] ; then
6031c97d6d2cSSergio Andres Gomez Del Real  cat > $TMPC << EOF
6032c97d6d2cSSergio Andres Gomez Del Real#include <Hypervisor/hv.h>
6033c97d6d2cSSergio Andres Gomez Del Realint main() { return 0;}
6034c97d6d2cSSergio Andres Gomez Del RealEOF
6035c97d6d2cSSergio Andres Gomez Del Real  if ! compile_object ""; then
6036c97d6d2cSSergio Andres Gomez Del Real    hvf='no'
6037c97d6d2cSSergio Andres Gomez Del Real  else
6038c97d6d2cSSergio Andres Gomez Del Real    hvf='yes'
6039db5adeaaSPaolo Bonzini    QEMU_LDFLAGS="-framework Hypervisor $QEMU_LDFLAGS"
6040c97d6d2cSSergio Andres Gomez Del Real  fi
6041c97d6d2cSSergio Andres Gomez Del Realfi
6042c97d6d2cSSergio Andres Gomez Del Real
6043277abf15SJan Vesely##########################################
60444d04351fSChristopher Covington# check for sysmacros.h
60454d04351fSChristopher Covington
60464d04351fSChristopher Covingtonhave_sysmacros=no
60474d04351fSChristopher Covingtoncat > $TMPC << EOF
60484d04351fSChristopher Covington#include <sys/sysmacros.h>
60494d04351fSChristopher Covingtonint main(void) {
60504d04351fSChristopher Covington    return makedev(0, 0);
60514d04351fSChristopher Covington}
60524d04351fSChristopher CovingtonEOF
60534d04351fSChristopher Covingtonif compile_prog "" "" ; then
60544d04351fSChristopher Covington    have_sysmacros=yes
60554d04351fSChristopher Covingtonfi
60564d04351fSChristopher Covington
60574d04351fSChristopher Covington##########################################
605849e00a18SAndreas Grapentin# check for _Static_assert()
605949e00a18SAndreas Grapentin
606049e00a18SAndreas Grapentinhave_static_assert=no
606149e00a18SAndreas Grapentincat > $TMPC << EOF
606249e00a18SAndreas Grapentin_Static_assert(1, "success");
606349e00a18SAndreas Grapentinint main(void) {
606449e00a18SAndreas Grapentin    return 0;
606549e00a18SAndreas Grapentin}
606649e00a18SAndreas GrapentinEOF
606749e00a18SAndreas Grapentinif compile_prog "" "" ; then
606849e00a18SAndreas Grapentin    have_static_assert=yes
606949e00a18SAndreas Grapentinfi
607049e00a18SAndreas Grapentin
607149e00a18SAndreas Grapentin##########################################
6072e674605fSTomáš Golembiovský# check for utmpx.h, it is missing e.g. on OpenBSD
6073e674605fSTomáš Golembiovský
6074e674605fSTomáš Golembiovskýhave_utmpx=no
6075e674605fSTomáš Golembiovskýcat > $TMPC << EOF
6076e674605fSTomáš Golembiovský#include <utmpx.h>
6077e674605fSTomáš Golembiovskýstruct utmpx user_info;
6078e674605fSTomáš Golembiovskýint main(void) {
6079e674605fSTomáš Golembiovský    return 0;
6080e674605fSTomáš Golembiovský}
6081e674605fSTomáš GolembiovskýEOF
6082e674605fSTomáš Golembiovskýif compile_prog "" "" ; then
6083e674605fSTomáš Golembiovský    have_utmpx=yes
6084e674605fSTomáš Golembiovskýfi
6085e674605fSTomáš Golembiovský
6086e674605fSTomáš Golembiovský##########################################
6087db1ed1abSRichard Henderson# check for getrandom()
6088db1ed1abSRichard Henderson
6089db1ed1abSRichard Hendersonhave_getrandom=no
6090db1ed1abSRichard Hendersoncat > $TMPC << EOF
6091db1ed1abSRichard Henderson#include <sys/random.h>
6092db1ed1abSRichard Hendersonint main(void) {
6093db1ed1abSRichard Henderson    return getrandom(0, 0, GRND_NONBLOCK);
6094db1ed1abSRichard Henderson}
6095db1ed1abSRichard HendersonEOF
6096db1ed1abSRichard Hendersonif compile_prog "" "" ; then
6097db1ed1abSRichard Henderson    have_getrandom=yes
6098db1ed1abSRichard Hendersonfi
6099db1ed1abSRichard Henderson
6100db1ed1abSRichard Henderson##########################################
6101247724cbSMarc-André Lureau# checks for sanitizers
6102247724cbSMarc-André Lureau
6103247724cbSMarc-André Lureauhave_asan=no
6104247724cbSMarc-André Lureauhave_ubsan=no
6105d83414e1SMarc-André Lureauhave_asan_iface_h=no
6106d83414e1SMarc-André Lureauhave_asan_iface_fiber=no
6107247724cbSMarc-André Lureau
6108247724cbSMarc-André Lureauif test "$sanitizers" = "yes" ; then
6109b9f44da2SMarc-André Lureau  write_c_skeleton
6110247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
6111247724cbSMarc-André Lureau      have_asan=yes
6112247724cbSMarc-André Lureau  fi
6113b9f44da2SMarc-André Lureau
6114b9f44da2SMarc-André Lureau  # we could use a simple skeleton for flags checks, but this also
6115b9f44da2SMarc-André Lureau  # detect the static linking issue of ubsan, see also:
6116b9f44da2SMarc-André Lureau  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84285
6117b9f44da2SMarc-André Lureau  cat > $TMPC << EOF
6118b9f44da2SMarc-André Lureau#include <stdlib.h>
6119b9f44da2SMarc-André Lureauint main(void) {
6120b9f44da2SMarc-André Lureau    void *tmp = malloc(10);
6121f2dfe54cSLeonid Bloch    if (tmp != NULL) {
6122b9f44da2SMarc-André Lureau        return *(int *)(tmp + 2);
6123b9f44da2SMarc-André Lureau    }
6124d1abf3fcSOlaf Hering    return 1;
6125f2dfe54cSLeonid Bloch}
6126b9f44da2SMarc-André LureauEOF
6127247724cbSMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
6128247724cbSMarc-André Lureau      have_ubsan=yes
6129247724cbSMarc-André Lureau  fi
6130d83414e1SMarc-André Lureau
6131d83414e1SMarc-André Lureau  if check_include "sanitizer/asan_interface.h" ; then
6132d83414e1SMarc-André Lureau      have_asan_iface_h=yes
6133d83414e1SMarc-André Lureau  fi
6134d83414e1SMarc-André Lureau
6135d83414e1SMarc-André Lureau  cat > $TMPC << EOF
6136d83414e1SMarc-André Lureau#include <sanitizer/asan_interface.h>
6137d83414e1SMarc-André Lureauint main(void) {
6138d83414e1SMarc-André Lureau  __sanitizer_start_switch_fiber(0, 0, 0);
6139d83414e1SMarc-André Lureau  return 0;
6140d83414e1SMarc-André Lureau}
6141d83414e1SMarc-André LureauEOF
6142d83414e1SMarc-André Lureau  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" "" ; then
6143d83414e1SMarc-André Lureau      have_asan_iface_fiber=yes
6144d83414e1SMarc-André Lureau  fi
6145247724cbSMarc-André Lureaufi
6146247724cbSMarc-André Lureau
6147247724cbSMarc-André Lureau##########################################
6148adc28027SAlexander Bulekov# checks for fuzzer
6149adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
6150adc28027SAlexander Bulekov  write_c_fuzzer_skeleton
6151dd016265SAlexander Bulekov  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
6152adc28027SAlexander Bulekov    have_fuzzer=yes
615364ed6f92SPaolo Bonzini  else
615464ed6f92SPaolo Bonzini    error_exit "Your compiler doesn't support -fsanitize=fuzzer"
615564ed6f92SPaolo Bonzini    exit 1
6156adc28027SAlexander Bulekov  fi
6157adc28027SAlexander Bulekovfi
6158adc28027SAlexander Bulekov
61590aebab04SLingfeng Yang# Thread sanitizer is, for now, much noisier than the other sanitizers;
61600aebab04SLingfeng Yang# keep it separate until that is not the case.
61610aebab04SLingfeng Yangif test "$tsan" = "yes" && test "$sanitizers" = "yes"; then
61620aebab04SLingfeng Yang  error_exit "TSAN is not supported with other sanitiziers."
61630aebab04SLingfeng Yangfi
61640aebab04SLingfeng Yanghave_tsan=no
61650aebab04SLingfeng Yanghave_tsan_iface_fiber=no
61660aebab04SLingfeng Yangif test "$tsan" = "yes" ; then
61670aebab04SLingfeng Yang  write_c_skeleton
61680aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
61690aebab04SLingfeng Yang      have_tsan=yes
61700aebab04SLingfeng Yang  fi
61710aebab04SLingfeng Yang  cat > $TMPC << EOF
61720aebab04SLingfeng Yang#include <sanitizer/tsan_interface.h>
61730aebab04SLingfeng Yangint main(void) {
61740aebab04SLingfeng Yang  __tsan_create_fiber(0);
61750aebab04SLingfeng Yang  return 0;
61760aebab04SLingfeng Yang}
61770aebab04SLingfeng YangEOF
61780aebab04SLingfeng Yang  if compile_prog "$CPU_CFLAGS -Werror -fsanitize=thread" "" ; then
61790aebab04SLingfeng Yang      have_tsan_iface_fiber=yes
61800aebab04SLingfeng Yang  fi
61810aebab04SLingfeng Yangfi
61820aebab04SLingfeng Yang
6183adc28027SAlexander Bulekov##########################################
618417824406SJunyan He# check for libpmem
618517824406SJunyan He
618617824406SJunyan Heif test "$libpmem" != "no"; then
618717824406SJunyan He	if $pkg_config --exists "libpmem"; then
618817824406SJunyan He		libpmem="yes"
618917824406SJunyan He		libpmem_libs=$($pkg_config --libs libpmem)
619017824406SJunyan He		libpmem_cflags=$($pkg_config --cflags libpmem)
619117824406SJunyan He		QEMU_CFLAGS="$QEMU_CFLAGS $libpmem_cflags"
619217824406SJunyan He	else
619317824406SJunyan He		if test "$libpmem" = "yes" ; then
619417824406SJunyan He			feature_not_found "libpmem" "Install nvml or pmdk"
619517824406SJunyan He		fi
619617824406SJunyan He		libpmem="no"
619717824406SJunyan He	fi
619817824406SJunyan Hefi
619917824406SJunyan He
620017824406SJunyan He##########################################
620121b2eca6SJingqi Liu# check for libdaxctl
620221b2eca6SJingqi Liu
620321b2eca6SJingqi Liuif test "$libdaxctl" != "no"; then
620421b2eca6SJingqi Liu	if $pkg_config --atleast-version=57 "libdaxctl"; then
620521b2eca6SJingqi Liu		libdaxctl="yes"
620621b2eca6SJingqi Liu		libdaxctl_libs=$($pkg_config --libs libdaxctl)
620721b2eca6SJingqi Liu		libdaxctl_cflags=$($pkg_config --cflags libdaxctl)
620821b2eca6SJingqi Liu		QEMU_CFLAGS="$QEMU_CFLAGS $libdaxctl_cflags"
620921b2eca6SJingqi Liu	else
621021b2eca6SJingqi Liu		if test "$libdaxctl" = "yes" ; then
621121b2eca6SJingqi Liu			feature_not_found "libdaxctl" "Install libdaxctl"
621221b2eca6SJingqi Liu		fi
621321b2eca6SJingqi Liu		libdaxctl="no"
621421b2eca6SJingqi Liu	fi
621521b2eca6SJingqi Liufi
621621b2eca6SJingqi Liu
621721b2eca6SJingqi Liu##########################################
6218675b9b53SMarc-André Lureau# check for slirp
6219675b9b53SMarc-André Lureau
6220d599938aSLaurent Vivier# slirp is only required when building softmmu targets
6221d599938aSLaurent Vivierif test -z "$slirp" -a "$softmmu" != "yes" ; then
6222d599938aSLaurent Vivier    slirp="no"
6223d599938aSLaurent Vivierfi
6224d599938aSLaurent Vivier
6225675b9b53SMarc-André Lureaucase "$slirp" in
6226675b9b53SMarc-André Lureau  "" | yes)
6227675b9b53SMarc-André Lureau    if $pkg_config slirp; then
6228675b9b53SMarc-André Lureau      slirp=system
62297c57bdd8SMarc-André Lureau    elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
62307c57bdd8SMarc-André Lureau      slirp=git
6231675b9b53SMarc-André Lureau    elif test -e "${source_path}/slirp/Makefile" ; then
6232675b9b53SMarc-André Lureau      slirp=internal
6233675b9b53SMarc-André Lureau    elif test -z "$slirp" ; then
6234675b9b53SMarc-André Lureau      slirp=no
6235675b9b53SMarc-André Lureau    else
6236675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel or git submodule"
6237675b9b53SMarc-André Lureau    fi
6238675b9b53SMarc-André Lureau    ;;
6239675b9b53SMarc-André Lureau
6240675b9b53SMarc-André Lureau  system)
6241675b9b53SMarc-André Lureau    if ! $pkg_config slirp; then
6242675b9b53SMarc-André Lureau      feature_not_found "slirp" "Install slirp devel"
6243675b9b53SMarc-André Lureau    fi
6244675b9b53SMarc-André Lureau    ;;
6245675b9b53SMarc-André Lureauesac
6246675b9b53SMarc-André Lureau
6247675b9b53SMarc-André Lureaucase "$slirp" in
62487c57bdd8SMarc-André Lureau  git | internal)
62497c57bdd8SMarc-André Lureau    if test "$slirp" = git; then
62507c57bdd8SMarc-André Lureau      git_submodules="${git_submodules} slirp"
62517c57bdd8SMarc-André Lureau    fi
6252675b9b53SMarc-André Lureau    mkdir -p slirp
625325211446SPaolo Bonzini    slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
625425211446SPaolo Bonzini    slirp_libs="-L$PWD/slirp -lslirp"
6255b965e8c5SPaolo Bonzini    if test "$mingw32" = "yes" ; then
6256b965e8c5SPaolo Bonzini      slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
6257b965e8c5SPaolo Bonzini    fi
6258675b9b53SMarc-André Lureau    ;;
6259675b9b53SMarc-André Lureau
6260675b9b53SMarc-André Lureau  system)
6261675b9b53SMarc-André Lureau    slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
6262675b9b53SMarc-André Lureau    slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
6263675b9b53SMarc-André Lureau    slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
6264675b9b53SMarc-André Lureau    ;;
6265675b9b53SMarc-André Lureau
6266675b9b53SMarc-André Lureau  no)
6267675b9b53SMarc-André Lureau    ;;
6268675b9b53SMarc-André Lureau  *)
6269675b9b53SMarc-André Lureau    error_exit "Unknown state for slirp: $slirp"
6270675b9b53SMarc-André Lureau    ;;
6271675b9b53SMarc-André Lureauesac
6272675b9b53SMarc-André Lureau
627354e7aac0SAlexey Krasikov##########################################
627454e7aac0SAlexey Krasikov# check for usable __NR_keyctl syscall
627554e7aac0SAlexey Krasikov
627654e7aac0SAlexey Krasikovif test "$linux" = "yes" ; then
627754e7aac0SAlexey Krasikov
627854e7aac0SAlexey Krasikov    have_keyring=no
627954e7aac0SAlexey Krasikov    cat > $TMPC << EOF
628054e7aac0SAlexey Krasikov#include <errno.h>
628154e7aac0SAlexey Krasikov#include <asm/unistd.h>
628254e7aac0SAlexey Krasikov#include <linux/keyctl.h>
628354e7aac0SAlexey Krasikov#include <unistd.h>
628454e7aac0SAlexey Krasikovint main(void) {
628554e7aac0SAlexey Krasikov    return syscall(__NR_keyctl, KEYCTL_READ, 0, NULL, NULL, 0);
628654e7aac0SAlexey Krasikov}
628754e7aac0SAlexey KrasikovEOF
628854e7aac0SAlexey Krasikov    if compile_prog "" "" ; then
628954e7aac0SAlexey Krasikov        have_keyring=yes
629054e7aac0SAlexey Krasikov    fi
629154e7aac0SAlexey Krasikovfi
629254e7aac0SAlexey Krasikovif test "$secret_keyring" != "no"
629354e7aac0SAlexey Krasikovthen
6294b418d265SDavid Edmondson    if test "$have_keyring" = "yes"
629554e7aac0SAlexey Krasikov    then
629654e7aac0SAlexey Krasikov	secret_keyring=yes
629754e7aac0SAlexey Krasikov    else
629854e7aac0SAlexey Krasikov	if test "$secret_keyring" = "yes"
629954e7aac0SAlexey Krasikov	then
630054e7aac0SAlexey Krasikov	    error_exit "syscall __NR_keyctl requested, \
630154e7aac0SAlexey Krasikovbut not implemented on your system"
630254e7aac0SAlexey Krasikov	else
630354e7aac0SAlexey Krasikov	    secret_keyring=no
630454e7aac0SAlexey Krasikov	fi
630554e7aac0SAlexey Krasikov    fi
630654e7aac0SAlexey Krasikovfi
630754e7aac0SAlexey Krasikov
630892500362SAlexey Krasikov##########################################
630992500362SAlexey Krasikov# check for usable keyutils.h
631092500362SAlexey Krasikov
631192500362SAlexey Krasikovif test "$linux" = "yes" ; then
631292500362SAlexey Krasikov
631392500362SAlexey Krasikov    have_keyutils=no
631492500362SAlexey Krasikov    cat > $TMPC << EOF
631592500362SAlexey Krasikov#include <errno.h>
631692500362SAlexey Krasikov#include <asm/unistd.h>
631792500362SAlexey Krasikov#include <unistd.h>
631892500362SAlexey Krasikov#include <sys/types.h>
631992500362SAlexey Krasikov#include <keyutils.h>
632092500362SAlexey Krasikovint main(void) {
632192500362SAlexey Krasikov    return request_key("user", NULL, NULL, 0);
632292500362SAlexey Krasikov}
632392500362SAlexey KrasikovEOF
632492500362SAlexey Krasikov    if compile_prog "" "-lkeyutils"; then
632592500362SAlexey Krasikov        have_keyutils=yes
632692500362SAlexey Krasikov    fi
632792500362SAlexey Krasikovfi
632892500362SAlexey Krasikov
6329675b9b53SMarc-André Lureau
6330675b9b53SMarc-André Lureau##########################################
6331e86ecd4bSJuan Quintela# End of CC checks
6332e86ecd4bSJuan Quintela# After here, no more $cc or $ld runs
6333e86ecd4bSJuan Quintela
6334d83414e1SMarc-André Lureauwrite_c_skeleton
6335d83414e1SMarc-André Lureau
63361d728c39SBlue Swirlif test "$gcov" = "yes" ; then
6337bf0e56a3SMarc-André Lureau  :
6338b553a042SJohn Snowelif test "$fortify_source" = "yes" ; then
6339086d5f75SPaolo Bonzini  QEMU_CFLAGS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
6340086d5f75SPaolo Bonzini  debug=no
6341086d5f75SPaolo Bonzinifi
6342086d5f75SPaolo Bonziniif test "$debug_info" = "yes"; then
6343086d5f75SPaolo Bonzini  CFLAGS="-g $CFLAGS"
6344086d5f75SPaolo Bonzini  LDFLAGS="-g $LDFLAGS"
6345086d5f75SPaolo Bonzinifi
6346a5665051SPaolo Bonziniif test "$debug" = "no"; then
6347a5665051SPaolo Bonzini  CFLAGS="-O2 $CFLAGS"
6348a5665051SPaolo Bonzinifi
6349086d5f75SPaolo Bonzini
6350086d5f75SPaolo Bonzinicase "$ARCH" in
6351086d5f75SPaolo Bonzinialpha)
6352086d5f75SPaolo Bonzini  # Ensure there's only a single GP
6353086d5f75SPaolo Bonzini  QEMU_CFLAGS="-msmall-data $QEMU_CFLAGS"
6354086d5f75SPaolo Bonzini;;
6355086d5f75SPaolo Bonziniesac
6356086d5f75SPaolo Bonzini
6357086d5f75SPaolo Bonziniif test "$gprof" = "yes" ; then
6358086d5f75SPaolo Bonzini  QEMU_CFLAGS="-p $QEMU_CFLAGS"
6359086d5f75SPaolo Bonzini  QEMU_LDFLAGS="-p $QEMU_LDFLAGS"
6360086d5f75SPaolo Bonzinifi
6361a316e378SJuan Quintela
6362247724cbSMarc-André Lureauif test "$have_asan" = "yes"; then
6363db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=address $QEMU_CFLAGS"
6364db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=address $QEMU_LDFLAGS"
6365d83414e1SMarc-André Lureau  if test "$have_asan_iface_h" = "no" ; then
6366d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header missing." \
6367d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6368d83414e1SMarc-André Lureau  elif test "$have_asan_iface_fiber" = "no" ; then
6369d83414e1SMarc-André Lureau      echo "ASAN build enabled, but ASAN header is too old." \
6370d83414e1SMarc-André Lureau           "Without code annotation, the report may be inferior."
6371d83414e1SMarc-André Lureau  fi
6372247724cbSMarc-André Lureaufi
63730aebab04SLingfeng Yangif test "$have_tsan" = "yes" ; then
63740aebab04SLingfeng Yang  if test "$have_tsan_iface_fiber" = "yes" ; then
63750aebab04SLingfeng Yang    QEMU_CFLAGS="-fsanitize=thread $QEMU_CFLAGS"
63760aebab04SLingfeng Yang    QEMU_LDFLAGS="-fsanitize=thread $QEMU_LDFLAGS"
63770aebab04SLingfeng Yang  else
63780aebab04SLingfeng Yang    error_exit "Cannot enable TSAN due to missing fiber annotation interface."
63790aebab04SLingfeng Yang  fi
63800aebab04SLingfeng Yangelif test "$tsan" = "yes" ; then
63810aebab04SLingfeng Yang  error_exit "Cannot enable TSAN due to missing sanitize thread interface."
63820aebab04SLingfeng Yangfi
6383247724cbSMarc-André Lureauif test "$have_ubsan" = "yes"; then
6384db5adeaaSPaolo Bonzini  QEMU_CFLAGS="-fsanitize=undefined $QEMU_CFLAGS"
6385db5adeaaSPaolo Bonzini  QEMU_LDFLAGS="-fsanitize=undefined $QEMU_LDFLAGS"
6386247724cbSMarc-André Lureaufi
6387247724cbSMarc-André Lureau
63886542aa9cSPeter Lieven##########################################
63896542aa9cSPeter Lieven# Do we have libnfs
63906542aa9cSPeter Lievenif test "$libnfs" != "no" ; then
6391b7d769c9SPeter Lieven  if $pkg_config --atleast-version=1.9.3 libnfs; then
63926542aa9cSPeter Lieven    libnfs="yes"
63936542aa9cSPeter Lieven    libnfs_libs=$($pkg_config --libs libnfs)
63946542aa9cSPeter Lieven  else
63956542aa9cSPeter Lieven    if test "$libnfs" = "yes" ; then
63968efc9363SHu Tao      feature_not_found "libnfs" "Install libnfs devel >= 1.9.3"
63976542aa9cSPeter Lieven    fi
63986542aa9cSPeter Lieven    libnfs="no"
63996542aa9cSPeter Lieven  fi
64006542aa9cSPeter Lievenfi
64011d728c39SBlue Swirl
64023efac6ebSTomáš Golembiovský##########################################
64033efac6ebSTomáš Golembiovský# Do we have libudev
64043efac6ebSTomáš Golembiovskýif test "$libudev" != "no" ; then
64053efac6ebSTomáš Golembiovský  if $pkg_config libudev && test "$static" != "yes"; then
64063efac6ebSTomáš Golembiovský    libudev="yes"
64073efac6ebSTomáš Golembiovský    libudev_libs=$($pkg_config --libs libudev)
64083efac6ebSTomáš Golembiovský  else
64093efac6ebSTomáš Golembiovský    libudev="no"
64103efac6ebSTomáš Golembiovský  fi
64113efac6ebSTomáš Golembiovskýfi
64123efac6ebSTomáš Golembiovský
64136ca026cbSPeter Maydell# Now we've finished running tests it's OK to add -Werror to the compiler flags
64146ca026cbSPeter Maydellif test "$werror" = "yes"; then
64156ca026cbSPeter Maydell    QEMU_CFLAGS="-Werror $QEMU_CFLAGS"
64166ca026cbSPeter Maydellfi
64176ca026cbSPeter Maydell
64180aebab04SLingfeng Yang# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
64190aebab04SLingfeng Yangif test "$solaris" = "no" && test "$tsan" = "no"; then
6420e86ecd4bSJuan Quintela    if $ld --version 2>/dev/null | grep "GNU ld" >/dev/null 2>/dev/null ; then
6421db5adeaaSPaolo Bonzini        QEMU_LDFLAGS="-Wl,--warn-common $QEMU_LDFLAGS"
6422e86ecd4bSJuan Quintela    fi
6423e86ecd4bSJuan Quintelafi
6424e86ecd4bSJuan Quintela
642594dd53c5SGerd Hoffmann# test if pod2man has --utf8 option
642694dd53c5SGerd Hoffmannif pod2man --help | grep -q utf8; then
642794dd53c5SGerd Hoffmann    POD2MAN="pod2man --utf8"
642894dd53c5SGerd Hoffmannelse
642994dd53c5SGerd Hoffmann    POD2MAN="pod2man"
643094dd53c5SGerd Hoffmannfi
643194dd53c5SGerd Hoffmann
6432952afb71SBlue Swirl# Use ASLR, no-SEH and DEP if available
6433952afb71SBlue Swirlif test "$mingw32" = "yes" ; then
6434952afb71SBlue Swirl    for flag in --dynamicbase --no-seh --nxcompat; do
6435e9a3591fSChristian Borntraeger        if ld_has $flag ; then
6436db5adeaaSPaolo Bonzini            QEMU_LDFLAGS="-Wl,$flag $QEMU_LDFLAGS"
6437952afb71SBlue Swirl        fi
6438952afb71SBlue Swirl    done
6439952afb71SBlue Swirlfi
6440952afb71SBlue Swirl
64417776ea6bSPhilippe Mathieu-Daudé# Disable OpenBSD W^X if available
64427776ea6bSPhilippe Mathieu-Daudéif test "$tcg" = "yes" && test "$targetos" = "OpenBSD"; then
64437776ea6bSPhilippe Mathieu-Daudé    cat > $TMPC <<EOF
64447776ea6bSPhilippe Mathieu-Daudé    int main(void) { return 0; }
64457776ea6bSPhilippe Mathieu-DaudéEOF
64467776ea6bSPhilippe Mathieu-Daudé    wx_ldflags="-Wl,-z,wxneeded"
64477776ea6bSPhilippe Mathieu-Daudé    if compile_prog "" "$wx_ldflags"; then
64487776ea6bSPhilippe Mathieu-Daudé        QEMU_LDFLAGS="$QEMU_LDFLAGS $wx_ldflags"
64497776ea6bSPhilippe Mathieu-Daudé    fi
64507776ea6bSPhilippe Mathieu-Daudéfi
64517776ea6bSPhilippe Mathieu-Daudé
645210ea68b3SEduardo Habkostqemu_confdir=$sysconfdir$confsuffix
6453e26110cfSFam Zhengqemu_moddir=$libdir$confsuffix
6454528ae5b8SEduardo Habkostqemu_datadir=$datadir$confsuffix
6455834574eaSAnthony Liguoriqemu_localedir="$datadir/locale"
6456a8260d38SDaniel P. Berrangéqemu_icondir="$datadir/icons"
645767ea9546SDaniel P. Berrangéqemu_desktopdir="$datadir/applications"
64585a67135aSbellard
6459e0580342SKamil Rytarowski# We can only support ivshmem if we have eventfd
6460e0580342SKamil Rytarowskiif [ "$eventfd" = "yes" ]; then
6461e0580342SKamil Rytarowski  ivshmem=yes
6462e0580342SKamil Rytarowskifi
6463e0580342SKamil Rytarowski
64644b1c11fdSDaniel P. Berrangeif test "$softmmu" = yes ; then
6465b855f8d1SPaolo Bonzini  if test "$linux" = yes; then
64667e462613SPaolo Bonzini    if test "$virtfs" != no && test "$cap_ng" = yes && test "$attr" = yes ; then
6467983eef5aSMeador Inge      virtfs=yes
6468983eef5aSMeador Inge    else
6469983eef5aSMeador Inge      if test "$virtfs" = yes; then
64707e462613SPaolo Bonzini        error_exit "VirtFS requires libcap-ng devel and libattr devel"
6471983eef5aSMeador Inge      fi
647217500370SAndreas Färber      virtfs=no
6473983eef5aSMeador Inge    fi
6474fe8fc5aeSPaolo Bonzini    if test "$mpath" != no && test "$mpathpersist" = yes ; then
6475fe8fc5aeSPaolo Bonzini      mpath=yes
6476fe8fc5aeSPaolo Bonzini    else
6477fe8fc5aeSPaolo Bonzini      if test "$mpath" = yes; then
6478fe8fc5aeSPaolo Bonzini        error_exit "Multipath requires libmpathpersist devel"
6479fe8fc5aeSPaolo Bonzini      fi
6480fe8fc5aeSPaolo Bonzini      mpath=no
6481fe8fc5aeSPaolo Bonzini    fi
6482b855f8d1SPaolo Bonzini  else
6483b855f8d1SPaolo Bonzini    if test "$virtfs" = yes; then
6484b855f8d1SPaolo Bonzini      error_exit "VirtFS is supported only on Linux"
6485b855f8d1SPaolo Bonzini    fi
6486b855f8d1SPaolo Bonzini    virtfs=no
6487fe8fc5aeSPaolo Bonzini    if test "$mpath" = yes; then
6488fe8fc5aeSPaolo Bonzini      error_exit "Multipath is supported only on Linux"
6489fe8fc5aeSPaolo Bonzini    fi
6490fe8fc5aeSPaolo Bonzini    mpath=no
649117bff52bSM. Mohan Kumar  fi
6492ff69fd8cSLaurent Vivierfi
64939d6bc27bSMichael Roth
64949d6bc27bSMichael Roth# Probe for guest agent support/options
64959d6bc27bSMichael Roth
6496e8ef31a3SMichael Tokarevif [ "$guest_agent" != "no" ]; then
6497a5125905SLaurent Vivier  if [ "$softmmu" = no -a "$want_tools" = no ] ; then
6498a5125905SLaurent Vivier      guest_agent=no
6499a5125905SLaurent Vivier  elif [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" -o "$mingw32" = "yes" ] ; then
6500e8ef31a3SMichael Tokarev      guest_agent=yes
6501e8ef31a3SMichael Tokarev  elif [ "$guest_agent" != yes ]; then
6502e8ef31a3SMichael Tokarev      guest_agent=no
6503e8ef31a3SMichael Tokarev  else
6504e8ef31a3SMichael Tokarev      error_exit "Guest agent is not supported on this platform"
6505ca35f780SPaolo Bonzini  fi
65064b1c11fdSDaniel P. Berrangefi
6507ca35f780SPaolo Bonzini
65089d6bc27bSMichael Roth# Guest agent Window MSI  package
65099d6bc27bSMichael Roth
65109d6bc27bSMichael Rothif test "$guest_agent" != yes; then
65119d6bc27bSMichael Roth  if test "$guest_agent_msi" = yes; then
65129d6bc27bSMichael Roth    error_exit "MSI guest agent package requires guest agent enabled"
65139d6bc27bSMichael Roth  fi
65149d6bc27bSMichael Roth  guest_agent_msi=no
65159d6bc27bSMichael Rothelif test "$mingw32" != "yes"; then
65169d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
65179d6bc27bSMichael Roth    error_exit "MSI guest agent package is available only for MinGW Windows cross-compilation"
65189d6bc27bSMichael Roth  fi
65199d6bc27bSMichael Roth  guest_agent_msi=no
65209d6bc27bSMichael Rothelif ! has wixl; then
65219d6bc27bSMichael Roth  if test "$guest_agent_msi" = "yes"; then
65229d6bc27bSMichael Roth    error_exit "MSI guest agent package requires wixl tool installed ( usually from msitools package )"
65239d6bc27bSMichael Roth  fi
65249d6bc27bSMichael Roth  guest_agent_msi=no
65251a34904eSMichael Rothelse
65261a34904eSMichael Roth  # we support qemu-ga, mingw32, and wixl: default to MSI enabled if it wasn't
65271a34904eSMichael Roth  # disabled explicitly
65281a34904eSMichael Roth  if test "$guest_agent_msi" != "no"; then
65291a34904eSMichael Roth    guest_agent_msi=yes
65301a34904eSMichael Roth  fi
65319d6bc27bSMichael Rothfi
65329d6bc27bSMichael Roth
65331a34904eSMichael Rothif test "$guest_agent_msi" = "yes"; then
65349d6bc27bSMichael Roth  if test "$guest_agent_with_vss" = "yes"; then
65359d6bc27bSMichael Roth    QEMU_GA_MSI_WITH_VSS="-D InstallVss"
65369d6bc27bSMichael Roth  fi
65379d6bc27bSMichael Roth
65389d6bc27bSMichael Roth  if test "$QEMU_GA_MANUFACTURER" = ""; then
65399d6bc27bSMichael Roth    QEMU_GA_MANUFACTURER=QEMU
65409d6bc27bSMichael Roth  fi
65419d6bc27bSMichael Roth
65429d6bc27bSMichael Roth  if test "$QEMU_GA_DISTRO" = ""; then
65439d6bc27bSMichael Roth    QEMU_GA_DISTRO=Linux
65449d6bc27bSMichael Roth  fi
65459d6bc27bSMichael Roth
65469d6bc27bSMichael Roth  if test "$QEMU_GA_VERSION" = ""; then
654789138857SStefan Weil      QEMU_GA_VERSION=$(cat $source_path/VERSION)
65489d6bc27bSMichael Roth  fi
65499d6bc27bSMichael Roth
655089138857SStefan Weil  QEMU_GA_MSI_MINGW_DLL_PATH="-D Mingw_dlls=$($pkg_config --variable=prefix glib-2.0)/bin"
65519d6bc27bSMichael Roth
65529d6bc27bSMichael Roth  case "$cpu" in
65539d6bc27bSMichael Roth  x86_64)
65549d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-a x64 -D Arch=64"
65559d6bc27bSMichael Roth    ;;
65569d6bc27bSMichael Roth  i386)
65579d6bc27bSMichael Roth    QEMU_GA_MSI_ARCH="-D Arch=32"
65589d6bc27bSMichael Roth    ;;
65599d6bc27bSMichael Roth  *)
65609d6bc27bSMichael Roth    error_exit "CPU $cpu not supported for building installation package"
65619d6bc27bSMichael Roth    ;;
65629d6bc27bSMichael Roth  esac
65639d6bc27bSMichael Rothfi
65649d6bc27bSMichael Roth
6565ca35f780SPaolo Bonzini# Mac OS X ships with a broken assembler
6566ca35f780SPaolo Bonziniroms=
6567e633a5c6SEric Blakeif { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
6568e633a5c6SEric Blake        test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
6569e633a5c6SEric Blake        test "$softmmu" = yes ; then
6570e57218b6SPeter Maydell    # Different host OS linkers have different ideas about the name of the ELF
6571c65d5e4eSBrad Smith    # emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
6572c65d5e4eSBrad Smith    # variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
6573c65d5e4eSBrad Smith    for emu in elf_i386 elf_i386_fbsd elf_i386_obsd i386pe; do
6574e57218b6SPeter Maydell        if "$ld" -verbose 2>&1 | grep -q "^[[:space:]]*$emu[[:space:]]*$"; then
6575e57218b6SPeter Maydell            ld_i386_emulation="$emu"
6576ca35f780SPaolo Bonzini            roms="optionrom"
6577e57218b6SPeter Maydell            break
6578e57218b6SPeter Maydell        fi
6579e57218b6SPeter Maydell    done
6580ca35f780SPaolo Bonzinifi
6581ca35f780SPaolo Bonzini
65822e33c3f8SThomas Huth# Only build s390-ccw bios if we're on s390x and the compiler has -march=z900
65839933c305SChristian Borntraegerif test "$cpu" = "s390x" ; then
65842e33c3f8SThomas Huth  write_c_skeleton
65852e33c3f8SThomas Huth  if compile_prog "-march=z900" ""; then
65869933c305SChristian Borntraeger    roms="$roms s390-ccw"
65871ef6bfc2SPhilippe Mathieu-Daudé    # SLOF is required for building the s390-ccw firmware on s390x,
65881ef6bfc2SPhilippe Mathieu-Daudé    # since it is using the libnet code from SLOF for network booting.
65891ef6bfc2SPhilippe Mathieu-Daudé    if test -e "${source_path}/.git" ; then
65901ef6bfc2SPhilippe Mathieu-Daudé      git_submodules="${git_submodules} roms/SLOF"
65911ef6bfc2SPhilippe Mathieu-Daudé    fi
65929933c305SChristian Borntraeger  fi
65932e33c3f8SThomas Huthfi
65949933c305SChristian Borntraeger
659511cde1c8SBruno Dominguez# Check that the C++ compiler exists and works with the C compiler.
659611cde1c8SBruno 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.
659711cde1c8SBruno Dominguezif has $cxx; then
659811cde1c8SBruno Dominguez    cat > $TMPC <<EOF
659911cde1c8SBruno Dominguezint c_function(void);
660011cde1c8SBruno Dominguezint main(void) { return c_function(); }
660111cde1c8SBruno DominguezEOF
660211cde1c8SBruno Dominguez
660311cde1c8SBruno Dominguez    compile_object
660411cde1c8SBruno Dominguez
660511cde1c8SBruno Dominguez    cat > $TMPCXX <<EOF
660611cde1c8SBruno Dominguezextern "C" {
660711cde1c8SBruno Dominguez   int c_function(void);
660811cde1c8SBruno Dominguez}
660911cde1c8SBruno Dominguezint c_function(void) { return 42; }
661011cde1c8SBruno DominguezEOF
661111cde1c8SBruno Dominguez
661211cde1c8SBruno Dominguez    update_cxxflags
661311cde1c8SBruno Dominguez
6614086d5f75SPaolo Bonzini    if do_cxx $CXXFLAGS $QEMU_CXXFLAGS -o $TMPE $TMPCXX $TMPO $QEMU_LDFLAGS; then
661511cde1c8SBruno Dominguez        # C++ compiler $cxx works ok with C compiler $cc
661611cde1c8SBruno Dominguez        :
661711cde1c8SBruno Dominguez    else
661811cde1c8SBruno Dominguez        echo "C++ compiler $cxx does not work with C compiler $cc"
661911cde1c8SBruno Dominguez        echo "Disabling C++ specific optional code"
662011cde1c8SBruno Dominguez        cxx=
662111cde1c8SBruno Dominguez    fi
662211cde1c8SBruno Dominguezelse
662311cde1c8SBruno Dominguez    echo "No C++ compiler available; disabling C++ specific optional code"
662411cde1c8SBruno Dominguez    cxx=
662511cde1c8SBruno Dominguezfi
662611cde1c8SBruno Dominguez
662702d34f62SCole Robinsonecho_version() {
662802d34f62SCole Robinson    if test "$1" = "yes" ; then
662902d34f62SCole Robinson        echo "($2)"
663002d34f62SCole Robinson    fi
663102d34f62SCole Robinson}
663202d34f62SCole Robinson
6633b7612f45SPaolo Bonzini# prepend ftd flags after all config tests are done
6634b7612f45SPaolo BonziniQEMU_CFLAGS="$fdt_cflags $QEMU_CFLAGS"
66358a99e9a3SPhilippe Mathieu-DaudéQEMU_LDFLAGS="$fdt_ldflags $QEMU_LDFLAGS"
66365ca9388aSGerd Hoffmann
663798ec69acSJuan Quintelaconfig_host_mak="config-host.mak"
663897a847bcSbellard
6639dbd99ae3SStefan Weilecho "# Automatically generated by configure - do not modify" >config-all-disas.mak
6640dbd99ae3SStefan Weil
664198ec69acSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_host_mak
664298ec69acSJuan Quintelaecho >> $config_host_mak
664398ec69acSJuan Quintela
6644e6c3b0f7SPaolo Bonziniecho all: >> $config_host_mak
664599d7cc75SPaolo Bonziniecho "prefix=$prefix" >> $config_host_mak
664699d7cc75SPaolo Bonziniecho "bindir=$bindir" >> $config_host_mak
66473aa5d2beSAlon Levyecho "libdir=$libdir" >> $config_host_mak
66488bf188aaSMichael Tokarevecho "libexecdir=$libexecdir" >> $config_host_mak
66490f94d6daSAlon Levyecho "includedir=$includedir" >> $config_host_mak
665099d7cc75SPaolo Bonziniecho "mandir=$mandir" >> $config_host_mak
665199d7cc75SPaolo Bonziniecho "sysconfdir=$sysconfdir" >> $config_host_mak
665222d07038SEduardo Habkostecho "qemu_confdir=$qemu_confdir" >> $config_host_mak
66539afa52ceSEduardo Habkostecho "qemu_datadir=$qemu_datadir" >> $config_host_mak
66543d5eecabSGerd Hoffmannecho "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
66559afa52ceSEduardo Habkostecho "qemu_docdir=$qemu_docdir" >> $config_host_mak
6656e26110cfSFam Zhengecho "qemu_moddir=$qemu_moddir" >> $config_host_mak
66575a699bbbSLaszlo Ersekif test "$mingw32" = "no" ; then
6658785c23aeSLuiz Capitulino  echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
66595a699bbbSLaszlo Ersekfi
6660f354b1a1SMichael Tokarevecho "qemu_helperdir=$libexecdir" >> $config_host_mak
6661834574eaSAnthony Liguoriecho "qemu_localedir=$qemu_localedir" >> $config_host_mak
6662a8260d38SDaniel P. Berrangéecho "qemu_icondir=$qemu_icondir" >> $config_host_mak
666367ea9546SDaniel P. Berrangéecho "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
6664cc84d63aSDaniel P. Berrangeecho "GIT=$git" >> $config_host_mak
6665aef45d51SDaniel P. Berrangeecho "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
6666f62bbee5SDaniel P. Berrangeecho "GIT_UPDATE=$git_update" >> $config_host_mak
6667804edf29SJuan Quintela
666898ec69acSJuan Quintelaecho "ARCH=$ARCH" >> $config_host_mak
6669727e5283SPaolo Bonzini
6670f3494749SPaolo Bonziniif test "$default_devices" = "yes" ; then
6671f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak
6672f3494749SPaolo Bonzinielse
6673f3494749SPaolo Bonzini  echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
6674f3494749SPaolo Bonzinifi
6675f8393946Saurel32if test "$debug_tcg" = "yes" ; then
66762358a494SJuan Quintela  echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
6677f8393946Saurel32fi
66781625af87Saliguoriif test "$strip_opt" = "yes" ; then
667952ba784dSHollis Blanchard  echo "STRIP=${strip}" >> $config_host_mak
66801625af87Saliguorifi
66817d13299dSbellardif test "$bigendian" = "yes" ; then
6682e2542fe2SJuan Quintela  echo "HOST_WORDS_BIGENDIAN=y" >> $config_host_mak
668397a847bcSbellardfi
668467b915a5Sbellardif test "$mingw32" = "yes" ; then
668598ec69acSJuan Quintela  echo "CONFIG_WIN32=y" >> $config_host_mak
668689138857SStefan Weil  rc_version=$(cat $source_path/VERSION)
66879fe6de94SBlue Swirl  version_major=${rc_version%%.*}
66889fe6de94SBlue Swirl  rc_version=${rc_version#*.}
66899fe6de94SBlue Swirl  version_minor=${rc_version%%.*}
66909fe6de94SBlue Swirl  rc_version=${rc_version#*.}
66919fe6de94SBlue Swirl  version_subminor=${rc_version%%.*}
66929fe6de94SBlue Swirl  version_micro=0
66939fe6de94SBlue Swirl  echo "CONFIG_FILEVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
66949fe6de94SBlue Swirl  echo "CONFIG_PRODUCTVERSION=$version_major,$version_minor,$version_subminor,$version_micro" >> $config_host_mak
6695d9840e25STomoki Sekiyama  if test "$guest_agent_with_vss" = "yes" ; then
6696d9840e25STomoki Sekiyama    echo "CONFIG_QGA_VSS=y" >> $config_host_mak
6697f33ca81fSMichael Roth    echo "QGA_VSS_PROVIDER=$qga_vss_provider" >> $config_host_mak
6698d9840e25STomoki Sekiyama    echo "WIN_SDK=\"$win_sdk\"" >> $config_host_mak
6699d9840e25STomoki Sekiyama  fi
670050cbebb9SMichael Roth  if test "$guest_agent_ntddscsi" = "yes" ; then
670176dc75caSTomáš Golembiovský    echo "CONFIG_QGA_NTDDSCSI=y" >> $config_host_mak
670250cbebb9SMichael Roth  fi
67031a34904eSMichael Roth  if test "$guest_agent_msi" = "yes"; then
67049dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
67059dacf32dSYossi Hindin    echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
67069dacf32dSYossi Hindin    echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
67079dacf32dSYossi Hindin    echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
67089dacf32dSYossi Hindin    echo "QEMU_GA_MANUFACTURER=${QEMU_GA_MANUFACTURER}" >> $config_host_mak
67099dacf32dSYossi Hindin    echo "QEMU_GA_DISTRO=${QEMU_GA_DISTRO}" >> $config_host_mak
67109dacf32dSYossi Hindin    echo "QEMU_GA_VERSION=${QEMU_GA_VERSION}" >> $config_host_mak
67119dacf32dSYossi Hindin  fi
6712210fa556Spbrookelse
671335f4df27SJuan Quintela  echo "CONFIG_POSIX=y" >> $config_host_mak
6714210fa556Spbrookfi
6715128ab2ffSblueswir1
6716dffcb71cSMark McLoughlinif test "$linux" = "yes" ; then
6717dffcb71cSMark McLoughlin  echo "CONFIG_LINUX=y" >> $config_host_mak
6718dffcb71cSMark McLoughlinfi
6719dffcb71cSMark McLoughlin
672083fb7adfSbellardif test "$darwin" = "yes" ; then
672198ec69acSJuan Quintela  echo "CONFIG_DARWIN=y" >> $config_host_mak
672283fb7adfSbellardfi
6723b29fe3edSmalc
6724ec530c81Sbellardif test "$solaris" = "yes" ; then
672598ec69acSJuan Quintela  echo "CONFIG_SOLARIS=y" >> $config_host_mak
6726ec530c81Sbellardfi
6727179cf400SAndreas Färberif test "$haiku" = "yes" ; then
6728179cf400SAndreas Färber  echo "CONFIG_HAIKU=y" >> $config_host_mak
6729179cf400SAndreas Färberfi
673097a847bcSbellardif test "$static" = "yes" ; then
673198ec69acSJuan Quintela  echo "CONFIG_STATIC=y" >> $config_host_mak
673297a847bcSbellardfi
67331ba16968SStefan Weilif test "$profiler" = "yes" ; then
67342358a494SJuan Quintela  echo "CONFIG_PROFILER=y" >> $config_host_mak
673505c2a3e7Sbellardfi
6736c932ce31SPaolo Bonziniif test "$want_tools" = "yes" ; then
6737c932ce31SPaolo Bonzini  echo "CONFIG_TOOLS=y" >> $config_host_mak
6738c932ce31SPaolo Bonzinifi
6739f15bff25SPaolo Bonziniif test "$guest_agent" = "yes" ; then
6740f15bff25SPaolo Bonzini  echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
6741f15bff25SPaolo Bonzinifi
6742675b9b53SMarc-André Lureauif test "$slirp" != "no"; then
674398ec69acSJuan Quintela  echo "CONFIG_SLIRP=y" >> $config_host_mak
6744e2d8830eSBrad  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
6745675b9b53SMarc-André Lureau  echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
6746675b9b53SMarc-André Lureau  echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
6747675b9b53SMarc-André Lureaufi
6748859aef02SPaolo Bonzinisubdirs=
67497c57bdd8SMarc-André Lureauif [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
6750859aef02SPaolo Bonzini  subdirs="$subdirs slirp"
6751c20709aaSbellardfi
67528a16d273Sthsif test "$vde" = "yes" ; then
675398ec69acSJuan Quintela  echo "CONFIG_VDE=y" >> $config_host_mak
6754e2ad6f16SFam Zheng  echo "VDE_LIBS=$vde_libs" >> $config_host_mak
67558a16d273Sthsfi
675658952137SVincenzo Maffioneif test "$netmap" = "yes" ; then
675758952137SVincenzo Maffione  echo "CONFIG_NETMAP=y" >> $config_host_mak
675858952137SVincenzo Maffionefi
6759015a33bdSGongleiif test "$l2tpv3" = "yes" ; then
6760015a33bdSGonglei  echo "CONFIG_L2TPV3=y" >> $config_host_mak
6761015a33bdSGongleifi
67624cc600d2SPaolo Bonziniif test "$gprof" = "yes" ; then
67634cc600d2SPaolo Bonzini  echo "CONFIG_GPROF=y" >> $config_host_mak
67644cc600d2SPaolo Bonzinifi
676547e98658SCorey Bryantif test "$cap_ng" = "yes" ; then
6766a358bca2SPaolo Bonzini  echo "CONFIG_LIBCAP_NG=y" >> $config_host_mak
67673f99cf57SPaolo Bonzini  echo "LIBCAP_NG_LIBS=$cap_libs" >> $config_host_mak
676847e98658SCorey Bryantfi
67692358a494SJuan Quintelaecho "CONFIG_AUDIO_DRIVERS=$audio_drv_list" >> $config_host_mak
67700c58ac1cSmalcfor drv in $audio_drv_list; do
67711ef1ec2aSGerd Hoffmann    def=CONFIG_AUDIO_$(echo $drv | LC_ALL=C tr '[a-z]' '[A-Z]')
6772484e2cc7SPaolo Bonzini    echo "$def=y" >> $config_host_mak
67730c58ac1cSmalcdone
6774478e943fSPaolo Bonziniif test "$alsa" = "yes" ; then
6775478e943fSPaolo Bonzini    echo "CONFIG_ALSA=y" >> $config_host_mak
6776478e943fSPaolo Bonzinifi
6777b1149911SFam Zhengecho "ALSA_LIBS=$alsa_libs" >> $config_host_mak
6778478e943fSPaolo Bonziniecho "ALSA_CFLAGS=$alsa_cflags" >> $config_host_mak
6779478e943fSPaolo Bonziniif test "$libpulse" = "yes" ; then
6780478e943fSPaolo Bonzini    echo "CONFIG_LIBPULSE=y" >> $config_host_mak
6781478e943fSPaolo Bonzinifi
6782b1149911SFam Zhengecho "PULSE_LIBS=$pulse_libs" >> $config_host_mak
6783478e943fSPaolo Bonziniecho "PULSE_CFLAGS=$pulse_cflags" >> $config_host_mak
6784b1149911SFam Zhengecho "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
6785b1149911SFam Zhengecho "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
6786b1149911SFam Zhengecho "OSS_LIBS=$oss_libs" >> $config_host_mak
6787478e943fSPaolo Bonziniif test "$libjack" = "yes" ; then
6788478e943fSPaolo Bonzini    echo "CONFIG_LIBJACK=y" >> $config_host_mak
6789478e943fSPaolo Bonzinifi
67902e445703SGeoffrey McRaeecho "JACK_LIBS=$jack_libs" >> $config_host_mak
6791d5631638Smalcif test "$audio_win_int" = "yes" ; then
6792d5631638Smalc  echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
6793d5631638Smalcfi
6794b64ec4e4SFam Zhengecho "CONFIG_BDRV_RW_WHITELIST=$block_drv_rw_whitelist" >> $config_host_mak
6795b64ec4e4SFam Zhengecho "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
6796dce512deSChristoph Hellwigif test "$xfs" = "yes" ; then
6797dce512deSChristoph Hellwig  echo "CONFIG_XFS=y" >> $config_host_mak
6798dce512deSChristoph Hellwigfi
679989138857SStefan Weilqemu_version=$(head $source_path/VERSION)
68002358a494SJuan Quintelaecho "PKGVERSION=$pkgversion" >>$config_host_mak
680198ec69acSJuan Quintelaecho "SRC_PATH=$source_path" >> $config_host_mak
68022b1f35b9SAlex Bennéeecho "TARGET_DIRS=$target_list" >> $config_host_mak
6803a25dba17SJuan Quintelaif [ "$docs" = "yes" ] ; then
680498ec69acSJuan Quintela  echo "BUILD_DOCS=yes" >> $config_host_mak
6805cc8ae6deSpbrookfi
680617969268SFam Zhengif test "$modules" = "yes"; then
6807e26110cfSFam Zheng  # $shacmd can generate a hash started with digit, which the compiler doesn't
6808e26110cfSFam Zheng  # like as an symbol. So prefix it with an underscore
680989138857SStefan Weil  echo "CONFIG_STAMP=_$( (echo $qemu_version; echo $pkgversion; cat $0) | $shacmd - | cut -f1 -d\ )" >> $config_host_mak
681017969268SFam Zheng  echo "CONFIG_MODULES=y" >> $config_host_mak
681117969268SFam Zhengfi
6812bd83c861SChristian Ehrhardtif test "$module_upgrades" = "yes"; then
6813bd83c861SChristian Ehrhardt  echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
6814bd83c861SChristian Ehrhardtfi
6815e633a5c6SEric Blakeif test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
68168781595bSGerd Hoffmann  echo "CONFIG_X11=y" >> $config_host_mak
68178781595bSGerd Hoffmann  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
68188781595bSGerd Hoffmann  echo "X11_LIBS=$x11_libs" >> $config_host_mak
68198781595bSGerd Hoffmannfi
682049ecc3faSbellardif test "$cocoa" = "yes" ; then
682198ec69acSJuan Quintela  echo "CONFIG_COCOA=y" >> $config_host_mak
682249ecc3faSbellardfi
6823e08bb301SSamuel Thibaultif test "$iconv" = "yes" ; then
6824e08bb301SSamuel Thibault  echo "CONFIG_ICONV=y" >> $config_host_mak
6825e08bb301SSamuel Thibault  echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
6826e08bb301SSamuel Thibault  echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
6827e08bb301SSamuel Thibaultfi
68284d3b6f6eSbalrogif test "$curses" = "yes" ; then
6829484e2cc7SPaolo Bonzini  echo "CONFIG_CURSES=y" >> $config_host_mak
68302373f7d5SGerd Hoffmann  echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
68312373f7d5SGerd Hoffmann  echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
6832ab4e5602SJan Kiszkafi
6833099d6b0fSRiku Voipioif test "$pipe2" = "yes" ; then
68342358a494SJuan Quintela  echo "CONFIG_PIPE2=y" >> $config_host_mak
6835099d6b0fSRiku Voipiofi
683640ff6d7eSKevin Wolfif test "$accept4" = "yes" ; then
683740ff6d7eSKevin Wolf  echo "CONFIG_ACCEPT4=y" >> $config_host_mak
683840ff6d7eSKevin Wolffi
68393ce34dfbSvibisreenivasanif test "$splice" = "yes" ; then
68402358a494SJuan Quintela  echo "CONFIG_SPLICE=y" >> $config_host_mak
68413ce34dfbSvibisreenivasanfi
6842c2882b96SRiku Voipioif test "$eventfd" = "yes" ; then
6843c2882b96SRiku Voipio  echo "CONFIG_EVENTFD=y" >> $config_host_mak
6844c2882b96SRiku Voipiofi
6845751bcc39SMarc-André Lureauif test "$memfd" = "yes" ; then
6846751bcc39SMarc-André Lureau  echo "CONFIG_MEMFD=y" >> $config_host_mak
6847751bcc39SMarc-André Lureaufi
6848955727d2SCortland Tölvaif test "$have_usbfs" = "yes" ; then
6849955727d2SCortland Tölva  echo "CONFIG_USBFS=y" >> $config_host_mak
6850955727d2SCortland Tölvafi
6851d0927938SUlrich Hechtif test "$fallocate" = "yes" ; then
6852d0927938SUlrich Hecht  echo "CONFIG_FALLOCATE=y" >> $config_host_mak
6853d0927938SUlrich Hechtfi
68543d4fa43eSKusanagi Kouichiif test "$fallocate_punch_hole" = "yes" ; then
68553d4fa43eSKusanagi Kouichi  echo "CONFIG_FALLOCATE_PUNCH_HOLE=y" >> $config_host_mak
68563d4fa43eSKusanagi Kouichifi
6857b953f075SDenis V. Lunevif test "$fallocate_zero_range" = "yes" ; then
6858b953f075SDenis V. Lunev  echo "CONFIG_FALLOCATE_ZERO_RANGE=y" >> $config_host_mak
6859b953f075SDenis V. Lunevfi
6860ed911435SKevin Wolfif test "$posix_fallocate" = "yes" ; then
6861ed911435SKevin Wolf  echo "CONFIG_POSIX_FALLOCATE=y" >> $config_host_mak
6862ed911435SKevin Wolffi
6863c727f47dSPeter Maydellif test "$sync_file_range" = "yes" ; then
6864c727f47dSPeter Maydell  echo "CONFIG_SYNC_FILE_RANGE=y" >> $config_host_mak
6865c727f47dSPeter Maydellfi
6866dace20dcSPeter Maydellif test "$fiemap" = "yes" ; then
6867dace20dcSPeter Maydell  echo "CONFIG_FIEMAP=y" >> $config_host_mak
6868dace20dcSPeter Maydellfi
6869d0927938SUlrich Hechtif test "$dup3" = "yes" ; then
6870d0927938SUlrich Hecht  echo "CONFIG_DUP3=y" >> $config_host_mak
6871d0927938SUlrich Hechtfi
68724e0c6529SAlex Blighif test "$ppoll" = "yes" ; then
68734e0c6529SAlex Bligh  echo "CONFIG_PPOLL=y" >> $config_host_mak
68744e0c6529SAlex Blighfi
6875cd758dd0SAlex Blighif test "$prctl_pr_set_timerslack" = "yes" ; then
6876cd758dd0SAlex Bligh  echo "CONFIG_PRCTL_PR_SET_TIMERSLACK=y" >> $config_host_mak
6877cd758dd0SAlex Blighfi
68783b6edd16SPeter Maydellif test "$epoll" = "yes" ; then
68793b6edd16SPeter Maydell  echo "CONFIG_EPOLL=y" >> $config_host_mak
68803b6edd16SPeter Maydellfi
68813b6edd16SPeter Maydellif test "$epoll_create1" = "yes" ; then
68823b6edd16SPeter Maydell  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
68833b6edd16SPeter Maydellfi
6884a8fd1abaSPeter Maydellif test "$sendfile" = "yes" ; then
6885a8fd1abaSPeter Maydell  echo "CONFIG_SENDFILE=y" >> $config_host_mak
6886a8fd1abaSPeter Maydellfi
688751834341SRiku Voipioif test "$timerfd" = "yes" ; then
688851834341SRiku Voipio  echo "CONFIG_TIMERFD=y" >> $config_host_mak
688951834341SRiku Voipiofi
68909af5c906SRiku Voipioif test "$setns" = "yes" ; then
68919af5c906SRiku Voipio  echo "CONFIG_SETNS=y" >> $config_host_mak
68929af5c906SRiku Voipiofi
689338860a03SAleksandar Markovicif test "$clock_adjtime" = "yes" ; then
689438860a03SAleksandar Markovic  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
689538860a03SAleksandar Markovicfi
68965a03cd00SAleksandar Markovicif test "$syncfs" = "yes" ; then
68975a03cd00SAleksandar Markovic  echo "CONFIG_SYNCFS=y" >> $config_host_mak
68985a03cd00SAleksandar Markovicfi
6899db37dd89SAleksandar Markovicif test "$kcov" = "yes" ; then
6900db37dd89SAleksandar Markovic  echo "CONFIG_KCOV=y" >> $config_host_mak
6901db37dd89SAleksandar Markovicfi
69023b3f24adSaurel32if test "$inotify" = "yes" ; then
69032358a494SJuan Quintela  echo "CONFIG_INOTIFY=y" >> $config_host_mak
69043b3f24adSaurel32fi
6905c05c7a73SRiku Voipioif test "$inotify1" = "yes" ; then
6906c05c7a73SRiku Voipio  echo "CONFIG_INOTIFY1=y" >> $config_host_mak
6907c05c7a73SRiku Voipiofi
6908401bc051SPeter Maydellif test "$sem_timedwait" = "yes" ; then
6909401bc051SPeter Maydell  echo "CONFIG_SEM_TIMEDWAIT=y" >> $config_host_mak
6910401bc051SPeter Maydellfi
69115c99fa37SKeno Fischerif test "$strchrnul" = "yes" ; then
69125c99fa37SKeno Fischer  echo "HAVE_STRCHRNUL=y" >> $config_host_mak
69135c99fa37SKeno Fischerfi
69148a792b03SJiufei Xueif test "$st_atim" = "yes" ; then
69158a792b03SJiufei Xue  echo "HAVE_STRUCT_STAT_ST_ATIM=y" >> $config_host_mak
69168a792b03SJiufei Xuefi
69176ae9a1f4SJuan Quintelaif test "$byteswap_h" = "yes" ; then
69186ae9a1f4SJuan Quintela  echo "CONFIG_BYTESWAP_H=y" >> $config_host_mak
69196ae9a1f4SJuan Quintelafi
69206ae9a1f4SJuan Quintelaif test "$bswap_h" = "yes" ; then
69216ae9a1f4SJuan Quintela  echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
69226ae9a1f4SJuan Quintelafi
6923769ce76dSAlexander Grafif test "$curl" = "yes" ; then
6924484e2cc7SPaolo Bonzini  echo "CONFIG_CURL=y" >> $config_host_mak
6925b1d5a277SJuan Quintela  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
69266ebc91e5SFam Zheng  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
6927769ce76dSAlexander Graffi
69282e4d9fb1Saurel32if test "$brlapi" = "yes" ; then
692998ec69acSJuan Quintela  echo "CONFIG_BRLAPI=y" >> $config_host_mak
69308eca2889SFam Zheng  echo "BRLAPI_LIBS=$brlapi_libs" >> $config_host_mak
69312e4d9fb1Saurel32fi
6932a4ccabcfSAnthony Liguoriif test "$gtk" = "yes" ; then
6933484e2cc7SPaolo Bonzini  echo "CONFIG_GTK=y" >> $config_host_mak
6934a4ccabcfSAnthony Liguori  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
6935014cb152SGerd Hoffmann  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
6936925a0400SGerd Hoffmann  if test "$gtk_gl" = "yes" ; then
6937925a0400SGerd Hoffmann    echo "CONFIG_GTK_GL=y" >> $config_host_mak
6938925a0400SGerd Hoffmann  fi
6939bbbf9bfbSStefan Weilfi
6940f876b765SMarc-André Lureauif test "$gio" = "yes" ; then
6941f876b765SMarc-André Lureau    echo "CONFIG_GIO=y" >> $config_host_mak
6942f876b765SMarc-André Lureau    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
6943f876b765SMarc-André Lureau    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
694425a97a56SMarc-André Lureau    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
6945f876b765SMarc-André Lureaufi
6946a1c5e949SDaniel P. Berrangeecho "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
6947ddbb0d09SDaniel P. Berrangeif test "$gnutls" = "yes" ; then
6948ddbb0d09SDaniel P. Berrange  echo "CONFIG_GNUTLS=y" >> $config_host_mak
6949a81df1b6SPaolo Bonzini  echo "GNUTLS_CFLAGS=$gnutls_cflags" >> $config_host_mak
6950a81df1b6SPaolo Bonzini  echo "GNUTLS_LIBS=$gnutls_libs" >> $config_host_mak
6951ddbb0d09SDaniel P. Berrangefi
695291bfcdb0SDaniel P. Berrangeif test "$gcrypt" = "yes" ; then
695391bfcdb0SDaniel P. Berrange  echo "CONFIG_GCRYPT=y" >> $config_host_mak
69541f923c70SLongpeng(Mike)  if test "$gcrypt_hmac" = "yes" ; then
69551f923c70SLongpeng(Mike)    echo "CONFIG_GCRYPT_HMAC=y" >> $config_host_mak
69561f923c70SLongpeng(Mike)  fi
695762893b67SDaniel P. Berrangefi
695891bfcdb0SDaniel P. Berrangeif test "$nettle" = "yes" ; then
695991bfcdb0SDaniel P. Berrange  echo "CONFIG_NETTLE=y" >> $config_host_mak
6960becaeb72SRadim Krčmář  echo "CONFIG_NETTLE_VERSION_MAJOR=${nettle_version%%.*}" >> $config_host_mak
6961a81df1b6SPaolo Bonzini  echo "NETTLE_CFLAGS=$nettle_cflags" >> $config_host_mak
6962a81df1b6SPaolo Bonzini  echo "NETTLE_LIBS=$nettle_libs" >> $config_host_mak
6963ed754746SDaniel P. Berrangefi
6964e0576942SDaniel P. Berrangéif test "$qemu_private_xts" = "yes" ; then
6965e0576942SDaniel P. Berrangé  echo "CONFIG_QEMU_PRIVATE_XTS=y" >> $config_host_mak
6966e0576942SDaniel P. Berrangéfi
69679a2fd434SDaniel P. Berrangeif test "$tasn1" = "yes" ; then
69689a2fd434SDaniel P. Berrange  echo "CONFIG_TASN1=y" >> $config_host_mak
69699a2fd434SDaniel P. Berrangefi
69708953caf3SDaniel P. Berrangeif test "$auth_pam" = "yes" ; then
69718953caf3SDaniel P. Berrange    echo "CONFIG_AUTH_PAM=y" >> $config_host_mak
69728953caf3SDaniel P. Berrangefi
6973559607eaSDaniel P. Berrangeif test "$have_ifaddrs_h" = "yes" ; then
6974559607eaSDaniel P. Berrange    echo "HAVE_IFADDRS_H=y" >> $config_host_mak
6975559607eaSDaniel P. Berrangefi
6976e865b97fSChen Gangif test "$have_drm_h" = "yes" ; then
6977e865b97fSChen Gang  echo "HAVE_DRM_H=y" >> $config_host_mak
6978e865b97fSChen Gangfi
69796b39b063SEric Blakeif test "$have_broken_size_max" = "yes" ; then
69806b39b063SEric Blake    echo "HAVE_BROKEN_SIZE_MAX=y" >> $config_host_mak
69816b39b063SEric Blakefi
69829df8b20dSThomas Huthif test "$have_openpty" = "yes" ; then
69839df8b20dSThomas Huth    echo "HAVE_OPENPTY=y" >> $config_host_mak
69849df8b20dSThomas Huthfi
69852a4b472cSDavid CARLIERif test "$have_sys_signal_h" = "yes" ; then
69862a4b472cSDavid CARLIER    echo "HAVE_SYS_SIGNAL_H=y" >> $config_host_mak
69872a4b472cSDavid CARLIERfi
6988277abf15SJan Vesely
6989277abf15SJan Vesely# Work around a system header bug with some kernel/XFS header
6990277abf15SJan Vesely# versions where they both try to define 'struct fsxattr':
6991277abf15SJan Vesely# xfs headers will not try to redefine structs from linux headers
6992277abf15SJan Vesely# if this macro is set.
6993277abf15SJan Veselyif test "$have_fsxattr" = "yes" ; then
6994277abf15SJan Vesely    echo "HAVE_FSXATTR=y" >> $config_host_mak
6995277abf15SJan Veselyfi
69961efad060SFam Zhengif test "$have_copy_file_range" = "yes" ; then
69971efad060SFam Zheng    echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
69981efad060SFam Zhengfi
6999bbbf9bfbSStefan Weilif test "$vte" = "yes" ; then
7000bbbf9bfbSStefan Weil  echo "CONFIG_VTE=y" >> $config_host_mak
7001a4ccabcfSAnthony Liguori  echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak
7002e0fb129cSGerd Hoffmann  echo "VTE_LIBS=$vte_libs" >> $config_host_mak
7003a4ccabcfSAnthony Liguorifi
70049d9e1521SGerd Hoffmannif test "$virglrenderer" = "yes" ; then
70059d9e1521SGerd Hoffmann  echo "CONFIG_VIRGL=y" >> $config_host_mak
70069d9e1521SGerd Hoffmann  echo "VIRGL_CFLAGS=$virgl_cflags" >> $config_host_mak
70079d9e1521SGerd Hoffmann  echo "VIRGL_LIBS=$virgl_libs" >> $config_host_mak
70089d9e1521SGerd Hoffmannfi
7009e37630caSaliguoriif test "$xen" = "yes" ; then
70106dbd588aSJan Kiszka  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
7011d5b93ddfSAnthony PERARD  echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
7012582ea95fSMarc-André Lureau  echo "XEN_CFLAGS=$xen_cflags" >> $config_host_mak
7013582ea95fSMarc-André Lureau  echo "XEN_LIBS=$xen_libs" >> $config_host_mak
7014e37630caSaliguorifi
70155c6c3a6cSChristoph Hellwigif test "$linux_aio" = "yes" ; then
70165c6c3a6cSChristoph Hellwig  echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
70175c6c3a6cSChristoph Hellwigfi
7018c10dd856SAarushi Mehtaif test "$linux_io_uring" = "yes" ; then
7019c10dd856SAarushi Mehta  echo "CONFIG_LINUX_IO_URING=y" >> $config_host_mak
7020c10dd856SAarushi Mehta  echo "LINUX_IO_URING_CFLAGS=$linux_io_uring_cflags" >> $config_host_mak
7021c10dd856SAarushi Mehta  echo "LINUX_IO_URING_LIBS=$linux_io_uring_libs" >> $config_host_mak
7022c10dd856SAarushi Mehtafi
7023758e8e38SVenkateswararao Jujjuri (JV)if test "$attr" = "yes" ; then
7024758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_ATTR=y" >> $config_host_mak
7025ec0d5893SMarc-André Lureau  echo "LIBATTR_LIBS=$libattr_libs" >> $config_host_mak
7026758e8e38SVenkateswararao Jujjuri (JV)fi
70274f26f2b6SAvi Kivityif test "$libattr" = "yes" ; then
70284f26f2b6SAvi Kivity  echo "CONFIG_LIBATTR=y" >> $config_host_mak
70294f26f2b6SAvi Kivityfi
7030983eef5aSMeador Ingeif test "$virtfs" = "yes" ; then
7031758e8e38SVenkateswararao Jujjuri (JV)  echo "CONFIG_VIRTFS=y" >> $config_host_mak
7032758e8e38SVenkateswararao Jujjuri (JV)fi
7033fe8fc5aeSPaolo Bonziniif test "$mpath" = "yes" ; then
7034fe8fc5aeSPaolo Bonzini  echo "CONFIG_MPATH=y" >> $config_host_mak
70351b0578f5SMurilo Opsfelder Araujo  if test "$mpathpersist_new_api" = "yes"; then
70361b0578f5SMurilo Opsfelder Araujo    echo "CONFIG_MPATH_NEW_API=y" >> $config_host_mak
70371b0578f5SMurilo Opsfelder Araujo  fi
7038fe8fc5aeSPaolo Bonzinifi
70395e9be92dSNicholas Bellingerif test "$vhost_scsi" = "yes" ; then
70405e9be92dSNicholas Bellinger  echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
70415e9be92dSNicholas Bellingerfi
7042af3bba76SPaolo Bonziniif test "$vhost_net" = "yes" ; then
7043af3bba76SPaolo Bonzini  echo "CONFIG_VHOST_NET=y" >> $config_host_mak
7044af3bba76SPaolo Bonzinifi
7045af3bba76SPaolo Bonziniif test "$vhost_net_user" = "yes" ; then
704656f41de7SPaolo Bonzini  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
704703ce5744SNikolay Nikolaevfi
7048108a6481SCindy Luif test "$vhost_net_vdpa" = "yes" ; then
7049108a6481SCindy Lu  echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
7050108a6481SCindy Lufi
7051042cea27SGongleiif test "$vhost_crypto" = "yes" ; then
7052042cea27SGonglei  echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
7053042cea27SGongleifi
7054fc0b9b0eSStefan Hajnocziif test "$vhost_vsock" = "yes" ; then
7055fc0b9b0eSStefan Hajnoczi  echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
70565fe97d88SStefano Garzarella  if test "$vhost_user" = "yes" ; then
70575fe97d88SStefano Garzarella    echo "CONFIG_VHOST_USER_VSOCK=y" >> $config_host_mak
70585fe97d88SStefano Garzarella  fi
7059fc0b9b0eSStefan Hajnoczifi
7060299e6f19SPaolo Bonziniif test "$vhost_kernel" = "yes" ; then
7061299e6f19SPaolo Bonzini  echo "CONFIG_VHOST_KERNEL=y" >> $config_host_mak
7062299e6f19SPaolo Bonzinifi
7063e6a74868SMarc-André Lureauif test "$vhost_user" = "yes" ; then
7064e6a74868SMarc-André Lureau  echo "CONFIG_VHOST_USER=y" >> $config_host_mak
7065e6a74868SMarc-André Lureaufi
7066108a6481SCindy Luif test "$vhost_vdpa" = "yes" ; then
7067108a6481SCindy Lu  echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
7068108a6481SCindy Lufi
706998fc1adaSDr. David Alan Gilbertif test "$vhost_user_fs" = "yes" ; then
707098fc1adaSDr. David Alan Gilbert  echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
707198fc1adaSDr. David Alan Gilbertfi
707277755340Sthsif test "$blobs" = "yes" ; then
707398ec69acSJuan Quintela  echo "INSTALL_BLOBS=yes" >> $config_host_mak
707477755340Sthsfi
7075bf9298b9Saliguoriif test "$iovec" = "yes" ; then
70762358a494SJuan Quintela  echo "CONFIG_IOVEC=y" >> $config_host_mak
7077bf9298b9Saliguorifi
7078ceb42de8Saliguoriif test "$preadv" = "yes" ; then
70792358a494SJuan Quintela  echo "CONFIG_PREADV=y" >> $config_host_mak
7080ceb42de8Saliguorifi
7081e3971d61SPhilippe Mathieu-Daudéif test "$fdt" != "no" ; then
70823f0855b1SJuan Quintela  echo "CONFIG_FDT=y" >> $config_host_mak
70834a96337dSPaolo Bonzini  echo "FDT_CFLAGS=$fdt_cflags" >> $config_host_mak
70844a96337dSPaolo Bonzini  echo "FDT_LIBS=$fdt_ldflags $fdt_libs" >> $config_host_mak
7085f652e6afSaurel32fi
7086a40161cbSPaolo Bonziniif test "$membarrier" = "yes" ; then
7087a40161cbSPaolo Bonzini  echo "CONFIG_MEMBARRIER=y" >> $config_host_mak
7088a40161cbSPaolo Bonzinifi
7089dcc38d1cSMarcelo Tosattiif test "$signalfd" = "yes" ; then
7090dcc38d1cSMarcelo Tosatti  echo "CONFIG_SIGNALFD=y" >> $config_host_mak
7091dcc38d1cSMarcelo Tosattifi
7092d339d766SRichard W.M. Jonesif test "$optreset" = "yes" ; then
7093d339d766SRichard W.M. Jones  echo "HAVE_OPTRESET=y" >> $config_host_mak
7094d339d766SRichard W.M. Jonesfi
7095b3f6ea7eSPaolo Bonziniif test "$tcg" = "yes"; then
7096b3f6ea7eSPaolo Bonzini  echo "CONFIG_TCG=y" >> $config_host_mak
70979195b2c2SStefan Weil  if test "$tcg_interpreter" = "yes" ; then
70989195b2c2SStefan Weil    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
70999195b2c2SStefan Weil  fi
7100b3f6ea7eSPaolo Bonzinifi
71015f6b9e8fSBlue Swirlif test "$fdatasync" = "yes" ; then
71025f6b9e8fSBlue Swirl  echo "CONFIG_FDATASYNC=y" >> $config_host_mak
71035f6b9e8fSBlue Swirlfi
7104e78815a5SAndreas Färberif test "$madvise" = "yes" ; then
7105e78815a5SAndreas Färber  echo "CONFIG_MADVISE=y" >> $config_host_mak
7106e78815a5SAndreas Färberfi
7107e78815a5SAndreas Färberif test "$posix_madvise" = "yes" ; then
7108e78815a5SAndreas Färber  echo "CONFIG_POSIX_MADVISE=y" >> $config_host_mak
7109e78815a5SAndreas Färberfi
71109bc5a719SAndreas Gustafssonif test "$posix_memalign" = "yes" ; then
71119bc5a719SAndreas Gustafsson  echo "CONFIG_POSIX_MEMALIGN=y" >> $config_host_mak
71129bc5a719SAndreas Gustafssonfi
7113cd4ec0b4SGerd Hoffmannif test "$spice" = "yes" ; then
7114cd4ec0b4SGerd Hoffmann  echo "CONFIG_SPICE=y" >> $config_host_mak
71152634733cSPaolo Bonzini  echo "SPICE_CFLAGS=$spice_cflags" >> $config_host_mak
71162634733cSPaolo Bonzini  echo "SPICE_LIBS=$spice_libs" >> $config_host_mak
7117cd4ec0b4SGerd Hoffmannfi
7118cd4ec0b4SGerd Hoffmann
71197b02f544SMarc-André Lureauif test "$smartcard" = "yes" ; then
71207b02f544SMarc-André Lureau  echo "CONFIG_SMARTCARD=y" >> $config_host_mak
71217b62bf5aSFam Zheng  echo "SMARTCARD_CFLAGS=$libcacard_cflags" >> $config_host_mak
71227b62bf5aSFam Zheng  echo "SMARTCARD_LIBS=$libcacard_libs" >> $config_host_mak
7123111a38b0SRobert Relyeafi
7124111a38b0SRobert Relyea
71252b2325ffSGerd Hoffmannif test "$libusb" = "yes" ; then
71262b2325ffSGerd Hoffmann  echo "CONFIG_USB_LIBUSB=y" >> $config_host_mak
7127b878b652SFam Zheng  echo "LIBUSB_CFLAGS=$libusb_cflags" >> $config_host_mak
7128b878b652SFam Zheng  echo "LIBUSB_LIBS=$libusb_libs" >> $config_host_mak
71292b2325ffSGerd Hoffmannfi
71302b2325ffSGerd Hoffmann
713169354a83SHans de Goedeif test "$usb_redir" = "yes" ; then
713269354a83SHans de Goede  echo "CONFIG_USB_REDIR=y" >> $config_host_mak
7133cc7923fcSFam Zheng  echo "USB_REDIR_CFLAGS=$usb_redir_cflags" >> $config_host_mak
7134cc7923fcSFam Zheng  echo "USB_REDIR_LIBS=$usb_redir_libs" >> $config_host_mak
713569354a83SHans de Goedefi
713669354a83SHans de Goede
7137da076ffeSGerd Hoffmannif test "$opengl" = "yes" ; then
7138da076ffeSGerd Hoffmann  echo "CONFIG_OPENGL=y" >> $config_host_mak
7139da076ffeSGerd Hoffmann  echo "OPENGL_LIBS=$opengl_libs" >> $config_host_mak
7140014cb152SGerd Hoffmann  if test "$opengl_dmabuf" = "yes" ; then
7141014cb152SGerd Hoffmann    echo "CONFIG_OPENGL_DMABUF=y" >> $config_host_mak
7142014cb152SGerd Hoffmann  fi
714320ff075bSMichael Wallefi
714420ff075bSMichael Walle
7145d52c454aSMarc-André Lureauif test "$gbm" = "yes" ; then
7146d52c454aSMarc-André Lureau    echo "CONFIG_GBM=y" >> $config_host_mak
7147d52c454aSMarc-André Lureau    echo "GBM_LIBS=$gbm_libs" >> $config_host_mak
7148d52c454aSMarc-André Lureau    echo "GBM_CFLAGS=$gbm_cflags" >> $config_host_mak
7149d52c454aSMarc-André Lureaufi
7150d52c454aSMarc-André Lureau
7151d52c454aSMarc-André Lureau
71525a22ab71SYang Zhongif test "$malloc_trim" = "yes" ; then
71535a22ab71SYang Zhong  echo "CONFIG_MALLOC_TRIM=y" >> $config_host_mak
71545a22ab71SYang Zhongfi
71555a22ab71SYang Zhong
715699f2dbd3SLiang Liif test "$avx2_opt" = "yes" ; then
715799f2dbd3SLiang Li  echo "CONFIG_AVX2_OPT=y" >> $config_host_mak
715899f2dbd3SLiang Lifi
715999f2dbd3SLiang Li
71606b8cd447SRobert Hooif test "$avx512f_opt" = "yes" ; then
71616b8cd447SRobert Hoo  echo "CONFIG_AVX512F_OPT=y" >> $config_host_mak
71626b8cd447SRobert Hoofi
71636b8cd447SRobert Hoo
7164607dacd0Sqiaonuohanif test "$lzo" = "yes" ; then
7165607dacd0Sqiaonuohan  echo "CONFIG_LZO=y" >> $config_host_mak
7166708eab42SMarc-André Lureau  echo "LZO_LIBS=$lzo_libs" >> $config_host_mak
7167607dacd0Sqiaonuohanfi
7168607dacd0Sqiaonuohan
7169607dacd0Sqiaonuohanif test "$snappy" = "yes" ; then
7170607dacd0Sqiaonuohan  echo "CONFIG_SNAPPY=y" >> $config_host_mak
7171708eab42SMarc-André Lureau  echo "SNAPPY_LIBS=$snappy_libs" >> $config_host_mak
7172607dacd0Sqiaonuohanfi
7173607dacd0Sqiaonuohan
71746b383c08SPeter Wuif test "$bzip2" = "yes" ; then
71756b383c08SPeter Wu  echo "CONFIG_BZIP2=y" >> $config_host_mak
71766b383c08SPeter Wu  echo "BZIP2_LIBS=-lbz2" >> $config_host_mak
71776b383c08SPeter Wufi
71786b383c08SPeter Wu
717983bc1f97SJulio Faraccoif test "$lzfse" = "yes" ; then
718083bc1f97SJulio Faracco  echo "CONFIG_LZFSE=y" >> $config_host_mak
718183bc1f97SJulio Faracco  echo "LZFSE_LIBS=-llzfse" >> $config_host_mak
718283bc1f97SJulio Faraccofi
718383bc1f97SJulio Faracco
71843a678481SJuan Quintelaif test "$zstd" = "yes" ; then
71853a678481SJuan Quintela  echo "CONFIG_ZSTD=y" >> $config_host_mak
71865e5733e5SMarc-André Lureau  echo "ZSTD_CFLAGS=$zstd_cflags" >> $config_host_mak
71875e5733e5SMarc-André Lureau  echo "ZSTD_LIBS=$zstd_libs" >> $config_host_mak
71883a678481SJuan Quintelafi
71893a678481SJuan Quintela
7190c589b249SRonnie Sahlbergif test "$libiscsi" = "yes" ; then
7191484e2cc7SPaolo Bonzini  echo "CONFIG_LIBISCSI=y" >> $config_host_mak
71926ebc91e5SFam Zheng  echo "LIBISCSI_CFLAGS=$libiscsi_cflags" >> $config_host_mak
71936ebc91e5SFam Zheng  echo "LIBISCSI_LIBS=$libiscsi_libs" >> $config_host_mak
7194c589b249SRonnie Sahlbergfi
7195c589b249SRonnie Sahlberg
71966542aa9cSPeter Lievenif test "$libnfs" = "yes" ; then
7197484e2cc7SPaolo Bonzini  echo "CONFIG_LIBNFS=y" >> $config_host_mak
71984be4879fSColin Lord  echo "LIBNFS_LIBS=$libnfs_libs" >> $config_host_mak
71996542aa9cSPeter Lievenfi
72006542aa9cSPeter Lieven
7201f794573eSEduardo Otuboif test "$seccomp" = "yes"; then
7202f794573eSEduardo Otubo  echo "CONFIG_SECCOMP=y" >> $config_host_mak
7203c3883e1fSFam Zheng  echo "SECCOMP_CFLAGS=$seccomp_cflags" >> $config_host_mak
7204c3883e1fSFam Zheng  echo "SECCOMP_LIBS=$seccomp_libs" >> $config_host_mak
7205f794573eSEduardo Otubofi
7206f794573eSEduardo Otubo
720783fb7adfSbellard# XXX: suppress that
72087d3505c5Sbellardif [ "$bsd" = "yes" ] ; then
72092358a494SJuan Quintela  echo "CONFIG_BSD=y" >> $config_host_mak
72107d3505c5Sbellardfi
72117d3505c5Sbellard
72124d9310f4SDaniel P. Berrangeif test "$localtime_r" = "yes" ; then
72134d9310f4SDaniel P. Berrange  echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
72144d9310f4SDaniel P. Berrangefi
72153556c233SPaolo Bonziniif test "$qom_cast_debug" = "yes" ; then
72163556c233SPaolo Bonzini  echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
72173556c233SPaolo Bonzinifi
7218f27aaf4bSChristian Brunnerif test "$rbd" = "yes" ; then
7219484e2cc7SPaolo Bonzini  echo "CONFIG_RBD=y" >> $config_host_mak
72206ebc91e5SFam Zheng  echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
7221f27aaf4bSChristian Brunnerfi
722220ff6c80SAnthony Liguori
72237c2acc70SPeter Maydellecho "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
722470c60c08SStefan Hajnocziif test "$coroutine_pool" = "yes" ; then
722570c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
722670c60c08SStefan Hajnoczielse
722770c60c08SStefan Hajnoczi  echo "CONFIG_COROUTINE_POOL=0" >> $config_host_mak
722870c60c08SStefan Hajnoczifi
7229d0e2fce5SAneesh Kumar K.V
72307d992e4dSPeter Lievenif test "$debug_stack_usage" = "yes" ; then
72317d992e4dSPeter Lieven  echo "CONFIG_DEBUG_STACK_USAGE=y" >> $config_host_mak
72327d992e4dSPeter Lievenfi
72337d992e4dSPeter Lieven
7234f0d92b56SLongpeng(Mike)if test "$crypto_afalg" = "yes" ; then
7235f0d92b56SLongpeng(Mike)  echo "CONFIG_AF_ALG=y" >> $config_host_mak
7236f0d92b56SLongpeng(Mike)fi
7237f0d92b56SLongpeng(Mike)
7238d2042378SAneesh Kumar K.Vif test "$open_by_handle_at" = "yes" ; then
7239d2042378SAneesh Kumar K.V  echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
7240d2042378SAneesh Kumar K.Vfi
7241d2042378SAneesh Kumar K.V
7242e06a765eSHarsh Prateek Boraif test "$linux_magic_h" = "yes" ; then
7243e06a765eSHarsh Prateek Bora  echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
7244e06a765eSHarsh Prateek Borafi
7245e06a765eSHarsh Prateek Bora
72463f4349dcSKevin Wolfif test "$valgrind_h" = "yes" ; then
72473f4349dcSKevin Wolf  echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
72483f4349dcSKevin Wolffi
72493f4349dcSKevin Wolf
7250d83414e1SMarc-André Lureauif test "$have_asan_iface_fiber" = "yes" ; then
7251d83414e1SMarc-André Lureau    echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
7252d83414e1SMarc-André Lureaufi
7253d83414e1SMarc-André Lureau
72540aebab04SLingfeng Yangif test "$have_tsan" = "yes" && test "$have_tsan_iface_fiber" = "yes" ; then
72550aebab04SLingfeng Yang    echo "CONFIG_TSAN=y" >> $config_host_mak
72560aebab04SLingfeng Yangfi
72570aebab04SLingfeng Yang
72588ab1bf12SLuiz Capitulinoif test "$has_environ" = "yes" ; then
72598ab1bf12SLuiz Capitulino  echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
72608ab1bf12SLuiz Capitulinofi
72618ab1bf12SLuiz Capitulino
726276a347e1SRichard Hendersonif test "$cpuid_h" = "yes" ; then
726376a347e1SRichard Henderson  echo "CONFIG_CPUID_H=y" >> $config_host_mak
726476a347e1SRichard Hendersonfi
726576a347e1SRichard Henderson
7266f540166bSRichard Hendersonif test "$int128" = "yes" ; then
7267f540166bSRichard Henderson  echo "CONFIG_INT128=y" >> $config_host_mak
7268f540166bSRichard Hendersonfi
7269f540166bSRichard Henderson
72707ebee43eSRichard Hendersonif test "$atomic128" = "yes" ; then
72717ebee43eSRichard Henderson  echo "CONFIG_ATOMIC128=y" >> $config_host_mak
72727ebee43eSRichard Hendersonfi
72737ebee43eSRichard Henderson
7274e6cd4bb5SRichard Hendersonif test "$cmpxchg128" = "yes" ; then
7275e6cd4bb5SRichard Henderson  echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
7276e6cd4bb5SRichard Hendersonfi
7277e6cd4bb5SRichard Henderson
7278df79b996SRichard Hendersonif test "$atomic64" = "yes" ; then
7279df79b996SRichard Henderson  echo "CONFIG_ATOMIC64=y" >> $config_host_mak
7280df79b996SRichard Hendersonfi
7281df79b996SRichard Henderson
7282db8aaae8SRichard Hendersonif test "$attralias" = "yes" ; then
7283db8aaae8SRichard Henderson  echo "CONFIG_ATTRIBUTE_ALIAS=y" >> $config_host_mak
7284db8aaae8SRichard Hendersonfi
7285db8aaae8SRichard Henderson
72861e6e9acaSRichard Hendersonif test "$getauxval" = "yes" ; then
72871e6e9acaSRichard Henderson  echo "CONFIG_GETAUXVAL=y" >> $config_host_mak
72881e6e9acaSRichard Hendersonfi
72891e6e9acaSRichard Henderson
7290eb100396SBharata B Raoif test "$glusterfs" = "yes" ; then
7291484e2cc7SPaolo Bonzini  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
72926ebc91e5SFam Zheng  echo "GLUSTERFS_CFLAGS=$glusterfs_cflags" >> $config_host_mak
72936ebc91e5SFam Zheng  echo "GLUSTERFS_LIBS=$glusterfs_libs" >> $config_host_mak
7294eb100396SBharata B Raofi
7295eb100396SBharata B Rao
7296d85fa9ebSJeff Codyif test "$glusterfs_xlator_opt" = "yes" ; then
7297d85fa9ebSJeff Cody  echo "CONFIG_GLUSTERFS_XLATOR_OPT=y" >> $config_host_mak
7298d85fa9ebSJeff Codyfi
7299d85fa9ebSJeff Cody
73000c14fb47SBharata B Raoif test "$glusterfs_discard" = "yes" ; then
73010c14fb47SBharata B Rao  echo "CONFIG_GLUSTERFS_DISCARD=y" >> $config_host_mak
73020c14fb47SBharata B Raofi
73030c14fb47SBharata B Rao
7304df3a429aSNiels de Vosif test "$glusterfs_fallocate" = "yes" ; then
7305df3a429aSNiels de Vos  echo "CONFIG_GLUSTERFS_FALLOCATE=y" >> $config_host_mak
7306df3a429aSNiels de Vosfi
7307df3a429aSNiels de Vos
73087c815372SBharata B Raoif test "$glusterfs_zerofill" = "yes" ; then
73097c815372SBharata B Rao  echo "CONFIG_GLUSTERFS_ZEROFILL=y" >> $config_host_mak
73107c815372SBharata B Raofi
73117c815372SBharata B Rao
7312e014dbe7SPrasanna Kumar Kaleverif test "$glusterfs_ftruncate_has_stat" = "yes" ; then
7313e014dbe7SPrasanna Kumar Kalever  echo "CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT=y" >> $config_host_mak
7314e014dbe7SPrasanna Kumar Kaleverfi
7315e014dbe7SPrasanna Kumar Kalever
73160e3b891fSNiels de Vosif test "$glusterfs_iocb_has_stat" = "yes" ; then
73170e3b891fSNiels de Vos  echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak
73180e3b891fSNiels de Vosfi
73190e3b891fSNiels de Vos
7320b10d49d7SPino Toscanoif test "$libssh" = "yes" ; then
7321484e2cc7SPaolo Bonzini  echo "CONFIG_LIBSSH=y" >> $config_host_mak
7322b10d49d7SPino Toscano  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
7323b10d49d7SPino Toscano  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
73240a12ec87SRichard W.M. Jonesfi
73250a12ec87SRichard W.M. Jones
7326ed1701c6SDr. David Alan Gilbertif test "$live_block_migration" = "yes" ; then
7327ed1701c6SDr. David Alan Gilbert  echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
7328ed1701c6SDr. David Alan Gilbertfi
7329ed1701c6SDr. David Alan Gilbert
73303b8acc11SPaolo Bonziniif test "$tpm" = "yes"; then
73313cae16dbSPaolo Bonzini  echo 'CONFIG_TPM=y' >> $config_host_mak
73323b8acc11SPaolo Bonzinifi
73333b8acc11SPaolo Bonzini
73345b808275SLluís Vilanovaecho "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
73355b808275SLluís Vilanovaif have_backend "nop"; then
73366d8a764eSLluís  echo "CONFIG_TRACE_NOP=y" >> $config_host_mak
733722890ab5SPrerna Saxenafi
73385b808275SLluís Vilanovaif have_backend "simple"; then
73396d8a764eSLluís  echo "CONFIG_TRACE_SIMPLE=y" >> $config_host_mak
73406d8a764eSLluís  # Set the appropriate trace file.
7341953ffe0fSAndreas Färber  trace_file="\"$trace_file-\" FMT_pid"
73429410b56cSPrerna Saxenafi
7343ed7f5f1dSPaolo Bonziniif have_backend "log"; then
7344ed7f5f1dSPaolo Bonzini  echo "CONFIG_TRACE_LOG=y" >> $config_host_mak
73456d8a764eSLluísfi
73465b808275SLluís Vilanovaif have_backend "ust"; then
73476d8a764eSLluís  echo "CONFIG_TRACE_UST=y" >> $config_host_mak
7348a81df1b6SPaolo Bonzini  echo "LTTNG_UST_LIBS=$lttng_ust_libs" >> $config_host_mak
7349a81df1b6SPaolo Bonzini  echo "URCU_BP_LIBS=$urcu_bp_libs" >> $config_host_mak
73506d8a764eSLluísfi
73515b808275SLluís Vilanovaif have_backend "dtrace"; then
73526d8a764eSLluís  echo "CONFIG_TRACE_DTRACE=y" >> $config_host_mak
73536d8a764eSLluís  if test "$trace_backend_stap" = "yes" ; then
73546d8a764eSLluís    echo "CONFIG_TRACE_SYSTEMTAP=y" >> $config_host_mak
73556d8a764eSLluís  fi
7356c276b17dSDaniel P. Berrangefi
73575b808275SLluís Vilanovaif have_backend "ftrace"; then
7358781e9545SEiichi Tsukata  if test "$linux" = "yes" ; then
7359781e9545SEiichi Tsukata    echo "CONFIG_TRACE_FTRACE=y" >> $config_host_mak
7360781e9545SEiichi Tsukata  else
736121684af0SStewart Smith    feature_not_found "ftrace(trace backend)" "ftrace requires Linux"
7362781e9545SEiichi Tsukata  fi
7363781e9545SEiichi Tsukatafi
73640a852417SPaul Durrantif have_backend "syslog"; then
73650a852417SPaul Durrant  if test "$posix_syslog" = "yes" ; then
73660a852417SPaul Durrant    echo "CONFIG_TRACE_SYSLOG=y" >> $config_host_mak
73670a852417SPaul Durrant  else
73680a852417SPaul Durrant    feature_not_found "syslog(trace backend)" "syslog not available"
73690a852417SPaul Durrant  fi
73700a852417SPaul Durrantfi
73719410b56cSPrerna Saxenaecho "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
73729410b56cSPrerna Saxena
73732da776dbSMichael R. Hinesif test "$rdma" = "yes" ; then
73742da776dbSMichael R. Hines  echo "CONFIG_RDMA=y" >> $config_host_mak
7375392fb643SFam Zheng  echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
73762da776dbSMichael R. Hinesfi
73772da776dbSMichael R. Hines
737821ab34c9SMarcel Apfelbaumif test "$pvrdma" = "yes" ; then
737921ab34c9SMarcel Apfelbaum  echo "CONFIG_PVRDMA=y" >> $config_host_mak
738021ab34c9SMarcel Apfelbaumfi
738121ab34c9SMarcel Apfelbaum
7382575b22b1SLaurent Vivierif test "$have_rtnetlink" = "yes" ; then
7383575b22b1SLaurent Vivier  echo "CONFIG_RTNETLINK=y" >> $config_host_mak
7384575b22b1SLaurent Vivierfi
7385575b22b1SLaurent Vivier
7386ed279a06SKlim Kireevif test "$libxml2" = "yes" ; then
7387ed279a06SKlim Kireev  echo "CONFIG_LIBXML2=y" >> $config_host_mak
7388ed279a06SKlim Kireev  echo "LIBXML2_CFLAGS=$libxml2_cflags" >> $config_host_mak
7389ed279a06SKlim Kireev  echo "LIBXML2_LIBS=$libxml2_libs" >> $config_host_mak
7390ed279a06SKlim Kireevfi
7391ed279a06SKlim Kireev
7392a6b1d4c0SChanglong Xieif test "$replication" = "yes" ; then
7393a6b1d4c0SChanglong Xie  echo "CONFIG_REPLICATION=y" >> $config_host_mak
7394a6b1d4c0SChanglong Xiefi
7395a6b1d4c0SChanglong Xie
73966a02c806SStefan Hajnocziif test "$have_af_vsock" = "yes" ; then
73976a02c806SStefan Hajnoczi  echo "CONFIG_AF_VSOCK=y" >> $config_host_mak
73986a02c806SStefan Hajnoczifi
73996a02c806SStefan Hajnoczi
74004d04351fSChristopher Covingtonif test "$have_sysmacros" = "yes" ; then
74014d04351fSChristopher Covington  echo "CONFIG_SYSMACROS=y" >> $config_host_mak
74024d04351fSChristopher Covingtonfi
74034d04351fSChristopher Covington
740449e00a18SAndreas Grapentinif test "$have_static_assert" = "yes" ; then
740549e00a18SAndreas Grapentin  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
740649e00a18SAndreas Grapentinfi
740749e00a18SAndreas Grapentin
7408e674605fSTomáš Golembiovskýif test "$have_utmpx" = "yes" ; then
7409e674605fSTomáš Golembiovský  echo "HAVE_UTMPX=y" >> $config_host_mak
7410e674605fSTomáš Golembiovskýfi
7411db1ed1abSRichard Hendersonif test "$have_getrandom" = "yes" ; then
7412db1ed1abSRichard Henderson  echo "CONFIG_GETRANDOM=y" >> $config_host_mak
7413db1ed1abSRichard Hendersonfi
7414e0580342SKamil Rytarowskiif test "$ivshmem" = "yes" ; then
7415e0580342SKamil Rytarowski  echo "CONFIG_IVSHMEM=y" >> $config_host_mak
7416e0580342SKamil Rytarowskifi
7417e219c499SRichard Hendersonif test "$capstone" != "no" ; then
74188ca80760SRichard Henderson  echo "CONFIG_CAPSTONE=y" >> $config_host_mak
7419c9322ab5SMarc-André Lureau  echo "CAPSTONE_CFLAGS=$capstone_cflags" >> $config_host_mak
7420c9322ab5SMarc-André Lureau  echo "CAPSTONE_LIBS=$capstone_libs" >> $config_host_mak
74218ca80760SRichard Hendersonfi
7422ba59fb77SPaolo Bonziniif test "$debug_mutex" = "yes" ; then
7423ba59fb77SPaolo Bonzini  echo "CONFIG_DEBUG_MUTEX=y" >> $config_host_mak
7424ba59fb77SPaolo Bonzinifi
7425e0580342SKamil Rytarowski
74265c312079SDr. David Alan Gilbert# Hold two types of flag:
74275c312079SDr. David Alan Gilbert#   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
74285c312079SDr. David Alan Gilbert#                                     a thread we have a handle to
7429479a5747SRoman Bolshakov#   CONFIG_PTHREAD_SETNAME_NP_W_TID - A way of doing it on a particular
74305c312079SDr. David Alan Gilbert#                                     platform
7431479a5747SRoman Bolshakovif test "$pthread_setname_np_w_tid" = "yes" ; then
74325c312079SDr. David Alan Gilbert  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7433479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_W_TID=y" >> $config_host_mak
7434479a5747SRoman Bolshakovelif test "$pthread_setname_np_wo_tid" = "yes" ; then
7435479a5747SRoman Bolshakov  echo "CONFIG_THREAD_SETNAME_BYTHREAD=y" >> $config_host_mak
7436479a5747SRoman Bolshakov  echo "CONFIG_PTHREAD_SETNAME_NP_WO_TID=y" >> $config_host_mak
74375c312079SDr. David Alan Gilbertfi
74385c312079SDr. David Alan Gilbert
743917824406SJunyan Heif test "$libpmem" = "yes" ; then
744017824406SJunyan He  echo "CONFIG_LIBPMEM=y" >> $config_host_mak
7441c9322ab5SMarc-André Lureau  echo "LIBPMEM_LIBS=$libpmem_libs" >> $config_host_mak
7442c9322ab5SMarc-André Lureau  echo "LIBPMEM_CFLAGS=$libpmem_cflags" >> $config_host_mak
744317824406SJunyan Hefi
744417824406SJunyan He
744521b2eca6SJingqi Liuif test "$libdaxctl" = "yes" ; then
744621b2eca6SJingqi Liu  echo "CONFIG_LIBDAXCTL=y" >> $config_host_mak
7447c7c91a74SBruce Rogers  echo "LIBDAXCTL_LIBS=$libdaxctl_libs" >> $config_host_mak
744821b2eca6SJingqi Liufi
744921b2eca6SJingqi Liu
74502f740136SJeff Codyif test "$bochs" = "yes" ; then
74512f740136SJeff Cody  echo "CONFIG_BOCHS=y" >> $config_host_mak
74522f740136SJeff Codyfi
74532f740136SJeff Codyif test "$cloop" = "yes" ; then
74542f740136SJeff Cody  echo "CONFIG_CLOOP=y" >> $config_host_mak
74552f740136SJeff Codyfi
74562f740136SJeff Codyif test "$dmg" = "yes" ; then
74572f740136SJeff Cody  echo "CONFIG_DMG=y" >> $config_host_mak
74582f740136SJeff Codyfi
74592f740136SJeff Codyif test "$qcow1" = "yes" ; then
74602f740136SJeff Cody  echo "CONFIG_QCOW1=y" >> $config_host_mak
74612f740136SJeff Codyfi
74622f740136SJeff Codyif test "$vdi" = "yes" ; then
74632f740136SJeff Cody  echo "CONFIG_VDI=y" >> $config_host_mak
74642f740136SJeff Codyfi
74652f740136SJeff Codyif test "$vvfat" = "yes" ; then
74662f740136SJeff Cody  echo "CONFIG_VVFAT=y" >> $config_host_mak
74672f740136SJeff Codyfi
74682f740136SJeff Codyif test "$qed" = "yes" ; then
74692f740136SJeff Cody  echo "CONFIG_QED=y" >> $config_host_mak
74702f740136SJeff Codyfi
74712f740136SJeff Codyif test "$parallels" = "yes" ; then
74722f740136SJeff Cody  echo "CONFIG_PARALLELS=y" >> $config_host_mak
74732f740136SJeff Codyfi
74742f740136SJeff Codyif test "$sheepdog" = "yes" ; then
74752f740136SJeff Cody  echo "CONFIG_SHEEPDOG=y" >> $config_host_mak
74762f740136SJeff Codyfi
7477c9c8b88fSDavid CARLIERif test "$pty_h" = "yes" ; then
7478c9c8b88fSDavid CARLIER  echo "HAVE_PTY_H=y" >> $config_host_mak
7479c9c8b88fSDavid CARLIERfi
7480195588ccSDavid CARLIERif test "$have_mlockall" = "yes" ; then
7481195588ccSDavid CARLIER  echo "HAVE_MLOCKALL=y" >> $config_host_mak
7482195588ccSDavid CARLIERfi
7483adc28027SAlexander Bulekovif test "$fuzzing" = "yes" ; then
7484086d5f75SPaolo Bonzini  QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
7485adc28027SAlexander Bulekovfi
74862f740136SJeff Cody
748740e8c6f4SAlex Bennéeif test "$plugins" = "yes" ; then
748840e8c6f4SAlex Bennée    echo "CONFIG_PLUGIN=y" >> $config_host_mak
748940e8c6f4SAlex Bennée    LIBS="-ldl $LIBS"
749026fffe29SEmilio G. Cota    # Copy the export object list to the build dir
749126fffe29SEmilio G. Cota    if test "$ld_dynamic_list" = "yes" ; then
749226fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
749326fffe29SEmilio G. Cota	ld_symbols=qemu-plugins-ld.symbols
749426fffe29SEmilio G. Cota	cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
749526fffe29SEmilio G. Cota    elif test "$ld_exported_symbols_list" = "yes" ; then
749626fffe29SEmilio G. Cota	echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak
749726fffe29SEmilio G. Cota	ld64_symbols=qemu-plugins-ld64.symbols
749826fffe29SEmilio G. Cota	echo "# Automatically generated by configure - do not modify" > $ld64_symbols
749926fffe29SEmilio G. Cota	grep 'qemu_' "$source_path/plugins/qemu-plugins.symbols" | sed 's/;//g' | \
750026fffe29SEmilio G. Cota	    sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols
750126fffe29SEmilio G. Cota    else
750226fffe29SEmilio G. Cota	error_exit \
750326fffe29SEmilio G. Cota	    "If \$plugins=yes, either \$ld_dynamic_list or " \
750426fffe29SEmilio G. Cota	    "\$ld_exported_symbols_list should have been set to 'yes'."
750526fffe29SEmilio G. Cota    fi
750640e8c6f4SAlex Bennéefi
750740e8c6f4SAlex Bennée
7508f48e590aSAlex Bennéeif test -n "$gdb_bin" ; then
7509f48e590aSAlex Bennée    echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
7510f48e590aSAlex Bennéefi
7511f48e590aSAlex Bennée
751254e7aac0SAlexey Krasikovif test "$secret_keyring" = "yes" ; then
751354e7aac0SAlexey Krasikov  echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
751492500362SAlexey Krasikov  if test "$have_keyutils" = "yes" ; then
751592500362SAlexey Krasikov    echo "CONFIG_TEST_SECRET_KEYRING=y" >> $config_host_mak
751692500362SAlexey Krasikov  fi
751754e7aac0SAlexey Krasikovfi
751854e7aac0SAlexey Krasikov
75195b5e3037SPaolo Bonziniif test "$tcg_interpreter" = "yes"; then
752025211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
75215b5e3037SPaolo Bonzinielif test "$ARCH" = "sparc64" ; then
752225211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/sparc $QEMU_INCLUDES"
75235b5e3037SPaolo Bonzinielif test "$ARCH" = "s390x" ; then
752425211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/s390 $QEMU_INCLUDES"
7525e633a5c6SEric Blakeelif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
752625211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/i386 $QEMU_INCLUDES"
752740d964b5SRichard Hendersonelif test "$ARCH" = "ppc64" ; then
752825211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/ppc $QEMU_INCLUDES"
7529e633a5c6SEric Blakeelif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
753025211446SPaolo Bonzini  QEMU_INCLUDES="-I${source_path}/tcg/riscv $QEMU_INCLUDES"
75315b5e3037SPaolo Bonzinielse
753225211446SPaolo Bonzini  QEMU_INCLUDES="-iquote ${source_path}/tcg/${ARCH} $QEMU_INCLUDES"
75335b5e3037SPaolo Bonzinifi
75345b5e3037SPaolo Bonzini
753598ec69acSJuan Quintelaecho "ROMS=$roms" >> $config_host_mak
7536804edf29SJuan Quintelaecho "MAKE=$make" >> $config_host_mak
7537804edf29SJuan Quintelaecho "INSTALL=$install" >> $config_host_mak
75381901cb14SBradecho "INSTALL_DIR=$install -d -m 0755" >> $config_host_mak
75391901cb14SBradecho "INSTALL_DATA=$install -c -m 0644" >> $config_host_mak
75401901cb14SBradecho "INSTALL_PROG=$install -c -m 0755" >> $config_host_mak
754121655882SPaolo Bonziniecho "INSTALL_LIB=$install -c -m 0644" >> $config_host_mak
7542c886edfbSBlue Swirlecho "PYTHON=$python" >> $config_host_mak
75432eb054c2SPeter Maydellecho "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
754439d87c8cSAlex Bennéeecho "GENISOIMAGE=$genisoimage" >> $config_host_mak
7545a5665051SPaolo Bonziniecho "MESON=$meson" >> $config_host_mak
7546804edf29SJuan Quintelaecho "CC=$cc" >> $config_host_mak
7547a31a8642SMichael S. Tsirkinif $iasl -h > /dev/null 2>&1; then
7548859aef02SPaolo Bonzini  echo "CONFIG_IASL=$iasl" >> $config_host_mak
7549a31a8642SMichael S. Tsirkinfi
755083f73fceSTomoki Sekiyamaecho "CXX=$cxx" >> $config_host_mak
75513c4a4d0dSPeter Maydellecho "OBJCC=$objcc" >> $config_host_mak
7552804edf29SJuan Quintelaecho "AR=$ar" >> $config_host_mak
755345d285abSPeter Maydellecho "ARFLAGS=$ARFLAGS" >> $config_host_mak
7554cdbd727cSRichard Hendersonecho "AS=$as" >> $config_host_mak
75555f6f0e27SRichard Hendersonecho "CCAS=$ccas" >> $config_host_mak
75563dd46c78SBlue Swirlecho "CPP=$cpp" >> $config_host_mak
7557804edf29SJuan Quintelaecho "OBJCOPY=$objcopy" >> $config_host_mak
7558804edf29SJuan Quintelaecho "LD=$ld" >> $config_host_mak
75599f81aeb5SAlistair Francisecho "RANLIB=$ranlib" >> $config_host_mak
75604852ee95SStefan Weilecho "NM=$nm" >> $config_host_mak
7561daa79d9aSAlex Bennéeecho "PKG_CONFIG=$pkg_config_exe" >> $config_host_mak
75629fe6de94SBlue Swirlecho "WINDRES=$windres" >> $config_host_mak
7563e2a2ed06SJuan Quintelaecho "CFLAGS=$CFLAGS" >> $config_host_mak
7564086d5f75SPaolo Bonziniecho "CXXFLAGS=$CXXFLAGS" >> $config_host_mak
756546eef33bSBradecho "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
7566a558ee17SJuan Quintelaecho "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
756711cde1c8SBruno Dominguezecho "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
7568f9728943SPaolo Bonziniecho "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
7569a81df1b6SPaolo Bonziniecho "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
7570a81df1b6SPaolo Bonziniecho "GLIB_LIBS=$glib_libs" >> $config_host_mak
7571e39f0062SPaolo Bonziniif test "$sparse" = "yes" ; then
7572968b4db3SPaolo Bonzini  echo "SPARSE_CFLAGS = -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-non-pointer-null" >> $config_host_mak
7573e39f0062SPaolo Bonzinifi
75748a99e9a3SPhilippe Mathieu-Daudéecho "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
7575db5adeaaSPaolo Bonziniecho "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
75766969ec6cSJames Clarkeecho "LD_REL_FLAGS=$LD_REL_FLAGS" >> $config_host_mak
7577e57218b6SPeter Maydellecho "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
757873da375eSJuan Quintelaecho "LIBS+=$LIBS" >> $config_host_mak
75793e2e0e6bSJuan Quintelaecho "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
7580409437e1SDaniel P. Berrangeecho "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
7581804edf29SJuan Quintelaecho "EXESUF=$EXESUF" >> $config_host_mak
7582484e2cc7SPaolo Bonziniecho "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
758317969268SFam Zhengecho "LDFLAGS_SHARED=$LDFLAGS_SHARED" >> $config_host_mak
7584f15bff25SPaolo Bonziniecho "LIBS_QGA=$libs_qga" >> $config_host_mak
758590246037SDaniel P. Berrangeecho "TASN1_LIBS=$tasn1_libs" >> $config_host_mak
758690246037SDaniel P. Berrangeecho "TASN1_CFLAGS=$tasn1_cflags" >> $config_host_mak
758794dd53c5SGerd Hoffmannecho "POD2MAN=$POD2MAN" >> $config_host_mak
75881d728c39SBlue Swirlif test "$gcov" = "yes" ; then
75891d728c39SBlue Swirl  echo "CONFIG_GCOV=y" >> $config_host_mak
75901d728c39SBlue Swirlfi
7591804edf29SJuan Quintela
75923efac6ebSTomáš Golembiovskýif test "$libudev" != "no"; then
75933efac6ebSTomáš Golembiovský    echo "CONFIG_LIBUDEV=y" >> $config_host_mak
75943efac6ebSTomáš Golembiovský    echo "LIBUDEV_LIBS=$libudev_libs" >> $config_host_mak
75953efac6ebSTomáš Golembiovskýfi
7596adc28027SAlexander Bulekovif test "$fuzzing" != "no"; then
7597adc28027SAlexander Bulekov    echo "CONFIG_FUZZ=y" >> $config_host_mak
7598adc28027SAlexander Bulekovfi
75993efac6ebSTomáš Golembiovský
760005dfa22bSPhilippe Mathieu-Daudéif test "$edk2_blobs" = "yes" ; then
760105dfa22bSPhilippe Mathieu-Daudé  echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
760205dfa22bSPhilippe Mathieu-Daudéfi
760305dfa22bSPhilippe Mathieu-Daudé
7604b767d257SMarek Marczykowski-Góreckiif test "$rng_none" = "yes"; then
7605b767d257SMarek Marczykowski-Górecki  echo "CONFIG_RNG_NONE=y" >> $config_host_mak
7606b767d257SMarek Marczykowski-Góreckifi
7607b767d257SMarek Marczykowski-Górecki
76086efd7517SPeter Maydell# use included Linux headers
76096efd7517SPeter Maydellif test "$linux" = "yes" ; then
7610a307beb6SAndreas Färber  mkdir -p linux-headers
76116efd7517SPeter Maydell  case "$cpu" in
7612c72b26ecSRichard Henderson  i386|x86_64|x32)
761308312a63SPeter Maydell    linux_arch=x86
76146efd7517SPeter Maydell    ;;
7615f8378accSRichard Henderson  ppc|ppc64|ppc64le)
761608312a63SPeter Maydell    linux_arch=powerpc
76176efd7517SPeter Maydell    ;;
76186efd7517SPeter Maydell  s390x)
761908312a63SPeter Maydell    linux_arch=s390
762008312a63SPeter Maydell    ;;
76211f080313SClaudio Fontana  aarch64)
76221f080313SClaudio Fontana    linux_arch=arm64
76231f080313SClaudio Fontana    ;;
7624222e7d11SSanjay Lal  mips64)
7625222e7d11SSanjay Lal    linux_arch=mips
7626222e7d11SSanjay Lal    ;;
762708312a63SPeter Maydell  *)
762808312a63SPeter Maydell    # For most CPUs the kernel architecture name and QEMU CPU name match.
762908312a63SPeter Maydell    linux_arch="$cpu"
76306efd7517SPeter Maydell    ;;
76316efd7517SPeter Maydell  esac
763208312a63SPeter Maydell    # For non-KVM architectures we will not have asm headers
763308312a63SPeter Maydell    if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
763408312a63SPeter Maydell      symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
763508312a63SPeter Maydell    fi
76366efd7517SPeter Maydellfi
76376efd7517SPeter Maydell
763897a847bcSbellardfor target in $target_list; do
763997a847bcSbellardtarget_dir="$target"
764025be210fSJuan Quintelaconfig_target_mak=$target_dir/config-target.mak
764189138857SStefan Weiltarget_name=$(echo $target | cut -d '-' -f 1)
764252bf9771Stony.nguyen@bt.comtarget_aligned_only="no"
764352bf9771Stony.nguyen@bt.comcase "$target_name" in
764452bf9771Stony.nguyen@bt.com  alpha|hppa|mips64el|mips64|mipsel|mips|mipsn32|mipsn32el|sh4|sh4eb|sparc|sparc64|sparc32plus|xtensa|xtensaeb)
764552bf9771Stony.nguyen@bt.com  target_aligned_only="yes"
764652bf9771Stony.nguyen@bt.com  ;;
764752bf9771Stony.nguyen@bt.comesac
764897a847bcSbellardtarget_bigendian="no"
7649c1799a84SPaolo Bonzinicase "$target_name" in
7650a69dc537SThomas Huth  armeb|aarch64_be|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or1k|ppc|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb)
765152bf9771Stony.nguyen@bt.com  target_bigendian="yes"
7652ea2d6a39SJuan Quintela  ;;
7653ea2d6a39SJuan Quintelaesac
765497a847bcSbellardtarget_softmmu="no"
7655997344f3Sbellardtarget_user_only="no"
7656831b7825Sthstarget_linux_user="no"
765784778508Sblueswir1target_bsd_user="no"
76589e407a85Spbrookcase "$target" in
7659c1799a84SPaolo Bonzini  ${target_name}-softmmu)
76609e407a85Spbrook    target_softmmu="yes"
76619e407a85Spbrook    ;;
7662c1799a84SPaolo Bonzini  ${target_name}-linux-user)
76639e407a85Spbrook    target_user_only="yes"
76649e407a85Spbrook    target_linux_user="yes"
76659e407a85Spbrook    ;;
7666c1799a84SPaolo Bonzini  ${target_name}-bsd-user)
766784778508Sblueswir1    target_user_only="yes"
766884778508Sblueswir1    target_bsd_user="yes"
766984778508Sblueswir1    ;;
76709e407a85Spbrook  *)
767176ad07a4SPeter Maydell    error_exit "Target '$target' not recognised"
76729e407a85Spbrook    exit 1
76739e407a85Spbrook    ;;
76749e407a85Spbrookesac
7675831b7825Sths
767697a847bcSbellardmkdir -p $target_dir
767725be210fSJuan Quintelaecho "# Automatically generated by configure - do not modify" > $config_target_mak
767897a847bcSbellard
7679e5fe0c52Spbrookbflt="no"
7680ca759f9eSAlex Bennéemttcg="no"
768189138857SStefan Weilinterp_prefix1=$(echo "$interp_prefix" | sed "s/%M/$target_name/g")
768256aebc89Spbrookgdb_xml_files=""
76837ba1e619Saliguori
7684c1799a84SPaolo BonziniTARGET_ARCH="$target_name"
76856acff7daSJuan QuintelaTARGET_BASE_ARCH=""
7686e6e91b9cSJuan QuintelaTARGET_ABI_DIR=""
76873a30446aSMarc-André LureauTARGET_SYSTBL_ABI=""
76883a30446aSMarc-André LureauTARGET_SYSTBL=""
7689e73aae67SJuan Quintela
7690c1799a84SPaolo Bonzinicase "$target_name" in
76912408a527Saurel32  i386)
76920a7fa00aSEmilio G. Cota    mttcg="yes"
76937b0f97baSDoug Gale	gdb_xml_files="i386-32bit.xml"
769428988117SLaurent Vivier    TARGET_SYSTBL_ABI=i386
76953a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_32.tbl
76962408a527Saurel32  ;;
76972408a527Saurel32  x86_64)
76986acff7daSJuan Quintela    TARGET_BASE_ARCH=i386
76998d62f35aSLaurent Vivier    TARGET_SYSTBL_ABI=common,64
77003a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_64.tbl
77010a7fa00aSEmilio G. Cota    mttcg="yes"
77027b0f97baSDoug Gale    gdb_xml_files="i386-64bit.xml"
77032408a527Saurel32  ;;
77042408a527Saurel32  alpha)
77055ee4f3c2SRichard Henderson    mttcg="yes"
77066116aea9SLaurent Vivier    TARGET_SYSTBL_ABI=common
77072408a527Saurel32  ;;
77082408a527Saurel32  arm|armeb)
7709b498c8a0SJuan Quintela    TARGET_ARCH=arm
77105bcb4986SLaurent Vivier    TARGET_SYSTBL_ABI=common,oabi
7711e5fe0c52Spbrook    bflt="yes"
7712ca759f9eSAlex Bennée    mttcg="yes"
7713c888f7e0SPeter Maydell    gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml arm-m-profile.xml"
77142408a527Saurel32  ;;
7715722dd7beSMichael Weiser  aarch64|aarch64_be)
7716722dd7beSMichael Weiser    TARGET_ARCH=aarch64
77176a49fa95SAlexander Graf    TARGET_BASE_ARCH=arm
77186a49fa95SAlexander Graf    bflt="yes"
7719ca759f9eSAlex Bennée    mttcg="yes"
7720c888f7e0SPeter 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"
77216a49fa95SAlexander Graf  ;;
772242f3ff00SMichael Rolnik  avr)
772342f3ff00SMichael Rolnik    gdb_xml_files="avr-cpu.xml"
772442f3ff00SMichael Rolnik    target_compiler=$cross_cc_avr
772542f3ff00SMichael Rolnik  ;;
77262408a527Saurel32  cris)
77272408a527Saurel32  ;;
772861766fe9SRichard Henderson  hppa)
77297b93dab5SRichard Henderson    mttcg="yes"
77309566f4c6SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
773161766fe9SRichard Henderson  ;;
7732613a22c9SMichael Walle  lm32)
7733613a22c9SMichael Walle  ;;
77342408a527Saurel32  m68k)
77350938cda5Saurel32    bflt="yes"
7736a976ed3fSKONRAD Frederic    gdb_xml_files="cf-core.xml cf-fp.xml m68k-core.xml m68k-fp.xml"
77375b85cae9SLaurent Vivier    TARGET_SYSTBL_ABI=common
77382408a527Saurel32  ;;
7739877fdc12SEdgar E. Iglesias  microblaze|microblazeel)
7740877fdc12SEdgar E. Iglesias    TARGET_ARCH=microblaze
7741ddf0c4cdSLaurent Vivier    TARGET_SYSTBL_ABI=common
7742d449561bSEdgar E. Iglesias    mttcg="yes"
774372b675caSEdgar E. Iglesias    bflt="yes"
7744be73ef64SEdgar E. Iglesias    echo "TARGET_ABI32=y" >> $config_target_mak
774572b675caSEdgar E. Iglesias  ;;
77462408a527Saurel32  mips|mipsel)
77470454728cSAleksandar Markovic    mttcg="yes"
7748b498c8a0SJuan Quintela    TARGET_ARCH=mips
774925be210fSJuan Quintela    echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak
7750c59716fcSLaurent Vivier    TARGET_SYSTBL_ABI=o32
77513a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_o32.tbl
77522408a527Saurel32  ;;
77532408a527Saurel32  mipsn32|mipsn32el)
77540454728cSAleksandar Markovic    mttcg="yes"
7755597e2cecSRichard Henderson    TARGET_ARCH=mips64
77566acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
775725be210fSJuan Quintela    echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak
7758597e2cecSRichard Henderson    echo "TARGET_ABI32=y" >> $config_target_mak
7759686a0fe4SLaurent Vivier    TARGET_SYSTBL_ABI=n32
77603a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_n32.tbl
77612408a527Saurel32  ;;
77622408a527Saurel32  mips64|mips64el)
7763a092a955SAlex Bennée    mttcg="no"
7764b498c8a0SJuan Quintela    TARGET_ARCH=mips64
77656acff7daSJuan Quintela    TARGET_BASE_ARCH=mips
776625be210fSJuan Quintela    echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak
7767686a0fe4SLaurent Vivier    TARGET_SYSTBL_ABI=n64
77683a30446aSMarc-André Lureau    TARGET_SYSTBL=syscall_n64.tbl
77692408a527Saurel32  ;;
7770d15a9c23SAnthony Green  moxie)
7771d15a9c23SAnthony Green  ;;
7772e671711cSMarek Vasut  nios2)
7773e671711cSMarek Vasut  ;;
77744a09d0bbSRichard Henderson  or1k)
7775e67db06eSJia Liu    TARGET_ARCH=openrisc
7776e67db06eSJia Liu    TARGET_BASE_ARCH=openrisc
7777e67db06eSJia Liu  ;;
77782408a527Saurel32  ppc)
7779c8b3532dSaurel32    gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
778076a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,32
77812408a527Saurel32  ;;
77822408a527Saurel32  ppc64)
77836acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7784e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
778576a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,64
7786f0b0685dSNikunj A Dadhania    mttcg=yes
77871438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
77882408a527Saurel32  ;;
77899c35126cSDoug Kwan  ppc64le)
77909c35126cSDoug Kwan    TARGET_ARCH=ppc64
77919c35126cSDoug Kwan    TARGET_BASE_ARCH=ppc
77929c35126cSDoug Kwan    TARGET_ABI_DIR=ppc
779376a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,64
7794f0b0685dSNikunj A Dadhania    mttcg=yes
77951438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
77969c35126cSDoug Kwan  ;;
77972408a527Saurel32  ppc64abi32)
7798b498c8a0SJuan Quintela    TARGET_ARCH=ppc64
77996acff7daSJuan Quintela    TARGET_BASE_ARCH=ppc
7800e6e91b9cSJuan Quintela    TARGET_ABI_DIR=ppc
780176a691f1SLaurent Vivier    TARGET_SYSTBL_ABI=common,nospu,32
780225be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
78031438eff3SAnton Blanchard    gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml"
78042408a527Saurel32  ;;
780525fa194bSMichael Clark  riscv32)
780625fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
780725fa194bSMichael Clark    TARGET_ABI_DIR=riscv
780825fa194bSMichael Clark    mttcg=yes
7809ae4a70c0SKeith Packard    gdb_xml_files="riscv-32bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-32bit-csr.xml riscv-32bit-virtual.xml"
781025fa194bSMichael Clark  ;;
781125fa194bSMichael Clark  riscv64)
781225fa194bSMichael Clark    TARGET_BASE_ARCH=riscv
781325fa194bSMichael Clark    TARGET_ABI_DIR=riscv
781425fa194bSMichael Clark    mttcg=yes
7815ae4a70c0SKeith Packard    gdb_xml_files="riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-csr.xml riscv-64bit-virtual.xml"
781625fa194bSMichael Clark  ;;
7817c8c35e5fSYoshinori Sato  rx)
7818c8c35e5fSYoshinori Sato    TARGET_ARCH=rx
7819c8c35e5fSYoshinori Sato    bflt="yes"
7820c8c35e5fSYoshinori Sato    target_compiler=$cross_cc_rx
7821c8c35e5fSYoshinori Sato    gdb_xml_files="rx-core.xml"
7822c8c35e5fSYoshinori Sato  ;;
78232408a527Saurel32  sh4|sh4eb)
7824b498c8a0SJuan Quintela    TARGET_ARCH=sh4
7825d0c832f6SLaurent Vivier    TARGET_SYSTBL_ABI=common
78264dbed897Spbrook    bflt="yes"
78272408a527Saurel32  ;;
78282408a527Saurel32  sparc)
7829bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
78302408a527Saurel32  ;;
78312408a527Saurel32  sparc64)
78326acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7833bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,64
78342408a527Saurel32  ;;
78352408a527Saurel32  sparc32plus)
7836b498c8a0SJuan Quintela    TARGET_ARCH=sparc64
78376acff7daSJuan Quintela    TARGET_BASE_ARCH=sparc
7838e6e91b9cSJuan Quintela    TARGET_ABI_DIR=sparc
7839bb0cdc03SLaurent Vivier    TARGET_SYSTBL_ABI=common,32
784025be210fSJuan Quintela    echo "TARGET_ABI32=y" >> $config_target_mak
78412408a527Saurel32  ;;
784224e804ecSAlexander Graf  s390x)
7843318f371dSLaurent Vivier    TARGET_SYSTBL_ABI=common,64
784463685bc4SDavid Hildenbrand    mttcg=yes
784586158a2aSChristian 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"
784624e804ecSAlexander Graf  ;;
7847444e06b1SChen Gang  tilegx)
7848444e06b1SChen Gang  ;;
78495ecaa4edSPeter Crosthwaite  tricore)
78505ecaa4edSPeter Crosthwaite  ;;
7851d2fbca94SGuan Xuetao  unicore32)
7852d2fbca94SGuan Xuetao  ;;
7853cfa550c6SMax Filippov  xtensa|xtensaeb)
7854cfa550c6SMax Filippov    TARGET_ARCH=xtensa
7855a4a93592SLaurent Vivier    TARGET_SYSTBL_ABI=common
785602e33e9fSMax Filippov    bflt="yes"
78579fb40342SMax Filippov    mttcg="yes"
7858cfa550c6SMax Filippov  ;;
78592408a527Saurel32  *)
786076ad07a4SPeter Maydell    error_exit "Unsupported target CPU"
78612408a527Saurel32  ;;
78622408a527Saurel32esac
78635e8861a0SPaolo Bonzini# TARGET_BASE_ARCH needs to be defined after TARGET_ARCH
78645e8861a0SPaolo Bonziniif [ "$TARGET_BASE_ARCH" = "" ]; then
78655e8861a0SPaolo Bonzini  TARGET_BASE_ARCH=$TARGET_ARCH
78665e8861a0SPaolo Bonzinifi
78673a30446aSMarc-André Lureauif [ "$TARGET_SYSTBL_ABI" != "" ] && [ "$TARGET_SYSTBL" = "" ]; then
78683a30446aSMarc-André Lureau  TARGET_SYSTBL=syscall.tbl
78693a30446aSMarc-André Lureaufi
78705e8861a0SPaolo Bonzini
787199afc91dSDaniel P. Berrangeupper() {
787299afc91dSDaniel P. Berrange    echo "$@"| LC_ALL=C tr '[a-z]' '[A-Z]'
787399afc91dSDaniel P. Berrange}
787499afc91dSDaniel P. Berrange
787589138857SStefan Weiltarget_arch_name="$(upper $TARGET_ARCH)"
787625be210fSJuan Quintelaecho "TARGET_$target_arch_name=y" >> $config_target_mak
7877c1799a84SPaolo Bonziniecho "TARGET_NAME=$target_name" >> $config_target_mak
787825be210fSJuan Quintelaecho "TARGET_BASE_ARCH=$TARGET_BASE_ARCH" >> $config_target_mak
7879e6e91b9cSJuan Quintelaif [ "$TARGET_ABI_DIR" = "" ]; then
7880e6e91b9cSJuan Quintela  TARGET_ABI_DIR=$TARGET_ARCH
7881e6e91b9cSJuan Quintelafi
788225be210fSJuan Quintelaecho "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
7883adfc3e91SStacey Sonif [ "$HOST_VARIANT_DIR" != "" ]; then
7884adfc3e91SStacey Son    echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
7885adfc3e91SStacey Sonfi
78864d6a835dSLaurent Vivierif [ "$TARGET_SYSTBL_ABI" != "" ]; then
78874d6a835dSLaurent Vivier    echo "TARGET_SYSTBL_ABI=$TARGET_SYSTBL_ABI" >> $config_target_mak
78883a30446aSMarc-André Lureau    echo "TARGET_SYSTBL=$TARGET_SYSTBL" >> $config_target_mak
78894d6a835dSLaurent Vivierfi
78903b6b7550SPaolo Bonzini
78913b6b7550SPaolo Bonziniif supported_xen_target $target; then
789225be210fSJuan Quintela    echo "CONFIG_XEN=y" >> $config_target_mak
7893eb6fda0fSAnthony PERARD    if test "$xen_pci_passthrough" = yes; then
7894eb6fda0fSAnthony PERARD        echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
7895eb6fda0fSAnthony PERARD    fi
7896432d268cSJun Nakajimafi
78973b6b7550SPaolo Bonziniif supported_kvm_target $target; then
789825be210fSJuan Quintela    echo "CONFIG_KVM=y" >> $config_target_mak
7899c59249f9SJuan Quintelafi
79003b6b7550SPaolo Bonziniif supported_hax_target $target; then
7901b0cb0a66SVincent Palatin    echo "CONFIG_HAX=y" >> $config_target_mak
7902b0cb0a66SVincent Palatinfi
7903c97d6d2cSSergio Andres Gomez Del Realif supported_hvf_target $target; then
7904c97d6d2cSSergio Andres Gomez Del Real    echo "CONFIG_HVF=y" >> $config_target_mak
7905c97d6d2cSSergio Andres Gomez Del Realfi
7906d661d9a4SJustin Terry (VM)if supported_whpx_target $target; then
7907d661d9a4SJustin Terry (VM)    echo "CONFIG_WHPX=y" >> $config_target_mak
7908d661d9a4SJustin Terry (VM)fi
790952bf9771Stony.nguyen@bt.comif test "$target_aligned_only" = "yes" ; then
791052bf9771Stony.nguyen@bt.com  echo "TARGET_ALIGNED_ONLY=y" >> $config_target_mak
791152bf9771Stony.nguyen@bt.comfi
7912de83cd02Sbellardif test "$target_bigendian" = "yes" ; then
791325be210fSJuan Quintela  echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak
791497a847bcSbellardfi
791597a847bcSbellardif test "$target_softmmu" = "yes" ; then
791625be210fSJuan Quintela  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
7917ca759f9eSAlex Bennée  if test "$mttcg" = "yes" ; then
7918ca759f9eSAlex Bennée    echo "TARGET_SUPPORTS_MTTCG=y" >> $config_target_mak
7919ca759f9eSAlex Bennée  fi
7920de83cd02Sbellardfi
7921997344f3Sbellardif test "$target_user_only" = "yes" ; then
792225be210fSJuan Quintela  echo "CONFIG_USER_ONLY=y" >> $config_target_mak
7923a2c80be9SStefan Weil  echo "CONFIG_QEMU_INTERP_PREFIX=\"$interp_prefix1\"" >> $config_target_mak
79242898503cSPaolo Bonzini  symlink "../qemu-$target_name" "$target_dir/qemu-$target_name"
79252898503cSPaolo Bonzinielse
79262898503cSPaolo Bonzini  symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name"
7927997344f3Sbellardfi
7928831b7825Sthsif test "$target_linux_user" = "yes" ; then
792925be210fSJuan Quintela  echo "CONFIG_LINUX_USER=y" >> $config_target_mak
7930831b7825Sthsfi
793156aebc89Spbrooklist=""
793256aebc89Spbrookif test ! -z "$gdb_xml_files" ; then
793356aebc89Spbrook  for x in $gdb_xml_files; do
7934c9322ab5SMarc-André Lureau    list="$list gdb-xml/$x"
793556aebc89Spbrook  done
793625be210fSJuan Quintela  echo "TARGET_XML_FILES=$list" >> $config_target_mak
79373d0f1517SJuan Quintelafi
7938de83cd02Sbellard
7939e633a5c6SEric Blakeif test "$target_user_only" = "yes" && test "$bflt" = "yes"; then
794025be210fSJuan Quintela  echo "TARGET_HAS_BFLT=y" >> $config_target_mak
7941e5fe0c52Spbrookfi
794284778508Sblueswir1if test "$target_bsd_user" = "yes" ; then
794325be210fSJuan Quintela  echo "CONFIG_BSD_USER=y" >> $config_target_mak
794484778508Sblueswir1fi
79455b0753e0Sbellard
7946d75402b5SAlex Bennée
7947db5adeaaSPaolo Bonzini# generate QEMU_CFLAGS/QEMU_LDFLAGS for targets
7948fa282484SJuan Quintela
7949c765fcacSPeter Crosthwaitedisas_config() {
7950c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> $config_target_mak
7951c765fcacSPeter Crosthwaite  echo "CONFIG_${1}_DIS=y" >> config-all-disas.mak
7952c765fcacSPeter Crosthwaite}
7953c765fcacSPeter Crosthwaite
795464656024SJuan Quintelafor i in $ARCH $TARGET_BASE_ARCH ; do
795564656024SJuan Quintela  case "$i" in
795664656024SJuan Quintela  alpha)
7957c765fcacSPeter Crosthwaite    disas_config "ALPHA"
795864656024SJuan Quintela  ;;
795982295d8aSRichard Henderson  aarch64)
796082295d8aSRichard Henderson    if test -n "${cxx}"; then
7961c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
796282295d8aSRichard Henderson    fi
796382295d8aSRichard Henderson  ;;
796464656024SJuan Quintela  arm)
7965c765fcacSPeter Crosthwaite    disas_config "ARM"
7966999b53ecSClaudio Fontana    if test -n "${cxx}"; then
7967c765fcacSPeter Crosthwaite      disas_config "ARM_A64"
7968999b53ecSClaudio Fontana    fi
796964656024SJuan Quintela  ;;
797042f3ff00SMichael Rolnik  avr)
797142f3ff00SMichael Rolnik    disas_config "AVR"
797242f3ff00SMichael Rolnik  ;;
797364656024SJuan Quintela  cris)
7974c765fcacSPeter Crosthwaite    disas_config "CRIS"
797564656024SJuan Quintela  ;;
7976429b31a2SRichard Henderson  hppa)
7977429b31a2SRichard Henderson    disas_config "HPPA"
7978429b31a2SRichard Henderson  ;;
7979c72b26ecSRichard Henderson  i386|x86_64|x32)
7980c765fcacSPeter Crosthwaite    disas_config "I386"
798164656024SJuan Quintela  ;;
798279368f49SMichael Walle  lm32)
7983c765fcacSPeter Crosthwaite    disas_config "LM32"
798479368f49SMichael Walle  ;;
798564656024SJuan Quintela  m68k)
7986c765fcacSPeter Crosthwaite    disas_config "M68K"
798764656024SJuan Quintela  ;;
7988877fdc12SEdgar E. Iglesias  microblaze*)
7989c765fcacSPeter Crosthwaite    disas_config "MICROBLAZE"
799064656024SJuan Quintela  ;;
799164656024SJuan Quintela  mips*)
7992c765fcacSPeter Crosthwaite    disas_config "MIPS"
799389a955e8SAleksandar Markovic    if test -n "${cxx}"; then
799489a955e8SAleksandar Markovic      disas_config "NANOMIPS"
799589a955e8SAleksandar Markovic    fi
799664656024SJuan Quintela  ;;
7997d15a9c23SAnthony Green  moxie*)
7998c765fcacSPeter Crosthwaite    disas_config "MOXIE"
7999d15a9c23SAnthony Green  ;;
8000e671711cSMarek Vasut  nios2)
8001e671711cSMarek Vasut    disas_config "NIOS2"
8002e671711cSMarek Vasut  ;;
80034a09d0bbSRichard Henderson  or1k)
8004c765fcacSPeter Crosthwaite    disas_config "OPENRISC"
8005e67db06eSJia Liu  ;;
800664656024SJuan Quintela  ppc*)
8007c765fcacSPeter Crosthwaite    disas_config "PPC"
800864656024SJuan Quintela  ;;
8009c4f80543SAlistair Francis  riscv*)
801025fa194bSMichael Clark    disas_config "RISCV"
801125fa194bSMichael Clark  ;;
8012c8c35e5fSYoshinori Sato  rx)
8013c8c35e5fSYoshinori Sato    disas_config "RX"
8014c8c35e5fSYoshinori Sato  ;;
801524e804ecSAlexander Graf  s390*)
8016c765fcacSPeter Crosthwaite    disas_config "S390"
801764656024SJuan Quintela  ;;
801864656024SJuan Quintela  sh4)
8019c765fcacSPeter Crosthwaite    disas_config "SH4"
802064656024SJuan Quintela  ;;
802164656024SJuan Quintela  sparc*)
8022c765fcacSPeter Crosthwaite    disas_config "SPARC"
802364656024SJuan Quintela  ;;
8024cfa550c6SMax Filippov  xtensa*)
8025c765fcacSPeter Crosthwaite    disas_config "XTENSA"
8026cfa550c6SMax Filippov  ;;
802764656024SJuan Quintela  esac
802864656024SJuan Quinteladone
80299195b2c2SStefan Weilif test "$tcg_interpreter" = "yes" ; then
8030c765fcacSPeter Crosthwaite  disas_config "TCI"
80319195b2c2SStefan Weilfi
803264656024SJuan Quintela
803397a847bcSbellarddone # for target in $targets
80347d13299dSbellard
8035e3971d61SPhilippe Mathieu-Daudéif [ "$fdt" = "git" ]; then
8036859aef02SPaolo Bonzini  subdirs="$subdirs dtc"
8037a540f158SPeter Crosthwaitefi
8038e219c499SRichard Hendersonif [ "$capstone" = "git" -o "$capstone" = "internal" ]; then
8039859aef02SPaolo Bonzini  subdirs="$subdirs capstone"
8040e219c499SRichard Hendersonfi
8041859aef02SPaolo Bonziniecho "SUBDIRS=$subdirs" >> $config_host_mak
8042e219c499SRichard Hendersonif test -n "$LIBCAPSTONE"; then
8043e219c499SRichard Henderson  echo "LIBCAPSTONE=$LIBCAPSTONE" >> $config_host_mak
8044e219c499SRichard Hendersonfi
8045a540f158SPeter Crosthwaite
8046a99d57bbSWanlong Gaoif test "$numa" = "yes"; then
8047a99d57bbSWanlong Gao  echo "CONFIG_NUMA=y" >> $config_host_mak
8048ab318051SMarc-André Lureau  echo "NUMA_LIBS=$numa_libs" >> $config_host_mak
8049a99d57bbSWanlong Gaofi
8050a99d57bbSWanlong Gao
8051fd0e6053SJohn Snowif test "$ccache_cpp2" = "yes"; then
8052fd0e6053SJohn Snow  echo "export CCACHE_CPP2=y" >> $config_host_mak
8053fd0e6053SJohn Snowfi
8054fd0e6053SJohn Snow
80551e4f6065SDaniele Buonoif test "$safe_stack" = "yes"; then
80561e4f6065SDaniele Buono  echo "CONFIG_SAFESTACK=y" >> $config_host_mak
80571e4f6065SDaniele Buonofi
80581e4f6065SDaniele Buono
8059e29e5c6eSPeter Maydell# If we're using a separate build tree, set it up now.
8060e29e5c6eSPeter Maydell# DIRS are directories which we simply mkdir in the build tree;
8061e29e5c6eSPeter Maydell# LINKS are things to symlink back into the source tree
8062e29e5c6eSPeter Maydell# (these can be both files and directories).
8063e29e5c6eSPeter Maydell# Caution: do not add files or directories here using wildcards. This
8064e29e5c6eSPeter Maydell# will result in problems later if a new file matching the wildcard is
8065e29e5c6eSPeter Maydell# added to the source tree -- nothing will cause configure to be rerun
8066e29e5c6eSPeter Maydell# so the build tree will be missing the link back to the new file, and
8067e29e5c6eSPeter Maydell# tests might fail. Prefer to keep the relevant files in their own
8068e29e5c6eSPeter Maydell# directory and symlink the directory instead.
80691cf4323eSThomas HuthDIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
80701cf4323eSThomas HuthDIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
8071b855f8d1SPaolo BonziniDIRS="$DIRS docs docs/interop fsdev scsi"
8072744a928cSAlexey KardashevskiyDIRS="$DIRS pc-bios/optionrom pc-bios/s390-ccw"
80738db2a4fdSGerd HoffmannDIRS="$DIRS roms/seabios"
80742038f8c8SPaolo BonziniLINKS="Makefile"
8075e8f3bd71SMarc-André LureauLINKS="$LINKS tests/tcg/lm32/Makefile"
80763941996bSPaolo BonziniLINKS="$LINKS tests/tcg/Makefile.target"
8077ddcf607fSGerd HoffmannLINKS="$LINKS pc-bios/optionrom/Makefile"
8078e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/s390-ccw/Makefile"
80798db2a4fdSGerd HoffmannLINKS="$LINKS roms/seabios/Makefile"
8080e29e5c6eSPeter MaydellLINKS="$LINKS pc-bios/qemu-icon.bmp"
8081e29e5c6eSPeter MaydellLINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
808239950353SPeter MaydellLINKS="$LINKS tests/acceptance tests/data"
808339950353SPeter MaydellLINKS="$LINKS tests/qemu-iotests/check"
80848f8fd9edSCleber RosaLINKS="$LINKS python"
8085753d11f2SRichard Hendersonfor bios_file in \
8086753d11f2SRichard Henderson    $source_path/pc-bios/*.bin \
80873a631b8eSBin Meng    $source_path/pc-bios/*.elf \
8088225a9ab8SAlexey Kardashevskiy    $source_path/pc-bios/*.lid \
8089753d11f2SRichard Henderson    $source_path/pc-bios/*.rom \
8090753d11f2SRichard Henderson    $source_path/pc-bios/*.dtb \
8091e89e33e1SDominik Dingel    $source_path/pc-bios/*.img \
8092753d11f2SRichard Henderson    $source_path/pc-bios/openbios-* \
80934e73c781SAlexander Graf    $source_path/pc-bios/u-boot.* \
809426ce90fdSLaszlo Ersek    $source_path/pc-bios/edk2-*.fd.bz2 \
8095753d11f2SRichard Henderson    $source_path/pc-bios/palcode-*
8096753d11f2SRichard Hendersondo
8097e29e5c6eSPeter Maydell    LINKS="$LINKS pc-bios/$(basename $bios_file)"
80987ea78b74SJan Kiszkadone
8099d1807a4fSPaolo Bonzinimkdir -p $DIRS
8100e29e5c6eSPeter Maydellfor f in $LINKS ; do
8101cab00a5aSMichael S. Tsirkin    if [ -e "$source_path/$f" ] && [ "$pwd_is_source_path" != "y" ]; then
8102f9245e10SPeter Maydell        symlink "$source_path/$f" "$f"
8103f9245e10SPeter Maydell    fi
81047d13299dSbellarddone
81051ad2134fSPaul Brook
81062038f8c8SPaolo Bonzini(for i in $cross_cc_vars; do
81072038f8c8SPaolo Bonzini  export $i
81082038f8c8SPaolo Bonzinidone
8109afc3a8f9SAlex Bennéeexport target_list source_path use_containers
81102038f8c8SPaolo Bonzini$source_path/tests/tcg/configure.sh)
81112038f8c8SPaolo Bonzini
8112c34ebfdcSAnthony Liguori# temporary config to build submodules
81138db2a4fdSGerd Hoffmannfor rom in seabios; do
8114c34ebfdcSAnthony Liguori    config_mak=roms/$rom/config.mak
811537116c89SStefan Weil    echo "# Automatically generated by configure - do not modify" > $config_mak
8116c34ebfdcSAnthony Liguori    echo "SRC_PATH=$source_path/roms/$rom" >> $config_mak
8117cdbd727cSRichard Henderson    echo "AS=$as" >> $config_mak
81185f6f0e27SRichard Henderson    echo "CCAS=$ccas" >> $config_mak
8119c34ebfdcSAnthony Liguori    echo "CC=$cc" >> $config_mak
8120c34ebfdcSAnthony Liguori    echo "BCC=bcc" >> $config_mak
81213dd46c78SBlue Swirl    echo "CPP=$cpp" >> $config_mak
8122c34ebfdcSAnthony Liguori    echo "OBJCOPY=objcopy" >> $config_mak
8123a31a8642SMichael S. Tsirkin    echo "IASL=$iasl" >> $config_mak
8124c34ebfdcSAnthony Liguori    echo "LD=$ld" >> $config_mak
81259f81aeb5SAlistair Francis    echo "RANLIB=$ranlib" >> $config_mak
8126c34ebfdcSAnthony Liguoridone
8127c34ebfdcSAnthony Liguori
812876c7560aSMax Reitz# set up qemu-iotests in this build directory
812976c7560aSMax Reitziotests_common_env="tests/qemu-iotests/common.env"
813076c7560aSMax Reitz
813176c7560aSMax Reitzecho "# Automatically generated by configure - do not modify" > "$iotests_common_env"
813276c7560aSMax Reitzecho >> "$iotests_common_env"
813376c7560aSMax Reitzecho "export PYTHON='$python'" >> "$iotests_common_env"
813476c7560aSMax Reitz
8135a5665051SPaolo Bonziniif test "$skip_meson" = no; then
8136fc929892SMarc-André Lureaucross="config-meson.cross.new"
8137fc929892SMarc-André Lureaumeson_quote() {
8138fc929892SMarc-André Lureau    echo "['$(echo $* | sed "s/ /','/g")']"
8139fc929892SMarc-André Lureau}
8140fc929892SMarc-André Lureau
8141fc929892SMarc-André Lureauecho "# Automatically generated by configure - do not modify" > $cross
8142fc929892SMarc-André Lureauecho "[properties]" >> $cross
8143fc929892SMarc-André Lureautest -z "$cxx" && echo "link_language = 'c'" >> $cross
8144fc929892SMarc-André Lureauecho "[binaries]" >> $cross
8145fc929892SMarc-André Lureauecho "c = $(meson_quote $cc)" >> $cross
8146fc929892SMarc-André Lureautest -n "$cxx" && echo "cpp = $(meson_quote $cxx)" >> $cross
8147fc929892SMarc-André Lureauecho "ar = $(meson_quote $ar)" >> $cross
8148fc929892SMarc-André Lureauecho "nm = $(meson_quote $nm)" >> $cross
8149fc929892SMarc-André Lureauecho "pkgconfig = $(meson_quote $pkg_config_exe)" >> $cross
8150fc929892SMarc-André Lureauecho "ranlib = $(meson_quote $ranlib)" >> $cross
8151fc929892SMarc-André Lureauecho "strip = $(meson_quote $strip)" >> $cross
8152fc929892SMarc-André Lureauecho "windres = $(meson_quote $windres)" >> $cross
8153fc929892SMarc-André Lureauif test -n "$cross_prefix"; then
8154fc929892SMarc-André Lureau    cross_arg="--cross-file config-meson.cross"
8155fc929892SMarc-André Lureau    # Hack: Meson expects an absolute path for the *build* machine
8156fc929892SMarc-André Lureau    # for the prefix, so add a slash in front of a Windows path that
8157fc929892SMarc-André Lureau    # includes a drive letter.
8158fc929892SMarc-André Lureau    #
8159fc929892SMarc-André Lureau    # See https://github.com/mesonbuild/meson/issues/7577.
8160fc929892SMarc-André Lureau    echo "[host_machine]" >> $cross
8161fc929892SMarc-André Lureau    if test "$mingw32" = "yes" ; then
8162fc929892SMarc-André Lureau        echo "system = 'windows'" >> $cross
8163fc929892SMarc-André Lureau        case $prefix in
8164fc929892SMarc-André Lureau            ?:*) pre_prefix=/ ;;
8165fc929892SMarc-André Lureau        esac
8166fc929892SMarc-André Lureau    fi
8167fc929892SMarc-André Lureau    case "$ARCH" in
8168fc929892SMarc-André Lureau        i386|x86_64)
8169fc929892SMarc-André Lureau            echo "cpu_family = 'x86'" >> $cross
8170fc929892SMarc-André Lureau            ;;
8171fc929892SMarc-André Lureau        ppc64le)
8172fc929892SMarc-André Lureau            echo "cpu_family = 'ppc64'" >> $cross
8173fc929892SMarc-André Lureau            ;;
8174fc929892SMarc-André Lureau        *)
8175fc929892SMarc-André Lureau            echo "cpu_family = '$ARCH'" >> $cross
8176fc929892SMarc-André Lureau            ;;
8177fc929892SMarc-André Lureau    esac
8178fc929892SMarc-André Lureau    echo "cpu = '$cpu'" >> $cross
8179fc929892SMarc-André Lureau    if test "$bigendian" = "yes" ; then
8180fc929892SMarc-André Lureau        echo "endian = 'big'" >> $cross
8181fc929892SMarc-André Lureau    else
8182fc929892SMarc-André Lureau        echo "endian = 'little'" >> $cross
8183fc929892SMarc-André Lureau    fi
8184fc929892SMarc-André Lureauelse
8185fc929892SMarc-André Lureau    cross_arg="--native-file config-meson.cross"
8186fc929892SMarc-André Lureaufi
8187fc929892SMarc-André Lureaumv $cross config-meson.cross
8188fc929892SMarc-André Lureau
8189a5665051SPaolo Bonzinirm -rf meson-private meson-info meson-logs
819048328880SPaolo BonziniNINJA=${ninja:-$PWD/ninjatool} $meson setup \
8191fc929892SMarc-André Lureau        --prefix "${pre_prefix}$prefix" \
8192fc929892SMarc-André Lureau        --libdir "${pre_prefix}$libdir" \
8193fc929892SMarc-André Lureau        --libexecdir "${pre_prefix}$libexecdir" \
8194fc929892SMarc-André Lureau        --bindir "${pre_prefix}$bindir" \
8195fc929892SMarc-André Lureau        --includedir "${pre_prefix}$includedir" \
8196fc929892SMarc-André Lureau        --datadir "${pre_prefix}$datadir" \
8197fc929892SMarc-André Lureau        --mandir "${pre_prefix}$mandir" \
8198fc929892SMarc-André Lureau        --sysconfdir "${pre_prefix}$sysconfdir" \
8199fc929892SMarc-André Lureau        --localstatedir "${pre_prefix}$local_statedir" \
8200a5665051SPaolo Bonzini        -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
8201a5665051SPaolo Bonzini        -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
8202a5665051SPaolo Bonzini        -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
8203a5665051SPaolo Bonzini        -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
8204da6d48b9SMarc-André Lureau        -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
8205bf0e56a3SMarc-André Lureau        -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
820635be72baSPaolo Bonzini	-Dsdl=$sdl -Dsdl_image=$sdl_image \
8207a0b93237SPaolo Bonzini	-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
82080a40bcb7SCésar Belley	-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f\
8209fc929892SMarc-André Lureau        $cross_arg \
8210a5665051SPaolo Bonzini        "$PWD" "$source_path"
8211a5665051SPaolo Bonzini
8212a5665051SPaolo Bonziniif test "$?" -ne 0 ; then
8213a5665051SPaolo Bonzini    error_exit "meson setup failed"
8214a5665051SPaolo Bonzinifi
8215a5665051SPaolo Bonzinitouch ninjatool.stamp
8216a5665051SPaolo Bonzinifi
8217a5665051SPaolo Bonzini
8218dc655404SMichael S. Tsirkin# Save the configure command line for later reuse.
8219dc655404SMichael S. Tsirkincat <<EOD >config.status
8220dc655404SMichael S. Tsirkin#!/bin/sh
8221dc655404SMichael S. Tsirkin# Generated by configure.
8222dc655404SMichael S. Tsirkin# Run this file to recreate the current configuration.
8223dc655404SMichael S. Tsirkin# Compiler output produced by configure, useful for debugging
8224dc655404SMichael S. Tsirkin# configure, is in config.log if it exists.
8225dc655404SMichael S. TsirkinEOD
8226e811da7fSDaniel P. Berrangé
8227e811da7fSDaniel P. Berrangépreserve_env() {
8228e811da7fSDaniel P. Berrangé    envname=$1
8229e811da7fSDaniel P. Berrangé
8230e811da7fSDaniel P. Berrangé    eval envval=\$$envname
8231e811da7fSDaniel P. Berrangé
8232e811da7fSDaniel P. Berrangé    if test -n "$envval"
8233e811da7fSDaniel P. Berrangé    then
8234e811da7fSDaniel P. Berrangé	echo "$envname='$envval'" >> config.status
8235e811da7fSDaniel P. Berrangé	echo "export $envname" >> config.status
8236e811da7fSDaniel P. Berrangé    else
8237e811da7fSDaniel P. Berrangé	echo "unset $envname" >> config.status
8238e811da7fSDaniel P. Berrangé    fi
8239e811da7fSDaniel P. Berrangé}
8240e811da7fSDaniel P. Berrangé
8241e811da7fSDaniel P. Berrangé# Preserve various env variables that influence what
8242e811da7fSDaniel P. Berrangé# features/build target configure will detect
8243e811da7fSDaniel P. Berrangépreserve_env AR
8244e811da7fSDaniel P. Berrangépreserve_env AS
8245e811da7fSDaniel P. Berrangépreserve_env CC
8246e811da7fSDaniel P. Berrangépreserve_env CPP
8247e811da7fSDaniel P. Berrangépreserve_env CXX
8248e811da7fSDaniel P. Berrangépreserve_env INSTALL
8249e811da7fSDaniel P. Berrangépreserve_env LD
8250e811da7fSDaniel P. Berrangépreserve_env LD_LIBRARY_PATH
8251e811da7fSDaniel P. Berrangépreserve_env LIBTOOL
8252e811da7fSDaniel P. Berrangépreserve_env MAKE
8253e811da7fSDaniel P. Berrangépreserve_env NM
8254e811da7fSDaniel P. Berrangépreserve_env OBJCOPY
8255e811da7fSDaniel P. Berrangépreserve_env PATH
8256e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG
8257e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_LIBDIR
8258e811da7fSDaniel P. Berrangépreserve_env PKG_CONFIG_PATH
8259e811da7fSDaniel P. Berrangépreserve_env PYTHON
8260e811da7fSDaniel P. Berrangépreserve_env SDL2_CONFIG
8261e811da7fSDaniel P. Berrangépreserve_env SMBD
8262e811da7fSDaniel P. Berrangépreserve_env STRIP
8263e811da7fSDaniel P. Berrangépreserve_env WINDRES
8264e811da7fSDaniel P. Berrangé
8265dc655404SMichael S. Tsirkinprintf "exec" >>config.status
8266a5665051SPaolo Bonzinifor i in "$0" "$@"; do
8267a5665051SPaolo Bonzini  test "$i" = --skip-meson || printf " '%s'" "$i" >>config.status
8268a5665051SPaolo Bonzinidone
8269cf7cc929SDr. David Alan Gilbertecho ' "$@"' >>config.status
8270dc655404SMichael S. Tsirkinchmod +x config.status
8271dc655404SMichael S. Tsirkin
82728cd05ab6SPeter Maydellrm -r "$TMPDIR1"
8273